From 99729391a336376028100302df145a02ade96baf Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 6 Mar 2020 21:45:26 +0100 Subject: [PATCH 001/149] merge develop, first version of 5g simple main() --- cmake_targets/CMakeLists.txt | 79 +- common/utils/ocp_itti/intertask_interface.cpp | 3 + common/utils/ocp_itti/intertask_interface.h | 2 +- common/utils/system.c | 6 +- common/utils/threadPool/thread-pool.h | 6 +- doc/SystemX-tutorial-design.md | 317 ++++ executables/main-fs6.c | 1583 +++++++++++++++++ executables/main-ocp.c | 1385 ++++++++++++++ executables/nr-gnb.c | 88 +- executables/nr-ru.c | 40 +- executables/nr-softmodem.c | 132 +- executables/nr-ue.c | 110 +- executables/nr-uesoftmodem.c | 59 +- executables/ocp-gnb.c | 1011 +++++++++++ executables/softmodem-common.c | 50 +- executables/softmodem-common.h | 11 + executables/split_headers.h | 309 ++++ executables/transport_split.c | 174 ++ nfapi/oai_integration/nfapi.c | 2 +- nfapi/oai_integration/nfapi_pnf.c | 17 +- nfapi/oai_integration/nfapi_pnf.h | 2 +- .../nfapi/public_inc/nfapi_nr_interface_scf.h | 1 + .../pnf/public_inc/nfapi_pnf_interface.h | 7 +- nfapi/open-nFAPI/pnf/src/pnf_interface.c | 2 +- nfapi/open-nFAPI/pnf/src/pnf_p7.c | 18 +- nfapi/open-nFAPI/vnf/src/vnf_interface.c | 2 +- nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c | 2 +- openair1/PHY/CODING/TESTBENCH/ldpctest.c | 2 +- openair1/PHY/INIT/nr_init.c | 4 +- .../lte_dl_bf_channel_estimation.c | 92 +- .../PHY/LTE_ESTIMATION/lte_ue_measurements.c | 2 +- .../lte_ul_channel_estimation.c | 7 +- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 704 ++------ openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 24 +- openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c | 2 +- openair1/PHY/LTE_TRANSPORT/if5_tools.h | 3 +- openair1/PHY/LTE_TRANSPORT/phich.c | 2 +- openair1/PHY/LTE_TRANSPORT/pmch.c | 1 + openair1/PHY/LTE_TRANSPORT/prach.c | 55 +- openair1/PHY/LTE_TRANSPORT/pucch.c | 2 +- openair1/PHY/LTE_TRANSPORT/transport_eNB.h | 11 +- openair1/PHY/LTE_TRANSPORT/transport_proto.h | 36 +- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 650 ++----- .../PHY/LTE_UE_TRANSPORT/dlsch_decoding.c | 2 +- openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c | 2 +- openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c | 10 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 4 +- openair1/PHY/NR_UE_TRANSPORT/nr_prach.c | 2 +- openair1/PHY/TOOLS/lte_phy_scope.c | 12 +- openair1/PHY/TOOLS/time_meas.h | 2 +- openair1/PHY/defs_RU.h | 1 + openair1/PHY/defs_eNB.h | 89 +- openair1/SCHED/fapi_l1.c | 11 +- openair1/SCHED/fapi_l1.h | 6 +- openair1/SCHED/phy_procedures_lte_eNb.c | 266 +-- openair1/SCHED/prach_procedures.c | 9 + openair1/SCHED/ru_procedures.c | 4 +- openair1/SCHED/sched_common.h | 2 +- openair1/SCHED/sched_eNB.h | 8 +- openair1/SCHED_NR_UE/phy_frame_config_nr.c | 2 +- openair1/SIMULATION/LTE_PHY/dlsim.c | 29 +- openair1/SIMULATION/LTE_PHY/ulsim.c | 20 +- .../MAC/flexran_agent_mac_internal.c | 6 +- openair2/LAYER2/MAC/eNB_scheduler_fairRR.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 5 +- openair2/LAYER2/MAC/pre_processor.c | 13 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- .../LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h | 70 - openair2/LAYER2/RLC/rlc.h | 4 +- openair2/PHY_INTERFACE/IF_Module.c | 4 +- openair2/PHY_INTERFACE/IF_Module.h | 75 +- openair2/PHY_INTERFACE/phy_stub_UE.c | 8 +- openair2/PHY_INTERFACE/phy_stub_UE.h | 6 +- openair2/RRC/LTE/rrc_eNB.c | 10 +- openair2/RRC/NR/nr_rrc_extern.h | 8 +- openair2/RRC/NR/rrc_gNB.c | 15 +- openair2/UTIL/MEM/mem_block.c | 668 ------- openair2/UTIL/MEM/mem_block.h | 108 -- openair2/UTIL/MEM/mem_mngt.c | 489 ----- openair2/UTIL/MEM/mem_mngt_proto_extern.h | 21 - openair2/UTIL/MEM/mem_pool.h | 38 - openair2/UTIL/OPT/probe.c | 12 +- openair3/NAS/COMMON/UTIL/socket.c | 2 +- openair3/NAS/TOOLS/conf_network.c | 2 +- openair3/NAS/TOOLS/conf_parser.c | 2 +- targets/ARCH/rfsimulator/simulator.c | 25 +- targets/COMMON/create_tasks.c | 11 +- targets/RT/USER/lte-enb.c | 2 +- targets/RT/USER/lte-softmodem.c | 102 +- targets/RT/USER/lte-ue.c | 85 +- targets/RT/USER/lte-uesoftmodem.c | 18 +- 91 files changed, 6133 insertions(+), 3176 deletions(-) create mode 100644 doc/SystemX-tutorial-design.md create mode 100644 executables/main-fs6.c create mode 100644 executables/main-ocp.c create mode 100644 executables/ocp-gnb.c create mode 100644 executables/split_headers.h create mode 100644 executables/transport_split.c delete mode 100644 openair2/LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h delete mode 100644 openair2/UTIL/MEM/mem_block.c delete mode 100644 openair2/UTIL/MEM/mem_mngt.c delete mode 100644 openair2/UTIL/MEM/mem_mngt_proto_extern.h delete mode 100644 openair2/UTIL/MEM/mem_pool.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c4d3d7e62e..f582d6a0b2 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -127,7 +127,7 @@ endfunction() #set(CMAKE_BUILD_TYPE "Debug") if (CMAKE_BUILD_TYPE STREQUAL "") - set(CMAKE_BUILD_TYPE "Release") + set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}") add_list_string_option(CMAKE_BUILD_TYPE "RelWithDebInfo" "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." Debug Release RelWithDebInfo MinSizeRel) @@ -185,7 +185,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,${CMAKE_CU # set a flag for changes in the source code # these changes are related to hardcoded path to include .h files set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -DMALLOC_CHECK_=3") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g3 -DMALLOC_CHECK_=3 -O2") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g3 -DMALLOC_CHECK_=3 -Og") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3") set(GIT_BRANCH "UNKNOWN") @@ -820,7 +820,6 @@ add_boolean_option(TRACE_RLC_UM_TX_STATUS False "TRACE for RLC UM, TO BE CHANGE # PDCP LAYER OPTIONS ########################## #add_boolean_option(PDCP_USE_NETLINK False "For eNB, PDCP communicate with a NETLINK socket if connected to network driver, else could use a RT-FIFO") -#add_boolean_option(PDCP_USE_NETLINK_QUEUES False "When PDCP_USE_NETLINK is true, incoming IP packets are stored in queues") #add_boolean_option(LINK_ENB_PDCP_TO_IP_DRIVER False "For eNB, PDCP communicate with a IP driver") #add_boolean_option(LINK_ENB_PDCP_TO_GTPV1U True "For eNB, PDCP communicate with GTP-U protocol (eNB<->S-GW)") @@ -1555,6 +1554,7 @@ endif () add_library(PHY_COMMON ${PHY_SRC_COMMON}) add_dependencies(PHY_COMMON rrc_flag) add_library(PHY ${PHY_SRC}) + add_dependencies(PHY rrc_flag) add_library(PHY_UE ${PHY_SRC_UE}) add_dependencies(PHY_UE rrc_flag) @@ -2439,6 +2439,7 @@ add_executable(lte-softmodem ${OPENAIR_TARGETS}/RT/USER/lte-ru.c ${OPENAIR_TARGETS}/RT/USER/ru_control.c ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c + ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c ${OPENAIR_DIR}/executables/softmodem-common.c ${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c @@ -2474,6 +2475,43 @@ target_link_libraries (lte-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_L target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-softmodem ${T_LIB}) + +add_executable(ocp-softmodem + ${OPENAIR_DIR}/executables/main-ocp.c + ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c + ${OPENAIR_DIR}/executables/softmodem-common.c + ${OPENAIR_DIR}/executables/main-fs6.c + ${OPENAIR_DIR}/executables/transport_split.c + ${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c + ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c + ${OPENAIR_TARGETS}/COMMON/create_tasks.c + ${OPENAIR_TARGETS}/COMMON/create_tasks_mbms.c + ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c + ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c + ${OPENAIR2_DIR}/RRC/NAS/nas_config.c + ${OPENAIR2_DIR}/RRC/NAS/rb_config.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c + ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c + ${OPENAIR_DIR}/common/utils/utils.c + ${OPENAIR_DIR}/common/utils/system.c + ${GTPU_need_ITTI} + ${XFORMSINTERFACE_SOURCE} + ${T_SOURCE} + ${CONFIG_SOURCES} + ${SHLIB_LOADER_SOURCES} + ) +add_dependencies(ocp-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer) + +target_link_libraries (ocp-softmodem + -Wl,--start-group + RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB + PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 + ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} + -Wl,--end-group z dl) +target_link_libraries (ocp-softmodem ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) + add_executable(cu_test ${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c ${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_handler.c @@ -2588,6 +2626,40 @@ target_link_libraries (nr-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LI target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (nr-softmodem ${T_LIB}) +add_executable(ocp-gnb + ${rrc_h} + ${nr_rrc_h} + ${s1ap_h} +# ${OPENAIR_BIN_DIR}/messages_xml.h + ${OPENAIR_DIR}/executables/ocp-gnb.c + ${OPENAIR_DIR}/executables/softmodem-common.c + ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c + ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c + ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c + ${OPENAIR2_DIR}/RRC/NAS/nas_config.c + ${OPENAIR2_DIR}/RRC/NAS/rb_config.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${OPENAIR_DIR}/common/utils/utils.c + ${OPENAIR_DIR}/common/utils/system.c + ${GTPU_need_ITTI} + ${XFORMS_SOURCE_NR} + ${T_SOURCE} + ${CONFIG_SOURCES} + ${SHLIB_LOADER_SOURCES} + ) + +target_link_libraries (ocp-gnb + -Wl,--start-group + UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA + ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB + S1AP_LIB S1AP_ENB L2 L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB + X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB} + -Wl,--end-group z dl) + +target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES}) +target_link_libraries (ocp-gnb pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (ocp-gnb ${LIB_LMS_LIBRARIES}) +target_link_libraries (ocp-gnb ${T_LIB}) # nr-uesoftmodem is UE implementation ####################################### @@ -2784,6 +2856,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr add_executable(${myExe} ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c + ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/system.c ${XFORMS_SOURCE} diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index 89e19074bf..dc577f1334 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -86,6 +86,9 @@ extern "C" { temp->ittiMsgHeader.messageId = message_id; temp->ittiMsgHeader.originTaskId = origin_task_id; temp->ittiMsgHeader.ittiMsgSize = size; + temp->ittiMsgHeader.destinationTaskId=TASK_UNKNOWN; + temp->ittiMsgHeader.instance=0; + temp->ittiMsgHeader.lte_time={0}; return temp; //return itti_alloc_new_message_sized(origin_task_id, message_id, messages_info[message_id].size); } diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 52c733752d..349d1add44 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -288,7 +288,7 @@ typedef struct { TASK_DEF(TASK_PDCP_ENB, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_DATA_FORWARDING, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_END_MARKER, TASK_PRIORITY_MED, 200, NULL, NULL) \ - TASK_DEF(TASK_RRC_ENB, TASK_PRIORITY_MED, 200, NULL,NULL)\ + TASK_DEF(TASK_RRC_ENB, TASK_PRIORITY_MED, 200, rrc_enb_process_itti_msg,NULL)\ TASK_DEF(TASK_RRC_GNB, TASK_PRIORITY_MED, 200, NULL,NULL)\ TASK_DEF(TASK_RAL_ENB, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_S1AP, TASK_PRIORITY_MED, 200, NULL, NULL) \ diff --git a/common/utils/system.c b/common/utils/system.c index 3a8fe7be3d..1bd5c7d39b 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -243,6 +243,8 @@ void configure_linux(void) { // Set CPU frequency to it's maximum if ( 0 != system("for d in /sys/devices/system/cpu/cpu[0-9]*; do cat $d/cpufreq/cpuinfo_max_freq > $d/cpufreq/scaling_min_freq; done")) - LOG_W(HW,"Can't set cpu frequency\n"); - + LOG_E(HW,"Can't set cpu frequency\n"); + + mlockall(MCL_CURRENT | MCL_FUTURE); + } diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index 9a2681a828..1b59fb1589 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -217,11 +217,11 @@ static inline void pushTpool(tpool_t *t, notifiedFIFO_elt_t *msg) { static inline notifiedFIFO_elt_t *pullTpool(notifiedFIFO_t *responseFifo, tpool_t *t) { notifiedFIFO_elt_t *msg= pullNotifiedFIFO(responseFifo); - + AssertFatal(t->traceFd, "Thread pool used while not initialized"); if (t->measurePerf) msg->returnTime=rdtsc(); - if (t->traceFd >= 0) + if (t->traceFd > 0) if(write(t->traceFd, msg, sizeof(*msg))); return msg; @@ -229,7 +229,7 @@ static inline notifiedFIFO_elt_t *pullTpool(notifiedFIFO_t *responseFifo, tpool_ static inline notifiedFIFO_elt_t *tryPullTpool(notifiedFIFO_t *responseFifo, tpool_t *t) { notifiedFIFO_elt_t *msg= pollNotifiedFIFO(responseFifo); - + AssertFatal(t->traceFd, "Thread pool used while not initialized"); if (msg == NULL) return NULL; diff --git a/doc/SystemX-tutorial-design.md b/doc/SystemX-tutorial-design.md new file mode 100644 index 0000000000..371cb33a75 --- /dev/null +++ b/doc/SystemX-tutorial-design.md @@ -0,0 +1,317 @@ +# OpenAirInterface for SystemX + +#Terminology + +****This document use the 5G terminology**** + +**Central Unit (CU): **It is a logical node that includes the gNB +functions like Transfer of user data, Mobility control, Radio access +network sharing, Positioning, Session Management etc., except those +functions allocated exclusively to the DU. CU controls the operation of +DUs over front-haul (Fs) interface. A central unit (CU) may also be +known as BBU/REC/RCC/C-RAN/V-RAN/VNF + +**Distributed Unit (DU):** This logical node includes a subset of the +gNB functions, depending on the functional split option. Its operation +is controlled by the CU. Distributed Unit (DU) also known with other +names like RRH/RRU/RE/RU/PNF. + +In OpenAir code, the terminology is often RU and BBU. + +# OpenAirUsage +##EPC and general environment +### OAI EPC + +Use the stable OAI EPC, that can run in one machine (VM or standalone) + +Draft description: + + +##Standalone 4G + +EPC+eNB on one machine, the UE can be commercial or OAI UE. +### USRP B210 + +Main current issue: traffic is good only on coaxial link between UE and +eNB (probably power management issue). + +### Simulated RF + +Running eNB+UE both OAI can be done over a virtual RF link. + +The UE current status is that threads synchronization is implicit in +some cases. As the RF simulator is very quick, a “sleep()” is required +in the UE main loop + +(line 1744, targets/RT/USER/lte-ue.c). + +Running also the UE in the same machine is possible with simulated RF. + +Running in same machine is simpler, offers about infinite speed for +virtual RF samples transmission. + +A specific configuration is required because the EPC Sgi interface has +the same IP tunnel end point as the UE. + +So, we have to create a network namespace for the UE and to route data +in/out of the namespace. +``` bash +ip netns delete aNameSpace 2> /dev/null + +ip link delete v-eth1 2> /dev/null + +ip netns add aNameSpace + +ip link add v-eth1 type veth peer name v-peer1 + +ip link set v-peer1 netns aNameSpace + +ip addr add 10.200.1.1/24 dev v-eth1 + +ip link set v-eth1 up + +iptables -t nat -A POSTROUTING -s 10.200.1.0/255.255.255.0 -o enp0s31f6 +-j MASQUERADE + +iptables -A FORWARD -i enp0s31f6 -o v-eth1 -j ACCEPT + +iptables -A FORWARD -o enp0s31f6 -i v-eth1 -j ACCEPT + +ip netns exec aNameSpace ip link set dev lo up + +ip netns exec aNameSpace ip addr add 10.200.1.2/24 dev v-peer1 + +ip netns exec aNameSpace ip link set v-peer1 up + +ip netns exec aNameSpace bash +``` + +After the last command, the Linux shell is in the new namespace, ready +to run the UE. + +To make user plan traffic, the traffic generator has to run in the same +namespace + +`ip netns exec aNameSpace bash +` + +The traffic genenrator has to specify the interface: + +`route add default oaitun_ue1 +` + +or specify the outgoing route in the traffic generator (like option “-I” +in ping command). + +## Split 6 DL 4G + +The contract describes to reuse the uplink existing if4p5 and to develop +is this work the downlink “functional split 6”. + +The customer required after signature to develop also the uplink +functional split 6. This is accepted, as long as the whole work is +research with no delivery completeness warranty. +### Simulation + +To be able to verify the new features and to help in all future +developments, Open Cells added and improved the Rf board simulator +during this contract. + +We added the channel modeling simulation, that offer to simulate various +3GPP defined channels. +### Main loop + +The main log is in RF simulator is in + + targets/RT/USER/lte-ru.c and targets/RT/USER/lte-enb.c + +As this piece of SW is very complex and doesn’t meet our goals +(functional split 6), a cleaned version replaces these 2 files in +executables/ocp-main.c (openair1/SCHED/prach\_procedures.c is also +replaced by this new file as it only launching the RACH actual work in a +way not compatible with our FS6). + +The main loop cadences the I/Q samples reception, signal processing and +I/Q samples sending. + +The main loop uses extensively function pointers to call the right +processing function depending on the split case. + +A lot of OAI reduntant global variables contains the same semantic data: time,frame, subframe. +The reworked main loop take care of a uniq variable that comes directly from harware: RF board sampling number. + +To use OAI, we need to set all OAI variables that derivates from this timestamp value. The function setAllfromTS() implements this. + + +### Splitted main level +When FS6 is actived, a main loop for DU (du_fs6()) a main loop for CU case replaces the uniq eNB main loop. + +Each of these main loops calls initialization of OAI LTE data and the FS6 transport layer initialization. + +Then, it runs a infinite loop on: set time, call UL and DL. The time comes from the RF board, so the DU sends the time to the CU. + +This is enough for RF board dialog, but the FS6 is higher in SW layers, +we need to cut higher functions inside downlink and uplink procedures. + +As much as possible, the FS6 code is in the directory OPENAIR_DIR/executables. When a given OAI piece of code is small or need complex changes, it is reworked in the file fs6-main.c. The functions naming keeps the OAI function name, adding suffix _fromsplit() or _tosplit(). + +When this organization would lead to large code copy, it is better to insert modifications in OAI code. This is done in two files: + +- openair1/SCHED/phy_procedures_lte_eNb.c: to send signaling channels computation results + - the function sendFs6Ulharq() centralizes all signaling channels forwarding to CU +- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c: to deal with FS6 user plane split + - sendFs6Ul() is used once to forward user plane to CU + + +### DownLink + +The main procedure is phy\_procedures\_eNB\_TX() + +This is building the common channels (beacon, multi-UE signaling). + +The FS6 split breaks this function into pieces: + +* The multi-UE signals, built by common\_signal\_procedures(), + subframe2harq\_pid(), generate\_dci\_top(), subframe2harq\_pid() + * These functions run in the DU, nevertheless all context has to be sent + (it is also needed partially for UL spitting) + * Run in the DU also to meet the requirement of pushing + in DU the data encoded with large redundancy (>3 redundancy) + +* the per UE data: pdsch\_procedures() needs further splitting: + + * dlsch\_encoding\_all() that makes the encoding: turbo code + and lte\_rate\_matching\_turbo() that will be in the DU (some + unlikely cases can reach redundancy up to x3, when MCS is very + low (negative SINR cases)). + + * dlsch\_encoding() output needs to be transmitted between the + DU and the CU for functional split 6. + * dlsch\_scrambling() that will go in the DU + * dlsch\_modulation() that will go in the DU + + The du user plane data is made of expanded bit in OAI at FS6 split level. 1 pair of functions compact back these bits into 8bits/byte before sending data and expand it again in the DU data reception (functions: fs6Dl(un)pack()). + +### Uplink + +The uplink require configuration that is part of the DL transmission. + +It interprets the signalling to extract the RACH and the per UE data +channels. + +Ocp-main.c:rxtx() calls directly the entry procedure +phy\_procedures\_eNB\_uespec\_RX() calls: + +* rx\_ulsch() that demodulate and extract soft bits per UE. + + * This function runs in the DU + * the output data will be processes in the DU, so it needs to be + transmitted to the DU +* ulsch\_decoding() that do lte\_rate\_matching\_turbo\_rx() + sub\_block\_deinterleaving\_turbo() + then turbo decode that is in the CU +* fill\_ulsch\_cqi\_indication() fill\_crc\_indication() , fill\_rx\_indication() + * DU performs the signal processing of each channel data, prepare and sent to the CU the computed result + +* Random access channel detection runs in the DU + * the DU reports to the CU only the detected temprary identifier for RACH response + + +### signaling data in each direction (UL and DL) + + +* each LTE channel needs to be propagated between CU and DU + * the simplest are the almost static data such as PSS/SSS, that need only static eNB parameters and primary information (frame numbering) + * all the other channels require data transmission CU to DU and DU to CU + * the general design push all the low level processing for these channels in the DU + * the CU interface transports only signal processing results (UL) or configuration to create the RF signal (DL case) +* HARQ is detected in the DU, then only the ACK or NACK is reported to CU + +* the CU have to control the power and MCS (modulation and coding scheme) + * the DU performs the signal processing and report only the decoded data like the CQI + * as the DU performas the modulation, scrambling and puncturing, each data packet is associated with the LTE parameters required for these features + * in DL, the CU associates the control parameters and the user plane data + * in UL, the CU sends upfront the scheduled UL data to the DU. So, the DU have the required knowledge to decode the next subframes in time. + +### UDP transport layer + +A general UDP transport layer is in executables/transport\_split.c + +Linux offers a UDP socket builtin timeout, that we use. + +In and out buffers are memory zones that contains compacted +(concatenated) UDP chunks. + +For output, sendSubFrame() sends each UDP chunk + +For input, receiveSubFrame() collects all UDP chunks for a group (a +subframe in OAI LTE case). It returns in the following cases: + +- all chunks are received +- a timeout expired +- a chunk from the next subframe already arrived + +### Functional split 6 usage + +The ocp cleaned main hale to be used: run ocp-softmodem instead of +lte-softmodem. + +The functionality and parameters is the same, enhanced with FS6 mode. + +The end line option “--split73” enables the fs6 (also called split 7.3) mode and decided to be cu or du. + +Example: + +./ocp-softmodem -O $OPENAIR_DIR/enb.fs6.example.conf --rfsim --log_config.phy_log_level debug --split73 cu:127.0.0.1 +` +Run the CU init of the split 6 eNB, that will call du on 127.0.0.1 address + +./ocp-softmodem -O $OPENAIR_DIR/enb.fs6.example.conf --rfsim --log_config.phy_log_level debug --split73 du:127.0.0.1 + +will run the du, calling the cu on 127.0.0.1 +` +If the CU and the DU are not on the same machine, the remote address of each side need to be specified as per this example + +./ocp-softmodem -O $OPENAIR_DIR/enb.fs6.example.conf --rfsim --log_config.phy_log_level debug --split73 du:192.168.1.55 +` +runs the functional split 6 DU + +`./lte-uesoftmodem -C 2685000000 -r 50 --rfsim --rfsimulator.serveraddr 192.168.1.1 -d +` + +Runs the UE (to have the UE signal scope, compile it with make uescope) + +CU+DU+UE can run with option --noS1 to avoid to use a EPC and/or with --rfsim to simulate RF board + + +##5G and F1 + +Today 5G achievement is limited to physical layer. + +The available modulation is 40MHz, that require one X310 or N300 for the +gNB and a X310 or N300 for the nrUE. + +### Usage with X310 + +Linux configuration: + + +We included most of this configuration included in OAI source code. + +Remain to set the NIC (network interface card) MTU to 9000 (jumbo +frames). + +### Running 5G + +Usage with RFsimulator: + +gNB + +`sudo RFSIMULATOR=server ./nr-softmodem -O +../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +--parallel-config PARALLEL\_SINGLE\_THREAD` + +nrUE + +`sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --numerology 1 -r 106 -C +3510000000 -d` diff --git a/executables/main-fs6.c b/executables/main-fs6.c new file mode 100644 index 0000000000..0a5988c802 --- /dev/null +++ b/executables/main-fs6.c @@ -0,0 +1,1583 @@ +/* + Author: Laurent THOMAS, Open Cells Project company, funded by IRT SystemX + copyleft: OpenAirInterface Software Alliance and it's licence +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define FS6_BUF_SIZE 1000*1000 +static UDPsock_t sockFS6; + +int sum(uint8_t *b, int s) { + int sum=0; + + for (int i=0; i < s; i++) + sum+=b[i]; + + return sum; +} + +static inline int cmpintRev(const void *a, const void *b) { + uint64_t *aa=(uint64_t *)a; + uint64_t *bb=(uint64_t *)b; + return (int)(*bb-*aa); +} + +static inline void printMeas2(char *txt, Meas *M, int period, bool MaxMin) { + if (M->iterations%period == 0 ) { + char txt2[512]; + sprintf(txt2,"%s avg=%" PRIu64 " iterations=%" PRIu64 " %s=%" + PRIu64 ":%" PRIu64 ":%" PRIu64 ":%" PRIu64 ":%" PRIu64 ":%" PRIu64 ":%" PRIu64 ":%" PRIu64 ":%" PRIu64 ":%" PRIu64 "\n", + txt, + M->sum/M->iterations, + M->iterations, + MaxMin?"max":"min", + M->maxArray[1],M->maxArray[2], M->maxArray[3],M->maxArray[4], M->maxArray[5], + M->maxArray[6],M->maxArray[7], M->maxArray[8],M->maxArray[9],M->maxArray[10]); +#if T_TRACER + LOG_W(PHY,"%s",txt2); +#else + printf("%s",txt2); +#endif + } +} + +static inline void updateTimesReset(uint64_t start, Meas *M, int period, bool MaxMin, char *txt) { + if (start!=0) { + uint64_t end=rdtsc(); + long long diff=(end-start)/(cpuf*1000); + M->maxArray[0]=diff; + M->sum+=diff; + M->iterations++; + + if ( MaxMin) + qsort(M->maxArray, 11, sizeof(uint64_t), cmpint); + else + qsort(M->maxArray, 11, sizeof(uint64_t), cmpintRev); + + printMeas2(txt,M,period, MaxMin); + + if (M->iterations%period == 0 ) { + bzero(M,sizeof(*M)); + + if (!MaxMin) + for (int i=0; i<11; i++) + M->maxArray[i]=INT_MAX; + } + } +} + +static inline void measTransportTime(uint64_t DuSend, uint64_t CuMicroSec, Meas *M, int period, bool MaxMin, char *txt) { + if (DuSend!=0) { + uint64_t end=rdtsc(); + long long diff=(end-DuSend)/(cpuf*1000)-CuMicroSec; + M->maxArray[0]=diff; + M->sum+=diff; + M->iterations++; + + if ( MaxMin) + qsort(M->maxArray, 11, sizeof(uint64_t), cmpint); + else + qsort(M->maxArray, 11, sizeof(uint64_t), cmpintRev); + + printMeas2(txt,M,period, MaxMin); + + if (M->iterations%period == 0 ) { + bzero(M,sizeof(*M)); + + if (!MaxMin) + for (int i=0; i<11; i++) + M->maxArray[i]=INT_MAX; + } + } +} + +#define ceil16_bytes(a) ((((a+15)/16)*16)/8) + +static void fs6Dlunpack(void *out, void *in, int szUnpacked) { + static uint64_t *lut=NULL; + + if (!lut) { + lut=(uint64_t *) malloc(sizeof(*lut)*256); + + for (int i=0; i <256; i++) + for (int j=0; j<8; j++) + ((uint8_t *)(lut+i))[7-j]=(i>>j)&1; + } + + int64_t *out_64 = (int64_t *)out; + int sz=ceil16_bytes(szUnpacked); + + for (int i=0; iframe_parms, proc->frame_prach,proc->subframe_prach)<=0) + return; + + RU_t *ru; + int aa=0; + int ru_aa; + + for (int i=0; inum_RU; i++) { + ru=eNB->RU_list[i]; + + for (ru_aa=0,aa=0; ru_aanb_rx; ru_aa++,aa++) { + eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[i]->prach_rxsigF[ru_aa]; + int ce_level; + + for (ce_level=0; ce_level<4; ce_level++) + eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[i]->prach_rxsigF_br[ce_level][ru_aa]; + } + } + + ocp_rx_prach(eNB, + proc, + eNB->RU_list[0], + header->max_preamble, + header->max_preamble_energy, + header->max_preamble_delay, + header->avg_preamble_energy, + proc->frame_prach, + 0, + false + ); + // run PRACH detection for CE-level 0 only for now when br_flag is set + /* fixme: seems not operational and may overwrite regular LTE prach detection + * OAI code can call is sequence + rx_prach(eNB, + eNB->RU_list[0], + header->max_preamble, + header->max_preamble_energy, + header->max_preamble_delay, + header->avg_preamble_energy, + frame, + 0, + true + ); + */ + LOG_D(PHY,"RACH detection index 0: max preamble: %u, energy: %u, delay: %u, avg energy: %u\n", + header->max_preamble[0], + header->max_preamble_energy[0], + header->max_preamble_delay[0], + header->avg_preamble_energy[0] + ); + return; +} + +void prach_eNB_fromsplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc) { + fs6_ul_t *header=(fs6_ul_t *) commonUDPdata(bufferZone); + uint16_t *max_preamble=header->max_preamble; + uint16_t *max_preamble_energy=header->max_preamble_energy; + uint16_t *max_preamble_delay=header->max_preamble_delay; + uint16_t *avg_preamble_energy=header->avg_preamble_energy; + int subframe=proc->subframe_prach; + int frame=proc->frame_prach; + // Fixme: not clear why we call twice with "br" and without + int br_flag=0; + + if (br_flag==1) { + int prach_mask; + prach_mask = is_prach_subframe (&eNB->frame_parms, proc->frame_prach_br, proc->subframe_prach_br); + eNB->UL_INFO.rach_ind_br.rach_indication_body.preamble_list = eNB->preamble_list_br; + int ind = 0; + int ce_level = 0; + /* Save for later, it doesn't work + for (int ind=0,ce_level=0;ce_level<4;ce_level++) { + + if ((eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[ce_level]==1)&& + (prach_mask&(1<<(1+ce_level)) > 0) && // prach is active and CE level has finished its repetitions + (eNB->prach_vars_br.repetition_number[ce_level]== + eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level])) { + + */ + + if (eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0] == 1) { + if ((eNB->prach_energy_counter == 100) && (max_preamble_energy[0] > eNB->measurements.prach_I0 + eNB->prach_DTX_threshold_emtc[0])) { + eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles++; + eNB->preamble_list_br[ind].preamble_rel8.timing_advance = max_preamble_delay[ind]; // + eNB->preamble_list_br[ind].preamble_rel8.preamble = max_preamble[ind]; + // note: fid is implicitly 0 here, this is the rule for eMTC RA-RNTI from 36.321, Section 5.1.4 + eNB->preamble_list_br[ind].preamble_rel8.rnti = 1 + subframe + (60*(eNB->prach_vars_br.first_frame[ce_level] % 40)); + eNB->preamble_list_br[ind].instance_length = 0; //don't know exactly what this is + eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type = 1 + ce_level; // CE Level + LOG_I (PHY, "Filling NFAPI indication for RACH %d CELevel %d (mask %x) : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", + ind, + ce_level, + prach_mask, + eNB->preamble_list_br[ind].preamble_rel8.timing_advance, + eNB->preamble_list_br[ind].preamble_rel8.preamble, eNB->preamble_list_br[ind].preamble_rel8.rnti, eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type); + } + } + + /* + ind++; + } + } */// ce_level + } else if ((eNB->prach_energy_counter == 100) && + (max_preamble_energy[0] > eNB->measurements.prach_I0+eNB->prach_DTX_threshold)) { + LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n", + eNB->Mod_id, + eNB->CC_id, + frame, + subframe, + max_preamble[0], + max_preamble_energy[0]/10, + max_preamble_energy[0]%10, + max_preamble_delay[0]); + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 1; + eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = &eNB->preamble_list[0]; + eNB->UL_INFO.rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; + eNB->UL_INFO.rach_ind.header.message_id = NFAPI_RACH_INDICATION; + eNB->UL_INFO.rach_ind.sfn_sf = frame<<4 | subframe; + eNB->preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; + eNB->preamble_list[0].preamble_rel8.timing_advance = max_preamble_delay[0]; + eNB->preamble_list[0].preamble_rel8.preamble = max_preamble[0]; + eNB->preamble_list[0].preamble_rel8.rnti = 1+subframe; // note: fid is implicitly 0 here + eNB->preamble_list[0].preamble_rel13.rach_resource_type = 0; + eNB->preamble_list[0].instance_length = 0; //don't know exactly what this is + + if (NFAPI_MODE==NFAPI_MODE_PNF) { // If NFAPI PNF then we need to send the message to the VNF + LOG_D(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", + NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), + eNB->preamble_list[0].preamble_rel8.timing_advance, + eNB->preamble_list[0].preamble_rel8.preamble, + eNB->preamble_list[0].preamble_rel8.rnti, + eNB->preamble_list[0].preamble_rel13.rach_resource_type); + oai_nfapi_rach_ind(&eNB->UL_INFO.rach_ind); + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 0; + } + + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + } // max_preamble_energy > prach_I0 + 100 + else { + eNB->measurements.prach_I0 = ((eNB->measurements.prach_I0*900)>>10) + ((avg_preamble_energy[0]*124)>>10); + + if (eNB->prach_energy_counter < 100) + eNB->prach_energy_counter++; + } +} + +void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, + uint16_t rnti, + int32_t stat) { + static int current_fsf=-1; + int fsf=frame*16+subframe; + uint8_t *bufferZone=eNB->FS6bufferZone; + commonUDP_t *FirstUDPheader=(commonUDP_t *) bufferZone; + // move to the end + uint8_t *firstFreeByte=bufferZone; + int curBlock=0; + + if ( current_fsf != fsf ) { + for (int i=0; i < FirstUDPheader->nbBlocks; i++) { + AssertFatal( ((commonUDP_t *) firstFreeByte)->blockID==curBlock,""); + firstFreeByte+=alignedSize(firstFreeByte); + curBlock++; + } + + commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte; + FirstUDPheader->nbBlocks++; + newUDPheader->blockID=curBlock; + newUDPheader->contentBytes=sizeof(fs6_ul_t)+sizeof(fs6_ul_uespec_uci_t); + hULUEuci(newUDPheader)->type=fs6ULcch; + hULUEuci(newUDPheader)->nb_active_ue=0; + } else + for (int i=0; i < FirstUDPheader->nbBlocks-1; i++) { + AssertFatal( ((commonUDP_t *) firstFreeByte)->blockID==curBlock,""); + firstFreeByte+=alignedSize(firstFreeByte); + curBlock++; + } + + LOG_D(PHY,"FS6 du, block: %d: adding ul harq/sr: %d, rnti: %d, ueid: %d\n", + curBlock, type, rnti, UEid); + commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte; + fs6_ul_uespec_uci_element_t *tmp=(fs6_ul_uespec_uci_element_t *)(hULUEuci(newUDPheader)+1); + tmp+=hULUEuci(newUDPheader)->nb_active_ue; + tmp->type=type; + tmp->UEid=UEid; + tmp->frame=frame; + tmp->subframe=subframe; + + if (uci != NULL) + memcpy(&tmp->uci, uci, sizeof(*uci)); + else + tmp->uci.ue_id=0xFFFF; + + if (harq_ack != NULL) + memcpy(tmp->harq_ack, harq_ack, 4); + + tmp->tdd_mapping_mode=tdd_mapping_mode; + tmp->tdd_multiplexing_mask=tdd_multiplexing_mask; + tmp->n0_subband_power_dB=eNB->measurements.n0_subband_power_dB[0][0]; + tmp->rnti=rnti; + tmp->stat=stat; + hULUEuci(newUDPheader)->nb_active_ue++; + newUDPheader->contentBytes+=sizeof(fs6_ul_uespec_uci_element_t); +} + + +void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { + uint8_t *bufferZone=eNB->FS6bufferZone; + commonUDP_t *FirstUDPheader=(commonUDP_t *) bufferZone; + // move to the end + uint8_t *firstFreeByte=bufferZone; + int curBlock=0; + + for (int i=0; i < FirstUDPheader->nbBlocks; i++) { + AssertFatal( ((commonUDP_t *) firstFreeByte)->blockID==curBlock,""); + firstFreeByte+=alignedSize(firstFreeByte); + curBlock++; + } + + commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte; + FirstUDPheader->nbBlocks++; + newUDPheader->blockID=curBlock; + newUDPheader->contentBytes=sizeof(fs6_ul_t)+sizeof(fs6_ul_uespec_t) + dataLen; + hULUE(newUDPheader)->type=fs6ULsch; + hULUE(newUDPheader)->UE_id=UE_id; + hULUE(newUDPheader)->harq_id=harq_pid; + memcpy(hULUE(newUDPheader)->ulsch_power, + eNB->pusch_vars[UE_id]->ulsch_power, + sizeof(int)*2); + hULUE(newUDPheader)->cqi_crc_status=eNB->ulsch[UE_id]->harq_processes[harq_pid]->cqi_crc_status; + hULUE(newUDPheader)->O_ACK=eNB->ulsch[UE_id]->harq_processes[harq_pid]->O_ACK; + memcpy(hULUE(newUDPheader)->o_ACK, eNB->ulsch[UE_id]->harq_processes[harq_pid]->o_ACK, + sizeof(eNB->ulsch[UE_id]->harq_processes[harq_pid]->o_ACK)); + hULUE(newUDPheader)->ta=lte_est_timing_advance_pusch(eNB, UE_id); + hULUE(newUDPheader)->segment=segmentID; + memcpy(hULUE(newUDPheader)->o, eNB->ulsch[UE_id]->harq_processes[harq_pid]->o, + sizeof(eNB->ulsch[UE_id]->harq_processes[harq_pid]->o)); + memcpy(hULUE(newUDPheader)+1, data, dataLen); + hULUE(newUDPheader)->segLen=dataLen; + hULUE(newUDPheader)->r_offset=r_offset; + hULUE(newUDPheader)->G=eNB->ulsch[UE_id]->harq_processes[harq_pid]->G; +} + +void pusch_procedures_tosplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { + uint32_t harq_pid; + LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; + const int subframe = proc->subframe_rx; + const int frame = proc->frame_rx; + + for (int i = 0; i < NUMBER_OF_UE_MAX; i++) { + LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[i]; + + if (ulsch->ue_type > NOCE) + harq_pid = 0; + else + harq_pid= subframe2harq_pid(&eNB->frame_parms,frame,subframe); + + LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; + + if (ulsch->rnti>0) + LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d active: %d handled:%d]\n", + i, harq_pid, frame,subframe,i,ulsch->rnti, + ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->status, ulsch_harq->handled); + + if ((ulsch) && + (ulsch->rnti>0) && + (ulsch_harq->status == ACTIVE) && + (ulsch_harq->frame == frame) && + (ulsch_harq->subframe == subframe) && + (ulsch_harq->handled == 0)) { + // UE has ULSCH scheduling + for (int rb=0; + rb<=ulsch_harq->nb_rb; + rb++) { + int rb2 = rb+ulsch_harq->first_rb; + eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); + } + + LOG_D(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n", + eNB->Mod_id, frame, subframe, i); + uint8_t nPRS= fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]; + ulsch->cyclicShift = (ulsch_harq->n_DMRS2 + + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + + nPRS)%12; + AssertFatal(ulsch_harq->TBS>0,"illegal TBS %d\n",ulsch_harq->TBS); + LOG_D(PHY, + "[eNB %d][PUSCH %d] Frame %d Subframe %d Demodulating PUSCH: dci_alloc %d, rar_alloc %d, round %d, first_rb %d, nb_rb %d, Qm %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, ), O_ACK %d, beta_cqi %d \n", + eNB->Mod_id,harq_pid,frame,subframe, + ulsch_harq->dci_alloc, + ulsch_harq->rar_alloc, + ulsch_harq->round, + ulsch_harq->first_rb, + ulsch_harq->nb_rb, + ulsch_harq->Qm, + ulsch_harq->TBS, + ulsch_harq->rvidx, + ulsch->cyclicShift, + ulsch_harq->n_DMRS2, + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift, + ulsch_harq->O_ACK, + ulsch->beta_offset_cqi_times8); + start_meas(&eNB->ulsch_demodulation_stats); + eNB->FS6bufferZone=bufferZone; + rx_ulsch(eNB, proc, i); + stop_meas(&eNB->ulsch_demodulation_stats); + // TBD: add datablock for transmission + start_meas(&eNB->ulsch_decoding_stats); + ulsch_decoding(eNB,proc, + i, + 0, // control_only_flag + ulsch_harq->V_UL_DAI, + ulsch_harq->nb_rb>20 ? 1 : 0); + stop_meas(&eNB->ulsch_decoding_stats); + } + } +} + +void phy_procedures_eNB_uespec_RX_tosplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { + //RX processing for ue-specific resources + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + const int subframe = proc->subframe_rx; + const int frame = proc->frame_rx; + /* TODO: use correct rxdata */ + + if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; + + LOG_D (PHY, "[eNB %d] Frame %d: Doing phy_procedures_eNB_uespec_RX(%d)\n", eNB->Mod_id, frame, subframe); + eNB->rb_mask_ul[0] = 0; + eNB->rb_mask_ul[1] = 0; + eNB->rb_mask_ul[2] = 0; + eNB->rb_mask_ul[3] = 0; + // Fix me here, these should be locked + eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus = 0; + eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs = 0; + // Call SRS first since all others depend on presence of SRS or lack thereof + srs_procedures (eNB, proc); + eNB->first_run_I0_measurements = 0; + uci_procedures (eNB, proc); + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { // If PNF or monolithic + pusch_procedures_tosplit(bufferZone, bufSize, eNB,proc); + } + + lte_eNB_I0_measurements (eNB, subframe, 0, eNB->first_run_I0_measurements); + int min_I0=1000,max_I0=0; + + if ((frame==0) && (subframe==4)) { + for (int i=0; iframe_parms.N_RB_UL; i++) { + if (i==(eNB->frame_parms.N_RB_UL>>1) - 1) i+=2; + + if (eNB->measurements.n0_subband_power_tot_dB[i]measurements.n0_subband_power_tot_dB[i]; + + if (eNB->measurements.n0_subband_power_tot_dB[i]>max_I0) + max_I0 = eNB->measurements.n0_subband_power_tot_dB[i]; + } + + LOG_I (PHY, "max_I0 %d, min_I0 %d\n", max_I0, min_I0); + } + + return; +} + + +void fill_rx_indication_from_split(uint8_t *bufferZone, PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe, ul_propagation_t *ul_propa) { + nfapi_rx_indication_pdu_t *pdu; + int timing_advance_update; + uint32_t harq_pid; + + if (eNB->ulsch[UE_id]->ue_type > 0) + harq_pid = 0; + else + harq_pid = subframe2harq_pid (&eNB->frame_parms, + frame, subframe); + + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.rx_ind.sfn_sf = frame<<4| subframe; + eNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + pdu = &eNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus]; + // pdu->rx_ue_information.handle = eNB->ulsch[UE_id]->handle; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = eNB->ulsch[UE_id]->rnti; + pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; + pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation + pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->decodedBytes; + // estimate timing advance for MAC + timing_advance_update = ul_propa[UE_id].ta; + + // if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} + // if (timing_advance_update < -10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} + switch (eNB->frame_parms.N_RB_DL) { + case 6: /* nothing to do */ + break; + + case 15: + timing_advance_update /= 2; + break; + + case 25: + timing_advance_update /= 4; + break; + + case 50: + timing_advance_update /= 8; + break; + + case 75: + timing_advance_update /= 12; + break; + + case 100: + timing_advance_update /= 16; + break; + + default: + abort (); + } + + // put timing advance command in 0..63 range + timing_advance_update += 31; + + if (timing_advance_update < 0) + timing_advance_update = 0; + + if (timing_advance_update > 63) + timing_advance_update = 63; + + pdu->rx_indication_rel8.timing_advance = timing_advance_update; + // estimate UL_CQI for MAC (from antenna port 0 only) + int SNRtimes10 = dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_power[0]) - 10 * eNB->measurements.n0_subband_power_dB[0][0]; + + if (SNRtimes10 < -640) + pdu->rx_indication_rel8.ul_cqi = 0; + else if (SNRtimes10 > 635) + pdu->rx_indication_rel8.ul_cqi = 255; + else + pdu->rx_indication_rel8.ul_cqi = (640 + SNRtimes10) / 5; + + LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n", + harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, + timing_advance_update); + eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++; + eNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | subframe; + pthread_mutex_unlock(&eNB->UL_INFO_mutex); +} + +void pusch_procedures_fromsplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, ul_propagation_t *ul_propa) { + //LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; + const int subframe = proc->subframe_rx; + const int frame = proc->frame_rx; + uint32_t harq_pid; + uint32_t harq_pid0 = subframe2harq_pid(&eNB->frame_parms,frame,subframe); + + for (int i = 0; i < NUMBER_OF_UE_MAX; i++) { + LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[i]; + + if (ulsch->ue_type > NOCE) harq_pid = 0; + else harq_pid=harq_pid0; + + LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; + + if (ulsch->rnti>0) + LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n", + i, harq_pid, frame,subframe,i,ulsch->rnti, + ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled); + + if ((ulsch) && + (ulsch->rnti>0) && + (ulsch_harq->status == ACTIVE) && + (ulsch_harq->frame == frame) && + (ulsch_harq->subframe == subframe) && + (ulsch_harq->handled == 0)) { + // UE has ULSCH scheduling + for (int rb=0; + rb<=ulsch_harq->nb_rb; + rb++) { + int rb2 = rb+ulsch_harq->first_rb; + eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); + } + + start_meas(&eNB->ulsch_decoding_stats); + // This is a new packet, so compute quantities regarding segmentation + ulsch_harq->B = ulsch_harq->TBS+24; + lte_segmentation(NULL, + NULL, + ulsch_harq->B, + &ulsch_harq->C, + &ulsch_harq->Cplus, + &ulsch_harq->Cminus, + &ulsch_harq->Kplus, + &ulsch_harq->Kminus, + &ulsch_harq->F); + ulsch_decoding_data(eNB, proc, i, harq_pid, + ulsch_harq->nb_rb>20 ? 1 : 0); + stop_meas(&eNB->ulsch_decoding_stats); + } // if ((ulsch) && + // (ulsch->rnti>0) && + // (ulsch_harq->status == ACTIVE)) + else if ((ulsch) && + (ulsch->rnti>0) && + (ulsch_harq->status == ACTIVE) && + (ulsch_harq->frame == frame) && + (ulsch_harq->subframe == subframe) && + (ulsch_harq->handled == 1)) { + // this harq process is stale, kill it, this 1024 frames later (10s), consider reducing that + ulsch_harq->status = SCH_IDLE; + ulsch_harq->handled = 0; + ulsch->harq_mask &= ~(1 << harq_pid); + LOG_W (PHY, "Removing stale ULSCH config for UE %x harq_pid %d (harq_mask is now 0x%2.2x)\n", ulsch->rnti, harq_pid, ulsch->harq_mask); + } + } // for (i=0; inbDecode > 0) { + notifiedFIFO_elt_t *req=pullTpool(proc->respDecode, proc->threadPool); + postDecode(proc, req); + delNotifiedFIFO_elt(req); + } +} + +void recvFs6Ul(uint8_t *bufferZone, int nbBlocks, PHY_VARS_eNB *eNB, ul_propagation_t *ul_propa) { + void *bufPtr=bufferZone; + + for (int i=0; i < nbBlocks; i++) { //nbBlocks is the actual received blocks + if ( ((commonUDP_t *)bufPtr)->contentBytes > sizeof(fs6_ul_t) ) { + int type=hULUE(bufPtr)->type; + + if ( type == fs6ULsch) { + LTE_eNB_ULSCH_t *ulsch =eNB->ulsch[hULUE(bufPtr)->UE_id]; + LTE_UL_eNB_HARQ_t *ulsch_harq=ulsch->harq_processes[hULUE(bufPtr)->harq_id]; + memcpy(ulsch_harq->eUL+hULUE(bufPtr)->r_offset, + hULUE(bufPtr)+1, + hULUE(bufPtr)->segLen); + memcpy(eNB->pusch_vars[hULUE(bufPtr)->UE_id]->ulsch_power, + hULUE(bufPtr)->ulsch_power, + sizeof(int)*2); + ulsch_harq->G=hULUE(bufPtr)->G; + ulsch_harq->cqi_crc_status=hULUE(bufPtr)->cqi_crc_status; + //ulsch_harq->O_ACK= hULUE(bufPtr)->O_ACK; + memcpy(ulsch_harq->o_ACK, hULUE(bufPtr)->o_ACK, + sizeof(ulsch_harq->o_ACK)); + memcpy(ulsch_harq->o,hULUE(bufPtr)->o, sizeof(ulsch_harq->o)); + ul_propa[hULUE(bufPtr)->UE_id].ta=hULUE(bufPtr)->ta; + LOG_D(PHY,"Received ulsch data for: rnti:%x, cqi_crc_status %d O_ACK: %d, segment: %d, seglen: %d \n", + ulsch->rnti, ulsch_harq->cqi_crc_status, ulsch_harq->O_ACK,hULUE(bufPtr)->segment, hULUE(bufPtr)->segLen); + } else if ( type == fs6ULcch ) { + int nb_uci=hULUEuci(bufPtr)->nb_active_ue; + fs6_ul_uespec_uci_element_t *tmp=(fs6_ul_uespec_uci_element_t *)(hULUEuci(bufPtr)+1); + + for (int j=0; j < nb_uci ; j++) { + LOG_D(PHY,"FS6 cu, block: %d/%d: received ul harq/sr: %d, rnti: %d, ueid: %d\n", + i, j, type, tmp->rnti, tmp->UEid); + eNB->measurements.n0_subband_power_dB[0][0]=tmp->n0_subband_power_dB; + + if (tmp->uci.ue_id != 0xFFFF) + memcpy(&eNB->uci_vars[tmp->UEid],&tmp->uci, sizeof(tmp->uci)); + + if ( tmp->type == fs6ULindicationHarq ) + fill_uci_harq_indication (tmp->UEid, eNB, &eNB->uci_vars[tmp->UEid], + tmp->frame, tmp->subframe, tmp->harq_ack, + tmp->tdd_mapping_mode, tmp->tdd_multiplexing_mask); + else if ( tmp->type == fs6ULindicationSr ) + fill_sr_indication(tmp->UEid, eNB,tmp->rnti,tmp->frame,tmp->subframe,tmp->stat); + else + LOG_E(PHY, "Split FS6: impossible UL harq type\n"); + + tmp++; + } + } else + LOG_E(PHY, "FS6 ul packet type impossible\n" ); + } + + bufPtr+=alignedSize(bufPtr); + } +} + +void phy_procedures_eNB_uespec_RX_fromsplit(uint8_t *bufferZone, int nbBlocks,PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc) { + // The configuration arrived in Dl, so we can extract the UL data + ul_propagation_t ul_propa[NUMBER_OF_UE_MAX]; + recvFs6Ul(bufferZone, nbBlocks, eNB, ul_propa); + + // dirty memory allocation in OAI... + for (int i = 0; i < NUMBER_OF_UCI_VARS_MAX; i++) + if ( eNB->uci_vars[i].frame == proc->frame_rx && + eNB->uci_vars[i].subframe == proc->subframe_rx ) + eNB->uci_vars[i].active=0; + + pusch_procedures_fromsplit(bufferZone, nbBlocks, eNB, proc, ul_propa); +} + +void rcvFs6DL(uint8_t *bufferZone, int nbBlocks, PHY_VARS_eNB *eNB, int frame, int subframe) { + void *bufPtr=bufferZone; + + for (int i=0; i < nbBlocks; i++) { //nbBlocks is the actual received blocks + if ( ((commonUDP_t *)bufPtr)->contentBytes > sizeof(fs6_dl_t) ) { + int type=hDLUE(bufPtr)->type; + + if ( type == fs6DlConfig) { + int curUE=hDLUE(bufPtr)->UE_id; + LTE_eNB_DLSCH_t *dlsch0 = eNB->dlsch[curUE][0]; + LTE_DL_eNB_HARQ_t *dlsch_harq=dlsch0->harq_processes[hDLUE(bufPtr)->harq_pid]; +#ifdef PHY_TX_THREAD + dlsch0->active[subframe] = 1; +#else + dlsch0->active = 1; +#endif + dlsch0->harq_ids[frame%2][subframe]=hDLUE(bufPtr)->harq_pid; + dlsch0->rnti=hDLUE(bufPtr)->rnti; + dlsch0->sqrt_rho_a=hDLUE(bufPtr)->sqrt_rho_a; + dlsch0->sqrt_rho_b=hDLUE(bufPtr)->sqrt_rho_b; + dlsch_harq->nb_rb=hDLUE(bufPtr)->nb_rb; + memcpy(dlsch_harq->rb_alloc, hDLUE(bufPtr)->rb_alloc, sizeof(hDLUE(bufPtr)->rb_alloc)); + dlsch_harq->Qm=hDLUE(bufPtr)->Qm; + dlsch_harq->Nl=hDLUE(bufPtr)->Nl; + dlsch_harq->pdsch_start=hDLUE(bufPtr)->pdsch_start; +#ifdef PHY_TX_THREAD + dlsch_harq->CEmode = hDLUE(bufPtr)->CEmode; + dlsch_harq->i0=hDLUE(bufPtr)->i0; + dlsch_harq->sib1_br_flag=hDLUE(bufPtr)->sib1_br_flag; +#else + dlsch0->i0=hDLUE(bufPtr)->i0; + dlsch0->sib1_br_flag=hDLUE(bufPtr)->sib1_br_flag; +#endif + fs6Dlunpack(dlsch_harq->eDL, + hDLUE(bufPtr)+1, hDLUE(bufPtr)->dataLen); + LOG_D(PHY,"received %d bits, in harq id: %di fsf: %d.%d, sum %d\n", + hDLUE(bufPtr)->dataLen, hDLUE(bufPtr)->harq_pid, frame, subframe, sum(dlsch_harq->eDL, hDLUE(bufPtr)->dataLen)); + } else if (type == fs6UlConfig) { + int nbUE=(((commonUDP_t *)bufPtr)->contentBytes - sizeof(fs6_dl_t)) / sizeof( fs6_dl_ulsched_t ) ; +#define cpyVal(a) memcpy(&ulsch_harq->a,&hTxULUE(bufPtr)->a, sizeof(ulsch_harq->a)) + + for ( int i=0; i < nbUE; i++ ) { + int curUE=hTxULUE(bufPtr)->UE_id; + LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[curUE]; + LTE_UL_eNB_HARQ_t *ulsch_harq=ulsch->harq_processes[hTxULUE(bufPtr)->harq_pid]; + ulsch->ue_type=hTxULUE(bufPtr)->ue_type; + ulsch->harq_mask=hTxULUE(bufPtr)->harq_mask; + ulsch->Mlimit=hTxULUE(bufPtr)->Mlimit; + ulsch->max_turbo_iterations=hTxULUE(bufPtr)->max_turbo_iterations; + ulsch->bundling=hTxULUE(bufPtr)->bundling; + ulsch->beta_offset_cqi_times8=hTxULUE(bufPtr)->beta_offset_cqi_times8; + ulsch->beta_offset_ri_times8=hTxULUE(bufPtr)->beta_offset_ri_times8; + ulsch->beta_offset_harqack_times8=hTxULUE(bufPtr)->beta_offset_harqack_times8; + ulsch->Msg3_active=hTxULUE(bufPtr)->Msg3_active; + ulsch->cyclicShift=hTxULUE(bufPtr)->cyclicShift; + ulsch->cooperation_flag=hTxULUE(bufPtr)->cooperation_flag; + ulsch->num_active_cba_groups=hTxULUE(bufPtr)->num_active_cba_groups; + memcpy(ulsch->cba_rnti,hTxULUE(bufPtr)->cba_rnti,sizeof(ulsch->cba_rnti));//NUM_MAX_CBA_GROUP]; + ulsch->rnti=hTxULUE(bufPtr)->rnti; + ulsch_harq->nb_rb=hTxULUE(bufPtr)->nb_rb; + ulsch_harq->handled=0; + ulsch_harq->status = ACTIVE; + ulsch_harq->frame = frame; + ulsch_harq->subframe = subframe; + ulsch_harq->first_rb=hTxULUE(bufPtr)->first_rb; + ulsch_harq->O_RI=hTxULUE(bufPtr)->O_RI; + ulsch_harq->Or1=hTxULUE(bufPtr)->Or1; + ulsch_harq->Msc_initial=hTxULUE(bufPtr)->Msc_initial; + ulsch_harq->Nsymb_initial=hTxULUE(bufPtr)->Nsymb_initial; + ulsch_harq->V_UL_DAI=hTxULUE(bufPtr)->V_UL_DAI; + ulsch_harq->Qm=hTxULUE(bufPtr)->Qm; + ulsch_harq->srs_active=hTxULUE(bufPtr)->srs_active; + ulsch_harq->TBS=hTxULUE(bufPtr)->TBS; + ulsch_harq->Nsymb_pusch=hTxULUE(bufPtr)->Nsymb_pusch; + cpyVal(dci_alloc); + cpyVal(rar_alloc); + cpyVal(status); + cpyVal(Msg3_flag); + cpyVal(phich_active); + cpyVal(phich_ACK); + cpyVal(previous_first_rb); + cpyVal(B); + cpyVal(G); + //cpyVal(o); + cpyVal(uci_format); + cpyVal(Or2); + cpyVal(o_RI); + cpyVal(o_ACK); + cpyVal(O_ACK); + //cpyVal(q); + cpyVal(o_RCC); + cpyVal(q_ACK); + cpyVal(q_RI); + cpyVal(RTC); + cpyVal(ndi); + cpyVal(round); + cpyVal(rvidx); + cpyVal(Nl); + cpyVal(n_DMRS); + cpyVal(previous_n_DMRS); + cpyVal(n_DMRS2); + cpyVal(delta_TF); + cpyVal(repetition_number ); + cpyVal(total_number_of_repetitions); + LOG_D(PHY,"Received request to perform ulsch for: rnti:%d, fsf: %d/%d, O_ACK: %d\n", + ulsch->rnti, frame, subframe, ulsch_harq->O_ACK); + } + } else if ( type == fs6ULConfigCCH ) { + fs6_dl_uespec_ulcch_element_t *tmp=(fs6_dl_uespec_ulcch_element_t *)(hTxULcch(bufPtr)+1); + + for (int i=0; i< hTxULcch(bufPtr)->nb_active_ue; i++ ) + memcpy(&eNB->uci_vars[tmp->UE_id], &tmp->cch_vars, sizeof(tmp->cch_vars)); + } else + LOG_E(PHY, "Impossible block in fs6 DL\n"); + } + + bufPtr+=alignedSize(bufPtr); + } +} + +void phy_procedures_eNB_TX_fromsplit(uint8_t *bufferZone, int nbBlocks, PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, int do_meas ) { + LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; + int subframe=proc->subframe_tx; + int frame=proc->frame_tx; + //LTE_UL_eNB_HARQ_t *ulsch_harq; + eNB->pdcch_vars[subframe&1].num_pdcch_symbols=hDL(bufferZone)->num_pdcch_symbols; + eNB->pdcch_vars[subframe&1].num_dci=hDL(bufferZone)->num_dci; + uint8_t num_mdci = eNB->mpdcch_vars[subframe&1].num_dci = hDL(bufferZone)->num_mdci; + eNB->pbch_configured=true; + memcpy(eNB->pbch_pdu,hDL(bufferZone)->pbch_pdu, 4); + + // Remove all scheduled DL, we will populate from the CU sending + for (int UE_id=0; UE_iddlsch[UE_id][0]; + + if ( dlsch0 && dlsch0->rnti>0 ) { +#ifdef PHY_TX_THREAD + dlsch0->active[subframe] = 0; +#else + dlsch0->active = 0; +#endif + } + } + + rcvFs6DL(bufferZone, nbBlocks, eNB, frame, subframe); + + if (do_meas==1) { + start_meas(&eNB->phy_proc_tx); + start_meas(&eNB->dlsch_common_and_dci); + } + + // clear the transmit data array for the current subframe + for (int aa = 0; aa < fp->nb_antenna_ports_eNB; aa++) { + memset (&eNB->common_vars.txdataF[aa][subframe * fp->ofdm_symbol_size * (fp->symbols_per_tti)], + 0, fp->ofdm_symbol_size * (fp->symbols_per_tti) * sizeof (int32_t)); + } + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { + if (is_pmch_subframe(frame,subframe,fp)) { + pmch_procedures(eNB,proc); + } else { + // this is not a pmch subframe, so generate PSS/SSS/PBCH + common_signal_procedures(eNB,frame, subframe); + } + } + + // clear previous allocation information for all UEs + for (int i = 0; i < NUMBER_OF_UE_MAX; i++) { + //if (eNB->dlsch[i][0]) + //eNB->dlsch[i][0]->subframe_tx[subframe] = 0; + } + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { + for (int i=0; i< hDL(bufferZone)->num_dci; i++) + eNB->pdcch_vars[subframe&1].dci_alloc[i]=hDL(bufferZone)->dci_alloc[i]; + + LOG_D (PHY, "Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %" PRIu8 ")\n", frame, subframe, hDL(bufferZone)->num_dci); + generate_dci_top(hDL(bufferZone)->num_pdcch_symbols, + hDL(bufferZone)->num_dci, + &eNB->pdcch_vars[subframe&1].dci_alloc[0], + 0, + hDL(bufferZone)->amp, + fp, + eNB->common_vars.txdataF, + subframe); + + if (num_mdci > 0) { + LOG_D (PHY, "[eNB %" PRIu8 "] Frame %d, subframe %d: Calling generate_mdci_top (mpdcch) (num_dci %" PRIu8 ")\n", eNB->Mod_id, frame, subframe, num_mdci); + generate_mdci_top (eNB, frame, subframe, AMP, eNB->common_vars.txdataF); + } + } + + for (int UE_id=0; UE_iddlsch[UE_id][0]; + LTE_eNB_DLSCH_t *dlsch1 = eNB->dlsch[UE_id][1]; + + if ((dlsch0)&&(dlsch0->rnti>0)&& +#ifdef PHY_TX_THREAD + (dlsch0->active[subframe] == 1) +#else + (dlsch0->active == 1) +#endif + ) { + uint64_t sum=0; + + for ( int i= subframe * fp->ofdm_symbol_size * (fp->symbols_per_tti); + i< (subframe+1) * fp->ofdm_symbol_size * (fp->symbols_per_tti); + i++) + sum+=((int32_t *)(eNB->common_vars.txdataF[0]))[i]; + + LOG_D(PHY,"frame: %d, subframe: %d, sum of dlsch mod v1: %lx\n", frame, subframe, sum); + int harq_pid=dlsch0->harq_ids[frame%2][subframe]; + pdsch_procedures(eNB, + proc, + harq_pid, + dlsch0, + dlsch1); + } + } + + eNB->phich_vars[subframe&1]=hDL(bufferZone)->phich_vars; + generate_phich_top(eNB, + proc, + AMP); +} + +#define cpyToDu(a) hTxULUE(newUDPheader)->a=ulsch->a +#define cpyToDuHarq(a) hTxULUE(newUDPheader)->a=ulsch_harq->a +#define memcpyToDuHarq(a) memcpy(&hTxULUE(newUDPheader)->a,&ulsch_harq->a, sizeof(ulsch_harq->a)); + +void appendFs6TxULUE(uint8_t *bufferZone, LTE_DL_FRAME_PARMS *fp, int curUE, LTE_eNB_ULSCH_t *ulsch, int frame, int subframe) { + commonUDP_t *FirstUDPheader=(commonUDP_t *) bufferZone; + // move to the end + uint8_t *firstFreeByte=bufferZone; + int curBlock=0; + + for (int i=0; i < FirstUDPheader->nbBlocks; i++) { + AssertFatal( ((commonUDP_t *) firstFreeByte)->blockID==curBlock,""); + firstFreeByte+=alignedSize(firstFreeByte); + curBlock++; + } + + commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte; + FirstUDPheader->nbBlocks++; + newUDPheader->blockID=curBlock; + newUDPheader->contentBytes=sizeof(fs6_dl_t)+sizeof(fs6_dl_ulsched_t); + // We skip the fs6 DL header, that is populated by caller + // This header will be duplicated during sending + hTxULUE(newUDPheader)->type=fs6UlConfig; + hTxULUE(newUDPheader)->UE_id=curUE; + int harq_pid; + + if (ulsch->ue_type > NOCE) + // LTE-M case + harq_pid = 0; + else + harq_pid = subframe2harq_pid(fp, frame, subframe); + + LTE_UL_eNB_HARQ_t *ulsch_harq=ulsch->harq_processes[harq_pid]; + hTxULUE(newUDPheader)->harq_pid=harq_pid; + cpyToDu(ue_type); + cpyToDu(harq_mask); + cpyToDu(Mlimit); + cpyToDu(max_turbo_iterations); + cpyToDu(bundling); + cpyToDu(beta_offset_cqi_times8); + cpyToDu(beta_offset_ri_times8); + cpyToDu(beta_offset_harqack_times8); + cpyToDu(Msg3_active); + cpyToDu(cyclicShift); + cpyToDu(cooperation_flag); + cpyToDu(num_active_cba_groups); + memcpy(hTxULUE(newUDPheader)->cba_rnti,ulsch->cba_rnti,sizeof(ulsch->cba_rnti));//NUM_MAX_CBA_GROUP]; + cpyToDu(rnti); + cpyToDuHarq(nb_rb); + cpyToDuHarq(Msc_initial); + cpyToDuHarq(Nsymb_initial); + cpyToDuHarq(O_RI); + cpyToDuHarq(Or1); + cpyToDuHarq(first_rb); + cpyToDuHarq(V_UL_DAI); + cpyToDuHarq(Qm); + cpyToDuHarq(srs_active); + cpyToDuHarq(TBS); + cpyToDuHarq(Nsymb_pusch); + memcpyToDuHarq(dci_alloc); + memcpyToDuHarq(rar_alloc); + memcpyToDuHarq(status); + memcpyToDuHarq(Msg3_flag); + memcpyToDuHarq(phich_active); + memcpyToDuHarq(phich_ACK); + memcpyToDuHarq(previous_first_rb); + memcpyToDuHarq(B); + memcpyToDuHarq(G); + //memcpyToDuHarq(o); + memcpyToDuHarq(uci_format); + memcpyToDuHarq(Or2); + memcpyToDuHarq(o_RI); + memcpyToDuHarq(o_ACK); + memcpyToDuHarq(O_ACK); + //memcpyToDuHarq(q); + memcpyToDuHarq(o_RCC); + memcpyToDuHarq(q_ACK); + memcpyToDuHarq(q_RI); + memcpyToDuHarq(RTC); + memcpyToDuHarq(ndi); + memcpyToDuHarq(round); + memcpyToDuHarq(rvidx); + memcpyToDuHarq(Nl); + memcpyToDuHarq(n_DMRS); + memcpyToDuHarq(previous_n_DMRS); + memcpyToDuHarq(n_DMRS2); + memcpyToDuHarq(delta_TF); + memcpyToDuHarq(repetition_number ); + memcpyToDuHarq(total_number_of_repetitions); + LOG_D(PHY,"Added request to perform ulsch for: rnti:%x, fsf: %d/%d\n", ulsch->rnti, frame, subframe); +} + +void appendFs6DLUE(uint8_t *bufferZone, LTE_DL_FRAME_PARMS *fp, int UE_id, int8_t harq_pid, LTE_eNB_DLSCH_t *dlsch0, LTE_DL_eNB_HARQ_t *harqData, int frame, int subframe) { + commonUDP_t *FirstUDPheader=(commonUDP_t *) bufferZone; + // move to the end + uint8_t *firstFreeByte=bufferZone; + int curBlock=0; + + for (int i=0; i < FirstUDPheader->nbBlocks; i++) { + AssertFatal( ((commonUDP_t *) firstFreeByte)->blockID==curBlock,""); + firstFreeByte+=alignedSize(firstFreeByte); + curBlock++; + } + + int UEdataLen= get_G(fp, + harqData->nb_rb, + harqData->rb_alloc, + harqData->Qm, + harqData->Nl, + harqData->pdsch_start, + frame,subframe, + 0); + AssertFatal(firstFreeByte+ceil16_bytes(UEdataLen)+sizeof(fs6_dl_t) <= bufferZone+FS6_BUF_SIZE, ""); + commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte; + FirstUDPheader->nbBlocks++; + newUDPheader->blockID=curBlock; + newUDPheader->contentBytes=sizeof(fs6_dl_t)+sizeof(fs6_dl_uespec_t) + ceil16_bytes(UEdataLen); + // We skip the fs6 DL header, that is populated by caller + // This header will be duplicated during sending + hDLUE(newUDPheader)->type=fs6DlConfig; + hDLUE(newUDPheader)->UE_id=UE_id; + hDLUE(newUDPheader)->harq_pid=harq_pid; + hDLUE(newUDPheader)->rnti=dlsch0->rnti; + hDLUE(newUDPheader)->sqrt_rho_a=dlsch0->sqrt_rho_a; + hDLUE(newUDPheader)->sqrt_rho_b=dlsch0->sqrt_rho_b; + hDLUE(newUDPheader)->nb_rb=harqData->nb_rb; + memcpy(hDLUE(newUDPheader)->rb_alloc, harqData->rb_alloc, sizeof(harqData->rb_alloc)); + hDLUE(newUDPheader)->Qm=harqData->Qm; + hDLUE(newUDPheader)->Nl=harqData->Nl; + hDLUE(newUDPheader)->pdsch_start=harqData->pdsch_start; +#ifdef PHY_TX_THREAD + hDLUE(newUDPheader)->CEmode=harqData->CEmode; + hDLUE(newUDPheader)->i0=harqData->i0; + hDLUE(newUDPheader)->sib1_br_flag=harqData->sib1_br_flag; +#else + hDLUE(newUDPheader)->i0=dlsch0->i0; + hDLUE(newUDPheader)->sib1_br_flag=dlsch0->sib1_br_flag; +#endif + hDLUE(newUDPheader)->dataLen=UEdataLen; + fs6Dlpack(hDLUE(newUDPheader)+1, harqData->eDL, UEdataLen); + LOG_D(PHY,"sending %d bits, in harq id: %di fsf: %d.%d, sum %d\n", + UEdataLen, harq_pid, frame, subframe, sum(harqData->eDL, UEdataLen)); + //for (int i=0; i < UEdataLen; i++) + //LOG_D(PHY,"buffer ei[%d]:%hhx\n", i, ( (uint8_t *)(hDLUE(newUDPheader)+1) )[i]); +} + +void appendFs6DLUEcch(uint8_t *bufferZone, PHY_VARS_eNB *eNB, int frame, int subframe) { + commonUDP_t *FirstUDPheader=(commonUDP_t *) bufferZone; + // move to the end + uint8_t *firstFreeByte=bufferZone; + int curBlock=0; + + for (int i=0; i < FirstUDPheader->nbBlocks; i++) { + AssertFatal( ((commonUDP_t *) firstFreeByte)->blockID==curBlock,""); + firstFreeByte+=alignedSize(firstFreeByte); + curBlock++; + } + + commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte; + bool first_UE=true; + + for (int i = 0; i < NUMBER_OF_UCI_VARS_MAX; i++) { + LTE_eNB_UCI *uci = &(eNB->uci_vars[i]); + + if ((uci->active == 1) && (uci->frame == frame) && (uci->subframe == subframe)) { + LOG_D(PHY,"Frame %d, subframe %d: adding uci procedures (type %d) for %d \n", + frame, + subframe, + uci->type, + i); + + if ( first_UE ) { + FirstUDPheader->nbBlocks++; + newUDPheader->blockID=curBlock; + newUDPheader->contentBytes=sizeof(fs6_dl_t)+sizeof(fs6_dl_uespec_ulcch_t); + hTxULcch(newUDPheader)->type=fs6ULConfigCCH; + hTxULcch(newUDPheader)->nb_active_ue=0; + first_UE=false; + } + + fs6_dl_uespec_ulcch_element_t *tmp=(fs6_dl_uespec_ulcch_element_t *)(hTxULcch(newUDPheader)+1); + tmp+=hTxULcch(newUDPheader)->nb_active_ue; + tmp->UE_id=i; + memcpy(&tmp->cch_vars,uci, sizeof(tmp->cch_vars)); + hTxULcch(newUDPheader)->nb_active_ue++; + newUDPheader->contentBytes+=sizeof(fs6_dl_uespec_ulcch_element_t); + } + } +} + +void phy_procedures_eNB_TX_tosplit(uint8_t *bufferZone, PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, int do_meas, uint8_t *buf, int bufSize) { + int frame=proc->frame_tx; + int subframe=proc->subframe_tx; + LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; + + if ((fp->frame_type == TDD) && (subframe_select (fp, subframe) == SF_UL)) { + LOG_W(HW,"no sending in eNB_TX\n"); + return; + } + + // clear previous allocation information for all UEs + for (int i = 0; i < NUMBER_OF_UE_MAX; i++) { + //if (eNB->dlsch[i][0]) + //eNB->dlsch[i][0]->subframe_tx[subframe] = 0; + } + + // Send to DU the UL scheduled for future UL subframe + for (int i=0; iulsch[i]; + + if (ulsch->ue_type > NOCE) + harq_pid = 0; + else + harq_pid= subframe2harq_pid(&eNB->frame_parms,frame,subframe); + + LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; + + if (ulsch->rnti>0) { + LOG_D(PHY,"check in UL scheduled harq %d: rnti %d, tx frame %d/%d, ulsch: %d, %d/%d (handled: %d)\n", + harq_pid, ulsch->rnti, frame, subframe, ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled); + } + + for (int k=0; k<8; k++) { + ulsch_harq = ulsch->harq_processes[k]; + + if (ulsch && + (ulsch->rnti>0) && + (ulsch_harq->status == ACTIVE) && + (ulsch_harq->frame == frame) && + (ulsch_harq->subframe == subframe) && + (ulsch_harq->handled == 0) + ) + appendFs6TxULUE(bufferZone, + fp, + i, + ulsch, + frame, + subframe + ); + } + } + + appendFs6DLUEcch(bufferZone, + eNB, + frame, + subframe + ); + uint8_t num_pdcch_symbols = eNB->pdcch_vars[subframe&1].num_pdcch_symbols; + uint8_t num_dci = eNB->pdcch_vars[subframe&1].num_dci; + uint8_t num_mdci = eNB->mpdcch_vars[subframe&1].num_dci; + memcpy(hDL(bufferZone)->pbch_pdu,eNB->pbch_pdu,4); + + if ( num_dci <= 8 ) + LOG_D(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci); + else { + LOG_E(PHY, "Num dci too large for current FS6 implementation, reducing to 8 dci (was %d)\n", num_dci); + num_dci=8; + } + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { + hDL(bufferZone)->num_pdcch_symbols=num_pdcch_symbols; + hDL(bufferZone)->num_dci=num_dci; + hDL(bufferZone)->num_mdci=num_mdci; + hDL(bufferZone)->amp=AMP; + + for (int i=0; i< hDL(bufferZone)->num_dci; i++) + hDL(bufferZone)->dci_alloc[i]=eNB->pdcch_vars[subframe&1].dci_alloc[i]; + + LOG_D(PHY, "pbch configured: %d\n", eNB->pbch_configured); + } + + if (do_meas==1) stop_meas(&eNB->dlsch_common_and_dci); + + if (do_meas==1) start_meas(&eNB->dlsch_ue_specific); + + for (int UE_id=0; UE_iddlsch[UE_id][0]; + + if ((dlsch0)&&(dlsch0->rnti>0)&& +#ifdef PHY_TX_THREAD + (dlsch0->active[subframe] == 1) +#else + (dlsch0->active == 1) +#endif + ) { + // get harq_pid + int harq_pid = dlsch0->harq_ids[frame%2][subframe]; + AssertFatal(harq_pid>=0,"harq_pid is negative\n"); + + if (harq_pid>=8) { + if (dlsch0->ue_type == NOCE) + LOG_E(PHY,"harq_pid:%d corrupt must be 0-7 UE_id:%d frame:%d subframe:%d rnti:%x [ %1d.%1d.%1d.%1d.%1d.%1d.%1d.%1d\n", harq_pid,UE_id,frame,subframe,dlsch0->rnti, + dlsch0->harq_ids[frame%2][0], + dlsch0->harq_ids[frame%2][1], + dlsch0->harq_ids[frame%2][2], + dlsch0->harq_ids[frame%2][3], + dlsch0->harq_ids[frame%2][4], + dlsch0->harq_ids[frame%2][5], + dlsch0->harq_ids[frame%2][6], + dlsch0->harq_ids[frame%2][7]); + } else { + if (dlsch_procedures(eNB, + proc, + harq_pid, + dlsch0, + &eNB->UE_stats[(uint32_t)UE_id])) { + // data in: dlsch0 harq_processes[harq_pid]->e + /* length + get_G(fp, + dlsch_harq->nb_rb, + dlsch_harq->rb_alloc, + dlsch_harq->Qm, + dlsch_harq->Nl, + dlsch_harq->pdsch_start, + frame,subframe, + 0) + need harq_pid + */ + LTE_DL_eNB_HARQ_t *dlsch_harq=dlsch0->harq_processes[harq_pid]; + appendFs6DLUE(bufferZone, + fp, + UE_id, + harq_pid, + dlsch0, + dlsch_harq, + frame, + subframe + ); + } + } + } else if ((dlsch0)&&(dlsch0->rnti>0)&& +#ifdef PHY_TX_THREAD + (dlsch0->active[subframe] == 0) +#else + (dlsch0->active == 0) +#endif + ) { + // clear subframe TX flag since UE is not scheduled for PDSCH in this subframe (so that we don't look for PUCCH later) + //dlsch0->subframe_tx[subframe]=0; + } + } + + hDL(bufferZone)->phich_vars=eNB->phich_vars[subframe&1]; + + if (do_meas==1) stop_meas(&eNB->dlsch_ue_specific); + + if (do_meas==1) stop_meas(&eNB->phy_proc_tx); + + // MBMS is not working in OAI + if (hDL(bufferZone)->num_mdci) abort(); + + return; +} + +void *DL_du_fs6(void *arg) { + RU_t *ru=(RU_t *)arg; + static uint64_t lastTS; + L1_rxtx_proc_t L1proc= {0}; + // We pick the global thread pool from the legacy code global vars + L1proc.threadPool=RC.eNB[0][0]->proc.L1_proc.threadPool; + L1proc.respEncode=RC.eNB[0][0]->proc.L1_proc.respEncode; + L1proc.respDecode=RC.eNB[0][0]->proc.L1_proc.respDecode; + initStaticTime(begingWait); + initStaticTime(begingProcessing); + initRefTimes(fullLoop); + initRefTimes(DuHigh); + initRefTimes(DuLow); + initRefTimes(transportTime); + + while (1) { + for (int i=0; inum_eNB; i++) { + initBufferZone(bufferZone); + pickStaticTime(begingWait); + int nb_blocks=receiveSubFrame(&sockFS6, bufferZone, sizeof(bufferZone), CTsentCUv0 ); + updateTimesReset(begingWait, &fullLoop, 1000, false, "DU wait CU"); + + if (nb_blocks > 0) { + if ( lastTS+ru->eNB_list[i]->frame_parms.samples_per_tti < hUDP(bufferZone)->timestamp) { + LOG_E(HW,"Missed a subframe: expecting: %lu, received %lu\n", + lastTS+ru->eNB_list[i]->frame_parms.samples_per_tti, + hUDP(bufferZone)->timestamp); + } else if ( lastTS+ru->eNB_list[i]->frame_parms.samples_per_tti > hUDP(bufferZone)->timestamp) { + LOG_E(HW,"Received a subframe in past time from CU (dropping it): expecting: %lu, received %lu\n", + lastTS+ru->eNB_list[i]->frame_parms.samples_per_tti, + hUDP(bufferZone)->timestamp); + } + + pickStaticTime(begingProcessing); + lastTS=hUDP(bufferZone)->timestamp; + setAllfromTS(hUDP(bufferZone)->timestamp - sf_ahead*ru->eNB_list[i]->frame_parms.samples_per_tti, &L1proc); + measTransportTime(hDL(bufferZone)->DuClock, hDL(bufferZone)->CuSpentMicroSec, + &transportTime, 1000, false, "Transport time, to CU + from CU for one subframe"); + phy_procedures_eNB_TX_fromsplit( bufferZone, nb_blocks, ru->eNB_list[i], &L1proc, 1); + updateTimesReset(begingProcessing, &DuHigh, 1000, false, "DU high layer1 processing for DL"); + } else + LOG_E(PHY,"DL not received for subframe\n"); + } + + pickStaticTime(begingProcessing); + feptx_prec(ru, L1proc.frame_tx,L1proc.subframe_tx ); + feptx_ofdm(ru, L1proc.frame_tx,L1proc.subframe_tx ); + ocp_tx_rf(ru, &L1proc); + updateTimesReset(begingProcessing, &DuLow, 1000, false, "DU low layer1 processing for DL"); + + if ( IS_SOFTMODEM_RFSIM ) + return NULL; + } + + return NULL; +} + +void UL_du_fs6(RU_t *ru, L1_rxtx_proc_t *proc) { + initStaticTime(begingWait); + initRefTimes(fullLoop); + pickStaticTime(begingWait); + rx_rf(ru, proc); + updateTimesReset(begingWait, &fullLoop, 1000, false, "DU wait USRP"); + // front end processing: convert from time domain to frequency domain + // fills rxdataF buffer + fep_full(ru, proc->subframe_rx); + // Fixme: datamodel issue + PHY_VARS_eNB *eNB = RC.eNB[0][0]; + + if (NFAPI_MODE==NFAPI_MODE_PNF) { + // I am a PNF and I need to let nFAPI know that we have a (sub)frame tick + //add_subframe(&frame, &subframe, 4); + //oai_subframe_ind(proc->frame_tx, proc->subframe_tx); + oai_subframe_ind(proc->frame_rx, proc->subframe_rx); + } + + initBufferZone(bufferZone); + hUDP(bufferZone)->timestamp=proc->timestamp_rx; + prach_eNB_tosplit(bufferZone, FS6_BUF_SIZE, eNB, proc ); + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { + phy_procedures_eNB_uespec_RX_tosplit(bufferZone, FS6_BUF_SIZE, eNB, proc ); + } + + if (hUDP(bufferZone)->nbBlocks==0) { + hUDP(bufferZone)->nbBlocks=1; // We have to send the signaling, even is there is no user plan data (no UE) + hUDP(bufferZone)->blockID=0; + hUDP(bufferZone)->contentBytes=sizeof(fs6_ul_t); + } + + for (int i=0; inum_eNB; i++) { + sendSubFrame(&sockFS6, bufferZone, sizeof(fs6_ul_t), CTsentDUv0); + } +} + +void DL_cu_fs6(RU_t *ru, L1_rxtx_proc_t *proc, uint64_t DuClock, uint64_t startCycle) { + initRefTimes(CUprocessing); + // Fixme: datamodel issue + PHY_VARS_eNB *eNB = RC.eNB[0][0]; + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.frame = proc->frame_rx; + eNB->UL_INFO.subframe = proc->subframe_rx; + eNB->UL_INFO.module_id = eNB->Mod_id; + eNB->UL_INFO.CC_id = eNB->CC_id; + eNB->if_inst->UL_indication(&eNB->UL_INFO, proc); + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + initBufferZone(bufferZone); + phy_procedures_eNB_TX_tosplit(bufferZone, eNB, proc, 1, bufferZone, FS6_BUF_SIZE); + hUDP(bufferZone)->timestamp=proc->timestamp_tx; + + if (hUDP(bufferZone)->nbBlocks==0) { + hUDP(bufferZone)->nbBlocks=1; // We have to send the signaling, even is there is no user plan data (no UE) + hUDP(bufferZone)->blockID=0; + hUDP(bufferZone)->contentBytes=sizeof(fs6_dl_t); + } + + hDL(bufferZone)->DuClock=DuClock; + hDL(bufferZone)->CuSpentMicroSec=(rdtsc()-startCycle)/(cpuf*1000); + updateTimesReset(startCycle, &CUprocessing, 1000, true,"CU entire processing from recv to send"); + sendSubFrame(&sockFS6, bufferZone, sizeof(fs6_dl_t), CTsentCUv0 ); + return; +} + +void UL_cu_fs6(RU_t *ru, L1_rxtx_proc_t *proc, uint64_t *TS, uint64_t *DuClock, uint64_t *startProcessing) { + initBufferZone(bufferZone); + initStaticTime(begingWait); + initRefTimes(fullLoop); + pickStaticTime(begingWait); + int nb_blocks=receiveSubFrame(&sockFS6, bufferZone, sizeof(bufferZone), CTsentDUv0 ); + * DuClock=hUDP(bufferZone)->senderClock; + * startProcessing=rdtsc(); + updateTimesReset(begingWait, &fullLoop, 1000, false, "CU wait DU"); + + if (nb_blocks ==0) { + LOG_W(PHY, "CU lost a subframe\n"); + return; + } + + if (nb_blocks != hUDP(bufferZone)->nbBlocks ) + LOG_W(PHY, "received %d blocks for %d expected\n", nb_blocks, hUDP(bufferZone)->nbBlocks); + + if ( *TS != hUDP(bufferZone)->timestamp ) { + LOG_W(HW, "CU received time: %lu instead of %lu expected\n", hUDP(bufferZone)->timestamp, *TS); + *TS=hUDP(bufferZone)->timestamp; + } + + setAllfromTS(hUDP(bufferZone)->timestamp, proc); + PHY_VARS_eNB *eNB = RC.eNB[0][0]; + + if (is_prach_subframe(&eNB->frame_parms, proc->frame_prach,proc->subframe_prach)>0) + prach_eNB_fromsplit(bufferZone, sizeof(bufferZone), eNB, proc); + + release_UE_in_freeList(eNB->Mod_id); + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { + phy_procedures_eNB_uespec_RX_fromsplit(bufferZone, nb_blocks, eNB, proc); + } +} + +void *cu_fs6(void *arg) { + setbuf(stdout, NULL); + setbuf(stderr, NULL); + RU_t *ru = (RU_t *)arg; + //RU_proc_t *proc = &ru->proc; + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(ru->frame_parms,1); + phy_init_RU(ru); + wait_sync("ru_thread"); + char remoteIP[1024]; + strncpy(remoteIP,get_softmodem_params()->split73+3, 1023); //three first char should be cu: or du: + char port_def[256]=DU_PORT; + for (int i=0; i <1000; i++) + if (remoteIP[i]==':') { + strncpy(port_def,remoteIP+i+1,255); + remoteIP[i]=0; + break; + } + + AssertFatal(createUDPsock(NULL, CU_PORT, remoteIP, port_def, &sockFS6), ""); + L1_rxtx_proc_t L1proc= {0}; + // We pick the global thread pool from the legacy code global vars + L1proc.threadPool=RC.eNB[0][0]->proc.L1_proc.threadPool; + L1proc.respEncode=RC.eNB[0][0]->proc.L1_proc.respEncode; + L1proc.respDecode=RC.eNB[0][0]->proc.L1_proc.respDecode; + uint64_t timeStamp=0; + initStaticTime(begingWait); + initStaticTime(begingWait2); + initRefTimes(waitDUAndProcessingUL); + initRefTimes(makeSendDL); + initRefTimes(fullLoop); + uint64_t DuClock=0, startProcessing=0; + + while(1) { + timeStamp+=ru->frame_parms->samples_per_tti; + updateTimesReset(begingWait, &fullLoop, 1000, true, "CU for full SubFrame (must be less 1ms)"); + pickStaticTime(begingWait); + UL_cu_fs6(ru, &L1proc, &timeStamp, &DuClock, &startProcessing); + updateTimesReset(begingWait, &waitDUAndProcessingUL, 1000, true,"CU Time in wait Rx + Ul processing"); + pickStaticTime(begingWait2); + DL_cu_fs6(ru, &L1proc, DuClock, startProcessing); + updateTimesReset(begingWait2, &makeSendDL, 1000, true,"CU Time in DL build+send"); + } + + return NULL; +} + +void *du_fs6(void *arg) { + setbuf(stdout, NULL); + setbuf(stderr, NULL); + RU_t *ru = (RU_t *)arg; + //RU_proc_t *proc = &ru->proc; + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(ru->frame_parms,1); + phy_init_RU(ru); + init_rf(ru); + wait_sync("ru_thread"); + char remoteIP[1024]; + strncpy(remoteIP,get_softmodem_params()->split73+3,1023); //three first char should be cu: or du: + char port_def[256]=CU_PORT; + for (int i=0; i <1000; i++) + if (remoteIP[i]==':') { + strncpy(port_def,remoteIP+i+1,255); + remoteIP[i]=0; + break; + } + AssertFatal(createUDPsock(NULL, DU_PORT, remoteIP, port_def, &sockFS6), ""); + + if (ru->rfdevice.trx_start_func(&ru->rfdevice) != 0) + LOG_E(HW,"Could not start the RF device\n"); + else + LOG_I(PHY,"RU %d rf device ready\n",ru->idx); + + initStaticTime(begingWait); + initRefTimes(waitRxAndProcessingUL); + initRefTimes(fullLoop); + pthread_t t; + + if ( !IS_SOFTMODEM_RFSIM ) + threadCreate(&t, DL_du_fs6, (void *)ru, "MainDuTx", -1, OAI_PRIORITY_RT_MAX); + + L1_rxtx_proc_t L1proc= {0}; + // We pick the global thread pool from the legacy code global vars + L1proc.threadPool=RC.eNB[0][0]->proc.L1_proc.threadPool; + L1proc.respEncode=RC.eNB[0][0]->proc.L1_proc.respEncode; + L1proc.respDecode=RC.eNB[0][0]->proc.L1_proc.respDecode; + + while(!oai_exit) { + updateTimesReset(begingWait, &fullLoop, 1000, true,"DU for full SubFrame (must be less 1ms)"); + pickStaticTime(begingWait); + UL_du_fs6(ru, &L1proc); + + if ( IS_SOFTMODEM_RFSIM ) + DL_du_fs6((void *)ru); + + updateTimesReset(begingWait, &waitRxAndProcessingUL, 1000, true,"DU Time in wait Rx + Ul processing"); + } + + ru->rfdevice.trx_end_func(&ru->rfdevice); + LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); + return NULL; +} diff --git a/executables/main-ocp.c b/executables/main-ocp.c new file mode 100644 index 0000000000..a68ee290d0 --- /dev/null +++ b/executables/main-ocp.c @@ -0,0 +1,1385 @@ +/* + Author: Laurent THOMAS, Open Cells Project company, funded by IRT SystemX + copyleft: OpenAirInterface Software Alliance and it's licence + * This file replaces + * targets/RT/USER/lte-softmodem.c + * targets/RT/USER/rt_wrapper.c + * targets/RT/USER/lte-ru.c + * targets/RT/USER/lte-enb.c + * targets/RT/USER/ru_control.c + * openair1/SCHED/prach_procedures.c + * The merger of OpenAir central code to this branch + * should check if these 3 files are modified and analyze if code code has to be copied in here + */ +#define _GNU_SOURCE +#include + +#include +#include +#include +static int DEFBANDS[] = {7}; +static int DEFENBS[] = {0}; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +pthread_cond_t nfapi_sync_cond; +pthread_mutex_t nfapi_sync_mutex; +int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex +pthread_cond_t sync_cond; +pthread_mutex_t sync_mutex; +int sync_var=-1; //!< protected by mutex \ref sync_mutex. +int config_sync_var=-1; +volatile int oai_exit = 0; +double cpuf; +uint16_t sf_ahead=4; +int otg_enabled; +uint32_t downlink_frequency[MAX_NUM_CCs][4]; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; +int split73; +char * split73_config; +int split73; + +static void *ru_thread( void *param ); +void kill_RU_proc(RU_t *ru) { +} +void kill_eNB_proc(int inst) { +} +void free_transport(PHY_VARS_eNB *eNB) { +} +void reset_opp_meas(void) { +} +extern void phy_free_RU(RU_t *); + +void exit_function(const char *file, const char *function, const int line, const char *s) { + if (s != NULL) { + printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s); + } + + close_log_mem(); + oai_exit = 1; + + if (RC.ru == NULL) + exit(-1); // likely init not completed, prevent crash or hang, exit now... + + for (int ru_id=0; ru_idrfdevice.trx_end_func) { + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + RC.ru[ru_id]->rfdevice.trx_end_func = NULL; + } + + if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) { + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + RC.ru[ru_id]->ifdevice.trx_end_func = NULL; + } + } + + sleep(1); //allow lte-softmodem threads to exit first + exit(1); +} + +// Fixme: there are many mistakes in the datamodel and in redondant variables +// TDD is also mode complex +void setAllfromTS(uint64_t TS, L1_rxtx_proc_t *proc) { + for (int i=0; i < RC.nb_inst; i++) { + for (int j=0; jframe_parms; + uint64_t TStx=TS+(sf_ahead)*fp->samples_per_tti; + uint64_t TSrach=TS;//-fp->samples_per_tti; + proc->timestamp_rx= TS; + proc->timestamp_tx= TStx; + proc->subframe_rx= (TS / fp->samples_per_tti)%10; + proc->subframe_prach=(TSrach / fp->samples_per_tti)%10; + proc->subframe_prach_br=(TSrach / fp->samples_per_tti)%10; + proc->frame_rx= (TS / (fp->samples_per_tti*10))&1023; + proc->frame_prach= (TSrach / (fp->samples_per_tti*10))&1023; + proc->frame_prach_br=(TSrach / (fp->samples_per_tti*10))&1023; + proc->frame_tx= (TStx / (fp->samples_per_tti*10))&1023; + proc->subframe_tx= (TStx / fp->samples_per_tti)%10; + } + } + + return; +} + +void init_RU_proc(RU_t *ru) { + pthread_t t; + + switch(split73) { + case SPLIT73_CU: + threadCreate(&t, cu_fs6, (void *)ru, "MainCu", -1, OAI_PRIORITY_RT_MAX); + break; + case SPLIT73_DU: + threadCreate(&t, du_fs6, (void *)ru, "MainDuRx", -1, OAI_PRIORITY_RT_MAX); + break; + default: + threadCreate(&t, ru_thread, (void *)ru, "MainRu", -1, OAI_PRIORITY_RT_MAX); + } +} + +// Create per UE structures +void init_transport(PHY_VARS_eNB *eNB) { + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + LOG_I(PHY, "Initialise transport\n"); + + for (int i=0; idlsch[i][j] = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL,0,fp)) != NULL, + "Can't get eNB dlsch structures for UE %d \n", i); + eNB->dlsch[i][j]->rnti=0; + LOG_D(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,eNB->dlsch[i][j], eNB->dlsch[i][j]->rnti); + } + + LOG_D(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i); + AssertFatal((eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0)) != NULL, + "Can't get eNB ulsch structures\n"); + // this is the transmission mode for the signalling channels + // this will be overwritten with the real transmission mode by the RRC once the UE is connected + eNB->transmission_mode[i] = fp->nb_antenna_ports_eNB==1 ? 1 : 2; + } + + // ULSCH for RA + AssertFatal( (eNB->ulsch[0] = new_eNB_ulsch(MAX_TURBO_ITERATIONS, fp->N_RB_UL, 0)) !=NULL, + "Can't get eNB ulsch structures\n"); + eNB->dlsch_SI = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp); + LOG_D(PHY,"eNB %d.%d : SI %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_SI); + eNB->dlsch_ra = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp); + LOG_D(PHY,"eNB %d.%d : RA %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_ra); + eNB->dlsch_MCH = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp); + LOG_D(PHY,"eNB %d.%d : MCH %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_MCH); + eNB->rx_total_gain_dB=130; + + for(int i=0; imu_mimo_mode[i].dl_pow_off = 2; + + eNB->check_for_total_transmissions = 0; + eNB->check_for_MUMIMO_transmissions = 0; + eNB->FULL_MUMIMO_transmissions = 0; + eNB->check_for_SUMIMO_transmissions = 0; + fp->pucch_config_common.deltaPUCCH_Shift = 1; +} + +void init_eNB_afterRU(void) { + for (int inst=0; instframe_parms.nb_antennas_rx = 0; + eNB->frame_parms.nb_antennas_tx = 0; + eNB->prach_vars.rxsigF[0] = (int16_t **)malloc16(64*sizeof(int16_t *)); + + for (int ce_level=0; ce_level<4; ce_level++) { + eNB->prach_vars_br.rxsigF[ce_level] = (int16_t **)malloc16(64*sizeof(int16_t *)); + } + + for (int ru_id=0,aa=0; ru_idnum_RU; ru_id++) { + eNB->frame_parms.nb_antennas_rx += eNB->RU_list[ru_id]->nb_rx; + eNB->frame_parms.nb_antennas_tx += eNB->RU_list[ru_id]->nb_tx; + AssertFatal(eNB->RU_list[ru_id]->common.rxdataF!=NULL, + "RU %d : common.rxdataF is NULL\n", + eNB->RU_list[ru_id]->idx); + AssertFatal(eNB->RU_list[ru_id]->prach_rxsigF!=NULL, + "RU %d : prach_rxsigF is NULL\n", + eNB->RU_list[ru_id]->idx); + + for (int i=0; iRU_list[ru_id]->nb_rx; aa++,i++) { + LOG_I(PHY,"Attaching RU %d antenna %d to eNB antenna %d\n",eNB->RU_list[ru_id]->idx,i,aa); + eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[ru_id]->prach_rxsigF[i]; + + for (int ce_level=0; ce_level<4; ce_level++) + eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[ru_id]->prach_rxsigF_br[ce_level][i]; + + eNB->common_vars.rxdataF[aa] = eNB->RU_list[ru_id]->common.rxdataF[i]; + } + } + + AssertFatal( eNB->frame_parms.nb_antennas_rx > 0 && eNB->frame_parms.nb_antennas_rx < 4, ""); + AssertFatal( eNB->frame_parms.nb_antennas_tx > 0 && eNB->frame_parms.nb_antennas_rx < 4, ""); + LOG_I(PHY,"inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,eNB->frame_parms.nb_antennas_rx); + init_transport(eNB); + //init_precoding_weights(RC.eNB[inst][CC_id]); + } + } +} + +void init_eNB(int single_thread_flag,int wait_for_sync) { + AssertFatal(RC.eNB != NULL,"RC.eNB must have been allocated\n"); + + for (int inst=0; instabstraction_flag = 0; + eNB->single_thread_flag = single_thread_flag; + AssertFatal((eNB->if_inst = IF_Module_init(inst))!=NULL,"Cannot register interface"); + eNB->if_inst->schedule_response = schedule_response; + eNB->if_inst->PHY_config_req = phy_config_request; + memset((void *)&eNB->UL_INFO,0,sizeof(eNB->UL_INFO)); + memset((void *)&eNB->Sched_INFO,0,sizeof(eNB->Sched_INFO)); + pthread_mutex_init( &eNB->UL_INFO_mutex, NULL); + LOG_I(PHY,"Setting indication lists\n"); + eNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list = eNB->rx_pdu_list; + eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list = eNB->crc_pdu_list; + eNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = eNB->sr_pdu_list; + eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = eNB->harq_pdu_list; + eNB->UL_INFO.cqi_ind.cqi_indication_body.cqi_pdu_list = eNB->cqi_pdu_list; + eNB->UL_INFO.cqi_ind.cqi_indication_body.cqi_raw_pdu_list = eNB->cqi_raw_pdu_list; + eNB->prach_energy_counter = 0; + } + } + + SET_LOG_DEBUG(PRACH); +} + +void stop_eNB(int nb_inst) { + for (int inst=0; instframe_parms; + openair0_config_t *cfg = &ru->openair0_cfg; + //printf("////////////////numerology in config = %d\n",numerology); + int numerology = get_softmodem_params()->numerology; + + if(fp->N_RB_DL == 100) { + if(numerology == 0) { + if (fp->threequarter_fs) { + cfg->sample_rate=23.04e6; + cfg->samples_per_frame = 230400; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } else { + cfg->sample_rate=30.72e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + } else if(numerology == 1) { + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 20e6; + cfg->rx_bw = 20e6; + } else if(numerology == 2) { + cfg->sample_rate=122.88e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; + } else { + LOG_E(PHY,"Wrong input for numerology %d\n setting to 20MHz normal CP configuration",numerology); + cfg->sample_rate=30.72e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + } else if(fp->N_RB_DL == 50) { + cfg->sample_rate=15.36e6; + cfg->samples_per_frame = 153600; + cfg->tx_bw = 5e6; + cfg->rx_bw = 5e6; + } else if (fp->N_RB_DL == 25) { + cfg->sample_rate=7.68e6; + cfg->samples_per_frame = 76800; + cfg->tx_bw = 2.5e6; + cfg->rx_bw = 2.5e6; + } else if (fp->N_RB_DL == 6) { + cfg->sample_rate=1.92e6; + cfg->samples_per_frame = 19200; + cfg->tx_bw = 1.5e6; + cfg->rx_bw = 1.5e6; + } else AssertFatal(1==0,"Unknown N_RB_DL %d\n",fp->N_RB_DL); + + if (fp->frame_type==TDD) + cfg->duplex_mode = duplex_mode_TDD; + else //FDD + cfg->duplex_mode = duplex_mode_FDD; + + cfg->Mod_id = 0; + cfg->num_rb_dl=fp->N_RB_DL; + cfg->tx_num_channels=ru->nb_tx; + cfg->rx_num_channels=ru->nb_rx; + cfg->clock_source=get_softmodem_params()->clock_source; + + for (i=0; inb_tx; i++) { + cfg->tx_freq[i] = (double)fp->dl_CarrierFreq; + cfg->rx_freq[i] = (double)fp->ul_CarrierFreq; + cfg->tx_gain[i] = (double)ru->att_tx; + cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx; + cfg->configFilename = rf_config_file; + LOG_I(PHY,"channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", + i, cfg->tx_gain[i], + cfg->rx_gain[i], + cfg->tx_freq[i], + cfg->rx_freq[i]); + } +} + +/* this function maps the RU tx and rx buffers to the available rf chains. + Each rf chain is is addressed by the card number and the chain on the card. The + rf_map specifies for each antenna port, on which rf chain the mapping should start. Multiple + antennas are mapped to successive RF chains on the same card. */ +int setup_RU_buffers(RU_t *ru) { + //uint16_t N_TA_offset = 0; + LTE_DL_FRAME_PARMS *frame_parms; + AssertFatal(ru, "ru is NULL"); + frame_parms = ru->frame_parms; + LOG_I(PHY,"setup_RU_buffers: frame_parms = %p\n",frame_parms); + + if (frame_parms->frame_type == TDD) { + if (frame_parms->N_RB_DL == 100) { + ru->N_TA_offset = 624; + } else if (frame_parms->N_RB_DL == 50) { + ru->N_TA_offset = 624/2; + ru->sf_extension /= 2; + ru->end_of_burst_delay /= 2; + } else if (frame_parms->N_RB_DL == 25) { + ru->N_TA_offset = 624/4; + ru->sf_extension /= 4; + ru->end_of_burst_delay /= 4; + } else { + LOG_E(PHY,"not handled, todo\n"); + exit(1); + } + } else { + ru->N_TA_offset = 0; + ru->sf_extension = 0; + ru->end_of_burst_delay = 0; + } + + return(0); +} + +void init_precoding_weights(PHY_VARS_eNB *eNB) { + int layer,ru_id,aa,re,ue,tb; + LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; + RU_t *ru; + LTE_eNB_DLSCH_t *dlsch; + + // init precoding weigths + for (ue=0; uedlsch[ue][tb]; + + for (layer=0; layer<4; layer++) { + int nb_tx=0; + + for (ru_id=0; ru_idnb_tx; + } + + dlsch->ue_spec_bf_weights[layer] = (int32_t **)malloc16(nb_tx*sizeof(int32_t *)); + + for (aa=0; aaue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(fp->ofdm_symbol_size*sizeof(int32_t)); + + for (re=0; reofdm_symbol_size; re++) { + dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff; + } + } + } + } + } +} + +void ocp_rx_prach(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, + RU_t *ru, + uint16_t *max_preamble, + uint16_t *max_preamble_energy, + uint16_t *max_preamble_delay, + uint16_t *avg_preamble_energy, + uint16_t Nf, + uint8_t tdd_mapindex, + uint8_t br_flag) { + int i; + int prach_mask=0; + + if (br_flag == 0) { + rx_prach0(eNB,ru,proc->frame_prach, proc->subframe_prach, + max_preamble,max_preamble_energy,max_preamble_delay,avg_preamble_energy,Nf,tdd_mapindex,0,0); + } else { // This is procedure for eMTC, basically handling the repetitions + prach_mask = is_prach_subframe(&eNB->frame_parms,proc->frame_prach_br,proc->subframe_prach_br); + + for (i=0; i<4; i++) { + if ((eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i]==1) && + ((prach_mask&(1<<(i+1))) > 0)) { // check that prach CE level is active now + + // if first reception in group of repetitions store frame for later (in RA-RNTI for Msg2) + if (eNB->prach_vars_br.repetition_number[i]==0) eNB->prach_vars_br.first_frame[i]=proc->frame_prach_br; + + // increment repetition number + eNB->prach_vars_br.repetition_number[i]++; + // do basic PRACH reception + rx_prach0(eNB,ru,proc->frame_prach, proc->subframe_prach_br, + max_preamble,max_preamble_energy,max_preamble_delay,avg_preamble_energy,Nf,tdd_mapindex,1,i); + + // if last repetition, clear counter + if (eNB->prach_vars_br.repetition_number[i] == eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[i]) { + eNB->prach_vars_br.repetition_number[i]=0; + } + } + } /* for i ... */ + } /* else br_flag == 0 */ +} + +void prach_procedures_ocp(PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, int br_flag) { + uint16_t max_preamble[4],max_preamble_energy[4],max_preamble_delay[4],avg_preamble_energy[4]; + RU_t *ru; + int aa=0; + int ru_aa; + + for (int i=0; inum_RU; i++) { + ru=eNB->RU_list[i]; + + for (ru_aa=0,aa=0; ru_aanb_rx; ru_aa++,aa++) { + eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[i]->prach_rxsigF[ru_aa]; + int ce_level; + + if (br_flag==1) + for (ce_level=0; ce_level<4; ce_level++) + eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[i]->prach_rxsigF_br[ce_level][ru_aa]; + } + } + + // run PRACH detection for CE-level 0 only for now when br_flag is set + ocp_rx_prach(eNB, + proc, + eNB->RU_list[0], + &max_preamble[0], + &max_preamble_energy[0], + &max_preamble_delay[0], + &avg_preamble_energy[0], + proc->frame_prach, + 0 + ,br_flag + ); + LOG_D(PHY,"RACH detection index 0: max preamble: %u, energy: %u, delay: %u, avg energy: %u\n", + max_preamble[0], + max_preamble_energy[0], + max_preamble_delay[0], + avg_preamble_energy[0] + ); + + if (br_flag==1) { + int prach_mask; + prach_mask = is_prach_subframe (&eNB->frame_parms, proc->frame_prach_br, proc->subframe_prach_br); + eNB->UL_INFO.rach_ind_br.rach_indication_body.preamble_list = eNB->preamble_list_br; + int ind = 0; + int ce_level = 0; + /* Save for later, it doesn't work + for (int ind=0,ce_level=0;ce_level<4;ce_level++) { + + if ((eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[ce_level]==1)&& + (prach_mask&(1<<(1+ce_level)) > 0) && // prach is active and CE level has finished its repetitions + (eNB->prach_vars_br.repetition_number[ce_level]== + eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level])) { + + */ + + if (eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0] == 1) { + if ((eNB->prach_energy_counter == 100) && (max_preamble_energy[0] > eNB->measurements.prach_I0 + eNB->prach_DTX_threshold_emtc[0])) { + eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles++; + eNB->preamble_list_br[ind].preamble_rel8.timing_advance = max_preamble_delay[ind]; // + eNB->preamble_list_br[ind].preamble_rel8.preamble = max_preamble[ind]; + // note: fid is implicitly 0 here, this is the rule for eMTC RA-RNTI from 36.321, Section 5.1.4 + eNB->preamble_list_br[ind].preamble_rel8.rnti = 1 + proc->subframe_prach + (60*(eNB->prach_vars_br.first_frame[ce_level] % 40)); + eNB->preamble_list_br[ind].instance_length = 0; //don't know exactly what this is + eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type = 1 + ce_level; // CE Level + LOG_I (PHY, "Filling NFAPI indication for RACH %d CELevel %d (mask %x) : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", + ind, + ce_level, + prach_mask, + eNB->preamble_list_br[ind].preamble_rel8.timing_advance, + eNB->preamble_list_br[ind].preamble_rel8.preamble, eNB->preamble_list_br[ind].preamble_rel8.rnti, eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type); + } + } + + /* + ind++; + } + } */// ce_level + } else if ((eNB->prach_energy_counter == 100) && + (max_preamble_energy[0] > eNB->measurements.prach_I0+eNB->prach_DTX_threshold)) { + LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n", + eNB->Mod_id, + eNB->CC_id, + proc->frame_prach, + proc->subframe_prach, + max_preamble[0], + max_preamble_energy[0]/10, + max_preamble_energy[0]%10, + max_preamble_delay[0]); + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 1; + eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = &eNB->preamble_list[0]; + eNB->UL_INFO.rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; + eNB->UL_INFO.rach_ind.header.message_id = NFAPI_RACH_INDICATION; + eNB->UL_INFO.rach_ind.sfn_sf = proc->frame_prach<<4 | proc->subframe_prach; + eNB->preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; + eNB->preamble_list[0].preamble_rel8.timing_advance = max_preamble_delay[0]; + eNB->preamble_list[0].preamble_rel8.preamble = max_preamble[0]; + eNB->preamble_list[0].preamble_rel8.rnti = 1+proc->subframe_prach; // note: fid is implicitly 0 here + eNB->preamble_list[0].preamble_rel13.rach_resource_type = 0; + eNB->preamble_list[0].instance_length = 0; //don't know exactly what this is + + if (NFAPI_MODE==NFAPI_MODE_PNF) { // If NFAPI PNF then we need to send the message to the VNF + LOG_D(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", + NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), + eNB->preamble_list[0].preamble_rel8.timing_advance, + eNB->preamble_list[0].preamble_rel8.preamble, + eNB->preamble_list[0].preamble_rel8.rnti, + eNB->preamble_list[0].preamble_rel13.rach_resource_type); + oai_nfapi_rach_ind(&eNB->UL_INFO.rach_ind); + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 0; + } + + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + } // max_preamble_energy > prach_I0 + 100 + else { + eNB->measurements.prach_I0 = ((eNB->measurements.prach_I0*900)>>10) + ((avg_preamble_energy[0]*124)>>10); + + if (eNB->prach_energy_counter < 100) + eNB->prach_energy_counter++; + } +} // else br_flag + +void prach_eNB(PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, int frame,int subframe) { + // check if we have to detect PRACH first + if (is_prach_subframe(&eNB->frame_parms, frame,subframe)>0) { + prach_procedures_ocp(eNB, proc, 0); + prach_procedures_ocp(eNB, proc, 1); + } +} + +static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name) { + AssertFatal( eNB !=NULL, ""); + + if (NFAPI_MODE==NFAPI_MODE_PNF) { + // I am a PNF and I need to let nFAPI know that we have a (sub)frame tick + //add_subframe(&frame, &subframe, 4); + //oai_subframe_ind(proc->frame_tx, proc->subframe_tx); + oai_subframe_ind(proc->frame_rx, proc->subframe_rx); + } + + AssertFatal( !(NFAPI_MODE==NFAPI_MODE_PNF && + eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0), ""); + prach_eNB(eNB,proc,proc->frame_rx,proc->subframe_rx); + release_UE_in_freeList(eNB->Mod_id); + + // UE-specific RX processing for subframe n + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { + phy_procedures_eNB_uespec_RX(eNB, proc); + } + + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.frame = proc->frame_rx; + eNB->UL_INFO.subframe = proc->subframe_rx; + eNB->UL_INFO.module_id = eNB->Mod_id; + eNB->UL_INFO.CC_id = eNB->CC_id; + eNB->if_inst->UL_indication(&eNB->UL_INFO, proc); + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + phy_procedures_eNB_TX(eNB, proc, 1); + return(0); +} + +void rx_rf(RU_t *ru, L1_rxtx_proc_t *proc) { + LTE_DL_FRAME_PARMS *fp = ru->frame_parms; + void *rxp[ru->nb_rx]; + unsigned int rxs; + int i; + openair0_timestamp ts=0, timestamp_rx; + static openair0_timestamp old_ts=0; + + for (i=0; inb_rx; i++) + //receive in the next slot + rxp[i] = (void *)&ru->common.rxdata[i][((proc->subframe_rx+1)%10)*fp->samples_per_tti]; + + rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, + &ts, + rxp, + fp->samples_per_tti, + ru->nb_rx); + timestamp_rx = ts-ru->ts_offset; + + // AssertFatal(rxs == fp->samples_per_tti, + // "rx_rf: Asked for %d samples, got %d from SDR\n",fp->samples_per_tti,rxs); + if(rxs != fp->samples_per_tti) { + LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from SDR\n",fp->samples_per_tti,rxs); +#if defined(USRP_REC_PLAY) + exit_fun("Exiting IQ record/playback"); +#else + //exit_fun( "problem receiving samples" ); + LOG_E(PHY, "problem receiving samples"); +#endif + } + + if (old_ts != 0 && timestamp_rx - old_ts != fp->samples_per_tti) { + LOG_E(HW,"impossible shift in rx stream, rx: %ld, previous rx distance: %ld, should be %d\n", timestamp_rx, proc->timestamp_rx - old_ts, fp->samples_per_tti); + //ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); + //proc->timestamp_rx = ts-ru->ts_offset; + } + + old_ts=timestamp_rx; + setAllfromTS(timestamp_rx, proc); +} + +void ocp_tx_rf(RU_t *ru, L1_rxtx_proc_t *proc) { + LTE_DL_FRAME_PARMS *fp = ru->frame_parms; + void *txp[ru->nb_tx]; + int i; + lte_subframe_t SF_type = subframe_select(fp,proc->subframe_tx%10); + lte_subframe_t prevSF_type = subframe_select(fp,(proc->subframe_tx+9)%10); + int sf_extension = 0; + + if ((SF_type == SF_DL) || + (SF_type == SF_S)) { + int siglen=fp->samples_per_tti,flags=1; + + if (SF_type == SF_S) { + /* end_of_burst_delay is used to stop TX only "after a while". + * If we stop right after effective signal, with USRP B210 and + * B200mini, we observe a high EVM on the S subframe (on the + * PSS). + * A value of 400 (for 30.72MHz) solves this issue. This is + * the default. + */ + siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + + (fp->dl_symbols_in_S_subframe - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples) + + ru->end_of_burst_delay; + flags=3; // end of burst + } + + if (fp->frame_type == TDD && + SF_type == SF_DL && + prevSF_type == SF_UL) { + flags = 2; // start of burst + sf_extension = ru->sf_extension; + } + +#if defined(__x86_64) || defined(__i386__) +#ifdef __AVX2__ + sf_extension = (sf_extension)&0xfffffff8; +#else + sf_extension = (sf_extension)&0xfffffffc; +#endif +#elif defined(__arm__) + sf_extension = (sf_extension)&0xfffffffc; +#endif + + for (i=0; inb_tx; i++) + txp[i] = (void *)&ru->common.txdata[i][(proc->subframe_tx*fp->samples_per_tti)-sf_extension]; + + /* add fail safe for late command end */ + // prepare tx buffer pointers + ru->rfdevice.trx_write_func(&ru->rfdevice, + proc->timestamp_tx+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, + txp, + siglen+sf_extension, + ru->nb_tx, + flags); + LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, subframe %d\n",ru->idx, + (long long unsigned int)proc->timestamp_tx,proc->frame_tx,proc->subframe_tx); + } + + return; +} + +static void *ru_thread( void *param ) { + setbuf(stdout, NULL); + setbuf(stderr, NULL); + RU_t *ru = (RU_t *)param; + L1_rxtx_proc_t L1proc= {0}; + // We pick the global thread pool from the legacy code global vars + L1proc.threadPool=RC.eNB[0][0]->proc.L1_proc.threadPool; + L1proc.respEncode=RC.eNB[0][0]->proc.L1_proc.respEncode; + L1proc.respDecode=RC.eNB[0][0]->proc.L1_proc.respDecode; + + if (ru->if_south == LOCAL_RF) { // configure RF parameters only + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(ru->frame_parms,1); + phy_init_RU(ru); + init_rf(ru); + } + + AssertFatal(setup_RU_buffers(ru)==0, "Exiting, cannot initialize RU Buffers\n"); + LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); + wait_sync("ru_thread"); + + // Start RF device if any + if (ru->rfdevice.trx_start_func(&ru->rfdevice) != 0) + LOG_E(HW,"Could not start the RF device\n"); + else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); + + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + while (!oai_exit) { + // synchronization on input FH interface, acquire signals/data and block + rx_rf(ru, &L1proc); + // do RX front-end processing (frequency-shift, dft) if needed + fep_full(ru, L1proc.subframe_rx); + + // At this point, all information for subframe has been received on FH interface + // If this proc is to provide synchronization, do so + // Fixme: not used + // wakeup_slaves(proc); + for (int i=0; inum_eNB; i++) { + char string[20]; + sprintf(string,"Incoming RU %d",ru->idx); + + if (rxtx(ru->eNB_list[i],&L1proc,string) < 0) + LOG_E(PHY,"eNB %d CC_id %d failed during execution\n", + ru->eNB_list[i]->Mod_id,ru->eNB_list[i]->CC_id); + } + + // do TX front-end processing if needed (precoding and/or IDFTs) + feptx_prec(ru, L1proc.frame_tx, L1proc.subframe_tx); + // do OFDM if needed + feptx_ofdm(ru, L1proc.frame_tx, L1proc.subframe_tx); + // do outgoing fronthaul (south) if needed + ocp_tx_rf(ru, &L1proc); + } + + LOG_W(PHY,"Exiting ru_thread \n"); + ru->rfdevice.trx_end_func(&ru->rfdevice); + LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); + return NULL; +} + +int init_rf(RU_t *ru) { + char name[256]; + pthread_getname_np(pthread_self(),name, 255); + pthread_setname_np(pthread_self(),"UHD for OAI"); + int ret=openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + pthread_setname_np(pthread_self(),name); + return ret; +} + +void init_RU(char *rf_config_file, clock_source_t clock_source,clock_source_t time_source,int send_dmrssync) { + RU_t *ru; + PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; + int i; + int CC_id; + // read in configuration file) + LOG_I(PHY,"configuring RU from file\n"); + LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n", + RC.nb_L1_inst,RC.nb_RU,get_nprocs()); + + if (RC.nb_CC != 0) + for (i=0; inum_RU=0; + + LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); + + for (int ru_id=0; ru_idrf_config_file = rf_config_file; + ru->idx = ru_id; + ru->ts_offset = 0; + + if (ru->is_slave == 1) { + ru->in_synch = 0; + ru->generate_dmrs_sync = 0; + } else { + ru->in_synch = 1; + ru->generate_dmrs_sync=send_dmrssync; + } + + ru->cmd = EMPTY; + ru->south_out_cnt= 0; + // use eNB_list[0] as a reference for RU frame parameters + // NOTE: multiple CC_id are not handled here yet! + ru->openair0_cfg.clock_source = clock_source; + ru->openair0_cfg.time_source = time_source; + + // ru->generate_dmrs_sync = (ru->is_slave == 0) ? 1 : 0; + if (ru->generate_dmrs_sync == 1) { + generate_ul_ref_sigs(); + ru->dmrssync = (int16_t *)malloc16_clear(ru->frame_parms->ofdm_symbol_size*2*sizeof(int16_t)); + } + + ru->wakeup_L1_sleeptime = 2000; + ru->wakeup_L1_sleep_cnt_max = 3; + + if (ru->num_eNB > 0) { + LOG_D(PHY, "%s() RC.ru[%d].num_eNB:%d ru->eNB_list[0]:%p RC.eNB[0][0]:%p rf_config_file:%s\n", + __FUNCTION__, ru_id, ru->num_eNB, ru->eNB_list[0], RC.eNB[0][0], ru->rf_config_file); + AssertFatal(ru->eNB_list[0], "ru->eNB_list is not initialized\n"); + } else { + LOG_E(PHY,"Wrong data model, assigning eNB 0, carrier 0 to RU 0\n"); + ru->eNB_list[0] = RC.eNB[0][0]; + ru->num_eNB=1; + } + + eNB0 = ru->eNB_list[0]; + // datamodel error in regular OAI: a RU uses one single eNB carrier parameters! + ru->frame_parms = &eNB0->frame_parms; + + for (i=0; inum_eNB; i++) { + eNB0 = ru->eNB_list[i]; + int ruIndex=eNB0->num_RU++; + eNB0->RU_list[ruIndex] = ru; + } + } // for ru_id +} + +void stop_RU(int nb_ru) { + for (int inst = 0; inst < nb_ru; inst++) { + LOG_I(PHY, "Stopping RU %d processing threads\n", inst); + kill_RU_proc(RC.ru[inst]); + } +} + +/* --------------------------------------------------------*/ +/* from here function to use configuration module */ +static int DEFBFW[] = {0x00007fff}; +void RCconfig_RU(void) { + paramdef_t RUParams[] = RUPARAMS_DESC; + paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; + config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL); + + if ( RUParamList.numelt == 0 ) { + LOG_W(PHY, "Calling RCconfig_RU while no ru\n"); + RC.nb_RU = 0; + return; + } // setting != NULL + + if ( RC.ru != NULL ) { + LOG_W(PHY, "Calling RCconfig_RU twice (nb ru=%d), ignoring the second call data structure is %p\n", + RUParamList.numelt,RC.ru); + return; + } + + RC.ru = (RU_t **)malloc(RC.nb_RU*sizeof(RU_t *)); + + for (int j = 0; j < RC.nb_RU; j++) { + RC.ru[j] = (RU_t *)calloc(sizeof(RU_t), 1); + RC.ru[j]->idx = j; + LOG_I(PHY,"Creating RC.ru[%d]:%p\n", j, RC.ru[j]); + RC.ru[j]->if_timing = synch_to_ext_device; + paramdef_t *vals=RUParamList.paramarray[j]; + + if (RC.nb_L1_inst >0) + RC.ru[j]->num_eNB = vals[RU_ENB_LIST_IDX].numelt; + else + RC.ru[j]->num_eNB = 0; + + for (int i=0; inum_eNB; i++) + RC.ru[j]->eNB_list[i] = RC.eNB[vals[RU_ENB_LIST_IDX].iptr[i]][0]; + + if (config_isparamset(vals, RU_SDR_ADDRS)) { + RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(vals[RU_SDR_ADDRS].strptr)); + } + + if (config_isparamset(vals, RU_SDR_CLK_SRC)) { + char *paramVal=*(vals[RU_SDR_CLK_SRC].strptr); + LOG_D(PHY, "RU clock source set as %s\n", paramVal); + + if (strcmp(paramVal, "internal") == 0) { + RC.ru[j]->openair0_cfg.clock_source = internal; + } else if (strcmp(paramVal, "external") == 0) { + RC.ru[j]->openair0_cfg.clock_source = external; + } else if (strcmp(paramVal, "gpsdo") == 0) { + RC.ru[j]->openair0_cfg.clock_source = gpsdo; + } else { + LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", paramVal); + } + } + + if (strcmp(*(vals[RU_LOCAL_RF_IDX].strptr), "yes") == 0) { + if ( !(config_isparamset(vals,RU_LOCAL_IF_NAME_IDX)) ) { + RC.ru[j]->if_south = LOCAL_RF; + RC.ru[j]->function = eNodeB_3GPP; + LOG_I(PHY, "Setting function for RU %d to eNodeB_3GPP\n",j); + } else { + RC.ru[j]->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); + RC.ru[j]->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); + RC.ru[j]->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); + RC.ru[j]->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); + RC.ru[j]->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); + RC.ru[j]->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); + RC.ru[j]->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); + } + + RC.ru[j]->max_pdschReferenceSignalPower = *(vals[RU_MAX_RS_EPRE_IDX].uptr);; + RC.ru[j]->max_rxgain = *(vals[RU_MAX_RXGAIN_IDX].uptr); + RC.ru[j]->num_bands = vals[RU_BAND_LIST_IDX].numelt; + /* sf_extension is in unit of samples for 30.72MHz here, has to be scaled later */ + RC.ru[j]->sf_extension = *(vals[RU_SF_EXTENSION_IDX].uptr); + RC.ru[j]->end_of_burst_delay = *(vals[RU_END_OF_BURST_DELAY_IDX].uptr); + + for (int i=0; inum_bands; i++) RC.ru[j]->band[i] = vals[RU_BAND_LIST_IDX].iptr[i]; + } else { + LOG_I(PHY,"RU %d: Transport %s\n",j,*(vals[RU_TRANSPORT_PREFERENCE_IDX].strptr)); + RC.ru[j]->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); + RC.ru[j]->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); + RC.ru[j]->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); + RC.ru[j]->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); + RC.ru[j]->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); + RC.ru[j]->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); + RC.ru[j]->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); + } /* strcmp(local_rf, "yes") != 0 */ + + RC.ru[j]->nb_tx = *(vals[RU_NB_TX_IDX].uptr); + RC.ru[j]->nb_rx = *(vals[RU_NB_RX_IDX].uptr); + RC.ru[j]->att_tx = *(vals[RU_ATT_TX_IDX].uptr); + RC.ru[j]->att_rx = *(vals[RU_ATT_RX_IDX].uptr); + }// j=0..num_rus + + return; +} + + +static void get_options(void) { + CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); + get_common_options(SOFTMODEM_ENB_BIT); + CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); + + if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) { + memset((void *)&RC,0,sizeof(RC)); + /* Read RC configuration file */ + RCConfig(); + NB_eNB_INST = RC.nb_inst; + printf("Configuration: nb_rrc_inst %d, nb_L1_inst %d, nb_ru %d\n",NB_eNB_INST,RC.nb_L1_inst,RC.nb_RU); + + if (!IS_SOFTMODEM_NONBIOT) { + load_NB_IoT(); + printf(" nb_nbiot_rrc_inst %d, nb_nbiot_L1_inst %d, nb_nbiot_macrlc_inst %d\n", + RC.nb_nb_iot_rrc_inst, RC.nb_nb_iot_L1_inst, RC.nb_nb_iot_macrlc_inst); + } else { + printf("All Nb-IoT instances disabled\n"); + RC.nb_nb_iot_rrc_inst=RC.nb_nb_iot_L1_inst=RC.nb_nb_iot_macrlc_inst=0; + } + } +} + +void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { + int CC_id; + + for (CC_id=0; CC_idframe_type = FDD; + frame_parms[CC_id]->tdd_config = 3; + frame_parms[CC_id]->tdd_config_S = 0; + frame_parms[CC_id]->N_RB_DL = 100; + frame_parms[CC_id]->N_RB_UL = 100; + frame_parms[CC_id]->Ncp = NORMAL; + frame_parms[CC_id]->Ncp_UL = NORMAL; + frame_parms[CC_id]->Nid_cell = 0; + frame_parms[CC_id]->num_MBSFN_config = 0; + frame_parms[CC_id]->nb_antenna_ports_eNB = 1; + frame_parms[CC_id]->nb_antennas_tx = 1; + frame_parms[CC_id]->nb_antennas_rx = 1; + frame_parms[CC_id]->nushift = 0; + frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; + frame_parms[CC_id]->phich_config_common.phich_duration = normal; + // UL RS Config + frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = 0;//n_DMRS1 set to 0 + frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0; + frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; + frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; + frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; + // downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. + // downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; + // downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; + // downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; + //printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); + frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0]; + } +} + +void init_pdcp(void) { + if (!NODE_IS_DU(RC.rrc[0]->node_type)) { + pdcp_layer_init(); + uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? + (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; + + if (IS_SOFTMODEM_NOS1) + pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; + + pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_W_MBMS_BIT; + + if ( split73!=SPLIT73_DU) + pdcp_module_init(pdcp_initmask); + + if (NODE_IS_CU(RC.rrc[0]->node_type)) { + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + } else { + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + } + } else { + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + } +} + +static void wait_nfapi_init(char *thread_name) { + printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); + pthread_mutex_lock( &nfapi_sync_mutex ); + + while (nfapi_sync_var<0) + pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex ); + + pthread_mutex_unlock(&nfapi_sync_mutex); + printf( "NFAPI: got sync (%s)\n", thread_name); +} + +void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) { + LOG_I(ENB_APP, "sending TERMINATE_MESSAGE from task %s (%d) to task %s (%d)\n", + itti_get_task_name(from), from, itti_get_task_name(to), to); + MessageDef *msg; + msg = itti_alloc_new_message (from, TERMINATE_MESSAGE); + itti_send_msg_to_task (to, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg); +} + +int stop_L1L2(module_id_t enb_id) { + LOG_W(ENB_APP, "stopping lte-softmodem\n"); + + if (!RC.ru) { + LOG_UI(ENB_APP, "no RU configured\n"); + return -1; + } + + /* these tasks need to pick up new configuration */ + terminate_task(enb_id, TASK_ENB_APP, TASK_RRC_ENB); + oai_exit = 1; + LOG_I(ENB_APP, "calling kill_RU_proc() for instance %d\n", enb_id); + kill_RU_proc(RC.ru[enb_id]); + LOG_I(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id); + kill_eNB_proc(enb_id); + oai_exit = 0; + + for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) { + free_transport(RC.eNB[enb_id][cc_id]); + phy_free_lte_eNB(RC.eNB[enb_id][cc_id]); + } + + phy_free_RU(RC.ru[enb_id]); + free_lte_top(); + return 0; +} + +/* + * Restart the lte-softmodem after it has been soft-stopped with stop_L1L2() + */ +int restart_L1L2(module_id_t enb_id) { + RU_t *ru = RC.ru[enb_id]; + MessageDef *msg_p = NULL; + LOG_W(ENB_APP, "restarting lte-softmodem\n"); + /* block threads */ + pthread_mutex_lock(&sync_mutex); + sync_var = -1; + pthread_mutex_unlock(&sync_mutex); + RC.ru_mask |= (1 << ru->idx); + /* copy the changed frame parameters to the RU */ + /* TODO this should be done for all RUs associated to this eNB */ + memcpy(&ru->frame_parms, &RC.eNB[enb_id][0]->frame_parms, sizeof(LTE_DL_FRAME_PARMS)); + /* reset the list of connected UEs in the MAC, since in this process with + * loose all UEs (have to reconnect) */ + init_UE_list(&RC.mac[enb_id]->UE_list); + LOG_I(ENB_APP, "attempting to create ITTI tasks\n"); + // No more rrc thread, as many race conditions are hidden behind + rrc_enb_init(); + itti_mark_task_ready(TASK_RRC_ENB); + /* pass a reconfiguration request which will configure everything down to + * RC.eNB[i][j]->frame_parms, too */ + msg_p = itti_alloc_new_message(TASK_ENB_APP, RRC_CONFIGURATION_REQ); + RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration; + itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); + /* TODO XForms might need to be restarted, but it is currently (09/02/18) + * broken, so we cannot test it */ + init_RU_proc(ru); + ru->rf_map.card = 0; + ru->rf_map.chain = 0; /* CC_id + chain_offset;*/ + init_eNB_afterRU(); + printf("Sending sync to all threads\n"); + pthread_mutex_lock(&sync_mutex); + sync_var=0; + pthread_cond_broadcast(&sync_cond); + pthread_mutex_unlock(&sync_mutex); + return 0; +} + +int main ( int argc, char **argv ) { + int i; + int CC_id = 0; + int node_type = ngran_eNB; + AssertFatal(load_configmodule(argc,argv,0), "[SOFTMODEM] Error, configuration module init failed\n"); + logInit(); + printf("Reading in command-line options\n"); + get_options (); + AssertFatal(!CONFIG_ISFLAGSET(CONFIG_ABORT),"Getting configuration failed\n"); + EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; +#if T_TRACER + T_Config_Init(); +#endif + configure_linux(); + cpuf=get_cpu_freq_GHz(); + set_taus_seed (0); + + if (opp_enabled ==1) + reset_opp_meas(); + + itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); + init_opt(); +#ifndef PACKAGE_VERSION +# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" +#endif + LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); + + /* Read configuration */ + if (RC.nb_inst > 0) { + // Allocate memory from RC variable + read_config_and_init(); + } else { + printf("RC.nb_inst = 0, Initializing L1\n"); + RCconfig_L1(); + } + + /* We need to read RU configuration before FlexRAN starts so it knows what + * splits to report. Actual RU start comes later. */ + if (RC.nb_RU > 0 && NFAPI_MODE != NFAPI_MODE_VNF) { + RCconfig_RU(); + LOG_I(PHY, + "number of L1 instances %d, number of RU %d, number of CPU cores %d\n", + RC.nb_L1_inst, RC.nb_RU, get_nprocs()); + } + + if ( strlen(get_softmodem_params()->split73) > 0 ) { + char tmp[1024]={0}; + strncpy(tmp,get_softmodem_params()->split73, 1023); + tmp[2]=0; + if ( strncasecmp(tmp,"cu", 2)==0 ) + split73=SPLIT73_CU; + else if ( strncasecmp(tmp,"du", 2)==0 ) + split73=SPLIT73_DU; + else + AssertFatal(false,"split73 syntax: :[:] (string found: %s) \n",get_softmodem_params()->split73); + } + + if (RC.nb_inst > 0) { + /* Start the agent. If it is turned off in the configuration, it won't start */ + for (i = 0; i < RC.nb_inst; i++) { + flexran_agent_start(i); + } + + /* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks + * for monolithic/F1 modes */ + init_pdcp(); + AssertFatal(create_tasks(1)==0,"cannot create ITTI tasks\n"); + + for (int enb_id = 0; enb_id < RC.nb_inst; enb_id++) { + MessageDef *msg_p = itti_alloc_new_message (TASK_ENB_APP, RRC_CONFIGURATION_REQ); + RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration; + itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); + } + + node_type = RC.rrc[0]->node_type; + } + + if (RC.nb_inst > 0 && NODE_IS_CU(node_type)) { + protocol_ctxt_t ctxt; + ctxt.module_id = 0 ; + ctxt.instance = 0; + ctxt.rnti = 0; + ctxt.enb_flag = 1; + ctxt.frame = 0; + ctxt.subframe = 0; + pdcp_run(&ctxt); + } + + /* start threads if only L1 or not a CU */ + if (RC.nb_inst == 0 || !NODE_IS_CU(node_type) || NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) { + // init UE_PF_PO and mutex lock + pthread_mutex_init(&ue_pf_po_mutex, NULL); + memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs); + pthread_cond_init(&sync_cond,NULL); + pthread_mutex_init(&sync_mutex, NULL); + + if (NFAPI_MODE!=NFAPI_MONOLITHIC) { + LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); + pthread_cond_init(&sync_cond,NULL); + pthread_mutex_init(&sync_mutex, NULL); + } + + if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF +#if defined(PRE_SCD_THREAD) + init_ru_vnf(); // ru pointer is necessary for pre_scd. +#endif + wait_nfapi_init("main?"); + } + + LOG_I(ENB_APP,"START MAIN THREADS\n"); + // start the main threads + number_of_cards = 1; + printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); + + if (RC.nb_L1_inst > 0) { + printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", + get_softmodem_params()->single_thread_flag, + get_softmodem_params()->wait_for_sync); + init_eNB(get_softmodem_params()->single_thread_flag, + get_softmodem_params()->wait_for_sync); + } + + for (int x=0; x < RC.nb_L1_inst; x++) + for (int CC_id=0; CC_idproc.L1_proc; + L1proc->threadPool=(tpool_t *)malloc(sizeof(tpool_t)); + L1proc->respEncode=(notifiedFIFO_t *) malloc(sizeof(notifiedFIFO_t)); + L1proc->respDecode=(notifiedFIFO_t *) malloc(sizeof(notifiedFIFO_t)); + + if ( strlen(get_softmodem_params()->threadPoolConfig) > 0 ) + initTpool(get_softmodem_params()->threadPoolConfig, L1proc->threadPool, true); + else + initTpool("n", L1proc->threadPool, true); + + initNotifiedFIFO(L1proc->respEncode); + initNotifiedFIFO(L1proc->respDecode); + } + } + + printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); + + // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. + // but RU thread deals with pre_scd and this is necessary in VNF and simulator. + // some initialization is necessary and init_ru_vnf do this. + if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { + printf("Initializing RU threads\n"); + init_RU(get_softmodem_params()->rf_config_file, + get_softmodem_params()->clock_source, + get_softmodem_params()->timing_source, + get_softmodem_params()->send_dmrs_sync); + + for (int ru_id=0; ru_idrf_map.card=0; + RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); + LOG_I(PHY,"Starting ru_thread %d\n",ru_id); + init_RU_proc(RC.ru[ru_id]); + } + + config_sync_var=0; + + if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF + wait_nfapi_init("main?"); + } + + LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU); + // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) + printf("ALL RUs ready - init eNBs\n"); + + if (NFAPI_MODE!=NFAPI_MODE_PNF && NFAPI_MODE!=NFAPI_MODE_VNF) { + LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n"); + init_eNB_afterRU(); + } else { + LOG_I(ENB_APP,"NFAPI mode - DO NOT call init_eNB_afterRU()\n"); + } + + LOG_UI(ENB_APP,"ALL RUs ready - ALL eNBs ready\n"); + // connect the TX/RX buffers + sleep(1); /* wait for thread activation */ + LOG_I(ENB_APP,"Sending sync to all threads\n"); + pthread_mutex_lock(&sync_mutex); + sync_var=0; + pthread_cond_broadcast(&sync_cond); + pthread_mutex_unlock(&sync_mutex); + config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS); + } + + create_tasks_mbms(1); + // wait for end of program + LOG_UI(ENB_APP,"TYPE TO TERMINATE\n"); + // CI -- Flushing the std outputs for the previous marker to show on the eNB / DU / CU log file + fflush(stdout); + fflush(stderr); + + // end of CI modifications + //getchar(); + if(IS_SOFTMODEM_DOFORMS) + load_softscope("enb"); + + itti_wait_tasks_end(); + oai_exit=1; + LOG_I(ENB_APP,"oai_exit=%d\n",oai_exit); + // stop threads + + if (RC.nb_inst == 0 || !NODE_IS_CU(node_type)) { + if(IS_SOFTMODEM_DOFORMS) + end_forms(); + + LOG_I(ENB_APP,"stopping MODEM threads\n"); + stop_eNB(NB_eNB_INST); + stop_RU(RC.nb_RU); + + /* release memory used by the RU/eNB threads (incomplete), after all + * threads have been stopped (they partially use the same memory) */ + for (int inst = 0; inst < NB_eNB_INST; inst++) { + for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) { + free_transport(RC.eNB[inst][cc_id]); + phy_free_lte_eNB(RC.eNB[inst][cc_id]); + } + } + + for (int inst = 0; inst < RC.nb_RU; inst++) { + phy_free_RU(RC.ru[inst]); + } + + free_lte_top(); + end_configmodule(); + pthread_cond_destroy(&sync_cond); + pthread_mutex_destroy(&sync_mutex); + pthread_cond_destroy(&nfapi_sync_cond); + pthread_mutex_destroy(&nfapi_sync_mutex); + pthread_mutex_destroy(&ue_pf_po_mutex); + + for(int ru_id=0; ru_idrfdevice.trx_end_func) { + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + RC.ru[ru_id]->rfdevice.trx_end_func = NULL; + } + + if (RC.ru[ru_id]->ifdevice.trx_end_func) { + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + RC.ru[ru_id]->ifdevice.trx_end_func = NULL; + } + } + } + + terminate_opt(); + logClean(); + printf("Bye.\n"); + return 0; +} diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index fc012b0ab2..d8f119061e 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -178,14 +178,14 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t // **************************************** // Common RX procedures subframe n T(T_GNB_PHY_DL_TICK, T_INT(gNB->Mod_id), T_INT(frame_tx), T_INT(slot_tx)); -/* - // if this is IF5 or 3GPP_gNB - if (gNB && gNB->RU_list && gNB->RU_list[0] && gNB->RU_list[0]->function < NGFI_RAU_IF4p5) { - wakeup_prach_gNB(gNB,NULL,proc->frame_rx,proc->slot_rx); - } + /* + // if this is IF5 or 3GPP_gNB + if (gNB && gNB->RU_list && gNB->RU_list[0] && gNB->RU_list[0]->function < NGFI_RAU_IF4p5) { + wakeup_prach_gNB(gNB,NULL,proc->frame_rx,proc->slot_rx); + } - // UE-specific RX processing for subframe n - if (nfapi_mode == 0 || nfapi_mode == 1) */ + // UE-specific RX processing for subframe n + if (nfapi_mode == 0 || nfapi_mode == 1) */ pthread_mutex_lock(&gNB->UL_INFO_mutex); gNB->UL_INFO.frame = frame_rx; @@ -205,8 +205,8 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t if (oai_exit) return(-1); - //if (slot_rx == NR_UPLINK_SLOT || gNB->frame_parms.frame_type == FDD) - phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx); + //if (slot_rx == NR_UPLINK_SLOT || gNB->frame_parms.frame_type == FDD) + phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx); if(get_thread_parallel_conf() != PARALLEL_RU_L1_TRX_SPLIT) { phy_procedures_gNB_TX(gNB, frame_tx,slot_tx, 1); @@ -316,7 +316,7 @@ static void *gNB_L1_thread( void *param ) { gNB_L1_rxtx_proc_t *L1_proc = &gNB_proc->L1_proc; //PHY_VARS_gNB *gNB = RC.gNB[0][proc->CC_id]; char thread_name[100]; - + // set default return value // set default return value gNB_thread_rxtx_status = 0; @@ -412,7 +412,7 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot int waitret = 0, ret = 0, time_ns = 1000*1000; struct timespec now, abstime; - + // note this should depend on the numerology used by the TX L1 thread, set here for 500us slot time // note this should depend on the numerology used by the TX L1 thread, set here for 500us slot time VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL,1); time_ns = time_ns/gNB->frame_parms.slots_per_subframe; @@ -434,27 +434,27 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL,0); if (waitret == ETIMEDOUT) { - LOG_W(PHY,"Dropping TX slot (%d.%d) because FH is blocked more than 1 slot times (500us)\n",frame_tx,slot_tx); + LOG_W(PHY,"Dropping TX slot (%d.%d) because FH is blocked more than 1 slot times (500us)\n",frame_tx,slot_tx); - AssertFatal((ret=pthread_mutex_lock(&gNB->proc.mutex_RU_tx))==0,"mutex_lock returns %d\n",ret); - gNB->proc.RU_mask_tx = 0; - AssertFatal((ret=pthread_mutex_unlock(&gNB->proc.mutex_RU_tx))==0,"mutex_unlock returns %d\n",ret); - AssertFatal((ret=pthread_mutex_lock(&proc->mutex_RUs_tx))==0,"mutex_lock returns %d\n",ret); - proc->instance_cnt_RUs = 0; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,proc->instance_cnt_RUs); - AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_RUs_tx))==0,"mutex_unlock returns %d\n",ret); + AssertFatal((ret=pthread_mutex_lock(&gNB->proc.mutex_RU_tx))==0,"mutex_lock returns %d\n",ret); + gNB->proc.RU_mask_tx = 0; + AssertFatal((ret=pthread_mutex_unlock(&gNB->proc.mutex_RU_tx))==0,"mutex_unlock returns %d\n",ret); + AssertFatal((ret=pthread_mutex_lock(&proc->mutex_RUs_tx))==0,"mutex_lock returns %d\n",ret); + proc->instance_cnt_RUs = 0; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,proc->instance_cnt_RUs); + AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_RUs_tx))==0,"mutex_unlock returns %d\n",ret); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_UE,1); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_UE,0); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_UE,1); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_UE,0); + + return(-1); + } - return(-1); - } - for(int i=0; inum_RU; i++) { ru = gNB->RU_list[i]; ru_proc = &ru->proc; - + if (ru_proc->instance_cnt_gNBs == 0) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST_UE, 1); @@ -475,10 +475,10 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_UE, ru_proc->instance_cnt_gNBs); - LOG_D(PHY,"Signaling tx_thread_fh for %d.%d\n",frame_tx,slot_tx); + LOG_D(PHY,"Signaling tx_thread_fh for %d.%d\n",frame_tx,slot_tx); // the thread can now be woken up AssertFatal(pthread_cond_signal(&ru_proc->cond_gNBs) == 0, - "[gNB] ERROR pthread_cond_signal for gNB TXnp4 thread\n"); + "[gNB] ERROR pthread_cond_signal for gNB TXnp4 thread\n"); AssertFatal((ret=pthread_mutex_unlock(&ru_proc->mutex_gNBs))==0,"mutex_unlock returned %d\n",ret); } @@ -496,7 +496,7 @@ int wakeup_tx(PHY_VARS_gNB *gNB,int frame_rx,int slot_rx,int frame_tx,int slot_t AssertFatal((ret = pthread_mutex_lock(&L1_proc_tx->mutex))==0,"mutex_lock returns %d\n",ret); - while(L1_proc_tx->instance_cnt == 0){ + while(L1_proc_tx->instance_cnt == 0) { pthread_cond_wait(&L1_proc_tx->cond,&L1_proc_tx->mutex); } @@ -512,7 +512,7 @@ int wakeup_tx(PHY_VARS_gNB *gNB,int frame_rx,int slot_rx,int frame_tx,int slot_t VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_UE,1); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_UE,0); - + // the thread can now be woken up // the thread can now be woken up AssertFatal(pthread_cond_signal(&L1_proc_tx->cond) == 0, "ERROR pthread_cond_signal for gNB L1 thread\n"); @@ -532,11 +532,11 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) { int time_ns = 50000; AssertFatal((ret=pthread_mutex_lock(&proc->mutex_RU))==0,"mutex_lock returns %d\n",ret); - for (i=0;inum_RU;i++) { + for (i=0; inum_RU; i++) { if (ru == gNB->RU_list[i]) { if ((proc->RU_mask&(1< 0) - LOG_E(PHY,"gNB %d frame %d, subframe %d : previous information from RU %d (num_RU %d,mask %x) has not been served yet!\n", - gNB->Mod_id,proc->frame_rx,proc->slot_rx,ru->idx,gNB->num_RU,proc->RU_mask); + LOG_E(PHY,"gNB %d frame %d, subframe %d : previous information from RU %d (num_RU %d,mask %x) has not been served yet!\n", + gNB->Mod_id,proc->frame_rx,proc->slot_rx,ru->idx,gNB->num_RU,proc->RU_mask); proc->RU_mask |= (1<mutex, &abstime)) == 0,"mutex_lock returns %d\n", ret); if (L1_proc->instance_cnt == 0) { // L1_thread is busy so abort the subframe - AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"muex_unlock return %d\n",ret); - LOG_W(PHY,"L1_thread isn't ready in %d.%d, aborting RX processing\n",ru_proc->frame_rx,ru_proc->tti_rx); - return(-1); + AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"muex_unlock return %d\n",ret); + LOG_W(PHY,"L1_thread isn't ready in %d.%d, aborting RX processing\n",ru_proc->frame_rx,ru_proc->tti_rx); + return(-1); } - + ++L1_proc->instance_cnt; - - // We have just received and processed the common part of a subframe, say n. - // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired + // We have just received and processed the common part of a subframe, say n. + // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired // transmitted timestamp of the next TX slot (first). - // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, + // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, // we want to generate subframe (n+sl_ahead), so TS_tx = TX_rx+sl_ahead*samples_per_tti, // and proc->slot_tx = proc->slot_rx+sl_ahead + // and proc->slot_tx = proc->slot_rx+sl_ahead L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sl_ahead*fp->samples_per_slot); L1_proc->frame_rx = ru_proc->frame_rx; L1_proc->slot_rx = ru_proc->tti_rx; @@ -592,7 +592,7 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) { exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - + return(0); } /* @@ -696,9 +696,9 @@ static void* gNB_thread_prach( void* param ) { extern void init_td_thread(PHY_VARS_gNB *); extern void init_te_thread(PHY_VARS_gNB *); -static void* process_stats_thread(void* param) { +static void *process_stats_thread(void *param) { - PHY_VARS_gNB *gNB = (PHY_VARS_gNB*)param; + PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param; reset_meas(&gNB->dlsch_encoding_stats); reset_meas(&gNB->dlsch_scrambling_stats); @@ -902,7 +902,7 @@ void init_eNB_afterRU(void) { for (i=0; iRU_list[ru_id]->nb_rx; aa++,i++) { LOG_I(PHY,"Attaching RU %d antenna %d to gNB antenna %d\n",gNB->RU_list[ru_id]->idx,i,aa); - // gNB->prach_vars.rxsigF[0][aa] = gNB->RU_list[ru_id]->prach_rxsigF[i]; + // gNB->prach_vars.rxsigF[0][aa] = gNB->RU_list[ru_id]->prach_rxsigF[i]; gNB->common_vars.rxdataF[aa] = gNB->RU_list[ru_id]->common.rxdataF[i]; } } diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 0003cf770d..05ae216d00 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -92,7 +92,7 @@ unsigned short config_frames[4] = {2,9,11,13}; static int DEFBANDS[] = {7}; static int DEFENBS[] = {0}; static int DEFBFW[] = {0x00007fff}; - + //static int DEFNRBANDS[] = {7}; //static int DEFGNBS[] = {0}; @@ -712,7 +712,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { } -void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { +void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { RU_proc_t *proc = &ru->proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; //nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config; @@ -758,7 +758,7 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, slot ); - for (i=0; inb_tx; i++){ + for (i=0; inb_tx; i++) { txp[i] = (void *)&ru->common.txdata[i][(slot*fp->samples_per_slot)-sf_extension]; } @@ -870,7 +870,7 @@ static void *ru_thread_prach( void *param ) { 0,0 ); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 0 );*/ + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 0 );*/ if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"ru_prach_thread") < 0) break; } @@ -1097,16 +1097,16 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { } } else if(N_RB == 106) { if (fp->threequarter_fs) { - cfg->sample_rate=46.08e6; - cfg->samples_per_frame = 460800; - cfg->tx_bw = 40e6; - cfg->rx_bw = 40e6; + cfg->sample_rate=46.08e6; + cfg->samples_per_frame = 460800; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; } else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 40e6; - cfg->rx_bw = 40e6; + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 614400; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; } } else { AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu); @@ -1210,7 +1210,7 @@ static void *ru_stats_thread(void *param) { if (ru->feprx) print_meas(&ru->ofdm_demod_stats,"feprx",NULL,NULL); - if (ru->feptx_ofdm){ + if (ru->feptx_ofdm) { print_meas(&ru->precoding_stats,"feptx_prec",NULL,NULL); print_meas(&ru->txdataF_copy_stats,"txdataF_copy",NULL,NULL); print_meas(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL); @@ -1219,7 +1219,7 @@ static void *ru_stats_thread(void *param) { if (ru->fh_north_asynch_in) print_meas(&ru->rx_fhaul,"rx_fhaul",NULL,NULL); - print_meas(&ru->tx_fhaul,"tx_fhaul",NULL,NULL); + print_meas(&ru->tx_fhaul,"tx_fhaul",NULL,NULL); if (ru->fh_north_out) { print_meas(&ru->compression,"compression",NULL,NULL); print_meas(&ru->transport,"transport",NULL,NULL); @@ -1346,7 +1346,7 @@ static void *ru_thread_tx( void *param ) { if (L1_proc->instance_cnt_RUs == -1) { L1_proc->instance_cnt_RUs = 0; AssertFatal(pthread_cond_signal(&L1_proc->cond_RUs) == 0, - "ERROR pthread_cond_signal for gNB_L1_thread\n"); + "ERROR pthread_cond_signal for gNB_L1_thread\n"); } //else AssertFatal(1==0,"gNB TX thread is not ready\n"); ret = pthread_mutex_unlock(&L1_proc->mutex_RUs_tx); AssertFatal(ret == 0,"mutex_unlock returns %d\n",ret); @@ -1371,7 +1371,7 @@ static void *ru_thread( void *param ) { int print_frame = 8; int i = 0; int aa; - + // set default return value // set default return value ru_thread_status = 0; // set default return value @@ -1499,9 +1499,9 @@ static void *ru_thread( void *param ) { LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx); LOG_D(PHY,"Copying rxdataF from RU to gNB\n"); - for (aa=0;aanb_rx;aa++) - memcpy((void*)RC.gNB[0][0]->common_vars.rxdataF[aa], - (void*)ru->common.rxdataF[aa], fp->symbols_per_slot*fp->ofdm_symbol_size*sizeof(int32_t)); + for (aa=0; aanb_rx; aa++) + memcpy((void *)RC.gNB[0][0]->common_vars.rxdataF[aa], + (void *)ru->common.rxdataF[aa], fp->symbols_per_slot*fp->ofdm_symbol_size*sizeof(int32_t)); // At this point, all information for subframe has been received on FH interface @@ -2260,7 +2260,7 @@ void RCconfig_RU(void) } } else { - RC.ru[j]->openair0_cfg.clock_source = unset; + RC.ru[j]->openair0_cfg.clock_source = unset; } if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index df6c48d866..012b42f767 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -107,7 +107,7 @@ static int wait_for_sync = 0; unsigned int mmapped_dma=0; int single_thread_flag=1; -static int8_t threequarter_fs=0; +int8_t threequarter_fs=0; uint32_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; @@ -170,6 +170,10 @@ uint32_t target_ul_mcs = 20; uint32_t timing_advance = 0; uint64_t num_missed_slots=0; // counter for the number of missed slots +int split73=0; +void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { + AssertFatal(false, "Must not be called in this context\n"); +} extern void reset_opp_meas(void); extern void print_opp_meas(void); @@ -713,13 +717,9 @@ int restart_L1L2(module_id_t gnb_id) { memcpy(&ru->nr_frame_parms, &RC.gNB[gnb_id][0]->frame_parms, sizeof(NR_DL_FRAME_PARMS)); set_function_spec_param(RC.ru[gnb_id]); LOG_I(GNB_APP, "attempting to create ITTI tasks\n"); - - if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) { - LOG_E(RRC, "Create task for RRC eNB failed\n"); - return -1; - } else { - LOG_I(RRC, "Re-created task for RRC gNB successfully\n"); - } + // No more rrc thread, as many race conditions are hidden behind + rrc_enb_init(); + itti_mark_task_ready(TASK_RRC_ENB); if (itti_create_task (TASK_L2L1, l2l1_task, NULL) < 0) { LOG_E(PDCP, "Create task for L2L1 failed\n"); @@ -762,23 +762,23 @@ static void wait_nfapi_init(char *thread_name) { void init_pdcp(void) { //if (!NODE_IS_DU(RC.rrc[0]->node_type)) { - pdcp_layer_init(); - uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? - (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; + pdcp_layer_init(); + uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? + (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; - if (IS_SOFTMODEM_NOS1){ - printf("IS_SOFTMODEM_NOS1 option enabled \n"); - pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; - } + if (IS_SOFTMODEM_NOS1) { + printf("IS_SOFTMODEM_NOS1 option enabled \n"); + pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; + } - pdcp_module_init(pdcp_initmask); + pdcp_module_init(pdcp_initmask); - /*if (NODE_IS_CU(RC.rrc[0]->node_type)) { - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); - } else {*/ - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); - //} + /*if (NODE_IS_CU(RC.rrc[0]->node_type)) { + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + } else {*/ + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + //} /*} else { pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); }*/ @@ -831,7 +831,7 @@ int main( int argc, char **argv ) MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); -init_opt(); + init_opt(); #ifdef PDCP_USE_NETLINK @@ -848,7 +848,7 @@ if(!IS_SOFTMODEM_NOS1) LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); if(IS_SOFTMODEM_NOS1) - init_pdcp(); + init_pdcp(); if (RC.nb_nr_inst > 0) { // don't create if node doesn't connect to RRC/S1/GTP @@ -871,37 +871,37 @@ if(!IS_SOFTMODEM_NOS1) mlockall(MCL_CURRENT | MCL_FUTURE); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); -/*#ifdef XFORMS - int UE_id; + /*#ifdef XFORMS + int UE_id; - if (do_forms==1) { - fl_initialize (&argc, argv, NULL, 0, 0); - form_stats_l2 = create_form_stats_form(); - fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); - form_stats = create_form_stats_form(); - fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); + if (do_forms==1) { + fl_initialize (&argc, argv, NULL, 0, 0); + form_stats_l2 = create_form_stats_form(); + fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); + form_stats = create_form_stats_form(); + fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - for(UE_id=0; UE_idphy_scope_gnb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + for(UE_id=0; UE_idphy_scope_gnb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - if (otg_enabled) { - fl_set_button(form_gnb[CC_id][UE_id]->button_0,1); - fl_set_object_label(form_gnb[CC_id][UE_id]->button_0,"DL Traffic ON"); - } else { - fl_set_button(form_gnb[CC_id][UE_id]->button_0,0); - fl_set_object_label(form_gnb[CC_id][UE_id]->button_0,"DL Traffic OFF"); - } - } // CC_id - } // UE_id + if (otg_enabled) { + fl_set_button(form_gnb[CC_id][UE_id]->button_0,1); + fl_set_object_label(form_gnb[CC_id][UE_id]->button_0,"DL Traffic ON"); + } else { + fl_set_button(form_gnb[CC_id][UE_id]->button_0,0); + fl_set_object_label(form_gnb[CC_id][UE_id]->button_0,"DL Traffic OFF"); + } + } // CC_id + } // UE_id - threadCreate(&forms_thread, scope_thread, NULL, "scope", -1, OAI_PRIORITY_RT_LOW); - printf("Scope thread created, ret=%d\n",ret); - } + threadCreate(&forms_thread, scope_thread, NULL, "scope", -1, OAI_PRIORITY_RT_LOW); + printf("Scope thread created, ret=%d\n",ret); + } -#endif*/ + #endif*/ usleep(10*1000); if (nfapi_mode) { @@ -999,27 +999,27 @@ if(!IS_SOFTMODEM_NOS1) printf("oai_exit=%d\n",oai_exit); // stop threads -/*#ifdef XFORMS + /*#ifdef XFORMS - printf("waiting for XFORMS thread\n"); + printf("waiting for XFORMS thread\n"); - if (do_forms==1) { - pthread_join(forms_thread,&status); - fl_hide_form(form_stats->stats_form); - fl_free_form(form_stats->stats_form); + if (do_forms==1) { + pthread_join(forms_thread,&status); + fl_hide_form(form_stats->stats_form); + fl_free_form(form_stats->stats_form); - fl_hide_form(form_stats_l2->stats_form); - fl_free_form(form_stats_l2->stats_form); + fl_hide_form(form_stats_l2->stats_form); + fl_free_form(form_stats_l2->stats_form); - for(UE_id=0; UE_idphy_scope_gNB); - fl_free_form(form_enb[CC_id][UE_id]->phy_scope_gNB); - } - } - } + for(UE_id=0; UE_idphy_scope_gNB); + fl_free_form(form_enb[CC_id][UE_id]->phy_scope_gNB); + } + } + } -#endif*/ + #endif*/ printf("stopping MODEM threads\n"); // cleanup stop_gNB(NB_gNB_INST); diff --git a/executables/nr-ue.c b/executables/nr-ue.c index b4af0f68ea..767f258817 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -148,7 +148,7 @@ PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, ue->Mod_id = UE_id; ue->mac_enabled = 1; - + // initialize all signal buffers // initialize all signal buffers init_nr_ue_signal(ue,1,abstraction_flag); // intialize transport @@ -380,7 +380,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { scheduled_response.CC_id = 0; scheduled_response.frame = proc->frame_rx; scheduled_response.slot = proc->nr_tti_rx; - + //--------------------------Temporary configuration-----------------------------// //--------------------------Temporary configuration-----------------------------// n_rnti = 0x1234; nb_rb = 50; @@ -391,7 +391,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { mcs = 9; harq_pid = 0; rvidx = 0; - //------------------------------------------------------------------------------// + //------------------------------------------------------------------------------// scheduled_response.ul_config->sfn_slot = NR_UPLINK_SLOT; scheduled_response.ul_config->number_pdus = 1; @@ -426,7 +426,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { } } - + // no UL for now // no UL for now /* if (UE->mac_enabled==1) { @@ -464,7 +464,7 @@ void UE_processing(void *arg) { PHY_VARS_NR_UE *UE = rxtxD->UE; processSlotRX(UE, proc); uint8_t gNB_id = 0; - + // params for UL time alignment procedure // params for UL time alignment procedure NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &UE->ul_time_alignment[gNB_id]; uint8_t numerology = UE->frame_parms.numerology_index; @@ -474,24 +474,24 @@ void UE_processing(void *arg) { //printf(">>> mac ended\n"); // Prepare the future Tx data -/* -#ifndef NO_RAT_NR + /* + #ifndef NO_RAT_NR - if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_UPLINK_SLOT) -#else - if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || - (UE->frame_parms.frame_type == FDD) ) -#endif -*/ + if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_UPLINK_SLOT) + #else + if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || + (UE->frame_parms.frame_type == FDD) ) + #endif + */ /* UL time alignment // If the current tx frame and slot match the TA configuration in ul_time_alignment // then timing advance is processed and set to be applied in the next UL transmission */ if (UE->mac_enabled == 1) { - if (frame_tx == ul_time_alignment->ta_frame && slot_tx == ul_time_alignment->ta_slot){ + if (frame_tx == ul_time_alignment->ta_frame && slot_tx == ul_time_alignment->ta_slot) { LOG_D(PHY,"Applying timing advance -- frame %d -- slot %d\n", frame_tx, slot_tx); - + //if (nfapi_mode!=3){ //if (nfapi_mode!=3){ nr_process_timing_advance(UE->Mod_id, UE->CC_id, ul_time_alignment->ta_command, numerology, bwp_ul_NB_RB); ul_time_alignment->ta_frame = -1; @@ -500,7 +500,7 @@ void UE_processing(void *arg) { } } - if (proc->nr_tti_tx == NR_UPLINK_SLOT || UE->frame_parms.frame_type == FDD){ + if (proc->nr_tti_tx == NR_UPLINK_SLOT || UE->frame_parms.frame_type == FDD) { thread_id = PHY_vars_UE_g[UE->Mod_id][0]->current_thread_id[proc->nr_tti_tx]; @@ -565,7 +565,7 @@ void trashFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { UE->frame_parms.samples_per_subframe, UE->frame_parms.nb_antennas_rx); if (IS_SOFTMODEM_RFSIM ) { - usleep(1000); // slow down, as would do actual rf to let cpu for the synchro thread + usleep(1000); // slow down, as would do actual rf to let cpu for the synchro thread } } @@ -578,24 +578,24 @@ void trashFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { - LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); - void *dummy_tx[UE->frame_parms.nb_antennas_tx]; + LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); + void *dummy_tx[UE->frame_parms.nb_antennas_tx]; - for (int i=0; iframe_parms.nb_antennas_tx; i++) - dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_subframe*4); + for (int i=0; iframe_parms.nb_antennas_tx; i++) + dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_subframe*4); - for ( int size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_subframe ) { - int unitTransfer=size>UE->frame_parms.samples_per_subframe ? UE->frame_parms.samples_per_subframe : size ; - AssertFatal(unitTransfer == - UE->rfdevice.trx_read_func(&UE->rfdevice, - timestamp, - (void **)UE->common_vars.rxdata, - unitTransfer, - UE->frame_parms.nb_antennas_rx),""); - } + for ( int size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_subframe ) { + int unitTransfer=size>UE->frame_parms.samples_per_subframe ? UE->frame_parms.samples_per_subframe : size ; + AssertFatal(unitTransfer == + UE->rfdevice.trx_read_func(&UE->rfdevice, + timestamp, + (void **)UE->common_vars.rxdata, + unitTransfer, + UE->frame_parms.nb_antennas_rx),""); + } - for (int i=0; iframe_parms.nb_antennas_tx; i++) - free(dummy_tx[i]); + for (int i=0; iframe_parms.nb_antennas_tx; i++) + free(dummy_tx[i]); } @@ -726,7 +726,7 @@ void *UE_thread(void *arg) { #ifdef OAI_ADRV9371_ZC706 /*uint32_t total_gain_dB_prev = 0; if (total_gain_dB_prev != UE->rx_total_gain_dB) { - total_gain_dB_prev = UE->rx_total_gain_dB; + total_gain_dB_prev = UE->rx_total_gain_dB; openair0_cfg[0].rx_gain[0] = UE->rx_total_gain_dB; UE->rfdevice.trx_set_gains_func(&UE->rfdevice,&openair0_cfg[0]); }*/ @@ -762,29 +762,29 @@ void *UE_thread(void *arg) { readBlockSize, UE->frame_parms.nb_antennas_rx),""); -if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX - 1)%20) - AssertFatal( writeBlockSize == - UE->rfdevice.trx_write_func(&UE->rfdevice, - timestamp+ - (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) - - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - - openair0_cfg[0].tx_sample_advance, - txp, - writeBlockSize, - UE->frame_parms.nb_antennas_tx, - 2),""); + if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX - 1)%20) + AssertFatal( writeBlockSize == + UE->rfdevice.trx_write_func(&UE->rfdevice, + timestamp+ + (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) - + UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - + openair0_cfg[0].tx_sample_advance, + txp, + writeBlockSize, + UE->frame_parms.nb_antennas_tx, + 2),""); -if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX)%20) - AssertFatal( writeBlockSize == - UE->rfdevice.trx_write_func(&UE->rfdevice, - timestamp+ - (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) - - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - - openair0_cfg[0].tx_sample_advance, - txp, - writeBlockSize, - UE->frame_parms.nb_antennas_tx, - 3),""); + if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX)%20) + AssertFatal( writeBlockSize == + UE->rfdevice.trx_write_func(&UE->rfdevice, + timestamp+ + (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) - + UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - + openair0_cfg[0].tx_sample_advance, + txp, + writeBlockSize, + UE->frame_parms.nb_antennas_tx, + 3),""); if( slot_nr==(nb_slot_frame-1)) { // read in first symbol of next frame and adjust for timing drift diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index e0cb380365..3efa8d098c 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -215,7 +215,7 @@ int emulate_rf = 0; tpool_t *Tpool; #ifdef UE_DLSCH_PARALLELISATION -tpool_t *Tpool_dl; + tpool_t *Tpool_dl; #endif @@ -309,8 +309,8 @@ static void *scope_thread(void *arg) { while (!oai_exit) { phy_scope_nrUE(form_nrue[0], - PHY_vars_UE_g[0][0], - 0,0,1); + PHY_vars_UE_g[0][0], + 0,0,1); usleep(100*1000); } @@ -381,9 +381,9 @@ static void get_options(void) { int tddflag=0, nonbiotflag, vcdflag=0; char *loopfile=NULL; int dumpframe=0; - //uint32_t noS1; //uint32_t nokrnmod; + //uint32_t nokrnmod; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC_UE ; config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); @@ -510,12 +510,12 @@ void init_openair0(void) { else { openair0_cfg[card].sample_rate=122.88e6; openair0_cfg[card].samples_per_frame = 1228800; - } + } } else { LOG_E(PHY,"Unsupported numerology!\n"); exit(-1); } - }else if(frame_parms[0]->N_RB_DL == 273) { + } else if(frame_parms[0]->N_RB_DL == 273) { if (numerology==1) { if (frame_parms[0]->threequarter_fs) { AssertFatal(0 == 1,"three quarter sampling not supported for N_RB 273\n"); @@ -523,12 +523,12 @@ void init_openair0(void) { else { openair0_cfg[card].sample_rate=122.88e6; openair0_cfg[card].samples_per_frame = 1228800; - } + } } else { LOG_E(PHY,"Unsupported numerology!\n"); exit(-1); } - }else if(frame_parms[0]->N_RB_DL == 106) { + } else if(frame_parms[0]->N_RB_DL == 106) { if (numerology==0) { if (frame_parms[0]->threequarter_fs) { openair0_cfg[card].sample_rate=23.04e6; @@ -537,15 +537,15 @@ void init_openair0(void) { openair0_cfg[card].sample_rate=30.72e6; openair0_cfg[card].samples_per_frame = 307200; } - } else if (numerology==1) { + } else if (numerology==1) { if (frame_parms[0]->threequarter_fs) { - openair0_cfg[card].sample_rate=46.08e6; - openair0_cfg[card].samples_per_frame = 460800; + openair0_cfg[card].sample_rate=46.08e6; + openair0_cfg[card].samples_per_frame = 460800; } else { - openair0_cfg[card].sample_rate=61.44e6; - openair0_cfg[card].samples_per_frame = 614400; - } + openair0_cfg[card].sample_rate=61.44e6; + openair0_cfg[card].samples_per_frame = 614400; + } } else if (numerology==2) { openair0_cfg[card].sample_rate=122.88e6; openair0_cfg[card].samples_per_frame = 1228800; @@ -620,7 +620,7 @@ void init_pdcp(void) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; /*if (rlc_module_init() != 0) { - LOG_I(RLC, "Problem at RLC initiation \n"); + LOG_I(RLC, "Problem at RLC initiation \n"); } pdcp_layer_init(); nr_ip_over_LTE_DRB_preconfiguration();*/ @@ -630,6 +630,11 @@ void init_pdcp(void) { LOG_I(PDCP, "Before getting out from init_pdcp() \n"); } +// Stupid function addition because UE itti messages queues definition is common with eNB +void *rrc_enb_process_itti_msg(void *notUsed) { + return NULL; +} + int main( int argc, char **argv ) { //uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; @@ -657,12 +662,12 @@ int main( int argc, char **argv ) { set_taus_seed (0); tpool_t pool; Tpool = &pool; - char params[]="-1,-1"; + char params[]="-1,-1"; initTpool(params, Tpool, false); #ifdef UE_DLSCH_PARALLELISATION tpool_t pool_dl; Tpool_dl = &pool_dl; - char params_dl[]="-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1"; + char params_dl[]="-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"; initTpool(params_dl, Tpool_dl, false); #endif cpuf=get_cpu_freq_GHz(); @@ -670,21 +675,21 @@ int main( int argc, char **argv ) { init_opt() ; if(IS_SOFTMODEM_NOS1) - init_pdcp(); + init_pdcp(); if (ouput_vcd) { vcd_signal_dumper_init("/tmp/openair_dump_nrUE.vcd"); } -/* -#ifdef PDCP_USE_NETLINK - netlink_init(); -#if defined(PDCP_USE_NETLINK_QUEUES) - pdcp_netlink_init(); -#endif -#endif -*/ - #ifndef PACKAGE_VERSION + /* + #ifdef PDCP_USE_NETLINK + netlink_init(); + #if defined(PDCP_USE_NETLINK_QUEUES) + pdcp_netlink_init(); + #endif + #endif + */ +#ifndef PACKAGE_VERSION # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" #endif LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c new file mode 100644 index 0000000000..a28c9732ea --- /dev/null +++ b/executables/ocp-gnb.c @@ -0,0 +1,1011 @@ +/* + * Author: Laurent Thomas, Open Cells Project + * all rights reserved + */ + +#define _GNU_SOURCE +#include +#include "assertions.h" +#include +#include + +#include "PHY/types.h" + +#include "PHY/INIT/phy_init.h" + +#include "PHY/defs_gNB.h" +#include "SCHED/sched_eNB.h" +#include "SCHED_NR/sched_nr.h" +#include "SCHED_NR/fapi_nr_l1.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "../../ARCH/COMMON/common_lib.h" + +#include "PHY/phy_extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" +#include "common/utils/LOG/log_extern.h" +#include "UTIL/OTG/otg_tx.h" +#include "UTIL/OTG/otg_externs.h" +#include "UTIL/MATH/oml.h" +#include "common/utils/LOG/vcd_signal_dumper.h" +#include "UTIL/OPT/opt.h" +#include "enb_config.h" +#include "s1ap_eNB.h" +#include "SIMULATION/ETH_TRANSPORT/proto.h" +#include +#include +#include +#include +#include + +// should be in a shared lib +#include +#include +#include + +// Global vars +#include +#include +#include +#include +volatile int oai_exit; +int transmission_mode; +int single_thread_flag=1; +uint32_t do_forms=0; +unsigned int mmapped_dma=0; +int8_t threequarter_fs=0; + +uint32_t target_dl_mcs = 28; //maximum allowed mcs +uint32_t target_ul_mcs = 20; +int chain_offset=0; +uint16_t sl_ahead=6; +uint16_t sf_ahead=6; +uint32_t timing_advance = 0; +int transmission_mode=1; +int emulate_rf = 0; +int numerology = 0; + + +unsigned char NB_gNB_INST = 1; +int config_sync_var=-1; +pthread_mutex_t nfapi_sync_mutex; +pthread_cond_t nfapi_sync_cond; +int nfapi_sync_var=-1; +uint8_t nfapi_mode = NFAPI_MONOLITHIC; // Default to monolithic mode +double cpuf; + +uint32_t downlink_frequency[MAX_NUM_CCs][4]; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; +int sync_var=-1; //!< protected by mutex \ref sync_mutex. +time_stats_t softmodem_stats_mt; // main thread +time_stats_t softmodem_stats_hw; // hw acquisition +time_stats_t softmodem_stats_rxtx_sf; // total tx time +time_stats_t nfapi_meas; // total tx time +time_stats_t softmodem_stats_rx_sf; // total rx time + +int split73=0; +void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { + AssertFatal(false, "Must not be called in this context\n"); +} +int stop_L1L2(module_id_t gnb_id) { + AssertFatal(false, "Must not be called in this context\n"); +} +int restart_L1L2(module_id_t gnb_id) { + AssertFatal(false, "Must not be called in this context\n"); +} + +static int wait_for_sync = 0; +static char *itti_dump_file = NULL; +static char *parallel_config = NULL; +static char *worker_config = NULL; +static double snr_dB=20; +static int DEFBANDS[] = {7}; +static int DEFENBS[] = {0}; +static int DEFBFW[] = {0x00007fff}; + +extern double cpuf; + +short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,16384,16384,-16384,-16384,16384,16384,16384,-16384,-16384,16384,-16384,-16384,7327,7327,7327,21981,21981,7327,21981,21981,7327,-7327,7327,-21981,21981,-7327,21981,-21981,-7327,7327,-7327,21981,-21981,7327,-21981,21981,-7327,-7327,-7327,-21981,-21981,-7327,-21981,-21981,10726,10726,10726,3576,3576,10726,3576,3576,10726,17876,10726,25027,3576,17876,3576,25027,17876,10726,17876,3576,25027,10726,25027,3576,17876,17876,17876,25027,25027,17876,25027,25027,10726,-10726,10726,-3576,3576,-10726,3576,-3576,10726,-17876,10726,-25027,3576,-17876,3576,-25027,17876,-10726,17876,-3576,25027,-10726,25027,-3576,17876,-17876,17876,-25027,25027,-17876,25027,-25027,-10726,10726,-10726,3576,-3576,10726,-3576,3576,-10726,17876,-10726,25027,-3576,17876,-3576,25027,-17876,10726,-17876,3576,-25027,10726,-25027,3576,-17876,17876,-17876,25027,-25027,17876,-25027,25027,-10726,-10726,-10726,-3576,-3576,-10726,-3576,-3576,-10726,-17876,-10726,-25027,-3576,-17876,-3576,-25027,-17876,-10726,-17876,-3576,-25027,-10726,-25027,-3576,-17876,-17876,-17876,-25027,-25027,-17876,-25027,-25027,8886,8886,8886,12439,12439,8886,12439,12439,8886,5332,8886,1778,12439,5332,12439,1778,5332,8886,5332,12439,1778,8886,1778,12439,5332,5332,5332,1778,1778,5332,1778,1778,8886,19547,8886,15993,12439,19547,12439,15993,8886,23101,8886,26655,12439,23101,12439,26655,5332,19547,5332,15993,1778,19547,1778,15993,5332,23101,5332,26655,1778,23101,1778,26655,19547,8886,19547,12439,15993,8886,15993,12439,19547,5332,19547,1778,15993,5332,15993,1778,23101,8886,23101,12439,26655,8886,26655,12439,23101,5332,23101,1778,26655,5332,26655,1778,19547,19547,19547,15993,15993,19547,15993,15993,19547,23101,19547,26655,15993,23101,15993,26655,23101,19547,23101,15993,26655,19547,26655,15993,23101,23101,23101,26655,26655,23101,26655,26655,8886,-8886,8886,-12439,12439,-8886,12439,-12439,8886,-5332,8886,-1778,12439,-5332,12439,-1778,5332,-8886,5332,-12439,1778,-8886,1778,-12439,5332,-5332,5332,-1778,1778,-5332,1778,-1778,8886,-19547,8886,-15993,12439,-19547,12439,-15993,8886,-23101,8886,-26655,12439,-23101,12439,-26655,5332,-19547,5332,-15993,1778,-19547,1778,-15993,5332,-23101,5332,-26655,1778,-23101,1778,-26655,19547,-8886,19547,-12439,15993,-8886,15993,-12439,19547,-5332,19547,-1778,15993,-5332,15993,-1778,23101,-8886,23101,-12439,26655,-8886,26655,-12439,23101,-5332,23101,-1778,26655,-5332,26655,-1778,19547,-19547,19547,-15993,15993,-19547,15993,-15993,19547,-23101,19547,-26655,15993,-23101,15993,-26655,23101,-19547,23101,-15993,26655,-19547,26655,-15993,23101,-23101,23101,-26655,26655,-23101,26655,-26655,-8886,8886,-8886,12439,-12439,8886,-12439,12439,-8886,5332,-8886,1778,-12439,5332,-12439,1778,-5332,8886,-5332,12439,-1778,8886,-1778,12439,-5332,5332,-5332,1778,-1778,5332,-1778,1778,-8886,19547,-8886,15993,-12439,19547,-12439,15993,-8886,23101,-8886,26655,-12439,23101,-12439,26655,-5332,19547,-5332,15993,-1778,19547,-1778,15993,-5332,23101,-5332,26655,-1778,23101,-1778,26655,-19547,8886,-19547,12439,-15993,8886,-15993,12439,-19547,5332,-19547,1778,-15993,5332,-15993,1778,-23101,8886,-23101,12439,-26655,8886,-26655,12439,-23101,5332,-23101,1778,-26655,5332,-26655,1778,-19547,19547,-19547,15993,-15993,19547,-15993,15993,-19547,23101,-19547,26655,-15993,23101,-15993,26655,-23101,19547,-23101,15993,-26655,19547,-26655,15993,-23101,23101,-23101,26655,-26655,23101,-26655,26655,-8886,-8886,-8886,-12439,-12439,-8886,-12439,-12439,-8886,-5332,-8886,-1778,-12439,-5332,-12439,-1778,-5332,-8886,-5332,-12439,-1778,-8886,-1778,-12439,-5332,-5332,-5332,-1778,-1778,-5332,-1778,-1778,-8886,-19547,-8886,-15993,-12439,-19547,-12439,-15993,-8886,-23101,-8886,-26655,-12439,-23101,-12439,-26655,-5332,-19547,-5332,-15993,-1778,-19547,-1778,-15993,-5332,-23101,-5332,-26655,-1778,-23101,-1778,-26655,-19547,-8886,-19547,-12439,-15993,-8886,-15993,-12439,-19547,-5332,-19547,-1778,-15993,-5332,-15993,-1778,-23101,-8886,-23101,-12439,-26655,-8886,-26655,-12439,-23101,-5332,-23101,-1778,-26655,-5332,-26655,-1778,-19547,-19547,-19547,-15993,-15993,-19547,-15993,-15993,-19547,-23101,-19547,-26655,-15993,-23101,-15993,-26655,-23101,-19547,-23101,-15993,-26655,-19547,-26655,-15993,-23101,-23101,-23101,-26655,-26655,-23101,-26655,-26655}; + +static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_tx, int slot_tx) { + start_meas(&softmodem_stats_rxtx_sf); + + // ******************************************************************* + + if (nfapi_mode == NFAPI_MODE_PNF) { + // I am a PNF and I need to let nFAPI know that we have a (sub)frame tick + //add_subframe(&frame, &subframe, 4); + //oai_subframe_ind(proc->frame_tx, proc->subframe_tx); + //LOG_D(PHY, "oai_subframe_ind(frame:%u, subframe:%d) - NOT CALLED ********\n", frame, subframe); + start_meas(&nfapi_meas); + oai_subframe_ind(frame_rx, slot_rx); + stop_meas(&nfapi_meas); + + if (gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus|| + gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs || + gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs || + gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles || + gNB->UL_INFO.cqi_ind.number_of_cqis + ) { + LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d preambles:%05d:%d cqis:%d] RX:%04d%d TX:%04d%d \n", + NFAPI_SFNSF2DEC(gNB->UL_INFO.rx_ind.sfn_sf), gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, + NFAPI_SFNSF2DEC(gNB->UL_INFO.harq_ind.sfn_sf), gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, + NFAPI_SFNSF2DEC(gNB->UL_INFO.crc_ind.sfn_sf), gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, + NFAPI_SFNSF2DEC(gNB->UL_INFO.rach_ind.sfn_sf), gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, + gNB->UL_INFO.cqi_ind.number_of_cqis, + frame_rx, slot_rx, + frame_tx, slot_tx); + } + } + + /// NR disabling + // **************************************** + // Common RX procedures subframe n + pthread_mutex_lock(&gNB->UL_INFO_mutex); + gNB->UL_INFO.frame = frame_rx; + gNB->UL_INFO.slot = slot_rx; + gNB->UL_INFO.module_id = gNB->Mod_id; + gNB->UL_INFO.CC_id = gNB->CC_id; + gNB->if_inst->NR_UL_indication(&gNB->UL_INFO); + pthread_mutex_unlock(&gNB->UL_INFO_mutex); + + //if (slot_rx == NR_UPLINK_SLOT || gNB->frame_parms.frame_type == FDD) + phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx); + phy_procedures_gNB_TX(gNB, frame_tx,slot_tx, 1); + + stop_meas( &softmodem_stats_rxtx_sf ); + LOG_D(PHY,"%s() Exit proc[rx:%d%d tx:%d%d]\n", __FUNCTION__, frame_rx, slot_rx, frame_tx, slot_tx); + return(0); +} + +void gNB_top(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, struct RU_t_s *ru) { + gNB_L1_proc_t *proc = &gNB->proc; + gNB_L1_rxtx_proc_t *L1_proc = &proc->L1_proc; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + RU_proc_t *ru_proc=&ru->proc; + proc->frame_rx = frame_rx; + proc->slot_rx = slot_rx; + + if (!oai_exit) { + L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sl_ahead*fp->samples_per_slot); + L1_proc->frame_rx = ru_proc->frame_rx; + L1_proc->slot_rx = ru_proc->tti_rx; + L1_proc->frame_tx = (L1_proc->slot_rx > (fp->slots_per_frame-1-sl_ahead)) ? + (L1_proc->frame_rx+1)&1023 : + L1_proc->frame_rx; + L1_proc->slot_tx = (L1_proc->slot_rx + sl_ahead)%fp->slots_per_frame; + + if (rxtx(gNB,L1_proc->frame_rx,L1_proc->slot_rx,L1_proc->frame_tx,L1_proc->slot_tx) < 0) + LOG_E(PHY,"gNB %d CC_id %d failed during execution\n",gNB->Mod_id,gNB->CC_id); + + ru_proc->timestamp_tx = L1_proc->timestamp_tx; + ru_proc->tti_tx = L1_proc->slot_tx; + ru_proc->frame_tx = L1_proc->frame_tx; + } +} + +static void *process_stats_thread(void *param) { + PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param; + RU_t *ru = (RU_t *)NULL; + reset_meas(&gNB->dlsch_encoding_stats); + reset_meas(&gNB->dlsch_scrambling_stats); + reset_meas(&gNB->dlsch_modulation_stats); + reset_meas(&softmodem_stats_mt); + reset_meas(&softmodem_stats_hw); + for (int sfn=0; sfn < 10; sfn++) { + reset_meas(&softmodem_stats_rxtx_sf); + reset_meas(&softmodem_stats_rx_sf); + } + while(!oai_exit) { + sleep(1); + print_meas(&gNB->dlsch_encoding_stats, "pdsch_encoding", NULL, NULL); + print_meas(&gNB->dlsch_scrambling_stats, "pdsch_scrambling", NULL, NULL); + print_meas(&gNB->dlsch_modulation_stats, "pdsch_modulation", NULL, NULL); + print_meas(&softmodem_stats_mt, "Main gNB Thread", NULL, NULL); + print_meas(&softmodem_stats_hw, "HW Acquisation", NULL, NULL); + print_meas(&ru->ofdm_demod_stats,"feprx",NULL,NULL); + print_meas(&ru->precoding_stats,"feptx_prec",NULL,NULL); + print_meas(&ru->txdataF_copy_stats,"txdataF_copy",NULL,NULL); + print_meas(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL); + print_meas(&ru->ofdm_total_stats,"feptx_total",NULL,NULL); + print_meas(&ru->rx_fhaul,"rx_fhaul",NULL,NULL); + print_meas(&ru->tx_fhaul,"tx_fhaul",NULL,NULL); + print_meas(&ru->compression,"compression",NULL,NULL); + print_meas(&ru->transport,"transport",NULL,NULL); + for (int sfn=0; sfn < 10; sfn++) { + print_meas(&softmodem_stats_rxtx_sf,"[gNB][total_phy_proc_rxtx]",NULL, NULL); + print_meas(&softmodem_stats_rx_sf,"[gNB][total_phy_proc_rx]",NULL,NULL); + } + } + return(NULL); +} + +void init_gNB_proc(int inst) { + int CC_id; + PHY_VARS_gNB *gNB; + gNB_L1_proc_t *proc; + gNB_L1_rxtx_proc_t *L1_proc,*L1_proc_tx; + + for (CC_id=0; CC_idproc; + L1_proc = &proc->L1_proc; + L1_proc_tx = &proc->L1_proc_tx; + L1_proc->instance_cnt = -1; + L1_proc_tx->instance_cnt = -1; + L1_proc->instance_cnt_RUs = 0; + L1_proc_tx->instance_cnt_RUs = 0; + proc->instance_cnt_prach = -1; + proc->instance_cnt_asynch_rxtx = -1; + proc->CC_id = CC_id; + proc->first_rx =1; + proc->first_tx =1; + proc->RU_mask =0; + proc->RU_mask_tx = (1<num_RU)-1; + proc->RU_mask_prach =0; + pthread_mutex_init( &gNB->UL_INFO_mutex, NULL); + } +} + +/// eNB kept in function name for nffapi calls, TO FIX +void init_eNB_afterRU(void) { + int inst,CC_id,ru_id,i,aa; + PHY_VARS_gNB *gNB; + LOG_I(PHY,"%s() RC.nb_nr_inst:%d\n", __FUNCTION__, RC.nb_nr_inst); + + for (inst=0; instnum_RU,gNB->Mod_id); + //LOG_I(PHY,"Overwriting gNB->prach_vars.rxsigF[0]:%p\n", gNB->prach_vars.rxsigF[0]); + // gNB->prach_vars.rxsigF[0] = (int16_t **)malloc16(64*sizeof(int16_t *)); + LOG_I(PHY,"gNB->num_RU:%d\n", gNB->num_RU); + + for (ru_id=0,aa=0; ru_idnum_RU; ru_id++) { + AssertFatal(gNB->RU_list[ru_id]->common.rxdataF!=NULL, + "RU %d : common.rxdataF is NULL\n", + gNB->RU_list[ru_id]->idx); + AssertFatal(gNB->RU_list[ru_id]->prach_rxsigF!=NULL, + "RU %d : prach_rxsigF is NULL\n", + gNB->RU_list[ru_id]->idx); + + for (i=0; iRU_list[ru_id]->nb_rx; aa++,i++) { + LOG_I(PHY,"Attaching RU %d antenna %d to gNB antenna %d\n",gNB->RU_list[ru_id]->idx,i,aa); + // gNB->prach_vars.rxsigF[0][aa] = gNB->RU_list[ru_id]->prach_rxsigF[i]; + gNB->common_vars.rxdataF[aa] = gNB->RU_list[ru_id]->common.rxdataF[i]; + } + } + //init_precoding_weights(RC.gNB[inst][CC_id]); + } + } +} + +void init_gNB(int single_thread_flag,int wait_for_sync) { + int CC_id; + int inst; + PHY_VARS_gNB *gNB; + LOG_I(PHY,"[nr-softmodem.c] gNB structure about to be allocated RC.nb_nr_L1_inst:%d RC.nb_nr_L1_CC[0]:%d\n",RC.nb_nr_L1_inst,RC.nb_nr_L1_CC[0]); + + AssertFatal(RC.gNB != NULL,""); + for (inst=0; instabstraction_flag = false; + gNB->single_thread_flag = true; + /*nr_polar_init(&gNB->nrPolar_params, + NR_POLAR_PBCH_MESSAGE_TYPE, + NR_POLAR_PBCH_PAYLOAD_BITS, + NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ + LOG_I(PHY,"Registering with MAC interface module\n"); + AssertFatal((gNB->if_inst = NR_IF_Module_init(inst))!=NULL,"Cannot register interface"); + gNB->if_inst->NR_Schedule_response = nr_schedule_response; + gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; + memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO)); + memset((void *)&gNB->UL_tti_req,0,sizeof(nfapi_nr_ul_tti_request_t)); + //memset((void *)&gNB->Sched_INFO,0,sizeof(gNB->Sched_INFO)); + LOG_I(PHY,"Setting indication lists\n"); + gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list = gNB->rx_pdu_list; + gNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list = gNB->crc_pdu_list; + gNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = gNB->sr_pdu_list; + gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list; + gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list; + gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list; + gNB->prach_energy_counter = 0; + } + } + LOG_I(PHY,"[nr-softmodem.c] gNB structure allocated\n"); +} + + +void stop_gNB(int nb_inst) { +} + +static void get_options(void) { + paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC_GNB ; + config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); + + if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) { + memset((void *)&RC,0,sizeof(RC)); + /* Read RC configuration file */ + NRRCConfig(); + NB_gNB_INST = RC.nb_nr_inst; + NB_RU = RC.nb_RU; + printf("Configuration: nb_rrc_inst %d, nb_nr_L1_inst %d, nb_ru %hhu\n",NB_gNB_INST,RC.nb_nr_L1_inst,NB_RU); + } +} + +void set_default_frame_parms(nfapi_nr_config_request_t *config[MAX_NUM_CCs], + NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { + for (int CC_id=0; CC_idsubframe_config.numerology_index_mu.value =1; + config[CC_id]->subframe_config.duplex_mode.value = 1; //FDD + config[CC_id]->subframe_config.dl_cyclic_prefix_type.value = 0; //NORMAL + config[CC_id]->rf_config.dl_carrier_bandwidth.value = 106; + config[CC_id]->rf_config.ul_carrier_bandwidth.value = 106; + config[CC_id]->sch_config.physical_cell_id.value = 0; + } +} + +static void init_pdcp(void) { + //if (!NODE_IS_DU(RC.rrc[0]->node_type)) { + pdcp_layer_init(); + uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? + (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; + + if (IS_SOFTMODEM_NOS1) { + printf("IS_SOFTMODEM_NOS1 option enabled \n"); + pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; + } + + pdcp_module_init(pdcp_initmask); + /*if (NODE_IS_CU(RC.rrc[0]->node_type)) { + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + } else {*/ + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + //} + /*} else { + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + }*/ +} + +void init_main_gNB(void) { + RCconfig_NR_L1(); + RCconfig_nr_macrlc(); + if (RC.nb_nr_L1_inst>0) AssertFatal(l1_north_init_gNB()==0,"could not initialize L1 north interface\n"); + + LOG_I(GNB_APP,"Allocating gNB_RRC_INST for %d instances\n",RC.nb_nr_inst); + + RC.nrrrc = (gNB_RRC_INST **)malloc(RC.nb_nr_inst*sizeof(gNB_RRC_INST *)); + LOG_I(PHY, "%s() RC.nb_nr_inst:%d RC.nrrrc:%p\n", __FUNCTION__, RC.nb_nr_inst, RC.nrrrc); + + int gnb_id=0; // only 1 gnb per process, index 0 for now + + RC.nrrrc[gnb_id] = (gNB_RRC_INST*)malloc(sizeof(gNB_RRC_INST)); + memset((void *)RC.nrrrc[gnb_id],0,sizeof(gNB_RRC_INST)); + MessageDef *msg_p = itti_alloc_new_message (TASK_GNB_APP, NRRRC_CONFIGURATION_REQ); + + RCconfig_NRRRC(msg_p,gnb_id, RC.nrrrc[gnb_id]); + openair_rrc_gNB_configuration(GNB_INSTANCE_TO_MODULE_ID(ITTI_MSG_INSTANCE(msg_p)), &NRRRC_CONFIGURATION_REQ(msg_p)); +} + +static void wait_nfapi_init(char *thread_name) { + printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); + pthread_mutex_lock( &nfapi_sync_mutex ); + + while (nfapi_sync_var<0) + pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex ); + + pthread_mutex_unlock(&nfapi_sync_mutex); + printf( "NFAPI: got sync (%s)\n", thread_name); +} + +void wait_gNBs(void) { + int i,j; + int waiting=1; + + while (waiting==1) { + printf("Waiting for gNB L1 instances to all get configured ... sleeping 50ms (nb_nr_sL1_inst %d)\n",RC.nb_nr_L1_inst); + usleep(50*1000); + waiting=0; + + for (i=0; iconfigured==0) { + waiting=1; + break; + } + } + } + } + + printf("gNB L1 are configured\n"); +} + +void exit_function(const char *file, const char *function, const int line, const char *s) { + int ru_id; + + if (s != NULL) { + printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s); + } + + oai_exit = 1; + + if (RC.ru == NULL) + exit(-1); // likely init not completed, prevent crash or hang, exit now... + + for (ru_id=0; ru_idrfdevice.trx_end_func) { + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + RC.ru[ru_id]->rfdevice.trx_end_func = NULL; + } + + if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) { + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + RC.ru[ru_id]->ifdevice.trx_end_func = NULL; + } + } + + sleep(1); //allow lte-softmodem threads to exit first + exit(1); +} + +void stop_RU(int nb_ru) { +} + +void RCconfig_RU(void) { + int i = 0, j = 0; + paramdef_t RUParams[] = RUPARAMS_DESC; + paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; + config_getlist( &RUParamList, RUParams, sizeof(RUParams)/sizeof(paramdef_t), NULL); + + if ( RUParamList.numelt > 0) { + RC.ru = (RU_t **)malloc(RC.nb_RU*sizeof(RU_t *)); + RC.ru_mask=(1<idx = j; + RC.ru[j]->nr_frame_parms = (NR_DL_FRAME_PARMS *)malloc(sizeof(NR_DL_FRAME_PARMS)); + RC.ru[j]->frame_parms = (LTE_DL_FRAME_PARMS *)malloc(sizeof(LTE_DL_FRAME_PARMS)); + printf("Creating RC.ru[%d]:%p\n", j, RC.ru[j]); + RC.ru[j]->if_timing = synch_to_ext_device; + + if (RC.nb_nr_L1_inst >0) + RC.ru[j]->num_gNB = RUParamList.paramarray[j][RU_ENB_LIST_IDX].numelt; + else + RC.ru[j]->num_gNB = 0; + + for (i=0; inum_gNB; i++) RC.ru[j]->gNB_list[i] = RC.gNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; + + if (config_isparamset(RUParamList.paramarray[j], RU_SDR_ADDRS)) { + RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr)); + } + + if (config_isparamset(RUParamList.paramarray[j], RU_SDR_CLK_SRC)) { + if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "internal") == 0) { + RC.ru[j]->openair0_cfg.clock_source = internal; + LOG_D(PHY, "RU clock source set as internal\n"); + } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "external") == 0) { + RC.ru[j]->openair0_cfg.clock_source = external; + LOG_D(PHY, "RU clock source set as external\n"); + } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "gpsdo") == 0) { + RC.ru[j]->openair0_cfg.clock_source = gpsdo; + LOG_D(PHY, "RU clock source set as gpsdo\n"); + } else { + LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr)); + } + } else { + RC.ru[j]->openair0_cfg.clock_source = unset; + } + + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { + if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { + RC.ru[j]->if_south = LOCAL_RF; + RC.ru[j]->function = gNodeB_3GPP; + printf("Setting function for RU %d to gNodeB_3GPP\n",j); + } else { + } + + RC.ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; + RC.ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); + RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; + + for (i=0; inum_bands; i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; + } //strcmp(local_rf, "yes") == 0 + else { + } + + RC.ru[j]->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); + RC.ru[j]->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); + RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); + + if (config_isparamset(RUParamList.paramarray[j], RU_BF_WEIGHTS_LIST_IDX)) { + RC.ru[j]->nb_bfw = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].numelt; + + for (i=0; inum_gNB; i++) { + RC.ru[j]->bw_list[i] = (int32_t *)malloc16_clear((RC.ru[j]->nb_bfw)*sizeof(int32_t)); + + for (int b=0; bnb_bfw; b++) RC.ru[j]->bw_list[i][b] = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].iptr[b]; + } + } + }// j=0..num_rus + } else { + RC.nb_RU = 0; + } // setting != NULL + + return; +} + +void rx_rf(RU_t *ru,int *frame,int *slot) { + RU_proc_t *proc = &ru->proc; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + void *rxp[ru->nb_rx]; + unsigned int rxs; + int i; + openair0_timestamp ts,old_ts; + AssertFatal(*slotslots_per_frame && *slot>=0, "slot %d is illegal (%d)\n",*slot,fp->slots_per_frame); + + for (i=0; inb_rx; i++) + rxp[i] = (void *)&ru->common.rxdata[i][*slot*fp->samples_per_slot]; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); + old_ts = proc->timestamp_rx; + LOG_D(PHY,"Reading %d samples for slot %d (%p)\n",fp->samples_per_slot,*slot,rxp[0]); + + rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, + &ts, + rxp, + fp->samples_per_slot, + ru->nb_rx); + + proc->timestamp_rx = ts-ru->ts_offset; + + //AssertFatal(rxs == fp->samples_per_subframe, + //"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_subframe,rxs); + if (rxs != fp->samples_per_slot) + LOG_E(PHY, "rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_slot,rxs); + + if (proc->first_rx == 1) { + ru->ts_offset = proc->timestamp_rx; + proc->timestamp_rx = 0; + AssertFatal(proc->tti_rx == *slot && proc->frame_rx == *frame , + "Received Timestamp (%llu) doesn't correspond to the time we think it is \n\ +(proc->tti_rx %d, subframe %d, proc->frame_rx %d frame %d)\n", + (long long unsigned int)proc->timestamp_rx,proc->tti_rx,*slot, proc->frame_rx,*frame); + } else { + if (proc->timestamp_rx - old_ts != fp->samples_per_slot) { + LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n", + proc->timestamp_rx - old_ts - fp->samples_per_slot,ru->ts_offset); + ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_slot); + proc->timestamp_rx = ts-ru->ts_offset; + } + } + + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_slot*fp->slots_per_frame))&1023; + proc->tti_rx = (proc->timestamp_rx / fp->samples_per_slot)%fp->slots_per_frame; + *frame = proc->frame_rx; + *slot = proc->tti_rx; + proc->first_rx = 0; + + if (rxs != fp->samples_per_slot) + LOG_E(PHY, "problem receiving samples\n"); +} + +void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { + RU_proc_t *proc = &ru->proc; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + //nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config; + void *txp[ru->nb_tx]; + unsigned int txs; + int i; + T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot), + T_INT(0), T_BUFFER(&ru->common.txdata[0][slot * fp->samples_per_slot], fp->samples_per_slot * 4)); + int sf_extension = 0; + //nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame,frame); + + if ((slot == 0) || + (slot == 1) || IS_SOFTMODEM_RFSIM ) { + int siglen=fp->samples_per_slot; + int flags; + + if (slot==0) + flags = 2; + else if (slot==1) + flags=3; + else + flags=4; + + /* + if (SF_type == SF_S) { + siglen = fp->dl_symbols_in_S_subframe*(fp->ofdm_symbol_size+fp->nb_prefix_samples0); + flags=3; // end of burst + } + if ((fp->frame_type == TDD) && + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_DL)) { + flags = 2; // start of burst + sf_extension = ru->N_TA_offset<<1; + } + + if ((cfg->subframe_config.duplex_mode == TDD) && + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_UL)) { + flags = 4; // start of burst and end of burst (only one DL SF between two UL) + sf_extension = ru->N_TA_offset<<1; + } */ + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, slot ); + + for (i=0; inb_tx; i++) { + txp[i] = (void *)&ru->common.txdata[i][(slot*fp->samples_per_slot)-sf_extension]; + } + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + // prepare tx buffer pointers + start_meas(&ru->tx_fhaul); + txs = ru->rfdevice.trx_write_func(&ru->rfdevice, + timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, + txp, + siglen+sf_extension, + ru->nb_tx, + flags); + stop_meas(&ru->tx_fhaul); + LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, subframe %d\n",ru->idx, + (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); + AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %u/%d)\n", txs, siglen); + } +} + +// this is for RU with local RF unit +void fill_rf_config(RU_t *ru, char *rf_config_file) { + int i; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + nfapi_nr_config_request_t *gNB_config = &ru->gNB_list[0]->gNB_config; //tmp index + openair0_config_t *cfg = &ru->openair0_cfg; + int N_RB = gNB_config->rf_config.dl_carrier_bandwidth.value; + int mu = gNB_config->subframe_config.numerology_index_mu.value; + + if (mu == NR_MU_0) { //or if LTE + if(N_RB == 100) { + if (fp->threequarter_fs) { + cfg->sample_rate=23.04e6; + cfg->samples_per_frame = 230400; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } else { + cfg->sample_rate=30.72e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + } else if(N_RB == 50) { + cfg->sample_rate=15.36e6; + cfg->samples_per_frame = 153600; + cfg->tx_bw = 5e6; + cfg->rx_bw = 5e6; + } else if (N_RB == 25) { + cfg->sample_rate=7.68e6; + cfg->samples_per_frame = 76800; + cfg->tx_bw = 2.5e6; + cfg->rx_bw = 2.5e6; + } else if (N_RB == 6) { + cfg->sample_rate=1.92e6; + cfg->samples_per_frame = 19200; + cfg->tx_bw = 1.5e6; + cfg->rx_bw = 1.5e6; + } else AssertFatal(1==0,"Unknown N_RB %d\n",N_RB); + } else if (mu == NR_MU_1) { + if(N_RB == 273) { + if (fp->threequarter_fs) { + AssertFatal(0 == 1,"three quarter sampling not supported for N_RB 273\n"); + } else { + cfg->sample_rate=122.88e6; + cfg->samples_per_frame = 1228800; + cfg->tx_bw = 100e6; + cfg->rx_bw = 100e6; + } + } else if(N_RB == 217) { + if (fp->threequarter_fs) { + cfg->sample_rate=92.16e6; + cfg->samples_per_frame = 921600; + cfg->tx_bw = 80e6; + cfg->rx_bw = 80e6; + } else { + cfg->sample_rate=122.88e6; + cfg->samples_per_frame = 1228800; + cfg->tx_bw = 80e6; + cfg->rx_bw = 80e6; + } + } else if(N_RB == 106) { + if (fp->threequarter_fs) { + cfg->sample_rate=46.08e6; + cfg->samples_per_frame = 460800; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; + } else { + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 614400; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; + } + } else { + AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu); + } + } else { + AssertFatal(0 == 1,"Numerology %d not supported for the moment\n",mu); + } + + if (gNB_config->subframe_config.duplex_mode.value==TDD) + cfg->duplex_mode = duplex_mode_TDD; + else //FDD + cfg->duplex_mode = duplex_mode_FDD; + + cfg->Mod_id = 0; + cfg->num_rb_dl=N_RB; + cfg->tx_num_channels=ru->nb_tx; + cfg->rx_num_channels=ru->nb_rx; + + for (i=0; inb_tx; i++) { + cfg->tx_freq[i] = (double)fp->dl_CarrierFreq; + cfg->rx_freq[i] = (double)fp->ul_CarrierFreq; + cfg->tx_gain[i] = ru->att_tx; + cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx; + cfg->configFilename = rf_config_file; + printf("channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", + i, cfg->tx_gain[i], + cfg->rx_gain[i], + cfg->tx_freq[i], + cfg->rx_freq[i]); + } +} + +static void *ru_thread( void *param ) { + RU_t *ru = (RU_t *)param; + RU_proc_t *proc = &ru->proc; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + int slot = fp->slots_per_frame-1; + int frame = 1023; + + LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,NB_functions[ru->function],NB_timing[ru->if_timing]); + + nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp); + nr_dump_frame_parms(fp); + fill_rf_config(ru,ru->rf_config_file); + nr_phy_init_RU(ru); + + AssertFatal(openair0_device_load(&ru->rfdevice,&ru->openair0_cfg)==0,"Cannot connect to local radio\n"); + AssertFatal(ru->rfdevice.trx_start_func(&ru->rfdevice) == 0,"Could not start the RF device\n"); + + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + while (!oai_exit) { + // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. + // They are set on the first rx/tx in the underly FH routines. + if (slot==(fp->slots_per_frame-1)) { + slot=0; + frame++; + frame&=1023; + } else { + slot++; + } + + // synchronization on input FH interface, acquire signals/data and block + LOG_D(PHY,"[RU_thread] read data: frame_rx = %d, tti_rx = %d\n", frame, slot); + rx_rf(ru,&frame,&slot); + + LOG_D(PHY,"AFTER rx_rf - SFN/SL:%d%d RU->proc[RX:%d.%d TX:%d.%d] RC.gNB[0][0]:[RX:%d%d TX(SFN):%d]\n", + frame,slot, + proc->frame_rx,proc->tti_rx, + proc->frame_tx,proc->tti_tx, + RC.gNB[0][0]->proc.frame_rx,RC.gNB[0][0]->proc.slot_rx, + RC.gNB[0][0]->proc.frame_tx); + /* + LOG_D(PHY,"RU thread (do_prach %d, is_prach_subframe %d), received frame %d, subframe %d\n", + ru->do_prach, + is_prach_subframe(fp, proc->frame_rx, proc->tti_rx), + proc->frame_rx,proc->tti_rx); + + if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->tti_rx)==1)) { + wakeup_prach_ru(ru); + }*/ + + // adjust for timing offset between RU + //printf("~~~~~~~~~~~~~~~~~~~~~~~~~~%d.%d in ru_thread is in process\n", proc->frame_rx, proc->tti_rx); + if (ru->idx!=0) + proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023; + + // do RX front-end processing (frequency-shift, dft) if needed + + if (proc->tti_rx == NR_UPLINK_SLOT || fp->frame_type == FDD) { + nr_fep_full(ru,proc->tti_rx); + } + + gNB_top(RC.gNB[0][0], frame, slot, ru); + + // do TX front-end processing if needed (precoding and/or IDFTs) + //ru->feptx_prec(ru,proc->frame_tx,proc->tti_tx); + nr_feptx_prec(ru,proc->frame_tx,proc->tti_tx); + // do OFDM with/without TX front-end processing if needed + //ru->feptx_ofdm + nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config; + if (nr_slot_select(cfg,proc->tti_tx,proc->frame_tx ) != SF_UL) { + int aa=0; // antenna 0 hardcoded + NR_DL_FRAME_PARMS *fp=ru->nr_frame_parms; + nr_feptx0(ru,proc->tti_tx,0,fp->symbols_per_slot,aa); + } + + // do outgoing fronthaul (south) if needed + tx_rf(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx); + } + + printf( "Exiting ru_thread \n"); + ru->rfdevice.trx_end_func(&ru->rfdevice); + + static int ru_thread_status = 0; + return &ru_thread_status; +} + +void launch_NR_RU(char *rf_config_file) { + printf("configuring RU from file\n"); + RCconfig_RU(); + LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n", + RC.nb_nr_L1_inst,RC.nb_RU,get_nprocs()); + + LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); + + for (int ru_id=0; ru_idrf_config_file = rf_config_file; + ru->idx = ru_id; + ru->ts_offset = 0; + // use gNB_list[0] as a reference for RU frame parameters + // NOTE: multiple CC_id are not handled here yet! + + LOG_D(PHY, "%s() RC.ru[%d].num_gNB:%d ru->gNB_list[0]:%p RC.gNB[0][0]:%p rf_config_file:%s\n", + __FUNCTION__, ru_id, ru->num_gNB, ru->gNB_list[0], RC.gNB[0][0], ru->rf_config_file); + LOG_E(PHY,"ru->gNB_list ru->num_gNB hardcoded: one RU connected to carrier 0 of gNB 0\n"); + ru->gNB_list[0] = RC.gNB[0][0]; + ru->num_gNB=1; + LOG_I(PHY,"Copying frame parms from gNB in RC to ru %d and frame_parms in ru\n",ru->idx); + memcpy((void *)ru->nr_frame_parms,&RC.gNB[0][0]->frame_parms,sizeof(NR_DL_FRAME_PARMS)); + for (int i=0; inum_gNB; i++) { + PHY_VARS_gNB *gNB0 = ru->gNB_list[i]; + gNB0->RU_list[gNB0->num_RU++] = ru; + } + RU_proc_t *proc = &ru->proc; + threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "thread_FH", -1, OAI_PRIORITY_RT_MAX ); + } +} + +int main( int argc, char **argv ) { + + AssertFatal(load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY), + "[SOFTMODEM] Error, configuration module init failed\n"); + logInit(); +#ifndef PACKAGE_VERSION +# define PACKAGE_VERSION "UNKNOWN" +#endif + LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); + + configure_linux(); + get_options (); + get_common_options(SOFTMODEM_GNB_BIT ); + + if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { + fprintf(stderr,"Getting configuration failed\n"); + exit(-1); + } + cpuf=get_cpu_freq_GHz(); + itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); + set_taus_seed (0); + + init_opt(); + + if(IS_SOFTMODEM_NOS1) + init_pdcp(); + + init_main_gNB(); + + /* Start the agent. If it is turned off in the configuration, it won't start */ + RCconfig_nr_flexran(); + for (int i = 0; i < RC.nb_nr_L1_inst; i++) { + flexran_agent_start(i); + } + + // init UE_PF_PO and mutex lock (paging from S1AP) + pthread_mutex_init(&ue_pf_po_mutex, NULL); + + printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); + pthread_cond_init(&nfapi_sync_cond,NULL); + pthread_mutex_init(&nfapi_sync_mutex, NULL); + + const char *nfapi_mode_str[] = { + "MONOLITHIC", "PNF", "VNF", }; + AssertFatal(nfapi_mode < 3,""); + printf("NFAPI MODE:%s\n", nfapi_mode_str[nfapi_mode]); + + if (nfapi_mode==NFAPI_MODE_VNF) // VNF + wait_nfapi_init("main?"); + + number_of_cards = 1; + LOG_I(PHY,"Initializing gNB threads\n"); + init_gNB(single_thread_flag,wait_for_sync); + + printf("wait_gNBs()\n"); + wait_gNBs(); + printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); + + config_sync_var=0; + + if (nfapi_mode==NFAPI_MODE_PNF) { // PNF + wait_nfapi_init("main?"); + } + + printf("wait RUs\n"); + printf("ALL RUs READY!\n"); + printf("RC.nb_RU:%d\n", RC.nb_RU); + // once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration) + printf("ALL RUs ready - init gNBs\n"); + + if (nfapi_mode != NFAPI_MODE_PNF && nfapi_mode != NFAPI_MODE_VNF) { + printf("Not NFAPI mode - call init_eNB_afterRU()\n"); + init_eNB_afterRU(); + } else { + printf("NFAPI mode - DO NOT call init_gNB_afterRU()\n"); + } + + init_gNB_proc(0); // only instance 0 (one gNB per process) + if (RC.nb_RU >0) { + printf("Initializing RU threads\n"); + launch_NR_RU(get_softmodem_params()->rf_config_file); + } + + if (opp_enabled ==1) { + pthread_t t; + threadCreate(&t, process_stats_thread, + (void *)NULL, "time_meas", -1, OAI_PRIORITY_RT_LOW); + } + + if (do_forms==1) { + scopeParms_t tmp={&argc, argv}; + startScope(&tmp); + } + + while(!oai_exit) + sleep(1); + + for(int ru_id=0; ru_idrfdevice.trx_end_func) + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + + if (RC.ru[ru_id]->ifdevice.trx_end_func) + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + } + + logClean(); + printf("Bye.\n"); + return 0; +} diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c index 0c4032c41b..e8081e5ed6 100644 --- a/executables/softmodem-common.c +++ b/executables/softmodem-common.c @@ -81,9 +81,9 @@ char *get_softmodem_function(uint64_t *sofmodemfunc_mask_ptr) { } void get_common_options(uint32_t execmask) { - uint32_t online_log_messages; - uint32_t glog_level ; - uint32_t start_telnetsrv = 0; + uint32_t online_log_messages=0; + uint32_t glog_level =0; + uint32_t start_telnetsrv=0; uint32_t noS1 = 0, nokrnmod = 0, nonbiot = 0; uint32_t rfsim = 0, basicsim = 0, do_forms = 0; char *logmem_filename = NULL; @@ -146,27 +146,27 @@ void get_common_options(uint32_t execmask) { } void softmodem_printresources(int sig, telnet_printfunc_t pf) { - struct rusage usage; - struct timespec stop; + struct rusage usage; + struct timespec stop; - clock_gettime(CLOCK_BOOTTIME, &stop); + clock_gettime(CLOCK_BOOTTIME, &stop); - uint64_t elapse = (stop.tv_sec - start.tv_sec) ; // in seconds + uint64_t elapse = (stop.tv_sec - start.tv_sec) ; // in seconds - int st = getrusage(RUSAGE_SELF,&usage); - if (!st) { - pf("\nRun time: %lluh %llus\n",(unsigned long long)elapse/3600,(unsigned long long)(elapse - (elapse/3600))); - pf("\tTime executing user inst.: %lds %ldus\n",(long)usage.ru_utime.tv_sec,(long)usage.ru_utime.tv_usec); - pf("\tTime executing system inst.: %lds %ldus\n",(long)usage.ru_stime.tv_sec,(long)usage.ru_stime.tv_usec); - pf("\tMax. Phy. memory usage: %ldkB\n",(long)usage.ru_maxrss); - pf("\tPage fault number (no io): %ld\n",(long)usage.ru_minflt); - pf("\tPage fault number (requiring io): %ld\n",(long)usage.ru_majflt); - pf("\tNumber of file system read: %ld\n",(long)usage.ru_inblock); - pf("\tNumber of filesystem write: %ld\n",(long)usage.ru_oublock); - pf("\tNumber of context switch (process origin, io...): %ld\n",(long)usage.ru_nvcsw); - pf("\tNumber of context switch (os origin, priority...): %ld\n",(long)usage.ru_nivcsw); - } + int st = getrusage(RUSAGE_SELF,&usage); + if (!st) { + pf("\nRun time: %lluh %llus\n",(unsigned long long)elapse/3600,(unsigned long long)(elapse - (elapse/3600))); + pf("\tTime executing user inst.: %lds %ldus\n",(long)usage.ru_utime.tv_sec,(long)usage.ru_utime.tv_usec); + pf("\tTime executing system inst.: %lds %ldus\n",(long)usage.ru_stime.tv_sec,(long)usage.ru_stime.tv_usec); + pf("\tMax. Phy. memory usage: %ldkB\n",(long)usage.ru_maxrss); + pf("\tPage fault number (no io): %ld\n",(long)usage.ru_minflt); + pf("\tPage fault number (requiring io): %ld\n",(long)usage.ru_majflt); + pf("\tNumber of file system read: %ld\n",(long)usage.ru_inblock); + pf("\tNumber of filesystem write: %ld\n",(long)usage.ru_oublock); + pf("\tNumber of context switch (process origin, io...): %ld\n",(long)usage.ru_nvcsw); + pf("\tNumber of context switch (os origin, priority...): %ld\n",(long)usage.ru_nivcsw); + } } void signal_handler(int sig) { @@ -181,9 +181,9 @@ void signal_handler(int sig) { backtrace_symbols_fd(array, size, 2); exit(-1); } else { - if(sig==SIGINT ||sig==SOFTMODEM_RTSIGNAL) - softmodem_printresources(sig,(telnet_printfunc_t)printf); - if (sig != SOFTMODEM_RTSIGNAL) { + if(sig==SIGINT ||sig==SOFTMODEM_RTSIGNAL) + softmodem_printresources(sig,(telnet_printfunc_t)printf); + if (sig != SOFTMODEM_RTSIGNAL) { printf("Linux signal %s...\n",strsignal(sig)); exit_function(__FILE__, __FUNCTION__, __LINE__,"softmodem starting exit procedure\n"); } @@ -193,7 +193,7 @@ void signal_handler(int sig) { void set_softmodem_sighandler(void) { - struct sigaction act,oldact; + struct sigaction act,oldact; clock_gettime(CLOCK_BOOTTIME, &start); memset(&act,0,sizeof(act)); act.sa_handler=signal_handler; @@ -202,5 +202,5 @@ void set_softmodem_sighandler(void) { signal(SIGSEGV, signal_handler); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); - signal(SIGABRT, signal_handler); + signal(SIGABRT, signal_handler); } diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index c9a24577dc..a59b0f59b9 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -38,6 +38,11 @@ extern "C" #endif /* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */ #define CONFIG_HLP_RFCFGF "Configuration file for front-end (e.g. LMS7002M)\n" +#define CONFIG_HLP_SPLIT73 "Split 7.3 (below rate matching) option: ::" +#define CONFIG_HLP_TPOOL "Thread pool configuration: \n\ + default no pool (runs in calling thread),\n\ + list of cores, comma separated (negative value is no core affinity)\n\ + example: -1,3 launches two working threads one floating, the second set on core 3" #define CONFIG_HLP_ULMAXE "set the eNodeB max ULSCH erros\n" #define CONFIG_HLP_CALUER "set UE RX calibration\n" #define CONFIG_HLP_CALUERM "" @@ -88,6 +93,8 @@ extern "C" /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*-----------------------------------------------------------------------------------------------------------------------------------------------------*/ #define RF_CONFIG_FILE softmodem_params.rf_config_file +#define SPLIT73 softmodem_params.split73 +#define TP_CONFIG softmodem_params.threadPoolConfig #define PHY_TEST softmodem_params.phy_test #define WAIT_FOR_SYNC softmodem_params.wait_for_sync #define SINGLE_THREAD_FLAG softmodem_params.single_thread_flag @@ -103,6 +110,8 @@ extern "C" #define CMDLINE_PARAMS_DESC { \ {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, sizeof(RF_CONFIG_FILE)},\ + {"split73", CONFIG_HLP_SPLIT73, 0, strptr:(char **)&SPLIT73, defstrval:NULL, TYPE_STRING, sizeof(SPLIT73)},\ + {"thread-pool", CONFIG_HLP_TPOOL, 0, strptr:(char **)&TP_CONFIG, defstrval:"n", TYPE_STRING, sizeof(TP_CONFIG)}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&PHY_TEST, defintval:0, TYPE_INT, 0}, \ {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&USIM_TEST, defintval:0, TYPE_UINT8, 0}, \ {"clock", CONFIG_HLP_CLK, 0, uptr:&CLOCK_SOURCE, defintval:0, TYPE_UINT, 0}, \ @@ -191,6 +200,8 @@ typedef struct { uint64_t optmask; THREAD_STRUCT thread_struct; char rf_config_file[1024]; + char split73[1024]; + char threadPoolConfig[1024]; int phy_test; uint8_t usim_test; int emulate_rf; diff --git a/executables/split_headers.h b/executables/split_headers.h new file mode 100644 index 0000000000..62293c7369 --- /dev/null +++ b/executables/split_headers.h @@ -0,0 +1,309 @@ +/* + Author: Laurent THOMAS, Open Cells Project company, funded by IRT SystemX + copyleft: OpenAirInterface Software Alliance and it's licence +*/ +#ifndef __SPLIT_HEADERS_H +#define __SPLIT_HEADERS_H + +#include +#include +#include + +#define CU_PORT "7878" +#define DU_PORT "8787" +#define SPLIT73_CU 1 +#define SPLIT73_DU 2 +extern int split73; + +#define MTU 65536 +#define UDP_TIMEOUT 900000L // in micro second (struct timeval, NOT struct timespec) +// linux may timeout for a much longer time (up to 10ms) +#define blockAlign 32 //bytes to align memory for SIMD copy (256 bits vectors) + +// FS6 transport configuration and handler +typedef struct { + char *sourceIP; + char *sourcePort; + char *destIP; + char *destPort; + struct addrinfo *destAddr; + int sockHandler; +} UDPsock_t; + +#define CTsentCUv0 0xA500 +#define CTsentDUv0 0x5A00 + +// Main FS6 transport layer header +// All packets starts with this header +typedef struct commonUDP_s { + uint64_t timestamp; // id of the group (subframe for LTE) + uint16_t nbBlocks; // total number of blocks for this timestamp + uint16_t blockID; // id: 0..nbBocks-1 + uint16_t contentType; // defines the content format + uint16_t contentBytes; // will be sent in a UDP packet, so must be < 2^16 bytes + uint64_t senderClock; +} commonUDP_t; + +// FS6 UL common header (DU to CU) +// gives the RACH detection data and is always sent to inform the CU that a subframe arrived +typedef struct { + uint16_t max_preamble[4]; + uint16_t max_preamble_energy[4]; + uint16_t max_preamble_delay[4]; + uint16_t avg_preamble_energy[4]; +} fs6_ul_t; + +// FS6 DL common header (CU to DU) +// gives the DCI configuration from each subframe +typedef struct { + uint8_t pbch_pdu[4]; + int num_pdcch_symbols; + int num_dci; + DCI_ALLOC_t dci_alloc[8]; + int num_mdci; + int amp; + LTE_eNB_PHICH phich_vars; + uint64_t DuClock; + uint64_t CuSpentMicroSec; +} fs6_dl_t; + +// a value to type all sub packets, +// to detect errors, and to be able to extend to other versions +// the first byte of each sub structure should match one of these values +enum pckType { + fs6UlConfig=25, + fs6DlConfig=26, + fs6ULConfigCCH=27, + fs6ULsch=28, + fs6ULcch=29, + fs6ULindicationHarq=40, + fs6ULindicationSr=41, +}; + +// CU to DU definition of a future UL subframe decode +// defines a UE future data plane +typedef struct { + enum pckType type:8; + uint16_t UE_id; + int8_t harq_pid; + UE_type_t ue_type; + + uint8_t dci_alloc; + uint8_t rar_alloc; + SCH_status_t status; + uint8_t Msg3_flag; + uint8_t subframe; + uint32_t frame; + uint8_t handled; + uint8_t phich_active; + uint8_t phich_ACK; + uint16_t previous_first_rb; + uint32_t B; + uint32_t G; + UCI_format_t uci_format; + uint8_t Or2; + uint8_t o_RI[2]; + uint8_t o_ACK[4]; + uint8_t O_ACK; + uint8_t o_RCC; + int16_t q_ACK[MAX_ACK_PAYLOAD]; + int16_t q_RI[MAX_RI_PAYLOAD]; + uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS]; + uint8_t ndi; + uint8_t round; + uint8_t rvidx; + uint8_t Nl; + uint8_t n_DMRS; + uint8_t previous_n_DMRS; + uint8_t n_DMRS2; + int32_t delta_TF; + uint32_t repetition_number ; + uint32_t total_number_of_repetitions; + + uint16_t harq_mask; + uint16_t nb_rb; + uint8_t Qm; + uint16_t first_rb; + uint8_t O_RI; + uint8_t Or1; + uint16_t Msc_initial; + uint8_t Nsymb_initial; + uint8_t V_UL_DAI; + uint8_t srs_active; + uint32_t TBS; + uint8_t Nsymb_pusch; + uint8_t Mlimit; + uint8_t max_turbo_iterations; + uint8_t bundling; + uint16_t beta_offset_cqi_times8; + uint16_t beta_offset_ri_times8; + uint16_t beta_offset_harqack_times8; + uint8_t Msg3_active; + uint16_t rnti; + uint8_t cyclicShift; + uint8_t cooperation_flag; + uint8_t num_active_cba_groups; + uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; +} fs6_dl_ulsched_t; + +// CU to DU defintion of a DL packet for a given UE +// The data itself is padded at the end of this structure +typedef struct { + enum pckType type:8; + int UE_id; + int8_t harq_pid; + uint16_t rnti; + int16_t sqrt_rho_a; + int16_t sqrt_rho_b; + CEmode_t CEmode:8; + uint16_t nb_rb; + uint8_t Qm; + int8_t Nl; + uint8_t pdsch_start; + uint8_t sib1_br_flag; + uint16_t i0; + uint32_t rb_alloc[4]; + int dataLen; +} fs6_dl_uespec_t; + +// CU to DU definition of CCH channel +typedef struct { + int16_t UE_id; + LTE_eNB_UCI cch_vars; +} fs6_dl_uespec_ulcch_element_t; + +// header to group all UE CCH channels definitions in one UDP packet +typedef struct { + enum pckType type:8; + int16_t nb_active_ue; +} fs6_dl_uespec_ulcch_t; + +// code internal, not transmitted as this +typedef struct { + int ta; +} ul_propagation_t; + +// One UE UL data, data plane, UE data appended after the header +typedef struct { + enum pckType type:8; + short UE_id; + uint8_t harq_id; + uint8_t segment; + int segLen; + int r_offset; + int G; + int ulsch_power[2]; + uint8_t o_ACK[4]; + uint8_t O_ACK; + int ta; + uint8_t o[MAX_CQI_BYTES]; + uint8_t cqi_crc_status; +} fs6_ul_uespec_t; + +// UL UCI (control plane), per UE +typedef struct { + enum pckType type:8; + int UEid; + int frame; + int subframe; + LTE_eNB_UCI uci; + uint8_t harq_ack[4]; + uint8_t tdd_mapping_mode; + uint16_t tdd_multiplexing_mask; + unsigned short n0_subband_power_dB; + uint16_t rnti; + int32_t stat; +} fs6_ul_uespec_uci_element_t; + +// all segments UCI grouped in one UDP packet +typedef struct { + enum pckType type:8; + int16_t nb_active_ue; +} fs6_ul_uespec_uci_t; + + +bool createUDPsock (char *sourceIP, char *sourcePort, char *destIP, char *destPort, UDPsock_t *result); +int receiveSubFrame(UDPsock_t *sock, void *bufferZone, int bufferSize, uint16_t contentType); +int sendSubFrame(UDPsock_t *sock, void *bufferZone, ssize_t secondHeaderSize, uint16_t contentType); + +#define initBufferZone(xBuf) \ + uint8_t xBuf[FS6_BUF_SIZE]; \ + ((commonUDP_t *)xBuf)->nbBlocks=0; + +#define hUDP(xBuf) ((commonUDP_t *)xBuf) +#define hDL(xBuf) ((fs6_dl_t*)(((commonUDP_t *)xBuf)+1)) +#define hUL(xBuf) ((fs6_ul_t*)(((commonUDP_t *)xBuf)+1)) +#define hDLUE(xBuf) ((fs6_dl_uespec_t*) (((fs6_dl_t*)(((commonUDP_t *)xBuf)+1))+1)) +#define hTxULUE(xBuf) ((fs6_dl_ulsched_t*) (((fs6_dl_t*)(((commonUDP_t *)xBuf)+1))+1)) +#define hTxULcch(xBuf) ((fs6_dl_uespec_ulcch_t*) (((fs6_dl_t*)(((commonUDP_t *)xBuf)+1))+1)) +#define hULUE(xBuf) ((fs6_ul_uespec_t*) (((fs6_ul_t*)(((commonUDP_t *)xBuf)+1))+1)) +#define hULUEuci(xBuf) ((fs6_ul_uespec_uci_t*) (((fs6_ul_t*)(((commonUDP_t *)xBuf)+1))+1)) + +static inline size_t alignedSize(uint8_t *ptr) { + commonUDP_t *header=(commonUDP_t *) ptr; + return ((header->contentBytes+sizeof(commonUDP_t)+blockAlign-1)/blockAlign)*blockAlign; +} + +static inline void *commonUDPdata(uint8_t *ptr) { + return (void *) (((commonUDP_t *)ptr)+1); +} + +void setAllfromTS(uint64_t TS, L1_rxtx_proc_t *proc); +void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB,LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, + uint16_t rnti, int32_t stat); +void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset); +void *cu_fs6(void *arg); +void *du_fs6(void *arg); +void fill_rf_config(RU_t *ru, char *rf_config_file); +int init_rf(RU_t *ru); +void rx_rf(RU_t *ru, L1_rxtx_proc_t *proc); +void tx_rf(RU_t *ru, L1_rxtx_proc_t *proc); +void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe); +void pmch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc); +bool dlsch_procedures(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, + int harq_pid, + LTE_eNB_DLSCH_t *dlsch, + LTE_eNB_UE_stats *ue_stats) ; +void postDecode(L1_rxtx_proc_t *proc, notifiedFIFO_elt_t *req); +void pdsch_procedures(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, + int harq_pid, + LTE_eNB_DLSCH_t *dlsch, + LTE_eNB_DLSCH_t *dlsch1); +void srs_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc); +void uci_procedures(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc); +void ocp_rx_prach(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, + RU_t *ru, + uint16_t *max_preamble, + uint16_t *max_preamble_energy, + uint16_t *max_preamble_delay, + uint16_t *avg_preamble_energy, + uint16_t Nf, + uint8_t tdd_mapindex, + uint8_t br_flag); +void rx_prach0(PHY_VARS_eNB *eNB, + RU_t *ru, + int frame_prach, + int subframe, + uint16_t *max_preamble, + uint16_t *max_preamble_energy, + uint16_t *max_preamble_delay, + uint16_t *avg_preamble_energy, + uint16_t Nf, + uint8_t tdd_mapindex, + uint8_t br_flag, + uint8_t ce_level + ); +void ocp_tx_rf(RU_t *ru, L1_rxtx_proc_t *proc); + +// mistakes in main OAI +void phy_init_RU(RU_t *); +void fep_full(RU_t *ru, int subframe); +void feptx_prec(RU_t *ru,int frame,int subframe); +void feptx_ofdm(RU_t *ru, int frame, int subframe); +void oai_subframe_ind(uint16_t sfn, uint16_t sf); +extern uint16_t sf_ahead; +#endif diff --git a/executables/transport_split.c b/executables/transport_split.c new file mode 100644 index 0000000000..7a1ee3e85e --- /dev/null +++ b/executables/transport_split.c @@ -0,0 +1,174 @@ +/* + Author: Laurent THOMAS, Open Cells Project company, funded by IRT SystemX + copyleft: OpenAirInterface Software Alliance and it's licence +*/ +#include +#include /* See NOTES */ +#include +#include +#include +#include +#include + +bool createUDPsock (char *sourceIP, char *sourcePort, char *destIP, char *destPort, UDPsock_t *result) { + struct addrinfo hints= {0}, *servinfo, *p; + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = AI_PASSIVE; + int status; + + if ((status = getaddrinfo(sourceIP, sourcePort, &hints, &servinfo)) != 0) { + LOG_E(GTPU,"getaddrinfo error: %s\n", gai_strerror(status)); + return false; + } + + // loop through all the results and bind to the first we can + for(p = servinfo; p != NULL; p = p->ai_next) { + if ((result->sockHandler = socket(p->ai_family, p->ai_socktype, + p->ai_protocol)) == -1) { + LOG_W(GTPU,"socket: %s\n", strerror(errno)); + continue; + } + + if (bind(result->sockHandler, p->ai_addr, p->ai_addrlen) == -1) { + close(result->sockHandler); + LOG_W(GTPU,"bind: %s\n", strerror(errno)); + continue; + } + + break; // if we get here, we must have connected successfully + } + + if (p == NULL) { + // looped off the end of the list with no successful bind + LOG_E(GTPU,"failed to bind socket: %s %s \n",sourceIP,sourcePort); + return false; + } + + freeaddrinfo(servinfo); // all done with this structure + + if ((status = getaddrinfo(destIP, destPort, &hints, &servinfo)) != 0) { + LOG_E(GTPU,"getaddrinfo error: %s\n", gai_strerror(status)); + return false; + } + + if (servinfo) { + result->destAddr=servinfo; + } else { + LOG_E(PHY,"No valid UDP addr: %s:%s\n",destIP, destPort); + return false; + } + + int enable=1; + AssertFatal(setsockopt(result->sockHandler, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable))==0,""); + struct timeval tv= {0,UDP_TIMEOUT}; + + if (IS_SOFTMODEM_RFSIM) + tv.tv_sec=2; //debug: wait 2 seconds for human understanding + + AssertFatal(setsockopt(result->sockHandler, SOL_SOCKET, SO_RCVTIMEO,&tv,sizeof(tv)) ==0,""); + // Make a send/recv buffer larger than a a couple of subframe + // so the kernel will store for us in and out paquets + int buff=1000*1000*10; + AssertFatal ( setsockopt(result->sockHandler, SOL_SOCKET, SO_SNDBUF, &buff, sizeof(buff)) == 0, ""); + AssertFatal ( setsockopt(result->sockHandler, SOL_SOCKET, SO_RCVBUF, &buff, sizeof(buff)) == 0, ""); + return true; +} + +// sock: udp socket +// bufferZone: a reception area of bufferSize +int receiveSubFrame(UDPsock_t *sock, void *bufferZone, int bufferSize, uint16_t contentType) { + int rcved=0; + commonUDP_t *bufOrigin=(commonUDP_t *)bufferZone; + static uint8_t crossData[65536]; + static int crossDataSize=0; + + if (crossDataSize) { + LOG_D(HW,"copy a block received in previous subframe\n"); + memcpy(bufferZone, crossData, crossDataSize); + rcved=1; + bufferZone+=crossDataSize; + crossDataSize=0; + } + + do { + //read all subframe data from the control unit + int ret=recv(sock->sockHandler, bufferZone, bufferSize, 0); + + if ( ret==-1) { + if ( errno == EWOULDBLOCK || errno== EINTR ) { + LOG_I(HW,"Received: Timeout, subframe incomplete\n"); + return rcved; + } else { + LOG_E(HW,"Critical issue in socket: %s\n", strerror(errno)); + return -1; + } + } else { + if (hUDP(bufferZone)->contentType != contentType) + abort(); + + if (rcved && bufOrigin->timestamp != hUDP(bufferZone)->timestamp ) { + if ( hUDP(bufferZone)->timestamp > bufOrigin->timestamp ) { + LOG_W(HW,"Received data for TS: %lu before end of TS : %lu completion\n", + hUDP(bufferZone)->timestamp, + bufOrigin->timestamp); + memcpy(crossData, bufferZone, ret ); + crossDataSize=ret; + return rcved; + } else { + LOG_W(HW,"Dropping late packet\n"); + continue; + } + } + + rcved++; + bufferZone+=ret; + } + + LOG_D(HW,"Received: blocks: %d/%d, size %d, TS: %lu\n", + rcved, bufOrigin->nbBlocks, ret, bufOrigin->timestamp); + } while ( rcved == 0 || rcved < bufOrigin->nbBlocks ); + + return rcved; +} + +int sendSubFrame(UDPsock_t *sock, void *bufferZone, ssize_t secondHeaderSize, uint16_t contentType) { + commonUDP_t *UDPheader=(commonUDP_t *)bufferZone ; + UDPheader->contentType=contentType; + UDPheader->senderClock=rdtsc(); + int nbBlocks=UDPheader->nbBlocks; + int blockId=0; + + if (nbBlocks <= 0 ) { + LOG_E(PHY,"FS6: can't send blocks: %d\n", nbBlocks); + return 0; + } + + do { + if (blockId > 0 ) { + commonUDP_t *currentHeader=(commonUDP_t *)bufferZone; + currentHeader->timestamp=UDPheader->timestamp; + currentHeader->nbBlocks=UDPheader->nbBlocks; + currentHeader->blockID=blockId; + currentHeader->contentType=UDPheader->contentType; + memcpy(commonUDPdata((void *)currentHeader), commonUDPdata(bufferZone), secondHeaderSize); + } + + blockId++; + int sz=alignedSize(bufferZone); + // Let's use the first address returned by getaddrinfo() + int ret=sendto(sock->sockHandler, bufferZone, sz, 0, + sock->destAddr->ai_addr, sock->destAddr->ai_addrlen); + + if ( ret != sz ) + LOG_W(HW,"Wrote socket doesn't return size %d (val: %d, errno:%d, %s)\n", + sz, ret, errno, strerror(errno)); + + LOG_D(HW,"Sent: TS: %lu, blocks %d/%d, block size : %d \n", + UDPheader->timestamp, UDPheader->nbBlocks-nbBlocks, UDPheader->nbBlocks, sz); + bufferZone+=sz; + nbBlocks--; + } while (nbBlocks); + + return 0; +} diff --git a/nfapi/oai_integration/nfapi.c b/nfapi/oai_integration/nfapi.c index 4fc35fd951..86d1ae3127 100644 --- a/nfapi/oai_integration/nfapi.c +++ b/nfapi/oai_integration/nfapi.c @@ -29,7 +29,7 @@ typedef struct { nfapi_mode_t nfapi_mode; } nfapi_params_t; -static nfapi_params_t nfapi_params; +static nfapi_params_t nfapi_params = {0}; void set_thread_priority(int priority) { //printf("%s(priority:%d)\n", __FUNCTION__, priority); diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index f07fb1ad23..37b57e899d 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -692,13 +692,14 @@ void pnf_phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) { free(header); } -int pnf_phy_hi_dci0_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_hi_dci0_request_t *req) { +int pnf_phy_hi_dci0_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_hi_dci0_request_t *req) { if (req->hi_dci0_request_body.number_of_dci == 0 && req->hi_dci0_request_body.number_of_hi == 0) LOG_D(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi); //phy_info* phy = (phy_info*)(pnf_p7->user_data); struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - L1_rxtx_proc_t *proc = &eNB->proc.L1_proc; + if (proc ==NULL) + proc = &eNB->proc.L1_proc; for (int i=0; ihi_dci0_request_body.number_of_dci + req->hi_dci0_request_body.number_of_hi; i++) { //LOG_D(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); @@ -719,7 +720,7 @@ int pnf_phy_hi_dci0_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_hi_dci0_request_t * return 0; } -int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { +int pnf_phy_dl_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { if (RC.ru == 0) { return -1; } @@ -740,7 +741,8 @@ int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); int sf = NFAPI_SFNSF2SF(req->sfn_sf); struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - L1_rxtx_proc_t *proc = &eNB->proc.L1_proc; + if (proc==NULL) + proc = &eNB->proc.L1_proc; nfapi_dl_config_request_pdu_t *dl_config_pdu_list = req->dl_config_request_body.dl_config_pdu_list; LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[sf&1]; pdcch_vars->num_pdcch_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols; @@ -797,7 +799,7 @@ int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request uint8_t *dlsch_sdu = tx_pdus[UE_id][harq_pid]; memcpy(dlsch_sdu, tx_pdu->segments[0].segment_data, tx_pdu->segments[0].segment_length); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() DLSCH:pdu_index:%d handle_nfapi_dlsch_pdu(eNB, proc_rxtx, dlsch_pdu, transport_blocks:%d sdu:%p) eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols:%d\n", __FUNCTION__, rel8_pdu->pdu_index, rel8_pdu->transport_blocks, dlsch_sdu, eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols); - handle_nfapi_dlsch_pdu( eNB, sfn,sf, &eNB->proc.L1_proc, &dl_config_pdu_list[i], rel8_pdu->transport_blocks-1, dlsch_sdu); + handle_nfapi_dlsch_pdu( eNB, sfn,sf, proc, &dl_config_pdu_list[i], rel8_pdu->transport_blocks-1, dlsch_sdu); } else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() DLSCH NULL TX PDU SFN/SF:%d PDU_INDEX:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), rel8_pdu->pdu_index); } @@ -837,7 +839,7 @@ int pnf_phy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { return 0; } -int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request_t *req) { +int pnf_phy_ul_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request_t *req) { if (0)LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), @@ -866,7 +868,8 @@ int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request uint16_t curr_sfn = NFAPI_SFNSF2SFN(req->sfn_sf); uint16_t curr_sf = NFAPI_SFNSF2SF(req->sfn_sf); struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - L1_rxtx_proc_t *proc = &eNB->proc.L1_proc; + if (proc==NULL) + proc = &eNB->proc.L1_proc; nfapi_ul_config_request_pdu_t *ul_config_pdu_list = req->ul_config_request_body.ul_config_pdu_list; for (int i=0; iul_config_request_body.number_of_pdus; i++) { diff --git a/nfapi/oai_integration/nfapi_pnf.h b/nfapi/oai_integration/nfapi_pnf.h index e213d785f1..2c8201737c 100644 --- a/nfapi/oai_integration/nfapi_pnf.h +++ b/nfapi/oai_integration/nfapi_pnf.h @@ -23,5 +23,5 @@ #define NFAPI_PNF_H__ int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port); - +void oai_subframe_ind(uint16_t sfn, uint16_t sf); #endif diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index 1eea6474f3..408da13718 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -11,6 +11,7 @@ #include "stddef.h" #include "nfapi_interface.h" +#include #define NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS 5 #define NFAPI_NR_MAX_NB_TCI_STATES_PDCCH 64 diff --git a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h index 8d17416a41..d169177d6b 100644 --- a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h +++ b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h @@ -24,6 +24,7 @@ extern "C" { #include "nfapi_interface.h" #include "debug.h" +#include #include @@ -619,21 +620,21 @@ typedef struct nfapi_pnf_p7_config * \param req A pointer to the dl config request message structure * \return not currently used */ - int (*dl_config_req)(nfapi_pnf_p7_config_t* config, nfapi_dl_config_request_t* req); + int (*dl_config_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_dl_config_request_t* req); /*! A callback for the UL_CONFIG.request * \param config A poiner to the PNF P7 config * \param req A pointer to the ul config request message structure * \return not currently used */ - int (*ul_config_req)(nfapi_pnf_p7_config_t* config, nfapi_ul_config_request_t* req); + int (*ul_config_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_ul_config_request_t* req); /*! A callback for the HI_DCI0.request * \param config A poiner to the PNF P7 config * \param req A pointer to the hi dci0 request message structure * \return not currently used */ - int (*hi_dci0_req)(nfapi_pnf_p7_config_t* config, nfapi_hi_dci0_request_t* req); + int (*hi_dci0_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_hi_dci0_request_t* req); /*! A callback for the TX_REQ.request * \param config A poiner to the PNF P7 config diff --git a/nfapi/open-nFAPI/pnf/src/pnf_interface.c b/nfapi/open-nFAPI/pnf/src/pnf_interface.c index 7310fc0c66..dda0d0fdc6 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_interface.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_interface.c @@ -39,7 +39,7 @@ nfapi_pnf_config_t* nfapi_pnf_config_create() _this->_public.codec_config.allocate = &malloc; _this->_public.codec_config.deallocate = &free; - return &(_this->_public); + return (nfapi_pnf_config_t* )_this; } void nfapi_pnf_config_destory(nfapi_pnf_config_t* config) diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7.c b/nfapi/open-nFAPI/pnf/src/pnf_p7.c index 9446730375..5ba912e059 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7.c @@ -576,20 +576,20 @@ void send_dummy_subframe(pnf_p7_t* pnf_p7, uint16_t sfn_sf) { pnf_p7->_public.dummy_subframe.dl_config_req->sfn_sf = sfn_sf; //NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy dl_config_req - enter\n"); - (pnf_p7->_public.dl_config_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.dl_config_req); + (pnf_p7->_public.dl_config_req)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_subframe.dl_config_req); //NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy dl_config_req - exit\n"); } if(pnf_p7->_public.ul_config_req && pnf_p7->_public.dummy_subframe.ul_config_req) { pnf_p7->_public.dummy_subframe.ul_config_req->sfn_sf = sfn_sf; NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy ul_config_req - enter\n"); - (pnf_p7->_public.ul_config_req)(&pnf_p7->_public, pnf_p7->_public.dummy_subframe.ul_config_req); + (pnf_p7->_public.ul_config_req)(NULL, &pnf_p7->_public, pnf_p7->_public.dummy_subframe.ul_config_req); } if(pnf_p7->_public.hi_dci0_req && pnf_p7->_public.dummy_subframe.hi_dci0_req) { pnf_p7->_public.dummy_subframe.hi_dci0_req->sfn_sf = sfn_sf; NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy hi_dci0 - enter\n"); - (pnf_p7->_public.hi_dci0_req)(&pnf_p7->_public, pnf_p7->_public.dummy_subframe.hi_dci0_req); + (pnf_p7->_public.hi_dci0_req)(NULL, &pnf_p7->_public, pnf_p7->_public.dummy_subframe.hi_dci0_req); } if(pnf_p7->_public.lbt_dl_config_req && pnf_p7->_public.dummy_subframe.lbt_dl_config_req) { @@ -699,7 +699,7 @@ int pnf_p7_subframe_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn_sf) if(tx_subframe_buffer->dl_config_req != 0) { if(pnf_p7->_public.dl_config_req) - (pnf_p7->_public.dl_config_req)(&(pnf_p7->_public), tx_subframe_buffer->dl_config_req); + (pnf_p7->_public.dl_config_req)(NULL, &(pnf_p7->_public), tx_subframe_buffer->dl_config_req); //deallocate_nfapi_dl_config_request(subframe_buffer->dl_config_req, pnf_p7); } @@ -709,14 +709,14 @@ int pnf_p7_subframe_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn_sf) if(pnf_p7->_public.dl_config_req && pnf_p7->_public.dummy_subframe.dl_config_req) { pnf_p7->_public.dummy_subframe.dl_config_req->sfn_sf = sfn_sf_tx; - (pnf_p7->_public.dl_config_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.dl_config_req); + (pnf_p7->_public.dl_config_req)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_subframe.dl_config_req); } } if(tx_subframe_buffer->hi_dci0_req != 0) { if(pnf_p7->_public.hi_dci0_req) - (pnf_p7->_public.hi_dci0_req)(&(pnf_p7->_public), tx_subframe_buffer->hi_dci0_req); + (pnf_p7->_public.hi_dci0_req)(NULL, &(pnf_p7->_public), tx_subframe_buffer->hi_dci0_req); //deallocate_nfapi_hi_dci0_request(subframe_buffer->hi_dci0_req, pnf_p7); } @@ -726,7 +726,7 @@ int pnf_p7_subframe_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn_sf) if(pnf_p7->_public.hi_dci0_req && pnf_p7->_public.dummy_subframe.hi_dci0_req) { pnf_p7->_public.dummy_subframe.hi_dci0_req->sfn_sf = sfn_sf_tx; - (pnf_p7->_public.hi_dci0_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.hi_dci0_req); + (pnf_p7->_public.hi_dci0_req)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_subframe.hi_dci0_req); } } @@ -777,7 +777,7 @@ int pnf_p7_subframe_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn_sf) if(subframe_buffer->ul_config_req != 0) { if(pnf_p7->_public.ul_config_req) - (pnf_p7->_public.ul_config_req)(&(pnf_p7->_public), subframe_buffer->ul_config_req); + (pnf_p7->_public.ul_config_req)(NULL, &(pnf_p7->_public), subframe_buffer->ul_config_req); //deallocate_nfapi_ul_config_request(subframe_buffer->ul_config_req, pnf_p7); } @@ -787,7 +787,7 @@ int pnf_p7_subframe_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn_sf) if(pnf_p7->_public.ul_config_req && pnf_p7->_public.dummy_subframe.ul_config_req) { pnf_p7->_public.dummy_subframe.ul_config_req->sfn_sf = sfn_sf; - (pnf_p7->_public.ul_config_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.ul_config_req); + (pnf_p7->_public.ul_config_req)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_subframe.ul_config_req); } } diff --git a/nfapi/open-nFAPI/vnf/src/vnf_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_interface.c index 0aba0a29f5..59d7f3eb4f 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_interface.c @@ -55,7 +55,7 @@ nfapi_vnf_config_t* nfapi_vnf_config_create() _this->_public.codec_config.deallocate = &free; - return &(_this->_public); + return (nfapi_vnf_config_t* )_this; } void nfapi_vnf_config_destory(nfapi_vnf_config_t* config) diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c index 8b60122483..b7adc808ca 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c @@ -47,7 +47,7 @@ nfapi_vnf_p7_config_t* nfapi_vnf_p7_config_create() _this->_public.codec_config.deallocate = &free; - return &(_this->_public); + return (nfapi_vnf_p7_config_t*)_this; } void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config) diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 95ee3fed17..0af006beef 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -525,7 +525,7 @@ int main(int argc, char *argv[]) time_stats_t time_optim[10], time_decoder[10]; n_iter_stats_t dec_iter[3]; - short BG=0,Zc,Kb; + short BG=0,Zc,Kb=0; while ((c = getopt (argc, argv, "q:r:s:S:l:n:d:i:t:u:h")) != -1) switch (c) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index f0ad3cbaae..61307b7389 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -45,7 +45,7 @@ extern uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_nrarfcn); extern int32_t get_nr_uldl_offset(int nr_bandP);*/ extern openair0_config_t openair0_cfg[MAX_CARDS]; - +extern uint8_t threequarter_fs; int l1_north_init_gNB() { if (RC.nb_nr_L1_inst > 0 && RC.nb_nr_L1_CC != NULL && RC.gNB != NULL) { @@ -450,7 +450,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) fp->dl_CarrierFreq = from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); get_band(fp->dl_CarrierFreq, &gNB_config->nfapi_config.rf_bands.rf_band[0], &uplink_frequency_offset[CC_id][0], &fp->frame_type); fp->ul_CarrierFreq = fp->dl_CarrierFreq + uplink_frequency_offset[CC_id][0]; - fp->threequarter_fs = openair0_cfg[0].threequarter_fs; + fp->threequarter_fs = threequarter_fs; LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,DL freq %u, UL freq %u)\n", Mod_id, CC_id, diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c index 43c0350efb..2331e253d5 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c @@ -43,7 +43,7 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue, uint8_t pilot0,pilot1,pilot2,pilot3; short ch[2], *pil, *rxF, *dl_bf_ch, *dl_bf_ch_prev; - short *fl, *fm, *fr, *fl_dc, *fm_dc, *fr_dc, *f1, *f2l, *f2r; + short *fl=NULL, *fm=NULL, *fr=NULL, *fl_dc=NULL, *fm_dc=NULL, *fr_dc=NULL, *f1, *f2l=NULL, *f2r=NULL; unsigned int *rballoc; int **rxdataF; @@ -58,10 +58,10 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue, dlsch0_harq = dlsch_ue[0]->harq_processes[harq_pid]; if (((frame_parms->Ncp == NORMAL) && (symbol>=7)) || - ((frame_parms->Ncp == EXTENDED) && (symbol>=6))) - rballoc = dlsch0_harq->rb_alloc_odd; + ((frame_parms->Ncp == EXTENDED) && (symbol>=6))) + rballoc = dlsch0_harq->rb_alloc_odd; else - rballoc = dlsch0_harq->rb_alloc_even; + rballoc = dlsch0_harq->rb_alloc_even; rxdataF = phy_vars_ue->common_vars.common_vars_rx_data_per_thread[phy_vars_ue->current_thread_id[Ns>>1]].rxdataF; @@ -69,56 +69,56 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue, beamforming_mode = phy_vars_ue->transmission_mode[eNB_id]>6 ? phy_vars_ue->transmission_mode[eNB_id] : 0; if (phy_vars_ue->high_speed_flag == 0) // use second channel estimate position for temporary storage - ch_offset = frame_parms->ofdm_symbol_size; + ch_offset = frame_parms->ofdm_symbol_size; else - ch_offset = frame_parms->ofdm_symbol_size*symbol; + ch_offset = frame_parms->ofdm_symbol_size*symbol; + - uespec_nushift = frame_parms->Nid_cell%3; subframe = Ns>>1; - - //generate ue specific pilots - lprime = symbol/3-1; - lte_dl_ue_spec_rx(phy_vars_ue,uespec_pilot,Ns,5,lprime,0,dlsch0_harq->nb_rb); - //LOG_M("uespec_pilot_rx.m","uespec_pilot",uespec_pilot,300,1,1); - if (frame_parms->Ncp==0){ - if (symbol==3 || symbol==6 || symbol==9 || symbol==12) - uespec_pilots = 1; - } else{ - if (symbol==4 || symbol==7 || symbol==10) - uespec_pilots = 1; - } - - if ((frame_parms->Ncp==0 && (symbol==6 ||symbol ==12)) || (frame_parms->Ncp==1 && symbol==7)) - uespec_poffset = 2; + //generate ue specific pilots + lprime = symbol/3-1; + lte_dl_ue_spec_rx(phy_vars_ue,uespec_pilot,Ns,5,lprime,0,dlsch0_harq->nb_rb); + //LOG_M("uespec_pilot_rx.m","uespec_pilot",uespec_pilot,300,1,1); - if (phy_vars_ue->frame_parms.Ncp == 0) { // normal prefix - pilot0 = 3; - pilot1 = 6; - pilot2 = 9; - pilot3 = 12; - } else { // extended prefix - pilot0 = 4; - pilot1 = 7; - pilot2 = 10; - } + if (frame_parms->Ncp==0){ + if (symbol==3 || symbol==6 || symbol==9 || symbol==12) + uespec_pilots = 1; + } else{ + if (symbol==4 || symbol==7 || symbol==10) + uespec_pilots = 1; + } - //define the filter - pil_offset = (uespec_nushift+uespec_poffset)%3; - // printf("symbol=%d,pil_offset=%d\n",symbol,pil_offset); - switch (pil_offset) { - case 0: - fl = filt16_l0; - fm = filt16_m0; - fr = filt16_r0; - fl_dc = filt16_l0; - fm_dc = filt16_m0; - fr_dc = filt16_r0; - f1 = filt16_1; - f2l = filt16_2l0; - f2r = filt16_2r0; + if ((frame_parms->Ncp==0 && (symbol==6 ||symbol ==12)) || (frame_parms->Ncp==1 && symbol==7)) + uespec_poffset = 2; + + if (phy_vars_ue->frame_parms.Ncp == 0) { // normal prefix + pilot0 = 3; + pilot1 = 6; + pilot2 = 9; + pilot3 = 12; + } else { // extended prefix + pilot0 = 4; + pilot1 = 7; + pilot2 = 10; + } + + //define the filter + pil_offset = (uespec_nushift+uespec_poffset)%3; + // printf("symbol=%d,pil_offset=%d\n",symbol,pil_offset); + switch (pil_offset) { + case 0: + fl = filt16_l0; + fm = filt16_m0; + fr = filt16_r0; + fl_dc = filt16_l0; + fm_dc = filt16_m0; + fr_dc = filt16_r0; + f1 = filt16_1; + f2l = filt16_2l0; + f2r = filt16_2r0; break; case 1: diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c index 2e4f3e6036..880c056578 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c @@ -1029,7 +1029,7 @@ void lte_ue_measurements(PHY_VARS_UE *ue, int N_RB_DL = frame_parms->N_RB_DL; - int rank_tm3_tm4; + int rank_tm3_tm4=-1; ue->measurements.nb_antennas_rx = frame_parms->nb_antennas_rx; diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index cb001f9dc4..5a0751c5ef 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -50,8 +50,11 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB, int32_t **ul_ch_estimates_time = (eNB!=NULL) ? pusch_vars->drs_ch_estimates_time : calibration->drs_ch_estimates_time; AssertFatal(ul_ch_estimates_time != NULL, "ul_ch_estimates_time is null\n"); int32_t **rxdataF_ext = (eNB!=NULL) ? pusch_vars->rxdataF_ext : calibration->rxdataF_ext; - int subframe = (eNB!=NULL) ? proc->subframe_rx : ru->proc.tti_rx; - uint8_t harq_pid; + + int subframe = proc->subframe_rx; + + uint8_t harq_pid; + int16_t delta_phase = 0; int16_t *ru1 = ru_90; int16_t *ru2 = ru_90; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 6595158f1a..15eb5206a1 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -20,15 +20,15 @@ */ /*! \file PHY/LTE_TRANSPORT/dlsch_coding.c -* \brief Top-level routines for implementing Turbo-coded (DLSCH) transport channels from 36-212, V8.6 2009-03 -* \author R. Knopp -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: knopp@eurecom.fr -* \note -* \warning -*/ + * \brief Top-level routines for implementing Turbo-coded (DLSCH) transport channels from 36-212, V8.6 2009-03 + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ #include "PHY/defs_eNB.h" #include "PHY/phy_extern.h" @@ -42,22 +42,23 @@ #include "common/utils/LOG/log.h" #include "targets/RT/USER/lte-softmodem.h" #include -#include "executables/thread-common.h" +#include "targets/RT/USER/rt_wrapper.h" +#include //#define DEBUG_DLSCH_CODING //#define DEBUG_DLSCH_FREE 1 /* -#define is_not_pilot(pilots,first_pilot,re) (pilots==0) || \ + #define is_not_pilot(pilots,first_pilot,re) (pilots==0) || \ ((pilots==1)&&(first_pilot==1)&&(((re>2)&&(re<6))||((re>8)&&(re<12)))) || \ ((pilots==1)&&(first_pilot==0)&&(((re<3))||((re>5)&&(re<9)))) \ */ #define is_not_pilot(pilots,first_pilot,re) (1) /*extern void thread_top_init(char *thread_name, - int affinity, - uint64_t runtime, - uint64_t deadline, - uint64_t period);*/ + int affinity, + uint64_t runtime, + uint64_t deadline, + uint64_t period);*/ extern volatile int oai_exit; @@ -83,11 +84,6 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); dlsch->harq_processes[i]->c[r] = NULL; } - - if (dlsch->harq_processes[i]->d[r]) { - free16(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144))); - dlsch->harq_processes[i]->d[r] = NULL; - } } free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t)); @@ -108,26 +104,26 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, LTE_DL_FRAME_PARMS *frame_parms) { LTE_eNB_DLSCH_t *dlsch; - unsigned char exit_flag = 0,i,j,r,aa,layer; + unsigned char exit_flag = 0,i,r,aa,layer; int re; unsigned char bw_scaling =1; switch (N_RB_DL) { - case 6: - bw_scaling =16; - break; + case 6: + bw_scaling =16; + break; - case 25: - bw_scaling =4; - break; + case 25: + bw_scaling =4; + break; - case 50: - bw_scaling =2; - break; + case 50: + bw_scaling =2; + break; - default: - bw_scaling =1; - break; + default: + bw_scaling =1; + break; } dlsch = (LTE_eNB_DLSCH_t *)malloc16(sizeof(LTE_eNB_DLSCH_t)); @@ -153,11 +149,11 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, // NOTE: THIS HAS TO BE REVISED FOR RU, commenting to remove memory leak !!!!! /* - dlsch->calib_dl_ch_estimates = (int32_t**)malloc16(frame_parms->nb_antennas_tx*sizeof(int32_t*)); - for (aa=0; aanb_antennas_tx; aa++) { - dlsch->calib_dl_ch_estimates[aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t)); + dlsch->calib_dl_ch_estimates = (int32_t**)malloc16(frame_parms->nb_antennas_tx*sizeof(int32_t*)); + for (aa=0; aanb_antennas_tx; aa++) { + dlsch->calib_dl_ch_estimates[aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t)); - }*/ + }*/ for (i=0; i<20; i++) dlsch->harq_ids[i/10][i%10] = Mdlharq; @@ -183,7 +179,6 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, for (r=0; rharq_processes[i]->c[r] = (uint8_t *)malloc16(((r==0)?8:0) + 3+ 768); - dlsch->harq_processes[i]->d[r] = (uint8_t *)malloc16((96+12+3+(3*6144))); if (dlsch->harq_processes[i]->c[r]) { bzero(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+ 768); @@ -191,13 +186,6 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, printf("Can't get c\n"); exit_flag=2; } - - if (dlsch->harq_processes[i]->d[r]) { - bzero(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144))); - } else { - printf("Can't get d\n"); - exit_flag=2; - } } } } else { @@ -209,13 +197,6 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, if (exit_flag==0) { for (i=0; iharq_processes[i]->round=0; - - for (j=0; j<96; j++) - for (r=0; rharq_processes[%d]->d[%d] %p\n",i,r,dlsch->harq_processes[i]->d[r]); - if (dlsch->harq_processes[i]->d[r]) - dlsch->harq_processes[i]->d[r][j] = LTE_NULL; - } } return(dlsch); @@ -231,7 +212,7 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) { unsigned char Mdlharq; - unsigned char i,j,r; + unsigned char i; if (dlsch) { Mdlharq = dlsch->Mdlharq; @@ -255,307 +236,17 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) { dlsch->harq_processes[i]->status = 0; dlsch->harq_processes[i]->round = 0; - for (j=0; j<96; j++) - for (r=0; rharq_processes[i]->d[r]) - dlsch->harq_processes[i]->d[r][j] = LTE_NULL; } } } } - -int dlsch_encoding_2threads0(te_params *tep) { - LTE_eNB_DLSCH_t *dlsch = tep->dlsch; - unsigned int G = tep->G; - unsigned char harq_pid = tep->harq_pid; - unsigned int total_worker = tep->total_worker; - unsigned int current_worker = tep->current_worker; - unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; - unsigned int Kr=0,Kr_bytes,r,r_offset=0; - // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_IN); - - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - for (r=(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*current_worker; r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker+1); r++) { - if (rharq_processes[harq_pid]->Cminus) - Kr = dlsch->harq_processes[harq_pid]->Kminus; - else - Kr = dlsch->harq_processes[harq_pid]->Kplus; - - Kr_bytes = Kr>>3; - encoder(dlsch->harq_processes[harq_pid]->c[r], - Kr>>3, - &dlsch->harq_processes[harq_pid]->d[r][96], - (r==0) ? dlsch->harq_processes[harq_pid]->F : 0 - ); - dlsch->harq_processes[harq_pid]->RTC[r] = - sub_block_interleaving_turbo(4+(Kr_bytes*8), - &dlsch->harq_processes[harq_pid]->d[r][96], - dlsch->harq_processes[harq_pid]->w[r]); - } - } - - // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the - // outputs for each code segment, see Section 5.1.5 p.20 - - for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker+1); r++) { - if(r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker)) { - int Nl=dlsch->harq_processes[harq_pid]->Nl; - int Qm=dlsch->harq_processes[harq_pid]->Qm; - int C = dlsch->harq_processes[harq_pid]->C; - int Gp = G/Nl/Qm; - int GpmodC = Gp%C; - - if (r < (C-(GpmodC))) - r_offset += Nl*Qm * (Gp/C); - else - r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); - } else { - r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], - G, //G - dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->C, // C - dlsch->Nsoft, // Nsoft, - dlsch->Mdlharq, - dlsch->Kmimo, - dlsch->harq_processes[harq_pid]->rvidx, - dlsch->harq_processes[harq_pid]->Qm, - dlsch->harq_processes[harq_pid]->Nl, - r, - nb_rb); - // m); // r - } - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_OUT); - return(0); -} - - void *te_thread(void *param) { - te_params *tep = (te_params *)param; - - //wait_sync("te_thread"); - - while (!oai_exit) { - if (wait_on_condition(&tep->mutex_te,&tep->cond_te,&tep->instance_cnt_te,"te thread")<0) break; - - if(oai_exit) break; - - dlsch_encoding_2threads0(tep); - - if (release_thread(&tep->mutex_te,&tep->instance_cnt_te,"te thread")<0) break; - - if (pthread_cond_signal(&tep->cond_te) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return(NULL); - } - - /*if(opp_enabled == 1 && te_wakeup_stats0->p_time>50*3000){ - print_meas_now(te_wakeup_stats0,"coding_wakeup",stderr); - printf("te_thread0 delay for waking up in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); - }*/ - } - return(NULL); } - -int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, - unsigned char *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *te_wait_stats, - time_stats_t *te_main_stats, - time_stats_t *te_wakeup_stats0, - time_stats_t *te_wakeup_stats1, - time_stats_t *i_stats, - int worker_num) { - //start_meas(&eNB->dlsch_turbo_encoding_preperation_stats); - LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; - L1_proc_t *proc = &eNB->proc; - unsigned int G; - unsigned int crc=1; - unsigned char harq_pid = dlsch->harq_ids[frame%2][subframe]; - if((harq_pid < 0) || (harq_pid >= dlsch->Mdlharq)) { - LOG_E(PHY,"dlsch_encoding_2threads illegal harq_pid %d %s:%d\n", harq_pid, __FILE__, __LINE__); - return(-1); - } - - unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; - unsigned int A; - unsigned char mod_order; - unsigned int Kr=0,Kr_bytes,r,r_offset=0; - // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); - A = dlsch->harq_processes[harq_pid]->TBS; //6228 - mod_order = dlsch->harq_processes[harq_pid]->Qm; - G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe, - dlsch->harq_processes[harq_pid]->mimo_mode==TM7?7:0); - - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - start_meas(&eNB->dlsch_turbo_encoding_preperation_stats); - // Add 24-bit crc (polynomial A) to payload - crc = crc24a(a, - A)>>8; - stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats); - a[A>>3] = ((uint8_t *)&crc)[2]; - a[1+(A>>3)] = ((uint8_t *)&crc)[1]; - a[2+(A>>3)] = ((uint8_t *)&crc)[0]; - dlsch->harq_processes[harq_pid]->B = A+24; - memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); - //stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats); - start_meas(&eNB->dlsch_turbo_encoding_segmentation_stats); - - if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, - dlsch->harq_processes[harq_pid]->c, - dlsch->harq_processes[harq_pid]->B, - &dlsch->harq_processes[harq_pid]->C, - &dlsch->harq_processes[harq_pid]->Cplus, - &dlsch->harq_processes[harq_pid]->Cminus, - &dlsch->harq_processes[harq_pid]->Kplus, - &dlsch->harq_processes[harq_pid]->Kminus, - &dlsch->harq_processes[harq_pid]->F)<0) - return(-1); - - stop_meas(&eNB->dlsch_turbo_encoding_segmentation_stats); - start_meas(&eNB->dlsch_turbo_encoding_signal_stats); - - for(int i=0; itep[i].eNB = eNB; - proc->tep[i].dlsch = dlsch; - proc->tep[i].G = G; - proc->tep[i].harq_pid = harq_pid; - proc->tep[i].total_worker = worker_num; - proc->tep[i].current_worker = i; - pthread_mutex_lock( &proc->tep[i].mutex_te ); - - if (proc->tep[i].instance_cnt_te==0) { - printf("[eNB] TE thread busy\n"); - exit_fun("TE thread busy"); - pthread_mutex_unlock( &proc->tep[i].mutex_te ); - return(-1); - } - - ++proc->tep[i].instance_cnt_te; - - // wakeup worker to do segments - if (pthread_cond_signal(&proc->tep[i].cond_te) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread %d exit\n",i); - exit_fun( "ERROR pthread_cond_signal" ); - return (-1); - } - - pthread_mutex_unlock( &proc->tep[i].mutex_te ); - } - - stop_meas(&eNB->dlsch_turbo_encoding_signal_stats); - start_meas(te_main_stats); - - for (r=(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num; rharq_processes[harq_pid]->C; r++) { - if (rharq_processes[harq_pid]->Cminus) - Kr = dlsch->harq_processes[harq_pid]->Kminus; - else - Kr = dlsch->harq_processes[harq_pid]->Kplus; - - Kr_bytes = Kr>>3; - start_meas(te_stats); - encoder(dlsch->harq_processes[harq_pid]->c[r], - Kr>>3, - &dlsch->harq_processes[harq_pid]->d[r][96], - (r==0) ? dlsch->harq_processes[harq_pid]->F : 0 - ); - stop_meas(te_stats); - start_meas(i_stats); - dlsch->harq_processes[harq_pid]->RTC[r] = - sub_block_interleaving_turbo(4+(Kr_bytes*8), - &dlsch->harq_processes[harq_pid]->d[r][96], - dlsch->harq_processes[harq_pid]->w[r]); - stop_meas(i_stats); - } - } else { - for(int i=0; itep[i].eNB = eNB; - proc->tep[i].dlsch = dlsch; - proc->tep[i].G = G; - proc->tep[i].total_worker = worker_num; - proc->tep[i].current_worker = i; - - if (pthread_cond_signal(&proc->tep[i].cond_te) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (-1); - } - } - } - - // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the - // outputs for each code segment, see Section 5.1.5 p.20 - for (r=0,r_offset=0; rharq_processes[harq_pid]->C; r++) { - // get information for E for the segments that are handled by the worker thread - if (r<(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num) { - int Nl=dlsch->harq_processes[harq_pid]->Nl; - int Qm=dlsch->harq_processes[harq_pid]->Qm; - int C = dlsch->harq_processes[harq_pid]->C; - int Gp = G/Nl/Qm; - int GpmodC = Gp%C; - - if (r < (C-(GpmodC))) - r_offset += Nl*Qm * (Gp/C); - else - r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); - } else { - start_meas(rm_stats); - r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], - G, //G - dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->C, // C - dlsch->Nsoft, // Nsoft, - dlsch->Mdlharq, - dlsch->Kmimo, - dlsch->harq_processes[harq_pid]->rvidx, - dlsch->harq_processes[harq_pid]->Qm, - dlsch->harq_processes[harq_pid]->Nl, - r, - nb_rb); - // m); // r - stop_meas(rm_stats); - } - } - - stop_meas(te_main_stats); - start_meas(te_wait_stats); - - if(worker_num == 1) { - wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); - } else if(worker_num == 2) { - wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); - wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1"); - } else { - wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); - wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1"); - wait_on_busy_condition(&proc->tep[2].mutex_te,&proc->tep[2].cond_te,&proc->tep[2].instance_cnt_te,"te thread 2"); - } - - stop_meas(te_wait_stats); - /*if(opp_enabled == 1 && te_wait_stats->p_time>100*3000){ - print_meas_now(te_wait_stats,"coding_wait",stderr); - printf("coding delay in wait on codition in frame_rx: %d \n",proc->frame_rx); - }*/ - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); - return(0); -} - - int dlsch_encoding_all(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, unsigned char *a, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, @@ -568,108 +259,72 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, time_stats_t *te_wakeup_stats0, time_stats_t *te_wakeup_stats1, time_stats_t *i_stats) { - int encoding_return = 0; - unsigned int L,C,B; uint8_t harq_pid = dlsch->harq_ids[frame%2][subframe]; if(harq_pid >= dlsch->Mdlharq) { LOG_E(PHY,"dlsch_encoding_all illegal harq_pid %d\n", harq_pid); return(-1); } - B = dlsch->harq_processes[harq_pid]->B; + + LOG_D(PHY,"B %d, harq_pid %d\n", + dlsch->harq_processes[harq_pid]->B, + dlsch->harq_ids[frame%2][subframe]); - LOG_D(PHY,"B %d, harq_pid %d\n",B,dlsch->harq_ids[frame%2][subframe]); + return dlsch_encoding(eNB, + proc, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + i_stats); - if(B<=6144) { - L=0; - C=1; - } else { - L=24; - C = B/(6144-L); - - if((6144-L)*C < B) { - C = C+1; - } - } - - if(get_thread_worker_conf() == WORKER_ENABLE) { - if(C >= 8) { //one main three worker - encoding_return = - dlsch_encoding_2threads(eNB, - a, - num_pdcch_symbols, - dlsch, - frame, - subframe, - rm_stats, - te_stats, - te_wait_stats, - te_main_stats, - te_wakeup_stats0, - te_wakeup_stats1, - i_stats, - 3); - } else if(C >= 6) { //one main two worker - encoding_return = - dlsch_encoding_2threads(eNB, - a, - num_pdcch_symbols, - dlsch, - frame, - subframe, - rm_stats, - te_stats, - te_wait_stats, - te_main_stats, - te_wakeup_stats0, - te_wakeup_stats1, - i_stats, - 2); - } else if(C >= 4) { //one main one worker - encoding_return = - dlsch_encoding_2threads(eNB, - a, - num_pdcch_symbols, - dlsch, - frame, - subframe, - rm_stats, - te_stats, - te_wait_stats, - te_main_stats, - te_wakeup_stats0, - te_wakeup_stats1, - i_stats, - 1); - } else { - encoding_return = - dlsch_encoding(eNB, - a, - num_pdcch_symbols, - dlsch, - frame, - subframe, - rm_stats, - te_stats, - i_stats); - } - } else { - encoding_return = - dlsch_encoding(eNB, - a, - num_pdcch_symbols, - dlsch, - frame, - subframe, - rm_stats, - te_stats, - i_stats); - } - - return encoding_return; } +static void TPencode(void * arg) { + turboEncode_t * rdata=(turboEncode_t *) arg; + unsigned char harq_pid = rdata->harq_pid; + LTE_DL_eNB_HARQ_t *hadlsch=rdata->dlsch->harq_processes[harq_pid]; + + if ( rdata-> round == 0) { + uint8_t tmp[96+12+3+3*6144]; + memset(tmp,LTE_NULL, TURBO_SIMD_SOFTBITS); + start_meas(rdata->te_stats); + encoder(rdata->input, + rdata->Kr_bytes, + tmp+96,//&dlsch->harq_processes[harq_pid]->d[r][96], + rdata->filler); + stop_meas(rdata->te_stats); + start_meas(rdata->i_stats); + hadlsch->RTC[rdata->r] = + sub_block_interleaving_turbo(4+(rdata->Kr_bytes*8), + tmp+96, + hadlsch->w[rdata->r]); + stop_meas(rdata->i_stats); + } + + // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the + // outputs for each code segment, see Section 5.1.5 p.20 + start_meas(rdata->rm_stats); + lte_rate_matching_turbo(hadlsch->RTC[rdata->r], + rdata->G, //G + hadlsch->w[rdata->r], + hadlsch->eDL+rdata->r_offset, + hadlsch->C, // C + rdata->dlsch->Nsoft, // Nsoft, + rdata->dlsch->Mdlharq, + rdata->dlsch->Kmimo, + hadlsch->rvidx, + hadlsch->Qm, + hadlsch->Nl, + rdata->r, + hadlsch->nb_rb); + stop_meas(rdata->rm_stats); +} int dlsch_encoding(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, unsigned char *a, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, @@ -678,8 +333,6 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *i_stats) { - unsigned int G; - unsigned int crc=1; LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; unsigned char harq_pid = dlsch->harq_ids[frame%2][subframe]; if((harq_pid < 0) || (harq_pid >= dlsch->Mdlharq)) { @@ -687,135 +340,88 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, return(-1); } - unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; - unsigned int A; - unsigned char mod_order; - unsigned int Kr=0,Kr_bytes,r,r_offset=0; - // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; + LTE_DL_eNB_HARQ_t *hadlsch=dlsch->harq_processes[harq_pid]; uint8_t beamforming_mode=0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); - A = dlsch->harq_processes[harq_pid]->TBS; //6228 - // printf("Encoder: A: %d\n",A); - mod_order = dlsch->harq_processes[harq_pid]->Qm; - if(dlsch->harq_processes[harq_pid]->mimo_mode == TM7) + if(hadlsch->mimo_mode == TM7) beamforming_mode = 7; - else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM8) + else if(hadlsch->mimo_mode == TM8) beamforming_mode = 8; - else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM9_10) + else if(hadlsch->mimo_mode == TM9_10) beamforming_mode = 9; - G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe,beamforming_mode); + unsigned int G = get_G(frame_parms,hadlsch->nb_rb, + hadlsch->rb_alloc, + hadlsch->Qm, // mod order + hadlsch->Nl, + num_pdcch_symbols, + frame,subframe,beamforming_mode); - // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet -#ifdef DEBUG_DLSCH_CODING - printf("encoding thinks this is a new packet for harq_pid %d (%p), A %u \n",harq_pid,dlsch,A); -#endif - /* - int i; - printf("dlsch (tx): \n"); - for (i=0;i<(A>>3);i++) - printf("%02x.",a[i]); - printf("\n"); - */ + proc->nbEncode=0; + + // if (hadlsch->Ndi == 1) { // this is a new packet + if (hadlsch->round == 0) { // this is a new packet // Add 24-bit crc (polynomial A) to payload - crc = crc24a(a, + unsigned int A=hadlsch->TBS; //6228; + unsigned int crc = crc24a(a, A)>>8; a[A>>3] = ((uint8_t *)&crc)[2]; a[1+(A>>3)] = ((uint8_t *)&crc)[1]; a[2+(A>>3)] = ((uint8_t *)&crc)[0]; // printf("CRC %x (A %d)\n",crc,A); - dlsch->harq_processes[harq_pid]->B = A+24; - // dlsch->harq_processes[harq_pid]->b = a; - memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); - - if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, - dlsch->harq_processes[harq_pid]->c, - dlsch->harq_processes[harq_pid]->B, - &dlsch->harq_processes[harq_pid]->C, - &dlsch->harq_processes[harq_pid]->Cplus, - &dlsch->harq_processes[harq_pid]->Cminus, - &dlsch->harq_processes[harq_pid]->Kplus, - &dlsch->harq_processes[harq_pid]->Kminus, - &dlsch->harq_processes[harq_pid]->F)<0) + hadlsch->B = A+24; + // hadlsch->b = a; + memcpy(hadlsch->b,a,(A/8)+4); + + if (lte_segmentation(hadlsch->b, + hadlsch->c, + hadlsch->B, + &hadlsch->C, + &hadlsch->Cplus, + &hadlsch->Cminus, + &hadlsch->Kplus, + &hadlsch->Kminus, + &hadlsch->F)<0) return(-1); - - for (r=0; rharq_processes[harq_pid]->C; r++) { - if (rharq_processes[harq_pid]->Cminus) - Kr = dlsch->harq_processes[harq_pid]->Kminus; - else - Kr = dlsch->harq_processes[harq_pid]->Kplus; - - Kr_bytes = Kr>>3; -#ifdef DEBUG_DLSCH_CODING - printf("Generating Code Segment %u (%u bits)\n",r,Kr); - // generate codewords - printf("bits_per_codeword (Kr)= %u, A %u\n",Kr,A); - printf("N_RB = %d\n",nb_rb); - printf("Ncp %d\n",frame_parms->Ncp); - printf("mod_order %d\n",mod_order); -#endif - start_meas(te_stats); - encoder(dlsch->harq_processes[harq_pid]->c[r], - Kr>>3, - &dlsch->harq_processes[harq_pid]->d[r][96], - (r==0) ? dlsch->harq_processes[harq_pid]->F : 0 - ); - stop_meas(te_stats); -#ifdef DEBUG_DLSCH_CODING - - if (r==0) - LOG_M("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[r][96],(3*8*Kr_bytes)+12,1,4); - -#endif - start_meas(i_stats); - dlsch->harq_processes[harq_pid]->RTC[r] = - sub_block_interleaving_turbo(4+(Kr_bytes*8), - &dlsch->harq_processes[harq_pid]->d[r][96], - dlsch->harq_processes[harq_pid]->w[r]); - stop_meas(i_stats); + } + + for (int r=0, r_offset=0; rC; r++) { + + union turboReqUnion id= {.s={dlsch->rnti,frame,subframe,r,0}}; + notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(turboEncode_t), id.p, proc->respEncode, TPencode); + turboEncode_t * rdata=(turboEncode_t *) NotifiedFifoData(req); + rdata->input=hadlsch->c[r]; + rdata->Kr_bytes= ( rCminus ? hadlsch->Kminus : hadlsch->Kplus) >>3; + rdata->filler=(r==0) ? hadlsch->F : 0; + rdata->r=r; + rdata->harq_pid=harq_pid; + rdata->dlsch=dlsch; + rdata->rm_stats=rm_stats; + rdata->te_stats=te_stats; + rdata->i_stats=i_stats; + rdata->round=hadlsch->round; + rdata->r_offset=r_offset; + rdata->G=G; + + if ( proc->threadPool->activated ) { + pushTpool(proc->threadPool,req); + proc->nbEncode++; + } else { + TPencode(rdata); + delNotifiedFIFO_elt(req); } + + int Qm=hadlsch->Qm; + int C=hadlsch->C; + int Nl=hadlsch->Nl; + int Gp = G/Nl/Qm; + int GpmodC = Gp%C; + if (r < (C-(GpmodC))) + r_offset += Nl*Qm * (Gp/C); + else + r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); } - // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the - // outputs for each code segment, see Section 5.1.5 p.20 - - for (r=0; rharq_processes[harq_pid]->C; r++) { -#ifdef DEBUG_DLSCH_CODING - printf("Rate Matching, Code segment %u (coded bits (G) %u,unpunctured/repeated bits per code segment %u,mod_order %d, nb_rb %d)...\n", - r, - G, - Kr*3, - mod_order,nb_rb); -#endif - start_meas(rm_stats); -#ifdef DEBUG_DLSCH_CODING - printf("rvidx in encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx); -#endif - r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], - G, //G - dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->C, // C - dlsch->Nsoft, // Nsoft, - dlsch->Mdlharq, - dlsch->Kmimo, - dlsch->harq_processes[harq_pid]->rvidx, - dlsch->harq_processes[harq_pid]->Qm, - dlsch->harq_processes[harq_pid]->Nl, - r, - nb_rb); - // m); // r - stop_meas(rm_stats); -#ifdef DEBUG_DLSCH_CODING - - if (r==dlsch->harq_processes[harq_pid]->C-1) - LOG_M("enc_output.m","enc",dlsch->harq_processes[harq_pid]->e,r_offset,1,4); - -#endif - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); return(0); } diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 04a49d062a..475c8bd521 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -158,7 +158,7 @@ int allocate_REs_in_RB_no_pilots_QPSK_siso(PHY_VARS_eNB* phy_vars_eNB, { LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->frame_parms; - uint8_t *x0 = dlsch0_harq->e; + uint8_t *x0 = dlsch0_harq->eDL; uint32_t qpsk_table_offset_re = 0; uint32_t qpsk_table_offset_im = 0; @@ -248,7 +248,7 @@ int allocate_REs_in_RB_pilots_QPSK_siso(PHY_VARS_eNB* phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms=&phy_vars_eNB->frame_parms; - uint8_t *x0 = dlsch0_harq->e; + uint8_t *x0 = dlsch0_harq->eDL; uint32_t qpsk_table_offset_re = 0; uint32_t qpsk_table_offset_im = 0; @@ -343,7 +343,7 @@ int allocate_REs_in_RB_no_pilots_16QAM_siso(PHY_VARS_eNB* phy_vars_eNB, { LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->frame_parms; - uint8_t *x0 = dlsch0_harq->e; + uint8_t *x0 = dlsch0_harq->eDL; uint32_t qam16_table_offset_re = 0; uint32_t qam16_table_offset_im = 0; @@ -439,7 +439,7 @@ int allocate_REs_in_RB_pilots_16QAM_siso(PHY_VARS_eNB* phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms=&phy_vars_eNB->frame_parms; - uint8_t *x0 = dlsch0_harq->e; + uint8_t *x0 = dlsch0_harq->eDL; uint32_t qam16_table_offset_re = 0; uint32_t qam16_table_offset_im = 0; @@ -542,7 +542,7 @@ int allocate_REs_in_RB_no_pilots_64QAM_siso(PHY_VARS_eNB* phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->frame_parms; - uint8_t *x0 = dlsch0_harq->e; + uint8_t *x0 = dlsch0_harq->eDL; uint32_t qam64_table_offset_re = 0; uint32_t qam64_table_offset_im = 0; @@ -699,7 +699,7 @@ int allocate_REs_in_RB_pilots_64QAM_siso(PHY_VARS_eNB* phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms=&phy_vars_eNB->frame_parms; - uint8_t *x0 = dlsch0_harq->e; + uint8_t *x0 = dlsch0_harq->eDL; uint32_t qam64_table_offset_re = 0; uint32_t qam64_table_offset_im = 0; @@ -866,12 +866,12 @@ int allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, if ((dlsch0_harq != NULL) && (dlsch1_harq != NULL)) { //this is for TM3, TM4 - x0 = dlsch0_harq->e; + x0 = dlsch0_harq->eDL; mimo_mode = dlsch0_harq->mimo_mode; first_layer0 = dlsch0_harq->first_layer; Nlayers0 = dlsch0_harq->Nlayers; mod_order0 = dlsch0_harq->Qm; - x1 = dlsch1_harq->e; + x1 = dlsch1_harq->eDL; // Fill these in later for TM8-10 // Nlayers1 = dlsch1_harq->Nlayers; // first_layer1 = dlsch1_harq->first_layer; @@ -879,7 +879,7 @@ int allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, } else if ((dlsch0_harq != NULL) && (dlsch1_harq == NULL)){ //This is for SIS0 TM1, TM6, etc - x0 = dlsch0_harq->e; + x0 = dlsch0_harq->eDL; mimo_mode = dlsch0_harq->mimo_mode; first_layer0 = dlsch0_harq->first_layer; Nlayers0 = dlsch0_harq->Nlayers; @@ -887,7 +887,7 @@ int allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, } else if ((dlsch0_harq == NULL) && (dlsch1_harq != NULL)){ // This is for TM4 retransmission - x0 = dlsch1_harq->e; + x0 = dlsch1_harq->eDL; mimo_mode = dlsch1_harq->mimo_mode; first_layer0 = dlsch1_harq->first_layer; Nlayers0 = dlsch1_harq->Nlayers; @@ -2692,7 +2692,7 @@ int dlsch_modulation_SIC(int32_t **sic_buffer, LTE_DL_eNB_HARQ_t *dlsch0_harq = dlsch0->harq_processes[harq_pid]; uint32_t i,jj,re_allocated=0; uint8_t mod_order0 = dlsch0_harq->Qm; - uint8_t *x0 = dlsch0_harq->e; + uint8_t *x0 = dlsch0_harq->eDL; uint8_t qam64_table_offset_re = 0; uint8_t qam64_table_offset_im = 0; uint8_t qam16_table_offset_re = 0; @@ -2883,7 +2883,7 @@ int mch_modulation(int32_t **txdataF, &jj, re_offset, symbol_offset, - dlsch->harq_processes[0]->e, + dlsch->harq_processes[0]->eDL, l, mod_order, amp, diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c index 2e8ddde848..d48164e07d 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c @@ -52,7 +52,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, int n; // uint8_t reset; uint32_t x1, x2, s=0; - uint8_t *dlsch_e=dlsch->harq_processes[harq_pid]->e; + uint8_t *dlsch_e=dlsch->harq_processes[harq_pid]->eDL; uint8_t *e=dlsch_e; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_SCRAMBLING, VCD_FUNCTION_IN); // Rule for accumulation of subframes for BL/CE UEs diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.h b/openair1/PHY/LTE_TRANSPORT/if5_tools.h index 0f24f7bece..6c75b20bd9 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.h @@ -61,7 +61,8 @@ typedef struct IF5_mobipass_header IF5_mobipass_header_t; void send_IF5(RU_t *, openair0_timestamp, int, uint8_t*, uint16_t); -void recv_IF5(RU_t *, openair0_timestamp*, int, uint16_t); +void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16_t packet_type); + void malloc_IF5_buffer(RU_t *ru); diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index ab2fe2d743..6d8b58818b 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -714,7 +714,7 @@ void generate_phich_top(PHY_VARS_eNB *eNB, int32_t **txdataF = eNB->common_vars.txdataF; uint8_t Ngroup_PHICH,ngroup_PHICH,nseq_PHICH; uint8_t NSF_PHICH = 4; - uint8_t pusch_subframe; + uint8_t pusch_subframe=-1; uint8_t i; int subframe = proc->subframe_tx; phich_config_t *phich; diff --git a/openair1/PHY/LTE_TRANSPORT/pmch.c b/openair1/PHY/LTE_TRANSPORT/pmch.c index f48ee629a1..90e2836b1e 100644 --- a/openair1/PHY/LTE_TRANSPORT/pmch.c +++ b/openair1/PHY/LTE_TRANSPORT/pmch.c @@ -105,6 +105,7 @@ void generate_mch(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,uint8_t *a) AssertFatal(eNB->dlsch_MCH->harq_processes[0]->pdu != NULL, "attempt to encode a NULL harq PDU\n"); AssertFatal(dlsch_encoding(eNB, + proc, // a, eNB->dlsch_MCH->harq_processes[0]->pdu, 1, diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index 3471f98af7..99d8aa1bbc 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -38,9 +38,13 @@ #include "SCHED/sched_eNB.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "prach_extern.h" +#include +#include void rx_prach0(PHY_VARS_eNB *eNB, RU_t *ru, + int frame_prach, + int subframe, uint16_t *max_preamble, uint16_t *max_preamble_energy, uint16_t *max_preamble_delay, @@ -51,17 +55,14 @@ void rx_prach0(PHY_VARS_eNB *eNB, uint8_t ce_level ) { int i; - LTE_DL_FRAME_PARMS *fp=NULL; lte_frame_type_t frame_type; uint16_t rootSequenceIndex; uint8_t prach_ConfigIndex; uint8_t Ncs_config; uint8_t restricted_set; uint8_t n_ra_prb; - int subframe; int16_t *prachF=NULL; int16_t **rxsigF=NULL; - int nb_rx=0; int16_t *prach2; uint8_t preamble_index; uint16_t NCS,NCS2; @@ -89,6 +90,8 @@ void rx_prach0(PHY_VARS_eNB *eNB, int32_t **prach_ifftp=(int32_t **)NULL; int prach_ifft_cnt=0; + LTE_DL_FRAME_PARMS *fp; + int nb_rx; if(eNB) { fp = &(eNB->frame_parms); nb_rx = fp->nb_antennas_rx; @@ -96,7 +99,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, fp = (ru->frame_parms); nb_rx = ru->nb_rx; } - + AssertFatal(fp!=NULL,"rx_prach called without valid RU or eNB descriptor\n"); frame_type = fp->frame_type; @@ -133,14 +136,13 @@ void rx_prach0(PHY_VARS_eNB *eNB, if (eNB) { if (br_flag == 1) { prach_ifftp = eNB->prach_vars_br.prach_ifft[ce_level]; - subframe = eNB->proc.subframe_prach_br; prachF = eNB->prach_vars_br.prachF; rxsigF = eNB->prach_vars_br.rxsigF[ce_level]; if (LOG_DEBUGFLAG(PRACH)) { - if (((eNB->proc.frame_prach)&1023) < 20) LOG_I(PHY, + if (((frame_prach)&1023) < 20) LOG_I(PHY, "PRACH (eNB) : running rx_prach (br_flag %d, ce_level %d) for frame %d subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d, rootSequenceIndex %d, repetition number %d,numRepetitionsPrePreambleAttempt %d\n", - br_flag,ce_level,eNB->proc.frame_prach,subframe, + br_flag,ce_level,frame_prach,subframe, fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[ce_level], prach_ConfigIndex,rootSequenceIndex, eNB->prach_vars_br.repetition_number[ce_level], @@ -148,30 +150,27 @@ void rx_prach0(PHY_VARS_eNB *eNB, } } else { prach_ifftp = eNB->prach_vars.prach_ifft[0]; - subframe = eNB->proc.subframe_prach; prachF = eNB->prach_vars.prachF; rxsigF = eNB->prach_vars.rxsigF[0]; if (LOG_DEBUGFLAG(PRACH)) { - if (((eNB->proc.frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (eNB) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d , rootSequenceIndex %d\n", subframe, + if (((frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (eNB) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d , rootSequenceIndex %d\n", subframe, fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset,prach_ConfigIndex,rootSequenceIndex); } } } else { if (br_flag == 1) { - subframe = ru->proc.subframe_prach_br; rxsigF = ru->prach_rxsigF_br[ce_level]; if (LOG_DEBUGFLAG(PRACH)) { - if (((ru->proc.frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (RU) : running rx_prach (br_flag %d, ce_level %d) for frame %d subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n", - br_flag,ce_level,ru->proc.frame_prach,subframe,fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[ce_level],prach_ConfigIndex); + if (((frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (RU) : running rx_prach (br_flag %d, ce_level %d) for frame %d subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n", + br_flag,ce_level,frame_prach,subframe,fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[ce_level],prach_ConfigIndex); } } else { - subframe = ru->proc.subframe_prach; rxsigF = ru->prach_rxsigF; if (LOG_DEBUGFLAG(PRACH)) { - if (((ru->proc.frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (RU) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n", + if (((frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (RU) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n", subframe,fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset,prach_ConfigIndex); } } @@ -202,7 +201,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, if (prach[0]!= NULL) LOG_M("prach_rx","prach_rx",prach[0],fp->samples_per_tti,1,1); LOG_I(PHY,"RU %d, br_flag %d ce_level %d frame %d subframe %d per_tti:%d prach:%p (energy %d) TA:%d %s rxdata:%p index:%d\n", - ru->idx,br_flag,ce_level,ru->proc.frame_prach,subframe,fp->samples_per_tti, + ru->idx,br_flag,ce_level,frame_prach,subframe,fp->samples_per_tti, prach[aa],dbEn0,ru->N_TA_offset,buffer,ru->common.rxdata[aa], (subframe*fp->samples_per_tti)-ru->N_TA_offset); } @@ -407,16 +406,16 @@ void rx_prach0(PHY_VARS_eNB *eNB, if ((eNB==NULL) && ru->function == NGFI_RRU_IF4p5) { /// **** send_IF4 of rxsigF to RAU **** /// if (br_flag == 1) - send_IF4p5(ru, ru->proc.frame_prach, ru->proc.subframe_prach, IF4p5_PRACH+1+ce_level); + send_IF4p5(ru, frame_prach, subframe, IF4p5_PRACH+1+ce_level); else - send_IF4p5(ru, ru->proc.frame_prach, ru->proc.subframe_prach, IF4p5_PRACH); + send_IF4p5(ru, frame_prach, subframe, IF4p5_PRACH); return; } else if (eNB!=NULL) { if ( LOG_DEBUGFLAG(PRACH)) { int en = dB_fixed(signal_energy((int32_t *)&rxsigF[0][0],840)); - if ((en > 60)&&(br_flag==1)) LOG_I(PHY,"PRACH (br_flag %d,ce_level %d, n_ra_prb %d, k %d): Frame %d, Subframe %d => %d dB\n",br_flag,ce_level,n_ra_prb,k,eNB->proc.frame_rx,eNB->proc.subframe_rx,en); + if ((en > 60)&&(br_flag==1)) LOG_I(PHY,"PRACH (br_flag %d,ce_level %d, n_ra_prb %d, k %d): Frame %d, Subframe %d => %d dB\n",br_flag,ce_level,n_ra_prb,k,frame_prach,subframe,en); } } @@ -457,7 +456,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, if (LOG_DEBUGFLAG(PRACH)) { int en = dB_fixed(signal_energy((int32_t *)&rxsigF[0][0],840)); - if (en>60) LOG_I(PHY,"frame %d, subframe %d : Trying preamble %d (br_flag %d)\n",ru->proc.frame_prach,subframe,preamble_index,br_flag); + if (en>60) LOG_I(PHY,"frame %d, subframe %d : Trying preamble %d (br_flag %d)\n",frame_prach,subframe,preamble_index,br_flag); } if (restricted_set == 0) { @@ -543,7 +542,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, int en = dB_fixed(signal_energy((int32_t *)&rxsigF[0][0],840)); if (en>60) LOG_I(PHY,"frame %d, subframe %d : preamble index %d: offset %d, preamble shift %d (br_flag %d, en %d)\n", - ru->proc.frame_prach,subframe,preamble_index,preamble_offset,preamble_shift,br_flag,en); + frame_prach,subframe,preamble_index,preamble_offset,preamble_shift,br_flag,en); } log2_ifft_size = 10; @@ -618,7 +617,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, if (LOG_DEBUGFLAG(PRACH)) { int en = dB_fixed(signal_energy((int32_t *)&rxsigF[0][0],840)); - if (en>60) LOG_I(PHY,"frame %d, subframe %d: Checking for peak in time-domain (br_flag %d, en %d)\n",ru->proc.frame_prach,subframe,br_flag,en); + if (en>60) LOG_I(PHY,"frame %d, subframe %d: Checking for peak in time-domain (br_flag %d, en %d)\n",frame_prach,subframe,br_flag,en); } preamble_shift2 = ((preamble_shift==0) ? 0 : ((preamble_shift<60) && (br_flag==1)) LOG_D(PHY,"frame %d, subframe %d : max_preamble_energy %d, max_preamble_delay %d, max_preamble %d (br_flag %d,ce_level %d, levdB %d, lev %d)\n", - ru->proc.frame_prach,subframe, + frame_prach,subframe, *max_preamble_energy,*max_preamble_delay, *max_preamble,br_flag,ce_level,levdB,lev); } @@ -694,8 +693,16 @@ void rx_prach(PHY_VARS_eNB *eNB, int i; int prach_mask=0; + int subframe; + if (eNB) + subframe= br_flag?eNB->proc.subframe_prach_br:eNB->proc.subframe_prach; + else + subframe= br_flag?ru->proc.subframe_prach_br:ru->proc.subframe_prach; + + int frame_prach=eNB?eNB->proc.frame_prach: ru->proc.frame_prach; + if (br_flag == 0) { - rx_prach0(eNB,ru,max_preamble,max_preamble_energy,max_preamble_delay,avg_preamble_energy,Nf,tdd_mapindex,0,0); + rx_prach0(eNB,ru,frame_prach,subframe,max_preamble,max_preamble_energy,max_preamble_delay,avg_preamble_energy,Nf,tdd_mapindex,0,0); } else { // This is procedure for eMTC, basically handling the repetitions prach_mask = is_prach_subframe(&eNB->frame_parms,eNB->proc.frame_prach_br,eNB->proc.subframe_prach_br); @@ -709,7 +716,7 @@ void rx_prach(PHY_VARS_eNB *eNB, // increment repetition number eNB->prach_vars_br.repetition_number[i]++; // do basic PRACH reception - rx_prach0(eNB,ru,max_preamble,max_preamble_energy,max_preamble_delay,avg_preamble_energy,Nf,tdd_mapindex,1,i); + rx_prach0(eNB,ru,frame_prach,subframe,max_preamble,max_preamble_energy,max_preamble_delay,avg_preamble_energy,Nf,tdd_mapindex,1,i); // if last repetition, clear counter if (eNB->prach_vars_br.repetition_number[i] == eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[i]) { diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index e142d2f29f..8637e80137 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -180,7 +180,7 @@ uint16_t pucchfmt3_ChannelEstimation( int16_t SubCarrierDeMapData[NB_ANTENNAS_RX uint16_t n3_pucch_array[NUMBER_OF_UE_MAX], uint8_t ncs_cell[20][7] ) { uint32_t aa, symNo, k, slotNo, sym, i, j; - int16_t np, np_n, ip_ind; + int16_t np, np_n, ip_ind=-1; //int16_t npucch_sf; int16_t calctmp[2]; int16_t BsCshData[NB_ANTENNAS_RX][D_NSYM1SF][D_NSC1RB][2]; diff --git a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h index 7b9004ba80..5e446db5fd 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h @@ -100,7 +100,7 @@ typedef struct { /// start symbold of pdsch uint8_t pdsch_start; /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - uint8_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32))); + uint8_t eDL[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32))); /// Turbo-code outputs (36-212 V8.6 2009-03, p.12 uint8_t *d[MAX_NUM_DLSCH_SEGMENTS];//[(96+3+(3*6144))]; /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17) @@ -261,12 +261,13 @@ typedef struct { /// coded RI bits int16_t q_RI[MAX_RI_PAYLOAD]; /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - int16_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32))); + int16_t eUL[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32))); /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled uint8_t h[MAX_NUM_CHANNEL_BITS]; /// Pointer to the payload - uint8_t *b; + uint8_t *decodedBytes; /// Pointers to transport block segments + //TBD uint8_t *c[MAX_NUM_ULSCH_SEGMENTS]; /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS]; @@ -282,8 +283,12 @@ typedef struct { uint8_t rvidx; /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; + int16_t pusch_rep_buffer[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + //TBD int16_t *d[MAX_NUM_ULSCH_SEGMENTS]; + uint32_t processedSegments; + uint32_t processedBadSegment; /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) uint32_t C; /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) diff --git a/openair1/PHY/LTE_TRANSPORT/transport_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_proto.h index f034039e7e..3988923bb9 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_proto.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_proto.h @@ -73,18 +73,19 @@ void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch); LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); int dlsch_encoding_all(PHY_VARS_eNB *eNB, - unsigned char *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *te_wait_stats, - time_stats_t *te_main_stats, - time_stats_t *te_wakeup_stats0, - time_stats_t *te_wakeup_stats1, - time_stats_t *i_stats); + L1_rxtx_proc_t *proc, + unsigned char *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, + time_stats_t *i_stats); /** \fn dlsch_encoding(PHY_VARS_eNB *eNB, uint8_t *input_buffer, @@ -112,6 +113,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, @returns status */ int32_t dlsch_encoding(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, uint8_t *a, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, @@ -467,9 +469,12 @@ void rx_ulsch(PHY_VARS_eNB *eNB, int ulsch_decoding_data_all(PHY_VARS_eNB *eNB, - int UE_id, - int harq_pid, - int llr8_flag); + + L1_rxtx_proc_t *proc, + int UE_id, + int harq_pid, + int llr8_flag); + /*! \brief Decoding of PUSCH/ACK/RI/ACK from 36-212. @@ -511,6 +516,7 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB, @returns 0 on success */ int ulsch_decoding_data(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, int UE_id, int harq_pid, int llr8_flag); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 39556902fc..36a3cd9a5c 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -41,22 +41,22 @@ #include "RRC/LTE/rrc_extern.h" #include "PHY_INTERFACE/phy_interface.h" #include "transport_proto.h" -#include "common/utils/LOG/vcd_signal_dumper.h" - +#include extern WORKER_CONF_t get_thread_worker_conf(void); extern volatile int oai_exit; + void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch) { int i,r; if (ulsch) { for (i=0; i<8; i++) { if (ulsch->harq_processes[i]) { - if (ulsch->harq_processes[i]->b) { - free16(ulsch->harq_processes[i]->b,MAX_ULSCH_PAYLOAD_BYTES); - ulsch->harq_processes[i]->b = NULL; + if (ulsch->harq_processes[i]->decodedBytes) { + free16(ulsch->harq_processes[i]->decodedBytes,MAX_ULSCH_PAYLOAD_BYTES); + ulsch->harq_processes[i]->decodedBytes = NULL; } for (r=0; rharq_processes[i]) { memset(ulsch->harq_processes[i],0,sizeof(LTE_UL_eNB_HARQ_t)); - ulsch->harq_processes[i]->b = (uint8_t *)malloc16(MAX_ULSCH_PAYLOAD_BYTES/bw_scaling); + ulsch->harq_processes[i]->decodedBytes = (uint8_t *)malloc16(MAX_ULSCH_PAYLOAD_BYTES/bw_scaling); - if (ulsch->harq_processes[i]->b) - memset(ulsch->harq_processes[i]->b,0,MAX_ULSCH_PAYLOAD_BYTES/bw_scaling); + if (ulsch->harq_processes[i]->decodedBytes) + memset(ulsch->harq_processes[i]->decodedBytes,0,MAX_ULSCH_PAYLOAD_BYTES/bw_scaling); else exit_flag=3; @@ -210,388 +210,26 @@ uint8_t extract_cqi_crc(uint8_t *cqi,uint8_t CQI_LENGTH) { return(crc); } - - - -int ulsch_decoding_data_2thread0(td_params *tdp) { - PHY_VARS_eNB *eNB = tdp->eNB; - int UE_id = tdp->UE_id; - int harq_pid = tdp->harq_pid; - int llr8_flag = tdp->llr8_flag; - unsigned int r,r_offset=0,Kr,Kr_bytes; - uint8_t crc_type; - int offset = 0; - int ret = 1; - int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; - LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; - LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; - int Q_m = ulsch_harq->Qm; - int G = ulsch_harq->G; - uint32_t E=0; - uint32_t Gp,GpmodC,Nl=1; - uint32_t C = ulsch_harq->C; - decoder_if_t *tc; - - if (llr8_flag == 0) - tc = decoder16; - else - tc = decoder8; - - // go through first half of segments to get r_offset - for (r=0; r<(ulsch_harq->C/2); r++) { - // Get Turbo interleaver parameters - if (rCminus) - Kr = ulsch_harq->Kminus; - else - Kr = ulsch_harq->Kplus; - - Kr_bytes = Kr>>3; - // This is stolen from rate-matching algorithm to get the value of E - Gp = G/Nl/Q_m; - GpmodC = Gp%C; - - if (r < (C-(GpmodC))) - E = Nl*Q_m * (Gp/C); - else - E = Nl*Q_m * ((GpmodC==0?0:1) + (Gp/C)); - - r_offset += E; - - if (r==0) { - offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0); - } else { - offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0)); - } - } - - // go through second half of segments - for (; r<(ulsch_harq->C); r++) { - // printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]); - // Get Turbo interleaver parameters - if (rCminus) - Kr = ulsch_harq->Kminus; - else - Kr = ulsch_harq->Kplus; - - Kr_bytes = Kr>>3; - memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short)); - ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8), - (uint8_t *)&dummy_w[r][0], +void processULSegment(void * arg) { + turboDecode_t* rdata=(turboDecode_t*) arg; + PHY_VARS_eNB *eNB=rdata->eNB; + LTE_UL_eNB_HARQ_t *ulsch_harq=rdata->ulsch_harq; + int r=rdata->segment_r; + int G=ulsch_harq->G; + int Kr_bytes=rdata->Kr>>3; + int16_t dummy_w[3*(6144+64)]; + + memset(&dummy_w[0],0,3*(6144+64)*sizeof(short)); + ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8), + (uint8_t *)&dummy_w[0], (r==0) ? ulsch_harq->F : 0); -#ifdef DEBUG_ULSCH_DECODING - printf("Rate Matching Segment %u (coded bits (G) %d,unpunctured/repeated bits %u, Q_m %d, nb_rb %d, Nl %d)...\n", - r, G, - Kr*3, - Q_m, - nb_rb, - ulsch_harq->Nl); -#endif - - if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r], - G, - ulsch_harq->w[r], - (uint8_t *) &dummy_w[r][0], - ulsch_harq->e+r_offset, - ulsch_harq->C, - NSOFT, - 0, //Uplink - 1, - ulsch_harq->rvidx, - (ulsch_harq->round==0)?1:0, // clear - ulsch_harq->Qm, - 1, - r, - &E)==-1) { - LOG_E(PHY,"ulsch_decoding.c: Problem in rate matching\n"); - return(-1); - } - - r_offset += E; - sub_block_deinterleaving_turbo(4+Kr, - &ulsch_harq->d[r][96], - ulsch_harq->w[r]); - - if (ulsch_harq->C == 1) - crc_type = CRC24_A; - else - crc_type = CRC24_B; - - ret = tc(&ulsch_harq->d[r][96], - NULL, - ulsch_harq->c[r], - NULL, - Kr, - ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS, - crc_type, - (r==0) ? ulsch_harq->F : 0, - &eNB->ulsch_tc_init_stats, - &eNB->ulsch_tc_alpha_stats, - &eNB->ulsch_tc_beta_stats, - &eNB->ulsch_tc_gamma_stats, - &eNB->ulsch_tc_ext_stats, - &eNB->ulsch_tc_intl1_stats, - &eNB->ulsch_tc_intl2_stats); - - // Reassembly of Transport block here - - if (ret != (1+ulsch->max_turbo_iterations)) { - if (rCminus) - Kr = ulsch_harq->Kminus; - else - Kr = ulsch_harq->Kplus; - - Kr_bytes = Kr>>3; - memcpy(ulsch_harq->b+offset, - ulsch_harq->c[r], - Kr_bytes - ((ulsch_harq->C>1)?3:0)); - offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0)); - } else { - break; - } - } - - return(ret); -} - - -void *td_thread(void *param) { - PHY_VARS_eNB *eNB = ((td_params *)param)->eNB; - L1_proc_t *proc = &eNB->proc; - pthread_setname_np( pthread_self(),"td processing"); - LOG_I(PHY,"thread td created id=%ld\n", syscall(__NR_gettid)); - //wait_sync("td_thread"); - - while (!oai_exit) { - if (wait_on_condition(&proc->mutex_td,&proc->cond_td,&proc->instance_cnt_td,"td thread")<0) break; - - if(oai_exit) break; - - ((td_params *)param)->ret = ulsch_decoding_data_2thread0((td_params *)param); - - if (release_thread(&proc->mutex_td,&proc->instance_cnt_td,"td thread")<0) break; - - if (pthread_cond_signal(&proc->cond_td) != 0) { - printf("[eNB] ERROR pthread_cond_signal for td thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return(NULL); - } - } - - return(NULL); -} - -int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) { - L1_proc_t *proc = &eNB->proc; - unsigned int r,r_offset=0,Kr,Kr_bytes; - uint8_t crc_type; - int offset = 0; - int ret = 1; - int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; - LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; - LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; - int G = ulsch_harq->G; + start_meas(&eNB->ulsch_deinterleaving_stats); unsigned int E; - int Cby2; - decoder_if_t *tc; - struct timespec wait; - wait.tv_sec=0; - wait.tv_nsec=5000000L; - - if (llr8_flag == 0) - tc = decoder16; - else - tc = decoder8; - - if (ulsch_harq->C>1) { // wakeup worker if more than 1 segment - if (pthread_mutex_timedlock(&proc->mutex_td,&wait) != 0) { - printf("[eNB] ERROR pthread_mutex_lock for TD thread (IC %d)\n", proc->instance_cnt_td); - exit_fun( "error locking mutex_fep" ); - return -1; - } - - if (proc->instance_cnt_td==0) { - printf("[eNB] TD thread busy\n"); - exit_fun("TD thread busy"); - pthread_mutex_unlock( &proc->mutex_td ); - return -1; - } - - ++proc->instance_cnt_td; - proc->tdp.eNB = eNB; - proc->tdp.UE_id = UE_id; - proc->tdp.harq_pid = harq_pid; - proc->tdp.llr8_flag = llr8_flag; - - // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_td) != 0) { - printf("[eNB] ERROR pthread_cond_signal for td thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (1+ulsch->max_turbo_iterations); - } - - pthread_mutex_unlock( &proc->mutex_td ); - Cby2 = ulsch_harq->C/2; - } else { - Cby2 = 1; - } - - // go through first half of segments in main thread - for (r=0; rc[r]); - // Get Turbo interleaver parameters - if (rCminus) - Kr = ulsch_harq->Kminus; - else - Kr = ulsch_harq->Kplus; - - Kr_bytes = Kr>>3; - memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short)); - ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8), - (uint8_t *)&dummy_w[r][0], - (r==0) ? ulsch_harq->F : 0); -#ifdef DEBUG_ULSCH_DECODING - printf("Rate Matching Segment %u (coded bits (G) %d,unpunctured/repeated bits %u, Q_m %d, nb_rb %d, Nl %d)...\n", - r, G, - Kr*3, - Q_m, - nb_rb, - ulsch_harq->Nl); -#endif - start_meas(&eNB->ulsch_rate_unmatching_stats); - - if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r], + if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r], G, ulsch_harq->w[r], - (uint8_t *) &dummy_w[r][0], - ulsch_harq->e+r_offset, - ulsch_harq->C, - NSOFT, - 0, //Uplink - 1, - ulsch_harq->rvidx, - (ulsch_harq->round==0)?1:0, // clear - ulsch_harq->Qm, - 1, - r, - &E)==-1) { - LOG_E(PHY,"ulsch_decoding.c: Problem in rate matching\n"); - return(-1); - } - - stop_meas(&eNB->ulsch_rate_unmatching_stats); - r_offset += E; - start_meas(&eNB->ulsch_deinterleaving_stats); - sub_block_deinterleaving_turbo(4+Kr, - &ulsch_harq->d[r][96], - ulsch_harq->w[r]); - stop_meas(&eNB->ulsch_deinterleaving_stats); - - if (ulsch_harq->C == 1) - crc_type = CRC24_A; - else - crc_type = CRC24_B; - - start_meas(&eNB->ulsch_turbo_decoding_stats); - ret = tc(&ulsch_harq->d[r][96], - NULL, - ulsch_harq->c[r], - NULL, - Kr, - ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS, - crc_type, - (r==0) ? ulsch_harq->F : 0, - &eNB->ulsch_tc_init_stats, - &eNB->ulsch_tc_alpha_stats, - &eNB->ulsch_tc_beta_stats, - &eNB->ulsch_tc_gamma_stats, - &eNB->ulsch_tc_ext_stats, - &eNB->ulsch_tc_intl1_stats, - &eNB->ulsch_tc_intl2_stats); - - // Reassembly of Transport block here - - if (ret != (1+ulsch->max_turbo_iterations)) { - if (rCminus) - Kr = ulsch_harq->Kminus; - else - Kr = ulsch_harq->Kplus; - - Kr_bytes = Kr>>3; - - if (r==0) { - memcpy(ulsch_harq->b, - &ulsch_harq->c[0][(ulsch_harq->F>>3)], - Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0)); - offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0); - } else { - memcpy(ulsch_harq->b+offset, - ulsch_harq->c[r], - Kr_bytes - ((ulsch_harq->C>1)?3:0)); - offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0)); - } - } else { - break; - } - - stop_meas(&eNB->ulsch_turbo_decoding_stats); - //printf("/////////////////////////////////////////**************************loop for %d time in ulsch_decoding main\n",r); - } - - // wait for worker to finish - wait_on_busy_condition(&proc->mutex_td,&proc->cond_td,&proc->instance_cnt_td,"td thread"); - return( (ret>proc->tdp.ret) ? ret : proc->tdp.ret ); -} - -int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) { - unsigned int r,r_offset=0,Kr,Kr_bytes; - uint8_t crc_type; - int offset = 0; - int ret = 1; - int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; - LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; - LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; - int G = ulsch_harq->G; - unsigned int E; - decoder_if_t *tc; - static int32_t pusch_rep_buffer[3*(6144+64)]; - int max_Ncb; - - if (llr8_flag == 0) - tc = *decoder16; - else - tc = *decoder8; - - if(ulsch_harq->repetition_number == 1) { - memset(pusch_rep_buffer,0,(sizeof(int32_t)*3*(6144+64))) ; // reset the buffer every new repetitions - } - - for (r=0; rC; r++) { - // printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]); - // Get Turbo interleaver parameters - if (rCminus) - Kr = ulsch_harq->Kminus; - else - Kr = ulsch_harq->Kplus; - - Kr_bytes = Kr>>3; - memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short)); - ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8), - (uint8_t *)&dummy_w[r][0], - (r==0) ? ulsch_harq->F : 0); -#ifdef DEBUG_ULSCH_DECODING - printf("Rate Matching Segment %u (coded bits (G) %d,unpunctured/repeated bits %u, Q_m %d, Nl %d)...\n", - r, G, - Kr*3, - ulsch_harq->Qm, - ulsch_harq->Nl); -#endif - start_meas(&eNB->ulsch_rate_unmatching_stats); - - if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r], - G, - ulsch_harq->w[r], - (uint8_t *) &dummy_w[r][0], - ulsch_harq->e+r_offset, + (uint8_t *) &dummy_w[0], + ulsch_harq->eUL+rdata->r_offset, ulsch_harq->C, NSOFT, 0, //Uplink @@ -603,97 +241,132 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) r, &E)==-1) { LOG_E(PHY,"ulsch_decoding.c: Problem in rate matching\n"); - return(-1); + return; + } + stop_meas(&eNB->ulsch_rate_unmatching_stats); + int max_Ncb = 3*ulsch_harq->RTC[r]*32 ; + + if(ulsch_harq->repetition_number == 1) { + memset(ulsch_harq->pusch_rep_buffer[r],0,(sizeof(int32_t)*3*(6144+64))) ; // reset the buffer every new repetitions + } + if(ulsch_harq->total_number_of_repetitions > 1) { + if (ulsch_harq->rvidx==1) { + LOG_E(PHY,"Adding HARQ data for segment: %d\n", r); + // Store the result of HARQ combining in the last emtc repetitions of sequence 0,2,3,1 + for (int nn=0; nnpusch_rep_buffer[r][nn] += ulsch_harq->w[r][nn] ; } - stop_meas(&eNB->ulsch_rate_unmatching_stats); - max_Ncb = 3*ulsch_harq->RTC[r]*32 ; - - if(ulsch_harq->total_number_of_repetitions > 1) { - if (ulsch_harq->rvidx==1) { - // Store the result of HARQ combining in the last emtc repetitions of sequence 0,2,3,1 - for (int nn=0; nnw[r][nn] ; - } - } - - if (ulsch_harq->repetition_number == ulsch_harq->total_number_of_repetitions) { - for (int nn=0; nnw[r][nn] = pusch_rep_buffer[nn] ; - } - } - } - - r_offset += E; - start_meas(&eNB->ulsch_deinterleaving_stats); - sub_block_deinterleaving_turbo(4+Kr, - &ulsch_harq->d[r][96], - ulsch_harq->w[r]); - stop_meas(&eNB->ulsch_deinterleaving_stats); - - if (ulsch_harq->C == 1) - crc_type = CRC24_A; - else - crc_type = CRC24_B; - - start_meas(&eNB->ulsch_turbo_decoding_stats); - ret = tc(&ulsch_harq->d[r][96], - NULL, - ulsch_harq->c[r], - NULL, - Kr, - ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS, - crc_type, - (r==0) ? ulsch_harq->F : 0, - &eNB->ulsch_tc_init_stats, - &eNB->ulsch_tc_alpha_stats, - &eNB->ulsch_tc_beta_stats, - &eNB->ulsch_tc_gamma_stats, - &eNB->ulsch_tc_ext_stats, - &eNB->ulsch_tc_intl1_stats, - &eNB->ulsch_tc_intl2_stats); - stop_meas(&eNB->ulsch_turbo_decoding_stats); - - // Reassembly of Transport block here - - if (ret != (1+ulsch->max_turbo_iterations)) { - if (rCminus) - Kr = ulsch_harq->Kminus; - else - Kr = ulsch_harq->Kplus; - - Kr_bytes = Kr>>3; - - if (r==0) { - memcpy(ulsch_harq->b, - &ulsch_harq->c[0][(ulsch_harq->F>>3)], - Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0)); - offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0); - } else { - memcpy(ulsch_harq->b+offset, - ulsch_harq->c[r], - Kr_bytes - ((ulsch_harq->C>1)?3:0)); - offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0)); - } - } else { - break; + if (ulsch_harq->repetition_number == ulsch_harq->total_number_of_repetitions) { + LOG_E(PHY,"Will use HARQ data sum up for segment: %d\n", r); + for (int nn=0; nnw[r][nn] = ulsch_harq->pusch_rep_buffer[r][nn] ; } } + int16_t soft_bits[3*8*6144+12+96] __attribute__((aligned(32))); + sub_block_deinterleaving_turbo(4+rdata->Kr, + soft_bits+96, + ulsch_harq->w[r]); + stop_meas(&eNB->ulsch_deinterleaving_stats); + rdata->decodeIterations = rdata->function( soft_bits+96, + NULL, + rdata->decoded_bytes, + NULL, + rdata->Kr, + rdata->maxIterations, + rdata->nbSegments == 1 ? CRC24_A: CRC24_B, + rdata->Fbits, + &eNB->ulsch_tc_init_stats, + &eNB->ulsch_tc_alpha_stats, + &eNB->ulsch_tc_beta_stats, + &eNB->ulsch_tc_gamma_stats, + &eNB->ulsch_tc_ext_stats, + &eNB->ulsch_tc_intl1_stats, + &eNB->ulsch_tc_intl2_stats); + stop_meas(&eNB->ulsch_turbo_decoding_stats); + +} +void *td_thread(void *param) { + + return(NULL); +} + +int ulsch_decoding_data(PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, + int UE_id,int harq_pid,int llr8_flag) { + unsigned int r_offset=0; + int offset = 0; + LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; + LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; + int G = ulsch_harq->G; + unsigned int E; + int ret=0; + + decoder_if_t * td=llr8_flag == 0 ? + *decoder16 : *decoder8; + ulsch_harq->processedSegments=0; + + for (int r=0; rC; r++) { + // printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]); + // Get Turbo interleaver parameters + unsigned int Kr= rCminus ? + ulsch_harq->Kminus :ulsch_harq->Kplus; + unsigned int Kr_bytes = Kr>>3; + +#ifdef DEBUG_ULSCH_DECODING + printf("Rate Matching Segment %u (coded bits (G) %d,unpunctured/repeated bits %u, Q_m %d, Nl %d, r_offset %d)...\n", + r, G, + Kr*3, + ulsch_harq->Qm, + ulsch_harq->Nl, r_offset); +#endif + int Gp=G/ulsch_harq->Qm; + int GpmodC = Gp%ulsch_harq->C; + + if (r < (ulsch_harq->C-(GpmodC))) + E = ulsch_harq->Qm * (Gp/ulsch_harq->C); + else + E = ulsch_harq->Qm * ((GpmodC==0?0:1) + (Gp/ulsch_harq->C)); + + if ( split73 == SPLIT73_DU ) { + sendFs6Ul(eNB, UE_id, harq_pid, r, ulsch_harq->eUL+r_offset, E*sizeof(int16_t), r_offset); + r_offset += E; + continue; + } + + union turboReqUnion id= {.s={ulsch->rnti,proc->frame_rx,proc->subframe_rx,0,0}}; + notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(turboDecode_t), id.p, proc->respDecode, processULSegment); + turboDecode_t * rdata=(turboDecode_t *) NotifiedFifoData(req); + + rdata->eNB=eNB; + rdata->frame=proc->frame_rx; + rdata->subframe=proc->subframe_rx; + rdata->UEid=UE_id; + rdata->harq_pid=harq_pid; + rdata->Kr=Kr; + rdata->maxIterations=eNB->ulsch[UE_id]->max_turbo_iterations; + rdata->ulsch_harq=ulsch_harq; + rdata->eNB=eNB; + rdata->nbSegments=ulsch_harq->C; + rdata->segment_r=r; + rdata->Fbits=(r==0) ? ulsch_harq->F : 0; + rdata->r_offset=r_offset; + rdata->offset=offset; + rdata->function=td; + int Fbytes=(r==0) ? rdata->Fbits>>3 : 0; + int sz=Kr_bytes - Fbytes - ((ulsch_harq->C>1)?3:0); + pushTpool(proc->threadPool,req); + proc->nbDecode++; + LOG_D(PHY,"Added a block to decode, in pipe: %d\n",proc->nbDecode); + r_offset+=E; + offset+=sz; + } return(ret); } -int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) { - int ret = 0; - /*if(get_thread_worker_conf() == WORKER_ENABLE) - { - ret = ulsch_decoding_data_2thread(eNB,UE_id,harq_pid,llr8_flag); - } - else*/ - { - ret = ulsch_decoding_data(eNB,UE_id,harq_pid,llr8_flag); - } - return ret; +int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, + int UE_id,int harq_pid,int llr8_flag) { + return ulsch_decoding_data(eNB,proc,UE_id,harq_pid,llr8_flag); } static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2, unsigned char reset) __attribute__((always_inline)); @@ -767,7 +440,6 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, else harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,1); // x1 is set in lte_gold_generic x2 = ((uint32_t)ulsch->rnti<<14) + ((uint32_t)subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.3.1 ulsch_harq = ulsch->harq_processes[harq_pid]; @@ -779,8 +451,9 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, A = ulsch_harq->TBS; Q_m = ulsch_harq->Qm; G = nb_rb * (12 * Q_m) * ulsch_harq->Nsymb_pusch; + LOG_D(PHY, "PUSCH nb_rb %d Q_m %d ulsch_harq->Nsymb_pusch %d\n",nb_rb, Q_m, ulsch_harq->Nsymb_pusch); //#ifdef DEBUG_ULSCH_DECODING - LOG_D(PHY,"[PUSCH %d] Frame %d, Subframe %d: ulsch_decoding (Nid_cell %d, rnti %x, x2 %x): A %d, round %d, RV %d, O_r1 %d, O_RI %d, O_ACK %d, G %d, Q_m %d Nsymb_pusch %d nb_rb %d\n", + LOG_D(PHY,"[PUSCH harq %d] Frame %d, Subframe %d: ulsch_decoding (Nid_cell %d, rnti %x, x2 %x): TBS %d, round %d, RV %d, O_r1 %d, O_RI %d, O_ACK %d, G %d, Q_m %d Nsymb_pusch %d nb_rb %d\n", harq_pid, proc->frame_rx,subframe, frame_parms->Nid_cell,ulsch->rnti,x2, @@ -833,6 +506,12 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, subframe); // Compute Q_ri Qprime = ulsch_harq->O_RI*ulsch_harq->Msc_initial*ulsch_harq->Nsymb_initial * ulsch->beta_offset_ri_times8; + LOG_D(PHY, "Qprime %d, O_RI %d, Msc %d, Nym %d beta %d\n", + Qprime, + ulsch_harq->O_RI, + ulsch_harq->Msc_initial, + ulsch_harq->Nsymb_initial, + ulsch->beta_offset_ri_times8); if (Qprime > 0 ) { if ((Qprime % (8*sumKr)) > 0) @@ -1209,8 +888,8 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, j2+=2; } - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; } break; @@ -1222,10 +901,10 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, j2+=4; } - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; } break; @@ -1237,12 +916,12 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, j2+=6; } - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; - ulsch_harq->e[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; + ulsch_harq->eUL[iprime++] = y[j2++]; } break; @@ -1280,7 +959,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, */ int16_t *yp,*ep; - for (iprime=0,yp=&y[j2],ep=&ulsch_harq->e[0]; + for (iprime=0,yp=&y[j2],ep=&ulsch_harq->eUL[0]; iprimeO_ACK,ulsch_harq->o_ACK[0],ulsch_harq->o_ACK[1],ulsch_harq->o_ACK[2],ulsch_harq->o_ACK[3]); // Do ULSCH Decoding for data portion - ret = ulsch_decoding_data_all(eNB,UE_id,harq_pid,llr8_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,0); + ret = ulsch_decoding_data_all(eNB,proc, UE_id,harq_pid,llr8_flag); return(ret); } diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c index 4ca9a7c762..7442a0ae7e 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c @@ -793,7 +793,7 @@ int dlsch_encoding_SIC(PHY_VARS_UE *ue, r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], G, //G dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, + dlsch->harq_processes[harq_pid]->eDL+r_offset, dlsch->harq_processes[harq_pid]->C, // C dlsch->Nsoft, // Nsoft, dlsch->Mdlharq, diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c index 49fa484c26..a1b7898a2d 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c @@ -65,7 +65,7 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1 uint16_t *prach_root_sequence_map; uint16_t preamble_offset,preamble_shift; uint16_t preamble_index0,n_shift_ra,n_shift_ra_bar; - uint16_t d_start,numshift; + uint16_t d_start=-1,numshift; uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); //uint8_t Nsp=2; //uint8_t f_ra,t1_ra; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c index cc1f762e70..de1c3891da 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c @@ -446,6 +446,13 @@ uint32_t ulsch_encoding(uint8_t *a, Qprime = (ulsch->O + L) * ulsch->harq_processes[harq_pid]->Msc_initial*ulsch->harq_processes[harq_pid]->Nsymb_initial * ulsch->beta_offset_cqi_times8; else Qprime = 0; + LOG_D(PHY,"Qprime %d, O_RI %d + %d, Msc %d, Nym %d beta %d\n", + Qprime, + ulsch->O, L, + ulsch->harq_processes[harq_pid]->Msc_initial, + ulsch->harq_processes[harq_pid]->Nsymb_initial, + ulsch->beta_offset_cqi_times8); + if (Qprime > 0) { if ((Qprime % (8*sumKr)) > 0) @@ -455,7 +462,7 @@ uint32_t ulsch_encoding(uint8_t *a, } G = ulsch->harq_processes[harq_pid]->nb_rb * (12 * Q_m) * (ulsch->Nsymb_pusch); - + LOG_D(PHY,"G: rb %d * ( 12 * Qm %d ) * nsymb %d, Qprime %d, O_RI %d\n", ulsch->harq_processes[harq_pid]->nb_rb, Q_m, ulsch->Nsymb_pusch, Qprime, ulsch->O_RI); if (Qprime > (G - ulsch->O_RI)) Qprime = G - ulsch->O_RI; @@ -465,6 +472,7 @@ uint32_t ulsch_encoding(uint8_t *a, G = G - Q_RI - Q_CQI; + LOG_D(PHY,"new G: %d, Q_RI %d Q_CQI %d\n", G , Q_RI , Q_CQI); ulsch->harq_processes[harq_pid]->G = G; /* diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 69077f0276..e59c651713 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -2032,7 +2032,7 @@ uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue, ul_res_alloc_type_1 = 1; } - uint8_t n_bits_freq_dom_res_assign_ul=0,n_ul_RGB_tmp; + uint8_t n_bits_freq_dom_res_assign_ul=0,n_ul_RGB_tmp=0; if (ul_res_alloc_type_0 == 1) { // implementation of Table 6.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1 // config1: PUSCH-Config IE contains rbg-Size ENUMERATED {config1 config2} @@ -2070,7 +2070,7 @@ uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue, dl_res_alloc_type_1 = 1; } - uint8_t n_bits_freq_dom_res_assign_dl=0,n_dl_RGB_tmp; + uint8_t n_bits_freq_dom_res_assign_dl=0,n_dl_RGB_tmp=-1; if (dl_res_alloc_type_0 == 1) { // implementation of Table 5.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1 // config1: PDSCH-Config IE contains rbg-Size ENUMERATED {config1, config2} diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index f4f4ac8926..d7a0aaeca6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -585,7 +585,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, uint16_t *prach_root_sequence_map; uint16_t preamble_offset,preamble_shift; uint16_t preamble_index0,n_shift_ra,n_shift_ra_bar; - uint16_t d_start,numshift; + uint16_t d_start=-1,numshift; uint16_t prach_fmt = get_nr_prach_fmt(prach_ConfigIndex); //uint8_t Nsp=2; diff --git a/openair1/PHY/TOOLS/lte_phy_scope.c b/openair1/PHY/TOOLS/lte_phy_scope.c index dbcd9540be..8621898d9d 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.c +++ b/openair1/PHY/TOOLS/lte_phy_scope.c @@ -325,12 +325,18 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form, // PUSCH I/Q of MF Output if (pusch_comp!=NULL) { ind=0; + int range=80*1000*1000; for (k=0; ksymbols_per_tti; k++) { for (i=0; i<12*frame_parms->N_RB_UL; i++) { - I[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i]; - Q[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1]; - ind++; + if ( pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i] > -range && + pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i] < range && + pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1] > -range && + pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1] < range ) { + I[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i]; + Q[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1]; + ind++; + } } } diff --git a/openair1/PHY/TOOLS/time_meas.h b/openair1/PHY/TOOLS/time_meas.h index b9777686ea..2deab40f27 100644 --- a/openair1/PHY/TOOLS/time_meas.h +++ b/openair1/PHY/TOOLS/time_meas.h @@ -33,7 +33,7 @@ #include // global var to enable openair performance profiler extern int opp_enabled; -double cpu_freq_GHz; +double cpu_freq_GHz __attribute__ ((aligned(32)));; #if defined(__x86_64__) || defined(__i386__) typedef struct { diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h index 94afeed12f..bf8ffd71d6 100644 --- a/openair1/PHY/defs_RU.h +++ b/openair1/PHY/defs_RU.h @@ -38,6 +38,7 @@ #include "openairinterface5g_limits.h" #include "PHY/TOOLS/time_meas.h" #include "defs_common.h" +#include #define MAX_BANDS_PER_RRU 4 diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 7b06f6c8c7..557b8bfc30 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -201,41 +201,11 @@ typedef struct { int repetition_number[4]; } LTE_eNB_PRACH; -/// Context data structure for RX/TX portion of subframe processing -typedef struct { - /// Component Carrier index - uint8_t CC_id; - /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; - /// subframe to act upon for transmission - int subframe_tx; - /// subframe to act upon for reception - int subframe_rx; - /// frame to act upon for transmission - int frame_tx; - /// frame to act upon for reception - int frame_rx; - /// \brief Instance count for RXn-TXnp4 processing thread. - /// \internal This variable is protected by \ref mutex_rxtx. - int instance_cnt; - /// pthread structure for RXn-TXnp4 processing thread - pthread_t pthread; - /// pthread attributes for RXn-TXnp4 processing thread - pthread_attr_t attr; - /// condition variable for tx processing thread - pthread_cond_t cond; - /// mutex for RXn-TXnp4 processing thread - pthread_mutex_t mutex; - /// scheduling parameters for RXn-TXnp4 thread - struct sched_param sched_param_rxtx; +#include "PHY/TOOLS/time_meas.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" - /// \internal This variable is protected by \ref mutex_RUs. - int instance_cnt_RUs; - /// condition variable for tx processing thread - pthread_cond_t cond_RUs; - /// mutex for RXn-TXnp4 processing thread - pthread_mutex_t mutex_RUs; -} L1_rxtx_proc_t; typedef struct { struct PHY_VARS_eNB_s *eNB; @@ -694,6 +664,57 @@ typedef struct PHY_VARS_eNB_s { int32_t pusch_stats_mcs[NUMBER_OF_UE_MAX][10240]; int32_t pusch_stats_bsr[NUMBER_OF_UE_MAX][10240]; int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240]; + uint8_t *FS6bufferZone; } PHY_VARS_eNB; + +struct turboReqId { + uint16_t rnti; + uint16_t frame; + uint8_t subframe; + uint8_t codeblock; + uint16_t spare; +} __attribute__((packed)); + +union turboReqUnion { + struct turboReqId s; + uint64_t p; +}; + +typedef struct TurboDecode_s { + PHY_VARS_eNB *eNB; + decoder_if_t *function; + uint8_t decoded_bytes[3+1768] __attribute__((aligned(32))); + int UEid; + int harq_pid; + int frame; + int subframe; + int Fbits; + int Kr; + LTE_UL_eNB_HARQ_t *ulsch_harq; + int nbSegments; + int segment_r; + int r_offset; + int offset; + int maxIterations; + int decodeIterations; +} turboDecode_t; + +#define TURBO_SIMD_SOFTBITS 96+12+3+3*6144 +typedef struct turboEncode_s { + uint8_t * input; + int Kr_bytes; + int filler; + unsigned int G; + int r; + int harq_pid; + int round; + int r_offset; + LTE_eNB_DLSCH_t *dlsch; + time_stats_t *rm_stats; + time_stats_t *te_stats; + time_stats_t *i_stats; +} turboEncode_t; + + #endif /* __PHY_DEFS_ENB__H__ */ diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 8105877bc3..6b7f925c61 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -381,6 +381,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro dlsch0_harq->TBS, dlsch0_harq->Qm, dlsch0_harq->codeword, dlsch0_harq->rb_alloc[0], rel8->length ); + dlsch0->active = 1; harq_pid = dlsch0->harq_ids[frame%2][proc->subframe_tx]; dlsch0->harq_mask |= (1<pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) { AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE not handled yet\n"); } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) { - AssertFatal((UE_id = find_uci(ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti, + AssertFatal((UE_id = find_uci(ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti, proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0, "No available UE UCI for rnti %x\n",ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti); handle_uci_sr_pdu(eNB,UE_id,ul_config_pdu,frame,subframe,srs_present); @@ -745,9 +746,8 @@ void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, } } -void schedule_response(Sched_Rsp_t *Sched_INFO) { +void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc) { PHY_VARS_eNB *eNB; - L1_rxtx_proc_t *proc; // copy data from L2 interface into L1 structures module_id_t Mod_id = Sched_INFO->module_id; uint8_t CC_id = Sched_INFO->CC_id; @@ -767,7 +767,6 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) { AssertFatal(RC.eNB[Mod_id][CC_id]!=NULL,"RC.eNB[%d][%d] is null\n",Mod_id,CC_id); eNB = RC.eNB[Mod_id][CC_id]; fp = &eNB->frame_parms; - proc = &eNB->proc.L1_proc; /* TODO: check that following line is correct - in the meantime it is disabled */ //if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)==SF_UL)) return; ul_subframe = pdcch_alloc2ul_subframe(fp,subframe); @@ -1020,11 +1019,11 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) { /*Dummy functions*/ -int memcpy_dl_config_req (nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { +int memcpy_dl_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { return 0; } -int memcpy_ul_config_req (nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request_t *req) { +int memcpy_ul_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request_t *req) { return 0; } diff --git a/openair1/SCHED/fapi_l1.h b/openair1/SCHED/fapi_l1.h index 05ec813917..4da1fa63ec 100644 --- a/openair1/SCHED/fapi_l1.h +++ b/openair1/SCHED/fapi_l1.h @@ -37,10 +37,10 @@ #include "SCHED/sched_common.h" #include "nfapi_interface.h" -void fill_uci_harq_indication(PHY_VARS_eNB *eNB,LTE_eNB_UCI *uci,int frame,int subframe,uint8_t *harq_ack,uint8_t tdd_mapping_mode,uint16_t tdd_multiplexing_mask); +void fill_uci_harq_indication(int UEid, PHY_VARS_eNB *eNB,LTE_eNB_UCI *uci,int frame,int subframe,uint8_t *harq_ack,uint8_t tdd_mapping_mode,uint16_t tdd_multiplexing_mask); void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq,uint16_t rnti, int frame,int subframe,int bundling); void fill_ulsch_cqi_indication(PHY_VARS_eNB *eNB,uint16_t frame,uint8_t subframe,LTE_UL_eNB_HARQ_t *ulsch_harq,uint16_t rnti); -void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,uint32_t stat); +void fill_sr_indication(int UEid, PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,uint32_t stat); void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe); void fill_crc_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe,uint8_t crc_flag); void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,nfapi_dl_config_request_pdu_t *dl_config_pdu); @@ -81,4 +81,4 @@ void handle_uci_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu void handle_srs_pdu(PHY_VARS_eNB *eNB,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe); -void schedule_response(Sched_Rsp_t *Sched_INFO); +void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 34d5a01590..daa9039236 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -47,6 +47,7 @@ #include #include "intertask_interface.h" +#include #define MBMS_NFAPI_SCHEDULER @@ -303,6 +304,7 @@ bool dlsch_procedures(PHY_VARS_eNB *eNB, start_meas(&eNB->dlsch_encoding_stats); dlsch_encoding_all(eNB, + proc, dlsch_harq->pdu, dlsch_harq->pdsch_start, dlsch, @@ -317,6 +319,14 @@ bool dlsch_procedures(PHY_VARS_eNB *eNB, &eNB->dlsch_interleaving_stats); stop_meas(&eNB->dlsch_encoding_stats); + if ( proc->threadPool->activated ) { + // Wait all other threads finish to process + while (proc->nbEncode) { + delNotifiedFIFO_elt(pullTpool(proc->respEncode, proc->threadPool)); + proc->nbEncode--; + } + } + if(eNB->dlsch_encoding_stats.p_time>500*3000 && opp_enabled == 1) { print_meas_now(&eNB->dlsch_encoding_stats,"total coding",stderr); } @@ -431,6 +441,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, if (ul_subframe < 10) { // This means that there is a potential UL subframe that will be scheduled here for (i=0; iulsch[i] && eNB->ulsch[i]->ue_type >0) harq_pid = 0; + else harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe); @@ -591,7 +602,12 @@ void srs_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { } } -void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,uint32_t stat) { +void fill_sr_indication(int UEid, PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,uint32_t stat) { + if ( split73 == SPLIT73_DU ) { + sendFs6Ulharq(fs6ULindicationSr, UEid, eNB, NULL, frame, subframe, NULL,0,0, rnti, stat); + return; + } + pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_sr_indication_t *sr_ind = &eNB->UL_INFO.sr_ind; nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body; @@ -604,6 +620,7 @@ void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,u pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.rnti = rnti; int SNRtimes10 = dB_fixed_times10(stat) - 10 * eNB->measurements.n0_subband_power_dB[0][0]; + LOG_D(PHY,"stat %d subbandpower %d, SNRtimes10 %d\n", stat, eNB->measurements.n0_subband_power_dB[0][0], SNRtimes10); pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; @@ -710,7 +727,7 @@ uci_procedures(PHY_VARS_eNB *eNB, if (uci->type == SR) { if (SR_payload == 1) { - fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); + fill_sr_indication(i, eNB,uci->rnti,frame,subframe,metric_SR); break; } else { break; @@ -744,7 +761,7 @@ uci_procedures(PHY_VARS_eNB *eNB, /* cancel SR detection if reception on n1_pucch0 is better than on SR PUCCH resource index, otherwise send it up to MAC */ if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; - else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); + else if (SR_payload == 1) fill_sr_indication(i, eNB,uci->rnti,frame,subframe,metric_SR); if (uci->type==HARQ_SR && metric[0] <= metric_SR) { /* when transmitting ACK/NACK on SR PUCCH resource index, SR payload is always 1 */ @@ -769,7 +786,7 @@ uci_procedures(PHY_VARS_eNB *eNB, frame,subframe, pucch_b0b1[0][0],metric[0]); uci->stat = metric[0]; - fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff); + fill_uci_harq_indication(i, eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff); } else { // frame_type == TDD LOG_D(PHY,"Frame %d Subframe %d Demodulating PUCCH (UCI %d) for ACK/NAK (uci->pucch_fmt %d,uci->type %d.uci->frame %d, uci->subframe %d): n1_pucch0 %d SR_payload %d\n", frame,subframe,i, @@ -791,7 +808,7 @@ uci_procedures(PHY_VARS_eNB *eNB, ); if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; - else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); + else if (SR_payload == 1) fill_sr_indication(i, eNB,uci->rnti,frame,subframe,metric_SR); if (uci->type==HARQ_SR && metric[0] <= metric_SR) { SR_payload = 1; @@ -873,7 +890,7 @@ uci_procedures(PHY_VARS_eNB *eNB, } uci->stat = metric[0]; - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode + fill_uci_harq_indication(i, eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode } else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==2)) { // multiplexing + no SR, implement Table 10.1.3-5 (Rel14) for multiplexing with M=2 if (pucch_b0b1[0][0] == 4 || pucch_b0b1[1][0] == 4) { // there isn't a likely transmission @@ -909,7 +926,7 @@ uci_procedures(PHY_VARS_eNB *eNB, } uci->stat = max(metric[0],metric[1]); - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode + fill_uci_harq_indication(i, eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode } //else if ((uci->tdd_bundling == 0) && (res==2)) else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==3)) { // multiplexing + no SR, implement Table 10.1.3-6 (Rel14) for multiplexing with M=3 if (harq_ack[0] == 4 || @@ -980,7 +997,7 @@ uci_procedures(PHY_VARS_eNB *eNB, } uci->stat = max_metric; - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode + fill_uci_harq_indication(i, eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode } } //else if ((uci->tdd_bundling == 0) && (res==3)) else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==4)) { // multiplexing + no SR, implement Table 10.1.3-7 (Rel14) for multiplexing with M=4 @@ -1102,14 +1119,14 @@ uci_procedures(PHY_VARS_eNB *eNB, } uci->stat = max_metric; - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode + fill_uci_harq_indication(i, eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode } // else if ((uci->tdd_bundling == 0) && (res==4)) else { // bundling harq_ack[0] = pucch_b0b1[0][0]; harq_ack[1] = pucch_b0b1[0][1]; uci->stat = metric[0]; LOG_D(PHY,"bundling: (%d,%d), metric %d\n",harq_ack[0],harq_ack[1],uci->stat); - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode + fill_uci_harq_indication(i, eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode } #ifdef DEBUG_PHY_PROC @@ -1140,8 +1157,93 @@ uci_procedures(PHY_VARS_eNB *eNB, } // end loop for (int i = 0; i < NUMBER_OF_UE_MAX; i++) { } +void postDecode(L1_rxtx_proc_t *proc, notifiedFIFO_elt_t *req) { + turboDecode_t * rdata=(turboDecode_t *) NotifiedFifoData(req); + + LTE_eNB_ULSCH_t *ulsch = rdata->eNB->ulsch[rdata->UEid]; + LTE_UL_eNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; + PHY_VARS_eNB *eNB=rdata->eNB; + + bool decodeSucess=rdata->decodeIterations <= rdata->maxIterations; + ulsch_harq->processedSegments++; + LOG_D(PHY, "processing result of segment: %d, ue %d, processed %d/%d\n", + rdata->segment_r, rdata->UEid, ulsch_harq->processedSegments, rdata->nbSegments); + proc->nbDecode--; + LOG_D(PHY,"remain to decoded in subframe: %d\n", proc->nbDecode); + if (decodeSucess) { + int Fbytes=(rdata->segment_r==0) ? rdata->Fbits>>3 : 0; + int sz=(rdata->Kr>>3) - Fbytes - ((ulsch_harq->C>1)?3:0); + memcpy(ulsch_harq->decodedBytes+rdata->offset, + rdata->decoded_bytes+Fbytes, + sz); + } else { + if ( rdata->nbSegments != ulsch_harq->processedSegments ) { + int nb=abortTpool(proc->threadPool, req->key); + nb+=abortNotifiedFIFO(proc->respDecode, req->key); + proc->nbDecode-=nb; + LOG_I(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); + AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", + ulsch_harq->processedSegments, nb, rdata->nbSegments); + ulsch_harq->processedSegments=rdata->nbSegments; + } + } + + // if this UE segments are all done + if ( rdata->nbSegments == ulsch_harq->processedSegments) { + //compute the expected ULSCH RX power (for the stats) + int i=rdata->UEid; + ulsch_harq->delta_TF = get_hundred_times_delta_IF_eNB(eNB,i,rdata->harq_pid, 0); // 0 means bw_factor is not considered + if (RC.mac != NULL) { /* ulsim does not use RC.mac context. */ + if (ulsch_harq->cqi_crc_status == 1) { + fill_ulsch_cqi_indication(eNB,rdata->frame,rdata->subframe,ulsch_harq,ulsch->rnti); + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << rdata->subframe)); + } else { + if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag & (1 << rdata->subframe) ) { + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << rdata->subframe)); + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30; + LOG_D(PHY,"Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",rdata->frame,rdata->subframe); + } + } + } + + if (!decodeSucess) { + fill_crc_indication(eNB,i,rdata->frame,rdata->subframe,1); // indicate NAK to MAC + fill_rx_indication(eNB,i,rdata->frame,rdata->subframe); // indicate SDU to MAC + LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d Error receiving ULSCH, round %d/%d (ACK %d,%d)\n", + eNB->Mod_id,rdata->harq_pid, + rdata->frame,rdata->subframe, i, + ulsch_harq->round, + ulsch->Mlimit, + ulsch_harq->o_ACK[0], + ulsch_harq->o_ACK[1]); + + if (ulsch_harq->round >= 3) { + ulsch_harq->status = SCH_IDLE; + ulsch_harq->handled = 0; + ulsch->harq_mask &= ~(1 << rdata->harq_pid); + ulsch_harq->round = 0; + } + /* Mark the HARQ process to release it later if max transmission reached + * (see below). + * MAC does not send the max transmission count, we have to deal with it + * locally in PHY. + */ + ulsch_harq->handled = 1; + } // ulsch in error + else if(ulsch_harq->repetition_number == ulsch_harq->total_number_of_repetitions){ + fill_crc_indication(eNB,i,rdata->frame,rdata->subframe,0); // indicate ACK to MAC + fill_rx_indication(eNB,i,rdata->frame,rdata->subframe); // indicate SDU to MAC + ulsch_harq->status = SCH_IDLE; + ulsch->harq_mask &= ~(1 << rdata->harq_pid); + } // ulsch not in error + + if (ulsch_harq->O_ACK>0) + fill_ulsch_harq_indication(eNB,ulsch_harq,ulsch->rnti,rdata->frame,rdata->subframe,ulsch->bundling); + } +} + void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { - uint32_t ret=0,i; + uint32_t i; uint32_t harq_pid; uint8_t nPRS; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; @@ -1150,7 +1252,6 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; uint32_t harq_pid0 = subframe2harq_pid(&eNB->frame_parms,frame,subframe); - int rvidx_tab[4] = {0,2,3,1}; for (i = 0; i < NUMBER_OF_UE_MAX; i++) { ulsch = eNB->ulsch[i]; @@ -1204,127 +1305,13 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { rx_ulsch(eNB,proc, i); stop_meas(&eNB->ulsch_demodulation_stats); start_meas(&eNB->ulsch_decoding_stats); - ret = ulsch_decoding(eNB,proc, + ulsch_decoding(eNB,proc, i, 0, // control_only_flag ulsch_harq->V_UL_DAI, ulsch_harq->nb_rb>20 ? 1 : 0); stop_meas(&eNB->ulsch_decoding_stats); - LOG_D(PHY, - "[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d ulsch_harq->cqi_crc_status:%d ackBits:%d ulsch_decoding_stats[t:%lld max:%lld]\n", - eNB->Mod_id,harq_pid, - frame,subframe, - ulsch->rnti, - dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]), - dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]), - 30,//eNB->measurements.n0_power_dB[0], - 30,//eNB->measurements.n0_power_dB[1], - ulsch_harq->o_ACK[0], - ulsch_harq->o_ACK[1], - ret, - ulsch_harq->cqi_crc_status, - ulsch_harq->O_ACK, - eNB->ulsch_decoding_stats.p_time, eNB->ulsch_decoding_stats.max); - if (ulsch_harq->repetition_number < ulsch_harq->total_number_of_repetitions){ - ulsch_harq->rvidx = rvidx_tab[(ulsch_harq->repetition_number%4)] ; // Set the correct rvidx for the next emtc repetitions - ulsch_harq->repetition_number +=1 ; // Increment repetition_number for the next ULSCH allocation - } - //compute the expected ULSCH RX power (for the stats) - ulsch_harq->delta_TF = get_hundred_times_delta_IF_eNB(eNB,i,harq_pid, 0); // 0 means bw_factor is not considered - - if (RC.mac != NULL) { /* ulsim does not use RC.mac context. */ - if (ulsch_harq->cqi_crc_status == 1) { -#ifdef DEBUG_PHY_PROC - //if (((frame%10) == 0) || (frame < 50)) - print_CQI(ulsch_harq->o,ulsch_harq->uci_format,0,fp->N_RB_DL); -#endif - fill_ulsch_cqi_indication(eNB,frame,subframe,ulsch_harq,ulsch->rnti); - RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe)); - } else { - if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag & (1 << subframe) ) { - RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe)); - RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30; - LOG_D(PHY,"Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe); - } - } - } - - if (ret == (1+MAX_TURBO_ITERATIONS)) { - T(T_ENB_PHY_ULSCH_UE_NACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(ulsch->rnti), - T_INT(harq_pid)); - fill_crc_indication(eNB,i,frame,subframe,1); // indicate NAK to MAC - fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC - LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d Error receiving ULSCH, round %d/%d (ACK %d,%d)\n", - eNB->Mod_id,harq_pid, - frame,subframe, i, - ulsch_harq->round, - ulsch->Mlimit, - ulsch_harq->o_ACK[0], - ulsch_harq->o_ACK[1]); - - if (ulsch_harq->round >= 3) { - ulsch_harq->status = SCH_IDLE; - ulsch_harq->handled = 0; - ulsch->harq_mask &= ~(1 << harq_pid); - ulsch_harq->round = 0; - } - - MSC_LOG_RX_DISCARDED_MESSAGE( - MSC_PHY_ENB,MSC_PHY_UE, - NULL,0, - "%05u:%02u ULSCH received rnti %x harq id %u round %d", - frame,subframe, - ulsch->rnti,harq_pid, - ulsch_harq->round-1 - ); - /* Mark the HARQ process to release it later if max transmission reached - * (see below). - * MAC does not send the max transmission count, we have to deal with it - * locally in PHY. - */ - ulsch_harq->handled = 1; - } // ulsch in error - else if(ulsch_harq->repetition_number == ulsch_harq->total_number_of_repetitions){ - fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC - fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC - ulsch_harq->status = SCH_IDLE; - ulsch->harq_mask &= ~(1 << harq_pid); - T (T_ENB_PHY_ULSCH_UE_ACK, T_INT (eNB->Mod_id), T_INT (frame), T_INT (subframe), T_INT (ulsch->rnti), T_INT (harq_pid)); - MSC_LOG_RX_MESSAGE( - MSC_PHY_ENB,MSC_PHY_UE, - NULL,0, - "%05u:%02u ULSCH received rnti %x harq id %u", - frame,subframe, - ulsch->rnti,harq_pid - ); -#ifdef DEBUG_PHY_PROC -#ifdef DEBUG_ULSCH - LOG_D(PHY,"[eNB] Frame %d, Subframe %d : ULSCH SDU (RX harq_pid %d) %d bytes:",frame,subframe, - harq_pid,ulsch_harq->TBS>>3); - - for (j=0; jTBS>>3; j++) - LOG_T(PHY,"%x.",ulsch->harq_processes[harq_pid]->b[j]); - - LOG_T(PHY,"\n"); -#endif -#endif - } // ulsch not in error - - if (ulsch_harq->O_ACK>0) fill_ulsch_harq_indication(eNB,ulsch_harq,ulsch->rnti,frame,subframe,ulsch->bundling); - - LOG_D(PHY,"[eNB %d] Frame %d subframe %d: received ULSCH harq_pid %d for UE %d, ret = %d, CQI CRC Status %d, ACK %d,%d, ulsch_errors %d/%d\n", - eNB->Mod_id,frame,subframe, - harq_pid, - i, - ret, - ulsch_harq->cqi_crc_status, - ulsch_harq->o_ACK[0], - ulsch_harq->o_ACK[1], - eNB->UE_stats[i].ulsch_errors[harq_pid], - eNB->UE_stats[i].ulsch_decoding_attempts[harq_pid][0]); - } // if ((ulsch) && - // (ulsch->rnti>0) && - // (ulsch_harq->status == ACTIVE)) + } else if ((ulsch) && (ulsch->rnti>0) && (ulsch_harq->status == ACTIVE) && @@ -1338,6 +1325,12 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { LOG_W (PHY, "Removing stale ULSCH config for UE %x harq_pid %d (harq_mask is now 0x%2.2x)\n", ulsch->rnti, harq_pid, ulsch->harq_mask); } } // for (i=0; inbDecode > 0) { + notifiedFIFO_elt_t *req=pullTpool(proc->respDecode, proc->threadPool); + postDecode(proc, req); + delNotifiedFIFO_elt(req); + } } extern int oai_exit; @@ -1345,24 +1338,29 @@ extern int oai_exit; extern void *td_thread (void *); void init_td_thread(PHY_VARS_eNB *eNB) { + /* L1_proc_t *proc = &eNB->proc; proc->tdp.eNB = eNB; proc->instance_cnt_td = -1; threadCreate(&proc->pthread_td, td_thread, (void *)&proc->tdp, "TD", -1, OAI_PRIORITY_RT); + */ } void kill_td_thread(PHY_VARS_eNB *eNB) { + /* L1_proc_t *proc = &eNB->proc; proc->instance_cnt_td = 0; pthread_cond_signal(&proc->cond_td); pthread_join(proc->pthread_td, NULL); pthread_mutex_destroy( &proc->mutex_td ); pthread_cond_destroy( &proc->cond_td ); + */ } extern void *te_thread (void *); void init_te_thread(PHY_VARS_eNB *eNB) { + /* L1_proc_t *proc = &eNB->proc; for(int i=0; i<3 ; i++) { @@ -1373,9 +1371,11 @@ void init_te_thread(PHY_VARS_eNB *eNB) { sprintf(txt,"TE_%d", i); threadCreate(&proc->tep[i].pthread_te, te_thread, (void *)&proc->tep[i], txt, -1, OAI_PRIORITY_RT); } + */ } void kill_te_thread(PHY_VARS_eNB *eNB) { + /* L1_proc_t *proc = &eNB->proc; for(int i=0; i<3 ; i++) { @@ -1385,6 +1385,7 @@ void kill_te_thread(PHY_VARS_eNB *eNB) { pthread_mutex_destroy( &proc->tep[i].mutex_te); pthread_cond_destroy( &proc->tep[i].cond_te); } + */ } void fill_rx_indication(PHY_VARS_eNB *eNB, @@ -1412,7 +1413,7 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation - pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->b; + pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->decodedBytes; // estimate timing advance for MAC sync_pos = lte_est_timing_advance_pusch(eNB,UE_id); timing_advance_update = sync_pos; // - eNB->frame_parms.nb_prefix_samples/4; //to check @@ -1745,7 +1746,12 @@ void fill_ulsch_harq_indication (PHY_VARS_eNB *eNB, LTE_UL_eNB_HARQ_t *ulsch_har pthread_mutex_unlock(&eNB->UL_INFO_mutex); } -void fill_uci_harq_indication (PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask) { +void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask) { + if ( split73 == SPLIT73_DU ) { + sendFs6Ulharq(fs6ULindicationHarq, UEid, eNB, uci, frame, subframe, harq_ack, tdd_mapping_mode, tdd_multiplexing_mask, 0, 0); + return; + } + int UE_id=find_dlsch(uci->rnti,eNB,SEARCH_EXIST); //AssertFatal(UE_id>=0,"UE_id doesn't exist rnti:%x\n", uci->rnti); diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c index eb9a2922c5..9b1124d32a 100644 --- a/openair1/SCHED/prach_procedures.c +++ b/openair1/SCHED/prach_procedures.c @@ -106,6 +106,15 @@ void prach_procedures(PHY_VARS_eNB *eNB, eNB->prach_energy_counter, eNB->measurements.prach_I0+eNB->prach_DTX_threshold, eNB->measurements.prach_I0); + if (max_preamble_energy[0] > 100 && br_flag==0) + LOG_W(PHY,"[RAPROC] Frame %d, subframe %d : BR %d Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d), threshold %d, I0 %d\n", + frame,subframe,br_flag, + max_preamble[0], + max_preamble_energy[0]/10, + max_preamble_delay[0], + eNB->prach_energy_counter, + eNB->measurements.prach_I0+eNB->prach_DTX_threshold, + eNB->measurements.prach_I0); if (br_flag==1) { int prach_mask; diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 6d392b0437..8846b77af9 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -321,7 +321,7 @@ void feptx_ofdm(RU_t *ru, fp->nb_prefix_samples, CYCLIC_PREFIX); } else { - if(is_pmch_subframe(ru->proc.frame_tx,subframe,fp)/*subframe==1*/){ + if(is_pmch_subframe(frame,subframe,fp)/*subframe==1*/){ normal_prefix_mod(&ru->common.txdataF_BF[aa][0], dummy_tx_b, 2, @@ -426,7 +426,7 @@ void feptx_ofdm(RU_t *ru, stop_meas(&ru->ofdm_mod_stats); LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, subframe %d: txp (time %p) %d dB, txp (freq) %d dB\n", - ru->proc.frame_tx,subframe,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->samples_per_tti)), + frame,subframe,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->samples_per_tti)), dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF))); } } diff --git a/openair1/SCHED/sched_common.h b/openair1/SCHED/sched_common.h index e9af869b05..f3e43d516e 100644 --- a/openair1/SCHED/sched_common.h +++ b/openair1/SCHED/sched_common.h @@ -311,7 +311,7 @@ void get_cqipmiri_params(PHY_VARS_UE *ue,uint8_t eNB_id); int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id, uint8_t eNB_index); -void schedule_response(Sched_Rsp_t *Sched_INFO); +void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc); LTE_eNB_UE_stats* get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti); diff --git a/openair1/SCHED/sched_eNB.h b/openair1/SCHED/sched_eNB.h index e74b9a312f..f04bec2e5c 100644 --- a/openair1/SCHED/sched_eNB.h +++ b/openair1/SCHED/sched_eNB.h @@ -128,8 +128,8 @@ void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,L1_rxtx_proc_t *proc); @param br_flag indicator for eMTC PRACH */ -void prach_procedures(PHY_VARS_eNB *eNB, - int br_flag); +void prach_procedures(PHY_VARS_eNB *eNB, + int br_flag); /*! \brief Function to compute timing of Msg3 transmission on UL-SCH (first UE transmission in RA procedure). This implements the timing in paragraph a) from Section 6.1.1 in 36.213 (p. 17 in version 8.6). Used by eNB upon transmission of random-access response (RA_RNTI) to program corresponding ULSCH reception procedure. Used by UE upon reception of random-access response (RA_RNTI) to program corresponding ULSCH transmission procedure. This does not support the UL_delay field in RAR (always assumed to be 0). @@ -193,7 +193,7 @@ int8_t find_ue_ulsch(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB); -void schedule_response(Sched_Rsp_t *Sched_INFO); +void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc); LTE_eNB_UE_stats *get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti); @@ -218,8 +218,6 @@ int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subf void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); void release_rnti_of_phy(module_id_t mod_id); - -void ru_fep_full_2thread(RU_t *ru, int subframe); /*@}*/ diff --git a/openair1/SCHED_NR_UE/phy_frame_config_nr.c b/openair1/SCHED_NR_UE/phy_frame_config_nr.c index fc1c459ba4..e93eb09b8e 100644 --- a/openair1/SCHED_NR_UE/phy_frame_config_nr.c +++ b/openair1/SCHED_NR_UE/phy_frame_config_nr.c @@ -135,7 +135,7 @@ int set_tdd_config_nr(NR_DL_FRAME_PARMS *frame_parms, int dl_UL_TransmissionPeri void add_tdd_dedicated_configuration_nr(NR_DL_FRAME_PARMS *frame_parms, int slotIndex, int nrofDownlinkSymbols, int nrofUplinkSymbols) { TDD_UL_DL_SlotConfig_t *p_TDD_UL_DL_ConfigDedicated = frame_parms->p_TDD_UL_DL_ConfigDedicated; - TDD_UL_DL_SlotConfig_t *p_previous_TDD_UL_DL_ConfigDedicated; + TDD_UL_DL_SlotConfig_t *p_previous_TDD_UL_DL_ConfigDedicated=NULL; int next = 0; while (p_TDD_UL_DL_ConfigDedicated != NULL) { diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 6706b0f912..f65e1f9633 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -59,6 +59,7 @@ #include "unitary_defs.h" #include "dummy_functions.c" #include "executables/thread-common.h" +#include "executables/split_headers.h" void feptx_ofdm(RU_t *ru, int frame, int subframe); void feptx_prec(RU_t *ru, int frame, int subframe); @@ -78,6 +79,13 @@ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ int emulate_rf = 0; +int split73=0; +void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { + AssertFatal(false, "Must not be called in this context\n"); +} +void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, uint16_t rnti, int32_t stat) { + AssertFatal(false, "Must not be called in this context\n"); +} void handler(int sig) { void *array[10]; @@ -515,7 +523,7 @@ int main(int argc, char **argv) { char fname[32],vname[32]; FILE *bler_fd; char bler_fname[256]; - FILE *time_meas_fd; + FILE *time_meas_fd=NULL; char time_meas_fname[256]; // FILE *tikz_fd; // char tikz_fname[256]; @@ -1266,6 +1274,13 @@ int main(int argc, char **argv) { } L1_rxtx_proc_t *proc_eNB = &eNB->proc.L1_proc; + proc_eNB->threadPool=(tpool_t*)malloc(sizeof(tpool_t)); + proc_eNB->respEncode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + proc_eNB->respDecode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initTpool("n", proc_eNB->threadPool, true); + initNotifiedFIFO(proc_eNB->respEncode); + initNotifiedFIFO(proc_eNB->respDecode); + proc_eNB->frame_tx=0; if (input_fd==NULL) { @@ -1446,7 +1461,7 @@ int main(int argc, char **argv) { sched_resp.subframe=subframe; sched_resp.frame=proc_eNB->frame_tx; eNB->abstraction_flag=0; - schedule_response(&sched_resp); + schedule_response(&sched_resp, proc_eNB); phy_procedures_eNB_TX(eNB,proc_eNB,1); if (uncoded_ber_bit == NULL) { @@ -1480,7 +1495,7 @@ int main(int argc, char **argv) { TX_req.tx_request_body.number_of_pdus=0; proc_eNB->subframe_tx = subframe+1; sched_resp.subframe=subframe+1; - schedule_response(&sched_resp); + schedule_response(&sched_resp, proc_eNB); phy_procedures_eNB_TX(eNB,proc_eNB,0); ru->proc.tti_tx=(subframe+1)%10; feptx_prec(ru,proc_eNB->frame_tx,subframe+1); @@ -1583,11 +1598,11 @@ int main(int argc, char **argv) { subframe<<1); for (i=0; idlsch[0][0]->harq_processes[0]->e[i]==1 && UE->pdsch_vars[UE->current_thread_id[subframe]][0]->llr[0][i] > 0)|| - (eNB->dlsch[0][0]->harq_processes[0]->e[i]==0 && UE->pdsch_vars[UE->current_thread_id[subframe]][0]->llr[0][i] < 0)) { + if ((eNB->dlsch[0][0]->harq_processes[0]->eDL[i]==1 && UE->pdsch_vars[UE->current_thread_id[subframe]][0]->llr[0][i] > 0)|| + (eNB->dlsch[0][0]->harq_processes[0]->eDL[i]==0 && UE->pdsch_vars[UE->current_thread_id[subframe]][0]->llr[0][i] < 0)) { uncoded_ber_bit[bit_errors++] = 1; printf("error in pos %d : %d => %d\n",i, - eNB->dlsch[0][0]->harq_processes[0]->e[i], + eNB->dlsch[0][0]->harq_processes[0]->eDL[i], UE->pdsch_vars[UE->current_thread_id[subframe]][0]->llr[0][i]); } else { /* @@ -1634,7 +1649,7 @@ int main(int argc, char **argv) { //pdsch_vars printf("coded_bits_per_codeword %u\n",coded_bits_per_codeword); dump_dlsch2(UE,eNB_id,subframe,&coded_bits_per_codeword,round, UE->dlsch[UE->current_thread_id[subframe]][0][0]->current_harq_pid); - LOG_M("dlsch_e.m","e",eNB->dlsch[0][0]->harq_processes[0]->e,coded_bits_per_codeword,1,4); + LOG_M("dlsch_e.m","e",eNB->dlsch[0][0]->harq_processes[0]->eDL,coded_bits_per_codeword,1,4); //pdcch_vars LOG_M("pdcchF0_ext.m","pdcchF_ext", UE->pdcch_vars[0][eNB_id]->rxdataF_ext[0],2*3*UE->frame_parms.ofdm_symbol_size,1,1); LOG_M("pdcch00_ch0_ext.m","pdcch00_ch0_ext",UE->pdcch_vars[0][eNB_id]->dl_ch_estimates_ext[0],300*3,1,1); diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index db97240ed5..064066801d 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -54,6 +54,7 @@ #include "common/config/config_load_configmodule.h" #include "executables/thread-common.h" #include "targets/RT/USER/lte-softmodem.h" +#include "executables/split_headers.h" double cpuf; #define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0)) @@ -81,6 +82,14 @@ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ +int split73=0; +void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { + AssertFatal(false, "Must not be called in this context\n"); +} +void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, uint16_t rnti, int32_t stat) { + AssertFatal(false, "Must not be called in this context\n"); +} + extern void fep_full(RU_t *ru, int subframe); extern void ru_fep_full_2thread(RU_t *ru, int subframe); //extern void eNB_fep_full(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc); @@ -793,6 +802,13 @@ int main(int argc, char **argv) { proc_rxtx_ue->frame_rx = (subframe<4)?(proc_rxtx->frame_tx-1):(proc_rxtx->frame_tx); proc_rxtx_ue->subframe_tx = proc_rxtx->subframe_rx; proc_rxtx_ue->subframe_rx = (proc_rxtx->subframe_tx+6)%10; + proc_rxtx->threadPool=(tpool_t*)malloc(sizeof(tpool_t)); + proc_rxtx->respEncode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + proc_rxtx->respDecode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initTpool("n",proc_rxtx->threadPool, true); + initNotifiedFIFO(proc_rxtx->respEncode); + initNotifiedFIFO(proc_rxtx->respDecode); + printf("Init UL hopping UE\n"); init_ul_hopping(&UE->frame_parms); printf("Init UL hopping eNB\n"); @@ -995,7 +1011,7 @@ int main(int argc, char **argv) { srs_flag); sched_resp.subframe=(subframe+6)%10; sched_resp.frame=(1024+eNB->proc.frame_rx+((subframe<4)?-1:0))&1023; - schedule_response(&sched_resp); + schedule_response(&sched_resp, proc_rxtx); ///////////////////// if (abstx) { @@ -1352,7 +1368,7 @@ int main(int argc, char **argv) { printStatIndent2(&eNB->ulsch_deinterleaving_stats,"sub-block interleaving" ); printStatIndent2(&eNB->ulsch_demultiplexing_stats,"sub-block demultiplexing" ); printStatIndent2(&eNB->ulsch_rate_unmatching_stats,"sub-block rate-matching" ); - printf("|__ turbo_decoder(%d bits), avg iterations: %.1f %.2f us (%d cycles, %d trials)\n", + printf(" |__ turbo_decoder(%d bits), avg iterations: %.1f %.2f us (%d cycles, %d trials)\n", eNB->ulsch[0]->harq_processes[harq_pid]->Cminus ? eNB->ulsch[0]->harq_processes[harq_pid]->Kminus : eNB->ulsch[0]->harq_processes[harq_pid]->Kplus, diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index 30c10940c9..a85cbac543 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -290,7 +290,7 @@ Protocol__FlexUlCqiReport * copy_ul_cqi_report(Protocol__FlexUlCqiReport * origi full_ul_report->has_sfn_sn = original->has_sfn_sn; full_ul_report->n_cqi_meas = original->n_cqi_meas; - Protocol__FlexUlCqi **ul_report; + Protocol__FlexUlCqi **ul_report=NULL; ul_report = malloc(sizeof(Protocol__FlexUlCqi *) * full_ul_report->n_cqi_meas); if(ul_report == NULL) goto error; @@ -348,7 +348,7 @@ Protocol__FlexDlCqiReport * copy_dl_cqi_report(Protocol__FlexDlCqiReport * origi dl_report->has_sfn_sn = original->has_sfn_sn; dl_report->n_csi_report = original->n_csi_report; - Protocol__FlexDlCsi **csi_reports; + Protocol__FlexDlCsi **csi_reports=NULL; csi_reports = malloc(sizeof(Protocol__FlexDlCsi *) * dl_report->n_csi_report); if (csi_reports == NULL) goto error; @@ -383,7 +383,7 @@ Protocol__FlexPagingBufferReport * copy_paging_buffer_report(Protocol__FlexPagin protocol__flex_paging_buffer_report__init(copy); copy->n_paging_info = original->n_paging_info; - Protocol__FlexPagingInfo **p_info; + Protocol__FlexPagingInfo **p_info=NULL; p_info = malloc(sizeof(Protocol__FlexPagingInfo *) * copy->n_paging_info); if (p_info == NULL) goto error; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c index 260d8a7417..f47f88ca4d 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -1962,7 +1962,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( uint8_t first_ue_total[MAX_NUM_CCs][20]; uint8_t first_ue_id[MAX_NUM_CCs][20]; uint8_t ul_inactivity_num[MAX_NUM_CCs]; - uint8_t ul_inactivity_id[MAX_NUM_CCs][20]; + uint8_t ul_inactivity_id[MAX_NUM_CCs][20]={0}; // LTE_DL_FRAME_PARMS *frame_parms; uint8_t ulsch_ue_max_num[MAX_NUM_CCs]; uint16_t saved_ulsch_dci[MAX_NUM_CCs]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index d240e35a87..d5572e1d3b 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -182,7 +182,7 @@ rx_sdu(const module_id_t enb_mod_idP, UE_template_ptr->scheduled_ul_bytes = 0; } } else { // sduP == NULL => error - LOG_W(MAC, "[eNB %d][PUSCH %d] CC_id %d %d.%d ULSCH in error in round %d, ul_cqi %d, UE_id %d, RNTI %x\n", + LOG_W(MAC, "[eNB %d][PUSCH %d] CC_id %d %d.%d ULSCH in error in round %d, ul_cqi %d, UE_id %d, RNTI %x (len %d)\n", enb_mod_idP, harq_pid, CC_idP, @@ -191,7 +191,8 @@ rx_sdu(const module_id_t enb_mod_idP, UE_scheduling_control->round_UL[CC_idP][harq_pid], ul_cqi, UE_id, - current_rnti); + current_rnti, + sdu_lenP); if (ul_cqi > 200) { // too high energy pattern UE_scheduling_control->pusch_snr[CC_idP] = ul_cqi; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index bd4e4de2a4..37e3ef9802 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -1789,12 +1789,17 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, } total_allocated_rbs[CC_id] += nb_allocated_rbs[CC_id][UE_id]; - LOG_D(MAC, "In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d\n", + LOG_D(MAC, "In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d, nb_rb_ul %d, %d ,%d, slice %d, round ul %d\n", nb_allocated_rbs[CC_id][UE_id], UE_id, rntiTable[UE_id], CC_id, - harq_pid); + harq_pid, + UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid], + UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[slice_idx], + average_rbs_per_user[CC_id], + slice_idx, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]); } } @@ -1819,6 +1824,10 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, while (UE_template->pre_allocated_nb_rb_ul[slice_idx] > 0 && nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul[slice_idx] && total_remaining_rbs[CC_id] > 0) { + LOG_D(PHY,"in ulsch alloc: prealloc: %d, nb_allocated %d, total remain%d\n", + UE_template->pre_allocated_nb_rb_ul[slice_idx], + nb_allocated_rbs[CC_id][UE_id], + total_remaining_rbs[CC_id]); nb_allocated_rbs[CC_id][UE_id] = cmin(nb_allocated_rbs[CC_id][UE_id] + 1, UE_template->pre_allocated_nb_rb_ul[slice_idx]); total_remaining_rbs[CC_id]--; total_allocated_rbs[CC_id]++; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 2df700e031..37e6bc0467 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2069,7 +2069,7 @@ void nr_ue_send_sdu(module_id_t module_idP, if (opt_enabled) { trace_pdu(DIRECTION_DOWNLINK, pduP, pdu_len, module_idP, WS_C_RNTI, - (int)(UE_mac_inst[module_idP].cs_RNTI), frameP, ttiP, 0, 0); //subframeP + *UE_mac_inst[module_idP].cs_RNTI, frameP, ttiP, 0, 0); //subframeP LOG_D(OPT, "[UE %d][DLSCH] Frame %d trace pdu for rnti %p with size %d\n", module_idP, frameP, UE_mac_inst[module_idP].cs_RNTI, pdu_len); } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h deleted file mode 100644 index b9f62acc3c..0000000000 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* - pdcp_proto_extern.h - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr - - ***************************************************************************/ -#ifndef __PDCP_PROTO_EXTERN_H__ -# define __PDCP_PROTO_EXTERN_H__ - -//# include "pdcp_entity.h" -//# include "rb_mux.h" -# include "mem_block.h" - -#ifdef ROHC -extern void pdcp_data_ind (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, mem_block_t *sduP); -extern void pdcp_data_req (struct pdcp_entity *pdcpP, mem_block *sduP); -extern void send_pdcp_control_primitive (struct pdcp_entity *pdcpP, mem_block *cprimitiveP); -extern void control_pdcp (struct pdcp_entity *pdcpP); -extern void pdcp_process_input_sdus_high(struct pdcp_entity *pdcpP); -extern void pdcp_process_input_sdus_am (struct pdcp_entity *pdcpP, uint16_t data_sizeP, mem_block *sduP); -extern void pdcp_process_output_sdus (struct pdcp_entity *pdcpP, mem_block *sduP, uint8_t rb_idP); -extern void pdcp_process_output_sdus_high (struct pdcp_entity *pdcpP, mem_block *sduP, uint16_t data_sizeP, uint16_t rb_idP); -extern void pdcp_process_input_sdus_um (struct pdcp_entity *pdcpP, uint16_t data_sizeP, mem_block *sduP); -extern void pdcp_process_input_sdus_tr (struct pdcp_entity *pdcpP, uint16_t data_sizeP, mem_block *sduP); -extern void init_pdcp (struct pdcp_entity *pdcpP, struct rb_dispatcher *rbP, uint8_t rb_idP); -extern void *pdcp_tx (struct pdcp_entity *pdcpP, uint16_t data_sizeP, mem_block *sduP); -extern int reception_from_rohc_mt(void); -extern int reception_from_rohc_bs(void); -#else -extern BOOL pdcp_data_ind (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, mem_block_t *sduP, uint8_t is_data_plane); -extern BOOL pdcp_data_req (module_id_t module_id, uint32_t frame, uint8_t eNB_flag, rb_id_t rab_id, uint32_t muiP, uint32_t confirmP, sdu_size_t sdu_buffer_size, unsigned char *sdu_buffer, - uint8_t is_data_pdu,const uint32_t *const sourceL2Id,const uint32_t *const destinationL2Id - ); -//extern BOOL pdcp_data_req (struct pdcp_entity *pdcpP, mem_block * sduP); -extern void send_pdcp_control_primitive (struct pdcp_entity *pdcpP, mem_block *cprimitiveP); -extern void control_pdcp (struct pdcp_entity *pdcpP); -extern void pdcp_process_input_sdus_am (struct pdcp_entity *pdcpP); -extern void pdcp_process_output_sdus (struct pdcp_entity *pdcpP, mem_block *sduP, uint8_t rb_idP); -extern void pdcp_process_input_sdus_um (struct pdcp_entity *pdcpP); -extern void pdcp_process_input_sdus_tr (struct pdcp_entity *pdcpP); -extern void init_pdcp (struct pdcp_entity *pdcpP, struct rb_dispatcher *rbP, uint8_t rb_idP); -extern void *pdcp_tx (void *argP); -#endif - -extern void pdcp_pc5_socket_init(void); - -#endif diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index dfdf527123..b337bcac7e 100644 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -137,7 +137,7 @@ void (*rlc_rrc_data_ind)( const protocol_ctxt_t *const ctxtP, const rb_id_t rb_idP, const sdu_size_t sdu_sizeP, - const uint8_t *const sduP); + const uint8_t *const sduP) __attribute__ ((aligned(32))); void (*rlc_rrc_data_conf)( const protocol_ctxt_t *const ctxtP, @@ -250,7 +250,7 @@ logical_chan_id_t rlc_mbms_rbid2lcid_eNB[MAX_eNB][NB_RB_MBMS_MAX]; (((hash_key_t)(sESSION_ID)) << 37) | \ (((hash_key_t)(0x0000000000000001)) << 63)) -hash_table_t *rlc_coll_p; +hash_table_t *rlc_coll_p __attribute__ ((aligned(32))); /*! \fn tbs_size_t mac_rlc_serialize_tb (char* bufferP, list_t transport_blocksP) * \brief Serialize a list of transport blocks coming from RLC in order to be processed by MAC. diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index b5cda35193..d98c603d78 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -685,7 +685,7 @@ static void dump_dl(Sched_Rsp_t *d) { /* debug utility functions end */ /****************************************************************************/ -void UL_indication(UL_IND_t *UL_info) { +void UL_indication(UL_IND_t *UL_info, L1_rxtx_proc_t *proc) { AssertFatal(UL_info!=NULL,"UL_INFO is null\n"); #ifdef DUMP_FAPI dump_ul(UL_info); @@ -767,7 +767,7 @@ void UL_indication(UL_IND_t *UL_info) { "schedule_response is null (mod %d, cc %d)\n", module_id, CC_id); - ifi->schedule_response(sched_info); + ifi->schedule_response(sched_info, proc ); } LOG_D(PHY,"Schedule_response: SFN_SF:%d%d dl_pdus:%d\n",sched_info->frame,sched_info->subframe,sched_info->DL_req->dl_config_request_body.number_pdu); diff --git a/openair2/PHY_INTERFACE/IF_Module.h b/openair2/PHY_INTERFACE/IF_Module.h index f260222097..42a4459732 100644 --- a/openair2/PHY_INTERFACE/IF_Module.h +++ b/openair2/PHY_INTERFACE/IF_Module.h @@ -34,10 +34,12 @@ #include +#include //#include "openair1/PHY/LTE_TRANSPORT/transport_eNB.h" #include "nfapi_interface.h" #include "platform_constants.h" #include "platform_types.h" +#include #define MAX_NUM_DL_PDU 100 #define MAX_NUM_UL_PDU 100 @@ -130,16 +132,69 @@ typedef struct { } Sched_Rsp_t; typedef struct { - uint8_t Mod_id; - int CC_id; - nfapi_config_request_t *cfg; -} PHY_Config_t; + uint8_t Mod_id; + int CC_id; + nfapi_config_request_t *cfg; +}PHY_Config_t; +#include +/// Context data structure for RX/TX portion of subframe processing +typedef struct { + /// Component Carrier index + uint8_t CC_id; + /// timestamp transmitted to HW + openair0_timestamp timestamp_tx; + openair0_timestamp timestamp_rx; + /// subframe to act upon for transmission + int subframe_tx; + /// subframe to act upon for reception + int subframe_rx; + /// frame to act upon for transmission + int frame_tx; + /// frame to act upon for reception + int frame_rx; + int frame_prach; + int subframe_prach; + int frame_prach_br; + int subframe_prach_br; + /// \brief Instance count for RXn-TXnp4 processing thread. + /// \internal This variable is protected by \ref mutex_rxtx. + int instance_cnt; + /// pthread structure for RXn-TXnp4 processing thread + pthread_t pthread; + /// pthread attributes for RXn-TXnp4 processing thread + pthread_attr_t attr; + /// condition variable for tx processing thread + pthread_cond_t cond; + /// mutex for RXn-TXnp4 processing thread + pthread_mutex_t mutex; + /// scheduling parameters for RXn-TXnp4 thread + struct sched_param sched_param_rxtx; + + /// \internal This variable is protected by \ref mutex_RUs. + int instance_cnt_RUs; + /// condition variable for tx processing thread + pthread_cond_t cond_RUs; + /// mutex for RXn-TXnp4 processing thread + pthread_mutex_t mutex_RUs; + tpool_t *threadPool; + int nbEncode; + int nbDecode; + notifiedFIFO_t *respEncode; + notifiedFIFO_t *respDecode; + pthread_mutex_t mutex_emulateRF; + int instance_cnt_emulateRF; + pthread_t pthread_emulateRF; + pthread_attr_t attr_emulateRF; + pthread_cond_t cond_emulateRF; + int first_rx; +} L1_rxtx_proc_t; + +typedef struct IF_Module_s{ +//define the function pointer + void (*UL_indication)(UL_IND_t *UL_INFO, L1_rxtx_proc_t *proc); + void (*schedule_response)(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc); + void (*PHY_config_req)(PHY_Config_t* config_INFO); -typedef struct IF_Module_s { - //define the function pointer - void (*UL_indication)(UL_IND_t *UL_INFO); - void (*schedule_response)(Sched_Rsp_t *Sched_INFO); - void (*PHY_config_req)(PHY_Config_t *config_INFO); void (*PHY_config_update_sib2_req)(PHY_Config_t* config_INFO); void (*PHY_config_update_sib13_req)(PHY_Config_t* config_INFO); uint32_t CC_mask; @@ -165,7 +220,7 @@ void IF_Module_kill(int Mod_id); /*Interface for uplink, transmitting the Preamble(list), ULSCH SDU, NAK, Tick (trigger scheduler) */ -void UL_indication(UL_IND_t *UL_INFO); +void UL_indication(UL_IND_t *UL_INFO, L1_rxtx_proc_t *proc); /*Interface for Downlink, transmitting the DLSCH SDU, DCI SDU*/ void Schedule_Response(Sched_Rsp_t *Sched_INFO); diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 14974c2e15..3704897e03 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -840,7 +840,7 @@ int hi_dci0_req_UE_MAC(nfapi_hi_dci0_request_t* req, module_id_t Mod_id) // The following set of memcpy functions should be getting called as callback functions from // pnf_p7_subframe_ind. -int memcpy_dl_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) +int memcpy_dl_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) { //for (Mod_id=0; Mod_idinitial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); RC.nrrrc[ctxt.module_id]->s1ap_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); memcpy(&RC.nrrrc[ctxt.module_id]->configuration,configuration,sizeof(gNB_RrcConfigurationReq)); - /// System Information INIT - LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" Checking release \n",PROTOCOL_NR_RRC_CTXT_ARGS(&ctxt)); for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { init_NR_SI(&ctxt, diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c deleted file mode 100644 index 0150ef00cd..0000000000 --- a/openair2/UTIL/MEM/mem_block.c +++ /dev/null @@ -1,668 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - mem_block.c - description - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr - - - ***************************************************************************/ -#define MEM_BLOCK_C -//#include "rtos_header.h" -#include "mem_block.h" -#include "mem_pool.h" -#include "list.h" -#include "LAYER2/MAC/mac_extern.h" -#include "assertions.h" -/* all function calls are protected by a mutex - * to ensure that many threads calling them at - * the same time don't mess up. - * We might be more clever in the future, it's a - * bit overkill. - * Commenting this define removes the protection, - * so be careful with it. - */ -#define MEMBLOCK_BIG_LOCK - -#ifdef MEMBLOCK_BIG_LOCK -static pthread_mutex_t mtex = PTHREAD_MUTEX_INITIALIZER; -#endif - -//----------------------------------------------------------------------------- -//#define DEBUG_MEM_MNGT_FREE -//#define DEBUG_MEM_MNGT_ALLOC_SIZE -//#define DEBUG_MEM_MNGT_ALLOC -//----------------------------------------------------------------------------- -#if defined(DEBUG_MEM_MNGT_ALLOC) -uint32_t counters[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -#endif -//----------------------------------------------------------------------------- -/* - * initialize all ures - */ -extern mem_pool *memBlockVar; -void * -pool_buffer_init (void) -{ - //----------------------------------------------------------------------------- - - uint32_t index, mb_index, pool_index; - mem_pool *memory = (mem_pool *) &mem_block_var; - memBlockVar=malloc(sizeof(mem_pool)); - int pool_sizes[14] = { MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB1_NB_BLOCKS, - MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB3_NB_BLOCKS, - MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB5_NB_BLOCKS, - MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB7_NB_BLOCKS, - MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB9_NB_BLOCKS, - MEM_MNGT_MB10_NB_BLOCKS, MEM_MNGT_MB11_NB_BLOCKS, - MEM_MNGT_MB12_NB_BLOCKS, MEM_MNGT_MBCOPY_NB_BLOCKS - }; - -#ifdef MEMBLOCK_BIG_LOCK - if (pthread_mutex_lock(&mtex)) abort(); -#endif - - memset (memory, 0, sizeof (mem_pool)); - mb_index = 0; - - // LG_TEST - for (pool_index = 0; pool_index <= MEM_MNGT_POOL_ID_COPY; pool_index++) { - list_init (&memory->mem_lists[pool_index], "POOL"); - - for (index = 0; index < pool_sizes[pool_index]; index++) { - //memory->mem_blocks[mb_index + index].previous = NULL; -> done in memset 0 - //memory->mem_blocks[mb_index + index].next = NULL; -> done in memset 0 - switch (pool_index) { - case 0: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool0[index][0]); - break; - - case 1: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool1[index][0]); - break; - - case 2: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool2[index][0]); - break; - - case 3: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool3[index][0]); - break; - - case 4: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool4[index][0]); - break; - - case 5: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool5[index][0]); - break; - - case 6: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool6[index][0]); - break; - - case 7: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool7[index][0]); - break; - - case 8: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool8[index][0]); - break; - - case 9: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool9[index][0]); - break; - - case 10: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool10[index][0]); - break; - - case 11: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool11[index][0]); - break; - - case 12: - memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool12[index][0]); - break; - - default: - ; - memory->mem_blocks[mb_index + index].data = NULL; // pool copy - - } - - memory->mem_blocks[mb_index + index].pool_id = pool_index; - list_add_tail_eurecom (&memory->mem_blocks[mb_index + index], &memory->mem_lists[pool_index]); - } - - mb_index += pool_sizes[pool_index]; - } - -#ifdef MEMBLOCK_BIG_LOCK - if (pthread_mutex_unlock(&mtex)) abort(); -#endif - - return 0; -} - -//----------------------------------------------------------------------------- -void * -pool_buffer_clean (void *arg) -{ - //----------------------------------------------------------------------------- - return 0; -} -//----------------------------------------------------------------------------- -void -free_mem_block (mem_block_t * leP, const char* caller) -{ - //----------------------------------------------------------------------------- - - if (!(leP)) { - LOG_W (RLC,"[MEM_MNGT][FREE] WARNING FREE NULL MEM_BLOCK\n"); - return; - } - -#ifdef MEMBLOCK_BIG_LOCK - if (pthread_mutex_lock(&mtex)) abort(); -#endif - -#ifdef DEBUG_MEM_MNGT_FREE - LOG_D (RLC,"[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id); -#endif -#ifdef DEBUG_MEM_MNGT_ALLOC - check_free_mem_block (leP); -#endif - - if (leP->pool_id <= MEM_MNGT_POOL_ID_COPY) { - list_add_tail_eurecom (leP, &mem_block_var.mem_lists[leP->pool_id]); -#ifdef DEBUG_MEM_MNGT_ALLOC - counters[leP->pool_id] -= 1; - LGO_D (RLC,"[%s][MEM_MNGT][INFO] after pool[%2d] freed: counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n", - caller, leP->pool_id, - counters[0],counters[1],counters[2],counters[3],counters[4], - counters[5],counters[6],counters[7],counters[8],counters[9], - counters[10],counters[11]); -#endif - leP = NULL; // this prevent from freeing the block twice - } else { - LOG_E (RLC,"[MEM_MNGT][FREE] ERROR free_mem_block() unknown pool_id : %d\n", leP->pool_id); - } - -#ifdef MEMBLOCK_BIG_LOCK - if (pthread_mutex_unlock(&mtex)) abort(); -#endif -} - -//----------------------------------------------------------------------------- -mem_block_t * -get_free_mem_block (uint32_t sizeP, const char* caller) -{ - //----------------------------------------------------------------------------- - mem_block_t *le = NULL; - int pool_selected; - int size; - - if (sizeP > MEM_MNGT_MB12_BLOCK_SIZE) { - LOG_E (RLC,"[MEM_MNGT][ERROR][FATAL] size requested %d out of bounds\n", sizeP); - display_mem_load (); - AssertFatal(1==0,"get_free_mem_block size requested out of bounds"); - return NULL; - } - -#ifdef MEMBLOCK_BIG_LOCK - if (pthread_mutex_lock(&mtex)) abort(); -#endif - - size = sizeP >> 6; - pool_selected = 0; - - while ((size)) { - pool_selected += 1; - size = size >> 1; - } - - // pool is selected according to the size requested, now get a block - // if no block is available pick one in an other pool - do { - if ((le = list_remove_head (&mem_block_var.mem_lists[pool_selected]))) { -#ifdef DEBUG_MEM_MNGT_ALLOC - counters[pool_selected] += 1; - LOG_D (RLC,"[%s][MEM_MNGT][INFO] after pool[%2d] allocated: counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n", - caller, - pool_selected, - counters[0],counters[1],counters[2],counters[3],counters[4], - counters[5],counters[6],counters[7],counters[8],counters[9], - counters[10],counters[11]); -#endif -#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE - LOG_D (RLC,"[MEM_MNGT][INFO] ALLOC MEM_BLOCK SIZE %d bytes pool %d (%p)\n", sizeP, pool_selected,le); -#endif - - AssertFatal(le->pool_id == pool_selected, "Unexpected pool ID!"); - -#ifdef MEMBLOCK_BIG_LOCK - if (pthread_mutex_unlock(&mtex)) abort(); -#endif - - return le; - } - -#ifdef DEBUG_MEM_MNGT_ALLOC - LOG_E (RLC,"[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]); - // display_mem_load (); - // check_mem_area ((void *)&mem_block_var); -#endif - } while (pool_selected++ < 12); - - LOG_E(PHY, "[MEM_MNGT][ERROR][FATAL] failed allocating MEM_BLOCK size %d byes (pool_selected=%d size=%d)\n", sizeP, pool_selected, size); -// display_mem_load(); -// AssertFatal(1==0,"get_free_mem_block failed"); - LOG_E(MAC,"[MEM_MNGT][ERROR][FATAL] get_free_mem_block failed!!!\n"); -#ifdef MEMBLOCK_BIG_LOCK - if (pthread_mutex_unlock(&mtex)) abort(); -#endif - - return NULL; -}; - -//----------------------------------------------------------------------------- -mem_block_t * -get_free_copy_mem_block (void) -{ - //----------------------------------------------------------------------------- - mem_block_t *le; - -#ifdef MEMBLOCK_BIG_LOCK - AssertFatal(0, "This function is not handled properly but not used anywhere. FIXME?\n"); -#endif - - if ((le = list_remove_head (&mem_block_var.mem_lists[MEM_MNGT_POOL_ID_COPY]))) { -#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE - LOG_D (RLC,"[MEM_MNGT][INFO] ALLOC COPY MEM BLOCK (%p)\n",le); -#endif -#ifdef DEBUG_MEM_MNGT_ALLOC - counters[MEM_MNGT_POOL_ID_COPY] += 1; - LOG_D (RLC,"[MEM_MNGT][INFO] pool counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n", - counters[0],counters[1],counters[2],counters[3],counters[4], - counters[5],counters[6],counters[7],counters[8],counters[9], - counters[10],counters[11]); -#endif - return le; - } else { - LOG_E (RLC,"[MEM_MNGT][ERROR] POOL COPY IS EMPTY\n"); - //#ifdef DEBUG_MEM_MNGT_ALLOC - check_mem_area (); - // break_point (); - //#endif - - AssertFatal(1==0,"mem pool is empty"); - return NULL; - } -} - -//----------------------------------------------------------------------------- -mem_block_t * -copy_mem_block (mem_block_t * leP, mem_block_t * destP) -{ - //----------------------------------------------------------------------------- - -#ifdef MEMBLOCK_BIG_LOCK - AssertFatal(0, "This function is not handled properly but not used anywhere. FIXME?\n"); -#endif - - if ((destP != NULL) && (leP != NULL) && (destP->pool_id == MEM_MNGT_POOL_ID_COPY)) { - destP->data = leP->data; - } else { - LOG_E (RLC,"[MEM_MNGT][COPY] copy_mem_block() pool dest src or dest is NULL\n"); - } - - return destP; -} - -//----------------------------------------------------------------------------- -void -display_mem_load (void) -{ - //----------------------------------------------------------------------------- -#ifdef MEMBLOCK_BIG_LOCK - /* this function does not need to be protected, do nothing */ -#endif - - mem_pool *memory = (mem_pool *) &mem_block_var; - - LOG_D (RLC,"POOL 0 (%d elements of %d Bytes): ", MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB0_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID0]); - LOG_D (RLC,"POOL 1 (%d elements of %d Bytes): ", MEM_MNGT_MB1_NB_BLOCKS, MEM_MNGT_MB1_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID1]); - LOG_D (RLC,"POOL 2 (%d elements of %d Bytes): ", MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB2_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID2]); - LOG_D (RLC,"POOL 3 (%d elements of %d Bytes): ", MEM_MNGT_MB3_NB_BLOCKS, MEM_MNGT_MB3_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID3]); - LOG_D (RLC,"POOL 4 (%d elements of %d Bytes): ", MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB4_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID4]); - LOG_D (RLC,"POOL 5 (%d elements of %d Bytes): ", MEM_MNGT_MB5_NB_BLOCKS, MEM_MNGT_MB5_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID5]); - LOG_D (RLC,"POOL 6 (%d elements of %d Bytes): ", MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB6_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID6]); - LOG_D (RLC,"POOL 7 (%d elements of %d Bytes): ", MEM_MNGT_MB7_NB_BLOCKS, MEM_MNGT_MB7_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID7]); - LOG_D (RLC,"POOL 8 (%d elements of %d Bytes): ", MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB8_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID8]); - LOG_D (RLC,"POOL 9 (%d elements of %d Bytes): ", MEM_MNGT_MB9_NB_BLOCKS, MEM_MNGT_MB9_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID9]); - LOG_D (RLC,"POOL 10 (%d elements of %d Bytes): ", MEM_MNGT_MB10_NB_BLOCKS, MEM_MNGT_MB10_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID10]); - LOG_D (RLC,"POOL 11 (%d elements of %d Bytes): ", MEM_MNGT_MB11_NB_BLOCKS, MEM_MNGT_MB11_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID11]); - LOG_D (RLC,"POOL 12 (%d elements of %d Bytes): ", MEM_MNGT_MB12_NB_BLOCKS, MEM_MNGT_MB12_BLOCK_SIZE); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID12]); - LOG_D (RLC,"POOL C (%d elements): ", MEM_MNGT_MBCOPY_NB_BLOCKS); - list_display (&memory->mem_lists[MEM_MNGT_POOL_ID_COPY]); -} - -//----------------------------------------------------------------------------- -void -check_mem_area (void) -{ - //----------------------------------------------------------------------------- - int index, mb_index; - mem_pool *memory = (mem_pool *) &mem_block_var; - -#ifdef MEMBLOCK_BIG_LOCK - AssertFatal(0, "This function is not handled properly but not used anywhere. FIXME?\n"); -#endif - - for (index = 0; index < MEM_MNGT_MB0_NB_BLOCKS; index++) { - if ((memory->mem_blocks[index].data != (unsigned char*)&(memory->mem_pool0[index][0])) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID0)) { - LOG_D (RLC,"[MEM] ERROR POOL0 block index %d\n", index); - } - } - - mb_index = MEM_MNGT_MB0_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB1_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool1[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID1)) { - LOG_D (RLC,"[MEM] ERROR POOL1 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB1_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB2_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool2[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID2)) { - LOG_D (RLC,"[MEM] ERROR POOL2 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB2_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB3_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool3[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID3)) { - LOG_D (RLC,"[MEM] ERROR POOL3 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB3_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB4_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool4[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID4)) { - LOG_D (RLC,"[MEM] ERROR POOL4 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB4_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB5_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool5[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID5)) { - LOG_D (RLC,"[MEM] ERROR POOL5 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB5_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB6_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool6[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID6)) { - LOG_D (RLC,"[MEM] ERROR POOL6 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB6_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB7_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool7[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID7)) { - LOG_D (RLC,"[MEM] ERROR POOL7 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB7_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB8_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool8[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID8)) { - LOG_D (RLC,"[MEM] ERROR POOL8 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB8_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB9_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool9[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID9)) { - LOG_D (RLC,"[MEM] ERROR POOL9 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB9_NB_BLOCKS; - - for (index = mb_index; index < MEM_MNGT_MB10_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool10[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID10)) { - LOG_D (RLC,"[MEM] ERROR POOL10 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB10_NB_BLOCKS; - - for (index = mb_index; index < MEM_MNGT_MB11_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool11[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID11)) { - LOG_D (RLC,"[MEM] ERROR POOL11 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB11_NB_BLOCKS; - - for (index = mb_index; index < MEM_MNGT_MB12_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool12[index][0])) - && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID12)) { - LOG_D (RLC,"[MEM] ERROR POOL12 block index %d\n", index); - } - } - - mb_index += MEM_MNGT_MB12_NB_BLOCKS; - - for (index = mb_index; index < MEM_MNGT_NB_ELEMENTS; index++) { - if ((memory->mem_blocks[index].data != NULL) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID_COPY)) { - LOG_D (RLC,"[MEM] ERROR POOL COPY block index %d\n", index); - } - } -} - -//----------------------------------------------------------------------------- -void -check_free_mem_block (mem_block_t * leP) -{ - //----------------------------------------------------------------------------- - ptrdiff_t block_index; - -#ifdef MEMBLOCK_BIG_LOCK - /* this function does not SEEM TO need to be protected, do nothing (for the moment) */ -#endif - - if ((leP >= mem_block_var.mem_blocks) && (leP <= &mem_block_var.mem_blocks[MEM_MNGT_NB_ELEMENTS-1])) { - // the pointer is inside the memory region - block_index = leP - mem_block_var.mem_blocks; - // block_index is now: 0 <= block_index < MEM_MNGT_NB_ELEMENTS - - if (block_index < MEM_MNGT_MB0_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool0[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID0)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB0_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB1_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool1[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID1)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB1_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB2_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool2[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID2)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB2_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB3_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool3[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID3)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB3_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB4_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool4[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID4)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB4_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB5_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool5[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID5)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB5_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB6_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool6[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID6)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB6_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB7_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool7[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID7)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB7_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB8_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool8[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID8)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB8_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB9_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool9[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID9)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB9_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB10_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool10[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID10)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB10_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB11_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool11[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID11)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - - block_index -= MEM_MNGT_MB11_NB_BLOCKS; - - if (block_index < MEM_MNGT_MB12_NB_BLOCKS) { - if ((leP->data != (unsigned char*)mem_block_var.mem_pool12[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID12)) { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - return; - } - } else { - LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - - // the block is ok -} diff --git a/openair2/UTIL/MEM/mem_block.h b/openair2/UTIL/MEM/mem_block.h index f40566f6ed..0d99430640 100644 --- a/openair2/UTIL/MEM/mem_block.h +++ b/openair2/UTIL/MEM/mem_block.h @@ -57,91 +57,8 @@ mem_block_t *get_free_copy_mem_block (void); mem_block_t *get_free_copy_mem_block_up (void); mem_block_t *copy_mem_block (mem_block_t * leP, mem_block_t * destP); void display_mem_load (void); - -void check_mem_area (void); -void check_free_mem_block (mem_block_t * leP); -# define MEM_SCALE MAX_MOBILES_PER_ENB -// definition of the size of the allocated memory area -# define MEM_MNGT_MB0_BLOCK_SIZE 64 -// 64 -# define MEM_MNGT_MB0_NB_BLOCKS 4096 * MEM_SCALE -# define MEM_MNGT_POOL_ID0 0 - -# define MEM_MNGT_MB1_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*2 -// 128 -# define MEM_MNGT_MB1_NB_BLOCKS 4096 * MEM_SCALE -# define MEM_MNGT_POOL_ID1 1 - -# define MEM_MNGT_MB2_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*4 -// 256 -# define MEM_MNGT_MB2_NB_BLOCKS 2048 * MEM_SCALE -# define MEM_MNGT_POOL_ID2 2 - -# define MEM_MNGT_MB3_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*8 -// 512 -# define MEM_MNGT_MB3_NB_BLOCKS 2048 * MEM_SCALE -# define MEM_MNGT_POOL_ID3 3 - -# define MEM_MNGT_MB4_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*16 -// 1024 -# define MEM_MNGT_MB4_NB_BLOCKS 1024 * MEM_SCALE -# define MEM_MNGT_POOL_ID4 4 - -# define MEM_MNGT_MB5_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*32 -// 2048 -# define MEM_MNGT_MB5_NB_BLOCKS 1024 * MEM_SCALE // LG WAS 1024 -# define MEM_MNGT_POOL_ID5 5 - -# define MEM_MNGT_MB6_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*64 -// 4096 -# define MEM_MNGT_MB6_NB_BLOCKS 1024 * MEM_SCALE // LG WAS 256 -# define MEM_MNGT_POOL_ID6 6 - -# define MEM_MNGT_MB7_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*128 -// 8192 -# define MEM_MNGT_MB7_NB_BLOCKS 64* MEM_SCALE // LG WAS 32 -# define MEM_MNGT_POOL_ID7 7 - -# define MEM_MNGT_MB8_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*256 - -#ifdef JUMBO_FRAMES -# define MEM_MNGT_MB8_NB_BLOCKS 256 * MEM_SCALE -#else -# define MEM_MNGT_MB8_NB_BLOCKS 16 * MEM_SCALE -// 16384 -#endif -# define MEM_MNGT_POOL_ID8 8 - -# define MEM_MNGT_MB9_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*512 -// 32768 -# define MEM_MNGT_MB9_NB_BLOCKS 8 * MEM_SCALE -# define MEM_MNGT_POOL_ID9 9 - -# define MEM_MNGT_MB10_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*1024 -// 65536 -# define MEM_MNGT_MB10_NB_BLOCKS 0 * MEM_SCALE -# define MEM_MNGT_POOL_ID10 10 - -# define MEM_MNGT_MB11_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*2048 -// 131072 -# define MEM_MNGT_MB11_NB_BLOCKS 0 * MEM_SCALE -# define MEM_MNGT_POOL_ID11 11 - -# define MEM_MNGT_MB12_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*4096 -// 262144 -# define MEM_MNGT_MB12_NB_BLOCKS 32 * MEM_SCALE -//# define MEM_MNGT_MB12_NB_BLOCKS 4096 * MEM_SCALE - -# define MEM_MNGT_POOL_ID12 12 - - -# define MEM_MNGT_MBCOPY_NB_BLOCKS 1024 -# define MEM_MNGT_NB_ELEMENTS MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + MEM_MNGT_MB6_NB_BLOCKS + MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS + MEM_MNGT_MB9_NB_BLOCKS + MEM_MNGT_MB10_NB_BLOCKS + MEM_MNGT_MB11_NB_BLOCKS + MEM_MNGT_MB12_NB_BLOCKS + MEM_MNGT_MBCOPY_NB_BLOCKS -# define MEM_MNGT_POOL_ID_COPY 13 - #define LIST_NAME_MAX_CHAR 32 - typedef struct { struct mem_block_t *head; struct mem_block_t *tail; @@ -156,31 +73,6 @@ typedef struct { char name[LIST_NAME_MAX_CHAR]; } list_t; - - -typedef struct { - //----------------------------------------------------------- - // basic memory management - //----------------------------------------------------------- - char mem_pool0[MEM_MNGT_MB0_NB_BLOCKS][MEM_MNGT_MB0_BLOCK_SIZE]; - char mem_pool1[MEM_MNGT_MB1_NB_BLOCKS][MEM_MNGT_MB1_BLOCK_SIZE]; - char mem_pool2[MEM_MNGT_MB2_NB_BLOCKS][MEM_MNGT_MB2_BLOCK_SIZE]; - char mem_pool3[MEM_MNGT_MB3_NB_BLOCKS][MEM_MNGT_MB3_BLOCK_SIZE]; - char mem_pool4[MEM_MNGT_MB4_NB_BLOCKS][MEM_MNGT_MB4_BLOCK_SIZE]; - char mem_pool5[MEM_MNGT_MB5_NB_BLOCKS][MEM_MNGT_MB5_BLOCK_SIZE]; - char mem_pool6[MEM_MNGT_MB6_NB_BLOCKS][MEM_MNGT_MB6_BLOCK_SIZE]; - char mem_pool7[MEM_MNGT_MB7_NB_BLOCKS][MEM_MNGT_MB7_BLOCK_SIZE]; - char mem_pool8[MEM_MNGT_MB8_NB_BLOCKS][MEM_MNGT_MB8_BLOCK_SIZE]; - char mem_pool9[MEM_MNGT_MB9_NB_BLOCKS][MEM_MNGT_MB9_BLOCK_SIZE]; - char mem_pool10[MEM_MNGT_MB10_NB_BLOCKS][MEM_MNGT_MB10_BLOCK_SIZE]; - char mem_pool11[MEM_MNGT_MB11_NB_BLOCKS][MEM_MNGT_MB11_BLOCK_SIZE]; - char mem_pool12[MEM_MNGT_MB12_NB_BLOCKS][MEM_MNGT_MB12_BLOCK_SIZE]; - mem_block_t mem_blocks[MEM_MNGT_NB_ELEMENTS]; - list_t mem_lists[14]; - -} mem_pool; - - #ifdef __cplusplus } #endif diff --git a/openair2/UTIL/MEM/mem_mngt.c b/openair2/UTIL/MEM/mem_mngt.c deleted file mode 100644 index 57c90ea4f9..0000000000 --- a/openair2/UTIL/MEM/mem_mngt.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - mem_mngt.c - description - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr - - - ***************************************************************************/ -#define MEM_MNGT_C -#include "rtos_header.h" -#include "platform.h" -#include "protocol_vars_extern.h" -#include "print.h" - -#include "mem_block.h" -#include "mem_pool.h" -#include "lists_proto_extern.h" -#include "umts_sched.h" -//----------------------------------------------------------------------------- -#define DEBUG_MEM_MNGT_FREE -#define DEBUG_MEM_MNGT_ALLOC_SIZE -#define DEBUG_MEM_MNGT_ALLOC -#ifdef DEBUG_MEM_MNGT_ADDR -# define PRINT_MEM_MNGT_ADDR msg -#else -# define PRINT_MEM_MNGT_ADDR -// -#endif -//----------------------------------------------------------------------------- -uint32_t counters[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -//----------------------------------------------------------------------------- -/* - * initialize all ures - */ -void * -pool_buffer_init (void *arg) -{ - //----------------------------------------------------------------------------- - - uint32_t index, mb_index, pool_index; - mem_pool *memory = (mem_pool *) arg; - int pool_sizes[11] = { MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB1_NB_BLOCKS, - MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB3_NB_BLOCKS, - MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB5_NB_BLOCKS, - MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB7_NB_BLOCKS, - MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB9_NB_BLOCKS, - MEM_MNGT_MBCOPY_NB_BLOCKS - }; - - memset (memory, 0, sizeof (mem_pool)); - mb_index = 0; - - // LG_TEST - for (pool_index = 0; pool_index <= MEM_MNGT_POOL_ID_COPY; pool_index++) { - init_list (&memory->mem_lists[pool_index], "POOL"); - - for (index = 0; index < pool_sizes[pool_index]; index++) { - //memory->mem_blocks[mb_index + index].previous = NULL; -> done in memset 0 - //memory->mem_blocks[mb_index + index].next = NULL; -> done in memset 0 - switch (pool_index) { - case 0: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool0[index][0]); - break; - - case 1: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool1[index][0]); - break; - - case 2: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool2[index][0]); - break; - - case 3: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool3[index][0]); - break; - - case 4: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool4[index][0]); - break; - - case 5: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool5[index][0]); - break; - - case 6: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool6[index][0]); - break; - - case 7: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool7[index][0]); - break; - - case 8: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool8[index][0]); - break; - - case 9: - memory->mem_blocks[mb_index + index].data = &(memory->mem_pool9[index][0]); - break; - - default: - ; - memory->mem_blocks[mb_index + index].data = NULL; // pool copy - - } - - memory->mem_blocks[mb_index + index].pool_id = pool_index; - add_tail (&memory->mem_blocks[mb_index + index], &memory->mem_lists[pool_index]); - } - - mb_index += pool_sizes[pool_index]; - } - - return 0; -} - -//----------------------------------------------------------------------------- -void * -pool_buffer_clean (void *arg) -{ - //----------------------------------------------------------------------------- -#ifndef NO_THREAD_SAFE - mem_pool *memory = (mem_pool *) arg; - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID0].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID1].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID2].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID3].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID4].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID5].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID6].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID7].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID8].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID9].mutex); - pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID_COPY].mutex); -#endif - return 0; -} -//----------------------------------------------------------------------------- -void -free_mem_block (mem_block_t * leP, __func__) -{ - //----------------------------------------------------------------------------- - - if (!(leP)) { - msg ("[MEM_MNGT][FREE] WARNING FREE NULL MEM_BLOCK\n"); - return; - } - -#ifdef DEBUG_MEM_MNGT_FREE - msg ("[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id, __func__); -#endif -#ifdef DEBUG_MEM_MNGT_ALLOC - check_free_mem_block (leP, __func__); -#endif - - if (leP->pool_id <= MEM_MNGT_POOL_ID_COPY) { - add_tail (leP, &mem->mem_lists[leP->pool_id]); -#ifdef DEBUG_MEM_MNGT_ALLOC - counters[leP->pool_id] -= 1; -#endif - leP = NULL; // this prevent from freeing the block twice - } else { - msg ("[MEM_MNGT][FREE] ERROR free_mem_block() unknown pool_id : %d\n", leP->pool_id, __func__); - } -} - - -//----------------------------------------------------------------------------- -mem_block_t * -get_free_mem_block (uint16_t sizeP, __func__) -{ - //----------------------------------------------------------------------------- - mem_block_t *le = NULL; - int pool_selected; - int size; - - if (sizeP > MEM_MNGT_MB9_BLOCK_SIZE) { - msg ("[MEM_MNGT][ERROR][FATAL] size requested %d out of bounds %d\n",sizeP,MEM_MNGT_MB9_BLOCK_SIZE); - wcdma_handle_error (WCDMA_ERROR_OUT_OF_MEM_BLOCK); - return NULL; - } - - size = sizeP >> 6; - pool_selected = 0; - - while ((size)) { - pool_selected += 1; - size = size >> 1; - } - - // pool is selected according to the size requested, now get a block - // if no block is available pick one in an other pool - do { - if ((le = remove_head (&mem->mem_lists[pool_selected]))) { -#ifdef DEBUG_MEM_MNGT_ALLOC - counters[pool_selected] += 1; -#endif -#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE - msg ("[MEM_MNGT][INFO] ALLOC MEM_BLOCK SIZE %d bytes pool %d\n", sizeP, pool_selected); -#endif - return le; - } - -#ifdef DEBUG_MEM_MNGT_ALLOC - msg ("[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]); - display_mem_load (); - check_mem_area (mem); -#endif - } while (pool_selected++ < 9); - - msg ("[MEM_MNGT][ERROR][FATAL] size %d requested out of bounds or memory pools empty\n", sizeP); - wcdma_handle_error (WCDMA_ERROR_OUT_OF_MEM_BLOCK); - return NULL; -}; - -//----------------------------------------------------------------------------- -mem_block_t * -get_free_copy_mem_block (void) -{ - //----------------------------------------------------------------------------- - mem_block_t *le; - - if ((le = remove_head (&mem->mem_lists[MEM_MNGT_POOL_ID_COPY]))) { - return le; - } else { - msg ("[MEM_MNGT][ERROR] POOL COPY IS EMPTY\n"); - display_mem_load (); -#ifdef DEBUG_MEM_MNGT_ALLOC - check_mem_area (mem); - break_point (); -#endif - wcdma_handle_error (WCDMA_ERROR_OUT_OF_MEM_BLOCK); - - return NULL; - } -} - -//----------------------------------------------------------------------------- -mem_block_t * -copy_mem_block (mem_block_t * leP, mem_block_t * destP) -{ - //----------------------------------------------------------------------------- - - if ((destP != NULL) && (leP != NULL) && (destP->pool_id == MEM_MNGT_POOL_ID_COPY)) { - destP->data = leP->data; - } else { - msg ("[MEM_MNGT][COPY] copy_mem_block() pool dest src or dest is NULL\n"); - } - - return destP; -} - -//----------------------------------------------------------------------------- -void -display_mem_load (void) -{ - //----------------------------------------------------------------------------- - - msg ("POOL 0 (%d elements of %d Bytes): \n", MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB0_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID0]); - msg ("POOL 1 (%d elements of %d Bytes): \n", MEM_MNGT_MB1_NB_BLOCKS, MEM_MNGT_MB1_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID1]); - msg ("POOL 2 (%d elements of %d Bytes): \n", MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB2_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID2]); - msg ("POOL 3 (%d elements of %d Bytes): \n", MEM_MNGT_MB3_NB_BLOCKS, MEM_MNGT_MB3_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID3]); - msg ("POOL 4 (%d elements of %d Bytes): \n", MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB4_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID4]); - msg ("POOL 5 (%d elements of %d Bytes): \n", MEM_MNGT_MB5_NB_BLOCKS, MEM_MNGT_MB5_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID5]); - msg ("POOL 6 (%d elements of %d Bytes): \n", MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB6_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID6]); - msg ("POOL 7 (%d elements of %d Bytes): \n", MEM_MNGT_MB7_NB_BLOCKS, MEM_MNGT_MB7_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID7]); - msg ("POOL 8 (%d elements of %d Bytes): \n", MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB8_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID8]); - msg ("POOL 9 (%d elements of %d Bytes): \n", MEM_MNGT_MB9_NB_BLOCKS, MEM_MNGT_MB9_BLOCK_SIZE); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID9]); - msg ("POOL C (%d elements): \n", MEM_MNGT_MBCOPY_NB_BLOCKS); - display_list (&mem->mem_lists[MEM_MNGT_POOL_ID_COPY]); -} - -//----------------------------------------------------------------------------- -void -check_mem_area (void *arg) -{ - //----------------------------------------------------------------------------- - int index, mb_index; - mem_pool *memory = (mem_pool *) arg; - - for (index = 0; index < MEM_MNGT_MB0_NB_BLOCKS; index++) { - if ((memory->mem_blocks[index].data != &(memory->mem_pool0[index][0])) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID0)) { - msg ("[MEM] ERROR POOL0 block index %d\n", index); - break_point (); - } - } - - mb_index = MEM_MNGT_MB0_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB1_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool1[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID1)) { - msg ("[MEM] ERROR POOL1 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB1_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB2_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool2[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID2)) { - msg ("[MEM] ERROR POOL2 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB2_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB3_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool3[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID3)) { - msg ("[MEM] ERROR POOL3 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB3_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB4_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool4[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID4)) { - msg ("[MEM] ERROR POOL4 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB4_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB5_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool5[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID5)) { - msg ("[MEM] ERROR POOL5 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB5_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB6_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool6[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID6)) { - msg ("[MEM] ERROR POOL6 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB6_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB7_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool7[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID7)) { - msg ("[MEM] ERROR POOL7 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB7_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB8_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool8[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID8)) { - msg ("[MEM] ERROR POOL8 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB8_NB_BLOCKS; - - for (index = 0; index < MEM_MNGT_MB9_NB_BLOCKS; index++) { - if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool9[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID9)) { - msg ("[MEM] ERROR POOL9 block index %d\n", index); - break_point (); - } - } - - mb_index += MEM_MNGT_MB9_NB_BLOCKS; - - for (index = mb_index; index < MEM_MNGT_NB_ELEMENTS; index++) { - if ((memory->mem_blocks[index].data != NULL) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID_COPY)) { - msg ("[MEM] ERROR POOL COPY block index %d\n", index); - break_point (); - } - } -} - -//----------------------------------------------------------------------------- -void -check_free_mem_block (mem_block_t * leP, __func__) -{ - //----------------------------------------------------------------------------- - int block_index; - - if ((leP >= &mem->mem_blocks[0]) && (leP <= &mem->mem_blocks[MEM_MNGT_NB_ELEMENTS])) { - block_index = ((uint32_t) leP - (uint32_t) (&mem->mem_blocks[0])) / sizeof (mem_block_t); - - if (block_index < MEM_MNGT_MB0_NB_BLOCKS) { - if (((uint32_t) (leP->data) != (uint32_t) (&(mem->mem_pool0[block_index][0]))) && (leP->pool_id != MEM_MNGT_POOL_ID0)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < (MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS)) { - if ((leP->data != &(mem->mem_pool1[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID1)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS) { - if ((leP->data != &(mem->mem_pool2[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID2)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS) { - if ((leP->data != &(mem->mem_pool3[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID3)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS) { - if ((leP->data != &(mem->mem_pool4[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID4)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + - MEM_MNGT_MB5_NB_BLOCKS) { - if ((leP->data != &(mem->mem_pool5[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID5)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < - MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + - MEM_MNGT_MB6_NB_BLOCKS) { - if ((leP->data != &(mem->mem_pool6[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID6)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < - MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + - MEM_MNGT_MB6_NB_BLOCKS + - MEM_MNGT_MB7_NB_BLOCKS) { - if ((leP->data != &(mem->mem_pool7[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID7)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < - MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + - MEM_MNGT_MB6_NB_BLOCKS + - MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS) { - if ((leP->data != &(mem->mem_pool8[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID8)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } else if (block_index < - MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + - MEM_MNGT_MB6_NB_BLOCKS + - MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS + MEM_MNGT_MB9_NB_BLOCKS) { - if ((leP->data != &(mem->mem_pool9[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID9)) { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } - } - - } else { - msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n"); - } -} - -//----------------------------------------------------------------------------- -void -break_point (void) -{ - //----------------------------------------------------------------------------- - int break_var; - - msg ("[BREAK_POINT]\n"); - break_var = 1; -} diff --git a/openair2/UTIL/MEM/mem_mngt_proto_extern.h b/openair2/UTIL/MEM/mem_mngt_proto_extern.h deleted file mode 100644 index 4690bba42e..0000000000 --- a/openair2/UTIL/MEM/mem_mngt_proto_extern.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - diff --git a/openair2/UTIL/MEM/mem_pool.h b/openair2/UTIL/MEM/mem_pool.h deleted file mode 100644 index cc0face78c..0000000000 --- a/openair2/UTIL/MEM/mem_pool.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - mem_pool.h - description - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr - - - ***************************************************************************/ -#ifndef __MEM_POOL_H__ -# define __MEM_POOL_H__ - -# include "list.h" -# include "mem_block.h" - - -#endif diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index f8cd0ef64c..8c6a74e042 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -99,8 +99,8 @@ int opt_enabled=0; //static unsigned char g_PDUBuffer[1600]; //static unsigned int g_PDUOffset; -static char *in_ip; -static char *in_path; +static char in_ip[128]={0}; +static char in_path[128]={0}; FILE *file_fd = NULL; pcap_hdr_t file_header = { 0xa1b2c3d4, /* magic number */ @@ -447,9 +447,11 @@ int init_opt(void) char *in_type=NULL; paramdef_t opt_params[] = OPT_PARAMS_DESC ; checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC; - uint16_t in_port; - config_set_checkfunctions(opt_params, opt_checkParams, sizeof(opt_params)/sizeof(paramdef_t)); - config_get(opt_params, sizeof(opt_params)/sizeof(paramdef_t), OPT_CONFIGPREFIX); + uint16_t in_port=0; + config_set_checkfunctions(opt_params, opt_checkParams, + sizeof(opt_params)/sizeof(paramdef_t)); + config_get( opt_params,sizeof(opt_params)/sizeof(paramdef_t),OPT_CONFIGPREFIX); + subframesSinceCaptureStart = 0; int tmptype = config_get_processedint( &(opt_params[OPTTYPE_IDX])); diff --git a/openair3/NAS/COMMON/UTIL/socket.c b/openair3/NAS/COMMON/UTIL/socket.c index 25876c3e6f..53a6ec8823 100644 --- a/openair3/NAS/COMMON/UTIL/socket.c +++ b/openair3/NAS/COMMON/UTIL/socket.c @@ -107,7 +107,7 @@ void* socket_udp_open(int type, const char* host, const char* port) { struct addrinfo socket_info; /* endpoint information */ struct addrinfo *socket_addr, *sp; /* endpoint address */ - int sfd; /* socket file descriptor */ + int sfd=-1; /* socket file descriptor */ /* * Parameters sanity check diff --git a/openair3/NAS/TOOLS/conf_network.c b/openair3/NAS/TOOLS/conf_network.c index 96e2183327..e7e6c90d1b 100644 --- a/openair3/NAS/TOOLS/conf_network.c +++ b/openair3/NAS/TOOLS/conf_network.c @@ -80,7 +80,6 @@ bool parse_plmn_param(config_setting_t *plmn_setting, plmn_conf_param_t *conf) { bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) { config_setting_t *plmn_setting = NULL; - char plmn[10]; int size = 0; size = config_setting_length(all_plmn_setting); @@ -93,6 +92,7 @@ bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) { for (int i = 0; i < networks->size; i++) { network_t *network = &networks->items[i]; + char plmn[100]; sprintf(plmn, "%s%d", PLMN, i); plmn_setting = config_setting_get_member(all_plmn_setting, plmn); if (plmn_setting == NULL) { diff --git a/openair3/NAS/TOOLS/conf_parser.c b/openair3/NAS/TOOLS/conf_parser.c index d46142c461..b473ce502b 100644 --- a/openair3/NAS/TOOLS/conf_parser.c +++ b/openair3/NAS/TOOLS/conf_parser.c @@ -13,7 +13,6 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou config_setting_t *root_setting = NULL; config_setting_t *ue_setting = NULL; config_setting_t *all_plmn_setting = NULL; - char user[10]; config_t cfg; networks_t networks;; @@ -47,6 +46,7 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou user_plmns_t user_plmns; + char user[100]; sprintf(user, "%s%d", UE, i); ue_setting = config_setting_get_member(root_setting, user); diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 906314a67c..01a78213ca 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -33,7 +33,7 @@ #include #define PORT 4043 //default TCP port for this simulator -#define CirSize 3072000 // 100ms is enough +#define CirSize 307200 // 100ms is enough #define sampleToByte(a,b) ((a)*(b)*sizeof(sample_t)) #define byteToSample(a,b) ((a)/(sizeof(sample_t)*(b))) @@ -346,7 +346,8 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp if ( t->lastWroteTS != 0 && abs((double)t->lastWroteTS-timestamp) > (double)CirSize) LOG_E(HW,"Discontinuous TX gap too large Tx:%lu, %lu\n", t->lastWroteTS, timestamp); - AssertFatal(t->lastWroteTS <= timestamp+1, " Not supported to send Tx out of order (same in USRP) %lu, %lu\n", + if (t->lastWroteTS > timestamp+nsamps) + LOG_E(HW,"Not supported to send Tx out of order (same in USRP) %lu, %lu\n", t->lastWroteTS, timestamp); t->lastWroteTS=timestamp+nsamps; @@ -420,7 +421,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi if ( sz < 0 ) { if ( errno != EAGAIN ) { LOG_E(HW,"socket failed %s\n", strerror(errno)); - abort(); + //abort(); } } else if ( sz == 0 ) continue; @@ -439,11 +440,15 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi b->headerMode=false; if ( t->nextTimestamp == 0 ) { // First block in UE, resync with the eNB current TS - t->nextTimestamp = b->th.timestamp > nsamps_for_initial ? b->th.timestamp - nsamps_for_initial : 0; - b->lastReceivedTS = b->th.timestamp > nsamps_for_initial ? b->th.timestamp : nsamps_for_initial; - LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp); - b->trashingPacket=true; - } else if ( b->lastReceivedTS < b->th.timestamp) { + t->nextTimestamp=b->th.timestamp> nsamps_for_initial ? + b->th.timestamp - nsamps_for_initial : + 0; + b->lastReceivedTS=b->th.timestamp> nsamps_for_initial ? + b->th.timestamp : + nsamps_for_initial; + LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp); + b->trashingPacket=true; + } else if ( b->lastReceivedTS < b->th.timestamp) { int nbAnt= b->th.nbAnt; for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) { @@ -463,8 +468,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi } else if ( b->lastReceivedTS == b->th.timestamp ) { // normal case } else { - abort(); - AssertFatal(false, "received data in past: current is %lu, new reception: %lu!\n", b->lastReceivedTS, b->th.timestamp); + LOG_E(HW, "received data in past: current is %lu, new reception: %lu!\n", b->lastReceivedTS, b->th.timestamp); + b->trashingPacket=true; } pthread_mutex_lock(&Sockmutex); diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index cbbd30b62c..10691d2db8 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -41,6 +41,7 @@ # include "f1ap_du_task.h" # include "enb_app.h" # include "openair2/LAYER2/MAC/mac_proto.h" +#include extern RAN_CONTEXT_t RC; @@ -55,16 +56,16 @@ int create_tasks(uint32_t enb_nb) { rc = itti_create_task (TASK_ENB_APP, eNB_app_task, NULL); AssertFatal(rc >= 0, "Create task for eNB APP failed\n"); - LOG_I(RRC,"Creating RRC eNB Task\n"); - rc = itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL); - AssertFatal(rc >= 0, "Create task for RRC eNB failed\n"); + // No more rrc thread, as many race conditions are hidden behind + rrc_enb_init(); + itti_mark_task_ready(TASK_RRC_ENB); - if (EPC_MODE_ENABLED) { + if (EPC_MODE_ENABLED && ! ( split73==SPLIT73_DU ) ) { rc = itti_create_task(TASK_SCTP, sctp_eNB_task, NULL); AssertFatal(rc >= 0, "Create task for SCTP failed\n"); } - if (EPC_MODE_ENABLED && !NODE_IS_DU(type)) { + if (EPC_MODE_ENABLED && !NODE_IS_DU(type) && ! ( split73==SPLIT73_DU ) ) { rc = itti_create_task(TASK_S1AP, s1ap_eNB_task, NULL); AssertFatal(rc >= 0, "Create task for S1AP failed\n"); if (!(get_softmodem_params()->emulate_rf)){ diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8c5c50836f..a61b56a088 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -261,7 +261,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB, eNB->UL_INFO.subframe = proc->subframe_rx; eNB->UL_INFO.module_id = eNB->Mod_id; eNB->UL_INFO.CC_id = eNB->CC_id; - eNB->if_inst->UL_indication(&eNB->UL_INFO); + eNB->if_inst->UL_indication(&eNB->UL_INFO, proc); AssertFatal((ret= pthread_mutex_unlock(&eNB->UL_INFO_mutex))==0,"error unlocking UL_INFO_mutex, return %d\n",ret); /* this conflict resolution may be totally wrong, to be tested */ /* CONFLICT RESOLUTION: BEGIN */ diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index c08ab2a77b..888a7cd0fb 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -80,7 +80,7 @@ unsigned short config_frames[4] = {2,9,11,13}; //#include "PHY/TOOLS/time_meas.h" #ifndef OPENAIR2 -#include "UTIL/OTG/otg_vars.h" + #include "UTIL/OTG/otg_vars.h" #endif @@ -93,6 +93,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "lte-softmodem.h" #include "NB_IoT_interface.h" +#include pthread_cond_t nfapi_sync_cond; @@ -152,6 +153,13 @@ int otg_enabled; uint64_t num_missed_slots=0; // counter for the number of missed slots +int split73=0; +void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { + AssertFatal(false, "Must not be called in this context\n"); +} +void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, uint16_t rnti, int32_t stat) { + AssertFatal(false, "Must not be called in this context\n"); +} extern void reset_opp_meas(void); extern void print_opp_meas(void); @@ -170,7 +178,7 @@ eth_params_t *eth_params; double cpuf; int oaisim_flag=0; -//threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1}; + /* forward declarations */ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); @@ -438,12 +446,9 @@ int restart_L1L2(module_id_t enb_id) { init_UE_list(&RC.mac[enb_id]->UE_list); LOG_I(ENB_APP, "attempting to create ITTI tasks\n"); - if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) { - LOG_E(RRC, "Create task for RRC eNB failed\n"); - return -1; - } else { - LOG_I(RRC, "Re-created task for RRC eNB successfully\n"); - } + // No more rrc thread, as many race conditions are hidden behind + rrc_enb_init(); + itti_mark_task_ready(TASK_RRC_ENB); /* pass a reconfiguration request which will configure everything down to * RC.eNB[i][j]->frame_parms, too */ @@ -539,7 +544,7 @@ int main ( int argc, char **argv ) cpuf=get_cpu_freq_GHz(); printf("ITTI init, useMME: %i\n",EPC_MODE_ENABLED); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); - + // allows to forward in wireshark L2 protocol for decoding // initialize mscgen log after ITTI if (get_softmodem_params()->start_msc) { load_module_shlib("msc",NULL,0,&msc_interface); @@ -547,8 +552,6 @@ int main ( int argc, char **argv ) MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); init_opt(); - // to make a graceful exit when ctrl-c is pressed - set_softmodem_sighandler(); check_clock(); #ifndef PACKAGE_VERSION # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" @@ -579,11 +582,11 @@ int main ( int argc, char **argv ) for (i = 0; i < RC.nb_inst; i++) { flexran_agent_start(i); } - + /* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks * for monolithic/F1 modes */ - init_pdcp(); - + init_pdcp(); + if (create_tasks(1) < 0) { printf("cannot create ITTI tasks\n"); exit(-1); @@ -607,7 +610,7 @@ int main ( int argc, char **argv ) ctxt.subframe = 0; pdcp_run(&ctxt); } - + /* start threads if only L1 or not a CU */ if (RC.nb_inst == 0 || !NODE_IS_CU(node_type) || NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) { // init UE_PF_PO and mutex lock @@ -618,65 +621,78 @@ int main ( int argc, char **argv ) pthread_mutex_init(&sync_mutex, NULL); rt_sleep_ns(10*100000000ULL); - + if (NFAPI_MODE!=NFAPI_MONOLITHIC) { LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); } - + if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF #if defined(PRE_SCD_THREAD) init_ru_vnf(); // ru pointer is necessary for pre_scd. #endif wait_nfapi_init("main?"); } - + LOG_I(ENB_APP,"START MAIN THREADS\n"); // start the main threads number_of_cards = 1; printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); - + if (RC.nb_L1_inst > 0) { printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); - // for (inst=0;instproc.L1_proc; + L1proc->threadPool=(tpool_t*)malloc(sizeof(tpool_t)); + L1proc->respEncode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + L1proc->respDecode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + if ( strlen(get_softmodem_params()->threadPoolConfig) > 0 ) + initTpool(get_softmodem_params()->threadPoolConfig, L1proc->threadPool, true); + else + initTpool("n", L1proc->threadPool, true); + initNotifiedFIFO(L1proc->respEncode); + initNotifiedFIFO(L1proc->respDecode); + } + + } printf("wait_eNBs()\n"); wait_eNBs(); printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); - - // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. - // but RU thread deals with pre_scd and this is necessary in VNF and simulator. - // some initialization is necessary and init_ru_vnf do this. - if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { - printf("Initializing RU threads\n"); + + // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. + // but RU thread deals with pre_scd and this is necessary in VNF and simulator. + // some initialization is necessary and init_ru_vnf do this. + if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { + printf("Initializing RU threads\n"); init_RU(get_softmodem_params()->rf_config_file,get_softmodem_params()->clock_source,get_softmodem_params()->timing_source,get_softmodem_params()->send_dmrs_sync); - - for (ru_id=0; ru_idrf_map.card=0; - RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); + + for (ru_id=0; ru_idrf_map.card=0; + RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); } - + config_sync_var=0; - + if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF wait_nfapi_init("main?"); } - + printf("wait RUs\n"); - // CI -- Flushing the std outputs for the previous marker to show on the eNB / RRU log file + // end of CI modifications fflush(stdout); fflush(stderr); - // end of CI modifications + // wait_RUs() is wrong and over complex! wait_RUs(); LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU); // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init eNBs\n"); - + if (NFAPI_MODE!=NFAPI_MODE_PNF && NFAPI_MODE!=NFAPI_MODE_VNF) { LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n"); init_eNB_afterRU(); @@ -723,7 +739,7 @@ int main ( int argc, char **argv ) for (int inst = 0; inst < NB_eNB_INST; inst++) { for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) { free_transport(RC.eNB[inst][cc_id]); - phy_free_lte_eNB(RC.eNB[inst][cc_id]); + phy_free_lte_eNB(RC.eNB[inst][cc_id]); } } @@ -741,17 +757,17 @@ int main ( int argc, char **argv ) for(ru_id=0; ru_idrfdevice.trx_end_func) { - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - RC.ru[ru_id]->rfdevice.trx_end_func = NULL; + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + RC.ru[ru_id]->rfdevice.trx_end_func = NULL; } if (RC.ru[ru_id]->ifdevice.trx_end_func) { - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - RC.ru[ru_id]->ifdevice.trx_end_func = NULL; + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + RC.ru[ru_id]->ifdevice.trx_end_func = NULL; } } } - + terminate_opt(); logClean(); printf("Bye.\n"); diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 5a8afc2358..fdd19e3bd2 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -1522,12 +1522,12 @@ void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) { for ( int i=0; i < UE->frame_parms.nb_antennas_tx; i++) samplesVoid[i]=(void *)&v; - AssertFatal(1 == UE->rfdevice.trx_write_func(&UE->rfdevice, - timestamp+2*UE->frame_parms.samples_per_tti, - samplesVoid, - 1, - UE->frame_parms.nb_antennas_tx, - 1),""); + AssertFatal( 1 == UE->rfdevice.trx_write_func(&UE->rfdevice, + timestamp+2*UE->frame_parms.samples_per_tti, + samplesVoid, + 1, + UE->frame_parms.nb_antennas_tx, + 1),""); } void *UE_thread(void *arg) @@ -1578,37 +1578,36 @@ void *UE_thread(void *arg) int instance_cnt_synch = UE->proc.instance_cnt_synch; int is_synchronized = UE->is_synchronized; AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); - + if (is_synchronized == 0) { if (instance_cnt_synch < 0) { // we can invoke the synch // grab 10 ms of signal and wakeup synch thread - if (UE->mode != loop_through_memory) { - if (IS_SOFTMODEM_RFSIM) { - for(int sf=0; sf<10; sf++) { - for (int i=0; iframe_parms.nb_antennas_rx; i++) - rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf]; - - AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - rxp, - UE->frame_parms.samples_per_tti, - UE->frame_parms.nb_antennas_rx), ""); - write_dummy(UE, timestamp); - } - } else { - for (int i=0; iframe_parms.nb_antennas_rx; i++) - rxp[i] = (void *)&UE->common_vars.rxdata[i][0]; - - AssertFatal( UE->frame_parms.samples_per_tti*10 == + if (IS_SOFTMODEM_RFSIM ) { + for(int sf=0; sf<10; sf++) { + for (int i=0; iframe_parms.nb_antennas_rx; i++) + rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf]; + + AssertFatal( UE->frame_parms.samples_per_tti == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + rxp, + UE->frame_parms.samples_per_tti, + UE->frame_parms.nb_antennas_rx), ""); + write_dummy(UE, timestamp); + } + } else { + for (int i=0; iframe_parms.nb_antennas_rx; i++) + rxp[i] = (void *)&UE->common_vars.rxdata[i][0]; + + AssertFatal( UE->frame_parms.samples_per_tti*10 == UE->rfdevice.trx_read_func(&UE->rfdevice, ×tamp, rxp, UE->frame_parms.samples_per_tti*10, UE->frame_parms.nb_antennas_rx), ""); - } - } - + } + } AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); instance_cnt_synch = ++UE->proc.instance_cnt_synch; @@ -1637,10 +1636,10 @@ void *UE_thread(void *arg) rxp, UE->frame_parms.samples_per_tti, UE->frame_parms.nb_antennas_rx); - if (IS_SOFTMODEM_RFSIM ) - write_dummy(UE, timestamp); - } - } + if (IS_SOFTMODEM_RFSIM ) + write_dummy(UE, timestamp); + } + } #endif } } // UE->is_synchronized==0 @@ -1651,17 +1650,17 @@ void *UE_thread(void *arg) if (UE->mode != loop_through_memory) { if (UE->no_timing_correction==0) { LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); - while ( UE->rx_offset ) { - size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti); + while ( UE->rx_offset ) { + size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti); AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - (void **)UE->common_vars.rxdata, - s, - UE->frame_parms.nb_antennas_rx),""); - if (IS_SOFTMODEM_RFSIM ) - write_dummy(UE, timestamp); - UE->rx_offset-=s; - } + ×tamp, + (void **)UE->common_vars.rxdata, + s, + UE->frame_parms.nb_antennas_rx),""); + if (IS_SOFTMODEM_RFSIM ) + write_dummy(UE, timestamp); + UE->rx_offset-=s; + } } UE->rx_offset=0; @@ -1702,7 +1701,7 @@ void *UE_thread(void *arg) pthread_mutex_unlock(&proc->mutex_rxtx); } - usleep(300); + usleep(300); } LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index d0014b5e8a..42a4222edb 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -285,13 +285,13 @@ void exit_function(const char *file, const char *function, const int line, const extern int16_t dlsch_demod_shift; static void get_options(void) { - int CC_id; - int tddflag = 0; - char *loopfile = NULL; - int dumpframe = 0; - int timingadv = 0; + int CC_id=0; + int tddflag=0; + char *loopfile=NULL; + int dumpframe=0; + int timingadv=0; uint8_t nfapi_mode = NFAPI_MONOLITHIC; - int simL1flag = 0; + int simL1flag =0; set_default_frame_parms(frame_parms); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); @@ -544,6 +544,11 @@ void init_pdcp(void) { pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); } +// Stupid function addition because UE itti messages queues definition is common with eNB +void *rrc_enb_process_itti_msg(void *notUsed) { + return NULL; +} + int main( int argc, char **argv ) { int CC_id; uint8_t abstraction_flag=0; @@ -602,6 +607,7 @@ int main( int argc, char **argv ) { pthread_mutex_init(&sync_mutex, NULL); printf("ITTI init\n"); +#define UE itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); // initialize mscgen log after ITTI From a9ec7a1d7cccfdb2dcc0bf0ca2ed69d15d5a4ef1 Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 10 Apr 2020 20:55:50 +0200 Subject: [PATCH 002/149] merge develop, updates related --- executables/ocp-gnb.c | 140 ++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 95 deletions(-) diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index eba4862fc8..8f27e6b724 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -185,29 +185,21 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t return(0); } -void gNB_top(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, struct RU_t_s *ru) { - gNB_L1_proc_t *proc = &gNB->proc; +void gNB_top(gNB_L1_proc_t *proc, struct RU_t_s *ru) { gNB_L1_rxtx_proc_t *L1_proc = &proc->L1_proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; RU_proc_t *ru_proc=&ru->proc; - proc->frame_rx = frame_rx; - proc->slot_rx = slot_rx; sl_ahead = sf_ahead*fp->slots_per_subframe; - - if (!oai_exit) { - L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_subframe); - L1_proc->frame_rx = ru_proc->frame_rx; - L1_proc->slot_rx = ru_proc->tti_rx; - L1_proc->frame_tx = (L1_proc->slot_rx > (fp->slots_per_frame-1-(fp->slots_per_subframe*sf_ahead))) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; - L1_proc->slot_tx = (L1_proc->slot_rx + (fp->slots_per_subframe*sf_ahead))%fp->slots_per_frame; - - if (rxtx(gNB,L1_proc->frame_rx,L1_proc->slot_rx,L1_proc->frame_tx,L1_proc->slot_tx) < 0) - LOG_E(PHY,"gNB %d CC_id %d failed during execution\n",gNB->Mod_id,gNB->CC_id); - - ru_proc->timestamp_tx = L1_proc->timestamp_tx; - ru_proc->tti_tx = L1_proc->slot_tx; - ru_proc->frame_tx = L1_proc->frame_tx; - } + L1_proc->frame_rx = proc->frame_rx = proc->frame_prach = ru_proc->frame_rx = + (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; + L1_proc->slot_rx = proc->slot_rx = proc->slot_prach = + ru_proc->tti_rx; // computed before + L1_proc->timestamp_tx = proc->timestamp_tx = ru_proc->timestamp_tx = + ru_proc->timestamp_rx + sl_ahead; + L1_proc->frame_tx = proc->frame_rx = ru_proc->frame_rx = + (proc->timestamp_tx / (fp->samples_per_subframe*10))&1023; + L1_proc->slot_tx = ru_proc->tti_tx = + (L1_proc->slot_rx + sl_ahead)%fp->slots_per_frame; } static void *process_stats_thread(void *param) { @@ -536,55 +528,37 @@ void RCconfig_RU(void) { return; } -void rx_rf(RU_t *ru,int *frame,int *slot) { +int rx_rf(RU_t *ru, int lastReadSz) { RU_proc_t *proc = &ru->proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; void *rxp[ru->nb_rx]; - unsigned int rxs; - int i; - uint32_t samples_per_slot = fp->get_samples_per_slot(*slot,fp); - openair0_timestamp ts,old_ts; - AssertFatal(*slotslots_per_frame && *slot>=0, "slot %d is illegal (%d)\n",*slot,fp->slots_per_frame); + uint32_t samples_per_slot = fp->get_samples_per_slot(proc->tti_rx,fp); - for (i=0; inb_rx; i++) - rxp[i] = (void *)&ru->common.rxdata[i][fp->get_samples_slot_timestamp(*slot,fp,0)]; + for (int i=0; inb_rx; i++) + rxp[i] = (void *)&ru->common.rxdata[i][fp->get_samples_slot_timestamp(proc->tti_rx,fp,0)]; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); - old_ts = proc->timestamp_rx; - LOG_D(PHY,"Reading %d samples for slot %d (%p)\n",samples_per_slot,*slot,rxp[0]); - rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, - &ts, - rxp, - samples_per_slot, - ru->nb_rx); - proc->timestamp_rx = ts-ru->ts_offset; + openair0_timestamp old_ts = proc->timestamp_rx; + LOG_D(PHY,"Reading %d samples for slot %d (%p)\n",samples_per_slot,proc->tti_rx,rxp[0]); + unsigned int rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, + & proc->timestamp_rx, + rxp, + samples_per_slot, + ru->nb_rx); - //AssertFatal(rxs == fp->samples_per_subframe, - //"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_subframe,rxs); - if (rxs != samples_per_slot) LOG_E(PHY, "rx_rf: Asked for %d samples, got %d from USRP\n",samples_per_slot,rxs); + if (rxs != samples_per_slot) + LOG_E(PHY, "rx_rf: Asked for %d samples, got %d from USRP\n",samples_per_slot,rxs); - if (proc->first_rx == 1) { - ru->ts_offset = proc->timestamp_rx; - proc->timestamp_rx = 0; - } else { - if (proc->timestamp_rx - old_ts != fp->get_samples_per_slot((*slot-1)%fp->slots_per_frame,fp)) { - LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - samples_per_slot,ru->ts_offset); - ru->ts_offset += (proc->timestamp_rx - old_ts - samples_per_slot); - proc->timestamp_rx = ts-ru->ts_offset; - } - } + // In case we need offset, between RU or any other need + // The sync system can put a offset to use betwwen RF boards + proc->timestamp_rx+=ru->ts_offset; - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; - uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; - proc->tti_rx = (idx_sf * fp->slots_per_subframe + (int)round((float)(proc->timestamp_rx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame); - *frame = proc->frame_rx; - *slot = proc->tti_rx; - proc->first_rx = 0; + if (lastReadSz && proc->timestamp_rx - old_ts != lastReadSz) + LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n", + proc->timestamp_rx - old_ts - samples_per_slot,ru->ts_offset); - if (rxs != samples_per_slot) { - LOG_E(PHY, "problem receiving samples\n"); - } + return rxs; } + void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { RU_proc_t *proc = &ru->proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; @@ -797,8 +771,6 @@ static void *ru_thread( void *param ) { RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; - int slot = fp->slots_per_frame-1; - int frame = 1023; LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,NB_functions[ru->function],NB_timing[ru->if_timing]); fp->threequarter_fs=threequarter_fs; nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp); @@ -807,50 +779,28 @@ static void *ru_thread( void *param ) { nr_phy_init_RU(ru); AssertFatal(openair0_device_load(&ru->rfdevice,&ru->openair0_cfg)==0,"Cannot connect to local radio\n"); AssertFatal(ru->rfdevice.trx_start_func(&ru->rfdevice) == 0,"Could not start the RF device\n"); - // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + int lastReadSz=0; + while (!oai_exit) { - // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. - // They are set on the first rx/tx in the underly FH routines. - if (slot==(fp->slots_per_frame-1)) { - slot=0; - frame++; - frame&=1023; - } else { - slot++; - } - // synchronization on input FH interface, acquire signals/data and block - LOG_D(PHY,"[RU_thread] read data: frame_rx = %d, tti_rx = %d\n", frame, slot); - rx_rf(ru,&frame,&slot); - LOG_D(PHY,"AFTER rx_rf - SFN/SL:%d%d RU->proc[RX:%d.%d TX:%d.%d] RC.gNB[0][0]:[RX:%d%d TX(SFN):%d]\n", - frame,slot, - proc->frame_rx,proc->tti_rx, - proc->frame_tx,proc->tti_tx, - RC.gNB[0][0].proc.frame_rx,RC.gNB[0][0].proc.slot_rx, - RC.gNB[0][0].proc.frame_tx); - /* - LOG_D(PHY,"RU thread (do_prach %d, is_prach_subframe %d), received frame %d, subframe %d\n", - ru->do_prach, - is_prach_subframe(fp, proc->frame_rx, proc->tti_rx), - proc->frame_rx,proc->tti_rx); - - if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->tti_rx)==1)) { - wakeup_prach_ru(ru); - }*/ - - // adjust for timing offset between RU - //printf("~~~~~~~~~~~~~~~~~~~~~~~~~~%d.%d in ru_thread is in process\n", proc->frame_rx, proc->tti_rx); - if (ru->idx!=0) - proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023; - + lastReadSz=rx_rf(ru, lastReadSz); // do RX front-end processing (frequency-shift, dft) if needed + uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; + uint32_t offsetInSubframe=proc->timestamp_rx % fp->samples_per_subframe; + proc->tti_rx = (idx_sf * fp->slots_per_subframe + + lroundf((float)offsetInSubframe / fp->samples_per_slot0))%(fp->slots_per_frame); if (proc->tti_rx == NR_UPLINK_SLOT || fp->frame_type == FDD) { nr_fep_full(ru,proc->tti_rx); } - gNB_top(&RC.gNB[0][0], frame, slot, ru); + gNB_top(&RC.gNB[0][0].proc, ru); + gNB_L1_rxtx_proc_t *L1_proc = &RC.gNB[0][0].proc.L1_proc; + + if (rxtx(&RC.gNB[0][0],L1_proc->frame_rx,L1_proc->slot_rx,L1_proc->frame_tx,L1_proc->slot_tx) < 0) + LOG_E(PHY,"gNB %d CC_id %d failed during execution\n",RC.gNB[0][0].Mod_id,RC.gNB[0][0].CC_id); + // do TX front-end processing if needed (precoding and/or IDFTs) //ru->feptx_prec(ru,proc->frame_tx,proc->tti_tx); nr_feptx_prec(ru,proc->frame_tx,proc->tti_tx); From b0b5a1012a9eb493e5fdd588569abc0282deb3d2 Mon Sep 17 00:00:00 2001 From: laurent Date: Tue, 14 Apr 2020 19:53:43 +0200 Subject: [PATCH 003/149] cosmetic --- cmake_targets/CMakeLists.txt | 2 ++ common/utils/ocp_itti/intertask_interface.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c0ff93bc7f..45baf2a603 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -821,6 +821,7 @@ add_boolean_option(TRACE_RLC_UM_TX_STATUS False "TRACE for RLC UM, TO BE CHANGE # PDCP LAYER OPTIONS ########################## #add_boolean_option(PDCP_USE_NETLINK False "For eNB, PDCP communicate with a NETLINK socket if connected to network driver, else could use a RT-FIFO") +#add_boolean_option(PDCP_USE_NETLINK_QUEUES False "When PDCP_USE_NETLINK is true, incoming IP packets are stored in queues") #add_boolean_option(LINK_ENB_PDCP_TO_IP_DRIVER False "For eNB, PDCP communicate with a IP driver") #add_boolean_option(LINK_ENB_PDCP_TO_GTPV1U True "For eNB, PDCP communicate with GTP-U protocol (eNB<->S-GW)") @@ -2664,6 +2665,7 @@ target_link_libraries (nr-softmodem ${LIBXML2_LIBRARIES}) target_link_libraries (nr-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (nr-softmodem ${T_LIB}) + add_dependencies( nr-softmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) add_executable(ocp-gnb diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index dc577f1334..42c3828dc4 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -7,6 +7,7 @@ #include +extern "C" { #include #include @@ -35,7 +36,6 @@ typedef struct task_list_s { int timer_expired(int fd); task_list_t tasks[TASK_MAX]; -extern "C" { void *pool_buffer_init (void) { return 0; } From 151bde05c82088f3c5a377a31d18160d77ef56b2 Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 24 Apr 2020 11:45:22 +0200 Subject: [PATCH 004/149] merge develop, compile only --- cmake_targets/CMakeLists.txt | 8 +++---- cmake_targets/phy_simulators/CMakeLists.txt | 21 ++++++++++--------- executables/ocp-gnb.c | 12 +++++------ openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 2 +- .../PHY/LTE_TRANSPORT/ulsch_demodulation.c | 1 - openair1/SCHED_NR/nr_prach_procedures.c | 2 +- openair2/MCE_APP/mce_app.c | 4 +++- openair2/PHY_INTERFACE/phy_stub_UE.c | 12 +++++------ targets/ARCH/rfsimulator/README.md | 6 ++++++ 9 files changed, 38 insertions(+), 30 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 638c4fc84e..e83c8ddf74 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2519,7 +2519,7 @@ target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-softmodem ${T_LIB}) -add_executable(ocp-softmodem +add_executable(ocp-enb ${OPENAIR_DIR}/executables/main-ocp.c ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c ${OPENAIR_DIR}/executables/softmodem-common.c @@ -2545,15 +2545,15 @@ add_executable(ocp-softmodem ${CONFIG_SOURCES} ${SHLIB_LOADER_SOURCES} ) -add_dependencies(ocp-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer) +add_dependencies(ocp-enb rrc_flag s1ap_flag x2_flag oai_iqplayer) -target_link_libraries (ocp-softmodem +target_link_libraries (ocp-enb -Wl,--start-group RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} -Wl,--end-group z dl) -target_link_libraries (ocp-softmodem ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) +target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) add_executable(cu_test ${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c diff --git a/cmake_targets/phy_simulators/CMakeLists.txt b/cmake_targets/phy_simulators/CMakeLists.txt index a41e259e7b..2c648103b3 100644 --- a/cmake_targets/phy_simulators/CMakeLists.txt +++ b/cmake_targets/phy_simulators/CMakeLists.txt @@ -1,14 +1,15 @@ cmake_minimum_required(VERSION 2.8) -set(PACKAGE_NAME "unitary_tests_simulators") -set(PHYSIM True) -set(RF_BOARD None) -set(XFORMS True) -set(ENABLE_ITTI True) -set(DEBUG_PHY False) -set(MU_RECIEVER False) -set(NAS_UE False) -set(MESSAGE_CHART_GENERATOR False) -set(RRC_ASN1_VERSION "Rel15") +set ( CMAKE_BUILD_TYPE ) +set ( CFLAGS_PROCESSOR_USER "" ) +set ( UE_EXPANSION False ) +set ( PRE_SCD_THREAD False ) +set ( UESIM_EXPANSION False ) +set ( ENABLE_VCD_FIFO False ) +set ( RF_BOARD "OAI_USRP") +set ( TRANSP_PRO "None") +set ( PACKAGE_NAME "") +set ( DEADLINE_SCHEDULER "False" ) +set ( CPU_AFFINITY "False" ) set(T_TRACER True) set ( UE_AUTOTEST_TRACE False ) set ( UE_DEBUG_TRACE False ) diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 8f27e6b724..10d68cb0de 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -131,7 +131,7 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t oai_subframe_ind(frame_rx, slot_rx); stop_meas(&nfapi_meas); - if (gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus|| + /*if (gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus|| gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs || gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs || gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles || @@ -145,7 +145,7 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t gNB->UL_INFO.cqi_ind.number_of_cqis, frame_rx, slot_rx, frame_tx, slot_tx); - } + }*/ } /// NR disabling @@ -296,12 +296,12 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { memset((void *)&gNB->UL_tti_req,0,sizeof(nfapi_nr_ul_tti_request_t)); //memset((void *)&gNB->Sched_INFO,0,sizeof(gNB->Sched_INFO)); LOG_I(PHY,"Setting indication lists\n"); - gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list = gNB->rx_pdu_list; - gNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list = gNB->crc_pdu_list; - gNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = gNB->sr_pdu_list; + gNB->UL_INFO.rx_ind.pdu_list = gNB->rx_pdu_list; + gNB->UL_INFO.crc_ind.crc_list = gNB->crc_pdu_list; + /*gNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = gNB->sr_pdu_list; gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list; gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list; - gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list; + gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;*/ gNB->prach_energy_counter = 0; } diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index f433920512..90492b9999 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -572,7 +572,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, G = G - Q_RI - Q_CQI; ulsch_harq->G = G; AssertFatal((int)G > 0, - "FATAL: ulsch_decoding.c G < 0 (%d) : Q_RI %d, Q_CQI %d\n",G,Q_RI,Q_CQI); + "FATAL: ulsch_decoding.c G < 0 (%u) : Q_RI %u, Q_CQI %u\n",G,Q_RI,Q_CQI); H = G + Q_CQI; Hprime = H/Q_m; // Demultiplexing/Deinterleaving of PUSCH/ACK/RI/CQI diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index 0e7bdd2ae4..f357e385f0 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -780,7 +780,6 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, #endif for (rb=0; rbnode_type, mce_id_start, mce_id_end); } diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 393a178599..b117ae109c 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -879,10 +879,7 @@ int memcpy_dl_config_req(L1_rxtx_proc_t *proc, int memcpy_ul_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req) { - - //for (Mod_id=0; Mod_idsfn_sf = req->sfn_sf; @@ -928,9 +925,12 @@ int memcpy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { return 0; } -int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) -{ +int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, + nfapi_pnf_p7_config_t* pnf_p7, + nfapi_hi_dci0_request_t* req) { hi_dci0_req = (nfapi_hi_dci0_request_t *)malloc(sizeof(nfapi_hi_dci0_request_t)); + //if(req!=0){ + hi_dci0_req->sfn_sf = req->sfn_sf; hi_dci0_req->vendor_extension = req->vendor_extension; diff --git a/targets/ARCH/rfsimulator/README.md b/targets/ARCH/rfsimulator/README.md index 014f5f7505..421cc662bb 100644 --- a/targets/ARCH/rfsimulator/README.md +++ b/targets/ARCH/rfsimulator/README.md @@ -3,6 +3,12 @@ This is an RF simulator that allows to test OAI without an RF board. It replaces As much as possible, it works like an RF board, but not in real-time: It can run faster than real-time if there is enough CPU, or slower (it is CPU-bound instead of real-time RF sampling-bound). +It can be run either in: + +- "noS1" mode: the generated IP traffic is sent and received between gNB and UE IP tunnel interfaces ("oaitun") by applications like ping and iperf +- "phy-test" mode: random UL and DL traffic is generated at every scheduling opportunity + + # build ## From [build_oai](../../../doc/BUILD.md) script From 7aa9a7bd495b15efda1e2349eae4d0f72d119bf7 Mon Sep 17 00:00:00 2001 From: laurent Date: Sun, 3 May 2020 18:30:26 +0200 Subject: [PATCH 005/149] work in progress, re-merge before continuing --- cmake_targets/CMakeLists.txt | 1 + cmake_targets/nas_sim_tools/CMakeLists.txt | 1 + common/utils/itti_analyzer/common/queue.h | 592 --------------- openair1/PHY/LTE_UE_TRANSPORT/sldch.c | 5 - openair1/PHY/LTE_UE_TRANSPORT/slsch.c | 4 - openair1/PHY/LTE_UE_TRANSPORT/slss.c | 4 - .../NR_TRANSPORT/nr_transport_proto_common.h | 66 +- openair1/PHY/phy_vars_nr_ue.h | 2 +- openair1/PHY/phy_vars_ue.h | 6 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 11 - openair1/SIMULATION/TOOLS/rangen_double.c | 2 - openair3/M3AP/m3ap_MCE_handler.h | 8 +- openair3/M3AP/m3ap_MME_generate_messages.h | 8 +- openair3/NAS/COMMON/API/NETWORK/as_message.h | 578 --------------- openair3/NAS/COMMON/commonDef.h | 333 --------- openair3/NAS/COMMON/networkDef.h | 271 ------- openair3/UTILS/queue.h | 592 --------------- openair3/UTILS/tree.h | 678 ------------------ 18 files changed, 17 insertions(+), 3145 deletions(-) delete mode 100644 common/utils/itti_analyzer/common/queue.h delete mode 100644 openair3/NAS/COMMON/API/NETWORK/as_message.h delete mode 100644 openair3/NAS/COMMON/commonDef.h delete mode 100644 openair3/NAS/COMMON/networkDef.h delete mode 100644 openair3/UTILS/queue.h delete mode 100644 openair3/UTILS/tree.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index e83c8ddf74..6c136ae1db 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -884,6 +884,7 @@ include_directories("${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0") include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES") include_directories("${OPENAIR2_DIR}/RRC/LTE") include_directories("${OPENAIR_DIR}/common/utils") +include_directories("${OPENAIR_DIR}/common/utils/collection") include_directories("${OPENAIR_DIR}/common/utils/ocp_itti") include_directories("${OPENAIR3_DIR}/NAS/COMMON") include_directories("${OPENAIR3_DIR}/NAS/COMMON/API/NETWORK") diff --git a/cmake_targets/nas_sim_tools/CMakeLists.txt b/cmake_targets/nas_sim_tools/CMakeLists.txt index c1a0bb419b..308c71be4c 100644 --- a/cmake_targets/nas_sim_tools/CMakeLists.txt +++ b/cmake_targets/nas_sim_tools/CMakeLists.txt @@ -14,6 +14,7 @@ set(CMAKE_C_FLAGS set(OPENAIR_DIR $ENV{OPENAIR_DIR}) set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3) +include_directories (${OPENAIR_DIR}/openair2/COMMON) set(CONF2UEDATA_LIB_SRC ${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_emm.c diff --git a/common/utils/itti_analyzer/common/queue.h b/common/utils/itti_analyzer/common/queue.h deleted file mode 100644 index 294d485110..0000000000 --- a/common/utils/itti_analyzer/common/queue.h +++ /dev/null @@ -1,592 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - */ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -/* - * This file defines five types of data structures: singly-linked lists, - * lists, simple queues, tail queues, and circular queues. - * - * A singly-linked list is headed by a single forward pointer. The - * elements are singly linked for minimum space and pointer manipulation - * overhead at the expense of O(n) removal for arbitrary elements. New - * elements can be added to the list after an existing element or at the - * head of the list. Elements being removed from the head of the list - * should use the explicit macro for this purpose for optimum - * efficiency. A singly-linked list may only be traversed in the forward - * direction. Singly-linked lists are ideal for applications with large - * datasets and few or no removals or for implementing a LIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A simple queue is headed by a pair of pointers, one the head of the - * list and the other to the tail of the list. The elements are singly - * linked to save space, so elements can only be removed from the - * head of the list. New elements can be added to the list after - * an existing element, at the head of the list, or at the end of the - * list. A simple queue may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * A circle queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or after - * an existing element, at the head of the list, or at the end of the list. - * A circle queue may be traversed in either direction, but has a more - * complex end of list detection. - * - * For details on the use of these macros, see the queue(3) manual page. - * SLIST LIST STAILQ TAILQ CIRCLEQ - * _HEAD + + + + + - * _HEAD_INITIALIZER + + + + + - * _ENTRY + + + + + - * _INIT + + + + + - * _EMPTY + + + + + - * _FIRST + + + + + - * _NEXT + + + + + - * _PREV - - - + + - * _LAST - - + + + - * _FOREACH + + + + + - * _FOREACH_REVERSE - - - + + - * _INSERT_HEAD + + + + + - * _INSERT_BEFORE - + - + + - * _INSERT_AFTER + + + + + - * _INSERT_TAIL - - + + + - * _REMOVE_HEAD + - + - - - * _REMOVE + + + + + - */ - -/* - * List definitions. - */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ -#define LIST_INIT(head) do { \ - (head)->lh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - (elm)->field.le_next = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &(elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.le_next = (head)->lh_first) != NULL) \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} while (/*CONSTCOND*/0) - -#define LIST_REMOVE(elm, field) do { \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_FOREACH(var, head, field) \ - for ((var) = ((head)->lh_first); \ - (var); \ - (var) = ((var)->field.le_next)) - -/* - * List access methods. - */ -#define LIST_EMPTY(head) ((head)->lh_first == NULL) -#define LIST_FIRST(head) ((head)->lh_first) -#define LIST_NEXT(elm, field) ((elm)->field.le_next) - - -/* - * Singly-linked List definitions. - */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List functions. - */ -#define SLIST_INIT(head) do { \ - (head)->slh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - (elm)->field.sle_next = (slistelm)->field.sle_next; \ - (slistelm)->field.sle_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.sle_next = (head)->slh_first; \ - (head)->slh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE_HEAD(head, field) do { \ - (head)->slh_first = (head)->slh_first->field.sle_next; \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE(head, elm, type, field) do { \ - if ((head)->slh_first == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = (head)->slh_first; \ - while(curelm->field.sle_next != (elm)) \ - curelm = curelm->field.sle_next; \ - curelm->field.sle_next = \ - curelm->field.sle_next->field.sle_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define SLIST_FOREACH(var, head, field) \ - for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) - -/* - * Singly-linked List access methods. - */ -#define SLIST_EMPTY(head) ((head)->slh_first == NULL) -#define SLIST_FIRST(head) ((head)->slh_first) -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) - - -/* - * Singly-linked Tail queue declarations. - */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first; /* first element */ \ - struct type **stqh_last; /* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -/* - * Singly-linked Tail queue functions. - */ -#define STAILQ_INIT(head) do { \ - (head)->stqh_first = NULL; \ - (head)->stqh_last = &(head)->stqh_first; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (head)->stqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.stqe_next = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &(elm)->field.stqe_next; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (listelm)->field.stqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ - (head)->stqh_last = &(head)->stqh_first; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_REMOVE(head, elm, type, field) do { \ - if ((head)->stqh_first == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->stqh_first; \ - while (curelm->field.stqe_next != (elm)) \ - curelm = curelm->field.stqe_next; \ - if ((curelm->field.stqe_next = \ - curelm->field.stqe_next->field.stqe_next) == NULL) \ - (head)->stqh_last = &(curelm)->field.stqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define STAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->stqh_first); \ - (var); \ - (var) = ((var)->field.stqe_next)) - -#define STAILQ_CONCAT(head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -/* - * Singly-linked Tail queue access methods. - */ -#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) -#define STAILQ_FIRST(head) ((head)->stqh_first) -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) - - -/* - * Simple queue definitions. - */ -#define SIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define SIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define SIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} - -/* - * Simple queue functions. - */ -#define SIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ - if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ - if ((head)->sqh_first == (elm)) { \ - SIMPLEQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->sqh_first; \ - while (curelm->field.sqe_next != (elm)) \ - curelm = curelm->field.sqe_next; \ - if ((curelm->field.sqe_next = \ - curelm->field.sqe_next->field.sqe_next) == NULL) \ - (head)->sqh_last = &(curelm)->field.sqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->sqh_first); \ - (var); \ - (var) = ((var)->field.sqe_next)) - -/* - * Simple queue access methods. - */ -#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) -#define SIMPLEQ_FIRST(head) ((head)->sqh_first) -#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - - -/* - * Tail queue definitions. - */ -#define _TAILQ_HEAD(name, type, qual) \ -struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last; /* addr of last next element */ \ -} -#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) - -#define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define _TAILQ_ENTRY(type, qual) \ -struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev; /* address of previous next element */\ -} -#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) - -/* - * Tail queue functions. - */ -#define TAILQ_INIT(head) do { \ - (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_REMOVE(head, elm, field) do { \ - if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->tqh_first); \ - (var); \ - (var) = ((var)->field.tqe_next)) - -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ - (var); \ - (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) - -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -/* - * Tail queue access methods. - */ -#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) -#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - - -/* - * Circular queue definitions. - */ -#define CIRCLEQ_HEAD(name, type) \ -struct name { \ - struct type *cqh_first; /* first element */ \ - struct type *cqh_last; /* last element */ \ -} - -#define CIRCLEQ_HEAD_INITIALIZER(head) \ - { (void *)&head, (void *)&head } - -#define CIRCLEQ_ENTRY(type) \ -struct { \ - struct type *cqe_next; /* next element */ \ - struct type *cqe_prev; /* previous element */ \ -} - -/* - * Circular queue functions. - */ -#define CIRCLEQ_INIT(head) do { \ - (head)->cqh_first = (void *)(head); \ - (head)->cqh_last = (void *)(head); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - (elm)->field.cqe_next = (listelm)->field.cqe_next; \ - (elm)->field.cqe_prev = (listelm); \ - if ((listelm)->field.cqe_next == (void *)(head)) \ - (head)->cqh_last = (elm); \ - else \ - (listelm)->field.cqe_next->field.cqe_prev = (elm); \ - (listelm)->field.cqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ - (elm)->field.cqe_next = (listelm); \ - (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ - if ((listelm)->field.cqe_prev == (void *)(head)) \ - (head)->cqh_first = (elm); \ - else \ - (listelm)->field.cqe_prev->field.cqe_next = (elm); \ - (listelm)->field.cqe_prev = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.cqe_next = (head)->cqh_first; \ - (elm)->field.cqe_prev = (void *)(head); \ - if ((head)->cqh_last == (void *)(head)) \ - (head)->cqh_last = (elm); \ - else \ - (head)->cqh_first->field.cqe_prev = (elm); \ - (head)->cqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.cqe_next = (void *)(head); \ - (elm)->field.cqe_prev = (head)->cqh_last; \ - if ((head)->cqh_first == (void *)(head)) \ - (head)->cqh_first = (elm); \ - else \ - (head)->cqh_last->field.cqe_next = (elm); \ - (head)->cqh_last = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_REMOVE(head, elm, field) do { \ - if ((elm)->field.cqe_next == (void *)(head)) \ - (head)->cqh_last = (elm)->field.cqe_prev; \ - else \ - (elm)->field.cqe_next->field.cqe_prev = \ - (elm)->field.cqe_prev; \ - if ((elm)->field.cqe_prev == (void *)(head)) \ - (head)->cqh_first = (elm)->field.cqe_next; \ - else \ - (elm)->field.cqe_prev->field.cqe_next = \ - (elm)->field.cqe_next; \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->cqh_first); \ - (var) != (const void *)(head); \ - (var) = ((var)->field.cqe_next)) - -#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ - for ((var) = ((head)->cqh_last); \ - (var) != (const void *)(head); \ - (var) = ((var)->field.cqe_prev)) - -/* - * Circular queue access methods. - */ -#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) -#define CIRCLEQ_FIRST(head) ((head)->cqh_first) -#define CIRCLEQ_LAST(head) ((head)->cqh_last) -#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) -#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) - -#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ - (((elm)->field.cqe_next == (void *)(head)) \ - ? ((head)->cqh_first) \ - : (elm->field.cqe_next)) -#define CIRCLEQ_LOOP_PREV(head, elm, field) \ - (((elm)->field.cqe_prev == (void *)(head)) \ - ? ((head)->cqh_last) \ - : (elm->field.cqe_prev)) - -#endif /* sys/queue.h */ diff --git a/openair1/PHY/LTE_UE_TRANSPORT/sldch.c b/openair1/PHY/LTE_UE_TRANSPORT/sldch.c index 9c9d36c974..2ce0f91c26 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/sldch.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/sldch.c @@ -29,8 +29,6 @@ * \note * \warning */ -#ifndef __LTE_TRANSPORT_SLSS__C__ -#define __LTE_TRANSPORT_SLSS__C__ #include "PHY/defs_UE.h" extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); @@ -61,6 +59,3 @@ void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx) sldch_header_len+sizeof(SLDCH_t)); } - - -#endif diff --git a/openair1/PHY/LTE_UE_TRANSPORT/slsch.c b/openair1/PHY/LTE_UE_TRANSPORT/slsch.c index e51e33626d..e4e94a232d 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/slsch.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/slsch.c @@ -29,8 +29,6 @@ * \note * \warning */ -#ifndef __LTE_TRANSPORT_SLSS__C__ -#define __LTE_TRANSPORT_SLSS__C__ #include "PHY/defs_UE.h" extern int @@ -66,5 +64,3 @@ void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slsch,int frame_tx,int subframe_tx) } } - -#endif diff --git a/openair1/PHY/LTE_UE_TRANSPORT/slss.c b/openair1/PHY/LTE_UE_TRANSPORT/slss.c index 18bc5a28de..3cd1c1acb0 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/slss.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/slss.c @@ -29,8 +29,6 @@ * \note * \warning */ -#ifndef __LTE_TRANSPORT_SLSS__C__ -#define __LTE_TRANSPORT_SLSS__C__ #include "PHY/defs_UE.h" @@ -39,5 +37,3 @@ void generate_slss(PHY_VARS_UE *ue,SLSS_t *slss,int frame_tx,int subframe_tx) { AssertFatal(1==0,"Should get here yet for UE %d\n",ue->Mod_id); } - -#endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto_common.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto_common.h index dd37455e26..a9b3c35458 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto_common.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto_common.h @@ -29,8 +29,8 @@ * \note * \warning */ -#ifndef __NR_TRANSPORT_PROTO_UE__H__ -#define __NR_TRANSPORT_PROTO_UE__H__ +#ifndef __NR_TRANSPORT_PROTO_COMMON__H__ +#define __NR_TRANSPORT_PROTO_COMMON__H__ #include "PHY/defs_nr_UE.h" #include "SCHED_NR_UE/defs.h" //#include "PHY/LTE_TRANSPORT/transport_common_proto.h" @@ -43,29 +43,6 @@ * @{ */ -/** \fn free_ue_dlsch(NR_UE_DLSCH_t *dlsch) - \brief This function frees memory allocated for a particular DLSCH at UE - @param dlsch Pointer to DLSCH to be removed -*/ -void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch); - -/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag) - \brief This function allocates structures for a particular DLSCH at UE - @returns Pointer to DLSCH to be removed - @param Kmimo Kmimo factor from 36-212/36-213 - @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) - @param Nsoft Soft-LLR buffer size from UE-Category - @params N_RB_DL total number of resource blocks (determine the operating BW) - @param abstraction_flag Flag to indicate abstracted interface -*/ -NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag); - - -void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch); - - -NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag); - void fill_UE_dlsch_MCH(PHY_VARS_NR_UE *ue,int mcs,int ndi,int rvidx,int eNB_id); int rx_pmch(PHY_VARS_NR_UE *phy_vars_ue, @@ -1055,21 +1032,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, NR_DL_FRAME_PARMS* frame_parms, uint8_t harq_pid); -/*! \brief Perform PUSCH scrambling. TS 38.211 V15.4.0 subclause 6.3.1.1 - @param[in] in Pointer to input bits - @param[in] size of input bits - @param[in] Nid cell id - @param[in] n_RNTI CRNTI - @param[out] out the scrambled bits -*/ - -void nr_pusch_codeword_scrambling(uint8_t *in, - uint16_t size, - uint32_t Nid, - uint32_t n_RNTI, - uint32_t* out); - - uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, int eNB_id, @@ -1130,14 +1092,7 @@ int32_t nr_rx_pdsch(PHY_VARS_NR_UE *phy_vars_ue, int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, uint32_t frame, - uint8_t nr_tti_rx, - uint8_t eNB_id, - MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t is_secondary_ue, - int nb_coreset_active, - uint16_t symbol_mon, - NR_SEARCHSPACE_TYPE_t searchSpaceType); + uint32_t slot); /*! \brief Extract PSS and SSS resource elements @param phy_vars_ue Pointer to UE variables @@ -1471,17 +1426,6 @@ void init_transport_channels(uint8_t); void generate_RIV_tables(void); -/*! - \brief This function performs the initial cell search procedure - PSS detection, SSS detection and PBCH detection. At the - end, the basic frame parameters are known (Frame configuration - TDD/FDD and cyclic prefix length, - N_RB_DL, PHICH_CONFIG and Nid_cell) and the UE can begin decoding PDCCH and DLSCH SI to retrieve the rest. Once these - parameters are know, the routine calls some basic initialization routines (cell-specific reference signals, etc.) - @param phy_vars_ue Pointer to UE variables - @param mode current running mode -*/ -int nr_initial_sync(UE_nr_rxtx_proc_t *proc, - PHY_VARS_NR_UE *phy_vars_ue, runmode_t mode); - /*! \brief Encoding of PUSCH/ACK/RI/ACK from 36-212. @@ -1724,10 +1668,6 @@ uint8_t get_prach_prb_offset(NR_DL_FRAME_PARMS *frame_parms, uint8_t n_ra_prboffset, uint8_t tdd_mapindex, uint16_t Nf); -void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, - int16_t *z, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common); - - uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset); int nr_rx_pdsch(PHY_VARS_NR_UE *ue, diff --git a/openair1/PHY/phy_vars_nr_ue.h b/openair1/PHY/phy_vars_nr_ue.h index bd077b5b0c..479e42345a 100644 --- a/openair1/PHY/phy_vars_nr_ue.h +++ b/openair1/PHY/phy_vars_nr_ue.h @@ -142,4 +142,4 @@ uint8_t scrambling_lut[65536*16] __attribute__((aligned(32))); uint8_t max_ldpc_iterations=4; uint8_t max_turbo_iterations=4; -#endif /*__PHY_VARS_H__ */ +#endif diff --git a/openair1/PHY/phy_vars_ue.h b/openair1/PHY/phy_vars_ue.h index 05f2e1b8f1..52d4ba543b 100644 --- a/openair1/PHY/phy_vars_ue.h +++ b/openair1/PHY/phy_vars_ue.h @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#ifndef __PHY_VARS_H__ -#define __PHY_VARS_H__ +#ifndef __PHY_VARS_UE_H__ +#define __PHY_VARS_UE_H__ #include "PHY/types.h" #include "PHY/defs_UE.h" @@ -133,4 +133,4 @@ int16_t unscrambling_lut[65536*16] __attribute__((aligned(32))); uint8_t scrambling_lut[65536*16] __attribute__((aligned(32))); uint8_t max_turbo_iterations=4; -#endif /*__PHY_VARS_H__ */ +#endif diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 1f46408e48..e5e48ee0ed 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -86,17 +86,6 @@ char nr_mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"}; extern double cpuf; - - -int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, - uint32_t frame, - uint32_t slot); - -uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, - int frame, - int nr_tti_rx, - fapi_nr_dci_indication_t *dci_ind); - /* int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, uint8_t eNB_id, diff --git a/openair1/SIMULATION/TOOLS/rangen_double.c b/openair1/SIMULATION/TOOLS/rangen_double.c index 82b1557a5b..c114df912d 100644 --- a/openair1/SIMULATION/TOOLS/rangen_double.c +++ b/openair1/SIMULATION/TOOLS/rangen_double.c @@ -67,8 +67,6 @@ void randominit(unsigned seed_init) double uniformrandom(void) { -#define a 1664525lu -#define mod 4294967296.0 /* is 2**32 */ int j; diff --git a/openair3/M3AP/m3ap_MCE_handler.h b/openair3/M3AP/m3ap_MCE_handler.h index ce4997e80d..26a887bac6 100644 --- a/openair3/M3AP/m3ap_MCE_handler.h +++ b/openair3/M3AP/m3ap_MCE_handler.h @@ -19,15 +19,15 @@ * contact@openairinterface.org */ -/*! \file m2ap_handler.h - * \brief m2ap handler procedures for eNB +/*! \file m3ap_handler.h + * \brief m3ap handler procedures for eNB * \author Javier Morgade * \date 2019 * \version 0.1 */ -#ifndef M2AP_MCE_HANDLERS_H_ -#define M2AP_MCE_HANDLERS_H_ +#ifndef M3AP_MCE_HANDLERS_H_ +#define M3AP_MCE_HANDLERS_H_ #include "m2ap_MCE_defs.h" diff --git a/openair3/M3AP/m3ap_MME_generate_messages.h b/openair3/M3AP/m3ap_MME_generate_messages.h index 1632dc807a..146f58825a 100644 --- a/openair3/M3AP/m3ap_MME_generate_messages.h +++ b/openair3/M3AP/m3ap_MME_generate_messages.h @@ -19,15 +19,15 @@ * contact@openairinterface.org */ -/*! \file m2ap_MCE_generate_messages.h - * \brief m2ap procedures for MCE +/*! \file m3ap_MCE_generate_messages.h + * \brief m3ap procedures for MCE * \author Javier Morgade * \date 2019 * \version 0.1 */ -#ifndef M2AP_MCE_GENERATE_MESSAGES_H_ -#define M2AP_MCE_GENERATE_MESSAGES_H_ +#ifndef M3AP_MCE_GENERATE_MESSAGES_H_ +#define M3AP_MCE_GENERATE_MESSAGES_H_ #include "m2ap_MCE_defs.h" #include "m2ap_common.h" diff --git a/openair3/NAS/COMMON/API/NETWORK/as_message.h b/openair3/NAS/COMMON/API/NETWORK/as_message.h deleted file mode 100644 index 30810a325e..0000000000 --- a/openair3/NAS/COMMON/API/NETWORK/as_message.h +++ /dev/null @@ -1,578 +0,0 @@ -/* - * Copyright (c) 2015, EURECOM (www.eurecom.fr) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of the FreeBSD Project. - */ - - -/***************************************************************************** - -Source as_message.h - -Version 0.1 - -Date 2012/10/18 - -Product NAS stack - -Subsystem Application Programming Interface - -Author Frederic Maurel - -Description Defines the messages supported by the Access Stratum sublayer - protocol (usually RRC and S1AP for E-UTRAN) and functions used - to encode and decode - -*****************************************************************************/ -#ifndef __AS_MESSAGE_H__ -#define __AS_MESSAGE_H__ - -#include "commonDef.h" -#include "networkDef.h" - -/****************************************************************************/ -/********************* G L O B A L C O N S T A N T S *******************/ -/****************************************************************************/ - -/* - * -------------------------------------------------------------------------- - * Access Stratum message types - * -------------------------------------------------------------------------- - */ -#define AS_REQUEST 0x0100 -#define AS_RESPONSE 0x0200 -#define AS_INDICATION 0x0400 -#define AS_CONFIRM 0x0800 - -/* - * -------------------------------------------------------------------------- - * Access Stratum message identifiers - * -------------------------------------------------------------------------- - */ - -/* Broadcast information */ -#define AS_BROADCAST_INFO 0x01 -#define AS_BROADCAST_INFO_IND (AS_BROADCAST_INFO | AS_INDICATION) - -/* Cell information relevant for cell selection processing */ -#define AS_CELL_INFO 0x02 -#define AS_CELL_INFO_REQ (AS_CELL_INFO | AS_REQUEST) -#define AS_CELL_INFO_CNF (AS_CELL_INFO | AS_CONFIRM) -#define AS_CELL_INFO_IND (AS_CELL_INFO | AS_INDICATION) - -/* Paging information */ -#define AS_PAGING 0x03 -#define AS_PAGING_REQ (AS_PAGING | AS_REQUEST) -#define AS_PAGING_IND (AS_PAGING | AS_INDICATION) - -/* NAS signalling connection establishment */ -#define AS_NAS_ESTABLISH 0x04 -#define AS_NAS_ESTABLISH_REQ (AS_NAS_ESTABLISH | AS_REQUEST) -#define AS_NAS_ESTABLISH_IND (AS_NAS_ESTABLISH | AS_INDICATION) -#define AS_NAS_ESTABLISH_RSP (AS_NAS_ESTABLISH | AS_RESPONSE) -#define AS_NAS_ESTABLISH_CNF (AS_NAS_ESTABLISH | AS_CONFIRM) - -/* NAS signalling connection release */ -#define AS_NAS_RELEASE 0x05 -#define AS_NAS_RELEASE_REQ (AS_NAS_RELEASE | AS_REQUEST) -#define AS_NAS_RELEASE_IND (AS_NAS_RELEASE | AS_INDICATION) - -/* Uplink information transfer */ -#define AS_UL_INFO_TRANSFER 0x06 -#define AS_UL_INFO_TRANSFER_REQ (AS_UL_INFO_TRANSFER | AS_REQUEST) -#define AS_UL_INFO_TRANSFER_CNF (AS_UL_INFO_TRANSFER | AS_CONFIRM) -#define AS_UL_INFO_TRANSFER_IND (AS_UL_INFO_TRANSFER | AS_INDICATION) - -/* Downlink information transfer */ -#define AS_DL_INFO_TRANSFER 0x07 -#define AS_DL_INFO_TRANSFER_REQ (AS_DL_INFO_TRANSFER | AS_REQUEST) -#define AS_DL_INFO_TRANSFER_CNF (AS_DL_INFO_TRANSFER | AS_CONFIRM) -#define AS_DL_INFO_TRANSFER_IND (AS_DL_INFO_TRANSFER | AS_INDICATION) - -/* Radio Access Bearer establishment */ -#define AS_RAB_ESTABLISH 0x08 -#define AS_RAB_ESTABLISH_REQ (AS_RAB_ESTABLISH | AS_REQUEST) -#define AS_RAB_ESTABLISH_IND (AS_RAB_ESTABLISH | AS_INDICATION) -#define AS_RAB_ESTABLISH_RSP (AS_RAB_ESTABLISH | AS_RESPONSE) -#define AS_RAB_ESTABLISH_CNF (AS_RAB_ESTABLISH | AS_CONFIRM) - -/* Radio Access Bearer release */ -#define AS_RAB_RELEASE 0x09 -#define AS_RAB_RELEASE_REQ (AS_RAB_RELEASE | AS_REQUEST) -#define AS_RAB_RELEASE_IND (AS_RAB_RELEASE | AS_INDICATION) - -/* NAS Cause */ -#define EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED (8) -#define EPS_SERVICES_NOT_ALLOWED (7) -#define PLMN_NOT_ALLOWED (11) -#define TRACKING_AREA_NOT_ALLOWED (12) -#define ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA (13) -#define EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN (14) -#define NO_SUITABLE_CELLS_IN_TRACKING_AREA (15) -#define NETWORK_FAILURE (17) -#define ESM_FAILURE (19) - -typedef enum nas_cause_s { - NAS_CAUSE_EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED = EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED, - NAS_CAUSE_EPS_SERVICES_NOT_ALLOWED = EPS_SERVICES_NOT_ALLOWED, - NAS_CAUSE_PLMN_NOT_ALLOWED = PLMN_NOT_ALLOWED, - NAS_CAUSE_TRACKING_AREA_NOT_ALLOWED = TRACKING_AREA_NOT_ALLOWED, - NAS_CAUSE_ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA = ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA, - NAS_CAUSE_EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN = EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN, - NAS_CAUSE_NO_SUITABLE_CELLS_IN_TRACKING_AREA = NO_SUITABLE_CELLS_IN_TRACKING_AREA, - NAS_CAUSE_NETWORK_FAILURE = NETWORK_FAILURE, - NAS_CAUSE_ESM_FAILURE = ESM_FAILURE -} nas_cause_t; - -/* - * -------------------------------------------------------------------------- - * Access Stratum message global parameters - * -------------------------------------------------------------------------- - */ - -/* Error code */ -typedef enum nas_error_code_s { - AS_SUCCESS = 1, /* Success code, transaction is going on */ - AS_TERMINATED_NAS, /* Transaction terminated by NAS */ - AS_TERMINATED_AS, /* Transaction terminated by AS */ - AS_FAILURE /* Failure code */ -} nas_error_code_t; - -/* Core network domain */ -typedef enum core_network_s { - AS_PS = 1, /* Packet-Switched */ - AS_CS /* Circuit-Switched */ -} core_network_t; - -/* SAE Temporary Mobile Subscriber Identity */ -typedef struct as_stmsi_s { - uint8_t MMEcode; /* MME code that allocated the GUTI */ - uint32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */ -} as_stmsi_t; - -/* Dedicated NAS information */ -typedef struct as_nas_info_s { - uint32_t length; /* Length of the NAS information data */ - Byte_t* data; /* Dedicated NAS information data container */ -} as_nas_info_t; - -/* Radio Access Bearer identity */ -typedef uint8_t as_rab_id_t; - -/****************************************************************************/ -/************************ G L O B A L T Y P E S ************************/ -/****************************************************************************/ - -/* - * -------------------------------------------------------------------------- - * Broadcast information - * -------------------------------------------------------------------------- - */ - -/* - * AS->NAS - Broadcast information indication - * AS may asynchronously report to NAS available PLMNs within specific - * location area - */ -typedef struct broadcast_info_ind_s { -#define PLMN_LIST_MAX_SIZE 6 - PLMN_LIST_T(PLMN_LIST_MAX_SIZE) plmnIDs; /* List of PLMN identifiers */ - ci_t cellID; /* Identity of the cell serving the listed PLMNs */ - tac_t tac; /* Code of the tracking area the cell belongs to */ -} broadcast_info_ind_t; - -/* - * -------------------------------------------------------------------------- - * Cell information relevant for cell selection processing - * -------------------------------------------------------------------------- - */ - -/* Radio access technologies supported by the network */ -#define AS_GSM (1 << NET_ACCESS_GSM) -#define AS_COMPACT (1 << NET_ACCESS_COMPACT) -#define AS_UTRAN (1 << NET_ACCESS_UTRAN) -#define AS_EGPRS (1 << NET_ACCESS_EGPRS) -#define AS_HSDPA (1 << NET_ACCESS_HSDPA) -#define AS_HSUPA (1 << NET_ACCESS_HSUPA) -#define AS_HSDUPA (1 << NET_ACCESS_HSDUPA) -#define AS_EUTRAN (1 << NET_ACCESS_EUTRAN) - -/* - * NAS->AS - Cell Information request - * NAS request AS to search for a suitable cell belonging to the selected - * PLMN to camp on. - */ -typedef struct cell_info_req_s { - plmn_t plmnID; /* Selected PLMN identity */ - Byte_t rat; /* Bitmap - set of radio access technologies */ -} cell_info_req_t; - -/* - * AS->NAS - Cell Information confirm - * AS search for a suitable cell and respond to NAS. If found, the cell - * is selected to camp on. - */ -typedef struct cell_info_cnf_s { - uint8_t errCode; /* Error code */ - ci_t cellID; /* Identity of the cell serving the selected PLMN */ - tac_t tac; /* Code of the tracking area the cell belongs to */ - AcT_t rat; /* Radio access technology supported by the cell */ - uint8_t rsrq; /* Reference signal received quality */ - uint8_t rsrp; /* Reference signal received power */ -} cell_info_cnf_t; - -/* - * AS->NAS - Cell Information indication - * AS may change cell selection if a more suitable cell is found. - */ -typedef struct cell_info_ind_s { - ci_t cellID; /* Identity of the new serving cell */ - tac_t tac; /* Code of the tracking area the cell belongs to */ -} cell_info_ind_t; - -/* - * -------------------------------------------------------------------------- - * Paging information - * -------------------------------------------------------------------------- - */ - -/* Paging cause */ -typedef enum paging_cause_s { - AS_CONNECTION_ESTABLISH, /* Establish NAS signalling connection */ - AS_EPS_ATTACH, /* Perform local detach and initiate EPS - * attach procedure */ - AS_CS_FALLBACK /* Inititate CS fallback procedure */ -} paging_cause_t; - -/* - * NAS->AS - Paging Information request - * NAS requests the AS that NAS signalling messages or user data is pending - * to be sent. - */ -typedef struct paging_req_s { - as_stmsi_t s_tmsi; /* UE identity */ - uint8_t CN_domain; /* Core network domain */ -} paging_req_t; - -/* - * AS->NAS - Paging Information indication - * AS reports to the NAS that appropriate procedure has to be initiated. - */ -typedef struct paging_ind_s { - paging_cause_t cause; /* Paging cause */ -} paging_ind_t; - -/* - * -------------------------------------------------------------------------- - * NAS signalling connection establishment - * -------------------------------------------------------------------------- - */ - -/* Cause of RRC connection establishment */ -typedef enum as_cause_s { - AS_CAUSE_UNKNOWN = 0, - AS_CAUSE_EMERGENCY = NET_ESTABLISH_CAUSE_EMERGENCY, - AS_CAUSE_HIGH_PRIO = NET_ESTABLISH_CAUSE_HIGH_PRIO, - AS_CAUSE_MT_ACCESS = NET_ESTABLISH_CAUSE_MT_ACCESS, - AS_CAUSE_MO_SIGNAL = NET_ESTABLISH_CAUSE_MO_SIGNAL, - AS_CAUSE_MO_DATA = NET_ESTABLISH_CAUSE_MO_DATA, - AS_CAUSE_V1020 = NET_ESTABLISH_CAUSE_V1020 -} as_cause_t; - -/* Type of the call associated to the RRC connection establishment */ -typedef enum as_call_type_s { - AS_TYPE_ORIGINATING_SIGNAL = NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL, - AS_TYPE_EMERGENCY_CALLS = NET_ESTABLISH_TYPE_EMERGENCY_CALLS, - AS_TYPE_ORIGINATING_CALLS = NET_ESTABLISH_TYPE_ORIGINATING_CALLS, - AS_TYPE_TERMINATING_CALLS = NET_ESTABLISH_TYPE_TERMINATING_CALLS, - AS_TYPE_MO_CS_FALLBACK = NET_ESTABLISH_TYPE_MO_CS_FALLBACK -} as_call_type_t; - -/* - * NAS->AS - NAS signalling connection establishment request - * NAS requests the AS to perform the RRC connection establishment procedure - * to transfer initial NAS message to the network while UE is in IDLE mode. - */ -typedef struct nas_establish_req_s { - as_cause_t cause; /* RRC connection establishment cause */ - as_call_type_t type; /* RRC associated call type */ - as_stmsi_t s_tmsi; /* UE identity */ - plmn_t plmnID; /* Selected PLMN identity */ - as_nas_info_t initialNasMsg; /* Initial NAS message to transfer */ -} nas_establish_req_t; - -/* - * AS->NAS - NAS signalling connection establishment indication - * AS transfers the initial NAS message to the NAS. - */ -typedef struct nas_establish_ind_s { - uint32_t UEid; /* UE lower layer identifier */ - tac_t tac; /* Code of the tracking area the initiating - * UE belongs to */ - as_cause_t asCause; /* Establishment cause */ - as_nas_info_t initialNasMsg; /* Initial NAS message to transfer */ -} nas_establish_ind_t; - -/* - * NAS->AS - NAS signalling connection establishment response - * NAS responds to the AS that initial answer message has to be provided to - * the UE. - */ -typedef struct nas_establish_rsp_s { - uint32_t UEid; /* UE lower layer identifier */ - as_stmsi_t s_tmsi; /* UE identity */ - nas_error_code_t errCode; /* Transaction status */ - as_nas_info_t nasMsg; /* NAS message to transfer */ - uint32_t nas_ul_count; /* UL NAS COUNT */ - uint16_t selected_encryption_algorithm; - uint16_t selected_integrity_algorithm; -} nas_establish_rsp_t; - -/* - * AS->NAS - NAS signalling connection establishment confirm - * AS transfers the initial answer message to the NAS. - */ -typedef struct nas_establish_cnf_s { - uint32_t UEid; /* UE lower layer identifier */ - nas_error_code_t errCode; /* Transaction status */ - as_nas_info_t nasMsg; /* NAS message to transfer */ - uint32_t ul_nas_count; - uint16_t selected_encryption_algorithm; - uint16_t selected_integrity_algorithm; -} nas_establish_cnf_t; - -/* - * -------------------------------------------------------------------------- - * NAS signalling connection release - * -------------------------------------------------------------------------- - */ - -/* Release cause */ -typedef enum release_cause_s { - AS_AUTHENTICATION_FAILURE = 1, /* Authentication procedure failed */ - AS_DETACH /* Detach requested */ -} release_cause_t; - -/* - * NAS->AS - NAS signalling connection release request - * NAS requests the termination of the connection with the UE. - */ -typedef struct nas_release_req_s { - uint32_t UEid; /* UE lower layer identifier */ - as_stmsi_t s_tmsi; /* UE identity */ - release_cause_t cause; /* Release cause */ -} nas_release_req_t; - -/* - * AS->NAS - NAS signalling connection release indication - * AS reports that connection has been terminated by the network. - */ -typedef struct nas_release_ind_s { - release_cause_t cause; /* Release cause */ -} nas_release_ind_t; - -/* - * -------------------------------------------------------------------------- - * NAS information transfer - * -------------------------------------------------------------------------- - */ - -/* - * NAS->AS - Uplink data transfer request - * NAS requests the AS to transfer uplink information to the NAS that - * operates at the network side. - */ -typedef struct ul_info_transfer_req_s { - uint32_t UEid; /* UE lower layer identifier */ - as_stmsi_t s_tmsi; /* UE identity */ - as_nas_info_t nasMsg; /* Uplink NAS message */ -} ul_info_transfer_req_t; - -/* - * AS->NAS - Uplink data transfer confirm - * AS immediately notifies the NAS whether uplink information has been - * successfully sent to the network or not. - */ -typedef struct ul_info_transfer_cnf_s { - uint32_t UEid; /* UE lower layer identifier */ - nas_error_code_t errCode; /* Transaction status */ -} ul_info_transfer_cnf_t; - -/* - * AS->NAS - Uplink data transfer indication - * AS delivers the uplink information message to the NAS that operates - * at the network side. - */ -typedef struct ul_info_transfer_ind_s { - uint32_t UEid; /* UE lower layer identifier */ - as_nas_info_t nasMsg; /* Uplink NAS message */ -} ul_info_transfer_ind_t; - -/* - * NAS->AS - Downlink data transfer request - * NAS requests the AS to transfer downlink information to the NAS that - * operates at the UE side. - */ -typedef ul_info_transfer_req_t dl_info_transfer_req_t; - -/* - * AS->NAS - Downlink data transfer confirm - * AS immediately notifies the NAS whether downlink information has been - * successfully sent to the network or not. - */ -typedef ul_info_transfer_cnf_t dl_info_transfer_cnf_t; - -/* - * AS->NAS - Downlink data transfer indication - * AS delivers the downlink information message to the NAS that operates - * at the UE side. - */ -typedef ul_info_transfer_ind_t dl_info_transfer_ind_t; - -/* - * -------------------------------------------------------------------------- - * Radio Access Bearer establishment - * -------------------------------------------------------------------------- - */ - -/* TODO: Quality of Service parameters */ -typedef struct {} as_qos_t; - -/* - * NAS->AS - Radio access bearer establishment request - * NAS requests the AS to allocate transmission resources to radio access - * bearer initialized at the network side. - */ -typedef struct rab_establish_req_s { - as_stmsi_t s_tmsi; /* UE identity */ - as_rab_id_t rabID; /* Radio access bearer identity */ - as_qos_t QoS; /* Requested Quality of Service */ -} rab_establish_req_t; - -/* - * AS->NAS - Radio access bearer establishment indication - * AS notifies the NAS that specific radio access bearer has to be setup. - */ -typedef struct rab_establish_ind_s { - as_rab_id_t rabID; /* Radio access bearer identity */ -} rab_establish_ind_t; - -/* - * NAS->AS - Radio access bearer establishment response - * NAS responds to AS whether the specified radio access bearer has been - * successfully setup or not. - */ -typedef struct rab_establish_rsp_s { - as_stmsi_t s_tmsi; /* UE identity */ - as_rab_id_t rabID; /* Radio access bearer identity */ - nas_error_code_t errCode; /* Transaction status */ -} rab_establish_rsp_t; - -/* - * AS->NAS - Radio access bearer establishment confirm - * AS notifies NAS whether the specified radio access bearer has been - * successfully setup at the UE side or not. - */ -typedef struct rab_establish_cnf_s { - as_rab_id_t rabID; /* Radio access bearer identity */ - nas_error_code_t errCode; /* Transaction status */ -} rab_establish_cnf_t; - -/* - * -------------------------------------------------------------------------- - * Radio Access Bearer release - * -------------------------------------------------------------------------- - */ - -/* - * NAS->AS - Radio access bearer release request - * NAS requests the AS to release transmission resources previously allocated - * to specific radio access bearer at the network side. - */ -typedef struct rab_release_req_s { - as_stmsi_t s_tmsi; /* UE identity */ - as_rab_id_t rabID; /* Radio access bearer identity */ -} rab_release_req_t; - -/* - * AS->NAS - Radio access bearer release indication - * AS notifies NAS that specific radio access bearer has been released. - */ -typedef struct rab_release_ind_s { - as_rab_id_t rabID; /* Radio access bearer identity */ -} rab_release_ind_t; - -/* - * -------------------------------------------------------------------------- - * Structure of the AS messages handled by the network sublayer - * -------------------------------------------------------------------------- - */ -typedef struct as_message_s { - uint16_t msgID; - union { - broadcast_info_ind_t broadcast_info_ind; - cell_info_req_t cell_info_req; - cell_info_cnf_t cell_info_cnf; - cell_info_ind_t cell_info_ind; - paging_req_t paging_req; - paging_ind_t paging_ind; - nas_establish_req_t nas_establish_req; - nas_establish_ind_t nas_establish_ind; - nas_establish_rsp_t nas_establish_rsp; - nas_establish_cnf_t nas_establish_cnf; - nas_release_req_t nas_release_req; - nas_release_ind_t nas_release_ind; - ul_info_transfer_req_t ul_info_transfer_req; - ul_info_transfer_cnf_t ul_info_transfer_cnf; - ul_info_transfer_ind_t ul_info_transfer_ind; - dl_info_transfer_req_t dl_info_transfer_req; - dl_info_transfer_cnf_t dl_info_transfer_cnf; - dl_info_transfer_ind_t dl_info_transfer_ind; - rab_establish_req_t rab_establish_req; - rab_establish_ind_t rab_establish_ind; - rab_establish_rsp_t rab_establish_rsp; - rab_establish_cnf_t rab_establish_cnf; - rab_release_req_t rab_release_req; - rab_release_ind_t rab_release_ind; - } __attribute__((__packed__)) msg; -} as_message_t; - -/****************************************************************************/ -/******************** G L O B A L V A R I A B L E S ********************/ -/****************************************************************************/ - -/****************************************************************************/ -/****************** E X P O R T E D F U N C T I O N S ******************/ -/****************************************************************************/ - -int as_message_decode(const char* buffer, as_message_t* msg, int length); - -int as_message_encode(char* buffer, as_message_t* msg, int length); - -/* Implemented in the network_api.c body file */ -int as_message_send(as_message_t* as_msg); - -#endif /* __AS_MESSAGE_H__*/ diff --git a/openair3/NAS/COMMON/commonDef.h b/openair3/NAS/COMMON/commonDef.h deleted file mode 100644 index e9f769db55..0000000000 --- a/openair3/NAS/COMMON/commonDef.h +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright (c) 2015, EURECOM (www.eurecom.fr) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of the FreeBSD Project. - */ -/* - -Source commonDef.h - -Version 0.1 - -Date 2012/02/27 - -Product NAS stack - -Subsystem include - -Author Frederic Maurel - -Description Contains global common definitions - -*****************************************************************************/ -#ifndef __COMMONDEF_H__ -#define __COMMONDEF_H__ - -#include -#include -#include - -typedef signed char boolean_t; - -#if !defined(TRUE) -#define TRUE (boolean_t)0x01 -#endif - -#if !defined(FALSE) -#define FALSE (boolean_t)0x00 -#endif - -#define BOOL_NOT(b) (b^TRUE) - -#define NAS_UE_ID_FMT "0x%06x" - -/****************************************************************************/ -/********************* G L O B A L C O N S T A N T S *******************/ -/****************************************************************************/ - -#define RETURNok (0) -#define RETURNerror (-1) - -/* - * Name of the environment variable which defines the default directory - * where the NAS application is executed and where are located files - * where non-volatile data are stored - */ -#define DEFAULT_NAS_PATH "PWD" - -/****************************************************************************/ -/************************ G L O B A L T Y P E S ************************/ -/****************************************************************************/ - -/* ------------------------------------------------------------------------------ - Standard data type definitions ------------------------------------------------------------------------------ -*/ -typedef int8_t SByte_t; /* 8 bit signed integer */ -typedef uint8_t Byte_t; /* 8 bit unsigned integer */ - - -/* ------------------------------------------------------------------------------ - Common NAS data type definitions ------------------------------------------------------------------------------ -*/ - -typedef uint8_t Stat_t; /* Registration status */ -typedef uint16_t lac_t; /* Location Area Code */ -typedef uint8_t rac_t; /* Routing Area Code */ -typedef uint16_t tac_t; /* Tracking Area Code */ -typedef uint32_t ci_t; /* Cell Identifier */ -typedef uint8_t AcT_t; /* Access Technology */ - -/* - * International Mobile Subscriber Identity - */ -typedef struct { - Byte_t length; - union { - struct { - Byte_t digit2:4; - Byte_t digit1:4; - Byte_t digit4:4; - Byte_t digit3:4; - Byte_t digit6:4; - Byte_t digit5:4; - Byte_t digit8:4; - Byte_t digit7:4; - Byte_t digit10:4; - Byte_t digit9:4; - Byte_t digit12:4; - Byte_t digit11:4; - Byte_t digit14:4; - Byte_t digit13:4; -#define EVEN_PARITY 0 -#define ODD_PARITY 1 - Byte_t parity:4; - Byte_t digit15:4; - } num; -#define IMSI_SIZE 8 - Byte_t value[IMSI_SIZE]; - } u; -} imsi_t; - -#define NAS_IMSI2STR(iMsI_t_PtR,iMsI_sTr, MaXlEn) \ - {\ - int l_offset = 0;\ - int l_ret = 0;\ - l_ret = snprintf(iMsI_sTr + l_offset, MaXlEn - l_offset, "%u%u%u%u%u",\ - iMsI_t_PtR->u.num.digit1, iMsI_t_PtR->u.num.digit2,\ - iMsI_t_PtR->u.num.digit3, iMsI_t_PtR->u.num.digit4,\ - iMsI_t_PtR->u.num.digit5);\ - if ((iMsI_t_PtR->u.num.digit6 != 0xf) && (l_ret > 0)) {\ - l_offset += l_ret;\ - l_ret = snprintf(iMsI_sTr + l_offset, MaXlEn - l_offset, "%u", iMsI_t_PtR->u.num.digit6);\ - }\ - if (l_ret > 0) {\ - l_offset += l_ret;\ - l_ret = snprintf(iMsI_sTr + l_offset, MaXlEn - l_offset, "%u%u%u%u%u%u%u%u",\ - iMsI_t_PtR->u.num.digit7, iMsI_t_PtR->u.num.digit8,\ - iMsI_t_PtR->u.num.digit9, iMsI_t_PtR->u.num.digit10,\ - iMsI_t_PtR->u.num.digit11, iMsI_t_PtR->u.num.digit12,\ - iMsI_t_PtR->u.num.digit13, iMsI_t_PtR->u.num.digit14);\ - }\ - if ((iMsI_t_PtR->u.num.digit15 != 0xf) && (l_ret > 0)) {\ - l_offset += l_ret;\ - l_ret = snprintf(iMsI_sTr + l_offset, MaXlEn - l_offset, "%u", iMsI_t_PtR->u.num.digit15);\ - }\ - } - -/* - * Mobile subscriber dialing number - */ -typedef struct { - Byte_t ext:1; - /* Type Of Number */ -#define MSISDN_TON_UNKNOWKN 0b000 -#define MSISDN_TON_INTERNATIONAL 0b001 -#define MSISDN_TON_NATIONAL 0b010 -#define MSISDN_TON_NETWORK 0b011 -#define MSISDN_TON_SUBCRIBER 0b100 -#define MSISDN_TON_ABBREVIATED 0b110 -#define MSISDN_TON_RESERVED 0b111 - Byte_t ton:3; - /* Numbering Plan Identification */ -#define MSISDN_NPI_UNKNOWN 0b0000 -#define MSISDN_NPI_ISDN_TELEPHONY 0b0001 -#define MSISDN_NPI_GENERIC 0b0010 -#define MSISDN_NPI_DATA 0b0011 -#define MSISDN_NPI_TELEX 0b0100 -#define MSISDN_NPI_MARITIME_MOBILE 0b0101 -#define MSISDN_NPI_LAND_MOBILE 0b0110 -#define MSISDN_NPI_ISDN_MOBILE 0b0111 -#define MSISDN_NPI_PRIVATE 0b1110 -#define MSISDN_NPI_RESERVED 0b1111 - Byte_t npi:4; - /* Dialing Number */ - struct { - Byte_t lsb:4; - Byte_t msb:4; -#define MSISDN_DIGIT_SIZE 10 - } digit[MSISDN_DIGIT_SIZE]; -} msisdn_t; - -/* - * International Mobile Equipment Identity - */ -typedef imsi_t imei_t; - -/* - * Public Land Mobile Network identifier - * PLMN = BCD encoding (Mobile Country Code + Mobile Network Code) - */ -typedef struct { - Byte_t MCCdigit2:4; - Byte_t MCCdigit1:4; - Byte_t MNCdigit3:4; - Byte_t MCCdigit3:4; - Byte_t MNCdigit2:4; - Byte_t MNCdigit1:4; -} plmn_t; - -/* - * Location Area Identification - */ -typedef struct { - plmn_t plmn; /* + */ - lac_t lac; /* Location Area Code */ -} lai_t; - -/* - * GPRS Routing Area Identification - */ -typedef struct { - plmn_t plmn; /* + */ - lac_t lac; /* Location Area Code */ - rac_t rac; /* Routing Area Code */ -} RAI_t; - -/* - * EPS Tracking Area Identification - */ -typedef struct { - plmn_t plmn; /* + */ - tac_t tac; /* Tracking Area Code */ -} tai_t; - -/* - * EPS Globally Unique MME Identity - */ -typedef struct { - plmn_t plmn; /* + */ - uint16_t MMEgid; /* MME group identifier */ - uint8_t MMEcode; /* MME code */ -} gummei_t; - -/* - * EPS Globally Unique Temporary UE Identity - */ -typedef struct { - gummei_t gummei; /* Globally Unique MME Identity */ - uint32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */ -} GUTI_t; -#define GUTI2STR(GuTi_PtR, GuTi_StR, MaXlEn) \ - {\ - int l_offset = 0;\ - int l_ret = 0;\ - l_ret += snprintf(GuTi_StR + l_offset,MaXlEn-l_offset, "%03u.",\ - GuTi_PtR->gummei.plmn.MCCdigit3 * 100 +\ - GuTi_PtR->gummei.plmn.MCCdigit2 * 10 +\ - GuTi_PtR->gummei.plmn.MCCdigit1);\ - if (l_ret > 0) {\ - l_offset += l_ret;\ - } else {\ - l_offset = MaXlEn;\ - }\ - if (GuTi_PtR->gummei.plmn.MNCdigit1 != 0xf) {\ - l_ret += snprintf(GuTi_StR + l_offset,MaXlEn-l_offset, "%03u|%04x|%02x|%08x",\ - GuTi_PtR->gummei.plmn.MNCdigit3 * 100 +\ - GuTi_PtR->gummei.plmn.MNCdigit2 * 10 +\ - GuTi_PtR->gummei.plmn.MNCdigit1,\ - GuTi_PtR->gummei.MMEgid,\ - GuTi_PtR->gummei.MMEcode,\ - GuTi_PtR->m_tmsi);\ - } else {\ - l_ret += snprintf(GuTi_StR + l_offset,MaXlEn-l_offset, "%02u|%04x|%02x|%08x",\ - GuTi_PtR->gummei.plmn.MNCdigit2 * 10 +\ - GuTi_PtR->gummei.plmn.MNCdigit1,\ - GuTi_PtR->gummei.MMEgid,\ - GuTi_PtR->gummei.MMEcode,\ - GuTi_PtR->m_tmsi);\ - }\ - } - - - - -/* Checks PLMN validity */ -#define PLMN_IS_VALID(plmn) (((plmn).MCCdigit1 & \ - (plmn).MCCdigit2 & \ - (plmn).MCCdigit3) != 0x0F) - -/* Checks TAC validity */ -#define TAC_IS_VALID(tac) (((tac) != 0x0000) && ((tac) != 0xFFF0)) - -/* Checks TAI validity */ -#define TAI_IS_VALID(tai) (PLMN_IS_VALID((tai).plmn) && \ - TAC_IS_VALID((tai).tac)) -/* - * A list of PLMNs - */ -#define PLMN_LIST_T(SIZE) struct {Byte_t n_plmns; plmn_t plmn[SIZE];} - -/* - * A list of TACs - */ -#define TAC_LIST_T(SIZE) struct {Byte_t n_tacs; TAC_t tac[SIZE];} - -/* - * A list of TAIs - */ -#define TAI_LIST_T(SIZE) struct {Byte_t n_tais; tai_t tai[SIZE];} - -typedef enum eps_protocol_discriminator_e { - /* Protocol discriminator identifier for EPS Mobility Management */ - EPS_MOBILITY_MANAGEMENT_MESSAGE = 0x7, - - /* Protocol discriminator identifier for EPS Session Management */ - EPS_SESSION_MANAGEMENT_MESSAGE = 0x2, -} eps_protocol_discriminator_t; - -/****************************************************************************/ -/******************** G L O B A L V A R I A B L E S ********************/ -/****************************************************************************/ - -/****************************************************************************/ -/****************** E X P O R T E D F U N C T I O N S ******************/ -/****************************************************************************/ - -#endif /* __COMMONDEF_H__*/ diff --git a/openair3/NAS/COMMON/networkDef.h b/openair3/NAS/COMMON/networkDef.h deleted file mode 100644 index 5390eac2f0..0000000000 --- a/openair3/NAS/COMMON/networkDef.h +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2015, EURECOM (www.eurecom.fr) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of the FreeBSD Project. - */ - -/***************************************************************************** - -Source networkDef.h - -Version 0.1 - -Date 2012/09/21 - -Product NAS stack - -Subsystem include - -Author Frederic Maurel - -Description Contains network's global definitions - -*****************************************************************************/ -#ifndef __NETWORKDEF_H__ -#define __NETWORKDEF_H__ - -/****************************************************************************/ -/********************* G L O B A L C O N S T A N T S *******************/ -/****************************************************************************/ - -/* - * ---------------------- - * Network selection mode - * ---------------------- - */ -#define NET_PLMN_AUTO 0 -#define NET_PLMN_MANUAL 1 - -/* - * --------------------------- - * Network registration status - * --------------------------- - */ -/* not registered, not currently searching an operator to register to */ -#define NET_REG_STATE_OFF 0 -/* registered, home network */ -#define NET_REG_STATE_HN 1 -/* not registered, currently trying to attach or searching an operator - * to register to */ -#define NET_REG_STATE_ON 2 -/* registration denied */ -#define NET_REG_STATE_DENIED 3 -/* unknown (e.g. out of GERAN/UTRAN/E-UTRAN coverage) */ -#define NET_REG_STATE_UNKNOWN 4 -/* registered, roaming */ -#define NET_REG_STATE_ROAMING 5 -/* registered for "SMS only", home network */ -#define NET_REG_STATE_SMS_HN 6 -/* registered, for "SMS only", roaming */ -#define NET_REG_STATE_SMS_ROAMING 7 -/* attached for emergency bearer services only (applicable to UTRAN) */ -#define NET_REG_STATE_EMERGENCY 8 - -/* - * ------------------------------------ - * Network access technology indicators - * ------------------------------------ - */ -#define NET_ACCESS_UNAVAILABLE (-1) /* Not available */ -#define NET_ACCESS_GSM 0 /* GSM */ -#define NET_ACCESS_COMPACT 1 /* GSM Compact */ -#define NET_ACCESS_UTRAN 2 /* UTRAN */ -#define NET_ACCESS_EGPRS 3 /* GSM w/EGPRS */ -#define NET_ACCESS_HSDPA 4 /* UTRAN w/HSDPA */ -#define NET_ACCESS_HSUPA 5 /* UTRAN w/HSUPA */ -#define NET_ACCESS_HSDUPA 6 /* UTRAN w/HSDPA and HSUPA */ -#define NET_ACCESS_EUTRAN 7 /* E-UTRAN */ - -/* - * --------------------------------------- - * Network operator representation formats - * --------------------------------------- - */ -#define NET_FORMAT_LONG 0 /* long format alphanumeric */ -#define NET_FORMAT_SHORT 1 /* short format alphanumeric */ -#define NET_FORMAT_NUM 2 /* numeric format */ - -#define NET_FORMAT_MAX_SIZE NET_FORMAT_LONG_SIZE - -/* - * ----------------------------- - * Network operator availability - * ----------------------------- - */ -#define NET_OPER_UNKNOWN 0 /* unknown operator */ -#define NET_OPER_AVAILABLE 1 /* available operator */ -#define NET_OPER_CURRENT 2 /* currently selected operator */ -#define NET_OPER_FORBIDDEN 3 /* forbidden operator */ - -/* - * -------------------------------------- - * Network connection establishment cause - * -------------------------------------- - */ -#define NET_ESTABLISH_CAUSE_EMERGENCY 0x01 -#define NET_ESTABLISH_CAUSE_HIGH_PRIO 0x02 -#define NET_ESTABLISH_CAUSE_MT_ACCESS 0x03 -#define NET_ESTABLISH_CAUSE_MO_SIGNAL 0x04 -#define NET_ESTABLISH_CAUSE_MO_DATA 0x05 -#define NET_ESTABLISH_CAUSE_V1020 0x06 - -/* - * -------------------------------------- - * Network connection establishment type - * -------------------------------------- - */ -#define NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL 0x10 -#define NET_ESTABLISH_TYPE_EMERGENCY_CALLS 0x20 -#define NET_ESTABLISH_TYPE_ORIGINATING_CALLS 0x30 -#define NET_ESTABLISH_TYPE_TERMINATING_CALLS 0x40 -#define NET_ESTABLISH_TYPE_MO_CS_FALLBACK 0x50 - -/* - * ------------------- - * PDN connection type - * ------------------- - */ -#define NET_PDN_TYPE_IPV4 (0 + 1) -#define NET_PDN_TYPE_IPV6 (1 + 1) -#define NET_PDN_TYPE_IPV4V6 (2 + 1) - -/****************************************************************************/ -/************************ G L O B A L T Y P E S ************************/ -/****************************************************************************/ - -/* - * --------------------- - * PDN connection status - * --------------------- - */ -typedef enum { - /* MT = The Mobile Terminal, NW = The Network */ - NET_PDN_MT_DEFAULT_ACT = 1, /* MT has activated a PDN connection */ - NET_PDN_NW_DEFAULT_DEACT, /* NW has deactivated a PDN connection */ - NET_PDN_MT_DEFAULT_DEACT, /* MT has deactivated a PDN connection */ - NET_PDN_NW_DEDICATED_ACT, /* NW has activated an EPS bearer context */ - NET_PDN_MT_DEDICATED_ACT, /* MT has activated an EPS bearer context */ - NET_PDN_NW_DEDICATED_DEACT, /* NW has deactivated an EPS bearer context */ - NET_PDN_MT_DEDICATED_DEACT, /* MT has deactivated an EPS bearer context */ -} network_pdn_state_t; - -/* - * --------------------------- - * Network operator identifier - * --------------------------- - */ -typedef struct { -#define NET_FORMAT_LONG_SIZE 16 /* Long alphanumeric format */ -#define NET_FORMAT_SHORT_SIZE 8 /* Short alphanumeric format */ -#define NET_FORMAT_NUM_SIZE 6 /* Numeric format (PLMN identifier */ - union { - unsigned char alpha_long[NET_FORMAT_LONG_SIZE+1]; - unsigned char alpha_short[NET_FORMAT_SHORT_SIZE+1]; - unsigned char num[NET_FORMAT_NUM_SIZE+1]; - } id; -} network_plmn_t; - -/* - * ------------------------------- - * EPS bearer level QoS parameters - * ------------------------------- - */ -typedef struct { - int gbrUL; /* Guaranteed Bit Rate for uplink */ - int gbrDL; /* Guaranteed Bit Rate for downlink */ - int mbrUL; /* Maximum Bit Rate for uplink */ - int mbrDL; /* Maximum Bit Rate for downlink */ - int qci; /* QoS Class Identifier */ -} network_qos_t; - -/* - * ----------------------------- - * IPv4 packet filter parameters - * ----------------------------- - */ -typedef struct { - unsigned char protocol; /* Protocol identifier */ - unsigned char tos; /* Type of service */ -#define NET_PACKET_FILTER_IPV4_ADDR_SIZE 4 - unsigned char addr[NET_PACKET_FILTER_IPV4_ADDR_SIZE]; - unsigned char mask[NET_PACKET_FILTER_IPV4_ADDR_SIZE]; -} network_ipv4_data_t; - -/* - * ----------------------------- - * IPv6 packet filter parameters - * ----------------------------- - */ -typedef struct { - unsigned char nh; /* Next header type */ - unsigned char tf; /* Traffic class */ -#define NET_PACKET_FILTER_IPV6_ADDR_SIZE 16 - unsigned char addr[NET_PACKET_FILTER_IPV6_ADDR_SIZE]; - unsigned char mask[NET_PACKET_FILTER_IPV6_ADDR_SIZE]; - unsigned int ipsec; /* IPSec security parameter index */ - unsigned int fl; /* Flow label */ -} network_ipv6_data_t; - -/* - * ------------- - * Packet Filter - * ------------- - */ -typedef struct { - unsigned char id; /* Packet filter identifier */ -#define NET_PACKET_FILTER_DOWNLINK 0x01 -#define NET_PACKET_FILTER_UPLINK 0x02 -#define NET_PACKET_FILTER_BIDIR 0x03 - unsigned char dir; /* Packet filter direction */ - unsigned char precedence; /* Evaluation precedence */ - union { - network_ipv4_data_t ipv4; - network_ipv6_data_t ipv6; - } data; - unsigned short lport; /* Local (UE) port number */ - unsigned short rport; /* Remote (network) port number */ -} network_pkf_t; - -/* - * --------------------- - * Traffic Flow Template - * --------------------- - */ -typedef struct { - int n_pkfs; -#define NET_PACKET_FILTER_MAX 16 - network_pkf_t* pkf[NET_PACKET_FILTER_MAX]; -} network_tft_t; - -/****************************************************************************/ -/******************** G L O B A L V A R I A B L E S ********************/ -/****************************************************************************/ - -/****************************************************************************/ -/****************** E X P O R T E D F U N C T I O N S ******************/ -/****************************************************************************/ - -#endif /* __NETWORKDEF_H__*/ diff --git a/openair3/UTILS/queue.h b/openair3/UTILS/queue.h deleted file mode 100644 index f8665c0f1a..0000000000 --- a/openair3/UTILS/queue.h +++ /dev/null @@ -1,592 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - */ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -/* - * This file defines five types of data structures: singly-linked lists, - * lists, simple queues, tail queues, and circular queues. - * - * A singly-linked list is headed by a single forward pointer. The - * elements are singly linked for minimum space and pointer manipulation - * overhead at the expense of O(n) removal for arbitrary elements. New - * elements can be added to the list after an existing element or at the - * head of the list. Elements being removed from the head of the list - * should use the explicit macro for this purpose for optimum - * efficiency. A singly-linked list may only be traversed in the forward - * direction. Singly-linked lists are ideal for applications with large - * datasets and few or no removals or for implementing a LIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A simple queue is headed by a pair of pointers, one the head of the - * list and the other to the tail of the list. The elements are singly - * linked to save space, so elements can only be removed from the - * head of the list. New elements can be added to the list after - * an existing element, at the head of the list, or at the end of the - * list. A simple queue may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * A circle queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or after - * an existing element, at the head of the list, or at the end of the list. - * A circle queue may be traversed in either direction, but has a more - * complex end of list detection. - * - * For details on the use of these macros, see the queue(3) manual page. - * SLIST LIST STAILQ TAILQ CIRCLEQ - * _HEAD + + + + + - * _HEAD_INITIALIZER + + + + + - * _ENTRY + + + + + - * _INIT + + + + + - * _EMPTY + + + + + - * _FIRST + + + + + - * _NEXT + + + + + - * _PREV - - - + + - * _LAST - - + + + - * _FOREACH + + + + + - * _FOREACH_REVERSE - - - + + - * _INSERT_HEAD + + + + + - * _INSERT_BEFORE - + - + + - * _INSERT_AFTER + + + + + - * _INSERT_TAIL - - + + + - * _REMOVE_HEAD + - + - - - * _REMOVE + + + + + - */ - -/* - * List definitions. - */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ -#define LIST_INIT(head) do { \ - (head)->lh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - (elm)->field.le_next = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &(elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.le_next = (head)->lh_first) != NULL) \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} while (/*CONSTCOND*/0) - -#define LIST_REMOVE(elm, field) do { \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_FOREACH(var, head, field) \ - for ((var) = ((head)->lh_first); \ - (var); \ - (var) = ((var)->field.le_next)) - -/* - * List access methods. - */ -#define LIST_EMPTY(head) ((head)->lh_first == NULL) -#define LIST_FIRST(head) ((head)->lh_first) -#define LIST_NEXT(elm, field) ((elm)->field.le_next) - - -/* - * Singly-linked List definitions. - */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List functions. - */ -#define SLIST_INIT(head) do { \ - (head)->slh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - (elm)->field.sle_next = (slistelm)->field.sle_next; \ - (slistelm)->field.sle_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.sle_next = (head)->slh_first; \ - (head)->slh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE_HEAD(head, field) do { \ - (head)->slh_first = (head)->slh_first->field.sle_next; \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE(head, elm, type, field) do { \ - if ((head)->slh_first == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = (head)->slh_first; \ - while(curelm->field.sle_next != (elm)) \ - curelm = curelm->field.sle_next; \ - curelm->field.sle_next = \ - curelm->field.sle_next->field.sle_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define SLIST_FOREACH(var, head, field) \ - for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) - -/* - * Singly-linked List access methods. - */ -#define SLIST_EMPTY(head) ((head)->slh_first == NULL) -#define SLIST_FIRST(head) ((head)->slh_first) -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) - - -/* - * Singly-linked Tail queue declarations. - */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first; /* first element */ \ - struct type **stqh_last; /* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -/* - * Singly-linked Tail queue functions. - */ -#define STAILQ_INIT(head) do { \ - (head)->stqh_first = NULL; \ - (head)->stqh_last = &(head)->stqh_first; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (head)->stqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.stqe_next = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &(elm)->field.stqe_next; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (listelm)->field.stqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ - (head)->stqh_last = &(head)->stqh_first; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_REMOVE(head, elm, type, field) do { \ - if ((head)->stqh_first == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->stqh_first; \ - while (curelm->field.stqe_next != (elm)) \ - curelm = curelm->field.stqe_next; \ - if ((curelm->field.stqe_next = \ - curelm->field.stqe_next->field.stqe_next) == NULL) \ - (head)->stqh_last = &(curelm)->field.stqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define STAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->stqh_first); \ - (var); \ - (var) = ((var)->field.stqe_next)) - -#define STAILQ_CONCAT(head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -/* - * Singly-linked Tail queue access methods. - */ -#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) -#define STAILQ_FIRST(head) ((head)->stqh_first) -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) - - -/* - * Simple queue definitions. - */ -#define SIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define SIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define SIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} - -/* - * Simple queue functions. - */ -#define SIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ - if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ - if ((head)->sqh_first == (elm)) { \ - SIMPLEQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->sqh_first; \ - while (curelm->field.sqe_next != (elm)) \ - curelm = curelm->field.sqe_next; \ - if ((curelm->field.sqe_next = \ - curelm->field.sqe_next->field.sqe_next) == NULL) \ - (head)->sqh_last = &(curelm)->field.sqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->sqh_first); \ - (var); \ - (var) = ((var)->field.sqe_next)) - -/* - * Simple queue access methods. - */ -#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) -#define SIMPLEQ_FIRST(head) ((head)->sqh_first) -#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - - -/* - * Tail queue definitions. - */ -#define _TAILQ_HEAD(name, type, qual) \ -struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last; /* addr of last next element */ \ -} -#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) - -#define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define _TAILQ_ENTRY(type, qual) \ -struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev; /* address of previous next element */\ -} -#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) - -/* - * Tail queue functions. - */ -#define TAILQ_INIT(head) do { \ - (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_REMOVE(head, elm, field) do { \ - if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->tqh_first); \ - (var); \ - (var) = ((var)->field.tqe_next)) - -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ - (var); \ - (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) - -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -/* - * Tail queue access methods. - */ -#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) -#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - - -/* - * Circular queue definitions. - */ -#define CIRCLEQ_HEAD(name, type) \ -struct name { \ - struct type *cqh_first; /* first element */ \ - struct type *cqh_last; /* last element */ \ -} - -#define CIRCLEQ_HEAD_INITIALIZER(head) \ - { (void *)&head, (void *)&head } - -#define CIRCLEQ_ENTRY(type) \ -struct { \ - struct type *cqe_next; /* next element */ \ - struct type *cqe_prev; /* previous element */ \ -} - -/* - * Circular queue functions. - */ -#define CIRCLEQ_INIT(head) do { \ - (head)->cqh_first = (void *)(head); \ - (head)->cqh_last = (void *)(head); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - (elm)->field.cqe_next = (listelm)->field.cqe_next; \ - (elm)->field.cqe_prev = (listelm); \ - if ((listelm)->field.cqe_next == (void *)(head)) \ - (head)->cqh_last = (elm); \ - else \ - (listelm)->field.cqe_next->field.cqe_prev = (elm); \ - (listelm)->field.cqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ - (elm)->field.cqe_next = (listelm); \ - (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ - if ((listelm)->field.cqe_prev == (void *)(head)) \ - (head)->cqh_first = (elm); \ - else \ - (listelm)->field.cqe_prev->field.cqe_next = (elm); \ - (listelm)->field.cqe_prev = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.cqe_next = (head)->cqh_first; \ - (elm)->field.cqe_prev = (void *)(head); \ - if ((head)->cqh_last == (void *)(head)) \ - (head)->cqh_last = (elm); \ - else \ - (head)->cqh_first->field.cqe_prev = (elm); \ - (head)->cqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.cqe_next = (void *)(head); \ - (elm)->field.cqe_prev = (head)->cqh_last; \ - if ((head)->cqh_first == (void *)(head)) \ - (head)->cqh_first = (elm); \ - else \ - (head)->cqh_last->field.cqe_next = (elm); \ - (head)->cqh_last = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_REMOVE(head, elm, field) do { \ - if ((elm)->field.cqe_next == (void *)(head)) \ - (head)->cqh_last = (elm)->field.cqe_prev; \ - else \ - (elm)->field.cqe_next->field.cqe_prev = \ - (elm)->field.cqe_prev; \ - if ((elm)->field.cqe_prev == (void *)(head)) \ - (head)->cqh_first = (elm)->field.cqe_next; \ - else \ - (elm)->field.cqe_prev->field.cqe_next = \ - (elm)->field.cqe_next; \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->cqh_first); \ - (var) != (const void *)(head); \ - (var) = ((var)->field.cqe_next)) - -#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ - for ((var) = ((head)->cqh_last); \ - (var) != (const void *)(head); \ - (var) = ((var)->field.cqe_prev)) - -/* - * Circular queue access methods. - */ -#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) -#define CIRCLEQ_FIRST(head) ((head)->cqh_first) -#define CIRCLEQ_LAST(head) ((head)->cqh_last) -#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) -#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) - -#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ - (((elm)->field.cqe_next == (void *)(head)) \ - ? ((head)->cqh_first) \ - : (elm->field.cqe_next)) -#define CIRCLEQ_LOOP_PREV(head, elm, field) \ - (((elm)->field.cqe_prev == (void *)(head)) \ - ? ((head)->cqh_last) \ - : (elm->field.cqe_prev)) - -#endif /* sys/queue.h */ diff --git a/openair3/UTILS/tree.h b/openair3/UTILS/tree.h deleted file mode 100644 index 351df9dfc5..0000000000 --- a/openair3/UTILS/tree.h +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Copyright 2002 Niels Provos - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_TREE_H_ -#define _SYS_TREE_H_ - -/* - * This file defines data structures for different types of trees: - * splay trees and red-black trees. - * - * A splay tree is a self-organizing data structure. Every operation - * on the tree causes a splay to happen. The splay moves the requested - * node to the root of the tree and partly rebalances it. - * - * This has the benefit that request locality causes faster lookups as - * the requested nodes move to the top of the tree. On the other hand, - * every lookup causes memory writes. - * - * The Balance Theorem bounds the total access time for m operations - * and n inserts on an initially empty tree as O((m + n)lg n). The - * amortized cost for a sequence of m accesses to a splay tree is O(lg n); - * - * A red-black tree is a binary search tree with the node color as an - * extra attribute. It fulfills a set of conditions: - * - every search path from the root to a leaf consists of the - * same number of black nodes, - * - each red node (except for the root) has a black parent, - * - each leaf node is black. - * - * Every operation on a red-black tree is bounded as O(lg n). - * The maximum height of a red-black tree is 2lg (n+1). - */ - -#define SPLAY_HEAD(name, type) \ -struct name { \ - struct type *sph_root; /* root of the tree */ \ -} - -#define SPLAY_INITIALIZER(root) \ - { NULL } - -#define SPLAY_INIT(root) do { \ - (root)->sph_root = NULL; \ -} while (0) - -#define SPLAY_ENTRY(type) \ -struct { \ - struct type *spe_left; /* left element */ \ - struct type *spe_right; /* right element */ \ -} - -#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -#define SPLAY_ROOT(head) (head)->sph_root -#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) - -/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (0) - -#define SPLAY_LINKLEFT(head, tmp, field) do { \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -} while (0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do { \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -} while (0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ - SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -} while (0) - -/* Generates prototypes and inline functions */ - -#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -void name##_SPLAY(struct name *, struct type *); \ -void name##_SPLAY_MINMAX(struct name *, int); \ -struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ - \ -/* Finds the node with the same key as elm */ \ -static __inline struct type * \ -name##_SPLAY_FIND(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) \ - return(NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) \ - return (head->sph_root); \ - return (NULL); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -{ \ - name##_SPLAY(head, elm); \ - if (SPLAY_RIGHT(elm, field) != NULL) { \ - elm = SPLAY_RIGHT(elm, field); \ - while (SPLAY_LEFT(elm, field) != NULL) { \ - elm = SPLAY_LEFT(elm, field); \ - } \ - } else \ - elm = NULL; \ - return (elm); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_MIN_MAX(struct name *head, int val) \ -{ \ - name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ -} - -/* Main splay operation. - * Moves node close to the key of elm to top - */ -#define SPLAY_GENERATE(name, type, field, cmp) \ -struct type * \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return ((head)->sph_root); \ - } \ - (head)->sph_root = (elm); \ - return (NULL); \ -} \ - \ -struct type * \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return (NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - return (elm); \ - } \ - return (NULL); \ -} \ - \ -void \ -name##_SPLAY(struct name *head, struct type *elm) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ -\ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ - __left = __right = &__node; \ -\ - while ((__comp = (cmp)(elm, (head)->sph_root))) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) > 0){ \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} \ - \ -/* Splay with either the minimum or the maximum element \ - * Used to find minimum or maximum element in tree. \ - */ \ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ -\ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ - __left = __right = &__node; \ -\ - while (1) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp > 0) { \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} - -#define SPLAY_NEGINF -1 -#define SPLAY_INF 1 - -#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head) \ - for ((x) = SPLAY_MIN(name, head); \ - (x) != NULL; \ - (x) = SPLAY_NEXT(name, head, x)) - -/* Macros that define a red-back tree */ -#define RB_HEAD(name, type) \ -struct name { \ - struct type *rbh_root; /* root of the tree */ \ -} - -#define RB_INITIALIZER(root) \ - { NULL } - -#define RB_INIT(root) do { \ - (root)->rbh_root = NULL; \ -} while (0) - -#define RB_BLACK 0 -#define RB_RED 1 -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} - -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right -#define RB_PARENT(elm, field) (elm)->field.rbe_parent -#define RB_COLOR(elm, field) (elm)->field.rbe_color -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) - -#define RB_SET(elm, parent, field) do { \ - RB_PARENT(elm, field) = parent; \ - RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ - RB_COLOR(elm, field) = RB_RED; \ -} while (0) - -#define RB_SET_BLACKRED(black, red, field) do { \ - RB_COLOR(black, field) = RB_BLACK; \ - RB_COLOR(red, field) = RB_RED; \ -} while (0) - -#ifndef RB_AUGMENT -#define RB_AUGMENT(x) -#endif - -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) { \ - RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_LEFT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) { \ - RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_RIGHT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (0) - -/* Generates prototypes and inline functions */ -#define RB_PROTOTYPE(name, type, field, cmp) \ -void name##_RB_INSERT_COLOR(struct name *, struct type *); \ -void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -struct type *name##_RB_REMOVE(struct name *, struct type *); \ -struct type *name##_RB_INSERT(struct name *, struct type *); \ -struct type *name##_RB_FIND(struct name *, struct type *); \ -struct type *name##_RB_NEXT(struct type *); \ -struct type *name##_RB_MINMAX(struct name *, int); \ - \ - -/* Main rb operation. - * Moves node close to the key of elm to top - */ -#define RB_GENERATE(name, type, field, cmp) \ -void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -{ \ - struct type *parent, *gparent, *tmp; \ - while ((parent = RB_PARENT(elm, field)) && \ - RB_COLOR(parent, field) == RB_RED) { \ - gparent = RB_PARENT(parent, field); \ - if (parent == RB_LEFT(gparent, field)) { \ - tmp = RB_RIGHT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field);\ - elm = gparent; \ - continue; \ - } \ - if (RB_RIGHT(parent, field) == elm) { \ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_RIGHT(head, gparent, tmp, field); \ - } else { \ - tmp = RB_LEFT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field);\ - elm = gparent; \ - continue; \ - } \ - if (RB_LEFT(parent, field) == elm) { \ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_LEFT(head, gparent, tmp, field); \ - } \ - } \ - RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -} \ - \ -void \ -name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ -{ \ - struct type *tmp; \ - while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ - elm != RB_ROOT(head)) { \ - if (RB_LEFT(parent, field) == elm) { \ - tmp = RB_RIGHT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - tmp = RB_RIGHT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ - struct type *oleft; \ - if ((oleft = RB_LEFT(tmp, field)))\ - RB_COLOR(oleft, field) = RB_BLACK;\ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_RIGHT(head, tmp, oleft, field);\ - tmp = RB_RIGHT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_RIGHT(tmp, field)) \ - RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - elm = RB_ROOT(head); \ - break; \ - } \ - } else { \ - tmp = RB_LEFT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - tmp = RB_LEFT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ - struct type *oright; \ - if ((oright = RB_RIGHT(tmp, field)))\ - RB_COLOR(oright, field) = RB_BLACK;\ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_LEFT(head, tmp, oright, field);\ - tmp = RB_LEFT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_LEFT(tmp, field)) \ - RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - elm = RB_ROOT(head); \ - break; \ - } \ - } \ - } \ - if (elm) \ - RB_COLOR(elm, field) = RB_BLACK; \ -} \ - \ -struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *child, *parent, *old = elm; \ - int color; \ - if (RB_LEFT(elm, field) == NULL) \ - child = RB_RIGHT(elm, field); \ - else if (RB_RIGHT(elm, field) == NULL) \ - child = RB_LEFT(elm, field); \ - else { \ - struct type *left; \ - elm = RB_RIGHT(elm, field); \ - while ((left = RB_LEFT(elm, field))) \ - elm = left; \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ - if (RB_PARENT(elm, field) == old) \ - parent = elm; \ - (elm)->field = (old)->field; \ - if (RB_PARENT(old, field)) { \ - if (RB_LEFT(RB_PARENT(old, field), field) == old)\ - RB_LEFT(RB_PARENT(old, field), field) = elm;\ - else \ - RB_RIGHT(RB_PARENT(old, field), field) = elm;\ - RB_AUGMENT(RB_PARENT(old, field)); \ - } else \ - RB_ROOT(head) = elm; \ - RB_PARENT(RB_LEFT(old, field), field) = elm; \ - if (RB_RIGHT(old, field)) \ - RB_PARENT(RB_RIGHT(old, field), field) = elm; \ - if (parent) { \ - left = parent; \ - do { \ - RB_AUGMENT(left); \ - } while ((left = RB_PARENT(left, field))); \ - } \ - goto color; \ - } \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ -color: \ - if (color == RB_BLACK) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - return (old); \ -} \ - \ -/* Inserts a node into the RB tree */ \ -struct type * \ -name##_RB_INSERT(struct name *head, struct type *elm) \ -{ \ - struct type *tmp; \ - struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ - parent = tmp; \ - comp = (cmp)(elm, parent); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - RB_SET(elm, parent, field); \ - if (parent != NULL) { \ - if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - RB_AUGMENT(parent); \ - } else \ - { \ - RB_ROOT(head) = elm; \ - } \ - name##_RB_INSERT_COLOR(head, elm); \ - return (NULL); \ -} \ - \ -/* Finds the node with the same key as elm */ \ -struct type * \ -name##_RB_FIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (NULL); \ -} \ - \ -struct type * \ -name##_RB_NEXT(struct type *elm) \ -{ \ - if (RB_RIGHT(elm, field)) { \ - elm = RB_RIGHT(elm, field); \ - while (RB_LEFT(elm, field)) \ - elm = RB_LEFT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -struct type * \ -name##_RB_MINMAX(struct name *head, int val) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *parent = NULL; \ - while (tmp) { \ - parent = tmp; \ - if (val < 0) \ - tmp = RB_LEFT(tmp, field); \ - else \ - tmp = RB_RIGHT(tmp, field); \ - } \ - return (parent); \ -} - -#define RB_NEGINF -1 -#define RB_INF 1 - -#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) - -#define RB_FOREACH(x, name, head) \ - for ((x) = RB_MIN(name, head); \ - (x) != NULL; \ - (x) = name##_RB_NEXT(x)) - -#endif /* _SYS_TREE_H_ */ From cbd801b6e54b4f8a52a080870aa08bdbd0b161cb Mon Sep 17 00:00:00 2001 From: laurent Date: Tue, 19 May 2020 21:29:13 +0200 Subject: [PATCH 006/149] some cleanup and checks --- cmake_targets/CMakeLists.txt | 8 ++-- cmake_targets/build_oai | 4 ++ cmake_targets/tools/build_helper | 14 ++++--- executables/ocp-gnb.c | 33 +++++++++------ openair1/PHY/LTE_TRANSPORT/transport_extern.h | 2 +- .../NR_TRANSPORT/nr_transport_common_proto.h | 1 + openair1/PHY/NR_TRANSPORT/pucch_rx.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c | 1 + openair1/PHY/phy_extern.h | 33 +++++++-------- openair1/PHY/phy_extern_nr_ue.h | 30 ++++++------- openair1/PHY/phy_extern_ue.h | 33 +++++++-------- openair1/PHY/phy_vars.h | 42 +++++++++---------- openair1/PHY/phy_vars_nr_ue.h | 34 +++++++-------- openair1/PHY/phy_vars_ue.h | 34 +++++++-------- openair2/LAYER2/MAC/mac_extern.h | 2 +- openair2/LAYER2/MAC/pre_processor.c | 1 + openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h | 2 +- openair3/NAS/TOOLS/conf_network.c | 2 +- targets/RT/USER/lte-softmodem.c | 1 + 19 files changed, 145 insertions(+), 134 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 5e5e1a47ec..6b30d4f362 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2439,9 +2439,9 @@ endif (${T_TRACER}) #This rule and the following deal with it. add_custom_command ( OUTPUT ${OPENAIR_DIR}/common/utils/T/T_IDs.h - COMMAND $(MAKE) clean - COMMAND $(MAKE) - COMMAND $(MAKE) check_vcd + COMMAND make clean + COMMAND make + COMMAND make check_vcd WORKING_DIRECTORY ${OPENAIR_DIR}/common/utils/T DEPENDS ${OPENAIR_DIR}/common/utils/T/T_messages.txt ${OPENAIR_DIR}/common/utils/LOG/vcd_signal_dumper.c @@ -3073,7 +3073,7 @@ function(make_driver name dir) endforeach() CONFIGURE_FILE(${OPENAIR_CMAKE}/tools/Kbuild.cmake ${OPENAIR_BIN_DIR}/${name}/Kbuild) add_custom_command(OUTPUT ${name}.ko - COMMAND $(MAKE) -C ${module_build_path} M=${OPENAIR_BIN_DIR}/${name} + COMMAND make -C ${module_build_path} M=${OPENAIR_BIN_DIR}/${name} WORKING_DIRECTORY ${OPENAIR_BIN_DIR}/${name} COMMENT "building ${module}.ko" VERBATIM diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 965dfaea3a..9a5d5f370c 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -408,6 +408,10 @@ function main() { SKIP_SHARED_LIB_FLAG="True" echo_info "Skipping build of shared libraries, rfsimulator, basicsimulator and transport protocol libraries" shift;; + --ninja) + CMAKE_CMD="$CMAKE_CMD -GNinja" + MAKE_CMD=ninja + shift;; -h | --help) print_help exit 1;; diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 8e4ae59a7f..81cf5698f8 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -183,10 +183,14 @@ compilations() { else COV_SCAN_PREFIX="" fi - if [ "$VERBOSE_COMPILE" == "1" ]; then - $COV_SCAN_PREFIX make -j`nproc` $2 VERBOSE=$VERBOSE_COMPILE - else - $COV_SCAN_PREFIX make -j`nproc` $2 + if [ "$MAKE_CMD" != "" ]; then + $MAKE_CMD $2 + else + if [ "$VERBOSE_COMPILE" == "1" ]; then + $COV_SCAN_PREFIX make -j`nproc` $2 VERBOSE=$VERBOSE_COMPILE + else + $COV_SCAN_PREFIX make -j`nproc` $2 + fi fi } > $dlog/$2.$REL.txt 2>&1 @@ -778,7 +782,7 @@ install_asn1c_from_source(){ install_nas_tools() { if [ ! -f .ue.nvram0 ]; then - echo_success "generate .ue_emm.nvram .ue.nvram" + echo_success "generate .ue_emm.nvram .ue.nvram ./nvram --gen -c $1 -o $2" ./nvram --gen -c $1 -o $2 else [ ./nvram -nt .ue.nvram0 -o ./nvram -nt .ue_emm.nvram0 ] && ./nvram --gen -c $1 -o $2 diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index a296e715ab..d963db2096 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -486,34 +486,39 @@ void RCconfig_RU(void) { return; } -int rx_rf(RU_t *ru, int lastReadSz) { - RU_proc_t *proc = &ru->proc; - NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; - void *rxp[ru->nb_rx]; +int rx_rf(RU_proc_t *proc, NR_DL_FRAME_PARMS *fp,int nb_rx, int32_t** rxdata, int lastReadSz, + openair0_device* rfdevice, openair0_timestamp ts_offset) { + void *rxp[nb_rx]; int nextSlot=(proc->tti_rx+1)%fp->slots_per_frame; uint32_t samples_per_slot = fp->get_samples_per_slot(nextSlot,fp); - for (int i=0; inb_rx; i++) - rxp[i] = (void *)&ru->common.rxdata[i][fp->get_samples_slot_timestamp(nextSlot,fp,0)]; + int rxBufOffet=fp->get_samples_slot_timestamp(nextSlot,fp,0); + int controlrxBufOffet=(proc->timestamp_rx+lastReadSz)%fp->samples_per_frame; + AssertFatal(rxBufOffet == controlrxBufOffet && + rxBufOffet+ samples_per_slot <= fp->samples_per_frame, + "inconsistent IQ samples read"); + + for (int i=0; itimestamp_rx; LOG_D(PHY,"Reading %d samples for slot %d (%p)\n",samples_per_slot,nextSlot,rxp[0]); - unsigned int rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, - & proc->timestamp_rx, + unsigned int rxs = rfdevice->trx_read_func(rfdevice, + &proc->timestamp_rx, rxp, samples_per_slot, - ru->nb_rx); + nb_rx); if (rxs != samples_per_slot) LOG_E(PHY, "rx_rf: Asked for %d samples, got %d from USRP\n",samples_per_slot,rxs); // In case we need offset, between RU or any other need // The sync system can put a offset to use betwwen RF boards - proc->timestamp_rx+=ru->ts_offset; + proc->timestamp_rx+=ts_offset; if (lastReadSz && proc->timestamp_rx - old_ts != lastReadSz) LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n", - proc->timestamp_rx - old_ts - samples_per_slot,ru->ts_offset); + proc->timestamp_rx - old_ts - samples_per_slot,ts_offset); return rxs; } @@ -738,10 +743,12 @@ static void *ru_thread( void *param ) { // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices int lastReadSz=0; sf_ahead = (uint16_t) ceil((float)6/(0x01<numerology_index)); + proc->tti_rx=-1; // we increment before each read + openair0_timestamp ts_offset=0; //for multi RU while (!oai_exit) { // synchronization on input FH interface, acquire signals/data and block - lastReadSz=rx_rf(ru, lastReadSz); + lastReadSz=rx_rf(proc, fp, ru->nb_rx,ru->common.rxdata,lastReadSz, &ru->rfdevice, ts_offset); // do RX front-end processing (frequency-shift, dft) if needed proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; @@ -824,7 +831,7 @@ void launch_NR_RU(char *rf_config_file) { } } -void init_eNB_afterRU() { +void init_eNB_afterRU(void) { AssertFatal(false,""); } diff --git a/openair1/PHY/LTE_TRANSPORT/transport_extern.h b/openair1/PHY/LTE_TRANSPORT/transport_extern.h index 357d31ca10..8b33449cca 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_extern.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_extern.h @@ -22,7 +22,7 @@ extern unsigned int dlsch_tbs25[27][25],TBStable[27][110],TBStable1C[32]; extern unsigned short lte_cqi_eff1024[16]; extern char lte_cqi_snr_dB[15]; -extern short conjugate[8],conjugate2[8]; +extern const short conjugate[8],conjugate2[8]; extern short minus_one[8]; extern short minus_one[8]; extern short *ul_ref_sigs[30][2][34]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 85f3c00b90..ab5b0c38ac 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -61,4 +61,5 @@ uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch, uint8_t nb_re_dmrs, uint uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r); +void init_pucch2_luts(void); #endif diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 62ced5af9d..ee8657ed22 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -263,7 +263,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, } #else - int16_t *x_re = table_5_2_2_2_2_Re[u],*x_im = table_5_2_2_2_2_Im[u]; + const int16_t *x_re = table_5_2_2_2_2_Re[u],*x_im = table_5_2_2_2_2_Im[u]; int16_t xr[24] __attribute__((aligned(32))); int16_t xrt[24] __attribute__((aligned(32))); int32_t xrtmag=0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 2a08d54c5a..c8f7268d04 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -38,6 +38,7 @@ #include "PHY/NR_UE_TRANSPORT/pucch_nr.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" +#include #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" diff --git a/openair1/PHY/phy_extern.h b/openair1/PHY/phy_extern.h index deb7087c8c..165ed961b3 100644 --- a/openair1/PHY/phy_extern.h +++ b/openair1/PHY/phy_extern.h @@ -38,7 +38,7 @@ extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; extern unsigned int DAQ_MBOX; extern int number_of_cards; -extern short conjugate[8],conjugate2[8]; +extern const short conjugate[8],conjugate2[8]; extern RAN_CONTEXT_t RC; @@ -73,8 +73,8 @@ extern int flag_LA; extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX]; extern double sinr_bler_map_up[MCS_COUNT][2][16]; extern int table_length[MCS_COUNT]; -extern double sinr_to_cqi[4][16]; -extern int cqi_to_mcs[16]; +extern const double sinr_to_cqi[4][16]; +extern const int cqi_to_mcs[16]; //for MU-MIMO abstraction using MIESM //this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively @@ -82,23 +82,22 @@ extern double MI_map_4qam[3][162]; extern double MI_map_16qam[3][197]; extern double MI_map_64qam[3][227]; -extern double beta1_dlsch_MI[6][MCS_COUNT]; -extern double beta2_dlsch_MI[6][MCS_COUNT]; +extern const double beta1_dlsch_MI[6][MCS_COUNT]; +extern const double beta2_dlsch_MI[6][MCS_COUNT]; -extern double q_qpsk[8]; -extern double q_qam16[8]; -extern double q_qam64[8]; +extern const double q_qpsk[8]; +extern const double q_qam16[8]; +extern const double q_qam64[8]; +extern const double p_qpsk[8]; +extern const double p_qam16[8]; +extern const double p_qam64[8]; -extern double p_qpsk[8]; -extern double p_qam16[8]; -extern double p_qam64[8]; +extern const double beta1_dlsch[6][MCS_COUNT]; +extern const double beta2_dlsch[6][MCS_COUNT]; -extern double beta1_dlsch[6][MCS_COUNT]; -extern double beta2_dlsch[6][MCS_COUNT]; - -extern char NB_functions[7][20]; -extern char NB_timing[2][20]; -extern char ru_if_types[MAX_RU_IF_TYPES][20]; +extern const char NB_functions[7][20]; +extern const char NB_timing[2][20]; +extern const char ru_if_types[MAX_RU_IF_TYPES][20]; extern int16_t unscrambling_lut[65536*16]; extern uint8_t scrambling_lut[65536*16]; diff --git a/openair1/PHY/phy_extern_nr_ue.h b/openair1/PHY/phy_extern_nr_ue.h index 569bec6851..2f2a0427f4 100644 --- a/openair1/PHY/phy_extern_nr_ue.h +++ b/openair1/PHY/phy_extern_nr_ue.h @@ -34,7 +34,7 @@ extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; //#include "PHY/LTE_TRANSPORT/transport_extern.h" -extern short conjugate[8],conjugate2[8]; +extern const short conjugate[8],conjugate2[8]; extern int number_of_cards; @@ -70,8 +70,8 @@ extern int flag_LA; extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX]; extern double sinr_bler_map_up[MCS_COUNT][2][16]; extern int table_length[MCS_COUNT]; -extern double sinr_to_cqi[4][16]; -extern int cqi_to_mcs[16]; +extern const double sinr_to_cqi[4][16]; +extern const int cqi_to_mcs[16]; //for MU-MIMO abstraction using MIESM //this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively @@ -79,23 +79,19 @@ extern double MI_map_4qam[3][162]; extern double MI_map_16qam[3][197]; extern double MI_map_64qam[3][227]; -extern double beta1_dlsch_MI[6][MCS_COUNT]; -extern double beta2_dlsch_MI[6][MCS_COUNT]; +extern const double beta1_dlsch_MI[6][MCS_COUNT]; +extern const double beta2_dlsch_MI[6][MCS_COUNT]; -extern double q_qpsk[8]; -extern double q_qam16[8]; -extern double q_qam64[8]; +extern const double q_qpsk[8]; +extern const double q_qam16[8]; +extern const double q_qam64[8]; -extern double p_qpsk[8]; -extern double p_qam16[8]; -extern double p_qam64[8]; +extern const double beta1_dlsch[6][MCS_COUNT]; +extern const double beta2_dlsch[6][MCS_COUNT]; -extern double beta1_dlsch[6][MCS_COUNT]; -extern double beta2_dlsch[6][MCS_COUNT]; - -extern char NB_functions[7][20]; -extern char NB_timing[2][20]; -extern char ru_if_types[MAX_RU_IF_TYPES][20]; +extern const char NB_functions[7][20]; +extern const char NB_timing[2][20]; +extern const char ru_if_types[MAX_RU_IF_TYPES][20]; extern int16_t unscrambling_lut[65536*16]; extern uint8_t scrambling_lut[65536*16]; diff --git a/openair1/PHY/phy_extern_ue.h b/openair1/PHY/phy_extern_ue.h index 4f9ed0f26b..71ca20705e 100644 --- a/openair1/PHY/phy_extern_ue.h +++ b/openair1/PHY/phy_extern_ue.h @@ -36,9 +36,6 @@ extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; extern int number_of_cards; -extern short conjugate[8],conjugate2[8]; - - extern PHY_VARS_UE ***PHY_vars_UE_g; extern short primary_synch0[144]; @@ -70,8 +67,8 @@ extern int flag_LA; extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX]; extern double sinr_bler_map_up[MCS_COUNT][2][16]; extern int table_length[MCS_COUNT]; -extern double sinr_to_cqi[4][16]; -extern int cqi_to_mcs[16]; +extern const double sinr_to_cqi[4][16]; +extern const int cqi_to_mcs[16]; //for MU-MIMO abstraction using MIESM //this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively @@ -79,23 +76,23 @@ extern double MI_map_4qam[3][162]; extern double MI_map_16qam[3][197]; extern double MI_map_64qam[3][227]; -extern double beta1_dlsch_MI[6][MCS_COUNT]; -extern double beta2_dlsch_MI[6][MCS_COUNT]; +extern const double beta1_dlsch_MI[6][MCS_COUNT]; +extern const double beta2_dlsch_MI[6][MCS_COUNT]; -extern double q_qpsk[8]; -extern double q_qam16[8]; -extern double q_qam64[8]; +extern const double q_qpsk[8]; +extern const double q_qam16[8]; +extern const double q_qam64[8]; -extern double p_qpsk[8]; -extern double p_qam16[8]; -extern double p_qam64[8]; +extern const double p_qpsk[8]; +extern const double p_qam16[8]; +extern const double p_qam64[8]; -extern double beta1_dlsch[6][MCS_COUNT]; -extern double beta2_dlsch[6][MCS_COUNT]; +extern const double beta1_dlsch[6][MCS_COUNT]; +extern const double beta2_dlsch[6][MCS_COUNT]; -extern char NB_functions[7][20]; -extern char NB_timing[2][20]; -extern char ru_if_types[MAX_RU_IF_TYPES][20]; +extern const char NB_functions[7][20]; +extern const char NB_timing[2][20]; +extern const char ru_if_types[MAX_RU_IF_TYPES][20]; extern int16_t unscrambling_lut[65536*16]; extern uint8_t scrambling_lut[65536*16]; diff --git a/openair1/PHY/phy_vars.h b/openair1/PHY/phy_vars.h index 26540f6fc8..2cf5cbda04 100644 --- a/openair1/PHY/phy_vars.h +++ b/openair1/PHY/phy_vars.h @@ -50,8 +50,8 @@ unsigned short rev[2048],rev_times4[8192],rev_half[1024]; unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192]; -short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; -short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; +const short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; +const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; #include "SIMULATION/ETH_TRANSPORT/vars.h" @@ -59,10 +59,10 @@ short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; unsigned char NB_RU=0; #ifndef OPENAIR2 -unsigned char NB_eNB_INST=0; -uint16_t NB_UE_INST=0; -unsigned char NB_RN_INST=0; -unsigned char NB_INST=0; +//unsigned char NB_eNB_INST=0; +//uint16_t NB_UE_INST=0; +//unsigned char NB_RN_INST=0; +//unsigned char NB_INST=0; #endif int number_of_cards; @@ -84,29 +84,29 @@ double MI_map_16qam[3][197]; double MI_map_64qam[3][227]; // here the first index is for transmission mode 1, 2, 5 and 6 whereas the second index is for the 16 sinr vaues corresponding to 16 CQIs -double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424}, +const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424}, {-2.2360, -2.2360, -1.3919, -0.0218, 1.5319, 2.9574, 4.3234, 6.3387, 8.9879, 9.5096, 12.6609, 14.0116, 16.4984, 18.1572, 18.1572, 18.1572}, {-1, -1.0000, -0.4198, -0.0140, 1.0362, 2.3520, 3.5793, 6.1136, 8.4836, 9.0858, 12.4723, 13.9128, 16.2054, 17.7392, 17.7392, 17.7392}, { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545} }; //int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27}; -int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; +const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; //for SNR to MI conversion 7 th order Polynomial coeff -double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; -double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; -double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898}; +const double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; +const double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; +const double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898}; //for MI to SNR conversion 7 th order Polynomial coeff -double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965}; -double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089}; -double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343}; +const double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965}; +const double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089}; +const double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343}; // ideal CE MIESM -double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,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.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}}; -double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,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.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}}; +const double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,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.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}}; +const double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,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.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}}; //real CE MIESM /* @@ -116,8 +116,8 @@ double beta2_dlsch_MI[6][MCS_COUNT] = { {1.36875, 0.59304, 0.53870, 0.98239, 0.8 //ideal channel estimation values //double beta1_dlsch[6][MCS_COUNT] = { {2.3814, 0.4956, 0.5273, 1.1708, 0.8014, 0.7889, 0.8111, 0.8139, 0.8124, 0.8479, 1.9280, 1.9664, 2.3857, 2.5147, 2.4511, 3.0158, 2.8643, 5.3013, 5.8594, 6.5372, 7.8073, 7.8030, 7.5295, 7.1320}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; //double beta2_dlsch[6][MCS_COUNT] = { {2.3639, 0.4952, 0.5207, 1.1572, 0.8026, 0.7864, 0.7996, 0.8034, 0.8200, 0.8367, 1.8701, 1.9212, 2.2947, 2.4472, 2.4091, 2.9479, 2.8973, 5.0591, 5.5134, 6.1483, 7.2166, 7.5177, 7.5704, 7.2248}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; -double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; -double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; +const double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; +const double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; //real channel estimation valus /* @@ -129,9 +129,9 @@ double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.1682 #ifdef OCP_FRAMEWORK #include #else -char NB_functions[7][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5","gNodeB_3GPP",}; -char NB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; -char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; +const char NB_functions[7][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5","gNodeB_3GPP",}; +const char NB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; +const char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; #endif /// lookup table for unscrambling in RX diff --git a/openair1/PHY/phy_vars_nr_ue.h b/openair1/PHY/phy_vars_nr_ue.h index 479e42345a..8feb21c2aa 100644 --- a/openair1/PHY/phy_vars_nr_ue.h +++ b/openair1/PHY/phy_vars_nr_ue.h @@ -49,8 +49,8 @@ unsigned short rev[2048],rev_times4[8192],rev_half[1024]; unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192]; -short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; -short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; +const short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; +const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; #include "SIMULATION/ETH_TRANSPORT/vars.h" @@ -84,29 +84,29 @@ double MI_map_16qam[3][197]; double MI_map_64qam[3][227]; // here the first index is for transmission mode 1, 2, 5 and 6 whereas the second index is for the 16 sinr vaues corresponding to 16 CQIs -double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424}, +const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424}, {-2.2360, -2.2360, -1.3919, -0.0218, 1.5319, 2.9574, 4.3234, 6.3387, 8.9879, 9.5096, 12.6609, 14.0116, 16.4984, 18.1572, 18.1572, 18.1572}, {-1, -1.0000, -0.4198, -0.0140, 1.0362, 2.3520, 3.5793, 6.1136, 8.4836, 9.0858, 12.4723, 13.9128, 16.2054, 17.7392, 17.7392, 17.7392}, { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545} }; //int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27}; -int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; +const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; //for SNR to MI conversion 7 th order Polynomial coeff -double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; -double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; -double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898}; +const double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; +const double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; +const double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898}; //for MI to SNR conversion 7 th order Polynomial coeff -double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965}; -double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089}; -double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343}; +const double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965}; +const double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089}; +const double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343}; // ideal CE MIESM -double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,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.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}}; -double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,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.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}}; +const double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,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.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}}; +const double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,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.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}}; //real CE MIESM /* @@ -116,8 +116,8 @@ double beta2_dlsch_MI[6][MCS_COUNT] = { {1.36875, 0.59304, 0.53870, 0.98239, 0.8 //ideal channel estimation values //double beta1_dlsch[6][MCS_COUNT] = { {2.3814, 0.4956, 0.5273, 1.1708, 0.8014, 0.7889, 0.8111, 0.8139, 0.8124, 0.8479, 1.9280, 1.9664, 2.3857, 2.5147, 2.4511, 3.0158, 2.8643, 5.3013, 5.8594, 6.5372, 7.8073, 7.8030, 7.5295, 7.1320}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; //double beta2_dlsch[6][MCS_COUNT] = { {2.3639, 0.4952, 0.5207, 1.1572, 0.8026, 0.7864, 0.7996, 0.8034, 0.8200, 0.8367, 1.8701, 1.9212, 2.2947, 2.4472, 2.4091, 2.9479, 2.8973, 5.0591, 5.5134, 6.1483, 7.2166, 7.5177, 7.5704, 7.2248}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; -double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; -double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; +const double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; +const double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; //real channel estimation valus /* @@ -129,9 +129,9 @@ double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.1682 #ifdef OCP_FRAMEWORK #include #else -char NB_functions[7][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5","gNodeB_3GPP",}; -char NB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; -char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; +const char NB_functions[7][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5","gNodeB_3GPP",}; +const char NB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; +const char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; #endif /// lookup table for unscrambling in RX diff --git a/openair1/PHY/phy_vars_ue.h b/openair1/PHY/phy_vars_ue.h index 52d4ba543b..310c7331c4 100644 --- a/openair1/PHY/phy_vars_ue.h +++ b/openair1/PHY/phy_vars_ue.h @@ -43,8 +43,8 @@ unsigned short rev[2048],rev_times4[8192],rev_half[1024]; unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192]; -short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; -short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; +const short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; +const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; #include "SIMULATION/ETH_TRANSPORT/vars.h" @@ -77,29 +77,29 @@ double MI_map_16qam[3][197]; double MI_map_64qam[3][227]; // here the first index is for transmission mode 1, 2, 5 and 6 whereas the second index is for the 16 sinr vaues corresponding to 16 CQIs -double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424}, +const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424}, {-2.2360, -2.2360, -1.3919, -0.0218, 1.5319, 2.9574, 4.3234, 6.3387, 8.9879, 9.5096, 12.6609, 14.0116, 16.4984, 18.1572, 18.1572, 18.1572}, {-1, -1.0000, -0.4198, -0.0140, 1.0362, 2.3520, 3.5793, 6.1136, 8.4836, 9.0858, 12.4723, 13.9128, 16.2054, 17.7392, 17.7392, 17.7392}, { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545} }; //int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27}; -int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; +const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; //for SNR to MI conversion 7 th order Polynomial coeff -double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; -double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; -double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898}; +const double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; +const double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; +const double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898}; //for MI to SNR conversion 7 th order Polynomial coeff -double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965}; -double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089}; -double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343}; +const double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965}; +const double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089}; +const double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343}; // ideal CE MIESM -double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,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.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}}; -double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,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.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}}; +const double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,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.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}}; +const double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,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.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}}; //real CE MIESM /* @@ -109,8 +109,8 @@ double beta2_dlsch_MI[6][MCS_COUNT] = { {1.36875, 0.59304, 0.53870, 0.98239, 0.8 //ideal channel estimation values //double beta1_dlsch[6][MCS_COUNT] = { {2.3814, 0.4956, 0.5273, 1.1708, 0.8014, 0.7889, 0.8111, 0.8139, 0.8124, 0.8479, 1.9280, 1.9664, 2.3857, 2.5147, 2.4511, 3.0158, 2.8643, 5.3013, 5.8594, 6.5372, 7.8073, 7.8030, 7.5295, 7.1320}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; //double beta2_dlsch[6][MCS_COUNT] = { {2.3639, 0.4952, 0.5207, 1.1572, 0.8026, 0.7864, 0.7996, 0.8034, 0.8200, 0.8367, 1.8701, 1.9212, 2.2947, 2.4472, 2.4091, 2.9479, 2.8973, 5.0591, 5.5134, 6.1483, 7.2166, 7.5177, 7.5704, 7.2248}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; -double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; -double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; +const double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; +const double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; //real channel estimation valus /* @@ -122,9 +122,9 @@ double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.1682 #ifdef OCP_FRAMEWORK #include #else -char NB_functions[7][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5","gNodeB_3GPP",}; -char NB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; -char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; +const char NB_functions[7][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5","gNodeB_3GPP",}; +const char NB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; +const char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; #endif /// lookup table for unscrambling in RX diff --git a/openair2/LAYER2/MAC/mac_extern.h b/openair2/LAYER2/MAC/mac_extern.h index dbf5b57b6b..cee6066a9e 100644 --- a/openair2/LAYER2/MAC/mac_extern.h +++ b/openair2/LAYER2/MAC/mac_extern.h @@ -60,7 +60,7 @@ extern uint16_t NB_THREAD_INST; extern unsigned char NB_RN_INST; extern unsigned short NODE_ID[1]; -extern int cqi_to_mcs[16]; +extern const int cqi_to_mcs[16]; extern uint32_t RRC_CONNECTION_FLAG; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index c4dd6b8419..8569d8f166 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -36,6 +36,7 @@ #include "LAYER2/MAC/mac.h" #include "LAYER2/MAC/mac_proto.h" #include "LAYER2/MAC/mac_extern.h" +#include #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h index 2cfce4766f..63c81def82 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h @@ -45,7 +45,7 @@ extern const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]; extern UE_RRC_INST *UE_rrc_inst; extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 -extern int cqi_to_mcs[16]; +extern const int cqi_to_mcs[16]; extern uint32_t RRC_CONNECTION_FLAG; extern uint8_t rb_table[34]; extern mac_rlc_am_muilist_t rlc_am_mui; diff --git a/openair3/NAS/TOOLS/conf_network.c b/openair3/NAS/TOOLS/conf_network.c index 7e71c9b4ee..054189a130 100644 --- a/openair3/NAS/TOOLS/conf_network.c +++ b/openair3/NAS/TOOLS/conf_network.c @@ -43,7 +43,7 @@ void gen_network_record_from_conf(const plmn_conf_param_t *conf, network_record_ strcpy(record->fullname, conf->fullname); strcpy(record->shortname, conf->shortname); - char num[6]; + char num[60]; sprintf(num, "%s%s", conf->mcc, conf->mnc); record->num = atoi(num); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 00ccb9b676..8f49116a11 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -660,6 +660,7 @@ int main ( int argc, char **argv ) initTpool("n", L1proc->threadPool, true); initNotifiedFIFO(L1proc->respEncode); initNotifiedFIFO(L1proc->respDecode); + RC.eNB[x][CC_id]->proc.L1_proc_tx.threadPool=L1proc->threadPool; } From 62f9e7b5e7fec580828d8aa5f754a854531cf510 Mon Sep 17 00:00:00 2001 From: laurent Date: Tue, 2 Jun 2020 10:35:17 +0200 Subject: [PATCH 007/149] remove all usage of RC.ru global var in ocp-gnb and nr-uesoftmodem --- cmake_targets/CMakeLists.txt | 14 +- cmake_targets/tools/build_helper | 3 +- common/ran_context.h | 1 + executables/ocp-gnb.c | 281 ++++++++---------- nfapi/oai_integration/nfapi_pnf.c | 6 - .../PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c | 12 +- openair1/PHY/LTE_ESTIMATION/lte_estimation.h | 17 +- .../lte_ul_channel_estimation.c | 28 +- openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 2 + .../PHY/LTE_TRANSPORT/ulsch_demodulation.c | 6 +- openair1/PHY/TOOLS/nr_phy_scope.c | 11 +- openair1/PHY/TOOLS/nr_phy_scope.h | 11 +- openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- openair1/SCHED/ru_procedures.c | 8 +- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 2 + .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 2 + openair2/ENB_APP/flexran_agent_extern.h | 9 +- targets/ARCH/rfsimulator/simulator.c | 45 +-- 18 files changed, 208 insertions(+), 252 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 6b30d4f362..8520570494 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1593,6 +1593,7 @@ add_library(PHY_COMMON ${PHY_SRC_COMMON}) add_dependencies(PHY_COMMON rrc_flag) add_dependencies(PHY_COMMON dfts) add_library(PHY ${PHY_SRC}) + add_dependencies(PHY rrc_flag) add_library(PHY_UE ${PHY_SRC_UE}) add_dependencies(PHY_UE rrc_flag) @@ -2417,7 +2418,7 @@ target_link_libraries(gnbscope ${XFORMS_LIBRARIES}) add_library(rfsimulator MODULE ${OPENAIR_TARGETS}/ARCH/rfsimulator/simulator.c ) -target_link_libraries(rfsimulator SIMU ${ATLAS_LIBRARIES}) +target_link_libraries(rfsimulator ${ATLAS_LIBRARIES}) add_library(oai_iqplayer MODULE ${OPENAIR_TARGETS}/ARCH/iqplayer/iqplayer_lib.c @@ -2711,7 +2712,7 @@ add_executable(ocp-gnb target_link_libraries (ocp-gnb -Wl,--start-group UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA - ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB + ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB} -Wl,--end-group z dl) @@ -2720,7 +2721,7 @@ target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES}) target_link_libraries (ocp-gnb pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (ocp-gnb ${LIB_LMS_LIBRARIES}) target_link_libraries (ocp-gnb ${T_LIB}) -add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) +add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc params_libconfig rfsimulator oai_usrpdevif) # nr-uesoftmodem is UE implementation @@ -2853,6 +2854,7 @@ target_link_libraries(ldpctest add_executable(nr_dlschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c ${OPENAIR_DIR}/common/utils/system.c + ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) @@ -2864,6 +2866,7 @@ target_link_libraries(nr_dlschsim add_executable(nr_pbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c ${OPENAIR_DIR}/common/utils/system.c + ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) @@ -2878,6 +2881,7 @@ add_executable(nr_pucchsim ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/system.c + ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) @@ -2891,6 +2895,7 @@ add_executable(nr_dlsim ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/executables/softmodem-common.c + ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) @@ -2905,6 +2910,7 @@ add_executable(nr_prachsim ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR1_DIR}/SCHED_NR/phy_procedures_nr_common.c + ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES}) target_link_libraries(nr_prachsim @@ -2913,6 +2919,7 @@ target_link_libraries(nr_prachsim add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c ${OPENAIR_DIR}/common/utils/system.c + ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) @@ -2926,6 +2933,7 @@ add_executable(nr_ulsim ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/executables/softmodem-common.c + ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 81cf5698f8..361f2075e1 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -623,6 +623,7 @@ check_install_oai_software() { build-essential \ cmake \ cmake-curses-gui \ + ninja-build \ doxygen \ doxygen-gui \ texlive-latex-base \ @@ -782,7 +783,7 @@ install_asn1c_from_source(){ install_nas_tools() { if [ ! -f .ue.nvram0 ]; then - echo_success "generate .ue_emm.nvram .ue.nvram ./nvram --gen -c $1 -o $2" + echo_success "generate .ue_emm.nvram .ue.nvram" ./nvram --gen -c $1 -o $2 else [ ./nvram -nt .ue.nvram0 -o ./nvram -nt .ue_emm.nvram0 ] && ./nvram --gen -c $1 -o $2 diff --git a/common/ran_context.h b/common/ran_context.h index 8262f5dd55..e8d8ed0653 100644 --- a/common/ran_context.h +++ b/common/ran_context.h @@ -110,6 +110,7 @@ typedef struct { /// GTPu descriptor gtpv1u_data_t *gtpv1u_data_g; /// RU descriptors. These describe what each radio unit is supposed to do and contain the necessary functions for fronthaul interfaces + // LTS: not coherent (xxx_frame_parms cardinatlity wtih xNB (so one carrier)) struct RU_t_s **ru; /// Mask to indicate fronthaul setup status of RU (hard-limit to 64 RUs) uint64_t ru_mask; diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index d963db2096..4cef3eac6e 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -90,6 +90,16 @@ time_stats_t softmodem_stats_rxtx_sf; // total tx time time_stats_t nfapi_meas; // total tx time time_stats_t softmodem_stats_rx_sf; // total rx time +AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]; +AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]; +int flexran_agent_start(mid_t mod_id) { + memset (agent_rrc_xface, 0, sizeof(agent_rrc_xface)); + memset (agent_mac_xface, 0, sizeof(agent_mac_xface)); + return 0; +} +void flexran_agent_slice_update(mid_t module_idP) { +} + int split73=0; void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { AssertFatal(false, "Must not be called in this context\n"); @@ -130,20 +140,20 @@ static inline int rxtx(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { oai_subframe_ind(proc->frame_rx, proc->slot_rx); stop_meas(&nfapi_meas); /*if (gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus|| - gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs || - gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs || - gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles || - gNB->UL_INFO.cqi_ind.number_of_cqis - ) { + gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs || + gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs || + gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles || + gNB->UL_INFO.cqi_ind.number_of_cqis + ) { LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d preambles:%05d:%d cqis:%d] RX:%04d%d TX:%04d%d \n", - NFAPI_SFNSF2DEC(gNB->UL_INFO.rx_ind.sfn_sf), gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, - NFAPI_SFNSF2DEC(gNB->UL_INFO.harq_ind.sfn_sf), gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, - NFAPI_SFNSF2DEC(gNB->UL_INFO.crc_ind.sfn_sf), gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, - NFAPI_SFNSF2DEC(gNB->UL_INFO.rach_ind.sfn_sf), gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, - gNB->UL_INFO.cqi_ind.number_of_cqis, - frame_rx, slot_rx, - frame_tx, slot_tx); - }*/ + NFAPI_SFNSF2DEC(gNB->UL_INFO.rx_ind.sfn_sf), gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, + NFAPI_SFNSF2DEC(gNB->UL_INFO.harq_ind.sfn_sf), gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, + NFAPI_SFNSF2DEC(gNB->UL_INFO.crc_ind.sfn_sf), gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, + NFAPI_SFNSF2DEC(gNB->UL_INFO.rach_ind.sfn_sf), gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, + gNB->UL_INFO.cqi_ind.number_of_cqis, + frame_rx, slot_rx, + frame_tx, slot_tx); + }*/ } /// NR disabling @@ -240,15 +250,12 @@ void init_gNB_proc(int inst) { /// eNB kept in function name for nffapi calls, TO FIX void init_gNB_phase2(void) { - int inst,ru_id,i,aa; + int inst; LOG_I(PHY,"%s() RC.nb_nr_inst:%d\n", __FUNCTION__, RC.nb_nr_inst); for (inst=0; instRU_list[0] = RC.ru[0]; - gNB->num_RU=1; - RC.ru[0]->nr_frame_parms=&RC.gNB[inst]->frame_parms; LOG_E(PHY,"hard coded gNB->num_RU:%d\n", gNB->num_RU); phy_init_nr_gNB(gNB,0,0); //init_precoding_weights(RC.gNB[inst][CC_id]); @@ -262,9 +269,9 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { gNB->abstraction_flag = false; gNB->single_thread_flag = true; /*nr_polar_init(&gNB->nrPolar_params, - NR_POLAR_PBCH_MESSAGE_TYPE, - NR_POLAR_PBCH_PAYLOAD_BITS, - NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ + NR_POLAR_PBCH_MESSAGE_TYPE, + NR_POLAR_PBCH_PAYLOAD_BITS, + NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ LOG_I(PHY,"Registering with MAC interface module\n"); AssertFatal((gNB->if_inst = NR_IF_Module_init(inst))!=NULL,"Cannot register interface"); gNB->if_inst->NR_Schedule_response = nr_schedule_response; @@ -276,9 +283,9 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { gNB->UL_INFO.rx_ind.pdu_list = gNB->rx_pdu_list; gNB->UL_INFO.crc_ind.crc_list = gNB->crc_pdu_list; /*gNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = gNB->sr_pdu_list; - gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list; - gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list; - gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;*/ + gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list; + gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list; + gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;*/ gNB->prach_energy_counter = 0; } @@ -331,13 +338,13 @@ static void init_pdcp(void) { pdcp_module_init(pdcp_initmask); /*if (NODE_IS_CU(RC.rrc[0]->node_type)) { pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); - } else {*/ + } else {*/ pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); //} /*} else { pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); - }*/ + }*/ } void init_main_gNB(void) { @@ -369,134 +376,99 @@ static void wait_nfapi_init(char *thread_name) { } void exit_function(const char *file, const char *function, const int line, const char *s) { - int ru_id; - if (s != NULL) { printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s); } oai_exit = 1; - - if (RC.ru == NULL) - exit(-1); // likely init not completed, prevent crash or hang, exit now... - - for (ru_id=0; ru_idrfdevice.trx_end_func) { - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - RC.ru[ru_id]->rfdevice.trx_end_func = NULL; - } - - if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) { - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - RC.ru[ru_id]->ifdevice.trx_end_func = NULL; - } - } - sleep(1); //allow lte-softmodem threads to exit first exit(1); } void stop_RU(int nb_ru) { + return; } -void RCconfig_RU(void) { - int i = 0, j = 0; +void OCPconfig_RU(RU_t *ru) { + int i = 0, j = 0; // Ru and gNB cardinality paramdef_t RUParams[] = RUPARAMS_DESC; paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; config_getlist( &RUParamList, RUParams, sizeof(RUParams)/sizeof(paramdef_t), NULL); + AssertFatal( RUParamList.numelt == 1 && RC.nb_nr_L1_inst ==1,"" ); + printf("Set RU mask to %lx\n",RC.ru_mask); + ru->idx=0; + ru->nr_frame_parms = (NR_DL_FRAME_PARMS *)malloc(sizeof(NR_DL_FRAME_PARMS)); + ru->frame_parms = (LTE_DL_FRAME_PARMS *)malloc(sizeof(LTE_DL_FRAME_PARMS)); + ru->if_timing = synch_to_ext_device; + ru->num_gNB = RUParamList.paramarray[j][RU_ENB_LIST_IDX].numelt; + ru->gNB_list[i] = &RC.gNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; - if ( RUParamList.numelt > 0) { - RC.ru = (RU_t **)malloc(RC.nb_RU*sizeof(RU_t *)); - RC.ru_mask=(1<openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr)); + } - for (j = 0; j < RC.nb_RU; j++) { - RC.ru[j] = (RU_t *)malloc(sizeof(RU_t)); - memset((void *)RC.ru[j],0,sizeof(RU_t)); - RC.ru[j]->idx = j; - RC.ru[j]->nr_frame_parms = (NR_DL_FRAME_PARMS *)malloc(sizeof(NR_DL_FRAME_PARMS)); - RC.ru[j]->frame_parms = (LTE_DL_FRAME_PARMS *)malloc(sizeof(LTE_DL_FRAME_PARMS)); - printf("Creating RC.ru[%d]:%p\n", j, RC.ru[j]); - RC.ru[j]->if_timing = synch_to_ext_device; - - if (RC.nb_nr_L1_inst >0) - RC.ru[j]->num_gNB = RUParamList.paramarray[j][RU_ENB_LIST_IDX].numelt; - else - RC.ru[j]->num_gNB = 0; - - for (i=0; inum_gNB; i++) RC.ru[j]->gNB_list[i] = &RC.gNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; - - if (config_isparamset(RUParamList.paramarray[j], RU_SDR_ADDRS)) { - RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr)); - } - - if (config_isparamset(RUParamList.paramarray[j], RU_SDR_CLK_SRC)) { - if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "internal") == 0) { - RC.ru[j]->openair0_cfg.clock_source = internal; - LOG_D(PHY, "RU clock source set as internal\n"); - } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "external") == 0) { - RC.ru[j]->openair0_cfg.clock_source = external; - LOG_D(PHY, "RU clock source set as external\n"); - } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "gpsdo") == 0) { - RC.ru[j]->openair0_cfg.clock_source = gpsdo; - LOG_D(PHY, "RU clock source set as gpsdo\n"); - } else { - LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr)); - } - } else { - RC.ru[j]->openair0_cfg.clock_source = unset; - } - - if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { - if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = gNodeB_3GPP; - printf("Setting function for RU %d to gNodeB_3GPP\n",j); - } else { - } - - RC.ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; - RC.ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); - RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; - - for (i=0; inum_bands; i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; - } //strcmp(local_rf, "yes") == 0 - else { - } - - RC.ru[j]->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); - RC.ru[j]->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); - RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); - RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); - - if (config_isparamset(RUParamList.paramarray[j], RU_BF_WEIGHTS_LIST_IDX)) { - RC.ru[j]->nb_bfw = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].numelt; - - for (i=0; inum_gNB; i++) { - RC.ru[j]->bw_list[i] = (int32_t *)malloc16_clear((RC.ru[j]->nb_bfw)*sizeof(int32_t)); - - for (int b=0; bnb_bfw; b++) RC.ru[j]->bw_list[i][b] = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].iptr[b]; - } - } - }// j=0..num_rus + if (config_isparamset(RUParamList.paramarray[j], RU_SDR_CLK_SRC)) { + if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "internal") == 0) { + ru->openair0_cfg.clock_source = internal; + LOG_D(PHY, "RU clock source set as internal\n"); + } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "external") == 0) { + ru->openair0_cfg.clock_source = external; + LOG_D(PHY, "RU clock source set as external\n"); + } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "gpsdo") == 0) { + ru->openair0_cfg.clock_source = gpsdo; + LOG_D(PHY, "RU clock source set as gpsdo\n"); + } else { + LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr)); + } } else { - RC.nb_RU = 0; - } // setting != NULL + ru->openair0_cfg.clock_source = unset; + } + + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { + if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { + ru->if_south = LOCAL_RF; + ru->function = gNodeB_3GPP; + printf("Setting function for RU %d to gNodeB_3GPP\n",j); + } else { + } + + ru->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; + ru->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); + ru->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; + + for (i=0; inum_bands; i++) ru->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; + } //strcmp(local_rf, "yes") == 0 + else { + } + + ru->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); + ru->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); + ru->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + ru->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); + + if (config_isparamset(RUParamList.paramarray[j], RU_BF_WEIGHTS_LIST_IDX)) { + ru->nb_bfw = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].numelt; + + for (i=0; inum_gNB; i++) { + ru->bw_list[i] = (int32_t *)malloc16_clear((ru->nb_bfw)*sizeof(int32_t)); + + for (int b=0; bnb_bfw; b++) ru->bw_list[i][b] = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].iptr[b]; + } + } return; } -int rx_rf(RU_proc_t *proc, NR_DL_FRAME_PARMS *fp,int nb_rx, int32_t** rxdata, int lastReadSz, - openair0_device* rfdevice, openair0_timestamp ts_offset) { +int rx_rf(RU_proc_t *proc, NR_DL_FRAME_PARMS *fp,int nb_rx, int32_t **rxdata, int lastReadSz, + openair0_device *rfdevice, openair0_timestamp ts_offset) { void *rxp[nb_rx]; int nextSlot=(proc->tti_rx+1)%fp->slots_per_frame; uint32_t samples_per_slot = fp->get_samples_per_slot(nextSlot,fp); - int rxBufOffet=fp->get_samples_slot_timestamp(nextSlot,fp,0); int controlrxBufOffet=(proc->timestamp_rx+lastReadSz)%fp->samples_per_frame; - AssertFatal(rxBufOffet == controlrxBufOffet && - rxBufOffet+ samples_per_slot <= fp->samples_per_frame, - "inconsistent IQ samples read"); + AssertFatal(rxBufOffet == controlrxBufOffet && + rxBufOffet+ samples_per_slot <= fp->samples_per_frame, + "inconsistent IQ samples read"); for (int i=0; iproc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config; - void *txp[ru->nb_tx]; - unsigned int txs; int i,txsymb; - T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot), - T_INT(0), T_BUFFER(&ru->common.txdata[0][fp->get_samples_slot_timestamp(slot,fp,0)], fp->samples_per_subframe * 4)); int slot_type = nr_slot_select(cfg,frame,slot%fp->slots_per_frame); int prevslot_type = nr_slot_select(cfg,frame,(slot+(fp->slots_per_frame-1))%fp->slots_per_frame); int nextslot_type = nr_slot_select(cfg,frame,(slot+1)%fp->slots_per_frame); @@ -580,33 +548,28 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { if (slot==0) beam = 11; //3 for boresight & 8 to enable /* - if (slot==0 || slot==40) beam=0&8; - if (slot==10 || slot==50) beam=1&8; - if (slot==20 || slot==60) beam=2&8; - if (slot==30 || slot==70) beam=3&8; + if (slot==0 || slot==40) beam=0&8; + if (slot==10 || slot==50) beam=1&8; + if (slot==20 || slot==60) beam=2&8; + if (slot==30 || slot==70) beam=3&8; */ flags |= beam<<8; } - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS, flags ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, slot ); + void *txp[ru->nb_tx]; for (i=0; inb_tx; i++) txp[i] = (void *)&ru->common.txdata[i][fp->get_samples_slot_timestamp(slot,fp,0)-sf_extension]; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); // prepare tx buffer pointers - txs = ru->rfdevice.trx_write_func(&ru->rfdevice, - timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, - txp, - siglen+sf_extension, - ru->nb_tx, - flags); + unsigned int txs = ru->rfdevice.trx_write_func(&ru->rfdevice, + timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, + txp, + siglen+sf_extension, + ru->nb_tx, + flags); LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, slot %d\n",ru->idx, (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %u/%d)\n", txs, siglen); } } @@ -806,14 +769,13 @@ static void *ru_thread( void *param ) { static int ru_thread_status = 0; return &ru_thread_status; } -void launch_NR_RU(char *rf_config_file) { +void launch_NR_RU(RU_t *ru, char *rf_config_file) { LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n", RC.nb_nr_L1_inst,RC.nb_RU,get_nprocs()); LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); for (int ru_id=0; ru_idrf_config_file = rf_config_file; ru->idx = ru_id; ru->ts_offset = 0; @@ -825,7 +787,6 @@ void launch_NR_RU(char *rf_config_file) { ru->gNB_list[0] = &RC.gNB[0][0]; ru->num_gNB=1; LOG_I(PHY,"Copying frame parms from gNB in RC to ru %d and frame_parms in ru\n",ru->idx); - memcpy((void *)ru->nr_frame_parms,&RC.gNB[0][0].frame_parms,sizeof(NR_DL_FRAME_PARMS)); RU_proc_t *proc = &ru->proc; threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "thread_FH", -1, OAI_PRIORITY_RT_MAX ); } @@ -894,16 +855,18 @@ int main( int argc, char **argv ) { // once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init gNBs\n"); LOG_E(PHY,"configuring RU from file, hardcoded one gNB for one RU, one carrier\n"); - RCconfig_RU(); - RC.ru[0]->nr_frame_parms->threequarter_fs=threequarter_fs; - fill_rf_config(RC.ru[0],RC.ru[0]->rf_config_file); + RU_t ru; + OCPconfig_RU(&ru); + ru.nr_frame_parms->threequarter_fs=threequarter_fs; + fill_rf_config(&ru,ru.rf_config_file); init_gNB_phase2(); - nr_phy_init_RU(RC.ru[0]); + memcpy((void *)ru.nr_frame_parms,&RC.gNB[0][0].frame_parms,sizeof(NR_DL_FRAME_PARMS)); + nr_phy_init_RU(&ru); init_gNB_proc(0); // only instance 0 (one gNB per process) if (RC.nb_RU >0) { printf("Initializing RU threads\n"); - launch_NR_RU(get_softmodem_params()->rf_config_file); + launch_NR_RU(&ru, get_softmodem_params()->rf_config_file); } if (opp_enabled ==1) { @@ -913,21 +876,13 @@ int main( int argc, char **argv ) { } if (do_forms==1) { - scopeParms_t tmp= {&argc, argv}; + scopeParms_t tmp= {&argc, argv, NULL, NULL}; startScope(&tmp); } while(!oai_exit) sleep(1); - for(int ru_id=0; ru_idrfdevice.trx_end_func) - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - - if (RC.ru[ru_id]->ifdevice.trx_end_func) - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - } - logClean(); printf("Bye.\n"); return 0; diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 59857659c1..3dfbc2811d 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -720,9 +720,6 @@ int pnf_phy_hi_dci0_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfa } int pnf_phy_dl_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { - if (RC.ru == 0) { - return -1; - } if (RC.eNB == 0) { return -2; @@ -847,9 +844,6 @@ int pnf_phy_ul_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, n req->ul_config_request_body.srs_present ); - if (RC.ru == 0) { - return -1; - } if (RC.eNB == 0) { return -2; diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c index aaa138fcd9..f85162e095 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c @@ -112,18 +112,12 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms, } -int lte_est_timing_advance_pusch(PHY_VARS_eNB *eNB, - module_id_t UE_id) +int lte_est_timing_advance_pusch(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **ul_ch_estimates_time) { int temp, i, aa, max_pos=0, max_val=0; short Re,Im; - RU_t *ru; - ru = RC.ru[UE_id]; - LTE_DL_FRAME_PARMS *frame_parms = (eNB==NULL) ? ru->frame_parms : &eNB->frame_parms; - LTE_eNB_PUSCH *eNB_pusch_vars = (eNB!=NULL) ? eNB->pusch_vars[UE_id] : (LTE_eNB_PUSCH*)NULL; - RU_CALIBRATION *calibration = &ru->calibration; - int32_t **ul_ch_estimates_time = (eNB==NULL) ? calibration->drs_ch_estimates_time : eNB_pusch_vars->drs_ch_estimates_time; uint8_t cyclic_shift = 0; int sync_pos = (frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size); @@ -149,7 +143,7 @@ int lte_est_timing_advance_pusch(PHY_VARS_eNB *eNB, max_pos = max_pos-frame_parms->ofdm_symbol_size; //#ifdef DEBUG_PHY - LOG_D(PHY,"frame %d: max_pos = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,sync_pos); + LOG_D(PHY,"max_pos = %d, sync_pos=%d\n",max_pos,sync_pos); //#endif //DEBUG_PHY return max_pos - sync_pos; diff --git a/openair1/PHY/LTE_ESTIMATION/lte_estimation.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h index 01883224db..8e541a2bba 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_estimation.h +++ b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h @@ -220,11 +220,15 @@ void phy_adjust_gain (PHY_VARS_UE *phy_vars_ue, uint32_t rx_power_fil_dB, unsigned char eNB_id); -int lte_ul_channel_estimation(PHY_VARS_eNB *phy_vars_eNB, - L1_rxtx_proc_t *proc, - module_id_t UE_id, - uint8_t l, - uint8_t Ns); +int32_t lte_ul_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, + L1_rxtx_proc_t *proc, + LTE_eNB_ULSCH_t * ulsch, + int32_t **ul_ch_estimates, + int32_t **ul_ch_estimates_time, + int32_t **rxdataF_ext, + module_id_t UE_id, + unsigned char l, + unsigned char Ns); int32_t lte_ul_channel_estimation_RRU(LTE_DL_FRAME_PARMS *frame_parms, int32_t **ul_ch_estimates, @@ -258,7 +262,8 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms, unsigned char number_of_cards, short coef); -int lte_est_timing_advance_pusch(PHY_VARS_eNB* phy_vars_eNB,module_id_t UE_id); +int lte_est_timing_advance_pusch(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **ul_ch_estimates_time); void lte_eNB_I0_measurements(PHY_VARS_eNB *phy_vars_eNB, int subframe, diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index 7caaf07406..abe5101013 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -34,23 +34,17 @@ static int16_t ru_90c[2*128] = {32767, 0,32766, -402,32758, -804,32746, -1206,32 #define SCALE 0x3FFF -int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB, +int32_t lte_ul_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, L1_rxtx_proc_t *proc, - module_id_t UE_id, + LTE_eNB_ULSCH_t * ulsch, + int32_t **ul_ch_estimates, + int32_t **ul_ch_estimates_time, + int32_t **rxdataF_ext, + module_id_t UE_id, unsigned char l, unsigned char Ns) { - RU_t *ru; - ru = RC.ru[UE_id]; - LTE_DL_FRAME_PARMS *frame_parms = (eNB!=NULL) ? &eNB->frame_parms : ru->frame_parms; - LTE_eNB_PUSCH *pusch_vars = (eNB!=NULL) ? eNB->pusch_vars[UE_id] : NULL; - RU_CALIBRATION *calibration = &ru->calibration; - int32_t **ul_ch_estimates = (eNB!=NULL) ? pusch_vars->drs_ch_estimates : calibration->drs_ch_estimates; - AssertFatal(ul_ch_estimates != NULL, "ul_ch_estimates is null (eNB %p, pusch %p, pusch->drs_ch_estimates %p, pusch->drs_ch_estimates[0] %p ul_ch_estimates %p UE_id %d)\n",eNB,pusch_vars, - pusch_vars->drs_ch_estimates,pusch_vars->drs_ch_estimates[0],ul_ch_estimates,UE_id); - int32_t **ul_ch_estimates_time = (eNB!=NULL) ? pusch_vars->drs_ch_estimates_time : calibration->drs_ch_estimates_time; + AssertFatal(ul_ch_estimates != NULL, "ul_ch_estimates is null "); AssertFatal(ul_ch_estimates_time != NULL, "ul_ch_estimates_time is null\n"); - int32_t **rxdataF_ext = (eNB!=NULL) ? pusch_vars->rxdataF_ext : calibration->rxdataF_ext; - int subframe = proc->subframe_rx; uint8_t harq_pid; @@ -83,16 +77,16 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB, #endif int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32))); - if (eNB->ulsch[UE_id]->ue_type > 0) harq_pid = 0; + if (ulsch->ue_type > 0) harq_pid = 0; else { harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe); } - uint16_t N_rb_alloc = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb; + uint16_t N_rb_alloc = ulsch->harq_processes[harq_pid]->nb_rb; int32_t tmp_estimates[N_rb_alloc*12] __attribute__((aligned(16))); Msc_RS = N_rb_alloc*12; cyclic_shift = (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + - eNB->ulsch[UE_id]->harq_processes[harq_pid]->n_DMRS2 + + ulsch->harq_processes[harq_pid]->n_DMRS2 + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[(subframe<<1)+Ns]) % 12; Msc_idx_ptr = (uint16_t *) bsearch(&Msc_RS, dftsizes, 34, sizeof(uint16_t), compareints); @@ -276,7 +270,7 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB, #if T_TRACER if (aa == 0) - T(T_ENB_PHY_UL_CHANNEL_ESTIMATE, T_INT(0), T_INT(eNB->ulsch[UE_id]->rnti), + T(T_ENB_PHY_UL_CHANNEL_ESTIMATE, T_INT(0), T_INT(ulsch->rnti), T_INT(proc->frame_rx), T_INT(subframe), T_INT(0), T_BUFFER(ul_ch_estimates_time[0], 512 * 4)); diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 475c8bd521..2f05bac13b 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2432,6 +2432,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, } // mapping ue specific beamforming weights from UE specified DLSCH structure to RU beam weights for the eNB + /* for (ru_id=0;ru_idnum_eNB;eNB_id++){ @@ -2445,6 +2446,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, } } } + */ } diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index f357e385f0..1b23fc99bf 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -1047,7 +1047,11 @@ void rx_ulsch(PHY_VARS_eNB *eNB, l%(frame_parms->symbols_per_tti/2), l/(frame_parms->symbols_per_tti/2), frame_parms); - lte_ul_channel_estimation(eNB,proc, + lte_ul_channel_estimation(&eNB->frame_parms,proc, + eNB->ulsch[UE_id], + eNB->pusch_vars[UE_id]->drs_ch_estimates, + eNB->pusch_vars[UE_id]->drs_ch_estimates_time, + eNB->pusch_vars[UE_id]->rxdataF_ext, UE_id, l%(frame_parms->symbols_per_tti/2), l/(frame_parms->symbols_per_tti/2)); diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 67ec027a9d..8c92214e68 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -911,19 +911,18 @@ void reset_stats_gNB(FL_OBJECT *button, static void *scope_thread_gNB(void *arg) { - int UE_id; - int ue_cnt=0; + scopeParms_t * p=(scopeParms_t *) arg; //# ifdef ENABLE_XFORMS_WRITE_STATS // FILE *gNB_stats = fopen("gNB_stats.txt", "w"); //#endif while (!oai_exit) { - ue_cnt=0; + int ue_cnt=0; - for(UE_id=0; UE_idgNB, p->ru, UE_id); ue_cnt++; } } @@ -983,5 +982,5 @@ void startScope(scopeParms_t * p) { } // UE_id pthread_t forms_thread; - threadCreate(&forms_thread, scope_thread_gNB, NULL, "scope", -1, OAI_PRIORITY_RT_LOW); + threadCreate(&forms_thread, scope_thread_gNB, p, "scope", -1, OAI_PRIORITY_RT_LOW); } diff --git a/openair1/PHY/TOOLS/nr_phy_scope.h b/openair1/PHY/TOOLS/nr_phy_scope.h index aaee08a554..29229d6b12 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.h +++ b/openair1/PHY/TOOLS/nr_phy_scope.h @@ -69,19 +69,13 @@ typedef struct { typedef struct { int *argc; char **argv; + RU_t* ru; + PHY_VARS_gNB *gNB; } scopeParms_t; extern unsigned char scope_enb_num_ue; -FD_phy_scope_gnb * create_phy_scope_gnb( void ); FD_phy_scope_nrue * create_phy_scope_nrue( void ); - -void phy_scope_gNB(FD_phy_scope_gnb *form, - PHY_VARS_gNB *phy_vars_gnb, - RU_t *phy_vars_ru, - int UE_id); - - void phy_scope_nrUE(FD_phy_scope_nrue *form, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, @@ -91,6 +85,5 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, void startScope(scopeParms_t * p); - extern RAN_CONTEXT_t RC; #endif diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index ba03e79e62..fc9407f8d0 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1419,7 +1419,7 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->decodedBytes; // estimate timing advance for MAC - sync_pos = lte_est_timing_advance_pusch(eNB,UE_id); + sync_pos = lte_est_timing_advance_pusch(&eNB->frame_parms, eNB->pusch_vars[UE_id]->drs_ch_estimates_time); timing_advance_update = sync_pos; // - eNB->frame_parms.nb_prefix_samples/4; //to check // if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 8846b77af9..cb03821388 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -693,12 +693,6 @@ void ru_fep_full_2thread(RU_t *ru, 3/(fp->symbols_per_tti/2),// Ns = slot number fp); - /*lte_ul_channel_estimation((PHY_VARS_eNB *)NULL, - proc, - ru->idx, - 3%(fp->symbols_per_tti/2), - 3/(fp->symbols_per_tti/2)); - */ lte_ul_channel_estimation_RRU(fp, calibration->drs_ch_estimates, calibration->drs_ch_estimates_time, @@ -713,7 +707,7 @@ void ru_fep_full_2thread(RU_t *ru, 0,//interpolate, 0 /*eNB->ulsch[ru->idx]->rnti rnti or ru->ulsch[eNB_id]->rnti*/); - check_sync_pos = lte_est_timing_advance_pusch((PHY_VARS_eNB *)NULL, ru->idx); + check_sync_pos = lte_est_timing_advance_pusch(ru->frame_parms, ru->calibration.drs_ch_estimates_time); if (ru->state == RU_CHECK_SYNC) { if ((check_sync_pos >= 0 && check_sync_pos<8) || (check_sync_pos < 0 && check_sync_pos>-8)) { LOG_I(PHY,"~~~~~~~~~~~ check_sync_pos %d, frame %d, cnt %d\n",check_sync_pos,proc->frame_rx,ru->wait_check); diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 975ac4e96f..d043963a59 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1579,10 +1579,12 @@ int flexran_agent_unregister_mac_xface(mid_t mod_id) return 0; } +#if 0 AGENT_MAC_xface *flexran_agent_get_mac_xface(mid_t mod_id) { return agent_mac_xface[mod_id]; } +#endif void flexran_create_config_structures(mid_t mod_id) { diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index 92c9917622..0957b8a845 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -921,7 +921,9 @@ int flexran_agent_unregister_rrc_xface(mid_t mod_id) return 0; } +#if 0 AGENT_RRC_xface *flexran_agent_get_rrc_xface(mid_t mod_id) { return agent_rrc_xface[mod_id]; } +#endif diff --git a/openair2/ENB_APP/flexran_agent_extern.h b/openair2/ENB_APP/flexran_agent_extern.h index 119bc3d44c..8c3d1c069f 100644 --- a/openair2/ENB_APP/flexran_agent_extern.h +++ b/openair2/ENB_APP/flexran_agent_extern.h @@ -41,10 +41,15 @@ AGENT_PHY_xface *flexran_agent_get_phy_xface(mid_t mod_id); /* Control module interface for the communication of the MAC Control Module with the agent */ -AGENT_MAC_xface *flexran_agent_get_mac_xface(mid_t mod_id); +//AGENT_MAC_xface *flexran_agent_get_mac_xface(mid_t mod_id); +extern AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]; +#define flexran_agent_get_mac_xface(mod_id) (agent_mac_xface[mod_id]) + /* Control module interface for the communication of the RRC Control Module with the agent */ -AGENT_RRC_xface *flexran_agent_get_rrc_xface(mid_t mod_id); +// AGENT_RRC_xface *flexran_agent_get_rrc_xface(mid_t mod_id); +extern AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]; +#define flexran_agent_get_rrc_xface(mod_id) (agent_rrc_xface[mod_id]) /* Control module interface for the communication of the RRC Control Module with the agent */ AGENT_PDCP_xface *flexran_agent_get_pdcp_xface(mid_t mod_id); diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index dc448b33e9..638ff71688 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -295,7 +295,7 @@ sin_addr: }; bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr)); AssertFatal(listen(t->listen_sock, 5) == 0, ""); - struct epoll_event ev={0}; + struct epoll_event ev= {0}; ev.events = EPOLLIN; ev.data.fd = t->listen_sock; AssertFatal(epoll_ctl(t->epollfd, EPOLL_CTL_ADD, t->listen_sock, &ev) != -1, ""); @@ -367,7 +367,8 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp if (t->lastWroteTS > timestamp+nsamps) LOG_E(HW,"Not supported to send Tx out of order (same in USRP) %lu, %lu\n", - t->lastWroteTS, timestamp); + t->lastWroteTS, timestamp); + t->lastWroteTS=timestamp+nsamps; if (!alreadyLocked) @@ -459,17 +460,17 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi b->headerMode=false; if ( t->nextTimestamp == 0 ) { // First block in UE, resync with the eNB current TS - t->nextTimestamp=b->th.timestamp> nsamps_for_initial ? - b->th.timestamp - nsamps_for_initial : - 0; - b->lastReceivedTS=b->th.timestamp> nsamps_for_initial ? - b->th.timestamp : - nsamps_for_initial; - LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp); - b->trashingPacket=true; - } else if ( b->lastReceivedTS < b->th.timestamp) { + t->nextTimestamp=b->th.timestamp> nsamps_for_initial ? + b->th.timestamp - nsamps_for_initial : + 0; + b->lastReceivedTS=b->th.timestamp> nsamps_for_initial ? + b->th.timestamp : + nsamps_for_initial; + LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp); + b->trashingPacket=true; + } else if ( b->lastReceivedTS < b->th.timestamp) { int nbAnt= b->th.nbAnt; - + for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) { for (int a=0; a < nbAnt; a++) { b->circularBuf[(index*nbAnt+a)%CirSize].r = 0; @@ -479,8 +480,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi if (b->lastReceivedTS != 0 && b->th.timestamp-b->lastReceivedTS > 50 ) LOG_W(HW,"UEsock: %d gap of: %ld in reception\n", fd, b->th.timestamp-b->lastReceivedTS ); + b->lastReceivedTS=b->th.timestamp; - } else if ( b->lastReceivedTS > b->th.timestamp && b->th.size == 1 ) { LOG_W(HW,"Received Rx/Tx synchro out of order\n"); b->trashingPacket=true; @@ -488,7 +489,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi // normal case } else { LOG_E(HW, "received data in past: current is %lu, new reception: %lu!\n", b->lastReceivedTS, b->th.timestamp); - b->trashingPacket=true; + b->trashingPacket=true; } pthread_mutex_lock(&Sockmutex); @@ -561,31 +562,33 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo pthread_mutex_unlock(&Sockmutex); usleep(10000); pthread_mutex_lock(&Sockmutex); + if ( t->lastWroteTS < t->nextTimestamp ) { // Assuming Tx is not done fully in another thread // We can never write is the past from the received time // So, the node perform receive but will never write these symbols // let's tell this to the opposite node - // We send timestamp for nb samples required - // assuming this should have been done earlier if a Tx would exist + // We send timestamp for nb samples required + // assuming this should have been done earlier if a Tx would exist pthread_mutex_unlock(&Sockmutex); struct complex16 v= {0}; void *samplesVoid[t->tx_num_channels]; for ( int i=0; i < t->tx_num_channels; i++) samplesVoid[i]=(void *)&v; - LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n", - t->lastWroteTS, t->nextTimestamp); + + LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n", + t->lastWroteTS, t->nextTimestamp); rfsimulator_write_internal(t, t->nextTimestamp, samplesVoid, 1, t->tx_num_channels, 1, true); } else { - pthread_mutex_unlock(&Sockmutex); + pthread_mutex_unlock(&Sockmutex); LOG_W(HW, "trx_write came from another thread\n"); } } else pthread_mutex_unlock(&Sockmutex); - + bool have_to_wait; do { @@ -712,7 +715,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { rfsimulator->rx_num_channels=openair0_cfg->rx_num_channels; rfsimulator->sample_rate=openair0_cfg->sample_rate; rfsimulator->tx_bw=openair0_cfg->tx_bw; - randominit(0); + //randominit(0); set_taus_seed(0); return 0; } From 64e3e9715860dad3a4fc69bebb367ca78bed3325 Mon Sep 17 00:00:00 2001 From: laurent Date: Tue, 9 Jun 2020 09:00:03 +0200 Subject: [PATCH 008/149] more cleanup, start scope vizualisation rework --- cmake_targets/CMakeLists.txt | 78 ++-- common/ran_context.h | 6 +- executables/main-fs6.c | 2 +- executables/main-ocp.c | 240 +++++-------- executables/ocp-gnb.c | 13 +- openair1/PHY/LTE_ESTIMATION/lte_estimation.h | 4 +- openair1/PHY/NR_REFSIG/scrambling_luts.c | 3 +- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 8 +- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 1 - openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 2 +- openair1/PHY/TOOLS/nr_phy_scope.c | 339 ++++++++---------- openair1/PHY/phy_vars_ue.h | 2 - openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- openair1/SIMULATION/TOOLS/sim.h | 9 - .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 6 - .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 7 +- openair2/GNB_APP/gnb_app.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 10 +- openair2/RRC/NR/rrc_gNB_nsa.c | 2 +- targets/ARCH/rfsimulator/apply_channelmod.c | 8 +- targets/ARCH/rfsimulator/new_channel_sim.c | 108 ++++++ targets/ARCH/rfsimulator/rfsimulator.h | 37 ++ targets/ARCH/rfsimulator/simulator.c | 35 +- 23 files changed, 490 insertions(+), 434 deletions(-) create mode 100644 targets/ARCH/rfsimulator/new_channel_sim.c create mode 100644 targets/ARCH/rfsimulator/rfsimulator.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 20dabb7779..d3c589a63f 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2239,11 +2239,14 @@ add_library(LFDS7 ${lfds7_queue} ${lfds7_ring} ${lfds7_qbss} ${lfds7_stack} ${lfds7_freelist} ${lfds7_btree} ${lfds7_hash} ${lfds7_ordered_list} ${lfds7_unordered_list} ${lfds7_misc} ) +add_library(SIMU_COMMON + ${OPENAIR1_DIR}/SIMULATION/TOOLS/random_channel.c + ${OPENAIR1_DIR}/SIMULATION/TOOLS/rangen_double.c + ) + # Simulation library ########################## set (SIMUSRC -${OPENAIR1_DIR}/SIMULATION/TOOLS/random_channel.c -${OPENAIR1_DIR}/SIMULATION/TOOLS/rangen_double.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_channel.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_tv_channel.c @@ -2252,7 +2255,6 @@ ${OPENAIR1_DIR}/SIMULATION/TOOLS/channel_sim.c ${OPENAIR1_DIR}/SIMULATION/RF/rf.c ${OPENAIR1_DIR}/SIMULATION/RF/dac.c ${OPENAIR1_DIR}/SIMULATION/RF/adc.c -${OPENAIR_DIR}/targets/ARCH/rfsimulator/apply_channelmod.c #${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ) @@ -2416,9 +2418,11 @@ target_link_libraries(gnbscope ${XFORMS_LIBRARIES}) add_library(rfsimulator MODULE - ${OPENAIR_TARGETS}/ARCH/rfsimulator/simulator.c + ${OPENAIR_TARGETS}/ARCH/rfsimulator/simulator.c + ${OPENAIR_TARGETS}/ARCH/rfsimulator/apply_channelmod.c + ${OPENAIR_TARGETS}/ARCH/rfsimulator/new_channel_sim.c ) -target_link_libraries(rfsimulator ${ATLAS_LIBRARIES}) +target_link_libraries(rfsimulator SIMU_COMMON ${ATLAS_LIBRARIES}) add_library(oai_iqplayer MODULE ${OPENAIR_TARGETS}/ARCH/iqplayer/iqplayer_lib.c @@ -2441,7 +2445,7 @@ endif (${T_TRACER}) add_custom_command ( OUTPUT ${OPENAIR_DIR}/common/utils/T/T_IDs.h COMMAND make clean - COMMAND make + COMMAND make -j2 COMMAND make check_vcd WORKING_DIRECTORY ${OPENAIR_DIR}/common/utils/T DEPENDS ${OPENAIR_DIR}/common/utils/T/T_messages.txt @@ -2564,8 +2568,8 @@ add_dependencies(ocp-enb rrc_flag s1ap_flag x2_flag oai_iqplayer) target_link_libraries (ocp-enb -Wl,--start-group RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB - PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 - ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} + PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 SIMU_COMMON + ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} -Wl,--end-group z dl) target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) @@ -2634,7 +2638,7 @@ target_link_libraries (lte-uesoftmodem -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP F1AP_LIB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON - PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB + PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU_COMMON SIMU_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${ATLAS_LIBRARIES} -Wl,--end-group z dl) @@ -2714,7 +2718,7 @@ target_link_libraries (ocp-gnb UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB - X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB} + X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB SIMU_COMMON -Wl,--end-group z dl) target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES}) @@ -2748,6 +2752,7 @@ add_executable(nr-uesoftmodem ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${XFORMS_SOURCE_NR} ${T_SOURCE} + ${UTIL_SRC} ${CONFIG_SOURCES} ${SHLIB_LOADER_SOURCES} ) @@ -2767,29 +2772,6 @@ target_link_libraries (nr-uesoftmodem ${T_LIB}) add_dependencies( nr-uesoftmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) -# USIM process -################# -#add_executable(usim -# ${OPENAIR3_DIR}/NAS/TOOLS/usim_data.c -# ${OPENAIR3_DIR}/NAS/USER/API/USIM/usim_api.c -# ${OPENAIR3_DIR}/NAS/USER/API/USIM/aka_functions.c -# ${OPENAIR3_DIR}/NAS/COMMON/UTIL/memory.c -# ${OPENAIR3_DIR}/NAS/COMMON/UTIL/nas_log.c -# ${OPENAIR3_DIR}/NAS/COMMON/UTIL/OctetString.c -# ${OPENAIR3_DIR}/NAS/COMMON/UTIL/TLVEncoder.c -# ) -#target_link_libraries (usim ${NAS_LIB} UTIL ${ITTI_LIB} LFDS pthread rt nettle crypto m) - -# ??? -##################### -#add_executable(nvram -# ${OPENAIR3_DIR}/NAS/TOOLS/ue_data.c -# ${OPENAIR3_DIR}/NAS/COMMON/UTIL/memory.c -# ${OPENAIR3_DIR}/NAS/COMMON/UTIL/nas_log.c -# ) -#target_link_libraries (nvram LIB_NAS_UE UTIL ${ITTI_LIB} LFDS pthread rt nettle crypto m) - - ###################################" # Addexecutables for tests #################################### @@ -2806,7 +2788,7 @@ add_executable(dlsim_tm4 ${T_SOURCE} ) target_link_libraries (dlsim_tm4 - -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY LFDS ${ITTI_LIB} -Wl,--end-group + -Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY LFDS ${ITTI_LIB} -Wl,--end-group pthread m rt ${CONFIG_LIB} ${ATLAS_LIBRARIES} ${T_LIB} ) @@ -2819,7 +2801,7 @@ add_executable(polartest ${SHLIB_LOADER_SOURCES} ) target_link_libraries(polartest - -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE CONFIG_LIB -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} dl ) @@ -2834,7 +2816,7 @@ add_executable(smallblocktest target_link_libraries(smallblocktest - -Wl,--start-group UTIL SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} dl ) @@ -2847,7 +2829,7 @@ add_executable(ldpctest add_dependencies( ldpctest ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) target_link_libraries(ldpctest - -Wl,--start-group UTIL SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} dl ) @@ -2859,7 +2841,7 @@ add_executable(nr_dlschsim ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_dlschsim - -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) @@ -2871,7 +2853,7 @@ add_executable(nr_pbchsim ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_pbchsim - -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) @@ -2886,7 +2868,7 @@ add_executable(nr_pucchsim ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_pucchsim - -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) @@ -2900,7 +2882,7 @@ add_executable(nr_dlsim ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_dlsim - -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) target_compile_definitions(nr_dlsim PUBLIC -DPHYSICAL_SIMULATOR) @@ -2914,7 +2896,7 @@ add_executable(nr_prachsim ${T_SOURCE} ${SHLIB_LOADER_SOURCES}) target_link_libraries(nr_prachsim - -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON SCHED_NR_LIB SCHED_NR_UE_LIB RRC_LIB NR_RRC_LIB L2_NR CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON SCHED_NR_LIB SCHED_NR_UE_LIB RRC_LIB NR_RRC_LIB L2_NR CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c @@ -2924,7 +2906,7 @@ add_executable(nr_ulschsim ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_ulschsim - -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) @@ -2938,7 +2920,7 @@ add_executable(nr_ulsim ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_ulsim - -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) target_compile_definitions(nr_ulsim PUBLIC -DPHYSICAL_SIMULATOR) @@ -2957,7 +2939,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr ${NFAPI_USER_DIR}/nfapi.c ) target_link_libraries (${myExe} - -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_NR_COMMON PHY PHY_UE PHY_RU LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group + -Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_NR_COMMON PHY PHY_UE PHY_RU LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group pthread m rt ${CONFIG_LIB} ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} dl ) @@ -3037,8 +3019,8 @@ if (${T_TRACER}) NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX L2 L2_LTE L2_NR L2_UE NR_L2_UE MAC_NR_COMMON MAC_NR MAC_UE_NR - CN_UTILS GTPV1U SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU SIMU_ETH OPENAIR0_LIB - ldpc_orig ldpc_optim ldpc_optim8seg ldpc PROTO_AGENT) + CN_UTILS GTPV1U SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB + ldpc_orig ldpc_optim ldpc_optim8seg ldpc PROTO_AGENT dfts) if (TARGET ${i}) add_dependencies(${i} generate_T) endif() @@ -3081,7 +3063,7 @@ function(make_driver name dir) endforeach() CONFIGURE_FILE(${OPENAIR_CMAKE}/tools/Kbuild.cmake ${OPENAIR_BIN_DIR}/${name}/Kbuild) add_custom_command(OUTPUT ${name}.ko - COMMAND make -C ${module_build_path} M=${OPENAIR_BIN_DIR}/${name} + COMMAND make -j2 -C ${module_build_path} M=${OPENAIR_BIN_DIR}/${name} WORKING_DIRECTORY ${OPENAIR_BIN_DIR}/${name} COMMENT "building ${module}.ko" VERBATIM diff --git a/common/ran_context.h b/common/ran_context.h index e8d8ed0653..4819db6960 100644 --- a/common/ran_context.h +++ b/common/ran_context.h @@ -113,11 +113,11 @@ typedef struct { // LTS: not coherent (xxx_frame_parms cardinatlity wtih xNB (so one carrier)) struct RU_t_s **ru; /// Mask to indicate fronthaul setup status of RU (hard-limit to 64 RUs) - uint64_t ru_mask; + //uint64_t ru_mask; /// Mutex for protecting ru_mask - pthread_mutex_t ru_mutex; + //pthread_mutex_t ru_mutex; /// condition variable for signaling setup completion of an RU - pthread_cond_t ru_cond; + //pthread_cond_t ru_cond; } RAN_CONTEXT_t; diff --git a/executables/main-fs6.c b/executables/main-fs6.c index 46dd05224b..dcf0c0fd35 100644 --- a/executables/main-fs6.c +++ b/executables/main-fs6.c @@ -401,7 +401,7 @@ void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_ hULUE(newUDPheader)->O_ACK=eNB->ulsch[UE_id]->harq_processes[harq_pid]->O_ACK; memcpy(hULUE(newUDPheader)->o_ACK, eNB->ulsch[UE_id]->harq_processes[harq_pid]->o_ACK, sizeof(eNB->ulsch[UE_id]->harq_processes[harq_pid]->o_ACK)); - hULUE(newUDPheader)->ta=lte_est_timing_advance_pusch(eNB, UE_id); + hULUE(newUDPheader)->ta=lte_est_timing_advance_pusch(&eNB->frame_parms, eNB->pusch_vars[UE_id]->drs_ch_estimates_time); hULUE(newUDPheader)->segment=segmentID; memcpy(hULUE(newUDPheader)->o, eNB->ulsch[UE_id]->harq_processes[harq_pid]->o, sizeof(eNB->ulsch[UE_id]->harq_processes[harq_pid]->o)); diff --git a/executables/main-ocp.c b/executables/main-ocp.c index d2ee9418dc..47832ade96 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -80,6 +80,15 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int split73; char * split73_config; int split73; +AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]= {0}; +AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]= {0}; +void flexran_agent_slice_update(mid_t module_idP) { +} +int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p){ + return 0; +} +void proto_agent_stop(mod_id_t mod_id){ +} static void *ru_thread( void *param ); void kill_RU_proc(RU_t *ru) { @@ -100,21 +109,6 @@ void exit_function(const char *file, const char *function, const int line, const close_log_mem(); oai_exit = 1; - if (RC.ru == NULL) - exit(-1); // likely init not completed, prevent crash or hang, exit now... - - for (int ru_id=0; ru_idrfdevice.trx_end_func) { - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - RC.ru[ru_id]->rfdevice.trx_end_func = NULL; - } - - if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) { - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - RC.ru[ru_id]->ifdevice.trx_end_func = NULL; - } - } - sleep(1); //allow lte-softmodem threads to exit first exit(1); } @@ -398,6 +392,7 @@ int setup_RU_buffers(RU_t *ru) { return(0); } +#if 0 void init_precoding_weights(PHY_VARS_eNB *eNB) { int layer,ru_id,aa,re,ue,tb; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; @@ -430,6 +425,7 @@ void init_precoding_weights(PHY_VARS_eNB *eNB) { } } } +#endif void ocp_rx_prach(PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, @@ -803,8 +799,7 @@ int init_rf(RU_t *ru) { return ret; } -void init_RU(char *rf_config_file, int send_dmrssync) { - RU_t *ru; +void ocp_init_RU(RU_t *ru, char *rf_config_file, int send_dmrssync) { PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; int i; int CC_id; @@ -820,11 +815,8 @@ void init_RU(char *rf_config_file, int send_dmrssync) { LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); - for (int ru_id=0; ru_idrf_config_file = rf_config_file; - ru->idx = ru_id; + ru->idx = 0; ru->ts_offset = 0; if (ru->is_slave == 1) { @@ -848,8 +840,6 @@ void init_RU(char *rf_config_file, int send_dmrssync) { ru->wakeup_L1_sleep_cnt_max = 3; if (ru->num_eNB > 0) { - LOG_D(PHY, "%s() RC.ru[%d].num_eNB:%d ru->eNB_list[0]:%p RC.eNB[0][0]:%p rf_config_file:%s\n", - __FUNCTION__, ru_id, ru->num_eNB, ru->eNB_list[0], RC.eNB[0][0], ru->rf_config_file); AssertFatal(ru->eNB_list[0], "ru->eNB_list is not initialized\n"); } else { LOG_E(PHY,"Wrong data model, assigning eNB 0, carrier 0 to RU 0\n"); @@ -866,20 +856,19 @@ void init_RU(char *rf_config_file, int send_dmrssync) { int ruIndex=eNB0->num_RU++; eNB0->RU_list[ruIndex] = ru; } - } // for ru_id } void stop_RU(int nb_ru) { for (int inst = 0; inst < nb_ru; inst++) { LOG_I(PHY, "Stopping RU %d processing threads\n", inst); - kill_RU_proc(RC.ru[inst]); + //kill_RU_proc(RC.ru[inst]); } } /* --------------------------------------------------------*/ /* from here function to use configuration module */ static int DEFBFW[] = {0x00007fff}; -void RCconfig_RU(void) { +void ocpRCconfig_RU(RU_t* ru) { paramdef_t RUParams[] = RUPARAMS_DESC; paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL); @@ -890,87 +879,74 @@ void RCconfig_RU(void) { return; } // setting != NULL - if ( RC.ru != NULL ) { - LOG_W(PHY, "Calling RCconfig_RU twice (nb ru=%d), ignoring the second call data structure is %p\n", - RUParamList.numelt,RC.ru); - return; + ru->idx = 0; + ru->if_timing = synch_to_ext_device; + paramdef_t *vals=RUParamList.paramarray[0]; + + if (RC.nb_L1_inst >0) + ru->num_eNB = vals[RU_ENB_LIST_IDX].numelt; + else + ru->num_eNB = 0; + + for (int i=0; inum_eNB; i++) + ru->eNB_list[i] = RC.eNB[vals[RU_ENB_LIST_IDX].iptr[i]][0]; + + if (config_isparamset(vals, RU_SDR_ADDRS)) { + ru->openair0_cfg.sdr_addrs = strdup(*(vals[RU_SDR_ADDRS].strptr)); } - RC.ru = (RU_t **)malloc(RC.nb_RU*sizeof(RU_t *)); - - for (int j = 0; j < RC.nb_RU; j++) { - RC.ru[j] = (RU_t *)calloc(sizeof(RU_t), 1); - RC.ru[j]->idx = j; - LOG_I(PHY,"Creating RC.ru[%d]:%p\n", j, RC.ru[j]); - RC.ru[j]->if_timing = synch_to_ext_device; - paramdef_t *vals=RUParamList.paramarray[j]; - - if (RC.nb_L1_inst >0) - RC.ru[j]->num_eNB = vals[RU_ENB_LIST_IDX].numelt; - else - RC.ru[j]->num_eNB = 0; - - for (int i=0; inum_eNB; i++) - RC.ru[j]->eNB_list[i] = RC.eNB[vals[RU_ENB_LIST_IDX].iptr[i]][0]; - - if (config_isparamset(vals, RU_SDR_ADDRS)) { - RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(vals[RU_SDR_ADDRS].strptr)); - } - - if (config_isparamset(vals, RU_SDR_CLK_SRC)) { - char *paramVal=*(vals[RU_SDR_CLK_SRC].strptr); - LOG_D(PHY, "RU clock source set as %s\n", paramVal); - - if (strcmp(paramVal, "internal") == 0) { - RC.ru[j]->openair0_cfg.clock_source = internal; - } else if (strcmp(paramVal, "external") == 0) { - RC.ru[j]->openair0_cfg.clock_source = external; - } else if (strcmp(paramVal, "gpsdo") == 0) { - RC.ru[j]->openair0_cfg.clock_source = gpsdo; - } else { - LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", paramVal); - } - } - - if (strcmp(*(vals[RU_LOCAL_RF_IDX].strptr), "yes") == 0) { - if ( !(config_isparamset(vals,RU_LOCAL_IF_NAME_IDX)) ) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = eNodeB_3GPP; - LOG_I(PHY, "Setting function for RU %d to eNodeB_3GPP\n",j); - } else { - RC.ru[j]->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); - RC.ru[j]->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); - RC.ru[j]->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); - RC.ru[j]->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); - RC.ru[j]->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); - } - - RC.ru[j]->max_pdschReferenceSignalPower = *(vals[RU_MAX_RS_EPRE_IDX].uptr);; - RC.ru[j]->max_rxgain = *(vals[RU_MAX_RXGAIN_IDX].uptr); - RC.ru[j]->num_bands = vals[RU_BAND_LIST_IDX].numelt; - /* sf_extension is in unit of samples for 30.72MHz here, has to be scaled later */ - RC.ru[j]->sf_extension = *(vals[RU_SF_EXTENSION_IDX].uptr); - RC.ru[j]->end_of_burst_delay = *(vals[RU_END_OF_BURST_DELAY_IDX].uptr); - - for (int i=0; inum_bands; i++) RC.ru[j]->band[i] = vals[RU_BAND_LIST_IDX].iptr[i]; + if (config_isparamset(vals, RU_SDR_CLK_SRC)) { + char *paramVal=*(vals[RU_SDR_CLK_SRC].strptr); + LOG_D(PHY, "RU clock source set as %s\n", paramVal); + + if (strcmp(paramVal, "internal") == 0) { + ru->openair0_cfg.clock_source = internal; + } else if (strcmp(paramVal, "external") == 0) { + ru->openair0_cfg.clock_source = external; + } else if (strcmp(paramVal, "gpsdo") == 0) { + ru->openair0_cfg.clock_source = gpsdo; } else { - LOG_I(PHY,"RU %d: Transport %s\n",j,*(vals[RU_TRANSPORT_PREFERENCE_IDX].strptr)); - RC.ru[j]->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); - RC.ru[j]->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); - RC.ru[j]->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); - RC.ru[j]->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); - RC.ru[j]->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); + LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", paramVal); + } + } + + if (strcmp(*(vals[RU_LOCAL_RF_IDX].strptr), "yes") == 0) { + if ( !(config_isparamset(vals,RU_LOCAL_IF_NAME_IDX)) ) { + ru->if_south = LOCAL_RF; + ru->function = eNodeB_3GPP; + } else { + ru->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); + ru->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); + ru->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); + ru->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); + ru->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); + ru->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); + ru->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); + } + + ru->max_pdschReferenceSignalPower = *(vals[RU_MAX_RS_EPRE_IDX].uptr);; + ru->max_rxgain = *(vals[RU_MAX_RXGAIN_IDX].uptr); + ru->num_bands = vals[RU_BAND_LIST_IDX].numelt; + /* sf_extension is in unit of samples for 30.72MHz here, has to be scaled later */ + ru->sf_extension = *(vals[RU_SF_EXTENSION_IDX].uptr); + ru->end_of_burst_delay = *(vals[RU_END_OF_BURST_DELAY_IDX].uptr); + + for (int i=0; inum_bands; i++) + ru->band[i] = vals[RU_BAND_LIST_IDX].iptr[i]; + } else { + ru->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); + ru->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); + ru->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); + ru->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); + ru->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); + ru->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); + ru->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); } /* strcmp(local_rf, "yes") != 0 */ - RC.ru[j]->nb_tx = *(vals[RU_NB_TX_IDX].uptr); - RC.ru[j]->nb_rx = *(vals[RU_NB_RX_IDX].uptr); - RC.ru[j]->att_tx = *(vals[RU_ATT_TX_IDX].uptr); - RC.ru[j]->att_rx = *(vals[RU_ATT_RX_IDX].uptr); - }// j=0..num_rus + ru->nb_tx = *(vals[RU_NB_TX_IDX].uptr); + ru->nb_rx = *(vals[RU_NB_RX_IDX].uptr); + ru->att_tx = *(vals[RU_ATT_TX_IDX].uptr); + ru->att_rx = *(vals[RU_ATT_RX_IDX].uptr); return; } @@ -1054,13 +1030,13 @@ void init_pdcp(void) { pdcp_module_init(pdcp_initmask); if (NODE_IS_CU(RC.rrc[0]->node_type)) { - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + //pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); } else { pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); } } else { - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + //pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); } } @@ -1086,16 +1062,11 @@ void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) { int stop_L1L2(module_id_t enb_id) { LOG_W(ENB_APP, "stopping lte-softmodem\n"); - if (!RC.ru) { - LOG_UI(ENB_APP, "no RU configured\n"); - return -1; - } - /* these tasks need to pick up new configuration */ terminate_task(enb_id, TASK_ENB_APP, TASK_RRC_ENB); oai_exit = 1; LOG_I(ENB_APP, "calling kill_RU_proc() for instance %d\n", enb_id); - kill_RU_proc(RC.ru[enb_id]); + //kill_RU_proc(RC.ru[enb_id]); LOG_I(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id); kill_eNB_proc(enb_id); oai_exit = 0; @@ -1105,7 +1076,7 @@ int stop_L1L2(module_id_t enb_id) { phy_free_lte_eNB(RC.eNB[enb_id][cc_id]); } - phy_free_RU(RC.ru[enb_id]); + //phy_free_RU(RC.ru[enb_id]); free_lte_top(); return 0; } @@ -1114,14 +1085,13 @@ int stop_L1L2(module_id_t enb_id) { * Restart the lte-softmodem after it has been soft-stopped with stop_L1L2() */ int restart_L1L2(module_id_t enb_id) { - RU_t *ru = RC.ru[enb_id]; + RU_t *ru = NULL; //RC.ru[enb_id]; MessageDef *msg_p = NULL; LOG_W(ENB_APP, "restarting lte-softmodem\n"); /* block threads */ pthread_mutex_lock(&sync_mutex); sync_var = -1; pthread_mutex_unlock(&sync_mutex); - RC.ru_mask |= (1 << ru->idx); /* copy the changed frame parameters to the RU */ /* TODO this should be done for all RUs associated to this eNB */ memcpy(&ru->frame_parms, &RC.eNB[enb_id][0]->frame_parms, sizeof(LTE_DL_FRAME_PARMS)); @@ -1187,10 +1157,16 @@ int main ( int argc, char **argv ) { RCconfig_L1(); } + // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. + // but RU thread deals with pre_scd and this is necessary in VNF and simulator. + // some initialization is necessary and init_ru_vnf do this. + RU_t ru; + + /* We need to read RU configuration before FlexRAN starts so it knows what * splits to report. Actual RU start comes later. */ - if (RC.nb_RU > 0 && NFAPI_MODE != NFAPI_MODE_VNF) { - RCconfig_RU(); + if ( NFAPI_MODE != NFAPI_MODE_VNF) { + ocpRCconfig_RU(&ru); LOG_I(PHY, "number of L1 instances %d, number of RU %d, number of CPU cores %d\n", RC.nb_L1_inst, RC.nb_RU, get_nprocs()); @@ -1211,7 +1187,7 @@ int main ( int argc, char **argv ) { if (RC.nb_inst > 0) { /* Start the agent. If it is turned off in the configuration, it won't start */ for (i = 0; i < RC.nb_inst; i++) { - flexran_agent_start(i); + //flexran_agent_start(i); } /* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks @@ -1292,20 +1268,16 @@ int main ( int argc, char **argv ) { printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); - // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. - // but RU thread deals with pre_scd and this is necessary in VNF and simulator. - // some initialization is necessary and init_ru_vnf do this. + if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { printf("Initializing RU threads\n"); - init_RU(get_softmodem_params()->rf_config_file, + ocp_init_RU(&ru, + get_softmodem_params()->rf_config_file, get_softmodem_params()->send_dmrs_sync); - for (int ru_id=0; ru_idrf_map.card=0; - RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); - LOG_I(PHY,"Starting ru_thread %d\n",ru_id); - init_RU_proc(RC.ru[ru_id]); - } + ru.rf_map.card=0; + ru.rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); + init_RU_proc(&ru); config_sync_var=0; @@ -1316,6 +1288,7 @@ int main ( int argc, char **argv ) { LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU); // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init eNBs\n"); + sleep(1); if (NFAPI_MODE!=NFAPI_MODE_PNF && NFAPI_MODE!=NFAPI_MODE_VNF) { LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n"); @@ -1369,10 +1342,6 @@ int main ( int argc, char **argv ) { } } - for (int inst = 0; inst < RC.nb_RU; inst++) { - phy_free_RU(RC.ru[inst]); - } - free_lte_top(); end_configmodule(); pthread_cond_destroy(&sync_cond); @@ -1381,17 +1350,6 @@ int main ( int argc, char **argv ) { pthread_mutex_destroy(&nfapi_sync_mutex); pthread_mutex_destroy(&ue_pf_po_mutex); - for(int ru_id=0; ru_idrfdevice.trx_end_func) { - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - RC.ru[ru_id]->rfdevice.trx_end_func = NULL; - } - - if (RC.ru[ru_id]->ifdevice.trx_end_func) { - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - RC.ru[ru_id]->ifdevice.trx_end_func = NULL; - } - } } terminate_opt(); diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 4cef3eac6e..6d134ecec1 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -99,7 +99,11 @@ int flexran_agent_start(mid_t mod_id) { } void flexran_agent_slice_update(mid_t module_idP) { } - +int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p){ + return 0; +} +void proto_agent_stop(mod_id_t mod_id){ +} int split73=0; void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { AssertFatal(false, "Must not be called in this context\n"); @@ -395,7 +399,6 @@ void OCPconfig_RU(RU_t *ru) { paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; config_getlist( &RUParamList, RUParams, sizeof(RUParams)/sizeof(paramdef_t), NULL); AssertFatal( RUParamList.numelt == 1 && RC.nb_nr_L1_inst ==1,"" ); - printf("Set RU mask to %lx\n",RC.ru_mask); ru->idx=0; ru->nr_frame_parms = (NR_DL_FRAME_PARMS *)malloc(sizeof(NR_DL_FRAME_PARMS)); ru->frame_parms = (LTE_DL_FRAME_PARMS *)malloc(sizeof(LTE_DL_FRAME_PARMS)); @@ -788,7 +791,7 @@ void launch_NR_RU(RU_t *ru, char *rf_config_file) { ru->num_gNB=1; LOG_I(PHY,"Copying frame parms from gNB in RC to ru %d and frame_parms in ru\n",ru->idx); RU_proc_t *proc = &ru->proc; - threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "thread_FH", -1, OAI_PRIORITY_RT_MAX ); + threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "MainLoop", -1, OAI_PRIORITY_RT_MAX ); } } @@ -855,7 +858,7 @@ int main( int argc, char **argv ) { // once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init gNBs\n"); LOG_E(PHY,"configuring RU from file, hardcoded one gNB for one RU, one carrier\n"); - RU_t ru; + RU_t ru={0}; OCPconfig_RU(&ru); ru.nr_frame_parms->threequarter_fs=threequarter_fs; fill_rf_config(&ru,ru.rf_config_file); @@ -876,7 +879,7 @@ int main( int argc, char **argv ) { } if (do_forms==1) { - scopeParms_t tmp= {&argc, argv, NULL, NULL}; + scopeParms_t tmp= {&argc, argv, &ru, RC.gNB[0]}; startScope(&tmp); } diff --git a/openair1/PHY/LTE_ESTIMATION/lte_estimation.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h index 8e541a2bba..512dd6da72 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_estimation.h +++ b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h @@ -227,8 +227,8 @@ int32_t lte_ul_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, int32_t **ul_ch_estimates_time, int32_t **rxdataF_ext, module_id_t UE_id, - unsigned char l, - unsigned char Ns); + uint8_t l, + uint8_t Ns); int32_t lte_ul_channel_estimation_RRU(LTE_DL_FRAME_PARMS *frame_parms, int32_t **ul_ch_estimates, diff --git a/openair1/PHY/NR_REFSIG/scrambling_luts.c b/openair1/PHY/NR_REFSIG/scrambling_luts.c index 9d957de0f7..790d3f7719 100644 --- a/openair1/PHY/NR_REFSIG/scrambling_luts.c +++ b/openair1/PHY/NR_REFSIG/scrambling_luts.c @@ -27,6 +27,7 @@ #include "PHY/impl_defs_nr.h" #include "PHY/sse_intrin.h" +#include __m64 byte2m64_re[256]; __m64 byte2m64_im[256]; @@ -42,7 +43,7 @@ void init_byte2m64(void) { byte2m64_im[s] = _mm_insert_pi16(byte2m64_im[s],(1-2*((s>>5)&1)),2); byte2m64_re[s] = _mm_insert_pi16(byte2m64_re[s],(1-2*((s>>6)&1)),3); byte2m64_im[s] = _mm_insert_pi16(byte2m64_im[s],(1-2*((s>>7)&1)),3); - printf("init_scrambling_luts: s %x (%d) ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n", + LOG_T(PHY,"init_scrambling_luts: s %x (%d) ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n", ((uint16_t*)&s)[0], (1-2*(s&1)), ((int16_t*)&byte2m64_re[s])[0],((int16_t*)&byte2m64_im[s])[0], diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 6dfbffc46e..82adf111d1 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -154,7 +154,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, * Defining cyclic shift hopping TS 38.211 Subclause 6.3.2.2.2 */ // alpha is cyclic shift - double alpha; + //double alpha; // lnormal is the OFDM symbol number in the PUCCH transmission where l=0 corresponds to the first OFDM symbol of the PUCCH transmission //uint8_t lnormal; // lprime is the index of the OFDM symbol in the slot that corresponds to the first OFDM symbol of the PUCCH transmission in the slot given by [5, TS 38.213] @@ -193,7 +193,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, for(i=0;inr_of_symbols; l++){ - alpha = nr_cyclic_shift_hopping(pucch_pdu->hopping_id,pucch_pdu->initial_cyclic_shift,mcs[i],l,pucch_pdu->start_symbol_index,slot); + double alpha = nr_cyclic_shift_hopping(pucch_pdu->hopping_id,pucch_pdu->initial_cyclic_shift,mcs[i],l,pucch_pdu->start_symbol_index,slot); #ifdef DEBUG_NR_PUCCH_RX printf("\t [nr_generate_pucch0] sequence generation \tu=%d \tv=%d \talpha=%lf \t(for symbol l=%d/%d,mcs %d)\n",u,v,alpha,l,l+pucch_pdu->start_symbol_index,mcs[i]); printf("lut output %d\n",gNB->pucch0_lut.lut[cs_ind][slot][l+pucch_pdu->start_symbol_index]); @@ -266,7 +266,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, const int16_t *x_re = table_5_2_2_2_2_Re[u],*x_im = table_5_2_2_2_2_Im[u]; int16_t xr[24] __attribute__((aligned(32))); - int16_t xrt[24] __attribute__((aligned(32))); + //int16_t xrt[24] __attribute__((aligned(32))); int32_t xrtmag=0; int maxpos=0; int n2=0; @@ -959,7 +959,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, int32_t **rxdataF = gNB->common_vars.rxdataF; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; - pucch_GroupHopping_t pucch_GroupHopping = pucch_pdu->group_hop_flag + (pucch_pdu->sequence_hop_flag<<1); + //pucch_GroupHopping_t pucch_GroupHopping = pucch_pdu->group_hop_flag + (pucch_pdu->sequence_hop_flag<<1); AssertFatal(pucch_pdu->nr_of_symbols==1 || pucch_pdu->nr_of_symbols==2, "Illegal number of symbols for PUCCH 2 %d\n",pucch_pdu->nr_of_symbols); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 7299b085bb..556a5626c5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -225,7 +225,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, unsigned int crc; NR_UL_UE_HARQ_t *harq_process; uint16_t nb_rb ; - uint8_t nb_symb_sch ; uint32_t A, Z, F; uint32_t *pz; uint8_t mod_order; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 69b3421ace..da0528655f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -110,7 +110,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t dmrs_type, nb_dmrs_re_per_rb, number_of_symbols, mcs, Nl; int ap, start_symbol, Nid_cell, i; int sample_offsetF, N_RE_prime, N_PRB_oh; - uint16_t n_rnti, ul_dmrs_symb_pos; + uint16_t ul_dmrs_symb_pos; uint8_t data_existing =0; uint8_t L_ptrs, K_ptrs; // PTRS parameters uint16_t beta_ptrs; // PTRS parameter related to power control diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 8c92214e68..027354ef77 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -36,6 +36,12 @@ float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue_max[NUMBER_OF_UE_MAX] = {0}; +void drawsymbol(FL_OBJECT *obj, int id, + FL_POINT *p, int n, int w, int h) { + fl_points( p, n, FL_YELLOW); +} + + static void ia_receiver_on_off( FL_OBJECT *button, long arg) { @@ -84,12 +90,13 @@ FD_phy_scope_gnb *create_phy_scope_gnb( void ) fl_set_object_color( fdui->rxsig_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->rxsig_t, FL_WHITE ); // Label color fl_set_xyplot_ybounds(fdui->rxsig_t,10,70); - + fl_set_xyplot_symbol(fdui->rxsig_t, 0, drawsymbol); // Time-domain channel response fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "SRS Frequency Response (samples, abs)" ); fl_set_object_boxtype( fdui->chest_t, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_t, FL_WHITE ); // Label color + fl_set_xyplot_symbol(fdui->chest_t, 0, drawsymbol); // Frequency-domain channel response fdui->chest_f = fl_add_xyplot( FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency Response (RE, dB)" ); @@ -97,6 +104,8 @@ FD_phy_scope_gnb *create_phy_scope_gnb( void ) fl_set_object_color( fdui->chest_f, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_f, FL_WHITE ); // Label color fl_set_xyplot_ybounds( fdui->chest_f,30,70); + fl_set_xyplot_symbol(fdui->chest_f, 0, drawsymbol); + // LLR of PUSCH fdui->pusch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 260, 500, 200, "PUSCH Log-Likelihood Ratios (LLR, mag)" ); @@ -104,6 +113,8 @@ FD_phy_scope_gnb *create_phy_scope_gnb( void ) fl_set_object_color( fdui->pusch_llr, FL_BLACK, FL_YELLOW ); fl_set_object_lcolor( fdui->pusch_llr, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pusch_llr,2); + fl_set_xyplot_symbol(fdui->pusch_llr, 0, drawsymbol); + // I/Q PUSCH comp fdui->pusch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 260, 240, 200, "PUSCH I/Q of MF Output" ); @@ -119,6 +130,8 @@ FD_phy_scope_gnb *create_phy_scope_gnb( void ) fl_set_object_color( fdui->pucch_comp1, FL_BLACK, FL_YELLOW ); fl_set_object_lcolor( fdui->pucch_comp1, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pucch_comp1,2); + fl_set_xyplot_symbol(fdui->pucch_comp1, 0, drawsymbol); + // fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR); // I/Q PUCCH comp (fromat 1a/b) @@ -127,6 +140,8 @@ FD_phy_scope_gnb *create_phy_scope_gnb( void ) fl_set_object_color( fdui->pucch_comp, FL_BLACK, FL_YELLOW ); fl_set_object_lcolor( fdui->pucch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pucch_comp,2); + fl_set_xyplot_symbol(fdui->pucch_comp, 0, drawsymbol); + // fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR); // Throughput on PUSCH @@ -134,6 +149,8 @@ FD_phy_scope_gnb *create_phy_scope_gnb( void ) fl_set_object_boxtype( fdui->pusch_tput, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pusch_tput, FL_BLACK, FL_WHITE ); fl_set_object_lcolor( fdui->pusch_tput, FL_WHITE ); // Label color + fl_set_xyplot_symbol(fdui->pusch_tput, 0, drawsymbol); + // Generic eNB Button fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 20, 600, 240, 40, "" ); @@ -155,29 +172,12 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, RU_t *phy_vars_ru, int UE_id) { - int i, arx; //int i,i2,arx,atx,ind,k; NR_DL_FRAME_PARMS *frame_parms = &phy_vars_gnb->frame_parms; //int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; //uint8_t nb_antennas_tx = 1; // frame_parms->nb_antennas_tx; // in LTE Rel. 8 and 9 only a single transmit antenna is assumed at the UE - int16_t **rxsig_t, **rxsig_f; - // int16_t **chest_t=NULL; - // int16_t **chest_f=NULL; - // int16_t *pusch_llr=NULL; - // int32_t *pusch_comp=NULL; - // int32_t *pucch1_comp=NULL; - // int32_t *pucch1_thres=NULL; - // int32_t *pucch1ab_comp=NULL; - // float Re,Im,ymax; - float *llr, *bit; - // float I[nsymb_ce*2], Q[nsymb_ce*2]; - // float I_pucch[10240],Q_pucch[10240],A_pucch[10240],B_pucch[10240],C_pucch[10240]; - float *rxsig_t_dB[nb_antennas_rx]; - float *rxsig_f_dB[nb_antennas_rx]; - float time[frame_parms->samples_per_frame]; // float freq[nsymb_ce*nb_antennas_rx*nb_antennas_tx]; // uint32_t total_dlsch_bitrate = phy_vars_gnb->total_dlsch_bitrate; - int coded_bits_per_codeword = 0; // uint8_t harq_pid; // in TDD config 3 it is sf-2, i.e., can be 0,1,2 int Qm = 2; @@ -192,31 +192,16 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, } } */ - coded_bits_per_codeword = frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti; - - for (arx=0; arxsamples_per_frame,sizeof(float)); - rxsig_f_dB[arx] = (float*) calloc(frame_parms->samples_per_slot_wCP,sizeof(float)); - } - llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero - bit = malloc(coded_bits_per_codeword*sizeof(float)); - - rxsig_t = (int16_t**) phy_vars_ru->common.rxdata; - rxsig_f = (int16_t**) phy_vars_ru->common.rxdataF; - //chest_t = (int16_t**) phy_vars_gnb->pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id]; - /* chest_t = (int16_t**) phy_vars_gnb->srs_vars[UE_id].srs_ch_estimates; - chest_f = (int16_t**) phy_vars_gnb->pusch_vars[UE_id]->drs_ch_estimates; - pusch_llr = (int16_t*) phy_vars_gnb->pusch_vars[UE_id]->llr; - pusch_comp = (int32_t*) phy_vars_gnb->pusch_vars[UE_id]->rxdataF_comp; - pucch1_comp = (int32_t*) phy_vars_gnb->pucch1_stats[UE_id]; - pucch1_thres = (int32_t*) phy_vars_gnb->pucch1_stats_thres[UE_id]; - pucch1ab_comp = (int32_t*) phy_vars_gnb->pucch1ab_stats[UE_id]; - */ + int32_t *pucch1_thres = (int32_t*) NULL; // phy_vars_gnb->pucch1_stats_thres[UE_id]; + // Received signal in time domain of receive antenna 0 - if (rxsig_t != NULL) { + if (phy_vars_ru->common.rxdata) { + int16_t **rxsig_t = phy_vars_ru->common.rxdata; + float rxsig_t_dB[nb_antennas_rx][frame_parms->samples_per_frame]; + float time[frame_parms->samples_per_frame]; if (rxsig_t[0] != NULL) { - for (i=0; isamples_per_frame; i++) { + for (int i=0; isamples_per_frame; i++) { rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((rxsig_t[0][2*i])*(rxsig_t[0][2*i])+(rxsig_t[0][2*i+1])*(rxsig_t[0][2*i+1]))); time[i] = (float) i; } @@ -224,9 +209,9 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, fl_set_xyplot_data(form->rxsig_t,time,rxsig_t_dB[0],frame_parms->samples_per_frame,"","",""); } - for (arx=1; arxsamples_per_frame; i++) { + for (int i=0; isamples_per_frame; i++) { rxsig_t_dB[arx][i] = 10*log10(1.0+(float) ((rxsig_t[arx][2*i])*(rxsig_t[arx][2*i])+(rxsig_t[arx][2*i+1])*(rxsig_t[arx][2*i+1]))); } @@ -235,15 +220,17 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, } } - /* // Channel Impulse Response - if (chest_t != NULL) { - ymax = 0; + if (phy_vars_gnb->pusch_vars[UE_id]->ul_ch_estimates_time) { + int16_t **chest_t = (int16_t**) phy_vars_gnb->pusch_vars[UE_id]->ul_ch_estimates_time; + int ymax = 0; + float time2[2*frame_parms->ofdm_symbol_size]; + float chest_t_abs[nb_antennas_rx][2*frame_parms->ofdm_symbol_size]; if (chest_t[0] !=NULL) { - for (i=0; i<(frame_parms->ofdm_symbol_size); i++) { + for (int i=0; i<(2*frame_parms->ofdm_symbol_size); i++) { //i2 = (i+(frame_parms->ofdm_symbol_size>>1))%frame_parms->ofdm_symbol_size; - i2=i; + int i2=i; //time2[i] = (float)(i-(frame_parms->ofdm_symbol_size>>1)); time2[i] = (float)i; chest_t_abs[0][i] = 10*log10((float) (1+chest_t[0][2*i2]*chest_t[0][2*i2]+chest_t[0][2*i2+1]*chest_t[0][2*i2+1])); @@ -252,19 +239,19 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, ymax = chest_t_abs[0][i]; } - fl_set_xyplot_data(form->chest_t,time2,chest_t_abs[0],(frame_parms->ofdm_symbol_size),"","",""); + fl_set_xyplot_data(form->chest_t,time2,chest_t_abs[0],(2*frame_parms->ofdm_symbol_size),"","",""); } - for (arx=1; arxofdm_symbol_size>>3); i++) { + for (int i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) { chest_t_abs[arx][i] = 10*log10((float) (1+chest_t[arx][2*i]*chest_t[arx][2*i]+chest_t[arx][2*i+1]*chest_t[arx][2*i+1])); - + if (chest_t_abs[arx][i] > ymax) ymax = chest_t_abs[arx][i]; } - fl_add_xyplot_overlay(form->chest_t,arx,time,chest_t_abs[arx],(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); + fl_add_xyplot_overlay(form->chest_t,arx,time2,chest_t_abs[arx],(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); fl_set_xyplot_overlay_type(form->chest_t,arx,FL_DASHED_XYPLOT); } } @@ -273,36 +260,35 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, // fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax); fl_set_xyplot_ybounds(form->chest_t,0,ymax); } - */ - + // Channel Frequency Response - if (rxsig_f != NULL) { + if (phy_vars_ru->common.rxdataF) { + int16_t **rxsig_f = (int16_t**) phy_vars_ru->common.rxdataF; + float rxsig_f_dB[nb_antennas_rx][frame_parms->samples_per_slot_wCP]; + float time[frame_parms->samples_per_slot_wCP]; if (rxsig_f[0] != NULL) { - for (i=0; isamples_per_slot_wCP; i++) { + for (int i=0; isamples_per_slot_wCP; i++) { rxsig_f_dB[0][i] = 10*log10(1.0+(float) ((rxsig_f[0][2*i])*(rxsig_f[0][2*i])+(rxsig_f[0][2*i+1])*(rxsig_f[0][2*i+1]))); time[i] = (float) i; } - + fl_set_xyplot_data(form->chest_t,time,rxsig_f_dB[0],frame_parms->samples_per_slot_wCP,"","",""); } - } - - /* - for (arx=0; arxchest_f,0,nb_antennas_rx*nb_antennas_tx*nsymb_ce); fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*frame_parms->symbols_per_tti,3); @@ -327,24 +313,34 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, fl_add_xyplot_overlay(form->chest_f,atx,&freq[atx*nsymb_ce],&chest_f_abs[atx*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]); } } + */ } // PUSCH LLRs - if (pusch_llr != NULL) { - for (i=0; ipusch_vars[UE_id]->llr) { + int16_t *pusch_llr = (int16_t*) phy_vars_gnb->pusch_vars[UE_id]->llr; + + int coded_bits_per_codeword = frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti; + float llr[coded_bits_per_codeword]; + float bit[coded_bits_per_codeword]; + for (int i=0; ipusch_llr,bit,llr,coded_bits_per_codeword,"","",""); } // PUSCH I/Q of MF Output - if (pusch_comp!=NULL) { - ind=0; + if (phy_vars_gnb->pusch_vars[UE_id]->rxdataF_comp) { + int32_t *pusch_comp = (int32_t*) phy_vars_gnb->pusch_vars[UE_id]->rxdataF_comp; - for (k=0; ksymbols_per_tti; k++) { - for (i=0; i<12*frame_parms->N_RB_UL; i++) { + int sz=frame_parms->symbols_per_tti*12*frame_parms->N_RB_UL; + float I[sz], Q[sz]; + int ind=0; + + for (int k=0; ksymbols_per_tti; k++) { + for (int i=0; i<12*frame_parms->N_RB_UL; i++) { I[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i]; Q[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1]; ind++; @@ -355,8 +351,13 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, } // PUSCH I/Q of MF Output - if (pucch1ab_comp!=NULL) { - for (ind=0; ind<10240; ind++) { + if (NULL) { + + int32_t* pucch1ab_comp = (int32_t*) NULL; //phy_vars_gnb->pucch1ab_stats[UE_id]; + int32_t *pucch1_comp = (int32_t*) NULL;//phy_vars_gnb->pucch1_stats[UE_id]; + + float I_pucch[10240],Q_pucch[10240],A_pucch[10240],B_pucch[10240],C_pucch[10240]; + for (int ind=0; ind<10240; ind++) { I_pucch[ind] = (float)pucch1ab_comp[2*(ind)]; Q_pucch[ind] = (float)pucch1ab_comp[2*(ind)+1]; @@ -385,13 +386,8 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, // fl_get_xyplot_ybounds(form->pusch_tput,&ymin,&ymax); // fl_set_xyplot_ybounds(form->pusch_tput,0,ymax); - - */ fl_check_forms(); - - free(llr); - free(bit); } FD_phy_scope_nrue *create_phy_scope_nrue( void ) @@ -413,19 +409,24 @@ FD_phy_scope_nrue *create_phy_scope_nrue( void ) fl_set_object_color( fdui->rxsig_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->rxsig_t, FL_WHITE ); // Label color fl_set_xyplot_ybounds(fdui->rxsig_t,10,70); + fl_set_xyplot_symbol(fdui->rxsig_t, 0, drawsymbol); + // Time-domain channel response fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "Channel Impulse Response (samples, abs)" ); fl_set_object_boxtype( fdui->chest_t, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_t, FL_WHITE ); // Label color + fl_set_xyplot_symbol(fdui->chest_t, 0, drawsymbol); + // Frequency-domain channel response - fdui->chest_f = fl_add_xyplot( FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency Response (RE, dB)" ); + fdui->chest_f = fl_add_xyplot( FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency data (RE, dB)" ); fl_set_object_boxtype( fdui->chest_f, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_f, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_f, FL_WHITE ); // Label color fl_set_xyplot_ybounds( fdui->chest_f,30,70); + fl_set_xyplot_symbol(fdui->chest_f, 0, drawsymbol); // LLR of PBCH fdui->pbch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 260, 500, 100, "PBCH Log-Likelihood Ratios (LLR, mag)" ); @@ -435,6 +436,8 @@ FD_phy_scope_nrue *create_phy_scope_nrue( void ) fl_set_xyplot_symbolsize( fdui->pbch_llr,2); fl_set_xyplot_xgrid( fdui->pbch_llr,FL_GRID_MAJOR); //fl_set_xyplot_xbounds( fdui->pbch_llr,0,1920); + fl_set_xyplot_symbol(fdui->pbch_llr, 0, drawsymbol); + // I/Q PBCH comp fdui->pbch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 260, 240, 100, "PBCH I/Q of MF Output" ); @@ -451,6 +454,8 @@ FD_phy_scope_nrue *create_phy_scope_nrue( void ) fl_set_object_color( fdui->pdcch_llr, FL_BLACK, FL_CYAN ); fl_set_object_lcolor( fdui->pdcch_llr, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pdcch_llr,2); + fl_set_xyplot_symbol(fdui->pdcch_llr, 0, drawsymbol); + // I/Q PDCCH comp fdui->pdcch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 380, 240, 100, "PDCCH I/Q of MF Output" ); @@ -458,7 +463,9 @@ FD_phy_scope_nrue *create_phy_scope_nrue( void ) fl_set_object_color( fdui->pdcch_comp, FL_BLACK, FL_CYAN ); fl_set_object_lcolor( fdui->pdcch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pdcch_comp,2); - fl_set_xyplot_xgrid( fdui->pdcch_llr,FL_GRID_MAJOR); + fl_set_xyplot_xgrid( fdui->pdcch_comp,FL_GRID_MAJOR); + fl_set_xyplot_symbol(fdui->pdcch_comp, 0, drawsymbol); + // LLR of PDSCH fdui->pdsch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 500, 500, 200, "PDSCH Log-Likelihood Ratios (LLR, mag)" ); @@ -467,6 +474,8 @@ FD_phy_scope_nrue *create_phy_scope_nrue( void ) fl_set_object_lcolor( fdui->pdsch_llr, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pdsch_llr,2); fl_set_xyplot_xgrid( fdui->pdsch_llr,FL_GRID_MAJOR); + fl_set_xyplot_symbol(fdui->pdsch_llr, 0, drawsymbol); + // I/Q PDSCH comp fdui->pdsch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 500, 240, 200, "PDSCH I/Q of MF Output" ); @@ -474,12 +483,16 @@ FD_phy_scope_nrue *create_phy_scope_nrue( void ) fl_set_object_color( fdui->pdsch_comp, FL_BLACK, FL_YELLOW ); fl_set_object_lcolor( fdui->pdsch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pdsch_comp,2); + fl_set_xyplot_symbol(fdui->pdsch_comp, 0, drawsymbol); + // Throughput on PDSCH fdui->pdsch_tput = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 720, 500, 100, "PDSCH Throughput [frame]/[kbit/s]" ); fl_set_object_boxtype( fdui->pdsch_tput, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pdsch_tput, FL_BLACK, FL_WHITE ); fl_set_object_lcolor( fdui->pdsch_tput, FL_WHITE ); // Label color + fl_set_xyplot_symbol(fdui->pdsch_tput, 0, drawsymbol); + // Generic UE Button fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 540, 720, 240, 40, "" ); @@ -509,34 +522,11 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, int samples_per_frame = frame_parms->samples_per_frame; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; uint8_t nb_antennas_tx = frame_parms->nb_antenna_ports_gNB; - int16_t **rxsig_t; - float **rxsig_t_dB; - float *time; - float *corr; - int16_t **chest_t; - int16_t **chest_f; - int16_t *pdsch_llr; - int16_t *pdsch_comp; //int16_t *pdsch_mag; - int8_t *pdcch_llr; - int16_t *pdcch_comp; - int16_t *pbch_llr; - int16_t *pbch_comp; - float llr_pbch[1920], bit_pbch[1920]; - float *llr, *bit; - float *llr_pdcch, *bit_pdcch; - float *I, *Q; int num_pdcch_symbols=2; - int num_re = 4500; - int Qm = 2; - int coded_bits_per_codeword = num_re*Qm; int symbol, first_symbol=2,nb_re; int nb_rb_pdsch=50,nb_symb_sch=9; float ymax=1; - float **chest_t_abs; - float Re,Im; - float *chest_f_abs; - float *freq; static int overlay = 0; /* int frame = phy_vars_ue->proc.proc_rxtx[0].frame_rx; @@ -579,47 +569,18 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, coded_bits_per_codeword = 0; //frame_parms->N_RB_DL*12*get_Qm(mcs)*(frame_parms->symbols_per_tti); } */ - I = (float*) calloc(frame_parms->ofdm_symbol_size*frame_parms->symbols_per_slot*2,sizeof(float)); - Q = (float*) calloc(frame_parms->ofdm_symbol_size*frame_parms->symbols_per_slot*2,sizeof(float)); - chest_t_abs = (float**) malloc(nb_antennas_rx*sizeof(float*)); - for (arx=0; arxofdm_symbol_size,sizeof(float)); - } - chest_f_abs = (float*) calloc(frame_parms->ofdm_symbol_size,sizeof(float)); - freq = (float*) calloc(frame_parms->ofdm_symbol_size,sizeof(float)); - - llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero - bit = malloc(coded_bits_per_codeword*sizeof(float)); - - llr_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); // init to zero - bit_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); - - rxsig_t = (int16_t**) phy_vars_ue->common_vars.rxdata; - rxsig_t_dB = calloc(nb_antennas_rx,sizeof(float*)); - for (arx=0; arxpbch_vars[eNB_id]->dl_ch_estimates_time; - chest_f = (int16_t**) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates; - - pbch_llr = (int16_t*) phy_vars_ue->pbch_vars[eNB_id]->llr; - pbch_comp = (int16_t*) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; - - pdcch_llr = (int8_t*) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr; - pdcch_comp = (int16_t*) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp[0]; - pdsch_llr = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; // stream 0 - // pdsch_llr = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars_SI[eNB_id]->llr[0]; // stream 0 - pdsch_comp = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp0[0]; //pdsch_mag = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->dl_ch_mag0[0]; // Received signal in time domain of receive antenna 0 - if (rxsig_t != NULL) { + if ( phy_vars_ue->common_vars.rxdata) { + int16_t** rxsig_t = (int16_t**) phy_vars_ue->common_vars.rxdata; + float rxsig_t_dB[nb_antennas_rx][samples_per_frame]; + float time[samples_per_frame]; + + if (rxsig_t[0] != NULL) { for (i=0; iis_synchronized==0) { + //float corr[samples_per_frame]; for (ind=0;ind<3;ind++) { /* if (pss_corr_ue[ind]) { @@ -669,9 +631,13 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, } // Channel Impulse Response - if (chest_t != NULL) { - ymax = 0; + + if (phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time) { + int16_t **chest_t = (int16_t**) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time; + ymax = 0; + float chest_t_abs[nb_antennas_rx][frame_parms->ofdm_symbol_size]; + float time[frame_parms->ofdm_symbol_size>>3]; if (chest_t[0] !=NULL) { for (i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) { chest_t_abs[0][i] = (float) (chest_t[0][2*i]*chest_t[0][2*i]+chest_t[0][2*i+1]*chest_t[0][2*i+1]); @@ -705,16 +671,20 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, } // Channel Frequency Response (includes 5 complex sample for filter) - if (chest_f != NULL) { + if (phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates) { + int16_t ** chest_f = (int16_t**) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates; + ind = 0; + float chest_f_abs[frame_parms->ofdm_symbol_size]; + float freq[frame_parms->ofdm_symbol_size]; for (atx=0; atxofdm_symbol_size; k++) { freq[ind] = (float)ind; - Re = (float)(chest_f[(atx<<1)+arx][6144+(2*k)]); - Im = (float)(chest_f[(atx<<1)+arx][6144+(2*k)+1]); + float Re = (float)(chest_f[(atx<<1)+arx][6144+(2*k)]); + float Im = (float)(chest_f[(atx<<1)+arx][6144+(2*k)+1]); chest_f_abs[ind] = (short)10*log10(1.0+((double)Re*Re + (double)Im*Im)); ind++; @@ -753,7 +723,10 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, } // PBCH LLRs - if (pbch_llr != NULL) { + if ( phy_vars_ue->pbch_vars[eNB_id]->llr) { + int16_t* pbch_llr = (int16_t*) phy_vars_ue->pbch_vars[eNB_id]->llr; + float llr_pbch[1920], bit_pbch[1920]; + for (i=0; i<864; i++) { llr_pbch[i] = (float) pbch_llr[i]; bit_pbch[i] = (float) i; @@ -765,7 +738,11 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, first_symbol=1; // PBCH I/Q of MF Output - if (pbch_comp!=NULL) { + if (phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]) { + int16_t * pbch_comp = (int16_t*) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; + + float I[432]; + float Q[432]; for (symbol=first_symbol; symbol<(first_symbol+3); symbol++) { if (symbol == 2 || symbol == 6) nb_re = 72; @@ -780,7 +757,12 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, } // PDCCH LLRs - if (pdcch_llr != NULL) { + if (phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr) { + int8_t* pdcch_llr = (int8_t*) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr; + + float llr_pdcch[12*frame_parms->N_RB_DL*num_pdcch_symbols*2]; + float bit_pdcch[12*frame_parms->N_RB_DL*num_pdcch_symbols*2]; + for (i=0; i<100; i++) { //12*frame_parms->N_RB_DL*2*num_pdcch_symbols llr_pdcch[i] = (float) pdcch_llr[2*24*9 +i]; bit_pdcch[i] = (float) i; @@ -790,16 +772,29 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, } // PDCCH I/Q of MF Output - if (pdcch_comp!=NULL) { + if (phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp[0]) { + int16_t* pdcch_comp = (int16_t*) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp[0]; + + float I[frame_parms->ofdm_symbol_size*frame_parms->symbols_per_slot*2]; + float Q[frame_parms->ofdm_symbol_size*frame_parms->symbols_per_slot*2]; for (i=0; i<100; i++) { I[i] = pdcch_comp[2*50*12+2*i]; Q[i] = pdcch_comp[2*50*12+2*i+1]; - } + } fl_set_xyplot_data(form->pdcch_comp,I,Q,12*frame_parms->N_RB_DL*num_pdcch_symbols,"","",""); } - + // PDSCH LLRs - if (pdsch_llr != NULL) { + if (phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]) { + int16_t *pdsch_llr = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; // stream 0 + // pdsch_llr = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars_SI[eNB_id]->llr[0]; // stream 0 + + int num_re = 4500; + int Qm = 2; + int coded_bits_per_codeword = num_re*Qm; + float llr[coded_bits_per_codeword]; + float bit[coded_bits_per_codeword]; + for (i=0; ipdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp0[0]) { + int16_t* pdsch_comp = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp0[0]; + + float I[nb_symb_sch]; + float Q[nb_symb_sch]; for (symbol=0;symbolN_RB_DL*12+i) ]; @@ -842,28 +841,6 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, */ fl_check_forms(); - - free(time); - free(corr); - for (arx=0; arxphy_proc_tx); - LOG_D(PHY,"phy_procedures_gNB_TX: %d/%d\n", frame,slot); + // clear the transmit data array for the current subframe for (aa=0; aacarrier_config.num_tx_ant.value; aa++) { memset(&gNB->common_vars.txdataF[aa][txdataF_offset],0,fp->samples_per_slot_wCP*sizeof(int32_t)); diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 0bc5975d99..ac46d51174 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -432,15 +432,6 @@ void multipath_tv_channel(channel_desc_t *desc, /**@} */ /**@} */ -void rxAddInput( struct complex16 *input_sig, - struct complex16 *after_channel_sig, - int rxAnt, - channel_desc_t *channelDesc, - int nbSamples, - uint64_t TS, - uint32_t CirSize - ); - int modelid_fromname(char *modelname); double channelmod_get_snr_dB(void); double channelmod_get_sinr_dB(void); diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index d043963a59..603ff25198 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1579,12 +1579,6 @@ int flexran_agent_unregister_mac_xface(mid_t mod_id) return 0; } -#if 0 -AGENT_MAC_xface *flexran_agent_get_mac_xface(mid_t mod_id) -{ - return agent_mac_xface[mod_id]; -} -#endif void flexran_create_config_structures(mid_t mod_id) { diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index 0957b8a845..ec907a1956 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -921,9 +921,4 @@ int flexran_agent_unregister_rrc_xface(mid_t mod_id) return 0; } -#if 0 -AGENT_RRC_xface *flexran_agent_get_rrc_xface(mid_t mod_id) -{ - return agent_rrc_xface[mod_id]; -} -#endif + diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index f11e302771..d072ff71d5 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -170,7 +170,7 @@ void *gNB_app_task(void *args_p) if (is_x2ap_enabled() ) { //&& !NODE_IS_DU(RC.rrc[0]->node_type) LOG_I(X2AP, "X2AP enabled \n"); - x2_register_gnb_pending = gNB_app_register_x2 (gnb_id_start, gnb_id_end); + __attribute__((unused)) uint32_t x2_register_gnb_pending = gNB_app_register_x2 (gnb_id_start, gnb_id_end); } if (EPC_MODE_ENABLED) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 2c2dfac499..0dc533a574 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3101,7 +3101,7 @@ void nr_ue_process_mac_pdu(module_id_t module_idP, mac_sdu_len = 0x0000; rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pdu_ptr)->LCID; - LOG_D(MAC, "[UE] LCID %d, PDU length %d\n", rx_lcid, pdu_len); + LOG_D(MAC, "[UE] LCID %d, PDU length %d\n", rx_lcid, pdu_len); switch(rx_lcid){ // MAC CE @@ -3255,12 +3255,12 @@ void nr_ue_process_mac_pdu(module_id_t module_idP, LOG_D(MAC, "[UE %d] Frame %d : DLSCH -> DL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, gNB_index, mac_sdu_len); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_D(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); + LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); - for (int i = 0; i < 32; i++) - LOG_D(MAC, "%x.", (pdu_ptr + mac_subheader_len)[i]); + for (i = 0; i < 32; i++) + LOG_T(MAC, "%x.", (pdu_ptr + mac_subheader_len)[i]); - LOG_D(MAC, "\n"); + LOG_T(MAC, "\n"); #endif if (IS_SOFTMODEM_NOS1){ diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 763c208dfe..d4647511a9 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -130,7 +130,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ ue_context_p->ue_id_rnti = ue_context_p->ue_context.secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity; NR_CG_Config_t *CG_Config = calloc(1,sizeof(*CG_Config)); memset((void*)CG_Config,0,sizeof(*CG_Config)); - int CG_Config_size = generate_CG_Config(rrc,CG_Config,ue_context_p->ue_context.reconfig,ue_context_p->ue_context.rb_config); + __attribute__((unused))int CG_Config_size = generate_CG_Config(rrc,CG_Config,ue_context_p->ue_context.reconfig,ue_context_p->ue_context.rb_config); //X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer_size = CG_Config_size; //Need to verify correct value for the buffer_size // Send to X2 entity to transport to MeNB diff --git a/targets/ARCH/rfsimulator/apply_channelmod.c b/targets/ARCH/rfsimulator/apply_channelmod.c index faf84bb0aa..7aa5d78bf8 100644 --- a/targets/ARCH/rfsimulator/apply_channelmod.c +++ b/targets/ARCH/rfsimulator/apply_channelmod.c @@ -34,6 +34,9 @@ #include #include #include +#include +#include +#include /* Legacy study: @@ -99,8 +102,8 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si } //l } - out_ptr->r += round(rx_tmp.x*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); - out_ptr->i += round(rx_tmp.y*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); + out_ptr->r += round(rx_tmp.x*pathLossLinear + noise_per_sample*gaussZiggurat(0.0,1.0)); + out_ptr->i += round(rx_tmp.y*pathLossLinear + noise_per_sample*gaussZiggurat(0.0,1.0)); out_ptr++; } @@ -112,3 +115,4 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si channelDesc->path_loss_dB, 10*log10(noise_per_sample)); } + diff --git a/targets/ARCH/rfsimulator/new_channel_sim.c b/targets/ARCH/rfsimulator/new_channel_sim.c new file mode 100644 index 0000000000..0501babd20 --- /dev/null +++ b/targets/ARCH/rfsimulator/new_channel_sim.c @@ -0,0 +1,108 @@ +/* +* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The OpenAirInterface Software Alliance licenses this file to You under +* the OAI Public License, Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.openairinterface.org/?page_id=698 +* +* Author and copyright: Laurent Thomas, open-cells.com +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*------------------------------------------------------------------------------- +* For more information about the OpenAirInterface (OAI) Software Alliance: +* contact@openairinterface.org +*/ + + +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include + +// Ziggurat +static double wn[128],fn[128]; +static uint32_t iz,jz,jsr=123456789,kn[128]; +static int32_t hz; +#define SHR3 (jz=jsr, jsr^=(jsr<<13),jsr^=(jsr>>17),jsr^=(jsr<<5),jz+jsr) +#define UNI (0.5+(signed) SHR3 * 0.2328306e-9) + +double nfix(void) { + const double r = 3.442620; + static double x, y; + + for (;;) { + x=hz * wn[iz]; + + if (iz==0) { + do { + x = - 0.2904764 * log (UNI); + y = - log (UNI); + } while (y+y < x*x); + + return (hz>0)? r+x : -r-x; + } + + if (fn[iz]+UNI*(fn[iz-1]-fn[iz]) +#include #define PORT 4043 //default TCP port for this simulator #define CirSize 307200 // 100ms is enough @@ -146,6 +147,12 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) { // the value channel_model->path_loss_dB seems only a storage place (new_channel_desc_scm() only copy the passed value) // Legacy changes directlty the variable channel_model->path_loss_dB place to place // while calling new_channel_desc_scm() with path losses = 0 + static bool init_done=false; + if (!init_done) { + randominit(0); + tableNor(0); + init_done=true; + } ptr->channel_model=new_channel_desc_scm(bridge->tx_num_channels,bridge->rx_num_channels, bridge->channelmod, bridge->sample_rate, @@ -368,7 +375,6 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp if (t->lastWroteTS > timestamp+nsamps) LOG_E(HW,"Not supported to send Tx out of order (same in USRP) %lu, %lu\n", t->lastWroteTS, timestamp); - t->lastWroteTS=timestamp+nsamps; if (!alreadyLocked) @@ -470,18 +476,20 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi b->trashingPacket=true; } else if ( b->lastReceivedTS < b->th.timestamp) { int nbAnt= b->th.nbAnt; - - for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) { - for (int a=0; a < nbAnt; a++) { - b->circularBuf[(index*nbAnt+a)%CirSize].r = 0; - b->circularBuf[(index*nbAnt+a)%CirSize].i = 0; - } - } - + if ( b->th.timestamp-b->lastReceivedTS < CirSize ) { + for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) { + for (int a=0; a < nbAnt; a++) { + b->circularBuf[(index*nbAnt+a)%CirSize].r = 0; + b->circularBuf[(index*nbAnt+a)%CirSize].i = 0; + } + } + } else { + memset(b->circularBuf, 0, sampleToByte(CirSize,1)); + } if (b->lastReceivedTS != 0 && b->th.timestamp-b->lastReceivedTS > 50 ) LOG_W(HW,"UEsock: %d gap of: %ld in reception\n", fd, b->th.timestamp-b->lastReceivedTS ); - b->lastReceivedTS=b->th.timestamp; + } else if ( b->lastReceivedTS > b->th.timestamp && b->th.size == 1 ) { LOG_W(HW,"Received Rx/Tx synchro out of order\n"); b->trashingPacket=true; @@ -640,10 +648,11 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ); else { // no channel modeling sample_t *out=(sample_t *)samplesVoid[a]; - + const int64_t base=t->nextTimestamp*nbAnt+a; for ( int i=0; i < nsamps; i++ ) { - out[i].r+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt+a)%CirSize].r; - out[i].i+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt+a)%CirSize].i; + const int idx=(i*nbAnt+base)%CirSize; + out[i].r+=ptr->circularBuf[idx].r; + out[i].i+=ptr->circularBuf[idx].i; } } // end of no channel modeling } // end for a... From d21a40066d084532cf6afba1b9629ad60d378256 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 18 Jun 2020 10:19:52 +0200 Subject: [PATCH 009/149] scope for 5G --- doc/SystemX-tutorial-design.md | 90 ------ executables/nr-softmodem.c | 4 +- executables/nr-uesoftmodem.c | 4 +- executables/ocp-gnb.c | 2 +- .../PHY/NR_TRANSPORT/nr_ulsch_demodulation.c | 1 + .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 4 +- openair1/PHY/TOOLS/nr_phy_scope.c | 280 ++++++++---------- openair1/PHY/TOOLS/nr_phy_scope.h | 7 +- 8 files changed, 138 insertions(+), 254 deletions(-) diff --git a/doc/SystemX-tutorial-design.md b/doc/SystemX-tutorial-design.md index 9feaf189c5..3e4496f7de 100644 --- a/doc/SystemX-tutorial-design.md +++ b/doc/SystemX-tutorial-design.md @@ -1,18 +1,10 @@ # OpenAirInterface for SystemX -<<<<<<< HEAD -#Terminology - -****This document use the 5G terminology**** - -**Central Unit (CU): **It is a logical node that includes the gNB -======= # Terminology ****This document use the 5G terminology**** **Central Unit (CU):** It is a logical node that includes the gNB ->>>>>>> da54778c4ab381743c388078676103663addafcc functions like Transfer of user data, Mobility control, Radio access network sharing, Positioning, Session Management etc., except those functions allocated exclusively to the DU. CU controls the operation of @@ -27,13 +19,9 @@ names like RRH/RRU/RE/RU/PNF. In OpenAir code, the terminology is often RU and BBU. # OpenAirUsage -<<<<<<< HEAD -##EPC and general environment -======= ## EPC and general environment ->>>>>>> da54778c4ab381743c388078676103663addafcc ### OAI EPC Use the stable OAI EPC, that can run in one machine (VM or standalone) @@ -41,16 +29,10 @@ Use the stable OAI EPC, that can run in one machine (VM or standalone) Draft description: -<<<<<<< HEAD -##Standalone 4G - -EPC+eNB on one machine, the UE can be commercial or OAI UE. -======= ## Standalone 4G EPC+eNB on one machine, the UE can be commercial or OAI UE. ->>>>>>> da54778c4ab381743c388078676103663addafcc ### USRP B210 Main current issue: traffic is good only on coaxial link between UE and @@ -76,12 +58,8 @@ the same IP tunnel end point as the UE. So, we have to create a network namespace for the UE and to route data in/out of the namespace. -<<<<<<< HEAD -``` bash -======= ```bash ->>>>>>> da54778c4ab381743c388078676103663addafcc ip netns delete aNameSpace 2> /dev/null ip link delete v-eth1 2> /dev/null @@ -96,11 +74,7 @@ ip addr add 10.200.1.1/24 dev v-eth1 ip link set v-eth1 up -<<<<<<< HEAD -iptables -t nat -A POSTROUTING -s 10.200.1.0/255.255.255.0 -o enp0s31f6 -======= iptables -t nat -A POSTROUTING -s 10.200.1.0/255.255.255.0 -o enp0s31f6 \ ->>>>>>> da54778c4ab381743c388078676103663addafcc -j MASQUERADE iptables -A FORWARD -i enp0s31f6 -o v-eth1 -j ACCEPT @@ -122,15 +96,6 @@ to run the UE. To make user plan traffic, the traffic generator has to run in the same namespace -<<<<<<< HEAD -`ip netns exec aNameSpace bash -` - -The traffic genenrator has to specify the interface: - -`route add default oaitun_ue1 -` -======= ```bash ip netns exec aNameSpace bash ``` @@ -140,7 +105,6 @@ The traffic genenrator has to specify the interface: ```bash route add default oaitun_ue1 ``` ->>>>>>> da54778c4ab381743c388078676103663addafcc or specify the outgoing route in the traffic generator (like option “-I” in ping command). @@ -153,10 +117,7 @@ is this work the downlink “functional split 6”. The customer required after signature to develop also the uplink functional split 6. This is accepted, as long as the whole work is research with no delivery completeness warranty. -<<<<<<< HEAD -======= ->>>>>>> da54778c4ab381743c388078676103663addafcc ### Simulation To be able to verify the new features and to help in all future @@ -165,19 +126,12 @@ during this contract. We added the channel modeling simulation, that offer to simulate various 3GPP defined channels. -<<<<<<< HEAD -======= ->>>>>>> da54778c4ab381743c388078676103663addafcc ### Main loop The main log is in RF simulator is in -<<<<<<< HEAD - targets/RT/USER/lte-ru.c and targets/RT/USER/lte-enb.c -======= `targets/RT/USER/lte-ru.c and targets/RT/USER/lte-enb.c` ->>>>>>> da54778c4ab381743c388078676103663addafcc As this piece of SW is very complex and doesn’t meet our goals (functional split 6), a cleaned version replaces these 2 files in @@ -196,13 +150,8 @@ The reworked main loop take care of a uniq variable that comes directly from har To use OAI, we need to set all OAI variables that derivates from this timestamp value. The function setAllfromTS() implements this. -<<<<<<< HEAD - -### Splitted main level -======= ### Splitted main level ->>>>>>> da54778c4ab381743c388078676103663addafcc When FS6 is actived, a main loop for DU (du_fs6()) a main loop for CU case replaces the uniq eNB main loop. Each of these main loops calls initialization of OAI LTE data and the FS6 transport layer initialization. @@ -321,31 +270,6 @@ The end line option “--split73” enables the fs6 (also called split 7.3) mode Example: -<<<<<<< HEAD -./ocp-softmodem -O $OPENAIR_DIR/enb.fs6.example.conf --rfsim --log_config.phy_log_level debug --split73 cu:127.0.0.1 -` -Run the CU init of the split 6 eNB, that will call du on 127.0.0.1 address - -./ocp-softmodem -O $OPENAIR_DIR/enb.fs6.example.conf --rfsim --log_config.phy_log_level debug --split73 du:127.0.0.1 - -will run the du, calling the cu on 127.0.0.1 -` -If the CU and the DU are not on the same machine, the remote address of each side need to be specified as per this example - -./ocp-softmodem -O $OPENAIR_DIR/enb.fs6.example.conf --rfsim --log_config.phy_log_level debug --split73 du:192.168.1.55 -` -runs the functional split 6 DU - -`./lte-uesoftmodem -C 2685000000 -r 50 --rfsim --rfsimulator.serveraddr 192.168.1.1 -d -` - -Runs the UE (to have the UE signal scope, compile it with make uescope) - -CU+DU+UE can run with option --noS1 to avoid to use a EPC and/or with --rfsim to simulate RF board - - -##5G and F1 -======= ```bash ./ocp-softmodem -O $OPENAIR_DIR/enb.fs6.example.conf --rfsim --log_config.phy_log_level debug --split73 cu:127.0.0.1 ``` @@ -376,7 +300,6 @@ CU+DU+UE can run with option `--noS1` to avoid to use a EPC and/or with `--rfsim ## 5G and F1 ->>>>>>> da54778c4ab381743c388078676103663addafcc Today 5G achievement is limited to physical layer. @@ -397,18 +320,6 @@ frames). Usage with RFsimulator: -<<<<<<< HEAD -gNB - -`sudo RFSIMULATOR=server ./nr-softmodem -O -../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf ---parallel-config PARALLEL\_SINGLE\_THREAD` - -nrUE - -`sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --numerology 1 -r 106 -C -3510000000 -d` -======= **gNB** ```bash @@ -423,4 +334,3 @@ sudo RFSIMULATOR=server ./nr-softmodem -O \ sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --numerology 1 -r 106 -C \ 3510000000 -d ``` ->>>>>>> da54778c4ab381743c388078676103663addafcc diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index f473d0161b..1f291cfc19 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -954,7 +954,9 @@ if(!IS_SOFTMODEM_NOS1) scopeParms_t p; p.argc=&argc; p.argv=argv; - startScope(&p); + p.gNB=RC.gNB[0]; + p.ru=RC.ru[0]; + gNBinitScope(&p); } if (nfapi_mode != 1 && nfapi_mode != 2) { diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 2eaf624404..9c33f2d360 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -249,7 +249,7 @@ void exit_function(const char *file, const char *function, const int line, const } -void reset_stats(FL_OBJECT *button, long arg) { +void reset_stats(long arg) { //int i,j,k; /*PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[0][0]; @@ -729,7 +729,7 @@ int main( int argc, char **argv ) { configure_linux(); mlockall(MCL_CURRENT | MCL_FUTURE); if (do_forms) - init_scope(PHY_vars_UE_g[0][0]); + nrUEinitScope(PHY_vars_UE_g[0][0]); number_of_cards = 1; for(int CC_id=0; CC_idulsch_llr_stats); + AssertFatal(gNB->pusch_vars[UE_id]->rxdataF_ext_offset * rel15_ul->qam_mod_order+nb_re_pusch*rel15_ul->qam_mod_order < (8*((3*8*6144)+12)) , "Mysterious llr buffer size check"); nr_ulsch_compute_llr(&gNB->pusch_vars[UE_id]->rxdataF_comp[0][symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB], gNB->pusch_vars[UE_id]->ul_ch_mag0, gNB->pusch_vars[UE_id]->ul_ch_magb0, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index fcd61b33bf..3af9280d30 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -669,13 +669,11 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->llr_offset[symbol] = len*dlsch0_harq->Qm + llr_offset_symbol; - LOG_I(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x energy %d\n", + LOG_I(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d energy %d\n", symbol, nb_rb,dlsch0_harq->Qm, pdsch_vars[eNB_id]->llr_length[symbol], pdsch_vars[eNB_id]->llr_offset[symbol], - (int16_t*)pdsch_vars[eNB_id]->llr[0], - pllr_symbol_cw0, signal_energy(pdsch_vars[eNB_id]->rxdataF_comp0[0], 7*2*frame_parms->N_RB_DL*12)); //if (ue->current_thread_id[nr_tti_rx] ==0 ) //phy_scope_nrUE(NULL, ue, 0, 0, 0); diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 02cf000f37..24b7be74d1 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -26,6 +26,7 @@ #include #include "nr_phy_scope.h" #include "executables/nr-softmodem-common.h" +#include #define TPUT_WINDOW_LENGTH 100 #define localBuff(NaMe,SiZe) float NaMe[SiZe]; memset(NaMe,0,sizeof(NaMe)); @@ -39,6 +40,12 @@ float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue_max[NUMBER_OF_UE_MAX] = {0}; +typedef struct { + int16_t r; + int16_t i; +} scopeSample_t; +#define SquaredNorm(VaR) ((VaR).r*(VaR).r+(VaR).i*(VaR).i) + typedef struct OAIgraph { FL_OBJECT *graph; void (*gNBfunct) (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id); @@ -62,7 +69,7 @@ typedef struct { } FD_stats_form; static void drawsymbol(FL_OBJECT *obj, int id, - FL_POINT *p, int n, int w, int h) { + FL_POINT *p, int n, int w, int h) { fl_points( p, n, FL_YELLOW); } @@ -91,7 +98,7 @@ static void dl_traffic_on_off( FL_OBJECT *button, long arg) { } static FL_OBJECT *commonGraph( int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { - FL_OBJECT * graph; + FL_OBJECT *graph; graph=fl_add_xyplot(type, x, y, w, h, label); fl_set_object_boxtype(graph, FL_EMBOSSED_BOX ); fl_set_object_lcolor(graph, FL_WHITE ); // Label color @@ -101,7 +108,7 @@ static FL_OBJECT *commonGraph( int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_ } static OAIgraph_t gNBcommonGraph( void (*funct) (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id), - int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { + int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { OAIgraph_t graph; graph.graph=commonGraph(type, x, y, w, h, label, pointColor); graph.gNBfunct=funct; @@ -110,7 +117,7 @@ static OAIgraph_t gNBcommonGraph( void (*funct) (FL_OBJECT *graph, PHY_VARS_gNB } static OAIgraph_t nrUEcommonGraph( void (*funct) (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id), - int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { + int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { OAIgraph_t graph; graph.graph=commonGraph(type, x, y, w, h, label, pointColor); graph.gNBfunct=NULL; @@ -122,13 +129,15 @@ void phy_scope_gNB(FD_phy_scope_t *form, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { - static FD_phy_scope_t *remeberForm=NULL; + static FD_phy_scope_t *remeberForm=NULL; if (form==NULL) form=remeberForm; else remeberForm=form; + if (form==NULL) return; + int i=0; while (form->graph[i].graph) { @@ -146,70 +155,51 @@ static void timeSignal (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_ NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - int16_t **rxsig_t = phy_vars_ru->common.rxdata; - float rxsig_t_dB[nb_antennas_rx][frame_parms->samples_per_frame]; + scopeSample_t **rxsig_t = (scopeSample_t **)phy_vars_ru->common.rxdata; + float rxsig_t_dB[frame_parms->samples_per_frame]; float time[frame_parms->samples_per_frame]; - if (rxsig_t[0] != NULL) { - for (int i=0; isamples_per_frame; i++) { - rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((rxsig_t[0][2*i])*(rxsig_t[0][2*i])+ - (rxsig_t[0][2*i+1])*(rxsig_t[0][2*i+1]))); - time[i] = (float) i; - } - - fl_set_xyplot_data(graph,time,rxsig_t_dB[0],frame_parms->samples_per_frame,"","",""); - } - - for (int arx=1; arxsamples_per_frame; i++) { - rxsig_t_dB[arx][i] = 10*log10(1.0+(float) ((rxsig_t[arx][2*i])*(rxsig_t[arx][2*i])+ - (rxsig_t[arx][2*i+1])*(rxsig_t[arx][2*i+1]))); + rxsig_t_dB[i] = 10*log10(1.0+SquaredNorm(rxsig_t[arx][i])); } - fl_add_xyplot_overlay(graph,arx,time,rxsig_t_dB[arx],frame_parms->samples_per_frame,rx_antenna_colors[arx]); + if (arx==0) + fl_set_xyplot_data(graph,time,rxsig_t_dB, frame_parms->samples_per_frame,"","",""); + else + fl_add_xyplot_overlay(graph,arx,time,rxsig_t_dB,frame_parms->samples_per_frame,rx_antenna_colors[arx]); } } } static void timeResponse (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { - // Channel Impulse Response if (!phy_vars_gnb->pusch_vars[UE_id]->ul_ch_estimates_time) return; NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - int16_t **chest_t = (int16_t **) phy_vars_gnb->pusch_vars[UE_id]->ul_ch_estimates_time; + scopeSample_t **chest_t = (scopeSample_t **) phy_vars_gnb->pusch_vars[UE_id]->ul_ch_estimates_time; int ymax = 0; float time2[2*frame_parms->ofdm_symbol_size]; - float chest_t_abs[nb_antennas_rx][2*frame_parms->ofdm_symbol_size]; + float chest_t_abs[2*frame_parms->ofdm_symbol_size]; - if (chest_t[0] !=NULL) { - for (int i=0; i<(2*frame_parms->ofdm_symbol_size); i++) { - //i2 = (i+(frame_parms->ofdm_symbol_size>>1))%frame_parms->ofdm_symbol_size; - int i2=i; - //time2[i] = (float)(i-(frame_parms->ofdm_symbol_size>>1)); - time2[i] = (float)i; - chest_t_abs[0][i] = 10*log10((float) (1+chest_t[0][2*i2]*chest_t[0][2*i2]+chest_t[0][2*i2+1]*chest_t[0][2*i2+1])); - - if (chest_t_abs[0][i] > ymax) - ymax = chest_t_abs[0][i]; - } - - fl_set_xyplot_data(graph,time2,chest_t_abs[0],(2*frame_parms->ofdm_symbol_size),"","",""); - } - - for (int arx=1; arxofdm_symbol_size>>3); i++) { - chest_t_abs[arx][i] = 10*log10((float) (1+chest_t[arx][2*i]*chest_t[arx][2*i]+chest_t[arx][2*i+1]*chest_t[arx][2*i+1])); + for (int i=0; i<(2*frame_parms->ofdm_symbol_size); i++) { + time2[i] = (float)i; + chest_t_abs[i] = 10*log10(1.0 + SquaredNorm(chest_t[0][i])); - if (chest_t_abs[arx][i] > ymax) - ymax = chest_t_abs[arx][i]; + if (chest_t_abs[i] > ymax) + ymax = chest_t_abs[i]; } - fl_add_xyplot_overlay(graph,arx,time2,chest_t_abs[arx],(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); - fl_set_xyplot_overlay_type(graph,arx,FL_DASHED_XYPLOT); + if (arx==0) + fl_set_xyplot_data(graph,time2,chest_t_abs,(2*frame_parms->ofdm_symbol_size),"","",""); + else { + fl_add_xyplot_overlay(graph,arx,time2,chest_t_abs,(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); + fl_set_xyplot_overlay_type(graph,arx,FL_DASHED_XYPLOT); + } } } @@ -224,58 +214,38 @@ static void frequencyResponse (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_ return; NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; - uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - int16_t **rxsig_f = (int16_t **) phy_vars_ru->common.rxdataF; - float rxsig_f_dB[nb_antennas_rx][frame_parms->samples_per_slot_wCP]; + //uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; + scopeSample_t **rxsig_f = (scopeSample_t **) phy_vars_ru->common.rxdataF; + float rxsig_f_dB[frame_parms->samples_per_slot_wCP]; float time[frame_parms->samples_per_slot_wCP]; if (rxsig_f[0] != NULL) { for (int i=0; isamples_per_slot_wCP; i++) { - rxsig_f_dB[0][i] = 10*log10(1.0+(float) ((rxsig_f[0][2*i])*(rxsig_f[0][2*i])+(rxsig_f[0][2*i+1])*(rxsig_f[0][2*i+1]))); + rxsig_f_dB[i] = 10*log10(1.0+ SquaredNorm(rxsig_f[0][i])); time[i] = (float) i; } - fl_set_xyplot_data(graph,time,rxsig_f_dB[0],frame_parms->samples_per_slot_wCP,"","",""); + fl_set_xyplot_data(graph,time,rxsig_f_dB,frame_parms->samples_per_slot_wCP,"","",""); } /* - for (arx=0; arxchest_f,1,time,chest_f_abs,nsymb_ce,rx_antenna_colors[arx]); } - } - } - + } + */ + /* // tx antenna 0 fl_set_xyplot_xbounds(form->chest_f,0,nb_antennas_rx*nb_antennas_tx*nsymb_ce); fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*frame_parms->symbols_per_tti,3); fl_set_xyplot_xgrid(form->chest_f,FL_GRID_MAJOR); fl_set_xyplot_data(form->chest_f,freq,chest_f_abs,nsymb_ce,"","",""); - - for (arx=1; arxchest_f,1,&freq[arx*nsymb_ce],&chest_f_abs[arx*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]); - } - - // other tx antennas - if (nb_antennas_tx > 1) { - if (nb_antennas_rx > 1) { - for (atx=1; atxchest_f,(atx<<1)+arx,&freq[((atx<<1)+arx)*nsymb_ce],&chest_f_abs[((atx<<1)+arx)*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]); - } - } - } else { // 1 rx antenna - atx=1; - arx=0; - fl_add_xyplot_overlay(form->chest_f,atx,&freq[atx*nsymb_ce],&chest_f_abs[atx*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]); - } - } */ } @@ -284,10 +254,10 @@ static void puschLLR (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_va if (!phy_vars_gnb->pusch_vars[UE_id]->llr) return; - NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; - int Qm = 2; + //NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; + //int Qm = 2; int16_t *pusch_llr = (int16_t *) phy_vars_gnb->pusch_vars[UE_id]->llr; - int coded_bits_per_codeword = frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti; + int coded_bits_per_codeword =3*8*6144+12; // (8*((3*8*6144)+12)); // frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti; float llr[coded_bits_per_codeword]; float bit[coded_bits_per_codeword]; @@ -305,20 +275,16 @@ static void puschIQ (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_var return; NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; - int32_t *pusch_comp = (int32_t *) phy_vars_gnb->pusch_vars[UE_id]->rxdataF_comp; - int sz=frame_parms->symbols_per_tti*12*frame_parms->N_RB_UL; + scopeSample_t *pusch_comp = (scopeSample_t *) phy_vars_gnb->pusch_vars[UE_id]->rxdataF_comp[0]; + int sz=frame_parms->N_RB_UL*12*frame_parms->symbols_per_slot; float I[sz], Q[sz]; - int ind=0; - for (int k=0; ksymbols_per_tti; k++) { - for (int i=0; i<12*frame_parms->N_RB_UL; i++) { - I[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i]; - Q[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1]; - ind++; - } + for (int k=0; kargc, p->argv, NULL, 0, 0); + /* form_stats_l2 = create_form_stats_form(); fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); form_stats = create_form_stats_form(); fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); */ - for(int UE_id=0; UE_idframe_parms; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; int samples_per_frame = frame_parms->samples_per_frame; - int16_t **rxsig_t = (int16_t **) phy_vars_ue->common_vars.rxdata; - float rxsig_t_dB[nb_antennas_rx][samples_per_frame]; + scopeSample_t **rxsig_t = (scopeSample_t **) phy_vars_ue->common_vars.rxdata; + float rxsig_t_dB[samples_per_frame]; float time[samples_per_frame]; if (rxsig_t[0] != NULL) { for (int i=0; iframe_parms; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - int16_t **chest_t = (int16_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time; + scopeSample_t **chest_t = (scopeSample_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time; int ymax = 0; - float chest_t_abs[nb_antennas_rx][frame_parms->ofdm_symbol_size]; + float chest_t_abs[frame_parms->ofdm_symbol_size]; float time[frame_parms->ofdm_symbol_size>>3]; if (chest_t[0] !=NULL) { for (int i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) { - chest_t_abs[0][i] = (float) (chest_t[0][2*i]*chest_t[0][2*i]+chest_t[0][2*i+1]*chest_t[0][2*i+1]); + chest_t_abs[i] = SquaredNorm(chest_t[0][i]); time[i] = (float) i; - if (chest_t_abs[0][i] > ymax) - ymax = chest_t_abs[0][i]; + if (chest_t_abs[i] > ymax) + ymax = chest_t_abs[i]; } - fl_set_xyplot_data(graph,time,chest_t_abs[0],(frame_parms->ofdm_symbol_size>>3),"","",""); + fl_set_xyplot_data(graph,time,chest_t_abs,(frame_parms->ofdm_symbol_size>>3),"","",""); } for (int arx=1; arxofdm_symbol_size>>3); i++) { - chest_t_abs[arx][i] = (float) (chest_t[arx][4*i]*chest_t[arx][4*i]+chest_t[arx][4*i+1]*chest_t[arx][4*i+1]); + chest_t_abs[i] = SquaredNorm(chest_t[arx][i]); - if (chest_t_abs[arx][i] > ymax) - ymax = chest_t_abs[arx][i]; + if (chest_t_abs[i] > ymax) + ymax = chest_t_abs[i]; } - fl_add_xyplot_overlay(graph,arx,time,chest_t_abs[arx],(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); + fl_add_xyplot_overlay(graph,arx,time,chest_t_abs,(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); fl_set_xyplot_overlay_type(graph,arx,FL_DASHED_XYPLOT); } } @@ -577,7 +550,7 @@ static void uePbchFrequencyResp (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, NR_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->frame_parms; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; uint8_t nb_antennas_tx = frame_parms->nb_antenna_ports_gNB; - int16_t **chest_f = (int16_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates; + scopeSample_t **chest_f = (scopeSample_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates; int ind = 0; float chest_f_abs[frame_parms->ofdm_symbol_size]; float freq[frame_parms->ofdm_symbol_size]; @@ -587,9 +560,7 @@ static void uePbchFrequencyResp (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, if (chest_f[(atx<<1)+arx] != NULL) { for (int k=0; kofdm_symbol_size; k++) { freq[ind] = (float)ind; - float Re = (float)(chest_f[(atx<<1)+arx][6144+(2*k)]); - float Im = (float)(chest_f[(atx<<1)+arx][6144+(2*k)+1]); - chest_f_abs[ind] = (short)10*log10(1.0+((double)Re*Re + (double)Im*Im)); + chest_f_abs[ind] = (short)10*log10(1.0+SquaredNorm(chest_f[(atx<<1)+arx][6144+k])); ind++; } } @@ -610,7 +581,7 @@ static void uePbchLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i return; int16_t *pbch_llr = (int16_t *) phy_vars_ue->pbch_vars[eNB_id]->llr; - float llr_pbch[1920], bit_pbch[1920]; + float llr_pbch[864], bit_pbch[864]; for (int i=0; i<864; i++) { llr_pbch[i] = (float) pbch_llr[i]; @@ -653,7 +624,6 @@ static void uePbchIQ (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id } static void uePcchLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { - // PDCCH LLRs if (!phy_vars_ue->pdcch_vars[0][eNB_id]->llr) return; @@ -661,7 +631,7 @@ static void uePcchLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i NR_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->frame_parms; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; uint8_t nb_antennas_tx = frame_parms->nb_antennas_tx; - int16_t **chest_f = (int16_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates; + scopeSample_t **chest_f = (scopeSample_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates; int ind = 0; float chest_f_abs[frame_parms->ofdm_symbol_size]; float freq[frame_parms->ofdm_symbol_size]; @@ -671,9 +641,7 @@ static void uePcchLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i if (chest_f[(atx<<1)+arx] != NULL) { for (int k=0; kofdm_symbol_size; k++) { freq[ind] = (float)ind; - float Re = (float)(chest_f[(atx<<1)+arx][6144+(2*k)]); - float Im = (float)(chest_f[(atx<<1)+arx][6144+(2*k)+1]); - chest_f_abs[ind] = (short)10*log10(1.0+((double)Re*Re + (double)Im*Im)); + chest_f_abs[ind] = (short)10*log10(1.0+SquaredNorm(chest_f[(atx<<1)+arx][6144+k])); ind++; } } @@ -689,7 +657,6 @@ static void uePcchLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i } static void uePcchIQ (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { - // PDCCH I/Q of MF Output if (!phy_vars_ue->pdcch_vars[0][eNB_id]->rxdataF_comp[0]) return; @@ -836,7 +803,7 @@ static FD_phy_scope_t *create_phy_scope_nrue( int ID ) { fl_hide_object(fdui->button_0); fl_end_form( ); fdui->phy_scope->fdui = fdui; - char buf[100]; + char buf[100]; sprintf(buf,"NR DL SCOPE UE %d", ID); fl_show_form (fdui->phy_scope, FL_PLACE_HOTSPOT, FL_FULLBORDER, buf); return fdui; @@ -852,23 +819,55 @@ void phy_scope_nrUE(FD_phy_scope_t *form, form=remeberForm; else remeberForm=form; + if (form==NULL) return; + int i=0; while (form->graph[i].graph) { form->graph[i].nrUEfunct(form->graph[i].graph, phy_vars_ue, eNB_id, UE_id); i++; } - + fl_check_forms(); } +static FD_phy_scope_t *form_nrue[NUMBER_OF_UE_MAX]; +static pthread_t forms_thread; + +static void *nrUEscopeThread(void *arg) { + PHY_VARS_NR_UE *ue=(PHY_VARS_NR_UE *)arg; + size_t stksize; + pthread_attr_t atr; + pthread_attr_getstacksize(&atr, &stksize); + pthread_attr_setstacksize(&atr,32*1024*1024 ); + + while (!oai_exit) { + phy_scope_nrUE(form_nrue[0], + ue, + 0,0); + usleep(99*1000); + } + + pthread_exit((void *)arg); +} + +void nrUEinitScope(PHY_VARS_NR_UE *ue) { + int fl_argc=1; + char *name="5G-UE-scope"; + fl_initialize (&fl_argc, &name, NULL, 0, 0); + form_nrue[0] = create_phy_scope_nrue(0); + threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW); +} + +// Kept to put back the functionality soon +#if 0 //FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; //char title[255]; //static pthread_t forms_thread; //xforms static void reset_stats_gNB(FL_OBJECT *button, - long arg) { + long arg) { int i,k; //PHY_VARS_gNB *phy_vars_gNB = RC.gNB[0][0]; @@ -907,32 +906,7 @@ static FD_stats_form *create_form_stats_form(int ID) { fdui->stats_form->fdui = fdui; return fdui; } - -static FD_phy_scope_t *form_nrue[NUMBER_OF_UE_MAX]; -static pthread_t forms_thread; - -static void *scope_thread(void *arg) { - PHY_VARS_NR_UE *ue=(PHY_VARS_NR_UE *)arg; - - while (!oai_exit) { - phy_scope_nrUE(form_nrue[0], - ue, - 0,0); - sleep(100*1000); - } - - pthread_exit((void *)arg); -} - -void init_scope(PHY_VARS_NR_UE *ue) { - int fl_argc=1; - char *name="5G-UE-scope"; - fl_initialize (&fl_argc, &name, NULL, 0, 0); - form_nrue[0] = create_phy_scope_nrue(0); - threadCreate(&forms_thread, scope_thread, ue, "scope", -1, OAI_PRIORITY_RT_LOW); -} - - +#endif diff --git a/openair1/PHY/TOOLS/nr_phy_scope.h b/openair1/PHY/TOOLS/nr_phy_scope.h index 31353f180c..ff347f53bb 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.h +++ b/openair1/PHY/TOOLS/nr_phy_scope.h @@ -29,7 +29,6 @@ #include #include "common/ran_context.h" #include -#include #include "PHY/defs_gNB.h" //#include "PHY/defs_nrUE.h" //#include "PHY/impl_defs_top.h" @@ -38,12 +37,12 @@ typedef struct { int *argc; char **argv; - RU_t* ru; + RU_t *ru; PHY_VARS_gNB *gNB; } scopeParms_t; -void startScope(scopeParms_t * p); -void init_scope(PHY_VARS_NR_UE *ue); +void gNBinitScope(scopeParms_t *p); +void nrUEinitScope(PHY_VARS_NR_UE *ue); extern RAN_CONTEXT_t RC; #endif From 36fab59e1c94bbf3217cd1c90fe9a20c31a59840 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 18 Jun 2020 15:41:10 +0200 Subject: [PATCH 010/149] fix pdcp race condition --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 55 +++++++-------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 85 +++++++++++------------- 3 files changed, 63 insertions(+), 79 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index b0e6143de1..7fd9c0a2c9 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -503,8 +503,6 @@ pdcp_data_ind( //----------------------------------------------------------------------------- { pdcp_t *pdcp_p = NULL; - list_t *sdu_list_p = NULL; - mem_block_t *new_sdu_p = NULL; uint8_t pdcp_header_len = 0; uint8_t pdcp_tailer_len = 0; pdcp_sn_t sequence_number = 0; @@ -576,7 +574,6 @@ pdcp_data_ind( } } - sdu_list_p = &pdcp_sdu_list; if (sdu_buffer_sizeP == 0) { LOG_W(PDCP, "SDU buffer size is zero! Ignoring this chunk!\n"); @@ -974,9 +971,8 @@ pdcp_data_ind( #endif if (FALSE == packet_forwarded) { - new_sdu_p = get_free_mem_block(sdu_buffer_sizeP - payload_offset + sizeof (pdcp_data_ind_header_t), __func__); + notifiedFIFO_elt_t * new_sdu_p = newNotifiedFIFO_elt(sdu_buffer_sizeP - payload_offset + sizeof (pdcp_data_ind_header_t), 0, NULL, NULL); - if (new_sdu_p) { if ((MBMS_flagP == 0) && (pdcp_p->rlc_mode == RLC_MODE_AM)) { pdcp_p->last_submitted_pdcp_rx_sn = sequence_number; } @@ -984,14 +980,15 @@ pdcp_data_ind( /* * Prepend PDCP indication header which is going to be removed at pdcp_fifo_flush_sdus() */ - memset(new_sdu_p->data, 0, sizeof (pdcp_data_ind_header_t)); - ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size = sdu_buffer_sizeP - payload_offset; + pdcp_data_ind_header_t * pdcpHead=(pdcp_data_ind_header_t *)NotifiedFifoData(new_sdu_p); + memset(pdcpHead, 0, sizeof (pdcp_data_ind_header_t)); + pdcpHead->data_size = sdu_buffer_sizeP - payload_offset; AssertFatal((sdu_buffer_sizeP - payload_offset >= 0), "invalid PDCP SDU size!"); // Here there is no virtualization possible - // set ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst for IP layer here + // set pdcpHead->inst for IP layer here if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id; + pdcpHead->rb_id = rb_id; if (EPC_MODE_ENABLED) { /* for the UE compiled in S1 mode, we need 1 here @@ -1002,48 +999,43 @@ pdcp_data_ind( #ifdef UESIM_EXPANSION if (UE_NAS_USE_TUN) { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; + pdcpHead->inst = ctxt_pP->module_id; } else { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 0; + pdcpHead->inst = 0; } #else - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; + pdcpHead->inst = ctxt_pP->module_id; #endif } else { // nfapi_mode if (UE_NAS_USE_TUN) { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; + pdcpHead->inst = ctxt_pP->module_id; } else { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1; + pdcpHead->inst = 1; } } // nfapi_mode } } else { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * LTE_maxDRB); - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; + pdcpHead->rb_id = rb_id + (ctxt_pP->module_id * LTE_maxDRB); + pdcpHead->inst = ctxt_pP->module_id; } if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { static uint32_t pdcp_inst = 0; - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = pdcp_inst++; - LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size); + pdcpHead->inst = pdcp_inst++; + LOG_D(PDCP, "inst=%d size=%d\n", pdcpHead->inst, pdcpHead->data_size); } - memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], + memcpy(pdcpHead+1, &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset); - - #if defined(ENABLE_PDCP_PAYLOAD_DEBUG) - LOG_I(PDCP, "Printing first bytes of PDCP SDU before adding it to the list: \n"); - for (int i=0; i<30; i++){ - LOG_I(PDCP, "%x", sdu_buffer_pP->data[i]); - } - #endif - list_add_tail_eurecom (new_sdu_p, sdu_list_p); - } + if( LOG_DEBUGFLAG(DEBUG_PDCP) ) + log_dump(PDCP, pdcpHead+1, min(sdu_buffer_sizeP - payload_offset,30) , LOG_DUMP_CHAR, + "Printing first bytes of PDCP SDU before adding it to the list: \n"); + pushNotifiedFIFO(&pdcp_sdu_list, new_sdu_p); /* Print octets of incoming data in hexadecimal form */ - LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", + LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t), sdu_buffer_sizeP - payload_offset); //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); @@ -2467,7 +2459,7 @@ void pdcp_layer_init(void) /* * Initialize SDU list */ - list_init(&pdcp_sdu_list, NULL); + initNotifiedFIFO(&pdcp_sdu_list); pdcp_coll_p = hashtable_create ((LTE_maxDRB + 2) * NUMBER_OF_UE_MAX, NULL, pdcp_free); AssertFatal(pdcp_coll_p != NULL, "UNRECOVERABLE error, PDCP hashtable_create failed"); @@ -2540,7 +2532,8 @@ void pdcp_layer_init(void) void pdcp_layer_cleanup (void) //----------------------------------------------------------------------------- { - list_free (&pdcp_sdu_list); + //list_free (&pdcp_sdu_list); + while(pollNotifiedFIFO(&pdcp_sdu_list)) {}; hashtable_destroy(&pdcp_coll_p); #ifdef MBMS_MULTICAST_OUT diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index e9ac85866c..8e265e8cf1 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -522,7 +522,7 @@ pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][LTE_maxServiceC sdu_size_t pdcp_output_sdu_bytes_to_write; sdu_size_t pdcp_output_header_bytes_to_write; -list_t pdcp_sdu_list; +notifiedFIFO_t pdcp_sdu_list; int pdcp_sent_a_sdu; pdcp_data_req_header_t pdcp_input_header; unsigned char pdcp_input_sdu_buffer[MAX_IP_PACKET_SIZE]; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index d203408e55..d764d6176a 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -111,69 +111,59 @@ void debug_pdcp_pc5s_sdu(sidelink_pc5s_element *sl_pc5s_msg, char *title) { } //----------------------------------------------------------------------------- int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { - mem_block_t *sdu_p; - int pdcp_nb_sdu_sent = 0; - int ret=0; + notifiedFIFO_elt_t *sdu_p; + int pdcp_nb_sdu_sent = 0; + int ret=0; + while ((sdu_p = pollNotifiedFIFO(&pdcp_sdu_list)) != NULL ) { + pdcp_data_ind_header_t * pdcpHead=(pdcp_data_ind_header_t *)NotifiedFifoData(sdu_p); + AssertFatal(pdcpHead->inst==ctxt_pP->module_id, "To implement correctly multi module id\n"); - while ((sdu_p = list_get_head (&pdcp_sdu_list)) != NULL && ((pdcp_data_ind_header_t *)(sdu_p->data))->inst == ctxt_pP->module_id) { - ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; - int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; + int rb_id = pdcpHead->rb_id; int sizeToWrite= sizeof (pdcp_data_ind_header_t) + - ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; - + pdcpHead->data_size; + void * pdcpData=(void*)(pdcpHead+1); + if (rb_id == 10) { //hardcoded for PC5-Signaling if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { - debug_pdcp_pc5s_sdu((sidelink_pc5s_element *)&(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), + debug_pdcp_pc5s_sdu((sidelink_pc5s_element *)pdcpData, "pdcp_fifo_flush_sdus sends a aPC5S message"); } - ret = sendto(pdcp_pc5_sockfd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), + ret = sendto(pdcp_pc5_sockfd, pdcpData, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr,sizeof(prose_pdcp_addr) ); } else if (UE_NAS_USE_TUN) { - //ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); + //ret = write(nas_sock_fd[ctxt_pP->module_id], pdcpData,sizeToWrite ); if(rb_id == mbms_rab_id){ - ret = write(nas_sock_mbms_fd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); - LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH MBMS DATA TO rb_id %d handle %d sizeToWrite %d\n",ret,rb_id,nas_sock_fd[ctxt_pP->module_id],sizeToWrite); + ret = write(nas_sock_mbms_fd, pdcpData,sizeToWrite ); + LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH MBMS DATA TO rb_id %d handle %d sizeToWrite %d\n", + ret,rb_id,nas_sock_fd[ctxt_pP->module_id],sizeToWrite); } else { - #if defined(ENABLE_PDCP_PAYLOAD_DEBUG) - LOG_I(PHY, "PDCP output to be sent to TUN interface: \n"); - for (int i = sizeof(pdcp_data_ind_header_t); i < sizeToWrite; i++) { - printf("%02x ",(unsigned char)sdu_p->data[i]); - } - printf("\n"); - #endif - ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); - //LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH DATA TO rb_id %d handle %d sizeToWrite %d\n",ret,rb_id,nas_sock_fd[ctxt_pP->module_id],sizeToWrite); + if( LOG_DEBUGFLAG(DEBUG_PDCP) ) + log_dump(PDCP, pdcpData, sizeToWrite, LOG_DUMP_CHAR,"PDCP output to be sent to TUN interface: \n"); + ret = write(nas_sock_fd[ctxt_pP->module_id], pdcpData,sizeToWrite ); + LOG_T(PDCP,"[UE PDCP_FIFOS] ret %d TRIED TO PUSH DATA TO rb_id %d handle %d sizeToWrite %d\n", + ret,rb_id,nas_sock_fd[ctxt_pP->module_id],sizeToWrite); } } else if (ENB_NAS_USE_TUN) { - #if defined(ENABLE_PDCP_PAYLOAD_DEBUG) - LOG_I(PHY, "PDCP output to be sent to TUN interface: \n"); - for (int i = sizeof(pdcp_data_ind_header_t); i < sizeToWrite; i++) { - printf("%02x ",(unsigned char)sdu_p->data[i]); - } - printf("\n"); - #endif - ret = write(nas_sock_fd[0], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), sizeToWrite); - + if( LOG_DEBUGFLAG(DEBUG_PDCP) ) + log_dump(PDCP, pdcpData, sizeToWrite, LOG_DUMP_CHAR,"PDCP output to be sent to TUN interface: \n"); + ret = write(nas_sock_fd[0], pdcpData, sizeToWrite); + LOG_T(PDCP,"[NB PDCP_FIFOS] ret %d TRIED TO PUSH DATA TO rb_id %d handle %d sizeToWrite %d\n",ret,rb_id,nas_sock_fd[0],sizeToWrite); } else if (PDCP_USE_NETLINK) { - memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) sdu_p->data, sizeToWrite); + memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) pdcpHead, sizeToWrite); nas_nlh_tx->nlmsg_len = sizeToWrite; ret = sendmsg(nas_sock_fd[0],&nas_msg_tx,0); } // PDCP_USE_NETLINK - - AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s), nas_sock_fd[0]: %d\n", errno, strerror(errno), nas_sock_fd[0]); - #if defined(ENABLE_PDCP_PAYLOAD_DEBUG) - LOG_I(PDCP, "Printing first bytes of PDCP SDU before removing it from the list: \n"); - for (int i=0; i<30; i++){ - LOG_I(PDCP, "%x", sdu_p->data[i]); - } - #endif - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); + AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s), nas_sock_fd[0]: %d\n", errno, strerror(errno), nas_sock_fd[0]); + + if( LOG_DEBUGFLAG(DEBUG_PDCP) ) + log_dump(PDCP, pdcpData, min(sizeToWrite,30) , LOG_DUMP_CHAR, + "Printing first bytes of PDCP SDU before removing it from the list: \n"); + delNotifiedFIFO_elt (sdu_p); pdcp_nb_sdu_sent ++; } @@ -181,12 +171,14 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { } int pdcp_fifo_flush_mbms_sdus(const protocol_ctxt_t *const ctxt_pP) { - mem_block_t *sdu_p; + notifiedFIFO_elt_t *sdu_p; int pdcp_nb_sdu_sent = 0; //int ret=0; - while ((sdu_p = list_get_head (&pdcp_sdu_list)) != NULL && ((pdcp_data_ind_header_t *)(sdu_p->data))->inst == ctxt_pP->module_id) { - ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; + while ((sdu_p = pollNotifiedFIFO(&pdcp_sdu_list)) != NULL ) { + pdcp_data_ind_header_t * pdcpHead=(pdcp_data_ind_header_t *)NotifiedFifoData(sdu_p); + AssertFatal(pdcpHead->inst==ctxt_pP->module_id, "To implement correctly multi module id\n"); + //int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; //int sizeToWrite= sizeof (pdcp_data_ind_header_t) + //((pdcp_data_ind_header_t *) sdu_p->data)->data_size; @@ -212,8 +204,7 @@ int pdcp_fifo_flush_mbms_sdus(const protocol_ctxt_t *const ctxt_pP) { //} // PDCP_USE_NETLINK //AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno)); - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); + delNotifiedFIFO_elt (sdu_p); pdcp_nb_sdu_sent ++; } From 794f9dac714d881fc888e8efbb4045a8a1b4af8f Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Sun, 1 Mar 2020 21:03:15 +0100 Subject: [PATCH 011/149] fixing NR_arfcn calculation --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index cfde40daad..81e0b20fb5 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -69,14 +69,14 @@ nr_bandentry_t nr_bandtable[] = { {83, 703000, 748000, 000, 000, 20, 140600, 100}, {84, 1920000, 1980000, 000, 000, 20, 384000, 100}, {86, 1710000, 1785000, 000, 000, 20, 342000, 100}, - {257,26500000,29500000,26500000,29500000, 1,2054166, 60}, - {257,26500000,29500000,26500000,29500000, 2,2054167, 120}, - {258,24250000,27500000,24250000,27500000, 1,2016667, 60}, - {258,24250000,27500000,24250000,27500000, 2,2016667, 120}, - {260,37000000,40000000,37000000,40000000, 1,2229166, 60}, - {260,37000000,40000000,37000000,40000000, 2,2229167, 120}, - {261,27500000,28350000,27500000,28350000, 1,2070833, 60}, - {261,27500000,28350000,27500000,28350000, 2,2070833, 120} + {257,26500020,29500000,26500020,29500000, 1,2054166, 60}, + {257,26500080,29500000,26500080,29500000, 2,2054167, 120}, + {258,24250080,27500000,24250080,27500000, 1,2016667, 60}, + {258,24250080,27500000,24250080,27500000, 2,2016667, 120}, + {260,37000020,40000000,37000020,40000000, 1,2229166, 60}, + {260,37000080,40000000,37000080,40000000, 2,2229167, 120}, + {261,27500040,28350000,27500040,28350000, 1,2070833, 60}, + {261,27500040,28350000,27500040,28350000, 2,2070833, 120} }; @@ -306,13 +306,23 @@ uint32_t to_nrarfcn(int nr_bandP, (long long unsigned int)(nr_bandtable[i].dl_max - bw_kHz)); int deltaFglobal = 60; + uint32_t N_REF_Offs = 2016667; + uint64_t F_REF_Offs_khz = 24250080; - if (dl_CarrierFreq < 3e9) deltaFglobal = 15; - if (dl_CarrierFreq < 24.25e9) deltaFglobal = 5; + if (dl_CarrierFreq < 24.25e9) { + deltaFglobal = 15; + N_REF_Offs = 600000; + F_REF_Offs_khz = 3000000; + } + if (dl_CarrierFreq < 3e9) { + deltaFglobal = 5; + N_REF_Offs = 0; + F_REF_Offs_khz = 0; + } // This is equation before Table 5.4.2.1-1 in 38101-1-f30 // F_REF=F_REF_Offs + deltaF_Global(N_REF-NREF_REF_Offs) - nrarfcn = (((dl_CarrierFreq_by_1k - nr_bandtable[i].dl_min)/deltaFglobal)+nr_bandtable[i].N_OFFs_DL); + nrarfcn = (((dl_CarrierFreq_by_1k - F_REF_Offs_khz)/deltaFglobal)+N_REF_Offs); delta_arfcn = nrarfcn - nr_bandtable[i].N_OFFs_DL; if(delta_arfcn%(nr_bandtable[i].step_size)!=0) @@ -329,13 +339,21 @@ uint64_t from_nrarfcn(int nr_bandP, { int i; int deltaFglobal = 5; + uint32_t N_REF_Offs = 0; + uint64_t F_REF_Offs_khz = 0; int scs_khz = 15< 599999 && dl_nrarfcn < 2016667) - deltaFglobal = 15; - if (dl_nrarfcn > 2016666 && dl_nrarfcn < 3279166) + if (dl_nrarfcn > 599999 && dl_nrarfcn < 2016667) { + deltaFglobal = 15; + N_REF_Offs = 600000; + F_REF_Offs_khz = 3000000; + } + if (dl_nrarfcn > 2016666 && dl_nrarfcn < 3279166) { deltaFglobal = 60; + N_REF_Offs = 2016667; + F_REF_Offs_khz = 24250080; + } AssertFatal(nr_bandP <= 261, "nr_band %d > 260\n", nr_bandP); for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++); @@ -349,14 +367,11 @@ uint64_t from_nrarfcn(int nr_bandP, if(delta_arfcn%(nr_bandtable[i].step_size)!=0) AssertFatal(1==0,"dl_nrarfcn %u is not on the raster for step size %lu",dl_nrarfcn,nr_bandtable[i].step_size); - LOG_I(PHY,"Computing dl_frequency (pointA %llu => %llu (dlmin %llu, nr_bandtable[%d].N_OFFs_DL %llu))\n", + LOG_I(PHY,"Computing dl_frequency (arfcn %llu => %llu)\n", (unsigned long long)dl_nrarfcn, - (unsigned long long)(1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal)), - (unsigned long long)nr_bandtable[i].dl_min, - i, - (unsigned long long)nr_bandtable[i].N_OFFs_DL); + (unsigned long long)(1000*(F_REF_Offs_khz + (dl_nrarfcn - N_REF_Offs) * deltaFglobal))); - return 1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal); + return 1000*(F_REF_Offs_khz + (dl_nrarfcn - N_REF_Offs) * deltaFglobal); } From 2634d57282207983c9524770747b287176b2602b Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Mon, 10 Feb 2020 10:42:40 +0100 Subject: [PATCH 012/149] changing RRC measurement config to FR2 --- openair2/RRC/LTE/rrc_eNB.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 5965e51720..27f04025ee 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -3214,18 +3214,18 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t if (MeasObj2 == NULL) exit(1); MeasObj2->measObjectId = 2; MeasObj2->measObject.present = LTE_MeasObjectToAddMod__measObject_PR_measObjectNR_r15; - MeasObj2->measObject.choice.measObjectNR_r15.carrierFreq_r15 = 642256; //634000; //(634000 = 3.51GHz) (640000 = 3.6GHz) (641272 = 3619.08MHz = 3600 + 30/1000*106*12/2) (642256 is for 3.6GHz and absoluteFrequencySSB = 642016) + MeasObj2->measObject.choice.measObjectNR_r15.carrierFreq_r15 = 2071241; //2071249=27525MHz (band n261) //(634000 = 3.51GHz) (640000 = 3.6GHz) (641272 = 3619.08MHz = 3600 + 30/1000*106*12/2) (642256 is for 3.6GHz and absoluteFrequencySSB = 642016) MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.periodicityAndOffset_r15.present = LTE_MTC_SSB_NR_r15__periodicityAndOffset_r15_PR_sf20_r15; MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.periodicityAndOffset_r15.choice.sf20_r15 = 0; MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.ssb_Duration_r15 = LTE_MTC_SSB_NR_r15__ssb_Duration_r15_sf4; - MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15 = LTE_RS_ConfigSSB_NR_r15__subcarrierSpacingSSB_r15_kHz30; + MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15 = LTE_RS_ConfigSSB_NR_r15__subcarrierSpacingSSB_r15_kHz120; MeasObj2->measObject.choice.measObjectNR_r15.quantityConfigSet_r15 = 1; MeasObj2->measObject.choice.measObjectNR_r15.ext1 = calloc(1, sizeof(struct LTE_MeasObjectNR_r15__ext1)); if (MeasObj2->measObject.choice.measObjectNR_r15.ext1 == NULL) exit(1); MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15 = calloc(1, sizeof(struct LTE_MeasObjectNR_r15__ext1__bandNR_r15)); if (MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15 == NULL) exit(1); MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->present = LTE_MeasObjectNR_r15__ext1__bandNR_r15_PR_setup; - MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->choice.setup = 78; + MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->choice.setup = 261; ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj2); } @@ -4375,6 +4375,7 @@ rrc_eNB_process_MeasurementReport( case 7: LOG_D(RRC, "NR event frame %d subframe %d\n", ctxt_pP->frame, ctxt_pP->subframe); + printf("NR event frame %d subframe %d\n", ctxt_pP->frame, ctxt_pP->subframe); break; default: From e4b2689e2912fda30c74b2f887ee103b022c660b Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 19 Jun 2020 20:35:32 +0200 Subject: [PATCH 013/149] continue scope rebuild --- openair1/PHY/TOOLS/nr_phy_scope.c | 616 ++++++++++------------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 4 - openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 2 - 3 files changed, 257 insertions(+), 365 deletions(-) diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 24b7be74d1..9d4648c94f 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -48,8 +48,13 @@ typedef struct { typedef struct OAIgraph { FL_OBJECT *graph; - void (*gNBfunct) (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id); - void (*nrUEfunct) (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id); + float maxX; + float maxY; + float minX; + float minY; + int iteration; + void (*gNBfunct) (struct OAIgraph *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id); + void (*nrUEfunct)(struct OAIgraph *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id); } OAIgraph_t; /* Forms and Objects */ @@ -57,7 +62,7 @@ typedef struct { FL_FORM *phy_scope; OAIgraph_t graph[20]; FL_OBJECT *button_0; -} FD_phy_scope_t; +} OAI_phy_scope_t; typedef struct { FL_FORM *stats_form; @@ -73,18 +78,8 @@ static void drawsymbol(FL_OBJECT *obj, int id, fl_points( p, n, FL_YELLOW); } -static void ia_receiver_on_off( FL_OBJECT *button, long arg) { - if (fl_get_button(button)) { - fl_set_object_label(button, "IA Receiver ON"); - // PHY_vars_UE_g[0][0]->use_ia_receiver = 1; - fl_set_object_color(button, FL_GREEN, FL_GREEN); - } else { - fl_set_object_label(button, "IA Receiver OFF"); - // PHY_vars_UE_g[0][0]->use_ia_receiver = 0; - fl_set_object_color(button, FL_RED, FL_RED); - } -} - +// button callback example +#if 0 static void dl_traffic_on_off( FL_OBJECT *button, long arg) { if (fl_get_button(button)) { fl_set_object_label(button, "DL Traffic ON"); @@ -96,198 +91,188 @@ static void dl_traffic_on_off( FL_OBJECT *button, long arg) { fl_set_object_color(button, FL_RED, FL_RED); } } +#endif static FL_OBJECT *commonGraph( int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { FL_OBJECT *graph; graph=fl_add_xyplot(type, x, y, w, h, label); - fl_set_object_boxtype(graph, FL_EMBOSSED_BOX ); fl_set_object_lcolor(graph, FL_WHITE ); // Label color - fl_set_xyplot_symbol(graph, 0, drawsymbol); fl_set_object_color(graph, FL_BLACK, pointColor); + fl_set_xyplot_symbol(graph, -1, drawsymbol); return graph; } -static OAIgraph_t gNBcommonGraph( void (*funct) (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id), +static OAIgraph_t gNBcommonGraph( void (*funct) (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id), int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { OAIgraph_t graph; graph.graph=commonGraph(type, x, y, w, h, label, pointColor); graph.gNBfunct=funct; graph.nrUEfunct=NULL; + graph.maxX=0; + graph.maxY=0; + graph.minX=0; + graph.minY=0; return graph; } -static OAIgraph_t nrUEcommonGraph( void (*funct) (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id), +static OAIgraph_t nrUEcommonGraph( void (*funct) (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id), int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { OAIgraph_t graph; graph.graph=commonGraph(type, x, y, w, h, label, pointColor); graph.gNBfunct=NULL; graph.nrUEfunct=funct; + graph.maxX=0; + graph.maxY=0; + graph.minX=0; + graph.minY=0; return graph; } -void phy_scope_gNB(FD_phy_scope_t *form, - PHY_VARS_gNB *phy_vars_gnb, - RU_t *phy_vars_ru, - int UE_id) { - static FD_phy_scope_t *remeberForm=NULL; - - if (form==NULL) - form=remeberForm; - else - remeberForm=form; - - if (form==NULL) return; - - int i=0; - - while (form->graph[i].graph) { - form->graph[i].gNBfunct(form->graph[i].graph, phy_vars_gnb, phy_vars_ru, UE_id); - i++; +static void setRange(OAIgraph_t *graph, float minX, float maxX, float minY, float maxY) { + if ( maxX > graph->maxX || maxY > graph->maxY || minX < graph->minX || minY < graph->minY ) { + graph->maxX=max(graph->maxX,maxX); + graph->minX=min(graph->minX,minX); + graph->maxY=max(graph->maxY,maxY); + graph->minY=min(graph->minY,minY); + fl_set_xyplot_ybounds(graph->graph, graph->minY, graph->maxY); + fl_set_xyplot_xbounds(graph->graph, graph->minX, graph->maxX); } - - fl_check_forms(); } -static void timeSignal (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { +static void oai_xygraph(OAIgraph_t *graph, float *x, float *y, int len, int layer, int NoAutoScale) { + if (layer==0) + fl_set_xyplot_data(graph->graph,x,y,len,"","",""); + else + fl_add_xyplot_overlay(graph->graph,layer,x,y,len,rx_antenna_colors[layer]); + + if ( NoAutoScale && graph->iteration%NoAutoScale == 0) { + float maxX=0, maxY=0, minX=0, minY=0; + + for (int k=0; kiteration++; +} + +static void genericLogPowerPerAntena(OAIgraph_t *graph, const int nb_ant, const scopeSample_t **data, const int len) { + float values[len]; + float time[len]; + + for (int ant=0; antcommon.rxdata) return; NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; - uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - scopeSample_t **rxsig_t = (scopeSample_t **)phy_vars_ru->common.rxdata; - float rxsig_t_dB[frame_parms->samples_per_frame]; - float time[frame_parms->samples_per_frame]; + genericLogPowerPerAntena(graph, frame_parms->nb_antennas_rx, + (const scopeSample_t **)phy_vars_ru->common.rxdata, + frame_parms->samples_per_frame); +} - for (int arx=0; arxsamples_per_frame; i++) { - rxsig_t_dB[i] = 10*log10(1.0+SquaredNorm(rxsig_t[arx][i])); +static void timeResponse (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) { + const int len=2*phy_vars_gnb->frame_parms.ofdm_symbol_size; + float values[len]; + float time[len]; + const int ant=0; // display antenna 0 for each UE + + for (int ue=0; uepusch_vars[ue]->ul_ch_estimates_time[ant]; + + if (data != NULL) { + for (int i=0; isamples_per_frame,"","",""); - else - fl_add_xyplot_overlay(graph,arx,time,rxsig_t_dB,frame_parms->samples_per_frame,rx_antenna_colors[arx]); + oai_xygraph(graph,time,values, len, ue, 10); } } } -static void timeResponse (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { - if (!phy_vars_gnb->pusch_vars[UE_id]->ul_ch_estimates_time) - return; - +static void frequencyResponse (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) { NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; - uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - scopeSample_t **chest_t = (scopeSample_t **) phy_vars_gnb->pusch_vars[UE_id]->ul_ch_estimates_time; - int ymax = 0; - float time2[2*frame_parms->ofdm_symbol_size]; - float chest_t_abs[2*frame_parms->ofdm_symbol_size]; - - for (int arx=0; arxofdm_symbol_size); i++) { - time2[i] = (float)i; - chest_t_abs[i] = 10*log10(1.0 + SquaredNorm(chest_t[0][i])); - - if (chest_t_abs[i] > ymax) - ymax = chest_t_abs[i]; - } - - if (arx==0) - fl_set_xyplot_data(graph,time2,chest_t_abs,(2*frame_parms->ofdm_symbol_size),"","",""); - else { - fl_add_xyplot_overlay(graph,arx,time2,chest_t_abs,(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); - fl_set_xyplot_overlay_type(graph,arx,FL_DASHED_XYPLOT); - } - } - } - - // Avoid flickering effect - // fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax); - fl_set_xyplot_ybounds(graph,0,ymax); + genericLogPowerPerAntena(graph, frame_parms->nb_antennas_rx, + (const scopeSample_t **)phy_vars_ru->common.rxdataF, + frame_parms->samples_per_slot_wCP); } -static void frequencyResponse (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { - // Channel Frequency Response - if (!phy_vars_ru->common.rxdataF) - return; - - NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; - //uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - scopeSample_t **rxsig_f = (scopeSample_t **) phy_vars_ru->common.rxdataF; - float rxsig_f_dB[frame_parms->samples_per_slot_wCP]; - float time[frame_parms->samples_per_slot_wCP]; - - if (rxsig_f[0] != NULL) { - for (int i=0; isamples_per_slot_wCP; i++) { - rxsig_f_dB[i] = 10*log10(1.0+ SquaredNorm(rxsig_f[0][i])); - time[i] = (float) i; - } - - fl_set_xyplot_data(graph,time,rxsig_f_dB,frame_parms->samples_per_slot_wCP,"","",""); - } - - /* - for (int arx=1; arxchest_f,1,time,chest_f_abs,nsymb_ce,rx_antenna_colors[arx]); - } - } - */ - /* - // tx antenna 0 - fl_set_xyplot_xbounds(form->chest_f,0,nb_antennas_rx*nb_antennas_tx*nsymb_ce); - fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*frame_parms->symbols_per_tti,3); - fl_set_xyplot_xgrid(form->chest_f,FL_GRID_MAJOR); - fl_set_xyplot_data(form->chest_f,freq,chest_f_abs,nsymb_ce,"","",""); - */ -} - -static void puschLLR (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { - // PUSCH LLRs - if (!phy_vars_gnb->pusch_vars[UE_id]->llr) - return; - - //NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; +static void puschLLR (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) { //int Qm = 2; - int16_t *pusch_llr = (int16_t *) phy_vars_gnb->pusch_vars[UE_id]->llr; int coded_bits_per_codeword =3*8*6144+12; // (8*((3*8*6144)+12)); // frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti; float llr[coded_bits_per_codeword]; float bit[coded_bits_per_codeword]; - for (int i=0; ipusch_vars[ue]->llr; - fl_set_xyplot_data(graph,bit,llr,coded_bits_per_codeword,"","",""); + if (pusch_llr) { + for (int i=0; ipusch_vars[UE_id]->rxdataF_comp) - return; - +static void puschIQ (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) { NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms; - scopeSample_t *pusch_comp = (scopeSample_t *) phy_vars_gnb->pusch_vars[UE_id]->rxdataF_comp[0]; int sz=frame_parms->N_RB_UL*12*frame_parms->symbols_per_slot; float I[sz], Q[sz]; - for (int k=0; kpusch_vars[ue]->rxdataF_comp[0]; + + if (pusch_comp) { + for (int k=0; kpucch1ab_stats[UE_id]; int32_t *pucch1_comp = (int32_t *) NULL; //phy_vars_gnb->pucch1_stats[UE_id]; float I_pucch[10240],Q_pucch[10240],A_pucch[10240],B_pucch[10240],C_pucch[10240]; @@ -308,16 +293,15 @@ static void puschIQ (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_var fl_set_xyplot_xbounds(graph,-5000,5000); fl_set_xyplot_ybounds(graph,0,80); } + */ } -static void pucchEnergy (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { +static void pucchIQ (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) { } -static void pucchIQ (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { -} - -static void puschThroughtput (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id) { +static void puschThroughtput (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) { // PUSCH Throughput + /* memmove( tput_time_enb[UE_id], &tput_time_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) ); memmove( tput_enb[UE_id], &tput_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) ); tput_time_enb[UE_id][TPUT_WINDOW_LENGTH-1] = (float) 0; @@ -325,64 +309,81 @@ static void puschThroughtput (FL_OBJECT *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t fl_set_xyplot_data(graph,tput_time_enb[UE_id],tput_enb[UE_id],TPUT_WINDOW_LENGTH,"","",""); // fl_get_xyplot_ybounds(form->pusch_tput,&ymin,&ymax); // fl_set_xyplot_ybounds(form->pusch_tput,0,ymax); + */ } -static FD_phy_scope_t *create_phy_scope_gnb(int UE_id ) { +static OAI_phy_scope_t *create_phy_scope_gnb(void) { FL_OBJECT *obj; - FD_phy_scope_t *fdui = fl_malloc( sizeof *fdui ); + OAI_phy_scope_t *fdui = calloc(( sizeof *fdui ),1); // Define form fdui->phy_scope = fl_bgn_form( FL_NO_BOX, 800, 800 ); // This the whole UI box obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 800, "" ); - fl_set_object_color( obj, FL_BLACK, FL_BLACK ); + fl_set_object_color( obj, FL_BLACK, FL_WHITE ); + int curY=0,x,y,w,h; // Received signal - fdui->graph[0] = gNBcommonGraph( timeSignal, FL_IMPULSE_XYPLOT, 20, 20, 370, 100, + fdui->graph[0] = gNBcommonGraph( timeSignal, FL_FILL_XYPLOT, 0, curY, 400, 100, "Received Signal (Time-Domain, dB)", FL_RED ); // Time-domain channel response - fdui->graph[1] = gNBcommonGraph( timeResponse, FL_NORMAL_XYPLOT, 410, 20, 370, 100, + fdui->graph[1] = gNBcommonGraph( timeResponse, FL_NORMAL_XYPLOT, 410, curY, 400, 100, "SRS Frequency Response (samples, abs)", FL_RED ); + fl_get_object_bbox(fdui->graph[0].graph,&x, &y,&w, &h); + curY+=h; // Frequency-domain channel response - fdui->graph[2] = gNBcommonGraph( frequencyResponse, FL_IMPULSE_XYPLOT, 20, 140, 760, 100, + fdui->graph[2] = gNBcommonGraph( frequencyResponse, FL_FILL_XYPLOT, 0, curY, 800, 100, "Channel Frequency Response (RE, dB)", FL_RED ); + fl_get_object_bbox(fdui->graph[2].graph,&x, &y,&w, &h); + curY+=h; // LLR of PUSCH - fdui->graph[3] = gNBcommonGraph( puschLLR, FL_POINTS_XYPLOT, 20, 260, 500, 200, + fdui->graph[3] = gNBcommonGraph( puschLLR, FL_POINTS_XYPLOT, 0, curY, 500, 200, "PUSCH Log-Likelihood Ratios (LLR, mag)", FL_YELLOW ); // I/Q PUSCH comp - fdui->graph[4] = gNBcommonGraph( puschIQ, FL_POINTS_XYPLOT, 540, 260, 240, 200, + fdui->graph[4] = gNBcommonGraph( puschIQ, FL_POINTS_XYPLOT, 500, curY, 300, 200, "PUSCH I/Q of MF Output", FL_YELLOW ); + fl_get_object_bbox(fdui->graph[3].graph,&x, &y,&w, &h); + curY+=h; // I/Q PUCCH comp (format 1) - fdui->graph[5] = gNBcommonGraph( pucchEnergy, FL_POINTS_XYPLOT, 540, 480, 240, 100, + fdui->graph[5] = gNBcommonGraph( pucchEnergy, FL_POINTS_XYPLOT, 0, curY, 300, 100, "PUCCH1 Energy (SR)", FL_YELLOW ); // fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR); // I/Q PUCCH comp (fromat 1a/b) - fdui->graph[6] = gNBcommonGraph( pucchIQ, FL_POINTS_XYPLOT, 540, 600, 240, 100, + fdui->graph[6] = gNBcommonGraph( pucchIQ, FL_POINTS_XYPLOT, 500, curY, 300, 100, "PUCCH I/Q of MF Output", FL_YELLOW ); + fl_get_object_bbox(fdui->graph[6].graph,&x, &y,&w, &h); + curY+=h; // Throughput on PUSCH - fdui->graph[7] = gNBcommonGraph( puschThroughtput, FL_NORMAL_XYPLOT, 20, 480, 500, 100, + fdui->graph[7] = gNBcommonGraph( puschThroughtput, FL_NORMAL_XYPLOT, 0, curY, 500, 100, "PUSCH Throughput [frame]/[kbit/s]", FL_WHITE ); fdui->graph[8].graph=NULL; - - // Generic eNB Button - if (0) { // code kept to later add command buttons - fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 20, 600, 240, 40, "" ); - fl_set_object_lalign(fdui->button_0, FL_ALIGN_CENTER ); - fl_set_button(fdui->button_0,0); - otg_enabled = 0; - fl_set_object_label(fdui->button_0, "DL Traffic OFF"); - fl_set_object_color(fdui->button_0, FL_RED, FL_RED); - fl_set_object_callback(fdui->button_0, dl_traffic_on_off, 0 ); - } - fl_end_form( ); fdui->phy_scope->fdui = fdui; - char title[100]; - sprintf (title, "LTE UL SCOPE eNB for UE %d",UE_id); - fl_show_form (fdui->phy_scope, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + fl_show_form (fdui->phy_scope, FL_PLACE_HOTSPOT, FL_FULLBORDER, "LTE UL SCOPE gNB"); return fdui; } -static FD_phy_scope_t *form_gnb[NUMBER_OF_UE_MAX]= {0}; -static unsigned char scope_enb_num_ue = 1; +static const int scope_enb_num_ue = 1; +void phy_scope_gNB(OAI_phy_scope_t *form, + PHY_VARS_gNB *phy_vars_gnb, + RU_t *phy_vars_ru, + int UE_id) { + static OAI_phy_scope_t *remeberForm=NULL; + + if (form==NULL) + form=remeberForm; + else + remeberForm=form; + + if (form==NULL) return; + + int i=0; + + while (form->graph[i].graph) { + form->graph[i].gNBfunct(form->graph+i, phy_vars_gnb, phy_vars_ru, UE_id); + i++; + } + + fl_check_forms(); +} static void *scope_thread_gNB(void *arg) { scopeParms_t *p=(scopeParms_t *) arg; @@ -394,155 +395,40 @@ static void *scope_thread_gNB(void *arg) { pthread_attr_getstacksize(&atr, &stksize); pthread_attr_setstacksize(&atr,32*1024*1024 ); sleep(3); // no clean interthread barriers + fl_initialize (p->argc, p->argv, NULL, 0, 0); + int nb_ue=min(NUMBER_OF_UE_MAX, scope_enb_num_ue); + OAI_phy_scope_t *form_gnb = create_phy_scope_gnb(); while (!oai_exit) { - int ue_cnt=0; - - for(int UE_id=0; UE_idgNB, p->ru, UE_id); - ue_cnt++; - } - } - + phy_scope_gNB(form_gnb, p->gNB, p->ru, nb_ue); usleep(99*1000); } - // printf("%s",stats_buffer); - /*#ifdef ENABLE_XFORMS_WRITE_STATS - - if (eNB_stats) { - rewind (gNB_stats); - fwrite (stats_buffer, 1, len, gNB_stats); - fclose (gNB_stats); - } - - #endif - pthread_exit((void *)arg); - }*/ return NULL; } void gNBinitScope(scopeParms_t *p) { - //FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; - fl_initialize (p->argc, p->argv, NULL, 0, 0); - - /* - form_stats_l2 = create_form_stats_form(); - fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); - form_stats = create_form_stats_form(); - fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - */ - for(int UE_id=0; UE_idcommon_vars.rxdata) - return; - - NR_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->frame_parms; - uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - int samples_per_frame = frame_parms->samples_per_frame; - scopeSample_t **rxsig_t = (scopeSample_t **) phy_vars_ue->common_vars.rxdata; - float rxsig_t_dB[samples_per_frame]; - float time[samples_per_frame]; - - if (rxsig_t[0] != NULL) { - for (int i=0; iis_synchronized==0) { - //float corr[samples_per_frame]; - for (int ind=0; ind<3; ind++) { - /* - if (pss_corr_ue[ind]) { - for (i=0; ichest_t,time,corr,samples_per_frame,"","",""); - else - fl_add_xyplot_overlay(form->chest_t,ind,time,corr,samples_per_frame,rx_antenna_colors[ind]); - - overlay = 1; - } - */ - } - - // if the UE is not synchronized, we can make only the time*power graph - } + genericLogPowerPerAntena(graph, phy_vars_ue->frame_parms.nb_antennas_rx, + (const scopeSample_t **) phy_vars_ue->common_vars.rxdata, + phy_vars_ue->frame_parms.samples_per_frame); } -static void ueChannelResponse (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void ueChannelResponse (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // Channel Impulse Response - if (!phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time) - return; - - NR_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->frame_parms; - uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; - scopeSample_t **chest_t = (scopeSample_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time; - int ymax = 0; - float chest_t_abs[frame_parms->ofdm_symbol_size]; - float time[frame_parms->ofdm_symbol_size>>3]; - - if (chest_t[0] !=NULL) { - for (int i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) { - chest_t_abs[i] = SquaredNorm(chest_t[0][i]); - time[i] = (float) i; - - if (chest_t_abs[i] > ymax) - ymax = chest_t_abs[i]; - } - - fl_set_xyplot_data(graph,time,chest_t_abs,(frame_parms->ofdm_symbol_size>>3),"","",""); - } - - for (int arx=1; arxofdm_symbol_size>>3); i++) { - chest_t_abs[i] = SquaredNorm(chest_t[arx][i]); - - if (chest_t_abs[i] > ymax) - ymax = chest_t_abs[i]; - } - - fl_add_xyplot_overlay(graph,arx,time,chest_t_abs,(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); - fl_set_xyplot_overlay_type(graph,arx,FL_DASHED_XYPLOT); - } - } - - // Avoid flickering effect - // fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax); // Does not always work... - fl_set_xyplot_ybounds(graph,0,(double) ymax); + genericPowerPerAntena(graph, phy_vars_ue->frame_parms.nb_antennas_rx, + (const scopeSample_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time, + phy_vars_ue->frame_parms.ofdm_symbol_size>>3); } -static void uePbchFrequencyResp (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePbchFrequencyResp (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // Channel Frequency Response (includes 5 complex sample for filter) if (!phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates) return; @@ -572,10 +458,10 @@ static void uePbchFrequencyResp (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, //fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*frame_parms->symbols_per_tti,2); // fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*2,2); //fl_set_xyplot_xgrid(form->chest_f,FL_GRID_MAJOR); - fl_set_xyplot_data(graph,freq,chest_f_abs,frame_parms->ofdm_symbol_size,"","",""); + oai_xygraph(graph,freq,chest_f_abs,frame_parms->ofdm_symbol_size,0,10); } -static void uePbchLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePbchLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PBCH LLRs if ( !phy_vars_ue->pbch_vars[eNB_id]->llr) return; @@ -588,15 +474,15 @@ static void uePbchLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i bit_pbch[i] = (float) i; } - fl_set_xyplot_data(graph,bit_pbch,llr_pbch,864,"","",""); + oai_xygraph(graph,bit_pbch,llr_pbch,864,0,10); } -static void uePbchIQ (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePbchIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PBCH I/Q of MF Output if (!phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]) return; - int16_t *pbch_comp = (int16_t *) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; + scopeSample_t *pbch_comp = (scopeSample_t *) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; localBuff(I,180*3); localBuff(Q,180*3); int first_symbol=1; @@ -613,17 +499,17 @@ static void uePbchIQ (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id AssertFatal(base+nb_re<180*3,""); for (int i=0; ipdcch_vars[0][eNB_id]->llr) return; @@ -653,34 +539,34 @@ static void uePcchLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i //fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*frame_parms->symbols_per_tti,2); // fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*2,2); //fl_set_xyplot_xgrid(form->chest_f,FL_GRID_MAJOR); - fl_set_xyplot_data(graph,freq,chest_f_abs,frame_parms->ofdm_symbol_size,"","",""); + oai_xygraph(graph,freq,chest_f_abs,frame_parms->ofdm_symbol_size,0,10); } -static void uePcchIQ (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePcchIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PDCCH I/Q of MF Output if (!phy_vars_ue->pdcch_vars[0][eNB_id]->rxdataF_comp[0]) return; - int nb=12*273*4; // 12*frame_parms->N_RB_DL*num_pdcch_symbols + int nb=4*273*12; // 12*frame_parms->N_RB_DL*num_pdcch_symbols localBuff(I,nb*RX_NB_TH_MAX); localBuff(Q,nb*RX_NB_TH_MAX); int base=0; for (int thr=0 ; thr < RX_NB_TH_MAX ; thr ++ ) { - int16_t *pdcch_comp = (int16_t *) phy_vars_ue->pdcch_vars[thr][eNB_id]->rxdataF_comp[0]; + scopeSample_t *pdcch_comp = (scopeSample_t *) phy_vars_ue->pdcch_vars[thr][eNB_id]->rxdataF_comp[0]; for (int i=0; i< nb; i++) { - I[base+i] = pdcch_comp[i*2]; - Q[base+i] = pdcch_comp[i*2+1]; + I[base+i] = pdcch_comp[i].r; + Q[base+i] = pdcch_comp[i].i; } base+=nb; } - fl_set_xyplot_data(graph,I,Q,base,"","",""); + oai_xygraph(graph,I,Q,base,0,10); } -static void uePdschLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePdschLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PDSCH LLRs if (!phy_vars_ue->pdsch_vars[0][eNB_id]->llr[0]) return; @@ -704,10 +590,10 @@ static void uePdschLLR (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_ } //fl_set_xyplot_xbounds(form->pdsch_llr,0,coded_bits_per_codeword); - fl_set_xyplot_data(graph,bit,llr,base,"","",""); + oai_xygraph(graph,bit,llr,base,0,10); } -static void uePdschIQ (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePdschIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PDSCH I/Q of MF Output if (!phy_vars_ue->pdsch_vars[0][eNB_id]->rxdataF_comp0[0]) return; @@ -719,17 +605,20 @@ static void uePdschIQ (FL_OBJECT *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i int base=0; for (int thr=0 ; thr < RX_NB_TH_MAX ; thr ++ ) { - int16_t *pdsch_comp = (int16_t *) phy_vars_ue->pdsch_vars[thr][eNB_id]->rxdataF_comp0[0]; + scopeSample_t *pdsch_comp = (scopeSample_t *) phy_vars_ue->pdsch_vars[thr][eNB_id]->rxdataF_comp0[0]; for (int s=0; sphy_scope = fl_bgn_form( FL_NO_BOX, 800, 900 ); // This the whole UI box obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 900, "" ); fl_set_object_color( obj, FL_BLACK, FL_BLACK ); + int curY=0,x,y,w,h; // Received signal fdui->graph[0] = nrUEcommonGraph(ueTimeResponse, - FL_IMPULSE_XYPLOT, 20, 20, 370, 100, "Received Signal (Time-Domain, dB)", FL_RED ); + FL_FILL_XYPLOT, 0, curY, 400, 100, "Received Signal (Time-Domain, dB)", FL_RED ); // Time-domain channel response fdui->graph[1] = nrUEcommonGraph(ueChannelResponse, - FL_NORMAL_XYPLOT, 410, 20, 370, 100, "Channel Impulse Response (samples, abs)", FL_RED ); + FL_NORMAL_XYPLOT, 400, curY, 400, 100, "Channel Impulse Response (samples, abs)", FL_RED ); + fl_get_object_bbox(fdui->graph[0].graph,&x, &y,&w, &h); + curY+=h; // Frequency-domain channel response fdui->graph[2] = nrUEcommonGraph(uePbchFrequencyResp, - FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency data (RE, dB)", FL_RED ); + FL_IMPULSE_XYPLOT, 0, curY, 800, 100, "Channel Frequency data (RE, dB)", FL_RED ); + fl_get_object_bbox(fdui->graph[2].graph,&x, &y,&w, &h); + curY+=h; // LLR of PBCH fdui->graph[3] = nrUEcommonGraph(uePbchLLR, - FL_POINTS_XYPLOT, 20, 260, 500, 100, "PBCH Log-Likelihood Ratios (LLR, mag)", FL_GREEN ); + FL_POINTS_XYPLOT, 0, curY, 500, 100, "PBCH Log-Likelihood Ratios (LLR, mag)", FL_GREEN ); fl_set_xyplot_xgrid(fdui->graph[3].graph,FL_GRID_MAJOR); // I/Q PBCH comp fdui->graph[4] = nrUEcommonGraph(uePbchIQ, - FL_POINTS_XYPLOT, 540, 260, 240, 100, "PBCH I/Q of MF Output", FL_GREEN ); + FL_POINTS_XYPLOT, 500, curY, 300, 100, "PBCH I/Q of MF Output", FL_GREEN ); + fl_get_object_bbox(fdui->graph[3].graph,&x, &y,&w, &h); + curY+=h; // LLR of PDCCH fdui->graph[5] = nrUEcommonGraph(uePcchLLR, - FL_POINTS_XYPLOT, 20, 380, 500, 100, "PDCCH Log-Likelihood Ratios (LLR, mag)", FL_CYAN ); + FL_POINTS_XYPLOT, 0, curY, 500, 100, "PDCCH Log-Likelihood Ratios (LLR, mag)", FL_CYAN ); // I/Q PDCCH comp fdui->graph[6] = nrUEcommonGraph(uePcchIQ, - FL_POINTS_XYPLOT, 540, 380, 240, 100, "PDCCH I/Q of MF Output", FL_CYAN ); + FL_POINTS_XYPLOT, 500, curY, 300, 100, "PDCCH I/Q of MF Output", FL_CYAN ); + fl_get_object_bbox(fdui->graph[5].graph,&x, &y,&w, &h); + curY+=h; // LLR of PDSCH fdui->graph[7] = nrUEcommonGraph(uePdschLLR, - FL_POINTS_XYPLOT, 20, 500, 500, 200, "PDSCH Log-Likelihood Ratios (LLR, mag)", FL_YELLOW ); + FL_POINTS_XYPLOT, 0, curY, 500, 200, "PDSCH Log-Likelihood Ratios (LLR, mag)", FL_YELLOW ); // I/Q PDSCH comp fdui->graph[8] = nrUEcommonGraph(uePdschIQ, - FL_POINTS_XYPLOT, 540, 500, 240, 200, "PDSCH I/Q of MF Output", FL_YELLOW ); + FL_POINTS_XYPLOT, 500, curY, 300, 200, "PDSCH I/Q of MF Output", FL_YELLOW ); + fl_get_object_bbox(fdui->graph[8].graph,&x, &y,&w, &h); + curY+=h; // Throughput on PDSCH fdui->graph[9] = nrUEcommonGraph(uePdschThroughput, - FL_NORMAL_XYPLOT, 20, 720, 500, 100, "PDSCH Throughput [frame]/[kbit/s]", FL_WHITE ); + FL_NORMAL_XYPLOT, 0, curY, 500, 100, "PDSCH Throughput [frame]/[kbit/s]", FL_WHITE ); fdui->graph[10].graph=NULL; // Generic UE Button +#if 0 fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 540, 720, 240, 40, "" ); fl_set_object_lalign(fdui->button_0, FL_ALIGN_CENTER ); //openair_daq_vars.use_ia_receiver = 0; @@ -801,6 +699,7 @@ static FD_phy_scope_t *create_phy_scope_nrue( int ID ) { fl_set_object_color(fdui->button_0, FL_RED, FL_RED); fl_set_object_callback(fdui->button_0, ia_receiver_on_off, 0 ); fl_hide_object(fdui->button_0); +#endif fl_end_form( ); fdui->phy_scope->fdui = fdui; char buf[100]; @@ -809,11 +708,11 @@ static FD_phy_scope_t *create_phy_scope_nrue( int ID ) { return fdui; } -void phy_scope_nrUE(FD_phy_scope_t *form, +void phy_scope_nrUE(OAI_phy_scope_t *form, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { - static FD_phy_scope_t *remeberForm=NULL; + static OAI_phy_scope_t *remeberForm=NULL; if (form==NULL) form=remeberForm; @@ -826,15 +725,13 @@ void phy_scope_nrUE(FD_phy_scope_t *form, int i=0; while (form->graph[i].graph) { - form->graph[i].nrUEfunct(form->graph[i].graph, phy_vars_ue, eNB_id, UE_id); + form->graph[i].nrUEfunct(form->graph+i, phy_vars_ue, eNB_id, UE_id); i++; } fl_check_forms(); } -static FD_phy_scope_t *form_nrue[NUMBER_OF_UE_MAX]; -static pthread_t forms_thread; static void *nrUEscopeThread(void *arg) { PHY_VARS_NR_UE *ue=(PHY_VARS_NR_UE *)arg; @@ -842,9 +739,13 @@ static void *nrUEscopeThread(void *arg) { pthread_attr_t atr; pthread_attr_getstacksize(&atr, &stksize); pthread_attr_setstacksize(&atr,32*1024*1024 ); + int fl_argc=1; + char *name="5G-UE-scope"; + fl_initialize (&fl_argc, &name, NULL, 0, 0); + OAI_phy_scope_t *form_nrue=create_phy_scope_nrue(0); while (!oai_exit) { - phy_scope_nrUE(form_nrue[0], + phy_scope_nrUE(form_nrue, ue, 0,0); usleep(99*1000); @@ -854,10 +755,7 @@ static void *nrUEscopeThread(void *arg) { } void nrUEinitScope(PHY_VARS_NR_UE *ue) { - int fl_argc=1; - char *name="5G-UE-scope"; - fl_initialize (&fl_argc, &name, NULL, 0, 0); - form_nrue[0] = create_phy_scope_nrue(0); + pthread_t forms_thread; threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW); } @@ -890,7 +788,7 @@ static void reset_stats_gNB(FL_OBJECT *button, static FD_stats_form *create_form_stats_form(int ID) { FL_OBJECT *obj; - FD_stats_form *fdui = fl_malloc( sizeof *fdui ); + FD_stats_form *fdui = calloc(( sizeof *fdui ),1); fdui->vdata = fdui->cdata = NULL; fdui->ldata = 0; fdui->stats_form = fl_bgn_form( FL_NO_BOX, 1115, 900 ); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 8e265e8cf1..de8a1b385b 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -34,10 +34,6 @@ #ifndef __PDCP_H__ # define __PDCP_H__ //----------------------------------------------------------------------------- -#ifndef NON_ACCESS_STRATUM - #include "UTIL/MEM/mem_block.h" - #include "UTIL/LISTS/list.h" -#endif //NON_ACCESS_STRATUM //----------------------------------------------------------------------------- #include "RRC/LTE/rrc_defs.h" #include "COMMON/platform_constants.h" diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index d764d6176a..c390638d16 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -55,7 +55,6 @@ extern int otg_enabled; #include "common/utils/LOG/log.h" #include "UTIL/OTG/otg_tx.h" #include "nfapi/oai_integration/vendor_ext.h" -#include "UTIL/FIFO/pad_list.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "platform_constants.h" #include "msc.h" @@ -91,7 +90,6 @@ extern struct msghdr nas_msg_rx; extern uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; #endif -extern Packet_OTG_List_t *otg_pdcp_buffer; # include "gtpv1u_eNB_task.h" From a456054d9b5d79f194f25835ca39272e8a32e467 Mon Sep 17 00:00:00 2001 From: laurent Date: Mon, 22 Jun 2020 12:02:58 +0200 Subject: [PATCH 014/149] continue scope --- executables/ocp-gnb.c | 12 ++++----- openair1/PHY/TOOLS/nr_phy_scope.c | 29 ++++++++++++++------- openair1/PHY/TOOLS/readme.md | 12 +++++++++ openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 6 ++--- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 2 +- 5 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 openair1/PHY/TOOLS/readme.md diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index be7679f610..69687c6f19 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -99,10 +99,10 @@ int flexran_agent_start(mid_t mod_id) { } void flexran_agent_slice_update(mid_t module_idP) { } -int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p){ - return 0; +int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) { + return 0; } -void proto_agent_stop(mod_id_t mod_id){ +void proto_agent_stop(mod_id_t mod_id) { } int split73=0; void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { @@ -400,8 +400,8 @@ void OCPconfig_RU(RU_t *ru) { config_getlist( &RUParamList, RUParams, sizeof(RUParams)/sizeof(paramdef_t), NULL); AssertFatal( RUParamList.numelt == 1 && RC.nb_nr_L1_inst ==1,"" ); ru->idx=0; - ru->nr_frame_parms = (NR_DL_FRAME_PARMS *)malloc(sizeof(NR_DL_FRAME_PARMS)); - ru->frame_parms = (LTE_DL_FRAME_PARMS *)malloc(sizeof(LTE_DL_FRAME_PARMS)); + ru->nr_frame_parms = (NR_DL_FRAME_PARMS *)calloc(sizeof(NR_DL_FRAME_PARMS),1); + ru->frame_parms = (LTE_DL_FRAME_PARMS *)calloc(sizeof(LTE_DL_FRAME_PARMS),1); ru->if_timing = synch_to_ext_device; ru->num_gNB = RUParamList.paramarray[j][RU_ENB_LIST_IDX].numelt; ru->gNB_list[i] = &RC.gNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; @@ -858,7 +858,7 @@ int main( int argc, char **argv ) { // once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init gNBs\n"); LOG_E(PHY,"configuring RU from file, hardcoded one gNB for one RU, one carrier\n"); - RU_t ru={0}; + RU_t ru= {0}; OCPconfig_RU(&ru); ru.nr_frame_parms->threequarter_fs=threequarter_fs; fill_rf_config(&ru,ru.rf_config_file); diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 9d4648c94f..dfb148d34e 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -162,19 +162,28 @@ static void oai_xygraph(OAIgraph_t *graph, float *x, float *y, int len, int laye } static void genericLogPowerPerAntena(OAIgraph_t *graph, const int nb_ant, const scopeSample_t **data, const int len) { - float values[len]; - float time[len]; + float *values=malloc(len*sizeof(*values)); + float *time=malloc(len*sizeof(*time)); for (int ant=0; antgraph[0] = gNBcommonGraph( timeSignal, FL_FILL_XYPLOT, 0, curY, 400, 100, + fdui->graph[0] = gNBcommonGraph( timeSignal, FL_NORMAL_XYPLOT, 0, curY, 400, 100, "Received Signal (Time-Domain, dB)", FL_RED ); // Time-domain channel response fdui->graph[1] = gNBcommonGraph( timeResponse, FL_NORMAL_XYPLOT, 410, curY, 400, 100, @@ -330,7 +339,7 @@ static OAI_phy_scope_t *create_phy_scope_gnb(void) { fl_get_object_bbox(fdui->graph[0].graph,&x, &y,&w, &h); curY+=h; // Frequency-domain channel response - fdui->graph[2] = gNBcommonGraph( frequencyResponse, FL_FILL_XYPLOT, 0, curY, 800, 100, + fdui->graph[2] = gNBcommonGraph( frequencyResponse, FL_NORMAL_XYPLOT, 0, curY, 800, 100, "Channel Frequency Response (RE, dB)", FL_RED ); fl_get_object_bbox(fdui->graph[2].graph,&x, &y,&w, &h); curY+=h; @@ -390,8 +399,8 @@ static void *scope_thread_gNB(void *arg) { //# ifdef ENABLE_XFORMS_WRITE_STATS // FILE *gNB_stats = fopen("gNB_stats.txt", "w"); //#endif - size_t stksize; - pthread_attr_t atr; + size_t stksize=0; + pthread_attr_t atr= {0}; pthread_attr_getstacksize(&atr, &stksize); pthread_attr_setstacksize(&atr,32*1024*1024 ); sleep(3); // no clean interthread barriers @@ -649,7 +658,7 @@ static OAI_phy_scope_t *create_phy_scope_nrue( int ID ) { int curY=0,x,y,w,h; // Received signal fdui->graph[0] = nrUEcommonGraph(ueTimeResponse, - FL_FILL_XYPLOT, 0, curY, 400, 100, "Received Signal (Time-Domain, dB)", FL_RED ); + FL_NORMAL_XYPLOT, 0, curY, 400, 100, "Received Signal (Time-Domain, dB)", FL_RED ); // Time-domain channel response fdui->graph[1] = nrUEcommonGraph(ueChannelResponse, FL_NORMAL_XYPLOT, 400, curY, 400, 100, "Channel Impulse Response (samples, abs)", FL_RED ); diff --git a/openair1/PHY/TOOLS/readme.md b/openair1/PHY/TOOLS/readme.md new file mode 100644 index 0000000000..f6671acc6d --- /dev/null +++ b/openair1/PHY/TOOLS/readme.md @@ -0,0 +1,12 @@ + +To use the scope, run the xNB or the UE with option "-d" + +Usage in gdb +In gdb, when you break, you can refresh immediatly the scope view by calling the display function. +The first paramter is the graph context, nevertheless we keep the last value for a dirty call in gdb (so you can use '0') + +Example with no variable known +phy_scope_nrUE(0, PHY_vars_UE_g[0][0], 0, 0, 0) + +or +phy_scope_gNB(0, phy_vars_gnb, phy_vars_ru, UE_id) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index e5e48ee0ed..99e345e9f3 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2989,10 +2989,8 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, pdcch_vars->nb_search_space); #endif - fapi_nr_dci_indication_t dci_ind; - nr_downlink_indication_t dl_indication; - memset((void*)&dci_ind,0,sizeof(dci_ind)); - memset((void*)&dl_indication,0,sizeof(dl_indication)); + fapi_nr_dci_indication_t dci_ind={0}; + nr_downlink_indication_t dl_indication={0}; dci_cnt = nr_dci_decoding_procedure(ue, proc->frame_rx, nr_tti_rx, diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 61f9ab601e..c5154d7a1f 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -50,7 +50,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) //LOG_I(MAC, "[MAIN] init UE MAC functions \n"); //init mac here - nr_ue_mac_inst = (NR_UE_MAC_INST_t *)malloc(sizeof(NR_UE_MAC_INST_t)*NB_NR_UE_MAC_INST); + nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST); if (rrc_inst) { nr_rrc_mac_config_req_ue(0,0,0,NULL,rrc_inst->cell_group_config->spCellConfig); From 0f032447c0511d39a7d922f4cbf3b1cd65e40dad Mon Sep 17 00:00:00 2001 From: laurent Date: Wed, 1 Jul 2020 17:44:36 +0200 Subject: [PATCH 015/149] fix bugs in main OAI, begining of PRACH test+fxi --- common/utils/ocp_itti/intertask_interface.h | 2 +- executables/ocp-gnb.c | 6 ++++-- openair2/ENB_APP/enb_config.c | 4 ++-- openair2/F1AP/f1ap_cu_ue_context_management.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 9e27ecf358..026c8270d7 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -415,7 +415,7 @@ static const message_info_t messages_info[] = { #undef MESSAGE_DEF }; -typedef struct __attribute__ ((__packed__)) MessageDef_s { +typedef struct MessageDef_s { MessageHeader ittiMsgHeader; /**< Message header */ msg_t ittiMsg; } MessageDef; diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 99df02b894..c7055f1a99 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -253,7 +253,7 @@ void init_gNB_proc(int inst) { } /// eNB kept in function name for nffapi calls, TO FIX -void init_gNB_phase2(void) { +void init_gNB_phase2(RU_t *ru) { int inst; LOG_I(PHY,"%s() RC.nb_nr_inst:%d\n", __FUNCTION__, RC.nb_nr_inst); @@ -262,6 +262,8 @@ void init_gNB_phase2(void) { PHY_VARS_gNB *gNB = RC.gNB[inst]; LOG_E(PHY,"hard coded gNB->num_RU:%d\n", gNB->num_RU); phy_init_nr_gNB(gNB,0,0); + RC.gNB[inst]->num_RU=1; + RC.gNB[inst]->RU_list[0]=ru; //init_precoding_weights(RC.gNB[inst][CC_id]); } } @@ -862,7 +864,7 @@ int main( int argc, char **argv ) { OCPconfig_RU(&ru); ru.nr_frame_parms->threequarter_fs=threequarter_fs; fill_rf_config(&ru,ru.rf_config_file); - init_gNB_phase2(); + init_gNB_phase2(&ru); memcpy((void *)ru.nr_frame_parms,&RC.gNB[0][0].frame_parms,sizeof(NR_DL_FRAME_PARMS)); memcpy((void*)&ru.config,(void*)&RC.gNB[0]->gNB_config,sizeof(ru.config)); diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 6dcc574746..2200c8f013 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -1545,7 +1545,7 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RRC_CONFIGURATION_REQ(msg_p).eMBMS_configured = 0; printf("No eMBMS configuration, skipping it\n"); // eMTC configuration - char brparamspath[MAX_OPTNAME_SIZE*2 + 16]; + char brparamspath[MAX_OPTNAME_SIZE*2 + 160]; sprintf(brparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_EMTC_PARAMETERS); config_get(eMTCParams, sizeof(eMTCParams)/sizeof(paramdef_t), brparamspath); RRC_CONFIGURATION_REQ(msg_p).eMTC_configured = eMTCconfig.eMTC_configured&1; @@ -1554,7 +1554,7 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { else printf("No eMTC configuration, skipping it\n"); // Sidelink configuration - char SLparamspath[MAX_OPTNAME_SIZE*2 + 16]; + char SLparamspath[MAX_OPTNAME_SIZE*2 + 160]; sprintf(SLparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_SL_PARAMETERS); config_get( SLParams, sizeof(SLParams)/sizeof(paramdef_t), SLparamspath); // Sidelink Resource pool information diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index a64f2d529b..789ce4c715 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -226,7 +226,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ie->value.choice.ResourceCoordinationTransferContainer.buf = malloc(4); ie->value.choice.ResourceCoordinationTransferContainer.size = 4; - strncpy((char *)ie->value.choice.ResourceCoordinationTransferContainer.buf, "123", 3); + strncpy((char *)ie->value.choice.ResourceCoordinationTransferContainer.buf, "123", 4); OCTET_STRING_fromBuf(&ie->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", From 4d6e647aaae8d22c259392a39dafd596cc7cdc8c Mon Sep 17 00:00:00 2001 From: laurent Date: Mon, 6 Jul 2020 14:07:46 +0200 Subject: [PATCH 016/149] fixes pushed also in develop --- executables/ocp-gnb.c | 12 +++++-- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 2 +- .../CODING/nrPolar_tools/nr_polar_encoder.c | 4 +-- openair1/PHY/MODULATION/slot_fep_nr.c | 4 +-- openair1/PHY/NR_TRANSPORT/nr_dci.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c | 6 ++-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 1 + targets/ARCH/rfsimulator/simulator.c | 32 ++++++++++++------- 10 files changed, 42 insertions(+), 25 deletions(-) diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 41f3b557e3..e2ee821425 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -40,6 +40,7 @@ #include #include #include +#include // should be in a shared lib #include @@ -176,11 +177,16 @@ static inline int rxtx(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { int rx_slot_type = nr_slot_select(cfg,proc->frame_rx,proc->slot_rx); if (rx_slot_type == NR_UPLINK_SLOT || rx_slot_type == NR_MIXED_SLOT) { - // UE-specific RX processing for subframe n - // TODO: check if this is correct for PARALLEL_RU_L1_TRX_SPLIT + // Do PRACH RU processing + int prach_id=find_nr_prach(gNB,proc->frame_rx,proc->slot_rx,0,SEARCH_EXIST); + if (prach_id>=0) { + L1_nr_prach_procedures(gNB,proc->frame_rx,proc->slot_rx,&gNB->prach_vars.list[prach_id].pdu); + gNB->prach_vars.list[prach_id].frame=-1; + } + phy_procedures_gNB_uespec_RX(gNB, proc->frame_rx, proc->slot_rx); } - + if (oai_exit) return(-1); // ***************************************** diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 6e01a05d0f..1cf49a224d 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -146,7 +146,7 @@ void polar_encoder_dci(uint32_t *in, uint16_t n_RNTI); void polar_encoder_fast(uint64_t *A, - uint32_t *out, + void *out, int32_t crcmask, uint8_t ones_flag, t_nrPolar_params *polarParams); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 70791302cc..f5697ace29 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -408,7 +408,7 @@ void build_polar_tables(t_nrPolar_params *polarParams) { } void polar_encoder_fast(uint64_t *A, - uint32_t *out, + void *out, int32_t crcmask, uint8_t ones_flag, t_nrPolar_params *polarParams) { @@ -676,5 +676,5 @@ void polar_encoder_fast(uint64_t *A, } } memset((void*)out,0,polarParams->encoderLength>>3); - polar_rate_matching(polarParams,(void *)D,(void *)out); + polar_rate_matching(polarParams,(void *)D,out); } diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 60ba3d7112..c24251dcf3 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -465,8 +465,8 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, dft(dftsize,(int16_t *)&rxdata[rxdata_offset-sample_offset], (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1); - LOG_T(PHY,"dft of size: %d done from %d (energy %d) to %d offsets (energy (%d)\n", - dftsize, + LOG_T(PHY,"Ns: %d, symbol: %d dft of size: %d done from %d (energy %d) to %d offsets (energy (%d)\n", + Ns, symbol, dftsize, rxdata_offset-sample_offset, signal_energy(&rxdata[rxdata_offset-sample_offset], dftsize), symbol * frame_parms->ofdm_symbol_size, signal_energy(&rxdataF[symbol * frame_parms->ofdm_symbol_size], dftsize) ); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 8508621ae5..6298de3c60 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -237,7 +237,7 @@ uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[d], pdcch_pdu_rel15->dci_pdu.AggregationLevel[d], 0,NULL); - polar_encoder_fast((uint64_t*)pdcch_pdu_rel15->dci_pdu.Payload[d], encoder_output, n_RNTI,1,currentPtr); + polar_encoder_fast((uint64_t*)pdcch_pdu_rel15->dci_pdu.Payload[d], (void*)encoder_output, n_RNTI,1,currentPtr); #ifdef DEBUG_CHANNEL_CODING printf("polar rnti %x,length %d, L %d\n",n_RNTI, pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[d],pdcch_pdu_rel15->dci_pdu.AggregationLevel[d]); printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n", diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index f5a26aec80..bc33d93811 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -297,7 +297,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, a_reversed |= (((uint64_t)pbch->pbch_a_prime>>i)&1)<<(31-i); /// CRC, coding and rate matching - polar_encoder_fast (&a_reversed, (uint32_t *)pbch->pbch_e, 0, 0, + polar_encoder_fast (&a_reversed, (void*)pbch->pbch_e, 0, 0, nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,0,NULL) ); #ifdef DEBUG_PBCH_ENCODING diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index e1358602ce..823de0a63e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -962,7 +962,7 @@ void nr_generate_pucch2(PHY_VARS_NR_UE *ue, uint64_t b[16]; // limit to 1024-bit encoded length // M_bit is the number of bits of block b (payload after encoding) uint16_t M_bit; - nr_uci_encoding(payload,nr_bit,pucch_format2_nr,0,nrofSymbols,nrofPRB,1,0,0,&b,&M_bit); + nr_uci_encoding(payload,nr_bit,pucch_format2_nr,0,nrofSymbols,nrofPRB,1,0,0,(void*)b,&M_bit); /* * Implementing TS 38.211 * Subclauses 6.3.2.5.1 Scrambling (PUCCH format 2) @@ -1128,7 +1128,7 @@ void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, printf("\t [nr_generate_pucch3_4] start function at slot(nr_tti_tx)=%d with payload=%lu and nr_bit=%d\n", nr_tti_tx, payload, nr_bit); #endif // b is the block of bits transmitted on the physical channel after payload coding - uint64_t b; + uint64_t b[16]; // M_bit is the number of bits of block b (payload after encoding) uint16_t M_bit; // parameter PUCCH-F4-preDFT-OCC-length set of {2,4} -> to use table -1 or -2 @@ -1153,7 +1153,7 @@ void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, //nrofPRB = 2; // only for test purposes if (fmt == pucch_format4_nr) nrofPRB = 1; - nr_uci_encoding(payload,nr_bit,fmt,is_pi_over_2_bpsk_enabled,nrofSymbols,nrofPRB,n_SF_PUCCH_s,intraSlotFrequencyHopping,add_dmrs,&b,&M_bit); + nr_uci_encoding(payload,nr_bit,fmt,is_pi_over_2_bpsk_enabled,nrofSymbols,nrofPRB,n_SF_PUCCH_s,intraSlotFrequencyHopping,add_dmrs,(void*)b,&M_bit); /* * Implementing TS 38.211 * Subclauses 6.3.2.6.1 Scrambling (PUCCH formats 3 and 4) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 938d9f56f3..574125fe9f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -272,7 +272,7 @@ int8_t nr_ue_decode_mib(module_id_t module_id, uint16_t frame_number_4lsb = 0; for (int i=0; i<4; i++) frame_number_4lsb |= ((extra_bits>>i)&1)<<(3-i); - uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1; // extra bits[4] + //uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1; // extra bits[4] uint8_t ssb_subcarrier_offset_msb = ( extra_bits >> 5 ) & 0x1; // extra bits[5] uint8_t ssb_subcarrier_offset = (uint8_t)mac->mib->ssb_SubcarrierOffset; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 9981dca7fd..62605aa604 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -155,6 +155,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { ret = sendmsg(nas_sock_fd[0],&nas_msg_tx,0); } // PDCP_USE_NETLINK + AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s), nas_sock_fd[0]: %d\n", errno, strerror(errno), nas_sock_fd[0]); if( LOG_DEBUGFLAG(DEBUG_PDCP) ) log_dump(PDCP, pdcpData, min(sizeToWrite,30) , LOG_DUMP_CHAR, diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index acda5aecf3..a26ad16a7b 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -148,11 +148,17 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) { // Legacy changes directlty the variable channel_model->path_loss_dB place to place // while calling new_channel_desc_scm() with path losses = 0 static bool init_done=false; + if (!init_done) { - randominit(0); + uint64_t rand; + FILE *h=fopen("/dev/random","r"); + fread(&rand,sizeof(rand),1,h); + fclose(h); + randominit(rand); tableNor(0); init_done=true; } + ptr->channel_model=new_channel_desc_scm(bridge->tx_num_channels,bridge->rx_num_channels, bridge->channelmod, bridge->sample_rate, @@ -375,6 +381,7 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp if (t->lastWroteTS > timestamp+nsamps) LOG_E(HW,"Not supported to send Tx out of order (same in USRP) %lu, %lu\n", t->lastWroteTS, timestamp); + t->lastWroteTS=timestamp+nsamps; if (!alreadyLocked) @@ -476,20 +483,22 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi b->trashingPacket=true; } else if ( b->lastReceivedTS < b->th.timestamp) { int nbAnt= b->th.nbAnt; + if ( b->th.timestamp-b->lastReceivedTS < CirSize ) { - for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) { - for (int a=0; a < nbAnt; a++) { - b->circularBuf[(index*nbAnt+a)%CirSize].r = 0; - b->circularBuf[(index*nbAnt+a)%CirSize].i = 0; + for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) { + for (int a=0; a < nbAnt; a++) { + b->circularBuf[(index*nbAnt+a)%CirSize].r = 0; + b->circularBuf[(index*nbAnt+a)%CirSize].i = 0; + } } - } } else { - memset(b->circularBuf, 0, sampleToByte(CirSize,1)); - } + memset(b->circularBuf, 0, sampleToByte(CirSize,1)); + } + if (b->lastReceivedTS != 0 && b->th.timestamp-b->lastReceivedTS > 50 ) LOG_W(HW,"UEsock: %d gap of: %ld in reception\n", fd, b->th.timestamp-b->lastReceivedTS ); - b->lastReceivedTS=b->th.timestamp; + b->lastReceivedTS=b->th.timestamp; } else if ( b->lastReceivedTS > b->th.timestamp && b->th.size == 1 ) { LOG_W(HW,"Received Rx/Tx synchro out of order\n"); b->trashingPacket=true; @@ -649,8 +658,9 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo else { // no channel modeling sample_t *out=(sample_t *)samplesVoid[a]; const int64_t base=t->nextTimestamp*nbAnt+a; + for ( int i=0; i < nsamps; i++ ) { - const int idx=(i*nbAnt+base)%CirSize; + const int idx=(i*nbAnt+base)%CirSize; out[i].r+=ptr->circularBuf[idx].r; out[i].i+=ptr->circularBuf[idx].i; } @@ -691,7 +701,7 @@ int rfsimulator_set_freq(openair0_device *device, openair0_config_t *openair0_cf int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) { return 0; } -int rfsimulator_write_init(openair0_device *device){ +int rfsimulator_write_init(openair0_device *device) { return 0; } __attribute__((__visibility__("default"))) From 4bc36627bed2b21eb9a8e770fa2862c40eea67a7 Mon Sep 17 00:00:00 2001 From: laurent Date: Tue, 7 Jul 2020 12:53:04 +0200 Subject: [PATCH 017/149] fix some used but not initialized variables --- common/utils/ocp_itti/intertask_interface.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index 3d4d356dcf..1680410ebb 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -80,7 +80,7 @@ task_list_t tasks[TASK_MAX]; void *itti_malloc(task_id_t origin_task_id, task_id_t destination_task_id, ssize_t size) { void *ptr = NULL; - AssertFatal ((ptr=malloc (size)) != NULL, "Memory allocation of %zu bytes failed (%d -> %d)!\n", + AssertFatal ((ptr=calloc (size, 1)) != NULL, "Memory allocation of %zu bytes failed (%d -> %d)!\n", size, origin_task_id, destination_task_id); return ptr; } @@ -91,8 +91,16 @@ task_list_t tasks[TASK_MAX]; return (EXIT_SUCCESS); } + // in the two following functions, the +32 in malloc is there to deal with gcc memory alignment + // because a struct size can be larger than sum(sizeof(struct components)) + // We should remove the itti principle of a huge union for all types of messages in paramter "msg_t ittiMsg" + // to use a more C classical pointer casting "void * ittiMsg", later casted in the right struct + // but we would have to change all legacy macros, as per this example + // #define S1AP_REGISTER_ENB_REQ(mSGpTR) (mSGpTR)->ittiMsg.s1ap_register_enb_req + // would become + // #define S1AP_REGISTER_ENB_REQ(mSGpTR) (s1ap_register_enb_req) mSGpTR)->ittiMsg MessageDef *itti_alloc_new_message_sized(task_id_t origin_task_id, MessagesIds message_id, MessageHeaderSize size) { - MessageDef *temp = (MessageDef *)itti_malloc (origin_task_id, TASK_UNKNOWN, sizeof(MessageHeader) + size); + MessageDef *temp = (MessageDef *)itti_malloc (origin_task_id, TASK_UNKNOWN, sizeof(MessageHeader) +32 + size); temp->ittiMsgHeader.messageId = message_id; temp->ittiMsgHeader.originTaskId = origin_task_id; temp->ittiMsgHeader.ittiMsgSize = size; @@ -100,7 +108,7 @@ task_list_t tasks[TASK_MAX]; } MessageDef *itti_alloc_new_message(task_id_t origin_task_id, MessagesIds message_id) { - int size=sizeof(MessageHeader) + messages_info[message_id].size; + int size=sizeof(MessageHeader) + 32 + messages_info[message_id].size; MessageDef *temp = (MessageDef *)itti_malloc (origin_task_id, TASK_UNKNOWN, size); temp->ittiMsgHeader.messageId = message_id; temp->ittiMsgHeader.originTaskId = origin_task_id; From 5e4d1f61ffa80a36cb417e95ddc0c94cc8cd47d9 Mon Sep 17 00:00:00 2001 From: laurent Date: Sat, 11 Jul 2020 11:52:49 +0200 Subject: [PATCH 018/149] small bug --- cmake_targets/CMakeLists.txt | 2 +- targets/ARCH/rfsimulator/simulator.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 4c9d647a12..d8287d4122 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -3126,7 +3126,7 @@ if (${T_TRACER}) NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX L2 L2_LTE L2_NR L2_UE NR_L2_UE MAC_NR_COMMON MAC_NR MAC_UE_NR - CN_UTILS GTPV1U SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB + CN_UTILS NR_GTPV1U GTPV1U SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB ldpc_orig ldpc_optim ldpc_optim8seg ldpc PROTO_AGENT dfts) if (TARGET ${i}) add_dependencies(${i} generate_T) diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index a26ad16a7b..35fd4f1911 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -155,7 +155,7 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) { fread(&rand,sizeof(rand),1,h); fclose(h); randominit(rand); - tableNor(0); + tableNor(rand); init_done=true; } From cf18c0d7e0a8d2d8d572e8101f4c9931a38fb2d5 Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 17 Jul 2020 15:12:20 +0200 Subject: [PATCH 019/149] ocp-gnb regression fixed on rfsimulator --- .../gnb.band78.tm1.106PRB.usrpn300.conf | 2 +- executables/ocp-gnb.c | 32 ++++++++++++------- openair1/PHY/INIT/nr_init.c | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index a7c3e670ee..915ae7f075 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -247,7 +247,7 @@ THREAD_STRUCT = ( #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" - worker_config = "WORKER_DISABLE"; + worker_config = "WORKER_ENABLE"; } ); diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 07635be127..f00b5f71b3 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -470,7 +470,6 @@ void OCPconfig_RU(RU_t *ru) { return; } - // this is for RU with local RF unit void fill_rf_config(RU_t *ru, char *rf_config_file) { int i; @@ -811,10 +810,8 @@ static void *ru_thread( void *param ) { AssertFatal(ru->rfdevice.trx_start_func(&ru->rfdevice) == 0,"Could not start the RF device\n"); tpool_t *threadPool=(tpool_t *)malloc(sizeof(tpool_t)); initTpool("-1,-1,-1", threadPool, true); - int64_t slot=-1; - int64_t nextTSshouldBe=0; - openair0_timestamp HWtimeStamp=0; //for multi RU + int64_t nextHWTSshouldBe=0, nextRxTSlogical=0; // weird globals, used in NR_IF_Module.c sf_ahead = (uint16_t) ceil((float)6/(0x01<numerology_index)); sl_ahead = sf_ahead*fp->slots_per_subframe; @@ -827,6 +824,7 @@ static void *ru_thread( void *param ) { int rxBuffOffset=fp->get_samples_slot_timestamp(nextSlot,fp,0); AssertFatal(rxBuffOffset + samples_per_slot <= fp->samples_per_frame, "Will read outside allocated buffer\n"); int samples=fp->get_samples_per_slot(nextSlot,fp); + openair0_timestamp HWtimeStamp=0; //for multi RU int rxs=rx_rf(rxBuffOffset, samples, ru->nb_rx, @@ -835,13 +833,24 @@ static void *ru_thread( void *param ) { &HWtimeStamp); LOG_D(PHY,"Reading %d samples for slot %d\n",samples_per_slot,nextSlot); - if ( HWtimeStamp != nextTSshouldBe) - LOG_E(HW,"reading a stream must be continuous, %ld, %ld\n", HWtimeStamp, nextTSshouldBe); + if ( HWtimeStamp != nextHWTSshouldBe) + LOG_E(HW,"reading a stream must be continuous, %ld, %ld\n", HWtimeStamp, nextHWTSshouldBe); - nextTSshouldBe=HWtimeStamp+rxs; - proc->tti_rx=nextSlot; - proc->timestamp_rx=(slot+1)*fp->samples_per_subframe; - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; + nextHWTSshouldBe=HWtimeStamp+rxs; + proc->timestamp_rx=nextRxTSlogical; + nextRxTSlogical+=samples_per_slot; + int64_t HW_to_logical_RxTSoffset=(int64_t)HWtimeStamp-(int64_t)proc->timestamp_rx; + printf("%lu, %lu\n",HWtimeStamp, (slot+1)*fp->samples_per_subframe); + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; + uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; + float offsetInSubframe=proc->timestamp_rx % fp->samples_per_subframe; + proc->tti_rx = (idx_sf * fp->slots_per_subframe + + lroundf(offsetInSubframe / fp->samples_per_slot0))% + fp->slots_per_frame; + LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, slot %d.%d / %d\n", + ru->idx, 0, + (unsigned long long int)proc->timestamp_rx, + (int)ru->ts_offset,proc->frame_rx,proc->tti_rx,proc->tti_tx,fp->slots_per_frame); int slot_type = nr_slot_select(&ru->gNB_list[0]->gNB_config,proc->frame_rx,proc->tti_rx); if (slot_type == NR_UPLINK_SLOT || slot_type == NR_MIXED_SLOT) { @@ -880,7 +889,8 @@ static void *ru_thread( void *param ) { } // do outgoing fronthaul (south) if needed - tx_rf(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx); + tx_rf(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx+HW_to_logical_RxTSoffset); + slot++; } printf( "Exiting ru_thread \n"); diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index a3856907f6..0f430c61a7 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -470,7 +470,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { AssertFatal(fp->ul_CarrierFreq==(fp->dl_CarrierFreq+dlul_offset), "Disagreement in uplink frequency for band %d\n", fp->nr_band); //fp->threequarter_fs = openair0_cfg[0].threequarter_fs; - fp->threequarter_fs = 1; + //fp->threequarter_fs = 1; LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", Mod_id, gNB_config->cell_config.phy_cell_id.value, From afc93b0f684ca2c712005e50ae3e0cafd3d524c1 Mon Sep 17 00:00:00 2001 From: laurent Date: Tue, 21 Jul 2020 18:50:25 +0200 Subject: [PATCH 020/149] add SA messages defintion --- openair3/NAS/COMMON/NR_NAS_defs.h | 214 ++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 openair3/NAS/COMMON/NR_NAS_defs.h diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h new file mode 100644 index 0000000000..8e8b003874 --- /dev/null +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -0,0 +1,214 @@ + +//TS 24.501, chap 9.2 => TS 24.007 +typedef enum { + SGSsessionmanagementmessages=0x2e, //LTEbox: 0xC0 ??? +SGSmobilitymanagementmessages=0x7e, +} Extendedprotocoldiscriminator_t; + +typedef enum { +Registrationrequest=0x41, +Registrationaccept=0x42, +Registrationcomplete=0x43, +Registrationreject=0x44, +DeregistrationrequestUEoriginating=0x45, +DeregistrationacceptUEoriginating=0x46, +DeregistrationrequestUEterminated=0x47, +DeregistrationacceptUEterminated=0x48, +Servicerequest=0x4c, +Servicereject=0x4d, +Serviceaccept=0x4e, +Controlplaneservicerequest=0x4f, +Networkslicespecificauthenticationcommand=0x50, +Networkslicespecificauthenticationcomplete=0x51, +Networkslicespecificauthenticationresult=0x52, +Configurationupdatecommand=0x54, +Configurationupdatecomplete=0x55, +Authenticationrequest=0x56, +Authenticationresponse=0x57, +Authenticationreject=0x58, +Authenticationfailure=0x59, +Authenticationresult=0x5a, +Identityrequest=0x5b, +Identityresponse=0x5c, +Securitymodecommand=0x5d, +Securitymodecomplete=0x5e, +Securitymodereject=0x5f, +SGMMstatus=0x64, +Notification=0x65, +Notificationresponse=0x66, +ULNAStransport=0x67, +DLNAStransport=0x68, +PDUsessionestablishmentrequest=0xc1, +PDUsessionestablishmentaccept=0xc2, +PDUsessionestablishmentreject=0xc3, +PDUsessionauthenticationcommand=0xc5, +PDUsessionauthenticationcomplete=0xc6, +PDUsessionauthenticationresult=0xc7, +PDUsessionmodificationrequest=0xc9, +PDUsessionmodificationreject=0xca, +PDUsessionmodificationcommand=0xcb, +PDUsessionmodificationcomplete=0xcc, +PDUsessionmodificationcommandreject=0xcd, +PDUsessionreleaserequest=0xd1, +PDUsessionreleasereject=0xd2, +PDUsessionreleasecommand=0xd3, +PDUsessionreleasecomplete=0xd4, +SGSMstatus=0xd6, +} SGSmobilitymanagementmessages_t; + +// TS 24.501 +typedef enum { + notsecurityprotected=0, +Integrityprotected=1, +Integrityprotectedandciphered=2, +Integrityprotectedwithnew5GNASsecuritycontext=3, +Integrityprotectedandcipheredwithnew5GNASsecuritycontext=4, +} Security_header_t; + +typedef enum { +SUCI=0, +SGGUTI, +IMEI, +SGSTMSI, +IMEISV, +MACaddress, +EUI64, +} identitytype_t; + + +// table 9.11.3.2.1 +#define FOREACH_CAUSE(CAUSE_DEF) \ +CAUSE_DEF(Illegal_UE,0x3 )\ +CAUSE_DEF(PEI_not_accepted,0x5 )\ +CAUSE_DEF(Illegal_ME,0x6 )\ +CAUSE_DEF(SGS_services_not_allowed,0x7 )\ +CAUSE_DEF(UE_identity_cannot_be_derived_by_the_network,0x9 )\ +CAUSE_DEF(Implicitly_de_registered,0x0a )\ +CAUSE_DEF(PLMN_not_allowed,0x0b )\ +CAUSE_DEF(Tracking_area_not_allowed,0x0c )\ +CAUSE_DEF(Roaming_not_allowed_in_this_tracking_area,0x0d )\ +CAUSE_DEF(No_suitable_cells_in_tracking_area,0x0f )\ +CAUSE_DEF(MAC_failure,0x14 )\ +CAUSE_DEF(Synch_failure,0x15 )\ +CAUSE_DEF(Congestion,0x16 )\ +CAUSE_DEF(UE_security_capabilities_mismatch,0x17 )\ +CAUSE_DEF(Security_mode_rejected_unspecified,0x18 )\ +CAUSE_DEF(Non_5G_authentication_unacceptable,0x1a )\ +CAUSE_DEF(N1_mode_not_allowed,0x1b )\ +CAUSE_DEF(Restricted_service_area,0x1c )\ +CAUSE_DEF(Redirection_to_EPC_required,0x1f )\ +CAUSE_DEF(LADN_not_available,0x2b )\ +CAUSE_DEF(No_network_slices_available,0x3e )\ +CAUSE_DEF(Maximum_number_of_PDU_sessions_reached,0x41 )\ +CAUSE_DEF(Insufficient_resources_for_specific_slice_and_DNN,0x43 )\ +CAUSE_DEF(Insufficient_resources_for_specific_slice,0x45 )\ +CAUSE_DEF(ngKSI_already_in_use,0x47 )\ +CAUSE_DEF(Non_3GPP_access_to_5GCN_not_allowed,0x48 )\ +CAUSE_DEF(Serving_network_not_authorized,0x49 )\ +CAUSE_DEF(Temporarily_not_authorized_for_this_SNPN,0x4A )\ +CAUSE_DEF(Permanently_not_authorized_for_this_SNPN,0x4b )\ +CAUSE_DEF(Not_authorized_for_this_CAG_or_authorized_for_CAG_cells_only,0x4c )\ +CAUSE_DEF(Wireline_access_area_not_allowed,0x4d )\ +CAUSE_DEF(Payload_was_not_forwarded,0x5a )\ +CAUSE_DEF(DNN_not_supported_or_not_subscribed_in_the_slice,0x5b )\ +CAUSE_DEF(Insufficient_user_plane_resources_for_the_PDU_session,0x5c )\ +CAUSE_DEF(Semantically_incorrect_message,0x5f )\ +CAUSE_DEF(Invalid_mandatory_information,0x60 )\ +CAUSE_DEF(Message_type_non_existent_or_not_implemented,0x61 )\ +CAUSE_DEF(Message_type_not_compatible_with_the_protocol_state,0x62 )\ +CAUSE_DEF(Information_element_non_existent_or_not_implemented,0x63 )\ +CAUSE_DEF(Conditional_IE_error,0x64 )\ +CAUSE_DEF(Message_not_compatible_with_the_protocol_state,0x65 )\ +CAUSE_DEF(Protocol_error_unspecified,0x67 ) + +/* Map task id to printable name. */ +typedef struct { + int id; + char text[256]; +} cause_text_info_t; +#define CAUSE_TEXT(LabEl, nUmID) {nUmID, #LabEl}, + +static const cause_text_info_t cause_text_info[] = { + FOREACH_CAUSE(CAUSE_TEXT) +}; + +#define CAUSE_ENUM(LabEl, nUmID ) LabEl = nUmID, +//! Tasks id of each task +typedef enum { + FOREACH_CAUSE(CAUSE_ENUM) +} cause_id_t; + + + +//_table_9.11.4.2.1:_5GSM_cause_information_element +#define FOREACH_CAUSE_SECU(CAUSE_SECU_DEF) \ +CAUSE_SECU_DEF(Security_Operator_determined_barring,0x08 )\ +CAUSE_SECU_DEF(Security_Insufficient_resources,0x1a )\ +CAUSE_SECU_DEF(Security_Missing_or_unknown_DNN,0x1b )\ +CAUSE_SECU_DEF(Security_Unknown_PDU_session_type,0x1c )\ +CAUSE_SECU_DEF(Security_User_authentication_or_authorization_failed,0x1d )\ +CAUSE_SECU_DEF(Security_Request_rejected_unspecified,0x1f )\ +CAUSE_SECU_DEF(Security_Service_option_not_supported,0x20 )\ +CAUSE_SECU_DEF(Security_Requested_service_option_not_subscribed,0x21 )\ +CAUSE_SECU_DEF(Security_Service_option_temporarily_out_of_order,0x22 )\ +CAUSE_SECU_DEF(Security_PTI_already_in_use,0x23 )\ +CAUSE_SECU_DEF(Security_Regular_deactivation,0x24 )\ +CAUSE_SECU_DEF(Security_Network_failure,0x26 )\ +CAUSE_SECU_DEF(Security_Reactivation_requested,0x27 )\ +CAUSE_SECU_DEF(Security_Semantic_error_in_the_TFT_operation,0x29 )\ +CAUSE_SECU_DEF(Security_Syntactical_error_in_the_TFT_operation,0x2a )\ +CAUSE_SECU_DEF(Security_Invalid_PDU_session_identity,0x2b )\ +CAUSE_SECU_DEF(Security_Semantic_errors_in_packet_filter,0x2c )\ +CAUSE_SECU_DEF(Security_Syntactical_error_in_packet_filter,0x2d )\ +CAUSE_SECU_DEF(Security_Out_of_LADN_service_area,0x2e )\ +CAUSE_SECU_DEF(Security_PTI_mismatch,0x2f )\ +CAUSE_SECU_DEF(Security_PDU_session_type_IPv4_only_allowed,0x32 )\ +CAUSE_SECU_DEF(Security_PDU_session_type_IPv6_only_allowed,0x33 )\ +CAUSE_SECU_DEF(Security_PDU_session_does_not_exist,0x36 )\ +CAUSE_SECU_DEF(Security_PDU_session_type_IPv4v6_only_allowed,0x39 )\ +CAUSE_SECU_DEF(Security_PDU_session_type_Unstructured_only_allowed,0x3a )\ +CAUSE_SECU_DEF(Security_PDU_session_type_Ethernet_only_allowed,0x3d )\ +CAUSE_SECU_DEF(Security_Insufficient_resources_for_specific_slice_and_DNN,0x43 )\ +CAUSE_SECU_DEF(Security_Not_supported_SSC_mode,0x44 )\ +CAUSE_SECU_DEF(Security_Insufficient_resources_for_specific_slice,0x45 )\ +CAUSE_SECU_DEF(Security_Missing_or_unknown_DNN_in_a_slice,0x46 )\ +CAUSE_SECU_DEF(Security_Invalid_PTI_value,0x51 )\ +CAUSE_SECU_DEF(Security_Maximum_data_rate_per_UE_for_user_plane_integrity_protection_is_too_low,0x52 )\ +CAUSE_SECU_DEF(Security_Semantic_error_in_the_QoS_operation,0x53 )\ +CAUSE_SECU_DEF(Security_Syntactical_error_in_the_QoS_operation,0x54 )\ +CAUSE_SECU_DEF(Security_Invalid_mapped_EPS_bearer_identity,0x55 )\ +CAUSE_SECU_DEF(Security_Semantically_incorrect_message,0x5f )\ +CAUSE_SECU_DEF(Security_Invalid_mandatory_information,0x60 )\ +CAUSE_SECU_DEF(Security_Message_type_non_existent_or_not_implemented,0x61 )\ +CAUSE_SECU_DEF(Security_Message_type_not_compatible_with_the_protocol_state,0x62 )\ +CAUSE_SECU_DEF(Security_Information_element_non_existent_or_not_implemented,0x63 )\ +CAUSE_SECU_DEF(Security_Conditional_IE_error,0x64 )\ +CAUSE_SECU_DEF(Security_Message_not_compatible_with_the_protocol_state,0x65 )\ +CAUSE_SECU_DEF(Security_Protocol_error_unspecified,0x6f ) + +static const cause_text_info_t cause_secu_text_info[] = { + FOREACH_CAUSE_SECU(CAUSE_TEXT) +}; + +#define CAUSE_ENUM(LabEl, nUmID ) LabEl = nUmID, +//! Tasks id of each task +typedef enum { + FOREACH_CAUSE_SECU(CAUSE_ENUM) +} cause_secu_id_t; + + typedef struct { + Extendedprotocoldiscriminator_t epd:8; + Security_header_t sh:8; + SGSmobilitymanagementmessages_t mt:8; + identitytype_t it:8; +} Identityrequest_t; + +// the message continues with the identity value, depending on identity type, see TS 14.501, 9.11.3.4 +typedef struct { + Extendedprotocoldiscriminator_t epd:8; + Security_header_t sh:8; + SGSmobilitymanagementmessages_t mt:8; + identitytype_t mi:8; +} Identityresponse_t; + + From d04b4c0eeb3d0842faeb3eb71d3e101f8c63fe46 Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 24 Jul 2020 11:29:49 +0200 Subject: [PATCH 021/149] fix ont bug in DFT and some performance improvements --- executables/ocp-gnb.c | 10 +- openair1/PHY/TOOLS/oai_dfts.c | 4549 ++++++++++++----------------- openair3/NAS/COMMON/NR_NAS_defs.h | 318 +- 3 files changed, 1981 insertions(+), 2896 deletions(-) diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index f00b5f71b3..506396b3be 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -840,7 +840,6 @@ static void *ru_thread( void *param ) { proc->timestamp_rx=nextRxTSlogical; nextRxTSlogical+=samples_per_slot; int64_t HW_to_logical_RxTSoffset=(int64_t)HWtimeStamp-(int64_t)proc->timestamp_rx; - printf("%lu, %lu\n",HWtimeStamp, (slot+1)*fp->samples_per_subframe); proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; float offsetInSubframe=proc->timestamp_rx % fp->samples_per_subframe; @@ -852,7 +851,7 @@ static void *ru_thread( void *param ) { (unsigned long long int)proc->timestamp_rx, (int)ru->ts_offset,proc->frame_rx,proc->tti_rx,proc->tti_tx,fp->slots_per_frame); int slot_type = nr_slot_select(&ru->gNB_list[0]->gNB_config,proc->frame_rx,proc->tti_rx); - + if (slot_type == NR_UPLINK_SLOT || slot_type == NR_MIXED_SLOT) { nr_fep_full(ru,proc->tti_rx); @@ -862,13 +861,14 @@ static void *ru_thread( void *param ) { LOG_D(PHY, "rxdataF energy: %d\n", signal_energy(ru->common.rxdataF[0], fp->symbols_per_slot*fp->ofdm_symbol_size)); } - + gNB_top(&RC.gNB[0][0].proc, ru); gNB_L1_rxtx_proc_t *L1_proc = &RC.gNB[0][0].proc.L1_proc; - + if (rxtx(&RC.gNB[0][0],L1_proc) < 0) LOG_E(PHY,"gNB %d CC_id %d failed during execution\n",RC.gNB[0][0].Mod_id,RC.gNB[0][0].CC_id); + // do TX front-end processing if needed (precoding and/or IDFTs) //ru->feptx_prec(ru,proc->frame_tx,proc->tti_tx); nr_feptx_prec(ru,proc->frame_tx,proc->tti_tx); @@ -887,7 +887,7 @@ static void *ru_thread( void *param ) { proc->frame_tx,proc->tti_tx,proc->timestamp_tx,dB_fixed(signal_energy((int32_t *)txdata,fp->get_samples_per_slot( proc->tti_tx,fp))),dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF))); } - + // do outgoing fronthaul (south) if needed tx_rf(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx+HW_to_logical_RxTSoffset); slot++; diff --git a/openair1/PHY/TOOLS/oai_dfts.c b/openair1/PHY/TOOLS/oai_dfts.c index 25244eeff5..2a7915665b 100644 --- a/openair1/PHY/TOOLS/oai_dfts.c +++ b/openair1/PHY/TOOLS/oai_dfts.c @@ -29,19 +29,19 @@ #include #ifndef M_PI -#define M_PI 3.14159265358979323846 + #define M_PI 3.14159265358979323846 #endif #define OAIDFTS_MAIN #ifndef MR_MAIN -#include "PHY/defs_common.h" -#include "PHY/impl_defs_top.h" + #include "PHY/defs_common.h" + #include "PHY/impl_defs_top.h" #else -#include "time_meas.h" -#include "LOG/log.h" -#define debug_msg -#define ONE_OVER_SQRT2_Q15 23170 + #include "time_meas.h" + #include "LOG/log.h" + #define debug_msg + #define ONE_OVER_SQRT2_Q15 23170 -int oai_exit=0; + int oai_exit=0; #endif #define ONE_OVER_SQRT3_Q15 18919 @@ -56,88 +56,68 @@ int oai_exit=0; #define print_ints(s,x) printf("%s %d %d %d %d\n",s,(x)[0],(x)[1],(x)[2],(x)[3]) -const static int16_t conjugatedft[32] __attribute__((aligned(32))) = {-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1}; - - -const static int16_t reflip[32] __attribute__((aligned(32))) = {1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1}; - +#ifdef __AVX2__ +typedef union { + __m256i v256; + __m128i v128; + int8_t scal8[32]; + int16_t scal16[16]; +} uniVect_t; +const static uniVect_t perm_mask= {.scal8={2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13,18,19,16,17,22,23,20,21,26,27,24,25,30,31,28,29}}; +const static uniVect_t reflip= {.scal16= {1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1}}; +const static uniVect_t conjugatedft= {.scal16= {-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1}}; +#endif #if defined(__x86_64__) || defined(__i386__) static inline void cmac(__m128i a,__m128i b, __m128i *re32, __m128i *im32) __attribute__((always_inline)); -static inline void cmac(__m128i a,__m128i b, __m128i *re32, __m128i *im32) -{ - +static inline void cmac(__m128i a,__m128i b, __m128i *re32, __m128i *im32) { __m128i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; - - cmac_tmp = _mm_sign_epi16(b,*(__m128i*)reflip); + cmac_tmp = _mm_sign_epi16(b,reflip.v128); cmac_tmp_re32 = _mm_madd_epi16(a,cmac_tmp); - - // cmac_tmp = _mm_shufflelo_epi16(b,_MM_SHUFFLE(2,3,0,1)); // cmac_tmp = _mm_shufflehi_epi16(cmac_tmp,_MM_SHUFFLE(2,3,0,1)); cmac_tmp = _mm_shuffle_epi8(b,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); cmac_tmp_im32 = _mm_madd_epi16(cmac_tmp,a); - *re32 = _mm_add_epi32(*re32,cmac_tmp_re32); *im32 = _mm_add_epi32(*im32,cmac_tmp_im32); } static inline void cmacc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) __attribute__((always_inline)); -static inline void cmacc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) -{ - +static inline void cmacc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) { __m128i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; - - cmac_tmp_re32 = _mm_madd_epi16(a,b); - - - cmac_tmp = _mm_sign_epi16(b,*(__m128i*)reflip); + cmac_tmp = _mm_sign_epi16(b,reflip.v128); // cmac_tmp = _mm_shufflelo_epi16(b,_MM_SHUFFLE(2,3,0,1)); // cmac_tmp = _mm_shufflehi_epi16(cmac_tmp,_MM_SHUFFLE(2,3,0,1)); cmac_tmp = _mm_shuffle_epi8(cmac_tmp,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); cmac_tmp_im32 = _mm_madd_epi16(cmac_tmp,a); - *re32 = _mm_add_epi32(*re32,cmac_tmp_re32); *im32 = _mm_add_epi32(*im32,cmac_tmp_im32); } #ifdef __AVX2__ -static inline void cmac_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) __attribute__((always_inline)); -static inline void cmac_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) -{ - __m256i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; - __m256i imshuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,19,18,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - - cmac_tmp = _mm256_sign_epi16(b,*(__m256i*)reflip); - cmac_tmp_re32 = _mm256_madd_epi16(a,cmac_tmp); - - cmac_tmp = _mm256_shuffle_epi8(b,imshuffle); - cmac_tmp_im32 = _mm256_madd_epi16(cmac_tmp,a); - - *re32 = _mm256_add_epi32(*re32,cmac_tmp_re32); - *im32 = _mm256_add_epi32(*im32,cmac_tmp_im32); -} +#define cmac_256(a,b,re32,im32) { \ + __m256i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; \ + cmac_tmp = _mm256_sign_epi16(b,reflip.v256); \ + cmac_tmp_re32 = _mm256_madd_epi16(a,cmac_tmp); \ + cmac_tmp = _mm256_shuffle_epi8(b,perm_mask.v256); \ + cmac_tmp_im32 = _mm256_madd_epi16(cmac_tmp,a); \ + re32 = _mm256_add_epi32(re32,cmac_tmp_re32); \ + im32 = _mm256_add_epi32(im32,cmac_tmp_im32); \ + } static inline void cmacc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) __attribute__((always_inline)); -static inline void cmacc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) -{ - +static inline void cmacc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) { __m256i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; - __m256i imshuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,19,18,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - cmac_tmp_re32 = _mm256_madd_epi16(a,b); - - - cmac_tmp = _mm256_sign_epi16(b,*(__m256i*)reflip); - cmac_tmp = _mm256_shuffle_epi8(b,imshuffle); + cmac_tmp = _mm256_sign_epi16(b,reflip.v256); + cmac_tmp = _mm256_shuffle_epi8(b,perm_mask.v256); cmac_tmp_im32 = _mm256_madd_epi16(cmac_tmp,a); - *re32 = _mm256_add_epi32(*re32,cmac_tmp_re32); *im32 = _mm256_add_epi32(*im32,cmac_tmp_im32); } @@ -146,241 +126,173 @@ static inline void cmacc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) static inline void cmult(__m128i a,__m128i b, __m128i *re32, __m128i *im32) __attribute__((always_inline)); -static inline void cmult(__m128i a,__m128i b, __m128i *re32, __m128i *im32) -{ - +static inline void cmult(__m128i a,__m128i b, __m128i *re32, __m128i *im32) { register __m128i mmtmpb; - - mmtmpb = _mm_sign_epi16(b,*(__m128i*)reflip); + mmtmpb = _mm_sign_epi16(b,reflip.v128); *re32 = _mm_madd_epi16(a,mmtmpb); // mmtmpb = _mm_shufflelo_epi16(b,_MM_SHUFFLE(2,3,0,1)); // mmtmpb = _mm_shufflehi_epi16(mmtmpb,_MM_SHUFFLE(2,3,0,1)); mmtmpb = _mm_shuffle_epi8(b,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); *im32 = _mm_madd_epi16(a,mmtmpb); - } #ifdef __AVX2__ -static inline void cmult_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) __attribute__((always_inline)); - -static inline void cmult_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) -{ - - register __m256i mmtmpb; - __m256i const perm_mask = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - - mmtmpb = _mm256_sign_epi16(b,*(__m256i*)reflip); - *re32 = _mm256_madd_epi16(a,mmtmpb); - mmtmpb = _mm256_shuffle_epi8(b,perm_mask); - *im32 = _mm256_madd_epi16(a,mmtmpb); - -} +#define cmult_256(a,b,out_re32,out_im32) {\ + register __m256i mmtmpb = _mm256_sign_epi16(b,reflip.v256);\ + out_re32 = _mm256_madd_epi16(a,mmtmpb);\ + mmtmpb = _mm256_shuffle_epi8(b,perm_mask.v256);\ + out_im32 = _mm256_madd_epi16(a,mmtmpb);\ + } #endif static inline void cmultc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) __attribute__((always_inline)); -static inline void cmultc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) -{ - +static inline void cmultc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) { register __m128i mmtmpb; - *re32 = _mm_madd_epi16(a,b); - mmtmpb = _mm_sign_epi16(b,*(__m128i*)reflip); + mmtmpb = _mm_sign_epi16(b,reflip.v128); mmtmpb = _mm_shuffle_epi8(mmtmpb,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); *im32 = _mm_madd_epi16(a,mmtmpb); - } #ifdef __AVX2__ -static inline void cmultc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) __attribute__((always_inline)); - -static inline void cmultc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) -{ - - register __m256i mmtmpb; - __m256i const perm_mask = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - - *re32 = _mm256_madd_epi16(a,b); - mmtmpb = _mm256_sign_epi16(b,*(__m256i*)reflip); - mmtmpb = _mm256_shuffle_epi8(mmtmpb,perm_mask); - *im32 = _mm256_madd_epi16(a,mmtmpb); - -} +#define cmultc_256(a,b,out_re, out_im) { \ + out_re = _mm256_madd_epi16(a,b);\ + __m256i mmtmpb = _mm256_sign_epi16(b,reflip.v256);\ + mmtmpb = _mm256_shuffle_epi8(mmtmpb,perm_mask.v256);\ + out_im = _mm256_madd_epi16(a,mmtmpb);\ + } #endif static inline __m128i cpack(__m128i xre,__m128i xim) __attribute__((always_inline)); -static inline __m128i cpack(__m128i xre,__m128i xim) -{ - +static inline __m128i cpack(__m128i xre,__m128i xim) { register __m128i cpack_tmp1,cpack_tmp2; - cpack_tmp1 = _mm_unpacklo_epi32(xre,xim); cpack_tmp2 = _mm_unpackhi_epi32(xre,xim); return(_mm_packs_epi32(_mm_srai_epi32(cpack_tmp1,15),_mm_srai_epi32(cpack_tmp2,15))); - } #ifdef __AVX2__ -static inline __m256i cpack_256(__m256i xre,__m256i xim) __attribute__((always_inline)); -static inline __m256i cpack_256(__m256i xre,__m256i xim) -{ - - register __m256i cpack_tmp1,cpack_tmp2; - - cpack_tmp1 = _mm256_unpacklo_epi32(xre,xim); - cpack_tmp2 = _mm256_unpackhi_epi32(xre,xim); - return(_mm256_packs_epi32(_mm256_srai_epi32(cpack_tmp1,15),_mm256_srai_epi32(cpack_tmp2,15))); - -} + #define cpack_256(xre,xim) _mm256_blend_epi16(_mm256_srai_epi32(xre,15),_mm256_slli_epi32(xim,1),0xaa) #endif static inline void packed_cmult(__m128i a,__m128i b, __m128i *c) __attribute__((always_inline)); -static inline void packed_cmult(__m128i a,__m128i b, __m128i *c) -{ - +static inline void packed_cmult(__m128i a,__m128i b, __m128i *c) { __m128i cre,cim; cmult(a,b,&cre,&cim); *c = cpack(cre,cim); - } #ifdef __AVX2__ static inline void packed_cmult_256(__m256i a,__m256i b, __m256i *c) __attribute__((always_inline)); -static inline void packed_cmult_256(__m256i a,__m256i b, __m256i *c) -{ - +static inline void packed_cmult_256(__m256i a,__m256i b, __m256i *c) { __m256i cre,cim; - cmult_256(a,b,&cre,&cim); + cmult_256(a,b,cre,cim); *c = cpack_256(cre,cim); - } #endif static inline void packed_cmultc(__m128i a,__m128i b, __m128i *c) __attribute__((always_inline)); -static inline void packed_cmultc(__m128i a,__m128i b, __m128i *c) -{ - +static inline void packed_cmultc(__m128i a,__m128i b, __m128i *c) { __m128i cre,cim; - cmultc(a,b,&cre,&cim); *c = cpack(cre,cim); - } #ifdef __AVX2__ static inline void packed_cmultc_256(__m256i a,__m256i b, __m256i *c) __attribute__((always_inline)); -static inline void packed_cmultc_256(__m256i a,__m256i b, __m256i *c) -{ - - __m256i cre,cim; - - cmultc_256(a,b,&cre,&cim); +static inline void packed_cmultc_256(__m256i a,__m256i b, __m256i *c) { + register __m256i cre,cim; + cmultc_256(a,b,cre,cim); *c = cpack_256(cre,cim); - } #endif static inline __m128i packed_cmult2(__m128i a,__m128i b,__m128i b2) __attribute__((always_inline)); -static inline __m128i packed_cmult2(__m128i a,__m128i b,__m128i b2) -{ - - +static inline __m128i packed_cmult2(__m128i a,__m128i b,__m128i b2) { register __m128i cre,cim; - cre = _mm_madd_epi16(a,b); cim = _mm_madd_epi16(a,b2); - return(cpack(cre,cim)); - } #ifdef __AVX2__ static inline __m256i packed_cmult2_256(__m256i a,__m256i b,__m256i b2) __attribute__((always_inline)); -static inline __m256i packed_cmult2_256(__m256i a,__m256i b,__m256i b2) -{ - - +static inline __m256i packed_cmult2_256(__m256i a,__m256i b,__m256i b2) { register __m256i cre,cim; - cre = _mm256_madd_epi16(a,b); cim = _mm256_madd_epi16(a,b2); - return(cpack_256(cre,cim)); - } #endif #elif defined (__arm__) static inline void cmac(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) __attribute__((always_inline)); -static inline void cmac(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) -{ - - +static inline void cmac(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) { int32x4_t ab_re0,ab_re1,ab_im0,ab_im1; int16x8_t bflip = vrev32q_s16(b); int16x8_t bconj = vmulq_s16(b,*(int16x8_t *)reflip); - - ab_re0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&bconj)[0]); - ab_re1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&bconj)[1]); - ab_im0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&bflip)[0]); - ab_im1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&bflip)[1]); - *re32 = vqaddq_s32(*re32,vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), - vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1]))); - *im32 = vqaddq_s32(*im32,vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), - vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1]))); + ab_re0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&bconj)[0]); + ab_re1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&bconj)[1]); + ab_im0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&bflip)[0]); + ab_im1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&bflip)[1]); + *re32 = vqaddq_s32(*re32,vcombine_s32(vpadd_s32(((int32x2_t *)&ab_re0)[0],((int32x2_t *)&ab_re0)[1]), + vpadd_s32(((int32x2_t *)&ab_re1)[0],((int32x2_t *)&ab_re1)[1]))); + *im32 = vqaddq_s32(*im32,vcombine_s32(vpadd_s32(((int32x2_t *)&ab_im0)[0],((int32x2_t *)&ab_im0)[1]), + vpadd_s32(((int32x2_t *)&ab_im1)[0],((int32x2_t *)&ab_im1)[1]))); } static inline void cmacc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) __attribute__((always_inline)); -static inline void cmacc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) -{ +static inline void cmacc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) { int32x4_t ab_re0,ab_re1,ab_im0,ab_im1; int16x8_t bconj = vmulq_s16(b,*(int16x8_t *)reflip); int16x8_t bflip = vrev32q_s16(bconj); - - ab_re0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&b)[0]); - ab_re1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&b)[1]); - ab_im0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&bflip)[0]); - ab_im1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&bflip)[1]); - *re32 = vqaddq_s32(*re32,vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), - vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1]))); - *im32 = vqaddq_s32(*im32,vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), - vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1]))); - + ab_re0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&b)[0]); + ab_re1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&b)[1]); + ab_im0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&bflip)[0]); + ab_im1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&bflip)[1]); + *re32 = vqaddq_s32(*re32,vcombine_s32(vpadd_s32(((int32x2_t *)&ab_re0)[0],((int32x2_t *)&ab_re0)[1]), + vpadd_s32(((int32x2_t *)&ab_re1)[0],((int32x2_t *)&ab_re1)[1]))); + *im32 = vqaddq_s32(*im32,vcombine_s32(vpadd_s32(((int32x2_t *)&ab_im0)[0],((int32x2_t *)&ab_im0)[1]), + vpadd_s32(((int32x2_t *)&ab_im1)[0],((int32x2_t *)&ab_im1)[1]))); } static inline void cmult(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) __attribute__((always_inline)); -static inline void cmult(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) -{ +static inline void cmult(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) { int32x4_t ab_re0,ab_re1,ab_im0,ab_im1; int16x8_t bflip = vrev32q_s16(b); int16x8_t bconj = vmulq_s16(b,*(int16x8_t *)reflip); int16x4_t al,ah,bcl,bch,bfl,bfh; int32x2_t abr0l,abr0h,abr1l,abr1h,abi0l,abi0h,abi1l,abi1h; - - al = vget_low_s16(a); ah = vget_high_s16(a); - bcl = vget_low_s16(bconj); bch = vget_high_s16(bconj); - bfl = vget_low_s16(bflip); bfh = vget_high_s16(bflip); - + al = vget_low_s16(a); + ah = vget_high_s16(a); + bcl = vget_low_s16(bconj); + bch = vget_high_s16(bconj); + bfl = vget_low_s16(bflip); + bfh = vget_high_s16(bflip); ab_re0 = vmull_s16(al,bcl); ab_re1 = vmull_s16(ah,bch); ab_im0 = vmull_s16(al,bfl); ab_im1 = vmull_s16(ah,bfh); - abr0l = vget_low_s32(ab_re0); abr0h = vget_high_s32(ab_re0); - abr1l = vget_low_s32(ab_re1); abr1h = vget_high_s32(ab_re1); - abi0l = vget_low_s32(ab_im0); abi0h = vget_high_s32(ab_im0); - abi1l = vget_low_s32(ab_im1); abi1h = vget_high_s32(ab_im1); - + abr0l = vget_low_s32(ab_re0); + abr0h = vget_high_s32(ab_re0); + abr1l = vget_low_s32(ab_re1); + abr1h = vget_high_s32(ab_re1); + abi0l = vget_low_s32(ab_im0); + abi0h = vget_high_s32(ab_im0); + abi1l = vget_low_s32(ab_im1); + abi1h = vget_high_s32(ab_im1); *re32 = vcombine_s32(vpadd_s32(abr0l,abr0h), vpadd_s32(abr1l,abr1h)); *im32 = vcombine_s32(vpadd_s32(abi0l,abi0h), @@ -389,90 +301,76 @@ static inline void cmult(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im static inline void cmultc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) __attribute__((always_inline)); -static inline void cmultc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) -{ +static inline void cmultc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) { int32x4_t ab_re0,ab_re1,ab_im0,ab_im1; int16x8_t bconj = vmulq_s16(b,*(int16x8_t *)reflip); int16x8_t bflip = vrev32q_s16(bconj); - int16x4_t al,ah,bl,bh,bfl,bfh; + int16x4_t al,ah,bl,bh,bfl,bfh; int32x2_t abr0l,abr0h,abr1l,abr1h,abi0l,abi0h,abi1l,abi1h; - al = vget_low_s16(a); ah = vget_high_s16(a); - bl = vget_low_s16(b); bh = vget_high_s16(b); - bfl = vget_low_s16(bflip); bfh = vget_high_s16(bflip); - + al = vget_low_s16(a); + ah = vget_high_s16(a); + bl = vget_low_s16(b); + bh = vget_high_s16(b); + bfl = vget_low_s16(bflip); + bfh = vget_high_s16(bflip); ab_re0 = vmull_s16(al,bl); ab_re1 = vmull_s16(ah,bh); ab_im0 = vmull_s16(al,bfl); ab_im1 = vmull_s16(ah,bfh); - - abr0l = vget_low_s32(ab_re0); abr0h = vget_high_s32(ab_re0); - abr1l = vget_low_s32(ab_re1); abr1h = vget_high_s32(ab_re1); - abi0l = vget_low_s32(ab_im0); abi0h = vget_high_s32(ab_im0); - abi1l = vget_low_s32(ab_im1); abi1h = vget_high_s32(ab_im1); - + abr0l = vget_low_s32(ab_re0); + abr0h = vget_high_s32(ab_re0); + abr1l = vget_low_s32(ab_re1); + abr1h = vget_high_s32(ab_re1); + abi0l = vget_low_s32(ab_im0); + abi0h = vget_high_s32(ab_im0); + abi1l = vget_low_s32(ab_im1); + abi1h = vget_high_s32(ab_im1); *re32 = vcombine_s32(vpadd_s32(abr0l,abr0h), - vpadd_s32(abr1l,abr1h)); + vpadd_s32(abr1l,abr1h)); *im32 = vcombine_s32(vpadd_s32(abi0l,abi0h), - vpadd_s32(abi1l,abi1h)); - + vpadd_s32(abi1l,abi1h)); } static inline int16x8_t cpack(int32x4_t xre,int32x4_t xim) __attribute__((always_inline)); -static inline int16x8_t cpack(int32x4_t xre,int32x4_t xim) -{ +static inline int16x8_t cpack(int32x4_t xre,int32x4_t xim) { int32x4x2_t xtmp; - xtmp = vzipq_s32(xre,xim); return(vcombine_s16(vqshrn_n_s32(xtmp.val[0],15),vqshrn_n_s32(xtmp.val[1],15))); - } static inline void packed_cmult(int16x8_t a,int16x8_t b, int16x8_t *c) __attribute__((always_inline)); -static inline void packed_cmult(int16x8_t a,int16x8_t b, int16x8_t *c) -{ - +static inline void packed_cmult(int16x8_t a,int16x8_t b, int16x8_t *c) { int32x4_t cre,cim; cmult(a,b,&cre,&cim); *c = cpack(cre,cim); - } static inline void packed_cmultc(int16x8_t a,int16x8_t b, int16x8_t *c) __attribute__((always_inline)); -static inline void packed_cmultc(int16x8_t a,int16x8_t b, int16x8_t *c) -{ - +static inline void packed_cmultc(int16x8_t a,int16x8_t b, int16x8_t *c) { int32x4_t cre,cim; - cmultc(a,b,&cre,&cim); *c = cpack(cre,cim); - } static inline int16x8_t packed_cmult2(int16x8_t a,int16x8_t b, int16x8_t b2) __attribute__((always_inline)); -static inline int16x8_t packed_cmult2(int16x8_t a,int16x8_t b, int16x8_t b2) -{ - - - +static inline int16x8_t packed_cmult2(int16x8_t a,int16x8_t b, int16x8_t b2) { int32x4_t ab_re0,ab_re1,ab_im0,ab_im1,cre,cim; - - ab_re0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&b)[0]); - ab_re1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&b)[1]); - ab_im0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&b2)[0]); - ab_im1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&b2)[1]); - cre = vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), - vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1])); - cim = vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), - vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1])); + ab_re0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&b)[0]); + ab_re1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&b)[1]); + ab_im0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&b2)[0]); + ab_im1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&b2)[1]); + cre = vcombine_s32(vpadd_s32(((int32x2_t *)&ab_re0)[0],((int32x2_t *)&ab_re0)[1]), + vpadd_s32(((int32x2_t *)&ab_re1)[0],((int32x2_t *)&ab_re1)[1])); + cim = vcombine_s32(vpadd_s32(((int32x2_t *)&ab_im0)[0],((int32x2_t *)&ab_im0)[1]), + vpadd_s32(((int32x2_t *)&ab_im1)[0],((int32x2_t *)&ab_im1)[1])); return(cpack(cre,cim)); - } #endif @@ -488,74 +386,68 @@ const static int16_t W35s[16]__attribute__((aligned(32))) = {-26510,19260,-26510 const static int16_t W45s[16]__attribute__((aligned(32))) = {10126,31163,10126,31163,10126,31163,10126,31163,10126,31163,10126,31163,10126,31163,10126,31163}; #if defined(__x86_64__) || defined(__i386__) -const __m128i *W0 = (__m128i *)W0s; -const __m128i *W13 = (__m128i *)W13s; -const __m128i *W23 = (__m128i *)W23s; -const __m128i *W15 = (__m128i *)W15s; -const __m128i *W25 = (__m128i *)W25s; -const __m128i *W35 = (__m128i *)W35s; -const __m128i *W45 = (__m128i *)W45s; + const __m128i *W0 = (__m128i *)W0s; + const __m128i *W13 = (__m128i *)W13s; + const __m128i *W23 = (__m128i *)W23s; + const __m128i *W15 = (__m128i *)W15s; + const __m128i *W25 = (__m128i *)W25s; + const __m128i *W35 = (__m128i *)W35s; + const __m128i *W45 = (__m128i *)W45s; -#ifdef __AVX2__ -const __m256i *W0_256 = (__m256i *)W0s; -const __m256i *W13_256 = (__m256i *)W13s; -const __m256i *W23_256 = (__m256i *)W23s; -const __m256i *W15_256 = (__m256i *)W15s; -const __m256i *W25_256 = (__m256i *)W25s; -const __m256i *W35_256 = (__m256i *)W35s; -const __m256i *W45_256 = (__m256i *)W45s; -#endif + #ifdef __AVX2__ + const __m256i *W0_256 = (__m256i *)W0s; + const __m256i *W13_256 = (__m256i *)W13s; + const __m256i *W23_256 = (__m256i *)W23s; + const __m256i *W15_256 = (__m256i *)W15s; + const __m256i *W25_256 = (__m256i *)W25s; + const __m256i *W35_256 = (__m256i *)W35s; + const __m256i *W45_256 = (__m256i *)W45s; + #endif #elif defined(__arm__) -int16x8_t *W0 = (int16x8_t *)W0s; -int16x8_t *W13 = (int16x8_t *)W13s; -int16x8_t *W23 = (int16x8_t *)W23s; -int16x8_t *W15 = (int16x8_t *)W15s; -int16x8_t *W25 = (int16x8_t *)W25s; -int16x8_t *W35 = (int16x8_t *)W35s; -int16x8_t *W45 = (int16x8_t *)W45s; + int16x8_t *W0 = (int16x8_t *)W0s; + int16x8_t *W13 = (int16x8_t *)W13s; + int16x8_t *W23 = (int16x8_t *)W23s; + int16x8_t *W15 = (int16x8_t *)W15s; + int16x8_t *W25 = (int16x8_t *)W25s; + int16x8_t *W35 = (int16x8_t *)W35s; + int16x8_t *W45 = (int16x8_t *)W45s; #endif const static int16_t dft_norm_table[16] = {9459, //12 - 6689,//24 - 5461,//36 - 4729,//482 - 4230,//60 - 23170,//72 - 3344,//96 - 3153,//108 - 2991,//120 - 18918,//sqrt(3),//144 - 18918,//sqrt(3),//180 - 16384,//2, //192 - 18918,//sqrt(3), // 216 - 16384,//2, //240 - 18918,//sqrt(3), // 288 - 14654 -}; //sqrt(5) //300 + 6689,//24 + 5461,//36 + 4729,//482 + 4230,//60 + 23170,//72 + 3344,//96 + 3153,//108 + 2991,//120 + 18918,//sqrt(3),//144 + 18918,//sqrt(3),//180 + 16384,//2, //192 + 18918,//sqrt(3), // 216 + 16384,//2, //240 + 18918,//sqrt(3), // 288 + 14654 + }; //sqrt(5) //300 #if defined(__x86_64__) || defined(__i386__) static inline void bfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw)__attribute__((always_inline)); -static inline void bfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw) -{ - +static inline void bfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw) { __m128i x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; __m128i bfly2_tmp1,bfly2_tmp2; - cmult(*(x0),*(W0),&x0r_2,&x0i_2); cmult(*(x1),*(tw),&x1r_2,&x1i_2); - dy0r = _mm_srai_epi32(_mm_add_epi32(x0r_2,x1r_2),15); dy1r = _mm_srai_epi32(_mm_sub_epi32(x0r_2,x1r_2),15); dy0i = _mm_srai_epi32(_mm_add_epi32(x0i_2,x1i_2),15); // printf("y0i %d\n",((int16_t *)y0i)[0]); dy1i = _mm_srai_epi32(_mm_sub_epi32(x0i_2,x1i_2),15); - bfly2_tmp1 = _mm_unpacklo_epi32(dy0r,dy0i); bfly2_tmp2 = _mm_unpackhi_epi32(dy0r,dy0i); *y0 = _mm_packs_epi32(bfly2_tmp1,bfly2_tmp2); - bfly2_tmp1 = _mm_unpacklo_epi32(dy1r,dy1i); bfly2_tmp2 = _mm_unpackhi_epi32(dy1r,dy1i); *y1 = _mm_packs_epi32(bfly2_tmp1,bfly2_tmp2); @@ -565,25 +457,19 @@ static inline void bfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m12 static inline void bfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw)__attribute__((always_inline)); -static inline void bfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw) -{ - +static inline void bfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw) { __m256i x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; __m256i bfly2_tmp1,bfly2_tmp2; - - cmult_256(*(x0),*(W0_256),&x0r_2,&x0i_2); - cmult_256(*(x1),*(tw),&x1r_2,&x1i_2); - + cmult_256(*(x0),*(W0_256),x0r_2,x0i_2); + cmult_256(*(x1),*(tw),x1r_2,x1i_2); dy0r = _mm256_srai_epi32(_mm256_add_epi32(x0r_2,x1r_2),15); dy1r = _mm256_srai_epi32(_mm256_sub_epi32(x0r_2,x1r_2),15); dy0i = _mm256_srai_epi32(_mm256_add_epi32(x0i_2,x1i_2),15); // printf("y0i %d\n",((int16_t *)y0i)[0]); dy1i = _mm256_srai_epi32(_mm256_sub_epi32(x0i_2,x1i_2),15); - bfly2_tmp1 = _mm256_unpacklo_epi32(dy0r,dy0i); bfly2_tmp2 = _mm256_unpackhi_epi32(dy0r,dy0i); *y0 = _mm256_packs_epi32(bfly2_tmp1,bfly2_tmp2); - bfly2_tmp1 = _mm256_unpacklo_epi32(dy1r,dy1i); bfly2_tmp2 = _mm256_unpackhi_epi32(dy1r,dy1i); *y1 = _mm256_packs_epi32(bfly2_tmp1,bfly2_tmp2); @@ -595,19 +481,14 @@ static inline void bfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,_ static inline void bfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw)__attribute__((always_inline)); -static inline void bfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw) -{ - +static inline void bfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw) { int32x4_t x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; - cmult(*(x0),*(W0),&x0r_2,&x0i_2); cmult(*(x1),*(tw),&x1r_2,&x1i_2); - dy0r = vqaddq_s32(x0r_2,x1r_2); dy1r = vqsubq_s32(x0r_2,x1r_2); dy0i = vqaddq_s32(x0i_2,x1i_2); dy1i = vqsubq_s32(x0i_2,x1i_2); - *y0 = cpack(dy0r,dy0i); *y1 = cpack(dy1r,dy1i); } @@ -618,39 +499,30 @@ static inline void bfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t * #if defined(__x86_64__) || defined(__i386__) static inline void bfly2_tw1(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1)__attribute__((always_inline)); -static inline void bfly2_tw1(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1) -{ - +static inline void bfly2_tw1(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1) { *y0 = _mm_adds_epi16(*x0,*x1); *y1 = _mm_subs_epi16(*x0,*x1); - } #elif defined(__arm__) static inline void bfly2_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1)__attribute__((always_inline)); -static inline void bfly2_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1) -{ - +static inline void bfly2_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1) { *y0 = vqaddq_s16(*x0,*x1); *y1 = vqsubq_s16(*x0,*x1); - } #endif - + #if defined(__x86_64__) || defined(__i386__) static inline void bfly2_16(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1, __m128i *tw, __m128i *twb)__attribute__((always_inline)); -static inline void bfly2_16(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1, __m128i *tw, __m128i *twb) -{ - +static inline void bfly2_16(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1, __m128i *tw, __m128i *twb) { // register __m128i x1t; __m128i x1t; - x1t = packed_cmult2(*(x1),*(tw),*(twb)); /* print_shorts("x0",(int16_t*)x0); @@ -668,12 +540,9 @@ static inline void bfly2_16(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1, static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i *y1, __m256i *tw, __m256i *twb)__attribute__((always_inline)); -static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i *y1, __m256i *tw, __m256i *twb) -{ - +static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i *y1, __m256i *tw, __m256i *twb) { // register __m256i x1t; __m256i x1t; - x1t = packed_cmult2_256(*(x1),*(tw),*(twb)); /* print_shorts256("x0",(int16_t*)x0); @@ -683,7 +552,6 @@ static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i * print_shorts256("x1t",(int16_t*)&x1t);*/ *y0 = _mm256_adds_epi16(*x0,x1t); *y1 = _mm256_subs_epi16(*x0,x1t); - /*print_shorts256("y0",(int16_t*)y0); print_shorts256("y1",(int16_t*)y1);*/ } @@ -694,37 +562,28 @@ static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i * static inline void bfly2_16(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1, int16x8_t *tw, int16x8_t *twb)__attribute__((always_inline)); -static inline void bfly2_16(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1, int16x8_t *tw, int16x8_t *twb) -{ - +static inline void bfly2_16(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1, int16x8_t *tw, int16x8_t *twb) { *y0 = vqaddq_s16(*x0,*x1); *y1 = vqsubq_s16(*x0,*x1); - } #endif #if defined(__x86_64__) || defined(__i386__) static inline void ibfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw)__attribute__((always_inline)); -static inline void ibfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw) -{ - +static inline void ibfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw) { __m128i x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; __m128i bfly2_tmp1,bfly2_tmp2; - cmultc(*(x0),*(W0),&x0r_2,&x0i_2); cmultc(*(x1),*(tw),&x1r_2,&x1i_2); - dy0r = _mm_srai_epi32(_mm_add_epi32(x0r_2,x1r_2),15); dy1r = _mm_srai_epi32(_mm_sub_epi32(x0r_2,x1r_2),15); dy0i = _mm_srai_epi32(_mm_add_epi32(x0i_2,x1i_2),15); // printf("y0i %d\n",((int16_t *)y0i)[0]); dy1i = _mm_srai_epi32(_mm_sub_epi32(x0i_2,x1i_2),15); - bfly2_tmp1 = _mm_unpacklo_epi32(dy0r,dy0i); bfly2_tmp2 = _mm_unpackhi_epi32(dy0r,dy0i); *y0 = _mm_packs_epi32(bfly2_tmp1,bfly2_tmp2); - bfly2_tmp1 = _mm_unpacklo_epi32(dy1r,dy1i); bfly2_tmp2 = _mm_unpackhi_epi32(dy1r,dy1i); *y1 = _mm_packs_epi32(bfly2_tmp1,bfly2_tmp2); @@ -733,48 +592,30 @@ static inline void ibfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m1 #ifdef __AVX2__ static inline void ibfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw)__attribute__((always_inline)); -static inline void ibfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw) -{ - - __m256i x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; - __m256i bfly2_tmp1,bfly2_tmp2; - - cmultc_256(*(x0),*(W0_256),&x0r_2,&x0i_2); - cmultc_256(*(x1),*(tw),&x1r_2,&x1i_2); - - dy0r = _mm256_srai_epi32(_mm256_add_epi32(x0r_2,x1r_2),15); - dy1r = _mm256_srai_epi32(_mm256_sub_epi32(x0r_2,x1r_2),15); - dy0i = _mm256_srai_epi32(_mm256_add_epi32(x0i_2,x1i_2),15); - // printf("y0i %d\n",((int16_t *)y0i)[0]); - dy1i = _mm256_srai_epi32(_mm256_sub_epi32(x0i_2,x1i_2),15); - - bfly2_tmp1 = _mm256_unpacklo_epi32(dy0r,dy0i); - bfly2_tmp2 = _mm256_unpackhi_epi32(dy0r,dy0i); - *y0 = _mm256_packs_epi32(bfly2_tmp1,bfly2_tmp2); - - bfly2_tmp1 = _mm256_unpacklo_epi32(dy1r,dy1i); - bfly2_tmp2 = _mm256_unpackhi_epi32(dy1r,dy1i); - *y1 = _mm256_packs_epi32(bfly2_tmp1,bfly2_tmp2); +static inline void ibfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw) { + register __m256i x0r_2,x0i_2,x1r_2,x1i_2; + cmultc_256(*(x0),*(W0_256),x0r_2,x0i_2); + cmultc_256(*(x1),*(tw),x1r_2,x1i_2); + const __m256i dy0r = _mm256_srai_epi32(_mm256_add_epi32(x0r_2,x1r_2),15); + const __m256i dy0i = _mm256_slli_epi32(_mm256_add_epi32(x0i_2,x1i_2),1); + *y0 = _mm256_blend_epi16(dy0r,dy0i,0xaa); + const __m256i dy1r = _mm256_srai_epi32(_mm256_sub_epi32(x0r_2,x1r_2),15); + const __m256i dy1i = _mm256_slli_epi32(_mm256_sub_epi32(x0i_2,x1i_2),1); + *y1 = _mm256_blend_epi16(dy1r,dy1i,0xaa); } #endif #elif defined(__arm__) -static inline void ibfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw) -{ - +static inline void ibfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw) { int32x4_t x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; - cmultc(*(x0),*(W0),&x0r_2,&x0i_2); cmultc(*(x1),*(tw),&x1r_2,&x1i_2); - dy0r = vqaddq_s32(x0r_2,x1r_2); dy1r = vqsubq_s32(x0r_2,x1r_2); dy0i = vqaddq_s32(x0i_2,x1i_2); dy1i = vqsubq_s32(x0i_2,x1i_2); - *y0 = cpack(dy0r,dy0i); *y1 = cpack(dy1r,dy1i); - } #endif @@ -792,11 +633,8 @@ static inline void bfly3(__m128i *x0,__m128i *x1,__m128i *x2, static inline void bfly3(__m128i *x0,__m128i *x1,__m128i *x2, __m128i *y0,__m128i *y1,__m128i *y2, - __m128i *tw1,__m128i *tw2) -{ - + __m128i *tw1,__m128i *tw2) { __m128i tmpre,tmpim,x1_2,x2_2; - packed_cmult(*(x1),*(tw1),&x1_2); packed_cmult(*(x2),*(tw2),&x2_2); *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(x1_2,x2_2)); @@ -813,25 +651,22 @@ static inline void bfly3(__m128i *x0,__m128i *x1,__m128i *x2, #ifdef __AVX2__ static inline void bfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2, - __m256i *tw1,__m256i *tw2) __attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2, + __m256i *tw1,__m256i *tw2) __attribute__((always_inline)); static inline void bfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2, - __m256i *tw1,__m256i *tw2) -{ - + __m256i *y0,__m256i *y1,__m256i *y2, + __m256i *tw1,__m256i *tw2) { __m256i tmpre,tmpim,x1_2,x2_2; - packed_cmult_256(*(x1),*(tw1),&x1_2); packed_cmult_256(*(x2),*(tw2),&x2_2); *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(x1_2,x2_2)); - cmult_256(x1_2,*(W13_256),&tmpre,&tmpim); - cmac_256(x2_2,*(W23_256),&tmpre,&tmpim); + cmult_256(x1_2,*(W13_256),tmpre,tmpim); + cmac_256(x2_2,*(W23_256),tmpre,tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmult_256(x1_2,*(W23_256),&tmpre,&tmpim); - cmac_256(x2_2,*(W13_256),&tmpre,&tmpim); + cmult_256(x1_2,*(W23_256),tmpre,tmpim); + cmac_256(x2_2,*(W13_256),tmpre,tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); } @@ -844,12 +679,9 @@ static inline void bfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, static inline void bfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, - int16x8_t *tw1,int16x8_t *tw2) -{ - + int16x8_t *tw1,int16x8_t *tw2) { int32x4_t tmpre,tmpim; int16x8_t x1_2,x2_2; - packed_cmult(*(x1),*(tw1),&x1_2); packed_cmult(*(x2),*(tw2),&x2_2); *(y0) = vqaddq_s16(*(x0),vqaddq_s16(x1_2,x2_2)); @@ -867,16 +699,13 @@ static inline void bfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, #if defined(__x86_64__) || defined(__i386__) static inline void ibfly3(__m128i *x0,__m128i *x1,__m128i *x2, - __m128i *y0,__m128i *y1,__m128i *y2, - __m128i *tw1,__m128i *tw2) __attribute__((always_inline)); + __m128i *y0,__m128i *y1,__m128i *y2, + __m128i *tw1,__m128i *tw2) __attribute__((always_inline)); static inline void ibfly3(__m128i *x0,__m128i *x1,__m128i *x2, - __m128i *y0,__m128i *y1,__m128i *y2, - __m128i *tw1,__m128i *tw2) -{ - + __m128i *y0,__m128i *y1,__m128i *y2, + __m128i *tw1,__m128i *tw2) { __m128i tmpre,tmpim,x1_2,x2_2; - packed_cmultc(*(x1),*(tw1),&x1_2); packed_cmultc(*(x2),*(tw2),&x2_2); *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(x1_2,x2_2)); @@ -893,24 +722,21 @@ static inline void ibfly3(__m128i *x0,__m128i *x1,__m128i *x2, #ifdef __AVX2__ static inline void ibfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2, - __m256i *tw1,__m256i *tw2) __attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2, + __m256i *tw1,__m256i *tw2) __attribute__((always_inline)); static inline void ibfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2, - __m256i *tw1,__m256i *tw2) -{ - + __m256i *y0,__m256i *y1,__m256i *y2, + __m256i *tw1,__m256i *tw2) { __m256i tmpre,tmpim,x1_2,x2_2; - packed_cmultc_256(*(x1),*(tw1),&x1_2); packed_cmultc_256(*(x2),*(tw2),&x2_2); *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(x1_2,x2_2)); - cmultc_256(x1_2,*(W13_256),&tmpre,&tmpim); + cmultc_256(x1_2,*(W13_256),tmpre,tmpim); cmacc_256(x2_2,*(W23_256),&tmpre,&tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmultc_256(x1_2,*(W23_256),&tmpre,&tmpim); + cmultc_256(x1_2,*(W23_256),tmpre,tmpim); cmacc_256(x2_2,*(W13_256),&tmpre,&tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); @@ -919,17 +745,14 @@ static inline void ibfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, #elif defined(__arm__) static inline void ibfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, - int16x8_t *tw1,int16x8_t *tw2) __attribute__((always_inline)); + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, + int16x8_t *tw1,int16x8_t *tw2) __attribute__((always_inline)); static inline void ibfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, - int16x8_t *tw1,int16x8_t *tw2) -{ - + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, + int16x8_t *tw1,int16x8_t *tw2) { int32x4_t tmpre,tmpim; int16x8_t x1_2,x2_2; - packed_cmultc(*(x1),*(tw1),&x1_2); packed_cmultc(*(x2),*(tw2),&x2_2); *(y0) = vqaddq_s16(*(x0),vqaddq_s16(x1_2,x2_2)); @@ -949,11 +772,8 @@ static inline void bfly3_tw1(__m128i *x0,__m128i *x1,__m128i *x2, __m128i *y0,__m128i *y1,__m128i *y2) __attribute__((always_inline)); static inline void bfly3_tw1(__m128i *x0,__m128i *x1,__m128i *x2, - __m128i *y0,__m128i *y1,__m128i *y2) -{ - + __m128i *y0,__m128i *y1,__m128i *y2) { __m128i tmpre,tmpim; - *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(*(x1),*(x2))); cmult(*(x1),*(W13),&tmpre,&tmpim); cmac(*(x2),*(W23),&tmpre,&tmpim); @@ -968,21 +788,18 @@ static inline void bfly3_tw1(__m128i *x0,__m128i *x1,__m128i *x2, #ifdef __AVX2__ static inline void bfly3_tw1_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2) __attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2) __attribute__((always_inline)); static inline void bfly3_tw1_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2) -{ - + __m256i *y0,__m256i *y1,__m256i *y2) { __m256i tmpre,tmpim; - *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(*(x1),*(x2))); - cmult_256(*(x1),*(W13_256),&tmpre,&tmpim); - cmac_256(*(x2),*(W23_256),&tmpre,&tmpim); + cmult_256(*(x1),*(W13_256),tmpre,tmpim); + cmac_256(*(x2),*(W23_256),tmpre,tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmult_256(*(x1),*(W23_256),&tmpre,&tmpim); - cmac_256(*(x2),*(W13_256),&tmpre,&tmpim); + cmult_256(*(x1),*(W23_256),tmpre,tmpim); + cmac_256(*(x2),*(W13_256),tmpre,tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); } @@ -993,11 +810,8 @@ static inline void bfly3_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2) __attribute__((always_inline)); static inline void bfly3_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2) -{ - + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2) { int32x4_t tmpre,tmpim; - *(y0) = vqaddq_s16(*(x0),vqaddq_s16(*(x1),*(x2))); cmult(*(x1),*(W13),&tmpre,&tmpim); cmac(*(x2),*(W23),&tmpre,&tmpim); @@ -1007,7 +821,6 @@ static inline void bfly3_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, cmac(*(x2),*(W13),&tmpre,&tmpim); *(y2) = cpack(tmpre,tmpim); *(y2) = vqaddq_s16(*(x0),*(y2)); - } #endif @@ -1019,11 +832,8 @@ static inline void bfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, static inline void bfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3, - __m128i *tw1,__m128i *tw2,__m128i *tw3) -{ - + __m128i *tw1,__m128i *tw2,__m128i *tw3) { __m128i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; - // cmult(*(x0),*(W0),&x0r_2,&x0i_2); cmult(*(x1),*(tw1),&x1r_2,&x1i_2); cmult(*(x2),*(tw2),&x2r_2,&x2i_2); @@ -1056,20 +866,17 @@ static inline void bfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, #ifdef __AVX2__ static inline void bfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3)__attribute__((always_inline)); static inline void bfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3) -{ - + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3) { __m256i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; - // cmult(*(x0),*(W0),&x0r_2,&x0i_2); - cmult_256(*(x1),*(tw1),&x1r_2,&x1i_2); - cmult_256(*(x2),*(tw2),&x2r_2,&x2i_2); - cmult_256(*(x3),*(tw3),&x3r_2,&x3i_2); + cmult_256(*(x1),*(tw1),x1r_2,x1i_2); + cmult_256(*(x2),*(tw2),x2r_2,x2i_2); + cmult_256(*(x3),*(tw3),x3r_2,x3i_2); // dy0r = _mm_add_epi32(x0r_2,_mm_add_epi32(x1r_2,_mm_add_epi32(x2r_2,x3r_2))); // dy0i = _mm_add_epi32(x0i_2,_mm_add_epi32(x1i_2,_mm_add_epi32(x2i_2,x3i_2))); // *(y0) = cpack(dy0r,dy0i); @@ -1103,11 +910,8 @@ static inline void bfly4(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3 static inline void bfly4(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3) -{ - + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3) { int32x4_t x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; - // cmult(*(x0),*(W0),&x0r_2,&x0i_2); cmult(*(x1),*(tw1),&x1r_2,&x1i_2); cmult(*(x2),*(tw2),&x2r_2,&x2i_2); @@ -1147,16 +951,11 @@ static inline void ibfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, static inline void ibfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3, - __m128i *tw1,__m128i *tw2,__m128i *tw3) -{ - + __m128i *tw1,__m128i *tw2,__m128i *tw3) { __m128i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; - - cmultc(*(x1),*(tw1),&x1r_2,&x1i_2); cmultc(*(x2),*(tw2),&x2r_2,&x2i_2); cmultc(*(x3),*(tw3),&x3r_2,&x3i_2); - dy0r = _mm_add_epi32(x1r_2,_mm_add_epi32(x2r_2,x3r_2)); dy0i = _mm_add_epi32(x1i_2,_mm_add_epi32(x2i_2,x3i_2)); *(y0) = _mm_add_epi16(*(x0),cpack(dy0r,dy0i)); @@ -1173,34 +972,44 @@ static inline void ibfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, #ifdef __AVX2__ -static inline void ibfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3)__attribute__((always_inline)); +#define cmultcM(a,b,out_re, out_im) { \ + out_re = _mm256_madd_epi16(a,b);\ + __m256i mmtmpb = _mm256_sign_epi16(b,reflip.v256);\ + mmtmpb = _mm256_shuffle_epi8(mmtmpb,perm_mask.v256);\ + out_im = _mm256_madd_epi16(a,mmtmpb);\ + } static inline void ibfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3) -{ + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3)__attribute__((always_inline)); - __m256i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; - - - cmultc_256(*(x1),*(tw1),&x1r_2,&x1i_2); - cmultc_256(*(x2),*(tw2),&x2r_2,&x2i_2); - cmultc_256(*(x3),*(tw3),&x3r_2,&x3i_2); - - dy0r = _mm256_add_epi32(x1r_2,_mm256_add_epi32(x2r_2,x3r_2)); - dy0i = _mm256_add_epi32(x1i_2,_mm256_add_epi32(x2i_2,x3i_2)); - *(y0) = _mm256_add_epi16(*(x0),cpack_256(dy0r,dy0i)); - dy3r = _mm256_sub_epi32(x1i_2,_mm256_add_epi32(x2r_2,x3i_2)); - dy3i = _mm256_sub_epi32(_mm256_sub_epi32(x3r_2,x2i_2),x1r_2); - *(y3) = _mm256_add_epi16(*(x0),cpack_256(dy3r,dy3i)); - dy2r = _mm256_sub_epi32(_mm256_sub_epi32(x2r_2,x3r_2),x1r_2); - dy2i = _mm256_sub_epi32(_mm256_sub_epi32(x2i_2,x3i_2),x1i_2); - *(y2) = _mm256_add_epi16(*(x0),cpack_256(dy2r,dy2i)); - dy1r = _mm256_sub_epi32(_mm256_sub_epi32(x3i_2,x2r_2),x1i_2); - dy1i = _mm256_sub_epi32(x1r_2,_mm256_add_epi32(x2i_2,x3r_2)); - *(y1) = _mm256_add_epi16(*(x0),cpack_256(dy1r,dy1i)); +static inline void ibfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3) { + register __m256i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2; + cmultcM(*(x1),*(tw1),x1r_2,x1i_2); + cmultcM(*(x2),*(tw2),x2r_2,x2i_2); + cmultcM(*(x3),*(tw3),x3r_2,x3i_2); + { + const __m256i dy0r = _mm256_add_epi32(x1r_2,_mm256_add_epi32(x2r_2,x3r_2)); + const __m256i dy0i = _mm256_add_epi32(x1i_2,_mm256_add_epi32(x2i_2,x3i_2)); + *(y0) = _mm256_add_epi16(*(x0),cpack_256(dy0r,dy0i)); + } + { + const __m256i dy3r = _mm256_sub_epi32(x1i_2,_mm256_add_epi32(x2r_2,x3i_2)); + const __m256i dy3i = _mm256_sub_epi32(_mm256_sub_epi32(x3r_2,x2i_2),x1r_2); + *(y3) = _mm256_add_epi16(*(x0),cpack_256(dy3r,dy3i)); + } + { + const __m256i dy2r = _mm256_sub_epi32(_mm256_sub_epi32(x2r_2,x3r_2),x1r_2); + const __m256i dy2i = _mm256_sub_epi32(_mm256_sub_epi32(x2i_2,x3i_2),x1i_2); + *(y2) = _mm256_add_epi16(*(x0),cpack_256(dy2r,dy2i)); + } + { + const __m256i dy1r = _mm256_sub_epi32(_mm256_sub_epi32(x3i_2,x2r_2),x1i_2); + const __m256i dy1i = _mm256_sub_epi32(x1r_2,_mm256_add_epi32(x2i_2,x3r_2)); + *(y1) = _mm256_add_epi16(*(x0),cpack_256(dy1r,dy1i)); + } } #endif @@ -1212,16 +1021,11 @@ static inline void ibfly4(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x static inline void ibfly4(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3) -{ - + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3) { int32x4_t x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; - - cmultc(*(x1),*(tw1),&x1r_2,&x1i_2); cmultc(*(x2),*(tw2),&x2r_2,&x2i_2); cmultc(*(x3),*(tw3),&x3r_2,&x3i_2); - dy0r = vqaddq_s32(x1r_2,vqaddq_s32(x2r_2,x3r_2)); dy0i = vqaddq_s32(x1i_2,vqaddq_s32(x2i_2,x3i_2)); *(y0) = vqaddq_s16(*(x0),cpack(dy0r,dy0i)); @@ -1244,24 +1048,21 @@ static inline void bfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3)__attribute__((always_inline)); static inline void bfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, - __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3) -{ + __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3) { register __m128i x1_flip,x3_flip,x02t,x13t; register __m128i complex_shuffle = _mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - x02t = _mm_adds_epi16(*(x0),*(x2)); x13t = _mm_adds_epi16(*(x1),*(x3)); *(y0) = _mm_adds_epi16(x02t,x13t); *(y2) = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(*(x1),*(__m128i*)conjugatedft); + x1_flip = _mm_sign_epi16(*(x1),conjugatedft.v128); x1_flip = _mm_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm_sign_epi16(*(x3),*(__m128i*)conjugatedft); + x3_flip = _mm_sign_epi16(*(x3),conjugatedft.v128); x3_flip = _mm_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm_subs_epi16(*(x0),*(x2)); x13t = _mm_subs_epi16(x1_flip,x3_flip); *(y1) = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y3) = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - /* *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(*(x1),_mm_adds_epi16(*(x2),*(x3)))); x1_flip = _mm_sign_epi16(*(x1),*(__m128i*)conjugatedft); @@ -1277,22 +1078,19 @@ static inline void bfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, #ifdef __AVX2__ static inline void bfly4_tw1_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3)__attribute__((always_inline)); static inline void bfly4_tw1_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3) -{ + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3) { register __m256i x1_flip,x3_flip,x02t,x13t; - register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - x02t = _mm256_adds_epi16(*(x0),*(x2)); x13t = _mm256_adds_epi16(*(x1),*(x3)); *(y0) = _mm256_adds_epi16(x02t,x13t); *(y2) = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(*(x1),*(__m256i*)conjugatedft); - x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm256_sign_epi16(*(x3),*(__m256i*)conjugatedft); - x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); + x1_flip = _mm256_sign_epi16(*(x1),conjugatedft.v256); + x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); + x3_flip = _mm256_sign_epi16(*(x3),conjugatedft.v256); + x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); x02t = _mm256_subs_epi16(*(x0),*(x2)); x13t = _mm256_subs_epi16(x1_flip,x3_flip); *(y1) = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f @@ -1306,14 +1104,11 @@ static inline void bfly4_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3)__attribute__((always_inline)); static inline void bfly4_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3) -{ - + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3) { register int16x8_t x1_flip,x3_flip; - *(y0) = vqaddq_s16(*(x0),vqaddq_s16(*(x1),vqaddq_s16(*(x2),*(x3)))); - x1_flip = vrev32q_s16(vmulq_s16(*(x1),*(int16x8_t*)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(*(x3),*(int16x8_t*)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(*(x1),*(int16x8_t *)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(*(x3),*(int16x8_t *)conjugatedft)); *(y1) = vqaddq_s16(*(x0),vqsubq_s16(x1_flip,vqaddq_s16(*(x2),x3_flip))); *(y2) = vqsubq_s16(*(x0),vqsubq_s16(*(x1),vqsubq_s16(*(x2),*(x3)))); *(y3) = vqsubq_s16(*(x0),vqaddq_s16(x1_flip,vqsubq_s16(*(x2),x3_flip))); @@ -1327,18 +1122,14 @@ static inline void ibfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3)__attribute__((always_inline)); static inline void ibfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, - __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3) -{ - + __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3) { register __m128i x1_flip,x3_flip; - *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(*(x1),_mm_adds_epi16(*(x2),*(x3)))); - - x1_flip = _mm_sign_epi16(*(x1),*(__m128i*)conjugatedft); + x1_flip = _mm_sign_epi16(*(x1),conjugatedft.v128); // x1_flip = _mm_shufflelo_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); // x1_flip = _mm_shufflehi_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(*(x3),*(__m128i*)conjugatedft); + x3_flip = _mm_sign_epi16(*(x3),conjugatedft.v128); // x3_flip = _mm_shufflelo_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); // x3_flip = _mm_shufflehi_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); @@ -1350,17 +1141,14 @@ static inline void ibfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, #elif defined(__arm__) static inline void ibfly4_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3)__attribute__((always_inline)); + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3)__attribute__((always_inline)); static inline void ibfly4_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3) -{ - + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3) { register int16x8_t x1_flip,x3_flip; - *(y0) = vqaddq_s16(*(x0),vqaddq_s16(*(x1),vqaddq_s16(*(x2),*(x3)))); - x1_flip = vrev32q_s16(vmulq_s16(*(x1),*(int16x8_t*)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(*(x3),*(int16x8_t*)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(*(x1),*(int16x8_t *)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(*(x3),*(int16x8_t *)conjugatedft)); *(y1) = vqsubq_s16(*(x0),vqaddq_s16(x1_flip,vqsubq_s16(*(x2),x3_flip))); *(y2) = vqsubq_s16(*(x0),vqsubq_s16(*(x1),vqsubq_s16(*(x2),*(x3)))); *(y3) = vqaddq_s16(*(x0),vqsubq_s16(x1_flip,vqaddq_s16(*(x2),x3_flip))); @@ -1377,17 +1165,12 @@ static inline void bfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, static inline void bfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3, __m128i *tw1,__m128i *tw2,__m128i *tw3, - __m128i *tw1b,__m128i *tw2b,__m128i *tw3b) -{ - + __m128i *tw1b,__m128i *tw2b,__m128i *tw3b) { register __m128i x1t,x2t,x3t,x02t,x13t; register __m128i x1_flip,x3_flip; - x1t = packed_cmult2(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2(*(x3),*(tw3),*(tw3b)); - - // bfly4_tw1(x0,&x1t,&x2t,&x3t,y0,y1,y2,y3); x02t = _mm_adds_epi16(*(x0),x2t); x13t = _mm_adds_epi16(x1t,x3t); @@ -1397,12 +1180,11 @@ static inline void bfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, */ *(y0) = _mm_adds_epi16(x02t,x13t); *(y2) = _mm_subs_epi16(x02t,x13t); - - x1_flip = _mm_sign_epi16(x1t,*(__m128i*)conjugatedft); + x1_flip = _mm_sign_epi16(x1t,conjugatedft.v128); // x1_flip = _mm_shufflelo_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); // x1_flip = _mm_shufflehi_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(x3t,*(__m128i*)conjugatedft); + x3_flip = _mm_sign_epi16(x3t,conjugatedft.v128); // x3_flip = _mm_shufflelo_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); // x3_flip = _mm_shufflehi_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); @@ -1414,47 +1196,38 @@ static inline void bfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, */ *(y1) = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y3) = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - } #ifdef __AVX2__ static inline void bfly4_16_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3, - __m256i *tw1b,__m256i *tw2b,__m256i *tw3b)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3, + __m256i *tw1b,__m256i *tw2b,__m256i *tw3b)__attribute__((always_inline)); static inline void bfly4_16_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3, - __m256i *tw1b,__m256i *tw2b,__m256i *tw3b) -{ - + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3, + __m256i *tw1b,__m256i *tw2b,__m256i *tw3b) { register __m256i x1t,x2t,x3t,x02t,x13t; register __m256i x1_flip,x3_flip; - register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - // each input xi is assumed to be to consecutive vectors xi0 xi1 on which to perform the 8 butterflies // [xi00 xi01 xi02 xi03 xi10 xi20 xi30 xi40] // each output yi is the same - x1t = packed_cmult2_256(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2_256(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2_256(*(x3),*(tw3),*(tw3b)); - x02t = _mm256_adds_epi16(*(x0),x2t); x13t = _mm256_adds_epi16(x1t,x3t); *(y0) = _mm256_adds_epi16(x02t,x13t); *(y2) = _mm256_subs_epi16(x02t,x13t); - - x1_flip = _mm256_sign_epi16(x1t,*(__m256i*)conjugatedft); - x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm256_sign_epi16(x3t,*(__m256i*)conjugatedft); - x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); + x1_flip = _mm256_sign_epi16(x1t,conjugatedft.v256); + x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); + x3_flip = _mm256_sign_epi16(x3t,conjugatedft.v256); + x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); x02t = _mm256_subs_epi16(*(x0),x2t); x13t = _mm256_subs_epi16(x1_flip,x3_flip); *(y1) = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y3) = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - } #endif @@ -1469,24 +1242,18 @@ static inline void bfly4_16(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t static inline void bfly4_16(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, - int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b) -{ - + int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b) { register int16x8_t x1t,x2t,x3t,x02t,x13t; register int16x8_t x1_flip,x3_flip; - x1t = packed_cmult2(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2(*(x3),*(tw3),*(tw3b)); - - - x02t = vqaddq_s16(*(x0),x2t); x13t = vqaddq_s16(x1t,x3t); *(y0) = vqaddq_s16(x02t,x13t); *(y2) = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(x1t,*(int16x8_t*)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(x3t,*(int16x8_t*)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(x1t,*(int16x8_t *)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(x3t,*(int16x8_t *)conjugatedft)); x02t = vqsubq_s16(*(x0),x2t); x13t = vqsubq_s16(x1_flip,x3_flip); *(y1) = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f @@ -1503,17 +1270,12 @@ static inline void ibfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, static inline void ibfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3, __m128i *tw1,__m128i *tw2,__m128i *tw3, - __m128i *tw1b,__m128i *tw2b,__m128i *tw3b) -{ - + __m128i *tw1b,__m128i *tw2b,__m128i *tw3b) { register __m128i x1t,x2t,x3t,x02t,x13t; register __m128i x1_flip,x3_flip; - x1t = packed_cmult2(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2(*(x3),*(tw3),*(tw3b)); - - // bfly4_tw1(x0,&x1t,&x2t,&x3t,y0,y1,y2,y3); x02t = _mm_adds_epi16(*(x0),x2t); x13t = _mm_adds_epi16(x1t,x3t); @@ -1523,12 +1285,11 @@ static inline void ibfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, */ *(y0) = _mm_adds_epi16(x02t,x13t); *(y2) = _mm_subs_epi16(x02t,x13t); - - x1_flip = _mm_sign_epi16(x1t,*(__m128i*)conjugatedft); + x1_flip = _mm_sign_epi16(x1t,conjugatedft.v128); // x1_flip = _mm_shufflelo_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); // x1_flip = _mm_shufflehi_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(x3t,*(__m128i*)conjugatedft); + x3_flip = _mm_sign_epi16(x3t,conjugatedft.v128); // x3_flip = _mm_shufflelo_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); // x3_flip = _mm_shufflehi_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); @@ -1540,75 +1301,62 @@ static inline void ibfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, */ *(y3) = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y1) = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - } #ifdef __AVX2__ static inline void ibfly4_16_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3, - __m256i *tw1b,__m256i *tw2b,__m256i *tw3b)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3, + __m256i *tw1b,__m256i *tw2b,__m256i *tw3b)__attribute__((always_inline)); static inline void ibfly4_16_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3, - __m256i *tw1b,__m256i *tw2b,__m256i *tw3b) -{ - + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3, + __m256i *tw1b,__m256i *tw2b,__m256i *tw3b) { register __m256i x1t,x2t,x3t,x02t,x13t; register __m256i x1_flip,x3_flip; - register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - // each input xi is assumed to be to consecutive vectors xi0 xi1 on which to perform the 8 butterflies // [xi00 xi01 xi02 xi03 xi10 xi20 xi30 xi40] // each output yi is the same - x1t = packed_cmult2_256(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2_256(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2_256(*(x3),*(tw3),*(tw3b)); - x02t = _mm256_adds_epi16(*(x0),x2t); x13t = _mm256_adds_epi16(x1t,x3t); *(y0) = _mm256_adds_epi16(x02t,x13t); *(y2) = _mm256_subs_epi16(x02t,x13t); - - x1_flip = _mm256_sign_epi16(x1t,*(__m256i*)conjugatedft); - x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm256_sign_epi16(x3t,*(__m256i*)conjugatedft); - x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); + x1_flip = _mm256_sign_epi16(x1t,conjugatedft.v256); + x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); + x3_flip = _mm256_sign_epi16(x3t,conjugatedft.v256); + x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); x02t = _mm256_subs_epi16(*(x0),x2t); x13t = _mm256_subs_epi16(x1_flip,x3_flip); *(y3) = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y1) = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - } #endif #elif defined(__arm__) static inline void ibfly4_16(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, - int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b)__attribute__((always_inline)); + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, + int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b)__attribute__((always_inline)); static inline void ibfly4_16(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, - int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b) -{ - + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, + int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b) { register int16x8_t x1t,x2t,x3t,x02t,x13t; register int16x8_t x1_flip,x3_flip; - x1t = packed_cmult2(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2(*(x3),*(tw3),*(tw3b)); - x02t = vqaddq_s16(*(x0),x2t); x13t = vqaddq_s16(x1t,x3t); *(y0) = vqaddq_s16(x02t,x13t); *(y2) = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(x1t,*(int16x8_t*)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(x3t,*(int16x8_t*)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(x1t,*(int16x8_t *)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(x3t,*(int16x8_t *)conjugatedft)); x02t = vqsubq_s16(*(x0),x2t); x13t = vqsubq_s16(x1_flip,x3_flip); *(y3) = vqaddq_s16(x02t,x13t); // x0 - x1f - x2 + x3f @@ -1624,18 +1372,12 @@ static inline void bfly5(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3,__m1 static inline void bfly5(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3,__m128i *x4, __m128i *y0, __m128i *y1, __m128i *y2, __m128i *y3,__m128i *y4, - __m128i *tw1,__m128i *tw2,__m128i *tw3,__m128i *tw4) -{ - - - + __m128i *tw1,__m128i *tw2,__m128i *tw3,__m128i *tw4) { __m128i x1_2,x2_2,x3_2,x4_2,tmpre,tmpim; - packed_cmult(*(x1),*(tw1),&x1_2); packed_cmult(*(x2),*(tw2),&x2_2); packed_cmult(*(x3),*(tw3),&x3_2); packed_cmult(*(x4),*(tw4),&x4_2); - *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(x1_2,_mm_adds_epi16(x2_2,_mm_adds_epi16(x3_2,x4_2)))); cmult(x1_2,*(W15),&tmpre,&tmpim); cmac(x2_2,*(W25),&tmpre,&tmpim); @@ -1643,81 +1385,65 @@ static inline void bfly5(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3,__m1 cmac(x4_2,*(W45),&tmpre,&tmpim); *(y1) = cpack(tmpre,tmpim); *(y1) = _mm_adds_epi16(*(x0),*(y1)); - cmult(x1_2,*(W25),&tmpre,&tmpim); cmac(x2_2,*(W45),&tmpre,&tmpim); cmac(x3_2,*(W15),&tmpre,&tmpim); cmac(x4_2,*(W35),&tmpre,&tmpim); *(y2) = cpack(tmpre,tmpim); *(y2) = _mm_adds_epi16(*(x0),*(y2)); - cmult(x1_2,*(W35),&tmpre,&tmpim); cmac(x2_2,*(W15),&tmpre,&tmpim); cmac(x3_2,*(W45),&tmpre,&tmpim); cmac(x4_2,*(W25),&tmpre,&tmpim); *(y3) = cpack(tmpre,tmpim); *(y3) = _mm_adds_epi16(*(x0),*(y3)); - cmult(x1_2,*(W45),&tmpre,&tmpim); cmac(x2_2,*(W35),&tmpre,&tmpim); cmac(x3_2,*(W25),&tmpre,&tmpim); cmac(x4_2,*(W15),&tmpre,&tmpim); *(y4) = cpack(tmpre,tmpim); *(y4) = _mm_adds_epi16(*(x0),*(y4)); - - } #ifdef __AVX2__ static inline void bfly5_256(__m256i *x0, __m256i *x1, __m256i *x2, __m256i *x3,__m256i *x4, - __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4, - __m256i *tw1,__m256i *tw2,__m256i *tw3,__m256i *tw4)__attribute__((always_inline)); + __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4, + __m256i *tw1,__m256i *tw2,__m256i *tw3,__m256i *tw4)__attribute__((always_inline)); static inline void bfly5_256(__m256i *x0, __m256i *x1, __m256i *x2, __m256i *x3,__m256i *x4, - __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4, - __m256i *tw1,__m256i *tw2,__m256i *tw3,__m256i *tw4) -{ - - - + __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4, + __m256i *tw1,__m256i *tw2,__m256i *tw3,__m256i *tw4) { __m256i x1_2,x2_2,x3_2,x4_2,tmpre,tmpim; - packed_cmult_256(*(x1),*(tw1),&x1_2); packed_cmult_256(*(x2),*(tw2),&x2_2); packed_cmult_256(*(x3),*(tw3),&x3_2); packed_cmult_256(*(x4),*(tw4),&x4_2); - *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(x1_2,_mm256_adds_epi16(x2_2,_mm256_adds_epi16(x3_2,x4_2)))); - cmult_256(x1_2,*(W15_256),&tmpre,&tmpim); - cmac_256(x2_2,*(W25_256),&tmpre,&tmpim); - cmac_256(x3_2,*(W35_256),&tmpre,&tmpim); - cmac_256(x4_2,*(W45_256),&tmpre,&tmpim); + cmult_256(x1_2,*(W15_256),tmpre,tmpim); + cmac_256(x2_2,*(W25_256),tmpre,tmpim); + cmac_256(x3_2,*(W35_256),tmpre,tmpim); + cmac_256(x4_2,*(W45_256),tmpre,tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - - cmult_256(x1_2,*(W25_256),&tmpre,&tmpim); - cmac_256(x2_2,*(W45_256),&tmpre,&tmpim); - cmac_256(x3_2,*(W15_256),&tmpre,&tmpim); - cmac_256(x4_2,*(W35_256),&tmpre,&tmpim); + cmult_256(x1_2,*(W25_256),tmpre,tmpim); + cmac_256(x2_2,*(W45_256),tmpre,tmpim); + cmac_256(x3_2,*(W15_256),tmpre,tmpim); + cmac_256(x4_2,*(W35_256),tmpre,tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); - - cmult_256(x1_2,*(W35_256),&tmpre,&tmpim); - cmac_256(x2_2,*(W15_256),&tmpre,&tmpim); - cmac_256(x3_2,*(W45_256),&tmpre,&tmpim); - cmac_256(x4_2,*(W25_256),&tmpre,&tmpim); + cmult_256(x1_2,*(W35_256),tmpre,tmpim); + cmac_256(x2_2,*(W15_256),tmpre,tmpim); + cmac_256(x3_2,*(W45_256),tmpre,tmpim); + cmac_256(x4_2,*(W25_256),tmpre,tmpim); *(y3) = cpack_256(tmpre,tmpim); *(y3) = _mm256_adds_epi16(*(x0),*(y3)); - - cmult_256(x1_2,*(W45_256),&tmpre,&tmpim); - cmac_256(x2_2,*(W35_256),&tmpre,&tmpim); - cmac_256(x3_2,*(W25_256),&tmpre,&tmpim); - cmac_256(x4_2,*(W15_256),&tmpre,&tmpim); + cmult_256(x1_2,*(W45_256),tmpre,tmpim); + cmac_256(x2_2,*(W35_256),tmpre,tmpim); + cmac_256(x3_2,*(W25_256),tmpre,tmpim); + cmac_256(x4_2,*(W15_256),tmpre,tmpim); *(y4) = cpack_256(tmpre,tmpim); *(y4) = _mm256_adds_epi16(*(x0),*(y4)); - - } #endif @@ -1728,19 +1454,13 @@ static inline void bfly5(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x8_t static inline void bfly5(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x8_t *x3,int16x8_t *x4, int16x8_t *y0, int16x8_t *y1, int16x8_t *y2, int16x8_t *y3,int16x8_t *y4, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3,int16x8_t *tw4) -{ - - - + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3,int16x8_t *tw4) { int16x8_t x1_2,x2_2,x3_2,x4_2; int32x4_t tmpre,tmpim; - packed_cmult(*(x1),*(tw1),&x1_2); packed_cmult(*(x2),*(tw2),&x2_2); packed_cmult(*(x3),*(tw3),&x3_2); packed_cmult(*(x4),*(tw4),&x4_2); - *(y0) = vqaddq_s16(*(x0),vqaddq_s16(x1_2,vqaddq_s16(x2_2,vqaddq_s16(x3_2,x4_2)))); cmult(x1_2,*(W15),&tmpre,&tmpim); cmac(x2_2,*(W25),&tmpre,&tmpim); @@ -1748,29 +1468,24 @@ static inline void bfly5(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x8_t cmac(x4_2,*(W45),&tmpre,&tmpim); *(y1) = cpack(tmpre,tmpim); *(y1) = vqaddq_s16(*(x0),*(y1)); - cmult(x1_2,*(W25),&tmpre,&tmpim); cmac(x2_2,*(W45),&tmpre,&tmpim); cmac(x3_2,*(W15),&tmpre,&tmpim); cmac(x4_2,*(W35),&tmpre,&tmpim); *(y2) = cpack(tmpre,tmpim); *(y2) = vqaddq_s16(*(x0),*(y2)); - cmult(x1_2,*(W35),&tmpre,&tmpim); cmac(x2_2,*(W15),&tmpre,&tmpim); cmac(x3_2,*(W45),&tmpre,&tmpim); cmac(x4_2,*(W25),&tmpre,&tmpim); *(y3) = cpack(tmpre,tmpim); *(y3) = vqaddq_s16(*(x0),*(y3)); - cmult(x1_2,*(W45),&tmpre,&tmpim); cmac(x2_2,*(W35),&tmpre,&tmpim); cmac(x3_2,*(W25),&tmpre,&tmpim); cmac(x4_2,*(W15),&tmpre,&tmpim); *(y4) = cpack(tmpre,tmpim); *(y4) = vqaddq_s16(*(x0),*(y4)); - - } @@ -1781,11 +1496,8 @@ static inline void bfly5_tw1(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3, __m128i *y0, __m128i *y1, __m128i *y2, __m128i *y3,__m128i *y4) __attribute__((always_inline)); static inline void bfly5_tw1(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3,__m128i *x4, - __m128i *y0, __m128i *y1, __m128i *y2, __m128i *y3,__m128i *y4) -{ - + __m128i *y0, __m128i *y1, __m128i *y2, __m128i *y3,__m128i *y4) { __m128i tmpre,tmpim; - *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(*(x1),_mm_adds_epi16(*(x2),_mm_adds_epi16(*(x3),*(x4))))); cmult(*(x1),*(W15),&tmpre,&tmpim); cmac(*(x2),*(W25),&tmpre,&tmpim); @@ -1815,37 +1527,34 @@ static inline void bfly5_tw1(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3, #ifdef __AVX2__ static inline void bfly5_tw1_256(__m256i *x0, __m256i *x1, __m256i *x2, __m256i *x3,__m256i *x4, - __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4) __attribute__((always_inline)); + __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4) __attribute__((always_inline)); static inline void bfly5_tw1_256(__m256i *x0, __m256i *x1, __m256i *x2, __m256i *x3,__m256i *x4, - __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4) -{ - + __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4) { __m256i tmpre,tmpim; - *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(*(x1),_mm256_adds_epi16(*(x2),_mm256_adds_epi16(*(x3),*(x4))))); - cmult_256(*(x1),*(W15_256),&tmpre,&tmpim); - cmac_256(*(x2),*(W25_256),&tmpre,&tmpim); - cmac_256(*(x3),*(W35_256),&tmpre,&tmpim); - cmac_256(*(x4),*(W45_256),&tmpre,&tmpim); + cmult_256(*(x1),*(W15_256),tmpre,tmpim); + cmac_256(*(x2),*(W25_256),tmpre,tmpim); + cmac_256(*(x3),*(W35_256),tmpre,tmpim); + cmac_256(*(x4),*(W45_256),tmpre,tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmult_256(*(x1),*(W25_256),&tmpre,&tmpim); - cmac_256(*(x2),*(W45_256),&tmpre,&tmpim); - cmac_256(*(x3),*(W15_256),&tmpre,&tmpim); - cmac_256(*(x4),*(W35_256),&tmpre,&tmpim); + cmult_256(*(x1),*(W25_256),tmpre,tmpim); + cmac_256(*(x2),*(W45_256),tmpre,tmpim); + cmac_256(*(x3),*(W15_256),tmpre,tmpim); + cmac_256(*(x4),*(W35_256),tmpre,tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); - cmult_256(*(x1),*(W35_256),&tmpre,&tmpim); - cmac_256(*(x2),*(W15_256),&tmpre,&tmpim); - cmac_256(*(x3),*(W45_256),&tmpre,&tmpim); - cmac_256(*(x4),*(W25_256),&tmpre,&tmpim); + cmult_256(*(x1),*(W35_256),tmpre,tmpim); + cmac_256(*(x2),*(W15_256),tmpre,tmpim); + cmac_256(*(x3),*(W45_256),tmpre,tmpim); + cmac_256(*(x4),*(W25_256),tmpre,tmpim); *(y3) = cpack_256(tmpre,tmpim); *(y3) = _mm256_adds_epi16(*(x0),*(y3)); - cmult_256(*(x1),*(W45_256),&tmpre,&tmpim); - cmac_256(*(x2),*(W35_256),&tmpre,&tmpim); - cmac_256(*(x3),*(W25_256),&tmpre,&tmpim); - cmac_256(*(x4),*(W15_256),&tmpre,&tmpim); + cmult_256(*(x1),*(W45_256),tmpre,tmpim); + cmac_256(*(x2),*(W35_256),tmpre,tmpim); + cmac_256(*(x3),*(W25_256),tmpre,tmpim); + cmac_256(*(x4),*(W15_256),tmpre,tmpim); *(y4) = cpack_256(tmpre,tmpim); *(y4) = _mm256_adds_epi16(*(x0),*(y4)); } @@ -1855,11 +1564,8 @@ static inline void bfly5_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x int16x8_t *y0, int16x8_t *y1, int16x8_t *y2, int16x8_t *y3,int16x8_t *y4) __attribute__((always_inline)); static inline void bfly5_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x8_t *x3,int16x8_t *x4, - int16x8_t *y0, int16x8_t *y1, int16x8_t *y2, int16x8_t *y3,int16x8_t *y4) -{ - + int16x8_t *y0, int16x8_t *y1, int16x8_t *y2, int16x8_t *y3,int16x8_t *y4) { int32x4_t tmpre,tmpim; - *(y0) = vqaddq_s16(*(x0),vqaddq_s16(*(x1),vqaddq_s16(*(x2),vqaddq_s16(*(x3),*(x4))))); cmult(*(x1),*(W15),&tmpre,&tmpim); cmac(*(x2),*(W25),&tmpre,&tmpim); @@ -1893,10 +1599,8 @@ static inline void bfly5_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x #if defined(__x86_64__) || defined(__i386__) static inline void transpose16(__m128i *x,__m128i *y) __attribute__((always_inline)); -static inline void transpose16(__m128i *x,__m128i *y) -{ +static inline void transpose16(__m128i *x,__m128i *y) { register __m128i ytmp0,ytmp1,ytmp2,ytmp3; - ytmp0 = _mm_unpacklo_epi32(x[0],x[1]); ytmp1 = _mm_unpackhi_epi32(x[0],x[1]); ytmp2 = _mm_unpacklo_epi32(x[2],x[3]); @@ -1909,13 +1613,10 @@ static inline void transpose16(__m128i *x,__m128i *y) #elif defined(__arm__) static inline void transpose16(int16x8_t *x,int16x8_t *y) __attribute__((always_inline)); -static inline void transpose16(int16x8_t *x,int16x8_t *y) -{ +static inline void transpose16(int16x8_t *x,int16x8_t *y) { register uint32x4x2_t ytmp0,ytmp1; - ytmp0 = vtrnq_u32((uint32x4_t)(x[0]),(uint32x4_t)(x[1])); ytmp1 = vtrnq_u32((uint32x4_t)(x[2]),(uint32x4_t)(x[3])); - y[0] = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); y[1] = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); y[2] = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); @@ -1927,16 +1628,14 @@ static inline void transpose16(int16x8_t *x,int16x8_t *y) #if defined(__x86_64__) || defined(__i386__) static inline void transpose16_ooff(__m128i *x,__m128i *y,int off) __attribute__((always_inline)); -static inline void transpose16_ooff(__m128i *x,__m128i *y,int off) -{ +static inline void transpose16_ooff(__m128i *x,__m128i *y,int off) { register __m128i ytmp0,ytmp1,ytmp2,ytmp3; __m128i *y2=y; - ytmp0 = _mm_unpacklo_epi32(x[0],x[1]); // x00 x10 x01 x11 ytmp1 = _mm_unpackhi_epi32(x[0],x[1]); // x02 x12 x03 x13 ytmp2 = _mm_unpacklo_epi32(x[2],x[3]); // x20 x30 x21 x31 ytmp3 = _mm_unpackhi_epi32(x[2],x[3]); // x22 x32 x23 x33 - *y2 = _mm_unpacklo_epi64(ytmp0,ytmp2); // x00 x10 x20 x30 + *y2 = _mm_unpacklo_epi64(ytmp0,ytmp2); // x00 x10 x20 x30 y2+=off; *y2 = _mm_unpackhi_epi64(ytmp0,ytmp2); // x01 x11 x21 x31 y2+=off; @@ -1948,12 +1647,10 @@ static inline void transpose16_ooff(__m128i *x,__m128i *y,int off) #ifdef __AVX2__ static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) __attribute__((always_inline)); -static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) -{ +static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) { register __m256i ytmp0,ytmp1,ytmp2,ytmp3,ytmp4,ytmp5,ytmp6,ytmp7; __m256i *y2=y; __m256i const perm_mask = _mm256_set_epi32(7, 3, 5, 1, 6, 2, 4, 0); - ytmp0 = _mm256_permutevar8x32_epi32(x[0],perm_mask); // x00 x10 x01 x11 x02 x12 x03 x13 ytmp1 = _mm256_permutevar8x32_epi32(x[1],perm_mask); // x20 x30 x21 x31 x22 x32 x23 x33 ytmp2 = _mm256_permutevar8x32_epi32(x[2],perm_mask); // x40 x50 x41 x51 x42 x52 x43 x53 @@ -1962,13 +1659,12 @@ static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) ytmp5 = _mm256_unpackhi_epi64(ytmp0,ytmp1); // x02 x12 x22 x32 x03 x13 x23 x33 ytmp6 = _mm256_unpacklo_epi64(ytmp2,ytmp3); // x40 x50 x60 x70 x41 x51 x61 x71 ytmp7 = _mm256_unpackhi_epi64(ytmp2,ytmp3); // x42 x52 x62 x72 x43 x53 x63 x73 - *y2 = _mm256_insertf128_si256(ytmp4,_mm256_extracti128_si256(ytmp6,0),1); //x00 x10 x20 x30 x40 x50 x60 x70 - y2+=off; + y2+=off; *y2 = _mm256_insertf128_si256(ytmp6,_mm256_extracti128_si256(ytmp4,1),0); //x01 x11 x21 x31 x41 x51 x61 x71 - y2+=off; + y2+=off; *y2 = _mm256_insertf128_si256(ytmp5,_mm256_extracti128_si256(ytmp7,0),1); //x00 x10 x20 x30 x40 x50 x60 x70 - y2+=off; + y2+=off; *y2 = _mm256_insertf128_si256(ytmp7,_mm256_extracti128_si256(ytmp5,1),0); //x01 x11 x21 x31 x41 x51 x61 x71 } #endif @@ -1976,20 +1672,18 @@ static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) #elif defined(__arm__) static inline void transpose16_ooff(int16x8_t *x,int16x8_t *y,int off) __attribute__((always_inline)); -static inline void transpose16_ooff(int16x8_t *x,int16x8_t *y,int off) -{ +static inline void transpose16_ooff(int16x8_t *x,int16x8_t *y,int off) { int16x8_t *y2=y; register uint32x4x2_t ytmp0,ytmp1; - ytmp0 = vtrnq_u32((uint32x4_t)(x[0]),(uint32x4_t)(x[1])); ytmp1 = vtrnq_u32((uint32x4_t)(x[2]),(uint32x4_t)(x[3])); - - *y2 = (int16x8_t)vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); y2+=off; - *y2 = (int16x8_t)vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); y2+=off; - *y2 = (int16x8_t)vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); y2+=off; + *y2 = (int16x8_t)vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); + y2+=off; + *y2 = (int16x8_t)vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); + y2+=off; + *y2 = (int16x8_t)vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); + y2+=off; *y2 = (int16x8_t)vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[1]),vget_high_s16((int16x8_t)ytmp1.val[1])); - - } #endif @@ -1997,11 +1691,9 @@ static inline void transpose16_ooff(int16x8_t *x,int16x8_t *y,int off) #if defined(__x86_64__) || defined(__i386__) static inline void transpose4_ooff(__m64 *x,__m64 *y,int off)__attribute__((always_inline)); -static inline void transpose4_ooff(__m64 *x,__m64 *y,int off) -{ +static inline void transpose4_ooff(__m64 *x,__m64 *y,int off) { y[0] = _mm_unpacklo_pi32(x[0],x[1]); y[off] = _mm_unpackhi_pi32(x[0],x[1]); - // x[0] = [x0 x1] // x[1] = [x2 x3] // y[0] = [x0 x2] @@ -2009,11 +1701,9 @@ static inline void transpose4_ooff(__m64 *x,__m64 *y,int off) } #ifdef __AVX2__ static inline void transpose4_ooff_simd256(__m256i *x,__m256i *y,int off)__attribute__((always_inline)); -static inline void transpose4_ooff_simd256(__m256i *x,__m256i *y,int off) -{ +static inline void transpose4_ooff_simd256(__m256i *x,__m256i *y,int off) { __m256i const perm_mask = _mm256_set_epi32(7, 5, 3, 1, 6, 4, 2, 0); __m256i perm_tmp0,perm_tmp1; - // x[0] = [x0 x1 x2 x3 x4 x5 x6 x7] // x[1] = [x8 x9 x10 x11 x12 x13 x14] // y[0] = [x0 x2 x4 x6 x8 x10 x12 x14] @@ -2027,10 +1717,8 @@ static inline void transpose4_ooff_simd256(__m256i *x,__m256i *y,int off) #elif (__arm__) static inline void transpose4_ooff(int16x4_t *x,int16x4_t *y,int off)__attribute__((always_inline)); -static inline void transpose4_ooff(int16x4_t *x,int16x4_t *y,int off) -{ +static inline void transpose4_ooff(int16x4_t *x,int16x4_t *y,int off) { uint32x2x2_t ytmp = vtrn_u32((uint32x2_t)x[0],(uint32x2_t)x[1]); - y[0] = (int16x4_t)ytmp.val[0]; y[off] = (int16x4_t)ytmp.val[1]; } @@ -2039,47 +1727,47 @@ static inline void transpose4_ooff(int16x4_t *x,int16x4_t *y,int off) // 16-point optimized DFT kernel -const static int16_t tw16[24] __attribute__((aligned(32))) = { 32767,0,30272,-12540,23169 ,-23170,12539 ,-30273, - 32767,0,23169,-23170,0 ,-32767,-23170,-23170, - 32767,0,12539,-30273,-23170,-23170,-30273,12539 - }; +const static int16_t tw16[24] __attribute__((aligned(32))) = { 32767,0,30272,-12540,23169,-23170,12539,-30273, + 32767,0,23169,-23170,0,-32767,-23170,-23170, + 32767,0,12539,-30273,-23170,-23170,-30273,12539 + }; -const static int16_t tw16a[24] __attribute__((aligned(32))) = {32767,0,30272,12540,23169 ,23170,12539 ,30273, - 32767,0,23169,23170,0 ,32767,-23170,23170, - 32767,0,12539,30273,-23170,23170,-30273,-12539 - }; +const static int16_t tw16a[24] __attribute__((aligned(32))) = {32767,0,30272,12540,23169,23170,12539,30273, + 32767,0,23169,23170,0,32767,-23170,23170, + 32767,0,12539,30273,-23170,23170,-30273,-12539 + }; -const static int16_t tw16b[24] __attribute__((aligned(32))) = { 0,32767,-12540,30272,-23170,23169 ,-30273,12539, - 0,32767,-23170,23169,-32767,0 ,-23170,-23170, - 0,32767,-30273,12539,-23170,-23170,12539 ,-30273 - }; +const static int16_t tw16b[24] __attribute__((aligned(32))) = { 0,32767,-12540,30272,-23170,23169,-30273,12539, + 0,32767,-23170,23169,-32767,0,-23170,-23170, + 0,32767,-30273,12539,-23170,-23170,12539,-30273 + }; -const static int16_t tw16c[24] __attribute__((aligned(32))) = { 0,32767,12540,30272,23170,23169 ,30273 ,12539, - 0,32767,23170,23169,32767,0 ,23170 ,-23170, - 0,32767,30273,12539,23170,-23170,-12539,-30273 - }; +const static int16_t tw16c[24] __attribute__((aligned(32))) = { 0,32767,12540,30272,23170,23169,30273,12539, + 0,32767,23170,23169,32767,0,23170,-23170, + 0,32767,30273,12539,23170,-23170,-12539,-30273 + }; #ifdef __AVX2__ -const static int16_t tw16rep[48] __attribute__((aligned(32))) = { 32767,0,30272,-12540,23169 ,-23170,12539 ,-30273,32767,0,30272,-12540,23169 ,-23170,12539 ,-30273, - 32767,0,23169,-23170,0 ,-32767,-23170,-23170,32767,0,23169,-23170,0 ,-32767,-23170,-23170, - 32767,0,12539,-30273,-23170,-23170,-30273,12539,32767,0,12539,-30273,-23170,-23170,-30273,12539 - }; +const static int16_t tw16rep[48] __attribute__((aligned(32))) = { 32767,0,30272,-12540,23169,-23170,12539,-30273,32767,0,30272,-12540,23169,-23170,12539,-30273, + 32767,0,23169,-23170,0,-32767,-23170,-23170,32767,0,23169,-23170,0,-32767,-23170,-23170, + 32767,0,12539,-30273,-23170,-23170,-30273,12539,32767,0,12539,-30273,-23170,-23170,-30273,12539 + }; -const static int16_t tw16arep[48] __attribute__((aligned(32))) = {32767,0,30272,12540,23169 ,23170,12539 ,30273,32767,0,30272,12540,23169 ,23170,12539 ,30273, - 32767,0,23169,23170,0 ,32767,-23170,23170,32767,0,23169,23170,0 ,32767,-23170,23170, - 32767,0,12539,30273,-23170,23170,-30273,-12539,32767,0,12539,30273,-23170,23170,-30273,-12539 - }; +const static int16_t tw16arep[48] __attribute__((aligned(32))) = {32767,0,30272,12540,23169,23170,12539,30273,32767,0,30272,12540,23169,23170,12539,30273, + 32767,0,23169,23170,0,32767,-23170,23170,32767,0,23169,23170,0,32767,-23170,23170, + 32767,0,12539,30273,-23170,23170,-30273,-12539,32767,0,12539,30273,-23170,23170,-30273,-12539 + }; -const static int16_t tw16brep[48] __attribute__((aligned(32))) = { 0,32767,-12540,30272,-23170,23169 ,-30273,12539,0,32767,-12540,30272,-23170,23169 ,-30273,12539, - 0,32767,-23170,23169,-32767,0 ,-23170,-23170,0,32767,-23170,23169,-32767,0 ,-23170,-23170, - 0,32767,-30273,12539,-23170,-23170,12539 ,-30273,0,32767,-30273,12539,-23170,-23170,12539 ,-30273 - }; +const static int16_t tw16brep[48] __attribute__((aligned(32))) = { 0,32767,-12540,30272,-23170,23169,-30273,12539,0,32767,-12540,30272,-23170,23169,-30273,12539, + 0,32767,-23170,23169,-32767,0,-23170,-23170,0,32767,-23170,23169,-32767,0,-23170,-23170, + 0,32767,-30273,12539,-23170,-23170,12539,-30273,0,32767,-30273,12539,-23170,-23170,12539,-30273 + }; -const static int16_t tw16crep[48] __attribute__((aligned(32))) = { 0,32767,12540,30272,23170,23169 ,30273 ,12539,0,32767,12540,30272,23170,23169 ,30273 ,12539, - 0,32767,23170,23169,32767,0 ,23170 ,-23170,0,32767,23170,23169,32767,0 ,23170 ,-23170, - 0,32767,30273,12539,23170,-23170,-12539,-30273,0,32767,30273,12539,23170,-23170,-12539,-30273 - }; +const static int16_t tw16crep[48] __attribute__((aligned(32))) = { 0,32767,12540,30272,23170,23169,30273,12539,0,32767,12540,30272,23170,23169,30273,12539, + 0,32767,23170,23169,32767,0,23170,-23170,0,32767,23170,23169,32767,0,23170,-23170, + 0,32767,30273,12539,23170,-23170,-12539,-30273,0,32767,30273,12539,23170,-23170,-12539,-30273 + }; #endif /* __AVX2__ */ @@ -2087,15 +1775,9 @@ const static int16_t tw16crep[48] __attribute__((aligned(32))) = { 0,32767,12540 static inline void dft16(int16_t *x,int16_t *y) __attribute__((always_inline)); -static inline void dft16(int16_t *x,int16_t *y) -{ - +static inline void dft16(int16_t *x,int16_t *y) { #if defined(__x86_64__) || defined(__i386__) - __m128i *tw16a_128=(__m128i *)tw16a,*tw16b_128=(__m128i *)tw16b,*x128=(__m128i *)x,*y128=(__m128i *)y; - - - /* This is the original version before unrolling bfly4_tw1(x128,x128+1,x128+2,x128+3, @@ -2107,26 +1789,22 @@ static inline void dft16(int16_t *x,int16_t *y) y128,y128+1,y128+2,y128+3, tw16_128,tw16_128+1,tw16_128+2); */ - register __m128i x1_flip,x3_flip,x02t,x13t; register __m128i ytmp0,ytmp1,ytmp2,ytmp3,xtmp0,xtmp1,xtmp2,xtmp3; register __m128i complex_shuffle = _mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - // First stage : 4 Radix-4 butterflies without input twiddles - x02t = _mm_adds_epi16(x128[0],x128[2]); x13t = _mm_adds_epi16(x128[1],x128[3]); xtmp0 = _mm_adds_epi16(x02t,x13t); xtmp2 = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(x128[1],*(__m128i*)conjugatedft); + x1_flip = _mm_sign_epi16(x128[1],conjugatedft.v128); x1_flip = _mm_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm_sign_epi16(x128[3],*(__m128i*)conjugatedft); + x3_flip = _mm_sign_epi16(x128[3],conjugatedft.v128); x3_flip = _mm_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm_subs_epi16(x128[0],x128[2]); x13t = _mm_subs_epi16(x1_flip,x3_flip); xtmp1 = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp3 = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - ytmp0 = _mm_unpacklo_epi32(xtmp0,xtmp1); ytmp1 = _mm_unpackhi_epi32(xtmp0,xtmp1); ytmp2 = _mm_unpacklo_epi32(xtmp2,xtmp3); @@ -2135,29 +1813,24 @@ static inline void dft16(int16_t *x,int16_t *y) xtmp1 = _mm_unpackhi_epi64(ytmp0,ytmp2); xtmp2 = _mm_unpacklo_epi64(ytmp1,ytmp3); xtmp3 = _mm_unpackhi_epi64(ytmp1,ytmp3); - // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2(xtmp1,tw16a_128[0],tw16b_128[0]); xtmp2 = packed_cmult2(xtmp2,tw16a_128[1],tw16b_128[1]); xtmp3 = packed_cmult2(xtmp3,tw16a_128[2],tw16b_128[2]); - x02t = _mm_adds_epi16(xtmp0,xtmp2); x13t = _mm_adds_epi16(xtmp1,xtmp3); y128[0] = _mm_adds_epi16(x02t,x13t); y128[2] = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(xtmp1,*(__m128i*)conjugatedft); + x1_flip = _mm_sign_epi16(xtmp1,conjugatedft.v128); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(xtmp3,*(__m128i*)conjugatedft); + x3_flip = _mm_sign_epi16(xtmp3,conjugatedft.v128); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); x02t = _mm_subs_epi16(xtmp0,xtmp2); x13t = _mm_subs_epi16(x1_flip,x3_flip); y128[1] = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f y128[3] = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - #elif defined(__arm__) - int16x8_t *tw16a_128=(int16x8_t *)tw16a,*tw16b_128=(int16x8_t *)tw16b,*x128=(int16x8_t *)x,*y128=(int16x8_t *)y; - /* This is the original version before unrolling bfly4_tw1(x128,x128+1,x128+2,x128+3, @@ -2169,95 +1842,76 @@ static inline void dft16(int16_t *x,int16_t *y) y128,y128+1,y128+2,y128+3, tw16_128,tw16_128+1,tw16_128+2); */ - register int16x8_t x1_flip,x3_flip,x02t,x13t; register int16x8_t xtmp0,xtmp1,xtmp2,xtmp3; register uint32x4x2_t ytmp0,ytmp1; register int16x8_t ytmp0b,ytmp1b,ytmp2b,ytmp3b; - // First stage : 4 Radix-4 butterflies without input twiddles - x02t = vqaddq_s16(x128[0],x128[2]); x13t = vqaddq_s16(x128[1],x128[3]); xtmp0 = vqaddq_s16(x02t,x13t); xtmp2 = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(x128[1],*(int16x8_t*)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(x128[3],*(int16x8_t*)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(x128[1],*(int16x8_t *)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(x128[3],*(int16x8_t *)conjugatedft)); x02t = vqsubq_s16(x128[0],x128[2]); x13t = vqsubq_s16(x1_flip,x3_flip); xtmp1 = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp3 = vqsubq_s16(x02t,x13t); // x0 - x1f - x2 + x3f - ytmp0 = vtrnq_u32((uint32x4_t)(xtmp0),(uint32x4_t)(xtmp1)); -// y0[0] = [x00 x10 x02 x12], y0[1] = [x01 x11 x03 x13] + // y0[0] = [x00 x10 x02 x12], y0[1] = [x01 x11 x03 x13] ytmp1 = vtrnq_u32((uint32x4_t)(xtmp2),(uint32x4_t)(xtmp3)); -// y1[0] = [x20 x30 x22 x32], y1[1] = [x21 x31 x23 x33] - - + // y1[0] = [x20 x30 x22 x32], y1[1] = [x21 x31 x23 x33] ytmp0b = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); -// y0 = [x00 x10 x20 x30] + // y0 = [x00 x10 x20 x30] ytmp1b = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); -// t1 = [x01 x11 x21 x31] + // t1 = [x01 x11 x21 x31] ytmp2b = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); -// t2 = [x02 x12 x22 x32] + // t2 = [x02 x12 x22 x32] ytmp3b = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[1]),vget_high_s16((int16x8_t)ytmp1.val[1])); -// t3 = [x03 x13 x23 x33] - - + // t3 = [x03 x13 x23 x33] // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2(ytmp1b,tw16a_128[0],tw16b_128[0]); xtmp2 = packed_cmult2(ytmp2b,tw16a_128[1],tw16b_128[1]); xtmp3 = packed_cmult2(ytmp3b,tw16a_128[2],tw16b_128[2]); - x02t = vqaddq_s16(ytmp0b,xtmp2); x13t = vqaddq_s16(xtmp1,xtmp3); y128[0] = vqaddq_s16(x02t,x13t); y128[2] = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(xtmp1,*(int16x8_t*)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(xtmp3,*(int16x8_t*)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(xtmp1,*(int16x8_t *)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(xtmp3,*(int16x8_t *)conjugatedft)); x02t = vqsubq_s16(ytmp0b,xtmp2); x13t = vqsubq_s16(x1_flip,x3_flip); y128[1] = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f y128[3] = vqsubq_s16(x02t,x13t); // x0 - x1f - x2 + x3f - - #endif } #if defined(__x86_64__) || defined(__i386__) #ifdef __AVX2__ -// Does two 16-point DFTS (x[0 .. 15] is 128 LSBs of input vector, x[16..31] is in 128 MSBs) +// Does two 16-point DFTS (x[0 .. 15] is 128 LSBs of input vector, x[16..31] is in 128 MSBs) static inline void dft16_simd256(int16_t *x,int16_t *y) __attribute__((always_inline)); -static inline void dft16_simd256(int16_t *x,int16_t *y) -{ - +static inline void dft16_simd256(int16_t *x,int16_t *y) { __m256i *tw16a_256=(__m256i *)tw16arep,*tw16b_256=(__m256i *)tw16brep,*x256=(__m256i *)x,*y256=(__m256i *)y; - __m256i x1_flip,x3_flip,x02t,x13t; __m256i ytmp0,ytmp1,ytmp2,ytmp3,xtmp0,xtmp1,xtmp2,xtmp3; - register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - // First stage : 4 Radix-4 butterflies without input twiddles - x02t = _mm256_adds_epi16(x256[0],x256[2]); x13t = _mm256_adds_epi16(x256[1],x256[3]); xtmp0 = _mm256_adds_epi16(x02t,x13t); xtmp2 = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(x256[1],*(__m256i*)conjugatedft); - x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm256_sign_epi16(x256[3],*(__m256i*)conjugatedft); - x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); + x1_flip = _mm256_sign_epi16(x256[1],conjugatedft.v256); + x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); + x3_flip = _mm256_sign_epi16(x256[3],conjugatedft.v256); + x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); x02t = _mm256_subs_epi16(x256[0],x256[2]); x13t = _mm256_subs_epi16(x1_flip,x3_flip); xtmp1 = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp3 = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - /* print_shorts256("xtmp0",(int16_t*)&xtmp0); print_shorts256("xtmp1",(int16_t*)&xtmp1); print_shorts256("xtmp2",(int16_t*)&xtmp2); print_shorts256("xtmp3",(int16_t*)&xtmp3);*/ - - ytmp0 = _mm256_unpacklo_epi32(xtmp0,xtmp1); + ytmp0 = _mm256_unpacklo_epi32(xtmp0,xtmp1); ytmp1 = _mm256_unpackhi_epi32(xtmp0,xtmp1); ytmp2 = _mm256_unpacklo_epi32(xtmp2,xtmp3); ytmp3 = _mm256_unpackhi_epi32(xtmp2,xtmp3); @@ -2265,57 +1919,47 @@ static inline void dft16_simd256(int16_t *x,int16_t *y) xtmp1 = _mm256_unpackhi_epi64(ytmp0,ytmp2); xtmp2 = _mm256_unpacklo_epi64(ytmp1,ytmp3); xtmp3 = _mm256_unpackhi_epi64(ytmp1,ytmp3); - // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2_256(xtmp1,tw16a_256[0],tw16b_256[0]); xtmp2 = packed_cmult2_256(xtmp2,tw16a_256[1],tw16b_256[1]); xtmp3 = packed_cmult2_256(xtmp3,tw16a_256[2],tw16b_256[2]); - /* print_shorts256("xtmp0",(int16_t*)&xtmp0); print_shorts256("xtmp1",(int16_t*)&xtmp1); print_shorts256("xtmp2",(int16_t*)&xtmp2); print_shorts256("xtmp3",(int16_t*)&xtmp3);*/ - x02t = _mm256_adds_epi16(xtmp0,xtmp2); x13t = _mm256_adds_epi16(xtmp1,xtmp3); ytmp0 = _mm256_adds_epi16(x02t,x13t); ytmp2 = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(xtmp1,*(__m256i*)conjugatedft); - x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm256_sign_epi16(xtmp3,*(__m256i*)conjugatedft); - x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); + x1_flip = _mm256_sign_epi16(xtmp1,conjugatedft.v256); + x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); + x3_flip = _mm256_sign_epi16(xtmp3,conjugatedft.v256); + x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); x02t = _mm256_subs_epi16(xtmp0,xtmp2); x13t = _mm256_subs_epi16(x1_flip,x3_flip); ytmp1 = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f ytmp3 = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - - // [y0 y1 y2 y3 y16 y17 y18 y19] // [y4 y5 y6 y7 y20 y21 y22 y23] // [y8 y9 y10 y11 y24 y25 y26 y27] // [y12 y13 y14 y15 y28 y29 y30 y31] - y256[0] = _mm256_insertf128_si256(ytmp0,_mm256_extracti128_si256(ytmp1,0),1); y256[1] = _mm256_insertf128_si256(ytmp2,_mm256_extracti128_si256(ytmp3,0),1); y256[2] = _mm256_insertf128_si256(ytmp1,_mm256_extracti128_si256(ytmp0,1),0); y256[3] = _mm256_insertf128_si256(ytmp3,_mm256_extracti128_si256(ytmp2,1),0); - // [y0 y1 y2 y3 y4 y5 y6 y7] // [y8 y9 y10 y11 y12 y13 y14 y15] // [y16 y17 y18 y19 y20 y21 y22 y23] // [y24 y25 y26 y27 y28 y29 y30 y31] } -#endif +#endif #endif static inline void idft16(int16_t *x,int16_t *y) __attribute__((always_inline)); -static inline void idft16(int16_t *x,int16_t *y) -{ - +static inline void idft16(int16_t *x,int16_t *y) { #if defined(__x86_64__) || defined(__i386__) __m128i *tw16a_128=(__m128i *)tw16,*tw16b_128=(__m128i *)tw16c,*x128=(__m128i *)x,*y128=(__m128i *)y; - /* bfly4_tw1(x128,x128+1,x128+2,x128+3, y128,y128+1,y128+2,y128+3); @@ -2326,25 +1970,21 @@ static inline void idft16(int16_t *x,int16_t *y) y128,y128+1,y128+2,y128+3, tw16_128,tw16_128+1,tw16_128+2); */ - register __m128i x1_flip,x3_flip,x02t,x13t; register __m128i ytmp0,ytmp1,ytmp2,ytmp3,xtmp0,xtmp1,xtmp2,xtmp3; - // First stage : 4 Radix-4 butterflies without input twiddles - x02t = _mm_adds_epi16(x128[0],x128[2]); x13t = _mm_adds_epi16(x128[1],x128[3]); xtmp0 = _mm_adds_epi16(x02t,x13t); xtmp2 = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(x128[1],*(__m128i*)conjugatedft); + x1_flip = _mm_sign_epi16(x128[1],conjugatedft.v128); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(x128[3],*(__m128i*)conjugatedft); + x3_flip = _mm_sign_epi16(x128[3],conjugatedft.v128); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); x02t = _mm_subs_epi16(x128[0],x128[2]); x13t = _mm_subs_epi16(x1_flip,x3_flip); xtmp3 = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp1 = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - ytmp0 = _mm_unpacklo_epi32(xtmp0,xtmp1); ytmp1 = _mm_unpackhi_epi32(xtmp0,xtmp1); ytmp2 = _mm_unpacklo_epi32(xtmp2,xtmp3); @@ -2353,28 +1993,24 @@ static inline void idft16(int16_t *x,int16_t *y) xtmp1 = _mm_unpackhi_epi64(ytmp0,ytmp2); xtmp2 = _mm_unpacklo_epi64(ytmp1,ytmp3); xtmp3 = _mm_unpackhi_epi64(ytmp1,ytmp3); - // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2(xtmp1,tw16a_128[0],tw16b_128[0]); xtmp2 = packed_cmult2(xtmp2,tw16a_128[1],tw16b_128[1]); xtmp3 = packed_cmult2(xtmp3,tw16a_128[2],tw16b_128[2]); - x02t = _mm_adds_epi16(xtmp0,xtmp2); x13t = _mm_adds_epi16(xtmp1,xtmp3); y128[0] = _mm_adds_epi16(x02t,x13t); y128[2] = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(xtmp1,*(__m128i*)conjugatedft); + x1_flip = _mm_sign_epi16(xtmp1,conjugatedft.v128); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(xtmp3,*(__m128i*)conjugatedft); + x3_flip = _mm_sign_epi16(xtmp3,conjugatedft.v128); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); x02t = _mm_subs_epi16(xtmp0,xtmp2); x13t = _mm_subs_epi16(x1_flip,x3_flip); y128[3] = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f y128[1] = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - #elif defined(__arm__) int16x8_t *tw16a_128=(int16x8_t *)tw16,*tw16b_128=(int16x8_t *)tw16c,*x128=(int16x8_t *)x,*y128=(int16x8_t *)y; - /* This is the original version before unrolling bfly4_tw1(x128,x128+1,x128+2,x128+3, @@ -2386,56 +2022,47 @@ static inline void idft16(int16_t *x,int16_t *y) y128,y128+1,y128+2,y128+3, tw16_128,tw16_128+1,tw16_128+2); */ - register int16x8_t x1_flip,x3_flip,x02t,x13t; register int16x8_t xtmp0,xtmp1,xtmp2,xtmp3; register uint32x4x2_t ytmp0,ytmp1; register int16x8_t ytmp0b,ytmp1b,ytmp2b,ytmp3b; - // First stage : 4 Radix-4 butterflies without input twiddles - x02t = vqaddq_s16(x128[0],x128[2]); x13t = vqaddq_s16(x128[1],x128[3]); xtmp0 = vqaddq_s16(x02t,x13t); xtmp2 = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(x128[1],*(int16x8_t*)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(x128[3],*(int16x8_t*)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(x128[1],*(int16x8_t *)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(x128[3],*(int16x8_t *)conjugatedft)); x02t = vqsubq_s16(x128[0],x128[2]); x13t = vqsubq_s16(x1_flip,x3_flip); xtmp3 = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp1 = vqsubq_s16(x02t,x13t); // x0 - x1f - x2 + x3f - ytmp0 = vtrnq_u32((uint32x4_t)(xtmp0),(uint32x4_t)(xtmp1)); -// y0[0] = [x00 x10 x02 x12], y0[1] = [x01 x11 x03 x13] + // y0[0] = [x00 x10 x02 x12], y0[1] = [x01 x11 x03 x13] ytmp1 = vtrnq_u32((uint32x4_t)(xtmp2),(uint32x4_t)(xtmp3)); -// y1[0] = [x20 x30 x22 x32], y1[1] = [x21 x31 x23 x33] - - + // y1[0] = [x20 x30 x22 x32], y1[1] = [x21 x31 x23 x33] ytmp0b = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); -// y0 = [x00 x10 x20 x30] + // y0 = [x00 x10 x20 x30] ytmp1b = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); -// t1 = [x01 x11 x21 x31] + // t1 = [x01 x11 x21 x31] ytmp2b = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); -// t2 = [x02 x12 x22 x32] + // t2 = [x02 x12 x22 x32] ytmp3b = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[1]),vget_high_s16((int16x8_t)ytmp1.val[1])); -// t3 = [x03 x13 x23 x33] - + // t3 = [x03 x13 x23 x33] // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2(ytmp1b,tw16a_128[0],tw16b_128[0]); xtmp2 = packed_cmult2(ytmp2b,tw16a_128[1],tw16b_128[1]); xtmp3 = packed_cmult2(ytmp3b,tw16a_128[2],tw16b_128[2]); - x02t = vqaddq_s16(ytmp0b,xtmp2); x13t = vqaddq_s16(xtmp1,xtmp3); y128[0] = vqaddq_s16(x02t,x13t); y128[2] = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(xtmp1,*(int16x8_t*)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(xtmp3,*(int16x8_t*)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(xtmp1,*(int16x8_t *)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(xtmp3,*(int16x8_t *)conjugatedft)); x02t = vqsubq_s16(ytmp0b,xtmp2); x13t = vqsubq_s16(x1_flip,x3_flip); y128[3] = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f y128[1] = vqsubq_s16(x02t,x13t); // x0 - x1f - x2 + x3f - #endif } @@ -2445,32 +2072,26 @@ void idft16f(int16_t *x,int16_t *y) { #if defined(__x86_64__) || defined(__i386__) #ifdef __AVX2__ -// Does two 16-point IDFTS (x[0 .. 15] is 128 LSBs of input vector, x[16..31] is in 128 MSBs) +// Does two 16-point IDFTS (x[0 .. 15] is 128 LSBs of input vector, x[16..31] is in 128 MSBs) static inline void idft16_simd256(int16_t *x,int16_t *y) __attribute__((always_inline)); -static inline void idft16_simd256(int16_t *x,int16_t *y) -{ - +static inline void idft16_simd256(int16_t *x,int16_t *y) { __m256i *tw16a_256=(__m256i *)tw16rep,*tw16b_256=(__m256i *)tw16crep,*x256=(__m256i *)x,*y256=(__m256i *)y; register __m256i x1_flip,x3_flip,x02t,x13t; register __m256i ytmp0,ytmp1,ytmp2,ytmp3,xtmp0,xtmp1,xtmp2,xtmp3; - register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); - // First stage : 4 Radix-4 butterflies without input twiddles - x02t = _mm256_adds_epi16(x256[0],x256[2]); x13t = _mm256_adds_epi16(x256[1],x256[3]); xtmp0 = _mm256_adds_epi16(x02t,x13t); xtmp2 = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(x256[1],*(__m256i*)conjugatedft); - x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm256_sign_epi16(x256[3],*(__m256i*)conjugatedft); - x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); + x1_flip = _mm256_sign_epi16(x256[1],conjugatedft.v256); + x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); + x3_flip = _mm256_sign_epi16(x256[3],conjugatedft.v256); + x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); x02t = _mm256_subs_epi16(x256[0],x256[2]); x13t = _mm256_subs_epi16(x1_flip,x3_flip); xtmp3 = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp1 = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - - ytmp0 = _mm256_unpacklo_epi32(xtmp0,xtmp1); + ytmp0 = _mm256_unpacklo_epi32(xtmp0,xtmp1); ytmp1 = _mm256_unpackhi_epi32(xtmp0,xtmp1); ytmp2 = _mm256_unpacklo_epi32(xtmp2,xtmp3); ytmp3 = _mm256_unpackhi_epi32(xtmp2,xtmp3); @@ -2478,138 +2099,126 @@ static inline void idft16_simd256(int16_t *x,int16_t *y) xtmp1 = _mm256_unpackhi_epi64(ytmp0,ytmp2); xtmp2 = _mm256_unpacklo_epi64(ytmp1,ytmp3); xtmp3 = _mm256_unpackhi_epi64(ytmp1,ytmp3); - // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2_256(xtmp1,tw16a_256[0],tw16b_256[0]); xtmp2 = packed_cmult2_256(xtmp2,tw16a_256[1],tw16b_256[1]); xtmp3 = packed_cmult2_256(xtmp3,tw16a_256[2],tw16b_256[2]); - x02t = _mm256_adds_epi16(xtmp0,xtmp2); x13t = _mm256_adds_epi16(xtmp1,xtmp3); ytmp0 = _mm256_adds_epi16(x02t,x13t); ytmp2 = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(xtmp1,*(__m256i*)conjugatedft); - x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm256_sign_epi16(xtmp3,*(__m256i*)conjugatedft); - x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); + x1_flip = _mm256_sign_epi16(xtmp1,conjugatedft.v256); + x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); + x3_flip = _mm256_sign_epi16(xtmp3,conjugatedft.v256); + x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); x02t = _mm256_subs_epi16(xtmp0,xtmp2); x13t = _mm256_subs_epi16(x1_flip,x3_flip); ytmp3 = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f ytmp1 = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - // [y0 y1 y2 y3 y16 y17 y18 y19] // [y4 y5 y6 y7 y20 y21 y22 y23] // [y8 y9 y10 y11 y24 y25 y26 y27] // [y12 y13 y14 y15 y28 y29 y30 y31] - y256[0] = _mm256_insertf128_si256(ytmp0,_mm256_extracti128_si256(ytmp1,0),1); y256[1] = _mm256_insertf128_si256(ytmp2,_mm256_extracti128_si256(ytmp3,0),1); y256[2] = _mm256_insertf128_si256(ytmp1,_mm256_extracti128_si256(ytmp0,1),0); y256[3] = _mm256_insertf128_si256(ytmp3,_mm256_extracti128_si256(ytmp2,1),0); - } -#endif +#endif #endif // 64-point optimized DFT -const static int16_t tw64[96] __attribute__((aligned(32))) = { -32767,0,32609,-3212,32137,-6393,31356,-9512, -30272,-12540,28897,-15447,27244,-18205,25329,-20788, -23169,-23170,20787,-25330,18204,-27245,15446,-28898, -12539,-30273,9511,-31357,6392,-32138,3211,-32610, -32767,0,32137,-6393,30272,-12540,27244,-18205, -23169,-23170,18204,-27245,12539,-30273,6392,-32138, -0,-32767,-6393,-32138,-12540,-30273,-18205,-27245, --23170,-23170,-27245,-18205,-30273,-12540,-32138,-6393, -32767,0,31356,-9512,27244,-18205,20787,-25330, -12539,-30273,3211,-32610,-6393,-32138,-15447,-28898, --23170,-23170,-28898,-15447,-32138,-6393,-32610,3211, --30273,12539,-25330,20787,-18205,27244,-9512,31356 - }; -const static int16_t tw64a[96] __attribute__((aligned(32))) = { -32767,0,32609,3212,32137,6393,31356,9512, -30272,12540,28897,15447,27244,18205,25329,20788, -23169,23170,20787,25330,18204,27245,15446,28898, -12539,30273,9511,31357,6392,32138,3211,32610, -32767,0,32137,6393,30272,12540,27244,18205, -23169,23170,18204,27245,12539,30273,6392,32138, -0,32767,-6393,32138,-12540,30273,-18205,27245, --23170,23170,-27245,18205,-30273,12540,-32138,6393, -32767,0,31356,9512,27244,18205,20787,25330, -12539,30273,3211,32610,-6393,32138,-15447,28898, --23170,23170,-28898,15447,-32138,6393,-32610,-3211, --30273,-12539,-25330,-20787,-18205,-27244,-9512,-31356 - }; -const static int16_t tw64b[96] __attribute__((aligned(32))) = { -0,32767,-3212,32609,-6393,32137,-9512,31356, --12540,30272,-15447,28897,-18205,27244,-20788,25329, --23170,23169,-25330,20787,-27245,18204,-28898,15446, --30273,12539,-31357,9511,-32138,6392,-32610,3211, -0,32767,-6393,32137,-12540,30272,-18205,27244, --23170,23169,-27245,18204,-30273,12539,-32138,6392, --32767,0,-32138,-6393,-30273,-12540,-27245,-18205, --23170,-23170,-18205,-27245,-12540,-30273,-6393,-32138, -0,32767,-9512,31356,-18205,27244,-25330,20787, --30273,12539,-32610,3211,-32138,-6393,-28898,-15447, --23170,-23170,-15447,-28898,-6393,-32138,3211,-32610, -12539,-30273,20787,-25330,27244,-18205,31356,-9512 - }; -const static int16_t tw64c[96] __attribute__((aligned(32))) = { -0,32767,3212,32609,6393,32137,9512,31356, -12540,30272,15447,28897,18205,27244,20788,25329, -23170,23169,25330,20787,27245,18204,28898,15446, -30273,12539,31357,9511,32138,6392,32610,3211, -0,32767,6393,32137,12540,30272,18205,27244, -23170,23169,27245,18204,30273,12539,32138,6392, -32767,0,32138,-6393,30273,-12540,27245,-18205, -23170,-23170,18205,-27245,12540,-30273,6393,-32138, -0,32767,9512,31356,18205,27244,25330,20787, -30273,12539,32610,3211,32138,-6393,28898,-15447, -23170,-23170,15447,-28898,6393,-32138,-3211,-32610, --12539,-30273,-20787,-25330,-27244,-18205,-31356,-9512 - }; +const static int16_t tw64[96] __attribute__((aligned(32))) = { + 32767,0,32609,-3212,32137,-6393,31356,-9512, + 30272,-12540,28897,-15447,27244,-18205,25329,-20788, + 23169,-23170,20787,-25330,18204,-27245,15446,-28898, + 12539,-30273,9511,-31357,6392,-32138,3211,-32610, + 32767,0,32137,-6393,30272,-12540,27244,-18205, + 23169,-23170,18204,-27245,12539,-30273,6392,-32138, + 0,-32767,-6393,-32138,-12540,-30273,-18205,-27245, + -23170,-23170,-27245,-18205,-30273,-12540,-32138,-6393, + 32767,0,31356,-9512,27244,-18205,20787,-25330, + 12539,-30273,3211,-32610,-6393,-32138,-15447,-28898, + -23170,-23170,-28898,-15447,-32138,-6393,-32610,3211, + -30273,12539,-25330,20787,-18205,27244,-9512,31356 +}; +const static int16_t tw64a[96] __attribute__((aligned(32))) = { + 32767,0,32609,3212,32137,6393,31356,9512, + 30272,12540,28897,15447,27244,18205,25329,20788, + 23169,23170,20787,25330,18204,27245,15446,28898, + 12539,30273,9511,31357,6392,32138,3211,32610, + 32767,0,32137,6393,30272,12540,27244,18205, + 23169,23170,18204,27245,12539,30273,6392,32138, + 0,32767,-6393,32138,-12540,30273,-18205,27245, + -23170,23170,-27245,18205,-30273,12540,-32138,6393, + 32767,0,31356,9512,27244,18205,20787,25330, + 12539,30273,3211,32610,-6393,32138,-15447,28898, + -23170,23170,-28898,15447,-32138,6393,-32610,-3211, + -30273,-12539,-25330,-20787,-18205,-27244,-9512,-31356 +}; +const static int16_t tw64b[96] __attribute__((aligned(32))) = { + 0,32767,-3212,32609,-6393,32137,-9512,31356, + -12540,30272,-15447,28897,-18205,27244,-20788,25329, + -23170,23169,-25330,20787,-27245,18204,-28898,15446, + -30273,12539,-31357,9511,-32138,6392,-32610,3211, + 0,32767,-6393,32137,-12540,30272,-18205,27244, + -23170,23169,-27245,18204,-30273,12539,-32138,6392, + -32767,0,-32138,-6393,-30273,-12540,-27245,-18205, + -23170,-23170,-18205,-27245,-12540,-30273,-6393,-32138, + 0,32767,-9512,31356,-18205,27244,-25330,20787, + -30273,12539,-32610,3211,-32138,-6393,-28898,-15447, + -23170,-23170,-15447,-28898,-6393,-32138,3211,-32610, + 12539,-30273,20787,-25330,27244,-18205,31356,-9512 +}; +const static int16_t tw64c[96] __attribute__((aligned(32))) = { + 0,32767,3212,32609,6393,32137,9512,31356, + 12540,30272,15447,28897,18205,27244,20788,25329, + 23170,23169,25330,20787,27245,18204,28898,15446, + 30273,12539,31357,9511,32138,6392,32610,3211, + 0,32767,6393,32137,12540,30272,18205,27244, + 23170,23169,27245,18204,30273,12539,32138,6392, + 32767,0,32138,-6393,30273,-12540,27245,-18205, + 23170,-23170,18205,-27245,12540,-30273,6393,-32138, + 0,32767,9512,31356,18205,27244,25330,20787, + 30273,12539,32610,3211,32138,-6393,28898,-15447, + 23170,-23170,15447,-28898,6393,-32138,-3211,-32610, + -12539,-30273,-20787,-25330,-27244,-18205,-31356,-9512 +}; #if defined(__x86_64__) || defined(__i386__) -#define simd_q15_t __m128i -#define simdshort_q15_t __m64 -#define shiftright_int16(a,shift) _mm_srai_epi16(a,shift) -#define set1_int16(a) _mm_set1_epi16(a); -#define mulhi_int16(a,b) _mm_mulhrs_epi16 (a,b) -#ifdef __AVX2__ -#define simd256_q15_t __m256i -#define shiftright_int16_simd256(a,shift) _mm256_srai_epi16(a,shift) -#define set1_int16_simd256(a) _mm256_set1_epi16(a); -#define mulhi_int16_simd256(a,b) _mm256_mulhrs_epi16(a,b); //_mm256_slli_epi16(_mm256_mulhi_epi16(a,b),1); -#endif + #define simd_q15_t __m128i + #define simdshort_q15_t __m64 + #define shiftright_int16(a,shift) _mm_srai_epi16(a,shift) + #define set1_int16(a) _mm_set1_epi16(a); + #define mulhi_int16(a,b) _mm_mulhrs_epi16 (a,b) + #ifdef __AVX2__ + #define simd256_q15_t __m256i + #define shiftright_int16_simd256(a,shift) _mm256_srai_epi16(a,shift) + #define set1_int16_simd256(a) _mm256_set1_epi16(a); + #define mulhi_int16_simd256(a,b) _mm256_mulhrs_epi16(a,b); //_mm256_slli_epi16(_mm256_mulhi_epi16(a,b),1); + #endif #elif defined(__arm__) -#define simd_q15_t int16x8_t -#define simdshort_q15_t int16x4_t -#define shiftright_int16(a,shift) vshrq_n_s16(a,shift) -#define set1_int16(a) vdupq_n_s16(a) -#define mulhi_int16(a,b) vqdmulhq_s16(a,b); -#define _mm_empty() -#define _m_empty() + #define simd_q15_t int16x8_t + #define simdshort_q15_t int16x4_t + #define shiftright_int16(a,shift) vshrq_n_s16(a,shift) + #define set1_int16(a) vdupq_n_s16(a) + #define mulhi_int16(a,b) vqdmulhq_s16(a,b); + #define _mm_empty() + #define _m_empty() #endif #ifndef __AVX2__ -void dft64(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft64(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[16],ytmp[16],*tw64a_128=(simd_q15_t *)tw64a,*tw64b_128=(simd_q15_t *)tw64b,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y; - - #ifdef D64STATS time_stats_t ts_t,ts_d,ts_b; - reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); start_meas(&ts_t); #endif - - transpose16_ooff(x128,xtmp,4); // xtmp0 = x00 x10 x20 x30 // xtmp4 = x01 x11 x21 x31 @@ -2630,59 +2239,47 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) // xtmp7 = xc1 xd1 xe1 xf1 // xtmp11 = xc2 xd2 xe2 xf2 // xtmp15 = xc3 xd3 xe3 xf3 - #ifdef D64STATS stop_meas(&ts_t); start_meas(&ts_d); #endif - // xtmp0 = x00 x10 x20 x30 // xtmp1 = x40 x50 x60 x70 // xtmp2 = x80 x90 xa0 xb0 // xtmp3 = xc0 xd0 xe0 xf0 - dft16((int16_t*)(xtmp),(int16_t*)ytmp); - + dft16((int16_t *)(xtmp),(int16_t *)ytmp); // xtmp4 = x01 x11 x21 x31 // xtmp5 = x41 x51 x61 x71 // xtmp6 = x81 x91 xa1 xb1 // xtmp7 = xc1 xd1 xe1 xf1 - dft16((int16_t*)(xtmp+4),(int16_t*)(ytmp+4)); - dft16((int16_t*)(xtmp+8),(int16_t*)(ytmp+8)); - dft16((int16_t*)(xtmp+12),(int16_t*)(ytmp+12)); - - + dft16((int16_t *)(xtmp+4),(int16_t *)(ytmp+4)); + dft16((int16_t *)(xtmp+8),(int16_t *)(ytmp+8)); + dft16((int16_t *)(xtmp+12),(int16_t *)(ytmp+12)); #ifdef D64STATS stop_meas(&ts_d); start_meas(&ts_b); #endif - - bfly4_16(ytmp,ytmp+4,ytmp+8,ytmp+12, y128,y128+4,y128+8,y128+12, tw64a_128,tw64a_128+4,tw64a_128+8, tw64b_128,tw64b_128+4,tw64b_128+8); - bfly4_16(ytmp+1,ytmp+5,ytmp+9,ytmp+13, y128+1,y128+5,y128+9,y128+13, tw64a_128+1,tw64a_128+5,tw64a_128+9, tw64b_128+1,tw64b_128+5,tw64b_128+9); - bfly4_16(ytmp+2,ytmp+6,ytmp+10,ytmp+14, y128+2,y128+6,y128+10,y128+14, tw64a_128+2,tw64a_128+6,tw64a_128+10, tw64b_128+2,tw64b_128+6,tw64b_128+10); - bfly4_16(ytmp+3,ytmp+7,ytmp+11,ytmp+15, y128+3,y128+7,y128+11,y128+15, tw64a_128+3,tw64a_128+7,tw64a_128+11, tw64b_128+3,tw64b_128+7,tw64b_128+11); - #ifdef D64STATS stop_meas(&ts_b); printf("t: %llu cycles, d: %llu cycles, b: %llu cycles\n",ts_t.diff,ts_d.diff,ts_b.diff); #endif - if (scale>0) { y128[0] = shiftright_int16(y128[0],3); y128[1] = shiftright_int16(y128[1],3); @@ -2704,32 +2301,25 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } #else // __AVX2__ -void dft64(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft64(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[16],ytmp[16],*tw64a_256=(simd256_q15_t *)tw64a,*tw64b_256=(simd256_q15_t *)tw64b,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y; simd256_q15_t xintl0,xintl1,xintl2,xintl3,xintl4,xintl5,xintl6,xintl7; simd256_q15_t const perm_mask = _mm256_set_epi32(7, 3, 5, 1, 6, 2, 4, 0); - - #ifdef D64STATS time_stats_t ts_t,ts_d,ts_b; - reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); start_meas(&ts_t); #endif - #ifdef D64STATS stop_meas(&ts_t); start_meas(&ts_d); #endif - /* + /* print_shorts256("x2560",(int16_t*)x256); print_shorts256("x2561",(int16_t*)(x256+1)); print_shorts256("x2562",(int16_t*)(x256+2)); @@ -2775,7 +2365,7 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) print_shorts256("xtmp6",(int16_t*)(xtmp+6)); print_shorts256("xtmp7",(int16_t*)(xtmp+7)); */ - dft16_simd256((int16_t*)(xtmp),(int16_t*)ytmp); + dft16_simd256((int16_t *)(xtmp),(int16_t *)ytmp); // [y0 y1 y2 y3 y4 y5 y6 y7] // [y8 y9 y10 y11 y12 y13 y14 y15] // [y16 y17 y18 y19 y20 y21 y22 y23] @@ -2786,7 +2376,7 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) print_shorts256("ytmp2",(int16_t*)(ytmp+2)); print_shorts256("ytmp3",(int16_t*)(ytmp+3)); */ - dft16_simd256((int16_t*)(xtmp+4),(int16_t*)(ytmp+4)); + dft16_simd256((int16_t *)(xtmp+4),(int16_t *)(ytmp+4)); // [y32 y33 y34 y35 y36 y37 y38 y39] // [y40 y41 y42 y43 y44 y45 y46 y47] // [y48 y49 y50 y51 y52 y53 y54 y55] @@ -2801,26 +2391,23 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) stop_meas(&ts_d); start_meas(&ts_b); #endif - - bfly4_16_256(ytmp,ytmp+2,ytmp+4,ytmp+6, - y256,y256+2,y256+4,y256+6, - tw64a_256,tw64a_256+2,tw64a_256+4, - tw64b_256,tw64b_256+2,tw64b_256+4); + y256,y256+2,y256+4,y256+6, + tw64a_256,tw64a_256+2,tw64a_256+4, + tw64b_256,tw64b_256+2,tw64b_256+4); // [y0 y1 y2 y3 y4 y5 y6 y7] // [y16 y17 y18 y19 y20 y21 y22 y23] // [y32 y33 y34 y35 y36 y37 y38 y39] // [y48 y49 y50 y51 y52 y53 y54 y55] - bfly4_16_256(ytmp+1,ytmp+3,ytmp+5,ytmp+7, - y256+1,y256+3,y256+5,y256+7, - tw64a_256+1,tw64a_256+3,tw64a_256+5, - tw64b_256+1,tw64b_256+3,tw64b_256+5); + y256+1,y256+3,y256+5,y256+7, + tw64a_256+1,tw64a_256+3,tw64a_256+5, + tw64b_256+1,tw64b_256+3,tw64b_256+5); // [y8 y9 y10 y11 y12 y13 y14 y15] // [y24 y25 y26 y27 y28 y29 y30 y31] // [y40 y41 y42 y43 y44 y45 y46 y47] // [y56 y57 y58 y59 y60 y61 y62 y63] - /* + /* print_shorts256("y256_0",(int16_t*)&y256[0]); print_shorts256("y256_1",(int16_t*)&y256[1]); print_shorts256("y256_2",(int16_t*)&y256[2]); @@ -2830,13 +2417,11 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) print_shorts256("y256_6",(int16_t*)&y256[6]); print_shorts256("y256_7",(int16_t*)&y256[7]); */ - #ifdef D64STATS stop_meas(&ts_b); printf("t: %llu cycles, d: %llu cycles, b: %llu cycles\n",ts_t.diff,ts_d.diff,ts_b.diff); #endif - if (scale>0) { y256[0] = shiftright_int16_simd256(y256[0],3); y256[1] = shiftright_int16_simd256(y256[1],3); @@ -2850,52 +2435,35 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - - } #endif #ifndef __AVX2__ -void idft64(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft64(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[16],ytmp[16],*tw64a_128=(simd_q15_t *)tw64,*tw64b_128=(simd_q15_t *)tw64c,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y; - - #ifdef D64STATS time_stats_t ts_t,ts_d,ts_b; - reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); start_meas(&ts_t); #endif - - transpose16_ooff(x128,xtmp,4); transpose16_ooff(x128+4,xtmp+1,4); transpose16_ooff(x128+8,xtmp+2,4); transpose16_ooff(x128+12,xtmp+3,4); - - #ifdef D64STATS stop_meas(&ts_t); start_meas(&ts_d); #endif - - - idft16((int16_t*)(xtmp),(int16_t*)ytmp); - idft16((int16_t*)(xtmp+4),(int16_t*)(ytmp+4)); - idft16((int16_t*)(xtmp+8),(int16_t*)(ytmp+8)); - idft16((int16_t*)(xtmp+12),(int16_t*)(ytmp+12)); - - + idft16((int16_t *)(xtmp),(int16_t *)ytmp); + idft16((int16_t *)(xtmp+4),(int16_t *)(ytmp+4)); + idft16((int16_t *)(xtmp+8),(int16_t *)(ytmp+8)); + idft16((int16_t *)(xtmp+12),(int16_t *)(ytmp+12)); #ifdef D64STATS stop_meas(&ts_d); start_meas(&ts_b); #endif - - ibfly4_16(ytmp,ytmp+4,ytmp+8,ytmp+12, y128,y128+4,y128+8,y128+12, tw64a_128,tw64a_128+4,tw64a_128+8, @@ -2904,25 +2472,20 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) y128+1,y128+5,y128+9,y128+13, tw64a_128+1,tw64a_128+5,tw64a_128+9, tw64b_128+1,tw64b_128+5,tw64b_128+9); - ibfly4_16(ytmp+2,ytmp+6,ytmp+10,ytmp+14, y128+2,y128+6,y128+10,y128+14, tw64a_128+2,tw64a_128+6,tw64a_128+10, tw64b_128+2,tw64b_128+6,tw64b_128+10); - ibfly4_16(ytmp+3,ytmp+7,ytmp+11,ytmp+15, y128+3,y128+7,y128+11,y128+15, tw64a_128+3,tw64a_128+7,tw64a_128+11, tw64b_128+3,tw64b_128+7,tw64b_128+11); - #ifdef D64STATS stop_meas(&ts_b); printf("t: %llu cycles, d: %llu cycles, b: %llu cycles\n",ts_t.diff,ts_d.diff,ts_b.diff); #endif - if (scale>0) { - y128[0] = shiftright_int16(y128[0],3); y128[1] = shiftright_int16(y128[1],3); y128[2] = shiftright_int16(y128[2],3); @@ -2939,37 +2502,28 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],3); y128[14] = shiftright_int16(y128[14],3); y128[15] = shiftright_int16(y128[15],3); - } _mm_empty(); _m_empty(); - } #else // __AVX2__ -void idft64(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft64(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[16],ytmp[16],*tw64a_256=(simd256_q15_t *)tw64,*tw64b_256=(simd256_q15_t *)tw64c,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y; register simd256_q15_t xintl0,xintl1,xintl2,xintl3,xintl4,xintl5,xintl6,xintl7; simd256_q15_t const perm_mask = _mm256_set_epi32(7, 3, 5, 1, 6, 2, 4, 0); - - #ifdef D64STATS time_stats_t ts_t,ts_d,ts_b; - reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); start_meas(&ts_t); #endif - #ifdef D64STATS stop_meas(&ts_t); start_meas(&ts_d); #endif - xintl0 = _mm256_permutevar8x32_epi32(x256[0],perm_mask); // x0 x4 x1 x5 x2 x6 x3 x7 xintl1 = _mm256_permutevar8x32_epi32(x256[1],perm_mask); // x8 x12 x9 x13 x10 x14 x11 x15 xintl2 = _mm256_permutevar8x32_epi32(x256[2],perm_mask); // x16 x20 x17 x21 x18 x22 x19 x23 @@ -2978,7 +2532,6 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) xintl5 = _mm256_permutevar8x32_epi32(x256[5],perm_mask); // x24 x28 x25 x29 x26 x30 x27 x31 xintl6 = _mm256_permutevar8x32_epi32(x256[6],perm_mask); // x24 x28 x25 x29 x26 x30 x27 x31 xintl7 = _mm256_permutevar8x32_epi32(x256[7],perm_mask); // x24 x28 x25 x29 x26 x30 x27 x31 - xtmp[0] = _mm256_unpacklo_epi64(xintl0,xintl1); // x0 x4 x8 x12 x1 x5 x9 x13 xtmp[4] = _mm256_unpackhi_epi64(xintl0,xintl1); // x2 x6 x10 x14 x3 x7 x11 x15 xtmp[1] = _mm256_unpacklo_epi64(xintl2,xintl3); // x16 x20 x24 x28 x17 x21 x25 x29 @@ -2987,51 +2540,41 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) xtmp[6] = _mm256_unpackhi_epi64(xintl4,xintl5); // x34 x38 x42 x46 x35 x39 x43 x47 xtmp[3] = _mm256_unpacklo_epi64(xintl6,xintl7); // x48 x52 x56 x60 x49 x53 x57 x61 xtmp[7] = _mm256_unpackhi_epi64(xintl6,xintl7); // x50 x54 x58 x62 x51 x55 x59 x63 - - - idft16_simd256((int16_t*)(xtmp),(int16_t*)ytmp); + idft16_simd256((int16_t *)(xtmp),(int16_t *)ytmp); // [y0 y1 y2 y3 y16 y17 y18 y19] // [y4 y5 y6 y7 y20 y21 y22 y23] // [y8 y9 y10 y11 y24 y25 y26 y27] // [y12 y13 y14 y15 y28 y29 y30 y31] - - idft16_simd256((int16_t*)(xtmp+4),(int16_t*)(ytmp+4)); + idft16_simd256((int16_t *)(xtmp+4),(int16_t *)(ytmp+4)); // [y32 y33 y34 y35 y48 y49 y50 y51] // [y36 y37 y38 y39 y52 y53 y54 y55] // [y40 y41 y42 y43 y56 y57 y58 y59] // [y44 y45 y46 y47 y60 y61 y62 y63] - #ifdef D64STATS stop_meas(&ts_d); start_meas(&ts_b); #endif - - ibfly4_16_256(ytmp,ytmp+2,ytmp+4,ytmp+6, - y256,y256+2,y256+4,y256+6, - tw64a_256,tw64a_256+2,tw64a_256+4, - tw64b_256,tw64b_256+2,tw64b_256+4); + y256,y256+2,y256+4,y256+6, + tw64a_256,tw64a_256+2,tw64a_256+4, + tw64b_256,tw64b_256+2,tw64b_256+4); // [y0 y1 y2 y3 y4 y5 y6 y7] // [y16 y17 y18 y19 y20 y21 y22 y23] // [y32 y33 y34 y35 y36 y37 y38 y39] // [y48 y49 y50 y51 y52 y53 y54 y55] - ibfly4_16_256(ytmp+1,ytmp+3,ytmp+5,ytmp+7, - y256+1,y256+3,y256+5,y256+7, - tw64a_256+1,tw64a_256+3,tw64a_256+5, - tw64b_256+1,tw64b_256+3,tw64b_256+5); + y256+1,y256+3,y256+5,y256+7, + tw64a_256+1,tw64a_256+3,tw64a_256+5, + tw64b_256+1,tw64b_256+3,tw64b_256+5); // [y8 y9 y10 y11 y12 y13 y14 y15] // [y24 y25 y26 y27 y28 y29 y30 y31] // [y40 y41 y42 y43 y44 y45 y46 y47] // [y56 y57 y58 y59 y60 y61 y62 y63] - - #ifdef D64STATS stop_meas(&ts_b); printf("t: %llu cycles, d: %llu cycles, b: %llu cycles\n",ts_t.diff,ts_d.diff,ts_b.diff); #endif - if (scale>0) { y256[0] = shiftright_int16_simd256(y256[0],3); y256[1] = shiftright_int16_simd256(y256[1],3); @@ -3045,7 +2588,6 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } #endif @@ -3058,17 +2600,13 @@ int16_t tw128b[128] __attribute__((aligned(32))) = {0,32767,-1608,32727,-3212,32 int16_t tw128c[128] __attribute__((aligned(32))) = {0,32767,1608,32727,3212,32609,4808,32412,6393,32137,7962,31785,9512,31356,11039,30851,12540,30272,14010,29621,15447,28897,16846,28105,18205,27244,19520,26318,20788,25329,22005,24278,23170,23169,24279,22004,25330,20787,26319,19519,27245,18204,28106,16845,28898,15446,29622,14009,30273,12539,30852,11038,31357,9511,31786,7961,32138,6392,32413,4807,32610,3211,32728,1607,32767,0,32728,-1608,32610,-3212,32413,-4808,32138,-6393,31786,-7962,31357,-9512,30852,-11039,30273,-12540,29622,-14010,28898,-15447,28106,-16846,27245,-18205,26319,-19520,25330,-20788,24279,-22005,23170,-23170,22005,-24279,20788,-25330,19520,-26319,18205,-27245,16846,-28106,15447,-28898,14010,-29622,12540,-30273,11039,-30852,9512,-31357,7962,-31786,6393,-32138,4808,-32413,3212,-32610,1608,-32728}; #ifndef __AVX2__ -void dft128(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft128(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[64],*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[32],*tw128a_128p=(simd_q15_t *)tw128a,*tw128b_128p=(simd_q15_t *)tw128b,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - - - transpose4_ooff(x64 ,xtmp,32); + transpose4_ooff(x64,xtmp,32); transpose4_ooff(x64+2,xtmp+1,32); transpose4_ooff(x64+4,xtmp+2,32); transpose4_ooff(x64+6,xtmp+3,32); @@ -3100,13 +2638,14 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) transpose4_ooff(x64+58,xtmp+29,32); transpose4_ooff(x64+60,xtmp+30,32); transpose4_ooff(x64+62,xtmp+31,32); + dft64((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft64((int16_t *)(xtmp+32),(int16_t *)(ytmp+16),1); - dft64((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft64((int16_t*)(xtmp+32),(int16_t*)(ytmp+16),1); if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("dft128a.m","dfta",ytmp,64,1,1); LOG_M("dft128b.m","dftb",ytmp+16,64,1,1); } + for (i=0; i<16; i++) { bfly2_16(ytmpp,ytmpp+16, y128p,y128p+16, @@ -3119,7 +2658,6 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - y128[0] = mulhi_int16(y128[0],ONE_OVER_SQRT2_Q15_128); y128[1] = mulhi_int16(y128[1],ONE_OVER_SQRT2_Q15_128); y128[2] = mulhi_int16(y128[2],ONE_OVER_SQRT2_Q15_128); @@ -3152,30 +2690,26 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) y128[29] = mulhi_int16(y128[29],ONE_OVER_SQRT2_Q15_128); y128[30] = mulhi_int16(y128[30],ONE_OVER_SQRT2_Q15_128); y128[31] = mulhi_int16(y128[31],ONE_OVER_SQRT2_Q15_128); - - } + if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("dft128out.m","dft128",y,128,1,1); - exit(-1); + LOG_M("dft128out.m","dft128",y,128,1,1); + exit(-1); } + _mm_empty(); _m_empty(); - } #else // __AVX2__ -void dft128(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft128(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[16],*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[16],*y256=(simd256_q15_t*)y; + simd256_q15_t ytmp[16],*y256=(simd256_q15_t *)y; simd256_q15_t *tw128a_256p=(simd256_q15_t *)tw128a,*tw128b_256p=(simd256_q15_t *)tw128b,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - - transpose4_ooff_simd256(x256 ,xtmp,8); + transpose4_ooff_simd256(x256,xtmp,8); transpose4_ooff_simd256(x256+2,xtmp+1,8); transpose4_ooff_simd256(x256+4,xtmp+2,8); transpose4_ooff_simd256(x256+6,xtmp+3,8); @@ -3183,23 +2717,25 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) transpose4_ooff_simd256(x256+10,xtmp+5,8); transpose4_ooff_simd256(x256+12,xtmp+6,8); transpose4_ooff_simd256(x256+14,xtmp+7,8); - if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("dft128ina_256.m","dftina",xtmp,64,1,1); - LOG_M("dft128inb_256.m","dftinb",xtmp+8,64,1,1); + + if (LOG_DUMPFLAG(DEBUG_DFT)) { + LOG_M("dft128ina_256.m","dftina",xtmp,64,1,1); + LOG_M("dft128inb_256.m","dftinb",xtmp+8,64,1,1); } - dft64((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft64((int16_t*)(xtmp+8),(int16_t*)(ytmp+8),1); - if (LOG_DUMPFLAG(DEBUG_DFT)) { + dft64((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft64((int16_t *)(xtmp+8),(int16_t *)(ytmp+8),1); + + if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("dft128outa_256.m","dftouta",ytmp,64,1,1); LOG_M("dft128outb_256.m","dftoutb",ytmp+8,64,1,1); } for (i=0; i<8; i++) { bfly2_16_256(ytmpp,ytmpp+8, - y256p,y256p+8, - tw128a_256p, - tw128b_256p); + y256p,y256p+8, + tw128a_256p, + tw128b_256p); tw128a_256p++; tw128b_256p++; y256p++; @@ -3207,7 +2743,6 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); @@ -3224,28 +2759,24 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) y256[13] = mulhi_int16_simd256(y256[13],ONE_OVER_SQRT2_Q15_256); y256[14] = mulhi_int16_simd256(y256[14],ONE_OVER_SQRT2_Q15_256); y256[15] = mulhi_int16_simd256(y256[15],ONE_OVER_SQRT2_Q15_256); - } - if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("dft128.m","dft",y256,128,1,1); - exit(-1); + + if (LOG_DUMPFLAG(DEBUG_DFT)) { + LOG_M("dft128.m","dft",y256,128,1,1); + exit(-1); } } #endif #ifndef __AVX2__ -void idft128(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft128(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[64],*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[32],*tw128_128p=(simd_q15_t *)tw128,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - - - transpose4_ooff(x64 ,xtmp,32); + transpose4_ooff(x64,xtmp,32); transpose4_ooff(x64+2,xtmp+1,32); transpose4_ooff(x64+4,xtmp+2,32); transpose4_ooff(x64+6,xtmp+3,32); @@ -3277,10 +2808,8 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) transpose4_ooff(x64+58,xtmp+29,32); transpose4_ooff(x64+60,xtmp+30,32); transpose4_ooff(x64+62,xtmp+31,32); - - idft64((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft64((int16_t*)(xtmp+32),(int16_t*)(ytmp+16),1); - + idft64((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft64((int16_t *)(xtmp+32),(int16_t *)(ytmp+16),1); for (i=0; i<16; i++) { ibfly2(ytmpp,ytmpp+16, @@ -3292,7 +2821,6 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - y128[0] = mulhi_int16(y128[0],ONE_OVER_SQRT2_Q15_128); y128[1] = mulhi_int16(y128[1],ONE_OVER_SQRT2_Q15_128); y128[2] = mulhi_int16(y128[2],ONE_OVER_SQRT2_Q15_128); @@ -3325,27 +2853,21 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) y128[29] = mulhi_int16(y128[29],ONE_OVER_SQRT2_Q15_128); y128[30] = mulhi_int16(y128[30],ONE_OVER_SQRT2_Q15_128); y128[31] = mulhi_int16(y128[31],ONE_OVER_SQRT2_Q15_128); - } _mm_empty(); _m_empty(); - } #else // __AVX2__ -void idft128(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft128(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[16],*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[16],*y256=(simd256_q15_t*)y; + simd256_q15_t ytmp[16],*y256=(simd256_q15_t *)y; simd256_q15_t *tw128_256p=(simd256_q15_t *)tw128,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - - - transpose4_ooff_simd256(x256 ,xtmp,8); + transpose4_ooff_simd256(x256,xtmp,8); transpose4_ooff_simd256(x256+2,xtmp+1,8); transpose4_ooff_simd256(x256+4,xtmp+2,8); transpose4_ooff_simd256(x256+6,xtmp+3,8); @@ -3353,22 +2875,19 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) transpose4_ooff_simd256(x256+10,xtmp+5,8); transpose4_ooff_simd256(x256+12,xtmp+6,8); transpose4_ooff_simd256(x256+14,xtmp+7,8); - - idft64((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft64((int16_t*)(xtmp+8),(int16_t*)(ytmp+8),1); - + idft64((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft64((int16_t *)(xtmp+8),(int16_t *)(ytmp+8),1); for (i=0; i<8; i++) { ibfly2_256(ytmpp,ytmpp+8, - y256p,y256p+8, - tw128_256p); + y256p,y256p+8, + tw128_256p); tw128_256p++; y256p++; ytmpp++; } if (scale>0) { - y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); @@ -3385,9 +2904,7 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) y256[13] = mulhi_int16_simd256(y256[13],ONE_OVER_SQRT2_Q15_256); y256[14] = mulhi_int16_simd256(y256[14],ONE_OVER_SQRT2_Q15_256); y256[15] = mulhi_int16_simd256(y256[15],ONE_OVER_SQRT2_Q15_256); - } - } #endif @@ -3407,16 +2924,12 @@ int16_t tw256b[384] __attribute__((aligned(32))) = {0,32767,-805,32757,-1608,327 0,32767,-2411,32678,-4808,32412,-7180,31970,-9512,31356,-11793,30571,-14010,29621,-16151,28510,-18205,27244,-20160,25831,-22005,24278,-23732,22594,-25330,20787,-26790,18867,-28106,16845,-29269,14732,-30273,12539,-31114,10278,-31786,7961,-32285,5601,-32610,3211,-32758,804,-32728,-1608,-32521,-4012,-32138,-6393,-31581,-8740,-30852,-11039,-29956,-13279,-28898,-15447,-27684,-17531,-26319,-19520,-24812,-21403,-23170,-23170,-21403,-24812,-19520,-26319,-17531,-27684,-15447,-28898,-13279,-29956,-11039,-30852,-8740,-31581,-6393,-32138,-4012,-32521,-1608,-32728,804,-32758,3211,-32610,5601,-32285,7961,-31786,10278,-31114,12539,-30273,14732,-29269,16845,-28106,18867,-26790,20787,-25330,22594,-23732,24278,-22005,25831,-20160,27244,-18205,28510,-16151,29621,-14010,30571,-11793,31356,-9512,31970,-7180,32412,-4808,32678,-2411 }; #ifndef __AVX2__ -void dft256(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft256(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[64],ytmp[64],*tw256a_128p=(simd_q15_t *)tw256a,*tw256b_128p=(simd_q15_t *)tw256b,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; - #ifdef D256STATS time_stats_t ts_t,ts_d,ts_b; - reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); @@ -3443,17 +2956,14 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff(x128+52,xtmp+13,16); transpose16_ooff(x128+56,xtmp+14,16); transpose16_ooff(x128+60,xtmp+15,16); - #ifdef D256STATS stop_meas(&ts_t); start_meas(&ts_d); #endif - - dft64((int16_t*)(xtmp),(int16_t*)(ytmp),1); - dft64((int16_t*)(xtmp+16),(int16_t*)(ytmp+16),1); - dft64((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); - dft64((int16_t*)(xtmp+48),(int16_t*)(ytmp+48),1); - + dft64((int16_t *)(xtmp),(int16_t *)(ytmp),1); + dft64((int16_t *)(xtmp+16),(int16_t *)(ytmp+16),1); + dft64((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); + dft64((int16_t *)(xtmp+48),(int16_t *)(ytmp+48),1); #ifdef D256STATS stop_meas(&ts_d); start_meas(&ts_b); @@ -3488,7 +2998,6 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) #endif if (scale>0) { - for (i=0; i<4; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -3506,22 +3015,17 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); - y128+=16; } - } _mm_empty(); _m_empty(); - } -void idft256(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft256(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[64],ytmp[64],*tw256_128p=(simd_q15_t *)tw256,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -3530,11 +3034,10 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff(x128+i,xtmp+j,16); } - - idft64((int16_t*)(xtmp),(int16_t*)(ytmp),1); - idft64((int16_t*)(xtmp+16),(int16_t*)(ytmp+16),1); - idft64((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); - idft64((int16_t*)(xtmp+48),(int16_t*)(ytmp+48),1); + idft64((int16_t *)(xtmp),(int16_t *)(ytmp),1); + idft64((int16_t *)(xtmp+16),(int16_t *)(ytmp+16),1); + idft64((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); + idft64((int16_t *)(xtmp+48),(int16_t *)(ytmp+48),1); for (i=0; i<16; i++) { ibfly4(ytmpp,ytmpp+16,ytmpp+32,ytmpp+48, @@ -3546,7 +3049,6 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - for (i=0; i<4; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -3564,26 +3066,20 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); - y128+=16; } - } _mm_empty(); _m_empty(); - } #else //__AVX2__ -void dft256(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft256(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[32],ytmp[32],*tw256a_256p=(simd256_q15_t *)tw256a,*tw256b_256p=(simd256_q15_t *)tw256b,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; - transpose16_ooff_simd256(x256+0,xtmp+0,8); transpose16_ooff_simd256(x256+4,xtmp+1,8); transpose16_ooff_simd256(x256+8,xtmp+2,8); @@ -3599,48 +3095,44 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) print_shorts256(vname,(int16_t*)(xtmp+i)); } exit(-1);*/ - - dft64((int16_t*)(xtmp),(int16_t*)(ytmp),1); - dft64((int16_t*)(xtmp+8),(int16_t*)(ytmp+8),1); - dft64((int16_t*)(xtmp+16),(int16_t*)(ytmp+16),1); - dft64((int16_t*)(xtmp+24),(int16_t*)(ytmp+24),1); - - + dft64((int16_t *)(xtmp),(int16_t *)(ytmp),1); + dft64((int16_t *)(xtmp+8),(int16_t *)(ytmp+8),1); + dft64((int16_t *)(xtmp+16),(int16_t *)(ytmp+16),1); + dft64((int16_t *)(xtmp+24),(int16_t *)(ytmp+24),1); bfly4_16_256(ytmpp,ytmpp+8,ytmpp+16,ytmpp+24, - y256p,y256p+8,y256p+16,y256p+24, - tw256a_256p,tw256a_256p+8,tw256a_256p+16, - tw256b_256p,tw256b_256p+8,tw256b_256p+16); + y256p,y256p+8,y256p+16,y256p+24, + tw256a_256p,tw256a_256p+8,tw256a_256p+16, + tw256b_256p,tw256b_256p+8,tw256b_256p+16); bfly4_16_256(ytmpp+1,ytmpp+9,ytmpp+17,ytmpp+25, - y256p+1,y256p+9,y256p+17,y256p+25, - tw256a_256p+1,tw256a_256p+9,tw256a_256p+17, - tw256b_256p+1,tw256b_256p+9,tw256b_256p+17); + y256p+1,y256p+9,y256p+17,y256p+25, + tw256a_256p+1,tw256a_256p+9,tw256a_256p+17, + tw256b_256p+1,tw256b_256p+9,tw256b_256p+17); bfly4_16_256(ytmpp+2,ytmpp+10,ytmpp+18,ytmpp+26, - y256p+2,y256p+10,y256p+18,y256p+26, - tw256a_256p+2,tw256a_256p+10,tw256a_256p+18, - tw256b_256p+2,tw256b_256p+10,tw256b_256p+18); + y256p+2,y256p+10,y256p+18,y256p+26, + tw256a_256p+2,tw256a_256p+10,tw256a_256p+18, + tw256b_256p+2,tw256b_256p+10,tw256b_256p+18); bfly4_16_256(ytmpp+3,ytmpp+11,ytmpp+19,ytmpp+27, - y256p+3,y256p+11,y256p+19,y256p+27, - tw256a_256p+3,tw256a_256p+11,tw256a_256p+19, - tw256b_256p+3,tw256b_256p+11,tw256b_256p+19); + y256p+3,y256p+11,y256p+19,y256p+27, + tw256a_256p+3,tw256a_256p+11,tw256a_256p+19, + tw256b_256p+3,tw256b_256p+11,tw256b_256p+19); bfly4_16_256(ytmpp+4,ytmpp+12,ytmpp+20,ytmpp+28, - y256p+4,y256p+12,y256p+20,y256p+28, - tw256a_256p+4,tw256a_256p+12,tw256a_256p+20, - tw256b_256p+4,tw256b_256p+12,tw256b_256p+20); + y256p+4,y256p+12,y256p+20,y256p+28, + tw256a_256p+4,tw256a_256p+12,tw256a_256p+20, + tw256b_256p+4,tw256b_256p+12,tw256b_256p+20); bfly4_16_256(ytmpp+5,ytmpp+13,ytmpp+21,ytmpp+29, - y256p+5,y256p+13,y256p+21,y256p+29, - tw256a_256p+5,tw256a_256p+13,tw256a_256p+21, - tw256b_256p+5,tw256b_256p+13,tw256b_256p+21); + y256p+5,y256p+13,y256p+21,y256p+29, + tw256a_256p+5,tw256a_256p+13,tw256a_256p+21, + tw256b_256p+5,tw256b_256p+13,tw256b_256p+21); bfly4_16_256(ytmpp+6,ytmpp+14,ytmpp+22,ytmpp+30, - y256p+6,y256p+14,y256p+22,y256p+30, - tw256a_256p+6,tw256a_256p+14,tw256a_256p+22, - tw256b_256p+6,tw256b_256p+14,tw256b_256p+22); + y256p+6,y256p+14,y256p+22,y256p+30, + tw256a_256p+6,tw256a_256p+14,tw256a_256p+22, + tw256b_256p+6,tw256b_256p+14,tw256b_256p+22); bfly4_16_256(ytmpp+7,ytmpp+15,ytmpp+23,ytmpp+31, - y256p+7,y256p+15,y256p+23,y256p+31, - tw256a_256p+7,tw256a_256p+15,tw256a_256p+23, - tw256b_256p+7,tw256b_256p+15,tw256b_256p+23); + y256p+7,y256p+15,y256p+23,y256p+31, + tw256a_256p+7,tw256a_256p+15,tw256a_256p+23, + tw256b_256p+7,tw256b_256p+15,tw256b_256p+23); if (scale>0) { - for (i=0; i<2; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -3658,24 +3150,18 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); - y256+=16; } - } _mm_empty(); _m_empty(); - } -void idft256(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft256(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[32],ytmp[32],*tw256_256p=(simd256_q15_t *)tw256,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; - transpose16_ooff_simd256(x256+0,xtmp+0,8); transpose16_ooff_simd256(x256+4,xtmp+1,8); transpose16_ooff_simd256(x256+8,xtmp+2,8); @@ -3684,48 +3170,36 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff_simd256(x256+20,xtmp+5,8); transpose16_ooff_simd256(x256+24,xtmp+6,8); transpose16_ooff_simd256(x256+28,xtmp+7,8); - - idft64((int16_t*)(xtmp),(int16_t*)(ytmp),1); - idft64((int16_t*)(xtmp+8),(int16_t*)(ytmp+8),1); - idft64((int16_t*)(xtmp+16),(int16_t*)(ytmp+16),1); - idft64((int16_t*)(xtmp+24),(int16_t*)(ytmp+24),1); - - + idft64((int16_t *)(xtmp),(int16_t *)(ytmp),1); + idft64((int16_t *)(xtmp+8),(int16_t *)(ytmp+8),1); + idft64((int16_t *)(xtmp+16),(int16_t *)(ytmp+16),1); + idft64((int16_t *)(xtmp+24),(int16_t *)(ytmp+24),1); ibfly4_256(ytmpp,ytmpp+8,ytmpp+16,ytmpp+24, - y256p,y256p+8,y256p+16,y256p+24, - tw256_256p,tw256_256p+8,tw256_256p+16); - + y256p,y256p+8,y256p+16,y256p+24, + tw256_256p,tw256_256p+8,tw256_256p+16); ibfly4_256(ytmpp+1,ytmpp+9,ytmpp+17,ytmpp+25, - y256p+1,y256p+9,y256p+17,y256p+25, - tw256_256p+1,tw256_256p+9,tw256_256p+17); - + y256p+1,y256p+9,y256p+17,y256p+25, + tw256_256p+1,tw256_256p+9,tw256_256p+17); ibfly4_256(ytmpp+2,ytmpp+10,ytmpp+18,ytmpp+26, - y256p+2,y256p+10,y256p+18,y256p+26, - tw256_256p+2,tw256_256p+10,tw256_256p+18); - + y256p+2,y256p+10,y256p+18,y256p+26, + tw256_256p+2,tw256_256p+10,tw256_256p+18); ibfly4_256(ytmpp+3,ytmpp+11,ytmpp+19,ytmpp+27, - y256p+3,y256p+11,y256p+19,y256p+27, - tw256_256p+3,tw256_256p+11,tw256_256p+19); - + y256p+3,y256p+11,y256p+19,y256p+27, + tw256_256p+3,tw256_256p+11,tw256_256p+19); ibfly4_256(ytmpp+4,ytmpp+12,ytmpp+20,ytmpp+28, - y256p+4,y256p+12,y256p+20,y256p+28, - tw256_256p+4,tw256_256p+12,tw256_256p+20); - + y256p+4,y256p+12,y256p+20,y256p+28, + tw256_256p+4,tw256_256p+12,tw256_256p+20); ibfly4_256(ytmpp+5,ytmpp+13,ytmpp+21,ytmpp+29, - y256p+5,y256p+13,y256p+21,y256p+29, - tw256_256p+5,tw256_256p+13,tw256_256p+21); - + y256p+5,y256p+13,y256p+21,y256p+29, + tw256_256p+5,tw256_256p+13,tw256_256p+21); ibfly4_256(ytmpp+6,ytmpp+14,ytmpp+22,ytmpp+30, - y256p+6,y256p+14,y256p+22,y256p+30, - tw256_256p+6,tw256_256p+14,tw256_256p+22); - + y256p+6,y256p+14,y256p+22,y256p+30, + tw256_256p+6,tw256_256p+14,tw256_256p+22); ibfly4_256(ytmpp+7,ytmpp+15,ytmpp+23,ytmpp+31, - y256p+7,y256p+15,y256p+23,y256p+31, - tw256_256p+7,tw256_256p+15,tw256_256p+23); + y256p+7,y256p+15,y256p+23,y256p+31, + tw256_256p+7,tw256_256p+15,tw256_256p+23); - if (scale>0) { - for (i=0; i<2; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -3743,15 +3217,12 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); - y256+=16; } - } _mm_empty(); _m_empty(); - } #endif @@ -3774,19 +3245,16 @@ int16_t tw512c[512] __attribute__((aligned(32))) = { }; #ifndef __AVX2__ -void dft512(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft512(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[256],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[128],*tw512a_128p=(simd_q15_t *)tw512a,*tw512b_128p=(simd_q15_t *)tw512b,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<4; i++) { - transpose4_ooff(x64 ,xtmpp,128); + transpose4_ooff(x64,xtmpp,128); transpose4_ooff(x64+2,xtmpp+1,128); transpose4_ooff(x64+4,xtmpp+2,128); transpose4_ooff(x64+6,xtmpp+3,128); @@ -3822,9 +3290,8 @@ void dft512(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - dft256((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft256((int16_t*)(xtmp+128),(int16_t*)(ytmp+64),1); - + dft256((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft256((int16_t *)(xtmp+128),(int16_t *)(ytmp+64),1); for (i=0; i<64; i+=8) { bfly2_16(ytmpp,ytmpp+64, @@ -3891,22 +3358,18 @@ void dft512(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } -void idft512(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft512(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[256],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[128],*tw512_128p=(simd_q15_t *)tw512,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<4; i++) { - transpose4_ooff(x64 ,xtmpp,128); + transpose4_ooff(x64,xtmpp,128); transpose4_ooff(x64+2,xtmpp+1,128); transpose4_ooff(x64+4,xtmpp+2,128); transpose4_ooff(x64+6,xtmpp+3,128); @@ -3942,9 +3405,8 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - idft256((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft256((int16_t*)(xtmp+128),(int16_t*)(ytmp+64),1); - + idft256((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft256((int16_t *)(xtmp+128),(int16_t *)(ytmp+64),1); for (i=0; i<64; i++) { ibfly2(ytmpp,ytmpp+64, @@ -3981,105 +3443,18 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } #else //__AVX2__ -void dft512(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft512(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[64],*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[64],*y256=(simd256_q15_t*)y; - simd256_q15_t *tw512_256p=(simd256_q15_t*)tw512,*y256p=(simd256_q15_t *)y; - simd256_q15_t *ytmpp = &ytmp[0]; - int i; - simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - - - transpose4_ooff_simd256(x256 ,xtmp,32); - transpose4_ooff_simd256(x256+2,xtmp+1,32); - transpose4_ooff_simd256(x256+4,xtmp+2,32); - transpose4_ooff_simd256(x256+6,xtmp+3,32); - transpose4_ooff_simd256(x256+8,xtmp+4,32); - transpose4_ooff_simd256(x256+10,xtmp+5,32); - transpose4_ooff_simd256(x256+12,xtmp+6,32); - transpose4_ooff_simd256(x256+14,xtmp+7,32); - transpose4_ooff_simd256(x256+16,xtmp+8,32); - transpose4_ooff_simd256(x256+18,xtmp+9,32); - transpose4_ooff_simd256(x256+20,xtmp+10,32); - transpose4_ooff_simd256(x256+22,xtmp+11,32); - transpose4_ooff_simd256(x256+24,xtmp+12,32); - transpose4_ooff_simd256(x256+26,xtmp+13,32); - transpose4_ooff_simd256(x256+28,xtmp+14,32); - transpose4_ooff_simd256(x256+30,xtmp+15,32); - transpose4_ooff_simd256(x256+32,xtmp+16,32); - transpose4_ooff_simd256(x256+34,xtmp+17,32); - transpose4_ooff_simd256(x256+36,xtmp+18,32); - transpose4_ooff_simd256(x256+38,xtmp+19,32); - transpose4_ooff_simd256(x256+40,xtmp+20,32); - transpose4_ooff_simd256(x256+42,xtmp+21,32); - transpose4_ooff_simd256(x256+44,xtmp+22,32); - transpose4_ooff_simd256(x256+46,xtmp+23,32); - transpose4_ooff_simd256(x256+48,xtmp+24,32); - transpose4_ooff_simd256(x256+50,xtmp+25,32); - transpose4_ooff_simd256(x256+52,xtmp+26,32); - transpose4_ooff_simd256(x256+54,xtmp+27,32); - transpose4_ooff_simd256(x256+56,xtmp+28,32); - transpose4_ooff_simd256(x256+58,xtmp+29,32); - transpose4_ooff_simd256(x256+60,xtmp+30,32); - transpose4_ooff_simd256(x256+62,xtmp+31,32); - - dft256((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft256((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); - - - for (i=0; i<32; i++) { - bfly2_256(ytmpp,ytmpp+32, - y256p,y256p+32, - tw512_256p); - tw512_256p++; - y256p++; - ytmpp++; - } - - if (scale>0) { - - for (i=0;i<4;i++) { - y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); - y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); - y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); - y256[3] = mulhi_int16_simd256(y256[3],ONE_OVER_SQRT2_Q15_256); - y256[4] = mulhi_int16_simd256(y256[4],ONE_OVER_SQRT2_Q15_256); - y256[5] = mulhi_int16_simd256(y256[5],ONE_OVER_SQRT2_Q15_256); - y256[6] = mulhi_int16_simd256(y256[6],ONE_OVER_SQRT2_Q15_256); - y256[7] = mulhi_int16_simd256(y256[7],ONE_OVER_SQRT2_Q15_256); - y256[8] = mulhi_int16_simd256(y256[8],ONE_OVER_SQRT2_Q15_256); - y256[9] = mulhi_int16_simd256(y256[9],ONE_OVER_SQRT2_Q15_256); - y256[10] = mulhi_int16_simd256(y256[10],ONE_OVER_SQRT2_Q15_256); - y256[11] = mulhi_int16_simd256(y256[11],ONE_OVER_SQRT2_Q15_256); - y256[12] = mulhi_int16_simd256(y256[12],ONE_OVER_SQRT2_Q15_256); - y256[13] = mulhi_int16_simd256(y256[13],ONE_OVER_SQRT2_Q15_256); - y256[14] = mulhi_int16_simd256(y256[14],ONE_OVER_SQRT2_Q15_256); - y256[15] = mulhi_int16_simd256(y256[15],ONE_OVER_SQRT2_Q15_256); - y256+=16; - } - } - -} - -void idft512(int16_t *x,int16_t *y,unsigned char scale) -{ - - simd256_q15_t xtmp[64],*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[64],*y256=(simd256_q15_t*)y; + simd256_q15_t ytmp[64],*y256=(simd256_q15_t *)y; simd256_q15_t *tw512_256p=(simd256_q15_t *)tw512,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - - - transpose4_ooff_simd256(x256 ,xtmp,32); + transpose4_ooff_simd256(x256,xtmp,32); transpose4_ooff_simd256(x256+2,xtmp+1,32); transpose4_ooff_simd256(x256+4,xtmp+2,32); transpose4_ooff_simd256(x256+6,xtmp+3,32); @@ -4111,23 +3486,20 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) transpose4_ooff_simd256(x256+58,xtmp+29,32); transpose4_ooff_simd256(x256+60,xtmp+30,32); transpose4_ooff_simd256(x256+62,xtmp+31,32); - - idft256((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft256((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); - + dft256((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft256((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); for (i=0; i<32; i++) { - ibfly2_256(ytmpp,ytmpp+32, - y256p,y256p+32, - tw512_256p); + bfly2_256(ytmpp,ytmpp+32, + y256p,y256p+32, + tw512_256p); tw512_256p++; y256p++; ytmpp++; } if (scale>0) { - - for (i=0;i<4;i++) { + for (i=0; i<4; i++) { y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); @@ -4147,7 +3519,80 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) y256+=16; } } +} +void idft512(int16_t *x,int16_t *y,unsigned char scale) { + simd256_q15_t xtmp[64],*x256 = (simd256_q15_t *)x; + simd256_q15_t ytmp[64],*y256=(simd256_q15_t *)y; + simd256_q15_t *tw512_256p=(simd256_q15_t *)tw512,*y256p=(simd256_q15_t *)y; + simd256_q15_t *ytmpp = &ytmp[0]; + int i; + simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); + transpose4_ooff_simd256(x256,xtmp,32); + transpose4_ooff_simd256(x256+2,xtmp+1,32); + transpose4_ooff_simd256(x256+4,xtmp+2,32); + transpose4_ooff_simd256(x256+6,xtmp+3,32); + transpose4_ooff_simd256(x256+8,xtmp+4,32); + transpose4_ooff_simd256(x256+10,xtmp+5,32); + transpose4_ooff_simd256(x256+12,xtmp+6,32); + transpose4_ooff_simd256(x256+14,xtmp+7,32); + transpose4_ooff_simd256(x256+16,xtmp+8,32); + transpose4_ooff_simd256(x256+18,xtmp+9,32); + transpose4_ooff_simd256(x256+20,xtmp+10,32); + transpose4_ooff_simd256(x256+22,xtmp+11,32); + transpose4_ooff_simd256(x256+24,xtmp+12,32); + transpose4_ooff_simd256(x256+26,xtmp+13,32); + transpose4_ooff_simd256(x256+28,xtmp+14,32); + transpose4_ooff_simd256(x256+30,xtmp+15,32); + transpose4_ooff_simd256(x256+32,xtmp+16,32); + transpose4_ooff_simd256(x256+34,xtmp+17,32); + transpose4_ooff_simd256(x256+36,xtmp+18,32); + transpose4_ooff_simd256(x256+38,xtmp+19,32); + transpose4_ooff_simd256(x256+40,xtmp+20,32); + transpose4_ooff_simd256(x256+42,xtmp+21,32); + transpose4_ooff_simd256(x256+44,xtmp+22,32); + transpose4_ooff_simd256(x256+46,xtmp+23,32); + transpose4_ooff_simd256(x256+48,xtmp+24,32); + transpose4_ooff_simd256(x256+50,xtmp+25,32); + transpose4_ooff_simd256(x256+52,xtmp+26,32); + transpose4_ooff_simd256(x256+54,xtmp+27,32); + transpose4_ooff_simd256(x256+56,xtmp+28,32); + transpose4_ooff_simd256(x256+58,xtmp+29,32); + transpose4_ooff_simd256(x256+60,xtmp+30,32); + transpose4_ooff_simd256(x256+62,xtmp+31,32); + idft256((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft256((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); + + for (i=0; i<32; i++) { + ibfly2_256(ytmpp,ytmpp+32, + y256p,y256p+32, + tw512_256p); + tw512_256p++; + y256p++; + ytmpp++; + } + + if (scale>0) { + for (i=0; i<4; i++) { + y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); + y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); + y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); + y256[3] = mulhi_int16_simd256(y256[3],ONE_OVER_SQRT2_Q15_256); + y256[4] = mulhi_int16_simd256(y256[4],ONE_OVER_SQRT2_Q15_256); + y256[5] = mulhi_int16_simd256(y256[5],ONE_OVER_SQRT2_Q15_256); + y256[6] = mulhi_int16_simd256(y256[6],ONE_OVER_SQRT2_Q15_256); + y256[7] = mulhi_int16_simd256(y256[7],ONE_OVER_SQRT2_Q15_256); + y256[8] = mulhi_int16_simd256(y256[8],ONE_OVER_SQRT2_Q15_256); + y256[9] = mulhi_int16_simd256(y256[9],ONE_OVER_SQRT2_Q15_256); + y256[10] = mulhi_int16_simd256(y256[10],ONE_OVER_SQRT2_Q15_256); + y256[11] = mulhi_int16_simd256(y256[11],ONE_OVER_SQRT2_Q15_256); + y256[12] = mulhi_int16_simd256(y256[12],ONE_OVER_SQRT2_Q15_256); + y256[13] = mulhi_int16_simd256(y256[13],ONE_OVER_SQRT2_Q15_256); + y256[14] = mulhi_int16_simd256(y256[14],ONE_OVER_SQRT2_Q15_256); + y256[15] = mulhi_int16_simd256(y256[15],ONE_OVER_SQRT2_Q15_256); + y256+=16; + } + } } #endif @@ -4155,9 +3600,7 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) int16_t tw1024[1536] __attribute__((aligned(32))); #ifndef __AVX2__ -void dft1024(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft1024(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[256],ytmp[256],*tw1024_128p=(simd_q15_t *)tw1024,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4166,11 +3609,10 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff(x128+i,xtmp+j,64); } - - dft256((int16_t*)(xtmp),(int16_t*)(ytmp),1); - dft256((int16_t*)(xtmp+64),(int16_t*)(ytmp+64),1); - dft256((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); - dft256((int16_t*)(xtmp+192),(int16_t*)(ytmp+192),1); + dft256((int16_t *)(xtmp),(int16_t *)(ytmp),1); + dft256((int16_t *)(xtmp+64),(int16_t *)(ytmp+64),1); + dft256((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); + dft256((int16_t *)(xtmp+192),(int16_t *)(ytmp+192),1); for (i=0; i<64; i++) { bfly4(ytmpp,ytmpp+64,ytmpp+128,ytmpp+192, @@ -4182,7 +3624,6 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - for (i=0; i<16; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -4200,20 +3641,15 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); - y128+=16; } - } _mm_empty(); _m_empty(); - } -void idft1024(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft1024(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[256],ytmp[256],*tw1024_128p=(simd_q15_t *)tw1024,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4222,11 +3658,10 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff(x128+i,xtmp+j,64); } - - idft256((int16_t*)(xtmp),(int16_t*)(ytmp),1); - idft256((int16_t*)(xtmp+64),(int16_t*)(ytmp+64),1); - idft256((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); - idft256((int16_t*)(xtmp+192),(int16_t*)(ytmp+192),1); + idft256((int16_t *)(xtmp),(int16_t *)(ytmp),1); + idft256((int16_t *)(xtmp+64),(int16_t *)(ytmp+64),1); + idft256((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); + idft256((int16_t *)(xtmp+192),(int16_t *)(ytmp+192),1); for (i=0; i<64; i++) { ibfly4(ytmpp,ytmpp+64,ytmpp+128,ytmpp+192, @@ -4238,7 +3673,6 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - for (i=0; i<16; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -4256,21 +3690,16 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); - y128+=16; } - } _mm_empty(); _m_empty(); - } #else //__AVX2__ -void dft1024(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft1024(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[128],ytmp[128],*tw1024_256p=(simd256_q15_t *)tw1024,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4279,23 +3708,21 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff_simd256(x256+i,xtmp+j,32); } - - dft256((int16_t*)(xtmp),(int16_t*)(ytmp),1); - dft256((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); - dft256((int16_t*)(xtmp+64),(int16_t*)(ytmp+64),1); - dft256((int16_t*)(xtmp+96),(int16_t*)(ytmp+96),1); + dft256((int16_t *)(xtmp),(int16_t *)(ytmp),1); + dft256((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); + dft256((int16_t *)(xtmp+64),(int16_t *)(ytmp+64),1); + dft256((int16_t *)(xtmp+96),(int16_t *)(ytmp+96),1); for (i=0; i<32; i++) { bfly4_256(ytmpp,ytmpp+32,ytmpp+64,ytmpp+96, - y256p,y256p+32,y256p+64,y256p+96, - tw1024_256p,tw1024_256p+32,tw1024_256p+64); + y256p,y256p+32,y256p+64,y256p+96, + tw1024_256p,tw1024_256p+32,tw1024_256p+64); tw1024_256p++; y256p++; ytmpp++; } if (scale>0) { - for (i=0; i<8; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -4313,20 +3740,15 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); - y256+=16; } - } _mm_empty(); _m_empty(); - } -void idft1024(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft1024(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[128],ytmp[128],*tw1024_256p=(simd256_q15_t *)tw1024,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4335,23 +3757,21 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff_simd256(x256+i,xtmp+j,32); } - - idft256((int16_t*)(xtmp),(int16_t*)(ytmp),1); - idft256((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); - idft256((int16_t*)(xtmp+64),(int16_t*)(ytmp+64),1); - idft256((int16_t*)(xtmp+96),(int16_t*)(ytmp+96),1); + idft256((int16_t *)(xtmp),(int16_t *)(ytmp),1); + idft256((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); + idft256((int16_t *)(xtmp+64),(int16_t *)(ytmp+64),1); + idft256((int16_t *)(xtmp+96),(int16_t *)(ytmp+96),1); for (i=0; i<32; i++) { ibfly4_256(ytmpp,ytmpp+32,ytmpp+64,ytmpp+96, - y256p,y256p+32,y256p+64,y256p+96, - tw1024_256p,tw1024_256p+32,tw1024_256p+64); + y256p,y256p+32,y256p+64,y256p+96, + tw1024_256p,tw1024_256p+32,tw1024_256p+64); tw1024_256p++; y256p++; ytmpp++; } if (scale>0) { - for (i=0; i<8; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -4369,34 +3789,28 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); - y256+=16; } - } _mm_empty(); _m_empty(); - } #endif int16_t tw2048[2048] __attribute__((aligned(32))); #ifndef __AVX2__ -void dft2048(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft2048(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[1024],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[512],*tw2048_128p=(simd_q15_t *)tw2048,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<16; i++) { - transpose4_ooff(x64 ,xtmpp,512); + transpose4_ooff(x64,xtmpp,512); transpose4_ooff(x64+2,xtmpp+1,512); transpose4_ooff(x64+4,xtmpp+2,512); transpose4_ooff(x64+6,xtmpp+3,512); @@ -4432,9 +3846,8 @@ void dft2048(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - dft1024((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft1024((int16_t*)(xtmp+512),(int16_t*)(ytmp+256),1); - + dft1024((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft1024((int16_t *)(xtmp+512),(int16_t *)(ytmp+256),1); for (i=0; i<256; i++) { bfly2(ytmpp,ytmpp+256, @@ -4471,23 +3884,17 @@ void dft2048(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - - } -void idft2048(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft2048(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[1024],*xtmpp,*x64 = (simdshort_q15_t *)x; - simd_q15_t ytmp[512],*tw2048_128p=(simd_q15_t *)tw2048,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; - simd_q15_t *ytmpp = &ytmp[0]; + simd_q15_t ytmp[512],*tw2048_128p=(simd_q15_t *)tw2048,*y128=(simd_q15_t *)y; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<16; i++) { - transpose4_ooff(x64 ,xtmpp,512); + transpose4_ooff(x64,xtmpp,512); transpose4_ooff(x64+2,xtmpp+1,512); transpose4_ooff(x64+4,xtmpp+2,512); transpose4_ooff(x64+6,xtmpp+3,512); @@ -4523,17 +3930,23 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - idft1024((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft1024((int16_t*)(xtmp+512),(int16_t*)(ytmp+256),1); + idft1024((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft1024((int16_t *)(xtmp+512),(int16_t *)(ytmp+256),1); - - for (i=0; i<256; i++) { - ibfly2(ytmpp,ytmpp+256, - y128p,y128p+256, + for (i=0, + simd_q15_t y128p=(simd_q15_t *)y, + simd_q15_t y128p256=((simd_q15_t *)y)+256, + simd_q15_t *ytmpp = ytmp, + simd_q15_t *ytmpp256= ytmp+256 ; + ; i<256; i++) { + ibfly2(ytmpp,ytmpp256, + y128p,y128p256, tw2048_128p); tw2048_128p++; y128p++; + y128p256++; ytmpp++; + ytmpp256++; } if (scale>0) { @@ -4562,25 +3975,18 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } #else // __AVX2__ -void dft2048(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft2048(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[256],*xtmpp,*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[256],*tw2048_256p=(simd256_q15_t *)tw2048,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; - simd256_q15_t *ytmpp = &ytmp[0]; - int i; + simd256_q15_t ytmp[256],*tw2048_256p=(simd256_q15_t *)tw2048,*y256=(simd256_q15_t *)y; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - - xtmpp = xtmp; - for (i=0; i<4; i++) { - transpose4_ooff_simd256(x256 ,xtmpp,128); + for (int i=0; i<4; i++) { + transpose4_ooff_simd256(x256,xtmpp,128); transpose4_ooff_simd256(x256+2,xtmpp+1,128); transpose4_ooff_simd256(x256+4,xtmpp+2,128); transpose4_ooff_simd256(x256+6,xtmpp+3,128); @@ -4616,17 +4022,17 @@ void dft2048(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - dft1024((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft1024((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); + dft1024((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft1024((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); + simd256_q15_t *y256p=(simd256_q15_t *)y; + simd256_q15_t *y256p128=y256p+128; + simd256_q15_t *ytmpp = ytmp; + simd256_q15_t *ytmpp128 = ytmp+128; - - for (i=0; i<128; i++) { - bfly2_256(ytmpp,ytmpp+128, - y256p,y256p+128, - tw2048_256p); - tw2048_256p++; - y256p++; - ytmpp++; + for (int i=0; i<128; i++) { + bfly2_256(ytmpp++,ytmpp128++, + y256p++,y256p128++, + tw2048_256p++); } if (scale>0) { @@ -4655,22 +4061,17 @@ void dft2048(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } -void idft2048(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft2048(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[256],*xtmpp,*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[256],*tw2048_256p=(simd256_q15_t *)tw2048,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; - simd256_q15_t *ytmpp = &ytmp[0]; + simd256_q15_t ytmp[256],*tw2048_256p=(simd256_q15_t *)tw2048,*y256=(simd256_q15_t *)y; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; - + for (i=0; i<4; i++) { - transpose4_ooff_simd256(x256 ,xtmpp,128); + transpose4_ooff_simd256(x256,xtmpp,128); transpose4_ooff_simd256(x256+2,xtmpp+1,128); transpose4_ooff_simd256(x256+4,xtmpp+2,128); transpose4_ooff_simd256(x256+6,xtmpp+3,128); @@ -4706,21 +4107,23 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - idft1024((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft1024((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); + idft1024((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft1024((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); + { + simd256_q15_t *y256p=(simd256_q15_t *)y; + simd256_q15_t *y256p128=y256p+128; + simd256_q15_t *ytmpp = ytmp; + simd256_q15_t *ytmpp128 = ytmp+128; - - for (i=0; i<128; i++) { - ibfly2_256(ytmpp,ytmpp+128, - y256p,y256p+128, - tw2048_256p); - tw2048_256p++; - y256p++; - ytmpp++; + for (i=0; i<128; i++) { + ibfly2_256(ytmpp++,ytmpp128++, + y256p++,y256p128++, + tw2048_256p++); + } } if (scale>0) { - y256p = y256; + simd256_q15_t *y256p = y256; for (i=0; i<16; i++) { y256p[0] = mulhi_int16_simd256(y256p[0],ONE_OVER_SQRT2_Q15_128); @@ -4745,7 +4148,6 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } #endif @@ -4755,9 +4157,7 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) int16_t tw4096[3*2*1024]; #ifndef __AVX2__ -void dft4096(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft4096(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[1024],ytmp[1024],*tw4096_128p=(simd_q15_t *)tw4096,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4766,11 +4166,10 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff(x128+i,xtmp+j,256); } - - dft1024((int16_t*)(xtmp),(int16_t*)(ytmp),1); - dft1024((int16_t*)(xtmp+256),(int16_t*)(ytmp+256),1); - dft1024((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); - dft1024((int16_t*)(xtmp+768),(int16_t*)(ytmp+768),1); + dft1024((int16_t *)(xtmp),(int16_t *)(ytmp),1); + dft1024((int16_t *)(xtmp+256),(int16_t *)(ytmp+256),1); + dft1024((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); + dft1024((int16_t *)(xtmp+768),(int16_t *)(ytmp+768),1); for (i=0; i<256; i++) { bfly4(ytmpp,ytmpp+256,ytmpp+512,ytmpp+768, @@ -4782,7 +4181,6 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - for (i=0; i<64; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -4800,22 +4198,17 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); - y128+=16; } - } _mm_empty(); _m_empty(); - } - -void idft4096(int16_t *x,int16_t *y,unsigned char scale) -{ +void idft4096(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[1024],ytmp[1024],*tw4096_128p=(simd_q15_t *)tw4096,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4824,11 +4217,10 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff(x128+i,xtmp+j,256); } - - idft1024((int16_t*)(xtmp),(int16_t*)(ytmp),1); - idft1024((int16_t*)(xtmp+256),(int16_t*)(ytmp+256),1); - idft1024((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); - idft1024((int16_t*)(xtmp+768),(int16_t*)(ytmp+768),1); + idft1024((int16_t *)(xtmp),(int16_t *)(ytmp),1); + idft1024((int16_t *)(xtmp+256),(int16_t *)(ytmp+256),1); + idft1024((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); + idft1024((int16_t *)(xtmp+768),(int16_t *)(ytmp+768),1); for (i=0; i<256; i++) { ibfly4(ytmpp,ytmpp+256,ytmpp+512,ytmpp+768, @@ -4840,7 +4232,6 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - for (i=0; i<64; i++) { y128[0] = shiftright_int16(y128[0],scale); y128[1] = shiftright_int16(y128[1],scale); @@ -4858,21 +4249,16 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],scale); y128[14] = shiftright_int16(y128[14],scale); y128[15] = shiftright_int16(y128[15],scale); - y128+=16; } - } _mm_empty(); _m_empty(); - } #else //__AVX2__ -void dft4096(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft4096(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[512],ytmp[512],*tw4096_256p=(simd256_q15_t *)tw4096,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4881,23 +4267,21 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff_simd256(x256+i,xtmp+j,128); } - - dft1024((int16_t*)(xtmp),(int16_t*)(ytmp),1); - dft1024((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); - dft1024((int16_t*)(xtmp+256),(int16_t*)(ytmp+256),1); - dft1024((int16_t*)(xtmp+384),(int16_t*)(ytmp+384),1); + dft1024((int16_t *)(xtmp),(int16_t *)(ytmp),1); + dft1024((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); + dft1024((int16_t *)(xtmp+256),(int16_t *)(ytmp+256),1); + dft1024((int16_t *)(xtmp+384),(int16_t *)(ytmp+384),1); for (i=0; i<128; i++) { bfly4_256(ytmpp,ytmpp+128,ytmpp+256,ytmpp+384, - y256p,y256p+128,y256p+256,y256p+384, - tw4096_256p,tw4096_256p+128,tw4096_256p+256); + y256p,y256p+128,y256p+256,y256p+384, + tw4096_256p,tw4096_256p+128,tw4096_256p+256); tw4096_256p++; y256p++; ytmpp++; } if (scale>0) { - for (i=0; i<32; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -4915,20 +4299,15 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); - y256+=16; } - } _mm_empty(); _m_empty(); - } -void idft4096(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft4096(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[512],ytmp[512],*tw4096_256p=(simd256_q15_t *)tw4096,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4937,23 +4316,21 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff_simd256(x256+i,xtmp+j,128); } - - idft1024((int16_t*)(xtmp),(int16_t*)(ytmp),1); - idft1024((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); - idft1024((int16_t*)(xtmp+256),(int16_t*)(ytmp+256),1); - idft1024((int16_t*)(xtmp+384),(int16_t*)(ytmp+384),1); + idft1024((int16_t *)(xtmp),(int16_t *)(ytmp),1); + idft1024((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); + idft1024((int16_t *)(xtmp+256),(int16_t *)(ytmp+256),1); + idft1024((int16_t *)(xtmp+384),(int16_t *)(ytmp+384),1); for (i=0; i<128; i++) { ibfly4_256(ytmpp,ytmpp+128,ytmpp+256,ytmpp+384, - y256p,y256p+128,y256p+256,y256p+384, - tw4096_256p,tw4096_256p+128,tw4096_256p+256); + y256p,y256p+128,y256p+256,y256p+384, + tw4096_256p,tw4096_256p+128,tw4096_256p+256); tw4096_256p++; y256p++; ytmpp++; } if (scale>0) { - for (i=0; i<32; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -4971,15 +4348,12 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); - y256+=16; } - } _mm_empty(); _m_empty(); - } #endif //__AVX2__ @@ -4988,19 +4362,16 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) int16_t tw8192[2*4096] __attribute__((aligned(32))); #ifndef __AVX2__ -void dft8192(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft8192(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[4096],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[1024],*tw8192_128p=(simd_q15_t *)tw8192,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<64; i++) { - transpose4_ooff(x64 ,xtmpp,2048); + transpose4_ooff(x64,xtmpp,2048); transpose4_ooff(x64+2,xtmpp+1,2048); transpose4_ooff(x64+4,xtmpp+2,2048); transpose4_ooff(x64+6,xtmpp+3,2048); @@ -5036,9 +4407,8 @@ void dft8192(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - dft4096((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+1024),1); - + dft4096((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft4096((int16_t *)(xtmp+2048),(int16_t *)(ytmp+1024),1); for (i=0; i<1024; i++) { bfly2(ytmpp,ytmpp+1024, @@ -5075,22 +4445,18 @@ void dft8192(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } -void idft8192(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft8192(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[4096],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[2048],*tw8192_128p=(simd_q15_t *)tw8192,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<64; i++) { - transpose4_ooff(x64 ,xtmpp,2048); + transpose4_ooff(x64,xtmpp,2048); transpose4_ooff(x64+2,xtmpp+1,2048); transpose4_ooff(x64+4,xtmpp+2,2048); transpose4_ooff(x64+6,xtmpp+3,2048); @@ -5126,9 +4492,8 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - idft4096((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+1024),1); - + idft4096((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft4096((int16_t *)(xtmp+2048),(int16_t *)(ytmp+1024),1); for (i=0; i<1024; i++) { ibfly2(ytmpp,ytmpp+1024, @@ -5165,24 +4530,19 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } #else // __AVX2__ -void dft8192(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft8192(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[1024],*xtmpp,*x256 = (simd256_q15_t *)x; simd256_q15_t ytmp[1024],*tw8192_256p=(simd256_q15_t *)tw8192,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; - simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<16; i++) { - transpose4_ooff_simd256(x256 ,xtmpp,512); + transpose4_ooff_simd256(x256,xtmpp,512); transpose4_ooff_simd256(x256+2,xtmpp+1,512); transpose4_ooff_simd256(x256+4,xtmpp+2,512); transpose4_ooff_simd256(x256+6,xtmpp+3,512); @@ -5218,14 +4578,13 @@ void dft8192(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - dft4096((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); - + dft4096((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft4096((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); for (i=0; i<512; i++) { bfly2_256(ytmpp,ytmpp+512, - y256p,y256p+512, - tw8192_256p); + y256p,y256p+512, + tw8192_256p); tw8192_256p++; y256p++; ytmpp++; @@ -5257,22 +4616,18 @@ void dft8192(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } -void idft8192(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft8192(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[1024],*xtmpp,*x256 = (simd256_q15_t *)x; simd256_q15_t ytmp[1024],*tw8192_256p=(simd256_q15_t *)tw8192,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<16; i++) { - transpose4_ooff_simd256(x256 ,xtmpp,512); + transpose4_ooff_simd256(x256,xtmpp,512); transpose4_ooff_simd256(x256+2,xtmpp+1,512); transpose4_ooff_simd256(x256+4,xtmpp+2,512); transpose4_ooff_simd256(x256+6,xtmpp+3,512); @@ -5308,14 +4663,13 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - idft4096((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); - + idft4096((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft4096((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); for (i=0; i<512; i++) { ibfly2_256(ytmpp,ytmpp+512, - y256p,y256p+512, - tw8192_256p); + y256p,y256p+512, + tw8192_256p); tw8192_256p++; y256p++; ytmpp++; @@ -5347,7 +4701,6 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } @@ -5356,9 +4709,7 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) int16_t tw16384[3*2*4096]; #ifndef __AVX2__ -void dft16384(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft16384(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[4096],ytmp[4096],*tw16384_128p=(simd_q15_t *)tw16384,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -5367,11 +4718,10 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff(x128+i,xtmp+j,1024); } - - dft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1); - dft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1); - dft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1); - dft4096((int16_t*)(xtmp+3072),(int16_t*)(ytmp+3072),1); + dft4096((int16_t *)(xtmp),(int16_t *)(ytmp),1); + dft4096((int16_t *)(xtmp+1024),(int16_t *)(ytmp+1024),1); + dft4096((int16_t *)(xtmp+2048),(int16_t *)(ytmp+2048),1); + dft4096((int16_t *)(xtmp+3072),(int16_t *)(ytmp+3072),1); for (i=0; i<1024; i++) { bfly4(ytmpp,ytmpp+1024,ytmpp+2048,ytmpp+3072, @@ -5383,7 +4733,6 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - for (i=0; i<256; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -5401,22 +4750,17 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); - y128+=16; } - } _mm_empty(); _m_empty(); - } - -void idft16384(int16_t *x,int16_t *y,unsigned char scale) -{ +void idft16384(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[4096],ytmp[4096],*tw16384_128p=(simd_q15_t *)tw16384,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -5425,11 +4769,10 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff(x128+i,xtmp+j,1024); } - - idft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1); - idft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1); - idft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1); - idft4096((int16_t*)(xtmp+3072),(int16_t*)(ytmp+3072),1); + idft4096((int16_t *)(xtmp),(int16_t *)(ytmp),1); + idft4096((int16_t *)(xtmp+1024),(int16_t *)(ytmp+1024),1); + idft4096((int16_t *)(xtmp+2048),(int16_t *)(ytmp+2048),1); + idft4096((int16_t *)(xtmp+3072),(int16_t *)(ytmp+3072),1); for (i=0; i<1024; i++) { ibfly4(ytmpp,ytmpp+1024,ytmpp+2048,ytmpp+3072, @@ -5441,7 +4784,6 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) } if (scale>0) { - for (i=0; i<256; i++) { y128[0] = shiftright_int16(y128[0],scale); y128[1] = shiftright_int16(y128[1],scale); @@ -5459,21 +4801,16 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) y128[13] = shiftright_int16(y128[13],scale); y128[14] = shiftright_int16(y128[14],scale); y128[15] = shiftright_int16(y128[15],scale); - y128+=16; } - } _mm_empty(); _m_empty(); - } #else //__AVX2__ -void dft16384(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft16384(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[2048],ytmp[2048],*tw16384_256p=(simd256_q15_t *)tw16384,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -5482,23 +4819,21 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff_simd256(x256+i,xtmp+j,512); } - - dft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1); - dft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); - dft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1); - dft4096((int16_t*)(xtmp+1536),(int16_t*)(ytmp+1536),1); + dft4096((int16_t *)(xtmp),(int16_t *)(ytmp),1); + dft4096((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); + dft4096((int16_t *)(xtmp+1024),(int16_t *)(ytmp+1024),1); + dft4096((int16_t *)(xtmp+1536),(int16_t *)(ytmp+1536),1); for (i=0; i<512; i++) { bfly4_256(ytmpp,ytmpp+512,ytmpp+1024,ytmpp+1536, - y256p,y256p+512,y256p+1024,y256p+1536, - tw16384_256p,tw16384_256p+512,tw16384_256p+1024); + y256p,y256p+512,y256p+1024,y256p+1536, + tw16384_256p,tw16384_256p+512,tw16384_256p+1024); tw16384_256p++; y256p++; ytmpp++; } if (scale>0) { - for (i=0; i<128; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -5516,20 +4851,15 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); - y256+=16; } - } _mm_empty(); _m_empty(); - } -void idft16384(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft16384(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[2048],ytmp[2048],*tw16384_256p=(simd256_q15_t *)tw16384,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -5538,23 +4868,21 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) transpose16_ooff_simd256(x256+i,xtmp+j,512); } - - idft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1); - idft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); - idft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1); - idft4096((int16_t*)(xtmp+1536),(int16_t*)(ytmp+1536),1); + idft4096((int16_t *)(xtmp),(int16_t *)(ytmp),1); + idft4096((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); + idft4096((int16_t *)(xtmp+1024),(int16_t *)(ytmp+1024),1); + idft4096((int16_t *)(xtmp+1536),(int16_t *)(ytmp+1536),1); for (i=0; i<512; i++) { ibfly4_256(ytmpp,ytmpp+512,ytmpp+1024,ytmpp+1536, - y256p,y256p+512,y256p+1024,y256p+1536, - tw16384_256p,tw16384_256p+512,tw16384_256p+1024); + y256p,y256p+512,y256p+1024,y256p+1536, + tw16384_256p,tw16384_256p+512,tw16384_256p+1024); tw16384_256p++; y256p++; ytmpp++; } if (scale>0) { - for (i=0; i<128; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -5572,15 +4900,12 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); - y256+=16; } - } _mm_empty(); _m_empty(); - } #endif //__AVX2__ @@ -5588,19 +4913,16 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) int16_t tw32768[2*16384] __attribute__((aligned(32))); #ifndef __AVX2__ -void dft32768(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft32768(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[16384],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[8192],*tw32768_128p=(simd_q15_t *)tw32768,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<256; i++) { - transpose4_ooff(x64 ,xtmpp,8192); + transpose4_ooff(x64,xtmpp,8192); transpose4_ooff(x64+2,xtmpp+1,8192); transpose4_ooff(x64+4,xtmpp+2,8192); transpose4_ooff(x64+6,xtmpp+3,8192); @@ -5636,9 +4958,8 @@ void dft32768(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - dft16384((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft16384((int16_t*)(xtmp+8192),(int16_t*)(ytmp+4096),1); - + dft16384((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft16384((int16_t *)(xtmp+8192),(int16_t *)(ytmp+4096),1); for (i=0; i<4096; i++) { bfly2(ytmpp,ytmpp+4096, @@ -5675,22 +4996,18 @@ void dft32768(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } -void idft32768(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft32768(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[16384],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[8192],*tw32768_128p=(simd_q15_t *)tw32768,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<256; i++) { - transpose4_ooff(x64 ,xtmpp,8192); + transpose4_ooff(x64,xtmpp,8192); transpose4_ooff(x64+2,xtmpp+1,8192); transpose4_ooff(x64+4,xtmpp+2,8192); transpose4_ooff(x64+6,xtmpp+3,8192); @@ -5726,9 +5043,8 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - idft16384((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft16384((int16_t*)(xtmp+8192),(int16_t*)(ytmp+4096),1); - + idft16384((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft16384((int16_t *)(xtmp+8192),(int16_t *)(ytmp+4096),1); for (i=0; i<4096; i++) { ibfly2(ytmpp,ytmpp+4096, @@ -5765,24 +5081,19 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } #else // __AVX2__ -void dft32768(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft32768(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[4096],*xtmpp,*x256 = (simd256_q15_t *)x; simd256_q15_t ytmp[4096],*tw32768_256p=(simd256_q15_t *)tw32768,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; - simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<256; i++) { - transpose4_ooff_simd256(x256 ,xtmpp,2048); + transpose4_ooff_simd256(x256,xtmpp,2048); transpose4_ooff_simd256(x256+2,xtmpp+1,2048); transpose4_ooff_simd256(x256+4,xtmpp+2,2048); transpose4_ooff_simd256(x256+6,xtmpp+3,2048); @@ -5818,14 +5129,13 @@ void dft32768(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - dft16384((int16_t*)(xtmp),(int16_t*)ytmp,1); - dft16384((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1); - + dft16384((int16_t *)(xtmp),(int16_t *)ytmp,1); + dft16384((int16_t *)(xtmp+2048),(int16_t *)(ytmp+2048),1); for (i=0; i<2048; i++) { bfly2_256(ytmpp,ytmpp+2048, - y256p,y256p+2048, - tw32768_256p); + y256p,y256p+2048, + tw32768_256p); tw32768_256p++; y256p++; ytmpp++; @@ -5857,22 +5167,18 @@ void dft32768(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } -void idft32768(int16_t *x,int16_t *y,unsigned char scale) -{ - +void idft32768(int16_t *x,int16_t *y,unsigned char scale) { simd256_q15_t xtmp[4096],*xtmpp,*x256 = (simd256_q15_t *)x; simd256_q15_t ytmp[4096],*tw32768_256p=(simd256_q15_t *)tw32768,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; for (i=0; i<64; i++) { - transpose4_ooff_simd256(x256 ,xtmpp,2048); + transpose4_ooff_simd256(x256,xtmpp,2048); transpose4_ooff_simd256(x256+2,xtmpp+1,2048); transpose4_ooff_simd256(x256+4,xtmpp+2,2048); transpose4_ooff_simd256(x256+6,xtmpp+3,2048); @@ -5908,14 +5214,13 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) xtmpp+=32; } - idft16384((int16_t*)(xtmp),(int16_t*)ytmp,1); - idft16384((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1); - + idft16384((int16_t *)(xtmp),(int16_t *)ytmp,1); + idft16384((int16_t *)(xtmp+2048),(int16_t *)(ytmp+2048),1); for (i=0; i<2048; i++) { ibfly2_256(ytmpp,ytmpp+2048, - y256p,y256p+2048, - tw32768_256p); + y256p,y256p+2048, + tw32768_256p); tw32768_256p++; y256p++; ytmpp++; @@ -5947,7 +5252,6 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) _mm_empty(); _m_empty(); - } @@ -5957,12 +5261,11 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) int16_t twa1536[1024],twb1536[1024]; // 512 x 3 -void idft1536(int16_t *input, int16_t *output, unsigned char scale) -{ +void idft1536(int16_t *input, int16_t *output, unsigned char scale) { int i,i2,j; uint32_t tmp[3][512 ]__attribute__((aligned(32))); uint32_t tmpo[3][512] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<512; i++) { @@ -5971,17 +5274,16 @@ void idft1536(int16_t *input, int16_t *output, unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - idft512((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - idft512((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - idft512((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + idft512((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + idft512((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + idft512((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); for (i=0,i2=0; i<1024; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+1024+i),(simd_q15_t*)(output+2048+i), - (simd_q15_t*)(twa1536+i),(simd_q15_t*)(twb1536+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+1024+i),(simd_q15_t *)(output+2048+i), + (simd_q15_t *)(twa1536+i),(simd_q15_t *)(twb1536+i)); } - if (scale==1) { for (i=0; i<24; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6006,15 +5308,13 @@ void idft1536(int16_t *input, int16_t *output, unsigned char scale) _mm_empty(); _m_empty(); - } -void dft1536(int16_t *input, int16_t *output, unsigned char scale) -{ +void dft1536(int16_t *input, int16_t *output, unsigned char scale) { int i,i2,j; uint32_t tmp[3][512] __attribute__((aligned(32))); uint32_t tmpo[3][512] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<512; i++) { @@ -6023,9 +5323,9 @@ void dft1536(int16_t *input, int16_t *output, unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - dft512((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - dft512((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - dft512((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + dft512((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + dft512((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + dft512((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); /* for (i=1; i<512; i++) { @@ -6038,10 +5338,11 @@ void dft1536(int16_t *input, int16_t *output, unsigned char scale) LOG_M("dft1536out1.m","o1",tmpo[1],2048,1,1); LOG_M("dft1536out2.m","o2",tmpo[2],2048,1,1); } + for (i=0,i2=0; i<1024; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+1024+i),(simd_q15_t*)(output+2048+i), - (simd_q15_t*)(twa1536+i),(simd_q15_t*)(twb1536+i)); + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+1024+i),(simd_q15_t *)(output+2048+i), + (simd_q15_t *)(twa1536+i),(simd_q15_t *)(twb1536+i)); } if (scale==1) { @@ -6068,18 +5369,16 @@ void dft1536(int16_t *input, int16_t *output, unsigned char scale) _mm_empty(); _m_empty(); - } int16_t twa3072[2048] __attribute__((aligned(32))); int16_t twb3072[2048] __attribute__((aligned(32))); // 1024 x 3 -void dft3072(int16_t *input, int16_t *output,unsigned char scale) -{ +void dft3072(int16_t *input, int16_t *output,unsigned char scale) { int i,i2,j; uint32_t tmp[3][1024] __attribute__((aligned(32))); uint32_t tmpo[3][1024] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<1024; i++) { @@ -6088,14 +5387,14 @@ void dft3072(int16_t *input, int16_t *output,unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - dft1024((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - dft1024((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - dft1024((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + dft1024((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + dft1024((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + dft1024((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); for (i=0,i2=0; i<2048; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+2048+i),(simd_q15_t*)(output+4096+i), - (simd_q15_t*)(twa3072+i),(simd_q15_t*)(twb3072+i)); + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+2048+i),(simd_q15_t *)(output+4096+i), + (simd_q15_t *)(twa3072+i),(simd_q15_t *)(twb3072+i)); } if (scale==1) { @@ -6124,12 +5423,11 @@ void dft3072(int16_t *input, int16_t *output,unsigned char scale) _m_empty(); } -void idft3072(int16_t *input, int16_t *output,unsigned char scale) -{ +void idft3072(int16_t *input, int16_t *output,unsigned char scale) { int i,i2,j; uint32_t tmp[3][1024]__attribute__((aligned(32))); uint32_t tmpo[3][1024] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<1024; i++) { @@ -6137,17 +5435,17 @@ void idft3072(int16_t *input, int16_t *output,unsigned char scale) tmp[1][i] = ((uint32_t *)input)[j++]; tmp[2][i] = ((uint32_t *)input)[j++]; } - idft1024((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - idft1024((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - idft1024((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + + idft1024((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + idft1024((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + idft1024((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); for (i=0,i2=0; i<2048; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+2048+i),(simd_q15_t*)(output+4096+i), - (simd_q15_t*)(twa3072+i),(simd_q15_t*)(twb3072+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+2048+i),(simd_q15_t *)(output+4096+i), + (simd_q15_t *)(twa3072+i),(simd_q15_t *)(twb3072+i)); } - if (scale==1) { for (i=0; i<48; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6178,12 +5476,11 @@ void idft3072(int16_t *input, int16_t *output,unsigned char scale) int16_t twa6144[4096] __attribute__((aligned(32))); int16_t twb6144[4096] __attribute__((aligned(32))); -void idft6144(int16_t *input, int16_t *output,unsigned char scale) -{ +void idft6144(int16_t *input, int16_t *output,unsigned char scale) { int i,i2,j; uint32_t tmp[3][2048] __attribute__((aligned(32))); uint32_t tmpo[3][2048] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<2048; i++) { @@ -6192,9 +5489,9 @@ void idft6144(int16_t *input, int16_t *output,unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - idft2048((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - idft2048((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - idft2048((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + idft2048((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + idft2048((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + idft2048((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("idft6144in.m","in",input,6144,1,1); @@ -6204,12 +5501,11 @@ void idft6144(int16_t *input, int16_t *output,unsigned char scale) } for (i=0,i2=0; i<4096; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+4096+i),(simd_q15_t*)(output+8192+i), - (simd_q15_t*)(twa6144+i),(simd_q15_t*)(twb6144+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+4096+i),(simd_q15_t *)(output+8192+i), + (simd_q15_t *)(twa6144+i),(simd_q15_t *)(twb6144+i)); } - if (scale==1) { for (i=0; i<96; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6234,16 +5530,14 @@ void idft6144(int16_t *input, int16_t *output,unsigned char scale) _mm_empty(); _m_empty(); - } -void dft6144(int16_t *input, int16_t *output,unsigned char scale) -{ +void dft6144(int16_t *input, int16_t *output,unsigned char scale) { int i,i2,j; uint32_t tmp[3][2048] __attribute__((aligned(32))); uint32_t tmpo[3][2048] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<2048; i++) { @@ -6252,9 +5546,9 @@ void dft6144(int16_t *input, int16_t *output,unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - dft2048((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - dft2048((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - dft2048((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + dft2048((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + dft2048((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + dft2048((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); /* for (i=1; i<2048; i++) { @@ -6267,10 +5561,11 @@ void dft6144(int16_t *input, int16_t *output,unsigned char scale) LOG_M("ft6144out1.m","o1",tmpo[1],2048,1,1); LOG_M("ft6144out2.m","o2",tmpo[2],2048,1,1); } + for (i=0,i2=0; i<4096; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+4096+i),(simd_q15_t*)(output+8192+i), - (simd_q15_t*)(twa6144+i),(simd_q15_t*)(twb6144+i)); + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+4096+i),(simd_q15_t *)(output+8192+i), + (simd_q15_t *)(twa6144+i),(simd_q15_t *)(twb6144+i)); } if (scale==1) { @@ -6294,33 +5589,30 @@ void dft6144(int16_t *input, int16_t *output,unsigned char scale) y128p+=16; } } + _mm_empty(); _m_empty(); - } int16_t twa9216[6144] __attribute__((aligned(32))); int16_t twb9216[6144] __attribute__((aligned(32))); // 3072 x 3 void dft9216(int16_t *input, int16_t *output,uint8_t scale) { - AssertFatal(1==0,"Need to do this ..\n"); } void idft9216(int16_t *input, int16_t *output,uint8_t scale) { - AssertFatal(1==0,"Need to do this ..\n"); } int16_t twa12288[8192] __attribute__((aligned(32))); int16_t twb12288[8192] __attribute__((aligned(32))); // 4096 x 3 -void dft12288(int16_t *input, int16_t *output,unsigned char scale) -{ +void dft12288(int16_t *input, int16_t *output,unsigned char scale) { int i,i2,j; uint32_t tmp[3][4096] __attribute__((aligned(32))); uint32_t tmpo[3][4096] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<4096; i++) { @@ -6329,9 +5621,10 @@ void dft12288(int16_t *input, int16_t *output,unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - dft4096((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),scale); - dft4096((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),scale); - dft4096((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),scale); + dft4096((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),scale); + dft4096((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),scale); + dft4096((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),scale); + /* for (i=1; i<4096; i++) { tmpo[0][i] = tmpo[0][i<<1]; @@ -6343,10 +5636,11 @@ void dft12288(int16_t *input, int16_t *output,unsigned char scale) LOG_M("dft12288out1.m","o1",tmpo[1],4096,1,1); LOG_M("dft12288out2.m","o2",tmpo[2],4096,1,1); } + for (i=0,i2=0; i<8192; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+8192+i),(simd_q15_t*)(output+16384+i), - (simd_q15_t*)(twa12288+i),(simd_q15_t*)(twb12288+i)); + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+8192+i),(simd_q15_t *)(output+16384+i), + (simd_q15_t *)(twa12288+i),(simd_q15_t *)(twb12288+i)); } if (scale==1) { @@ -6370,17 +5664,16 @@ void dft12288(int16_t *input, int16_t *output,unsigned char scale) y128p+=16; } } + _mm_empty(); _m_empty(); - } -void idft12288(int16_t *input, int16_t *output,unsigned char scale) -{ +void idft12288(int16_t *input, int16_t *output,unsigned char scale) { int i,i2,j; uint32_t tmp[3][4096] __attribute__((aligned(32))); uint32_t tmpo[3][4096] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<4096; i++) { @@ -6389,11 +5682,9 @@ void idft12288(int16_t *input, int16_t *output,unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - - - idft4096((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),scale); - idft4096((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),scale); - idft4096((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),scale); + idft4096((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),scale); + idft4096((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),scale); + idft4096((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),scale); if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("idft12288in.m","in",input,12288,1,1); @@ -6403,9 +5694,9 @@ void idft12288(int16_t *input, int16_t *output,unsigned char scale) } for (i=0,i2=0; i<8192; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+8192+i),(simd_q15_t*)(output+16384+i), - (simd_q15_t*)(twa12288+i),(simd_q15_t*)(twb12288+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+8192+i),(simd_q15_t *)(output+16384+i), + (simd_q15_t *)(twa12288+i),(simd_q15_t *)(twb12288+i)); } if (scale==1) { @@ -6429,10 +5720,12 @@ void idft12288(int16_t *input, int16_t *output,unsigned char scale) y128p+=16; } } + _mm_empty(); _m_empty(); + if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("idft12288out.m","out",output,6144,1,1); + LOG_M("idft12288out.m","out",output,6144,1,1); } } @@ -6440,11 +5733,10 @@ int16_t twa18432[12288] __attribute__((aligned(32))); int16_t twb18432[12288] __attribute__((aligned(32))); // 6144 x 3 void dft18432(int16_t *input, int16_t *output,unsigned char scale) { - int i,i2,j; uint32_t tmp[3][6144] __attribute__((aligned(32))); uint32_t tmpo[3][6144] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<6144; i++) { @@ -6453,15 +5745,16 @@ void dft18432(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft6144((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),scale); - dft6144((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),scale); - dft6144((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),scale); + dft6144((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),scale); + dft6144((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),scale); + dft6144((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),scale); for (i=0,i2=0; i<12288; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+12288+i),(simd_q15_t*)(output+24576+i), - (simd_q15_t*)(twa18432+i),(simd_q15_t*)(twb18432+i)); + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+12288+i),(simd_q15_t *)(output+24576+i), + (simd_q15_t *)(twa18432+i),(simd_q15_t *)(twb18432+i)); } + if (scale==1) { for (i=0; i<288; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6483,16 +5776,16 @@ void dft18432(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } + _mm_empty(); _m_empty(); } void idft18432(int16_t *input, int16_t *output,unsigned char scale) { - int i,i2,j; uint32_t tmp[3][6144] __attribute__((aligned(32))); uint32_t tmpo[3][6144] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<6144; i++) { @@ -6501,15 +5794,16 @@ void idft18432(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft6144((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),scale); - idft6144((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),scale); - idft6144((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),scale); + idft6144((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),scale); + idft6144((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),scale); + idft6144((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),scale); for (i=0,i2=0; i<12288; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+12288+i),(simd_q15_t*)(output+24576+i), - (simd_q15_t*)(twa18432+i),(simd_q15_t*)(twb18432+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+12288+i),(simd_q15_t *)(output+24576+i), + (simd_q15_t *)(twa18432+i),(simd_q15_t *)(twb18432+i)); } + if (scale==1) { for (i=0; i<288; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6531,6 +5825,7 @@ void idft18432(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } + _mm_empty(); _m_empty(); } @@ -6539,12 +5834,11 @@ void idft18432(int16_t *input, int16_t *output,unsigned char scale) { int16_t twa24576[16384] __attribute__((aligned(32))); int16_t twb24576[16384] __attribute__((aligned(32))); // 8192 x 3 -void dft24576(int16_t *input, int16_t *output,unsigned char scale) -{ +void dft24576(int16_t *input, int16_t *output,unsigned char scale) { int i,i2,j; uint32_t tmp[3][8192] __attribute__((aligned(32))); uint32_t tmpo[3][8192] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<8192; i++) { @@ -6553,9 +5847,10 @@ void dft24576(int16_t *input, int16_t *output,unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - dft8192((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - dft8192((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - dft8192((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + dft8192((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + dft8192((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + dft8192((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + /* for (i=1; i<8192; i++) { tmpo[0][i] = tmpo[0][i<<1]; @@ -6567,12 +5862,12 @@ void dft24576(int16_t *input, int16_t *output,unsigned char scale) LOG_M("dft24576out1.m","o1",tmpo[1],8192,1,1); LOG_M("dft24576out2.m","o2",tmpo[2],8192,1,1); } - for (i=0,i2=0; i<16384; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+16384+i),(simd_q15_t*)(output+32768+i), - (simd_q15_t*)(twa24576+i),(simd_q15_t*)(twb24576+i)); - } + for (i=0,i2=0; i<16384; i+=8,i2+=4) { + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+16384+i),(simd_q15_t *)(output+32768+i), + (simd_q15_t *)(twa24576+i),(simd_q15_t *)(twb24576+i)); + } if (scale==1) { for (i=0; i<384; i++) { @@ -6595,19 +5890,20 @@ void dft24576(int16_t *input, int16_t *output,unsigned char scale) y128p+=16; } } + _mm_empty(); _m_empty(); + if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("out.m","out",output,24576,1,1); + LOG_M("out.m","out",output,24576,1,1); } } -void idft24576(int16_t *input, int16_t *output,unsigned char scale) -{ +void idft24576(int16_t *input, int16_t *output,unsigned char scale) { int i,i2,j; uint32_t tmp[3][8192] __attribute__((aligned(32))); uint32_t tmpo[3][8192] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<8192; i++) { @@ -6616,10 +5912,10 @@ void idft24576(int16_t *input, int16_t *output,unsigned char scale) tmp[2][i] = ((uint32_t *)input)[j++]; } - idft8192((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - idft8192((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - idft8192((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); - + idft8192((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + idft8192((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + idft8192((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("idft24576in.m","in",input,24576,1,1); LOG_M("idft24576out0.m","o0",tmpo[0],8192,1,1); @@ -6628,10 +5924,11 @@ void idft24576(int16_t *input, int16_t *output,unsigned char scale) } for (i=0,i2=0; i<16384; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+16384+i),(simd_q15_t*)(output+32768+i), - (simd_q15_t*)(twa24576+i),(simd_q15_t*)(twb24576+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+16384+i),(simd_q15_t *)(output+32768+i), + (simd_q15_t *)(twa24576+i),(simd_q15_t *)(twb24576+i)); } + if (scale==1) { for (i=0; i<384; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6653,6 +5950,7 @@ void idft24576(int16_t *input, int16_t *output,unsigned char scale) y128p+=16; } } + _mm_empty(); _m_empty(); @@ -6666,11 +5964,10 @@ int16_t twb36864[24576] __attribute__((aligned(32))); // 12288 x 3 void dft36864(int16_t *input, int16_t *output,uint8_t scale) { - int i,i2,j; uint32_t tmp[3][12288] __attribute__((aligned(32))); uint32_t tmpo[3][12288] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<12288; i++) { @@ -6679,9 +5976,9 @@ void dft36864(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft12288((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - dft12288((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - dft12288((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + dft12288((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + dft12288((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + dft12288((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("dft36864out0.m","o0",tmpo[0],12288,1,1); @@ -6690,9 +5987,9 @@ void dft36864(int16_t *input, int16_t *output,uint8_t scale) { } for (i=0,i2=0; i<24576; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+24576+i),(simd_q15_t*)(output+49152+i), - (simd_q15_t*)(twa36864+i),(simd_q15_t*)(twb36864+i)); + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+24576+i),(simd_q15_t *)(output+49152+i), + (simd_q15_t *)(twa36864+i),(simd_q15_t *)(twb36864+i)); } if (scale==1) { @@ -6716,19 +6013,20 @@ void dft36864(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } + _mm_empty(); _m_empty(); + if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("out.m","out",output,36864,1,1); + LOG_M("out.m","out",output,36864,1,1); } } void idft36864(int16_t *input, int16_t *output,uint8_t scale) { - int i,i2,j; uint32_t tmp[3][12288] __attribute__((aligned(32))); uint32_t tmpo[3][12288] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<12288; i++) { @@ -6737,15 +6035,16 @@ void idft36864(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft12288((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - idft12288((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - idft12288((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + idft12288((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + idft12288((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + idft12288((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); for (i=0,i2=0; i<24576; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+24576+i),(simd_q15_t*)(output+49152+i), - (simd_q15_t*)(twa36864+i),(simd_q15_t*)(twb36864+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+24576+i),(simd_q15_t *)(output+49152+i), + (simd_q15_t *)(twa36864+i),(simd_q15_t *)(twb36864+i)); } + if (scale==1) { for (i=0; i<576; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6767,6 +6066,7 @@ void idft36864(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } + _mm_empty(); _m_empty(); } @@ -6776,11 +6076,10 @@ int16_t twb49152[32768] __attribute__((aligned(32))); // 16384 x 3 void dft49152(int16_t *input, int16_t *output,uint8_t scale) { - int i,i2,j; uint32_t tmp[3][16384] __attribute__((aligned(32))); uint32_t tmpo[3][16384] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<16384; i++) { @@ -6789,15 +6088,16 @@ void dft49152(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft16384((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - dft16384((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - dft16384((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + dft16384((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + dft16384((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + dft16384((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); for (i=0,i2=0; i<32768; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+32768+i),(simd_q15_t*)(output+65536+i), - (simd_q15_t*)(twa49152+i),(simd_q15_t*)(twb49152+i)); + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+32768+i),(simd_q15_t *)(output+65536+i), + (simd_q15_t *)(twa49152+i),(simd_q15_t *)(twb49152+i)); } + if (scale==1) { for (i=0; i<768; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6819,17 +6119,16 @@ void dft49152(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } + _mm_empty(); _m_empty(); - } void idft49152(int16_t *input, int16_t *output,uint8_t scale) { - - int i,i2,j; + int i,i2,j; uint32_t tmp[3][16384] __attribute__((aligned(32))); uint32_t tmpo[3][16384] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<16384; i++) { @@ -6838,15 +6137,16 @@ void idft49152(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft16384((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - idft16384((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - idft16384((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + idft16384((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + idft16384((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + idft16384((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); for (i=0,i2=0; i<32768; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+32768+i),(simd_q15_t*)(output+65536+i), - (simd_q15_t*)(twa49152+i),(simd_q15_t*)(twb49152+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+32768+i),(simd_q15_t *)(output+65536+i), + (simd_q15_t *)(twa49152+i),(simd_q15_t *)(twb49152+i)); } + if (scale==1) { for (i=0; i<768; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6868,6 +6168,7 @@ void idft49152(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } + _mm_empty(); _m_empty(); } @@ -6876,12 +6177,10 @@ int16_t twa73728[49152] __attribute__((aligned(32))); int16_t twb73728[49152] __attribute__((aligned(32))); // 24576 x 3 void dft73728(int16_t *input, int16_t *output,uint8_t scale) { - AssertFatal(1==0,"Need to do this ..\n"); } void idft73728(int16_t *input, int16_t *output,uint8_t scale) { - AssertFatal(1==0,"Need to do this ..\n"); } @@ -6890,11 +6189,10 @@ int16_t twa98304[65536] __attribute__((aligned(32))); int16_t twb98304[65536] __attribute__((aligned(32))); // 32768 x 3 void dft98304(int16_t *input, int16_t *output,uint8_t scale) { - int i,i2,j; uint32_t tmp[3][32768] __attribute__((aligned(32))); uint32_t tmpo[3][32768] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<32768; i++) { @@ -6903,15 +6201,16 @@ void dft98304(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft32768((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - dft32768((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - dft32768((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + dft32768((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + dft32768((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + dft32768((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); for (i=0,i2=0; i<65536; i+=8,i2+=4) { - bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+65536+i),(simd_q15_t*)(output+131072+i), - (simd_q15_t*)(twa98304+i),(simd_q15_t*)(twb98304+i)); + bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+65536+i),(simd_q15_t *)(output+131072+i), + (simd_q15_t *)(twa98304+i),(simd_q15_t *)(twb98304+i)); } + if (scale==1) { for (i=0; i<1536; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6933,17 +6232,16 @@ void dft98304(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } + _mm_empty(); _m_empty(); - } void idft98304(int16_t *input, int16_t *output,uint8_t scale) { - int i,i2,j; uint32_t tmp[3][32768] __attribute__((aligned(32))); uint32_t tmpo[3][32768] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t*)output; + simd_q15_t *y128p=(simd_q15_t *)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<32768; i++) { @@ -6952,15 +6250,16 @@ void idft98304(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft32768((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); - idft32768((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); - idft32768((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + idft32768((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); + idft32768((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); + idft32768((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); for (i=0,i2=0; i<65536; i+=8,i2+=4) { - ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), - (simd_q15_t*)(output+i),(simd_q15_t*)(output+65536+i),(simd_q15_t*)(output+131072+i), - (simd_q15_t*)(twa98304+i),(simd_q15_t*)(twb98304+i)); + ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), + (simd_q15_t *)(output+i),(simd_q15_t *)(output+65536+i),(simd_q15_t *)(output+131072+i), + (simd_q15_t *)(twa98304+i),(simd_q15_t *)(twb98304+i)); } + if (scale==1) { for (i=0; i<1536; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6982,11 +6281,12 @@ void idft98304(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } + _mm_empty(); _m_empty(); } - + /// THIS SECTION IS FOR ALL PUSCH DFTS (i.e. radix 2^a * 3^b * 4^c * 5^d) /// They use twiddles for 4-way parallel DFTS (i.e. 4 DFTS with interleaved input/output) @@ -7053,16 +6353,10 @@ static inline void dft12f(simd_q15_t *x0, simd_q15_t *y8, simd_q15_t *y9, simd_q15_t *y10, - simd_q15_t *y11) -{ - - + simd_q15_t *y11) { simd_q15_t tmp_dft12[12]; - simd_q15_t *tmp_dft12_ptr = &tmp_dft12[0]; - // msg("dft12\n"); - bfly4_tw1(x0, x3, x6, @@ -7071,8 +6365,6 @@ static inline void dft12f(simd_q15_t *x0, tmp_dft12_ptr+3, tmp_dft12_ptr+6, tmp_dft12_ptr+9); - - bfly4_tw1(x1, x4, x7, @@ -7081,8 +6373,6 @@ static inline void dft12f(simd_q15_t *x0, tmp_dft12_ptr+4, tmp_dft12_ptr+7, tmp_dft12_ptr+10); - - bfly4_tw1(x2, x5, x8, @@ -7091,7 +6381,6 @@ static inline void dft12f(simd_q15_t *x0, tmp_dft12_ptr+5, tmp_dft12_ptr+8, tmp_dft12_ptr+11); - // k2=0; bfly3_tw1(tmp_dft12_ptr, tmp_dft12_ptr+1, @@ -7099,9 +6388,6 @@ static inline void dft12f(simd_q15_t *x0, y0, y4, y8); - - - // k2=1; bfly3(tmp_dft12_ptr+3, tmp_dft12_ptr+4, @@ -7111,9 +6397,6 @@ static inline void dft12f(simd_q15_t *x0, y9, W1_12, W2_12); - - - // k2=2; bfly3(tmp_dft12_ptr+6, tmp_dft12_ptr+7, @@ -7123,7 +6406,6 @@ static inline void dft12f(simd_q15_t *x0, y10, W2_12, W4_12); - // k2=3; bfly3(tmp_dft12_ptr+9, tmp_dft12_ptr+10, @@ -7133,15 +6415,12 @@ static inline void dft12f(simd_q15_t *x0, y11, W3_12, W6_12); - } -void dft12(int16_t *x,int16_t *y ,unsigned char scale_flag) -{ - +void dft12(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t *x128 = (simd_q15_t *)x,*y128 = (simd_q15_t *)y; dft12f(&x128[0], &x128[1], @@ -7167,10 +6446,8 @@ void dft12(int16_t *x,int16_t *y ,unsigned char scale_flag) &y128[9], &y128[10], &y128[11]); - _mm_empty(); _m_empty(); - } #ifdef __AVX2__ @@ -7190,186 +6467,160 @@ simd256_q15_t *W6_12_256=(simd256_q15_t *)W6_12s_256; static inline void dft12f_simd256(simd256_q15_t *x0, - simd256_q15_t *x1, - simd256_q15_t *x2, - simd256_q15_t *x3, - simd256_q15_t *x4, - simd256_q15_t *x5, - simd256_q15_t *x6, - simd256_q15_t *x7, - simd256_q15_t *x8, - simd256_q15_t *x9, - simd256_q15_t *x10, - simd256_q15_t *x11, - simd256_q15_t *y0, - simd256_q15_t *y1, - simd256_q15_t *y2, - simd256_q15_t *y3, - simd256_q15_t *y4, - simd256_q15_t *y5, - simd256_q15_t *y6, - simd256_q15_t *y7, - simd256_q15_t *y8, - simd256_q15_t *y9, - simd256_q15_t *y10, - simd256_q15_t *y11) __attribute__((always_inline)); + simd256_q15_t *x1, + simd256_q15_t *x2, + simd256_q15_t *x3, + simd256_q15_t *x4, + simd256_q15_t *x5, + simd256_q15_t *x6, + simd256_q15_t *x7, + simd256_q15_t *x8, + simd256_q15_t *x9, + simd256_q15_t *x10, + simd256_q15_t *x11, + simd256_q15_t *y0, + simd256_q15_t *y1, + simd256_q15_t *y2, + simd256_q15_t *y3, + simd256_q15_t *y4, + simd256_q15_t *y5, + simd256_q15_t *y6, + simd256_q15_t *y7, + simd256_q15_t *y8, + simd256_q15_t *y9, + simd256_q15_t *y10, + simd256_q15_t *y11) __attribute__((always_inline)); static inline void dft12f_simd256(simd256_q15_t *x0, - simd256_q15_t *x1, - simd256_q15_t *x2, - simd256_q15_t *x3, - simd256_q15_t *x4, - simd256_q15_t *x5, - simd256_q15_t *x6, - simd256_q15_t *x7, - simd256_q15_t *x8, - simd256_q15_t *x9, - simd256_q15_t *x10, - simd256_q15_t *x11, - simd256_q15_t *y0, - simd256_q15_t *y1, - simd256_q15_t *y2, - simd256_q15_t *y3, - simd256_q15_t *y4, - simd256_q15_t *y5, - simd256_q15_t *y6, - simd256_q15_t *y7, - simd256_q15_t *y8, - simd256_q15_t *y9, - simd256_q15_t *y10, - simd256_q15_t *y11) -{ - - + simd256_q15_t *x1, + simd256_q15_t *x2, + simd256_q15_t *x3, + simd256_q15_t *x4, + simd256_q15_t *x5, + simd256_q15_t *x6, + simd256_q15_t *x7, + simd256_q15_t *x8, + simd256_q15_t *x9, + simd256_q15_t *x10, + simd256_q15_t *x11, + simd256_q15_t *y0, + simd256_q15_t *y1, + simd256_q15_t *y2, + simd256_q15_t *y3, + simd256_q15_t *y4, + simd256_q15_t *y5, + simd256_q15_t *y6, + simd256_q15_t *y7, + simd256_q15_t *y8, + simd256_q15_t *y9, + simd256_q15_t *y10, + simd256_q15_t *y11) { simd256_q15_t tmp_dft12[12]; - simd256_q15_t *tmp_dft12_ptr = &tmp_dft12[0]; - // msg("dft12\n"); - bfly4_tw1_256(x0, - x3, - x6, - x9, - tmp_dft12_ptr, - tmp_dft12_ptr+3, - tmp_dft12_ptr+6, - tmp_dft12_ptr+9); - - + x3, + x6, + x9, + tmp_dft12_ptr, + tmp_dft12_ptr+3, + tmp_dft12_ptr+6, + tmp_dft12_ptr+9); bfly4_tw1_256(x1, - x4, - x7, - x10, - tmp_dft12_ptr+1, - tmp_dft12_ptr+4, - tmp_dft12_ptr+7, - tmp_dft12_ptr+10); - - + x4, + x7, + x10, + tmp_dft12_ptr+1, + tmp_dft12_ptr+4, + tmp_dft12_ptr+7, + tmp_dft12_ptr+10); bfly4_tw1_256(x2, - x5, - x8, - x11, - tmp_dft12_ptr+2, - tmp_dft12_ptr+5, - tmp_dft12_ptr+8, - tmp_dft12_ptr+11); - + x5, + x8, + x11, + tmp_dft12_ptr+2, + tmp_dft12_ptr+5, + tmp_dft12_ptr+8, + tmp_dft12_ptr+11); // k2=0; bfly3_tw1_256(tmp_dft12_ptr, - tmp_dft12_ptr+1, - tmp_dft12_ptr+2, - y0, - y4, - y8); - - - + tmp_dft12_ptr+1, + tmp_dft12_ptr+2, + y0, + y4, + y8); // k2=1; bfly3_256(tmp_dft12_ptr+3, - tmp_dft12_ptr+4, - tmp_dft12_ptr+5, - y1, - y5, - y9, - W1_12_256, - W2_12_256); - - - + tmp_dft12_ptr+4, + tmp_dft12_ptr+5, + y1, + y5, + y9, + W1_12_256, + W2_12_256); // k2=2; bfly3_256(tmp_dft12_ptr+6, - tmp_dft12_ptr+7, - tmp_dft12_ptr+8, - y2, - y6, - y10, - W2_12_256, - W4_12_256); - + tmp_dft12_ptr+7, + tmp_dft12_ptr+8, + y2, + y6, + y10, + W2_12_256, + W4_12_256); // k2=3; bfly3_256(tmp_dft12_ptr+9, - tmp_dft12_ptr+10, - tmp_dft12_ptr+11, - y3, - y7, - y11, - W3_12_256, - W6_12_256); - + tmp_dft12_ptr+10, + tmp_dft12_ptr+11, + y3, + y7, + y11, + W3_12_256, + W6_12_256); } -void dft12_simd256(int16_t *x,int16_t *y) -{ - +void dft12_simd256(int16_t *x,int16_t *y) { simd256_q15_t *x256 = (simd256_q15_t *)x,*y256 = (simd256_q15_t *)y; dft12f_simd256(&x256[0], - &x256[1], - &x256[2], - &x256[3], - &x256[4], - &x256[5], - &x256[6], - &x256[7], - &x256[8], - &x256[9], - &x256[10], - &x256[11], - &y256[0], - &y256[1], - &y256[2], - &y256[3], - &y256[4], - &y256[5], - &y256[6], - &y256[7], - &y256[8], - &y256[9], - &y256[10], - &y256[11]); - + &x256[1], + &x256[2], + &x256[3], + &x256[4], + &x256[5], + &x256[6], + &x256[7], + &x256[8], + &x256[9], + &x256[10], + &x256[11], + &y256[0], + &y256[1], + &y256[2], + &y256[3], + &y256[4], + &y256[5], + &y256[6], + &y256[7], + &y256[8], + &y256[9], + &y256[10], + &y256[11]); _mm_empty(); _m_empty(); - } #endif static int16_t tw24[88]__attribute__((aligned(32))); -void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *tw128=(simd_q15_t *)&tw24[0]; simd_q15_t ytmp128[24];//=&ytmp128array[0]; int i,j,k; - // msg("dft24\n"); dft12f(x128, x128+2, @@ -7396,7 +6647,6 @@ void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) ytmp128+20, ytmp128+22); // msg("dft24b\n"); - dft12f(x128+1, x128+3, x128+5, @@ -7421,9 +6671,7 @@ void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) ytmp128+19, ytmp128+21, ytmp128+23); - // msg("dft24c\n"); - bfly2_tw1(ytmp128, ytmp128+1, y128, @@ -7432,7 +6680,6 @@ void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) // msg("dft24d\n"); for (i=2,j=1,k=0; i<24; i+=2,j++,k++) { - bfly2(ytmp128+i, ytmp128+i+1, y128+j, @@ -7451,24 +6698,18 @@ void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa36[88]__attribute__((aligned(32))); static int16_t twb36[88]__attribute__((aligned(32))); -void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *twa128=(simd_q15_t *)&twa36[0]; simd_q15_t *twb128=(simd_q15_t *)&twb36[0]; simd_q15_t ytmp128[36];//&ytmp128array[0]; - - int i,j,k; - dft12f(x128, x128+3, x128+6, @@ -7493,7 +6734,6 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) ytmp128+27, ytmp128+30, ytmp128+33); - dft12f(x128+1, x128+4, x128+7, @@ -7518,7 +6758,6 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) ytmp128+28, ytmp128+31, ytmp128+34); - dft12f(x128+2, x128+5, x128+8, @@ -7543,8 +6782,6 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) ytmp128+29, ytmp128+32, ytmp128+35); - - bfly3_tw1(ytmp128, ytmp128+1, ytmp128+2, @@ -7553,7 +6790,6 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) y128+24); for (i=3,j=1,k=0; i<36; i+=3,j++,k++) { - bfly3(ytmp128+i, ytmp128+i+1, ytmp128+i+2, @@ -7574,16 +6810,13 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa48[88]__attribute__((aligned(32))); static int16_t twb48[88]__attribute__((aligned(32))); static int16_t twc48[88]__attribute__((aligned(32))); -void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) -{ - +void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *twa128=(simd_q15_t *)&twa48[0]; @@ -7591,8 +6824,6 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) simd_q15_t *twc128=(simd_q15_t *)&twc48[0]; simd_q15_t ytmp128[48];//=&ytmp128array[0]; int i,j,k; - - dft12f(x128, x128+4, x128+8, @@ -7617,8 +6848,6 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) ytmp128+36, ytmp128+40, ytmp128+44); - - dft12f(x128+1, x128+5, x128+9, @@ -7643,8 +6872,6 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) ytmp128+37, ytmp128+41, ytmp128+45); - - dft12f(x128+2, x128+6, x128+10, @@ -7669,8 +6896,6 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) ytmp128+38, ytmp128+42, ytmp128+46); - - dft12f(x128+3, x128+7, x128+11, @@ -7695,9 +6920,6 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) ytmp128+39, ytmp128+43, ytmp128+47); - - - bfly4_tw1(ytmp128, ytmp128+1, ytmp128+2, @@ -7707,10 +6929,7 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) y128+24, y128+36); - - for (i=4,j=1,k=0; i<48; i+=4,j++,k++) { - bfly4(ytmp128+i, ytmp128+i+1, ytmp128+i+2, @@ -7722,7 +6941,6 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) twa128+k, twb128+k, twc128+k); - } if (scale_flag == 1) { @@ -7735,7 +6953,6 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa60[88]__attribute__((aligned(32))); @@ -7743,9 +6960,7 @@ static int16_t twb60[88]__attribute__((aligned(32))); static int16_t twc60[88]__attribute__((aligned(32))); static int16_t twd60[88]__attribute__((aligned(32))); -void dft60(int16_t *x,int16_t *y,unsigned char scale) -{ - +void dft60(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *twa128=(simd_q15_t *)&twa60[0]; @@ -7754,7 +6969,6 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) simd_q15_t *twd128=(simd_q15_t *)&twd60[0]; simd_q15_t ytmp128[60];//=&ytmp128array[0]; int i,j,k; - dft12f(x128, x128+5, x128+10, @@ -7779,7 +6993,6 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) ytmp128+45, ytmp128+50, ytmp128+55); - dft12f(x128+1, x128+6, x128+11, @@ -7804,7 +7017,6 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) ytmp128+46, ytmp128+51, ytmp128+56); - dft12f(x128+2, x128+7, x128+12, @@ -7829,7 +7041,6 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) ytmp128+47, ytmp128+52, ytmp128+57); - dft12f(x128+3, x128+8, x128+13, @@ -7854,7 +7065,6 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) ytmp128+48, ytmp128+53, ytmp128+58); - dft12f(x128+4, x128+9, x128+14, @@ -7879,7 +7089,6 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) ytmp128+49, ytmp128+54, ytmp128+59); - bfly5_tw1(ytmp128, ytmp128+1, ytmp128+2, @@ -7892,7 +7101,6 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) y128+48); for (i=5,j=1,k=0; i<60; i+=5,j++,k++) { - bfly5(ytmp128+i, ytmp128+i+1, ytmp128+i+2, @@ -7914,26 +7122,22 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) for (i=0; i<60; i++) { y128[i] = mulhi_int16(y128[i],norm128); -// printf("y[%d] = (%d,%d)\n",i,((int16_t*)&y128[i])[0],((int16_t*)&y128[i])[1]); + // printf("y[%d] = (%d,%d)\n",i,((int16_t*)&y128[i])[0],((int16_t*)&y128[i])[1]); } } _mm_empty(); _m_empty(); - } static int16_t tw72[280]__attribute__((aligned(32))); -void dft72(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft72(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *tw128=(simd_q15_t *)&tw72[0]; simd_q15_t x2128[72];// = (simd_q15_t *)&x2128array[0]; - simd_q15_t ytmp128[72];//=&ytmp128array2[0]; for (i=0,j=0; i<36; i++,j+=2) { @@ -7943,7 +7147,6 @@ void dft72(int16_t *x,int16_t *y,unsigned char scale_flag) dft36((int16_t *)x2128,(int16_t *)ytmp128,1); dft36((int16_t *)(x2128+36),(int16_t *)(ytmp128+36),1); - bfly2_tw1(ytmp128,ytmp128+36,y128,y128+36); for (i=1,j=0; i<36; i++,j++) { @@ -7964,15 +7167,11 @@ void dft72(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t tw96[376]__attribute__((aligned(32))); -void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - - +void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7980,7 +7179,6 @@ void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[96];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[96];//=&ytmp128array2[0]; - for (i=0,j=0; i<48; i++,j+=2) { x2128[i] = x128[j]; x2128[i+48] = x128[j+1]; @@ -7988,8 +7186,6 @@ void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) dft48((int16_t *)x2128,(int16_t *)ytmp128,0); dft48((int16_t *)(x2128+48),(int16_t *)(ytmp128+48),0); - - bfly2_tw1(ytmp128,ytmp128+48,y128,y128+48); for (i=1,j=0; i<48; i++,j++) { @@ -8010,14 +7206,12 @@ void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa108[280]__attribute__((aligned(32))); static int16_t twb108[280]__attribute__((aligned(32))); -void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) -{ +void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8026,7 +7220,6 @@ void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[108];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[108];//=&ytmp128array2[0]; - for (i=0,j=0; i<36; i++,j+=3) { x2128[i] = x128[j]; x2128[i+36] = x128[j+1]; @@ -8036,7 +7229,6 @@ void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) dft36((int16_t *)x2128,(int16_t *)ytmp128,0); dft36((int16_t *)(x2128+36),(int16_t *)(ytmp128+36),0); dft36((int16_t *)(x2128+72),(int16_t *)(ytmp128+72),0); - bfly3_tw1(ytmp128,ytmp128+36,ytmp128+72,y128,y128+36,y128+72); for (i=1,j=0; i<36; i++,j++) { @@ -8048,7 +7240,6 @@ void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) y128+72+i, twa128+j, twb128+j); - } if (scale_flag==1) { @@ -8061,12 +7252,10 @@ void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t tw120[472]__attribute__((aligned(32))); -void dft120(int16_t *x,int16_t *y, unsigned char scale_flag) -{ +void dft120(int16_t *x,int16_t *y, unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8081,8 +7270,6 @@ void dft120(int16_t *x,int16_t *y, unsigned char scale_flag) dft60((int16_t *)x2128,(int16_t *)ytmp128,0); dft60((int16_t *)(x2128+60),(int16_t *)(ytmp128+60),0); - - bfly2_tw1(ytmp128,ytmp128+60,y128,y128+60); for (i=1,j=0; i<60; i++,j++) { @@ -8103,14 +7290,12 @@ void dft120(int16_t *x,int16_t *y, unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa144[376]__attribute__((aligned(32))); static int16_t twb144[376]__attribute__((aligned(32))); -void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) -{ +void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8119,8 +7304,6 @@ void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[144];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[144];//=&ytmp128array2[0]; - - for (i=0,j=0; i<48; i++,j+=3) { x2128[i] = x128[j]; x2128[i+48] = x128[j+1]; @@ -8130,7 +7313,6 @@ void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) dft48((int16_t *)x2128,(int16_t *)ytmp128,1); dft48((int16_t *)(x2128+48),(int16_t *)(ytmp128+48),1); dft48((int16_t *)(x2128+96),(int16_t *)(ytmp128+96),1); - bfly3_tw1(ytmp128,ytmp128+48,ytmp128+96,y128,y128+48,y128+96); for (i=1,j=0; i<48; i++,j++) { @@ -8154,15 +7336,12 @@ void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa180[472]__attribute__((aligned(32))); static int16_t twb180[472]__attribute__((aligned(32))); -void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8171,8 +7350,6 @@ void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[180];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[180];//=&ytmp128array2[0]; - - for (i=0,j=0; i<60; i++,j+=3) { x2128[i] = x128[j]; x2128[i+60] = x128[j+1]; @@ -8182,7 +7359,6 @@ void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) dft60((int16_t *)x2128,(int16_t *)ytmp128,1); dft60((int16_t *)(x2128+60),(int16_t *)(ytmp128+60),1); dft60((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); - bfly3_tw1(ytmp128,ytmp128+60,ytmp128+120,y128,y128+60,y128+120); for (i=1,j=0; i<60; i++,j++) { @@ -8206,16 +7382,13 @@ void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa192[376]__attribute__((aligned(32))); static int16_t twb192[376]__attribute__((aligned(32))); static int16_t twc192[376]__attribute__((aligned(32))); -void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8225,8 +7398,6 @@ void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[192];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[192];//=&ytmp128array2[0]; - - for (i=0,j=0; i<48; i++,j+=4) { x2128[i] = x128[j]; x2128[i+48] = x128[j+1]; @@ -8238,7 +7409,6 @@ void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) dft48((int16_t *)(x2128+48),(int16_t *)(ytmp128+48),1); dft48((int16_t *)(x2128+96),(int16_t *)(ytmp128+96),1); dft48((int16_t *)(x2128+144),(int16_t *)(ytmp128+144),1); - bfly4_tw1(ytmp128,ytmp128+48,ytmp128+96,ytmp128+144,y128,y128+48,y128+96,y128+144); for (i=1,j=0; i<48; i++,j++) { @@ -8265,15 +7435,12 @@ void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa216[568]__attribute__((aligned(32))); static int16_t twb216[568]__attribute__((aligned(32))); -void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8282,8 +7449,6 @@ void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[216];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[216];//=&ytmp128array3[0]; - - for (i=0,j=0; i<72; i++,j+=3) { x2128[i] = x128[j]; x2128[i+72] = x128[j+1]; @@ -8293,7 +7458,6 @@ void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) dft72((int16_t *)x2128,(int16_t *)ytmp128,1); dft72((int16_t *)(x2128+72),(int16_t *)(ytmp128+72),1); dft72((int16_t *)(x2128+144),(int16_t *)(ytmp128+144),1); - bfly3_tw1(ytmp128,ytmp128+72,ytmp128+144,y128,y128+72,y128+144); for (i=1,j=0; i<72; i++,j++) { @@ -8317,16 +7481,13 @@ void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa240[472]__attribute__((aligned(32))); static int16_t twb240[472]__attribute__((aligned(32))); static int16_t twc240[472]__attribute__((aligned(32))); -void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8336,8 +7497,6 @@ void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[240];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[240];//=&ytmp128array2[0]; - - for (i=0,j=0; i<60; i++,j+=4) { x2128[i] = x128[j]; x2128[i+60] = x128[j+1]; @@ -8349,7 +7508,6 @@ void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) dft60((int16_t *)(x2128+60),(int16_t *)(ytmp128+60),1); dft60((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); dft60((int16_t *)(x2128+180),(int16_t *)(ytmp128+180),1); - bfly4_tw1(ytmp128,ytmp128+60,ytmp128+120,ytmp128+180,y128,y128+60,y128+120,y128+180); for (i=1,j=0; i<60; i++,j++) { @@ -8376,15 +7534,12 @@ void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa288[760]__attribute__((aligned(32))); static int16_t twb288[760]__attribute__((aligned(32))); -void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8393,8 +7548,6 @@ void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[288];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[288];//=&ytmp128array3[0]; - - for (i=0,j=0; i<96; i++,j+=3) { x2128[i] = x128[j]; x2128[i+96] = x128[j+1]; @@ -8404,7 +7557,6 @@ void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) dft96((int16_t *)x2128,(int16_t *)ytmp128,1); dft96((int16_t *)(x2128+96),(int16_t *)(ytmp128+96),1); dft96((int16_t *)(x2128+192),(int16_t *)(ytmp128+192),1); - bfly3_tw1(ytmp128,ytmp128+96,ytmp128+192,y128,y128+96,y128+192); for (i=1,j=0; i<96; i++,j++) { @@ -8428,7 +7580,6 @@ void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa300[472]__attribute__((aligned(32))); @@ -8436,9 +7587,7 @@ static int16_t twb300[472]__attribute__((aligned(32))); static int16_t twc300[472]__attribute__((aligned(32))); static int16_t twd300[472]__attribute__((aligned(32))); -void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8449,8 +7598,6 @@ void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[300];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[300];//=&ytmp128array2[0]; - - for (i=0,j=0; i<60; i++,j+=5) { x2128[i] = x128[j]; x2128[i+60] = x128[j+1]; @@ -8464,7 +7611,6 @@ void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) dft60((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); dft60((int16_t *)(x2128+180),(int16_t *)(ytmp128+180),1); dft60((int16_t *)(x2128+240),(int16_t *)(ytmp128+240),1); - bfly5_tw1(ytmp128,ytmp128+60,ytmp128+120,ytmp128+180,ytmp128+240,y128,y128+60,y128+120,y128+180,y128+240); for (i=1,j=0; i<60; i++,j++) { @@ -8494,14 +7640,12 @@ void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } static int16_t twa324[107*2*4]; static int16_t twb324[107*2*4]; -void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 3 -{ +void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8510,8 +7654,6 @@ void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 3 simd_q15_t x2128[324];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[324];//=&ytmp128array3[0]; - - for (i=0,j=0; i<108; i++,j+=3) { x2128[i] = x128[j]; x2128[i+108] = x128[j+1]; @@ -8521,7 +7663,6 @@ void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 3 dft108((int16_t *)x2128,(int16_t *)ytmp128,1); dft108((int16_t *)(x2128+108),(int16_t *)(ytmp128+108),1); dft108((int16_t *)(x2128+216),(int16_t *)(ytmp128+216),1); - bfly3_tw1(ytmp128,ytmp128+108,ytmp128+216,y128,y128+108,y128+216); for (i=1,j=0; i<108; i++,j++) { @@ -8545,14 +7686,12 @@ void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 3 _mm_empty(); _m_empty(); - }; static int16_t twa360[119*2*4]; static int16_t twb360[119*2*4]; -void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 3 -{ +void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8561,8 +7700,6 @@ void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 3 simd_q15_t x2128[360];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[360];//=&ytmp128array3[0]; - - for (i=0,j=0; i<120; i++,j+=3) { x2128[i] = x128[j]; x2128[i+120] = x128[j+1]; @@ -8572,7 +7709,6 @@ void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 3 dft120((int16_t *)x2128,(int16_t *)ytmp128,1); dft120((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); dft120((int16_t *)(x2128+240),(int16_t *)(ytmp128+240),1); - bfly3_tw1(ytmp128,ytmp128+120,ytmp128+240,y128,y128+120,y128+240); for (i=1,j=0; i<120; i++,j++) { @@ -8596,15 +7732,13 @@ void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 3 _mm_empty(); _m_empty(); - }; static int16_t twa384[95*2*4]; static int16_t twb384[95*2*4]; static int16_t twc384[95*2*4]; -void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) // 96 x 4 -{ +void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) { // 96 x 4 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8614,8 +7748,6 @@ void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) // 96 x 4 simd_q15_t x2128[384];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[384];//=&ytmp128array2[0]; - - for (i=0,j=0; i<96; i++,j+=4) { x2128[i] = x128[j]; x2128[i+96] = x128[j+1]; @@ -8627,7 +7759,6 @@ void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) // 96 x 4 dft96((int16_t *)(x2128+96),(int16_t *)(ytmp128+96),1); dft96((int16_t *)(x2128+192),(int16_t *)(ytmp128+192),1); dft96((int16_t *)(x2128+288),(int16_t *)(ytmp128+288),1); - bfly4_tw1(ytmp128,ytmp128+96,ytmp128+192,ytmp128+288,y128,y128+96,y128+192,y128+288); for (i=1,j=0; i<96; i++,j++) { @@ -8654,15 +7785,13 @@ void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) // 96 x 4 _mm_empty(); _m_empty(); - }; static int16_t twa432[107*2*4]; static int16_t twb432[107*2*4]; static int16_t twc432[107*2*4]; -void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 4 -{ +void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 4 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8672,7 +7801,6 @@ void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 4 simd_q15_t x2128[432];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[432];//=&ytmp128array2[0]; - for (i=0,j=0; i<108; i++,j+=4) { x2128[i] = x128[j]; x2128[i+108] = x128[j+1]; @@ -8684,7 +7812,6 @@ void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 4 dft108((int16_t *)(x2128+108),(int16_t *)(ytmp128+108),1); dft108((int16_t *)(x2128+216),(int16_t *)(ytmp128+216),1); dft108((int16_t *)(x2128+324),(int16_t *)(ytmp128+324),1); - bfly4_tw1(ytmp128,ytmp128+108,ytmp128+216,ytmp128+324,y128,y128+108,y128+216,y128+324); for (i=1,j=0; i<108; i++,j++) { @@ -8711,14 +7838,12 @@ void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 4 _mm_empty(); _m_empty(); - }; static int16_t twa480[119*2*4]; static int16_t twb480[119*2*4]; static int16_t twc480[119*2*4]; -void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 4 -{ +void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 4 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8728,8 +7853,6 @@ void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 4 simd_q15_t x2128[480];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[480];//=&ytmp128array2[0]; - - for (i=0,j=0; i<120; i++,j+=4) { x2128[i] = x128[j]; x2128[i+120] = x128[j+1]; @@ -8741,7 +7864,6 @@ void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 4 dft120((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); dft120((int16_t *)(x2128+240),(int16_t *)(ytmp128+240),1); dft120((int16_t *)(x2128+360),(int16_t *)(ytmp128+360),1); - bfly4_tw1(ytmp128,ytmp128+120,ytmp128+240,ytmp128+360,y128,y128+120,y128+240,y128+360); for (i=1,j=0; i<120; i++,j++) { @@ -8768,15 +7890,13 @@ void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 4 _mm_empty(); _m_empty(); - }; static int16_t twa540[179*2*4]; static int16_t twb540[179*2*4]; -void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 3 -{ +void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8785,8 +7905,6 @@ void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 3 simd_q15_t x2128[540];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[540];//=&ytmp128array3[0]; - - for (i=0,j=0; i<180; i++,j+=3) { x2128[i] = x128[j]; x2128[i+180] = x128[j+1]; @@ -8796,7 +7914,6 @@ void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 3 dft180((int16_t *)x2128,(int16_t *)ytmp128,1); dft180((int16_t *)(x2128+180),(int16_t *)(ytmp128+180),1); dft180((int16_t *)(x2128+360),(int16_t *)(ytmp128+360),1); - bfly3_tw1(ytmp128,ytmp128+180,ytmp128+360,y128,y128+180,y128+360); for (i=1,j=0; i<180; i++,j++) { @@ -8820,14 +7937,12 @@ void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 3 _mm_empty(); _m_empty(); - }; static int16_t twa576[191*2*4]; static int16_t twb576[191*2*4]; -void dft576(int16_t *x,int16_t *y,unsigned char scale_flag) // 192 x 3 -{ +void dft576(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8836,19 +7951,15 @@ void dft576(int16_t *x,int16_t *y,unsigned char scale_flag) // 192 x 3 simd_q15_t x2128[576];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[576];//=&ytmp128array3[0]; - - for (i=0,j=0; i<192; i++,j+=3) { x2128[i] = x128[j]; x2128[i+192] = x128[j+1]; x2128[i+384] = x128[j+2]; } - dft192((int16_t *)x2128,(int16_t *)ytmp128,1); dft192((int16_t *)(x2128+192),(int16_t *)(ytmp128+192),1); dft192((int16_t *)(x2128+384),(int16_t *)(ytmp128+384),1); - bfly3_tw1(ytmp128,ytmp128+192,ytmp128+384,y128,y128+192,y128+384); for (i=1,j=0; i<192; i++,j++) { @@ -8877,8 +7988,7 @@ void dft576(int16_t *x,int16_t *y,unsigned char scale_flag) // 192 x 3 static int16_t twa600[299*2*4]; -void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 2 -{ +void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 2 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8886,7 +7996,6 @@ void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 2 simd_q15_t x2128[600];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[600];//=&ytmp128array2[0]; - for (i=0,j=0; i<300; i++,j+=2) { x2128[i] = x128[j]; x2128[i+300] = x128[j+1]; @@ -8894,8 +8003,6 @@ void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 2 dft300((int16_t *)x2128,(int16_t *)ytmp128,1); dft300((int16_t *)(x2128+300),(int16_t *)(ytmp128+300),1); - - bfly2_tw1(ytmp128,ytmp128+300,y128,y128+300); for (i=1,j=0; i<300; i++,j++) { @@ -8922,8 +8029,7 @@ void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 2 static int16_t twa648[215*2*4]; static int16_t twb648[215*2*4]; -void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) // 216 x 3 -{ +void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) { // 216 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8932,8 +8038,6 @@ void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) // 216 x 3 simd_q15_t x2128[648];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[648];//=&ytmp128array3[0]; - - for (i=0,j=0; i<216; i++,j+=3) { x2128[i] = x128[j]; x2128[i+216] = x128[j+1]; @@ -8943,7 +8047,6 @@ void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) // 216 x 3 dft216((int16_t *)x2128,(int16_t *)ytmp128,1); dft216((int16_t *)(x2128+216),(int16_t *)(ytmp128+216),1); dft216((int16_t *)(x2128+432),(int16_t *)(ytmp128+432),1); - bfly3_tw1(ytmp128,ytmp128+216,ytmp128+432,y128,y128+216,y128+432); for (i=1,j=0; i<216; i++,j++) { @@ -8967,7 +8070,6 @@ void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) // 216 x 3 _mm_empty(); _m_empty(); - }; @@ -8976,8 +8078,7 @@ static int16_t twb720[179*2*4]; static int16_t twc720[179*2*4]; -void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 4 -{ +void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 4 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8987,8 +8088,6 @@ void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 4 simd_q15_t x2128[720];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[720];//=&ytmp128array2[0]; - - for (i=0,j=0; i<180; i++,j+=4) { x2128[i] = x128[j]; x2128[i+180] = x128[j+1]; @@ -9000,7 +8099,6 @@ void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 4 dft180((int16_t *)(x2128+180),(int16_t *)(ytmp128+180),1); dft180((int16_t *)(x2128+360),(int16_t *)(ytmp128+360),1); dft180((int16_t *)(x2128+540),(int16_t *)(ytmp128+540),1); - bfly4_tw1(ytmp128,ytmp128+180,ytmp128+360,ytmp128+540,y128,y128+180,y128+360,y128+540); for (i=1,j=0; i<180; i++,j++) { @@ -9027,7 +8125,6 @@ void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 4 _mm_empty(); _m_empty(); - }; static int16_t twa768[191*2*4]; @@ -9035,7 +8132,6 @@ static int16_t twb768[191*2*4]; static int16_t twc768[191*2*4]; void dft768(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192x 4; - int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -9045,8 +8141,6 @@ void dft768(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192x 4; simd_q15_t x2128[768];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[768];//=&ytmp128array2[0]; - - for (i=0,j=0; i<192; i++,j+=4) { x2128[i] = x128[j]; x2128[i+192] = x128[j+1]; @@ -9058,7 +8152,6 @@ void dft768(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192x 4; dft192((int16_t *)(x2128+192),(int16_t *)(ytmp128+192),1); dft192((int16_t *)(x2128+384),(int16_t *)(ytmp128+384),1); dft192((int16_t *)(x2128+576),(int16_t *)(ytmp128+576),1); - bfly4_tw1(ytmp128,ytmp128+192,ytmp128+384,ytmp128+576,y128,y128+192,y128+384,y128+576); for (i=1,j=0; i<192; i++,j++) { @@ -9085,16 +8178,13 @@ void dft768(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192x 4; _mm_empty(); _m_empty(); - - } static int16_t twa864[287*2*4]; static int16_t twb864[287*2*4]; -void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 3 -{ +void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -9103,8 +8193,6 @@ void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 3 simd_q15_t x2128[864];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[864];//=&ytmp128array3[0]; - - for (i=0,j=0; i<288; i++,j+=3) { x2128[i] = x128[j]; x2128[i+288] = x128[j+1]; @@ -9114,7 +8202,6 @@ void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 3 dft288((int16_t *)x2128,(int16_t *)ytmp128,1); dft288((int16_t *)(x2128+288),(int16_t *)(ytmp128+288),1); dft288((int16_t *)(x2128+576),(int16_t *)(ytmp128+576),1); - bfly3_tw1(ytmp128,ytmp128+288,ytmp128+576,y128,y128+288,y128+576); for (i=1,j=0; i<288; i++,j++) { @@ -9138,14 +8225,12 @@ void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 3 _mm_empty(); _m_empty(); - }; static int16_t twa900[299*2*4]; static int16_t twb900[299*2*4]; -void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 3 -{ +void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -9154,8 +8239,6 @@ void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 3 simd_q15_t x2128[900];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[900];//=&ytmp128array3[0]; - - for (i=0,j=0; i<300; i++,j+=3) { x2128[i] = x128[j]; x2128[i+300] = x128[j+1]; @@ -9165,7 +8248,6 @@ void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 3 dft300((int16_t *)x2128,(int16_t *)ytmp128,1); dft300((int16_t *)(x2128+300),(int16_t *)(ytmp128+300),1); dft300((int16_t *)(x2128+600),(int16_t *)(ytmp128+600),1); - bfly3_tw1(ytmp128,ytmp128+300,ytmp128+600,y128,y128+300,y128+600); for (i=1,j=0; i<300; i++,j++) { @@ -9189,7 +8271,6 @@ void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 3 _mm_empty(); _m_empty(); - }; @@ -9198,8 +8279,7 @@ static int16_t twb960[239*2*4]; static int16_t twc960[239*2*4]; -void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) // 240 x 4 -{ +void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) { // 240 x 4 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -9209,8 +8289,6 @@ void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) // 240 x 4 simd_q15_t x2128[960];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[960];//=&ytmp128array2[0]; - - for (i=0,j=0; i<240; i++,j+=4) { x2128[i] = x128[j]; x2128[i+240] = x128[j+1]; @@ -9222,7 +8300,6 @@ void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) // 240 x 4 dft240((int16_t *)(x2128+240),(int16_t *)(ytmp128+240),1); dft240((int16_t *)(x2128+480),(int16_t *)(ytmp128+480),1); dft240((int16_t *)(x2128+720),(int16_t *)(ytmp128+720),1); - bfly4_tw1(ytmp128,ytmp128+240,ytmp128+480,ytmp128+720,y128,y128+240,y128+480,y128+720); for (i=1,j=0; i<240; i++,j++) { @@ -9249,15 +8326,13 @@ void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) // 240 x 4 _mm_empty(); _m_empty(); - }; static int16_t twa972[323*2*4]; static int16_t twb972[323*2*4]; -void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) // 324 x 3 -{ +void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) { // 324 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -9266,8 +8341,6 @@ void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) // 324 x 3 simd_q15_t x2128[972];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[972];//=&ytmp128array3[0]; - - for (i=0,j=0; i<324; i++,j+=3) { x2128[i] = x128[j]; x2128[i+324] = x128[j+1]; @@ -9277,7 +8350,6 @@ void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) // 324 x 3 dft324((int16_t *)x2128,(int16_t *)ytmp128,1); dft324((int16_t *)(x2128+324),(int16_t *)(ytmp128+324),1); dft324((int16_t *)(x2128+648),(int16_t *)(ytmp128+648),1); - bfly3_tw1(ytmp128,ytmp128+324,ytmp128+648,y128,y128+324,y128+648); for (i=1,j=0; i<324; i++,j++) { @@ -9301,14 +8373,12 @@ void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) // 324 x 3 _mm_empty(); _m_empty(); - }; static int16_t twa1080[359*2*4]; static int16_t twb1080[359*2*4]; -void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) // 360 x 3 -{ +void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) { // 360 x 3 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -9317,8 +8387,6 @@ void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) // 360 x 3 simd_q15_t x2128[1080];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[1080];//=&ytmp128array3[0]; - - for (i=0,j=0; i<360; i++,j+=3) { x2128[i] = x128[j]; x2128[i+360] = x128[j+1]; @@ -9328,7 +8396,6 @@ void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) // 360 x 3 dft360((int16_t *)x2128,(int16_t *)ytmp128,1); dft360((int16_t *)(x2128+360),(int16_t *)(ytmp128+360),1); dft360((int16_t *)(x2128+720),(int16_t *)(ytmp128+720),1); - bfly3_tw1(ytmp128,ytmp128+360,ytmp128+720,y128,y128+360,y128+720); for (i=1,j=0; i<360; i++,j++) { @@ -9352,16 +8419,13 @@ void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) // 360 x 3 _mm_empty(); _m_empty(); - }; static int16_t twa1152[287*2*4]; static int16_t twb1152[287*2*4]; static int16_t twc1152[287*2*4]; -void dft1152(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 4 -{ - +void dft1152(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 4 int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -9371,8 +8435,6 @@ void dft1152(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 4 simd_q15_t x2128[1152];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[1152];//=&ytmp128array2[0]; - - for (i=0,j=0; i<288; i++,j+=4) { x2128[i] = x128[j]; x2128[i+288] = x128[j+1]; @@ -9384,7 +8446,6 @@ void dft1152(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 4 dft288((int16_t *)(x2128+288),(int16_t *)(ytmp128+288),1); dft288((int16_t *)(x2128+576),(int16_t *)(ytmp128+576),1); dft288((int16_t *)(x2128+864),(int16_t *)(ytmp128+864),1); - bfly4_tw1(ytmp128,ytmp128+288,ytmp128+576,ytmp128+864,y128,y128+288,y128+576,y128+864); for (i=1,j=0; i<288; i++,j++) { @@ -9417,9 +8478,7 @@ int16_t twa1200[4784]; int16_t twb1200[4784]; int16_t twc1200[4784]; -void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) -{ - +void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) { int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -9429,8 +8488,6 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) simd_q15_t x2128[1200];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[1200];//=&ytmp128array2[0]; - - for (i=0,j=0; i<300; i++,j+=4) { x2128[i] = x128[j]; x2128[i+300] = x128[j+1]; @@ -9442,7 +8499,6 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) dft300((int16_t *)(x2128+300),(int16_t *)(ytmp128+300),1); dft300((int16_t *)(x2128+600),(int16_t *)(ytmp128+600),1); dft300((int16_t *)(x2128+900),(int16_t *)(ytmp128+900),1); - bfly4_tw1(ytmp128,ytmp128+300,ytmp128+600,ytmp128+900,y128,y128+300,y128+600,y128+900); for (i=1,j=0; i<300; i++,j++) { @@ -9461,6 +8517,7 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) if (scale_flag==1) { norm128 = set1_int16(16384);//dft_norm_table[13]); + for (i=0; i<1200; i++) { y128[i] = mulhi_int16(y128[i],norm128); } @@ -9468,41 +8525,46 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) _mm_empty(); _m_empty(); - } void init_rad4(int N,int16_t *tw) { - int16_t *twa = tw; int16_t *twb = twa+(N/2); int16_t *twc = twb+(N/2); int i; - for (i=0;i<(N/4);i++) { - *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa++; - *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twa++; - *twb = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb++; - *twb = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); twb++; - *twc = (int16_t)round(32767.0*cos(2*M_PI*3*i/N)); twc++; - *twc = -(int16_t)round(32767.0*sin(2*M_PI*3*i/N)); twc++; + for (i=0; i<(N/4); i++) { + *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + twa++; + *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); + twa++; + *twb = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); + twb++; + *twb = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); + twb++; + *twc = (int16_t)round(32767.0*cos(2*M_PI*3*i/N)); + twc++; + *twc = -(int16_t)round(32767.0*sin(2*M_PI*3*i/N)); + twc++; } } void init_rad4_rep(int N,int16_t *twa,int16_t *twb,int16_t *twc) { - int i,j; - for (i=1;i<(N/4);i++) { - twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + for (i=1; i<(N/4); i++) { + twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa[1] = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twb[0] = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb[1] = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); twc[0] = (int16_t)round(32767.0*cos(2*M_PI*3*i/N)); twc[1] = -(int16_t)round(32767.0*sin(2*M_PI*3*i/N)); - for (j=1;j<4;j++) { - ((int32_t*)twa)[j]=((int32_t*)twa)[0]; - ((int32_t*)twb)[j]=((int32_t*)twb)[0]; - ((int32_t*)twc)[j]=((int32_t*)twc)[0]; + + for (j=1; j<4; j++) { + ((int32_t *)twa)[j]=((int32_t *)twa)[0]; + ((int32_t *)twb)[j]=((int32_t *)twb)[0]; + ((int32_t *)twc)[j]=((int32_t *)twc)[0]; } + twa+=8; twb+=8; twc+=8; @@ -9510,66 +8572,71 @@ void init_rad4_rep(int N,int16_t *twa,int16_t *twb,int16_t *twc) { } void init_rad2(int N,int16_t *tw) { - int16_t *twa = tw; int i; - for (i=0;i<(N>>1);i++) { - *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa++; - *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twa++; + for (i=0; i<(N>>1); i++) { + *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + twa++; + *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); + twa++; } } void init_rad2_rep(int N,int16_t *twa) { - int i,j; - for (i=1;i<(N/2);i++) { - twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + for (i=1; i<(N/2); i++) { + twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa[1] = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); - for (j=1;j<4;j++) { - ((int32_t*)twa)[j]=((int32_t*)twa)[0]; + + for (j=1; j<4; j++) { + ((int32_t *)twa)[j]=((int32_t *)twa)[0]; } + twa+=8; } } void init_rad3(int N,int16_t *twa,int16_t *twb) { - int i; - for (i=0;i<(N/3);i++) { - *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa++; - *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twa++; - *twb = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb++; - *twb = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); twb++; + for (i=0; i<(N/3); i++) { + *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + twa++; + *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); + twa++; + *twb = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); + twb++; + *twb = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); + twb++; } } void init_rad3_rep(int N,int16_t *twa,int16_t *twb) { - int i,j; - for (i=1;i<(N/3);i++) { - twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + for (i=1; i<(N/3); i++) { + twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa[1] = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twb[0] = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb[1] = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); - for (j=1;j<4;j++) { - ((int32_t*)twa)[j]=((int32_t*)twa)[0]; - ((int32_t*)twb)[j]=((int32_t*)twb)[0]; + + for (j=1; j<4; j++) { + ((int32_t *)twa)[j]=((int32_t *)twa)[0]; + ((int32_t *)twb)[j]=((int32_t *)twb)[0]; } + twa+=8; twb+=8; } } void init_rad5_rep(int N,int16_t *twa,int16_t *twb,int16_t *twc,int16_t *twd) { - int i,j; - for (i=1;i<(N/5);i++) { - twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + for (i=1; i<(N/5); i++) { + twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa[1] = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twb[0] = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb[1] = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); @@ -9577,30 +8644,30 @@ void init_rad5_rep(int N,int16_t *twa,int16_t *twb,int16_t *twc,int16_t *twd) { twc[1] = -(int16_t)round(32767.0*sin(2*M_PI*3*i/N)); twd[0] = (int16_t)round(32767.0*cos(2*M_PI*4*i/N)); twd[1] = -(int16_t)round(32767.0*sin(2*M_PI*4*i/N)); - for (j=1;j<4;j++) { - ((int32_t*)twa)[j]=((int32_t*)twa)[0]; - ((int32_t*)twb)[j]=((int32_t*)twb)[0]; - ((int32_t*)twc)[j]=((int32_t*)twc)[0]; - ((int32_t*)twd)[j]=((int32_t*)twd)[0]; + + for (j=1; j<4; j++) { + ((int32_t *)twa)[j]=((int32_t *)twa)[0]; + ((int32_t *)twb)[j]=((int32_t *)twb)[0]; + ((int32_t *)twc)[j]=((int32_t *)twc)[0]; + ((int32_t *)twd)[j]=((int32_t *)twd)[0]; } + twa+=8; twb+=8; twc+=8; - twd+=8; + twd+=8; } } /*----------------------------------------------------------------*/ /* dft library entry points: */ -int dfts_autoinit(void) -{ +int dfts_autoinit(void) { init_rad4(1024,tw1024); init_rad2(2048,tw2048); init_rad4(4096,tw4096); init_rad2(8192,tw8192); init_rad4(16384,tw16384); init_rad2(32768,tw32768); - init_rad3(1536,twa1536,twb1536); init_rad3(3072,twa3072,twb3072); init_rad3(6144,twa6144,twb6144); @@ -9610,8 +8677,6 @@ int dfts_autoinit(void) init_rad3(36864,twa36864,twb36864); init_rad3(49152,twa49152,twb49152); init_rad3(98304,twa98304,twb98304); - - init_rad2_rep(24,tw24); init_rad3_rep(36,twa36,twb36); init_rad4_rep(48,twa48,twb48,twc48); @@ -9652,14 +8717,14 @@ int dfts_autoinit(void) #ifndef MR_MAIN -void dft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){ - AssertFatal((sizeidx>=0 && sizeidx<(int)DFT_SIZE_IDXTABLESIZE),"Invalid dft size index %i\n",sizeidx); - dft_ftab[sizeidx](sigF,sig,scale_flag); +void dft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag) { + AssertFatal((sizeidx>=0 && sizeidx<(int)DFT_SIZE_IDXTABLESIZE),"Invalid dft size index %i\n",sizeidx); + dft_ftab[sizeidx](sigF,sig,scale_flag); }; -void idft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){ - AssertFatal((sizeidx>=0 && sizeidx<(int)IDFT_SIZE_IDXTABLESIZE),"Invalid idft size index %i\n",sizeidx); - idft_ftab[sizeidx](sigF,sig,scale_flag); +void idft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag) { + AssertFatal((sizeidx>=0 && sizeidx<(int)IDFT_SIZE_IDXTABLESIZE),"Invalid idft size index %i\n",sizeidx); + idft_ftab[sizeidx](sigF,sig,scale_flag); }; #endif @@ -9670,24 +8735,17 @@ void idft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){ #include #define LOG_M write_output -int write_output(const char *fname,const char *vname,void *data,int length,int dec,char format) -{ - +int write_output(const char *fname,const char *vname,void *data,int length,int dec,char format) { FILE *fp=NULL; int i; - - printf("Writing %d elements of type %d to %s\n",length,format,fname); - if (format == 10 || format ==11 || format == 12 || format == 13 || format == 14) { fp = fopen(fname,"a+"); } else if (format != 10 && format !=11 && format != 12 && format != 13 && format != 14) { fp = fopen(fname,"w+"); } - - if (fp== NULL) { printf("[OPENAIR][FILE OUTPUT] Cannot open file %s\n",fname); return(-1); @@ -9696,121 +8754,108 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d if (format != 10 && format !=11 && format != 12 && format != 13 && format != 14) fprintf(fp,"%s = [",vname); - switch (format) { - case 0: // real 16-bit + case 0: // real 16-bit + for (i=0; i 0)) + fprintf(fp,"%d + j*(%d),",((short *)data)[i],((short *)data)[i+1]); + else if (i == 2*(length-1)) + fprintf(fp,"%d + j*(%d);",((short *)data)[i],((short *)data)[i+1]); + else if (i == 0) + fprintf(fp,"\n%d + j*(%d),",((short *)data)[i],((short *)data)[i+1]); + } - break; + break; - case 9: // real unsigned 8-bit - for (i=0; i 0)) + fprintf(fp,"%d,",((short *)data)[i]); + else if (i == (length-1)) + fprintf(fp,"%d;",((short *)data)[i]); + else if (i == 0) + fprintf(fp,"\n%d,",((short *)data)[i]); + } - break; - - - case 10 : // case eren 16 bit complex : - - for (i=0; i 0)) - fprintf(fp,"%d + j*(%d),",((short *)data)[i],((short *)data)[i+1]); - else if (i == 2*(length-1)) - fprintf(fp,"%d + j*(%d);",((short *)data)[i],((short *)data)[i+1]); - else if (i == 0) - fprintf(fp,"\n%d + j*(%d),",((short *)data)[i],((short *)data)[i+1]); - - - - } - - break; - - case 11 : //case eren 16 bit real for channel magnitudes: - for (i=0; i 0)) - fprintf(fp,"%d,",((short *)data)[i]); - else if (i == (length-1)) - fprintf(fp,"%d;",((short *)data)[i]); - else if (i == 0) - fprintf(fp,"\n%d,",((short *)data)[i]); - } - - printf("\n erennnnnnnnnnnnnnn: length :%d",length); - break; - - case 12 : // case eren for log2_maxh real unsigned 8 bit - fprintf(fp,"%d \n",((unsigned char *)&data)[0]); - break; + printf("\n erennnnnnnnnnnnnnn: length :%d",length); + break; + case 12 : // case eren for log2_maxh real unsigned 8 bit + fprintf(fp,"%d \n",((unsigned char *)&data)[0]); + break; } if (format != 10 && format !=11 && format !=12 && format != 13 && format != 15) { @@ -9826,10 +8871,7 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d } -int main(int argc, char**argv) -{ - - +int main(int argc, char **argv) { time_stats_t ts; #ifdef __AVX2__ simd256_q15_t x[16384],x2[16384],y[16384],tw0,tw1,tw2,tw3; @@ -9837,204 +8879,210 @@ int main(int argc, char**argv) simd_q15_t x[32768],y[32768],tw0,tw1,tw2,tw3; #endif int i; - simd_q15_t *x128=(simd_q15_t*)x,*y128=(simd_q15_t*)y; - + simd_q15_t *x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y; dfts_autoinit(); - set_taus_seed(0); opp_enabled = 1; - /* - ((int16_t *)&tw0)[0] = 32767; - ((int16_t *)&tw0)[1] = 0; - ((int16_t *)&tw0)[2] = 32767; - ((int16_t *)&tw0)[3] = 0; - ((int16_t *)&tw0)[4] = 32767; - ((int16_t *)&tw0)[5] = 0; - ((int16_t *)&tw0)[6] = 32767; - ((int16_t *)&tw0)[7] = 0; - ((int16_t *)&tw1)[0] = 32767; - ((int16_t *)&tw1)[1] = 0; - ((int16_t *)&tw1)[2] = 32767; - ((int16_t *)&tw1)[3] = 0; - ((int16_t *)&tw1)[4] = 32767; - ((int16_t *)&tw1)[5] = 0; - ((int16_t *)&tw1)[6] = 32767; - ((int16_t *)&tw1)[7] = 0; + /* + ((int16_t *)&tw0)[0] = 32767; + ((int16_t *)&tw0)[1] = 0; + ((int16_t *)&tw0)[2] = 32767; + ((int16_t *)&tw0)[3] = 0; + ((int16_t *)&tw0)[4] = 32767; + ((int16_t *)&tw0)[5] = 0; + ((int16_t *)&tw0)[6] = 32767; + ((int16_t *)&tw0)[7] = 0; - ((int16_t *)&tw2)[0] = 32767; - ((int16_t *)&tw2)[1] = 0; - ((int16_t *)&tw2)[2] = 32767; - ((int16_t *)&tw2)[3] = 0; - ((int16_t *)&tw2)[4] = 32767; - ((int16_t *)&tw2)[5] = 0; - ((int16_t *)&tw2)[6] = 32767; - ((int16_t *)&tw2)[7] = 0; + ((int16_t *)&tw1)[0] = 32767; + ((int16_t *)&tw1)[1] = 0; + ((int16_t *)&tw1)[2] = 32767; + ((int16_t *)&tw1)[3] = 0; + ((int16_t *)&tw1)[4] = 32767; + ((int16_t *)&tw1)[5] = 0; + ((int16_t *)&tw1)[6] = 32767; + ((int16_t *)&tw1)[7] = 0; - ((int16_t *)&tw3)[0] = 32767; - ((int16_t *)&tw3)[1] = 0; - ((int16_t *)&tw3)[2] = 32767; - ((int16_t *)&tw3)[3] = 0; - ((int16_t *)&tw3)[4] = 32767; - ((int16_t *)&tw3)[5] = 0; - ((int16_t *)&tw3)[6] = 32767; - ((int16_t *)&tw3)[7] = 0; - */ - for (i=0;i<300;i++) { + ((int16_t *)&tw2)[0] = 32767; + ((int16_t *)&tw2)[1] = 0; + ((int16_t *)&tw2)[2] = 32767; + ((int16_t *)&tw2)[3] = 0; + ((int16_t *)&tw2)[4] = 32767; + ((int16_t *)&tw2)[5] = 0; + ((int16_t *)&tw2)[6] = 32767; + ((int16_t *)&tw2)[7] = 0; + + ((int16_t *)&tw3)[0] = 32767; + ((int16_t *)&tw3)[1] = 0; + ((int16_t *)&tw3)[2] = 32767; + ((int16_t *)&tw3)[3] = 0; + ((int16_t *)&tw3)[4] = 32767; + ((int16_t *)&tw3)[5] = 0; + ((int16_t *)&tw3)[6] = 32767; + ((int16_t *)&tw3)[7] = 0; + */ + for (i=0; i<300; i++) { #if defined(__x86_64__) || defined(__i386__) #ifndef __AVX2__ - x[i] = _mm_set1_epi32(taus()); - x[i] = _mm_srai_epi16(x[i],4); + x[i] = _mm_set1_epi32(taus()); + x[i] = _mm_srai_epi16(x[i],4); #else - x[i] = _mm256_set1_epi32(taus()); - x[i] = _mm256_srai_epi16(x[i],4); + x[i] = _mm256_set1_epi32(taus()); + x[i] = _mm256_srai_epi16(x[i],4); #endif #elif defined(__arm__) - x[i] = (int16x8_t)vdupq_n_s32(taus()); - x[i] = vshrq_n_s16(x[i],4); + x[i] = (int16x8_t)vdupq_n_s32(taus()); + x[i] = vshrq_n_s16(x[i],4); #endif - } - /* - bfly2_tw1(x,x+1,y,y+1); - printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1]); - printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3]); - printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5]); - printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7]); - bfly2(x,x+1,y,y+1, &tw0); - printf("0(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1]); - printf("1(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3]); - printf("2(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5]); - printf("3(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7]); - bfly2(x,x+1,y,y+1, &tw0); + } - bfly3_tw1(x,x+1,x+2,y, y+1,y+2); - printf("0(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1],((int16_t*)&y[2])[0],((int16_t*)&y[2])[1]); - printf("1(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3],((int16_t*)&y[2])[2],((int16_t*)&y[2])[3]); - printf("2(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5],((int16_t*)&y[2])[4],((int16_t*)&y[2])[5]); - printf("3(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7],((int16_t*)&y[2])[6],((int16_t*)&y[2])[7]); - bfly3(x,x+1,x+2,y, y+1,y+2,&tw0,&tw1); + /* + bfly2_tw1(x,x+1,y,y+1); + printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1]); + printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3]); + printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5]); + printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7]); + bfly2(x,x+1,y,y+1, &tw0); + printf("0(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1]); + printf("1(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3]); + printf("2(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5]); + printf("3(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7]); + bfly2(x,x+1,y,y+1, &tw0); - printf("0(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1],((int16_t*)&y[2])[0],((int16_t*)&y[2])[1]); - printf("1(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3],((int16_t*)&y[2])[2],((int16_t*)&y[2])[3]); - printf("2(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5],((int16_t*)&y[2])[4],((int16_t*)&y[2])[5]); - printf("3(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7],((int16_t*)&y[2])[6],((int16_t*)&y[2])[7]); + bfly3_tw1(x,x+1,x+2,y, y+1,y+2); + printf("0(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1],((int16_t*)&y[2])[0],((int16_t*)&y[2])[1]); + printf("1(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3],((int16_t*)&y[2])[2],((int16_t*)&y[2])[3]); + printf("2(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5],((int16_t*)&y[2])[4],((int16_t*)&y[2])[5]); + printf("3(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7],((int16_t*)&y[2])[6],((int16_t*)&y[2])[7]); + bfly3(x,x+1,x+2,y, y+1,y+2,&tw0,&tw1); + + printf("0(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1],((int16_t*)&y[2])[0],((int16_t*)&y[2])[1]); + printf("1(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3],((int16_t*)&y[2])[2],((int16_t*)&y[2])[3]); + printf("2(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5],((int16_t*)&y[2])[4],((int16_t*)&y[2])[5]); + printf("3(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7],((int16_t*)&y[2])[6],((int16_t*)&y[2])[7]); - bfly4_tw1(x,x+1,x+2,x+3,y, y+1,y+2,y+3); - printf("(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], - ((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1], - ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); + bfly4_tw1(x,x+1,x+2,x+3,y, y+1,y+2,y+3); + printf("(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], + ((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1], + ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); - bfly4(x,x+1,x+2,x+3,y, y+1,y+2,y+3,&tw0,&tw1,&tw2); - printf("0(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], - ((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1], - ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); - printf("1(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], - ((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3], - ((int16_t*)&y[2])[2],((int16_t*)&y[2])[3],((int16_t*)&y[3])[2],((int16_t*)&y[3])[3]); - printf("2(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], - ((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5], - ((int16_t*)&y[2])[4],((int16_t*)&y[2])[5],((int16_t*)&y[3])[4],((int16_t*)&y[3])[5]); - printf("3(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[6],((int16_t*)&x[2])[7],((int16_t*)&x[3])[6],((int16_t*)&x[3])[7], - ((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7], - ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); + bfly4(x,x+1,x+2,x+3,y, y+1,y+2,y+3,&tw0,&tw1,&tw2); + printf("0(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], + ((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1], + ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); + printf("1(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], + ((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3], + ((int16_t*)&y[2])[2],((int16_t*)&y[2])[3],((int16_t*)&y[3])[2],((int16_t*)&y[3])[3]); + printf("2(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], + ((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5], + ((int16_t*)&y[2])[4],((int16_t*)&y[2])[5],((int16_t*)&y[3])[4],((int16_t*)&y[3])[5]); + printf("3(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[6],((int16_t*)&x[2])[7],((int16_t*)&x[3])[6],((int16_t*)&x[3])[7], + ((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7], + ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); - bfly5_tw1(x,x+1,x+2,x+3,x+4,y,y+1,y+2,y+3,y+4); + bfly5_tw1(x,x+1,x+2,x+3,x+4,y,y+1,y+2,y+3,y+4); - for (i=0;i<5;i++) - printf("%d,%d,", - ((int16_t*)&x[i])[0],((int16_t*)&x[i])[1]); - printf("\n"); - for (i=0;i<5;i++) - printf("%d,%d,", - ((int16_t*)&y[i])[0],((int16_t*)&y[i])[1]); - printf("\n"); + for (i=0;i<5;i++) + printf("%d,%d,", + ((int16_t*)&x[i])[0],((int16_t*)&x[i])[1]); + printf("\n"); + for (i=0;i<5;i++) + printf("%d,%d,", + ((int16_t*)&y[i])[0],((int16_t*)&y[i])[1]); + printf("\n"); - bfly5(x,x+1,x+2,x+3,x+4,y, y+1,y+2,y+3,y+4,&tw0,&tw1,&tw2,&tw3); - for (i=0;i<5;i++) - printf("%d,%d,", - ((int16_t*)&x[i])[0],((int16_t*)&x[i])[1]); - printf("\n"); - for (i=0;i<5;i++) - printf("%d,%d,", - ((int16_t*)&y[i])[0],((int16_t*)&y[i])[1]); - printf("\n"); + bfly5(x,x+1,x+2,x+3,x+4,y, y+1,y+2,y+3,y+4,&tw0,&tw1,&tw2,&tw3); + for (i=0;i<5;i++) + printf("%d,%d,", + ((int16_t*)&x[i])[0],((int16_t*)&x[i])[1]); + printf("\n"); + for (i=0;i<5;i++) + printf("%d,%d,", + ((int16_t*)&y[i])[0],((int16_t*)&y[i])[1]); + printf("\n"); - printf("\n\n12-point\n"); - dft12f(x, - x+1, - x+2, - x+3, - x+4, - x+5, - x+6, - x+7, - x+8, - x+9, - x+10, - x+11, - y, - y+1, - y+2, - y+3, - y+4, - y+5, - y+6, - y+7, - y+8, - y+9, - y+10, - y+11); + printf("\n\n12-point\n"); + dft12f(x, + x+1, + x+2, + x+3, + x+4, + x+5, + x+6, + x+7, + x+8, + x+9, + x+10, + x+11, + y, + y+1, + y+2, + y+3, + y+4, + y+5, + y+6, + y+7, + y+8, + y+9, + y+10, + y+11); - printf("X: "); - for (i=0;i<12;i++) - printf("%d,%d,",((int16_t*)(&x[i]))[0],((int16_t *)(&x[i]))[1]); - printf("\nY:"); - for (i=0;i<12;i++) - printf("%d,%d,",((int16_t*)(&y[i]))[0],((int16_t *)(&y[i]))[1]); - printf("\n"); + printf("X: "); + for (i=0;i<12;i++) + printf("%d,%d,",((int16_t*)(&x[i]))[0],((int16_t *)(&x[i]))[1]); + printf("\nY:"); + for (i=0;i<12;i++) + printf("%d,%d,",((int16_t*)(&y[i]))[0],((int16_t *)(&y[i]))[1]); + printf("\n"); - */ + */ - for (i=0;i<32;i++) { - ((int16_t*)x)[i] = (int16_t)((taus()&0xffff))>>5; - } - memset((void*)&y[0],0,16*4); - idft16((int16_t *)x,(int16_t *)y); - printf("\n\n16-point\n"); - printf("X: "); - for (i=0;i<4;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); - printf("\nY:"); + for (i=0; i<32; i++) { + ((int16_t *)x)[i] = (int16_t)((taus()&0xffff))>>5; + } + + memset((void *)&y[0],0,16*4); + idft16((int16_t *)x,(int16_t *)y); + printf("\n\n16-point\n"); + printf("X: "); + + for (i=0; i<4; i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t *)&x[i])[0],((int16_t *)&x[i])[1],((int16_t *)&x[i])[2],((int16_t *)&x[i])[3],((int16_t *)&x[i])[4],((int16_t *)&x[i])[5],((int16_t *)&x[i])[6], + ((int16_t *)&x[i])[7]); + + printf("\nY:"); + + for (i=0; i<4; i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t *)&y[i])[0],((int16_t *)&y[i])[1],((int16_t *)&y[i])[2],((int16_t *)&y[i])[3],((int16_t *)&y[i])[4],((int16_t *)&y[i])[5],((int16_t *)&y[i])[6], + ((int16_t *)&y[i])[7]); + + printf("\n"); + memset((void *)&x[0],0,2048*4); - for (i=0;i<4;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); - printf("\n"); - - memset((void*)&x[0],0,2048*4); - for (i=0; i<2048; i+=4) { - ((int16_t*)x)[i<<1] = 1024; - ((int16_t*)x)[1+(i<<1)] = 0; - ((int16_t*)x)[2+(i<<1)] = 0; - ((int16_t*)x)[3+(i<<1)] = 1024; - ((int16_t*)x)[4+(i<<1)] = -1024; - ((int16_t*)x)[5+(i<<1)] = 0; - ((int16_t*)x)[6+(i<<1)] = 0; - ((int16_t*)x)[7+(i<<1)] = -1024; - } + ((int16_t *)x)[i<<1] = 1024; + ((int16_t *)x)[1+(i<<1)] = 0; + ((int16_t *)x)[2+(i<<1)] = 0; + ((int16_t *)x)[3+(i<<1)] = 1024; + ((int16_t *)x)[4+(i<<1)] = -1024; + ((int16_t *)x)[5+(i<<1)] = 0; + ((int16_t *)x)[6+(i<<1)] = 0; + ((int16_t *)x)[7+(i<<1)] = -1024; + } + /* for (i=0; i<2048; i+=2) { ((int16_t*)x)[i<<1] = 1024; @@ -10042,41 +9090,40 @@ int main(int argc, char**argv) ((int16_t*)x)[2+(i<<1)] = -1024; ((int16_t*)x)[3+(i<<1)] = 0; } - + for (i=0;i<2048*2;i++) { ((int16_t*)x)[i] = i/2;//(int16_t)((taus()&0xffff))>>5; } */ - memset((void*)&x[0],0,64*sizeof(int32_t)); - for (i=2;i<36;i++) { - if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; - else - ((int16_t*)x)[i] = -364; - } - for (i=(128-36);i<128;i++) { - if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; - else - ((int16_t*)x)[i] = -364; - } - idft64((int16_t *)x,(int16_t *)y,1); - + memset((void *)&x[0],0,64*sizeof(int32_t)); + for (i=2; i<36; i++) { + if ((taus() & 1)==0) + ((int16_t *)x)[i] = 364; + else + ((int16_t *)x)[i] = -364; + } + + for (i=(128-36); i<128; i++) { + if ((taus() & 1)==0) + ((int16_t *)x)[i] = 364; + else + ((int16_t *)x)[i] = -364; + } + + idft64((int16_t *)x,(int16_t *)y,1); printf("64-point\n"); printf("X: "); - for (i=0;i<8;i++) + + for (i=0; i<8; i++) print_shorts256("",((int16_t *)x)+(i*16)); printf("\nY:"); - for (i=0;i<8;i++) + for (i=0; i<8; i++) print_shorts256("",((int16_t *)y)+(i*16)); + printf("\n"); - - - - idft64((int16_t *)x,(int16_t *)y,1); idft64((int16_t *)x,(int16_t *)y,1); idft64((int16_t *)x,(int16_t *)y,1); @@ -10086,47 +9133,49 @@ int main(int argc, char**argv) start_meas(&ts); idft64((int16_t *)x,(int16_t *)y,1); stop_meas(&ts); - } + /* printf("\n\n64-point (%f cycles, #trials %d)\n",(double)ts.diff/(double)ts.trials,ts.trials); // LOG_M("x64.m","x64",x,64,1,1); LOG_M("y64.m","y64",y,64,1,1); LOG_M("x64.m","x64",x,64,1,1); */ -/* - printf("X: "); - for (i=0;i<16;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); - printf("\nY:"); + /* + printf("X: "); + for (i=0;i<16;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); + printf("\nY:"); - for (i=0;i<16;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); - printf("\n"); + for (i=0;i<16;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); + printf("\n"); - idft64((int16_t*)y,(int16_t*)x,1); - printf("X: "); - for (i=0;i<16;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); - - for (i=0; i<256; i++) { - ((int16_t*)x)[i] = (int16_t)((taus()&0xffff))>>5; - } -*/ - - memset((void*)&x[0],0,128*4); - for (i=2;i<72;i++) { + idft64((int16_t*)y,(int16_t*)x,1); + printf("X: "); + for (i=0;i<16;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); + + for (i=0; i<256; i++) { + ((int16_t*)x)[i] = (int16_t)((taus()&0xffff))>>5; + } + */ + memset((void *)&x[0],0,128*4); + + for (i=2; i<72; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=(256-72);i<256;i++) { + + for (i=(256-72); i<256; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); for (i=0; i<10000; i++) { @@ -10138,37 +9187,39 @@ int main(int argc, char**argv) printf("\n\n128-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y128.m","y128",y,128,1,1); LOG_M("x128.m","x128",x,128,1,1); -/* - printf("X: "); - for (i=0;i<32;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); - printf("\nY:"); - - for (i=0;i<32;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); - printf("\n"); -*/ + /* + printf("X: "); + for (i=0;i<32;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); + printf("\nY:"); + for (i=0;i<32;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); + printf("\n"); + */ /* for (i=0; i<512; i++) { ((int16_t*)x)[i] = (int16_t)((taus()&0xffff))>>5; } - + memset((void*)&y[0],0,256*4); */ - memset((void*)&x[0],0,256*sizeof(int32_t)); - for (i=2;i<144;i++) { + memset((void *)&x[0],0,256*sizeof(int32_t)); + + for (i=2; i<144; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=(512-144);i<512;i++) { + + for (i=(512-144); i<512; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); for (i=0; i<10000; i++) { @@ -10180,22 +9231,24 @@ int main(int argc, char**argv) printf("\n\n256-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y256.m","y256",y,256,1,1); LOG_M("x256.m","x256",x,256,1,1); + memset((void *)&x[0],0,512*sizeof(int32_t)); - memset((void*)&x[0],0,512*sizeof(int32_t)); - for (i=2;i<302;i++) { + for (i=2; i<302; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=(1024-300);i<1024;i++) { + + for (i=(1024-300); i<1024; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft512((int16_t *)x,(int16_t *)y,1); @@ -10215,20 +9268,22 @@ int main(int argc, char**argv) printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); printf("\n"); */ + memset((void *)x,0,1024*sizeof(int32_t)); - memset((void*)x,0,1024*sizeof(int32_t)); - for (i=2;i<602;i++) { + for (i=2; i<602; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*724;i<2048;i++) { + + for (i=2*724; i<2048; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); for (i=0; i<10000; i++) { @@ -10240,21 +9295,22 @@ int main(int argc, char**argv) printf("\n\n1024-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y1024.m","y1024",y,1024,1,1); LOG_M("x1024.m","x1024",x,1024,1,1); + memset((void *)x,0,1536*sizeof(int32_t)); + for (i=2; i<1202; i++) { + if ((taus() & 1)==0) + ((int16_t *)x)[i] = 364; + else + ((int16_t *)x)[i] = -364; + } - memset((void*)x,0,1536*sizeof(int32_t)); - for (i=2;i<1202;i++) { + for (i=2*(1536-600); i<3072; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; - } - for (i=2*(1536-600);i<3072;i++) { - if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; - else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); for (i=0; i<10000; i++) { @@ -10266,21 +9322,22 @@ int main(int argc, char**argv) printf("\n\n1536-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); write_output("y1536.m","y1536",y,1536,1,1); write_output("x1536.m","x1536",x,1536,1,1); + memset((void *)x,0,2048*sizeof(int32_t)); + for (i=2; i<1202; i++) { + if ((taus() & 1)==0) + ((int16_t *)x)[i] = 364; + else + ((int16_t *)x)[i] = -364; + } - memset((void*)x,0,2048*sizeof(int32_t)); - for (i=2;i<1202;i++) { + for (i=2*(2048-600); i<4096; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; - } - for (i=2*(2048-600);i<4096;i++) { - if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; - else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); for (i=0; i<10000; i++) { @@ -10292,20 +9349,21 @@ int main(int argc, char**argv) printf("\n\n2048-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y2048.m","y2048",y,2048,1,1); LOG_M("x2048.m","x2048",x,2048,1,1); + // NR 80Mhz, 217 PRB, 3/4 sampling + memset((void *)x, 0, 3072*sizeof(int32_t)); -// NR 80Mhz, 217 PRB, 3/4 sampling - memset((void*)x, 0, 3072*sizeof(int32_t)); - for (i=2;i<2506;i++) { + for (i=2; i<2506; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(3072-1252);i<6144;i++) { + + for (i=2*(3072-1252); i<6144; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } reset_meas(&ts); @@ -10319,21 +9377,22 @@ int main(int argc, char**argv) printf("\n\n3072-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); write_output("y3072.m","y3072",y,3072,1,1); write_output("x3072.m","x3072",x,3072,1,1); + memset((void *)x,0,4096*sizeof(int32_t)); + for (i=0; i<2400; i++) { + if ((taus() & 1)==0) + ((int16_t *)x)[i] = 364; + else + ((int16_t *)x)[i] = -364; + } - memset((void*)x,0,4096*sizeof(int32_t)); - for (i=0;i<2400;i++) { + for (i=2*(4096-1200); i<8192; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; - } - for (i=2*(4096-1200);i<8192;i++) { - if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; - else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); for (i=0; i<10000; i++) { @@ -10345,23 +9404,23 @@ int main(int argc, char**argv) printf("\n\n4096-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y4096.m","y4096",y,4096,1,1); LOG_M("x4096.m","x4096",x,4096,1,1); - dft4096((int16_t *)y,(int16_t *)x2,1); LOG_M("x4096_2.m","x4096_2",x2,4096,1,1); + // NR 160Mhz, 434 PRB, 3/4 sampling + memset((void *)x, 0, 6144*sizeof(int32_t)); -// NR 160Mhz, 434 PRB, 3/4 sampling - memset((void*)x, 0, 6144*sizeof(int32_t)); - for (i=2;i<5010;i++) { + for (i=2; i<5010; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(6144-2504);i<12288;i++) { + + for (i=2*(6144-2504); i<12288; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } reset_meas(&ts); @@ -10375,21 +9434,24 @@ int main(int argc, char**argv) printf("\n\n6144-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); write_output("y6144.m","y6144",y,6144,1,1); write_output("x6144.m","x6144",x,6144,1,1); + memset((void *)x,0,8192*sizeof(int32_t)); - memset((void*)x,0,8192*sizeof(int32_t)); - for (i=2;i<4802;i++) { + for (i=2; i<4802; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(8192-2400);i<16384;i++) { + + for (i=2*(8192-2400); i<16384; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft8192((int16_t *)x,(int16_t *)y,1); @@ -10399,21 +9461,24 @@ int main(int argc, char**argv) printf("\n\n8192-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y8192.m","y8192",y,8192,1,1); LOG_M("x8192.m","x8192",x,8192,1,1); + memset((void *)x,0,16384*sizeof(int32_t)); - memset((void*)x,0,16384*sizeof(int32_t)); - for (i=2;i<9602;i++) { + for (i=2; i<9602; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(16384-4800);i<32768;i++) { + + for (i=2*(16384-4800); i<32768; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); dft16384((int16_t *)x,(int16_t *)y,1); @@ -10423,21 +9488,24 @@ int main(int argc, char**argv) printf("\n\n16384-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y16384.m","y16384",y,16384,1,1); LOG_M("x16384.m","x16384",x,16384,1,1); + memset((void *)x,0,1536*sizeof(int32_t)); - memset((void*)x,0,1536*sizeof(int32_t)); - for (i=2;i<1202;i++) { + for (i=2; i<1202; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(1536-600);i<3072;i++) { + + for (i=2*(1536-600); i<3072; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft1536((int16_t *)x,(int16_t *)y,1); @@ -10447,25 +9515,27 @@ int main(int argc, char**argv) printf("\n\n1536-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y1536.m","y1536",y,1536,1,1); LOG_M("x1536.m","x1536",x,1536,1,1); - printf("\n\n1536-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y8192.m","y8192",y,8192,1,1); LOG_M("x8192.m","x8192",x,8192,1,1); + memset((void *)x,0,3072*sizeof(int32_t)); - memset((void*)x,0,3072*sizeof(int32_t)); - for (i=2;i<1202;i++) { + for (i=2; i<1202; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(3072-600);i<3072;i++) { + + for (i=2*(3072-600); i<3072; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft3072((int16_t *)x,(int16_t *)y,1); @@ -10475,21 +9545,24 @@ int main(int argc, char**argv) printf("\n\n3072-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y3072.m","y3072",y,3072,1,1); LOG_M("x3072.m","x3072",x,3072,1,1); + memset((void *)x,0,6144*sizeof(int32_t)); - memset((void*)x,0,6144*sizeof(int32_t)); - for (i=2;i<4802;i++) { + for (i=2; i<4802; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(6144-2400);i<12288;i++) { + + for (i=2*(6144-2400); i<12288; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft6144((int16_t *)x,(int16_t *)y,1); @@ -10499,21 +9572,24 @@ int main(int argc, char**argv) printf("\n\n6144-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y6144.m","y6144",y,6144,1,1); LOG_M("x6144.m","x6144",x,6144,1,1); + memset((void *)x,0,12288*sizeof(int32_t)); - memset((void*)x,0,12288*sizeof(int32_t)); - for (i=2;i<9602;i++) { + for (i=2; i<9602; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(12288-4800);i<24576;i++) { + + for (i=2*(12288-4800); i<24576; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft12288((int16_t *)x,(int16_t *)y,1); @@ -10523,21 +9599,24 @@ int main(int argc, char**argv) printf("\n\n12288-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y12288.m","y12288",y,12288,1,1); LOG_M("x12288.m","x12288",x,12288,1,1); + memset((void *)x,0,18432*sizeof(int32_t)); - memset((void*)x,0,18432*sizeof(int32_t)); - for (i=2;i<14402;i++) { + for (i=2; i<14402; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(18432-7200);i<36864;i++) { + + for (i=2*(18432-7200); i<36864; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft18432((int16_t *)x,(int16_t *)y,1); @@ -10547,21 +9626,24 @@ int main(int argc, char**argv) printf("\n\n18432-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y18432.m","y18432",y,18432,1,1); LOG_M("x18432.m","x18432",x,18432,1,1); + memset((void *)x,0,24576*sizeof(int32_t)); - memset((void*)x,0,24576*sizeof(int32_t)); - for (i=2;i<19202;i++) { + for (i=2; i<19202; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } - for (i=2*(24576-19200);i<49152;i++) { + + for (i=2*(24576-19200); i<49152; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft24576((int16_t *)x,(int16_t *)y,1); @@ -10571,22 +9653,24 @@ int main(int argc, char**argv) printf("\n\n24576-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y24576.m","y24576",y,24576,1,1); LOG_M("x24576.m","x24576",x,24576,1,1); + memset((void *)x,0,2*18432*sizeof(int32_t)); + for (i=2; i<(2*14402); i++) { + if ((taus() & 1)==0) + ((int16_t *)x)[i] = 364; + else + ((int16_t *)x)[i] = -364; + } - memset((void*)x,0,2*18432*sizeof(int32_t)); - for (i=2;i<(2*14402);i++) { + for (i=2*(36864-14400); i<(36864*2); i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; - } - for (i=2*(36864-14400);i<(36864*2);i++) { - if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; - else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); dft36864((int16_t *)x,(int16_t *)y,1); @@ -10596,22 +9680,24 @@ int main(int argc, char**argv) printf("\n\n36864-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y36864.m","y36864",y,36864,1,1); LOG_M("x36864.m","x36864",x,36864,1,1); + memset((void *)x,0,49152*sizeof(int32_t)); - - memset((void*)x,0,49152*sizeof(int32_t)); - for (i=2;i<28402;i++) { + for (i=2; i<28402; i++) { if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; + ((int16_t *)x)[i] = 364; else - ((int16_t*)x)[i] = -364; - } - for (i=2*(49152-14400);i<98304;i++) { - if ((taus() & 1)==0) - ((int16_t*)x)[i] = 364; - else - ((int16_t*)x)[i] = -364; + ((int16_t *)x)[i] = -364; } + + for (i=2*(49152-14400); i<98304; i++) { + if ((taus() & 1)==0) + ((int16_t *)x)[i] = 364; + else + ((int16_t *)x)[i] = -364; + } + reset_meas(&ts); + for (i=0; i<10000; i++) { start_meas(&ts); idft49152((int16_t *)x,(int16_t *)y,1); @@ -10629,22 +9715,22 @@ int main(int argc, char**argv) memset((void*)x,0,dftsizes[n]*8*sizeof(int16_t)); for (i=0;i TS 24.007 typedef enum { - SGSsessionmanagementmessages=0x2e, //LTEbox: 0xC0 ??? -SGSmobilitymanagementmessages=0x7e, + SGSsessionmanagementmessages=0x2e, //LTEbox: 0xC0 ??? + SGSmobilitymanagementmessages=0x7e, } Extendedprotocoldiscriminator_t; typedef enum { -Registrationrequest=0x41, -Registrationaccept=0x42, -Registrationcomplete=0x43, -Registrationreject=0x44, -DeregistrationrequestUEoriginating=0x45, -DeregistrationacceptUEoriginating=0x46, -DeregistrationrequestUEterminated=0x47, -DeregistrationacceptUEterminated=0x48, -Servicerequest=0x4c, -Servicereject=0x4d, -Serviceaccept=0x4e, -Controlplaneservicerequest=0x4f, -Networkslicespecificauthenticationcommand=0x50, -Networkslicespecificauthenticationcomplete=0x51, -Networkslicespecificauthenticationresult=0x52, -Configurationupdatecommand=0x54, -Configurationupdatecomplete=0x55, -Authenticationrequest=0x56, -Authenticationresponse=0x57, -Authenticationreject=0x58, -Authenticationfailure=0x59, -Authenticationresult=0x5a, -Identityrequest=0x5b, -Identityresponse=0x5c, -Securitymodecommand=0x5d, -Securitymodecomplete=0x5e, -Securitymodereject=0x5f, -SGMMstatus=0x64, -Notification=0x65, -Notificationresponse=0x66, -ULNAStransport=0x67, -DLNAStransport=0x68, -PDUsessionestablishmentrequest=0xc1, -PDUsessionestablishmentaccept=0xc2, -PDUsessionestablishmentreject=0xc3, -PDUsessionauthenticationcommand=0xc5, -PDUsessionauthenticationcomplete=0xc6, -PDUsessionauthenticationresult=0xc7, -PDUsessionmodificationrequest=0xc9, -PDUsessionmodificationreject=0xca, -PDUsessionmodificationcommand=0xcb, -PDUsessionmodificationcomplete=0xcc, -PDUsessionmodificationcommandreject=0xcd, -PDUsessionreleaserequest=0xd1, -PDUsessionreleasereject=0xd2, -PDUsessionreleasecommand=0xd3, -PDUsessionreleasecomplete=0xd4, -SGSMstatus=0xd6, + Registrationrequest=0x41, + Registrationaccept=0x42, + Registrationcomplete=0x43, + Registrationreject=0x44, + DeregistrationrequestUEoriginating=0x45, + DeregistrationacceptUEoriginating=0x46, + DeregistrationrequestUEterminated=0x47, + DeregistrationacceptUEterminated=0x48, + Servicerequest=0x4c, + Servicereject=0x4d, + Serviceaccept=0x4e, + Controlplaneservicerequest=0x4f, + Networkslicespecificauthenticationcommand=0x50, + Networkslicespecificauthenticationcomplete=0x51, + Networkslicespecificauthenticationresult=0x52, + Configurationupdatecommand=0x54, + Configurationupdatecomplete=0x55, + Authenticationrequest=0x56, + Authenticationresponse=0x57, + Authenticationreject=0x58, + Authenticationfailure=0x59, + Authenticationresult=0x5a, + Identityrequest=0x5b, + Identityresponse=0x5c, + Securitymodecommand=0x5d, + Securitymodecomplete=0x5e, + Securitymodereject=0x5f, + SGMMstatus=0x64, + Notification=0x65, + Notificationresponse=0x66, + ULNAStransport=0x67, + DLNAStransport=0x68, + PDUsessionestablishmentrequest=0xc1, + PDUsessionestablishmentaccept=0xc2, + PDUsessionestablishmentreject=0xc3, + PDUsessionauthenticationcommand=0xc5, + PDUsessionauthenticationcomplete=0xc6, + PDUsessionauthenticationresult=0xc7, + PDUsessionmodificationrequest=0xc9, + PDUsessionmodificationreject=0xca, + PDUsessionmodificationcommand=0xcb, + PDUsessionmodificationcomplete=0xcc, + PDUsessionmodificationcommandreject=0xcd, + PDUsessionreleaserequest=0xd1, + PDUsessionreleasereject=0xd2, + PDUsessionreleasecommand=0xd3, + PDUsessionreleasecomplete=0xd4, + SGSMstatus=0xd6, } SGSmobilitymanagementmessages_t; // TS 24.501 typedef enum { - notsecurityprotected=0, -Integrityprotected=1, -Integrityprotectedandciphered=2, -Integrityprotectedwithnew5GNASsecuritycontext=3, -Integrityprotectedandcipheredwithnew5GNASsecuritycontext=4, + notsecurityprotected=0, + Integrityprotected=1, + Integrityprotectedandciphered=2, + Integrityprotectedwithnew5GNASsecuritycontext=3, + Integrityprotectedandcipheredwithnew5GNASsecuritycontext=4, } Security_header_t; typedef enum { -SUCI=0, -SGGUTI, -IMEI, -SGSTMSI, -IMEISV, -MACaddress, -EUI64, + SUCI=0, + SGGUTI, + IMEI, + SGSTMSI, + IMEISV, + MACaddress, + EUI64, } identitytype_t; // table 9.11.3.2.1 #define FOREACH_CAUSE(CAUSE_DEF) \ -CAUSE_DEF(Illegal_UE,0x3 )\ -CAUSE_DEF(PEI_not_accepted,0x5 )\ -CAUSE_DEF(Illegal_ME,0x6 )\ -CAUSE_DEF(SGS_services_not_allowed,0x7 )\ -CAUSE_DEF(UE_identity_cannot_be_derived_by_the_network,0x9 )\ -CAUSE_DEF(Implicitly_de_registered,0x0a )\ -CAUSE_DEF(PLMN_not_allowed,0x0b )\ -CAUSE_DEF(Tracking_area_not_allowed,0x0c )\ -CAUSE_DEF(Roaming_not_allowed_in_this_tracking_area,0x0d )\ -CAUSE_DEF(No_suitable_cells_in_tracking_area,0x0f )\ -CAUSE_DEF(MAC_failure,0x14 )\ -CAUSE_DEF(Synch_failure,0x15 )\ -CAUSE_DEF(Congestion,0x16 )\ -CAUSE_DEF(UE_security_capabilities_mismatch,0x17 )\ -CAUSE_DEF(Security_mode_rejected_unspecified,0x18 )\ -CAUSE_DEF(Non_5G_authentication_unacceptable,0x1a )\ -CAUSE_DEF(N1_mode_not_allowed,0x1b )\ -CAUSE_DEF(Restricted_service_area,0x1c )\ -CAUSE_DEF(Redirection_to_EPC_required,0x1f )\ -CAUSE_DEF(LADN_not_available,0x2b )\ -CAUSE_DEF(No_network_slices_available,0x3e )\ -CAUSE_DEF(Maximum_number_of_PDU_sessions_reached,0x41 )\ -CAUSE_DEF(Insufficient_resources_for_specific_slice_and_DNN,0x43 )\ -CAUSE_DEF(Insufficient_resources_for_specific_slice,0x45 )\ -CAUSE_DEF(ngKSI_already_in_use,0x47 )\ -CAUSE_DEF(Non_3GPP_access_to_5GCN_not_allowed,0x48 )\ -CAUSE_DEF(Serving_network_not_authorized,0x49 )\ -CAUSE_DEF(Temporarily_not_authorized_for_this_SNPN,0x4A )\ -CAUSE_DEF(Permanently_not_authorized_for_this_SNPN,0x4b )\ -CAUSE_DEF(Not_authorized_for_this_CAG_or_authorized_for_CAG_cells_only,0x4c )\ -CAUSE_DEF(Wireline_access_area_not_allowed,0x4d )\ -CAUSE_DEF(Payload_was_not_forwarded,0x5a )\ -CAUSE_DEF(DNN_not_supported_or_not_subscribed_in_the_slice,0x5b )\ -CAUSE_DEF(Insufficient_user_plane_resources_for_the_PDU_session,0x5c )\ -CAUSE_DEF(Semantically_incorrect_message,0x5f )\ -CAUSE_DEF(Invalid_mandatory_information,0x60 )\ -CAUSE_DEF(Message_type_non_existent_or_not_implemented,0x61 )\ -CAUSE_DEF(Message_type_not_compatible_with_the_protocol_state,0x62 )\ -CAUSE_DEF(Information_element_non_existent_or_not_implemented,0x63 )\ -CAUSE_DEF(Conditional_IE_error,0x64 )\ -CAUSE_DEF(Message_not_compatible_with_the_protocol_state,0x65 )\ -CAUSE_DEF(Protocol_error_unspecified,0x67 ) + CAUSE_DEF(Illegal_UE,0x3 )\ + CAUSE_DEF(PEI_not_accepted,0x5 )\ + CAUSE_DEF(Illegal_ME,0x6 )\ + CAUSE_DEF(SGS_services_not_allowed,0x7 )\ + CAUSE_DEF(UE_identity_cannot_be_derived_by_the_network,0x9 )\ + CAUSE_DEF(Implicitly_de_registered,0x0a )\ + CAUSE_DEF(PLMN_not_allowed,0x0b )\ + CAUSE_DEF(Tracking_area_not_allowed,0x0c )\ + CAUSE_DEF(Roaming_not_allowed_in_this_tracking_area,0x0d )\ + CAUSE_DEF(No_suitable_cells_in_tracking_area,0x0f )\ + CAUSE_DEF(MAC_failure,0x14 )\ + CAUSE_DEF(Synch_failure,0x15 )\ + CAUSE_DEF(Congestion,0x16 )\ + CAUSE_DEF(UE_security_capabilities_mismatch,0x17 )\ + CAUSE_DEF(Security_mode_rejected_unspecified,0x18 )\ + CAUSE_DEF(Non_5G_authentication_unacceptable,0x1a )\ + CAUSE_DEF(N1_mode_not_allowed,0x1b )\ + CAUSE_DEF(Restricted_service_area,0x1c )\ + CAUSE_DEF(Redirection_to_EPC_required,0x1f )\ + CAUSE_DEF(LADN_not_available,0x2b )\ + CAUSE_DEF(No_network_slices_available,0x3e )\ + CAUSE_DEF(Maximum_number_of_PDU_sessions_reached,0x41 )\ + CAUSE_DEF(Insufficient_resources_for_specific_slice_and_DNN,0x43 )\ + CAUSE_DEF(Insufficient_resources_for_specific_slice,0x45 )\ + CAUSE_DEF(ngKSI_already_in_use,0x47 )\ + CAUSE_DEF(Non_3GPP_access_to_5GCN_not_allowed,0x48 )\ + CAUSE_DEF(Serving_network_not_authorized,0x49 )\ + CAUSE_DEF(Temporarily_not_authorized_for_this_SNPN,0x4A )\ + CAUSE_DEF(Permanently_not_authorized_for_this_SNPN,0x4b )\ + CAUSE_DEF(Not_authorized_for_this_CAG_or_authorized_for_CAG_cells_only,0x4c )\ + CAUSE_DEF(Wireline_access_area_not_allowed,0x4d )\ + CAUSE_DEF(Payload_was_not_forwarded,0x5a )\ + CAUSE_DEF(DNN_not_supported_or_not_subscribed_in_the_slice,0x5b )\ + CAUSE_DEF(Insufficient_user_plane_resources_for_the_PDU_session,0x5c )\ + CAUSE_DEF(Semantically_incorrect_message,0x5f )\ + CAUSE_DEF(Invalid_mandatory_information,0x60 )\ + CAUSE_DEF(Message_type_non_existent_or_not_implemented,0x61 )\ + CAUSE_DEF(Message_type_not_compatible_with_the_protocol_state,0x62 )\ + CAUSE_DEF(Information_element_non_existent_or_not_implemented,0x63 )\ + CAUSE_DEF(Conditional_IE_error,0x64 )\ + CAUSE_DEF(Message_not_compatible_with_the_protocol_state,0x65 )\ + CAUSE_DEF(Protocol_error_unspecified,0x67 ) /* Map task id to printable name. */ typedef struct { - int id; - char text[256]; -} cause_text_info_t; + int id; + char text[256]; +} cause_text_info_t; #define CAUSE_TEXT(LabEl, nUmID) {nUmID, #LabEl}, static const cause_text_info_t cause_text_info[] = { @@ -142,49 +142,49 @@ typedef enum { //_table_9.11.4.2.1:_5GSM_cause_information_element #define FOREACH_CAUSE_SECU(CAUSE_SECU_DEF) \ -CAUSE_SECU_DEF(Security_Operator_determined_barring,0x08 )\ -CAUSE_SECU_DEF(Security_Insufficient_resources,0x1a )\ -CAUSE_SECU_DEF(Security_Missing_or_unknown_DNN,0x1b )\ -CAUSE_SECU_DEF(Security_Unknown_PDU_session_type,0x1c )\ -CAUSE_SECU_DEF(Security_User_authentication_or_authorization_failed,0x1d )\ -CAUSE_SECU_DEF(Security_Request_rejected_unspecified,0x1f )\ -CAUSE_SECU_DEF(Security_Service_option_not_supported,0x20 )\ -CAUSE_SECU_DEF(Security_Requested_service_option_not_subscribed,0x21 )\ -CAUSE_SECU_DEF(Security_Service_option_temporarily_out_of_order,0x22 )\ -CAUSE_SECU_DEF(Security_PTI_already_in_use,0x23 )\ -CAUSE_SECU_DEF(Security_Regular_deactivation,0x24 )\ -CAUSE_SECU_DEF(Security_Network_failure,0x26 )\ -CAUSE_SECU_DEF(Security_Reactivation_requested,0x27 )\ -CAUSE_SECU_DEF(Security_Semantic_error_in_the_TFT_operation,0x29 )\ -CAUSE_SECU_DEF(Security_Syntactical_error_in_the_TFT_operation,0x2a )\ -CAUSE_SECU_DEF(Security_Invalid_PDU_session_identity,0x2b )\ -CAUSE_SECU_DEF(Security_Semantic_errors_in_packet_filter,0x2c )\ -CAUSE_SECU_DEF(Security_Syntactical_error_in_packet_filter,0x2d )\ -CAUSE_SECU_DEF(Security_Out_of_LADN_service_area,0x2e )\ -CAUSE_SECU_DEF(Security_PTI_mismatch,0x2f )\ -CAUSE_SECU_DEF(Security_PDU_session_type_IPv4_only_allowed,0x32 )\ -CAUSE_SECU_DEF(Security_PDU_session_type_IPv6_only_allowed,0x33 )\ -CAUSE_SECU_DEF(Security_PDU_session_does_not_exist,0x36 )\ -CAUSE_SECU_DEF(Security_PDU_session_type_IPv4v6_only_allowed,0x39 )\ -CAUSE_SECU_DEF(Security_PDU_session_type_Unstructured_only_allowed,0x3a )\ -CAUSE_SECU_DEF(Security_PDU_session_type_Ethernet_only_allowed,0x3d )\ -CAUSE_SECU_DEF(Security_Insufficient_resources_for_specific_slice_and_DNN,0x43 )\ -CAUSE_SECU_DEF(Security_Not_supported_SSC_mode,0x44 )\ -CAUSE_SECU_DEF(Security_Insufficient_resources_for_specific_slice,0x45 )\ -CAUSE_SECU_DEF(Security_Missing_or_unknown_DNN_in_a_slice,0x46 )\ -CAUSE_SECU_DEF(Security_Invalid_PTI_value,0x51 )\ -CAUSE_SECU_DEF(Security_Maximum_data_rate_per_UE_for_user_plane_integrity_protection_is_too_low,0x52 )\ -CAUSE_SECU_DEF(Security_Semantic_error_in_the_QoS_operation,0x53 )\ -CAUSE_SECU_DEF(Security_Syntactical_error_in_the_QoS_operation,0x54 )\ -CAUSE_SECU_DEF(Security_Invalid_mapped_EPS_bearer_identity,0x55 )\ -CAUSE_SECU_DEF(Security_Semantically_incorrect_message,0x5f )\ -CAUSE_SECU_DEF(Security_Invalid_mandatory_information,0x60 )\ -CAUSE_SECU_DEF(Security_Message_type_non_existent_or_not_implemented,0x61 )\ -CAUSE_SECU_DEF(Security_Message_type_not_compatible_with_the_protocol_state,0x62 )\ -CAUSE_SECU_DEF(Security_Information_element_non_existent_or_not_implemented,0x63 )\ -CAUSE_SECU_DEF(Security_Conditional_IE_error,0x64 )\ -CAUSE_SECU_DEF(Security_Message_not_compatible_with_the_protocol_state,0x65 )\ -CAUSE_SECU_DEF(Security_Protocol_error_unspecified,0x6f ) + CAUSE_SECU_DEF(Security_Operator_determined_barring,0x08 )\ + CAUSE_SECU_DEF(Security_Insufficient_resources,0x1a )\ + CAUSE_SECU_DEF(Security_Missing_or_unknown_DNN,0x1b )\ + CAUSE_SECU_DEF(Security_Unknown_PDU_session_type,0x1c )\ + CAUSE_SECU_DEF(Security_User_authentication_or_authorization_failed,0x1d )\ + CAUSE_SECU_DEF(Security_Request_rejected_unspecified,0x1f )\ + CAUSE_SECU_DEF(Security_Service_option_not_supported,0x20 )\ + CAUSE_SECU_DEF(Security_Requested_service_option_not_subscribed,0x21 )\ + CAUSE_SECU_DEF(Security_Service_option_temporarily_out_of_order,0x22 )\ + CAUSE_SECU_DEF(Security_PTI_already_in_use,0x23 )\ + CAUSE_SECU_DEF(Security_Regular_deactivation,0x24 )\ + CAUSE_SECU_DEF(Security_Network_failure,0x26 )\ + CAUSE_SECU_DEF(Security_Reactivation_requested,0x27 )\ + CAUSE_SECU_DEF(Security_Semantic_error_in_the_TFT_operation,0x29 )\ + CAUSE_SECU_DEF(Security_Syntactical_error_in_the_TFT_operation,0x2a )\ + CAUSE_SECU_DEF(Security_Invalid_PDU_session_identity,0x2b )\ + CAUSE_SECU_DEF(Security_Semantic_errors_in_packet_filter,0x2c )\ + CAUSE_SECU_DEF(Security_Syntactical_error_in_packet_filter,0x2d )\ + CAUSE_SECU_DEF(Security_Out_of_LADN_service_area,0x2e )\ + CAUSE_SECU_DEF(Security_PTI_mismatch,0x2f )\ + CAUSE_SECU_DEF(Security_PDU_session_type_IPv4_only_allowed,0x32 )\ + CAUSE_SECU_DEF(Security_PDU_session_type_IPv6_only_allowed,0x33 )\ + CAUSE_SECU_DEF(Security_PDU_session_does_not_exist,0x36 )\ + CAUSE_SECU_DEF(Security_PDU_session_type_IPv4v6_only_allowed,0x39 )\ + CAUSE_SECU_DEF(Security_PDU_session_type_Unstructured_only_allowed,0x3a )\ + CAUSE_SECU_DEF(Security_PDU_session_type_Ethernet_only_allowed,0x3d )\ + CAUSE_SECU_DEF(Security_Insufficient_resources_for_specific_slice_and_DNN,0x43 )\ + CAUSE_SECU_DEF(Security_Not_supported_SSC_mode,0x44 )\ + CAUSE_SECU_DEF(Security_Insufficient_resources_for_specific_slice,0x45 )\ + CAUSE_SECU_DEF(Security_Missing_or_unknown_DNN_in_a_slice,0x46 )\ + CAUSE_SECU_DEF(Security_Invalid_PTI_value,0x51 )\ + CAUSE_SECU_DEF(Security_Maximum_data_rate_per_UE_for_user_plane_integrity_protection_is_too_low,0x52 )\ + CAUSE_SECU_DEF(Security_Semantic_error_in_the_QoS_operation,0x53 )\ + CAUSE_SECU_DEF(Security_Syntactical_error_in_the_QoS_operation,0x54 )\ + CAUSE_SECU_DEF(Security_Invalid_mapped_EPS_bearer_identity,0x55 )\ + CAUSE_SECU_DEF(Security_Semantically_incorrect_message,0x5f )\ + CAUSE_SECU_DEF(Security_Invalid_mandatory_information,0x60 )\ + CAUSE_SECU_DEF(Security_Message_type_non_existent_or_not_implemented,0x61 )\ + CAUSE_SECU_DEF(Security_Message_type_not_compatible_with_the_protocol_state,0x62 )\ + CAUSE_SECU_DEF(Security_Information_element_non_existent_or_not_implemented,0x63 )\ + CAUSE_SECU_DEF(Security_Conditional_IE_error,0x64 )\ + CAUSE_SECU_DEF(Security_Message_not_compatible_with_the_protocol_state,0x65 )\ + CAUSE_SECU_DEF(Security_Protocol_error_unspecified,0x6f ) static const cause_text_info_t cause_secu_text_info[] = { FOREACH_CAUSE_SECU(CAUSE_TEXT) @@ -196,19 +196,19 @@ typedef enum { FOREACH_CAUSE_SECU(CAUSE_ENUM) } cause_secu_id_t; - typedef struct { - Extendedprotocoldiscriminator_t epd:8; - Security_header_t sh:8; - SGSmobilitymanagementmessages_t mt:8; - identitytype_t it:8; +typedef struct { + Extendedprotocoldiscriminator_t epd:8; + Security_header_t sh:8; + SGSmobilitymanagementmessages_t mt:8; + identitytype_t it:8; } Identityrequest_t; // the message continues with the identity value, depending on identity type, see TS 14.501, 9.11.3.4 typedef struct { - Extendedprotocoldiscriminator_t epd:8; - Security_header_t sh:8; - SGSmobilitymanagementmessages_t mt:8; - identitytype_t mi:8; + Extendedprotocoldiscriminator_t epd:8; + Security_header_t sh:8; + SGSmobilitymanagementmessages_t mt:8; + identitytype_t mi:8; } Identityresponse_t; From 384aec0d03366d1e4cca04aec0aae610439dfef2 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 27 Jul 2020 20:35:10 +0200 Subject: [PATCH 022/149] coding 5G SA, add documentation --- cmake_targets/build_oai | 1 + cmake_targets/install_ubuntu20.04 | 877 +++++++++++++++++++++++++++ doc/SW_archi.md | 86 +++ executables/ocp-gnb.c | 4 +- openair1/PHY/INIT/nr_init.c | 1 - openair1/PHY/TOOLS/oai_dfts.c | 2 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 4 + targets/ARCH/rfsimulator/simulator.c | 2 +- 8 files changed, 972 insertions(+), 5 deletions(-) create mode 100644 cmake_targets/install_ubuntu20.04 create mode 100644 doc/SW_archi.md diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 0ed570fd54..97e327ccfb 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -575,6 +575,7 @@ function main() { cmake_file=$DIR/$build_dir/CMakeLists.txt echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file + echo "(project (OpenAirInterface)" >> $cmake_file echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file echo "set ( UE_EXPANSION $UE_EXPANSION )" >> $cmake_file diff --git a/cmake_targets/install_ubuntu20.04 b/cmake_targets/install_ubuntu20.04 new file mode 100644 index 0000000000..5a59b9a8cc --- /dev/null +++ b/cmake_targets/install_ubuntu20.04 @@ -0,0 +1,877 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ + +# file build_helper +# brief +# authors Laurent Thomas, Lionel GAUTHIER +# +####################################### +if [ ! -f /etc/os-release ]; then + echo "No /etc/os-release file found. You're likely on an unsupported distro." + exit -1 +fi +OS_DISTRO=$(grep "^ID=" /etc/os-release | sed "s/ID=//" | sed "s/\"//g") +OS_RELEASE=$(grep "^VERSION_ID=" /etc/os-release | sed "s/VERSION_ID=//" | sed "s/\"//g") +case "$OS_DISTRO" in + fedora) OS_BASEDISTRO="fedora"; INSTALLER="dnf"; CMAKE="cmake" ;; + rhel) OS_BASEDISTRO="fedora"; INSTALLER="yum --skip-broken"; CMAKE="cmake3" ;; + centos) OS_BASEDISTRO="fedora"; INSTALLER="yum --skip-broken"; CMAKE="cmake3" ;; + debian) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; + ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; +esac +KERNEL_VERSION=$(uname -r | cut -d '.' -f1) +KERNEL_MAJOR=$(uname -r | cut -d '.' -f2) + +SUDO='sudo -E' + +############################### +## echo and family +############################### +black='\E[30m' +red='\E[31m' +green='\E[32m' +yellow='\E[33m' +blue='\E[1;34m' +magenta='\E[35m' +cyan='\E[36m' +white='\E[37m' +reset_color='\E[00m' +COLORIZE=1 + +cecho() { + # Color-echo + # arg1 = message + # arg2 = color + local default_msg="No Message." + message=${1:-$default_msg} + color=${2:-$green} + [ "$COLORIZE" = "1" ] && message="$color$message$reset_color" + echo -e "$message" + return +} + +echo_error() { cecho "$*" $red ;} +echo_fatal() { cecho "$*" $red; exit -1 ;} +echo_warning() { cecho "$*" $yellow ;} +echo_success() { cecho "$*" $green ;} +echo_info() { cecho "$*" $blue ;} + +######################## +# distribution helpers # +######################## + +# This function return a string to identify the distribution we are running +# If we can't check the distribution, it returns "Unknown" +# This function return always true as exit code by design +# Examples: +# ubuntu16.04 +# debian8.5 +get_distribution_release() { + if [[ ! -z "$OS_DISTRO$OS_RELEASE" ]]; then + echo "$OS_DISTRO$OS_RELEASE" + else + echo Unknown + fi +} + +check_supported_distribution() { + local distribution=$(get_distribution_release) + case "$distribution" in + "ubuntu18.04") return 0 ;; + "ubuntu17.10") return 0 ;; + "ubuntu17.04") return 0 ;; + "ubuntu16.04") return 0 ;; + "ubuntu14.04") return 0 ;; + "fedora24") return 0 ;; + "rhel7") return 0 ;; + "rhel7.6") return 0 ;; + "rhel7.7") return 0 ;; + "centos7") return 0 ;; + esac + return 1 +} + +################## +# Error handlers # +################## + +handler_EXIT() { + local exit_code=$? + [ "$exit_code" -eq 0 ] || echo_error "build have failed" + exit $exit_code +} + +trap handler_EXIT EXIT + +########################### +# Cleaners +########################### + +clean_kernel() { + $SUDO modprobe ip_tables + $SUDO modprobe x_tables + $SUDO iptables -P INPUT ACCEPT + $SUDO iptables -F INPUT + $SUDO iptables -P OUTPUT ACCEPT + $SUDO iptables -F OUTPUT + $SUDO iptables -P FORWARD ACCEPT + $SUDO iptables -F FORWARD + $SUDO iptables -t nat -F + $SUDO iptables -t mangle -F + $SUDO iptables -t filter -F + $SUDO iptables -t raw -F + echo_info "Flushed iptables" + $SUDO rmmod nasmesh > /dev/null 2>&1 + $SUDO rmmod oai_nw_drv > /dev/null 2>&1 + $SUDO rmmod openair_rf > /dev/null 2>&1 + $SUDO rmmod ue_ip > /dev/null 2>&1 + echo_info "removed drivers from kernel" +} + +clean_all_files() { + set_openair_env + dir=$OPENAIR_DIR/cmake_targets + rm -rf $dir/log $OPENAIR_DIR/targets/bin/* + rm -rf $dir/ran_build $dir/ran_build_noLOG + rm -rf $dir/lte-simulators/build + rm -rf $dir/phy_simulators/build $dir/nas_sim_tools/build + rm -rf $dir/oaisim_build_oai/build $dir/oaisim_build_oai/CMakeLists.txt + rm -rf $dir/autotests/bin $dir/autotests/log $dir/autotests/*/build +} + +################################### +# Compilers +################################### + +#check_warnings: +# print error message if the compilation had warnings +#argument: +# $1: log file +check_warnings() { + #we look for 'warning:' in the compilation log file + #this is how gcc starts a warning + #this is not perfect, we may get false positive + warning_count=`grep "warning:" "$1" | egrep -v "jobserver unavailable|disabling jobserver mode" | wc -l` + if [ $warning_count -gt 0 ]; then + echo_error "WARNING: $warning_count warnings. See $1" + fi +} + +compilations() { + cd $OPENAIR_DIR/cmake_targets/$1/build + set +e + { + if [ "$BUILD_COVERITY_SCAN" == "1" ]; then + COV_SCAN_PREFIX="cov-build --dir cov-int" + else + COV_SCAN_PREFIX="" + fi + if [ "$MAKE_CMD" != "" ]; then + $MAKE_CMD $2 + else + if [ "$VERBOSE_COMPILE" == "1" ]; then + $COV_SCAN_PREFIX make -j`nproc` $2 VERBOSE=$VERBOSE_COMPILE + else + $COV_SCAN_PREFIX make -j`nproc` $2 + fi + fi + + } > $dlog/$2.$REL.txt 2>&1 + set -e + echo_info "Log file for compilation has been written to: $dlog/$2.$REL.txt" + if [ -s $3 ] ; then + cp $3 $4 + echo_success "$2 compiled" + check_warnings "$dlog/$2.$REL.txt" + else + echo_error "$2 compilation failed" + exit 1 + fi +} + +############################################ +# External packages installers +############################################ + +install_protobuf_from_source(){ + protobuf_install_log=$OPENAIR_DIR/cmake_targets/log/protobuf_install_log.txt + echo_info "\nInstalling Google Protobuf from sources. The log file for Protobuf installation is here: $protobuf_install_log " + ( + cd /tmp + echo "Downloading protobuf" + #rm -rf /tmp/protobuf-2.6.1.tar.gz* /tmp/protobuf-2.6.1 + #wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz + #tar -xzvf protobuf-2.6.1.tar.gz --owner $USER --group $USER --no-same-owner + #cd protobuf-2.6.1/ + rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 + wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz + tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $(groups | cut -d" " -f1) --no-same-owner + cd protobuf-3.3.0/ + ./configure + echo "Compiling protobuf" + make -j`nproc` + $SUDO make install + $SUDO ldconfig + ) >& $protobuf_install_log +} + +install_protobuf_c_from_source(){ + protobuf_c_install_log=$OPENAIR_DIR/cmake_targets/log/protobuf_c_install_log.txt + echo_info "\nInstalling Google Protobuf_C from sources. The log file for Protobuf_C installation is here: $protobuf_c_install_log " + ( + if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig + fi + cd /tmp + echo "Downloading protobuf-c" + rm -rf /tmp/protobuf-c + git clone https://github.com/protobuf-c/protobuf-c.git + cd protobuf-c + git checkout 2a46af42784abf86804d536f6e0122d47cfeea45 + ./autogen.sh + ./configure + echo "Compiling protobuf-c" + make -j`nproc` + $SUDO make install + $SUDO ldconfig + ) >& $protobuf_c_install_log +} + +install_usrp_uhd_driver_from_source(){ + uhd_install_log=$OPENAIR_DIR/cmake_targets/log/uhd_install_log.txt + echo_info "\nInstalling UHD driver from sources. The log file for UHD driver installation is here: $uhd_install_log " + ( + cd /tmp + echo "Downloading UHD driver" + rm -rf /tmp/uhd + git clone https://github.com/EttusResearch/uhd.git + cd uhd + git checkout tags/v3.13.0.2 + mkdir -p host/build + cd host/build + $CMAKE ../ + echo "Compiling UHD" + make -j`nproc` + make test + $SUDO make install + $SUDO ldconfig + ) >& $uhd_install_log +} + +check_install_usrp_uhd_driver(){ + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + #first we remove old installation + $SUDO apt-get remove -y uhd || true + $SUDO apt-get remove libuhd-dev libuhd003 uhd-host -y || true + v=$(lsb_release -cs) + $SUDO apt-add-repository --remove "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/$v $v main" + # The new USRP repository + # Raphael Defosseux: Adding a loop on adding PPA because in CI the gpg key retrieve may + # timeout due to proxy / network latencies in Eurecom on VM + echo_info "\nAdding PPA repository ettusresearch/uhd\n" + x=0 + while [ $x -le 5 ] + do + if $SUDO add-apt-repository ppa:ettusresearch/uhd -y + then + echo_info "add-apt-repository successful\n" + break + else + echo_info "add-apt-repository failed, retrying...\n" + sleep 30 + fi + x=$((x + 1)) + done + $SUDO apt-get update + $SUDO apt-get -y install python python-tk libboost-all-dev libusb-1.0-0-dev + $SUDO apt-get -y install libuhd-dev libuhd003 uhd-host + elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then + $SUDO $INSTALLER -y install python boost libusb-devel libusbx-devel boost-devel python-mako python-docutils cmake + $SUDO -H pip install requests + if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then + # until EPEL repo hasn't bumped UHD driver to >=3.10 in EPEL, build driver from source + $SUDO $INSTALLER -y remove uhd uhd-devel uhd-firmware + install_usrp_uhd_driver_from_source + else + $SUDO $INSTALLER -y install uhd uhd-devel uhd-firmware + fi + fi +} + +install_usrp_uhd_driver() { + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + # We move uhd-host apart because it depends on linux kernel version + # On newer kernels, it fails to install + $SUDO apt-get -y install uhd-host + fi + # quick workaround for RHE7.6 + local distribution=$(get_distribution_release) + if [ -z $1 ]; then + if [[ "$OS_DISTRO" == "rhel" ]]; then + $SUDO /usr/local/bin/uhd_images_downloader + else + $SUDO uhd_images_downloader + fi + else + if [[ "$OS_DISTRO" == "rhel" ]]; then + $SUDO /usr/local/bin/uhd_images_downloader -i $1 + else + $SUDO uhd_images_downloader -i $1 + fi + fi +} + +install_bladerf_driver_from_source(){ + bladerf_install_log=$OPENAIR_DIR/cmake_targets/log/bladerf_install_log.txt + echo_info "\nInstalling BladeRF driver from sources. The log file for BladeRF driver installation is here: $bladerf_install_log " + ( + cd /tmp + echo "Downloading BladeRF driver" + rm -rf /tmp/bladeRF + git clone https://github.com/Nuand/bladeRF.git + cd bladeRF + git checkout tags/2016.06 + mkdir -p build + cd build + $CMAKE ../ + echo "Compiling BladeRF driver" + make + $SUDO make install + $SUDO ldconfig + echo "Downloading FPGA and firmware images" + cd /tmp/bladeRF + wget --tries=3 --retry-connrefused https://www.nuand.com/fx3/bladeRF_fw_latest.img + wget --tries=3 --retry-connrefused https://www.nuand.com/fpga/hostedx40-latest.rbf + sudo mkdir -p /usr/share/Nuand/bladeRF + sudo mv bladeRF_fw_latest.img /usr/share/Nuand/bladeRF/bladeRF_fw.img + sudo mv hostedx40-latest.rbf /usr/share/Nuand/bladeRF/hostedx40.rbf + ) >& $bladerf_install_log +} + +check_install_bladerf_driver(){ + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + if [ "$(get_distribution_release)" == "ubuntu14.04" ] ; then + $SUDO add-apt-repository -y ppa:bladerf/bladerf + $SUDO apt-get update + fi + $SUDO apt-get install -y bladerf libbladerf-dev + $SUDO apt-get install -y bladerf-firmware-fx3 + $SUDO apt-get install -y bladerf-fpga-hostedx40 + elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then + install_bladerf_driver_from_source + else + echo_error "BladeRF Installer for OAI does not support automatic build. Install BladeRF compiling sources manually from BladeRF website" + fi +} + +flash_firmware_bladerf() { + $SUDO bladeRF-cli --flash-firmware /usr/share/Nuand/bladeRF/bladeRF_fw.img +} + +check_install_lmssdr_driver(){ + if ( [ -d "/usr/local/include/lime" ] && + [ -f "/usr/local/include/lime/LimeSuite.h" ] ) + then + echo_success "Found lmssdr drivers and tools installed from source" + else + echo_error "lmssdr support implies installing lmssdr drivers and tools" \ + " from sources. check:" + echo_info "https://wiki.myriadrf.org/Lime_Suite" + echo_fatal "Cannot compile lmssdr device" + fi + + +} + +install_soapy_from_source(){ + soapy_install_log=$OPENAIR_DIR/cmake_targets/log/soapy_install_log.txt + echo_info "\nInstalling Soapy EcoSystem from source. The log file for Soapy installation is here: $soapy_install_log " + ( + cd /tmp + echo "Downloading SoapySDR" + rm -rf /tmp/soapysdr + git clone -b soapy-sdr-0.7.0 --single-branch https://github.com/pothosware/SoapySDR.git + cd SoapySDR + #git checkout tags/release_003_010_001_001 + mkdir -p build + cd build + $CMAKE ../ + echo "Compiling SoapySDR" + make -j`nproc` + $SUDO make install + $SUDO ldconfig + cd /tmp + echo "Downloading SoapyRemote" + rm -rf /tmp/soapyremote + git clone -b soapy-remote-0.5.0 --single-branch https://github.com/pothosware/SoapyRemote.git + cd SoapyRemote + #git checkout tags/release_003_010_001_001 + mkdir -p build + cd build + cmake ../ + echo "Compiling SoapyRemote" + make -j`nproc` + $SUDO make install + $SUDO ldconfig + ) >& $soapy_install_log +} + +install_soapy_iris_from_source(){ + iris_install_log=$OPENAIR_DIR/cmake_targets/log/iris_install_log.txt + echo_info "\nInstalling Iris driver from source. The log file for Iris driver installation is here: $iris_install_log " + ( + cd /tmp + echo "Downloading SoapyIris" + rm -rf /tmp/sklk-soapyiris + git clone -b soapy-iris-2018.08.0.1 --single-branch https://github.com/skylarkwireless/sklk-soapyiris.git + cd sklk-soapyiris + mkdir -p build + cd build + cmake ../ + echo "Compiling SoapyIris" + make -j`nproc` + $SUDO make install + $SUDO ldconfig + ) >& $iris_install_log +} + +check_install_soapy () { + #if [[ "$OS_DISTRO" == "ubuntu" ]]; then + #first we remove old installation + $SUDO apt-get remove -y soapysdr soapysdr-server libsoapysdr-dev python-soapysdr python3-soapysdr soapysdr-module-remote || true + #$SUDO add-apt-repository -y ppa:myriadrf/drivers + #$SUDO apt-get update + #$SUDO apt-get install -y soapysdr soapysdr-server libsoapysdr-dev python-soapysdr python3-soapysdr soapysdr-module-remote + + #elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then + # $SUDO $INSTALLER -y install software-properties-common python3-software-properties python-software-properties subversion git python3 python-numpy python3-numpy cmake swig python-dev + install_soapy_from_source + #fi + install_soapy_iris_from_source + +} + +check_install_additional_tools (){ + $SUDO $INSTALLER update -y + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + PACKAGE_LIST="\ + check \ + dialog \ + dkms \ + gawk \ + libboost-all-dev \ + libpthread-stubs0-dev \ + openvpn \ + pkg-config \ + python-dev \ + python-pexpect \ + sshfs \ + swig \ + tshark \ + uml-utilities \ + unzip \ + valgrind \ + vlan \ + ctags \ + ntpdate \ + iperf3 \ + android-tools-adb \ + wvdial \ + python-numpy \ + sshpass \ + nscd \ + bc \ + ntp \ + python-scipy \ + python-matplotlib" + elif [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then + PACKAGE_LIST="\ + check \ + dialog \ + dkms \ + gawk \ + boost-devel \ + openvpn \ + pkgconfig \ + pexpect \ + sshfs \ + swig \ + wireshark \ + unzip \ + valgrind \ + vconfig \ + ctags \ + ntpdate \ + iperf3 \ + wvdial \ + numpy \ + sshpass \ + nscd \ + python2-paramiko \ + python-pyroute2 \ + python-netifaces \ + scipy \ + python-matplotlib" + elif [[ "$OS_DISTRO" == "fedora" ]]; then + PACKAGE_LIST=" \ + check \ + dialog \ + dkms \ + gawk \ + boost-devel \ + openvpn \ + pkgconfig \ + python-pexpect \ + sshfs \ + swig \ + wireshark \ + unzip \ + valgrind \ + vconfig \ + ctags \ + ntpdate \ + iperf3 \ + wvdial \ + python-numpy \ + sshpass \ + nscd \ + python2-paramiko \ + python-pyroute2 \ + python-netifaces \ + python2-scipy \ + python2-matplotlib" + fi + $SUDO $INSTALLER install -y $PACKAGE_LIST + + $SUDO rm -fr /opt/ssh + $SUDO GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/ssh.git /opt/ssh + + #The packages below are already installed for Redhat distros (RHEL, CentOS, Fedora) + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + $SUDO -H pip install paramiko + $SUDO -H pip install pyroute2 colorama + log_netiface=$OPENAIR_DIR/cmake_targets/log/netiface_install_log.txt + echo_info "Installing Netinterfaces package. The logfile for installation is in $log_netiface" + ( + $SUDO rm -fr /tmp/netifaces-0.10.4.tar.gz /tmp/netifaces + wget --tries=3 --retry-connrefused -P /tmp https://pypi.python.org/packages/18/fa/dd13d4910aea339c0bb87d2b3838d8fd923c11869b1f6e741dbd0ff3bc00/netifaces-0.10.4.tar.gz + tar -xzvf /tmp/netifaces-0.10.4.tar.gz -C /tmp + cd /tmp/netifaces-0.10.4 + $SUDO python setup.py install + cd - + ) >& $log_netiface + fi +} + +check_install_oai_software() { + local specific_packages="" + if ! check_supported_distribution; then + echo_error "Your distribution $(get_distribution_release) is not supported by oai !" + exit 1 + fi + $SUDO $INSTALLER update -y + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + local LAPACK_LIBNAME="liblapack.so" + local LAPACK_TARGET="/usr/lib/atlas-base/atlas/liblapack.so" + $SUDO apt install -y software-properties-common + case "$(get_distribution_release)" in + "ubuntu14.04") + specific_packages="libtasn1-3-dev libgnutls-dev libatlas-dev iproute libconfig8-dev" + # For iperf3 + $SUDO add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports universe" + $SUDO apt-get update + ;; + "ubuntu16.04") + specific_packages="libtasn1-6-dev libgnutls-dev libatlas-dev iproute libconfig8-dev" + ;; + "ubuntu17.04") + specific_packages="libtasn1-6-dev libgnutls28-dev libatlas-dev iproute libconfig8-dev" + ;; + "ubuntu17.10") + specific_packages="libtasn1-6-dev libgnutls28-dev iproute libconfig8-dev" + LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" + LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" + ;; + "ubuntu18.04") + specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev" + LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" + LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" + ;; + esac + $SUDO apt-get install -y \ + $specific_packages \ + autoconf \ + automake \ + bison \ + build-essential \ + cmake \ + cmake-curses-gui \ + ninja-build \ + doxygen \ + doxygen-gui \ + texlive-latex-base \ + ethtool \ + flex \ + gdb \ + git \ + graphviz \ + gtkwave \ + guile-2.0-dev \ + iperf \ + iptables \ + iptables-dev \ + libatlas-base-dev \ + libblas-dev \ + liblapack-dev\ + liblapacke-dev\ + libffi-dev \ + libforms-bin \ + libforms-dev \ + libgcrypt11-dev \ + libgmp-dev \ + libgtk-3-dev \ + libidn2-0-dev \ + libidn11-dev \ + libmysqlclient-dev \ + libpython2.7-dev \ + libsctp1 \ + libsctp-dev \ + libssl-dev \ + libtool \ + libusb-1.0-0-dev \ + libxml2 \ + libxml2-dev \ + libxslt1-dev \ + mscgen \ + octave-signal \ + openssh-client \ + openssh-server \ + openssl \ + python \ + subversion \ + xmlstarlet \ + python-pip \ + pydb \ + libyaml-dev \ + wget \ + libxpm-dev \ + libboost-all-dev + + $SUDO update-alternatives --set "$LAPACK_LIBNAME" "$LAPACK_TARGET" + + $SUDO apt-get install -y nettle-dev nettle-bin + elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then + if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then + if rpm -q epel-release > /dev/null; then + echo "EPEL repos already present. Good." + else + echo "EPEL repos not present. Installing them." + $SUDO $INSTALLER install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + fi + $SUDO $INSTALLER install -y python-epdb vim-common + else + $SUDO $INSTALLER install -y mscgen pydb + fi + + $SUDO $INSTALLER install -y \ + autoconf \ + automake \ + bc \ + bison \ + $CMAKE \ + doxygen \ + ethtool \ + flex \ + gdb \ + git \ + graphviz \ + gtkwave \ + guile-devel \ + iperf \ + iproute \ + iptables \ + iptables-devel \ + atlas-devel \ + blas-devel \ + libconfig-devel \ + libffi-devel \ + xforms \ + xforms-devel \ + libgcrypt-devel \ + gmp-devel \ + gtk3-devel \ + libidn2-devel \ + libidn-devel \ + mariadb-devel \ + lksctp-tools \ + lksctp-tools-devel \ + openssl-devel \ + libtasn1 \ + libtool \ + libusb-devel \ + libxml2 \ + libxml2-devel \ + libxslt-devel \ + openssh-clients \ + openssh-server \ + openssl \ + patch \ + psmisc \ + python \ + subversion \ + xmlstarlet \ + python-pip \ + wget \ + kernel-headers \ + kernel-devel \ + nettle-devel \ + gnutls-devel \ + libXpm-devel \ + lapack \ + lapack-devel \ + blas \ + blas-devel \ + libyaml-devel + fi + + install_asn1c_from_source $1 + $SUDO rm -fr /opt/ssh + $SUDO git clone https://gist.github.com/2190472.git /opt/ssh +} + +install_asn1c_from_source(){ + asn1_install_log=$OPENAIR_DIR/cmake_targets/log/asn1c_install_log.txt + echo_info "\nInstalling ASN1. The log file for ASN1 installation is here: $asn1_install_log " + ( + $SUDO rm -rf /tmp/asn1c + # GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c + git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c + cd /tmp/asn1c + # better to use a given commit than a branch in case the branch + # is updated and requires modifications in the source of OAI + #git checkout velichkov_s1ap_plus_option_group + git checkout f12568d617dbf48497588f8e227d70388fa217c9 + autoreconf -iv + ./configure + make -j`nproc` + $SUDO make install + cd - + $SUDO ldconfig + ) > $asn1_install_log 2>&1 +} + +################################################# +# 2. compile +################################################ + +install_nas_tools() { + if [ ! -f .ue.nvram0 ]; then + echo_success "generate .ue_emm.nvram .ue.nvram" + ./nvram --gen -c $1 -o $2 + else + [ ./nvram -nt .ue.nvram0 -o ./nvram -nt .ue_emm.nvram0 ] && ./nvram --gen -c $1 -o $2 + fi + + if [ ! -f .usim.nvram0 ]; then + echo_success "generate .usim.nvram" + ./usim --gen -c $1 -o $2 + else + [ ./usim -nt .usim.nvram0 ] && ./usim --gen -c $1 -o $2 + fi + +} + + +################################ +# set_openair_env +############################### +set_openair_env(){ + fullpath=`readlink -f $BASH_SOURCE` + [ -f "/.$fullpath" ] || fullpath=`readlink -f $PWD/$fullpath` + openair_path=${fullpath%/cmake_targets/*} + openair_path=${openair_path%/targets/*} + openair_path=${openair_path%/openair[123]/*} + export OPENAIR_DIR=$openair_path + export OPENAIR1_DIR=$openair_path/openair1 + export OPENAIR2_DIR=$openair_path/openair2 + export OPENAIR3_DIR=$openair_path/openair3 + export OPENAIR_TARGETS=$openair_path/targets +} + +################################ +# Function to killall the subprocesses when Ctrl-C Key is hit +############################### +function handle_ctrl_c(){ +CURPID=$$ +ppid=$$ +arraycounter=1 +echo_info "** Trapped CTRL-C. Killing all subprocesses now..." +echo_info "** Calling sync now..." +sync +while true +do + FORLOOP=FALSE + # Get all the child process id + for i in `ps -ef| awk '$3 == '$ppid' { print $2 }'` + do + if [ $i -ne $CURPID ] ; then + procid[$arraycounter]=$i + arraycounter=`expr $arraycounter + 1` + ppid=$i + FORLOOP=TRUE + fi + done + if [ "$FORLOOP" = "FALSE" ] ; then + arraycounter=`expr $arraycounter - 1` + ## We want to kill child process id first and then parent id's + while [ $arraycounter -ne 0 ] + do + echo "first we send ctrl-c to program" + $SUDO kill -INT "${procid[$arraycounter]}" + sleep 5 + echo "Now we force kill if that didn't work" + $SUDO kill -9 "${procid[$arraycounter]}" >/dev/null + arraycounter=`expr $arraycounter - 1` + done + exit + fi +done +} + + +# get from http://www.linuxjournal.com/content/validating-ip-address-bash-script +validate_ip() { + +local ip=$1 +local stat=1 + +if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + OIFS=$IFS + IFS='.' + ip=($ip) + IFS=$OIFS + [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ + && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] + stat=$? +fi + +return $stat +} diff --git a/doc/SW_archi.md b/doc/SW_archi.md new file mode 100644 index 0000000000..b7f3551b69 --- /dev/null +++ b/doc/SW_archi.md @@ -0,0 +1,86 @@ +This tuto for 5G gNB design, with Open Cells main + +# Top file: executables/ocp-gnb.c + +the function main() initializes the data from configuration file + +# The main thread is in ru_thread() +The infinite loop: +## rx_rf() + Collect radio signal samples from RF board + called for each 5G NR slot + it blocks until data is available + the internal time comes from the RF board sampling numbers + (each sample has a incremental number representing a very accurate timing) +raw incoming data is in buffer called "rxdata" +### nr_fep_full() +"front end processing" of uplink signal +performs DFT on the signal +same function (duplicates): phy_procedures_gNB_common_RX() +it computes the buffer rxdataF (for frequency) from rxdata (samples over time) +### gNB_top() +only compute frame numbre, slot number, ... +### ocp_rxtx() +main processing for both UL and DL +all the context is in the passed structure UL_INFO +the context is not very clear: there is a mutex on it, +but not actual coherency (see below handle_nr_rach() assumes data is up-to-date) + +The first part (in NR_UL_indication, uses the data computed by the lower part (phy_procedures_gNB_uespec_RX), but for the previous slot + +Then, phy_procedures_gNB_uespec_RX will replace the data for the next run + +This is very tricky and not thread safe at all. + +#### NR_UL_indication() +This block processes data already decoded and stored in structures behind UL_INFO + +* handle_nr_rach() +process data from RACH primary detection +if the input is a UE RACH detection + * nr_schedule_msg2() +* handle_nr_uci() +???? +* handle_nr_ulsch() +handles ulsch data prepared by nr_fill_indication() +* gNB_dlsch_ulsch_scheduler () +also calls "run_pdcp()", as this is not a autonomous thread, it needs to be called here to update traffic requests (DL) and to propagate waiting UL to upper layers +* NR_Schedule_response() +process as per the scheduler decided + +#### L1_nr_prach_procedures() +???? +#### phy_procedures_gNB_uespec_RX() +* nr_decode_pucch0() +actual CCH channel decoding +* nr_rx_pusch() + * extracts data from rxdataF (frequency transformed received data) + * nr_pusch_channel_estimation() + * nr_ulsch_extract_rbs_single() + * nr_ulsch_scale_channel() + * nr_ulsch_channel_level() + * nr_ulsch_channel_compensation() + * nr_ulsch_compute_llr() +this function creates the "likelyhood ratios" +* nr_ulsch_procedures() + * actual ULsch decoding + * nr_ulsch_unscrambling() + * nr_ulsch_decoding() + * nr_fill_indication() +populated the data for the next call to "NR_UL_indication()" + +#### phy_procedures_gNB_TX() +* nr_common_signal_procedures() +generate common signals +* nr_generate_dci_top() +generate DCI: the scheduling informtion for each UE in both DL and UL +* nr_generate_pdsch() +generate DL shared channel (user data) + +### nr_feptx_prec() +tx precoding +### nr_feptx0 +do the inverse DFT +### tx_rf() +send radio signal samples to the RF board +the samples numbers are the future time for these samples emission on-air \ No newline at end of file diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 506396b3be..8c6aacb4df 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -130,7 +130,7 @@ extern double cpuf; short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,16384,16384,-16384,-16384,16384,16384,16384,-16384,-16384,16384,-16384,-16384,7327,7327,7327,21981,21981,7327,21981,21981,7327,-7327,7327,-21981,21981,-7327,21981,-21981,-7327,7327,-7327,21981,-21981,7327,-21981,21981,-7327,-7327,-7327,-21981,-21981,-7327,-21981,-21981,10726,10726,10726,3576,3576,10726,3576,3576,10726,17876,10726,25027,3576,17876,3576,25027,17876,10726,17876,3576,25027,10726,25027,3576,17876,17876,17876,25027,25027,17876,25027,25027,10726,-10726,10726,-3576,3576,-10726,3576,-3576,10726,-17876,10726,-25027,3576,-17876,3576,-25027,17876,-10726,17876,-3576,25027,-10726,25027,-3576,17876,-17876,17876,-25027,25027,-17876,25027,-25027,-10726,10726,-10726,3576,-3576,10726,-3576,3576,-10726,17876,-10726,25027,-3576,17876,-3576,25027,-17876,10726,-17876,3576,-25027,10726,-25027,3576,-17876,17876,-17876,25027,-25027,17876,-25027,25027,-10726,-10726,-10726,-3576,-3576,-10726,-3576,-3576,-10726,-17876,-10726,-25027,-3576,-17876,-3576,-25027,-17876,-10726,-17876,-3576,-25027,-10726,-25027,-3576,-17876,-17876,-17876,-25027,-25027,-17876,-25027,-25027,8886,8886,8886,12439,12439,8886,12439,12439,8886,5332,8886,1778,12439,5332,12439,1778,5332,8886,5332,12439,1778,8886,1778,12439,5332,5332,5332,1778,1778,5332,1778,1778,8886,19547,8886,15993,12439,19547,12439,15993,8886,23101,8886,26655,12439,23101,12439,26655,5332,19547,5332,15993,1778,19547,1778,15993,5332,23101,5332,26655,1778,23101,1778,26655,19547,8886,19547,12439,15993,8886,15993,12439,19547,5332,19547,1778,15993,5332,15993,1778,23101,8886,23101,12439,26655,8886,26655,12439,23101,5332,23101,1778,26655,5332,26655,1778,19547,19547,19547,15993,15993,19547,15993,15993,19547,23101,19547,26655,15993,23101,15993,26655,23101,19547,23101,15993,26655,19547,26655,15993,23101,23101,23101,26655,26655,23101,26655,26655,8886,-8886,8886,-12439,12439,-8886,12439,-12439,8886,-5332,8886,-1778,12439,-5332,12439,-1778,5332,-8886,5332,-12439,1778,-8886,1778,-12439,5332,-5332,5332,-1778,1778,-5332,1778,-1778,8886,-19547,8886,-15993,12439,-19547,12439,-15993,8886,-23101,8886,-26655,12439,-23101,12439,-26655,5332,-19547,5332,-15993,1778,-19547,1778,-15993,5332,-23101,5332,-26655,1778,-23101,1778,-26655,19547,-8886,19547,-12439,15993,-8886,15993,-12439,19547,-5332,19547,-1778,15993,-5332,15993,-1778,23101,-8886,23101,-12439,26655,-8886,26655,-12439,23101,-5332,23101,-1778,26655,-5332,26655,-1778,19547,-19547,19547,-15993,15993,-19547,15993,-15993,19547,-23101,19547,-26655,15993,-23101,15993,-26655,23101,-19547,23101,-15993,26655,-19547,26655,-15993,23101,-23101,23101,-26655,26655,-23101,26655,-26655,-8886,8886,-8886,12439,-12439,8886,-12439,12439,-8886,5332,-8886,1778,-12439,5332,-12439,1778,-5332,8886,-5332,12439,-1778,8886,-1778,12439,-5332,5332,-5332,1778,-1778,5332,-1778,1778,-8886,19547,-8886,15993,-12439,19547,-12439,15993,-8886,23101,-8886,26655,-12439,23101,-12439,26655,-5332,19547,-5332,15993,-1778,19547,-1778,15993,-5332,23101,-5332,26655,-1778,23101,-1778,26655,-19547,8886,-19547,12439,-15993,8886,-15993,12439,-19547,5332,-19547,1778,-15993,5332,-15993,1778,-23101,8886,-23101,12439,-26655,8886,-26655,12439,-23101,5332,-23101,1778,-26655,5332,-26655,1778,-19547,19547,-19547,15993,-15993,19547,-15993,15993,-19547,23101,-19547,26655,-15993,23101,-15993,26655,-23101,19547,-23101,15993,-26655,19547,-26655,15993,-23101,23101,-23101,26655,-26655,23101,-26655,26655,-8886,-8886,-8886,-12439,-12439,-8886,-12439,-12439,-8886,-5332,-8886,-1778,-12439,-5332,-12439,-1778,-5332,-8886,-5332,-12439,-1778,-8886,-1778,-12439,-5332,-5332,-5332,-1778,-1778,-5332,-1778,-1778,-8886,-19547,-8886,-15993,-12439,-19547,-12439,-15993,-8886,-23101,-8886,-26655,-12439,-23101,-12439,-26655,-5332,-19547,-5332,-15993,-1778,-19547,-1778,-15993,-5332,-23101,-5332,-26655,-1778,-23101,-1778,-26655,-19547,-8886,-19547,-12439,-15993,-8886,-15993,-12439,-19547,-5332,-19547,-1778,-15993,-5332,-15993,-1778,-23101,-8886,-23101,-12439,-26655,-8886,-26655,-12439,-23101,-5332,-23101,-1778,-26655,-5332,-26655,-1778,-19547,-19547,-19547,-15993,-15993,-19547,-15993,-15993,-19547,-23101,-19547,-26655,-15993,-23101,-15993,-26655,-23101,-19547,-23101,-15993,-26655,-19547,-26655,-15993,-23101,-23101,-23101,-26655,-26655,-23101,-26655,-26655}; -static inline int rxtx(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { +static inline int ocp_rxtx(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; start_meas(&softmodem_stats_rxtx_sf); @@ -865,7 +865,7 @@ static void *ru_thread( void *param ) { gNB_top(&RC.gNB[0][0].proc, ru); gNB_L1_rxtx_proc_t *L1_proc = &RC.gNB[0][0].proc.L1_proc; - if (rxtx(&RC.gNB[0][0],L1_proc) < 0) + if (ocp_rxtx(&RC.gNB[0][0],L1_proc) < 0) LOG_E(PHY,"gNB %d CC_id %d failed during execution\n",RC.gNB[0][0].Mod_id,RC.gNB[0][0].CC_id); diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 0f430c61a7..acd3a11dd8 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -470,7 +470,6 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { AssertFatal(fp->ul_CarrierFreq==(fp->dl_CarrierFreq+dlul_offset), "Disagreement in uplink frequency for band %d\n", fp->nr_band); //fp->threequarter_fs = openair0_cfg[0].threequarter_fs; - //fp->threequarter_fs = 1; LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", Mod_id, gNB_config->cell_config.phy_cell_id.value, diff --git a/openair1/PHY/TOOLS/oai_dfts.c b/openair1/PHY/TOOLS/oai_dfts.c index 2a7915665b..531053f71d 100644 --- a/openair1/PHY/TOOLS/oai_dfts.c +++ b/openair1/PHY/TOOLS/oai_dfts.c @@ -4038,7 +4038,7 @@ void dft2048(int16_t *x,int16_t *y,unsigned char scale) { if (scale>0) { y256p = y256; - for (i=0; i<16; i++) { + for (int i=0; i<16; i++) { y256p[0] = mulhi_int16_simd256(y256p[0],ONE_OVER_SQRT2_Q15_128); y256p[1] = mulhi_int16_simd256(y256p[1],ONE_OVER_SQRT2_Q15_128); y256p[2] = mulhi_int16_simd256(y256p[2],ONE_OVER_SQRT2_Q15_128); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index c00b57d7aa..d59ecf5626 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -578,3 +578,7 @@ void do_SpCellConfig(gNB_RRC_INST *rrc, spconfig->reconfigurationWithSync = CALLOC(1,sizeof(struct NR_ReconfigurationWithSync)); } + +int do_DLInformationTransfer_NR () { +} + diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index de994d6871..b8c8d8ca10 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -308,7 +308,7 @@ sin_addr: }; bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr)); AssertFatal(listen(t->listen_sock, 5) == 0, ""); - struct epoll_event ev= {0}; + struct epoll_event ev={0}; ev.events = EPOLLIN; ev.data.fd = t->listen_sock; AssertFatal(epoll_ctl(t->epollfd, EPOLL_CTL_ADD, t->listen_sock, &ev) != -1, ""); From 81eb39300007e551bf83b6e1387dbb4ac6d1a197 Mon Sep 17 00:00:00 2001 From: laurent Date: Wed, 29 Jul 2020 18:28:29 +0200 Subject: [PATCH 023/149] add preeliminary support for ubuntu 20 or debian 11, add file for 5G SA --- .../install_external_packages.ubuntu20 | 505 ++++++++++++++++++ openair2/RRC/NR/nr_rrc_gNB.c | 48 ++ 2 files changed, 553 insertions(+) create mode 100755 cmake_targets/install_external_packages.ubuntu20 create mode 100644 openair2/RRC/NR/nr_rrc_gNB.c diff --git a/cmake_targets/install_external_packages.ubuntu20 b/cmake_targets/install_external_packages.ubuntu20 new file mode 100755 index 0000000000..9ef79be9c2 --- /dev/null +++ b/cmake_targets/install_external_packages.ubuntu20 @@ -0,0 +1,505 @@ +#!/bin/bash +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ + +# brief +# authors Laurent Thomas +# +####################################### +if [ ! -f /etc/os-release ]; then + echo "No /etc/os-release file found. You're likely on an unsupported distro." + exit 1 +fi +OS_DISTRO=$(grep "^ID=" /etc/os-release | sed "s/ID=//" | sed "s/\"//g") +OS_RELEASE=$(grep "^VERSION_ID=" /etc/os-release | sed "s/VERSION_ID=//" | sed "s/\"//g") +case "$OS_DISTRO" in + ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt"; CMAKE="cmake" ;; +esac + +SUDO='sudo -E' + +############################### +## echo and family +############################### +black='\E[30m' +red='\E[31m' +green='\E[32m' +yellow='\E[33m' +blue='\E[1;34m' +magenta='\E[35m' +cyan='\E[36m' +white='\E[37m' +reset_color='\E[00m' +COLORIZE=1 + +cecho() { + # Color-echo + # arg1 = message + # arg2 = color + local default_msg="No Message." + message=${1:-$default_msg} + color=${2:-$green} + [ "$COLORIZE" = "1" ] && message="$color$message$reset_color" + echo -e "$message" + return +} + +echo_error() { cecho "$* $red" ;} +echo_fatal() { cecho "$* $red"; exit 1 ;} +echo_warning() { cecho "$* $yellow" ;} +echo_success() { cecho "$* $green" ;} +echo_info() { cecho "$* $blue" ;} + +######################## +# distribution helpers # +######################## + +# This function return a string to identify the distribution we are running +# Examples: +# ubuntu16.04 +# debian8.5 +get_distribution_release() { + echo "$OS_DISTRO$OS_RELEASE" +} + +check_supported_distribution() { + case $(get_distribution_release) in + "ubuntu20.04") return 0 ;; + esac + return 1 +} + +################## +# Error handlers # +################## + +handler_EXIT() { + local exit_code=$? + [ "$exit_code" -eq 0 ] || echo_error "build have failed" + exit $exit_code +} + +trap handler_EXIT EXIT + +########################### +# Cleaners +########################### + +clean_kernel() { + $SUDO modprobe ip_tables + $SUDO modprobe x_tables + $SUDO iptables -P INPUT ACCEPT + $SUDO iptables -F INPUT + $SUDO iptables -P OUTPUT ACCEPT + $SUDO iptables -F OUTPUT + $SUDO iptables -P FORWARD ACCEPT + $SUDO iptables -F FORWARD + $SUDO iptables -t nat -F + $SUDO iptables -t mangle -F + $SUDO iptables -t filter -F + $SUDO iptables -t raw -F + echo_info "Flushed iptables" + $SUDO rmmod nasmesh > /dev/null 2>&1 + $SUDO rmmod oai_nw_drv > /dev/null 2>&1 + $SUDO rmmod openair_rf > /dev/null 2>&1 + $SUDO rmmod ue_ip > /dev/null 2>&1 + echo_info "removed drivers from kernel" +} + +clean_all_files() { + set_openair_env + rm -rf "$OPENAIR_DIR"/targets/bin/* + dir="$OPENAIR_DIR/cmake_targets" + rm -rf "$dir"/log/* + rm -rf "$dir"/ran_build/build + rm -rf "$dir"/ran_build_noLOG/build + rm -rf "$dir"/lte-simulators/build + rm -rf "$dir"/phy_simulators/build + rm -rf "$dir"/nas_sim_tools/build + rm -rf "$dir"/oaisim_build_oai/build + rm -rf "$dir"/oaisim_build_oai/CMakeLists.txt + rm -rf "$dir"/autotests/bin + rm -rf "$dir"/autotests/log + rm -rf "$dir"/autotests/*/build +} + +############################################ +# External packages installers +############################################ + +install_protobuf_from_source(){ + protobuf_install_log=$OPENAIR_DIR/cmake_targets/log/protobuf_install_log.txt + echo_info "\nInstalling Google Protobuf from sources. The log file for Protobuf installation is here: $protobuf_install_log " + ( + cd /tmp || exit + echo "Downloading protobuf" + #rm -rf /tmp/protobuf-2.6.1.tar.gz* /tmp/protobuf-2.6.1 + #wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz + #tar -xzvf protobuf-2.6.1.tar.gz --owner $USER --group $USER --no-same-owner + #cd protobuf-2.6.1/ + rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 + wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz + tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner "$USER" --group "$(groups | cut -d" " -f1)" --no-same-owner + cd protobuf-3.3.0/ || exit + ./configure + echo "Compiling protobuf" + make -j"$(nproc)" + $SUDO make install + $SUDO ldconfig + ) >& "$protobuf_install_log" +} + +install_protobuf_c_from_source(){ + protobuf_c_install_log=$OPENAIR_DIR/cmake_targets/log/protobuf_c_install_log.txt + echo_info "\nInstalling Google Protobuf_C from sources. The log file for Protobuf_C installation is here: $protobuf_c_install_log " + ( + if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig + fi + cd /tmp || exit + echo "Downloading protobuf-c" + rm -rf /tmp/protobuf-c + git clone https://github.com/protobuf-c/protobuf-c.git + cd protobuf-c || exit + git checkout 2a46af42784abf86804d536f6e0122d47cfeea45 + ./autogen.sh + ./configure + echo "Compiling protobuf-c" + make -j"$(nproc)" + $SUDO make install + $SUDO ldconfig + ) >& "$protobuf_c_install_log" +} + +install_usrp_uhd_driver_from_source(){ + uhd_install_log=$OPENAIR_DIR/cmake_targets/log/uhd_install_log.txt + echo_info "\nInstalling UHD driver from sources. The log file for UHD driver installation is here: $uhd_install_log " + ( + cd /tmp || exit + echo "Downloading UHD driver" + rm -rf /tmp/uhd + git clone https://github.com/EttusResearch/uhd.git + cd uhd || exit + git checkout tags/v3.13.0.2 + mkdir -p host/build + cd host/build || exit + $CMAKE ../ + echo "Compiling UHD" + make -j"$(nproc)" + make test + $SUDO make install + $SUDO ldconfig + ) >& "$uhd_install_log" +} + +install_bladerf_driver_from_source(){ + bladerf_install_log=$OPENAIR_DIR/cmake_targets/log/bladerf_install_log.txt + echo_info "\nInstalling BladeRF driver from sources. The log file for BladeRF driver installation is here: $bladerf_install_log " + ( + cd /tmp || exit + echo "Downloading BladeRF driver" + rm -rf /tmp/bladeRF + git clone https://github.com/Nuand/bladeRF.git + cd bladeRF || exit + git checkout tags/2016.06 + mkdir -p build + cd build || exit + $CMAKE ../ + echo "Compiling BladeRF driver" + make -j"$(nproc)" + $SUDO make install + $SUDO ldconfig + echo "Downloading FPGA and firmware images" + cd /tmp/bladeRF || exit + wget --tries=3 --retry-connrefused https://www.nuand.com/fx3/bladeRF_fw_latest.img + wget --tries=3 --retry-connrefused https://www.nuand.com/fpga/hostedx40-latest.rbf + sudo mkdir -p /usr/share/Nuand/bladeRF + sudo mv bladeRF_fw_latest.img /usr/share/Nuand/bladeRF/bladeRF_fw.img + sudo mv hostedx40-latest.rbf /usr/share/Nuand/bladeRF/hostedx40.rbf + ) >& "$bladerf_install_log" +} + +check_install_bladerf_driver(){ + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + $SUDO apt-get install -y bladerf libbladerf-dev + $SUDO apt-get install -y bladerf-firmware-fx3 + $SUDO apt-get install -y bladerf-fpga-hostedx40 + elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then + install_bladerf_driver_from_source + else + echo_error "BladeRF Installer for OAI does not support automatic build. Install BladeRF compiling sources manually from BladeRF website" + fi +} + +flash_firmware_bladerf() { + $SUDO bladeRF-cli --flash-firmware /usr/share/Nuand/bladeRF/bladeRF_fw.img +} + +install_soapy_from_source(){ + soapy_install_log=$OPENAIR_DIR/cmake_targets/log/soapy_install_log.txt + echo_info "\nInstalling Soapy EcoSystem from source. The log file for Soapy installation is here: $soapy_install_log " + ( + cd /tmp || exit + echo "Downloading SoapySDR" + rm -rf /tmp/soapysdr + git clone -b soapy-sdr-0.7.0 --single-branch https://github.com/pothosware/SoapySDR.git + cd SoapySDR || exit + #git checkout tags/release_003_010_001_001 + mkdir -p build + cd build || exit + $CMAKE ../ + echo "Compiling SoapySDR" + make -j"$(nproc)" + $SUDO make install + $SUDO ldconfig + cd /tmp || exit + echo "Downloading SoapyRemote" + rm -rf /tmp/soapyremote + git clone -b soapy-remote-0.5.0 --single-branch https://github.com/pothosware/SoapyRemote.git + cd SoapyRemote || exit + #git checkout tags/release_003_010_001_001 + mkdir -p build + cd build || exit + cmake ../ + echo "Compiling SoapyRemote" + make -j"$(nproc)" + $SUDO make install + $SUDO ldconfig + ) >& "$soapy_install_log" +} + +install_soapy_iris_from_source(){ + iris_install_log=$OPENAIR_DIR/cmake_targets/log/iris_install_log.txt + echo_info "\nInstalling Iris driver from source. The log file for Iris driver installation is here: $iris_install_log " + ( + cd /tmp || exit + echo "Downloading SoapyIris" + rm -rf /tmp/sklk-soapyiris + git clone -b soapy-iris-2018.08.0.1 --single-branch https://github.com/skylarkwireless/sklk-soapyiris.git + cd sklk-soapyiris || exit + mkdir -p build + cd build ||exit + cmake ../ + echo "Compiling SoapyIris" + make -j"$(nproc)" + $SUDO make install + $SUDO ldconfig + ) >& "$iris_install_log" +} + +check_install_soapy () { + #if [[ "$OS_DISTRO" == "ubuntu" ]]; then + #first we remove old installation + $SUDO apt-get remove -y soapysdr soapysdr-server libsoapysdr-dev python-soapysdr python3-soapysdr soapysdr-module-remote || true + #$SUDO add-apt-repository -y ppa:myriadrf/drivers + #$SUDO apt-get update + #$SUDO apt-get install -y soapysdr soapysdr-server libsoapysdr-dev python-soapysdr python3-soapysdr soapysdr-module-remote + + #elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then + # $SUDO $INSTALLER -y install software-properties-common python3-software-properties python-software-properties subversion git python3 python-numpy python3-numpy cmake swig python-dev + install_soapy_from_source + #fi + install_soapy_iris_from_source + +} + +check_install_ubuntu_packages() { + $SUDO $INSTALLER update -y + if [[ "$OS_DISTRO" == "ubuntu" ]]; then + local LAPACK_LIBNAME="liblapack.so" + local LAPACK_TARGET="/usr/lib/atlas-base/atlas/liblapack.so" + $SUDO apt install -y software-properties-common + case "$(get_distribution_release)" in + "ubuntu20.04") + specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev" + LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" + LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" + ;; + esac + $SUDO $INSTALLER install -y \ + $specific_packages \ + check \ + dialog \ + dkms \ + gawk \ + libboost-all-dev \ + libpthread-stubs0-dev \ + openvpn \ + pkg-config \ + python3-dev \ + python-pexpect \ + sshfs \ + swig \ + tshark \ + uml-utilities \ + unzip \ + valgrind \ + vlan \ + exuberant-ctags \ + ntpdate \ + iperf3 \ + android-tools-adb \ + wvdial \ + python-numpy \ + sshpass \ + nscd \ + bc \ + ntp \ + python3-scipy \ + python3-matplotlib \ + bison \ + build-essential \ + cmake \ + cmake-curses-gui \ + ninja-build \ + doxygen \ + doxygen-gui \ + texlive-latex-base \ + ethtool \ + flex \ + gdb \ + git \ + graphviz \ + gtkwave \ + guile-2.0-dev \ + iperf \ + iptables \ + libxtables-dev \ + libatlas-base-dev \ + libblas-dev \ + liblapack-dev\ + liblapacke-dev\ + libffi-dev \ + libforms-bin \ + libforms-dev \ + libgcrypt20-dev \ + libgmp-dev \ + libgtk-3-dev \ + libidn2-0-dev \ + libidn11-dev \ + libmysqlclient-dev \ + libpython2.7-dev \ + libsctp1 \ + libsctp-dev \ + libssl-dev \ + libtool \ + libusb-1.0-0-dev \ + libxml2 \ + libxml2-dev \ + libxslt1-dev \ + mscgen \ + octave-signal \ + openssh-client \ + openssh-server \ + openssl \ + python3 \ + subversion \ + xmlstarlet \ + python3-pip \ + libyaml-dev \ + wget \ + libxpm-dev \ + libboost-all-dev \ + nettle-dev \ + nettle-bin + fi + + $SUDO update-alternatives --set "$LAPACK_LIBNAME" "$LAPACK_TARGET" + +} + +install_asn1c_from_source(){ + asn1_install_log=$OPENAIR_DIR/cmake_targets/log/asn1c_install_log.txt + echo_info "\nInstalling ASN1. The log file for ASN1 installation is here: $asn1_install_log " + ( + $SUDO rm -rf /tmp/asn1c + # GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c + git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c + cd /tmp/asn1c || exit + # better to use a given commit than a branch in case the branch + # is updated and requires modifications in the source of OAI + #git checkout velichkov_s1ap_plus_option_group + git checkout f12568d617dbf48497588f8e227d70388fa217c9 + autoreconf -iv + ./configure + make -j"$(nproc)" + $SUDO make install + cd - || exit + $SUDO ldconfig + ) > "$asn1_install_log" 2>&1 +} + +################################################# +# 2. compile +################################################ + +install_nas_tools() { + echo_success "generate .ue_emm.nvram .ue.nvram" + ./nvram --gen -c "$1" -o "$2" + ./usim --gen -c "$1" -o "$2" +} + + +################################ +# set_openair_env +############################### +set_openair_env(){ + fullpath=$(readlink -f "${BASH_SOURCE[0]}") + [ -f "/.$fullpath" ] || fullpath=$(readlink -f "$PWD/$fullpath") + openair_path=${fullpath%/cmake_targets/*} + openair_path=${openair_path%/targets/*} + openair_path=${openair_path%/openair[123]/*} + export OPENAIR_DIR=$openair_path + export OPENAIR1_DIR=$openair_path/openair1 + export OPENAIR2_DIR=$openair_path/openair2 + export OPENAIR3_DIR=$openair_path/openair3 + export OPENAIR_TARGETS=$openair_path/targets +} + +if ! check_supported_distribution; then + echo_error "Your distribution $(get_distribution_release) is not supported by oai !" + exit 1 +fi + +echo_info "Installing packages" +check_install_ubuntu_packages + +echo_info "installing ASN.1 compiler" +install_asn1c_from_source + +echo_info "installing protobuf/protobuf-c for flexran agent support" +install_protobuf_from_source +install_protobuf_c_from_source + +if [ "$1" == "USRP" ] ; then + echo_info "installing packages for USRP support" + install_usrp_uhd_driver +fi +if [ "$1" == "BLADERF" ] ; then + echo_info "installing packages for BLADERF support" + check_install_bladerf_driver + flash_firmware_bladerf +fi +if [ "$1" == "IRIS" ] ; then + echo_info "installing packages for IRIS support" + check_install_soapy + # flash_firmware_iris +fi diff --git a/openair2/RRC/NR/nr_rrc_gNB.c b/openair2/RRC/NR/nr_rrc_gNB.c new file mode 100644 index 0000000000..4f16683d71 --- /dev/null +++ b/openair2/RRC/NR/nr_rrc_gNB.c @@ -0,0 +1,48 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Author and copyright: Laurent Thomas, open-cells.com + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +rrc_gNB_send_NGAP_NAS_FIRST_REQ() { + // We are noCore only now + // create message that should come from 5GC + + // send it dow + rrc_gNB_process_NGAP_DOWNLINK_NAS() +} + +rrc_gNB_process_NGAP_DOWNLINK_NAS () { + do_DLInformationTransfer(); + // send it as DL data + rrc_data_req ( + &ctxt, + srb_id, + (*rrc_eNB_mui)++, + SDU_CONFIRM_NO, + length, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + +} + + +:q + From 9a72b0c52e7e39a49544148c8befcf006e6d4d73 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 6 Aug 2020 11:44:48 +0200 Subject: [PATCH 024/149] partial code for NR SIB1, existing bugs fix, merge develop --- cmake_targets/CMakeLists.txt | 21 +- cmake_targets/install_ubuntu20.04 | 877 ------------------ common/utils/LOG/log.h | 21 +- common/utils/LOG/vcd_signal_dumper.c | 1 + common/utils/LOG/vcd_signal_dumper.h | 8 + doc/SW_archi.md | 89 +- executables/nr-uesoftmodem.c | 3 + executables/split_headers.h | 2 + openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 9 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 6 + openair2/RRC/NR/L2_nr_interface.c | 8 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 4 +- openair2/RRC/NR/rrc_gNB.c | 5 +- 14 files changed, 139 insertions(+), 917 deletions(-) delete mode 100644 cmake_targets/install_ubuntu20.04 diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 38f212cebb..1c09673552 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -27,6 +27,10 @@ cmake_minimum_required (VERSION 3.0) # Base directories, compatible with legacy OAI building # ######################################################### set (OPENAIR_DIR $ENV{OPENAIR_DIR}) +if("${OPENAIR_DIR}" STREQUAL "") + string(REGEX REPLACE "/cmake_targets.*$" "" OPENAIR_DIR ${CMAKE_CURRENT_BINARY_DIR}) +endif() + set (NFAPI_DIR ${OPENAIR_DIR}/nfapi/open-nFAPI) set (NFAPI_USER_DIR ${OPENAIR_DIR}/nfapi/oai_integration) set (OPENAIR1_DIR ${OPENAIR_DIR}/openair1) @@ -228,8 +232,8 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,${CMAKE_CU ######################### # set a flag for changes in the source code # these changes are related to hardcoded path to include .h files -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -DMALLOC_CHECK_=3") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g3 -DMALLOC_CHECK_=3 -O0 -fno-delete-null-pointer-checks") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -O0 -DMALLOC_CHECK_=3") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g3 -DMALLOC_CHECK_=3 -O1 -fno-delete-null-pointer-checks") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3") set(GIT_BRANCH "UNKNOWN") @@ -288,7 +292,7 @@ add_boolean_option(TRACE_RLC_PAYLOAD False "print RLC PDU to stdout") # if tru add_boolean_option(TEST_OMG False "???") add_boolean_option(DEBUG_OMG False "???") add_boolean_option(PRINT_STATS False "This adds the possibility to see the status") -add_boolean_option(T_TRACER True "Activate the T tracer, a debugging/monitoring framework" ) +add_boolean_option(T_TRACER False "Activate the T tracer, a debugging/monitoring framework" ) add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs") add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace") add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace") @@ -772,7 +776,7 @@ Message("CPU_Affinity flag is ${CPU_AFFINITY}") add_boolean_option(NO_RRM True "DO WE HAVE A RADIO RESSOURCE MANAGER: NO") add_boolean_option(OAI_NW_DRIVER_TYPE_ETHERNET False "????") -add_boolean_option(DEADLINE_SCHEDULER True "Use the Linux scheduler SCHED_DEADLINE: kernel >= 3.14") +add_boolean_option(DEADLINE_SCHEDULER False "Use the Linux scheduler SCHED_DEADLINE: kernel >= 3.14") add_boolean_option(CPU_AFFINITY False "Enable CPU Affinity of threads (only valid without deadline scheduler). It is enabled only with >2 CPUs") add_boolean_option(NAS_NETLINK False "useless ??? Must be True to compile nasmesh driver without rtai ????") add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????") @@ -794,9 +798,9 @@ add_boolean_option(ENB_MODE True "Swap the include directories between openair2 ########################## # SCHEDULING/REAL-TIME/PERF options ########################## -add_boolean_option(ENABLE_USE_CPU_EXECUTION_TIME True "Add data in vcd traces: disable it if perf issues") -add_boolean_option(ENABLE_VCD True "always true now, time measurements of proc calls and var displays") -add_boolean_option(ENABLE_VCD_FIFO True "time measurements of proc calls and var displays sent to FIFO (one more thread)") +add_boolean_option(ENABLE_USE_CPU_EXECUTION_TIME False "Add data in vcd traces: disable it if perf issues") +add_boolean_option(ENABLE_VCD False "always true now, time measurements of proc calls and var displays") +add_boolean_option(ENABLE_VCD_FIFO False "time measurements of proc calls and var displays sent to FIFO (one more thread)") add_boolean_option(LINUX False "used in weird memcpy() in pdcp.c ???") add_boolean_option(LINUX_LIST False "used only in lists.c: either use OAI implementation of lists or Linux one (should be True, but it is False") add_boolean_option(OPENAIR_LTE True "Seems legacy: keep it to true") @@ -2698,7 +2702,6 @@ target_link_libraries (lte-uesoftmodem -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP F1AP_LIB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON - PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU_COMMON SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${ATLAS_LIBRARIES} -Wl,--end-group z dl) @@ -2788,7 +2791,7 @@ target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES}) target_link_libraries (ocp-gnb pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (ocp-gnb ${LIB_LMS_LIBRARIES}) target_link_libraries (ocp-gnb ${T_LIB}) -add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc params_libconfig rfsimulator oai_usrpdevif) +add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc params_libconfig rfsimulator oai_usrpdevif rfsimulator) # nr-uesoftmodem is UE implementation diff --git a/cmake_targets/install_ubuntu20.04 b/cmake_targets/install_ubuntu20.04 deleted file mode 100644 index 5a59b9a8cc..0000000000 --- a/cmake_targets/install_ubuntu20.04 +++ /dev/null @@ -1,877 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ - -# file build_helper -# brief -# authors Laurent Thomas, Lionel GAUTHIER -# -####################################### -if [ ! -f /etc/os-release ]; then - echo "No /etc/os-release file found. You're likely on an unsupported distro." - exit -1 -fi -OS_DISTRO=$(grep "^ID=" /etc/os-release | sed "s/ID=//" | sed "s/\"//g") -OS_RELEASE=$(grep "^VERSION_ID=" /etc/os-release | sed "s/VERSION_ID=//" | sed "s/\"//g") -case "$OS_DISTRO" in - fedora) OS_BASEDISTRO="fedora"; INSTALLER="dnf"; CMAKE="cmake" ;; - rhel) OS_BASEDISTRO="fedora"; INSTALLER="yum --skip-broken"; CMAKE="cmake3" ;; - centos) OS_BASEDISTRO="fedora"; INSTALLER="yum --skip-broken"; CMAKE="cmake3" ;; - debian) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; - ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; -esac -KERNEL_VERSION=$(uname -r | cut -d '.' -f1) -KERNEL_MAJOR=$(uname -r | cut -d '.' -f2) - -SUDO='sudo -E' - -############################### -## echo and family -############################### -black='\E[30m' -red='\E[31m' -green='\E[32m' -yellow='\E[33m' -blue='\E[1;34m' -magenta='\E[35m' -cyan='\E[36m' -white='\E[37m' -reset_color='\E[00m' -COLORIZE=1 - -cecho() { - # Color-echo - # arg1 = message - # arg2 = color - local default_msg="No Message." - message=${1:-$default_msg} - color=${2:-$green} - [ "$COLORIZE" = "1" ] && message="$color$message$reset_color" - echo -e "$message" - return -} - -echo_error() { cecho "$*" $red ;} -echo_fatal() { cecho "$*" $red; exit -1 ;} -echo_warning() { cecho "$*" $yellow ;} -echo_success() { cecho "$*" $green ;} -echo_info() { cecho "$*" $blue ;} - -######################## -# distribution helpers # -######################## - -# This function return a string to identify the distribution we are running -# If we can't check the distribution, it returns "Unknown" -# This function return always true as exit code by design -# Examples: -# ubuntu16.04 -# debian8.5 -get_distribution_release() { - if [[ ! -z "$OS_DISTRO$OS_RELEASE" ]]; then - echo "$OS_DISTRO$OS_RELEASE" - else - echo Unknown - fi -} - -check_supported_distribution() { - local distribution=$(get_distribution_release) - case "$distribution" in - "ubuntu18.04") return 0 ;; - "ubuntu17.10") return 0 ;; - "ubuntu17.04") return 0 ;; - "ubuntu16.04") return 0 ;; - "ubuntu14.04") return 0 ;; - "fedora24") return 0 ;; - "rhel7") return 0 ;; - "rhel7.6") return 0 ;; - "rhel7.7") return 0 ;; - "centos7") return 0 ;; - esac - return 1 -} - -################## -# Error handlers # -################## - -handler_EXIT() { - local exit_code=$? - [ "$exit_code" -eq 0 ] || echo_error "build have failed" - exit $exit_code -} - -trap handler_EXIT EXIT - -########################### -# Cleaners -########################### - -clean_kernel() { - $SUDO modprobe ip_tables - $SUDO modprobe x_tables - $SUDO iptables -P INPUT ACCEPT - $SUDO iptables -F INPUT - $SUDO iptables -P OUTPUT ACCEPT - $SUDO iptables -F OUTPUT - $SUDO iptables -P FORWARD ACCEPT - $SUDO iptables -F FORWARD - $SUDO iptables -t nat -F - $SUDO iptables -t mangle -F - $SUDO iptables -t filter -F - $SUDO iptables -t raw -F - echo_info "Flushed iptables" - $SUDO rmmod nasmesh > /dev/null 2>&1 - $SUDO rmmod oai_nw_drv > /dev/null 2>&1 - $SUDO rmmod openair_rf > /dev/null 2>&1 - $SUDO rmmod ue_ip > /dev/null 2>&1 - echo_info "removed drivers from kernel" -} - -clean_all_files() { - set_openair_env - dir=$OPENAIR_DIR/cmake_targets - rm -rf $dir/log $OPENAIR_DIR/targets/bin/* - rm -rf $dir/ran_build $dir/ran_build_noLOG - rm -rf $dir/lte-simulators/build - rm -rf $dir/phy_simulators/build $dir/nas_sim_tools/build - rm -rf $dir/oaisim_build_oai/build $dir/oaisim_build_oai/CMakeLists.txt - rm -rf $dir/autotests/bin $dir/autotests/log $dir/autotests/*/build -} - -################################### -# Compilers -################################### - -#check_warnings: -# print error message if the compilation had warnings -#argument: -# $1: log file -check_warnings() { - #we look for 'warning:' in the compilation log file - #this is how gcc starts a warning - #this is not perfect, we may get false positive - warning_count=`grep "warning:" "$1" | egrep -v "jobserver unavailable|disabling jobserver mode" | wc -l` - if [ $warning_count -gt 0 ]; then - echo_error "WARNING: $warning_count warnings. See $1" - fi -} - -compilations() { - cd $OPENAIR_DIR/cmake_targets/$1/build - set +e - { - if [ "$BUILD_COVERITY_SCAN" == "1" ]; then - COV_SCAN_PREFIX="cov-build --dir cov-int" - else - COV_SCAN_PREFIX="" - fi - if [ "$MAKE_CMD" != "" ]; then - $MAKE_CMD $2 - else - if [ "$VERBOSE_COMPILE" == "1" ]; then - $COV_SCAN_PREFIX make -j`nproc` $2 VERBOSE=$VERBOSE_COMPILE - else - $COV_SCAN_PREFIX make -j`nproc` $2 - fi - fi - - } > $dlog/$2.$REL.txt 2>&1 - set -e - echo_info "Log file for compilation has been written to: $dlog/$2.$REL.txt" - if [ -s $3 ] ; then - cp $3 $4 - echo_success "$2 compiled" - check_warnings "$dlog/$2.$REL.txt" - else - echo_error "$2 compilation failed" - exit 1 - fi -} - -############################################ -# External packages installers -############################################ - -install_protobuf_from_source(){ - protobuf_install_log=$OPENAIR_DIR/cmake_targets/log/protobuf_install_log.txt - echo_info "\nInstalling Google Protobuf from sources. The log file for Protobuf installation is here: $protobuf_install_log " - ( - cd /tmp - echo "Downloading protobuf" - #rm -rf /tmp/protobuf-2.6.1.tar.gz* /tmp/protobuf-2.6.1 - #wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz - #tar -xzvf protobuf-2.6.1.tar.gz --owner $USER --group $USER --no-same-owner - #cd protobuf-2.6.1/ - rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 - wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz - tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $(groups | cut -d" " -f1) --no-same-owner - cd protobuf-3.3.0/ - ./configure - echo "Compiling protobuf" - make -j`nproc` - $SUDO make install - $SUDO ldconfig - ) >& $protobuf_install_log -} - -install_protobuf_c_from_source(){ - protobuf_c_install_log=$OPENAIR_DIR/cmake_targets/log/protobuf_c_install_log.txt - echo_info "\nInstalling Google Protobuf_C from sources. The log file for Protobuf_C installation is here: $protobuf_c_install_log " - ( - if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig - fi - cd /tmp - echo "Downloading protobuf-c" - rm -rf /tmp/protobuf-c - git clone https://github.com/protobuf-c/protobuf-c.git - cd protobuf-c - git checkout 2a46af42784abf86804d536f6e0122d47cfeea45 - ./autogen.sh - ./configure - echo "Compiling protobuf-c" - make -j`nproc` - $SUDO make install - $SUDO ldconfig - ) >& $protobuf_c_install_log -} - -install_usrp_uhd_driver_from_source(){ - uhd_install_log=$OPENAIR_DIR/cmake_targets/log/uhd_install_log.txt - echo_info "\nInstalling UHD driver from sources. The log file for UHD driver installation is here: $uhd_install_log " - ( - cd /tmp - echo "Downloading UHD driver" - rm -rf /tmp/uhd - git clone https://github.com/EttusResearch/uhd.git - cd uhd - git checkout tags/v3.13.0.2 - mkdir -p host/build - cd host/build - $CMAKE ../ - echo "Compiling UHD" - make -j`nproc` - make test - $SUDO make install - $SUDO ldconfig - ) >& $uhd_install_log -} - -check_install_usrp_uhd_driver(){ - if [[ "$OS_DISTRO" == "ubuntu" ]]; then - #first we remove old installation - $SUDO apt-get remove -y uhd || true - $SUDO apt-get remove libuhd-dev libuhd003 uhd-host -y || true - v=$(lsb_release -cs) - $SUDO apt-add-repository --remove "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/$v $v main" - # The new USRP repository - # Raphael Defosseux: Adding a loop on adding PPA because in CI the gpg key retrieve may - # timeout due to proxy / network latencies in Eurecom on VM - echo_info "\nAdding PPA repository ettusresearch/uhd\n" - x=0 - while [ $x -le 5 ] - do - if $SUDO add-apt-repository ppa:ettusresearch/uhd -y - then - echo_info "add-apt-repository successful\n" - break - else - echo_info "add-apt-repository failed, retrying...\n" - sleep 30 - fi - x=$((x + 1)) - done - $SUDO apt-get update - $SUDO apt-get -y install python python-tk libboost-all-dev libusb-1.0-0-dev - $SUDO apt-get -y install libuhd-dev libuhd003 uhd-host - elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then - $SUDO $INSTALLER -y install python boost libusb-devel libusbx-devel boost-devel python-mako python-docutils cmake - $SUDO -H pip install requests - if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then - # until EPEL repo hasn't bumped UHD driver to >=3.10 in EPEL, build driver from source - $SUDO $INSTALLER -y remove uhd uhd-devel uhd-firmware - install_usrp_uhd_driver_from_source - else - $SUDO $INSTALLER -y install uhd uhd-devel uhd-firmware - fi - fi -} - -install_usrp_uhd_driver() { - if [[ "$OS_DISTRO" == "ubuntu" ]]; then - # We move uhd-host apart because it depends on linux kernel version - # On newer kernels, it fails to install - $SUDO apt-get -y install uhd-host - fi - # quick workaround for RHE7.6 - local distribution=$(get_distribution_release) - if [ -z $1 ]; then - if [[ "$OS_DISTRO" == "rhel" ]]; then - $SUDO /usr/local/bin/uhd_images_downloader - else - $SUDO uhd_images_downloader - fi - else - if [[ "$OS_DISTRO" == "rhel" ]]; then - $SUDO /usr/local/bin/uhd_images_downloader -i $1 - else - $SUDO uhd_images_downloader -i $1 - fi - fi -} - -install_bladerf_driver_from_source(){ - bladerf_install_log=$OPENAIR_DIR/cmake_targets/log/bladerf_install_log.txt - echo_info "\nInstalling BladeRF driver from sources. The log file for BladeRF driver installation is here: $bladerf_install_log " - ( - cd /tmp - echo "Downloading BladeRF driver" - rm -rf /tmp/bladeRF - git clone https://github.com/Nuand/bladeRF.git - cd bladeRF - git checkout tags/2016.06 - mkdir -p build - cd build - $CMAKE ../ - echo "Compiling BladeRF driver" - make - $SUDO make install - $SUDO ldconfig - echo "Downloading FPGA and firmware images" - cd /tmp/bladeRF - wget --tries=3 --retry-connrefused https://www.nuand.com/fx3/bladeRF_fw_latest.img - wget --tries=3 --retry-connrefused https://www.nuand.com/fpga/hostedx40-latest.rbf - sudo mkdir -p /usr/share/Nuand/bladeRF - sudo mv bladeRF_fw_latest.img /usr/share/Nuand/bladeRF/bladeRF_fw.img - sudo mv hostedx40-latest.rbf /usr/share/Nuand/bladeRF/hostedx40.rbf - ) >& $bladerf_install_log -} - -check_install_bladerf_driver(){ - if [[ "$OS_DISTRO" == "ubuntu" ]]; then - if [ "$(get_distribution_release)" == "ubuntu14.04" ] ; then - $SUDO add-apt-repository -y ppa:bladerf/bladerf - $SUDO apt-get update - fi - $SUDO apt-get install -y bladerf libbladerf-dev - $SUDO apt-get install -y bladerf-firmware-fx3 - $SUDO apt-get install -y bladerf-fpga-hostedx40 - elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then - install_bladerf_driver_from_source - else - echo_error "BladeRF Installer for OAI does not support automatic build. Install BladeRF compiling sources manually from BladeRF website" - fi -} - -flash_firmware_bladerf() { - $SUDO bladeRF-cli --flash-firmware /usr/share/Nuand/bladeRF/bladeRF_fw.img -} - -check_install_lmssdr_driver(){ - if ( [ -d "/usr/local/include/lime" ] && - [ -f "/usr/local/include/lime/LimeSuite.h" ] ) - then - echo_success "Found lmssdr drivers and tools installed from source" - else - echo_error "lmssdr support implies installing lmssdr drivers and tools" \ - " from sources. check:" - echo_info "https://wiki.myriadrf.org/Lime_Suite" - echo_fatal "Cannot compile lmssdr device" - fi - - -} - -install_soapy_from_source(){ - soapy_install_log=$OPENAIR_DIR/cmake_targets/log/soapy_install_log.txt - echo_info "\nInstalling Soapy EcoSystem from source. The log file for Soapy installation is here: $soapy_install_log " - ( - cd /tmp - echo "Downloading SoapySDR" - rm -rf /tmp/soapysdr - git clone -b soapy-sdr-0.7.0 --single-branch https://github.com/pothosware/SoapySDR.git - cd SoapySDR - #git checkout tags/release_003_010_001_001 - mkdir -p build - cd build - $CMAKE ../ - echo "Compiling SoapySDR" - make -j`nproc` - $SUDO make install - $SUDO ldconfig - cd /tmp - echo "Downloading SoapyRemote" - rm -rf /tmp/soapyremote - git clone -b soapy-remote-0.5.0 --single-branch https://github.com/pothosware/SoapyRemote.git - cd SoapyRemote - #git checkout tags/release_003_010_001_001 - mkdir -p build - cd build - cmake ../ - echo "Compiling SoapyRemote" - make -j`nproc` - $SUDO make install - $SUDO ldconfig - ) >& $soapy_install_log -} - -install_soapy_iris_from_source(){ - iris_install_log=$OPENAIR_DIR/cmake_targets/log/iris_install_log.txt - echo_info "\nInstalling Iris driver from source. The log file for Iris driver installation is here: $iris_install_log " - ( - cd /tmp - echo "Downloading SoapyIris" - rm -rf /tmp/sklk-soapyiris - git clone -b soapy-iris-2018.08.0.1 --single-branch https://github.com/skylarkwireless/sklk-soapyiris.git - cd sklk-soapyiris - mkdir -p build - cd build - cmake ../ - echo "Compiling SoapyIris" - make -j`nproc` - $SUDO make install - $SUDO ldconfig - ) >& $iris_install_log -} - -check_install_soapy () { - #if [[ "$OS_DISTRO" == "ubuntu" ]]; then - #first we remove old installation - $SUDO apt-get remove -y soapysdr soapysdr-server libsoapysdr-dev python-soapysdr python3-soapysdr soapysdr-module-remote || true - #$SUDO add-apt-repository -y ppa:myriadrf/drivers - #$SUDO apt-get update - #$SUDO apt-get install -y soapysdr soapysdr-server libsoapysdr-dev python-soapysdr python3-soapysdr soapysdr-module-remote - - #elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then - # $SUDO $INSTALLER -y install software-properties-common python3-software-properties python-software-properties subversion git python3 python-numpy python3-numpy cmake swig python-dev - install_soapy_from_source - #fi - install_soapy_iris_from_source - -} - -check_install_additional_tools (){ - $SUDO $INSTALLER update -y - if [[ "$OS_DISTRO" == "ubuntu" ]]; then - PACKAGE_LIST="\ - check \ - dialog \ - dkms \ - gawk \ - libboost-all-dev \ - libpthread-stubs0-dev \ - openvpn \ - pkg-config \ - python-dev \ - python-pexpect \ - sshfs \ - swig \ - tshark \ - uml-utilities \ - unzip \ - valgrind \ - vlan \ - ctags \ - ntpdate \ - iperf3 \ - android-tools-adb \ - wvdial \ - python-numpy \ - sshpass \ - nscd \ - bc \ - ntp \ - python-scipy \ - python-matplotlib" - elif [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then - PACKAGE_LIST="\ - check \ - dialog \ - dkms \ - gawk \ - boost-devel \ - openvpn \ - pkgconfig \ - pexpect \ - sshfs \ - swig \ - wireshark \ - unzip \ - valgrind \ - vconfig \ - ctags \ - ntpdate \ - iperf3 \ - wvdial \ - numpy \ - sshpass \ - nscd \ - python2-paramiko \ - python-pyroute2 \ - python-netifaces \ - scipy \ - python-matplotlib" - elif [[ "$OS_DISTRO" == "fedora" ]]; then - PACKAGE_LIST=" \ - check \ - dialog \ - dkms \ - gawk \ - boost-devel \ - openvpn \ - pkgconfig \ - python-pexpect \ - sshfs \ - swig \ - wireshark \ - unzip \ - valgrind \ - vconfig \ - ctags \ - ntpdate \ - iperf3 \ - wvdial \ - python-numpy \ - sshpass \ - nscd \ - python2-paramiko \ - python-pyroute2 \ - python-netifaces \ - python2-scipy \ - python2-matplotlib" - fi - $SUDO $INSTALLER install -y $PACKAGE_LIST - - $SUDO rm -fr /opt/ssh - $SUDO GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/ssh.git /opt/ssh - - #The packages below are already installed for Redhat distros (RHEL, CentOS, Fedora) - if [[ "$OS_DISTRO" == "ubuntu" ]]; then - $SUDO -H pip install paramiko - $SUDO -H pip install pyroute2 colorama - log_netiface=$OPENAIR_DIR/cmake_targets/log/netiface_install_log.txt - echo_info "Installing Netinterfaces package. The logfile for installation is in $log_netiface" - ( - $SUDO rm -fr /tmp/netifaces-0.10.4.tar.gz /tmp/netifaces - wget --tries=3 --retry-connrefused -P /tmp https://pypi.python.org/packages/18/fa/dd13d4910aea339c0bb87d2b3838d8fd923c11869b1f6e741dbd0ff3bc00/netifaces-0.10.4.tar.gz - tar -xzvf /tmp/netifaces-0.10.4.tar.gz -C /tmp - cd /tmp/netifaces-0.10.4 - $SUDO python setup.py install - cd - - ) >& $log_netiface - fi -} - -check_install_oai_software() { - local specific_packages="" - if ! check_supported_distribution; then - echo_error "Your distribution $(get_distribution_release) is not supported by oai !" - exit 1 - fi - $SUDO $INSTALLER update -y - if [[ "$OS_DISTRO" == "ubuntu" ]]; then - local LAPACK_LIBNAME="liblapack.so" - local LAPACK_TARGET="/usr/lib/atlas-base/atlas/liblapack.so" - $SUDO apt install -y software-properties-common - case "$(get_distribution_release)" in - "ubuntu14.04") - specific_packages="libtasn1-3-dev libgnutls-dev libatlas-dev iproute libconfig8-dev" - # For iperf3 - $SUDO add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports universe" - $SUDO apt-get update - ;; - "ubuntu16.04") - specific_packages="libtasn1-6-dev libgnutls-dev libatlas-dev iproute libconfig8-dev" - ;; - "ubuntu17.04") - specific_packages="libtasn1-6-dev libgnutls28-dev libatlas-dev iproute libconfig8-dev" - ;; - "ubuntu17.10") - specific_packages="libtasn1-6-dev libgnutls28-dev iproute libconfig8-dev" - LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" - LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" - ;; - "ubuntu18.04") - specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev" - LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" - LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" - ;; - esac - $SUDO apt-get install -y \ - $specific_packages \ - autoconf \ - automake \ - bison \ - build-essential \ - cmake \ - cmake-curses-gui \ - ninja-build \ - doxygen \ - doxygen-gui \ - texlive-latex-base \ - ethtool \ - flex \ - gdb \ - git \ - graphviz \ - gtkwave \ - guile-2.0-dev \ - iperf \ - iptables \ - iptables-dev \ - libatlas-base-dev \ - libblas-dev \ - liblapack-dev\ - liblapacke-dev\ - libffi-dev \ - libforms-bin \ - libforms-dev \ - libgcrypt11-dev \ - libgmp-dev \ - libgtk-3-dev \ - libidn2-0-dev \ - libidn11-dev \ - libmysqlclient-dev \ - libpython2.7-dev \ - libsctp1 \ - libsctp-dev \ - libssl-dev \ - libtool \ - libusb-1.0-0-dev \ - libxml2 \ - libxml2-dev \ - libxslt1-dev \ - mscgen \ - octave-signal \ - openssh-client \ - openssh-server \ - openssl \ - python \ - subversion \ - xmlstarlet \ - python-pip \ - pydb \ - libyaml-dev \ - wget \ - libxpm-dev \ - libboost-all-dev - - $SUDO update-alternatives --set "$LAPACK_LIBNAME" "$LAPACK_TARGET" - - $SUDO apt-get install -y nettle-dev nettle-bin - elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then - if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then - if rpm -q epel-release > /dev/null; then - echo "EPEL repos already present. Good." - else - echo "EPEL repos not present. Installing them." - $SUDO $INSTALLER install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - fi - $SUDO $INSTALLER install -y python-epdb vim-common - else - $SUDO $INSTALLER install -y mscgen pydb - fi - - $SUDO $INSTALLER install -y \ - autoconf \ - automake \ - bc \ - bison \ - $CMAKE \ - doxygen \ - ethtool \ - flex \ - gdb \ - git \ - graphviz \ - gtkwave \ - guile-devel \ - iperf \ - iproute \ - iptables \ - iptables-devel \ - atlas-devel \ - blas-devel \ - libconfig-devel \ - libffi-devel \ - xforms \ - xforms-devel \ - libgcrypt-devel \ - gmp-devel \ - gtk3-devel \ - libidn2-devel \ - libidn-devel \ - mariadb-devel \ - lksctp-tools \ - lksctp-tools-devel \ - openssl-devel \ - libtasn1 \ - libtool \ - libusb-devel \ - libxml2 \ - libxml2-devel \ - libxslt-devel \ - openssh-clients \ - openssh-server \ - openssl \ - patch \ - psmisc \ - python \ - subversion \ - xmlstarlet \ - python-pip \ - wget \ - kernel-headers \ - kernel-devel \ - nettle-devel \ - gnutls-devel \ - libXpm-devel \ - lapack \ - lapack-devel \ - blas \ - blas-devel \ - libyaml-devel - fi - - install_asn1c_from_source $1 - $SUDO rm -fr /opt/ssh - $SUDO git clone https://gist.github.com/2190472.git /opt/ssh -} - -install_asn1c_from_source(){ - asn1_install_log=$OPENAIR_DIR/cmake_targets/log/asn1c_install_log.txt - echo_info "\nInstalling ASN1. The log file for ASN1 installation is here: $asn1_install_log " - ( - $SUDO rm -rf /tmp/asn1c - # GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c - git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c - cd /tmp/asn1c - # better to use a given commit than a branch in case the branch - # is updated and requires modifications in the source of OAI - #git checkout velichkov_s1ap_plus_option_group - git checkout f12568d617dbf48497588f8e227d70388fa217c9 - autoreconf -iv - ./configure - make -j`nproc` - $SUDO make install - cd - - $SUDO ldconfig - ) > $asn1_install_log 2>&1 -} - -################################################# -# 2. compile -################################################ - -install_nas_tools() { - if [ ! -f .ue.nvram0 ]; then - echo_success "generate .ue_emm.nvram .ue.nvram" - ./nvram --gen -c $1 -o $2 - else - [ ./nvram -nt .ue.nvram0 -o ./nvram -nt .ue_emm.nvram0 ] && ./nvram --gen -c $1 -o $2 - fi - - if [ ! -f .usim.nvram0 ]; then - echo_success "generate .usim.nvram" - ./usim --gen -c $1 -o $2 - else - [ ./usim -nt .usim.nvram0 ] && ./usim --gen -c $1 -o $2 - fi - -} - - -################################ -# set_openair_env -############################### -set_openair_env(){ - fullpath=`readlink -f $BASH_SOURCE` - [ -f "/.$fullpath" ] || fullpath=`readlink -f $PWD/$fullpath` - openair_path=${fullpath%/cmake_targets/*} - openair_path=${openair_path%/targets/*} - openair_path=${openair_path%/openair[123]/*} - export OPENAIR_DIR=$openair_path - export OPENAIR1_DIR=$openair_path/openair1 - export OPENAIR2_DIR=$openair_path/openair2 - export OPENAIR3_DIR=$openair_path/openair3 - export OPENAIR_TARGETS=$openair_path/targets -} - -################################ -# Function to killall the subprocesses when Ctrl-C Key is hit -############################### -function handle_ctrl_c(){ -CURPID=$$ -ppid=$$ -arraycounter=1 -echo_info "** Trapped CTRL-C. Killing all subprocesses now..." -echo_info "** Calling sync now..." -sync -while true -do - FORLOOP=FALSE - # Get all the child process id - for i in `ps -ef| awk '$3 == '$ppid' { print $2 }'` - do - if [ $i -ne $CURPID ] ; then - procid[$arraycounter]=$i - arraycounter=`expr $arraycounter + 1` - ppid=$i - FORLOOP=TRUE - fi - done - if [ "$FORLOOP" = "FALSE" ] ; then - arraycounter=`expr $arraycounter - 1` - ## We want to kill child process id first and then parent id's - while [ $arraycounter -ne 0 ] - do - echo "first we send ctrl-c to program" - $SUDO kill -INT "${procid[$arraycounter]}" - sleep 5 - echo "Now we force kill if that didn't work" - $SUDO kill -9 "${procid[$arraycounter]}" >/dev/null - arraycounter=`expr $arraycounter - 1` - done - exit - fi -done -} - - -# get from http://www.linuxjournal.com/content/validating-ip-address-bash-script -validate_ip() { - -local ip=$1 -local stat=1 - -if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - OIFS=$IFS - IFS='.' - ip=($ip) - IFS=$OIFS - [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ - && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] - stat=$? -fi - -return $stat -} diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 8e74f4148c..ccf5b831b5 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -397,18 +397,21 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int /* define variable only used in LOG macro's */ # define LOG_VAR(A,B) A B # else /* T_TRACER: remove all debugging and tracing messages, except errors */ -# define LOG_I(c, x...) do {logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ; } while(0)/* */ -# define LOG_W(c, x...) do {logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ; } while(0)/* */ -# define LOG_E(c, x...) do {logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ERR, x) ; } while(0)/* */ -# define LOG_D(c, x...) do {logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ; } while(0)/* */ -# define LOG_T(c, x...) /* */ -# define LOG_DUMPMSG(c, b, s, x...) /* */ +# define LOG_E(c, x...) do { if( g_log->log_component[c].level >= OAILOG_ERR ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ERR, x) ;} while (0) +# define LOG_W(c, x...) do { if( g_log->log_component[c].level >= OAILOG_WARNING) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ;} while (0) +# define LOG_I(c, x...) do { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} while (0) +# define LOG_D(c, x...) do { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} while (0) +# define LOG_T(c, x...) do { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} while (0) +# define VLOG(c,l, f, args) do { if( g_log->log_component[c].level >= l ) vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, l, f, args) ; } while (0) + # define nfapi_log(FILE, FNC, LN, COMP, LVL, FMT...) -# define LOG_DEBUGFLAG(D) ( 0 ) -# define LOG_DUMPFLAG(D) ( 0 ) +# define LOG_DEBUGFLAG(D) (g_log->dump_mask & D) +# define LOG_DUMPFLAG(D) (g_log->debug_mask & D) +# define LOG_DUMPMSG(c, f, b, s, x...) do { if(g_log->dump_mask & f) log_dump(c, b, s, LOG_DUMP_CHAR, x) ;} while (0) /* */ + # define LOG_M(file, vector, data, len, dec, format) do { write_file_matlab(file, vector, data, len, dec, format);} while(0) -# define LOG_VAR(A,B) +# define LOG_VAR(A,B) A B # endif /* T_TRACER */ /* avoid warnings for variables only used in LOG macro's but set outside debug section */ #define GCC_NOTUSED __attribute__((unused)) diff --git a/common/utils/LOG/vcd_signal_dumper.c b/common/utils/LOG/vcd_signal_dumper.c index 90857d7cd9..bd598b48da 100644 --- a/common/utils/LOG/vcd_signal_dumper.c +++ b/common/utils/LOG/vcd_signal_dumper.c @@ -814,6 +814,7 @@ static inline unsigned long long int vcd_get_time(void) return (long long unsigned int)((time.tv_nsec - g_time_start.tv_nsec)) + ((long long unsigned int)time.tv_sec - (long long unsigned int)g_time_start.tv_sec) * 1000000000UL; #endif + return 0; } void vcd_signal_dumper_create_header(void) diff --git a/common/utils/LOG/vcd_signal_dumper.h b/common/utils/LOG/vcd_signal_dumper.h index 601465c628..f9f5868260 100644 --- a/common/utils/LOG/vcd_signal_dumper.h +++ b/common/utils/LOG/vcd_signal_dumper.h @@ -601,11 +601,19 @@ extern int ouput_vcd; #else /* T_TRACER */ +#if ENABLE_VCD #define VCD_SIGNAL_DUMPER_INIT(aRgUmEnT) vcd_signal_dumper_init(aRgUmEnT) #define VCD_SIGNAL_DUMPER_CLOSE() vcd_signal_dumper_close() #define VCD_SIGNAL_DUMPER_CREATE_HEADER() vcd_signal_dumper_create_header() #define VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(vAr1,vAr2) vcd_signal_dumper_dump_variable_by_name(vAr1,vAr2) #define VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(vAr1,vAr2) vcd_signal_dumper_dump_function_by_name(vAr1,vAr2) +#else +#define VCD_SIGNAL_DUMPER_INIT(aRgUmEnT) +#define VCD_SIGNAL_DUMPER_CLOSE() +#define VCD_SIGNAL_DUMPER_CREATE_HEADER() +#define VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(vAr1,vAr2) +#define VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(vAr1,vAr2) +#endif #endif /* T_TRACER */ diff --git a/doc/SW_archi.md b/doc/SW_archi.md index b7f3551b69..731098ca6f 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -1,4 +1,25 @@ + + + This tuto for 5G gNB design, with Open Cells main +{: .text-center} # Top file: executables/ocp-gnb.c @@ -13,74 +34,120 @@ The infinite loop: the internal time comes from the RF board sampling numbers (each sample has a incremental number representing a very accurate timing) raw incoming data is in buffer called "rxdata" +{: .func2} ### nr_fep_full() "front end processing" of uplink signal performs DFT on the signal same function (duplicates): phy_procedures_gNB_common_RX() it computes the buffer rxdataF (for frequency) from rxdata (samples over time) +{: .func3} ### gNB_top() only compute frame numbre, slot number, ... +{: .func3} ### ocp_rxtx() main processing for both UL and DL all the context is in the passed structure UL_INFO the context is not very clear: there is a mutex on it, but not actual coherency (see below handle_nr_rach() assumes data is up-to-date) - -The first part (in NR_UL_indication, uses the data computed by the lower part (phy_procedures_gNB_uespec_RX), but for the previous slot - -Then, phy_procedures_gNB_uespec_RX will replace the data for the next run - +The first part (in NR_UL_indication, uses the data computed by the lower part (phy_procedures_gNB_uespec_RX), but for the **previous** slot +Then, phy_procedures_gNB_uespec_RX will hereafter replace the data for the next run This is very tricky and not thread safe at all. +{: .func3} #### NR_UL_indication() This block processes data already decoded and stored in structures behind UL_INFO +{: .func4} * handle_nr_rach() process data from RACH primary detection if the input is a UE RACH detection +{: .func4} * nr_schedule_msg2() +{: .func4} * handle_nr_uci() ???? +{: .func4} * handle_nr_ulsch() handles ulsch data prepared by nr_fill_indication() +{: .func4} * gNB_dlsch_ulsch_scheduler () also calls "run_pdcp()", as this is not a autonomous thread, it needs to be called here to update traffic requests (DL) and to propagate waiting UL to upper layers +Calls schedule_nr_mib() that calls mac_rrc_nr_data_req() to fill MIB, +Calls each channel allocation: schedule SI, schedule_ul, schedule_dl, ... +this is a major entry for "phy-test" mode: in this mode, the allocation is fixed +all these channels goes to mac_rrc_nr_data_req() to get the data to transmit +{: .func4} * NR_Schedule_response() process as per the scheduler decided +{: .func4} #### L1_nr_prach_procedures() ???? +{: .func4} #### phy_procedures_gNB_uespec_RX() * nr_decode_pucch0() actual CCH channel decoding +{: .func4} * nr_rx_pusch() - * extracts data from rxdataF (frequency transformed received data) +{: .func4} + * extracts data from rxdataF (frequency transformed received data) +{: .func4} * nr_pusch_channel_estimation() - * nr_ulsch_extract_rbs_single() +{: .func4} + * nr_ulsch_extract_rbs_single() +{: .func4} * nr_ulsch_scale_channel() +{: .func4} * nr_ulsch_channel_level() +{: .func4} * nr_ulsch_channel_compensation() +{: .func4} * nr_ulsch_compute_llr() this function creates the "likelyhood ratios" +{: .func4} * nr_ulsch_procedures() +{: .func4} * actual ULsch decoding +{: .func4} * nr_ulsch_unscrambling() - * nr_ulsch_decoding() - * nr_fill_indication() + {: .func4} + * nr_ulsch_decoding() + {: .func4} + * nr_fill_indication() +{: .func4} populated the data for the next call to "NR_UL_indication()" +{: .func4} #### phy_procedures_gNB_TX() * nr_common_signal_procedures() generate common signals -* nr_generate_dci_top() +{: .func4} +* nr_generate_dci_top() generate DCI: the scheduling informtion for each UE in both DL and UL +{: .func4} * nr_generate_pdsch() generate DL shared channel (user data) +{: .func4} ### nr_feptx_prec() tx precoding +{: .func3} ### nr_feptx0 do the inverse DFT +{: .func3} ### tx_rf() send radio signal samples to the RF board -the samples numbers are the future time for these samples emission on-air \ No newline at end of file +the samples numbers are the future time for these samples emission on-air +{: .func3} + + +
+**Note** +{: .panel-heading} +
+ +NOTE DESCRIPTION + +
+
+ diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index e4c6d7b439..1c5eba0447 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -79,6 +79,9 @@ unsigned short config_frames[4] = {2,9,11,13}; /* Callbacks, globals and object handlers */ #include "PHY/TOOLS/nr_phy_scope.h" +// at eNB 0, an UL scope for every UE +//FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + #include #include "executables/softmodem-common.h" #include "executables/thread-common.h" diff --git a/executables/split_headers.h b/executables/split_headers.h index 4e328f74c4..985b1b7dae 100644 --- a/executables/split_headers.h +++ b/executables/split_headers.h @@ -28,6 +28,7 @@ #include #include #include +#include #define CU_PORT "7878" #define DU_PORT "8787" @@ -325,5 +326,6 @@ void fep_full(RU_t *ru, int subframe); void feptx_prec(RU_t *ru,int frame,int subframe); void feptx_ofdm(RU_t *ru, int frame, int subframe); void oai_subframe_ind(uint16_t sfn, uint16_t sf); +void softmodem_printresources(int sig, telnet_printfunc_t pf); extern uint16_t sf_ahead; #endif diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 2f05bac13b..66855c850c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2242,16 +2242,13 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, MIMO_mode_t mimo_mode = -1; uint8_t mprime=0,Ns; int8_t lprime=-1; - int aa=0; #ifdef DEBUG_DLSCH_MODULATION uint8_t Nl0; //= dlsch0_harq->Nl; uint8_t Nl1; #endif - int ru_id; RU_t *ru; - int eNB_id; if ((dlsch0 != NULL) && (dlsch1 != NULL)){ @@ -2433,11 +2430,11 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, // mapping ue specific beamforming weights from UE specified DLSCH structure to RU beam weights for the eNB /* - for (ru_id=0;ru_idnum_eNB;eNB_id++){ + for (int eNB_id=0;eNB_idnum_eNB;eNB_id++){ if (phy_vars_eNB == ru->eNB_list[eNB_id]) { - for (aa=0;aanb_tx;aa++){ + for (int aa=0;aanb_tx;aa++){ LOG_I(PHY,"ru_id:%d eNB_id:%d aa:%d memcpy(ru->beam_weights, dlsch0->ue_spec_bf_weights[ru_id][0],)\n", ru_id, eNB_id, aa); memcpy(ru->beam_weights[eNB_id][5][aa], dlsch0->ue_spec_bf_weights[ru_id][0], diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 992c908c5d..94e356951a 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -424,7 +424,7 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) for (int ULSCH_id=0;ULSCH_idulsch[ULSCH_id][0]; int harq_pid; - int no_sig; + //int no_sig; NR_UL_gNB_HARQ_t *ulsch_harq; if ((ulsch) && diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 5fa77c6ca7..a5a41ee4e7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -141,4 +141,10 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ } } +void +schedule_nr_SI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) +//------------------------------------------------------------------------------ +{ + +} diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 0905f6d7de..d117b18199 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -88,6 +88,12 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, } /* TODO BCCH SIB1 SIBs */ + if ((Srb_id & RAB_OFFSET ) == BCCH) { + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB1_MBMS, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_MBMS); + + } /* CCCH */ if( (Srb_id & RAB_OFFSET ) == CCCH) { @@ -114,4 +120,4 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, return(0); -} \ No newline at end of file +} diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index d59ecf5626..3e5922663b 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -340,11 +340,12 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ASN_SEQUENCE_ADD(&sib1->uac_BarringInfo->uac_BarringInfoSetList, &nr_uac_BarringInfoSet); #endif //encode SIB1 to data + carrier->SIB1=(uint8_t *) malloc16(128); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_DL_SCH_Message, NULL, (void *)sib1_message, carrier->SIB1, - 100); + 128); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); @@ -580,5 +581,6 @@ void do_SpCellConfig(gNB_RRC_INST *rrc, int do_DLInformationTransfer_NR () { + return 0; } diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 1f341cfdf9..36536eeedd 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -178,10 +178,11 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( ///---------------------------------------------------------------------------------------------------------------/// ///---------------------------------------------------------------------------------------------------------------/// -static void init_NR_SI(gNB_RRC_INST *rrc) { +static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration) { LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__); rrc->carrier.MIB = (uint8_t *) malloc16(4); rrc->carrier.sizeof_MIB = do_MIB_NR(rrc,0); + rrc->carrier.sizeof_SIB1 = do_SIB1_NR(rrc,configuration); LOG_I(NR_RRC,"Done init_NR_SI\n"); rrc_mac_config_req_gNB(rrc->module_id, rrc->carrier.ssb_SubcarrierOffset, @@ -267,7 +268,7 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu rrc->carrier.pdsch_AntennaPorts = configuration->pdsch_AntennaPorts; /// System Information INIT LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" Checking release \n",PROTOCOL_NR_RRC_CTXT_ARGS(&ctxt)); - init_NR_SI(rrc); + init_NR_SI(rrc, configuration); rrc_init_nr_global_param(); openair_nr_rrc_on(&ctxt); return 0; From 7d1d8744e66e48dcdd73712cd4e281443d64e8a7 Mon Sep 17 00:00:00 2001 From: laurent Date: Mon, 10 Aug 2020 17:46:10 +0200 Subject: [PATCH 025/149] continue 5G SA NAS messages --- cmake_targets/CMakeLists.txt | 5 ++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 8 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 9 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 53 ++++++------ openair3/NAS/COMMON/NR_NAS_defs.h | 33 ++++++++ openair3/NAS/NR_UE/nr_user_def.h | 3 + openair3/NAS/NR_UE/ue_process_nas.c | 73 ++++++++++++++++ openair3/NAS/gNB/network_process_nas.c | 84 +++++++++++++++++++ 10 files changed, 236 insertions(+), 36 deletions(-) create mode 100644 openair3/NAS/NR_UE/nr_user_def.h create mode 100644 openair3/NAS/NR_UE/ue_process_nas.c create mode 100644 openair3/NAS/gNB/network_process_nas.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 1c09673552..fcb704d1bc 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2266,6 +2266,11 @@ set (SHLIB_LOADER_SOURCES ${OPENAIR_DIR}/common/utils/load_module_shlib.c ) +add_library(LIB_5GNAS_GNB + ${NAS_SRC}/gNB/network_process_nas.c + ${NAS_SRC}/NR_UE/ue_process_nas.c + ) + # Make lfds as a own source code (even if it is a outside library) # For better intergration with compilation flags & structure of cmake ################################################################### diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index e25680e861..73fc3f62d6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -377,7 +377,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0) nr_ulmix_slots++; - if (slot_txP== 0 && (UE_list->fiveG_connected[UE_id] || get_softmodem_params()->phy_test)) { + if (slot_txP== 0 && (UE_list->UEcontext[UE_id].fiveG_connected || get_softmodem_params()->phy_test)) { for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k], 0, @@ -449,7 +449,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (get_softmodem_params()->phy_test == 0) nr_schedule_RA(module_idP, frame_txP, slot_txP); else - UE_list->fiveG_connected[UE_id] = true; + UE_list->UEcontext[UE_id].fiveG_connected = true; // Phytest scheduling @@ -471,7 +471,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, } } - if (UE_list->fiveG_connected[UE_id] && (is_xlsch_in_slot(*dlsch_in_slot_bitmap,slot_txP%num_slots_per_tdd))) { + if (UE_list->UEcontext[UE_id].fiveG_connected && (is_xlsch_in_slot(*dlsch_in_slot_bitmap,slot_txP%num_slots_per_tdd))) { ue_sched_ctl->current_harq_pid = slot_txP % num_slots_per_tdd; nr_update_pucch_scheduling(module_idP, UE_id, frame_txP, slot_txP, num_slots_per_tdd,&pucch_sched); nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP, &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); @@ -490,7 +490,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (is_nr_UL_slot(cc->ServingCellConfigCommon,slot_rxP)) { if (get_softmodem_params()->phy_test == 0) { - if (UE_list->fiveG_connected[UE_id]) + if (UE_list->UEcontext[UE_id].fiveG_connected) nr_schedule_pucch(module_idP, UE_id, frame_rxP, slot_rxP); schedule_nr_prach(module_idP, (frame_rxP+1)&1023, slot_rxP); nr_schedule_reception_msg3(module_idP, 0, frame_rxP, slot_rxP); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 2eb4ad498b..8542bf7b70 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -268,7 +268,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, } } if (pr_found) - UE_list->fiveG_connected[UE_id] = false; + UE_list->UEcontext[UE_id].fiveG_connected = false; else { LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated for UE_id %d\n", module_idP, preamble_index, UE_id); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 52fa761584..d0d52727b3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -303,7 +303,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, if (UE_list->active[i] == TRUE) { if (UE_list->tc_rnti[i] == current_rnti) { // for now the only thing we are doing is set the UE as 5G connected - UE_list->fiveG_connected[i] = true; + UE_list->UEcontext[i].fiveG_connected = true; LOG_I(MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly and UE_id %d is now 5G connected\n", gnb_mod_idP, current_rnti, i); } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index f84e7a900c..6a72a74d5a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -68,6 +68,9 @@ #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h" #include "NR_TAG.h" +#include + + /* Defs */ #define MAX_NUM_BWP 2 #define MAX_NUM_CORESET 2 @@ -278,6 +281,10 @@ typedef struct NR_preamble_ue { uint8_t *preamble_list; } NR_preamble_ue; +typedef struct { + boolean_t fiveG_connected; +} NRUEcontext_t; + /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ typedef struct { DLSCH_PDU DLSCH_pdu[4][MAX_MOBILES_PER_GNB]; @@ -290,7 +297,7 @@ typedef struct { int avail; int num_UEs; boolean_t active[MAX_MOBILES_PER_GNB]; - boolean_t fiveG_connected[MAX_MOBILES_PER_GNB]; + NRUEcontext_t UEcontext[MAX_MOBILES_PER_GNB]; rnti_t rnti[MAX_MOBILES_PER_GNB]; rnti_t tc_rnti[MAX_MOBILES_PER_GNB]; NR_preamble_ue preambles[MAX_MOBILES_PER_GNB]; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 3e5922663b..570d50005c 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -200,6 +200,10 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { mib->message.choice.mib->spare.bits_unused = 7; // This makes a spare of 1 bits mib->message.choice.mib->ssb_SubcarrierOffset = (carrier->ssb_SubcarrierOffset)&15; + /* + * The SIB1 will be sent in this allocation (Type0-PDCCH) : 38.213, 13-4 Table and 38.213 13-11 to 13-14 tables + * the reverse allocation is in nr_ue_decode_mib() + */ mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero; mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero; AssertFatal(scc->ssbSubcarrierSpacing != NULL, "scc->ssbSubcarrierSpacing is null\n"); @@ -265,10 +269,6 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, gNB_RrcConfigurationReq *configuration ) { asn_enc_rval_t enc_rval; - NR_BCCH_DL_SCH_Message_t *sib1_message ; - struct NR_SIB1 *sib1 ; - int i; - struct NR_PLMN_IdentityInfo nr_plmn_info; // TODO : Add support for more than one PLMN //int num_plmn = configuration->num_plmn; @@ -276,31 +276,29 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, struct NR_PLMN_Identity nr_plmn[num_plmn]; NR_MCC_MNC_Digit_t nr_mcc_digit[num_plmn][3]; NR_MCC_MNC_Digit_t nr_mnc_digit[num_plmn][3]; + memset(nr_plmn,0,sizeof(nr_plmn)); + memset(nr_mcc_digit,0,sizeof(nr_mcc_digit)); + memset(nr_mnc_digit,0,sizeof(nr_mnc_digit)); + // struct NR_UAC_BarringInfoSet nr_uac_BarringInfoSet; - sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t)); - memset(sib1_message,0,sizeof(NR_BCCH_DL_SCH_Message_t)); + NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t)); carrier->siblock1 = sib1_message; sib1_message->message.present = NR_BCCH_DL_SCH_MessageType_PR_c1; sib1_message->message.choice.c1 = CALLOC(1,sizeof(struct NR_BCCH_DL_SCH_MessageType__c1)); - memset(sib1_message->message.choice.c1,0,sizeof(struct NR_BCCH_DL_SCH_MessageType__c1)); sib1_message->message.choice.c1->present = NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1; sib1_message->message.choice.c1->choice.systemInformationBlockType1 = CALLOC(1,sizeof(struct NR_SIB1)); - sib1 = sib1_message->message.choice.c1->choice.systemInformationBlockType1; - memset(sib1,0,sizeof(struct NR_SIB1)); + + struct NR_SIB1 *sib1 = sib1_message->message.choice.c1->choice.systemInformationBlockType1; sib1->cellSelectionInfo = CALLOC(1,sizeof(struct NR_SIB1__cellSelectionInfo)); - memset(sib1->cellSelectionInfo,0,sizeof(struct NR_SIB1__cellSelectionInfo)); sib1->cellSelectionInfo->q_RxLevMin = -50; - memset(&nr_plmn_info.plmn_IdentityList,0,sizeof(struct NR_PLMN_IdentityInfo__plmn_IdentityList)); - asn_set_empty(&nr_plmn_info.plmn_IdentityList.list); - memset(&nr_plmn_info,0,sizeof(struct NR_PLMN_IdentityInfo)); - memset(nr_plmn,0,num_plmn*sizeof(struct NR_PLMN_Identity)); - for (i = 0; i < num_plmn; ++i) { + struct NR_PLMN_IdentityInfo *nr_plmn_info=CALLOC(1,sizeof(struct NR_PLMN_IdentityInfo)); + asn_set_empty(&nr_plmn_info->plmn_IdentityList.list); + for (int i = 0; i < num_plmn; ++i) { nr_mcc_digit[i][0] = (configuration->mcc[i]/100)%10; nr_mcc_digit[i][1] = (configuration->mcc[i]/10)%10; nr_mcc_digit[i][2] = (configuration->mcc[i])%10; nr_plmn[i].mcc = CALLOC(1,sizeof(struct NR_MCC)); - memset(nr_plmn[i].mcc,0,sizeof(struct NR_MCC)); asn_set_empty(&nr_plmn[i].mcc->list); ASN_SEQUENCE_ADD(&nr_plmn[i].mcc->list, &nr_mcc_digit[i][0]); ASN_SEQUENCE_ADD(&nr_plmn[i].mcc->list, &nr_mcc_digit[i][1]); @@ -308,26 +306,23 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, nr_mnc_digit[i][0] = (configuration->mnc[i]/100)%10; nr_mnc_digit[i][1] = (configuration->mnc[i]/10)%10; nr_mnc_digit[i][2] = (configuration->mnc[i])%10; - memset(&nr_plmn[i].mnc,0,sizeof(NR_MNC_t)); nr_plmn[i].mnc.list.size=0; nr_plmn[i].mnc.list.count=0; ASN_SEQUENCE_ADD(&nr_plmn[i].mnc.list, &nr_mnc_digit[i][0]); ASN_SEQUENCE_ADD(&nr_plmn[i].mnc.list, &nr_mnc_digit[i][1]); ASN_SEQUENCE_ADD(&nr_plmn[i].mnc.list, &nr_mnc_digit[i][2]); - ASN_SEQUENCE_ADD(&nr_plmn_info.plmn_IdentityList.list, &nr_plmn[i]); + ASN_SEQUENCE_ADD(&nr_plmn_info->plmn_IdentityList.list, &nr_plmn[i]); }//end plmn loop - nr_plmn_info.cellIdentity.buf = MALLOC(8); - memset(nr_plmn_info.cellIdentity.buf,0,8); - nr_plmn_info.cellIdentity.buf[0]= (configuration->cell_identity >> 20) & 0xff; - nr_plmn_info.cellIdentity.buf[1]= (configuration->cell_identity >> 12) & 0xff; - nr_plmn_info.cellIdentity.buf[2]= (configuration->cell_identity >> 4) & 0xff; - nr_plmn_info.cellIdentity.buf[3]= (configuration->cell_identity << 4) & 0xff; - nr_plmn_info.cellIdentity.size= 4; - nr_plmn_info.cellIdentity.bits_unused= 4; - nr_plmn_info.cellReservedForOperatorUse = 0; - memset(&sib1->cellAccessRelatedInfo,0,sizeof(NR_CellAccessRelatedInfo_t)); - ASN_SEQUENCE_ADD(&sib1->cellAccessRelatedInfo.plmn_IdentityList.list, &nr_plmn_info); + nr_plmn_info->cellIdentity.buf = CALLOC(1,8); + nr_plmn_info->cellIdentity.buf[0]= (configuration->cell_identity >> 20) & 0xff; + nr_plmn_info->cellIdentity.buf[1]= (configuration->cell_identity >> 12) & 0xff; + nr_plmn_info->cellIdentity.buf[2]= (configuration->cell_identity >> 4) & 0xff; + nr_plmn_info->cellIdentity.buf[3]= (configuration->cell_identity << 4) & 0xff; + nr_plmn_info->cellIdentity.size= 4; + nr_plmn_info->cellIdentity.bits_unused= 4; + nr_plmn_info->cellReservedForOperatorUse = 0; + ASN_SEQUENCE_ADD(&sib1->cellAccessRelatedInfo.plmn_IdentityList.list, nr_plmn_info); #if 0 sib1->uac_BarringInfo = CALLOC(1, sizeof(struct NR_SIB1__uac_BarringInfo)); memset(sib1->uac_BarringInfo, 0, sizeof(struct NR_SIB1__uac_BarringInfo)); diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index 386f79c504..b71748943b 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -196,6 +196,23 @@ typedef enum { FOREACH_CAUSE_SECU(CAUSE_ENUM) } cause_secu_id_t; +//TS 24.501 sub layer states for UE +// for network side, only 5GMMderegistered, 5GMMderegistered_initiated, 5GMMregistered, 5GMMservice_request_initiated are valid +typedef enum { + SGMMnull, + SGMMderegistered, + SGMMderegistered_initiated, + SGMMregistered, + SGMMregistered_initiated, + SGMMservice_request_initiated, +} SGMM_UE_states; + +typedef struct { + Extendedprotocoldiscriminator_t epd:8; + Security_header_t sh:8; + SGSmobilitymanagementmessages_t mt:8; +} SGScommonHeader_t; + typedef struct { Extendedprotocoldiscriminator_t epd:8; Security_header_t sh:8; @@ -212,3 +229,19 @@ typedef struct { } Identityresponse_t; +typedef struct { + Extendedprotocoldiscriminator_t epd:8; + Security_header_t sh:8; + SGSmobilitymanagementmessages_t mt:8; + int ngKSI:4; + int spare:4; + int ABBALen:8; +} authenticationrequestHeader_t; + +typedef struct { + Extendedprotocoldiscriminator_t epd:8; + Security_header_t sh:8; + SGSmobilitymanagementmessages_t mt:8; +} authenticationresponseHeader_t; + +//AUTHENTICATION RESULT diff --git a/openair3/NAS/NR_UE/nr_user_def.h b/openair3/NAS/NR_UE/nr_user_def.h new file mode 100644 index 0000000000..541360875b --- /dev/null +++ b/openair3/NAS/NR_UE/nr_user_def.h @@ -0,0 +1,3 @@ +typedef struct { + +} nr_user_nas_t; diff --git a/openair3/NAS/NR_UE/ue_process_nas.c b/openair3/NAS/NR_UE/ue_process_nas.c new file mode 100644 index 0000000000..a302f7419e --- /dev/null +++ b/openair3/NAS/NR_UE/ue_process_nas.c @@ -0,0 +1,73 @@ +#include +#include + +void SGSabortNet(void *msg, nr_user_nas_t *UE) { +} + + +/* + *Message reception + */ + + + +void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) { +} + +void SGSidentityReq(void *msg, nr_user_nas_t *UE) { +} + +void SGSsecurityModeCommand(void *msg, nr_user_nas_t *UE) { +} + + +void UEprocessNAS(void *msg,nr_user_nas_t *UE) { + SGScommonHeader_t *header=(SGScommonHeader_t *) msg; + + if ( header->sh > 4 ) + SGSabortNet(msg, UE); + else { + switch (header->epd) { +SGSmobilitymanagementmessages: + + switch (header->mt) { +Authenticationrequest: + SGSauthenticationReq(msg, UE); + break; +Identityrequest: + SGSidentityReq(msg, UE); + break; +Securitymodecommand: + SGSsecurityModeCommand(msg, UE); + break; + + default: + SGSabortNet(msg, UE); + } + + break; +SGSsessionmanagementmessages: + SGSabortNet(msg, UE); + break; + + default: + SGSabortNet(msg, UE); + } + } +} + +/* + * Messages emission + */ + +void identityResponse(void *msg, nr_user_nas_t *UE) { +} + +void authenticationResponse(void *msg,nr_user_nas_t *UE) { +} + +void securityModeComplete(void *msg, nr_user_nas_t *UE) { +} + +void registrationComplete(void *msg, nr_user_nas_t *UE) { +} diff --git a/openair3/NAS/gNB/network_process_nas.c b/openair3/NAS/gNB/network_process_nas.c new file mode 100644 index 0000000000..24ea42c726 --- /dev/null +++ b/openair3/NAS/gNB/network_process_nas.c @@ -0,0 +1,84 @@ +#include + +void SGSabortUE(void *msg, NRUEcontext_t *UE) { +} + + +/* + *Message reception + */ + +void SGSregistrationReq(void *msg, NRUEcontext_t *UE) { +} + +void SGSderegistrationUEReq(void *msg, NRUEcontext_t *UE) { +} + +void SGSauthenticationResp(void *msg, NRUEcontext_t *UE) { +} + +void SGSidentityResp(void *msg, NRUEcontext_t *UE) { +} + +void SGSsecurityModeComplete(void *msg, NRUEcontext_t *UE) { +} + +void SGSregistrationComplete(void *msg, NRUEcontext_t *UE) { +} + +void processNAS(void *msg, NRUEcontext_t *UE) { + SGScommonHeader_t *header=(SGScommonHeader_t *) msg; + + if ( header->sh > 4 ) + SGSabortUE(msg, UE); + else { + switch (header->epd) { +SGSmobilitymanagementmessages: + + switch (header->mt) { +Registrationrequest: + SGSregistrationReq(msg, UE); + break; +DeregistrationrequestUEoriginating: + SGSderegistrationUEReq(msg, UE); + break; +Authenticationresponse: + SGSauthenticationResp(msg, UE); + break; +Identityresponse: + SGSidentityResp(msg, UE); + break; +Securitymodecomplete: + SGSsecurityModeComplete(msg, UE); + break; +Registrationcomplete: + SGSregistrationComplete(msg, UE); + break; + + default: + SGSabortUE(msg, UE); + } + + break; +SGSsessionmanagementmessages: + SGSabortUE(msg, UE); + break; + + default: + SGSabortUE(msg, UE); + } + } +} + +/* + * Messages emission + */ + +void identityRequest(void *msg, NRUEcontext_t *UE) { +} + +void authenticationRequest(void *msg, NRUEcontext_t *UE) { +} + +void securityModeCommand(void *msg, NRUEcontext_t *UE) { +} From b07f3739c4124639eaf4a09eea02ac61b5dd169b Mon Sep 17 00:00:00 2001 From: Rakesh Date: Thu, 13 Aug 2020 11:45:48 +0200 Subject: [PATCH 026/149] fix for ue tx freq and gnb if_frequency --- executables/nr-uesoftmodem.c | 5 ++++- .../GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 9b2b704833..fc0cbf5dc2 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -741,8 +741,11 @@ int main( int argc, char **argv ) { nr_init_frame_parms_ue(frame_parms[CC_id],nrUE_config,NORMAL); // Overwrite DL frequency (for FR2 testing) - if (downlink_frequency[0][0]!=0) + if (downlink_frequency[0][0]!=0){ frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; + if (frame_parms[CC_id]->frame_type == TDD) + frame_parms[CC_id]->ul_CarrierFreq = downlink_frequency[0][0]; + } init_nr_ue_vars(UE[CC_id],frame_parms[CC_id],0,abstraction_flag); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf index 1363be3bce..f43691e621 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf @@ -238,7 +238,7 @@ RUs = ( max_rxgain = 114; eNB_instances = [0]; sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2"; - if_freq = 5300000000; + if_freq = 5300000000L; } ); From e4088f7f7fdba297ad295a9e38cd9737784759d5 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Fri, 14 Aug 2020 09:55:22 +0200 Subject: [PATCH 027/149] bug fix in dft memory allignment and get_band() for FR2 --- openair1/PHY/MODULATION/slot_fep_nr.c | 10 ++++++++-- openair2/LAYER2/NR_MAC_gNB/config.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index cf0a50a018..28983e0bc3 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -461,9 +461,15 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, dft(dftsize,(int16_t *)&tmp_dft_in, (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1); } - else - dft(dftsize,(int16_t *)&rxdata[rxdata_offset-sample_offset], + else { + //dft(dftsize,(int16_t *)&rxdata[rxdata_offset-sample_offset], + // (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1); + memcpy((void *)tmp_dft_in, + (void *) &rxdata[rxdata_offset-sample_offset], + (frame_parms->ofdm_symbol_size)*sizeof(int)); + dft(dftsize,(int16_t *)&tmp_dft_in, (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1); + } // clear DC carrier from OFDM symbols rxdataF[symbol * frame_parms->ofdm_symbol_size] = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 36b81927f8..2a61e6e896 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -125,7 +125,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm uint16_t band; int32_t offset; - get_band((cfg->carrier_config.dl_frequency.value)*1000, + get_band(((uint64_t)cfg->carrier_config.dl_frequency.value)*1000, &band, &offset, &frame_type); From 59964b0f8492166d8bf87f7a2e1d1d490f698b29 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 18 Aug 2020 14:07:56 +0200 Subject: [PATCH 028/149] Identity response encoding --- cmake_targets/CMakeLists.txt | 6 ++- executables/nr-uesoftmodem.c | 9 +++- executables/ocp-gnb.c | 5 +- openair3/NAS/COMMON/NR_NAS_defs.h | 28 ++++++++-- openair3/NAS/NR_UE/nr_user_def.h | 6 ++- openair3/NAS/NR_UE/ue_process_nas.c | 73 +++++++++++++++++++++----- openair3/NAS/gNB/network_process_nas.c | 6 +-- openair3/UICC/usim_interface.c | 50 ++++++++++++++++++ openair3/UICC/usim_interface.h | 46 ++++++++++++++++ 9 files changed, 204 insertions(+), 25 deletions(-) create mode 100644 openair3/UICC/usim_interface.c create mode 100644 openair3/UICC/usim_interface.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 55f7d05f4f..634726b89d 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2269,6 +2269,7 @@ set (SHLIB_LOADER_SOURCES add_library(LIB_5GNAS_GNB ${NAS_SRC}/gNB/network_process_nas.c ${NAS_SRC}/NR_UE/ue_process_nas.c + ${OPENAIR3_DIR}//UICC/usim_interface.c ) # Make lfds as a own source code (even if it is a outside library) @@ -2782,6 +2783,7 @@ add_executable(ocp-gnb ${T_SOURCE} ${CONFIG_SOURCES} ${SHLIB_LOADER_SOURCES} + ${XFORMSINTERFACE_SOURCE} ) target_link_libraries (ocp-gnb @@ -2796,7 +2798,7 @@ target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES}) target_link_libraries (ocp-gnb pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (ocp-gnb ${LIB_LMS_LIBRARIES}) target_link_libraries (ocp-gnb ${T_LIB}) -add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc params_libconfig rfsimulator oai_usrpdevif rfsimulator) +add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc params_libconfig rfsimulator oai_usrpdevif rfsimulator nrscope) # nr-uesoftmodem is UE implementation @@ -2833,7 +2835,7 @@ target_link_libraries (nr-uesoftmodem RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS NR_L2_UE L2_UE MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB S1AP_LIB S1AP_ENB - ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} + ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} LIB_5GNAS_GNB -Wl,--end-group z dl) target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES}) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 8a17d24a84..c7cb974cc8 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -78,11 +78,14 @@ unsigned short config_frames[4] = {2,9,11,13}; /* Callbacks, globals and object handlers */ +//#include "stats.h" +// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) +#include "PHY/TOOLS/phy_scope_interface.h" #include "PHY/TOOLS/nr_phy_scope.h" #include #include "executables/softmodem-common.h" #include "executables/thread-common.h" -#include +#include // Raphael : missing pthread_cond_t nfapi_sync_cond; @@ -756,6 +759,10 @@ int main( int argc, char **argv ) { memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); configure_linux(); mlockall(MCL_CURRENT | MCL_FUTURE); + + char * resp; +nr_user_nas_t UErrc={0}; + int size=identityResponse(&resp, &UErrc); if(IS_SOFTMODEM_DOFORMS) { load_softscope("nr",PHY_vars_UE_g[0][0]); diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index c209af2bd8..5d8acecacf 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -1005,11 +1005,12 @@ int main( int argc, char **argv ) { (void *)NULL, "time_meas", -1, OAI_PRIORITY_RT_LOW); } - if (do_forms==1) { + if(IS_SOFTMODEM_DOFORMS) { scopeParms_t tmp= {&argc, argv, &ru, RC.gNB[0]}; - gNBinitScope(&tmp); + load_softscope("nr",&tmp); } + while(!oai_exit) sleep(1); diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index b71748943b..269814824c 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -66,7 +66,7 @@ typedef enum { } Security_header_t; typedef enum { - SUCI=0, + SUCI=1, SGGUTI, IMEI, SGSTMSI, @@ -221,14 +221,33 @@ typedef struct { } Identityrequest_t; // the message continues with the identity value, depending on identity type, see TS 14.501, 9.11.3.4 -typedef struct { +typedef struct __attribute__((packed)) { Extendedprotocoldiscriminator_t epd:8; Security_header_t sh:8; SGSmobilitymanagementmessages_t mt:8; - identitytype_t mi:8; + uint16_t len; } Identityresponse_t; - +typedef struct __attribute__((packed)) { + Identityresponse_t common; + identitytype_t mi:8; + int supiFormat:4; + int identityType:4; + int mcc1:4; + int mcc2:4; + int mcc3:4; + int mnc3:4; + int mnc2:4; + int mnc1:4; + int routing1:4; + int routing2:4; + int routing3:4; + int routing4:4; + int protectScheme:4; + int spare:4; + uint8_t hplmnId; +} IdentityresponseIMSI_t; + typedef struct { Extendedprotocoldiscriminator_t epd:8; Security_header_t sh:8; @@ -244,4 +263,5 @@ typedef struct { SGSmobilitymanagementmessages_t mt:8; } authenticationresponseHeader_t; + //AUTHENTICATION RESULT diff --git a/openair3/NAS/NR_UE/nr_user_def.h b/openair3/NAS/NR_UE/nr_user_def.h index 541360875b..b996b08c0a 100644 --- a/openair3/NAS/NR_UE/nr_user_def.h +++ b/openair3/NAS/NR_UE/nr_user_def.h @@ -1,3 +1,7 @@ -typedef struct { +#include +typedef struct { + uicc_t * uicc; } nr_user_nas_t; + +int identityResponse(void **msg, nr_user_nas_t *UE); diff --git a/openair3/NAS/NR_UE/ue_process_nas.c b/openair3/NAS/NR_UE/ue_process_nas.c index a302f7419e..0d53de802d 100644 --- a/openair3/NAS/NR_UE/ue_process_nas.c +++ b/openair3/NAS/NR_UE/ue_process_nas.c @@ -1,17 +1,25 @@ #include #include + void SGSabortNet(void *msg, nr_user_nas_t *UE) { } +void nas_schedule(void) { +} /* *Message reception */ - - void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) { + Identityrequest_t *idmsg=(Identityrequest_t *) msg; + + if (idmsg->it == SUCI ) { + LOG_I(NAS,"Received Identity request, scheduling answer\n"); + nas_schedule(); + } else + LOG_E(NAS,"Not developped: identity request for %d\n", idmsg->it); } void SGSidentityReq(void *msg, nr_user_nas_t *UE) { @@ -28,16 +36,17 @@ void UEprocessNAS(void *msg,nr_user_nas_t *UE) { SGSabortNet(msg, UE); else { switch (header->epd) { -SGSmobilitymanagementmessages: - + case SGSmobilitymanagementmessages: switch (header->mt) { -Authenticationrequest: + case Authenticationrequest: SGSauthenticationReq(msg, UE); break; -Identityrequest: + + case Identityrequest: SGSidentityReq(msg, UE); break; -Securitymodecommand: + + case Securitymodecommand: SGSsecurityModeCommand(msg, UE); break; @@ -46,7 +55,8 @@ Securitymodecommand: } break; -SGSsessionmanagementmessages: + + case SGSsessionmanagementmessages: SGSabortNet(msg, UE); break; @@ -60,14 +70,53 @@ SGSsessionmanagementmessages: * Messages emission */ -void identityResponse(void *msg, nr_user_nas_t *UE) { +int identityResponse(void **msg, nr_user_nas_t *UE) { + if (UE->uicc == NULL) + // config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE + UE->uicc=init_uicc("uicc"); + + // TS 24.501 9.11.3.4 + int imsiL=strlen(UE->uicc->imsi); + int msinL=imsiL-3-UE->uicc->nmc_size; + int respSize=sizeof(IdentityresponseIMSI_t) + (msinL+1)/2; + IdentityresponseIMSI_t *resp=(IdentityresponseIMSI_t *) calloc(respSize,1); + resp->common.epd=SGSmobilitymanagementmessages; + resp->common.sh=0; + resp->common.mt=Identityresponse; + resp->common.len=htons(respSize-sizeof(Identityresponse_t)); + resp->mi=SUCI; + resp->mcc1=UE->uicc->imsi[0]-'0'; + resp->mcc2=UE->uicc->imsi[1]-'0'; + resp->mcc3=UE->uicc->imsi[2]-'0'; + resp->mnc1=UE->uicc->imsi[3]-'0'; + resp->mnc2=UE->uicc->imsi[4]-'0'; + resp->mnc3=UE->uicc->nmc_size==2? 0xF : UE->uicc->imsi[3]-'0'; + // TBD: routing to fill (FF ?) + char *out=(char *)(resp+1); + char *ptr=UE->uicc->imsi + 3 + UE->uicc->nmc_size; + + while ( ptr < UE->uicc->imsi+strlen(UE->uicc->imsi) ) { + *out=((*(ptr+1)-'0')<<4) | (*(ptr) -'0'); + out++; + ptr+=2; + } + + if (msinL%2 == 1) + *out=((*(ptr-1)-'0')) | 0xF0; + + *msg=resp; + log_dump(NAS, resp, respSize, LOG_DUMP_CHAR, "\n"); + return respSize; } -void authenticationResponse(void *msg,nr_user_nas_t *UE) { +int authenticationResponse(void **msg,nr_user_nas_t *UE) { + return -1; } -void securityModeComplete(void *msg, nr_user_nas_t *UE) { +int securityModeComplete(void **msg, nr_user_nas_t *UE) { + return -1; } -void registrationComplete(void *msg, nr_user_nas_t *UE) { +int registrationComplete(void **msg, nr_user_nas_t *UE) { + return -1; } diff --git a/openair3/NAS/gNB/network_process_nas.c b/openair3/NAS/gNB/network_process_nas.c index 24ea42c726..feb0d918cf 100644 --- a/openair3/NAS/gNB/network_process_nas.c +++ b/openair3/NAS/gNB/network_process_nas.c @@ -74,11 +74,11 @@ SGSsessionmanagementmessages: * Messages emission */ -void identityRequest(void *msg, NRUEcontext_t *UE) { +int identityRequest(void **msg, NRUEcontext_t *UE) { } -void authenticationRequest(void *msg, NRUEcontext_t *UE) { +int authenticationRequest(void **msg, NRUEcontext_t *UE) { } -void securityModeCommand(void *msg, NRUEcontext_t *UE) { +int securityModeCommand(void **msg, NRUEcontext_t *UE) { } diff --git a/openair3/UICC/usim_interface.c b/openair3/UICC/usim_interface.c new file mode 100644 index 0000000000..ec22d61ebb --- /dev/null +++ b/openair3/UICC/usim_interface.c @@ -0,0 +1,50 @@ +/* +* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The OpenAirInterface Software Alliance licenses this file to You under +* the OAI Public License, Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.openairinterface.org/?page_id=698 +* +* Author and copyright: Laurent Thomas, open-cells.com +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*------------------------------------------------------------------------------- +* For more information about the OpenAirInterface (OAI) Software Alliance: +* contact@openairinterface.org +*/ + +#include + +#define UICC_SECTION "uicc" +#define UICC_CONFIG_HELP_OPTIONS " list of comma separated options to interface a simulated (real UICC to be developped). Available options: \n"\ + " imsi: user imsi\n"\ + " key: cyphering key\n"\ + " opc: cyphering OPc\n" +/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* configuration parameters for the rfsimulator device */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +#define UICC_PARAMS_DESC {\ + {"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsi), defstrval:"", TYPE_STRING, 0 },\ + {"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\ + {"key", "USIM Ki\n", 0, strptr:&(uicc->key), defstrval:"", TYPE_STRING, 0 },\ + {"opc", "USIM OPc\n", 0, strptr:&(uicc->opc), defstrval:"", TYPE_STRING, 0 },\ + }; + +uicc_t *init_uicc(char *sectionName) { + uicc_t *uicc=(uicc_t *)calloc(sizeof(uicc_t),1); + paramdef_t uicc_params[] = UICC_PARAMS_DESC; + int ret = config_get( uicc_params,sizeof(uicc_params)/sizeof(paramdef_t),sectionName); + AssertFatal(ret >= 0, "configuration couldn't be performed"); + LOG_I(HW, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsi, uicc->key, uicc->opc); + return uicc; +} + diff --git a/openair3/UICC/usim_interface.h b/openair3/UICC/usim_interface.h new file mode 100644 index 0000000000..89c7242f2f --- /dev/null +++ b/openair3/UICC/usim_interface.h @@ -0,0 +1,46 @@ +/* +* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The OpenAirInterface Software Alliance licenses this file to You under +* the OAI Public License, Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.openairinterface.org/?page_id=698 +* +* Author and copyright: Laurent Thomas, open-cells.comopenair3/UICC/usim_interface.h +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*------------------------------------------------------------------------------- +* For more information about the OpenAirInterface (OAI) Software Alliance: +* contact@openairinterface.org +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common_lib.h" + +typedef struct { + char *imsi; + char *key; + char *opc; + int nmc_size; +} uicc_t; + +/* + * Read the configuration file, section name variable to be able to manage several UICC + */ +uicc_t *init_uicc(char *sectionName); From 76346c450d65541d02c636c3c2a652b7fd233042 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Tue, 18 Aug 2020 15:50:38 +0200 Subject: [PATCH 029/149] Tdd configuration and a small fix for get_band() for FR2 --- executables/nr-uesoftmodem.c | 15 +++++++-------- openair2/LAYER2/NR_MAC_UE/config_ue.c | 2 +- .../CONF/gnb.band257.tm1.32PRB.usrpx300.conf | 10 +++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 672548fb8f..897ea540c9 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -687,13 +687,6 @@ int main( int argc, char **argv ) { fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; nr_init_frame_parms_ue(frame_parms[CC_id],nrUE_config,NORMAL); - // Overwrite DL frequency (for FR2 testing) - if (downlink_frequency[0][0]!=0){ - frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; - if (frame_parms[CC_id]->frame_type == TDD) - frame_parms[CC_id]->ul_CarrierFreq = downlink_frequency[0][0]; - } - init_nr_ue_vars(UE[CC_id],frame_parms[CC_id],0,abstraction_flag); UE[CC_id]->mac_enabled = 1; @@ -752,8 +745,14 @@ int main( int argc, char **argv ) { UE[CC_id]->N_TA_offset = (int)(N_TA_offset * factor); LOG_I(PHY,"UE %d Setting N_TA_offset to %d samples (factor %f, UL Freq %lu, N_RB %d)\n", UE[CC_id]->Mod_id, UE[CC_id]->N_TA_offset, factor, UE[CC_id]->frame_parms.ul_CarrierFreq, N_RB); } - } + // Overwrite DL frequency (for FR2 testing) + if (downlink_frequency[0][0]!=0){ + frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; + if (frame_parms[CC_id]->frame_type == TDD) + frame_parms[CC_id]->ul_CarrierFreq = downlink_frequency[0][0]; + } + } // printf("tx_max_power = %d -> amp %d\n",tx_max_power[0],get_tx_amp(tx_max_poHwer,tx_max_power)); init_openair0(); // init UE_PF_PO and mutex lock diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 5a9620ed01..bbd51ec04c 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -205,7 +205,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, uint16_t band; int32_t offset; - get_band((cfg->carrier_config.dl_frequency)*1000, + get_band((uint64_t)(cfg->carrier_config.dl_frequency)*1000, &band, &offset, &frame_type); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf index c2c5bf751e..c441945f53 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf @@ -170,11 +170,11 @@ gNBs = # pattern1 # dl_UL_TransmissionPeriodicity # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 - dl_UL_TransmissionPeriodicity = 5; - nrofDownlinkSlots = 10; - nrofDownlinkSymbols = 0; - nrofUplinkSlots = 10; - nrofUplinkSymbols = 0; + dl_UL_TransmissionPeriodicity = 3; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; ssPBCH_BlockPower = 10; } From 0ee578f4bd34452ae61ebbf7c090c9fa0091cc7a Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 19 Aug 2020 19:30:53 +0200 Subject: [PATCH 030/149] add authentication request --- executables/nr-uesoftmodem.c | 11 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 +- openair3/NAS/COMMON/NR_NAS_defs.h | 38 ++- openair3/NAS/COMMON/aes.h | 184 +++++++++++++ openair3/NAS/COMMON/milenage.h | 337 ++++++++++++++++++++++++ openair3/NAS/NR_UE/nr_user_def.h | 7 +- openair3/NAS/NR_UE/ue_process_nas.c | 19 +- openair3/NAS/gNB/network_process_nas.c | 77 +++++- openair3/NAS/gNB/network_process_nas.h | 16 ++ openair3/UICC/usim_interface.c | 30 ++- openair3/UICC/usim_interface.h | 15 +- 11 files changed, 701 insertions(+), 37 deletions(-) create mode 100644 openair3/NAS/COMMON/aes.h create mode 100644 openair3/NAS/COMMON/milenage.h create mode 100644 openair3/NAS/gNB/network_process_nas.h diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index c7cb974cc8..c9d0ab0a47 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -86,6 +86,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "executables/softmodem-common.h" #include "executables/thread-common.h" #include +#include // Raphael : missing pthread_cond_t nfapi_sync_cond; @@ -761,8 +762,14 @@ int main( int argc, char **argv ) { mlockall(MCL_CURRENT | MCL_FUTURE); char * resp; -nr_user_nas_t UErrc={0}; - int size=identityResponse(&resp, &UErrc); + nr_user_nas_t UErrc={0}; + NRUEcontext_t UEnas={0}; + int size=identityRequest((void**)&resp, &UEnas); + log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Request:\n" );; + size=identityResponse((void**)&resp, &UErrc); + log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Response:\n" );; + size=authenticationRequest((void**)&resp, &UEnas); + log_dump(NAS, resp, size, LOG_DUMP_CHAR," authentication request:\n" );; if(IS_SOFTMODEM_DOFORMS) { load_softscope("nr",PHY_vars_UE_g[0][0]); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 6a72a74d5a..893fd74fd6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -69,6 +69,7 @@ #include "NR_TAG.h" #include +#include /* Defs */ @@ -282,7 +283,8 @@ typedef struct NR_preamble_ue { } NR_preamble_ue; typedef struct { - boolean_t fiveG_connected; + boolean_t fiveG_connected; + uicc_t *uicc; } NRUEcontext_t; /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index 269814824c..441e0db8d3 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -1,4 +1,16 @@ +/* TS 24.007 possible L3 formats: + Table 11.1: Formats of information elements + Format Meaning IEI present LI present Value part present + T Type only yes no no + V Value only no no yes + TV Type and Value yes no yes + LV Length and Value no yes yes + TLV Type, Length and Value yes yes yes + LV-E Length and Value no yes yes + TLV-E Type, Length and Value yes yes yes +*/ + //TS 24.501, chap 9.2 => TS 24.007 typedef enum { SGSsessionmanagementmessages=0x2e, //LTEbox: 0xC0 ??? @@ -190,6 +202,12 @@ static const cause_text_info_t cause_secu_text_info[] = { FOREACH_CAUSE_SECU(CAUSE_TEXT) }; +// IEI (information element identifier) are spread in each message definition +#define IEI_RAND 0x21 +#define IEI_AUTN 0x20 +#define IEI_EAP 0x78 +#define IEI_AuthenticationResponse 0x2d + #define CAUSE_ENUM(LabEl, nUmID ) LabEl = nUmID, //! Tasks id of each task typedef enum { @@ -226,7 +244,8 @@ typedef struct __attribute__((packed)) { Security_header_t sh:8; SGSmobilitymanagementmessages_t mt:8; uint16_t len; -} Identityresponse_t; +} +Identityresponse_t; typedef struct __attribute__((packed)) { Identityresponse_t common; @@ -246,16 +265,24 @@ typedef struct __attribute__((packed)) { int protectScheme:4; int spare:4; uint8_t hplmnId; -} IdentityresponseIMSI_t; - -typedef struct { +} +IdentityresponseIMSI_t; + +typedef struct __attribute__((packed)) { Extendedprotocoldiscriminator_t epd:8; Security_header_t sh:8; SGSmobilitymanagementmessages_t mt:8; int ngKSI:4; int spare:4; int ABBALen:8; -} authenticationrequestHeader_t; + int ABBA:16; + uint8_t ieiRAND; + uint8_t RAND[16]; + uint8_t ieiAUTN; + uint8_t AUTNlen; + uint8_t AUTN[16]; +} +authenticationrequestHeader_t; typedef struct { Extendedprotocoldiscriminator_t epd:8; @@ -264,4 +291,5 @@ typedef struct { } authenticationresponseHeader_t; + //AUTHENTICATION RESULT diff --git a/openair3/NAS/COMMON/aes.h b/openair3/NAS/COMMON/aes.h new file mode 100644 index 0000000000..ed103306e4 --- /dev/null +++ b/openair3/NAS/COMMON/aes.h @@ -0,0 +1,184 @@ +#ifndef AES_H +#define EAS_H + +// Implemented from Wikipedia description and OpenAir HSS + +/*--------------------- Rijndael S box table ----------------------*/ +static const uint8_t S[256] = { + 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, + 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, + 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, + 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, + 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, + 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, + 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, + 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, + 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, + 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, + 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, + 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, + 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, + 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, + 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, + 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 +}; +/*------- This array does the multiplication by x in GF(2^8) ------*/ +static const uint8_t Xtime[256] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, + 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, + 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, + 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, + 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, + 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, + 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, + 27, 25, 31, 29, 19, 17, 23, 21, 11, 9, 15, 13, 3, 1, 7, 5, + 59, 57, 63, 61, 51, 49, 55, 53, 43, 41, 47, 45, 35, 33, 39, 37, + 91, 89, 95, 93, 83, 81, 87, 85, 75, 73, 79, 77, 67, 65, 71, 69, + 123, 121, 127, 125, 115, 113, 119, 117, 107, 105, 111, 109, 99, 97, 103, 101, + 155, 153, 159, 157, 147, 145, 151, 149, 139, 137, 143, 141, 131, 129, 135, 133, + 187, 185, 191, 189, 179, 177, 183, 181, 171, 169, 175, 173, 163, 161, 167, 165, + 219, 217, 223, 221, 211, 209, 215, 213, 203, 201, 207, 205, 195, 193, 199, 197, + 251, 249, 255, 253, 243, 241, 247, 245, 235, 233, 239, 237, 227, 225, 231, 229 +}; + +/*------------------------------------------------------------------- + Rijndael key schedule function. Takes 16-byte key and creates + all Rijndael's internal subkeys ready for encryption. + -----------------------------------------------------------------*/ +static inline void RijndaelKeySchedule (const uint8_t key[16], uint8_t roundKeys[11][4][4]) { + //first round key equals key + for (int i = 0; i < 16; i++) + roundKeys[0][i & 0x03][i >> 2] = key[i]; + + //now calculate round keys + uint8_t roundConst = 1; + + for (int i = 0; i < 10; i++) { + int next=i+1; + roundKeys[next][0][0] = S[roundKeys[i][1][3]] + ^ roundKeys[i][0][0] ^ roundConst; + roundKeys[next][1][0] = S[roundKeys[i][2][3]] + ^ roundKeys[i][1][0]; + roundKeys[next][2][0] = S[roundKeys[i][3][3]] + ^ roundKeys[i][2][0]; + roundKeys[next][3][0] = S[roundKeys[i][0][3]] + ^ roundKeys[i][3][0]; + + for (int j = 0; j < 4; j++) { + roundKeys[next][j][1] = roundKeys[i][j][1] ^ roundKeys[next][j][0]; + roundKeys[next][j][2] = roundKeys[i][j][2] ^ roundKeys[next][j][1]; + roundKeys[next][j][3] = roundKeys[i][j][3] ^ roundKeys[next][j][2]; + } + + roundConst = Xtime[roundConst]; + } + + return; +} + +/* Round key addition function */ +static inline void KeyAdd (uint8_t state[4][4], uint8_t roundKeys[11][4][4], int round) { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + state[i][j] ^= roundKeys[round][i][j]; + + return; +} + +/* Byte substitution transformation */ +static inline void ByteSub (uint8_t state[4][4]) { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + state[i][j] = S[state[i][j]]; + + return; +} + +/* Row shift transformation */ +static inline void ShiftRow (uint8_t state[4][4]) { + // left rotate row 1 by 1 + uint8_t temp = state[1][0]; + state[1][0] = state[1][1]; + state[1][1] = state[1][2]; + state[1][2] = state[1][3]; + state[1][3] = temp; + //left rotate row 2 by 2 + temp = state[2][0]; + state[2][0] = state[2][2]; + state[2][2] = temp; + temp = state[2][1]; + state[2][1] = state[2][3]; + state[2][3] = temp; + // left rotate row 3 by 3 + temp = state[3][0]; + state[3][0] = state[3][3]; + state[3][3] = state[3][2]; + state[3][2] = state[3][1]; + state[3][1] = temp; + return; +} + +/* MixColumn transformation*/ +static inline void MixColumn ( uint8_t state[4][4]) { + // do one column at a time + for (int i = 0; i < 4; i++) { + uint8_t temp = state[0][i] ^ state[1][i] ^ state[2][i] ^ state[3][i]; + uint8_t tmp0 = state[0][i]; + // Xtime array does multiply by x in GF2^8 + uint8_t tmp = Xtime[state[0][i] ^ state[1][i]]; + state[0][i] ^= temp ^ tmp; + tmp = Xtime[state[1][i] ^ state[2][i]]; + state[1][i] ^= temp ^ tmp; + tmp = Xtime[state[2][i] ^ state[3][i]]; + state[2][i] ^= temp ^ tmp; + tmp = Xtime[state[3][i] ^ tmp0]; + state[3][i] ^= temp ^ tmp; + } + + return; +} + +/*------------------------------------------------------------------- + Rijndael encryption function. Takes 16-byte input and creates + 16-byte output (using round keys already derived from 16-byte + key). + -----------------------------------------------------------------*/ +static inline void RijndaelEncrypt ( const uint8_t input[16], uint8_t output[16], uint8_t roundKeys[11][4][4]) { + uint8_t state[4][4]; + int r; + + // initialise state array from input byte string + for (int i = 0; i < 16; i++) + state[i & 0x3][i >> 2] = input[i]; + + // add first round_key + KeyAdd (state, roundKeys, 0); + + // do lots of full rounds + for (r = 1; r <= 9; r++) { + ByteSub (state); + ShiftRow (state); + MixColumn (state); + KeyAdd (state, roundKeys, r); + } + + // final round + ByteSub (state); + ShiftRow (state); + KeyAdd (state, roundKeys, r); + + // produce output byte string from state array + for (int i = 0; i < 16; i++) + output[i] = state[i & 0x3][i >> 2]; + + return; +} + +static inline void aes_128_encrypt_block(const uint8_t *key, const uint8_t *clear, uint8_t *cyphered) { + uint8_t roundKeys[11][4][4]; + RijndaelKeySchedule(key, roundKeys); + RijndaelEncrypt (clear, cyphered, roundKeys); +} + +#endif diff --git a/openair3/NAS/COMMON/milenage.h b/openair3/NAS/COMMON/milenage.h new file mode 100644 index 0000000000..6737aeeaf9 --- /dev/null +++ b/openair3/NAS/COMMON/milenage.h @@ -0,0 +1,337 @@ +/* + Adpatatipn of SW from hereafter license + Author: laurent.thomas@open-cells.com +*/ +/* + 3GPP AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208) + Copyright (c) 2006-2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + Alternatively, this software may be distributed under the terms of BSD + license. + + See README and COPYING for more details. + + This file implements an example authentication algorithm defined for 3GPP + AKA. This can be used to implement a simple HLR/AuC into hlr_auc_gw to allow + EAP-AKA to be tested properly with real USIM cards. + + This implementations assumes that the r1..r5 and c1..c5 constants defined in + TS 35.206 are used, i.e., r1=64, r2=0, r3=32, r4=64, r5=96, c1=00..00, + c2=00..01, c3=00..02, c4=00..04, c5=00..08. The block cipher is assumed to + be AES (Rijndael). +*/ + +#ifndef MILENAGE_H +#define MILENAGE_H +#include + +#define u8 uint8_t +/** + milenage_f1 - Milenage f1 and f1* algorithms + @opc: OPc = 128-bit value derived from OP and K + @k: K = 128-bit subscriber key + @_rand: RAND = 128-bit random challenge + @sqn: SQN = 48-bit sequence number + @amf: AMF = 16-bit authentication management field + @mac_a: Buffer for MAC-A = 64-bit network authentication code, or %NULL + @mac_s: Buffer for MAC-S = 64-bit resync authentication code, or %NULL + Returns: true on success, false on failure +*/ +bool milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand, + const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s) { + u8 tmp1[16], tmp2[16], tmp3[16]; + int i; + + /* tmp1 = TEMP = E_K(RAND XOR OP_C) */ + for (i = 0; i < 16; i++) + tmp1[i] = _rand[i] ^ opc[i]; + + aes_128_encrypt_block(k, tmp1, tmp1); + /* tmp2 = IN1 = SQN || AMF || SQN || AMF */ + memcpy(tmp2, sqn, 6); + memcpy(tmp2 + 6, amf, 2); + memcpy(tmp2 + 8, tmp2, 8); + + /* OUT1 = E_K(TEMP XOR rot(IN1 XOR OP_C, r1) XOR c1) XOR OP_C */ + + /* rotate (tmp2 XOR OP_C) by r1 (= 0x40 = 8 bytes) */ + for (i = 0; i < 16; i++) + tmp3[(i + 8) % 16] = tmp2[i] ^ opc[i]; + + /* XOR with TEMP = E_K(RAND XOR OP_C) */ + for (i = 0; i < 16; i++) + tmp3[i] ^= tmp1[i]; + + /* XOR with c1 (= ..00, i.e., NOP) */ + /* f1 || f1* = E_K(tmp3) XOR OP_c */ + aes_128_encrypt_block(k, tmp3, tmp1); + + for (i = 0; i < 16; i++) + tmp1[i] ^= opc[i]; + + if (mac_a) + memcpy(mac_a, tmp1, 8); /* f1 */ + + if (mac_s) + memcpy(mac_s, tmp1 + 8, 8); /* f1* */ + + return true; +} + + +/** + milenage_f2345 - Milenage f2, f3, f4, f5, f5* algorithms + @opc: OPc = 128-bit value derived from OP and K + @k: K = 128-bit subscriber key + @_rand: RAND = 128-bit random challenge + @res: Buffer for RES = 64-bit signed response (f2), or %NULL + @ck: Buffer for CK = 128-bit confidentiality key (f3), or %NULL + @ik: Buffer for IK = 128-bit integrity key (f4), or %NULL + @ak: Buffer for AK = 48-bit anonymity key (f5), or %NULL + @akstar: Buffer for AK = 48-bit anonymity key (f5*), or %NULL + Returns: true on success, false on failure +*/ +bool milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand, + u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar) { + u8 tmp1[16], tmp2[16], tmp3[16]; + int i; + + /* tmp2 = TEMP = E_K(RAND XOR OP_C) */ + for (i = 0; i < 16; i++) + tmp1[i] = _rand[i] ^ opc[i]; + + aes_128_encrypt_block(k, tmp1, tmp2); + + /* OUT2 = E_K(rot(TEMP XOR OP_C, r2) XOR c2) XOR OP_C */ + /* OUT3 = E_K(rot(TEMP XOR OP_C, r3) XOR c3) XOR OP_C */ + /* OUT4 = E_K(rot(TEMP XOR OP_C, r4) XOR c4) XOR OP_C */ + /* OUT5 = E_K(rot(TEMP XOR OP_C, r5) XOR c5) XOR OP_C */ + + /* f2 and f5 */ + /* rotate by r2 (= 0, i.e., NOP) */ + for (i = 0; i < 16; i++) + tmp1[i] = tmp2[i] ^ opc[i]; + + tmp1[15] ^= 1; /* XOR c2 (= ..01) */ + /* f5 || f2 = E_K(tmp1) XOR OP_c */ + aes_128_encrypt_block(k, tmp1, tmp3); + + for (i = 0; i < 16; i++) + tmp3[i] ^= opc[i]; + + if (res) + memcpy(res, tmp3 + 8, 8); /* f2 */ + + if (ak) + memcpy(ak, tmp3, 6); /* f5 */ + + /* f3 */ + if (ck) { + /* rotate by r3 = 0x20 = 4 bytes */ + for (i = 0; i < 16; i++) + tmp1[(i + 12) % 16] = tmp2[i] ^ opc[i]; + + tmp1[15] ^= 2; /* XOR c3 (= ..02) */ + aes_128_encrypt_block(k, tmp1, ck); + + for (i = 0; i < 16; i++) + ck[i] ^= opc[i]; + } + + /* f4 */ + if (ik) { + /* rotate by r4 = 0x40 = 8 bytes */ + for (i = 0; i < 16; i++) + tmp1[(i + 8) % 16] = tmp2[i] ^ opc[i]; + + tmp1[15] ^= 4; /* XOR c4 (= ..04) */ + aes_128_encrypt_block(k, tmp1, ik); + + for (i = 0; i < 16; i++) + ik[i] ^= opc[i]; + } + + /* f5* */ + if (akstar) { + /* rotate by r5 = 0x60 = 12 bytes */ + for (i = 0; i < 16; i++) + tmp1[(i + 4) % 16] = tmp2[i] ^ opc[i]; + + tmp1[15] ^= 8; /* XOR c5 (= ..08) */ + aes_128_encrypt_block(k, tmp1, tmp1); + + for (i = 0; i < 6; i++) + akstar[i] = tmp1[i] ^ opc[i]; + } + + return true; +} + + +/** + milenage_generate - Generate AKA AUTN,IK,CK,RES + @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) + @amf: AMF = 16-bit authentication management field + @k: K = 128-bit subscriber key + @sqn: SQN = 48-bit sequence number + @_rand: RAND = 128-bit random challenge + @autn: Buffer for AUTN = 128-bit authentication token + @ik: Buffer for IK = 128-bit integrity key (f4), or %NULL + @ck: Buffer for CK = 128-bit confidentiality key (f3), or %NULL + @res: Buffer for RES = 64-bit signed response (f2), or %NULL + @res_len: Max length for res; set to used length or 0 on failure +*/ +bool milenage_generate(const u8 *opc, const u8 *amf, const u8 *k, + const u8 *sqn, const u8 *_rand, u8 *autn, u8 *ik, + u8 *ck, u8 *res) { + int i; + u8 mac_a[8], ak[6]; + + if (!milenage_f1(opc, k, _rand, sqn, amf, mac_a, NULL) || + !milenage_f2345(opc, k, _rand, res, ck, ik, ak, NULL)) + return false; + + /* AUTN = (SQN ^ AK) || AMF || MAC */ + for (i = 0; i < 6; i++) + autn[i] = sqn[i] ^ ak[i]; + + memcpy(autn + 6, amf, 2); + memcpy(autn + 8, mac_a, 8); + return true; +} + + +/** + milenage_auts - Milenage AUTS validation + @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) + @k: K = 128-bit subscriber key + @_rand: RAND = 128-bit random challenge + @auts: AUTS = 112-bit authentication token from client + @sqn: Buffer for SQN = 48-bit sequence number + Returns: 0 = success (sqn filled), -1 on failure +*/ +#define p(a) printf("%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n", (int)((a)[0]), (int)((a)[1]), (int)((a)[2]), (int)((a)[3]),(int)((a)[4]), (int)((a)[5])); +bool milenage_auts(const u8 *opc, const u8 *k, const u8 *_rand, const u8 *auts, + u8 *sqn) { + u8 amf[2] = { 0x00, 0x00 }; /* TS 33.102 v7.0.0, 6.3.3 */ + u8 ak[6], mac_s[8]; + int i; + + if (!milenage_f2345(opc, k, _rand, NULL, NULL, NULL, NULL, ak)) + return false; + + for (i = 0; i < 6; i++) + sqn[i] = auts[i] ^ ak[i]; + + //p(sqn); + if (!milenage_f1(opc, k, _rand, sqn, amf, NULL, mac_s) || + memcmp(mac_s, auts + 6, 8) != 0) + return false; + + return true; +} + + +/** + gsm_milenage - Generate GSM-Milenage (3GPP TS 55.205) authentication triplet + @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) + @k: K = 128-bit subscriber key + @_rand: RAND = 128-bit random challenge + @sres: Buffer for SRES = 32-bit SRES + @kc: Buffer for Kc = 64-bit Kc + Returns: 0 on success, -1 on failure +*/ +bool gsm_milenage(const u8 *opc, const u8 *k, const u8 *_rand, u8 *sres, u8 *kc) { + u8 res[8], ck[16], ik[16]; + int i; + + if (milenage_f2345(opc, k, _rand, res, ck, ik, NULL, NULL)) + return false; + + for (i = 0; i < 8; i++) + kc[i] = ck[i] ^ ck[i + 8] ^ ik[i] ^ ik[i + 8]; + +#ifdef GSM_MILENAGE_ALT_SRES + memcpy(sres, res, 4); +#else /* GSM_MILENAGE_ALT_SRES */ + + for (i = 0; i < 4; i++) + sres[i] = res[i] ^ res[i + 4]; + +#endif /* GSM_MILENAGE_ALT_SRES */ + return true; +} + + +/** + milenage_generate - Generate AKA AUTN,IK,CK,RES + @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) + @k: K = 128-bit subscriber key + @sqn: SQN = 48-bit sequence number + @_rand: RAND = 128-bit random challenge + @autn: AUTN = 128-bit authentication token + @ik: Buffer for IK = 128-bit integrity key (f4), or %NULL + @ck: Buffer for CK = 128-bit confidentiality key (f3), or %NULL + @res: Buffer for RES = 64-bit signed response (f2), or %NULL + @res_len: Variable that will be set to RES length + @auts: 112-bit buffer for AUTS + Returns: 0 on success, -1 on failure, or -2 on synchronization failure +*/ +int milenage_check(const u8 *opc, const u8 *k, const u8 *sqn, const u8 *_rand, + const u8 *autn, u8 *ik, u8 *ck, u8 *res, size_t *res_len, + u8 *auts) { + int i; + u8 mac_a[8], ak[6], rx_sqn[6]; + const u8 *amf; + + if (milenage_f2345(opc, k, _rand, res, ck, ik, ak, NULL)) + return -1; + + *res_len = 8; + + /* AUTN = (SQN ^ AK) || AMF || MAC */ + for (i = 0; i < 6; i++) + rx_sqn[i] = autn[i] ^ ak[i]; + + if (memcmp(rx_sqn, sqn, 6) <= 0) { + u8 auts_amf[2] = { 0x00, 0x00 }; /* TS 33.102 v7.0.0, 6.3.3 */ + + if (milenage_f2345(opc, k, _rand, NULL, NULL, NULL, NULL, ak)) + return -1; + + for (i = 0; i < 6; i++) + auts[i] = sqn[i] ^ ak[i]; + + if (milenage_f1(opc, k, _rand, sqn, auts_amf, NULL, auts + 6)) + return -1; + + return -2; + } + + amf = autn + 6; + + if (milenage_f1(opc, k, _rand, rx_sqn, amf, mac_a, NULL)) + return -1; + + if (memcmp(mac_a, autn + 8, 8) != 0) { + printf( "Milenage: MAC mismatch\n"); + return -1; + } + + return 0; +} + +void milenage_opc_gen(const u8 *k, const u8 *op, u8 *opc) { + int i; + /* Encrypt OP using K */ + aes_128_encrypt_block(k, op, opc); + + /* XOR the resulting Ek(OP) with OP */ + for (i = 0; i < 16; i++) + opc[i] = opc[i] ^ op[i]; +} +#endif diff --git a/openair3/NAS/NR_UE/nr_user_def.h b/openair3/NAS/NR_UE/nr_user_def.h index b996b08c0a..f8fb39a39d 100644 --- a/openair3/NAS/NR_UE/nr_user_def.h +++ b/openair3/NAS/NR_UE/nr_user_def.h @@ -1,7 +1,12 @@ +#ifndef NR_USER_DEF_H +#define NR_USER_DEF_H #include typedef struct { - uicc_t * uicc; + uicc_t *uicc; } nr_user_nas_t; +#define myCalloc(var, type) type * var=(type*)calloc(sizeof(type),1); + int identityResponse(void **msg, nr_user_nas_t *UE); +#endif diff --git a/openair3/NAS/NR_UE/ue_process_nas.c b/openair3/NAS/NR_UE/ue_process_nas.c index 0d53de802d..09c331cc28 100644 --- a/openair3/NAS/NR_UE/ue_process_nas.c +++ b/openair3/NAS/NR_UE/ue_process_nas.c @@ -76,7 +76,7 @@ int identityResponse(void **msg, nr_user_nas_t *UE) { UE->uicc=init_uicc("uicc"); // TS 24.501 9.11.3.4 - int imsiL=strlen(UE->uicc->imsi); + int imsiL=strlen(UE->uicc->imsiStr); int msinL=imsiL-3-UE->uicc->nmc_size; int respSize=sizeof(IdentityresponseIMSI_t) + (msinL+1)/2; IdentityresponseIMSI_t *resp=(IdentityresponseIMSI_t *) calloc(respSize,1); @@ -85,17 +85,17 @@ int identityResponse(void **msg, nr_user_nas_t *UE) { resp->common.mt=Identityresponse; resp->common.len=htons(respSize-sizeof(Identityresponse_t)); resp->mi=SUCI; - resp->mcc1=UE->uicc->imsi[0]-'0'; - resp->mcc2=UE->uicc->imsi[1]-'0'; - resp->mcc3=UE->uicc->imsi[2]-'0'; - resp->mnc1=UE->uicc->imsi[3]-'0'; - resp->mnc2=UE->uicc->imsi[4]-'0'; - resp->mnc3=UE->uicc->nmc_size==2? 0xF : UE->uicc->imsi[3]-'0'; + resp->mcc1=UE->uicc->imsiStr[0]-'0'; + resp->mcc2=UE->uicc->imsiStr[1]-'0'; + resp->mcc3=UE->uicc->imsiStr[2]-'0'; + resp->mnc1=UE->uicc->imsiStr[3]-'0'; + resp->mnc2=UE->uicc->imsiStr[4]-'0'; + resp->mnc3=UE->uicc->nmc_size==2? 0xF : UE->uicc->imsiStr[3]-'0'; // TBD: routing to fill (FF ?) char *out=(char *)(resp+1); - char *ptr=UE->uicc->imsi + 3 + UE->uicc->nmc_size; + char *ptr=UE->uicc->imsiStr + 3 + UE->uicc->nmc_size; - while ( ptr < UE->uicc->imsi+strlen(UE->uicc->imsi) ) { + while ( ptr < UE->uicc->imsiStr+strlen(UE->uicc->imsiStr) ) { *out=((*(ptr+1)-'0')<<4) | (*(ptr) -'0'); out++; ptr+=2; @@ -105,7 +105,6 @@ int identityResponse(void **msg, nr_user_nas_t *UE) { *out=((*(ptr-1)-'0')) | 0xF0; *msg=resp; - log_dump(NAS, resp, respSize, LOG_DUMP_CHAR, "\n"); return respSize; } diff --git a/openair3/NAS/gNB/network_process_nas.c b/openair3/NAS/gNB/network_process_nas.c index feb0d918cf..dbb024298b 100644 --- a/openair3/NAS/gNB/network_process_nas.c +++ b/openair3/NAS/gNB/network_process_nas.c @@ -1,4 +1,6 @@ -#include +#include +#include +#include void SGSabortUE(void *msg, NRUEcontext_t *UE) { } @@ -33,25 +35,29 @@ void processNAS(void *msg, NRUEcontext_t *UE) { SGSabortUE(msg, UE); else { switch (header->epd) { -SGSmobilitymanagementmessages: - + case SGSmobilitymanagementmessages: switch (header->mt) { -Registrationrequest: + case Registrationrequest: SGSregistrationReq(msg, UE); break; -DeregistrationrequestUEoriginating: + + case DeregistrationrequestUEoriginating: SGSderegistrationUEReq(msg, UE); break; -Authenticationresponse: + + case Authenticationresponse: SGSauthenticationResp(msg, UE); break; -Identityresponse: + + case Identityresponse: SGSidentityResp(msg, UE); break; -Securitymodecomplete: + + case Securitymodecomplete: SGSsecurityModeComplete(msg, UE); break; -Registrationcomplete: + + case Registrationcomplete: SGSregistrationComplete(msg, UE); break; @@ -60,7 +66,8 @@ Registrationcomplete: } break; -SGSsessionmanagementmessages: + + case SGSsessionmanagementmessages: SGSabortUE(msg, UE); break; @@ -75,10 +82,60 @@ SGSsessionmanagementmessages: */ int identityRequest(void **msg, NRUEcontext_t *UE) { + myCalloc(req, Identityrequest_t); + req->epd=SGSmobilitymanagementmessages; + req->sh=0; + req->mt=Identityrequest; + req->it=SUCI; + *msg=req; + return sizeof(Identityrequest_t); } int authenticationRequest(void **msg, NRUEcontext_t *UE) { + if (UE->uicc == NULL) + // config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE + UE->uicc=init_uicc("uicc"); + + myCalloc(req, authenticationrequestHeader_t); + req->epd=SGSmobilitymanagementmessages; + req->sh=0; + req->mt=Authenticationrequest; + // native security context => bit 4 to 0 + // probably from TS 33.501, table A-8.1 + // N-NAS-int-alg (Native NAS integrity) + /* + N-NAS-enc-alg 0x01 + N-NAS-int-alg 0x02 + N-RRC-enc-alg 0x03 + N-RRC-int-alg 0x04 + N-UP-enc-alg 0x05 + N-UP-int-alg 0x06 + */ + req->ngKSI=2; + // TS 33.501, Annex A.7.1: Initial set of security features defined for 5GS. + req->ABBALen=2; + req->ABBA=0; + //rand (TV) + req->ieiRAND=IEI_RAND; + FILE *h=fopen("/dev/random","r"); + + if ( sizeof(req->RAND) != fread(req->RAND,1,sizeof(req->RAND),h) ) + LOG_E(NAS, "can't read /dev/random\n"); + + fclose(h); + // challenge/AUTN (TLV) + req->ieiAUTN=IEI_AUTN; + req->AUTNlen=sizeof(req->AUTN); + uint8_t ik[16], ck[16], res[8]; + milenage_generate(UE->uicc->opc, UE->uicc->amf, UE->uicc->key, + UE->uicc->sqn, req->RAND, req->AUTN, ik, ck, res); + // EAP message (TLV-E) + // not developped + *msg=req; + return sizeof(authenticationrequestHeader_t); } int securityModeCommand(void **msg, NRUEcontext_t *UE) { + *msg=NULL; + return 0; } diff --git a/openair3/NAS/gNB/network_process_nas.h b/openair3/NAS/gNB/network_process_nas.h new file mode 100644 index 0000000000..8bb4ea4e20 --- /dev/null +++ b/openair3/NAS/gNB/network_process_nas.h @@ -0,0 +1,16 @@ +#ifndef NET_PROCESS_NAS_H +#define NET_PROCESS_NAS_H +#include + +void SGSabortUE(void *msg, NRUEcontext_t *UE) ; +void SGSregistrationReq(void *msg, NRUEcontext_t *UE); +void SGSderegistrationUEReq(void *msg, NRUEcontext_t *UE); +void SGSauthenticationResp(void *msg, NRUEcontext_t *UE); +void SGSidentityResp(void *msg, NRUEcontext_t *UE); +void SGSsecurityModeComplete(void *msg, NRUEcontext_t *UE); +void SGSregistrationComplete(void *msg, NRUEcontext_t *UE); +void processNAS(void *msg, NRUEcontext_t *UE); +int identityRequest(void **msg, NRUEcontext_t *UE); +int authenticationRequest(void **msg, NRUEcontext_t *UE); +int securityModeCommand(void **msg, NRUEcontext_t *UE); +#endif diff --git a/openair3/UICC/usim_interface.c b/openair3/UICC/usim_interface.c index ec22d61ebb..7076b284e6 100644 --- a/openair3/UICC/usim_interface.c +++ b/openair3/UICC/usim_interface.c @@ -33,18 +33,38 @@ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define UICC_PARAMS_DESC {\ - {"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsi), defstrval:"", TYPE_STRING, 0 },\ - {"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\ - {"key", "USIM Ki\n", 0, strptr:&(uicc->key), defstrval:"", TYPE_STRING, 0 },\ - {"opc", "USIM OPc\n", 0, strptr:&(uicc->opc), defstrval:"", TYPE_STRING, 0 },\ + {"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsiStr), defstrval:"", TYPE_STRING, 0 },\ + {"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\ + {"key", "USIM Ki\n", 0, strptr:&(uicc->keyStr), defstrval:"", TYPE_STRING, 0 },\ + {"opc", "USIM OPc\n", 0, strptr:&(uicc->opcStr), defstrval:"", TYPE_STRING, 0 },\ + {"amf", "USIM amf\n", 0, strptr:&(uicc->amfStr), defstrval:"8000", TYPE_STRING, 0 },\ + {"sqn", "USIM sqn\n", 0, strptr:&(uicc->sqnStr), defstrval:"000000", TYPE_STRING, 0 },\ }; +const char *hexTable="0123456789abcdef"; +static inline void to_hex(char *in, uint8_t *out, bool swap) { + if (swap) + for (size_t i=0; in[i]!=0; i++) { + out+=hexTable[in[i] & 0xf]; + out+=hexTable[in[i]>>4 & 0xf]; + } else { + for (size_t i=0; in[i]!=0; i++) { + out+=hexTable[in[i]>>4 & 0xf]; + out+=hexTable[in[i] & 0xf]; + } + } +} + uicc_t *init_uicc(char *sectionName) { uicc_t *uicc=(uicc_t *)calloc(sizeof(uicc_t),1); paramdef_t uicc_params[] = UICC_PARAMS_DESC; int ret = config_get( uicc_params,sizeof(uicc_params)/sizeof(paramdef_t),sectionName); AssertFatal(ret >= 0, "configuration couldn't be performed"); - LOG_I(HW, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsi, uicc->key, uicc->opc); + LOG_I(HW, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsiStr, uicc->keyStr, uicc->opcStr); + to_hex(uicc->keyStr,uicc->key, false); + to_hex(uicc->opcStr,uicc->opc, false); + to_hex(uicc->sqnStr,uicc->sqn, false); + to_hex(uicc->amfStr,uicc->amf, false); return uicc; } diff --git a/openair3/UICC/usim_interface.h b/openair3/UICC/usim_interface.h index 89c7242f2f..a3fa7b1bf3 100644 --- a/openair3/UICC/usim_interface.h +++ b/openair3/UICC/usim_interface.h @@ -20,6 +20,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ +#ifndef USIM_INTERFACE_H +#define USIM_INTERFACE_H #include #include @@ -34,9 +36,15 @@ #include "common_lib.h" typedef struct { - char *imsi; - char *key; - char *opc; + char *imsiStr; + char *keyStr; + char *opcStr; + char *amfStr; + char *sqnStr; + uint8_t key[16]; + uint8_t opc[16]; + uint8_t amf[2]; + uint8_t sqn[6]; int nmc_size; } uicc_t; @@ -44,3 +52,4 @@ typedef struct { * Read the configuration file, section name variable to be able to manage several UICC */ uicc_t *init_uicc(char *sectionName); +#endif From c05bc1a3e91cdbf03023d8526bae4448a081f705 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 21 Aug 2020 13:48:26 +0200 Subject: [PATCH 031/149] 5G SA authentication: authentication request, partial authentication response --- openair3/NAS/COMMON/NR_NAS_defs.h | 5 ++++- openair3/NAS/NR_UE/nr_user_def.h | 2 ++ openair3/NAS/NR_UE/ue_process_nas.c | 31 +++++++++++++++++++++++++---- openair3/UICC/usim_interface.h | 2 ++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index 441e0db8d3..78939908c3 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -288,7 +288,10 @@ typedef struct { Extendedprotocoldiscriminator_t epd:8; Security_header_t sh:8; SGSmobilitymanagementmessages_t mt:8; -} authenticationresponseHeader_t; + uint8_t iei; + uint8_t RESlen; + uint8_t RES[16]; +} authenticationresponse_t; diff --git a/openair3/NAS/NR_UE/nr_user_def.h b/openair3/NAS/NR_UE/nr_user_def.h index f8fb39a39d..62658a86a7 100644 --- a/openair3/NAS/NR_UE/nr_user_def.h +++ b/openair3/NAS/NR_UE/nr_user_def.h @@ -6,7 +6,9 @@ typedef struct { uicc_t *uicc; } nr_user_nas_t; +#define STATIC_ASSERT(test_for_true) _Static_assert((test_for_true), "(" #test_for_true ") failed") #define myCalloc(var, type) type * var=(type*)calloc(sizeof(type),1); +#define arrayCpy(tO, FroM) STATIC_ASSERT(sizeof(tO) == sizeof(FroM)) ; memcpy(tO, FroM, sizeof(tO)) int identityResponse(void **msg, nr_user_nas_t *UE); #endif diff --git a/openair3/NAS/NR_UE/ue_process_nas.c b/openair3/NAS/NR_UE/ue_process_nas.c index 09c331cc28..314ed16934 100644 --- a/openair3/NAS/NR_UE/ue_process_nas.c +++ b/openair3/NAS/NR_UE/ue_process_nas.c @@ -13,6 +13,13 @@ void nas_schedule(void) { */ void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) { + authenticationrequestHeader_t *amsg=(authenticationrequestHeader_t *) msg; + arrayCpy(UE->uicc->rand,amsg->RAND); + arrayCpy(UE->uicc->autn,amsg->AUTN); + nas_schedule(); +} + +void SGSidentityReq(void *msg, nr_user_nas_t *UE) { Identityrequest_t *idmsg=(Identityrequest_t *) msg; if (idmsg->it == SUCI ) { @@ -22,9 +29,6 @@ void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) { LOG_E(NAS,"Not developped: identity request for %d\n", idmsg->it); } -void SGSidentityReq(void *msg, nr_user_nas_t *UE) { -} - void SGSsecurityModeCommand(void *msg, nr_user_nas_t *UE) { } @@ -109,7 +113,26 @@ int identityResponse(void **msg, nr_user_nas_t *UE) { } int authenticationResponse(void **msg,nr_user_nas_t *UE) { - return -1; + if (UE->uicc == NULL) + // config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE + UE->uicc=init_uicc("uicc"); + + myCalloc(resp, authenticationresponse_t); + resp->epd=SGSmobilitymanagementmessages; + resp->sh=0; + resp->mt=Authenticationresponse; + resp->iei=IEI_AuthenticationResponse; + resp->RESlen=sizeof(resp->RES); + // Verify the AUTN + uint8_t ik[16], ck[16], res[8], AUTN[16]; + milenage_generate(UE->uicc->opc, UE->uicc->amf, UE->uicc->key, + UE->uicc->sqn, UE->uicc->rand, AUTN, ik, ck, res); + + if ( memcmp(UE-uicc->autn, AUTN ) { +} else { +} +*msg=resp; + return sizeof(authenticationresponse_t); } int securityModeComplete(void **msg, nr_user_nas_t *UE) { diff --git a/openair3/UICC/usim_interface.h b/openair3/UICC/usim_interface.h index a3fa7b1bf3..5d4ae2e16b 100644 --- a/openair3/UICC/usim_interface.h +++ b/openair3/UICC/usim_interface.h @@ -46,6 +46,8 @@ typedef struct { uint8_t amf[2]; uint8_t sqn[6]; int nmc_size; + uint8_t rand[16]; + uint8_t autn[16]; } uicc_t; /* From 038a80b2ffb03c282ad0463e5e9318ed58fbd5f0 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 21 Aug 2020 15:50:27 +0200 Subject: [PATCH 032/149] fixes after merge --- executables/main-ocp.c | 6 ------ executables/ocp-gnb.c | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/executables/main-ocp.c b/executables/main-ocp.c index 3c26d16d31..63bd152754 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -1324,14 +1324,8 @@ int main ( int argc, char **argv ) { // end of CI modifications //getchar(); -<<<<<<< HEAD - if(IS_SOFTMODEM_DOFORMS) { - load_softscope("enb",NULL); - } -======= if(IS_SOFTMODEM_DOFORMS) load_softscope("enb", NULL); ->>>>>>> 7f28f8d10dc0d73fd4b10d4a89fde554158f9fb5 itti_wait_tasks_end(); oai_exit=1; diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 5d8acecacf..b4f651b908 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -46,6 +46,7 @@ #include #include #include +#include // Global vars #include From 693364ddc5a7724a45ba65b17426a30c1e3eca38 Mon Sep 17 00:00:00 2001 From: Laurent Date: Sat, 29 Aug 2020 09:37:15 +0200 Subject: [PATCH 033/149] merge develop --- executables/nr-uesoftmodem.c | 7 ++--- openair3/NAS/NR_UE/ue_process_nas.c | 42 ++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 6e243ab13d..7af04ffd45 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -44,6 +44,7 @@ #include "SCHED/sched_common_vars.h" #include "PHY/MODULATION/modulation_vars.h" //#include "../../SIMU/USER/init_lte.h" +#include "PHY/NR_REFSIG/nr_mod_table.h" #include "LAYER2/MAC/mac_vars.h" #include "RRC/LTE/rrc_vars.h" @@ -764,11 +765,11 @@ int main( int argc, char **argv ) { nr_user_nas_t UErrc={0}; NRUEcontext_t UEnas={0}; int size=identityRequest((void**)&resp, &UEnas); - log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Request:\n" );; + log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Request:\n" ); size=identityResponse((void**)&resp, &UErrc); - log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Response:\n" );; + log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Response:\n" ); size=authenticationRequest((void**)&resp, &UEnas); - log_dump(NAS, resp, size, LOG_DUMP_CHAR," authentication request:\n" );; + log_dump(NAS, resp, size, LOG_DUMP_CHAR," authentication request:\n" ); if(IS_SOFTMODEM_DOFORMS) { load_softscope("nr",PHY_vars_UE_g[0][0]); diff --git a/openair3/NAS/NR_UE/ue_process_nas.c b/openair3/NAS/NR_UE/ue_process_nas.c index 4d8d6741d0..88ab9456d3 100644 --- a/openair3/NAS/NR_UE/ue_process_nas.c +++ b/openair3/NAS/NR_UE/ue_process_nas.c @@ -2,6 +2,41 @@ #include #include +void servingNetworkName(uint8_t * msg,nr_user_nas_t *UE) { + //SNN-network-identifier in TS 24.501 + // TS 24.501: If the MNC of the serving PLMN has two digits, then a zero is added at the beginning. + const char * format="5G:mnc000.mcc000.3gppnetwork.org"; + memcpy(msg,format, strlen(format)); + if (UE->uicc->nmc_size == 2) + memcpy(msg+7, UE->uicc->imsiStr+3, 2); + else + memcpy(msg+6, UE->uicc->imsiStr+3, 3); + memcpy(msg+13, UE->uicc->imsiStr, 3); +} + +xresToxresStar(uint8_t * msg),nr_user_nas_t *UE { + // TS 33.220 annex B.2 => FC=0x6B in TS 33.501 annex A.4 + //input S to KDF + uint8_t S[64]={0}; + S[0]=0x6B; + servingNetworkName(S+1, UE); + *(uint16_t*)(msg+strlen(msg))=htons(strlen(msg)); + msg+=strlen(msg)+sizeof(uint16_t); + // add rand + memcpy(msg, UE->uicc->rand, sizeof(UE->uicc->rand) ) ; + *(uint16_t*)(msg+sizeof(UE->uicc->rand))=htons(sizeof(UE->uicc->rand)); + msg+=sizeof(UE->uicc->rand)+sizeof(uint16_t); + msg+=strlen(msg)+sizeof(uint16_t); + // add xres + memcpy(msg, UE->uicc->xres, sizeof(UE->uicc->xres) ) ; + *(uint16_t*)(msg+sizeof(UE->uicc->xres))=htons(sizeof(UE->uicc->xres)); + msg+=sizeof(UE->uicc->xres)+sizeof(uint16_t); + // S is done + + + +} + void SGSabortNet(void *msg, nr_user_nas_t *UE) { } @@ -16,6 +51,9 @@ void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) { authenticationrequestHeader_t *amsg=(authenticationrequestHeader_t *) msg; arrayCpy(UE->uicc->rand,amsg->RAND); arrayCpy(UE->uicc->autn,amsg->AUTN); + // AUTHENTICATION REQUEST message that contains a valid ngKSI, SQN and MAC is received + // TBD verify ngKSI (we set it as '2', see gNB code) + // SQN and MAC are tested in auth resp processing nas_schedule(); } @@ -122,14 +160,16 @@ int authenticationResponse(void **msg,nr_user_nas_t *UE) { resp->sh=0; resp->mt=Authenticationresponse; resp->iei=IEI_AuthenticationResponse; - resp->RESlen=sizeof(resp->RES); + resp->RESlen=sizeof(resp->RES); // always 16 see TS 24.501 Table 8.2.2.1.1 // Verify the AUTN uint8_t ik[16], ck[16], res[8], AUTN[16]; milenage_generate(UE->uicc->opc, UE->uicc->amf, UE->uicc->key, UE->uicc->sqn, UE->uicc->rand, AUTN, ik, ck, res); + if ( memcmp(UE->uicc->autn, AUTN, sizeof(AUTN)) ) { // prepare and send good answer + } else { // prepare and send autn is not compatible with us } From 42fe39ece57c5467fb4ffb9964e0b511d1e8b223 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Tue, 8 Sep 2020 22:43:42 +0200 Subject: [PATCH 034/149] moving gpio control to the rx --- executables/nr-ru.c | 2 +- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 969ad21b8e..c2b5b80d31 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -747,7 +747,7 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { // the beam index is written in bits 8-10 of the flags // bit 11 enables the gpio programming int beam=0; - if (slot==0) beam = 11; //3 for boresight & 8 to enable + //if (slot==0) beam = 11; //3 for boresight & 8 to enable /* if (slot==0 || slot==40) beam=0&8; if (slot==10 || slot==50) beam=1&8; diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 6e94717a6f..4c27dc8ebb 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -69,7 +69,7 @@ /** @addtogroup _USRP_PHY_RF_INTERFACE_ * @{ */ - +int gpio789=0; extern int usrp_tx_thread; @@ -708,6 +708,12 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp s->rx_timestamp = s->rx_md.time_spec.to_ticks(s->sample_rate); *ptimestamp = s->rx_timestamp; + // push GPIO bits 7-9 from flags_msb + s->usrp->set_command_time(uhd::time_spec_t::from_ticks((s->rx_timestamp+(2*nsamps)),s->sample_rate)); + s->usrp->set_gpio_attr("FP0", "OUT", gpio789<<7, 0x380); + s->usrp->clear_command_time(); + gpio789 = (gpio789+1)&7; + if (device->recplay_state != NULL) { // record mode // Copy subframes to memory (later dump on a file) if (device->recplay_state->nb_samples < device->openair0_cfg->recplay_conf->u_sf_max) { From 39f84c3a628721c72252139888d6155b7be2cfe1 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Wed, 9 Sep 2020 15:46:25 +0200 Subject: [PATCH 035/149] FR2 testing --- executables/nr-ue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index cdcd014caa..de184d288e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -180,6 +180,9 @@ static void UE_synch(void *arg) { UE->is_synchronized = 0; if (UE->UE_scan == 0) { + UE->frame_parms.dl_CarrierFreq = downlink_frequency[0][0]; + UE->frame_parms.ul_CarrierFreq = downlink_frequency[0][0]; + LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu64", UL %"PRIu64" (oai_exit %d, rx_num_channels %d)\n", UE->frame_parms.dl_CarrierFreq, UE->frame_parms.ul_CarrierFreq, oai_exit, openair0_cfg[0].rx_num_channels); From 0b7573484c97caef0a35f7e1ccf110960364a0c2 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Wed, 9 Sep 2020 15:49:40 +0200 Subject: [PATCH 036/149] overiting centre frequency for FR2 testing --- executables/nr-ue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index de184d288e..aee4c5b144 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -180,8 +180,12 @@ static void UE_synch(void *arg) { UE->is_synchronized = 0; if (UE->UE_scan == 0) { - UE->frame_parms.dl_CarrierFreq = downlink_frequency[0][0]; - UE->frame_parms.ul_CarrierFreq = downlink_frequency[0][0]; + + // Overwrite DL frequency (for FR2 testing) + if (downlink_frequency[0][0]!=0){ + UE->frame_parms.dl_CarrierFreq = downlink_frequency[0][0]; + UE->frame_parms.ul_CarrierFreq = downlink_frequency[0][0]; + } LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu64", UL %"PRIu64" (oai_exit %d, rx_num_channels %d)\n", UE->frame_parms.dl_CarrierFreq, UE->frame_parms.ul_CarrierFreq, From 948dc6b1d94fb9ca670e2039ff4d5ffb80a4d24d Mon Sep 17 00:00:00 2001 From: Rakesh Date: Wed, 9 Sep 2020 15:53:13 +0200 Subject: [PATCH 037/149] bug fix in channel estimation --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 612dc6283d..6cff27bdee 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -36,7 +36,7 @@ #include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/INIT/phy_init.h" -//#define DEBUG_PBCH 1 +//#define DEBUG_PBCH //#define DEBUG_PBCH_ENCODING #ifdef OPENAIR2 @@ -61,7 +61,8 @@ uint16_t nr_pbch_extract(int **rxdataF, int nushiftmod4 = frame_parms->nushift; unsigned int rx_offset = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier; //and - if (rx_offset>= frame_parms->ofdm_symbol_size) rx_offset-=frame_parms->ofdm_symbol_size; + // if (rx_offset>= frame_parms->ofdm_symbol_size) rx_offset-=frame_parms->ofdm_symbol_size; + rx_offset=(rx_offset)%(frame_parms->ofdm_symbol_size); AssertFatal(symbol>=1 && symbol<5, "symbol %d illegal for PBCH extraction\n", @@ -103,8 +104,8 @@ uint16_t nr_pbch_extract(int **rxdataF, j++; } - //rx_offset=(rx_offset+1)&(frame_parms->ofdm_symbol_size-1); - rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 1) : (rx_offset+1); + rx_offset=(rx_offset+1)%(frame_parms->ofdm_symbol_size); + //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 1) : (rx_offset+1); } rxF_ext+=9; @@ -126,12 +127,14 @@ uint16_t nr_pbch_extract(int **rxdataF, j++; } - //rx_offset=(rx_offset+1)&(frame_parms->ofdm_symbol_size-1); - rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 1) : (rx_offset+1); + rx_offset=(rx_offset+1)%(frame_parms->ofdm_symbol_size); + //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 1) : (rx_offset+1); } rxF_ext+=9; - } else rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 12) : (rx_offset+12);//rx_offset = (rx_offset+12)&(frame_parms->ofdm_symbol_size-1); + } else{ //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 12) : (rx_offset+12); + rx_offset = (rx_offset+12)%(frame_parms->ofdm_symbol_size); + } } } From 26fb2905f51c8c8aee509b2b5a00edc748c0fe46 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Wed, 9 Sep 2020 15:59:03 +0200 Subject: [PATCH 038/149] adding prb 32 for timing advance calculation --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index eafc81cd91..65e3209d57 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -314,7 +314,8 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, case 245: timing_advance_update /= 32; break; case 273: timing_advance_update /= 32; break; case 66: timing_advance_update /= 12; break; - default: abort(); + case 32: timing_advance_update /= 12; break; + default: AssertFatal(0==1,"No case defined for PRB %d to calculate timing_advance_update\n",gNB->frame_parms.N_RB_DL); } // put timing advance command in 0..63 range From ec51d54f89ce68bc6f295923cb0d19ba68d844b7 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Wed, 9 Sep 2020 16:00:39 +0200 Subject: [PATCH 039/149] fix for number of slots per tdd period calculation --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index ec81ac8532..dfd3635019 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -382,6 +382,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, uint64_t *dlsch_in_slot_bitmap=NULL; uint64_t *ulsch_in_slot_bitmap=NULL; int pucch_sched; + int nb_periods_per_frame; UE_id=0; int bwp_id = 1; @@ -391,7 +392,45 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; NR_COMMON_channels_t *cc = gNB->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - int num_slots_per_tdd = (slots_per_frame[*scc->ssbSubcarrierSpacing])>>(7-scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + + switch(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity) { + case 0: + nb_periods_per_frame = 20; // 10ms/0p5ms + break; + + case 1: + nb_periods_per_frame = 16; // 10ms/0p625ms + break; + + case 2: + nb_periods_per_frame = 10; // 10ms/1ms + break; + + case 3: + nb_periods_per_frame = 8; // 10ms/1p25ms + break; + + case 4: + nb_periods_per_frame = 5; // 10ms/2ms + break; + + case 5: + nb_periods_per_frame = 4; // 10ms/2p5ms + break; + + case 6: + nb_periods_per_frame = 2; // 10ms/5ms + break; + + case 7: + nb_periods_per_frame = 1; // 10ms/10ms + break; + + default: + AssertFatal(1==0,"Undefined tdd period %d\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + } + + int num_slots_per_tdd = (slots_per_frame[*scc->ssbSubcarrierSpacing])/nb_periods_per_frame; int nr_ulmix_slots = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0) From 8022252513941d9b079c4b7373928bbbbe0117e7 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Wed, 9 Sep 2020 16:08:54 +0200 Subject: [PATCH 040/149] Function to check for ssb from rrc configuration --- openair1/SCHED_NR_UE/defs.h | 1 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 65 +++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index c6aea2ec08..bf6e65b261 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -387,6 +387,7 @@ void set_tx_harq_id(NR_UE_ULSCH_t *ulsch, int harq_pid, int slot_tx); int get_tx_harq_id(NR_UE_ULSCH_t *ulsch, int slot_tx); int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp); +int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp); /*@}*/ diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 17a9728f42..85e66abe6e 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2501,6 +2501,16 @@ void nr_ue_pbch_procedures(uint8_t gNB_id, } else { LOG_E(PHY,"[UE %d] frame %d, nr_tti_rx %d, Error decoding PBCH!\n", ue->Mod_id,frame_rx, nr_tti_rx); + /*FILE *fd; + if ((fd = fopen("rxsig_frame0.dat","w")) != NULL) { + fwrite((void *)&ue->common_vars.rxdata[0][0], + sizeof(int32_t), + ue->frame_parms.samples_per_frame, + fd); + LOG_I(PHY,"Dummping Frame ... bye bye \n"); + fclose(fd); + exit(0); + }*/ /* write_output("rxsig0.m","rxs0", ue->common_vars.rxdata[0],ue->frame_parms.samples_per_subframe,1,1); @@ -4006,6 +4016,59 @@ void *UE_thread_slot1_dl_processing(void *arg) { } #endif +int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp) +{ + int mu = fp->numerology_index; + //uint8_t half_frame_index = fp->half_frame_bit; + //uint8_t i_ssb = fp->ssb_index; + uint8_t Lmax = fp->Lmax; + + if (!(frame%(1<<(config->ssb_table.ssb_period-1)))){ + + if(Lmax <= 8) { + if(slot <=3 && (((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*slot)&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*slot +1))&0x80000000) == 0x80000000)) + return 1; + else return 0; + + } + else if(Lmax == 64) { + if (mu == NR_MU_3){ + + if (slot>=0 && slot <= 7){ + if(((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*slot)&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*slot +1))&0x80000000) == 0x80000000) + return 1; + else return 0; + } + else if (slot>=10 && slot <=17){ + if(((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*(slot-2))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*(slot-2) +1))&0x80000000) == 0x80000000) + return 1; + else return 0; + } + else if (slot>=20 && slot <=27){ + if(((config->ssb_table.ssb_mask_list[1].ssb_mask << 2*(slot-20))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[1].ssb_mask << (2*(slot-20) +1))&0x80000000) == 0x80000000) + return 1; + else return 0; + } + else if (slot>=30 && slot <=37){ + if(((config->ssb_table.ssb_mask_list[1].ssb_mask << 2*(slot-22))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[1].ssb_mask << (2*(slot-22) +1))&0x80000000) == 0x80000000) + return 1; + else return 0; + } + else return 0; + + } + + + else if (mu == NR_MU_4) { + AssertFatal(0==1, "not implemented for mu = %d yet\n", mu); + } + else AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu); + } + else AssertFatal(0==1, "Invalid Lmax %d for the synchronization block\n", Lmax); + } + else return 0; + +} int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp) { @@ -4037,6 +4100,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; int slot_pbch; + int slot_ssb; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; fapi_nr_config_request_t *cfg = &ue->nrUE_config; @@ -4059,6 +4123,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, get_coreset_rballoc(pdcch_vars->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); slot_pbch = is_pbch_in_slot(cfg, frame_rx, nr_tti_rx, fp); + slot_ssb = is_ssb_in_slot(cfg, frame_rx, nr_tti_rx, fp); // looking for pbch only in slot where it is supposed to be if ((ue->decode_MIB == 1) && slot_pbch) From 960ab9318385cf912392ec1a13c5284c411d1688 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Wed, 9 Sep 2020 16:11:01 +0200 Subject: [PATCH 041/149] changing UL PRB for FR2 32 PRB testing --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 9cc7b26803..3e1c0e754e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -912,7 +912,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, pusch_pdu->resource_alloc = 1; //type 1 pusch_pdu->rb_start = 0; if (get_softmodem_params()->phy_test==1) - pusch_pdu->rb_size = 50; + pusch_pdu->rb_size = 5; else pusch_pdu->rb_size = 5; } From 6931fd7d3732596e98004e254be2332a18a33849 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 3 Sep 2020 14:33:19 +0200 Subject: [PATCH 042/149] moving the OFDM phase rotation from RU to DU --- executables/nr-gnb.c | 8 ++++++ executables/nr-ru.c | 4 +-- openair1/PHY/MODULATION/nr_modulation.h | 6 +++++ openair1/PHY/MODULATION/slot_fep_nr.c | 32 ++++++++++++++++------- openair1/SCHED_NR/nr_ru_procedures.c | 32 ----------------------- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 15 ++++++++++- openair1/SIMULATION/NR_PHY/dlsim.c | 29 +------------------- 7 files changed, 54 insertions(+), 72 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 27b0ed08dd..bb2bfbb80e 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -208,6 +208,14 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t L1_nr_prach_procedures(gNB,frame_rx,slot_rx,&gNB->prach_vars.list[prach_id].pdu); gNB->prach_vars.list[prach_id].frame=-1; } + //apply the rx signal rotation here + apply_nr_rotation_ul(&gNB->frame_parms, + gNB->common_vars.rxdataF[0], + slot_rx, + 0, + gNB->frame_parms.Ncp==EXTENDED?12:14, + gNB->frame_parms.ofdm_symbol_size); + phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx); } diff --git a/executables/nr-ru.c b/executables/nr-ru.c index a0f5710128..a093952dd0 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -861,9 +861,9 @@ void *ru_thread_prach( void *param ) { if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"ru_prach_thread") < 0) break; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 1 ); + /*VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 1 ); - /*if (ru->gNB_list[0]){ + if (ru->gNB_list[0]){ prach_procedures( ru->gNB_list[0],0 ); diff --git a/openair1/PHY/MODULATION/nr_modulation.h b/openair1/PHY/MODULATION/nr_modulation.h index 31d8754768..3d2be905ac 100644 --- a/openair1/PHY/MODULATION/nr_modulation.h +++ b/openair1/PHY/MODULATION/nr_modulation.h @@ -112,4 +112,10 @@ void apply_nr_rotation(NR_DL_FRAME_PARMS *fp, void init_symbol_rotation(NR_DL_FRAME_PARMS *fp,uint64_t CarrierFreq); +void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, + int32_t *rxdataF, + int slot, + int first_symbol, + int nsymb, + int length); #endif diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 2ffdb013a5..c5363246f6 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -490,14 +490,28 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, // clear DC carrier from OFDM symbols rxdataF[symbol * frame_parms->ofdm_symbol_size] = 0; - int symb_offset = (Ns%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; - uint32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation)[symbol+symb_offset]; - ((int16_t*)&rot2)[1]=-((int16_t*)&rot2)[1]; - LOG_D(PHY,"slot %d, symb_offset %d rotating by %d.%d\n",Ns,symb_offset,((int16_t*)&rot2)[0],((int16_t*)&rot2)[1]); - rotate_cpx_vector((int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], - (int16_t*)&rot2, - (int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], - frame_parms->ofdm_symbol_size, - 15); return(0); } + +void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, + int32_t *rxdataF, + int slot, + int first_symbol, + int nsymb, + int length) { + + + int symb_offset = (slot%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; + + for (int symbol=0;symbolsymbol_rotation)[symbol+symb_offset]; + ((int16_t*)&rot2)[1]=-((int16_t*)&rot2)[1]; + LOG_D(PHY,"slot %d, symb_offset %d rotating by %d.%d\n",slot,symb_offset,((int16_t*)&rot2)[0],((int16_t*)&rot2)[1]); + rotate_cpx_vector((int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], + (int16_t*)&rot2, + (int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], + length, + 15); + } +} diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index 9723b2f99e..a78b1f4805 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -89,13 +89,6 @@ void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols, int aa) { if (fp->numerology_index != 0) { if (!(slot%(fp->slots_per_subframe/2))&&(first_symbol==0)) { // case where first symbol in slot has longer prefix - apply_nr_rotation(fp, - (int16_t*)&ru->common.txdataF_BF[aa][slot_offsetF], - slot, - 0, - 1, - fp->ofdm_symbol_size); - PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF], (int*)&ru->common.txdata[aa][slot_offset], fp->ofdm_symbol_size, @@ -103,13 +96,6 @@ void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols, int aa) { fp->nb_prefix_samples0, CYCLIC_PREFIX); - apply_nr_rotation(fp, - (int16_t*)&ru->common.txdataF_BF[aa][slot_offsetF+fp->ofdm_symbol_size], - slot, - 1, - num_symbols-1, - fp->ofdm_symbol_size); - PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF+fp->ofdm_symbol_size], (int*)&ru->common.txdata[aa][slot_offset+fp->nb_prefix_samples0+fp->ofdm_symbol_size], fp->ofdm_symbol_size, @@ -118,12 +104,6 @@ void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols, int aa) { CYCLIC_PREFIX); } else { // all symbols in slot have shorter prefix - apply_nr_rotation(fp, - (int16_t*)&ru->common.txdataF_BF[aa][slot_offsetF], - slot, - first_symbol, - num_symbols, - fp->ofdm_symbol_size); PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF], (int*)&ru->common.txdata[aa][slot_offset], fp->ofdm_symbol_size, @@ -141,12 +121,6 @@ void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols, int aa) { 1, fp->nb_prefix_samples, CYCLIC_PREFIX); - apply_nr_rotation(fp, - (int16_t*)&ru->common.txdata[aa][slot_offset], - slot, - idx_sym, - 1, - fp->ofdm_symbol_size+fp->nb_prefix_samples); slot_offset += fp->nb_prefix_samples+fp->ofdm_symbol_size; } else { @@ -156,12 +130,6 @@ void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols, int aa) { 1, fp->nb_prefix_samples0, CYCLIC_PREFIX); - apply_nr_rotation(fp, - (int16_t*)&ru->common.txdata[aa][slot_offset], - slot, - 0, - 1, - fp->ofdm_symbol_size+fp->nb_prefix_samples0); slot_offset += fp->nb_prefix_samples0+fp->ofdm_symbol_size; } } diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 6dfe967edc..269b9f7b1e 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -199,6 +199,10 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0); } + + //apply the OFDM symbol rotation here + apply_nr_rotation(fp,(int16_t*) &gNB->common_vars.txdataF[0][txdataF_offset],slot,0,fp->Ncp==EXTENDED?12:14,fp->ofdm_symbol_size); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_TX+offset,0); } @@ -446,7 +450,7 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) uint8_t symbol; unsigned char aa; - for(symbol = 0; symbol < NR_SYMBOLS_PER_SLOT; symbol++) { + for(symbol = 0; symbol < (gNB->frame_parms.Ncp==EXTENDED?12:14); symbol++) { // nr_slot_fep_ul(gNB, symbol, proc->slot_rx, 0, 0); for (aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) { @@ -460,6 +464,15 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) } } + for (aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) { + apply_nr_rotation_ul(&gNB->frame_parms, + gNB->common_vars.rxdataF[aa], + slot_rx, + 0, + gNB->frame_parms.Ncp==EXTENDED?12:14, + gNB->frame_parms.ofdm_symbol_size); + } + } void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 38400cab51..584e9ac328 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -803,38 +803,11 @@ int main(int argc, char **argv) 12, frame_parms->nb_prefix_samples, CYCLIC_PREFIX); - } else {/* + } else { nr_normal_prefix_mod(&gNB->common_vars.txdataF[aa][txdataF_offset], &txdata[aa][tx_offset], 14, frame_parms); - */ - PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][txdataF_offset], - (int*)&txdata[aa][tx_offset], - frame_parms->ofdm_symbol_size, - 1, - frame_parms->nb_prefix_samples0, - CYCLIC_PREFIX); - - apply_nr_rotation(frame_parms, - (int16_t*)&txdata[aa][tx_offset], - slot, - 0, - 1, - frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples0); - PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][txdataF_offset+frame_parms->ofdm_symbol_size], - (int*)&txdata[aa][tx_offset+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size], - frame_parms->ofdm_symbol_size, - 13, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); - apply_nr_rotation(frame_parms, - (int16_t*)&txdata[aa][tx_offset+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size], - slot, - 1, - 13, - frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples); - } } From 2cac29b5c69f9c9910a130a968e26e27ca74d736 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Thu, 17 Sep 2020 17:46:50 +0200 Subject: [PATCH 043/149] fix for modulation rotataion to support all numerlogies --- executables/nr-uesoftmodem.c | 2 +- openair1/PHY/MODULATION/nr_modulation.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 3105f06901..de7a3af980 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -686,6 +686,7 @@ int main( int argc, char **argv ) { fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; nr_init_frame_parms_ue(frame_parms[CC_id],nrUE_config,NORMAL); + init_symbol_rotation(frame_parms[CC_id],frame_parms[CC_id]->dl_CarrierFreq); init_nr_ue_vars(UE[CC_id],frame_parms[CC_id],0,abstraction_flag); UE[CC_id]->mac_enabled = 1; @@ -751,7 +752,6 @@ int main( int argc, char **argv ) { if (frame_parms[CC_id]->frame_type == TDD) frame_parms[CC_id]->ul_CarrierFreq = downlink_frequency[0][0]; } - init_symbol_rotation(frame_parms[CC_id],frame_parms[CC_id]->dl_CarrierFreq); } // printf("tx_max_power = %d -> amp %d\n",tx_max_power[0],get_tx_amp(tx_max_poHwer,tx_max_power)); init_openair0(); diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index 652421f77c..0a7088ba39 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -506,10 +506,10 @@ void init_symbol_rotation(NR_DL_FRAME_PARMS *fp,uint64_t CarrierFreq) { const int nsymb = fp->symbols_per_slot * fp->slots_per_frame/10; const double Tc=(1/480e3/4096); - const double Nu=2048*64*.5; + const double Nu=2048*64*(1/(float)(1<numerology_index)); const double f0= (double)CarrierFreq; - const double Ncp0=16*64 + (144*64*.5); - const double Ncp1=(144*64*.5); + const double Ncp0=16*64 + (144*64*(1/(float)(1<numerology_index))); + const double Ncp1=(144*64*(1/(float)(1<numerology_index))); double tl=0,poff,exp_re,exp_im; double Ncp,Ncpm1=Ncp0; From 93550b1cb084fe4bfe992525101b8a5374a45578 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 21 Sep 2020 15:11:02 +0200 Subject: [PATCH 044/149] add test code, finished authentication --- .../gnb.band78.tm1.fr1.106PRB.usrpb210.conf | 6 +- cmake_targets/CMakeLists.txt | 29 ++- executables/nr-uesoftmodem.c | 12 - openair3/NAS/COMMON/NR_NAS_defs.h | 223 +++++++++++------- openair3/NAS/COMMON/nr_common.c | 44 ++++ openair3/NAS/NR_UE/nr_user_def.h | 14 -- openair3/NAS/NR_UE/ue_process_nas.c | 66 ++---- openair3/NAS/gNB/network_process_nas.c | 60 ++++- openair3/NAS/gNB/network_process_nas.h | 16 -- openair3/TEST/test5Gnas.c | 34 +++ openair3/UICC/usim_interface.c | 52 ++-- openair3/UICC/usim_interface.h | 14 ++ 12 files changed, 355 insertions(+), 215 deletions(-) create mode 100644 openair3/NAS/COMMON/nr_common.c delete mode 100644 openair3/NAS/NR_UE/nr_user_def.h delete mode 100644 openair3/NAS/gNB/network_process_nas.h create mode 100644 openair3/TEST/test5Gnas.c diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index 92af74c300..a2d3d1d63c 100755 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -275,7 +275,7 @@ THREAD_STRUCT = ( { global_log_level ="info"; global_log_verbosity ="medium"; - hw_log_level ="info"; + hw_log_level ="debug"; hw_log_verbosity ="medium"; phy_log_level ="info"; phy_log_verbosity ="medium"; @@ -288,4 +288,6 @@ THREAD_STRUCT = ( rrc_log_level ="info"; rrc_log_verbosity ="medium"; }; - +uicc: { +opc = "testopc"; +}; diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c07ab4da7e..3446749f22 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1201,6 +1201,7 @@ set(SECU_OSA_SRC ${OPENAIR2_DIR}/UTIL/OSA/osa_stream_eia.c ) add_library(SECU_OSA ${SECU_OSA_SRC}) +target_link_libraries(SECU_OSA ${NETTLE_LIBRARIES}) set(SECU_CN_SRC ${OPENAIR3_DIR}/SECU/kdf.c @@ -1214,6 +1215,8 @@ set(SECU_CN_SRC ) add_library(SECU_CN ${SECU_CN_SRC}) +target_link_libraries(SECU_CN ${NETTLE_LIBRARIES}) + # Physical Channel Procedures Scheduling ################################" set(SCHED_SRC @@ -2269,10 +2272,12 @@ set (SHLIB_LOADER_SOURCES ) add_library(LIB_5GNAS_GNB + ${NAS_SRC}/COMMON/nr_common.c ${NAS_SRC}/gNB/network_process_nas.c ${NAS_SRC}/NR_UE/ue_process_nas.c ${OPENAIR3_DIR}//UICC/usim_interface.c ) +target_link_libraries(LIB_5GNAS_GNB SECU_CN) # Make lfds as a own source code (even if it is a outside library) # For better intergration with compilation flags & structure of cmake @@ -2563,6 +2568,12 @@ add_executable(measurement_display ${OPENAIR_DIR}/common/utils/threadPool/measurement_display.c) target_link_libraries (measurement_display minimal_lib) +add_executable(test5Gnas + ${OPENAIR_DIR}/openair3/TEST/test5Gnas.c +) +target_link_libraries (test5Gnas LIB_5GNAS_GNB CONFIG_LIB minimal_lib) + + # lte-softmodem is both eNB and UE implementation ################################################### @@ -2604,7 +2615,7 @@ target_link_libraries (lte-softmodem -Wl,--end-group z dl) target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES}) -target_link_libraries (lte-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) +target_link_libraries (lte-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-softmodem ${T_LIB}) @@ -2643,7 +2654,7 @@ target_link_libraries (ocp-enb PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 SIMU_COMMON ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} -Wl,--end-group z dl) -target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) +target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) add_executable(cu_test ${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c @@ -2715,7 +2726,7 @@ target_link_libraries (lte-uesoftmodem -Wl,--end-group z dl) target_link_libraries (lte-uesoftmodem ${LIBXML2_LIBRARIES}) -target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (lte-uesoftmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-uesoftmodem ${T_LIB}) @@ -2757,7 +2768,7 @@ target_link_libraries (nr-softmodem -Wl,--end-group z dl) target_link_libraries (nr-softmodem ${LIBXML2_LIBRARIES}) -target_link_libraries (nr-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (nr-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (nr-softmodem ${T_LIB}) @@ -2797,7 +2808,7 @@ target_link_libraries (ocp-gnb -Wl,--end-group z dl) target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES}) -target_link_libraries (ocp-gnb pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (ocp-gnb pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (ocp-gnb ${LIB_LMS_LIBRARIES}) target_link_libraries (ocp-gnb ${T_LIB}) add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc params_libconfig rfsimulator oai_usrpdevif rfsimulator nrscope) @@ -2841,7 +2852,7 @@ target_link_libraries (nr-uesoftmodem -Wl,--end-group z dl) target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES}) -target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (nr-uesoftmodem ${T_LIB}) @@ -3074,7 +3085,7 @@ add_executable(test_epc_generate_scenario ${OPENAIR3_DIR}/S1AP/s1ap_eNB_defs.h ) target_link_libraries (test_epc_generate_scenario - -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) add_executable(test_epc_play_scenario @@ -3093,7 +3104,7 @@ add_executable(test_epc_play_scenario ) target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c) target_link_libraries (test_epc_play_scenario - -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) @@ -3113,7 +3124,7 @@ foreach(myExe s1ap ${OPENAIR3_DIR}/TEST/test_${myExe}.c ) target_link_libraries (test_${myExe} - -Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) endforeach(myExe) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 7af04ffd45..fa816b506c 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -85,8 +85,6 @@ unsigned short config_frames[4] = {2,9,11,13}; #include #include "executables/softmodem-common.h" #include "executables/thread-common.h" -#include -#include // Raphael : missing pthread_cond_t nfapi_sync_cond; @@ -760,16 +758,6 @@ int main( int argc, char **argv ) { memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); configure_linux(); mlockall(MCL_CURRENT | MCL_FUTURE); - - char * resp; - nr_user_nas_t UErrc={0}; - NRUEcontext_t UEnas={0}; - int size=identityRequest((void**)&resp, &UEnas); - log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Request:\n" ); - size=identityResponse((void**)&resp, &UErrc); - log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Response:\n" ); - size=authenticationRequest((void**)&resp, &UEnas); - log_dump(NAS, resp, size, LOG_DUMP_CHAR," authentication request:\n" ); if(IS_SOFTMODEM_DOFORMS) { load_softscope("nr",PHY_vars_UE_g[0][0]); diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index 78939908c3..a84d8db4f8 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -1,3 +1,9 @@ +#ifndef NR_NAS_DEFS_H +#define NR_NAS_DEFS_H + +#include +#include +#include /* TS 24.007 possible L3 formats: Table 11.1: Formats of information elements @@ -11,61 +17,87 @@ TLV-E Type, Length and Value yes yes yes */ +/* Map task id to printable name. */ +typedef struct { + int id; + char text[256]; +} text_info_t; + +static inline const char * idToText(const text_info_t* table, int size, int id) { + for(int i=0; i TS 24.007 typedef enum { SGSsessionmanagementmessages=0x2e, //LTEbox: 0xC0 ??? SGSmobilitymanagementmessages=0x7e, } Extendedprotocoldiscriminator_t; +#define FOREACH_TYPE(TYPE_DEF) \ + TYPE_DEF( Registrationrequest,0x41 )\ +TYPE_DEF( Registrationaccept,0x42 )\ +TYPE_DEF( Registrationcomplete,0x43 )\ +TYPE_DEF( Registrationreject,0x44 )\ +TYPE_DEF( DeregistrationrequestUEoriginating,0x45 )\ +TYPE_DEF( DeregistrationacceptUEoriginating,0x46 )\ +TYPE_DEF( DeregistrationrequestUEterminated,0x47 )\ +TYPE_DEF( DeregistrationacceptUEterminated,0x48 )\ +TYPE_DEF( Servicerequest,0x4c )\ +TYPE_DEF( Servicereject,0x4d )\ +TYPE_DEF( Serviceaccept,0x4e )\ +TYPE_DEF( Controlplaneservicerequest,0x4f )\ +TYPE_DEF( Networkslicespecificauthenticationcommand,0x50 )\ +TYPE_DEF( Networkslicespecificauthenticationcomplete,0x51 )\ +TYPE_DEF( Networkslicespecificauthenticationresult,0x52 )\ +TYPE_DEF( Configurationupdatecommand,0x54 )\ +TYPE_DEF( Configurationupdatecomplete,0x55 )\ +TYPE_DEF( Authenticationrequest,0x56 )\ +TYPE_DEF( Authenticationresponse,0x57 )\ +TYPE_DEF( Authenticationreject,0x58 )\ +TYPE_DEF( Authenticationfailure,0x59 )\ +TYPE_DEF( Authenticationresult,0x5a )\ +TYPE_DEF( Identityrequest,0x5b )\ +TYPE_DEF( Identityresponse,0x5c )\ +TYPE_DEF( Securitymodecommand,0x5d )\ +TYPE_DEF( Securitymodecomplete,0x5e )\ +TYPE_DEF( Securitymodereject,0x5f )\ +TYPE_DEF( SGMMstatus,0x64 )\ +TYPE_DEF( Notification,0x65 )\ +TYPE_DEF( Notificationresponse,0x66 )\ +TYPE_DEF( ULNAStransport,0x67 )\ +TYPE_DEF( DLNAStransport,0x68 )\ +TYPE_DEF( PDUsessionestablishmentrequest,0xc1 )\ +TYPE_DEF( PDUsessionestablishmentaccept,0xc2 )\ +TYPE_DEF( PDUsessionestablishmentreject,0xc3 )\ +TYPE_DEF( PDUsessionauthenticationcommand,0xc5 )\ +TYPE_DEF( PDUsessionauthenticationcomplete,0xc6 )\ +TYPE_DEF( PDUsessionauthenticationresult,0xc7 )\ +TYPE_DEF( PDUsessionmodificationrequest,0xc9 )\ +TYPE_DEF( PDUsessionmodificationreject,0xca )\ +TYPE_DEF( PDUsessionmodificationcommand,0xcb )\ +TYPE_DEF( PDUsessionmodificationcomplete,0xcc )\ +TYPE_DEF( PDUsessionmodificationcommandreject,0xcd )\ +TYPE_DEF( PDUsessionreleaserequest,0xd1 )\ +TYPE_DEF( PDUsessionreleasereject,0xd2 )\ +TYPE_DEF( PDUsessionreleasecommand,0xd3 )\ +TYPE_DEF( PDUsessionreleasecomplete,0xd4 )\ +TYPE_DEF( SGSMstatus,0xd6 )\ + +static const text_info_t message_text_info[] = { + FOREACH_TYPE(TO_TEXT) +}; + +//! Tasks id of each task typedef enum { - Registrationrequest=0x41, - Registrationaccept=0x42, - Registrationcomplete=0x43, - Registrationreject=0x44, - DeregistrationrequestUEoriginating=0x45, - DeregistrationacceptUEoriginating=0x46, - DeregistrationrequestUEterminated=0x47, - DeregistrationacceptUEterminated=0x48, - Servicerequest=0x4c, - Servicereject=0x4d, - Serviceaccept=0x4e, - Controlplaneservicerequest=0x4f, - Networkslicespecificauthenticationcommand=0x50, - Networkslicespecificauthenticationcomplete=0x51, - Networkslicespecificauthenticationresult=0x52, - Configurationupdatecommand=0x54, - Configurationupdatecomplete=0x55, - Authenticationrequest=0x56, - Authenticationresponse=0x57, - Authenticationreject=0x58, - Authenticationfailure=0x59, - Authenticationresult=0x5a, - Identityrequest=0x5b, - Identityresponse=0x5c, - Securitymodecommand=0x5d, - Securitymodecomplete=0x5e, - Securitymodereject=0x5f, - SGMMstatus=0x64, - Notification=0x65, - Notificationresponse=0x66, - ULNAStransport=0x67, - DLNAStransport=0x68, - PDUsessionestablishmentrequest=0xc1, - PDUsessionestablishmentaccept=0xc2, - PDUsessionestablishmentreject=0xc3, - PDUsessionauthenticationcommand=0xc5, - PDUsessionauthenticationcomplete=0xc6, - PDUsessionauthenticationresult=0xc7, - PDUsessionmodificationrequest=0xc9, - PDUsessionmodificationreject=0xca, - PDUsessionmodificationcommand=0xcb, - PDUsessionmodificationcomplete=0xcc, - PDUsessionmodificationcommandreject=0xcd, - PDUsessionreleaserequest=0xd1, - PDUsessionreleasereject=0xd2, - PDUsessionreleasecommand=0xd3, - PDUsessionreleasecomplete=0xd4, - SGSMstatus=0xd6, + FOREACH_TYPE(TO_ENUM) } SGSmobilitymanagementmessages_t; // TS 24.501 @@ -134,24 +166,19 @@ typedef enum { CAUSE_DEF(Protocol_error_unspecified,0x67 ) /* Map task id to printable name. */ -typedef struct { - int id; - char text[256]; -} cause_text_info_t; + #define CAUSE_TEXT(LabEl, nUmID) {nUmID, #LabEl}, -static const cause_text_info_t cause_text_info[] = { - FOREACH_CAUSE(CAUSE_TEXT) +static const text_info_t cause_text_info[] = { + FOREACH_CAUSE(TO_TEXT) }; #define CAUSE_ENUM(LabEl, nUmID ) LabEl = nUmID, //! Tasks id of each task typedef enum { - FOREACH_CAUSE(CAUSE_ENUM) + FOREACH_CAUSE(TO_ENUM) } cause_id_t; - - //_table_9.11.4.2.1:_5GSM_cause_information_element #define FOREACH_CAUSE_SECU(CAUSE_SECU_DEF) \ CAUSE_SECU_DEF(Security_Operator_determined_barring,0x08 )\ @@ -198,22 +225,21 @@ typedef enum { CAUSE_SECU_DEF(Security_Message_not_compatible_with_the_protocol_state,0x65 )\ CAUSE_SECU_DEF(Security_Protocol_error_unspecified,0x6f ) -static const cause_text_info_t cause_secu_text_info[] = { - FOREACH_CAUSE_SECU(CAUSE_TEXT) +static const text_info_t cause_secu_text_info[] = { + FOREACH_CAUSE_SECU(TO_TEXT) }; - + +//! Tasks id of each task +typedef enum { + FOREACH_CAUSE_SECU(TO_ENUM) +} cause_secu_id_t; + // IEI (information element identifier) are spread in each message definition #define IEI_RAND 0x21 #define IEI_AUTN 0x20 #define IEI_EAP 0x78 #define IEI_AuthenticationResponse 0x2d -#define CAUSE_ENUM(LabEl, nUmID ) LabEl = nUmID, -//! Tasks id of each task -typedef enum { - FOREACH_CAUSE_SECU(CAUSE_ENUM) -} cause_secu_id_t; - //TS 24.501 sub layer states for UE // for network side, only 5GMMderegistered, 5GMMderegistered_initiated, 5GMMregistered, 5GMMservice_request_initiated are valid typedef enum { @@ -250,20 +276,20 @@ Identityresponse_t; typedef struct __attribute__((packed)) { Identityresponse_t common; identitytype_t mi:8; - int supiFormat:4; - int identityType:4; - int mcc1:4; - int mcc2:4; - int mcc3:4; - int mnc3:4; - int mnc2:4; - int mnc1:4; - int routing1:4; - int routing2:4; - int routing3:4; - int routing4:4; - int protectScheme:4; - int spare:4; + unsigned int supiFormat:4; + unsigned int identityType:4; + unsigned int mcc1:4; + unsigned int mcc2:4; + unsigned int mcc3:4; + unsigned int mnc3:4; + unsigned int mnc1:4; + unsigned int mnc2:4; + unsigned int routing1:4; + unsigned int routing2:4; + unsigned int routing3:4; + unsigned int routing4:4; + unsigned int protectScheme:4; + unsigned int spare:4; uint8_t hplmnId; } IdentityresponseIMSI_t; @@ -272,10 +298,10 @@ typedef struct __attribute__((packed)) { Extendedprotocoldiscriminator_t epd:8; Security_header_t sh:8; SGSmobilitymanagementmessages_t mt:8; - int ngKSI:4; - int spare:4; - int ABBALen:8; - int ABBA:16; + unsigned int ngKSI:4; + unsigned int spare:4; + unsigned int ABBALen:8; + unsigned int ABBA:16; uint8_t ieiRAND; uint8_t RAND[16]; uint8_t ieiAUTN; @@ -293,6 +319,31 @@ typedef struct { uint8_t RES[16]; } authenticationresponse_t; - - //AUTHENTICATION RESULT + + +typedef struct { + uicc_t *uicc; +} nr_user_nas_t; + +#define STATIC_ASSERT(test_for_true) _Static_assert((test_for_true), "(" #test_for_true ") failed") +#define myCalloc(var, type) type * var=(type*)calloc(sizeof(type),1); +#define arrayCpy(tO, FroM) STATIC_ASSERT(sizeof(tO) == sizeof(FroM)) ; memcpy(tO, FroM, sizeof(tO)) +int resToresStar(uint8_t *msg, uicc_t* uicc); + +int identityResponse(void **msg, nr_user_nas_t *UE); +int authenticationResponse(void **msg, nr_user_nas_t *UE); +void UEprocessNAS(void *msg,nr_user_nas_t *UE); +void SGSabortUE(void *msg, NRUEcontext_t *UE) ; +void SGSregistrationReq(void *msg, NRUEcontext_t *UE); +void SGSderegistrationUEReq(void *msg, NRUEcontext_t *UE); +void SGSauthenticationResp(void *msg, NRUEcontext_t *UE); +void SGSidentityResp(void *msg, NRUEcontext_t *UE); +void SGSsecurityModeComplete(void *msg, NRUEcontext_t *UE); +void SGSregistrationComplete(void *msg, NRUEcontext_t *UE); +void processNAS(void *msg, NRUEcontext_t *UE); +int identityRequest(void **msg, NRUEcontext_t *UE); +int authenticationRequest(void **msg, NRUEcontext_t *UE); +int securityModeCommand(void **msg, NRUEcontext_t *UE); + +#endif diff --git a/openair3/NAS/COMMON/nr_common.c b/openair3/NAS/COMMON/nr_common.c new file mode 100644 index 0000000000..9f5ff1d8ac --- /dev/null +++ b/openair3/NAS/COMMON/nr_common.c @@ -0,0 +1,44 @@ + +#include +#include + +void servingNetworkName(uint8_t *msg, char * imsiStr, int nmc_size) { + //SNN-network-identifier in TS 24.501 + // TS 24.501: If the MNC of the serving PLMN has two digits, then a zero is added at the beginning. + const char *format="5G:mnc000.mcc000.3gppnetwork.org"; + memcpy(msg,format, strlen(format)); + + if (nmc_size == 2) + memcpy(msg+7, imsiStr+3, 2); + else + memcpy(msg+6, imsiStr+3, 3); + + memcpy(msg+13, imsiStr, 3); +} + +int resToresStar(uint8_t *msg, uicc_t* uicc) { + // TS 33.220 annex B.2 => FC=0x6B in TS 33.501 annex A.4 + //input S to KDF + uint8_t S[128]= {0}; + S[0]=0x6B; + uint8_t *ptr=S+1; + servingNetworkName(ptr, uicc->imsiStr, uicc->nmc_size); + *(uint16_t *)(ptr+strlen((char *)ptr))=htons(strlen((char *)ptr)); + ptr+=strlen((char *)ptr)+sizeof(uint16_t); + // add rand + memcpy(ptr, uicc->rand, sizeof(uicc->rand) ) ; + *(uint16_t *)(ptr+sizeof(uicc->rand))=htons(sizeof(uicc->rand)); + ptr+=sizeof(uicc->rand)+sizeof(uint16_t); + // add res + memcpy(ptr, uicc->milenage_res, sizeof(uicc->milenage_res) ) ; + *(uint16_t *)(ptr+sizeof(uicc->milenage_res))=htons(sizeof(uicc->milenage_res)); + ptr+=sizeof(uicc->milenage_res)+sizeof(uint16_t); + // S is done + uint8_t ckik[sizeof(uicc->ck) +sizeof(uicc->ik)]; + memcpy(ckik, uicc->ck, sizeof(uicc->ck)); + memcpy(ckik+sizeof(uicc->ck),uicc->ik, sizeof(uicc->ik)); + uint8_t out[32]; + kdf(S, ptr-S, ckik, 32, out, sizeof(out)); + memcpy(msg, out+16, 16); + return 16; +} diff --git a/openair3/NAS/NR_UE/nr_user_def.h b/openair3/NAS/NR_UE/nr_user_def.h deleted file mode 100644 index 62658a86a7..0000000000 --- a/openair3/NAS/NR_UE/nr_user_def.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef NR_USER_DEF_H -#define NR_USER_DEF_H -#include - -typedef struct { - uicc_t *uicc; -} nr_user_nas_t; - -#define STATIC_ASSERT(test_for_true) _Static_assert((test_for_true), "(" #test_for_true ") failed") -#define myCalloc(var, type) type * var=(type*)calloc(sizeof(type),1); -#define arrayCpy(tO, FroM) STATIC_ASSERT(sizeof(tO) == sizeof(FroM)) ; memcpy(tO, FroM, sizeof(tO)) - -int identityResponse(void **msg, nr_user_nas_t *UE); -#endif diff --git a/openair3/NAS/NR_UE/ue_process_nas.c b/openair3/NAS/NR_UE/ue_process_nas.c index 88ab9456d3..74eba3e6df 100644 --- a/openair3/NAS/NR_UE/ue_process_nas.c +++ b/openair3/NAS/NR_UE/ue_process_nas.c @@ -1,46 +1,11 @@ -#include -#include -#include +#include +#include -void servingNetworkName(uint8_t * msg,nr_user_nas_t *UE) { - //SNN-network-identifier in TS 24.501 - // TS 24.501: If the MNC of the serving PLMN has two digits, then a zero is added at the beginning. - const char * format="5G:mnc000.mcc000.3gppnetwork.org"; - memcpy(msg,format, strlen(format)); - if (UE->uicc->nmc_size == 2) - memcpy(msg+7, UE->uicc->imsiStr+3, 2); - else - memcpy(msg+6, UE->uicc->imsiStr+3, 3); - memcpy(msg+13, UE->uicc->imsiStr, 3); -} - -xresToxresStar(uint8_t * msg),nr_user_nas_t *UE { - // TS 33.220 annex B.2 => FC=0x6B in TS 33.501 annex A.4 - //input S to KDF - uint8_t S[64]={0}; - S[0]=0x6B; - servingNetworkName(S+1, UE); - *(uint16_t*)(msg+strlen(msg))=htons(strlen(msg)); - msg+=strlen(msg)+sizeof(uint16_t); - // add rand - memcpy(msg, UE->uicc->rand, sizeof(UE->uicc->rand) ) ; - *(uint16_t*)(msg+sizeof(UE->uicc->rand))=htons(sizeof(UE->uicc->rand)); - msg+=sizeof(UE->uicc->rand)+sizeof(uint16_t); - msg+=strlen(msg)+sizeof(uint16_t); - // add xres - memcpy(msg, UE->uicc->xres, sizeof(UE->uicc->xres) ) ; - *(uint16_t*)(msg+sizeof(UE->uicc->xres))=htons(sizeof(UE->uicc->xres)); - msg+=sizeof(UE->uicc->xres)+sizeof(uint16_t); - // S is done - - - -} void SGSabortNet(void *msg, nr_user_nas_t *UE) { } -void nas_schedule(void) { +void ue_nas_schedule(void) { } /* @@ -54,7 +19,7 @@ void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) { // AUTHENTICATION REQUEST message that contains a valid ngKSI, SQN and MAC is received // TBD verify ngKSI (we set it as '2', see gNB code) // SQN and MAC are tested in auth resp processing - nas_schedule(); + ue_nas_schedule(); } void SGSidentityReq(void *msg, nr_user_nas_t *UE) { @@ -62,7 +27,7 @@ void SGSidentityReq(void *msg, nr_user_nas_t *UE) { if (idmsg->it == SUCI ) { LOG_I(NAS,"Received Identity request, scheduling answer\n"); - nas_schedule(); + ue_nas_schedule(); } else LOG_E(NAS,"Not developped: identity request for %d\n", idmsg->it); } @@ -79,6 +44,8 @@ void UEprocessNAS(void *msg,nr_user_nas_t *UE) { else { switch (header->epd) { case SGSmobilitymanagementmessages: + LOG_I(NAS,"Received message: %s\n", idStr(message_text_info, header->mt)); + switch (header->mt) { case Authenticationrequest: SGSauthenticationReq(msg, UE); @@ -154,7 +121,7 @@ int authenticationResponse(void **msg,nr_user_nas_t *UE) { if (UE->uicc == NULL) // config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE UE->uicc=init_uicc("uicc"); - + myCalloc(resp, authenticationresponse_t); resp->epd=SGSmobilitymanagementmessages; resp->sh=0; @@ -162,17 +129,20 @@ int authenticationResponse(void **msg,nr_user_nas_t *UE) { resp->iei=IEI_AuthenticationResponse; resp->RESlen=sizeof(resp->RES); // always 16 see TS 24.501 Table 8.2.2.1.1 // Verify the AUTN - uint8_t ik[16], ck[16], res[8], AUTN[16]; - milenage_generate(UE->uicc->opc, UE->uicc->amf, UE->uicc->key, - UE->uicc->sqn, UE->uicc->rand, AUTN, ik, ck, res); + // a full implementation need to test several SQN + // as the last 5bits can be any value + // and the value can also be greater and accepted (if it is in the accepted window) + uint8_t AUTN[16]; + uicc_milenage_generate(AUTN, UE->uicc); - - if ( memcmp(UE->uicc->autn, AUTN, sizeof(AUTN)) ) { + if ( memcmp(UE->uicc->autn, AUTN, sizeof(AUTN)) == 0 ) { // prepare and send good answer - + resToresStar(resp->RES,UE->uicc); } else { - // prepare and send autn is not compatible with us + // prepare and send autn is not compatible with our data + abort(); } + *msg=resp; return sizeof(authenticationresponse_t); } diff --git a/openair3/NAS/gNB/network_process_nas.c b/openair3/NAS/gNB/network_process_nas.c index dbb024298b..bdfa2183d6 100644 --- a/openair3/NAS/gNB/network_process_nas.c +++ b/openair3/NAS/gNB/network_process_nas.c @@ -1,11 +1,9 @@ -#include -#include -#include +#include void SGSabortUE(void *msg, NRUEcontext_t *UE) { } - - +void nas_schedule(void) { +} /* *Message reception */ @@ -16,10 +14,48 @@ void SGSregistrationReq(void *msg, NRUEcontext_t *UE) { void SGSderegistrationUEReq(void *msg, NRUEcontext_t *UE) { } -void SGSauthenticationResp(void *msg, NRUEcontext_t *UE) { +void SGSidentityResp(void *msg, NRUEcontext_t *UE) { + // use the UE SUPI to load the USIM + IdentityresponseIMSI_t *resp=(IdentityresponseIMSI_t *)msg; + char configName[100]={0}; + char * ptr= stpcpy(configName,"uicc"); + *ptr++=resp->mcc1+'0'; + *ptr++=resp->mcc2+'0'; + *ptr++=resp->mcc3+'0'; + *ptr++=resp->mnc1+'0'; + *ptr++=resp->mnc2+'0'; + if ( resp->mnc3 != 0xF ) + *ptr++=resp->mnc3 +'0'; + int respSize=ntohs(resp->common.len); + int msinByteSize=respSize-sizeof(IdentityresponseIMSI_t); + uint8_t * msin=(uint8_t *) (resp+1); + for(int i=3 ; i> 4) ; + *ptr++=(msin[i] & 0xf) +'0'; + if (digit1 != 0xf) + *ptr++=digit1 +'0'; + } + *ptr=0; + if (UE->uicc == NULL) + // config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE + UE->uicc=init_uicc(configName); + //We schedule Authentication request + nas_schedule(); } -void SGSidentityResp(void *msg, NRUEcontext_t *UE) { +void SGSauthenticationResp(void *msg, NRUEcontext_t *UE) { + // Let's check the answer + authenticationresponse_t* resp=(authenticationresponse_t*) msg; + uint8_t resStarLocal[16]; + resToresStar(resStarLocal,UE->uicc); + if ( memcmp(resStarLocal, resp->RES, sizeof(resStarLocal)) == 0 ) { + LOG_I(NAS,"UE answer to authentication resquest is correct\n"); + // we will send securityModeCommand + nas_schedule(); + } else { + LOG_E(NAS,"UE authentication response not good\n"); + // To be implemented ? + } } void SGSsecurityModeComplete(void *msg, NRUEcontext_t *UE) { @@ -36,6 +72,8 @@ void processNAS(void *msg, NRUEcontext_t *UE) { else { switch (header->epd) { case SGSmobilitymanagementmessages: + LOG_I(NAS,"Received message: %s\n", idStr(message_text_info, header->mt)); + switch (header->mt) { case Registrationrequest: SGSregistrationReq(msg, UE); @@ -92,9 +130,6 @@ int identityRequest(void **msg, NRUEcontext_t *UE) { } int authenticationRequest(void **msg, NRUEcontext_t *UE) { - if (UE->uicc == NULL) - // config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE - UE->uicc=init_uicc("uicc"); myCalloc(req, authenticationrequestHeader_t); req->epd=SGSmobilitymanagementmessages; @@ -123,12 +158,11 @@ int authenticationRequest(void **msg, NRUEcontext_t *UE) { LOG_E(NAS, "can't read /dev/random\n"); fclose(h); + memcpy(UE->uicc->rand, req->RAND, sizeof(UE->uicc->rand)); // challenge/AUTN (TLV) req->ieiAUTN=IEI_AUTN; req->AUTNlen=sizeof(req->AUTN); - uint8_t ik[16], ck[16], res[8]; - milenage_generate(UE->uicc->opc, UE->uicc->amf, UE->uicc->key, - UE->uicc->sqn, req->RAND, req->AUTN, ik, ck, res); + uicc_milenage_generate( req->AUTN, UE->uicc); // EAP message (TLV-E) // not developped *msg=req; diff --git a/openair3/NAS/gNB/network_process_nas.h b/openair3/NAS/gNB/network_process_nas.h deleted file mode 100644 index 8bb4ea4e20..0000000000 --- a/openair3/NAS/gNB/network_process_nas.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NET_PROCESS_NAS_H -#define NET_PROCESS_NAS_H -#include - -void SGSabortUE(void *msg, NRUEcontext_t *UE) ; -void SGSregistrationReq(void *msg, NRUEcontext_t *UE); -void SGSderegistrationUEReq(void *msg, NRUEcontext_t *UE); -void SGSauthenticationResp(void *msg, NRUEcontext_t *UE); -void SGSidentityResp(void *msg, NRUEcontext_t *UE); -void SGSsecurityModeComplete(void *msg, NRUEcontext_t *UE); -void SGSregistrationComplete(void *msg, NRUEcontext_t *UE); -void processNAS(void *msg, NRUEcontext_t *UE); -int identityRequest(void **msg, NRUEcontext_t *UE); -int authenticationRequest(void **msg, NRUEcontext_t *UE); -int securityModeCommand(void **msg, NRUEcontext_t *UE); -#endif diff --git a/openair3/TEST/test5Gnas.c b/openair3/TEST/test5Gnas.c new file mode 100644 index 0000000000..5124ad6e4d --- /dev/null +++ b/openair3/TEST/test5Gnas.c @@ -0,0 +1,34 @@ +#include +#include + +volatile int oai_exit; + +int main(int argc, char **argv) { + if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) { + exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); + } + + logInit(); + char *resp; + nr_user_nas_t UErrc= {0}; + NRUEcontext_t UEnas= {0}; + // Network generate identity request after a sucessfull radio attach + int size=identityRequest((void **)&resp, &UEnas); + log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Request:\n" ); + // UE process the message that it has received from phy layer in a "DL transfer" message + UEprocessNAS(resp, &UErrc); + // UE Scheduler should later call the response + size=identityResponse((void **)&resp, &UErrc); + log_dump(NAS, resp, size, LOG_DUMP_CHAR," identity Response:\n" ); + // Now the gNB process the identity response + processNAS(resp, &UEnas); + // gNB scheduler should call the next query + size=authenticationRequest((void **)&resp, &UEnas); + log_dump(NAS, resp, size, LOG_DUMP_CHAR," authentication request:\n" ); + // as above + UEprocessNAS(resp, &UErrc); + size=authenticationResponse((void **)&resp, &UErrc); + log_dump(NAS, resp, size, LOG_DUMP_CHAR," authentication response:\n" ); + processNAS(resp, &UEnas); + return 0; +} diff --git a/openair3/UICC/usim_interface.c b/openair3/UICC/usim_interface.c index 7076b284e6..15a4e2e540 100644 --- a/openair3/UICC/usim_interface.c +++ b/openair3/UICC/usim_interface.c @@ -22,6 +22,7 @@ */ #include +#include #define UICC_SECTION "uicc" #define UICC_CONFIG_HELP_OPTIONS " list of comma separated options to interface a simulated (real UICC to be developped). Available options: \n"\ @@ -42,29 +43,50 @@ }; const char *hexTable="0123456789abcdef"; -static inline void to_hex(char *in, uint8_t *out, bool swap) { - if (swap) - for (size_t i=0; in[i]!=0; i++) { - out+=hexTable[in[i] & 0xf]; - out+=hexTable[in[i]>>4 & 0xf]; - } else { - for (size_t i=0; in[i]!=0; i++) { - out+=hexTable[in[i]>>4 & 0xf]; - out+=hexTable[in[i] & 0xf]; - } +static inline uint8_t mkDigit(unsigned char in) { + for (int i=0; i<16; i++) + if (in==hexTable[i]) + return i; + LOG_E(SIM,"Impossible hexa input: %c\n",in); + return 0; +} + +static inline void to_hex(char *in, uint8_t *out, int size) { + for (size_t i=0; in[i]!=0 && i < size*2 ; i+=2) { + *out++=(mkDigit(in[i]) << 4) | mkDigit(in[i+1]); } } uicc_t *init_uicc(char *sectionName) { uicc_t *uicc=(uicc_t *)calloc(sizeof(uicc_t),1); paramdef_t uicc_params[] = UICC_PARAMS_DESC; + // here we call usim simulation, but calling actual usim is quite simple + // the code is in open-cells.com => program_uicc open source + // we can read the IMSI from the USIM + // key, OPc, sqn, amf don't need to be read from the true USIM int ret = config_get( uicc_params,sizeof(uicc_params)/sizeof(paramdef_t),sectionName); AssertFatal(ret >= 0, "configuration couldn't be performed"); - LOG_I(HW, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsiStr, uicc->keyStr, uicc->opcStr); - to_hex(uicc->keyStr,uicc->key, false); - to_hex(uicc->opcStr,uicc->opc, false); - to_hex(uicc->sqnStr,uicc->sqn, false); - to_hex(uicc->amfStr,uicc->amf, false); + LOG_I(SIM, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsiStr, uicc->keyStr, uicc->opcStr); + to_hex(uicc->keyStr,uicc->key, sizeof(uicc->key) ); + to_hex(uicc->opcStr,uicc->opc, sizeof(uicc->opc) ); + to_hex(uicc->sqnStr,uicc->sqn, sizeof(uicc->sqn) ); + to_hex(uicc->amfStr,uicc->amf, sizeof(uicc->amf) ); return uicc; } +void uicc_milenage_generate(uint8_t *autn, uicc_t *uicc) { + // here we call usim simulation, but calling actual usim is quite simple + // the code is in open-cells.com => program_uicc open source + milenage_generate(uicc->opc, uicc->amf, uicc->key, + uicc->sqn, uicc->rand, autn, uicc->ik, uicc->ck, uicc->milenage_res); + log_dump(SIM,uicc->opc,sizeof(uicc->opc), LOG_DUMP_CHAR,"opc:"); + log_dump(SIM,uicc->amf,sizeof(uicc->amf), LOG_DUMP_CHAR,"amf:"); + log_dump(SIM,uicc->key,sizeof(uicc->key), LOG_DUMP_CHAR,"key:"); + log_dump(SIM,uicc->sqn,sizeof(uicc->sqn), LOG_DUMP_CHAR,"sqn:"); + log_dump(SIM,uicc->rand,sizeof(uicc->rand), LOG_DUMP_CHAR,"rand:"); + log_dump(SIM,uicc->ik,sizeof(uicc->ik), LOG_DUMP_CHAR,"milenage output ik:"); + log_dump(SIM,uicc->ck,sizeof(uicc->ck), LOG_DUMP_CHAR,"milenage output ck:"); + log_dump(SIM,uicc->milenage_res,sizeof(uicc->milenage_res), LOG_DUMP_CHAR,"milenage output res:"); + log_dump(SIM,autn,sizeof(autn), LOG_DUMP_CHAR,"milenage output autn:"); +} + diff --git a/openair3/UICC/usim_interface.h b/openair3/UICC/usim_interface.h index 5d4ae2e16b..e8f241c1e8 100644 --- a/openair3/UICC/usim_interface.h +++ b/openair3/UICC/usim_interface.h @@ -35,6 +35,14 @@ #include #include "common_lib.h" +/* 3GPP glossary +RES RESponse +XRES eXpected RESponse +HRES Hash RESponse +HXRES Hash eXpected RESponse +So, RES can be either milenage res, or received response, so hash of milenage res +*/ + typedef struct { char *imsiStr; char *keyStr; @@ -48,10 +56,16 @@ typedef struct { int nmc_size; uint8_t rand[16]; uint8_t autn[16]; + uint8_t ak[6]; + uint8_t akstar[6]; + uint8_t ck[16]; + uint8_t ik[16]; + uint8_t milenage_res[8]; } uicc_t; /* * Read the configuration file, section name variable to be able to manage several UICC */ uicc_t *init_uicc(char *sectionName); +void uicc_milenage_generate(uint8_t * autn, uicc_t *uicc); #endif From ffd4c20e58b981b338044299edbd1ec5635e9fa0 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 24 Sep 2020 11:55:43 +0200 Subject: [PATCH 045/149] fix L2 tracing in wireshark, start security mode comman --- cmake_targets/CMakeLists.txt | 2 +- openair2/UTIL/OPT/mac_pcap.h | 17 +-- openair2/UTIL/OPT/opt.h | 2 +- openair2/UTIL/OPT/probe.c | 198 +++++++++++++------------ openair3/NAS/COMMON/NR_NAS_defs.h | 22 ++- openair3/NAS/gNB/network_process_nas.c | 16 ++ 6 files changed, 145 insertions(+), 112 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index cfd96f39c0..e68b3b0716 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2640,7 +2640,7 @@ target_link_libraries (measurement_display minimal_lib) add_executable(test5Gnas ${OPENAIR_DIR}/openair3/TEST/test5Gnas.c ) -target_link_libraries (test5Gnas LIB_5GNAS_GNB CONFIG_LIB minimal_lib ${NETTLE_LIBRARIES}) +target_link_libraries (test5Gnas ${NETTLE_LIBRARIES} LIB_5GNAS_GNB CONFIG_LIB minimal_lib ) # lte-softmodem is both eNB and UE implementation diff --git a/openair2/UTIL/OPT/mac_pcap.h b/openair2/UTIL/OPT/mac_pcap.h index 3141d17d59..c443ceb1fb 100644 --- a/openair2/UTIL/OPT/mac_pcap.h +++ b/openair2/UTIL/OPT/mac_pcap.h @@ -6,6 +6,7 @@ #include #define MAC_LTE_DLT 147 +#define DLT_IPV4 228 /********************************************************/ /* Definitions and descriptions come from: http://wiki.wireshark.org/Development/LibpcapFileFormat */ @@ -29,20 +30,4 @@ typedef struct pcaprec_hdr_s { unsigned int orig_len; /* actual length of packet */ } pcaprec_hdr_t; -/* Context information for every MAC PDU that will be logged */ -typedef struct MAC_Context_Info_t { - unsigned short radioType; - unsigned char direction; - unsigned char rntiType; - unsigned short rnti; - unsigned short ueid; - unsigned char isRetx; - unsigned char crcStatusOK; - - unsigned short sysFrameNumber; - unsigned short subFrameNumber; - - unsigned int subframesSinceCaptureStart; -} MAC_Context_Info_t; - #endif diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h index 6861e09cb1..ab591d3a65 100644 --- a/openair2/UTIL/OPT/opt.h +++ b/openair2/UTIL/OPT/opt.h @@ -73,7 +73,7 @@ typedef guint8 gboolean; /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*---------------------------------------------------------------------------------------------------------------------------------------------*/ #define OPT_PARAMS_DESC { \ - {"type" , CONFIG_HLP_TYPEMON, 0, strptr:&in_type, defstrval:"none", TYPE_STRING, 0}, \ + {"type" , CONFIG_HLP_TYPEMON, 0, strptr:(char**)&in_type, defstrval:"none", TYPE_STRING, 0}, \ {"ip" , CONFIG_HLP_L2MONIP, 0, strptr:(char**)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ {"path" , CONFIG_HLP_L2MONPATH, 0, strptr:(char**)&in_path,defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \ } diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index 8c6a74e042..912782dd47 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -90,6 +90,7 @@ what about the implementation #include #include +#include #include "common/config/config_userapi.h" #include "opt.h" #include "common/utils/system.h" @@ -99,8 +100,6 @@ int opt_enabled=0; //static unsigned char g_PDUBuffer[1600]; //static unsigned int g_PDUOffset; -static char in_ip[128]={0}; -static char in_path[128]={0}; FILE *file_fd = NULL; pcap_hdr_t file_header = { 0xa1b2c3d4, /* magic number */ @@ -108,10 +107,14 @@ pcap_hdr_t file_header = { 0, /* timezone */ 0, /* sigfigs - apparently all tools do this */ 65535, /* snaplen - this should be long enough */ - MAC_LTE_DLT /* Data Link Type (DLT). Set as unused value 147 for now */ + DLT_IPV4 + //MAC_LTE_DLT /* Data Link Type (DLT). Set as unused value 147 for now */ }; trace_mode_t opt_type = OPT_NONE; +static char *in_type=NULL; +static char *in_path=NULL; +static char *in_ip=NULL; static unsigned int subframesSinceCaptureStart; static int g_socksd = -1;/* UDP socket used for sending frames */ @@ -131,8 +134,80 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType, guint8 oob_event, guint8 oob_event_value, uint8_t *pdu_buffer, unsigned int pdu_buffer_size); -static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context, - const unsigned char *PDU, unsigned int length); +unsigned short checksum(unsigned short *ptr, int length) { + int sum = 0; + u_short answer = 0; + unsigned short *w = ptr; + int nleft = length; + + while(nleft > 1) { + sum += *w++; + nleft -= 2; + } + + sum = (sum >> 16) + (sum & 0xFFFF); + sum += (sum >> 16); + answer = ~sum; + return(answer); +} + +/* Write an individual PDU (PCAP packet header + mac-context + mac-pdu) */ +static int MAC_LTE_PCAP_WritePDU(const uint8_t *PDU, + unsigned int length) { + pcaprec_hdr_t packet_header; + // IPv4 header + typedef struct ip_hdr { + unsigned char ip_verlen; // 4-bit IPv4 version 4-bit header length (in 32-bit words) + unsigned char ip_tos; // IP type of service + unsigned short ip_totallength; // Total length + unsigned short ip_id; // Unique identifier + unsigned short ip_offset; // Fragment offset field + unsigned char ip_ttl; // Time to live + unsigned char ip_protocol; // Protocol(TCP,UDP etc) + unsigned short ip_checksum; // IP checksum + unsigned int ip_srcaddr; // Source address + unsigned int ip_destaddr; // Source address + } IPV4_HDR; + // Define the UDP header + typedef struct udp_hdr { + unsigned short src_portno; // Source port no. + unsigned short dst_portno; // Dest. port no. + unsigned short udp_length; // Udp packet length + unsigned short udp_checksum; // Udp checksum (optional) + } UDP_HDR; + IPV4_HDR IPheader= {0}; + IPheader.ip_verlen = (4 << 4) | (sizeof(IPV4_HDR) / sizeof(uint32_t)); + IPheader.ip_totallength = htons(sizeof(IPV4_HDR) + sizeof(UDP_HDR) + length); + IPheader.ip_ttl = 8; // Time-to-live is eight + IPheader.ip_protocol = IPPROTO_UDP; + IPheader.ip_srcaddr = inet_addr(in_ip); + IPheader.ip_destaddr = inet_addr(in_ip); + IPheader.ip_checksum = checksum((unsigned short *)&IPheader, sizeof(IPV4_HDR)); + // Initialize the UDP header + UDP_HDR UDPheader; + UDPheader.src_portno = htons( PACKET_MAC_LTE_DEFAULT_UDP_PORT); + UDPheader.dst_portno = htons( PACKET_MAC_LTE_DEFAULT_UDP_PORT); + UDPheader.udp_length = htons(sizeof(UDP_HDR) + length); + UDPheader.udp_checksum = 0; + /****************************************************************/ + /* PCAP Header */ + /* TODO: Timestamp might want to be relative to a more sensible + base time... */ + struct timeval tv; + gettimeofday(&tv, NULL); + packet_header.ts_sec = tv.tv_sec; + packet_header.ts_usec = tv.tv_usec; + packet_header.incl_len =sizeof(IPV4_HDR) + sizeof(UDP_HDR) + length; + packet_header.orig_len =sizeof(IPV4_HDR) + sizeof(UDP_HDR) + length; + /***************************************************************/ + /* Now write everything to the file */ + fwrite(&packet_header, sizeof(pcaprec_hdr_t), 1, file_fd); + fwrite(&IPheader, sizeof(IPV4_HDR), 1, file_fd); + fwrite(&UDPheader, sizeof(UDP_HDR), 1, file_fd); + fwrite(PDU, 1, length, file_fd); + fflush(file_fd); + return length; +} static void *opt_listener_thread(void *arg) { ssize_t ret; @@ -198,7 +273,6 @@ int opt_create_listener_socket(char *ip_address, uint16_t port) { } threadCreate(&opt_listener.thread, opt_listener_thread, NULL, "flexran", -1, OAI_PRIORITY_RT_LOW); - return 0; } @@ -321,67 +395,20 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType, frameOffset += pdu_buffer_size; } - /* Send out the data over the UDP socket */ - bytesSent = sendto(g_socksd, frameBuffer, frameOffset, 0, - (const struct sockaddr *)&g_serv_addr, sizeof(g_serv_addr)); + if ( opt_type == OPT_WIRESHARK ) + /* Send out the data over the UDP socket */ + bytesSent = sendto(g_socksd, frameBuffer, frameOffset, 0, + (const struct sockaddr *)&g_serv_addr, sizeof(g_serv_addr)); + else + bytesSent = MAC_LTE_PCAP_WritePDU(frameBuffer, frameOffset); if (bytesSent != frameOffset) { - LOG_W(OPT, "sendto() failed (not a thread-safe func)- expected %d bytes, got %ld (errno=%d)\n", + LOG_W(OPT, "trace_pdu expected %d bytes, got %ld (errno=%d)\n", frameOffset, bytesSent, errno); //exit(1); } } -/* Write an individual PDU (PCAP packet header + mac-context + mac-pdu) */ -static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context, - const uint8_t *PDU, - unsigned int length) -{ - pcaprec_hdr_t packet_header; - uint8_t context_header[256]; - int offset = 0; - unsigned short tmp16; - /*****************************************************************/ - /* Context information (same as written by UDP heuristic clients */ - context_header[offset++] = context->radioType; - context_header[offset++] = context->direction; - context_header[offset++] = context->rntiType; - /* RNTI */ - context_header[offset++] = MAC_LTE_RNTI_TAG; - tmp16 = htons(context->rnti); - memcpy(context_header+offset, &tmp16, 2); - offset += 2; - /* UEId */ - context_header[offset++] = MAC_LTE_UEID_TAG; - tmp16 = htons(context->ueid); - memcpy(context_header+offset, &tmp16, 2); - offset += 2; - /* Subframe number */ - context_header[offset++] = MAC_LTE_FRAME_SUBFRAME_TAG; - tmp16 = htons(context->subFrameNumber); - memcpy(context_header+offset, &tmp16, 2); - offset += 2; - /* CRC Status */ - context_header[offset++] = MAC_LTE_CRC_STATUS_TAG; - context_header[offset++] = context->crcStatusOK; - /* Data tag immediately preceding PDU */ - context_header[offset++] = MAC_LTE_PAYLOAD_TAG; - /****************************************************************/ - /* PCAP Header */ - /* TODO: Timestamp might want to be relative to a more sensible - base time... */ - packet_header.ts_sec = context->subframesSinceCaptureStart / 1000; - packet_header.ts_usec = (context->subframesSinceCaptureStart % 1000) * 1000; - packet_header.incl_len = offset + length; - packet_header.orig_len = offset + length; - /***************************************************************/ - /* Now write everything to the file */ - fwrite(&packet_header, sizeof(pcaprec_hdr_t), 1, file_fd); - fwrite(context_header, 1, offset, file_fd); - fwrite(PDU, 1, length, file_fd); - return 1; -} - #include extern RAN_CONTEXT_t RC; #include @@ -389,7 +416,6 @@ extern RAN_CONTEXT_t RC; void trace_pdu_implementation(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, int ueid, int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event, int oob_event_value) { - MAC_Context_Info_t pdu_context; int radioType=FDD_RADIO; LOG_D(OPT,"sending packet to wireshark: direction=%s, size: %d, ueid: %d, rnti: %x, frame/sf: %d.%d\n", direction?"DL":"UL", pdu_buffer_size, ueid, rnti, sysFrameNumber,subFrameNumber); @@ -405,53 +431,41 @@ void trace_pdu_implementation(int direction, uint8_t *pdu_buffer, unsigned int p switch (opt_type) { case OPT_WIRESHARK : - if (g_socksd == -1) { + if (g_socksd == -1) return; - } - SendFrame( radioType, - (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK, - rntiType, rnti, ueid, (sysFrameNumber<<4) + subFrameNumber, - 1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus - oob_event,oob_event_value, - pdu_buffer, pdu_buffer_size); break; case OPT_PCAP: - if (file_fd == NULL) { + if (file_fd == NULL) return; - } - pdu_context.radioType = radioType; - pdu_context.direction = (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK - : DIRECTION_UPLINK; - pdu_context.rntiType = rntiType; - pdu_context.rnti = rnti; - pdu_context.ueid = ueid; - pdu_context.isRetx = 0; - pdu_context.crcStatusOK =1; - pdu_context.sysFrameNumber = sysFrameNumber; - pdu_context.subFrameNumber = subFrameNumber; - pdu_context.subframesSinceCaptureStart = subframesSinceCaptureStart++; - MAC_LTE_PCAP_WritePDU( &pdu_context, pdu_buffer, pdu_buffer_size); break; case OPT_TSHARK: default: + return; break; } + + SendFrame( radioType, + (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK, + rntiType, rnti, ueid, (sysFrameNumber<<4) + subFrameNumber, + 1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus + oob_event,oob_event_value, + pdu_buffer, pdu_buffer_size); } + /*---------------------------------------------------*/ -int init_opt(void) -{ - char *in_type=NULL; +int init_opt(void) { + in_type=malloc(200); + in_ip=malloc(200); + in_path=malloc(200); paramdef_t opt_params[] = OPT_PARAMS_DESC ; checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC; - uint16_t in_port=0; config_set_checkfunctions(opt_params, opt_checkParams, sizeof(opt_params)/sizeof(paramdef_t)); config_get( opt_params,sizeof(opt_params)/sizeof(paramdef_t),OPT_CONFIGPREFIX); - subframesSinceCaptureStart = 0; int tmptype = config_get_processedint( &(opt_params[OPTTYPE_IDX])); @@ -472,15 +486,13 @@ int init_opt(void) config_printhelp(opt_params,sizeof(opt_params)/sizeof(paramdef_t),OPT_CONFIGPREFIX); } - in_port = PACKET_MAC_LTE_DEFAULT_UDP_PORT; - // trace_mode switch (opt_type) { case OPT_WIRESHARK: /* Create local server socket only if using localhost address */ if (strcmp(in_ip, "127.0.0.1") == 0) { - opt_create_listener_socket(in_ip, in_port); + opt_create_listener_socket(in_ip, PACKET_MAC_LTE_DEFAULT_UDP_PORT); } g_socksd = socket(AF_INET, SOCK_DGRAM, 0); @@ -493,7 +505,7 @@ int init_opt(void) /* Get remote IP address from the function argument */ g_serv_addr.sin_family = AF_INET; - g_serv_addr.sin_port = htons(in_port); + g_serv_addr.sin_port = htons(PACKET_MAC_LTE_DEFAULT_UDP_PORT); g_serv_addr.sin_addr.s_addr = inet_addr(in_ip); break; @@ -521,7 +533,7 @@ int init_opt(void) } if ( opt_type == OPT_WIRESHARK ) - LOG_E(OPT,"mode Wireshark: ip %s port %d\n", in_ip, in_port); + LOG_E(OPT,"mode Wireshark: ip %s port %d\n", in_ip, PACKET_MAC_LTE_DEFAULT_UDP_PORT); else if (opt_type == OPT_PCAP) LOG_E(OPT,"mode PCAB : path is %s \n",in_path); else diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index a84d8db4f8..927b65c74c 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -310,7 +310,7 @@ typedef struct __attribute__((packed)) { } authenticationrequestHeader_t; -typedef struct { +typedef struct __attribute__((packed){ Extendedprotocoldiscriminator_t epd:8; Security_header_t sh:8; SGSmobilitymanagementmessages_t mt:8; @@ -321,6 +321,26 @@ typedef struct { //AUTHENTICATION RESULT +typedef struct __attribute__((packed)) { + Extendedprotocoldiscriminator_t epd:8; + Security_header_t sh:8; + SGSmobilitymanagementmessages_t mt:8; + + unsigned int selectedNASsecurityalgorithms; + unsigned int ngKSI:4; //ngKSI NAS key set identifier 9.11.3.32 + unsigned int spare:4; + // LV 3-9 bytes Replayed UE security capabilities UE security capability 9.11.3.54 + + /* optional + TV (E-, 1 byte) Oprional IMEISV request IMEISV request 9.11.3.28 + TV (57, 2 bytes ) Selected EPS NAS security algorithms EPS NAS security algorithms 9.11.3.25 + TLV (36, 3 bytes) Additional 5G security information Additional 5G security information 9.11.3.12 + TLV-E (78,, 7-1503 bytes) EAP message EAP message 9.11.2.2 + TLV (38, 4-n)ABBA ABBA 9.11.3.10 + TLV (19, 4-7) Replayed S1 UE security capabilities S1 UE security capability 9.11.3.48A + */ + +} securityModeCommand_t; typedef struct { uicc_t *uicc; diff --git a/openair3/NAS/gNB/network_process_nas.c b/openair3/NAS/gNB/network_process_nas.c index bdfa2183d6..a878d7c8a4 100644 --- a/openair3/NAS/gNB/network_process_nas.c +++ b/openair3/NAS/gNB/network_process_nas.c @@ -59,6 +59,7 @@ void SGSauthenticationResp(void *msg, NRUEcontext_t *UE) { } void SGSsecurityModeComplete(void *msg, NRUEcontext_t *UE) { + } void SGSregistrationComplete(void *msg, NRUEcontext_t *UE) { @@ -171,5 +172,20 @@ int authenticationRequest(void **msg, NRUEcontext_t *UE) { int securityModeCommand(void **msg, NRUEcontext_t *UE) { *msg=NULL; + myCalloc(req, securityModeCommand_t); + req->epd=SGSmobilitymanagementmessages; + req->sh=0; + req->mt=Securitymodecommand; + + // integrity algo from 5G-IA0 (null algo) to 5G-IA7 in first 4 bits + unsigned int ia=0; + // cyphering algo from 5G-EA0 (null algo) to 5G-IA7 in MSB 4 bits + unsigned int ea=0; + // trace from commercial: 5G-IA0 (0) 128-5G-IA2 (2) + req->selectedNASsecurityalgorithms= ea<<4 | ia; + + // KSI: N-NAS-int-alg 0x02 + req->ngKSI=2; + return 0; } From 6b50cbcae277f1e4d55de0c53a01fd086ba70418 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 1 Oct 2020 16:13:03 +0200 Subject: [PATCH 046/149] continue 5G SA --- .../gnb.band78.tm1.fr1.106PRB.usrpb210.conf | 12 +- cmake_targets/CMakeLists.txt | 1 + executables/ocp-gnb.c | 4 +- openair1/PHY/TOOLS/lte_enb_scope.c | 2 +- openair1/PHY/TOOLS/lte_phy_scope.c | 188 +++++++----------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- openair2/RRC/NR/nr_rrc_gNB.c | 31 ++- openair2/RRC/NR/nr_rrc_proto.h | 2 +- openair2/UTIL/OPT/probe.c | 21 +- openair3/NAS/COMMON/NR_NAS_defs.h | 2 +- 10 files changed, 110 insertions(+), 155 deletions(-) diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index a2d3d1d63c..be8fb0ddaf 100755 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -199,7 +199,7 @@ gNBs = ////////// MME parameters: - mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + mme_ip_address = ( { ipv4 = "127.0.0.20"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; @@ -211,7 +211,7 @@ gNBs = t_reloc_prep = 1000; /* unit: millisecond */ tx2_reloc_overall = 2000; /* unit: millisecond */ target_enb_x2_ip_address = ( - { ipv4 = "CI_FR1_CTL_ENB_IP_ADDR"; + { ipv4 = "127.0.0.10"; ipv6 = "192:168:30::17"; preference = "ipv4"; } @@ -221,11 +221,11 @@ gNBs = { GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1_MME = "CI_GNB_IP_ADDR"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.10"; GNB_INTERFACE_NAME_FOR_S1U = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1U = "CI_GNB_IP_ADDR"; + GNB_IPV4_ADDRESS_FOR_S1U = "127.0.0.10"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 - GNB_IPV4_ADDRESS_FOR_X2C = "CI_GNB_IP_ADDR"; + GNB_IPV4_ADDRESS_FOR_X2C = "127.0.0.10"; GNB_PORT_FOR_X2C = 36422; # Spec 36422 }; } @@ -257,7 +257,7 @@ RUs = ( max_pdschReferenceSignalPower = -27; max_rxgain = 114; eNB_instances = [0]; - clock_src = "external"; + clock_src = "internal"; } ); diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index e68b3b0716..5fbd585409 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -377,6 +377,7 @@ add_custom_target ( add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source} ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c + ${OPENAIR2_DIR}/RRC/NR/nr_rrc_gNB.c ) add_dependencies(NR_RRC_LIB nr_rrc_flag) include_directories ("${NR_RRC_FULL_DIR}") diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index b4f651b908..723b0d8f35 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -436,7 +436,7 @@ void OCPconfig_RU(RU_t *ru) { if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { - ru->if_south = LOCAL_RF; + ru->if_south = REMOTE_IF5; //TBD: max value to avoid to call "ru" functions ru->function = gNodeB_3GPP; printf("Setting function for RU %d to gNodeB_3GPP\n",j); } else { @@ -472,7 +472,7 @@ void OCPconfig_RU(RU_t *ru) { // this is for RU with local RF unit void fill_rf_config(RU_t *ru, char *rf_config_file) { int i; - NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; nfapi_nr_config_request_scf_t *gNB_config = &ru->gNB_list[0]->gNB_config; //tmp index openair0_config_t *cfg = &ru->openair0_cfg; int mu = gNB_config->ssb_config.scs_common.value; diff --git a/openair1/PHY/TOOLS/lte_enb_scope.c b/openair1/PHY/TOOLS/lte_enb_scope.c index b2c6bd909f..19e135ae56 100644 --- a/openair1/PHY/TOOLS/lte_enb_scope.c +++ b/openair1/PHY/TOOLS/lte_enb_scope.c @@ -97,7 +97,7 @@ static void *scope_thread_eNB(void *arg) { } } - sleep(1); + usleep(100*1000); } // printf("%s",stats_buffer); diff --git a/openair1/PHY/TOOLS/lte_phy_scope.c b/openair1/PHY/TOOLS/lte_phy_scope.c index 8621898d9d..deef165d4f 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.c +++ b/openair1/PHY/TOOLS/lte_phy_scope.c @@ -37,9 +37,12 @@ float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue_max[NUMBER_OF_UE_MAX] = {0}; -static void ia_receiver_on_off( FL_OBJECT *button, long arg) -{ +void drawsymbol(FL_OBJECT *obj, int id, + FL_POINT *p, int n, int w, int h) { + fl_points( p, n, FL_YELLOW); +} +static void ia_receiver_on_off( FL_OBJECT *button, long arg) { if (fl_get_button(button)) { fl_set_object_label(button, "IA Receiver ON"); // PHY_vars_UE_g[0][0]->use_ia_receiver = 1; @@ -51,9 +54,7 @@ static void ia_receiver_on_off( FL_OBJECT *button, long arg) } } -static void dl_traffic_on_off( FL_OBJECT *button, long arg) -{ - +static void dl_traffic_on_off( FL_OBJECT *button, long arg) { if (fl_get_button(button)) { fl_set_object_label(button, "DL Traffic ON"); otg_enabled = 1; @@ -65,46 +66,38 @@ static void dl_traffic_on_off( FL_OBJECT *button, long arg) } } -FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void ) -{ - +FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void ) { FL_OBJECT *obj; FD_lte_phy_scope_enb *fdui = fl_malloc( sizeof *fdui ); - // Define form fdui->lte_phy_scope_enb = fl_bgn_form( FL_NO_BOX, 800, 800 ); - // This the whole UI box obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 800, "" ); fl_set_object_color( obj, FL_BLACK, FL_BLACK ); - // Received signal fdui->rxsig_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 20, 370, 100, "Received Signal (Time-Domain, dB)" ); fl_set_object_boxtype( fdui->rxsig_t, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->rxsig_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->rxsig_t, FL_WHITE ); // Label color fl_set_xyplot_ybounds(fdui->rxsig_t,10,70); - // Time-domain channel response fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "SRS Frequency Response (samples, abs)" ); fl_set_object_boxtype( fdui->chest_t, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_t, FL_WHITE ); // Label color - // Frequency-domain channel response fdui->chest_f = fl_add_xyplot( FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency Response (RE, dB)" ); fl_set_object_boxtype( fdui->chest_f, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_f, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_f, FL_WHITE ); // Label color fl_set_xyplot_ybounds( fdui->chest_f,30,70); - // LLR of PUSCH fdui->pusch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 260, 500, 200, "PUSCH Log-Likelihood Ratios (LLR, mag)" ); fl_set_object_boxtype( fdui->pusch_llr, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pusch_llr, FL_BLACK, FL_YELLOW ); fl_set_object_lcolor( fdui->pusch_llr, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pusch_llr,2); - + fl_set_xyplot_symbol(fdui->pusch_llr, 0, drawsymbol); // I/Q PUSCH comp fdui->pusch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 260, 240, 200, "PUSCH I/Q of MF Output" ); fl_set_object_boxtype( fdui->pusch_comp, FL_EMBOSSED_BOX ); @@ -112,7 +105,7 @@ FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void ) fl_set_object_lcolor( fdui->pusch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pusch_comp,2); fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR); - + fl_set_xyplot_symbol(fdui->pusch_comp, 0, drawsymbol); // I/Q PUCCH comp (format 1) fdui->pucch_comp1 = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 480, 240, 100, "PUCCH1 Energy (SR)" ); fl_set_object_boxtype( fdui->pucch_comp1, FL_EMBOSSED_BOX ); @@ -120,7 +113,7 @@ FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void ) fl_set_object_lcolor( fdui->pucch_comp1, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pucch_comp1,2); // fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR); - + fl_set_xyplot_symbol(fdui->pucch_comp1, 0, drawsymbol); // I/Q PUCCH comp (fromat 1a/b) fdui->pucch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 600, 240, 100, "PUCCH I/Q of MF Output" ); fl_set_object_boxtype( fdui->pucch_comp, FL_EMBOSSED_BOX ); @@ -128,13 +121,12 @@ FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void ) fl_set_object_lcolor( fdui->pucch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pucch_comp,2); // fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR); - + fl_set_xyplot_symbol(fdui->pucch_comp, 0, drawsymbol); // Throughput on PUSCH fdui->pusch_tput = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 480, 500, 100, "PUSCH Throughput [frame]/[kbit/s]" ); fl_set_object_boxtype( fdui->pusch_tput, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pusch_tput, FL_BLACK, FL_WHITE ); fl_set_object_lcolor( fdui->pusch_tput, FL_WHITE ); // Label color - // Generic eNB Button fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 20, 600, 240, 40, "" ); fl_set_object_lalign(fdui->button_0, FL_ALIGN_CENTER ); @@ -143,18 +135,16 @@ FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void ) fl_set_object_label(fdui->button_0, "DL Traffic OFF"); fl_set_object_color(fdui->button_0, FL_RED, FL_RED); fl_set_object_callback(fdui->button_0, dl_traffic_on_off, 0 ); - fl_end_form( ); fdui->lte_phy_scope_enb->fdui = fdui; - return fdui; } void phy_scope_eNB(FD_lte_phy_scope_enb *form, PHY_VARS_eNB *phy_vars_enb, - int UE_id) -{ - + int UE_id) { + LOG_D(HW,"scope for UE%d\n", UE_id); + int eNB_id = 0; int i,i2,arx,atx,ind,k; LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_enb->frame_parms; int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti; @@ -192,20 +182,18 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form, } coded_bits_per_codeword = frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti; - - chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float)); - llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero + chest_f_abs = (float *) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float)); + llr = (float *) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero bit = malloc(coded_bits_per_codeword*sizeof(float)); rxsig_t = (int16_t**) phy_vars_enb->RU_list[0]->common.rxdata; - //chest_t = (int16_t**) phy_vars_enb->pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id]; - chest_t = (int16_t**) phy_vars_enb->srs_vars[UE_id].srs_ch_estimates; - chest_f = (int16_t**) phy_vars_enb->pusch_vars[UE_id]->drs_ch_estimates; - pusch_llr = (int16_t*) phy_vars_enb->pusch_vars[UE_id]->llr; - pusch_comp = (int32_t*) phy_vars_enb->pusch_vars[UE_id]->rxdataF_comp[0]; - pucch1_comp = (int32_t*) phy_vars_enb->pucch1_stats[UE_id]; - pucch1_thres = (int32_t*) phy_vars_enb->pucch1_stats_thres[UE_id]; - pucch1ab_comp = (int32_t*) phy_vars_enb->pucch1ab_stats[UE_id]; + chest_t = (int16_t **) phy_vars_enb->srs_vars[UE_id].srs_ch_estimates; + chest_f = (int16_t **) phy_vars_enb->pusch_vars[UE_id]->drs_ch_estimates; + pusch_llr = (int16_t *) phy_vars_enb->pusch_vars[UE_id]->llr; + pusch_comp = (int32_t *) phy_vars_enb->pusch_vars[UE_id]->rxdataF_comp[0]; + pucch1_comp = (int32_t *) phy_vars_enb->pucch1_stats[UE_id]; + pucch1_thres = (int32_t *) phy_vars_enb->pucch1_stats_thres[UE_id]; + pucch1ab_comp = (int32_t *) phy_vars_enb->pucch1ab_stats[UE_id]; // Received signal in time domain of receive antenna 0 if (rxsig_t != NULL) { @@ -236,7 +224,7 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form, if (chest_t[0] !=NULL) { for (i=0; i<(frame_parms->ofdm_symbol_size); i++) { //i2 = (i+(frame_parms->ofdm_symbol_size>>1))%frame_parms->ofdm_symbol_size; - i2=i; + i2=i; //time2[i] = (float)(i-(frame_parms->ofdm_symbol_size>>1)); time2[i] = (float)i; chest_t_abs[0][i] = 10*log10((float) (1+chest_t[0][2*i2]*chest_t[0][2*i2]+chest_t[0][2*i2+1]*chest_t[0][2*i2+1])); @@ -278,7 +266,6 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form, freq[ind] = (float)ind; Re = (float)(chest_f[(atx<<1)+arx][(2*k)]); Im = (float)(chest_f[(atx<<1)+arx][(2*k)+1]); - chest_f_abs[ind] = (short)10*log10(1.0+((double)Re*Re + (double)Im*Im)); ind++; } @@ -333,9 +320,9 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form, pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i] < range && pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1] > -range && pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1] < range ) { - I[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i]; - Q[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1]; - ind++; + I[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i]; + Q[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1]; + ind++; } } } @@ -346,75 +333,62 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form, // PUSCH I/Q of MF Output if (pucch1ab_comp!=NULL) { for (ind=0; ind<10240; ind++) { - I_pucch[ind] = (float)pucch1ab_comp[2*(ind)]; Q_pucch[ind] = (float)pucch1ab_comp[2*(ind)+1]; A_pucch[ind] = 10*log10(pucch1_comp[ind]); B_pucch[ind] = ind; C_pucch[ind] = (float)pucch1_thres[ind]; } + fl_set_xyplot_data(form->pucch_comp,I_pucch,Q_pucch,10240,"","",""); fl_set_xyplot_data(form->pucch_comp1,B_pucch,A_pucch,1024,"","",""); fl_add_xyplot_overlay(form->pucch_comp1,1,B_pucch,C_pucch,1024,FL_RED); fl_set_xyplot_ybounds(form->pucch_comp,-5000,5000); fl_set_xyplot_xbounds(form->pucch_comp,-5000,5000); - fl_set_xyplot_ybounds(form->pucch_comp1,0,80); } - // PUSCH Throughput memmove( tput_time_enb[UE_id], &tput_time_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) ); memmove( tput_enb[UE_id], &tput_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) ); - tput_time_enb[UE_id][TPUT_WINDOW_LENGTH-1] = (float) frame; tput_enb[UE_id][TPUT_WINDOW_LENGTH-1] = ((float) total_dlsch_bitrate)/1000.0; - fl_set_xyplot_data(form->pusch_tput,tput_time_enb[UE_id],tput_enb[UE_id],TPUT_WINDOW_LENGTH,"","",""); - // fl_get_xyplot_ybounds(form->pusch_tput,&ymin,&ymax); // fl_set_xyplot_ybounds(form->pusch_tput,0,ymax); - fl_check_forms(); - free(llr); free(bit); free(chest_f_abs); } -FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) -{ - +FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) { FL_OBJECT *obj; FD_lte_phy_scope_ue *fdui = fl_malloc( sizeof *fdui ); - // Define form fdui->lte_phy_scope_ue = fl_bgn_form( FL_NO_BOX, 800, 900 ); - // This the whole UI box obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 900, "" ); fl_set_object_color( obj, FL_BLACK, FL_BLACK ); - // Received signal fdui->rxsig_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 20, 370, 100, "Received Signal (Time-Domain, dB)" ); fl_set_object_boxtype( fdui->rxsig_t, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->rxsig_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->rxsig_t, FL_WHITE ); // Label color fl_set_xyplot_ybounds(fdui->rxsig_t,10,70); - + fl_set_xyplot_symbol(fdui->rxsig_t, 0, drawsymbol); // Time-domain channel response fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "Channel Impulse Response (samples, abs)" ); fl_set_object_boxtype( fdui->chest_t, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_t, FL_WHITE ); // Label color - + fl_set_xyplot_symbol(fdui->chest_t, 0, drawsymbol); // Frequency-domain channel response fdui->chest_f = fl_add_xyplot( FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency Response (RE, dB)" ); fl_set_object_boxtype( fdui->chest_f, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_f, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_f, FL_WHITE ); // Label color fl_set_xyplot_ybounds( fdui->chest_f,30,70); - // LLR of PBCH fdui->pbch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 260, 500, 100, "PBCH Log-Likelihood Ratios (LLR, mag)" ); fl_set_object_boxtype( fdui->pbch_llr, FL_EMBOSSED_BOX ); @@ -423,23 +397,23 @@ FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) fl_set_xyplot_symbolsize( fdui->pbch_llr,2); fl_set_xyplot_xgrid( fdui->pbch_llr,FL_GRID_MAJOR); fl_set_xyplot_xbounds( fdui->pbch_llr,0,1920); - + fl_set_xyplot_symbol(fdui->pbch_llr, 0, drawsymbol); // I/Q PBCH comp fdui->pbch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 260, 240, 100, "PBCH I/Q of MF Output" ); fl_set_object_boxtype( fdui->pbch_comp, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pbch_comp, FL_BLACK, FL_GREEN ); fl_set_object_lcolor( fdui->pbch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pbch_comp,2); + fl_set_xyplot_symbol(fdui->pbch_comp, 0, drawsymbol); // fl_set_xyplot_xbounds( fdui->pbch_comp,-100,100); // fl_set_xyplot_ybounds( fdui->pbch_comp,-100,100); - // LLR of PDCCH fdui->pdcch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 380, 500, 100, "PDCCH Log-Likelihood Ratios (LLR, mag)" ); fl_set_object_boxtype( fdui->pdcch_llr, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pdcch_llr, FL_BLACK, FL_CYAN ); fl_set_object_lcolor( fdui->pdcch_llr, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pdcch_llr,2); - + fl_set_xyplot_symbol(fdui->pdcch_llr, 0, drawsymbol); // I/Q PDCCH comp fdui->pdcch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 380, 240, 100, "PDCCH I/Q of MF Output" ); fl_set_object_boxtype( fdui->pdcch_comp, FL_EMBOSSED_BOX ); @@ -447,7 +421,7 @@ FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) fl_set_object_lcolor( fdui->pdcch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pdcch_comp,2); fl_set_xyplot_xgrid( fdui->pdcch_llr,FL_GRID_MAJOR); - + fl_set_xyplot_symbol(fdui->pdcch_comp, 0, drawsymbol); // LLR of PDSCH fdui->pdsch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 500, 500, 200, "PDSCH Log-Likelihood Ratios (LLR, mag)" ); fl_set_object_boxtype( fdui->pdsch_llr, FL_EMBOSSED_BOX ); @@ -455,20 +429,19 @@ FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) fl_set_object_lcolor( fdui->pdsch_llr, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pdsch_llr,2); fl_set_xyplot_xgrid( fdui->pdsch_llr,FL_GRID_MAJOR); - + fl_set_xyplot_symbol(fdui->pdsch_llr, 0, drawsymbol); // I/Q PDSCH comp fdui->pdsch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 500, 240, 200, "PDSCH I/Q of MF Output" ); fl_set_object_boxtype( fdui->pdsch_comp, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pdsch_comp, FL_BLACK, FL_YELLOW ); fl_set_object_lcolor( fdui->pdsch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pdsch_comp,2); - + fl_set_xyplot_symbol(fdui->pdsch_comp, 0, drawsymbol); // Throughput on PDSCH fdui->pdsch_tput = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 720, 500, 100, "PDSCH Throughput [frame]/[kbit/s]" ); fl_set_object_boxtype( fdui->pdsch_tput, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pdsch_tput, FL_BLACK, FL_WHITE ); fl_set_object_lcolor( fdui->pdsch_tput, FL_WHITE ); // Label color - // Generic UE Button fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 540, 720, 240, 40, "" ); fl_set_object_lalign(fdui->button_0, FL_ALIGN_CENTER ); @@ -478,10 +451,8 @@ FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) fl_set_object_color(fdui->button_0, FL_RED, FL_RED); fl_set_object_callback(fdui->button_0, ia_receiver_on_off, 0 ); fl_hide_object(fdui->button_0); - fl_end_form( ); fdui->lte_phy_scope_ue->fdui = fdui; - return fdui; } @@ -489,8 +460,7 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, PHY_VARS_UE *phy_vars_ue, int eNB_id, int UE_id, - uint8_t subframe) -{ + uint8_t subframe) { int i,arx,atx,ind,k; LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->frame_parms; int nsymb_ce = frame_parms->ofdm_symbol_size;//*frame_parms->symbols_per_tti; @@ -521,7 +491,6 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, unsigned char harq_pid = 0; int beamforming_mode = phy_vars_ue->transmission_mode[eNB_id]>6 ? phy_vars_ue->transmission_mode[eNB_id] : 0; - if (phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]!=NULL) { harq_pid = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]->current_harq_pid; @@ -556,34 +525,32 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, coded_bits_per_codeword = 0; //frame_parms->N_RB_DL*12*get_Qm(mcs)*(frame_parms->symbols_per_tti); } - I = (float*) calloc(frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*2,sizeof(float)); - Q = (float*) calloc(frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*2,sizeof(float)); - chest_t_abs = (float**) malloc(nb_antennas_rx*sizeof(float*)); + I = (float *) calloc(frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*2,sizeof(float)); + Q = (float *) calloc(frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*2,sizeof(float)); + chest_t_abs = (float **) malloc(nb_antennas_rx*sizeof(float *)); for (arx=0; arxofdm_symbol_size,sizeof(float)); + chest_t_abs[arx] = (float *) calloc(frame_parms->ofdm_symbol_size,sizeof(float)); } - chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float)); + chest_f_abs = (float *) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float)); //llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // Cppcheck returns "invalidFunctionArg" error. - llr = (float*) malloc(coded_bits_per_codeword*sizeof(float)); + llr = (float *) malloc(coded_bits_per_codeword*sizeof(float)); memset((void *)llr, 0,coded_bits_per_codeword*sizeof(float)); // init to zero - bit = malloc(coded_bits_per_codeword*sizeof(float)); - llr_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); // init to zero - bit_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); - - rxsig_t = (int16_t**) phy_vars_ue->common_vars.rxdata; - chest_t = (int16_t**) phy_vars_ue->common_vars.common_vars_rx_data_per_thread[phy_vars_ue->current_thread_id[subframe]].dl_ch_estimates_time[eNB_id]; - chest_f = (int16_t**) phy_vars_ue->common_vars.common_vars_rx_data_per_thread[phy_vars_ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id]; - pbch_llr = (int8_t*) phy_vars_ue->pbch_vars[eNB_id]->llr; - pbch_comp = (int16_t*) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; - pdcch_llr = (int8_t*) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr; - pdcch_comp = (int16_t*) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp[0]; - pdsch_llr = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; // stream 0 + llr_pdcch = (float *) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); // init to zero + bit_pdcch = (float *) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); + rxsig_t = (int16_t **) phy_vars_ue->common_vars.rxdata; + chest_t = (int16_t **) phy_vars_ue->common_vars.common_vars_rx_data_per_thread[phy_vars_ue->current_thread_id[subframe]].dl_ch_estimates_time[eNB_id]; + chest_f = (int16_t **) phy_vars_ue->common_vars.common_vars_rx_data_per_thread[phy_vars_ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id]; + pbch_llr = (int8_t *) phy_vars_ue->pbch_vars[eNB_id]->llr; + pbch_comp = (int16_t *) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; + pdcch_llr = (int8_t *) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr; + pdcch_comp = (int16_t *) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp[0]; + pdsch_llr = (int16_t *) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; // stream 0 //pdsch_llr = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars_SI[eNB_id]->llr[0]; // stream 0 - pdsch_comp = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp0[0]; - pdsch_mag = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->dl_ch_mag0[0]; + pdsch_comp = (int16_t *) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp0[0]; + pdsch_mag = (int16_t *) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->dl_ch_mag0[0]; // Received signal in time domain of receive antenna 0 if (rxsig_t != NULL) { @@ -652,7 +619,6 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, freq[ind] = (float)ind; Re = (float)(chest_f[(atx<<1)+arx][(2*k)]); Im = (float)(chest_f[(atx<<1)+arx][(2*k)+1]); - chest_f_abs[ind] = (short)10*log10(1.0+((double)Re*Re + (double)Im*Im)); ind++; } @@ -715,13 +681,11 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, } fl_set_xyplot_xbounds(form->pdcch_llr,0,12*frame_parms->N_RB_DL*2*3); - if (frame_parms->N_RB_DL != 100) - { - fl_set_xyplot_data(form->pdcch_llr,bit_pdcch,llr_pdcch,12*frame_parms->N_RB_DL*2*num_pdcch_symbols,"","",""); - } - else - { - LOG_D(PHY,"UE PDCCH LLR plot is bugged in 20 MHz BW, to be fixed !!!\n"); + + if (frame_parms->N_RB_DL != 100) { + fl_set_xyplot_data(form->pdcch_llr,bit_pdcch,llr_pdcch,12*frame_parms->N_RB_DL*2*num_pdcch_symbols,"","",""); + } else { + LOG_D(PHY,"UE PDCCH LLR plot is bugged in 20 MHz BW, to be fixed !!!\n"); } } @@ -731,13 +695,11 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, I[i] = pdcch_comp[2*i]; Q[i] = pdcch_comp[2*i+1]; } - if (frame_parms->N_RB_DL != 100) - { - fl_set_xyplot_data(form->pdcch_comp,I,Q,12*frame_parms->N_RB_DL*num_pdcch_symbols,"","",""); - } - else - { - LOG_D(PHY,"UE PDCCH COMP plot is bugged in 20 MHz BW, to be fixed !!!\n"); + + if (frame_parms->N_RB_DL != 100) { + fl_set_xyplot_data(form->pdcch_comp,I,Q,12*frame_parms->N_RB_DL*num_pdcch_symbols,"","",""); + } else { + LOG_D(PHY,"UE PDCCH COMP plot is bugged in 20 MHz BW, to be fixed !!!\n"); } } @@ -749,13 +711,11 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, } fl_set_xyplot_xbounds(form->pdsch_llr,0,coded_bits_per_codeword); - if (frame_parms->N_RB_DL != 100) - { - fl_set_xyplot_data(form->pdsch_llr,bit,llr,coded_bits_per_codeword,"","",""); - } - else - { - LOG_D(PHY,"UE PDSCH LLR plot is bugged in 20 MHz BW, to be fixed !!!\n"); + + if (frame_parms->N_RB_DL != 100) { + fl_set_xyplot_data(form->pdsch_llr,bit,llr,coded_bits_per_codeword,"","",""); + } else { + LOG_D(PHY,"UE PDSCH LLR plot is bugged in 20 MHz BW, to be fixed !!!\n"); } } @@ -765,7 +725,7 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, for (k=0; ksymbols_per_tti; k++) { for (i=0; i<12*frame_parms->N_RB_DL/2; i++) { - int j = (2*frame_parms->N_RB_DL*12*k)+4*i; + int j = (2*frame_parms->N_RB_DL*12*k)+4*i; I[ind] = (pdsch_mag[j ]!=0? 1.0/pdsch_mag[j ]: 0.0) * pdsch_comp[j ]*1.0; Q[ind] = (pdsch_mag[j+1]!=0? 1.0/pdsch_mag[j+1]: 0.0) * pdsch_comp[j+1]*1.0; ind++; @@ -778,7 +738,6 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, // PDSCH Throughput memmove( tput_time_ue[UE_id], &tput_time_ue[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) ); memmove( tput_ue[UE_id], &tput_ue[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) ); - tput_time_ue[UE_id][TPUT_WINDOW_LENGTH-1] = (float) frame; tput_ue[UE_id][TPUT_WINDOW_LENGTH-1] = ((float) total_dlsch_bitrate)/1000.0; @@ -787,11 +746,8 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, } fl_set_xyplot_data(form->pdsch_tput,tput_time_ue[UE_id],tput_ue[UE_id],TPUT_WINDOW_LENGTH,"","",""); - fl_set_xyplot_ybounds(form->pdsch_tput,0,tput_ue_max[UE_id]); - fl_check_forms(); - free(I); free(Q); free(chest_f_abs); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 842ede6711..234fccddfa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -442,7 +442,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN); pdcp_run(&ctxt); - //rrc_rx_tx(&ctxt, CC_id); + nr_rrc_rx_tx(); //&ctxt, CC_id); /* send tick to RLC every ms */ if ((slot & ((1 << *scc->ssbSubcarrierSpacing) - 1)) == 0) { void nr_rlc_tick(int frame, int subframe); diff --git a/openair2/RRC/NR/nr_rrc_gNB.c b/openair2/RRC/NR/nr_rrc_gNB.c index 4f16683d71..0d4892bb88 100644 --- a/openair2/RRC/NR/nr_rrc_gNB.c +++ b/openair2/RRC/NR/nr_rrc_gNB.c @@ -20,18 +20,13 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ +#include +#include -rrc_gNB_send_NGAP_NAS_FIRST_REQ() { - // We are noCore only now - // create message that should come from 5GC - - // send it dow - rrc_gNB_process_NGAP_DOWNLINK_NAS() -} - -rrc_gNB_process_NGAP_DOWNLINK_NAS () { - do_DLInformationTransfer(); +void rrc_gNB_process_NGAP_DOWNLINK_NAS (void ) { + do_DLInformationTransfer(0,NULL,0,0,NULL); // send it as DL data +/* rrc_data_req ( &ctxt, srb_id, @@ -40,9 +35,23 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS () { length, buffer, PDCP_TRANSMISSION_MODE_CONTROL); +*/ } +void rrc_gNB_send_NGAP_NAS_FIRST_REQ(void ) { + // We are noCore only now + // create message that should come from 5GC + + // send it dow + rrc_gNB_process_NGAP_DOWNLINK_NAS(); +} -:q +void nr_rrc_rx_tx() { + // check timers + // check if UEs are lost, to remove them from upper layers + + // + +} diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 317282c814..7c3e5134e2 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -91,7 +91,7 @@ int generate_CG_Config(gNB_RRC_INST *rrc, int parse_CG_ConfigInfo(gNB_RRC_INST *rrc, NR_CG_ConfigInfo_t *CG_ConfigInfo, x2ap_ENDC_sgnb_addition_req_t *m); - +void nr_rrc_rx_tx(void); /**\brief RRC eNB task. \param void *args_p Pointer on arguments to start the task. */ diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index 912782dd47..3f416c9255 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -457,7 +457,7 @@ void trace_pdu_implementation(int direction, uint8_t *pdu_buffer, unsigned int p } /*---------------------------------------------------*/ -int init_opt(void) { +int init_opt(void) { in_type=malloc(200); in_ip=malloc(200); in_path=malloc(200); @@ -476,11 +476,9 @@ int init_opt(void) { } else if (tmptype == OPT_PCAP && strlen(in_path) > 0) { opt_type = OPT_PCAP; opt_enabled=1; - LOG_I(OPT,"Enabling OPT for PCAP with the following file %s \n",in_path); } else if (tmptype == OPT_WIRESHARK && strlen(in_ip) > 0) { opt_enabled=1; opt_type = OPT_WIRESHARK; - LOG_I(OPT,"Enabling OPT for wireshark for local interface %s\n",in_ip); } else { LOG_E(OPT,"Invalid OPT configuration\n"); config_printhelp(opt_params,sizeof(opt_params)/sizeof(paramdef_t),OPT_CONFIGPREFIX); @@ -489,9 +487,9 @@ int init_opt(void) { // trace_mode switch (opt_type) { case OPT_WIRESHARK: - + LOG_I(OPT,"mode Wireshark: ip %s port %d\n", in_ip, PACKET_MAC_LTE_DEFAULT_UDP_PORT); /* Create local server socket only if using localhost address */ - if (strcmp(in_ip, "127.0.0.1") == 0) { + if (strncmp(in_ip, "127.0.0.1", 4) == 0) { opt_create_listener_socket(in_ip, PACKET_MAC_LTE_DEFAULT_UDP_PORT); } @@ -510,6 +508,7 @@ int init_opt(void) { break; case OPT_PCAP: + LOG_I(OPT,"mode PCAB : path is %s \n",in_path); file_fd = fopen(in_path, "w"); if (file_fd == NULL) { @@ -528,19 +527,9 @@ int init_opt(void) { default: opt_type = OPT_NONE; - LOG_W(OPT, "supported Option\n"); + LOG_E(OPT,"Unsupported or unknown mode %d \n", opt_type); break; } - - if ( opt_type == OPT_WIRESHARK ) - LOG_E(OPT,"mode Wireshark: ip %s port %d\n", in_ip, PACKET_MAC_LTE_DEFAULT_UDP_PORT); - else if (opt_type == OPT_PCAP) - LOG_E(OPT,"mode PCAB : path is %s \n",in_path); - else - LOG_E(OPT,"Unsupported or unknown mode %d \n", opt_type); - - // mac_info = (mac_info*)malloc16(sizeof(mac_lte_info)); - // memset(mac_info, 0, sizeof(mac_lte_info)+pdu_buffer_size + 8); return (1); } diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index 927b65c74c..36af22fb5f 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -310,7 +310,7 @@ typedef struct __attribute__((packed)) { } authenticationrequestHeader_t; -typedef struct __attribute__((packed){ +typedef struct __attribute__((packed)) { Extendedprotocoldiscriminator_t epd:8; Security_header_t sh:8; SGSmobilitymanagementmessages_t mt:8; From 5f7c30fb8c55b5d10d2a38280326b69a54c70887 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Thu, 1 Oct 2020 17:47:17 +0200 Subject: [PATCH 047/149] fix for get_slot_from_timestamp --- executables/nr-ru.c | 13 +++++++------ openair1/PHY/INIT/nr_parms.c | 15 +++++++++++++++ openair1/PHY/NR_TRANSPORT/pucch_rx.c | 4 ++-- openair1/PHY/defs_nr_common.h | 3 +++ targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 4 ++-- .../CONF/gnb.band257.tm1.32PRB.usrpx300.conf | 2 ++ 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 46f2ff7b2e..fc34e68bae 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -623,6 +623,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { unsigned int rxs; int i; uint32_t samples_per_slot = fp->get_samples_per_slot(*slot,fp); + uint32_t samples_per_slot_prev ; openair0_timestamp ts,old_ts; AssertFatal(*slotslots_per_frame && *slot>=0, "slot %d is illegal (%d)\n",*slot,fp->slots_per_frame); @@ -658,16 +659,16 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { ru->ts_offset = proc->timestamp_rx; proc->timestamp_rx = 0; } else { - if (proc->timestamp_rx - old_ts != fp->get_samples_per_slot((*slot-1)%fp->slots_per_frame,fp)) { - LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - samples_per_slot,ru->ts_offset); - ru->ts_offset += (proc->timestamp_rx - old_ts - samples_per_slot); + samples_per_slot_prev = fp->get_samples_per_slot((*slot-1)%fp->slots_per_frame,fp); + if (proc->timestamp_rx - old_ts != samples_per_slot_prev) { + LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - samples_per_slot_prev,ru->ts_offset); + ru->ts_offset += (proc->timestamp_rx - old_ts - samples_per_slot_prev); proc->timestamp_rx = ts-ru->ts_offset; } } proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; - uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; - proc->tti_rx = (idx_sf * fp->slots_per_subframe + (int)round((float)(proc->timestamp_rx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame); + proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx,fp); // synchronize first reception to frame 0 subframe 0 LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, slot %d.%d / %d\n", ru->idx, @@ -688,7 +689,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { } if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",(long long unsigned int)proc->timestamp_rx,proc->frame_rx,*frame); + LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d, proc->tti_rx %d, slot %d)\n",(long long unsigned int)proc->timestamp_rx,proc->frame_rx,*frame,proc->tti_rx,*slot); exit_fun("Exiting"); } } else { diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 6045930b17..e2d39bc89f 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -233,6 +233,20 @@ uint32_t get_samples_per_slot(int slot, NR_DL_FRAME_PARMS* fp) return samp_count; } + +uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, NR_DL_FRAME_PARMS* fp) +{ + uint32_t slot_idx = 0; + int samples_till_the_slot = 0; + timestamp_rx = timestamp_rx%fp->samples_per_frame; + + while (timestamp_rx > samples_till_the_slot) { + samples_till_the_slot += fp->get_samples_per_slot(slot_idx,fp); + slot_idx++; + } + return slot_idx; +} + uint32_t get_samples_slot_timestamp(int slot, NR_DL_FRAME_PARMS* fp, uint8_t sl_ahead) { uint32_t samp_count = 0; @@ -289,6 +303,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); fp->get_samples_per_slot = &get_samples_per_slot; fp->get_samples_slot_timestamp = &get_samples_slot_timestamp; + fp->get_slot_from_timestamp = &get_slot_from_timestamp; fp->samples_per_frame = 10 * fp->samples_per_subframe; fp->freq_range = (fp->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2; diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 71132b64c5..d68a64ec04 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -414,7 +414,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0; uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1); uci_pdu->harq->harq_list[0].harq_value = index&0x01; - LOG_I(PHY, "HARQ value %d with confidence level (0 is good, 1 is bad) %d\n", + LOG_D(PHY, "HARQ value %d with confidence level (0 is good, 1 is bad) %d\n", uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); @@ -429,7 +429,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2); uci_pdu->harq->harq_list[1].harq_value = index&0x01; uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01; - LOG_I(PHY, "HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n", + LOG_D(PHY, "HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n", uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index a21af3fa03..bdcf38752c 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -233,6 +233,7 @@ typedef struct { typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; typedef uint32_t (*get_samples_per_slot_t)(int slot, NR_DL_FRAME_PARMS* fp); +typedef uint32_t (*get_slot_from_timestamp_t)(openair0_timestamp timestamp_rx, NR_DL_FRAME_PARMS* fp); typedef uint32_t (*get_samples_slot_timestamp_t)(int slot, NR_DL_FRAME_PARMS* fp, uint8_t sl_ahead); @@ -289,6 +290,8 @@ struct NR_DL_FRAME_PARMS { uint32_t samples_per_subframe; /// Number of samples in current slot get_samples_per_slot_t get_samples_per_slot; + /// slot calculation from timestamp + get_slot_from_timestamp_t get_slot_from_timestamp; /// Number of samples before slot get_samples_slot_timestamp_t get_samples_slot_timestamp; /// Number of samples in 0th and center slot of a subframe diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index b43c2769eb..dd29d01fae 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -693,10 +693,10 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp *ptimestamp = s->rx_timestamp; // push GPIO bits 7-9 from flags_msb - s->usrp->set_command_time(uhd::time_spec_t::from_ticks((s->rx_timestamp+(2*nsamps)),s->sample_rate)); + /*s->usrp->set_command_time(uhd::time_spec_t::from_ticks((s->rx_timestamp+(2*nsamps)),s->sample_rate)); s->usrp->set_gpio_attr("FP0", "OUT", gpio789<<7, 0x380); s->usrp->clear_command_time(); - gpio789 = (gpio789+1)&7; + gpio789 = (gpio789+1)&7;*/ if (device->recplay_state != NULL) { // record mode // Copy subframes to memory (later dump on a file) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf index fdaa965ae9..ea38aba1b2 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf @@ -239,6 +239,8 @@ RUs = ( eNB_instances = [0]; sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2"; if_freq = 5300000000L; + #time_source = "external"; + clock_source = "external"; } ); From 5cb8e9e14d1fc05077eaaa831fb6295d1136d0f6 Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 2 Oct 2020 11:26:46 +0200 Subject: [PATCH 048/149] Reduce difference with OSA develop branch for merge --- ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf | 2 -- cmake_targets/CMakeLists.txt | 4 ++-- common/ran_context.h | 1 - common/utils/assertions.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 -- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 1 - openair2/RRC/LTE/rrc_eNB.c | 1 - openair2/RRC/NR/rrc_gNB.c | 2 +- targets/ARCH/rfsimulator/simulator.c | 2 -- targets/COMMON/create_tasks.c | 1 - .../CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf | 2 +- targets/RT/USER/lte-softmodem.c | 1 - 13 files changed, 6 insertions(+), 17 deletions(-) diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index 252f886ce9..36e93ba14e 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -245,14 +245,12 @@ RUs = ( att_rx = 0; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 75; eNB_instances = [0]; #beamforming 1x4 matrix: bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2"; clock_src = "external"; - } ); diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 5fbd585409..2b160edf59 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -233,7 +233,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,${CMAKE_CU # set a flag for changes in the source code # these changes are related to hardcoded path to include .h files set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -O0 -DMALLOC_CHECK_=3") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g3 -DMALLOC_CHECK_=3 -O1 -fno-delete-null-pointer-checks") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g3 -DMALLOC_CHECK_=3 -O2 -fno-delete-null-pointer-checks") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3") set(GIT_BRANCH "UNKNOWN") @@ -292,7 +292,7 @@ add_boolean_option(TRACE_RLC_PAYLOAD False "print RLC PDU to stdout") # if tru add_boolean_option(TEST_OMG False "???") add_boolean_option(DEBUG_OMG False "???") add_boolean_option(PRINT_STATS False "This adds the possibility to see the status") -add_boolean_option(T_TRACER False "Activate the T tracer, a debugging/monitoring framework" ) +add_boolean_option(T_TRACER True "Activate the T tracer, a debugging/monitoring framework" ) add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs") add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace") add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace") diff --git a/common/ran_context.h b/common/ran_context.h index e8d8ed0653..8262f5dd55 100644 --- a/common/ran_context.h +++ b/common/ran_context.h @@ -110,7 +110,6 @@ typedef struct { /// GTPu descriptor gtpv1u_data_t *gtpv1u_data_g; /// RU descriptors. These describe what each radio unit is supposed to do and contain the necessary functions for fronthaul interfaces - // LTS: not coherent (xxx_frame_parms cardinatlity wtih xNB (so one carrier)) struct RU_t_s **ru; /// Mask to indicate fronthaul setup status of RU (hard-limit to 64 RUs) uint64_t ru_mask; diff --git a/common/utils/assertions.h b/common/utils/assertions.h index 06d43bdbfa..48d8df401c 100644 --- a/common/utils/assertions.h +++ b/common/utils/assertions.h @@ -39,7 +39,7 @@ void output_log_mem(void); display_backtrace(); \ fflush(stdout); \ fflush(stderr); \ - abort(); + exit(EXIT_FAILURE); \ #define _Assert_(cOND, aCTION, fORMAT, aRGS...) \ do { \ diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index f07425b537..2a6d3270d8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -687,7 +687,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->llr_offset[symbol] = len*dlsch0_harq->Qm + llr_offset_symbol; - LOG_I(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d energy %d\n", + LOG_D(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d energy %d\n", symbol, nb_rb,dlsch0_harq->Qm, pdsch_vars[eNB_id]->llr_length[symbol], diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 234fccddfa..1a08a65d7f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -563,14 +563,12 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (UE_list->UEcontext[UE_id].fiveG_connected ) nr_schedule_pucch(module_idP, UE_id, nr_ulmix_slots, frame, slot); - /* // Allocate CCEs for good after scheduling is done for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) allocate_CCEs(module_idP, CC_id, subframeP, 0); */ - stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 72164149c2..15c9c65d62 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -203,7 +203,6 @@ int pdcp_fifo_flush_mbms_sdus(const protocol_ctxt_t *const ctxt_pP) { //AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno)); - //AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno)); delNotifiedFIFO_elt (sdu_p); pdcp_nb_sdu_sent ++; } diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 6255423177..a6775bbf8a 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -9503,7 +9503,6 @@ void *rrc_enb_process_itti_msg(void *notUsed) { return NULL; } -// as there are race conditions, no rrc thread //----------------------------------------------------------------------------- void * rrc_enb_task( diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index a8deedc85f..90af46f6fb 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -182,7 +182,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__); rrc->carrier.MIB = (uint8_t *) malloc16(4); rrc->carrier.sizeof_MIB = do_MIB_NR(rrc,0); - rrc->carrier.sizeof_SIB1 = do_SIB1_NR(&rrc->carrier,configuration); + rrc->carrier.sizeof_SIB1 = do_SIB1_NR(&rrc->carrier,configuration); LOG_I(NR_RRC,"Done init_NR_SI\n"); rrc_mac_config_req_gNB(rrc->module_id, rrc->carrier.ssb_SubcarrierOffset, diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index daae8e722c..c4760d8aee 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -720,7 +720,6 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ); else { // no channel modeling sample_t *out=(sample_t *)samplesVoid[a]; - int nbAnt_tx = ptr->th.nbAnt;//number of Tx antennas //LOG_I(HW, "nbAnt_tx %d\n",nbAnt_tx); for (int i=0; i < nsamps; i++) {//loop over nsamps @@ -729,7 +728,6 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo out[i].i+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].i; } // end for a_tx } // end for i (number of samps) - } // end of no channel modeling } // end for a (number of rx antennas) } diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index c4d5109b7e..4d57ab4e16 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -56,7 +56,6 @@ int create_tasks(uint32_t enb_nb) { rc = itti_create_task (TASK_ENB_APP, eNB_app_task, NULL); AssertFatal(rc >= 0, "Create task for eNB APP failed\n"); - // No more rrc thread, as many race conditions are hidden behind LOG_I(RRC,"Creating RRC eNB Task\n"); rc = itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL); AssertFatal(rc >= 0, "Create task for RRC eNB failed\n"); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf index 83e32fd57b..ff8e261783 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf @@ -200,7 +200,7 @@ gNBs = ); ///X2 - enable_x2 = "no"; + enable_x2 = "yes"; t_reloc_prep = 1000; /* unit: millisecond */ tx2_reloc_overall = 2000; /* unit: millisecond */ target_enb_x2_ip_address = ( diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 1b40661025..0d0dde4ac4 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -444,7 +444,6 @@ int restart_L1L2(module_id_t enb_id) { init_UE_info(&RC.mac[enb_id]->UE_info); LOG_I(ENB_APP, "attempting to create ITTI tasks\n"); - // No more rrc thread, as many race conditions are hidden behind if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) { LOG_E(RRC, "Create task for RRC eNB failed\n"); return -1; From 4772f7f6e494f13c8a11fa7665ac163a0f10c42b Mon Sep 17 00:00:00 2001 From: Laurent Date: Sun, 4 Oct 2020 19:35:41 +0200 Subject: [PATCH 049/149] for push to OSA git --- .../gnb.band78.tm1.fr1.106PRB.usrpb210.conf | 15 ++++++++------- executables/ocp-gnb.c | 2 ++ openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 2 +- .../PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 4 ++-- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 1 + 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index 9182f8e6be..179e3ba10d 100755 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -199,7 +199,7 @@ gNBs = ////////// MME parameters: - mme_ip_address = ( { ipv4 = "127.0.0.20"; + mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; @@ -213,7 +213,7 @@ gNBs = t_dc_prep = 1000; /* unit: millisecond */ t_dc_overall = 2000; /* unit: millisecond */ target_enb_x2_ip_address = ( - { ipv4 = "127.0.0.10"; + { ipv4 = "CI_FR1_CTL_ENB_IP_ADDR"; ipv6 = "192:168:30::17"; preference = "ipv4"; } @@ -223,11 +223,11 @@ gNBs = { GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.10"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "CI_GNB_IP_ADDR"; GNB_INTERFACE_NAME_FOR_S1U = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1U = "127.0.0.10"; + GNB_IPV4_ADDRESS_FOR_S1U = "CI_GNB_IP_ADDR"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 - GNB_IPV4_ADDRESS_FOR_X2C = "127.0.0.10"; + GNB_IPV4_ADDRESS_FOR_X2C = "CI_GNB_IP_ADDR"; GNB_PORT_FOR_X2C = 36422; # Spec 36422 }; } @@ -259,7 +259,7 @@ RUs = ( max_pdschReferenceSignalPower = -27; max_rxgain = 114; eNB_instances = [0]; - clock_src = "internal"; + clock_src = "external"; } ); @@ -277,7 +277,7 @@ THREAD_STRUCT = ( { global_log_level ="info"; global_log_verbosity ="medium"; - hw_log_level ="debug"; + hw_log_level ="info"; hw_log_verbosity ="medium"; phy_log_level ="info"; phy_log_verbosity ="medium"; @@ -290,6 +290,7 @@ THREAD_STRUCT = ( rrc_log_level ="info"; rrc_log_verbosity ="medium"; }; + uicc: { opc = "testopc"; }; diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index c373b7933e..bcd337b836 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -93,6 +93,8 @@ time_stats_t softmodem_stats_hw; // hw acquisition time_stats_t softmodem_stats_rxtx_sf; // total tx time time_stats_t nfapi_meas; // total tx time time_stats_t softmodem_stats_rx_sf; // total rx time +// not used but needed for link +openair0_config_t openair0_cfg[MAX_CARDS]; AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]; AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 47d79e9455..057d259baa 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -479,7 +479,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { AssertFatal(fp->ul_CarrierFreq==(fp->dl_CarrierFreq+dlul_offset), "Disagreement in uplink frequency for band %d\n", fp->nr_band); - //fp->threequarter_fs = openair0_cfg[0].threequarter_fs; + fp->threequarter_fs = openair0_cfg[0].threequarter_fs; LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", Mod_id, gNB_config->cell_config.phy_cell_id.value, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 398ef586d5..7980206eb4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -346,7 +346,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *gNB, printf("ulsch_decoding.c: NULL ulsch_llr pointer\n"); return (ulsch->max_ldpc_iterations + 1); } - //log_dump(PHY,ulsch_llr, 32, LOG_DUMP_CHAR, "ul llr"); + if (!frame_parms) { printf("ulsch_decoding.c: NULL frame_parms pointer\n"); return (ulsch->max_ldpc_iterations + 1); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 2a6d3270d8..aee299d3c6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -693,8 +693,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->llr_length[symbol], pdsch_vars[eNB_id]->llr_offset[symbol], signal_energy(pdsch_vars[eNB_id]->rxdataF_comp0[0], 7*2*frame_parms->N_RB_DL*12)); - //if (ue->current_thread_id[nr_tti_rx] ==0 ) - //phy_scope_nrUE(NULL, ue, 0, 0, 0); + + /*printf("compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %p @LLR Buff(symb) %p\n", symbol, nb_rb,dlsch0_harq->Qm, diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 15c9c65d62..72164149c2 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -203,6 +203,7 @@ int pdcp_fifo_flush_mbms_sdus(const protocol_ctxt_t *const ctxt_pP) { //AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno)); + //AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno)); delNotifiedFIFO_elt (sdu_p); pdcp_nb_sdu_sent ++; } From 6b676d16058b7cc828580ea1f91623c791711fd7 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 6 Oct 2020 13:54:30 +0200 Subject: [PATCH 050/149] Fix compilation issues --- cmake_targets/CMakeLists.txt | 245 +++++++++++----------- openair1/SIMULATION/NR_PHY/dlsim.c | 5 +- openair1/SIMULATION/NR_PHY/prachsim.c | 6 +- openair1/SIMULATION/NR_PHY/ulsim.c | 6 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 + openair2/LAYER2/RLC/rlc.h | 2 +- openair2/RRC/NR/rrc_gNB.c | 1 + 7 files changed, 138 insertions(+), 129 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 467060f6fa..7846bfa47e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -23,6 +23,114 @@ cmake_minimum_required (VERSION 3.0) + +# System packages that are required +# We use either the cmake buildin, in ubuntu are in: /usr/share/cmake*/Modules/ +# or cmake provide a generic interface to pkg-config that widely used +################################### +include(FindPkgConfig) + +pkg_search_module(LIBXML2 libxml-2.0 REQUIRED) +include_directories(${LIBXML2_INCLUDE_DIRS}) + +pkg_search_module(LIBXSLT libxslt REQUIRED) +include_directories(${LIBXSLT_INCLUDE_DIRS}) + +pkg_search_module(OPENSSL openssl REQUIRED) +include_directories(${OPENSSL_INCLUDE_DIRS}) + +pkg_search_module(CONFIG libconfig REQUIRED) +include_directories(${CONFIG_INCLUDE_DIRS}) + +pkg_search_module(CRYPTO libcrypto REQUIRED) +include_directories(${CRYPTO_INCLUDE_DIRS}) + +#use native cmake method as this package is not in pkg-config +if (${RF_BOARD} STREQUAL "OAI_USRP") + find_package(Boost REQUIRED) + include_directories(${LIBBOOST_INCLUDE_DIR}) + +elseif (${RF_BOARD} STREQUAL "OAI_IRIS") + include_directories("${OPENAIR_TARGETS}/ARCH/IRIS/USERSPACE/LIB/") + include_directories("/usr/local/include/") + set(HW_SOURCE ${HW_SOURCE} + ${OPENAIR_TARGETS}/ARCH/IRIS/USERSPACE/LIB/iris_lib.cpp) + LINK_DIRECTORIES("/usr/local/lib") + set(option_HW_lib "-lSoapySDR -rdynamic -ldl") + +endif (${RF_BOARD} STREQUAL "OAI_USRP") + +pkg_search_module(OPENPGM openpgm-5.1 openpgm-5.2) +if(NOT ${OPENPGM_FOUND}) + message("PACKAGE openpgm-5.1 is required by binaries such as oaisim: will fail later if this target is built") +else() + include_directories(${OPENPGM_INCLUDE_DIRS}) +endif() + +pkg_search_module(NETTLE nettle) +if(NOT ${NETTLE_FOUND}) + message( FATAL_ERROR "PACKAGE nettle not found: some targets will fail. Run build_oai -I again!") +else() + include_directories(${NETTLE_INCLUDE_DIRS}) +endif() + +message ("NETTLE VERSION_INSTALLED = ${NETTLE_VERSION}") + +string(REGEX REPLACE "([0-9]+).*" "\\1" NETTLE_VERSION_MAJOR ${NETTLE_VERSION}) +string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" NETTLE_VERSION_MINOR ${NETTLE_VERSION}) +message ("NETTLE_VERSION_MAJOR = ${NETTLE_VERSION_MAJOR}") +message ("NETTLE_VERSION_MINOR = ${NETTLE_VERSION_MINOR}") + +if ("${NETTLE_VERSION_MAJOR}" STREQUAL "" OR "${NETTLE_VERSION_MINOR}" STREQUAL "") + message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" ) +endif() + +add_definitions("-DNETTLE_VERSION_MAJOR=${NETTLE_VERSION_MAJOR}") +add_definitions("-DNETTLE_VERSION_MINOR=${NETTLE_VERSION_MINOR}") + +pkg_search_module(XPM xpm) +if(NOT ${XPM_FOUND}) + message("PACKAGE xpm not found: some targets will fail") +else() + include_directories(${XPM_INCLUDE_DIRS}) +endif() + +# Atlas is required by some packages, but not found in pkg-config +# So, here are some hacks here. Hope this gets fixed in future! +if(EXISTS "/usr/include/atlas/cblas.h" OR EXISTS "/usr/include/cblas.h") + include_directories("/usr/include/atlas") + LINK_DIRECTORIES("/usr/lib/lapack") + LINK_DIRECTORIES("/usr/lib64") + LINK_DIRECTORIES("/usr/lib64/atlas") #Added because atlas libraries in CentOS 7 are here! + + if(EXISTS "/usr/lib64/libblas.so" OR EXISTS "/usr/lib/libblas.so") #Case for CentOS7 + list(APPEND ATLAS_LIBRARIES blas) + + else() # Case for Ubuntu + list(APPEND ATLAS_LIBRARIES cblas) + endif() + + if(EXISTS "/usr/lib/atlas/libtatlas.so" OR EXISTS "/usr/lib64/atlas/libtatlas.so") #Case for CentOS7 + list(APPEND ATLAS_LIBRARIES tatlas) + else() + list(APPEND ATLAS_LIBRARIES atlas) #Case for Ubuntu + endif() + + list(APPEND ATLAS_LIBRARIES lapack) + +# for ubuntu 17.10, directories are different +elseif(EXISTS "/usr/include/x86_64-linux-gnu/cblas.h") + + include_directories("/usr/include/x86_64-linux-gnu") + LINK_DIRECTORIES("/usr/lib/x86_64-linux-gnu") + list(APPEND ATLAS_LIBRARIES cblas) + list(APPEND ATLAS_LIBRARIES atlas) + list(APPEND ATLAS_LIBRARIES lapack) + +else() + message("No Blas/Atlas libs found, some targets will fail") +endif() + ######################################################### # Base directories, compatible with legacy OAI building # ######################################################### @@ -622,7 +730,7 @@ add_library(X2AP_ENB ${X2AP_DIR}/x2ap_ids.c ${X2AP_DIR}/x2ap_timers.c ) -add_dependencies(X2AP_ENB rrc_flag x2_flag) +add_dependencies(X2AP_ENB X2AP_LIB rrc_flag x2_flag) # F1AP @@ -2424,114 +2532,6 @@ include_directories("${NFAPI_DIR}/nfapi/inc") include_directories("${NFAPI_DIR}/sim_common/inc") include_directories("${NFAPI_DIR}/pnf_sim/inc") - -# System packages that are required -# We use either the cmake buildin, in ubuntu are in: /usr/share/cmake*/Modules/ -# or cmake provide a generic interface to pkg-config that widely used -################################### -include(FindPkgConfig) - -pkg_search_module(LIBXML2 libxml-2.0 REQUIRED) -include_directories(${LIBXML2_INCLUDE_DIRS}) - -pkg_search_module(LIBXSLT libxslt REQUIRED) -include_directories(${LIBXSLT_INCLUDE_DIRS}) - -pkg_search_module(OPENSSL openssl REQUIRED) -include_directories(${OPENSSL_INCLUDE_DIRS}) - -pkg_search_module(CONFIG libconfig REQUIRED) -include_directories(${CONFIG_INCLUDE_DIRS}) - -pkg_search_module(CRYPTO libcrypto REQUIRED) -include_directories(${CRYPTO_INCLUDE_DIRS}) - -#use native cmake method as this package is not in pkg-config -if (${RF_BOARD} STREQUAL "OAI_USRP") - find_package(Boost REQUIRED) - include_directories(${LIBBOOST_INCLUDE_DIR}) - -elseif (${RF_BOARD} STREQUAL "OAI_IRIS") - include_directories("${OPENAIR_TARGETS}/ARCH/IRIS/USERSPACE/LIB/") - include_directories("/usr/local/include/") - set(HW_SOURCE ${HW_SOURCE} - ${OPENAIR_TARGETS}/ARCH/IRIS/USERSPACE/LIB/iris_lib.cpp) - LINK_DIRECTORIES("/usr/local/lib") - set(option_HW_lib "-lSoapySDR -rdynamic -ldl") - -endif (${RF_BOARD} STREQUAL "OAI_USRP") - -pkg_search_module(OPENPGM openpgm-5.1 openpgm-5.2) -if(NOT ${OPENPGM_FOUND}) - message("PACKAGE openpgm-5.1 is required by binaries such as oaisim: will fail later if this target is built") -else() - include_directories(${OPENPGM_INCLUDE_DIRS}) -endif() - -pkg_search_module(NETTLE nettle) -if(NOT ${NETTLE_FOUND}) - message( FATAL_ERROR "PACKAGE nettle not found: some targets will fail. Run build_oai -I again!") -else() - include_directories(${NETTLE_INCLUDE_DIRS}) -endif() - -message ("NETTLE VERSION_INSTALLED = ${NETTLE_VERSION}") - -string(REGEX REPLACE "([0-9]+).*" "\\1" NETTLE_VERSION_MAJOR ${NETTLE_VERSION}) -string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" NETTLE_VERSION_MINOR ${NETTLE_VERSION}) -message ("NETTLE_VERSION_MAJOR = ${NETTLE_VERSION_MAJOR}") -message ("NETTLE_VERSION_MINOR = ${NETTLE_VERSION_MINOR}") - -if ("${NETTLE_VERSION_MAJOR}" STREQUAL "" OR "${NETTLE_VERSION_MINOR}" STREQUAL "") - message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" ) -endif() - -add_definitions("-DNETTLE_VERSION_MAJOR=${NETTLE_VERSION_MAJOR}") -add_definitions("-DNETTLE_VERSION_MINOR=${NETTLE_VERSION_MINOR}") - -pkg_search_module(XPM xpm) -if(NOT ${XPM_FOUND}) - message("PACKAGE xpm not found: some targets will fail") -else() - include_directories(${XPM_INCLUDE_DIRS}) -endif() - -# Atlas is required by some packages, but not found in pkg-config -# So, here are some hacks here. Hope this gets fixed in future! -if(EXISTS "/usr/include/atlas/cblas.h" OR EXISTS "/usr/include/cblas.h") - include_directories("/usr/include/atlas") - LINK_DIRECTORIES("/usr/lib/lapack") - LINK_DIRECTORIES("/usr/lib64") - LINK_DIRECTORIES("/usr/lib64/atlas") #Added because atlas libraries in CentOS 7 are here! - - if(EXISTS "/usr/lib64/libblas.so" OR EXISTS "/usr/lib/libblas.so") #Case for CentOS7 - list(APPEND ATLAS_LIBRARIES blas) - - else() # Case for Ubuntu - list(APPEND ATLAS_LIBRARIES cblas) - endif() - - if(EXISTS "/usr/lib/atlas/libtatlas.so" OR EXISTS "/usr/lib64/atlas/libtatlas.so") #Case for CentOS7 - list(APPEND ATLAS_LIBRARIES tatlas) - else() - list(APPEND ATLAS_LIBRARIES atlas) #Case for Ubuntu - endif() - - list(APPEND ATLAS_LIBRARIES lapack) - -# for ubuntu 17.10, directories are different -elseif(EXISTS "/usr/include/x86_64-linux-gnu/cblas.h") - - include_directories("/usr/include/x86_64-linux-gnu") - LINK_DIRECTORIES("/usr/lib/x86_64-linux-gnu") - list(APPEND ATLAS_LIBRARIES cblas) - list(APPEND ATLAS_LIBRARIES atlas) - list(APPEND ATLAS_LIBRARIES lapack) - -else() - message("No Blas/Atlas libs found, some targets will fail") -endif() - list(APPEND ATLAS_LIBRARIES lapack lapacke) include_directories ("/usr/include/X11") @@ -2641,7 +2641,7 @@ target_link_libraries (measurement_display minimal_lib) add_executable(test5Gnas ${OPENAIR_DIR}/openair3/TEST/test5Gnas.c ) -target_link_libraries (test5Gnas ${NETTLE_LIBRARIES} LIB_5GNAS_GNB CONFIG_LIB minimal_lib ) +target_link_libraries (test5Gnas LIB_5GNAS_GNB CONFIG_LIB minimal_lib ) # lte-softmodem is both eNB and UE implementation @@ -2685,7 +2685,7 @@ target_link_libraries (lte-softmodem -Wl,--end-group z dl) target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES}) -target_link_libraries (lte-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) +target_link_libraries (lte-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-softmodem ${T_LIB}) @@ -2724,7 +2724,7 @@ target_link_libraries (ocp-enb PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 SIMU_COMMON ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} -Wl,--end-group z dl) -target_link_libraries (ocp-enb ${NETTLE_LIBRARIES} ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) +target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) add_executable(cu_test ${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c @@ -2796,7 +2796,7 @@ target_link_libraries (lte-uesoftmodem -Wl,--end-group z dl) target_link_libraries (lte-uesoftmodem ${LIBXML2_LIBRARIES}) -target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (lte-uesoftmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-uesoftmodem ${T_LIB}) @@ -2838,7 +2838,7 @@ target_link_libraries (nr-softmodem -Wl,--end-group z dl) target_link_libraries (nr-softmodem ${LIBXML2_LIBRARIES}) -target_link_libraries (nr-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (nr-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (nr-softmodem ${T_LIB}) @@ -2877,7 +2877,7 @@ target_link_libraries (ocp-gnb X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB SIMU_COMMON -Wl,--end-group z dl) -target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES} ${NETTLE_LIBRARIES}) +target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES} ) target_link_libraries (ocp-gnb pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (ocp-gnb ${LIB_LMS_LIBRARIES}) target_link_libraries (ocp-gnb ${T_LIB}) @@ -2922,7 +2922,7 @@ target_link_libraries (nr-uesoftmodem -Wl,--end-group z dl) target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES}) -target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (nr-uesoftmodem ${T_LIB}) @@ -3089,7 +3089,7 @@ add_executable(nr_dlsim ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_dlsim - -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR HASHTABLE -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) target_compile_definitions(nr_dlsim PUBLIC -DPHYSICAL_SIMULATOR) @@ -3107,7 +3107,8 @@ add_executable(nr_prachsim ${T_SOURCE} ${SHLIB_LOADER_SOURCES}) target_link_libraries(nr_prachsim - -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON SCHED_NR_LIB MAC_UE_NR SCHED_NR_UE_LIB RRC_LIB NR_RRC_LIB L2_NR CONFIG_LIB HASHTABLE -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c @@ -3137,7 +3138,7 @@ add_executable(nr_ulsim ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_ulsim - -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR HASHTABLE -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) target_compile_definitions(nr_ulsim PUBLIC -DPHYSICAL_SIMULATOR) @@ -3172,7 +3173,7 @@ add_executable(test_epc_generate_scenario ${OPENAIR3_DIR}/S1AP/s1ap_eNB_defs.h ) target_link_libraries (test_epc_generate_scenario - -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) add_executable(test_epc_play_scenario @@ -3191,7 +3192,7 @@ add_executable(test_epc_play_scenario ) target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c) target_link_libraries (test_epc_play_scenario - -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) @@ -3211,7 +3212,7 @@ foreach(myExe s1ap ${OPENAIR3_DIR}/TEST/test_${myExe}.c ) target_link_libraries (test_${myExe} - -Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) endforeach(myExe) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 257fc56b85..ff02cf677c 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -66,8 +66,9 @@ #define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0)) #include "SIMULATION/LTE_PHY/common_sim.h" +#include +#include -unsigned char NB_eNB_INST=0; LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; rlc_info_t Rlc_info_um,Rlc_info_am_config; @@ -81,7 +82,6 @@ double cpuf; int sf_ahead=4 ; int sl_ahead=0; uint8_t nfapi_mode = 0; -uint16_t NB_UE_INST = 1; uint64_t downlink_frequency[MAX_NUM_CCs][4]; // dummy functions @@ -188,6 +188,7 @@ int main(int argc, char **argv) SCM_t channel_model=AWGN;//Rayleigh1_anticorr; + NB_UE_INST = 1; //double pbch_sinr; //int pbch_tx_ant; int N_RB_DL=106,mu=1; diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index cb196afe9a..b08b1281e8 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -45,11 +45,13 @@ #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "nr_unitary_defs.h" #include "OCG_vars.h" +#include +#include + #define NR_PRACH_DEBUG 1 #define PRACH_WRITE_OUTPUT_DEBUG 1 -unsigned char NB_eNB_INST=0; LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; rlc_info_t Rlc_info_um,Rlc_info_am_config; @@ -59,7 +61,6 @@ RAN_CONTEXT_t RC; RU_t *ru; double cpuf; extern uint16_t prach_root_sequence_map0_3[838]; -uint16_t NB_UE_INST=1; openair0_config_t openair0_cfg[MAX_CARDS]; uint8_t nfapi_mode=0; int sl_ahead = 0; @@ -114,6 +115,7 @@ int main(int argc, char **argv){ uint32_t tx_lev = 10000, prach_errors = 0, samp_count; //,tx_lev_dB; uint64_t SSB_positions = 0x01, absoluteFrequencyPointA = 640000; double DS_TDL = .03; + NB_UE_INST=1; // int8_t interf1=-19,interf2=-19; // uint8_t abstraction_flag=0,calibration_flag=0; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index da8f19c61d..42f1c7d135 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -58,9 +58,11 @@ #define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0)) #include "SIMULATION/LTE_PHY/common_sim.h" +#include +#include + //#define DEBUG_ULSIM -unsigned char NB_eNB_INST=0; LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; rlc_info_t Rlc_info_um,Rlc_info_am_config; @@ -73,7 +75,6 @@ int sf_ahead=4 ; int sl_ahead=0; double cpuf; uint8_t nfapi_mode = 0; -uint16_t NB_UE_INST = 1; uint64_t downlink_frequency[MAX_NUM_CCs][4]; @@ -156,6 +157,7 @@ int main(int argc, char **argv) uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; double tx_gain=1.0; double N0=30; + NB_UE_INST = 1; //unsigned char frame_type = 0; NR_DL_FRAME_PARMS *frame_parms; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 2de45db856..997fc6691e 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -56,6 +56,8 @@ #include "flexran.pb-c.h" #include "flexran_agent_mac.h" #include +#include + #include "T.h" diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index 27ca18ed7e..7e4920a579 100644 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -143,7 +143,7 @@ void (*rlc_rrc_data_conf)( const protocol_ctxt_t *const ctxtP, const rb_id_t rb_idP, const mui_t muiP, - const rlc_tx_status_t statusP); + const rlc_tx_status_t statusP) __attribute__ ((aligned(32))); typedef void (rrc_data_ind_cb_t)( const protocol_ctxt_t *const ctxtP, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 916ec09a15..4b9c66ee47 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -82,6 +82,7 @@ #include "executables/softmodem-common.h" #include +#include //#define XER_PRINT From 43c76e868f0baae109c895f23f7ca5d688953994 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Thu, 8 Oct 2020 13:44:56 +0200 Subject: [PATCH 051/149] CI: adding waiver on License Banner check for milenage.h file Signed-off-by: Raphael Defosseux --- ci-scripts/checkCodingFormattingRules.sh | 30 ++++++++++++++---------- openair3/NAS/COMMON/milenage.h | 4 +++- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ci-scripts/checkCodingFormattingRules.sh b/ci-scripts/checkCodingFormattingRules.sh index d47b90a9dd..3a2fcbb02c 100755 --- a/ci-scripts/checkCodingFormattingRules.sh +++ b/ci-scripts/checkCodingFormattingRules.sh @@ -59,7 +59,7 @@ if [ $# -eq 0 ] then echo " ---- Checking the whole repository ----" echo "" - NB_FILES_TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt --recursive *.c *.h | grep -c Formatted ` + NB_FILES_TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt --recursive *.c *.h | grep -c Formatted || true` echo "Nb Files that do NOT follow OAI rules: $NB_FILES_TO_FORMAT" echo $NB_FILES_TO_FORMAT > ./oai_rules_result.txt @@ -67,17 +67,17 @@ then awk '/#[ \t]*ifndef/ { gsub("^.*ifndef *",""); if (names[$1]!="") print "files with same {define ", FILENAME, names[$1]; names[$1]=FILENAME } /#[ \t]*define/ { gsub("^.*define *",""); if(names[$1]!=FILENAME) print "error in declaration", FILENAME, $1, names[$1]; nextfile }' `find openair* common targets executables -name *.h |grep -v LFDS` > header-files-w-incorrect-define.txt # Testing if explicit GNU GPL license banner - egrep -irl --exclude-dir=.git --include=*.cpp --include=*.c --include=*.h "General Public License" . > files-w-gnu-gpl-license-banner.txt + egrep -irl --exclude-dir=.git --include=*.cpp --include=*.c --include=*.h "General Public License" . | egrep -v "openair3/NAS/COMMON/milenage.h" > files-w-gnu-gpl-license-banner.txt # Looking at exotic/suspect banner LIST_OF_FILES_W_BANNER=`egrep -irl --exclude-dir=.git --include=*.cpp --include=*.c --include=*.h "Copyright|copyleft" .` if [ -f ./files-w-suspect-banner.txt ]; then rm -f ./files-w-suspect-banner.txt; fi for FILE in $LIST_OF_FILES_W_BANNER do - IS_NFAPI=`echo $FILE | egrep -c "nfapi/open-nFAPI|nfapi/oai_integration/vendor_ext"` - IS_OAI_LICENCE_PRESENT=`egrep -c "OAI Public License" $FILE` - IS_BSD_LICENCE_PRESENT=`egrep -c "the terms of the BSD Licence" $FILE` - IS_EXCEPTION=`echo $FILE | egrep -c "common/utils/collection/tree.h|common/utils/collection/queue.h|common/utils/itti_analyzer/common/queue.h|openair3/UTILS/tree.h|openair3/UTILS/queue.h|openair3/GTPV1-U/nw-gtpv1u|openair2/UTIL/OPT/ws_"` + IS_NFAPI=`echo $FILE | egrep -c "nfapi/open-nFAPI|nfapi/oai_integration/vendor_ext" || true` + IS_OAI_LICENCE_PRESENT=`egrep -c "OAI Public License" $FILE || true` + IS_BSD_LICENCE_PRESENT=`egrep -c "the terms of the BSD Licence" $FILE || true` + IS_EXCEPTION=`echo $FILE | egrep -c "common/utils/collection/tree.h|common/utils/collection/queue.h|common/utils/itti_analyzer/common/queue.h|openair3/UTILS/tree.h|openair3/UTILS/queue.h|openair3/GTPV1-U/nw-gtpv1u|openair2/UTIL/OPT/ws_|openair3/NAS/COMMON/milenage.h" || true` if [ $IS_OAI_LICENCE_PRESENT -eq 0 ] && [ $IS_BSD_LICENCE_PRESENT -eq 0 ] then if [ $IS_NFAPI -eq 0 ] && [ $IS_EXCEPTION -eq 0 ] @@ -178,7 +178,7 @@ do EXT="${filename##*.}" if [ $EXT = "c" ] || [ $EXT = "h" ] || [ $EXT = "cpp" ] || [ $EXT = "hpp" ] then - TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt $FULLFILE | grep -c Formatted ` + TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt $FULLFILE | grep -c Formatted || true` NB_TO_FORMAT=$((NB_TO_FORMAT + TO_FORMAT)) if [ $TO_FORMAT -ne 0 ] then @@ -186,15 +186,19 @@ do echo $FULLFILE >> ./oai_rules_result_list.txt fi # Testing if explicit GNU GPL license banner - egrep -i "General Public License" $FULLFILE >> files-w-gnu-gpl-license-banner.txt + GNU_EXCEPTION=`echo $FULLFILE | egrep -c "openair3/NAS/COMMON/milenage.h" || true` + if [ $GNU_EXCEPTION -eq 0 ] + then + egrep -il "General Public License" $FULLFILE >> files-w-gnu-gpl-license-banner.txt + fi # Looking at exotic/suspect banner - IS_BANNER=`egrep -i -c "Copyright|copyleft" $FULLFILE` + IS_BANNER=`egrep -i -c "Copyright|copyleft" $FULLFILE || true` if [ $IS_BANNER -ne 0 ] then - IS_NFAPI=`echo $FULLFILE | egrep -c "nfapi/open-nFAPI|nfapi/oai_integration/vendor_ext"` - IS_OAI_LICENCE_PRESENT=`egrep -c "OAI Public License" $FULLFILE` - IS_BSD_LICENCE_PRESENT=`egrep -c "the terms of the BSD Licence" $FULLFILE` - IS_EXCEPTION=`echo $FULLFILE | egrep -c "common/utils/collection/tree.h|common/utils/collection/queue.h|common/utils/itti_analyzer/common/queue.h|openair3/UTILS/tree.h|openair3/UTILS/queue.h|openair3/GTPV1-U/nw-gtpv1u|openair2/UTIL/OPT/ws_"` + IS_NFAPI=`echo $FULLFILE | egrep -c "nfapi/open-nFAPI|nfapi/oai_integration/vendor_ext" || true` + IS_OAI_LICENCE_PRESENT=`egrep -c "OAI Public License" $FULLFILE || true` + IS_BSD_LICENCE_PRESENT=`egrep -c "the terms of the BSD Licence" $FULLFILE || true` + IS_EXCEPTION=`echo $FULLFILE | egrep -c "common/utils/collection/tree.h|common/utils/collection/queue.h|common/utils/itti_analyzer/common/queue.h|openair3/UTILS/tree.h|openair3/UTILS/queue.h|openair3/GTPV1-U/nw-gtpv1u|openair2/UTIL/OPT/ws_|openair3/NAS/COMMON/milenage.h" || true` if [ $IS_OAI_LICENCE_PRESENT -eq 0 ] && [ $IS_BSD_LICENCE_PRESENT -eq 0 ] then if [ $IS_NFAPI -eq 0 ] && [ $IS_EXCEPTION -eq 0 ] diff --git a/openair3/NAS/COMMON/milenage.h b/openair3/NAS/COMMON/milenage.h index 7c2de2038f..3cb61a0cac 100644 --- a/openair3/NAS/COMMON/milenage.h +++ b/openair3/NAS/COMMON/milenage.h @@ -1,6 +1,8 @@ /* - Adpatatipn of SW from hereafter license + Adaptatipn of SW from hereafter license Author: laurent.thomas@open-cells.com + The OpenAirInterface project uses this copy under the terms of BSD + license. */ /* 3GPP AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208) From 489fc7c0fe799f15d1d90f38c51d98dbcb7e1250 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 12 Oct 2020 10:52:46 +0200 Subject: [PATCH 052/149] trial --- openair3/NAS/COMMON/aes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair3/NAS/COMMON/aes.h b/openair3/NAS/COMMON/aes.h index ed103306e4..e9d26521d6 100644 --- a/openair3/NAS/COMMON/aes.h +++ b/openair3/NAS/COMMON/aes.h @@ -1,5 +1,5 @@ #ifndef AES_H -#define EAS_H +#define AES_H // Implemented from Wikipedia description and OpenAir HSS From dd43752bbe5b390c8210346a1476a0f0e23dd620 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 16 Oct 2020 11:41:14 +0200 Subject: [PATCH 053/149] add thread pool init --- cmake_targets/CMakeLists.txt | 5 +++++ executables/ocp-gnb.c | 6 ++++++ openair1/PHY/defs_L1_NB_IoT.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 8c568f0da3..ea165edeaf 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2145,6 +2145,11 @@ set (GTPV1U_SRC add_library(GTPV1U ${GTPV1U_SRC}) add_dependencies(GTPV1U rrc_flag) +add_library (GTPV1U_OCP +${OPENAIR3_DIR}/ocp-gtp/gtp_itf.cpp +) +include_directories(${OPENAIR3_DIR}/ocp-gtp) + #NR case set (NR_GTPV1U_SRC ${NR_RRC_DIR}/rrc_gNB_GTPV1U.c diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index bcd337b836..0b93e1fbef 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -258,6 +258,12 @@ void init_gNB_proc(int inst) { proc->RU_mask_tx = (1<num_RU)-1; proc->RU_mask_prach =0; pthread_mutex_init( &gNB->UL_INFO_mutex, NULL); + gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); + gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + char ul_pool[] = "-1,-1"; + initTpool(ul_pool, gNB->threadPool, false); + initNotifiedFIFO(gNB->respDecode); + } /// eNB kept in function name for nffapi calls, TO FIX diff --git a/openair1/PHY/defs_L1_NB_IoT.h b/openair1/PHY/defs_L1_NB_IoT.h index 1f8c0b8eee..cc3ec94a95 100644 --- a/openair1/PHY/defs_L1_NB_IoT.h +++ b/openair1/PHY/defs_L1_NB_IoT.h @@ -32,7 +32,9 @@ #ifndef __PHY_DEFS_NB_IOT__H__ #define __PHY_DEFS_NB_IOT__H__ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include #include From 6b7eb07224b22ce32be52352387b843d040b7ec0 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 16 Oct 2020 12:01:20 +0200 Subject: [PATCH 054/149] remove gtp work --- cmake_targets/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index ea165edeaf..a86629bf3f 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2145,10 +2145,10 @@ set (GTPV1U_SRC add_library(GTPV1U ${GTPV1U_SRC}) add_dependencies(GTPV1U rrc_flag) -add_library (GTPV1U_OCP -${OPENAIR3_DIR}/ocp-gtp/gtp_itf.cpp -) -include_directories(${OPENAIR3_DIR}/ocp-gtp) +#add_library (GTPV1U_OCP +#${OPENAIR3_DIR}/ocp-gtp/gtp_itf.cpp +#) +#include_directories(${OPENAIR3_DIR}/ocp-gtp) #NR case set (NR_GTPV1U_SRC From f85559abf1a9609f9b903d0defa7e14389898ea4 Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Sun, 18 Oct 2020 23:51:48 -0500 Subject: [PATCH 055/149] Removed hard-coded PUSCH slot at UE; use dynamic grant --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 4 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 264 +++++++++++-------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 6 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h | 2 +- 4 files changed, 157 insertions(+), 119 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 4126b19b0b..209d3a16c7 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -119,8 +119,8 @@ uint32_t ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, int8_t nr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe); -int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format); -int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_index,fapi_nr_dci_indication_pdu_t *dci); +int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, frame_t frame, int slot, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format); +int nr_ue_process_dci_indication_pdu(module_id_t module_id, int cc_id, int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci); uint32_t get_ssb_frame(uint32_t test); uint32_t get_ssb_slot(uint32_t ssb_index); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index e237a910c6..ffbd728b59 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -775,7 +775,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in } } else if (ul_info) { - if (get_softmodem_params()->phy_test && ul_info->slot_tx == 8) { // ULSCH is handled only in phy-test mode (consistently with OAI gNB) + // ULSCH is handled only in phy-test mode (consistently with OAI gNB) + if (get_softmodem_params()->phy_test) { uint8_t nb_dmrs_re_per_rb; uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES]; @@ -794,101 +795,107 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); uint8_t access_mode = SCHEDULED_ACCESS; - // program PUSCH with UL DCI parameters - nr_dcireq_t dcireq; - nr_scheduled_response_t scheduled_response; - fapi_nr_tx_request_t tx_req; - fapi_nr_tx_request_body_t tx_req_body; - fapi_nr_ul_config_request_t *ul_config = &dcireq.ul_config_req; - nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; + fapi_nr_ul_config_request_t *ul_config_req = &mac->ul_config_request; - fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &mac->ul_config_request.ul_config_list[0]; + // Schedule ULSCH only if the frame and slot are as indicated in ul_config_req. + // These values were set based on the values of slot in which UL DCI was received and K2. + if (ul_info->frame_tx == ul_config_req->sfn && ul_info->slot_tx == ul_config_req->slot) { - uint16_t rnti = ulcfg_pdu->pusch_config_pdu.rnti; - uint32_t rb_size = ulcfg_pdu->pusch_config_pdu.rb_size; - uint32_t rb_start = ulcfg_pdu->pusch_config_pdu.rb_start; - uint8_t nr_of_symbols = ulcfg_pdu->pusch_config_pdu.nr_of_symbols; - uint8_t start_symbol_index = ulcfg_pdu->pusch_config_pdu.start_symbol_index; - uint8_t nrOfLayers = 1; - uint8_t mcs_index = ulcfg_pdu->pusch_config_pdu.mcs_index; - uint8_t mcs_table = ulcfg_pdu->pusch_config_pdu.mcs_table; - uint8_t harq_process_id = ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id; - uint8_t rv_index = ulcfg_pdu->pusch_config_pdu.pusch_data.rv_index; - uint16_t l_prime_mask = get_l_prime(nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); - uint8_t dmrs_config_type = 0; - uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; - // These should come from RRC config!!! - uint8_t ptrs_mcs1 = 2; - uint8_t ptrs_mcs2 = 4; - uint8_t ptrs_mcs3 = 10; - uint16_t n_rb0 = 25; - uint16_t n_rb1 = 75; - uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, mcs_index, mcs_table); - uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size); - uint16_t number_dmrs_symbols = 0; - uint16_t ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; + // program PUSCH with UL DCI parameters + nr_dcireq_t dcireq; + nr_scheduled_response_t scheduled_response; + fapi_nr_tx_request_t tx_req; + fapi_nr_tx_request_body_t tx_req_body; + fapi_nr_ul_config_request_t *ul_config = &dcireq.ul_config_req; + nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; + + fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &mac->ul_config_request.ul_config_list[0]; + + uint16_t rnti = ulcfg_pdu->pusch_config_pdu.rnti; + uint32_t rb_size = ulcfg_pdu->pusch_config_pdu.rb_size; + uint32_t rb_start = ulcfg_pdu->pusch_config_pdu.rb_start; + uint8_t nr_of_symbols = ulcfg_pdu->pusch_config_pdu.nr_of_symbols; + uint8_t start_symbol_index = ulcfg_pdu->pusch_config_pdu.start_symbol_index; + uint8_t nrOfLayers = 1; + uint8_t mcs_index = ulcfg_pdu->pusch_config_pdu.mcs_index; + uint8_t mcs_table = ulcfg_pdu->pusch_config_pdu.mcs_table; + uint8_t harq_process_id = ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id; + uint8_t rv_index = ulcfg_pdu->pusch_config_pdu.pusch_data.rv_index; + uint16_t l_prime_mask = get_l_prime(nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); + uint8_t dmrs_config_type = 0; + uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; + // These should come from RRC config!!! + uint8_t ptrs_mcs1 = 2; + uint8_t ptrs_mcs2 = 4; + uint8_t ptrs_mcs3 = 10; + uint16_t n_rb0 = 25; + uint16_t n_rb1 = 75; + uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, mcs_index, mcs_table); + uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size); + uint16_t number_dmrs_symbols = 0; + uint16_t ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; #ifdef DEBUG_DCI - LOG_I(MAC, " UL config params \n rnti: %x \n rb_size: %d \n", - rnti, rb_size); - LOG_I(MAC, "rb_start: %x \n nr_of_symbols: %d \n start_symbol_index: %d \n nrOfLayers: %d \n mcs_index: %d \n \ - mcs_table: %d \n harq_process_id: %d \n ndi: %d \n num_cb: %d \n rv_index: %d \n", - rb_start, nr_of_symbols, start_symbol_index, nrOfLayers, mcs_index, - mcs_table, harq_process_id, ndi, num_cb, rv_index); + LOG_I(MAC, " UL config params \n rnti: %x \n rb_size: %d \n", + rnti, rb_size); + LOG_I(MAC, "rb_start: %x \n nr_of_symbols: %d \n start_symbol_index: %d \n nrOfLayers: %d \n mcs_index: %d \n \ + mcs_table: %d \n harq_process_id: %d \n rv_index: %d \n", + rb_start, nr_of_symbols, start_symbol_index, nrOfLayers, mcs_index, + mcs_table, harq_process_id, rv_index); #endif - // PTRS ports configuration - // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised! - ptrs_ports_list.ptrs_re_offset = 0; + // PTRS ports configuration + // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised! + ptrs_ports_list.ptrs_re_offset = 0; - // Num PRB Overhead from PUSCH-ServingCellConfig - if (mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead == NULL) - N_PRB_oh = 0; - else - N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; + // Num PRB Overhead from PUSCH-ServingCellConfig + if (mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead == NULL) + N_PRB_oh = 0; + else + N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; - ul_config->slot = ul_info->slot_tx; - ul_config->number_pdus = 1; - ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; - ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; - ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; - ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; - ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; - ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; - ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; - ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; - ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; - ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; - ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; - ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; - ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(mcs_index, mcs_table); - ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(mcs_index, mcs_table); + ul_config->slot = ul_info->slot_tx; + ul_config->number_pdus = 1; + ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; + ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; + ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; + ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; + ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; + ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; + ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; + ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; + ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; + ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; + ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; + ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; + ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(mcs_index, mcs_table); + ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(mcs_index, mcs_table); - if (1 << ptrs_time_density >= nr_of_symbols) { - ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS - } + if (1 << ptrs_time_density >= nr_of_symbols) { + ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS + } - get_num_re_dmrs(&ul_config->ul_config_list[0].pusch_config_pdu, - &nb_dmrs_re_per_rb, - &number_dmrs_symbols); + get_num_re_dmrs(&ul_config->ul_config_list[0].pusch_config_pdu, + &nb_dmrs_re_per_rb, + &number_dmrs_symbols); - TBS = nr_compute_tbs(ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order, - ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate, - rb_size, - nr_of_symbols, - nb_dmrs_re_per_rb*number_dmrs_symbols, - N_PRB_oh, - 0, - nrOfLayers); - TBS_bytes = TBS/8; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS_bytes; + TBS = nr_compute_tbs(ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order, + ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate, + rb_size, + nr_of_symbols, + nb_dmrs_re_per_rb*number_dmrs_symbols, + N_PRB_oh, + 0, + nrOfLayers); + TBS_bytes = TBS/8; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS_bytes; if (IS_SOFTMODEM_NOS1){ // Getting IP traffic to be transmitted @@ -930,32 +937,34 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in #endif - dcireq.module_id = mod_id; - dcireq.gNB_index = gNB_index; - dcireq.cc_id = cc_id; - dcireq.frame = rx_frame; - dcireq.slot = rx_slot; + dcireq.module_id = mod_id; + dcireq.gNB_index = gNB_index; + dcireq.cc_id = cc_id; + dcireq.frame = rx_frame; + dcireq.slot = rx_slot; - // Config UL TX PDU - tx_req.slot = slot_tx; - tx_req.sfn = frame_tx; - // tx_req->tx_config // TbD - tx_req.number_of_pdus = 1; - tx_req_body.pdu_length = TBS_bytes; - tx_req_body.pdu_index = 0; - tx_req_body.pdu = ulsch_input_buffer; - tx_req.tx_request_body = &tx_req_body; + // Config UL TX PDU + tx_req.slot = slot_tx; + tx_req.sfn = frame_tx; + // tx_req->tx_config // TbD + tx_req.number_of_pdus = 1; + tx_req_body.pdu_length = TBS_bytes; + tx_req_body.pdu_index = 0; + tx_req_body.pdu = ulsch_input_buffer; + tx_req.tx_request_body = &tx_req_body; + + fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, rx_frame, rx_slot); + if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ + mac->if_module->scheduled_response(&scheduled_response); + } + + // TODO: expand + // Note: Contention resolution is currently not active + if (mac->RA_contention_resolution_timer_active == 1) + ue_contention_resolution(mod_id, gNB_index, cc_id, ul_info->frame_tx); - fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, rx_frame, rx_slot); - if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ - mac->if_module->scheduled_response(&scheduled_response); } - // TODO: expand - // Note: Contention resolution is currently not active - if (mac->RA_contention_resolution_timer_active == 1) - ue_contention_resolution(mod_id, gNB_index, cc_id, ul_info->frame_tx); - } else if (get_softmodem_params()->do_ra){ NR_UE_MAC_INST_t *mac = get_mac_inst(ul_info->module_id); @@ -2430,7 +2439,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, return 0; } ////////////// -int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_index,fapi_nr_dci_indication_pdu_t *dci) { +int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); @@ -2438,10 +2447,10 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits); int dci_format = nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,def_dci_pdu_rel15); - return (nr_ue_process_dci(module_id, cc_id, gNB_index, def_dci_pdu_rel15, dci->rnti, dci_format)); + return (nr_ue_process_dci(module_id, cc_id, gNB_index, frame, slot, def_dci_pdu_rel15, dci->rnti, dci_format)); } -int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){ +int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, frame_t frame, int slot, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){ int bwp_id = 1; @@ -2477,7 +2486,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space * 50 SUL_IND_0_0: */ - ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + // It's redundant to process PUSCH pdu here in the Rx path. This is done + // in the Tx path in nr_ue_scheduler(). Hence removing here. + //ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu.rnti = rnti; nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; /* IDENTIFIER_DCI_FORMATS */ @@ -2515,7 +2526,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc } /* SUL_IND_0_0 */ // To be implemented, FIXME!!! - ul_config->number_pdus = ul_config->number_pdus + 1; + // Removing since it's redundant to process PUSCH PDU in RX path!! + //ul_config->number_pdus = ul_config->number_pdus + 1; break; case NR_UL_DCI_FORMAT_0_1: @@ -2547,7 +2559,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc * 48 UL_SCH_IND * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space */ - ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + // It's redundant to process PUSCH pdu here in the Rx path. This is done + // in the Tx path in nr_ue_scheduler(). Hence removing here. + //ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu.rnti = rnti; nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu_0_1 = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; /* IDENTIFIER_DCI_FORMATS */ @@ -2841,7 +2855,29 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc // A value of "1" indicates UL-SCH shall be transmitted on the PUSCH and // a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH - ul_config->number_pdus = ul_config->number_pdus + 1; + // Calculate the slot in which ULSCH should be scheduled. This is current slot + K2, + // where K2 is the offset between the slot in which UL DCI is received and the slot + // in which ULSCH should be scheduled. K2 is configured in RRC configuration. + + // Get K2 from RRC configuration + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + if (pusch_config->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = pusch_config->pusch_TimeDomainAllocationList->choice.setup; + } + else if (mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + long k2 = *pusch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->k2; + + // Get the numerology to calculate the Tx frame and slot + int mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; + + // Calculate the slot and frame + ul_config->slot = (slot + k2) % nr_slots_per_frame[mu]; + ul_config->sfn = ((slot + k2) % nr_slots_per_frame[mu] > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; + // Removing since it's redundant to process PUSCH PDU in RX path!! + //ul_config->number_pdus = ul_config->number_pdus + 1; + LOG_I(MAC, "nr_ue_process_dci(): Calculated frame and slot for pusch Tx: %d.%d\n", ul_config->sfn, ul_config->slot); break; case NR_DL_DCI_FORMAT_1_0: diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 5d620181d1..5bd5a697cd 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -64,10 +64,10 @@ int handle_bcch_dlsch(module_id_t module_id, int cc_id, unsigned int gNB_index, return 0; } // L2 Abstraction Layer -int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, fapi_nr_dci_indication_pdu_t *dci){ +int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci){ //printf("handle_dci: rnti %x,dci_type %d\n",rnti,dci_type); - return nr_ue_process_dci_indication_pdu(module_id, cc_id, gNB_index, dci); + return nr_ue_process_dci_indication_pdu(module_id, cc_id, gNB_index, frame, slot, dci); } // L2 Abstraction Layer @@ -150,6 +150,8 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ int8_t ret = handle_dci(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, + dl_info->frame, + dl_info->slot, dl_info->dci_ind->dci_list+i); ret_mask |= (ret << FAPI_NR_DCI_IND); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index df2d78f0cb..aba6767465 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -224,7 +224,7 @@ int handle_bcch_bch(module_id_t module_id, int cc_id, unsigned int gNB_index, ui \param pduP pointer to pdu*/ int handle_bcch_dlsch(module_id_t module_id, int cc_id, unsigned int gNB_index, uint32_t sibs_mask, uint8_t *pduP, uint32_t pdu_len); -int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, fapi_nr_dci_indication_pdu_t *dci); +int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci); #endif From 288df1af6d26b874f90e2b286cee8ddbbf3af50f Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Tue, 20 Oct 2020 07:59:04 +0200 Subject: [PATCH 056/149] remove hardcoding of FR2 parameters --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- openair2/RRC/LTE/rrc_eNB.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 09372fe6d3..7a7ce43679 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -974,7 +974,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, pusch_pdu->resource_alloc = 1; //type 1 pusch_pdu->rb_start = 0; if (get_softmodem_params()->phy_test==1) - pusch_pdu->rb_size = 5; + pusch_pdu->rb_size = min(pusch_pdu->bwp_size,50); else pusch_pdu->rb_size = pusch_pdu->bwp_size; } diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 0b7a34239b..18b7173a08 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -3295,7 +3295,10 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.periodicityAndOffset_r15.present = LTE_MTC_SSB_NR_r15__periodicityAndOffset_r15_PR_sf20_r15; MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.periodicityAndOffset_r15.choice.sf20_r15 = 0; MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.ssb_Duration_r15 = LTE_MTC_SSB_NR_r15__ssb_Duration_r15_sf4; - MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15 = LTE_RS_ConfigSSB_NR_r15__subcarrierSpacingSSB_r15_kHz120; + if (rrc_inst->nr_scg_ssb_freq > 2016666) //FR2 + MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15 = LTE_RS_ConfigSSB_NR_r15__subcarrierSpacingSSB_r15_kHz120; + else + MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15 = LTE_RS_ConfigSSB_NR_r15__subcarrierSpacingSSB_r15_kHz30; MeasObj2->measObject.choice.measObjectNR_r15.quantityConfigSet_r15 = 1; MeasObj2->measObject.choice.measObjectNR_r15.ext1 = calloc(1, sizeof(struct LTE_MeasObjectNR_r15__ext1)); @@ -3306,7 +3309,10 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t if (MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15 == NULL) exit(1); MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->present = LTE_MeasObjectNR_r15__ext1__bandNR_r15_PR_setup; - MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->choice.setup = 261; + if (rrc_inst->nr_scg_ssb_freq > 2016666) //FR2 + MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->choice.setup = 261; + else + MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->choice.setup = 78; ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj2); } From 7344ca7e3b2fa94b1b6b68278c01f0c4ea783168 Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Tue, 20 Oct 2020 22:34:10 -0500 Subject: [PATCH 057/149] Support for PUSCH config requests for multiple UL slots --- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 +- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 19 ++++- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 89 +++++++++++++------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- 4 files changed, 75 insertions(+), 37 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 97c99b6050..aaf8ec7414 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -247,7 +247,7 @@ typedef struct { uint8_t generate_nr_prach; //// FAPI-like interface message - fapi_nr_ul_config_request_t ul_config_request; + fapi_nr_ul_config_request_t *ul_config_request; fapi_nr_dl_config_request_t dl_config_request; /// Interface module instances diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index bae8e0d3c0..7bc1d13210 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -57,10 +57,21 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) if (IS_SOFTMODEM_NOS1){ if (rlc_module_init(0) != 0) { - LOG_I(RLC, "Problem at RLC initiation \n"); - } - pdcp_layer_init(); - nr_DRB_preconfiguration(); + LOG_I(RLC, "Problem at RLC initiation \n"); + } + pdcp_layer_init(); + nr_DRB_preconfiguration(); + } + + // Allocate memory for ul_config_request in the mac instance. This is now a pointer and will + // point to a list of structures (one for each UL slot) to store PUSCH scheduling parameters + // received from UL DCI. + if (nr_ue_mac_inst->scc) { + int num_slots_ul = nr_ue_mac_inst->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; + if (nr_ue_mac_inst->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols>0) + num_slots_ul++; + LOG_D(MAC, "Initializing ul_config_request. num_slots_ul = %d\n", num_slots_ul); + nr_ue_mac_inst->ul_config_request = (fapi_nr_ul_config_request_t *)calloc(num_slots_ul, sizeof(fapi_nr_ul_config_request_t)); } } else LOG_I(MAC,"Running without RRC instance\n"); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ffbd728b59..4fd2c6b898 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -77,7 +77,7 @@ extern int bwp_id; extern dci_pdu_rel15_t *def_dci_pdu_rel15; -extern const uint16_t nr_slots_per_frame[5]; +extern const uint8_t nr_slots_per_frame[5]; extern void mac_rlc_data_ind ( const module_id_t module_idP, @@ -795,7 +795,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); uint8_t access_mode = SCHEDULED_ACCESS; - fapi_nr_ul_config_request_t *ul_config_req = &mac->ul_config_request; + fapi_nr_ul_config_request_t *ul_config_req = &mac->ul_config_request[1]; // Temporary workaround due to change in the structure to accommodate multiple UL config requests // Schedule ULSCH only if the frame and slot are as indicated in ul_config_req. // These values were set based on the values of slot in which UL DCI was received and K2. @@ -809,7 +809,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in fapi_nr_ul_config_request_t *ul_config = &dcireq.ul_config_req; nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; - fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &mac->ul_config_request.ul_config_list[0]; + fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &mac->ul_config_request[1].ul_config_list[0]; // Temporary workaround uint16_t rnti = ulcfg_pdu->pusch_config_pdu.rnti; uint32_t rb_size = ulcfg_pdu->pusch_config_pdu.rb_size; @@ -975,7 +975,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_body_t tx_req_body; - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[1]; // Temporary workaround fapi_nr_ul_config_request_pdu_t *ul_config_list = &ul_config->ul_config_list[ul_config->number_pdus]; uint16_t TBS_bytes = ul_config_list->pusch_config_pdu.pusch_data.tb_size; @@ -1087,7 +1087,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[1]; // Temporary workaround fapi_nr_ul_config_prach_pdu *prach_config_pdu; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_prach_config_t *prach_config = &cfg->prach_config; @@ -2450,13 +2450,45 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in return (nr_ue_process_dci(module_id, cc_id, gNB_index, frame, slot, def_dci_pdu_rel15, dci->rnti, dci_format)); } +long get_ul_config_request(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, uint8_t time_domain_ind, fapi_nr_ul_config_request_t **ul_config) { + // Get offset K2 from RRC configuration + NR_PUSCH_Config_t *pusch_config=mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + if (pusch_config->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = pusch_config->pusch_TimeDomainAllocationList->choice.setup; + } + else if (mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + long k2 = *pusch_TimeDomainAllocationList->list.array[time_domain_ind]->k2; + + // Calculate the index of the UL slot in mac->ul_config_request list. This is + // based on the TDD pattern (slot configuration period) and number of UL+mixed + // slots in the period. TS 38.213 Sec 11.1 + NR_TDD_UL_DL_Pattern_t *tdd_pattern = &mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int num_slots_per_tdd = nr_slots_per_frame[*mac->scc->ssbSubcarrierSpacing] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity); + const int num_slots_ul = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); + int index = slot + k2 + num_slots_ul - num_slots_per_tdd; + LOG_D(MAC, "nr_ue_procedures: get_ul_config() k2 %ld, slots per tdd %d, num_slots_ul %d, index %d\n", + k2, + num_slots_per_tdd, + num_slots_ul, + index); + + *ul_config = &mac->ul_config_request[index]; + + return k2; +} + int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, frame_t frame, int slot, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){ int bwp_id = 1; + int mu = 0; + long k2 = 0; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + fapi_nr_ul_config_request_t *ul_config = NULL; //const uint16_t n_RB_DLBWP = dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP; //make sure this has been set AssertFatal(mac->DLbwp[0]!=NULL,"DLbwp[0] should not be zero here!\n"); @@ -2486,9 +2518,11 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space * 50 SUL_IND_0_0: */ - // It's redundant to process PUSCH pdu here in the Rx path. This is done - // in the Tx path in nr_ue_scheduler(). Hence removing here. - //ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + // Get the UL config request for the slot in which PUSCH will be scheduled + k2 = get_ul_config_request(mac, frame, slot, dci->frequency_hopping_flag.val, &ul_config); + AssertFatal(ul_config != NULL, "nr_ue_process_dci(): ul_config is NULL\n"); + + ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu.rnti = rnti; nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; /* IDENTIFIER_DCI_FORMATS */ @@ -2526,8 +2560,14 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } /* SUL_IND_0_0 */ // To be implemented, FIXME!!! - // Removing since it's redundant to process PUSCH PDU in RX path!! - //ul_config->number_pdus = ul_config->number_pdus + 1; + // Get the numerology to calculate the Tx frame and slot + mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; + + // Calculate the slot and frame for PUSCH transmission + ul_config->slot = (slot + k2) % nr_slots_per_frame[mu]; + ul_config->sfn = ((slot + k2) % nr_slots_per_frame[mu] > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; + LOG_D(MAC, "nr_ue_process_dci(): Calculated frame and slot for pusch Tx: %d.%d, number of pdus %d\n", ul_config->sfn, ul_config->slot, ul_config->number_pdus); + ul_config->number_pdus = ul_config->number_pdus + 1; break; case NR_UL_DCI_FORMAT_0_1: @@ -2559,9 +2599,11 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr * 48 UL_SCH_IND * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space */ - // It's redundant to process PUSCH pdu here in the Rx path. This is done - // in the Tx path in nr_ue_scheduler(). Hence removing here. - //ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + // Get the UL config request for the slot in which PUSCH will be scheduled + k2 = get_ul_config_request(mac, frame, slot, dci->frequency_hopping_flag.val, &ul_config); + AssertFatal(ul_config != NULL, "nr_ue_process_dci(): ul_config is NULL\n"); + + ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu.rnti = rnti; nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu_0_1 = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; /* IDENTIFIER_DCI_FORMATS */ @@ -2854,30 +2896,15 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* UL_SCH_IND */ // A value of "1" indicates UL-SCH shall be transmitted on the PUSCH and // a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH - - // Calculate the slot in which ULSCH should be scheduled. This is current slot + K2, - // where K2 is the offset between the slot in which UL DCI is received and the slot - // in which ULSCH should be scheduled. K2 is configured in RRC configuration. - - // Get K2 from RRC configuration - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - if (pusch_config->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = pusch_config->pusch_TimeDomainAllocationList->choice.setup; - } - else if (mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - long k2 = *pusch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->k2; // Get the numerology to calculate the Tx frame and slot int mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; - // Calculate the slot and frame + // Calculate the slot and frame for PUSCH transmission ul_config->slot = (slot + k2) % nr_slots_per_frame[mu]; ul_config->sfn = ((slot + k2) % nr_slots_per_frame[mu] > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; - // Removing since it's redundant to process PUSCH PDU in RX path!! - //ul_config->number_pdus = ul_config->number_pdus + 1; LOG_I(MAC, "nr_ue_process_dci(): Calculated frame and slot for pusch Tx: %d.%d\n", ul_config->sfn, ul_config->slot); + ul_config->number_pdus = ul_config->number_pdus + 1; break; case NR_DL_DCI_FORMAT_1_0: diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 5bd5a697cd..55b30484c6 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -135,7 +135,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ module_id_t module_id = dl_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[1]; // Temporary workaround if (!dl_info->dci_ind && !dl_info->rx_ind) { // UL indication to schedule DCI reception From c8111292e99da9f600f0c5015e7d95828d232d26 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 22 Oct 2020 21:06:35 +0200 Subject: [PATCH 058/149] fix warnings from merge --- doc/SW_archi.md | 62 +- executables/main-ocp.c | 7 - executables/nr-softmodem.c | 2 +- executables/ocp-gnb.c | 92 +- openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 2 +- openair1/PHY/TOOLS/lte_phy_scope.c | 1 - openair1/PHY/TOOLS/oai_dfts.c | 4543 ++++++++++------- openair1/SIMULATION/LTE_PHY/common_sim.h | 4 - openair1/SIMULATION/LTE_PHY/dlsim.c | 3 + openair1/SIMULATION/LTE_PHY/ulsim.c | 5 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 1 + openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 8 +- openair3/NAS/COMMON/milenage.h | 3 + openair3/NAS/gNB/network_process_nas.c | 1 + 14 files changed, 2830 insertions(+), 1904 deletions(-) diff --git a/doc/SW_archi.md b/doc/SW_archi.md index 3dfa15193a..e553984437 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -29,23 +29,28 @@ the function main() initializes the data from configuration file The infinite loop: ## rx_rf() Collect radio signal samples from RF board + all SDR processing is triggered by I/Q sample reception and it's date (timestamp) + TX I/Q samples will have a date in the future, compared to RX timestamp called for each 5G NR slot it blocks until data is available the internal time comes from the RF board sampling numbers (each sample has a incremental number representing a very accurate timing) -raw incoming data is in buffer called "rxdata" +raw incoming data is in buffer called "rxdata" + We derivate frame number, slot number, ... from the RX timestamp {: .func2} -### nr_fep_full() +## nr_fep_full() "front end processing" of uplink signal performs DFT on the signal -same function (duplicates): phy_procedures_gNB_common_RX() -it computes the buffer rxdataF (for frequency) from rxdata (samples over time) +same function (duplicates): phy_procedures_gNB_common_RX() +it computes the buffer rxdataF (for frequency) from rxdata (samples over time) +rxdataF is the rxdata in frequency domain, phase aligned {: .func3} -### gNB_top() +## gNB_top() only compute frame numbre, slot number, ... {: .func3} -### ocp_rxtx() +## ocp_rxtx() main processing for both UL and DL +start by calling oai_subframe_ind() that trigger processing in pnf_p7_subframe_ind() purpose ??? all the context is in the passed structure UL_INFO the context is not very clear: there is a mutex on it, but not actual coherency (see below handle_nr_rach() assumes data is up-to-date) @@ -54,7 +59,7 @@ Then, phy_procedures_gNB_uespec_RX will hereafter replace the data for the next This is very tricky and not thread safe at all. {: .func3} -#### NR_UL_indication() +### NR_UL_indication() This block processes data already decoded and stored in structures behind UL_INFO {: .func4} @@ -71,22 +76,19 @@ if the input is a UE RACH detection handles ulsch data prepared by nr_fill_indication() {: .func4} * gNB_dlsch_ulsch_scheduler () -also calls "run_pdcp()", as this is not a autonomous thread, it needs to be called here to update traffic requests (DL) and to propagate waiting UL to upper layers -Calls schedule_nr_mib() that calls mac_rrc_nr_data_req() to fill MIB, -Calls each channel allocation: schedule SI, schedule_ul, schedule_dl, ... -this is a major entry for "phy-test" mode: in this mode, the allocation is fixed -all these channels goes to mac_rrc_nr_data_req() to get the data to transmit +the **scheduler** is called here, see dedicated chapter {: .func4} * NR_Schedule_response() process as per the scheduler decided {: .func4} -#### L1_nr_prach_procedures() +### L1_nr_prach_procedures() ???? {: .func4} -#### phy_procedures_gNB_uespec_RX() +### phy_procedures_gNB_uespec_RX() * nr_decode_pucch0() -actual CCH channel decoding +actual CCH channel decoding form rxdataF (rx data in frequency domain) +populates UL_INFO.uci_ind, actual uci data is in gNB->pucch {: .func4} * nr_rx_pusch() {: .func4} @@ -113,12 +115,12 @@ this function creates the "likelyhood ratios" {: .func4} * nr_ulsch_decoding() {: .func4} - * nr_fill_indication() -{: .func4} -populated the data for the next call to "NR_UL_indication()" + * nr_fill_indication() +populate the data for the next call to "NR_UL_indication()" +it would be better to call **NR_UL_indication()** now instead of before (on previous slot) {: .func4} -#### phy_procedures_gNB_TX() +### phy_procedures_gNB_TX() * nr_common_signal_procedures() generate common signals {: .func4} @@ -145,6 +147,25 @@ The scheduler is called by the chain: nr_ul_indication()=>gNB_dlsch_ulsch_schedu It calls sub functions to process each physical channel (rach, ...) The scheduler uses and internal map of used RB: vrb_map and vrb_map_UL, so each specific channel scheduler can see the already filled RB in each subframe (the function gNB_dlsch_ulsch_scheduler() clears these two arrays when it starts) +The scheduler also calls "run_pdcp()", as this is not a autonomous thread, it needs to be called here to update traffic requests (DL) and to propagate waiting UL to upper layers +After calling run_pdcp, it updates "rlc" time data but it doesn't actually process rlc +it sends a iiti message to activate the thread for RRC, the answer will be asynchronous in ???? + +Calls schedule_nr_mib() that calls mac_rrc_nr_data_req() to fill MIB, + +Calls each channel allocation: schedule SI, schedule_ul, schedule_dl, ... +this is a major entry for "phy-test" mode: in this mode, the allocation is fixed +all these channels goes to mac_rrc_nr_data_req() to get the data to transmit + +nr_schedule_ue_spec() is called +* calls nr_simple_dlsch_preprocessor()=> mac_rlc_status_ind() mac_rlc_status_ind() locks and checks directly inside rlc data the quantity of waiting data. So, the scheduler can allocate RBs +* calls nr_update_pucch_scheduling() + * get_pdsch_to_harq_feedback() to schedule retransmission in DL + +Calls nr_fill_nfapi_dl_pdu() to actually populate what should be done by the lower layers to make the Tx subframe + + + # RRC RRC is a regular thread with itti loop on queue: TASK_RRC_GNB it receives it's configuration in message NRRRC_CONFIGURATION_REQ, then real time mesages for all events: S1/NGAP events, X2AP messages and RRC_SUBFRAME_PROCESS @@ -155,7 +176,8 @@ how does it communicate to scheduler ? # RLC -RLC code is new implementation. +RLC code is new implementation, not using OAI mechanisms: it is implmented directly on pthreads, ignoring OAI common functions. +It runs a thread waiting incoming data, but it is mainly running inside calling thread. It is a library, running in thread RRC (except on itti message: F1AP_UL_RRC_MESSAGE for F1). # NGAP diff --git a/executables/main-ocp.c b/executables/main-ocp.c index 13a9f7226a..6e5857d6d1 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -1098,8 +1098,6 @@ int restart_L1L2(module_id_t enb_id) { /* TODO this should be done for all RUs associated to this eNB */ memcpy(&ru->frame_parms, &RC.eNB[enb_id][0]->frame_parms, sizeof(LTE_DL_FRAME_PARMS)); - RC.ru_mask |= (1 << ru->idx); - /* reset the list of connected UEs in the MAC, since in this process with * loose all UEs (have to reconnect) */ init_UE_info(&RC.mac[enb_id]->UE_info); @@ -1112,11 +1110,6 @@ int restart_L1L2(module_id_t enb_id) { msg_p = itti_alloc_new_message(TASK_ENB_APP, RRC_CONFIGURATION_REQ); RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration; itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); - /* TODO XForms might need to be restarted, but it is currently (09/02/18) - * broken, so we cannot test it */ - init_RU_proc(ru); - ru->rf_map.card = 0; - ru->rf_map.chain = 0; /* CC_id + chain_offset;*/ init_eNB_afterRU(); printf("Sending sync to all threads\n"); pthread_mutex_lock(&sync_mutex); diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index a3d0b325d6..8271e66e2f 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -956,7 +956,7 @@ if(!IS_SOFTMODEM_NOS1) // once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init gNBs\n"); if(IS_SOFTMODEM_DOFORMS) { - + sleep(1); scopeParms_t p; p.argc=&argc; p.argv=argv; diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 65db084767..67f68f43e3 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -56,7 +56,6 @@ #include #include volatile int oai_exit; -int transmission_mode; int single_thread_flag=1; uint32_t do_forms=0; unsigned int mmapped_dma=0; @@ -201,23 +200,6 @@ static inline int ocp_rxtx(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { return(0); } -void gNB_top(gNB_L1_proc_t *proc, struct RU_t_s *ru) { - gNB_L1_rxtx_proc_t *L1_proc = &proc->L1_proc; - NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; - RU_proc_t *ru_proc=&ru->proc; - proc->timestamp_rx = ru_proc->timestamp_rx; - L1_proc->frame_rx = proc->frame_rx = proc->frame_prach = ru_proc->frame_rx = - (ru_proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; - L1_proc->slot_rx = proc->slot_rx = proc->slot_prach = - ru_proc->tti_rx; // computed before in caller function - L1_proc->timestamp_tx = proc->timestamp_tx = ru_proc->timestamp_tx = - ru_proc->timestamp_rx + - sf_ahead*fp->samples_per_subframe; - L1_proc->frame_tx = proc->frame_tx = ru_proc->frame_tx = - (proc->timestamp_tx / (fp->samples_per_subframe*10))&1023; - L1_proc->slot_tx = ru_proc->tti_tx = - (L1_proc->slot_rx + sl_ahead)%fp->slots_per_frame; -} static void *process_stats_thread(void *param) { PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param; @@ -253,12 +235,11 @@ void init_gNB_proc(int inst) { proc->RU_mask_tx = (1<num_RU)-1; proc->RU_mask_prach =0; pthread_mutex_init( &gNB->UL_INFO_mutex, NULL); - gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); - gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->threadPool = (tpool_t *)malloc(sizeof(tpool_t)); + gNB->respDecode = (notifiedFIFO_t *) malloc(sizeof(notifiedFIFO_t)); char ul_pool[] = "-1,-1"; initTpool(ul_pool, gNB->threadPool, false); initNotifiedFIFO(gNB->respDecode); - } /// eNB kept in function name for nffapi calls, TO FIX @@ -319,7 +300,7 @@ static void get_options(void) { memset((void *)&RC,0,sizeof(RC)); /* Read RC configuration file */ NRRCConfig(); - printf("Configuration: nb_rrc_inst %d, nb_nr_L1_inst %d, nb_ru %hhu\n",RC.nb_nr_inst,RC.nb_nr_L1_inst,RC.nb_RU); + printf("Configuration: nb_rrc_inst %d, nb_nr_L1_inst %d, nb_ru %hhd\n", RC.nb_nr_inst,RC.nb_nr_L1_inst,RC.nb_RU); } AssertFatal(RC.nb_nr_L1_inst == 1 && RC.nb_RU == 1, "Only one gNB, one RU and one carrier is supported\n"); @@ -351,15 +332,8 @@ static void init_pdcp(void) { } pdcp_module_init(pdcp_initmask); - /*if (NODE_IS_CU(RC.rrc[0]->node_type)) { - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); - } else {*/ pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); - //} - /*} else { - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); - }*/ } void init_main_gNB(void) { @@ -807,15 +781,11 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { static void *ru_thread( void *param ) { RU_t *ru = (RU_t *)param; - RU_proc_t *proc = &ru->proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,NB_functions[ru->function],NB_timing[ru->if_timing]); - nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp); nr_dump_frame_parms(fp); AssertFatal(openair0_device_load(&ru->rfdevice,&ru->openair0_cfg)==0,"Cannot connect to local radio\n"); AssertFatal(ru->rfdevice.trx_start_func(&ru->rfdevice) == 0,"Could not start the RF device\n"); - tpool_t *threadPool=(tpool_t *)malloc(sizeof(tpool_t)); - initTpool("-1,-1,-1", threadPool, true); int64_t slot=-1; int64_t nextHWTSshouldBe=0, nextRxTSlogical=0; // weird globals, used in NR_IF_Module.c @@ -843,23 +813,23 @@ static void *ru_thread( void *param ) { LOG_E(HW,"reading a stream must be continuous, %ld, %ld\n", HWtimeStamp, nextHWTSshouldBe); nextHWTSshouldBe=HWtimeStamp+rxs; - proc->timestamp_rx=nextRxTSlogical; + ru->proc.timestamp_rx=nextRxTSlogical; nextRxTSlogical+=samples_per_slot; - int64_t HW_to_logical_RxTSoffset=(int64_t)HWtimeStamp-(int64_t)proc->timestamp_rx; - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; - uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; - float offsetInSubframe=proc->timestamp_rx % fp->samples_per_subframe; - proc->tti_rx = (idx_sf * fp->slots_per_subframe + - lroundf(offsetInSubframe / fp->samples_per_slot0))% - fp->slots_per_frame; + int64_t HW_to_logical_RxTSoffset=(int64_t)HWtimeStamp-(int64_t)ru->proc.timestamp_rx; + ru->proc.frame_rx = (ru->proc.timestamp_rx / (fp->samples_per_subframe*10))&1023; + uint32_t idx_sf = ru->proc.timestamp_rx / fp->samples_per_subframe; + float offsetInSubframe=ru->proc.timestamp_rx % fp->samples_per_subframe; + ru->proc.tti_rx = (idx_sf * fp->slots_per_subframe + + lroundf(offsetInSubframe / fp->samples_per_slot0))% + fp->slots_per_frame; LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, slot %d.%d / %d\n", ru->idx, 0, - (unsigned long long int)proc->timestamp_rx, - (int)ru->ts_offset,proc->frame_rx,proc->tti_rx,proc->tti_tx,fp->slots_per_frame); - int slot_type = nr_slot_select(&ru->gNB_list[0]->gNB_config,proc->frame_rx,proc->tti_rx); + (unsigned long long int)ru->proc.timestamp_rx, + (int)ru->ts_offset,ru->proc.frame_rx,ru->proc.tti_rx,ru->proc.tti_tx,fp->slots_per_frame); + int slot_type = nr_slot_select(&ru->gNB_list[0]->gNB_config,ru->proc.frame_rx,ru->proc.tti_rx); if (slot_type == NR_UPLINK_SLOT || slot_type == NR_MIXED_SLOT) { - nr_fep_full(ru,proc->tti_rx); + nr_fep_full(ru,ru->proc.tti_rx); for (int aa=0; aanb_rx; aa++) memcpy((void *)RC.gNB[0]->common_vars.rxdataF[aa], @@ -868,33 +838,47 @@ static void *ru_thread( void *param ) { LOG_D(PHY, "rxdataF energy: %d\n", signal_energy(ru->common.rxdataF[0], fp->symbols_per_slot*fp->ofdm_symbol_size)); } - gNB_top(&RC.gNB[0][0].proc, ru); - gNB_L1_rxtx_proc_t *L1_proc = &RC.gNB[0][0].proc.L1_proc; + gNB_L1_proc_t *gNBproc=&RC.gNB[0][0].proc; + gNB_L1_rxtx_proc_t *L1_proc = &gNBproc->L1_proc; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + gNBproc->timestamp_rx = ru->proc.timestamp_rx; + L1_proc->frame_rx = gNBproc->frame_rx = gNBproc->frame_prach = ru->proc.frame_rx = + (ru->proc.timestamp_rx / (fp->samples_per_subframe*10))&1023; + L1_proc->slot_rx = gNBproc->slot_rx = gNBproc->slot_prach = + ru->proc.tti_rx; // computed before in caller function + L1_proc->timestamp_tx = gNBproc->timestamp_tx = ru->proc.timestamp_tx = + ru->proc.timestamp_rx + + sf_ahead*fp->samples_per_subframe; + L1_proc->frame_tx = gNBproc->frame_tx = ru->proc.frame_tx = + (gNBproc->timestamp_tx / (fp->samples_per_subframe*10))&1023; + L1_proc->slot_tx = ru->proc.tti_tx = + (L1_proc->slot_rx + sl_ahead)%fp->slots_per_frame; if (ocp_rxtx(&RC.gNB[0][0],L1_proc) < 0) LOG_E(PHY,"gNB %d CC_id %d failed during execution\n",RC.gNB[0][0].Mod_id,RC.gNB[0][0].CC_id); // do TX front-end processing if needed (precoding and/or IDFTs) //ru->feptx_prec(ru,proc->frame_tx,proc->tti_tx); - nr_feptx_prec(ru,proc->frame_tx,proc->tti_tx); + nr_feptx_prec(ru,ru->proc.frame_tx,ru->proc.tti_tx); // do OFDM with/without TX front-end processing if needed //ru->feptx_ofdm nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config; - if (nr_slot_select(cfg,proc->frame_tx, proc->tti_tx ) != NR_UPLINK_SLOT) { + if (nr_slot_select(cfg,ru->proc.frame_tx, ru->proc.tti_tx ) != NR_UPLINK_SLOT) { int aa=0; // antenna 0 hardcoded NR_DL_FRAME_PARMS *fp=ru->nr_frame_parms; - nr_feptx0(ru,proc->tti_tx,0,fp->symbols_per_slot,aa); - int *txdata = &ru->common.txdata[aa][fp->get_samples_slot_timestamp(proc->tti_tx,fp,0)]; + nr_feptx0(ru,ru->proc.tti_tx,0,fp->symbols_per_slot,aa); + int *txdata = &ru->common.txdata[aa][fp->get_samples_slot_timestamp(ru->proc.tti_tx,fp,0)]; int slot_sizeF = (fp->ofdm_symbol_size)* ((NFAPI_CP_NORMAL == 1) ? 12 : 14); LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, slot %d: txp (time %ld) %d dB, txp (freq) %d dB\n", - proc->frame_tx,proc->tti_tx,proc->timestamp_tx,dB_fixed(signal_energy((int32_t *)txdata,fp->get_samples_per_slot( - proc->tti_tx,fp))),dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF))); + ru->proc.frame_tx,ru->proc.tti_tx,ru->proc.timestamp_tx, + dB_fixed(signal_energy((int32_t *)txdata,fp->get_samples_per_slot(ru->proc.tti_tx,fp))), + dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF))); } // do outgoing fronthaul (south) if needed - tx_rf(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx+HW_to_logical_RxTSoffset); + tx_rf(ru,ru->proc.frame_tx,ru->proc.tti_tx,ru->proc.timestamp_tx+HW_to_logical_RxTSoffset); slot++; } diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index a82ac21e63..347fbb026b 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2248,7 +2248,6 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, uint8_t Nl0; //= dlsch0_harq->Nl; uint8_t Nl1; #endif - RU_t *ru; if ((dlsch0 != NULL) && (dlsch1 != NULL)){ @@ -2431,6 +2430,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, // mapping ue specific beamforming weights from UE specified DLSCH structure to RU beam weights for the eNB /* for (int ru_id=0;ru_idnum_eNB;eNB_id++){ if (phy_vars_eNB == ru->eNB_list[eNB_id]) { diff --git a/openair1/PHY/TOOLS/lte_phy_scope.c b/openair1/PHY/TOOLS/lte_phy_scope.c index deef165d4f..acd22bc78d 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.c +++ b/openair1/PHY/TOOLS/lte_phy_scope.c @@ -144,7 +144,6 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form, PHY_VARS_eNB *phy_vars_enb, int UE_id) { LOG_D(HW,"scope for UE%d\n", UE_id); - int eNB_id = 0; int i,i2,arx,atx,ind,k; LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_enb->frame_parms; int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti; diff --git a/openair1/PHY/TOOLS/oai_dfts.c b/openair1/PHY/TOOLS/oai_dfts.c index 531053f71d..25244eeff5 100644 --- a/openair1/PHY/TOOLS/oai_dfts.c +++ b/openair1/PHY/TOOLS/oai_dfts.c @@ -29,19 +29,19 @@ #include #ifndef M_PI - #define M_PI 3.14159265358979323846 +#define M_PI 3.14159265358979323846 #endif #define OAIDFTS_MAIN #ifndef MR_MAIN - #include "PHY/defs_common.h" - #include "PHY/impl_defs_top.h" +#include "PHY/defs_common.h" +#include "PHY/impl_defs_top.h" #else - #include "time_meas.h" - #include "LOG/log.h" - #define debug_msg - #define ONE_OVER_SQRT2_Q15 23170 +#include "time_meas.h" +#include "LOG/log.h" +#define debug_msg +#define ONE_OVER_SQRT2_Q15 23170 - int oai_exit=0; +int oai_exit=0; #endif #define ONE_OVER_SQRT3_Q15 18919 @@ -56,68 +56,88 @@ #define print_ints(s,x) printf("%s %d %d %d %d\n",s,(x)[0],(x)[1],(x)[2],(x)[3]) +const static int16_t conjugatedft[32] __attribute__((aligned(32))) = {-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1}; + + +const static int16_t reflip[32] __attribute__((aligned(32))) = {1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1}; + -#ifdef __AVX2__ -typedef union { - __m256i v256; - __m128i v128; - int8_t scal8[32]; - int16_t scal16[16]; -} uniVect_t; -const static uniVect_t perm_mask= {.scal8={2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13,18,19,16,17,22,23,20,21,26,27,24,25,30,31,28,29}}; -const static uniVect_t reflip= {.scal16= {1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1}}; -const static uniVect_t conjugatedft= {.scal16= {-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1}}; -#endif #if defined(__x86_64__) || defined(__i386__) static inline void cmac(__m128i a,__m128i b, __m128i *re32, __m128i *im32) __attribute__((always_inline)); -static inline void cmac(__m128i a,__m128i b, __m128i *re32, __m128i *im32) { +static inline void cmac(__m128i a,__m128i b, __m128i *re32, __m128i *im32) +{ + __m128i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; - cmac_tmp = _mm_sign_epi16(b,reflip.v128); + + cmac_tmp = _mm_sign_epi16(b,*(__m128i*)reflip); cmac_tmp_re32 = _mm_madd_epi16(a,cmac_tmp); + + // cmac_tmp = _mm_shufflelo_epi16(b,_MM_SHUFFLE(2,3,0,1)); // cmac_tmp = _mm_shufflehi_epi16(cmac_tmp,_MM_SHUFFLE(2,3,0,1)); cmac_tmp = _mm_shuffle_epi8(b,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); cmac_tmp_im32 = _mm_madd_epi16(cmac_tmp,a); + *re32 = _mm_add_epi32(*re32,cmac_tmp_re32); *im32 = _mm_add_epi32(*im32,cmac_tmp_im32); } static inline void cmacc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) __attribute__((always_inline)); -static inline void cmacc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) { +static inline void cmacc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) +{ + __m128i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; + + cmac_tmp_re32 = _mm_madd_epi16(a,b); - cmac_tmp = _mm_sign_epi16(b,reflip.v128); + + + cmac_tmp = _mm_sign_epi16(b,*(__m128i*)reflip); // cmac_tmp = _mm_shufflelo_epi16(b,_MM_SHUFFLE(2,3,0,1)); // cmac_tmp = _mm_shufflehi_epi16(cmac_tmp,_MM_SHUFFLE(2,3,0,1)); cmac_tmp = _mm_shuffle_epi8(cmac_tmp,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); cmac_tmp_im32 = _mm_madd_epi16(cmac_tmp,a); + *re32 = _mm_add_epi32(*re32,cmac_tmp_re32); *im32 = _mm_add_epi32(*im32,cmac_tmp_im32); } #ifdef __AVX2__ +static inline void cmac_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) __attribute__((always_inline)); +static inline void cmac_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) +{ -#define cmac_256(a,b,re32,im32) { \ - __m256i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; \ - cmac_tmp = _mm256_sign_epi16(b,reflip.v256); \ - cmac_tmp_re32 = _mm256_madd_epi16(a,cmac_tmp); \ - cmac_tmp = _mm256_shuffle_epi8(b,perm_mask.v256); \ - cmac_tmp_im32 = _mm256_madd_epi16(cmac_tmp,a); \ - re32 = _mm256_add_epi32(re32,cmac_tmp_re32); \ - im32 = _mm256_add_epi32(im32,cmac_tmp_im32); \ - } + __m256i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; + __m256i imshuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,19,18,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + + cmac_tmp = _mm256_sign_epi16(b,*(__m256i*)reflip); + cmac_tmp_re32 = _mm256_madd_epi16(a,cmac_tmp); + + cmac_tmp = _mm256_shuffle_epi8(b,imshuffle); + cmac_tmp_im32 = _mm256_madd_epi16(cmac_tmp,a); + + *re32 = _mm256_add_epi32(*re32,cmac_tmp_re32); + *im32 = _mm256_add_epi32(*im32,cmac_tmp_im32); +} static inline void cmacc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) __attribute__((always_inline)); -static inline void cmacc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) { +static inline void cmacc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) +{ + __m256i cmac_tmp,cmac_tmp_re32,cmac_tmp_im32; + __m256i imshuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,19,18,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + cmac_tmp_re32 = _mm256_madd_epi16(a,b); - cmac_tmp = _mm256_sign_epi16(b,reflip.v256); - cmac_tmp = _mm256_shuffle_epi8(b,perm_mask.v256); + + + cmac_tmp = _mm256_sign_epi16(b,*(__m256i*)reflip); + cmac_tmp = _mm256_shuffle_epi8(b,imshuffle); cmac_tmp_im32 = _mm256_madd_epi16(cmac_tmp,a); + *re32 = _mm256_add_epi32(*re32,cmac_tmp_re32); *im32 = _mm256_add_epi32(*im32,cmac_tmp_im32); } @@ -126,173 +146,241 @@ static inline void cmacc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) static inline void cmult(__m128i a,__m128i b, __m128i *re32, __m128i *im32) __attribute__((always_inline)); -static inline void cmult(__m128i a,__m128i b, __m128i *re32, __m128i *im32) { +static inline void cmult(__m128i a,__m128i b, __m128i *re32, __m128i *im32) +{ + register __m128i mmtmpb; - mmtmpb = _mm_sign_epi16(b,reflip.v128); + + mmtmpb = _mm_sign_epi16(b,*(__m128i*)reflip); *re32 = _mm_madd_epi16(a,mmtmpb); // mmtmpb = _mm_shufflelo_epi16(b,_MM_SHUFFLE(2,3,0,1)); // mmtmpb = _mm_shufflehi_epi16(mmtmpb,_MM_SHUFFLE(2,3,0,1)); mmtmpb = _mm_shuffle_epi8(b,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); *im32 = _mm_madd_epi16(a,mmtmpb); + } #ifdef __AVX2__ -#define cmult_256(a,b,out_re32,out_im32) {\ - register __m256i mmtmpb = _mm256_sign_epi16(b,reflip.v256);\ - out_re32 = _mm256_madd_epi16(a,mmtmpb);\ - mmtmpb = _mm256_shuffle_epi8(b,perm_mask.v256);\ - out_im32 = _mm256_madd_epi16(a,mmtmpb);\ - } +static inline void cmult_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) __attribute__((always_inline)); + +static inline void cmult_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) +{ + + register __m256i mmtmpb; + __m256i const perm_mask = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + + mmtmpb = _mm256_sign_epi16(b,*(__m256i*)reflip); + *re32 = _mm256_madd_epi16(a,mmtmpb); + mmtmpb = _mm256_shuffle_epi8(b,perm_mask); + *im32 = _mm256_madd_epi16(a,mmtmpb); + +} #endif static inline void cmultc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) __attribute__((always_inline)); -static inline void cmultc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) { +static inline void cmultc(__m128i a,__m128i b, __m128i *re32, __m128i *im32) +{ + register __m128i mmtmpb; + *re32 = _mm_madd_epi16(a,b); - mmtmpb = _mm_sign_epi16(b,reflip.v128); + mmtmpb = _mm_sign_epi16(b,*(__m128i*)reflip); mmtmpb = _mm_shuffle_epi8(mmtmpb,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); *im32 = _mm_madd_epi16(a,mmtmpb); + } #ifdef __AVX2__ -#define cmultc_256(a,b,out_re, out_im) { \ - out_re = _mm256_madd_epi16(a,b);\ - __m256i mmtmpb = _mm256_sign_epi16(b,reflip.v256);\ - mmtmpb = _mm256_shuffle_epi8(mmtmpb,perm_mask.v256);\ - out_im = _mm256_madd_epi16(a,mmtmpb);\ - } +static inline void cmultc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) __attribute__((always_inline)); + +static inline void cmultc_256(__m256i a,__m256i b, __m256i *re32, __m256i *im32) +{ + + register __m256i mmtmpb; + __m256i const perm_mask = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + + *re32 = _mm256_madd_epi16(a,b); + mmtmpb = _mm256_sign_epi16(b,*(__m256i*)reflip); + mmtmpb = _mm256_shuffle_epi8(mmtmpb,perm_mask); + *im32 = _mm256_madd_epi16(a,mmtmpb); + +} #endif static inline __m128i cpack(__m128i xre,__m128i xim) __attribute__((always_inline)); -static inline __m128i cpack(__m128i xre,__m128i xim) { +static inline __m128i cpack(__m128i xre,__m128i xim) +{ + register __m128i cpack_tmp1,cpack_tmp2; + cpack_tmp1 = _mm_unpacklo_epi32(xre,xim); cpack_tmp2 = _mm_unpackhi_epi32(xre,xim); return(_mm_packs_epi32(_mm_srai_epi32(cpack_tmp1,15),_mm_srai_epi32(cpack_tmp2,15))); + } #ifdef __AVX2__ +static inline __m256i cpack_256(__m256i xre,__m256i xim) __attribute__((always_inline)); - #define cpack_256(xre,xim) _mm256_blend_epi16(_mm256_srai_epi32(xre,15),_mm256_slli_epi32(xim,1),0xaa) +static inline __m256i cpack_256(__m256i xre,__m256i xim) +{ + + register __m256i cpack_tmp1,cpack_tmp2; + + cpack_tmp1 = _mm256_unpacklo_epi32(xre,xim); + cpack_tmp2 = _mm256_unpackhi_epi32(xre,xim); + return(_mm256_packs_epi32(_mm256_srai_epi32(cpack_tmp1,15),_mm256_srai_epi32(cpack_tmp2,15))); + +} #endif static inline void packed_cmult(__m128i a,__m128i b, __m128i *c) __attribute__((always_inline)); -static inline void packed_cmult(__m128i a,__m128i b, __m128i *c) { +static inline void packed_cmult(__m128i a,__m128i b, __m128i *c) +{ + __m128i cre,cim; cmult(a,b,&cre,&cim); *c = cpack(cre,cim); + } #ifdef __AVX2__ static inline void packed_cmult_256(__m256i a,__m256i b, __m256i *c) __attribute__((always_inline)); -static inline void packed_cmult_256(__m256i a,__m256i b, __m256i *c) { +static inline void packed_cmult_256(__m256i a,__m256i b, __m256i *c) +{ + __m256i cre,cim; - cmult_256(a,b,cre,cim); + cmult_256(a,b,&cre,&cim); *c = cpack_256(cre,cim); + } #endif static inline void packed_cmultc(__m128i a,__m128i b, __m128i *c) __attribute__((always_inline)); -static inline void packed_cmultc(__m128i a,__m128i b, __m128i *c) { +static inline void packed_cmultc(__m128i a,__m128i b, __m128i *c) +{ + __m128i cre,cim; + cmultc(a,b,&cre,&cim); *c = cpack(cre,cim); + } #ifdef __AVX2__ static inline void packed_cmultc_256(__m256i a,__m256i b, __m256i *c) __attribute__((always_inline)); -static inline void packed_cmultc_256(__m256i a,__m256i b, __m256i *c) { - register __m256i cre,cim; - cmultc_256(a,b,cre,cim); +static inline void packed_cmultc_256(__m256i a,__m256i b, __m256i *c) +{ + + __m256i cre,cim; + + cmultc_256(a,b,&cre,&cim); *c = cpack_256(cre,cim); + } #endif static inline __m128i packed_cmult2(__m128i a,__m128i b,__m128i b2) __attribute__((always_inline)); -static inline __m128i packed_cmult2(__m128i a,__m128i b,__m128i b2) { +static inline __m128i packed_cmult2(__m128i a,__m128i b,__m128i b2) +{ + + register __m128i cre,cim; + cre = _mm_madd_epi16(a,b); cim = _mm_madd_epi16(a,b2); + return(cpack(cre,cim)); + } #ifdef __AVX2__ static inline __m256i packed_cmult2_256(__m256i a,__m256i b,__m256i b2) __attribute__((always_inline)); -static inline __m256i packed_cmult2_256(__m256i a,__m256i b,__m256i b2) { +static inline __m256i packed_cmult2_256(__m256i a,__m256i b,__m256i b2) +{ + + register __m256i cre,cim; + cre = _mm256_madd_epi16(a,b); cim = _mm256_madd_epi16(a,b2); + return(cpack_256(cre,cim)); + } #endif #elif defined (__arm__) static inline void cmac(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) __attribute__((always_inline)); -static inline void cmac(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) { +static inline void cmac(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) +{ + + int32x4_t ab_re0,ab_re1,ab_im0,ab_im1; int16x8_t bflip = vrev32q_s16(b); int16x8_t bconj = vmulq_s16(b,*(int16x8_t *)reflip); - ab_re0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&bconj)[0]); - ab_re1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&bconj)[1]); - ab_im0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&bflip)[0]); - ab_im1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&bflip)[1]); - *re32 = vqaddq_s32(*re32,vcombine_s32(vpadd_s32(((int32x2_t *)&ab_re0)[0],((int32x2_t *)&ab_re0)[1]), - vpadd_s32(((int32x2_t *)&ab_re1)[0],((int32x2_t *)&ab_re1)[1]))); - *im32 = vqaddq_s32(*im32,vcombine_s32(vpadd_s32(((int32x2_t *)&ab_im0)[0],((int32x2_t *)&ab_im0)[1]), - vpadd_s32(((int32x2_t *)&ab_im1)[0],((int32x2_t *)&ab_im1)[1]))); + + ab_re0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&bconj)[0]); + ab_re1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&bconj)[1]); + ab_im0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&bflip)[0]); + ab_im1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&bflip)[1]); + *re32 = vqaddq_s32(*re32,vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), + vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1]))); + *im32 = vqaddq_s32(*im32,vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), + vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1]))); } static inline void cmacc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) __attribute__((always_inline)); -static inline void cmacc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) { +static inline void cmacc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) +{ int32x4_t ab_re0,ab_re1,ab_im0,ab_im1; int16x8_t bconj = vmulq_s16(b,*(int16x8_t *)reflip); int16x8_t bflip = vrev32q_s16(bconj); - ab_re0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&b)[0]); - ab_re1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&b)[1]); - ab_im0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&bflip)[0]); - ab_im1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&bflip)[1]); - *re32 = vqaddq_s32(*re32,vcombine_s32(vpadd_s32(((int32x2_t *)&ab_re0)[0],((int32x2_t *)&ab_re0)[1]), - vpadd_s32(((int32x2_t *)&ab_re1)[0],((int32x2_t *)&ab_re1)[1]))); - *im32 = vqaddq_s32(*im32,vcombine_s32(vpadd_s32(((int32x2_t *)&ab_im0)[0],((int32x2_t *)&ab_im0)[1]), - vpadd_s32(((int32x2_t *)&ab_im1)[0],((int32x2_t *)&ab_im1)[1]))); + + ab_re0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&b)[0]); + ab_re1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&b)[1]); + ab_im0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&bflip)[0]); + ab_im1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&bflip)[1]); + *re32 = vqaddq_s32(*re32,vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), + vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1]))); + *im32 = vqaddq_s32(*im32,vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), + vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1]))); + } static inline void cmult(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) __attribute__((always_inline)); -static inline void cmult(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) { +static inline void cmult(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) +{ int32x4_t ab_re0,ab_re1,ab_im0,ab_im1; int16x8_t bflip = vrev32q_s16(b); int16x8_t bconj = vmulq_s16(b,*(int16x8_t *)reflip); int16x4_t al,ah,bcl,bch,bfl,bfh; int32x2_t abr0l,abr0h,abr1l,abr1h,abi0l,abi0h,abi1l,abi1h; - al = vget_low_s16(a); - ah = vget_high_s16(a); - bcl = vget_low_s16(bconj); - bch = vget_high_s16(bconj); - bfl = vget_low_s16(bflip); - bfh = vget_high_s16(bflip); + + al = vget_low_s16(a); ah = vget_high_s16(a); + bcl = vget_low_s16(bconj); bch = vget_high_s16(bconj); + bfl = vget_low_s16(bflip); bfh = vget_high_s16(bflip); + ab_re0 = vmull_s16(al,bcl); ab_re1 = vmull_s16(ah,bch); ab_im0 = vmull_s16(al,bfl); ab_im1 = vmull_s16(ah,bfh); - abr0l = vget_low_s32(ab_re0); - abr0h = vget_high_s32(ab_re0); - abr1l = vget_low_s32(ab_re1); - abr1h = vget_high_s32(ab_re1); - abi0l = vget_low_s32(ab_im0); - abi0h = vget_high_s32(ab_im0); - abi1l = vget_low_s32(ab_im1); - abi1h = vget_high_s32(ab_im1); + abr0l = vget_low_s32(ab_re0); abr0h = vget_high_s32(ab_re0); + abr1l = vget_low_s32(ab_re1); abr1h = vget_high_s32(ab_re1); + abi0l = vget_low_s32(ab_im0); abi0h = vget_high_s32(ab_im0); + abi1l = vget_low_s32(ab_im1); abi1h = vget_high_s32(ab_im1); + *re32 = vcombine_s32(vpadd_s32(abr0l,abr0h), vpadd_s32(abr1l,abr1h)); *im32 = vcombine_s32(vpadd_s32(abi0l,abi0h), @@ -301,76 +389,90 @@ static inline void cmult(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im static inline void cmultc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) __attribute__((always_inline)); -static inline void cmultc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) { +static inline void cmultc(int16x8_t a,int16x8_t b, int32x4_t *re32, int32x4_t *im32) +{ int32x4_t ab_re0,ab_re1,ab_im0,ab_im1; int16x8_t bconj = vmulq_s16(b,*(int16x8_t *)reflip); int16x8_t bflip = vrev32q_s16(bconj); - int16x4_t al,ah,bl,bh,bfl,bfh; + int16x4_t al,ah,bl,bh,bfl,bfh; int32x2_t abr0l,abr0h,abr1l,abr1h,abi0l,abi0h,abi1l,abi1h; - al = vget_low_s16(a); - ah = vget_high_s16(a); - bl = vget_low_s16(b); - bh = vget_high_s16(b); - bfl = vget_low_s16(bflip); - bfh = vget_high_s16(bflip); + al = vget_low_s16(a); ah = vget_high_s16(a); + bl = vget_low_s16(b); bh = vget_high_s16(b); + bfl = vget_low_s16(bflip); bfh = vget_high_s16(bflip); + ab_re0 = vmull_s16(al,bl); ab_re1 = vmull_s16(ah,bh); ab_im0 = vmull_s16(al,bfl); ab_im1 = vmull_s16(ah,bfh); - abr0l = vget_low_s32(ab_re0); - abr0h = vget_high_s32(ab_re0); - abr1l = vget_low_s32(ab_re1); - abr1h = vget_high_s32(ab_re1); - abi0l = vget_low_s32(ab_im0); - abi0h = vget_high_s32(ab_im0); - abi1l = vget_low_s32(ab_im1); - abi1h = vget_high_s32(ab_im1); + + abr0l = vget_low_s32(ab_re0); abr0h = vget_high_s32(ab_re0); + abr1l = vget_low_s32(ab_re1); abr1h = vget_high_s32(ab_re1); + abi0l = vget_low_s32(ab_im0); abi0h = vget_high_s32(ab_im0); + abi1l = vget_low_s32(ab_im1); abi1h = vget_high_s32(ab_im1); + *re32 = vcombine_s32(vpadd_s32(abr0l,abr0h), - vpadd_s32(abr1l,abr1h)); + vpadd_s32(abr1l,abr1h)); *im32 = vcombine_s32(vpadd_s32(abi0l,abi0h), - vpadd_s32(abi1l,abi1h)); + vpadd_s32(abi1l,abi1h)); + } static inline int16x8_t cpack(int32x4_t xre,int32x4_t xim) __attribute__((always_inline)); -static inline int16x8_t cpack(int32x4_t xre,int32x4_t xim) { +static inline int16x8_t cpack(int32x4_t xre,int32x4_t xim) +{ int32x4x2_t xtmp; + xtmp = vzipq_s32(xre,xim); return(vcombine_s16(vqshrn_n_s32(xtmp.val[0],15),vqshrn_n_s32(xtmp.val[1],15))); + } static inline void packed_cmult(int16x8_t a,int16x8_t b, int16x8_t *c) __attribute__((always_inline)); -static inline void packed_cmult(int16x8_t a,int16x8_t b, int16x8_t *c) { +static inline void packed_cmult(int16x8_t a,int16x8_t b, int16x8_t *c) +{ + int32x4_t cre,cim; cmult(a,b,&cre,&cim); *c = cpack(cre,cim); + } static inline void packed_cmultc(int16x8_t a,int16x8_t b, int16x8_t *c) __attribute__((always_inline)); -static inline void packed_cmultc(int16x8_t a,int16x8_t b, int16x8_t *c) { +static inline void packed_cmultc(int16x8_t a,int16x8_t b, int16x8_t *c) +{ + int32x4_t cre,cim; + cmultc(a,b,&cre,&cim); *c = cpack(cre,cim); + } static inline int16x8_t packed_cmult2(int16x8_t a,int16x8_t b, int16x8_t b2) __attribute__((always_inline)); -static inline int16x8_t packed_cmult2(int16x8_t a,int16x8_t b, int16x8_t b2) { +static inline int16x8_t packed_cmult2(int16x8_t a,int16x8_t b, int16x8_t b2) +{ + + + int32x4_t ab_re0,ab_re1,ab_im0,ab_im1,cre,cim; - ab_re0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&b)[0]); - ab_re1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&b)[1]); - ab_im0 = vmull_s16(((int16x4_t *)&a)[0],((int16x4_t *)&b2)[0]); - ab_im1 = vmull_s16(((int16x4_t *)&a)[1],((int16x4_t *)&b2)[1]); - cre = vcombine_s32(vpadd_s32(((int32x2_t *)&ab_re0)[0],((int32x2_t *)&ab_re0)[1]), - vpadd_s32(((int32x2_t *)&ab_re1)[0],((int32x2_t *)&ab_re1)[1])); - cim = vcombine_s32(vpadd_s32(((int32x2_t *)&ab_im0)[0],((int32x2_t *)&ab_im0)[1]), - vpadd_s32(((int32x2_t *)&ab_im1)[0],((int32x2_t *)&ab_im1)[1])); + + ab_re0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&b)[0]); + ab_re1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&b)[1]); + ab_im0 = vmull_s16(((int16x4_t*)&a)[0],((int16x4_t*)&b2)[0]); + ab_im1 = vmull_s16(((int16x4_t*)&a)[1],((int16x4_t*)&b2)[1]); + cre = vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), + vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1])); + cim = vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), + vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1])); return(cpack(cre,cim)); + } #endif @@ -386,68 +488,74 @@ const static int16_t W35s[16]__attribute__((aligned(32))) = {-26510,19260,-26510 const static int16_t W45s[16]__attribute__((aligned(32))) = {10126,31163,10126,31163,10126,31163,10126,31163,10126,31163,10126,31163,10126,31163,10126,31163}; #if defined(__x86_64__) || defined(__i386__) - const __m128i *W0 = (__m128i *)W0s; - const __m128i *W13 = (__m128i *)W13s; - const __m128i *W23 = (__m128i *)W23s; - const __m128i *W15 = (__m128i *)W15s; - const __m128i *W25 = (__m128i *)W25s; - const __m128i *W35 = (__m128i *)W35s; - const __m128i *W45 = (__m128i *)W45s; +const __m128i *W0 = (__m128i *)W0s; +const __m128i *W13 = (__m128i *)W13s; +const __m128i *W23 = (__m128i *)W23s; +const __m128i *W15 = (__m128i *)W15s; +const __m128i *W25 = (__m128i *)W25s; +const __m128i *W35 = (__m128i *)W35s; +const __m128i *W45 = (__m128i *)W45s; - #ifdef __AVX2__ - const __m256i *W0_256 = (__m256i *)W0s; - const __m256i *W13_256 = (__m256i *)W13s; - const __m256i *W23_256 = (__m256i *)W23s; - const __m256i *W15_256 = (__m256i *)W15s; - const __m256i *W25_256 = (__m256i *)W25s; - const __m256i *W35_256 = (__m256i *)W35s; - const __m256i *W45_256 = (__m256i *)W45s; - #endif +#ifdef __AVX2__ +const __m256i *W0_256 = (__m256i *)W0s; +const __m256i *W13_256 = (__m256i *)W13s; +const __m256i *W23_256 = (__m256i *)W23s; +const __m256i *W15_256 = (__m256i *)W15s; +const __m256i *W25_256 = (__m256i *)W25s; +const __m256i *W35_256 = (__m256i *)W35s; +const __m256i *W45_256 = (__m256i *)W45s; +#endif #elif defined(__arm__) - int16x8_t *W0 = (int16x8_t *)W0s; - int16x8_t *W13 = (int16x8_t *)W13s; - int16x8_t *W23 = (int16x8_t *)W23s; - int16x8_t *W15 = (int16x8_t *)W15s; - int16x8_t *W25 = (int16x8_t *)W25s; - int16x8_t *W35 = (int16x8_t *)W35s; - int16x8_t *W45 = (int16x8_t *)W45s; +int16x8_t *W0 = (int16x8_t *)W0s; +int16x8_t *W13 = (int16x8_t *)W13s; +int16x8_t *W23 = (int16x8_t *)W23s; +int16x8_t *W15 = (int16x8_t *)W15s; +int16x8_t *W25 = (int16x8_t *)W25s; +int16x8_t *W35 = (int16x8_t *)W35s; +int16x8_t *W45 = (int16x8_t *)W45s; #endif const static int16_t dft_norm_table[16] = {9459, //12 - 6689,//24 - 5461,//36 - 4729,//482 - 4230,//60 - 23170,//72 - 3344,//96 - 3153,//108 - 2991,//120 - 18918,//sqrt(3),//144 - 18918,//sqrt(3),//180 - 16384,//2, //192 - 18918,//sqrt(3), // 216 - 16384,//2, //240 - 18918,//sqrt(3), // 288 - 14654 - }; //sqrt(5) //300 + 6689,//24 + 5461,//36 + 4729,//482 + 4230,//60 + 23170,//72 + 3344,//96 + 3153,//108 + 2991,//120 + 18918,//sqrt(3),//144 + 18918,//sqrt(3),//180 + 16384,//2, //192 + 18918,//sqrt(3), // 216 + 16384,//2, //240 + 18918,//sqrt(3), // 288 + 14654 +}; //sqrt(5) //300 #if defined(__x86_64__) || defined(__i386__) static inline void bfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw)__attribute__((always_inline)); -static inline void bfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw) { +static inline void bfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw) +{ + __m128i x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; __m128i bfly2_tmp1,bfly2_tmp2; + cmult(*(x0),*(W0),&x0r_2,&x0i_2); cmult(*(x1),*(tw),&x1r_2,&x1i_2); + dy0r = _mm_srai_epi32(_mm_add_epi32(x0r_2,x1r_2),15); dy1r = _mm_srai_epi32(_mm_sub_epi32(x0r_2,x1r_2),15); dy0i = _mm_srai_epi32(_mm_add_epi32(x0i_2,x1i_2),15); // printf("y0i %d\n",((int16_t *)y0i)[0]); dy1i = _mm_srai_epi32(_mm_sub_epi32(x0i_2,x1i_2),15); + bfly2_tmp1 = _mm_unpacklo_epi32(dy0r,dy0i); bfly2_tmp2 = _mm_unpackhi_epi32(dy0r,dy0i); *y0 = _mm_packs_epi32(bfly2_tmp1,bfly2_tmp2); + bfly2_tmp1 = _mm_unpacklo_epi32(dy1r,dy1i); bfly2_tmp2 = _mm_unpackhi_epi32(dy1r,dy1i); *y1 = _mm_packs_epi32(bfly2_tmp1,bfly2_tmp2); @@ -457,19 +565,25 @@ static inline void bfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m12 static inline void bfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw)__attribute__((always_inline)); -static inline void bfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw) { +static inline void bfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw) +{ + __m256i x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; __m256i bfly2_tmp1,bfly2_tmp2; - cmult_256(*(x0),*(W0_256),x0r_2,x0i_2); - cmult_256(*(x1),*(tw),x1r_2,x1i_2); + + cmult_256(*(x0),*(W0_256),&x0r_2,&x0i_2); + cmult_256(*(x1),*(tw),&x1r_2,&x1i_2); + dy0r = _mm256_srai_epi32(_mm256_add_epi32(x0r_2,x1r_2),15); dy1r = _mm256_srai_epi32(_mm256_sub_epi32(x0r_2,x1r_2),15); dy0i = _mm256_srai_epi32(_mm256_add_epi32(x0i_2,x1i_2),15); // printf("y0i %d\n",((int16_t *)y0i)[0]); dy1i = _mm256_srai_epi32(_mm256_sub_epi32(x0i_2,x1i_2),15); + bfly2_tmp1 = _mm256_unpacklo_epi32(dy0r,dy0i); bfly2_tmp2 = _mm256_unpackhi_epi32(dy0r,dy0i); *y0 = _mm256_packs_epi32(bfly2_tmp1,bfly2_tmp2); + bfly2_tmp1 = _mm256_unpacklo_epi32(dy1r,dy1i); bfly2_tmp2 = _mm256_unpackhi_epi32(dy1r,dy1i); *y1 = _mm256_packs_epi32(bfly2_tmp1,bfly2_tmp2); @@ -481,14 +595,19 @@ static inline void bfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,_ static inline void bfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw)__attribute__((always_inline)); -static inline void bfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw) { +static inline void bfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw) +{ + int32x4_t x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; + cmult(*(x0),*(W0),&x0r_2,&x0i_2); cmult(*(x1),*(tw),&x1r_2,&x1i_2); + dy0r = vqaddq_s32(x0r_2,x1r_2); dy1r = vqsubq_s32(x0r_2,x1r_2); dy0i = vqaddq_s32(x0i_2,x1i_2); dy1i = vqsubq_s32(x0i_2,x1i_2); + *y0 = cpack(dy0r,dy0i); *y1 = cpack(dy1r,dy1i); } @@ -499,30 +618,39 @@ static inline void bfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t * #if defined(__x86_64__) || defined(__i386__) static inline void bfly2_tw1(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1)__attribute__((always_inline)); -static inline void bfly2_tw1(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1) { +static inline void bfly2_tw1(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1) +{ + *y0 = _mm_adds_epi16(*x0,*x1); *y1 = _mm_subs_epi16(*x0,*x1); + } #elif defined(__arm__) static inline void bfly2_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1)__attribute__((always_inline)); -static inline void bfly2_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1) { +static inline void bfly2_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1) +{ + *y0 = vqaddq_s16(*x0,*x1); *y1 = vqsubq_s16(*x0,*x1); + } #endif - + #if defined(__x86_64__) || defined(__i386__) static inline void bfly2_16(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1, __m128i *tw, __m128i *twb)__attribute__((always_inline)); -static inline void bfly2_16(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1, __m128i *tw, __m128i *twb) { +static inline void bfly2_16(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1, __m128i *tw, __m128i *twb) +{ + // register __m128i x1t; __m128i x1t; + x1t = packed_cmult2(*(x1),*(tw),*(twb)); /* print_shorts("x0",(int16_t*)x0); @@ -540,9 +668,12 @@ static inline void bfly2_16(__m128i *x0, __m128i *x1, __m128i *y0, __m128i *y1, static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i *y1, __m256i *tw, __m256i *twb)__attribute__((always_inline)); -static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i *y1, __m256i *tw, __m256i *twb) { +static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i *y1, __m256i *tw, __m256i *twb) +{ + // register __m256i x1t; __m256i x1t; + x1t = packed_cmult2_256(*(x1),*(tw),*(twb)); /* print_shorts256("x0",(int16_t*)x0); @@ -552,6 +683,7 @@ static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i * print_shorts256("x1t",(int16_t*)&x1t);*/ *y0 = _mm256_adds_epi16(*x0,x1t); *y1 = _mm256_subs_epi16(*x0,x1t); + /*print_shorts256("y0",(int16_t*)y0); print_shorts256("y1",(int16_t*)y1);*/ } @@ -562,28 +694,37 @@ static inline void bfly2_16_256(__m256i *x0, __m256i *x1, __m256i *y0, __m256i * static inline void bfly2_16(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1, int16x8_t *tw, int16x8_t *twb)__attribute__((always_inline)); -static inline void bfly2_16(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1, int16x8_t *tw, int16x8_t *twb) { +static inline void bfly2_16(int16x8_t *x0, int16x8_t *x1, int16x8_t *y0, int16x8_t *y1, int16x8_t *tw, int16x8_t *twb) +{ + *y0 = vqaddq_s16(*x0,*x1); *y1 = vqsubq_s16(*x0,*x1); + } #endif #if defined(__x86_64__) || defined(__i386__) static inline void ibfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw)__attribute__((always_inline)); -static inline void ibfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw) { +static inline void ibfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m128i *tw) +{ + __m128i x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; __m128i bfly2_tmp1,bfly2_tmp2; + cmultc(*(x0),*(W0),&x0r_2,&x0i_2); cmultc(*(x1),*(tw),&x1r_2,&x1i_2); + dy0r = _mm_srai_epi32(_mm_add_epi32(x0r_2,x1r_2),15); dy1r = _mm_srai_epi32(_mm_sub_epi32(x0r_2,x1r_2),15); dy0i = _mm_srai_epi32(_mm_add_epi32(x0i_2,x1i_2),15); // printf("y0i %d\n",((int16_t *)y0i)[0]); dy1i = _mm_srai_epi32(_mm_sub_epi32(x0i_2,x1i_2),15); + bfly2_tmp1 = _mm_unpacklo_epi32(dy0r,dy0i); bfly2_tmp2 = _mm_unpackhi_epi32(dy0r,dy0i); *y0 = _mm_packs_epi32(bfly2_tmp1,bfly2_tmp2); + bfly2_tmp1 = _mm_unpacklo_epi32(dy1r,dy1i); bfly2_tmp2 = _mm_unpackhi_epi32(dy1r,dy1i); *y1 = _mm_packs_epi32(bfly2_tmp1,bfly2_tmp2); @@ -592,30 +733,48 @@ static inline void ibfly2(__m128i *x0, __m128i *x1,__m128i *y0, __m128i *y1,__m1 #ifdef __AVX2__ static inline void ibfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw)__attribute__((always_inline)); -static inline void ibfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw) { - register __m256i x0r_2,x0i_2,x1r_2,x1i_2; - cmultc_256(*(x0),*(W0_256),x0r_2,x0i_2); - cmultc_256(*(x1),*(tw),x1r_2,x1i_2); - const __m256i dy0r = _mm256_srai_epi32(_mm256_add_epi32(x0r_2,x1r_2),15); - const __m256i dy0i = _mm256_slli_epi32(_mm256_add_epi32(x0i_2,x1i_2),1); - *y0 = _mm256_blend_epi16(dy0r,dy0i,0xaa); - const __m256i dy1r = _mm256_srai_epi32(_mm256_sub_epi32(x0r_2,x1r_2),15); - const __m256i dy1i = _mm256_slli_epi32(_mm256_sub_epi32(x0i_2,x1i_2),1); - *y1 = _mm256_blend_epi16(dy1r,dy1i,0xaa); +static inline void ibfly2_256(__m256i *x0, __m256i *x1,__m256i *y0, __m256i *y1,__m256i *tw) +{ + + __m256i x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; + __m256i bfly2_tmp1,bfly2_tmp2; + + cmultc_256(*(x0),*(W0_256),&x0r_2,&x0i_2); + cmultc_256(*(x1),*(tw),&x1r_2,&x1i_2); + + dy0r = _mm256_srai_epi32(_mm256_add_epi32(x0r_2,x1r_2),15); + dy1r = _mm256_srai_epi32(_mm256_sub_epi32(x0r_2,x1r_2),15); + dy0i = _mm256_srai_epi32(_mm256_add_epi32(x0i_2,x1i_2),15); + // printf("y0i %d\n",((int16_t *)y0i)[0]); + dy1i = _mm256_srai_epi32(_mm256_sub_epi32(x0i_2,x1i_2),15); + + bfly2_tmp1 = _mm256_unpacklo_epi32(dy0r,dy0i); + bfly2_tmp2 = _mm256_unpackhi_epi32(dy0r,dy0i); + *y0 = _mm256_packs_epi32(bfly2_tmp1,bfly2_tmp2); + + bfly2_tmp1 = _mm256_unpacklo_epi32(dy1r,dy1i); + bfly2_tmp2 = _mm256_unpackhi_epi32(dy1r,dy1i); + *y1 = _mm256_packs_epi32(bfly2_tmp1,bfly2_tmp2); } #endif #elif defined(__arm__) -static inline void ibfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw) { +static inline void ibfly2(int16x8_t *x0, int16x8_t *x1,int16x8_t *y0, int16x8_t *y1,int16x8_t *tw) +{ + int32x4_t x0r_2,x0i_2,x1r_2,x1i_2,dy0r,dy1r,dy0i,dy1i; + cmultc(*(x0),*(W0),&x0r_2,&x0i_2); cmultc(*(x1),*(tw),&x1r_2,&x1i_2); + dy0r = vqaddq_s32(x0r_2,x1r_2); dy1r = vqsubq_s32(x0r_2,x1r_2); dy0i = vqaddq_s32(x0i_2,x1i_2); dy1i = vqsubq_s32(x0i_2,x1i_2); + *y0 = cpack(dy0r,dy0i); *y1 = cpack(dy1r,dy1i); + } #endif @@ -633,8 +792,11 @@ static inline void bfly3(__m128i *x0,__m128i *x1,__m128i *x2, static inline void bfly3(__m128i *x0,__m128i *x1,__m128i *x2, __m128i *y0,__m128i *y1,__m128i *y2, - __m128i *tw1,__m128i *tw2) { + __m128i *tw1,__m128i *tw2) +{ + __m128i tmpre,tmpim,x1_2,x2_2; + packed_cmult(*(x1),*(tw1),&x1_2); packed_cmult(*(x2),*(tw2),&x2_2); *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(x1_2,x2_2)); @@ -651,22 +813,25 @@ static inline void bfly3(__m128i *x0,__m128i *x1,__m128i *x2, #ifdef __AVX2__ static inline void bfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2, - __m256i *tw1,__m256i *tw2) __attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2, + __m256i *tw1,__m256i *tw2) __attribute__((always_inline)); static inline void bfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2, - __m256i *tw1,__m256i *tw2) { + __m256i *y0,__m256i *y1,__m256i *y2, + __m256i *tw1,__m256i *tw2) +{ + __m256i tmpre,tmpim,x1_2,x2_2; + packed_cmult_256(*(x1),*(tw1),&x1_2); packed_cmult_256(*(x2),*(tw2),&x2_2); *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(x1_2,x2_2)); - cmult_256(x1_2,*(W13_256),tmpre,tmpim); - cmac_256(x2_2,*(W23_256),tmpre,tmpim); + cmult_256(x1_2,*(W13_256),&tmpre,&tmpim); + cmac_256(x2_2,*(W23_256),&tmpre,&tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmult_256(x1_2,*(W23_256),tmpre,tmpim); - cmac_256(x2_2,*(W13_256),tmpre,tmpim); + cmult_256(x1_2,*(W23_256),&tmpre,&tmpim); + cmac_256(x2_2,*(W13_256),&tmpre,&tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); } @@ -679,9 +844,12 @@ static inline void bfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, static inline void bfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, - int16x8_t *tw1,int16x8_t *tw2) { + int16x8_t *tw1,int16x8_t *tw2) +{ + int32x4_t tmpre,tmpim; int16x8_t x1_2,x2_2; + packed_cmult(*(x1),*(tw1),&x1_2); packed_cmult(*(x2),*(tw2),&x2_2); *(y0) = vqaddq_s16(*(x0),vqaddq_s16(x1_2,x2_2)); @@ -699,13 +867,16 @@ static inline void bfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, #if defined(__x86_64__) || defined(__i386__) static inline void ibfly3(__m128i *x0,__m128i *x1,__m128i *x2, - __m128i *y0,__m128i *y1,__m128i *y2, - __m128i *tw1,__m128i *tw2) __attribute__((always_inline)); + __m128i *y0,__m128i *y1,__m128i *y2, + __m128i *tw1,__m128i *tw2) __attribute__((always_inline)); static inline void ibfly3(__m128i *x0,__m128i *x1,__m128i *x2, - __m128i *y0,__m128i *y1,__m128i *y2, - __m128i *tw1,__m128i *tw2) { + __m128i *y0,__m128i *y1,__m128i *y2, + __m128i *tw1,__m128i *tw2) +{ + __m128i tmpre,tmpim,x1_2,x2_2; + packed_cmultc(*(x1),*(tw1),&x1_2); packed_cmultc(*(x2),*(tw2),&x2_2); *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(x1_2,x2_2)); @@ -722,21 +893,24 @@ static inline void ibfly3(__m128i *x0,__m128i *x1,__m128i *x2, #ifdef __AVX2__ static inline void ibfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2, - __m256i *tw1,__m256i *tw2) __attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2, + __m256i *tw1,__m256i *tw2) __attribute__((always_inline)); static inline void ibfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2, - __m256i *tw1,__m256i *tw2) { + __m256i *y0,__m256i *y1,__m256i *y2, + __m256i *tw1,__m256i *tw2) +{ + __m256i tmpre,tmpim,x1_2,x2_2; + packed_cmultc_256(*(x1),*(tw1),&x1_2); packed_cmultc_256(*(x2),*(tw2),&x2_2); *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(x1_2,x2_2)); - cmultc_256(x1_2,*(W13_256),tmpre,tmpim); + cmultc_256(x1_2,*(W13_256),&tmpre,&tmpim); cmacc_256(x2_2,*(W23_256),&tmpre,&tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmultc_256(x1_2,*(W23_256),tmpre,tmpim); + cmultc_256(x1_2,*(W23_256),&tmpre,&tmpim); cmacc_256(x2_2,*(W13_256),&tmpre,&tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); @@ -745,14 +919,17 @@ static inline void ibfly3_256(__m256i *x0,__m256i *x1,__m256i *x2, #elif defined(__arm__) static inline void ibfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, - int16x8_t *tw1,int16x8_t *tw2) __attribute__((always_inline)); + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, + int16x8_t *tw1,int16x8_t *tw2) __attribute__((always_inline)); static inline void ibfly3(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, - int16x8_t *tw1,int16x8_t *tw2) { + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2, + int16x8_t *tw1,int16x8_t *tw2) +{ + int32x4_t tmpre,tmpim; int16x8_t x1_2,x2_2; + packed_cmultc(*(x1),*(tw1),&x1_2); packed_cmultc(*(x2),*(tw2),&x2_2); *(y0) = vqaddq_s16(*(x0),vqaddq_s16(x1_2,x2_2)); @@ -772,8 +949,11 @@ static inline void bfly3_tw1(__m128i *x0,__m128i *x1,__m128i *x2, __m128i *y0,__m128i *y1,__m128i *y2) __attribute__((always_inline)); static inline void bfly3_tw1(__m128i *x0,__m128i *x1,__m128i *x2, - __m128i *y0,__m128i *y1,__m128i *y2) { + __m128i *y0,__m128i *y1,__m128i *y2) +{ + __m128i tmpre,tmpim; + *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(*(x1),*(x2))); cmult(*(x1),*(W13),&tmpre,&tmpim); cmac(*(x2),*(W23),&tmpre,&tmpim); @@ -788,18 +968,21 @@ static inline void bfly3_tw1(__m128i *x0,__m128i *x1,__m128i *x2, #ifdef __AVX2__ static inline void bfly3_tw1_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2) __attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2) __attribute__((always_inline)); static inline void bfly3_tw1_256(__m256i *x0,__m256i *x1,__m256i *x2, - __m256i *y0,__m256i *y1,__m256i *y2) { + __m256i *y0,__m256i *y1,__m256i *y2) +{ + __m256i tmpre,tmpim; + *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(*(x1),*(x2))); - cmult_256(*(x1),*(W13_256),tmpre,tmpim); - cmac_256(*(x2),*(W23_256),tmpre,tmpim); + cmult_256(*(x1),*(W13_256),&tmpre,&tmpim); + cmac_256(*(x2),*(W23_256),&tmpre,&tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmult_256(*(x1),*(W23_256),tmpre,tmpim); - cmac_256(*(x2),*(W13_256),tmpre,tmpim); + cmult_256(*(x1),*(W23_256),&tmpre,&tmpim); + cmac_256(*(x2),*(W13_256),&tmpre,&tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); } @@ -810,8 +993,11 @@ static inline void bfly3_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2) __attribute__((always_inline)); static inline void bfly3_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2) { + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2) +{ + int32x4_t tmpre,tmpim; + *(y0) = vqaddq_s16(*(x0),vqaddq_s16(*(x1),*(x2))); cmult(*(x1),*(W13),&tmpre,&tmpim); cmac(*(x2),*(W23),&tmpre,&tmpim); @@ -821,6 +1007,7 @@ static inline void bfly3_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2, cmac(*(x2),*(W13),&tmpre,&tmpim); *(y2) = cpack(tmpre,tmpim); *(y2) = vqaddq_s16(*(x0),*(y2)); + } #endif @@ -832,8 +1019,11 @@ static inline void bfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, static inline void bfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3, - __m128i *tw1,__m128i *tw2,__m128i *tw3) { + __m128i *tw1,__m128i *tw2,__m128i *tw3) +{ + __m128i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; + // cmult(*(x0),*(W0),&x0r_2,&x0i_2); cmult(*(x1),*(tw1),&x1r_2,&x1i_2); cmult(*(x2),*(tw2),&x2r_2,&x2i_2); @@ -866,17 +1056,20 @@ static inline void bfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, #ifdef __AVX2__ static inline void bfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3)__attribute__((always_inline)); static inline void bfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3) { + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3) +{ + __m256i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; + // cmult(*(x0),*(W0),&x0r_2,&x0i_2); - cmult_256(*(x1),*(tw1),x1r_2,x1i_2); - cmult_256(*(x2),*(tw2),x2r_2,x2i_2); - cmult_256(*(x3),*(tw3),x3r_2,x3i_2); + cmult_256(*(x1),*(tw1),&x1r_2,&x1i_2); + cmult_256(*(x2),*(tw2),&x2r_2,&x2i_2); + cmult_256(*(x3),*(tw3),&x3r_2,&x3i_2); // dy0r = _mm_add_epi32(x0r_2,_mm_add_epi32(x1r_2,_mm_add_epi32(x2r_2,x3r_2))); // dy0i = _mm_add_epi32(x0i_2,_mm_add_epi32(x1i_2,_mm_add_epi32(x2i_2,x3i_2))); // *(y0) = cpack(dy0r,dy0i); @@ -910,8 +1103,11 @@ static inline void bfly4(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3 static inline void bfly4(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3) { + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3) +{ + int32x4_t x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; + // cmult(*(x0),*(W0),&x0r_2,&x0i_2); cmult(*(x1),*(tw1),&x1r_2,&x1i_2); cmult(*(x2),*(tw2),&x2r_2,&x2i_2); @@ -951,11 +1147,16 @@ static inline void ibfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, static inline void ibfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3, - __m128i *tw1,__m128i *tw2,__m128i *tw3) { + __m128i *tw1,__m128i *tw2,__m128i *tw3) +{ + __m128i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; + + cmultc(*(x1),*(tw1),&x1r_2,&x1i_2); cmultc(*(x2),*(tw2),&x2r_2,&x2i_2); cmultc(*(x3),*(tw3),&x3r_2,&x3i_2); + dy0r = _mm_add_epi32(x1r_2,_mm_add_epi32(x2r_2,x3r_2)); dy0i = _mm_add_epi32(x1i_2,_mm_add_epi32(x2i_2,x3i_2)); *(y0) = _mm_add_epi16(*(x0),cpack(dy0r,dy0i)); @@ -972,44 +1173,34 @@ static inline void ibfly4(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, #ifdef __AVX2__ -#define cmultcM(a,b,out_re, out_im) { \ - out_re = _mm256_madd_epi16(a,b);\ - __m256i mmtmpb = _mm256_sign_epi16(b,reflip.v256);\ - mmtmpb = _mm256_shuffle_epi8(mmtmpb,perm_mask.v256);\ - out_im = _mm256_madd_epi16(a,mmtmpb);\ - } +static inline void ibfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3)__attribute__((always_inline)); static inline void ibfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3) +{ -static inline void ibfly4_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3) { - register __m256i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2; - cmultcM(*(x1),*(tw1),x1r_2,x1i_2); - cmultcM(*(x2),*(tw2),x2r_2,x2i_2); - cmultcM(*(x3),*(tw3),x3r_2,x3i_2); - { - const __m256i dy0r = _mm256_add_epi32(x1r_2,_mm256_add_epi32(x2r_2,x3r_2)); - const __m256i dy0i = _mm256_add_epi32(x1i_2,_mm256_add_epi32(x2i_2,x3i_2)); - *(y0) = _mm256_add_epi16(*(x0),cpack_256(dy0r,dy0i)); - } - { - const __m256i dy3r = _mm256_sub_epi32(x1i_2,_mm256_add_epi32(x2r_2,x3i_2)); - const __m256i dy3i = _mm256_sub_epi32(_mm256_sub_epi32(x3r_2,x2i_2),x1r_2); - *(y3) = _mm256_add_epi16(*(x0),cpack_256(dy3r,dy3i)); - } - { - const __m256i dy2r = _mm256_sub_epi32(_mm256_sub_epi32(x2r_2,x3r_2),x1r_2); - const __m256i dy2i = _mm256_sub_epi32(_mm256_sub_epi32(x2i_2,x3i_2),x1i_2); - *(y2) = _mm256_add_epi16(*(x0),cpack_256(dy2r,dy2i)); - } - { - const __m256i dy1r = _mm256_sub_epi32(_mm256_sub_epi32(x3i_2,x2r_2),x1i_2); - const __m256i dy1i = _mm256_sub_epi32(x1r_2,_mm256_add_epi32(x2i_2,x3r_2)); - *(y1) = _mm256_add_epi16(*(x0),cpack_256(dy1r,dy1i)); - } + __m256i x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; + + + cmultc_256(*(x1),*(tw1),&x1r_2,&x1i_2); + cmultc_256(*(x2),*(tw2),&x2r_2,&x2i_2); + cmultc_256(*(x3),*(tw3),&x3r_2,&x3i_2); + + dy0r = _mm256_add_epi32(x1r_2,_mm256_add_epi32(x2r_2,x3r_2)); + dy0i = _mm256_add_epi32(x1i_2,_mm256_add_epi32(x2i_2,x3i_2)); + *(y0) = _mm256_add_epi16(*(x0),cpack_256(dy0r,dy0i)); + dy3r = _mm256_sub_epi32(x1i_2,_mm256_add_epi32(x2r_2,x3i_2)); + dy3i = _mm256_sub_epi32(_mm256_sub_epi32(x3r_2,x2i_2),x1r_2); + *(y3) = _mm256_add_epi16(*(x0),cpack_256(dy3r,dy3i)); + dy2r = _mm256_sub_epi32(_mm256_sub_epi32(x2r_2,x3r_2),x1r_2); + dy2i = _mm256_sub_epi32(_mm256_sub_epi32(x2i_2,x3i_2),x1i_2); + *(y2) = _mm256_add_epi16(*(x0),cpack_256(dy2r,dy2i)); + dy1r = _mm256_sub_epi32(_mm256_sub_epi32(x3i_2,x2r_2),x1i_2); + dy1i = _mm256_sub_epi32(x1r_2,_mm256_add_epi32(x2i_2,x3r_2)); + *(y1) = _mm256_add_epi16(*(x0),cpack_256(dy1r,dy1i)); } #endif @@ -1021,11 +1212,16 @@ static inline void ibfly4(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x static inline void ibfly4(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3) { + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3) +{ + int32x4_t x1r_2,x1i_2,x2r_2,x2i_2,x3r_2,x3i_2,dy0r,dy0i,dy1r,dy1i,dy2r,dy2i,dy3r,dy3i; + + cmultc(*(x1),*(tw1),&x1r_2,&x1i_2); cmultc(*(x2),*(tw2),&x2r_2,&x2i_2); cmultc(*(x3),*(tw3),&x3r_2,&x3i_2); + dy0r = vqaddq_s32(x1r_2,vqaddq_s32(x2r_2,x3r_2)); dy0i = vqaddq_s32(x1i_2,vqaddq_s32(x2i_2,x3i_2)); *(y0) = vqaddq_s16(*(x0),cpack(dy0r,dy0i)); @@ -1048,21 +1244,24 @@ static inline void bfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3)__attribute__((always_inline)); static inline void bfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, - __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3) { + __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3) +{ register __m128i x1_flip,x3_flip,x02t,x13t; register __m128i complex_shuffle = _mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + x02t = _mm_adds_epi16(*(x0),*(x2)); x13t = _mm_adds_epi16(*(x1),*(x3)); *(y0) = _mm_adds_epi16(x02t,x13t); *(y2) = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(*(x1),conjugatedft.v128); + x1_flip = _mm_sign_epi16(*(x1),*(__m128i*)conjugatedft); x1_flip = _mm_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm_sign_epi16(*(x3),conjugatedft.v128); + x3_flip = _mm_sign_epi16(*(x3),*(__m128i*)conjugatedft); x3_flip = _mm_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm_subs_epi16(*(x0),*(x2)); x13t = _mm_subs_epi16(x1_flip,x3_flip); *(y1) = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y3) = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + /* *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(*(x1),_mm_adds_epi16(*(x2),*(x3)))); x1_flip = _mm_sign_epi16(*(x1),*(__m128i*)conjugatedft); @@ -1078,19 +1277,22 @@ static inline void bfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, #ifdef __AVX2__ static inline void bfly4_tw1_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3)__attribute__((always_inline)); static inline void bfly4_tw1_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3) { + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3) +{ register __m256i x1_flip,x3_flip,x02t,x13t; + register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + x02t = _mm256_adds_epi16(*(x0),*(x2)); x13t = _mm256_adds_epi16(*(x1),*(x3)); *(y0) = _mm256_adds_epi16(x02t,x13t); *(y2) = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(*(x1),conjugatedft.v256); - x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); - x3_flip = _mm256_sign_epi16(*(x3),conjugatedft.v256); - x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); + x1_flip = _mm256_sign_epi16(*(x1),*(__m256i*)conjugatedft); + x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); + x3_flip = _mm256_sign_epi16(*(x3),*(__m256i*)conjugatedft); + x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm256_subs_epi16(*(x0),*(x2)); x13t = _mm256_subs_epi16(x1_flip,x3_flip); *(y1) = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f @@ -1104,11 +1306,14 @@ static inline void bfly4_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3)__attribute__((always_inline)); static inline void bfly4_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3) { + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3) +{ + register int16x8_t x1_flip,x3_flip; + *(y0) = vqaddq_s16(*(x0),vqaddq_s16(*(x1),vqaddq_s16(*(x2),*(x3)))); - x1_flip = vrev32q_s16(vmulq_s16(*(x1),*(int16x8_t *)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(*(x3),*(int16x8_t *)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(*(x1),*(int16x8_t*)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(*(x3),*(int16x8_t*)conjugatedft)); *(y1) = vqaddq_s16(*(x0),vqsubq_s16(x1_flip,vqaddq_s16(*(x2),x3_flip))); *(y2) = vqsubq_s16(*(x0),vqsubq_s16(*(x1),vqsubq_s16(*(x2),*(x3)))); *(y3) = vqsubq_s16(*(x0),vqaddq_s16(x1_flip,vqsubq_s16(*(x2),x3_flip))); @@ -1122,14 +1327,18 @@ static inline void ibfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3)__attribute__((always_inline)); static inline void ibfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, - __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3) { + __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3) +{ + register __m128i x1_flip,x3_flip; + *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(*(x1),_mm_adds_epi16(*(x2),*(x3)))); - x1_flip = _mm_sign_epi16(*(x1),conjugatedft.v128); + + x1_flip = _mm_sign_epi16(*(x1),*(__m128i*)conjugatedft); // x1_flip = _mm_shufflelo_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); // x1_flip = _mm_shufflehi_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(*(x3),conjugatedft.v128); + x3_flip = _mm_sign_epi16(*(x3),*(__m128i*)conjugatedft); // x3_flip = _mm_shufflelo_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); // x3_flip = _mm_shufflehi_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); @@ -1141,14 +1350,17 @@ static inline void ibfly4_tw1(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, #elif defined(__arm__) static inline void ibfly4_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3)__attribute__((always_inline)); + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3)__attribute__((always_inline)); static inline void ibfly4_tw1(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3) { + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3) +{ + register int16x8_t x1_flip,x3_flip; + *(y0) = vqaddq_s16(*(x0),vqaddq_s16(*(x1),vqaddq_s16(*(x2),*(x3)))); - x1_flip = vrev32q_s16(vmulq_s16(*(x1),*(int16x8_t *)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(*(x3),*(int16x8_t *)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(*(x1),*(int16x8_t*)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(*(x3),*(int16x8_t*)conjugatedft)); *(y1) = vqsubq_s16(*(x0),vqaddq_s16(x1_flip,vqsubq_s16(*(x2),x3_flip))); *(y2) = vqsubq_s16(*(x0),vqsubq_s16(*(x1),vqsubq_s16(*(x2),*(x3)))); *(y3) = vqaddq_s16(*(x0),vqsubq_s16(x1_flip,vqaddq_s16(*(x2),x3_flip))); @@ -1165,12 +1377,17 @@ static inline void bfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, static inline void bfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3, __m128i *tw1,__m128i *tw2,__m128i *tw3, - __m128i *tw1b,__m128i *tw2b,__m128i *tw3b) { + __m128i *tw1b,__m128i *tw2b,__m128i *tw3b) +{ + register __m128i x1t,x2t,x3t,x02t,x13t; register __m128i x1_flip,x3_flip; + x1t = packed_cmult2(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2(*(x3),*(tw3),*(tw3b)); + + // bfly4_tw1(x0,&x1t,&x2t,&x3t,y0,y1,y2,y3); x02t = _mm_adds_epi16(*(x0),x2t); x13t = _mm_adds_epi16(x1t,x3t); @@ -1180,11 +1397,12 @@ static inline void bfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, */ *(y0) = _mm_adds_epi16(x02t,x13t); *(y2) = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(x1t,conjugatedft.v128); + + x1_flip = _mm_sign_epi16(x1t,*(__m128i*)conjugatedft); // x1_flip = _mm_shufflelo_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); // x1_flip = _mm_shufflehi_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(x3t,conjugatedft.v128); + x3_flip = _mm_sign_epi16(x3t,*(__m128i*)conjugatedft); // x3_flip = _mm_shufflelo_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); // x3_flip = _mm_shufflehi_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); @@ -1196,38 +1414,47 @@ static inline void bfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, */ *(y1) = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y3) = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + } #ifdef __AVX2__ static inline void bfly4_16_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3, - __m256i *tw1b,__m256i *tw2b,__m256i *tw3b)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3, + __m256i *tw1b,__m256i *tw2b,__m256i *tw3b)__attribute__((always_inline)); static inline void bfly4_16_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3, - __m256i *tw1b,__m256i *tw2b,__m256i *tw3b) { + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3, + __m256i *tw1b,__m256i *tw2b,__m256i *tw3b) +{ + register __m256i x1t,x2t,x3t,x02t,x13t; register __m256i x1_flip,x3_flip; + register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + // each input xi is assumed to be to consecutive vectors xi0 xi1 on which to perform the 8 butterflies // [xi00 xi01 xi02 xi03 xi10 xi20 xi30 xi40] // each output yi is the same + x1t = packed_cmult2_256(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2_256(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2_256(*(x3),*(tw3),*(tw3b)); + x02t = _mm256_adds_epi16(*(x0),x2t); x13t = _mm256_adds_epi16(x1t,x3t); *(y0) = _mm256_adds_epi16(x02t,x13t); *(y2) = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(x1t,conjugatedft.v256); - x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); - x3_flip = _mm256_sign_epi16(x3t,conjugatedft.v256); - x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); + + x1_flip = _mm256_sign_epi16(x1t,*(__m256i*)conjugatedft); + x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); + x3_flip = _mm256_sign_epi16(x3t,*(__m256i*)conjugatedft); + x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm256_subs_epi16(*(x0),x2t); x13t = _mm256_subs_epi16(x1_flip,x3_flip); *(y1) = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y3) = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + } #endif @@ -1242,18 +1469,24 @@ static inline void bfly4_16(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t static inline void bfly4_16(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, - int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b) { + int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b) +{ + register int16x8_t x1t,x2t,x3t,x02t,x13t; register int16x8_t x1_flip,x3_flip; + x1t = packed_cmult2(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2(*(x3),*(tw3),*(tw3b)); + + + x02t = vqaddq_s16(*(x0),x2t); x13t = vqaddq_s16(x1t,x3t); *(y0) = vqaddq_s16(x02t,x13t); *(y2) = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(x1t,*(int16x8_t *)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(x3t,*(int16x8_t *)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(x1t,*(int16x8_t*)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(x3t,*(int16x8_t*)conjugatedft)); x02t = vqsubq_s16(*(x0),x2t); x13t = vqsubq_s16(x1_flip,x3_flip); *(y1) = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f @@ -1270,12 +1503,17 @@ static inline void ibfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, static inline void ibfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, __m128i *y0,__m128i *y1,__m128i *y2,__m128i *y3, __m128i *tw1,__m128i *tw2,__m128i *tw3, - __m128i *tw1b,__m128i *tw2b,__m128i *tw3b) { + __m128i *tw1b,__m128i *tw2b,__m128i *tw3b) +{ + register __m128i x1t,x2t,x3t,x02t,x13t; register __m128i x1_flip,x3_flip; + x1t = packed_cmult2(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2(*(x3),*(tw3),*(tw3b)); + + // bfly4_tw1(x0,&x1t,&x2t,&x3t,y0,y1,y2,y3); x02t = _mm_adds_epi16(*(x0),x2t); x13t = _mm_adds_epi16(x1t,x3t); @@ -1285,11 +1523,12 @@ static inline void ibfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, */ *(y0) = _mm_adds_epi16(x02t,x13t); *(y2) = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(x1t,conjugatedft.v128); + + x1_flip = _mm_sign_epi16(x1t,*(__m128i*)conjugatedft); // x1_flip = _mm_shufflelo_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); // x1_flip = _mm_shufflehi_epi16(x1_flip,_MM_SHUFFLE(2,3,0,1)); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(x3t,conjugatedft.v128); + x3_flip = _mm_sign_epi16(x3t,*(__m128i*)conjugatedft); // x3_flip = _mm_shufflelo_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); // x3_flip = _mm_shufflehi_epi16(x3_flip,_MM_SHUFFLE(2,3,0,1)); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); @@ -1301,62 +1540,75 @@ static inline void ibfly4_16(__m128i *x0,__m128i *x1,__m128i *x2,__m128i *x3, */ *(y3) = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y1) = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + } #ifdef __AVX2__ static inline void ibfly4_16_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3, - __m256i *tw1b,__m256i *tw2b,__m256i *tw3b)__attribute__((always_inline)); + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3, + __m256i *tw1b,__m256i *tw2b,__m256i *tw3b)__attribute__((always_inline)); static inline void ibfly4_16_256(__m256i *x0,__m256i *x1,__m256i *x2,__m256i *x3, - __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, - __m256i *tw1,__m256i *tw2,__m256i *tw3, - __m256i *tw1b,__m256i *tw2b,__m256i *tw3b) { + __m256i *y0,__m256i *y1,__m256i *y2,__m256i *y3, + __m256i *tw1,__m256i *tw2,__m256i *tw3, + __m256i *tw1b,__m256i *tw2b,__m256i *tw3b) +{ + register __m256i x1t,x2t,x3t,x02t,x13t; register __m256i x1_flip,x3_flip; + register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + // each input xi is assumed to be to consecutive vectors xi0 xi1 on which to perform the 8 butterflies // [xi00 xi01 xi02 xi03 xi10 xi20 xi30 xi40] // each output yi is the same + x1t = packed_cmult2_256(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2_256(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2_256(*(x3),*(tw3),*(tw3b)); + x02t = _mm256_adds_epi16(*(x0),x2t); x13t = _mm256_adds_epi16(x1t,x3t); *(y0) = _mm256_adds_epi16(x02t,x13t); *(y2) = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(x1t,conjugatedft.v256); - x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); - x3_flip = _mm256_sign_epi16(x3t,conjugatedft.v256); - x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); + + x1_flip = _mm256_sign_epi16(x1t,*(__m256i*)conjugatedft); + x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); + x3_flip = _mm256_sign_epi16(x3t,*(__m256i*)conjugatedft); + x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm256_subs_epi16(*(x0),x2t); x13t = _mm256_subs_epi16(x1_flip,x3_flip); *(y3) = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f *(y1) = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + } #endif #elif defined(__arm__) static inline void ibfly4_16(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, - int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b)__attribute__((always_inline)); + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, + int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b)__attribute__((always_inline)); static inline void ibfly4_16(int16x8_t *x0,int16x8_t *x1,int16x8_t *x2,int16x8_t *x3, - int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, - int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b) { + int16x8_t *y0,int16x8_t *y1,int16x8_t *y2,int16x8_t *y3, + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3, + int16x8_t *tw1b,int16x8_t *tw2b,int16x8_t *tw3b) +{ + register int16x8_t x1t,x2t,x3t,x02t,x13t; register int16x8_t x1_flip,x3_flip; + x1t = packed_cmult2(*(x1),*(tw1),*(tw1b)); x2t = packed_cmult2(*(x2),*(tw2),*(tw2b)); x3t = packed_cmult2(*(x3),*(tw3),*(tw3b)); + x02t = vqaddq_s16(*(x0),x2t); x13t = vqaddq_s16(x1t,x3t); *(y0) = vqaddq_s16(x02t,x13t); *(y2) = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(x1t,*(int16x8_t *)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(x3t,*(int16x8_t *)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(x1t,*(int16x8_t*)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(x3t,*(int16x8_t*)conjugatedft)); x02t = vqsubq_s16(*(x0),x2t); x13t = vqsubq_s16(x1_flip,x3_flip); *(y3) = vqaddq_s16(x02t,x13t); // x0 - x1f - x2 + x3f @@ -1372,12 +1624,18 @@ static inline void bfly5(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3,__m1 static inline void bfly5(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3,__m128i *x4, __m128i *y0, __m128i *y1, __m128i *y2, __m128i *y3,__m128i *y4, - __m128i *tw1,__m128i *tw2,__m128i *tw3,__m128i *tw4) { + __m128i *tw1,__m128i *tw2,__m128i *tw3,__m128i *tw4) +{ + + + __m128i x1_2,x2_2,x3_2,x4_2,tmpre,tmpim; + packed_cmult(*(x1),*(tw1),&x1_2); packed_cmult(*(x2),*(tw2),&x2_2); packed_cmult(*(x3),*(tw3),&x3_2); packed_cmult(*(x4),*(tw4),&x4_2); + *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(x1_2,_mm_adds_epi16(x2_2,_mm_adds_epi16(x3_2,x4_2)))); cmult(x1_2,*(W15),&tmpre,&tmpim); cmac(x2_2,*(W25),&tmpre,&tmpim); @@ -1385,65 +1643,81 @@ static inline void bfly5(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3,__m1 cmac(x4_2,*(W45),&tmpre,&tmpim); *(y1) = cpack(tmpre,tmpim); *(y1) = _mm_adds_epi16(*(x0),*(y1)); + cmult(x1_2,*(W25),&tmpre,&tmpim); cmac(x2_2,*(W45),&tmpre,&tmpim); cmac(x3_2,*(W15),&tmpre,&tmpim); cmac(x4_2,*(W35),&tmpre,&tmpim); *(y2) = cpack(tmpre,tmpim); *(y2) = _mm_adds_epi16(*(x0),*(y2)); + cmult(x1_2,*(W35),&tmpre,&tmpim); cmac(x2_2,*(W15),&tmpre,&tmpim); cmac(x3_2,*(W45),&tmpre,&tmpim); cmac(x4_2,*(W25),&tmpre,&tmpim); *(y3) = cpack(tmpre,tmpim); *(y3) = _mm_adds_epi16(*(x0),*(y3)); + cmult(x1_2,*(W45),&tmpre,&tmpim); cmac(x2_2,*(W35),&tmpre,&tmpim); cmac(x3_2,*(W25),&tmpre,&tmpim); cmac(x4_2,*(W15),&tmpre,&tmpim); *(y4) = cpack(tmpre,tmpim); *(y4) = _mm_adds_epi16(*(x0),*(y4)); + + } #ifdef __AVX2__ static inline void bfly5_256(__m256i *x0, __m256i *x1, __m256i *x2, __m256i *x3,__m256i *x4, - __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4, - __m256i *tw1,__m256i *tw2,__m256i *tw3,__m256i *tw4)__attribute__((always_inline)); + __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4, + __m256i *tw1,__m256i *tw2,__m256i *tw3,__m256i *tw4)__attribute__((always_inline)); static inline void bfly5_256(__m256i *x0, __m256i *x1, __m256i *x2, __m256i *x3,__m256i *x4, - __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4, - __m256i *tw1,__m256i *tw2,__m256i *tw3,__m256i *tw4) { + __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4, + __m256i *tw1,__m256i *tw2,__m256i *tw3,__m256i *tw4) +{ + + + __m256i x1_2,x2_2,x3_2,x4_2,tmpre,tmpim; + packed_cmult_256(*(x1),*(tw1),&x1_2); packed_cmult_256(*(x2),*(tw2),&x2_2); packed_cmult_256(*(x3),*(tw3),&x3_2); packed_cmult_256(*(x4),*(tw4),&x4_2); + *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(x1_2,_mm256_adds_epi16(x2_2,_mm256_adds_epi16(x3_2,x4_2)))); - cmult_256(x1_2,*(W15_256),tmpre,tmpim); - cmac_256(x2_2,*(W25_256),tmpre,tmpim); - cmac_256(x3_2,*(W35_256),tmpre,tmpim); - cmac_256(x4_2,*(W45_256),tmpre,tmpim); + cmult_256(x1_2,*(W15_256),&tmpre,&tmpim); + cmac_256(x2_2,*(W25_256),&tmpre,&tmpim); + cmac_256(x3_2,*(W35_256),&tmpre,&tmpim); + cmac_256(x4_2,*(W45_256),&tmpre,&tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmult_256(x1_2,*(W25_256),tmpre,tmpim); - cmac_256(x2_2,*(W45_256),tmpre,tmpim); - cmac_256(x3_2,*(W15_256),tmpre,tmpim); - cmac_256(x4_2,*(W35_256),tmpre,tmpim); + + cmult_256(x1_2,*(W25_256),&tmpre,&tmpim); + cmac_256(x2_2,*(W45_256),&tmpre,&tmpim); + cmac_256(x3_2,*(W15_256),&tmpre,&tmpim); + cmac_256(x4_2,*(W35_256),&tmpre,&tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); - cmult_256(x1_2,*(W35_256),tmpre,tmpim); - cmac_256(x2_2,*(W15_256),tmpre,tmpim); - cmac_256(x3_2,*(W45_256),tmpre,tmpim); - cmac_256(x4_2,*(W25_256),tmpre,tmpim); + + cmult_256(x1_2,*(W35_256),&tmpre,&tmpim); + cmac_256(x2_2,*(W15_256),&tmpre,&tmpim); + cmac_256(x3_2,*(W45_256),&tmpre,&tmpim); + cmac_256(x4_2,*(W25_256),&tmpre,&tmpim); *(y3) = cpack_256(tmpre,tmpim); *(y3) = _mm256_adds_epi16(*(x0),*(y3)); - cmult_256(x1_2,*(W45_256),tmpre,tmpim); - cmac_256(x2_2,*(W35_256),tmpre,tmpim); - cmac_256(x3_2,*(W25_256),tmpre,tmpim); - cmac_256(x4_2,*(W15_256),tmpre,tmpim); + + cmult_256(x1_2,*(W45_256),&tmpre,&tmpim); + cmac_256(x2_2,*(W35_256),&tmpre,&tmpim); + cmac_256(x3_2,*(W25_256),&tmpre,&tmpim); + cmac_256(x4_2,*(W15_256),&tmpre,&tmpim); *(y4) = cpack_256(tmpre,tmpim); *(y4) = _mm256_adds_epi16(*(x0),*(y4)); + + } #endif @@ -1454,13 +1728,19 @@ static inline void bfly5(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x8_t static inline void bfly5(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x8_t *x3,int16x8_t *x4, int16x8_t *y0, int16x8_t *y1, int16x8_t *y2, int16x8_t *y3,int16x8_t *y4, - int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3,int16x8_t *tw4) { + int16x8_t *tw1,int16x8_t *tw2,int16x8_t *tw3,int16x8_t *tw4) +{ + + + int16x8_t x1_2,x2_2,x3_2,x4_2; int32x4_t tmpre,tmpim; + packed_cmult(*(x1),*(tw1),&x1_2); packed_cmult(*(x2),*(tw2),&x2_2); packed_cmult(*(x3),*(tw3),&x3_2); packed_cmult(*(x4),*(tw4),&x4_2); + *(y0) = vqaddq_s16(*(x0),vqaddq_s16(x1_2,vqaddq_s16(x2_2,vqaddq_s16(x3_2,x4_2)))); cmult(x1_2,*(W15),&tmpre,&tmpim); cmac(x2_2,*(W25),&tmpre,&tmpim); @@ -1468,24 +1748,29 @@ static inline void bfly5(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x8_t cmac(x4_2,*(W45),&tmpre,&tmpim); *(y1) = cpack(tmpre,tmpim); *(y1) = vqaddq_s16(*(x0),*(y1)); + cmult(x1_2,*(W25),&tmpre,&tmpim); cmac(x2_2,*(W45),&tmpre,&tmpim); cmac(x3_2,*(W15),&tmpre,&tmpim); cmac(x4_2,*(W35),&tmpre,&tmpim); *(y2) = cpack(tmpre,tmpim); *(y2) = vqaddq_s16(*(x0),*(y2)); + cmult(x1_2,*(W35),&tmpre,&tmpim); cmac(x2_2,*(W15),&tmpre,&tmpim); cmac(x3_2,*(W45),&tmpre,&tmpim); cmac(x4_2,*(W25),&tmpre,&tmpim); *(y3) = cpack(tmpre,tmpim); *(y3) = vqaddq_s16(*(x0),*(y3)); + cmult(x1_2,*(W45),&tmpre,&tmpim); cmac(x2_2,*(W35),&tmpre,&tmpim); cmac(x3_2,*(W25),&tmpre,&tmpim); cmac(x4_2,*(W15),&tmpre,&tmpim); *(y4) = cpack(tmpre,tmpim); *(y4) = vqaddq_s16(*(x0),*(y4)); + + } @@ -1496,8 +1781,11 @@ static inline void bfly5_tw1(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3, __m128i *y0, __m128i *y1, __m128i *y2, __m128i *y3,__m128i *y4) __attribute__((always_inline)); static inline void bfly5_tw1(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3,__m128i *x4, - __m128i *y0, __m128i *y1, __m128i *y2, __m128i *y3,__m128i *y4) { + __m128i *y0, __m128i *y1, __m128i *y2, __m128i *y3,__m128i *y4) +{ + __m128i tmpre,tmpim; + *(y0) = _mm_adds_epi16(*(x0),_mm_adds_epi16(*(x1),_mm_adds_epi16(*(x2),_mm_adds_epi16(*(x3),*(x4))))); cmult(*(x1),*(W15),&tmpre,&tmpim); cmac(*(x2),*(W25),&tmpre,&tmpim); @@ -1527,34 +1815,37 @@ static inline void bfly5_tw1(__m128i *x0, __m128i *x1, __m128i *x2, __m128i *x3, #ifdef __AVX2__ static inline void bfly5_tw1_256(__m256i *x0, __m256i *x1, __m256i *x2, __m256i *x3,__m256i *x4, - __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4) __attribute__((always_inline)); + __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4) __attribute__((always_inline)); static inline void bfly5_tw1_256(__m256i *x0, __m256i *x1, __m256i *x2, __m256i *x3,__m256i *x4, - __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4) { + __m256i *y0, __m256i *y1, __m256i *y2, __m256i *y3,__m256i *y4) +{ + __m256i tmpre,tmpim; + *(y0) = _mm256_adds_epi16(*(x0),_mm256_adds_epi16(*(x1),_mm256_adds_epi16(*(x2),_mm256_adds_epi16(*(x3),*(x4))))); - cmult_256(*(x1),*(W15_256),tmpre,tmpim); - cmac_256(*(x2),*(W25_256),tmpre,tmpim); - cmac_256(*(x3),*(W35_256),tmpre,tmpim); - cmac_256(*(x4),*(W45_256),tmpre,tmpim); + cmult_256(*(x1),*(W15_256),&tmpre,&tmpim); + cmac_256(*(x2),*(W25_256),&tmpre,&tmpim); + cmac_256(*(x3),*(W35_256),&tmpre,&tmpim); + cmac_256(*(x4),*(W45_256),&tmpre,&tmpim); *(y1) = cpack_256(tmpre,tmpim); *(y1) = _mm256_adds_epi16(*(x0),*(y1)); - cmult_256(*(x1),*(W25_256),tmpre,tmpim); - cmac_256(*(x2),*(W45_256),tmpre,tmpim); - cmac_256(*(x3),*(W15_256),tmpre,tmpim); - cmac_256(*(x4),*(W35_256),tmpre,tmpim); + cmult_256(*(x1),*(W25_256),&tmpre,&tmpim); + cmac_256(*(x2),*(W45_256),&tmpre,&tmpim); + cmac_256(*(x3),*(W15_256),&tmpre,&tmpim); + cmac_256(*(x4),*(W35_256),&tmpre,&tmpim); *(y2) = cpack_256(tmpre,tmpim); *(y2) = _mm256_adds_epi16(*(x0),*(y2)); - cmult_256(*(x1),*(W35_256),tmpre,tmpim); - cmac_256(*(x2),*(W15_256),tmpre,tmpim); - cmac_256(*(x3),*(W45_256),tmpre,tmpim); - cmac_256(*(x4),*(W25_256),tmpre,tmpim); + cmult_256(*(x1),*(W35_256),&tmpre,&tmpim); + cmac_256(*(x2),*(W15_256),&tmpre,&tmpim); + cmac_256(*(x3),*(W45_256),&tmpre,&tmpim); + cmac_256(*(x4),*(W25_256),&tmpre,&tmpim); *(y3) = cpack_256(tmpre,tmpim); *(y3) = _mm256_adds_epi16(*(x0),*(y3)); - cmult_256(*(x1),*(W45_256),tmpre,tmpim); - cmac_256(*(x2),*(W35_256),tmpre,tmpim); - cmac_256(*(x3),*(W25_256),tmpre,tmpim); - cmac_256(*(x4),*(W15_256),tmpre,tmpim); + cmult_256(*(x1),*(W45_256),&tmpre,&tmpim); + cmac_256(*(x2),*(W35_256),&tmpre,&tmpim); + cmac_256(*(x3),*(W25_256),&tmpre,&tmpim); + cmac_256(*(x4),*(W15_256),&tmpre,&tmpim); *(y4) = cpack_256(tmpre,tmpim); *(y4) = _mm256_adds_epi16(*(x0),*(y4)); } @@ -1564,8 +1855,11 @@ static inline void bfly5_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x int16x8_t *y0, int16x8_t *y1, int16x8_t *y2, int16x8_t *y3,int16x8_t *y4) __attribute__((always_inline)); static inline void bfly5_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x8_t *x3,int16x8_t *x4, - int16x8_t *y0, int16x8_t *y1, int16x8_t *y2, int16x8_t *y3,int16x8_t *y4) { + int16x8_t *y0, int16x8_t *y1, int16x8_t *y2, int16x8_t *y3,int16x8_t *y4) +{ + int32x4_t tmpre,tmpim; + *(y0) = vqaddq_s16(*(x0),vqaddq_s16(*(x1),vqaddq_s16(*(x2),vqaddq_s16(*(x3),*(x4))))); cmult(*(x1),*(W15),&tmpre,&tmpim); cmac(*(x2),*(W25),&tmpre,&tmpim); @@ -1599,8 +1893,10 @@ static inline void bfly5_tw1(int16x8_t *x0, int16x8_t *x1, int16x8_t *x2, int16x #if defined(__x86_64__) || defined(__i386__) static inline void transpose16(__m128i *x,__m128i *y) __attribute__((always_inline)); -static inline void transpose16(__m128i *x,__m128i *y) { +static inline void transpose16(__m128i *x,__m128i *y) +{ register __m128i ytmp0,ytmp1,ytmp2,ytmp3; + ytmp0 = _mm_unpacklo_epi32(x[0],x[1]); ytmp1 = _mm_unpackhi_epi32(x[0],x[1]); ytmp2 = _mm_unpacklo_epi32(x[2],x[3]); @@ -1613,10 +1909,13 @@ static inline void transpose16(__m128i *x,__m128i *y) { #elif defined(__arm__) static inline void transpose16(int16x8_t *x,int16x8_t *y) __attribute__((always_inline)); -static inline void transpose16(int16x8_t *x,int16x8_t *y) { +static inline void transpose16(int16x8_t *x,int16x8_t *y) +{ register uint32x4x2_t ytmp0,ytmp1; + ytmp0 = vtrnq_u32((uint32x4_t)(x[0]),(uint32x4_t)(x[1])); ytmp1 = vtrnq_u32((uint32x4_t)(x[2]),(uint32x4_t)(x[3])); + y[0] = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); y[1] = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); y[2] = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); @@ -1628,14 +1927,16 @@ static inline void transpose16(int16x8_t *x,int16x8_t *y) { #if defined(__x86_64__) || defined(__i386__) static inline void transpose16_ooff(__m128i *x,__m128i *y,int off) __attribute__((always_inline)); -static inline void transpose16_ooff(__m128i *x,__m128i *y,int off) { +static inline void transpose16_ooff(__m128i *x,__m128i *y,int off) +{ register __m128i ytmp0,ytmp1,ytmp2,ytmp3; __m128i *y2=y; + ytmp0 = _mm_unpacklo_epi32(x[0],x[1]); // x00 x10 x01 x11 ytmp1 = _mm_unpackhi_epi32(x[0],x[1]); // x02 x12 x03 x13 ytmp2 = _mm_unpacklo_epi32(x[2],x[3]); // x20 x30 x21 x31 ytmp3 = _mm_unpackhi_epi32(x[2],x[3]); // x22 x32 x23 x33 - *y2 = _mm_unpacklo_epi64(ytmp0,ytmp2); // x00 x10 x20 x30 + *y2 = _mm_unpacklo_epi64(ytmp0,ytmp2); // x00 x10 x20 x30 y2+=off; *y2 = _mm_unpackhi_epi64(ytmp0,ytmp2); // x01 x11 x21 x31 y2+=off; @@ -1647,10 +1948,12 @@ static inline void transpose16_ooff(__m128i *x,__m128i *y,int off) { #ifdef __AVX2__ static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) __attribute__((always_inline)); -static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) { +static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) +{ register __m256i ytmp0,ytmp1,ytmp2,ytmp3,ytmp4,ytmp5,ytmp6,ytmp7; __m256i *y2=y; __m256i const perm_mask = _mm256_set_epi32(7, 3, 5, 1, 6, 2, 4, 0); + ytmp0 = _mm256_permutevar8x32_epi32(x[0],perm_mask); // x00 x10 x01 x11 x02 x12 x03 x13 ytmp1 = _mm256_permutevar8x32_epi32(x[1],perm_mask); // x20 x30 x21 x31 x22 x32 x23 x33 ytmp2 = _mm256_permutevar8x32_epi32(x[2],perm_mask); // x40 x50 x41 x51 x42 x52 x43 x53 @@ -1659,12 +1962,13 @@ static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) { ytmp5 = _mm256_unpackhi_epi64(ytmp0,ytmp1); // x02 x12 x22 x32 x03 x13 x23 x33 ytmp6 = _mm256_unpacklo_epi64(ytmp2,ytmp3); // x40 x50 x60 x70 x41 x51 x61 x71 ytmp7 = _mm256_unpackhi_epi64(ytmp2,ytmp3); // x42 x52 x62 x72 x43 x53 x63 x73 + *y2 = _mm256_insertf128_si256(ytmp4,_mm256_extracti128_si256(ytmp6,0),1); //x00 x10 x20 x30 x40 x50 x60 x70 - y2+=off; + y2+=off; *y2 = _mm256_insertf128_si256(ytmp6,_mm256_extracti128_si256(ytmp4,1),0); //x01 x11 x21 x31 x41 x51 x61 x71 - y2+=off; + y2+=off; *y2 = _mm256_insertf128_si256(ytmp5,_mm256_extracti128_si256(ytmp7,0),1); //x00 x10 x20 x30 x40 x50 x60 x70 - y2+=off; + y2+=off; *y2 = _mm256_insertf128_si256(ytmp7,_mm256_extracti128_si256(ytmp5,1),0); //x01 x11 x21 x31 x41 x51 x61 x71 } #endif @@ -1672,18 +1976,20 @@ static inline void transpose16_ooff_simd256(__m256i *x,__m256i *y,int off) { #elif defined(__arm__) static inline void transpose16_ooff(int16x8_t *x,int16x8_t *y,int off) __attribute__((always_inline)); -static inline void transpose16_ooff(int16x8_t *x,int16x8_t *y,int off) { +static inline void transpose16_ooff(int16x8_t *x,int16x8_t *y,int off) +{ int16x8_t *y2=y; register uint32x4x2_t ytmp0,ytmp1; + ytmp0 = vtrnq_u32((uint32x4_t)(x[0]),(uint32x4_t)(x[1])); ytmp1 = vtrnq_u32((uint32x4_t)(x[2]),(uint32x4_t)(x[3])); - *y2 = (int16x8_t)vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); - y2+=off; - *y2 = (int16x8_t)vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); - y2+=off; - *y2 = (int16x8_t)vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); - y2+=off; + + *y2 = (int16x8_t)vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); y2+=off; + *y2 = (int16x8_t)vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); y2+=off; + *y2 = (int16x8_t)vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); y2+=off; *y2 = (int16x8_t)vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[1]),vget_high_s16((int16x8_t)ytmp1.val[1])); + + } #endif @@ -1691,9 +1997,11 @@ static inline void transpose16_ooff(int16x8_t *x,int16x8_t *y,int off) { #if defined(__x86_64__) || defined(__i386__) static inline void transpose4_ooff(__m64 *x,__m64 *y,int off)__attribute__((always_inline)); -static inline void transpose4_ooff(__m64 *x,__m64 *y,int off) { +static inline void transpose4_ooff(__m64 *x,__m64 *y,int off) +{ y[0] = _mm_unpacklo_pi32(x[0],x[1]); y[off] = _mm_unpackhi_pi32(x[0],x[1]); + // x[0] = [x0 x1] // x[1] = [x2 x3] // y[0] = [x0 x2] @@ -1701,9 +2009,11 @@ static inline void transpose4_ooff(__m64 *x,__m64 *y,int off) { } #ifdef __AVX2__ static inline void transpose4_ooff_simd256(__m256i *x,__m256i *y,int off)__attribute__((always_inline)); -static inline void transpose4_ooff_simd256(__m256i *x,__m256i *y,int off) { +static inline void transpose4_ooff_simd256(__m256i *x,__m256i *y,int off) +{ __m256i const perm_mask = _mm256_set_epi32(7, 5, 3, 1, 6, 4, 2, 0); __m256i perm_tmp0,perm_tmp1; + // x[0] = [x0 x1 x2 x3 x4 x5 x6 x7] // x[1] = [x8 x9 x10 x11 x12 x13 x14] // y[0] = [x0 x2 x4 x6 x8 x10 x12 x14] @@ -1717,8 +2027,10 @@ static inline void transpose4_ooff_simd256(__m256i *x,__m256i *y,int off) { #elif (__arm__) static inline void transpose4_ooff(int16x4_t *x,int16x4_t *y,int off)__attribute__((always_inline)); -static inline void transpose4_ooff(int16x4_t *x,int16x4_t *y,int off) { +static inline void transpose4_ooff(int16x4_t *x,int16x4_t *y,int off) +{ uint32x2x2_t ytmp = vtrn_u32((uint32x2_t)x[0],(uint32x2_t)x[1]); + y[0] = (int16x4_t)ytmp.val[0]; y[off] = (int16x4_t)ytmp.val[1]; } @@ -1727,47 +2039,47 @@ static inline void transpose4_ooff(int16x4_t *x,int16x4_t *y,int off) { // 16-point optimized DFT kernel -const static int16_t tw16[24] __attribute__((aligned(32))) = { 32767,0,30272,-12540,23169,-23170,12539,-30273, - 32767,0,23169,-23170,0,-32767,-23170,-23170, - 32767,0,12539,-30273,-23170,-23170,-30273,12539 - }; +const static int16_t tw16[24] __attribute__((aligned(32))) = { 32767,0,30272,-12540,23169 ,-23170,12539 ,-30273, + 32767,0,23169,-23170,0 ,-32767,-23170,-23170, + 32767,0,12539,-30273,-23170,-23170,-30273,12539 + }; -const static int16_t tw16a[24] __attribute__((aligned(32))) = {32767,0,30272,12540,23169,23170,12539,30273, - 32767,0,23169,23170,0,32767,-23170,23170, - 32767,0,12539,30273,-23170,23170,-30273,-12539 - }; +const static int16_t tw16a[24] __attribute__((aligned(32))) = {32767,0,30272,12540,23169 ,23170,12539 ,30273, + 32767,0,23169,23170,0 ,32767,-23170,23170, + 32767,0,12539,30273,-23170,23170,-30273,-12539 + }; -const static int16_t tw16b[24] __attribute__((aligned(32))) = { 0,32767,-12540,30272,-23170,23169,-30273,12539, - 0,32767,-23170,23169,-32767,0,-23170,-23170, - 0,32767,-30273,12539,-23170,-23170,12539,-30273 - }; +const static int16_t tw16b[24] __attribute__((aligned(32))) = { 0,32767,-12540,30272,-23170,23169 ,-30273,12539, + 0,32767,-23170,23169,-32767,0 ,-23170,-23170, + 0,32767,-30273,12539,-23170,-23170,12539 ,-30273 + }; -const static int16_t tw16c[24] __attribute__((aligned(32))) = { 0,32767,12540,30272,23170,23169,30273,12539, - 0,32767,23170,23169,32767,0,23170,-23170, - 0,32767,30273,12539,23170,-23170,-12539,-30273 - }; +const static int16_t tw16c[24] __attribute__((aligned(32))) = { 0,32767,12540,30272,23170,23169 ,30273 ,12539, + 0,32767,23170,23169,32767,0 ,23170 ,-23170, + 0,32767,30273,12539,23170,-23170,-12539,-30273 + }; #ifdef __AVX2__ -const static int16_t tw16rep[48] __attribute__((aligned(32))) = { 32767,0,30272,-12540,23169,-23170,12539,-30273,32767,0,30272,-12540,23169,-23170,12539,-30273, - 32767,0,23169,-23170,0,-32767,-23170,-23170,32767,0,23169,-23170,0,-32767,-23170,-23170, - 32767,0,12539,-30273,-23170,-23170,-30273,12539,32767,0,12539,-30273,-23170,-23170,-30273,12539 - }; +const static int16_t tw16rep[48] __attribute__((aligned(32))) = { 32767,0,30272,-12540,23169 ,-23170,12539 ,-30273,32767,0,30272,-12540,23169 ,-23170,12539 ,-30273, + 32767,0,23169,-23170,0 ,-32767,-23170,-23170,32767,0,23169,-23170,0 ,-32767,-23170,-23170, + 32767,0,12539,-30273,-23170,-23170,-30273,12539,32767,0,12539,-30273,-23170,-23170,-30273,12539 + }; -const static int16_t tw16arep[48] __attribute__((aligned(32))) = {32767,0,30272,12540,23169,23170,12539,30273,32767,0,30272,12540,23169,23170,12539,30273, - 32767,0,23169,23170,0,32767,-23170,23170,32767,0,23169,23170,0,32767,-23170,23170, - 32767,0,12539,30273,-23170,23170,-30273,-12539,32767,0,12539,30273,-23170,23170,-30273,-12539 - }; +const static int16_t tw16arep[48] __attribute__((aligned(32))) = {32767,0,30272,12540,23169 ,23170,12539 ,30273,32767,0,30272,12540,23169 ,23170,12539 ,30273, + 32767,0,23169,23170,0 ,32767,-23170,23170,32767,0,23169,23170,0 ,32767,-23170,23170, + 32767,0,12539,30273,-23170,23170,-30273,-12539,32767,0,12539,30273,-23170,23170,-30273,-12539 + }; -const static int16_t tw16brep[48] __attribute__((aligned(32))) = { 0,32767,-12540,30272,-23170,23169,-30273,12539,0,32767,-12540,30272,-23170,23169,-30273,12539, - 0,32767,-23170,23169,-32767,0,-23170,-23170,0,32767,-23170,23169,-32767,0,-23170,-23170, - 0,32767,-30273,12539,-23170,-23170,12539,-30273,0,32767,-30273,12539,-23170,-23170,12539,-30273 - }; +const static int16_t tw16brep[48] __attribute__((aligned(32))) = { 0,32767,-12540,30272,-23170,23169 ,-30273,12539,0,32767,-12540,30272,-23170,23169 ,-30273,12539, + 0,32767,-23170,23169,-32767,0 ,-23170,-23170,0,32767,-23170,23169,-32767,0 ,-23170,-23170, + 0,32767,-30273,12539,-23170,-23170,12539 ,-30273,0,32767,-30273,12539,-23170,-23170,12539 ,-30273 + }; -const static int16_t tw16crep[48] __attribute__((aligned(32))) = { 0,32767,12540,30272,23170,23169,30273,12539,0,32767,12540,30272,23170,23169,30273,12539, - 0,32767,23170,23169,32767,0,23170,-23170,0,32767,23170,23169,32767,0,23170,-23170, - 0,32767,30273,12539,23170,-23170,-12539,-30273,0,32767,30273,12539,23170,-23170,-12539,-30273 - }; +const static int16_t tw16crep[48] __attribute__((aligned(32))) = { 0,32767,12540,30272,23170,23169 ,30273 ,12539,0,32767,12540,30272,23170,23169 ,30273 ,12539, + 0,32767,23170,23169,32767,0 ,23170 ,-23170,0,32767,23170,23169,32767,0 ,23170 ,-23170, + 0,32767,30273,12539,23170,-23170,-12539,-30273,0,32767,30273,12539,23170,-23170,-12539,-30273 + }; #endif /* __AVX2__ */ @@ -1775,9 +2087,15 @@ const static int16_t tw16crep[48] __attribute__((aligned(32))) = { 0,32767,12540 static inline void dft16(int16_t *x,int16_t *y) __attribute__((always_inline)); -static inline void dft16(int16_t *x,int16_t *y) { +static inline void dft16(int16_t *x,int16_t *y) +{ + #if defined(__x86_64__) || defined(__i386__) + __m128i *tw16a_128=(__m128i *)tw16a,*tw16b_128=(__m128i *)tw16b,*x128=(__m128i *)x,*y128=(__m128i *)y; + + + /* This is the original version before unrolling bfly4_tw1(x128,x128+1,x128+2,x128+3, @@ -1789,22 +2107,26 @@ static inline void dft16(int16_t *x,int16_t *y) { y128,y128+1,y128+2,y128+3, tw16_128,tw16_128+1,tw16_128+2); */ + register __m128i x1_flip,x3_flip,x02t,x13t; register __m128i ytmp0,ytmp1,ytmp2,ytmp3,xtmp0,xtmp1,xtmp2,xtmp3; register __m128i complex_shuffle = _mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + // First stage : 4 Radix-4 butterflies without input twiddles + x02t = _mm_adds_epi16(x128[0],x128[2]); x13t = _mm_adds_epi16(x128[1],x128[3]); xtmp0 = _mm_adds_epi16(x02t,x13t); xtmp2 = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(x128[1],conjugatedft.v128); + x1_flip = _mm_sign_epi16(x128[1],*(__m128i*)conjugatedft); x1_flip = _mm_shuffle_epi8(x1_flip,complex_shuffle); - x3_flip = _mm_sign_epi16(x128[3],conjugatedft.v128); + x3_flip = _mm_sign_epi16(x128[3],*(__m128i*)conjugatedft); x3_flip = _mm_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm_subs_epi16(x128[0],x128[2]); x13t = _mm_subs_epi16(x1_flip,x3_flip); xtmp1 = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp3 = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + ytmp0 = _mm_unpacklo_epi32(xtmp0,xtmp1); ytmp1 = _mm_unpackhi_epi32(xtmp0,xtmp1); ytmp2 = _mm_unpacklo_epi32(xtmp2,xtmp3); @@ -1813,24 +2135,29 @@ static inline void dft16(int16_t *x,int16_t *y) { xtmp1 = _mm_unpackhi_epi64(ytmp0,ytmp2); xtmp2 = _mm_unpacklo_epi64(ytmp1,ytmp3); xtmp3 = _mm_unpackhi_epi64(ytmp1,ytmp3); + // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2(xtmp1,tw16a_128[0],tw16b_128[0]); xtmp2 = packed_cmult2(xtmp2,tw16a_128[1],tw16b_128[1]); xtmp3 = packed_cmult2(xtmp3,tw16a_128[2],tw16b_128[2]); + x02t = _mm_adds_epi16(xtmp0,xtmp2); x13t = _mm_adds_epi16(xtmp1,xtmp3); y128[0] = _mm_adds_epi16(x02t,x13t); y128[2] = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(xtmp1,conjugatedft.v128); + x1_flip = _mm_sign_epi16(xtmp1,*(__m128i*)conjugatedft); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(xtmp3,conjugatedft.v128); + x3_flip = _mm_sign_epi16(xtmp3,*(__m128i*)conjugatedft); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); x02t = _mm_subs_epi16(xtmp0,xtmp2); x13t = _mm_subs_epi16(x1_flip,x3_flip); y128[1] = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f y128[3] = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + #elif defined(__arm__) + int16x8_t *tw16a_128=(int16x8_t *)tw16a,*tw16b_128=(int16x8_t *)tw16b,*x128=(int16x8_t *)x,*y128=(int16x8_t *)y; + /* This is the original version before unrolling bfly4_tw1(x128,x128+1,x128+2,x128+3, @@ -1842,76 +2169,95 @@ static inline void dft16(int16_t *x,int16_t *y) { y128,y128+1,y128+2,y128+3, tw16_128,tw16_128+1,tw16_128+2); */ + register int16x8_t x1_flip,x3_flip,x02t,x13t; register int16x8_t xtmp0,xtmp1,xtmp2,xtmp3; register uint32x4x2_t ytmp0,ytmp1; register int16x8_t ytmp0b,ytmp1b,ytmp2b,ytmp3b; + // First stage : 4 Radix-4 butterflies without input twiddles + x02t = vqaddq_s16(x128[0],x128[2]); x13t = vqaddq_s16(x128[1],x128[3]); xtmp0 = vqaddq_s16(x02t,x13t); xtmp2 = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(x128[1],*(int16x8_t *)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(x128[3],*(int16x8_t *)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(x128[1],*(int16x8_t*)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(x128[3],*(int16x8_t*)conjugatedft)); x02t = vqsubq_s16(x128[0],x128[2]); x13t = vqsubq_s16(x1_flip,x3_flip); xtmp1 = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp3 = vqsubq_s16(x02t,x13t); // x0 - x1f - x2 + x3f + ytmp0 = vtrnq_u32((uint32x4_t)(xtmp0),(uint32x4_t)(xtmp1)); - // y0[0] = [x00 x10 x02 x12], y0[1] = [x01 x11 x03 x13] +// y0[0] = [x00 x10 x02 x12], y0[1] = [x01 x11 x03 x13] ytmp1 = vtrnq_u32((uint32x4_t)(xtmp2),(uint32x4_t)(xtmp3)); - // y1[0] = [x20 x30 x22 x32], y1[1] = [x21 x31 x23 x33] +// y1[0] = [x20 x30 x22 x32], y1[1] = [x21 x31 x23 x33] + + ytmp0b = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); - // y0 = [x00 x10 x20 x30] +// y0 = [x00 x10 x20 x30] ytmp1b = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); - // t1 = [x01 x11 x21 x31] +// t1 = [x01 x11 x21 x31] ytmp2b = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); - // t2 = [x02 x12 x22 x32] +// t2 = [x02 x12 x22 x32] ytmp3b = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[1]),vget_high_s16((int16x8_t)ytmp1.val[1])); - // t3 = [x03 x13 x23 x33] +// t3 = [x03 x13 x23 x33] + + // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2(ytmp1b,tw16a_128[0],tw16b_128[0]); xtmp2 = packed_cmult2(ytmp2b,tw16a_128[1],tw16b_128[1]); xtmp3 = packed_cmult2(ytmp3b,tw16a_128[2],tw16b_128[2]); + x02t = vqaddq_s16(ytmp0b,xtmp2); x13t = vqaddq_s16(xtmp1,xtmp3); y128[0] = vqaddq_s16(x02t,x13t); y128[2] = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(xtmp1,*(int16x8_t *)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(xtmp3,*(int16x8_t *)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(xtmp1,*(int16x8_t*)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(xtmp3,*(int16x8_t*)conjugatedft)); x02t = vqsubq_s16(ytmp0b,xtmp2); x13t = vqsubq_s16(x1_flip,x3_flip); y128[1] = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f y128[3] = vqsubq_s16(x02t,x13t); // x0 - x1f - x2 + x3f + + #endif } #if defined(__x86_64__) || defined(__i386__) #ifdef __AVX2__ -// Does two 16-point DFTS (x[0 .. 15] is 128 LSBs of input vector, x[16..31] is in 128 MSBs) +// Does two 16-point DFTS (x[0 .. 15] is 128 LSBs of input vector, x[16..31] is in 128 MSBs) static inline void dft16_simd256(int16_t *x,int16_t *y) __attribute__((always_inline)); -static inline void dft16_simd256(int16_t *x,int16_t *y) { +static inline void dft16_simd256(int16_t *x,int16_t *y) +{ + __m256i *tw16a_256=(__m256i *)tw16arep,*tw16b_256=(__m256i *)tw16brep,*x256=(__m256i *)x,*y256=(__m256i *)y; + __m256i x1_flip,x3_flip,x02t,x13t; __m256i ytmp0,ytmp1,ytmp2,ytmp3,xtmp0,xtmp1,xtmp2,xtmp3; + register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + // First stage : 4 Radix-4 butterflies without input twiddles + x02t = _mm256_adds_epi16(x256[0],x256[2]); x13t = _mm256_adds_epi16(x256[1],x256[3]); xtmp0 = _mm256_adds_epi16(x02t,x13t); xtmp2 = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(x256[1],conjugatedft.v256); - x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); - x3_flip = _mm256_sign_epi16(x256[3],conjugatedft.v256); - x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); + x1_flip = _mm256_sign_epi16(x256[1],*(__m256i*)conjugatedft); + x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); + x3_flip = _mm256_sign_epi16(x256[3],*(__m256i*)conjugatedft); + x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm256_subs_epi16(x256[0],x256[2]); x13t = _mm256_subs_epi16(x1_flip,x3_flip); xtmp1 = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp3 = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + /* print_shorts256("xtmp0",(int16_t*)&xtmp0); print_shorts256("xtmp1",(int16_t*)&xtmp1); print_shorts256("xtmp2",(int16_t*)&xtmp2); print_shorts256("xtmp3",(int16_t*)&xtmp3);*/ - ytmp0 = _mm256_unpacklo_epi32(xtmp0,xtmp1); + + ytmp0 = _mm256_unpacklo_epi32(xtmp0,xtmp1); ytmp1 = _mm256_unpackhi_epi32(xtmp0,xtmp1); ytmp2 = _mm256_unpacklo_epi32(xtmp2,xtmp3); ytmp3 = _mm256_unpackhi_epi32(xtmp2,xtmp3); @@ -1919,47 +2265,57 @@ static inline void dft16_simd256(int16_t *x,int16_t *y) { xtmp1 = _mm256_unpackhi_epi64(ytmp0,ytmp2); xtmp2 = _mm256_unpacklo_epi64(ytmp1,ytmp3); xtmp3 = _mm256_unpackhi_epi64(ytmp1,ytmp3); + // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2_256(xtmp1,tw16a_256[0],tw16b_256[0]); xtmp2 = packed_cmult2_256(xtmp2,tw16a_256[1],tw16b_256[1]); xtmp3 = packed_cmult2_256(xtmp3,tw16a_256[2],tw16b_256[2]); + /* print_shorts256("xtmp0",(int16_t*)&xtmp0); print_shorts256("xtmp1",(int16_t*)&xtmp1); print_shorts256("xtmp2",(int16_t*)&xtmp2); print_shorts256("xtmp3",(int16_t*)&xtmp3);*/ + x02t = _mm256_adds_epi16(xtmp0,xtmp2); x13t = _mm256_adds_epi16(xtmp1,xtmp3); ytmp0 = _mm256_adds_epi16(x02t,x13t); ytmp2 = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(xtmp1,conjugatedft.v256); - x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); - x3_flip = _mm256_sign_epi16(xtmp3,conjugatedft.v256); - x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); + x1_flip = _mm256_sign_epi16(xtmp1,*(__m256i*)conjugatedft); + x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); + x3_flip = _mm256_sign_epi16(xtmp3,*(__m256i*)conjugatedft); + x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm256_subs_epi16(xtmp0,xtmp2); x13t = _mm256_subs_epi16(x1_flip,x3_flip); ytmp1 = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f ytmp3 = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + + // [y0 y1 y2 y3 y16 y17 y18 y19] // [y4 y5 y6 y7 y20 y21 y22 y23] // [y8 y9 y10 y11 y24 y25 y26 y27] // [y12 y13 y14 y15 y28 y29 y30 y31] + y256[0] = _mm256_insertf128_si256(ytmp0,_mm256_extracti128_si256(ytmp1,0),1); y256[1] = _mm256_insertf128_si256(ytmp2,_mm256_extracti128_si256(ytmp3,0),1); y256[2] = _mm256_insertf128_si256(ytmp1,_mm256_extracti128_si256(ytmp0,1),0); y256[3] = _mm256_insertf128_si256(ytmp3,_mm256_extracti128_si256(ytmp2,1),0); + // [y0 y1 y2 y3 y4 y5 y6 y7] // [y8 y9 y10 y11 y12 y13 y14 y15] // [y16 y17 y18 y19 y20 y21 y22 y23] // [y24 y25 y26 y27 y28 y29 y30 y31] } -#endif +#endif #endif static inline void idft16(int16_t *x,int16_t *y) __attribute__((always_inline)); -static inline void idft16(int16_t *x,int16_t *y) { +static inline void idft16(int16_t *x,int16_t *y) +{ + #if defined(__x86_64__) || defined(__i386__) __m128i *tw16a_128=(__m128i *)tw16,*tw16b_128=(__m128i *)tw16c,*x128=(__m128i *)x,*y128=(__m128i *)y; + /* bfly4_tw1(x128,x128+1,x128+2,x128+3, y128,y128+1,y128+2,y128+3); @@ -1970,21 +2326,25 @@ static inline void idft16(int16_t *x,int16_t *y) { y128,y128+1,y128+2,y128+3, tw16_128,tw16_128+1,tw16_128+2); */ + register __m128i x1_flip,x3_flip,x02t,x13t; register __m128i ytmp0,ytmp1,ytmp2,ytmp3,xtmp0,xtmp1,xtmp2,xtmp3; + // First stage : 4 Radix-4 butterflies without input twiddles + x02t = _mm_adds_epi16(x128[0],x128[2]); x13t = _mm_adds_epi16(x128[1],x128[3]); xtmp0 = _mm_adds_epi16(x02t,x13t); xtmp2 = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(x128[1],conjugatedft.v128); + x1_flip = _mm_sign_epi16(x128[1],*(__m128i*)conjugatedft); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(x128[3],conjugatedft.v128); + x3_flip = _mm_sign_epi16(x128[3],*(__m128i*)conjugatedft); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); x02t = _mm_subs_epi16(x128[0],x128[2]); x13t = _mm_subs_epi16(x1_flip,x3_flip); xtmp3 = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp1 = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + ytmp0 = _mm_unpacklo_epi32(xtmp0,xtmp1); ytmp1 = _mm_unpackhi_epi32(xtmp0,xtmp1); ytmp2 = _mm_unpacklo_epi32(xtmp2,xtmp3); @@ -1993,24 +2353,28 @@ static inline void idft16(int16_t *x,int16_t *y) { xtmp1 = _mm_unpackhi_epi64(ytmp0,ytmp2); xtmp2 = _mm_unpacklo_epi64(ytmp1,ytmp3); xtmp3 = _mm_unpackhi_epi64(ytmp1,ytmp3); + // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2(xtmp1,tw16a_128[0],tw16b_128[0]); xtmp2 = packed_cmult2(xtmp2,tw16a_128[1],tw16b_128[1]); xtmp3 = packed_cmult2(xtmp3,tw16a_128[2],tw16b_128[2]); + x02t = _mm_adds_epi16(xtmp0,xtmp2); x13t = _mm_adds_epi16(xtmp1,xtmp3); y128[0] = _mm_adds_epi16(x02t,x13t); y128[2] = _mm_subs_epi16(x02t,x13t); - x1_flip = _mm_sign_epi16(xtmp1,conjugatedft.v128); + x1_flip = _mm_sign_epi16(xtmp1,*(__m128i*)conjugatedft); x1_flip = _mm_shuffle_epi8(x1_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); - x3_flip = _mm_sign_epi16(xtmp3,conjugatedft.v128); + x3_flip = _mm_sign_epi16(xtmp3,*(__m128i*)conjugatedft); x3_flip = _mm_shuffle_epi8(x3_flip,_mm_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2)); x02t = _mm_subs_epi16(xtmp0,xtmp2); x13t = _mm_subs_epi16(x1_flip,x3_flip); y128[3] = _mm_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f y128[1] = _mm_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + #elif defined(__arm__) int16x8_t *tw16a_128=(int16x8_t *)tw16,*tw16b_128=(int16x8_t *)tw16c,*x128=(int16x8_t *)x,*y128=(int16x8_t *)y; + /* This is the original version before unrolling bfly4_tw1(x128,x128+1,x128+2,x128+3, @@ -2022,47 +2386,56 @@ static inline void idft16(int16_t *x,int16_t *y) { y128,y128+1,y128+2,y128+3, tw16_128,tw16_128+1,tw16_128+2); */ + register int16x8_t x1_flip,x3_flip,x02t,x13t; register int16x8_t xtmp0,xtmp1,xtmp2,xtmp3; register uint32x4x2_t ytmp0,ytmp1; register int16x8_t ytmp0b,ytmp1b,ytmp2b,ytmp3b; + // First stage : 4 Radix-4 butterflies without input twiddles + x02t = vqaddq_s16(x128[0],x128[2]); x13t = vqaddq_s16(x128[1],x128[3]); xtmp0 = vqaddq_s16(x02t,x13t); xtmp2 = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(x128[1],*(int16x8_t *)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(x128[3],*(int16x8_t *)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(x128[1],*(int16x8_t*)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(x128[3],*(int16x8_t*)conjugatedft)); x02t = vqsubq_s16(x128[0],x128[2]); x13t = vqsubq_s16(x1_flip,x3_flip); xtmp3 = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp1 = vqsubq_s16(x02t,x13t); // x0 - x1f - x2 + x3f + ytmp0 = vtrnq_u32((uint32x4_t)(xtmp0),(uint32x4_t)(xtmp1)); - // y0[0] = [x00 x10 x02 x12], y0[1] = [x01 x11 x03 x13] +// y0[0] = [x00 x10 x02 x12], y0[1] = [x01 x11 x03 x13] ytmp1 = vtrnq_u32((uint32x4_t)(xtmp2),(uint32x4_t)(xtmp3)); - // y1[0] = [x20 x30 x22 x32], y1[1] = [x21 x31 x23 x33] +// y1[0] = [x20 x30 x22 x32], y1[1] = [x21 x31 x23 x33] + + ytmp0b = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[0]),vget_low_s16((int16x8_t)ytmp1.val[0])); - // y0 = [x00 x10 x20 x30] +// y0 = [x00 x10 x20 x30] ytmp1b = vcombine_s16(vget_low_s16((int16x8_t)ytmp0.val[1]),vget_low_s16((int16x8_t)ytmp1.val[1])); - // t1 = [x01 x11 x21 x31] +// t1 = [x01 x11 x21 x31] ytmp2b = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[0]),vget_high_s16((int16x8_t)ytmp1.val[0])); - // t2 = [x02 x12 x22 x32] +// t2 = [x02 x12 x22 x32] ytmp3b = vcombine_s16(vget_high_s16((int16x8_t)ytmp0.val[1]),vget_high_s16((int16x8_t)ytmp1.val[1])); - // t3 = [x03 x13 x23 x33] +// t3 = [x03 x13 x23 x33] + // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2(ytmp1b,tw16a_128[0],tw16b_128[0]); xtmp2 = packed_cmult2(ytmp2b,tw16a_128[1],tw16b_128[1]); xtmp3 = packed_cmult2(ytmp3b,tw16a_128[2],tw16b_128[2]); + x02t = vqaddq_s16(ytmp0b,xtmp2); x13t = vqaddq_s16(xtmp1,xtmp3); y128[0] = vqaddq_s16(x02t,x13t); y128[2] = vqsubq_s16(x02t,x13t); - x1_flip = vrev32q_s16(vmulq_s16(xtmp1,*(int16x8_t *)conjugatedft)); - x3_flip = vrev32q_s16(vmulq_s16(xtmp3,*(int16x8_t *)conjugatedft)); + x1_flip = vrev32q_s16(vmulq_s16(xtmp1,*(int16x8_t*)conjugatedft)); + x3_flip = vrev32q_s16(vmulq_s16(xtmp3,*(int16x8_t*)conjugatedft)); x02t = vqsubq_s16(ytmp0b,xtmp2); x13t = vqsubq_s16(x1_flip,x3_flip); y128[3] = vqaddq_s16(x02t,x13t); // x0 + x1f - x2 - x3f y128[1] = vqsubq_s16(x02t,x13t); // x0 - x1f - x2 + x3f + #endif } @@ -2072,26 +2445,32 @@ void idft16f(int16_t *x,int16_t *y) { #if defined(__x86_64__) || defined(__i386__) #ifdef __AVX2__ -// Does two 16-point IDFTS (x[0 .. 15] is 128 LSBs of input vector, x[16..31] is in 128 MSBs) +// Does two 16-point IDFTS (x[0 .. 15] is 128 LSBs of input vector, x[16..31] is in 128 MSBs) static inline void idft16_simd256(int16_t *x,int16_t *y) __attribute__((always_inline)); -static inline void idft16_simd256(int16_t *x,int16_t *y) { +static inline void idft16_simd256(int16_t *x,int16_t *y) +{ + __m256i *tw16a_256=(__m256i *)tw16rep,*tw16b_256=(__m256i *)tw16crep,*x256=(__m256i *)x,*y256=(__m256i *)y; register __m256i x1_flip,x3_flip,x02t,x13t; register __m256i ytmp0,ytmp1,ytmp2,ytmp3,xtmp0,xtmp1,xtmp2,xtmp3; + register __m256i complex_shuffle = _mm256_set_epi8(29,28,31,30,25,24,27,26,21,20,23,22,17,16,19,18,13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2); + // First stage : 4 Radix-4 butterflies without input twiddles + x02t = _mm256_adds_epi16(x256[0],x256[2]); x13t = _mm256_adds_epi16(x256[1],x256[3]); xtmp0 = _mm256_adds_epi16(x02t,x13t); xtmp2 = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(x256[1],conjugatedft.v256); - x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); - x3_flip = _mm256_sign_epi16(x256[3],conjugatedft.v256); - x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); + x1_flip = _mm256_sign_epi16(x256[1],*(__m256i*)conjugatedft); + x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); + x3_flip = _mm256_sign_epi16(x256[3],*(__m256i*)conjugatedft); + x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm256_subs_epi16(x256[0],x256[2]); x13t = _mm256_subs_epi16(x1_flip,x3_flip); xtmp3 = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f xtmp1 = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f - ytmp0 = _mm256_unpacklo_epi32(xtmp0,xtmp1); + + ytmp0 = _mm256_unpacklo_epi32(xtmp0,xtmp1); ytmp1 = _mm256_unpackhi_epi32(xtmp0,xtmp1); ytmp2 = _mm256_unpacklo_epi32(xtmp2,xtmp3); ytmp3 = _mm256_unpackhi_epi32(xtmp2,xtmp3); @@ -2099,126 +2478,138 @@ static inline void idft16_simd256(int16_t *x,int16_t *y) { xtmp1 = _mm256_unpackhi_epi64(ytmp0,ytmp2); xtmp2 = _mm256_unpacklo_epi64(ytmp1,ytmp3); xtmp3 = _mm256_unpackhi_epi64(ytmp1,ytmp3); + // Second stage : 4 Radix-4 butterflies with input twiddles xtmp1 = packed_cmult2_256(xtmp1,tw16a_256[0],tw16b_256[0]); xtmp2 = packed_cmult2_256(xtmp2,tw16a_256[1],tw16b_256[1]); xtmp3 = packed_cmult2_256(xtmp3,tw16a_256[2],tw16b_256[2]); + x02t = _mm256_adds_epi16(xtmp0,xtmp2); x13t = _mm256_adds_epi16(xtmp1,xtmp3); ytmp0 = _mm256_adds_epi16(x02t,x13t); ytmp2 = _mm256_subs_epi16(x02t,x13t); - x1_flip = _mm256_sign_epi16(xtmp1,conjugatedft.v256); - x1_flip = _mm256_shuffle_epi8(x1_flip,perm_mask.v256); - x3_flip = _mm256_sign_epi16(xtmp3,conjugatedft.v256); - x3_flip = _mm256_shuffle_epi8(x3_flip,perm_mask.v256); + x1_flip = _mm256_sign_epi16(xtmp1,*(__m256i*)conjugatedft); + x1_flip = _mm256_shuffle_epi8(x1_flip,complex_shuffle); + x3_flip = _mm256_sign_epi16(xtmp3,*(__m256i*)conjugatedft); + x3_flip = _mm256_shuffle_epi8(x3_flip,complex_shuffle); x02t = _mm256_subs_epi16(xtmp0,xtmp2); x13t = _mm256_subs_epi16(x1_flip,x3_flip); ytmp3 = _mm256_adds_epi16(x02t,x13t); // x0 + x1f - x2 - x3f ytmp1 = _mm256_subs_epi16(x02t,x13t); // x0 - x1f - x2 + x3f + // [y0 y1 y2 y3 y16 y17 y18 y19] // [y4 y5 y6 y7 y20 y21 y22 y23] // [y8 y9 y10 y11 y24 y25 y26 y27] // [y12 y13 y14 y15 y28 y29 y30 y31] + y256[0] = _mm256_insertf128_si256(ytmp0,_mm256_extracti128_si256(ytmp1,0),1); y256[1] = _mm256_insertf128_si256(ytmp2,_mm256_extracti128_si256(ytmp3,0),1); y256[2] = _mm256_insertf128_si256(ytmp1,_mm256_extracti128_si256(ytmp0,1),0); y256[3] = _mm256_insertf128_si256(ytmp3,_mm256_extracti128_si256(ytmp2,1),0); + } -#endif +#endif #endif // 64-point optimized DFT -const static int16_t tw64[96] __attribute__((aligned(32))) = { - 32767,0,32609,-3212,32137,-6393,31356,-9512, - 30272,-12540,28897,-15447,27244,-18205,25329,-20788, - 23169,-23170,20787,-25330,18204,-27245,15446,-28898, - 12539,-30273,9511,-31357,6392,-32138,3211,-32610, - 32767,0,32137,-6393,30272,-12540,27244,-18205, - 23169,-23170,18204,-27245,12539,-30273,6392,-32138, - 0,-32767,-6393,-32138,-12540,-30273,-18205,-27245, - -23170,-23170,-27245,-18205,-30273,-12540,-32138,-6393, - 32767,0,31356,-9512,27244,-18205,20787,-25330, - 12539,-30273,3211,-32610,-6393,-32138,-15447,-28898, - -23170,-23170,-28898,-15447,-32138,-6393,-32610,3211, - -30273,12539,-25330,20787,-18205,27244,-9512,31356 -}; -const static int16_t tw64a[96] __attribute__((aligned(32))) = { - 32767,0,32609,3212,32137,6393,31356,9512, - 30272,12540,28897,15447,27244,18205,25329,20788, - 23169,23170,20787,25330,18204,27245,15446,28898, - 12539,30273,9511,31357,6392,32138,3211,32610, - 32767,0,32137,6393,30272,12540,27244,18205, - 23169,23170,18204,27245,12539,30273,6392,32138, - 0,32767,-6393,32138,-12540,30273,-18205,27245, - -23170,23170,-27245,18205,-30273,12540,-32138,6393, - 32767,0,31356,9512,27244,18205,20787,25330, - 12539,30273,3211,32610,-6393,32138,-15447,28898, - -23170,23170,-28898,15447,-32138,6393,-32610,-3211, - -30273,-12539,-25330,-20787,-18205,-27244,-9512,-31356 -}; -const static int16_t tw64b[96] __attribute__((aligned(32))) = { - 0,32767,-3212,32609,-6393,32137,-9512,31356, - -12540,30272,-15447,28897,-18205,27244,-20788,25329, - -23170,23169,-25330,20787,-27245,18204,-28898,15446, - -30273,12539,-31357,9511,-32138,6392,-32610,3211, - 0,32767,-6393,32137,-12540,30272,-18205,27244, - -23170,23169,-27245,18204,-30273,12539,-32138,6392, - -32767,0,-32138,-6393,-30273,-12540,-27245,-18205, - -23170,-23170,-18205,-27245,-12540,-30273,-6393,-32138, - 0,32767,-9512,31356,-18205,27244,-25330,20787, - -30273,12539,-32610,3211,-32138,-6393,-28898,-15447, - -23170,-23170,-15447,-28898,-6393,-32138,3211,-32610, - 12539,-30273,20787,-25330,27244,-18205,31356,-9512 -}; -const static int16_t tw64c[96] __attribute__((aligned(32))) = { - 0,32767,3212,32609,6393,32137,9512,31356, - 12540,30272,15447,28897,18205,27244,20788,25329, - 23170,23169,25330,20787,27245,18204,28898,15446, - 30273,12539,31357,9511,32138,6392,32610,3211, - 0,32767,6393,32137,12540,30272,18205,27244, - 23170,23169,27245,18204,30273,12539,32138,6392, - 32767,0,32138,-6393,30273,-12540,27245,-18205, - 23170,-23170,18205,-27245,12540,-30273,6393,-32138, - 0,32767,9512,31356,18205,27244,25330,20787, - 30273,12539,32610,3211,32138,-6393,28898,-15447, - 23170,-23170,15447,-28898,6393,-32138,-3211,-32610, - -12539,-30273,-20787,-25330,-27244,-18205,-31356,-9512 -}; +const static int16_t tw64[96] __attribute__((aligned(32))) = { +32767,0,32609,-3212,32137,-6393,31356,-9512, +30272,-12540,28897,-15447,27244,-18205,25329,-20788, +23169,-23170,20787,-25330,18204,-27245,15446,-28898, +12539,-30273,9511,-31357,6392,-32138,3211,-32610, +32767,0,32137,-6393,30272,-12540,27244,-18205, +23169,-23170,18204,-27245,12539,-30273,6392,-32138, +0,-32767,-6393,-32138,-12540,-30273,-18205,-27245, +-23170,-23170,-27245,-18205,-30273,-12540,-32138,-6393, +32767,0,31356,-9512,27244,-18205,20787,-25330, +12539,-30273,3211,-32610,-6393,-32138,-15447,-28898, +-23170,-23170,-28898,-15447,-32138,-6393,-32610,3211, +-30273,12539,-25330,20787,-18205,27244,-9512,31356 + }; +const static int16_t tw64a[96] __attribute__((aligned(32))) = { +32767,0,32609,3212,32137,6393,31356,9512, +30272,12540,28897,15447,27244,18205,25329,20788, +23169,23170,20787,25330,18204,27245,15446,28898, +12539,30273,9511,31357,6392,32138,3211,32610, +32767,0,32137,6393,30272,12540,27244,18205, +23169,23170,18204,27245,12539,30273,6392,32138, +0,32767,-6393,32138,-12540,30273,-18205,27245, +-23170,23170,-27245,18205,-30273,12540,-32138,6393, +32767,0,31356,9512,27244,18205,20787,25330, +12539,30273,3211,32610,-6393,32138,-15447,28898, +-23170,23170,-28898,15447,-32138,6393,-32610,-3211, +-30273,-12539,-25330,-20787,-18205,-27244,-9512,-31356 + }; +const static int16_t tw64b[96] __attribute__((aligned(32))) = { +0,32767,-3212,32609,-6393,32137,-9512,31356, +-12540,30272,-15447,28897,-18205,27244,-20788,25329, +-23170,23169,-25330,20787,-27245,18204,-28898,15446, +-30273,12539,-31357,9511,-32138,6392,-32610,3211, +0,32767,-6393,32137,-12540,30272,-18205,27244, +-23170,23169,-27245,18204,-30273,12539,-32138,6392, +-32767,0,-32138,-6393,-30273,-12540,-27245,-18205, +-23170,-23170,-18205,-27245,-12540,-30273,-6393,-32138, +0,32767,-9512,31356,-18205,27244,-25330,20787, +-30273,12539,-32610,3211,-32138,-6393,-28898,-15447, +-23170,-23170,-15447,-28898,-6393,-32138,3211,-32610, +12539,-30273,20787,-25330,27244,-18205,31356,-9512 + }; +const static int16_t tw64c[96] __attribute__((aligned(32))) = { +0,32767,3212,32609,6393,32137,9512,31356, +12540,30272,15447,28897,18205,27244,20788,25329, +23170,23169,25330,20787,27245,18204,28898,15446, +30273,12539,31357,9511,32138,6392,32610,3211, +0,32767,6393,32137,12540,30272,18205,27244, +23170,23169,27245,18204,30273,12539,32138,6392, +32767,0,32138,-6393,30273,-12540,27245,-18205, +23170,-23170,18205,-27245,12540,-30273,6393,-32138, +0,32767,9512,31356,18205,27244,25330,20787, +30273,12539,32610,3211,32138,-6393,28898,-15447, +23170,-23170,15447,-28898,6393,-32138,-3211,-32610, +-12539,-30273,-20787,-25330,-27244,-18205,-31356,-9512 + }; #if defined(__x86_64__) || defined(__i386__) - #define simd_q15_t __m128i - #define simdshort_q15_t __m64 - #define shiftright_int16(a,shift) _mm_srai_epi16(a,shift) - #define set1_int16(a) _mm_set1_epi16(a); - #define mulhi_int16(a,b) _mm_mulhrs_epi16 (a,b) - #ifdef __AVX2__ - #define simd256_q15_t __m256i - #define shiftright_int16_simd256(a,shift) _mm256_srai_epi16(a,shift) - #define set1_int16_simd256(a) _mm256_set1_epi16(a); - #define mulhi_int16_simd256(a,b) _mm256_mulhrs_epi16(a,b); //_mm256_slli_epi16(_mm256_mulhi_epi16(a,b),1); - #endif +#define simd_q15_t __m128i +#define simdshort_q15_t __m64 +#define shiftright_int16(a,shift) _mm_srai_epi16(a,shift) +#define set1_int16(a) _mm_set1_epi16(a); +#define mulhi_int16(a,b) _mm_mulhrs_epi16 (a,b) +#ifdef __AVX2__ +#define simd256_q15_t __m256i +#define shiftright_int16_simd256(a,shift) _mm256_srai_epi16(a,shift) +#define set1_int16_simd256(a) _mm256_set1_epi16(a); +#define mulhi_int16_simd256(a,b) _mm256_mulhrs_epi16(a,b); //_mm256_slli_epi16(_mm256_mulhi_epi16(a,b),1); +#endif #elif defined(__arm__) - #define simd_q15_t int16x8_t - #define simdshort_q15_t int16x4_t - #define shiftright_int16(a,shift) vshrq_n_s16(a,shift) - #define set1_int16(a) vdupq_n_s16(a) - #define mulhi_int16(a,b) vqdmulhq_s16(a,b); - #define _mm_empty() - #define _m_empty() +#define simd_q15_t int16x8_t +#define simdshort_q15_t int16x4_t +#define shiftright_int16(a,shift) vshrq_n_s16(a,shift) +#define set1_int16(a) vdupq_n_s16(a) +#define mulhi_int16(a,b) vqdmulhq_s16(a,b); +#define _mm_empty() +#define _m_empty() #endif #ifndef __AVX2__ -void dft64(int16_t *x,int16_t *y,unsigned char scale) { +void dft64(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t xtmp[16],ytmp[16],*tw64a_128=(simd_q15_t *)tw64a,*tw64b_128=(simd_q15_t *)tw64b,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y; + + #ifdef D64STATS time_stats_t ts_t,ts_d,ts_b; + reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); start_meas(&ts_t); #endif + + transpose16_ooff(x128,xtmp,4); // xtmp0 = x00 x10 x20 x30 // xtmp4 = x01 x11 x21 x31 @@ -2239,47 +2630,59 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) { // xtmp7 = xc1 xd1 xe1 xf1 // xtmp11 = xc2 xd2 xe2 xf2 // xtmp15 = xc3 xd3 xe3 xf3 + #ifdef D64STATS stop_meas(&ts_t); start_meas(&ts_d); #endif + // xtmp0 = x00 x10 x20 x30 // xtmp1 = x40 x50 x60 x70 // xtmp2 = x80 x90 xa0 xb0 // xtmp3 = xc0 xd0 xe0 xf0 - dft16((int16_t *)(xtmp),(int16_t *)ytmp); + dft16((int16_t*)(xtmp),(int16_t*)ytmp); + // xtmp4 = x01 x11 x21 x31 // xtmp5 = x41 x51 x61 x71 // xtmp6 = x81 x91 xa1 xb1 // xtmp7 = xc1 xd1 xe1 xf1 - dft16((int16_t *)(xtmp+4),(int16_t *)(ytmp+4)); - dft16((int16_t *)(xtmp+8),(int16_t *)(ytmp+8)); - dft16((int16_t *)(xtmp+12),(int16_t *)(ytmp+12)); + dft16((int16_t*)(xtmp+4),(int16_t*)(ytmp+4)); + dft16((int16_t*)(xtmp+8),(int16_t*)(ytmp+8)); + dft16((int16_t*)(xtmp+12),(int16_t*)(ytmp+12)); + + #ifdef D64STATS stop_meas(&ts_d); start_meas(&ts_b); #endif + + bfly4_16(ytmp,ytmp+4,ytmp+8,ytmp+12, y128,y128+4,y128+8,y128+12, tw64a_128,tw64a_128+4,tw64a_128+8, tw64b_128,tw64b_128+4,tw64b_128+8); + bfly4_16(ytmp+1,ytmp+5,ytmp+9,ytmp+13, y128+1,y128+5,y128+9,y128+13, tw64a_128+1,tw64a_128+5,tw64a_128+9, tw64b_128+1,tw64b_128+5,tw64b_128+9); + bfly4_16(ytmp+2,ytmp+6,ytmp+10,ytmp+14, y128+2,y128+6,y128+10,y128+14, tw64a_128+2,tw64a_128+6,tw64a_128+10, tw64b_128+2,tw64b_128+6,tw64b_128+10); + bfly4_16(ytmp+3,ytmp+7,ytmp+11,ytmp+15, y128+3,y128+7,y128+11,y128+15, tw64a_128+3,tw64a_128+7,tw64a_128+11, tw64b_128+3,tw64b_128+7,tw64b_128+11); + #ifdef D64STATS stop_meas(&ts_b); printf("t: %llu cycles, d: %llu cycles, b: %llu cycles\n",ts_t.diff,ts_d.diff,ts_b.diff); #endif + if (scale>0) { y128[0] = shiftright_int16(y128[0],3); y128[1] = shiftright_int16(y128[1],3); @@ -2301,25 +2704,32 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } #else // __AVX2__ -void dft64(int16_t *x,int16_t *y,unsigned char scale) { +void dft64(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[16],ytmp[16],*tw64a_256=(simd256_q15_t *)tw64a,*tw64b_256=(simd256_q15_t *)tw64b,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y; simd256_q15_t xintl0,xintl1,xintl2,xintl3,xintl4,xintl5,xintl6,xintl7; simd256_q15_t const perm_mask = _mm256_set_epi32(7, 3, 5, 1, 6, 2, 4, 0); + + #ifdef D64STATS time_stats_t ts_t,ts_d,ts_b; + reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); start_meas(&ts_t); #endif + #ifdef D64STATS stop_meas(&ts_t); start_meas(&ts_d); #endif - /* + /* print_shorts256("x2560",(int16_t*)x256); print_shorts256("x2561",(int16_t*)(x256+1)); print_shorts256("x2562",(int16_t*)(x256+2)); @@ -2365,7 +2775,7 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) { print_shorts256("xtmp6",(int16_t*)(xtmp+6)); print_shorts256("xtmp7",(int16_t*)(xtmp+7)); */ - dft16_simd256((int16_t *)(xtmp),(int16_t *)ytmp); + dft16_simd256((int16_t*)(xtmp),(int16_t*)ytmp); // [y0 y1 y2 y3 y4 y5 y6 y7] // [y8 y9 y10 y11 y12 y13 y14 y15] // [y16 y17 y18 y19 y20 y21 y22 y23] @@ -2376,7 +2786,7 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) { print_shorts256("ytmp2",(int16_t*)(ytmp+2)); print_shorts256("ytmp3",(int16_t*)(ytmp+3)); */ - dft16_simd256((int16_t *)(xtmp+4),(int16_t *)(ytmp+4)); + dft16_simd256((int16_t*)(xtmp+4),(int16_t*)(ytmp+4)); // [y32 y33 y34 y35 y36 y37 y38 y39] // [y40 y41 y42 y43 y44 y45 y46 y47] // [y48 y49 y50 y51 y52 y53 y54 y55] @@ -2391,23 +2801,26 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) { stop_meas(&ts_d); start_meas(&ts_b); #endif + + bfly4_16_256(ytmp,ytmp+2,ytmp+4,ytmp+6, - y256,y256+2,y256+4,y256+6, - tw64a_256,tw64a_256+2,tw64a_256+4, - tw64b_256,tw64b_256+2,tw64b_256+4); + y256,y256+2,y256+4,y256+6, + tw64a_256,tw64a_256+2,tw64a_256+4, + tw64b_256,tw64b_256+2,tw64b_256+4); // [y0 y1 y2 y3 y4 y5 y6 y7] // [y16 y17 y18 y19 y20 y21 y22 y23] // [y32 y33 y34 y35 y36 y37 y38 y39] // [y48 y49 y50 y51 y52 y53 y54 y55] + bfly4_16_256(ytmp+1,ytmp+3,ytmp+5,ytmp+7, - y256+1,y256+3,y256+5,y256+7, - tw64a_256+1,tw64a_256+3,tw64a_256+5, - tw64b_256+1,tw64b_256+3,tw64b_256+5); + y256+1,y256+3,y256+5,y256+7, + tw64a_256+1,tw64a_256+3,tw64a_256+5, + tw64b_256+1,tw64b_256+3,tw64b_256+5); // [y8 y9 y10 y11 y12 y13 y14 y15] // [y24 y25 y26 y27 y28 y29 y30 y31] // [y40 y41 y42 y43 y44 y45 y46 y47] // [y56 y57 y58 y59 y60 y61 y62 y63] - /* + /* print_shorts256("y256_0",(int16_t*)&y256[0]); print_shorts256("y256_1",(int16_t*)&y256[1]); print_shorts256("y256_2",(int16_t*)&y256[2]); @@ -2417,11 +2830,13 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) { print_shorts256("y256_6",(int16_t*)&y256[6]); print_shorts256("y256_7",(int16_t*)&y256[7]); */ + #ifdef D64STATS stop_meas(&ts_b); printf("t: %llu cycles, d: %llu cycles, b: %llu cycles\n",ts_t.diff,ts_d.diff,ts_b.diff); #endif + if (scale>0) { y256[0] = shiftright_int16_simd256(y256[0],3); y256[1] = shiftright_int16_simd256(y256[1],3); @@ -2435,35 +2850,52 @@ void dft64(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + + } #endif #ifndef __AVX2__ -void idft64(int16_t *x,int16_t *y,unsigned char scale) { +void idft64(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t xtmp[16],ytmp[16],*tw64a_128=(simd_q15_t *)tw64,*tw64b_128=(simd_q15_t *)tw64c,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y; + + #ifdef D64STATS time_stats_t ts_t,ts_d,ts_b; + reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); start_meas(&ts_t); #endif + + transpose16_ooff(x128,xtmp,4); transpose16_ooff(x128+4,xtmp+1,4); transpose16_ooff(x128+8,xtmp+2,4); transpose16_ooff(x128+12,xtmp+3,4); + + #ifdef D64STATS stop_meas(&ts_t); start_meas(&ts_d); #endif - idft16((int16_t *)(xtmp),(int16_t *)ytmp); - idft16((int16_t *)(xtmp+4),(int16_t *)(ytmp+4)); - idft16((int16_t *)(xtmp+8),(int16_t *)(ytmp+8)); - idft16((int16_t *)(xtmp+12),(int16_t *)(ytmp+12)); + + + idft16((int16_t*)(xtmp),(int16_t*)ytmp); + idft16((int16_t*)(xtmp+4),(int16_t*)(ytmp+4)); + idft16((int16_t*)(xtmp+8),(int16_t*)(ytmp+8)); + idft16((int16_t*)(xtmp+12),(int16_t*)(ytmp+12)); + + #ifdef D64STATS stop_meas(&ts_d); start_meas(&ts_b); #endif + + ibfly4_16(ytmp,ytmp+4,ytmp+8,ytmp+12, y128,y128+4,y128+8,y128+12, tw64a_128,tw64a_128+4,tw64a_128+8, @@ -2472,20 +2904,25 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) { y128+1,y128+5,y128+9,y128+13, tw64a_128+1,tw64a_128+5,tw64a_128+9, tw64b_128+1,tw64b_128+5,tw64b_128+9); + ibfly4_16(ytmp+2,ytmp+6,ytmp+10,ytmp+14, y128+2,y128+6,y128+10,y128+14, tw64a_128+2,tw64a_128+6,tw64a_128+10, tw64b_128+2,tw64b_128+6,tw64b_128+10); + ibfly4_16(ytmp+3,ytmp+7,ytmp+11,ytmp+15, y128+3,y128+7,y128+11,y128+15, tw64a_128+3,tw64a_128+7,tw64a_128+11, tw64b_128+3,tw64b_128+7,tw64b_128+11); + #ifdef D64STATS stop_meas(&ts_b); printf("t: %llu cycles, d: %llu cycles, b: %llu cycles\n",ts_t.diff,ts_d.diff,ts_b.diff); #endif + if (scale>0) { + y128[0] = shiftright_int16(y128[0],3); y128[1] = shiftright_int16(y128[1],3); y128[2] = shiftright_int16(y128[2],3); @@ -2502,28 +2939,37 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],3); y128[14] = shiftright_int16(y128[14],3); y128[15] = shiftright_int16(y128[15],3); + } _mm_empty(); _m_empty(); + } #else // __AVX2__ -void idft64(int16_t *x,int16_t *y,unsigned char scale) { +void idft64(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[16],ytmp[16],*tw64a_256=(simd256_q15_t *)tw64,*tw64b_256=(simd256_q15_t *)tw64c,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y; register simd256_q15_t xintl0,xintl1,xintl2,xintl3,xintl4,xintl5,xintl6,xintl7; simd256_q15_t const perm_mask = _mm256_set_epi32(7, 3, 5, 1, 6, 2, 4, 0); + + #ifdef D64STATS time_stats_t ts_t,ts_d,ts_b; + reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); start_meas(&ts_t); #endif + #ifdef D64STATS stop_meas(&ts_t); start_meas(&ts_d); #endif + xintl0 = _mm256_permutevar8x32_epi32(x256[0],perm_mask); // x0 x4 x1 x5 x2 x6 x3 x7 xintl1 = _mm256_permutevar8x32_epi32(x256[1],perm_mask); // x8 x12 x9 x13 x10 x14 x11 x15 xintl2 = _mm256_permutevar8x32_epi32(x256[2],perm_mask); // x16 x20 x17 x21 x18 x22 x19 x23 @@ -2532,6 +2978,7 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) { xintl5 = _mm256_permutevar8x32_epi32(x256[5],perm_mask); // x24 x28 x25 x29 x26 x30 x27 x31 xintl6 = _mm256_permutevar8x32_epi32(x256[6],perm_mask); // x24 x28 x25 x29 x26 x30 x27 x31 xintl7 = _mm256_permutevar8x32_epi32(x256[7],perm_mask); // x24 x28 x25 x29 x26 x30 x27 x31 + xtmp[0] = _mm256_unpacklo_epi64(xintl0,xintl1); // x0 x4 x8 x12 x1 x5 x9 x13 xtmp[4] = _mm256_unpackhi_epi64(xintl0,xintl1); // x2 x6 x10 x14 x3 x7 x11 x15 xtmp[1] = _mm256_unpacklo_epi64(xintl2,xintl3); // x16 x20 x24 x28 x17 x21 x25 x29 @@ -2540,41 +2987,51 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) { xtmp[6] = _mm256_unpackhi_epi64(xintl4,xintl5); // x34 x38 x42 x46 x35 x39 x43 x47 xtmp[3] = _mm256_unpacklo_epi64(xintl6,xintl7); // x48 x52 x56 x60 x49 x53 x57 x61 xtmp[7] = _mm256_unpackhi_epi64(xintl6,xintl7); // x50 x54 x58 x62 x51 x55 x59 x63 - idft16_simd256((int16_t *)(xtmp),(int16_t *)ytmp); + + + idft16_simd256((int16_t*)(xtmp),(int16_t*)ytmp); // [y0 y1 y2 y3 y16 y17 y18 y19] // [y4 y5 y6 y7 y20 y21 y22 y23] // [y8 y9 y10 y11 y24 y25 y26 y27] // [y12 y13 y14 y15 y28 y29 y30 y31] - idft16_simd256((int16_t *)(xtmp+4),(int16_t *)(ytmp+4)); + + idft16_simd256((int16_t*)(xtmp+4),(int16_t*)(ytmp+4)); // [y32 y33 y34 y35 y48 y49 y50 y51] // [y36 y37 y38 y39 y52 y53 y54 y55] // [y40 y41 y42 y43 y56 y57 y58 y59] // [y44 y45 y46 y47 y60 y61 y62 y63] + #ifdef D64STATS stop_meas(&ts_d); start_meas(&ts_b); #endif + + ibfly4_16_256(ytmp,ytmp+2,ytmp+4,ytmp+6, - y256,y256+2,y256+4,y256+6, - tw64a_256,tw64a_256+2,tw64a_256+4, - tw64b_256,tw64b_256+2,tw64b_256+4); + y256,y256+2,y256+4,y256+6, + tw64a_256,tw64a_256+2,tw64a_256+4, + tw64b_256,tw64b_256+2,tw64b_256+4); // [y0 y1 y2 y3 y4 y5 y6 y7] // [y16 y17 y18 y19 y20 y21 y22 y23] // [y32 y33 y34 y35 y36 y37 y38 y39] // [y48 y49 y50 y51 y52 y53 y54 y55] + ibfly4_16_256(ytmp+1,ytmp+3,ytmp+5,ytmp+7, - y256+1,y256+3,y256+5,y256+7, - tw64a_256+1,tw64a_256+3,tw64a_256+5, - tw64b_256+1,tw64b_256+3,tw64b_256+5); + y256+1,y256+3,y256+5,y256+7, + tw64a_256+1,tw64a_256+3,tw64a_256+5, + tw64b_256+1,tw64b_256+3,tw64b_256+5); // [y8 y9 y10 y11 y12 y13 y14 y15] // [y24 y25 y26 y27 y28 y29 y30 y31] // [y40 y41 y42 y43 y44 y45 y46 y47] // [y56 y57 y58 y59 y60 y61 y62 y63] + + #ifdef D64STATS stop_meas(&ts_b); printf("t: %llu cycles, d: %llu cycles, b: %llu cycles\n",ts_t.diff,ts_d.diff,ts_b.diff); #endif + if (scale>0) { y256[0] = shiftright_int16_simd256(y256[0],3); y256[1] = shiftright_int16_simd256(y256[1],3); @@ -2588,6 +3045,7 @@ void idft64(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } #endif @@ -2600,13 +3058,17 @@ int16_t tw128b[128] __attribute__((aligned(32))) = {0,32767,-1608,32727,-3212,32 int16_t tw128c[128] __attribute__((aligned(32))) = {0,32767,1608,32727,3212,32609,4808,32412,6393,32137,7962,31785,9512,31356,11039,30851,12540,30272,14010,29621,15447,28897,16846,28105,18205,27244,19520,26318,20788,25329,22005,24278,23170,23169,24279,22004,25330,20787,26319,19519,27245,18204,28106,16845,28898,15446,29622,14009,30273,12539,30852,11038,31357,9511,31786,7961,32138,6392,32413,4807,32610,3211,32728,1607,32767,0,32728,-1608,32610,-3212,32413,-4808,32138,-6393,31786,-7962,31357,-9512,30852,-11039,30273,-12540,29622,-14010,28898,-15447,28106,-16846,27245,-18205,26319,-19520,25330,-20788,24279,-22005,23170,-23170,22005,-24279,20788,-25330,19520,-26319,18205,-27245,16846,-28106,15447,-28898,14010,-29622,12540,-30273,11039,-30852,9512,-31357,7962,-31786,6393,-32138,4808,-32413,3212,-32610,1608,-32728}; #ifndef __AVX2__ -void dft128(int16_t *x,int16_t *y,unsigned char scale) { +void dft128(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[64],*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[32],*tw128a_128p=(simd_q15_t *)tw128a,*tw128b_128p=(simd_q15_t *)tw128b,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - transpose4_ooff(x64,xtmp,32); + + + transpose4_ooff(x64 ,xtmp,32); transpose4_ooff(x64+2,xtmp+1,32); transpose4_ooff(x64+4,xtmp+2,32); transpose4_ooff(x64+6,xtmp+3,32); @@ -2638,14 +3100,13 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) { transpose4_ooff(x64+58,xtmp+29,32); transpose4_ooff(x64+60,xtmp+30,32); transpose4_ooff(x64+62,xtmp+31,32); - dft64((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft64((int16_t *)(xtmp+32),(int16_t *)(ytmp+16),1); + dft64((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft64((int16_t*)(xtmp+32),(int16_t*)(ytmp+16),1); if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("dft128a.m","dfta",ytmp,64,1,1); LOG_M("dft128b.m","dftb",ytmp+16,64,1,1); } - for (i=0; i<16; i++) { bfly2_16(ytmpp,ytmpp+16, y128p,y128p+16, @@ -2658,6 +3119,7 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + y128[0] = mulhi_int16(y128[0],ONE_OVER_SQRT2_Q15_128); y128[1] = mulhi_int16(y128[1],ONE_OVER_SQRT2_Q15_128); y128[2] = mulhi_int16(y128[2],ONE_OVER_SQRT2_Q15_128); @@ -2690,26 +3152,30 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) { y128[29] = mulhi_int16(y128[29],ONE_OVER_SQRT2_Q15_128); y128[30] = mulhi_int16(y128[30],ONE_OVER_SQRT2_Q15_128); y128[31] = mulhi_int16(y128[31],ONE_OVER_SQRT2_Q15_128); - } + + } if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("dft128out.m","dft128",y,128,1,1); - exit(-1); + LOG_M("dft128out.m","dft128",y,128,1,1); + exit(-1); } - _mm_empty(); _m_empty(); + } #else // __AVX2__ -void dft128(int16_t *x,int16_t *y,unsigned char scale) { +void dft128(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[16],*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[16],*y256=(simd256_q15_t *)y; + simd256_q15_t ytmp[16],*y256=(simd256_q15_t*)y; simd256_q15_t *tw128a_256p=(simd256_q15_t *)tw128a,*tw128b_256p=(simd256_q15_t *)tw128b,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - transpose4_ooff_simd256(x256,xtmp,8); + + transpose4_ooff_simd256(x256 ,xtmp,8); transpose4_ooff_simd256(x256+2,xtmp+1,8); transpose4_ooff_simd256(x256+4,xtmp+2,8); transpose4_ooff_simd256(x256+6,xtmp+3,8); @@ -2717,25 +3183,23 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) { transpose4_ooff_simd256(x256+10,xtmp+5,8); transpose4_ooff_simd256(x256+12,xtmp+6,8); transpose4_ooff_simd256(x256+14,xtmp+7,8); - - if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("dft128ina_256.m","dftina",xtmp,64,1,1); - LOG_M("dft128inb_256.m","dftinb",xtmp+8,64,1,1); + if (LOG_DUMPFLAG(DEBUG_DFT)) { + LOG_M("dft128ina_256.m","dftina",xtmp,64,1,1); + LOG_M("dft128inb_256.m","dftinb",xtmp+8,64,1,1); } - dft64((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft64((int16_t *)(xtmp+8),(int16_t *)(ytmp+8),1); - - if (LOG_DUMPFLAG(DEBUG_DFT)) { + dft64((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft64((int16_t*)(xtmp+8),(int16_t*)(ytmp+8),1); + if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("dft128outa_256.m","dftouta",ytmp,64,1,1); LOG_M("dft128outb_256.m","dftoutb",ytmp+8,64,1,1); } for (i=0; i<8; i++) { bfly2_16_256(ytmpp,ytmpp+8, - y256p,y256p+8, - tw128a_256p, - tw128b_256p); + y256p,y256p+8, + tw128a_256p, + tw128b_256p); tw128a_256p++; tw128b_256p++; y256p++; @@ -2743,6 +3207,7 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); @@ -2759,24 +3224,28 @@ void dft128(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = mulhi_int16_simd256(y256[13],ONE_OVER_SQRT2_Q15_256); y256[14] = mulhi_int16_simd256(y256[14],ONE_OVER_SQRT2_Q15_256); y256[15] = mulhi_int16_simd256(y256[15],ONE_OVER_SQRT2_Q15_256); - } - if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("dft128.m","dft",y256,128,1,1); - exit(-1); + } + if (LOG_DUMPFLAG(DEBUG_DFT)) { + LOG_M("dft128.m","dft",y256,128,1,1); + exit(-1); } } #endif #ifndef __AVX2__ -void idft128(int16_t *x,int16_t *y,unsigned char scale) { +void idft128(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[64],*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[32],*tw128_128p=(simd_q15_t *)tw128,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); - transpose4_ooff(x64,xtmp,32); + + + transpose4_ooff(x64 ,xtmp,32); transpose4_ooff(x64+2,xtmp+1,32); transpose4_ooff(x64+4,xtmp+2,32); transpose4_ooff(x64+6,xtmp+3,32); @@ -2808,8 +3277,10 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) { transpose4_ooff(x64+58,xtmp+29,32); transpose4_ooff(x64+60,xtmp+30,32); transpose4_ooff(x64+62,xtmp+31,32); - idft64((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft64((int16_t *)(xtmp+32),(int16_t *)(ytmp+16),1); + + idft64((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft64((int16_t*)(xtmp+32),(int16_t*)(ytmp+16),1); + for (i=0; i<16; i++) { ibfly2(ytmpp,ytmpp+16, @@ -2821,6 +3292,7 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + y128[0] = mulhi_int16(y128[0],ONE_OVER_SQRT2_Q15_128); y128[1] = mulhi_int16(y128[1],ONE_OVER_SQRT2_Q15_128); y128[2] = mulhi_int16(y128[2],ONE_OVER_SQRT2_Q15_128); @@ -2853,21 +3325,27 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) { y128[29] = mulhi_int16(y128[29],ONE_OVER_SQRT2_Q15_128); y128[30] = mulhi_int16(y128[30],ONE_OVER_SQRT2_Q15_128); y128[31] = mulhi_int16(y128[31],ONE_OVER_SQRT2_Q15_128); + } _mm_empty(); _m_empty(); + } #else // __AVX2__ -void idft128(int16_t *x,int16_t *y,unsigned char scale) { +void idft128(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[16],*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[16],*y256=(simd256_q15_t *)y; + simd256_q15_t ytmp[16],*y256=(simd256_q15_t*)y; simd256_q15_t *tw128_256p=(simd256_q15_t *)tw128,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - transpose4_ooff_simd256(x256,xtmp,8); + + + transpose4_ooff_simd256(x256 ,xtmp,8); transpose4_ooff_simd256(x256+2,xtmp+1,8); transpose4_ooff_simd256(x256+4,xtmp+2,8); transpose4_ooff_simd256(x256+6,xtmp+3,8); @@ -2875,19 +3353,22 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) { transpose4_ooff_simd256(x256+10,xtmp+5,8); transpose4_ooff_simd256(x256+12,xtmp+6,8); transpose4_ooff_simd256(x256+14,xtmp+7,8); - idft64((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft64((int16_t *)(xtmp+8),(int16_t *)(ytmp+8),1); + + idft64((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft64((int16_t*)(xtmp+8),(int16_t*)(ytmp+8),1); + for (i=0; i<8; i++) { ibfly2_256(ytmpp,ytmpp+8, - y256p,y256p+8, - tw128_256p); + y256p,y256p+8, + tw128_256p); tw128_256p++; y256p++; ytmpp++; } if (scale>0) { + y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); @@ -2904,7 +3385,9 @@ void idft128(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = mulhi_int16_simd256(y256[13],ONE_OVER_SQRT2_Q15_256); y256[14] = mulhi_int16_simd256(y256[14],ONE_OVER_SQRT2_Q15_256); y256[15] = mulhi_int16_simd256(y256[15],ONE_OVER_SQRT2_Q15_256); + } + } #endif @@ -2924,12 +3407,16 @@ int16_t tw256b[384] __attribute__((aligned(32))) = {0,32767,-805,32757,-1608,327 0,32767,-2411,32678,-4808,32412,-7180,31970,-9512,31356,-11793,30571,-14010,29621,-16151,28510,-18205,27244,-20160,25831,-22005,24278,-23732,22594,-25330,20787,-26790,18867,-28106,16845,-29269,14732,-30273,12539,-31114,10278,-31786,7961,-32285,5601,-32610,3211,-32758,804,-32728,-1608,-32521,-4012,-32138,-6393,-31581,-8740,-30852,-11039,-29956,-13279,-28898,-15447,-27684,-17531,-26319,-19520,-24812,-21403,-23170,-23170,-21403,-24812,-19520,-26319,-17531,-27684,-15447,-28898,-13279,-29956,-11039,-30852,-8740,-31581,-6393,-32138,-4012,-32521,-1608,-32728,804,-32758,3211,-32610,5601,-32285,7961,-31786,10278,-31114,12539,-30273,14732,-29269,16845,-28106,18867,-26790,20787,-25330,22594,-23732,24278,-22005,25831,-20160,27244,-18205,28510,-16151,29621,-14010,30571,-11793,31356,-9512,31970,-7180,32412,-4808,32678,-2411 }; #ifndef __AVX2__ -void dft256(int16_t *x,int16_t *y,unsigned char scale) { +void dft256(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t xtmp[64],ytmp[64],*tw256a_128p=(simd_q15_t *)tw256a,*tw256b_128p=(simd_q15_t *)tw256b,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; + #ifdef D256STATS time_stats_t ts_t,ts_d,ts_b; + reset_meas(&ts_t); reset_meas(&ts_d); reset_meas(&ts_b); @@ -2956,14 +3443,17 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff(x128+52,xtmp+13,16); transpose16_ooff(x128+56,xtmp+14,16); transpose16_ooff(x128+60,xtmp+15,16); + #ifdef D256STATS stop_meas(&ts_t); start_meas(&ts_d); #endif - dft64((int16_t *)(xtmp),(int16_t *)(ytmp),1); - dft64((int16_t *)(xtmp+16),(int16_t *)(ytmp+16),1); - dft64((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); - dft64((int16_t *)(xtmp+48),(int16_t *)(ytmp+48),1); + + dft64((int16_t*)(xtmp),(int16_t*)(ytmp),1); + dft64((int16_t*)(xtmp+16),(int16_t*)(ytmp+16),1); + dft64((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); + dft64((int16_t*)(xtmp+48),(int16_t*)(ytmp+48),1); + #ifdef D256STATS stop_meas(&ts_d); start_meas(&ts_b); @@ -2998,6 +3488,7 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) { #endif if (scale>0) { + for (i=0; i<4; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -3015,17 +3506,22 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); + y128+=16; } + } _mm_empty(); _m_empty(); + } -void idft256(int16_t *x,int16_t *y,unsigned char scale) { +void idft256(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t xtmp[64],ytmp[64],*tw256_128p=(simd_q15_t *)tw256,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -3034,10 +3530,11 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff(x128+i,xtmp+j,16); } - idft64((int16_t *)(xtmp),(int16_t *)(ytmp),1); - idft64((int16_t *)(xtmp+16),(int16_t *)(ytmp+16),1); - idft64((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); - idft64((int16_t *)(xtmp+48),(int16_t *)(ytmp+48),1); + + idft64((int16_t*)(xtmp),(int16_t*)(ytmp),1); + idft64((int16_t*)(xtmp+16),(int16_t*)(ytmp+16),1); + idft64((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); + idft64((int16_t*)(xtmp+48),(int16_t*)(ytmp+48),1); for (i=0; i<16; i++) { ibfly4(ytmpp,ytmpp+16,ytmpp+32,ytmpp+48, @@ -3049,6 +3546,7 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + for (i=0; i<4; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -3066,20 +3564,26 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); + y128+=16; } + } _mm_empty(); _m_empty(); + } #else //__AVX2__ -void dft256(int16_t *x,int16_t *y,unsigned char scale) { +void dft256(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[32],ytmp[32],*tw256a_256p=(simd256_q15_t *)tw256a,*tw256b_256p=(simd256_q15_t *)tw256b,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; + transpose16_ooff_simd256(x256+0,xtmp+0,8); transpose16_ooff_simd256(x256+4,xtmp+1,8); transpose16_ooff_simd256(x256+8,xtmp+2,8); @@ -3095,44 +3599,48 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) { print_shorts256(vname,(int16_t*)(xtmp+i)); } exit(-1);*/ - dft64((int16_t *)(xtmp),(int16_t *)(ytmp),1); - dft64((int16_t *)(xtmp+8),(int16_t *)(ytmp+8),1); - dft64((int16_t *)(xtmp+16),(int16_t *)(ytmp+16),1); - dft64((int16_t *)(xtmp+24),(int16_t *)(ytmp+24),1); + + dft64((int16_t*)(xtmp),(int16_t*)(ytmp),1); + dft64((int16_t*)(xtmp+8),(int16_t*)(ytmp+8),1); + dft64((int16_t*)(xtmp+16),(int16_t*)(ytmp+16),1); + dft64((int16_t*)(xtmp+24),(int16_t*)(ytmp+24),1); + + bfly4_16_256(ytmpp,ytmpp+8,ytmpp+16,ytmpp+24, - y256p,y256p+8,y256p+16,y256p+24, - tw256a_256p,tw256a_256p+8,tw256a_256p+16, - tw256b_256p,tw256b_256p+8,tw256b_256p+16); + y256p,y256p+8,y256p+16,y256p+24, + tw256a_256p,tw256a_256p+8,tw256a_256p+16, + tw256b_256p,tw256b_256p+8,tw256b_256p+16); bfly4_16_256(ytmpp+1,ytmpp+9,ytmpp+17,ytmpp+25, - y256p+1,y256p+9,y256p+17,y256p+25, - tw256a_256p+1,tw256a_256p+9,tw256a_256p+17, - tw256b_256p+1,tw256b_256p+9,tw256b_256p+17); + y256p+1,y256p+9,y256p+17,y256p+25, + tw256a_256p+1,tw256a_256p+9,tw256a_256p+17, + tw256b_256p+1,tw256b_256p+9,tw256b_256p+17); bfly4_16_256(ytmpp+2,ytmpp+10,ytmpp+18,ytmpp+26, - y256p+2,y256p+10,y256p+18,y256p+26, - tw256a_256p+2,tw256a_256p+10,tw256a_256p+18, - tw256b_256p+2,tw256b_256p+10,tw256b_256p+18); + y256p+2,y256p+10,y256p+18,y256p+26, + tw256a_256p+2,tw256a_256p+10,tw256a_256p+18, + tw256b_256p+2,tw256b_256p+10,tw256b_256p+18); bfly4_16_256(ytmpp+3,ytmpp+11,ytmpp+19,ytmpp+27, - y256p+3,y256p+11,y256p+19,y256p+27, - tw256a_256p+3,tw256a_256p+11,tw256a_256p+19, - tw256b_256p+3,tw256b_256p+11,tw256b_256p+19); + y256p+3,y256p+11,y256p+19,y256p+27, + tw256a_256p+3,tw256a_256p+11,tw256a_256p+19, + tw256b_256p+3,tw256b_256p+11,tw256b_256p+19); bfly4_16_256(ytmpp+4,ytmpp+12,ytmpp+20,ytmpp+28, - y256p+4,y256p+12,y256p+20,y256p+28, - tw256a_256p+4,tw256a_256p+12,tw256a_256p+20, - tw256b_256p+4,tw256b_256p+12,tw256b_256p+20); + y256p+4,y256p+12,y256p+20,y256p+28, + tw256a_256p+4,tw256a_256p+12,tw256a_256p+20, + tw256b_256p+4,tw256b_256p+12,tw256b_256p+20); bfly4_16_256(ytmpp+5,ytmpp+13,ytmpp+21,ytmpp+29, - y256p+5,y256p+13,y256p+21,y256p+29, - tw256a_256p+5,tw256a_256p+13,tw256a_256p+21, - tw256b_256p+5,tw256b_256p+13,tw256b_256p+21); + y256p+5,y256p+13,y256p+21,y256p+29, + tw256a_256p+5,tw256a_256p+13,tw256a_256p+21, + tw256b_256p+5,tw256b_256p+13,tw256b_256p+21); bfly4_16_256(ytmpp+6,ytmpp+14,ytmpp+22,ytmpp+30, - y256p+6,y256p+14,y256p+22,y256p+30, - tw256a_256p+6,tw256a_256p+14,tw256a_256p+22, - tw256b_256p+6,tw256b_256p+14,tw256b_256p+22); + y256p+6,y256p+14,y256p+22,y256p+30, + tw256a_256p+6,tw256a_256p+14,tw256a_256p+22, + tw256b_256p+6,tw256b_256p+14,tw256b_256p+22); bfly4_16_256(ytmpp+7,ytmpp+15,ytmpp+23,ytmpp+31, - y256p+7,y256p+15,y256p+23,y256p+31, - tw256a_256p+7,tw256a_256p+15,tw256a_256p+23, - tw256b_256p+7,tw256b_256p+15,tw256b_256p+23); + y256p+7,y256p+15,y256p+23,y256p+31, + tw256a_256p+7,tw256a_256p+15,tw256a_256p+23, + tw256b_256p+7,tw256b_256p+15,tw256b_256p+23); if (scale>0) { + for (i=0; i<2; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -3150,18 +3658,24 @@ void dft256(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); + y256+=16; } + } _mm_empty(); _m_empty(); + } -void idft256(int16_t *x,int16_t *y,unsigned char scale) { +void idft256(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[32],ytmp[32],*tw256_256p=(simd256_q15_t *)tw256,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; + transpose16_ooff_simd256(x256+0,xtmp+0,8); transpose16_ooff_simd256(x256+4,xtmp+1,8); transpose16_ooff_simd256(x256+8,xtmp+2,8); @@ -3170,36 +3684,48 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff_simd256(x256+20,xtmp+5,8); transpose16_ooff_simd256(x256+24,xtmp+6,8); transpose16_ooff_simd256(x256+28,xtmp+7,8); - idft64((int16_t *)(xtmp),(int16_t *)(ytmp),1); - idft64((int16_t *)(xtmp+8),(int16_t *)(ytmp+8),1); - idft64((int16_t *)(xtmp+16),(int16_t *)(ytmp+16),1); - idft64((int16_t *)(xtmp+24),(int16_t *)(ytmp+24),1); + + idft64((int16_t*)(xtmp),(int16_t*)(ytmp),1); + idft64((int16_t*)(xtmp+8),(int16_t*)(ytmp+8),1); + idft64((int16_t*)(xtmp+16),(int16_t*)(ytmp+16),1); + idft64((int16_t*)(xtmp+24),(int16_t*)(ytmp+24),1); + + ibfly4_256(ytmpp,ytmpp+8,ytmpp+16,ytmpp+24, - y256p,y256p+8,y256p+16,y256p+24, - tw256_256p,tw256_256p+8,tw256_256p+16); - ibfly4_256(ytmpp+1,ytmpp+9,ytmpp+17,ytmpp+25, - y256p+1,y256p+9,y256p+17,y256p+25, - tw256_256p+1,tw256_256p+9,tw256_256p+17); - ibfly4_256(ytmpp+2,ytmpp+10,ytmpp+18,ytmpp+26, - y256p+2,y256p+10,y256p+18,y256p+26, - tw256_256p+2,tw256_256p+10,tw256_256p+18); - ibfly4_256(ytmpp+3,ytmpp+11,ytmpp+19,ytmpp+27, - y256p+3,y256p+11,y256p+19,y256p+27, - tw256_256p+3,tw256_256p+11,tw256_256p+19); - ibfly4_256(ytmpp+4,ytmpp+12,ytmpp+20,ytmpp+28, - y256p+4,y256p+12,y256p+20,y256p+28, - tw256_256p+4,tw256_256p+12,tw256_256p+20); - ibfly4_256(ytmpp+5,ytmpp+13,ytmpp+21,ytmpp+29, - y256p+5,y256p+13,y256p+21,y256p+29, - tw256_256p+5,tw256_256p+13,tw256_256p+21); - ibfly4_256(ytmpp+6,ytmpp+14,ytmpp+22,ytmpp+30, - y256p+6,y256p+14,y256p+22,y256p+30, - tw256_256p+6,tw256_256p+14,tw256_256p+22); - ibfly4_256(ytmpp+7,ytmpp+15,ytmpp+23,ytmpp+31, - y256p+7,y256p+15,y256p+23,y256p+31, - tw256_256p+7,tw256_256p+15,tw256_256p+23); + y256p,y256p+8,y256p+16,y256p+24, + tw256_256p,tw256_256p+8,tw256_256p+16); + ibfly4_256(ytmpp+1,ytmpp+9,ytmpp+17,ytmpp+25, + y256p+1,y256p+9,y256p+17,y256p+25, + tw256_256p+1,tw256_256p+9,tw256_256p+17); + + ibfly4_256(ytmpp+2,ytmpp+10,ytmpp+18,ytmpp+26, + y256p+2,y256p+10,y256p+18,y256p+26, + tw256_256p+2,tw256_256p+10,tw256_256p+18); + + ibfly4_256(ytmpp+3,ytmpp+11,ytmpp+19,ytmpp+27, + y256p+3,y256p+11,y256p+19,y256p+27, + tw256_256p+3,tw256_256p+11,tw256_256p+19); + + ibfly4_256(ytmpp+4,ytmpp+12,ytmpp+20,ytmpp+28, + y256p+4,y256p+12,y256p+20,y256p+28, + tw256_256p+4,tw256_256p+12,tw256_256p+20); + + ibfly4_256(ytmpp+5,ytmpp+13,ytmpp+21,ytmpp+29, + y256p+5,y256p+13,y256p+21,y256p+29, + tw256_256p+5,tw256_256p+13,tw256_256p+21); + + ibfly4_256(ytmpp+6,ytmpp+14,ytmpp+22,ytmpp+30, + y256p+6,y256p+14,y256p+22,y256p+30, + tw256_256p+6,tw256_256p+14,tw256_256p+22); + + ibfly4_256(ytmpp+7,ytmpp+15,ytmpp+23,ytmpp+31, + y256p+7,y256p+15,y256p+23,y256p+31, + tw256_256p+7,tw256_256p+15,tw256_256p+23); + + if (scale>0) { + for (i=0; i<2; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -3217,12 +3743,15 @@ void idft256(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); + y256+=16; } + } _mm_empty(); _m_empty(); + } #endif @@ -3245,16 +3774,19 @@ int16_t tw512c[512] __attribute__((aligned(32))) = { }; #ifndef __AVX2__ -void dft512(int16_t *x,int16_t *y,unsigned char scale) { +void dft512(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[256],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[128],*tw512a_128p=(simd_q15_t *)tw512a,*tw512b_128p=(simd_q15_t *)tw512b,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<4; i++) { - transpose4_ooff(x64,xtmpp,128); + transpose4_ooff(x64 ,xtmpp,128); transpose4_ooff(x64+2,xtmpp+1,128); transpose4_ooff(x64+4,xtmpp+2,128); transpose4_ooff(x64+6,xtmpp+3,128); @@ -3290,8 +3822,9 @@ void dft512(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - dft256((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft256((int16_t *)(xtmp+128),(int16_t *)(ytmp+64),1); + dft256((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft256((int16_t*)(xtmp+128),(int16_t*)(ytmp+64),1); + for (i=0; i<64; i+=8) { bfly2_16(ytmpp,ytmpp+64, @@ -3358,18 +3891,22 @@ void dft512(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } -void idft512(int16_t *x,int16_t *y,unsigned char scale) { +void idft512(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[256],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[128],*tw512_128p=(simd_q15_t *)tw512,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<4; i++) { - transpose4_ooff(x64,xtmpp,128); + transpose4_ooff(x64 ,xtmpp,128); transpose4_ooff(x64+2,xtmpp+1,128); transpose4_ooff(x64+4,xtmpp+2,128); transpose4_ooff(x64+6,xtmpp+3,128); @@ -3405,8 +3942,9 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - idft256((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft256((int16_t *)(xtmp+128),(int16_t *)(ytmp+64),1); + idft256((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft256((int16_t*)(xtmp+128),(int16_t*)(ytmp+64),1); + for (i=0; i<64; i++) { ibfly2(ytmpp,ytmpp+64, @@ -3443,18 +3981,23 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } #else //__AVX2__ -void dft512(int16_t *x,int16_t *y,unsigned char scale) { +void dft512(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[64],*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[64],*y256=(simd256_q15_t *)y; - simd256_q15_t *tw512_256p=(simd256_q15_t *)tw512,*y256p=(simd256_q15_t *)y; + simd256_q15_t ytmp[64],*y256=(simd256_q15_t*)y; + simd256_q15_t *tw512_256p=(simd256_q15_t*)tw512,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - transpose4_ooff_simd256(x256,xtmp,32); + + + transpose4_ooff_simd256(x256 ,xtmp,32); transpose4_ooff_simd256(x256+2,xtmp+1,32); transpose4_ooff_simd256(x256+4,xtmp+2,32); transpose4_ooff_simd256(x256+6,xtmp+3,32); @@ -3486,20 +4029,23 @@ void dft512(int16_t *x,int16_t *y,unsigned char scale) { transpose4_ooff_simd256(x256+58,xtmp+29,32); transpose4_ooff_simd256(x256+60,xtmp+30,32); transpose4_ooff_simd256(x256+62,xtmp+31,32); - dft256((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft256((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); + + dft256((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft256((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); + for (i=0; i<32; i++) { bfly2_256(ytmpp,ytmpp+32, - y256p,y256p+32, - tw512_256p); + y256p,y256p+32, + tw512_256p); tw512_256p++; y256p++; ytmpp++; } if (scale>0) { - for (i=0; i<4; i++) { + + for (i=0;i<4;i++) { y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); @@ -3519,16 +4065,21 @@ void dft512(int16_t *x,int16_t *y,unsigned char scale) { y256+=16; } } + } -void idft512(int16_t *x,int16_t *y,unsigned char scale) { +void idft512(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[64],*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[64],*y256=(simd256_q15_t *)y; + simd256_q15_t ytmp[64],*y256=(simd256_q15_t*)y; simd256_q15_t *tw512_256p=(simd256_q15_t *)tw512,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_256 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - transpose4_ooff_simd256(x256,xtmp,32); + + + transpose4_ooff_simd256(x256 ,xtmp,32); transpose4_ooff_simd256(x256+2,xtmp+1,32); transpose4_ooff_simd256(x256+4,xtmp+2,32); transpose4_ooff_simd256(x256+6,xtmp+3,32); @@ -3560,20 +4111,23 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) { transpose4_ooff_simd256(x256+58,xtmp+29,32); transpose4_ooff_simd256(x256+60,xtmp+30,32); transpose4_ooff_simd256(x256+62,xtmp+31,32); - idft256((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft256((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); + + idft256((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft256((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); + for (i=0; i<32; i++) { ibfly2_256(ytmpp,ytmpp+32, - y256p,y256p+32, - tw512_256p); + y256p,y256p+32, + tw512_256p); tw512_256p++; y256p++; ytmpp++; } if (scale>0) { - for (i=0; i<4; i++) { + + for (i=0;i<4;i++) { y256[0] = mulhi_int16_simd256(y256[0],ONE_OVER_SQRT2_Q15_256); y256[1] = mulhi_int16_simd256(y256[1],ONE_OVER_SQRT2_Q15_256); y256[2] = mulhi_int16_simd256(y256[2],ONE_OVER_SQRT2_Q15_256); @@ -3593,6 +4147,7 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) { y256+=16; } } + } #endif @@ -3600,7 +4155,9 @@ void idft512(int16_t *x,int16_t *y,unsigned char scale) { int16_t tw1024[1536] __attribute__((aligned(32))); #ifndef __AVX2__ -void dft1024(int16_t *x,int16_t *y,unsigned char scale) { +void dft1024(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t xtmp[256],ytmp[256],*tw1024_128p=(simd_q15_t *)tw1024,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -3609,10 +4166,11 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff(x128+i,xtmp+j,64); } - dft256((int16_t *)(xtmp),(int16_t *)(ytmp),1); - dft256((int16_t *)(xtmp+64),(int16_t *)(ytmp+64),1); - dft256((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); - dft256((int16_t *)(xtmp+192),(int16_t *)(ytmp+192),1); + + dft256((int16_t*)(xtmp),(int16_t*)(ytmp),1); + dft256((int16_t*)(xtmp+64),(int16_t*)(ytmp+64),1); + dft256((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); + dft256((int16_t*)(xtmp+192),(int16_t*)(ytmp+192),1); for (i=0; i<64; i++) { bfly4(ytmpp,ytmpp+64,ytmpp+128,ytmpp+192, @@ -3624,6 +4182,7 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + for (i=0; i<16; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -3641,15 +4200,20 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); + y128+=16; } + } _mm_empty(); _m_empty(); + } -void idft1024(int16_t *x,int16_t *y,unsigned char scale) { +void idft1024(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t xtmp[256],ytmp[256],*tw1024_128p=(simd_q15_t *)tw1024,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -3658,10 +4222,11 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff(x128+i,xtmp+j,64); } - idft256((int16_t *)(xtmp),(int16_t *)(ytmp),1); - idft256((int16_t *)(xtmp+64),(int16_t *)(ytmp+64),1); - idft256((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); - idft256((int16_t *)(xtmp+192),(int16_t *)(ytmp+192),1); + + idft256((int16_t*)(xtmp),(int16_t*)(ytmp),1); + idft256((int16_t*)(xtmp+64),(int16_t*)(ytmp+64),1); + idft256((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); + idft256((int16_t*)(xtmp+192),(int16_t*)(ytmp+192),1); for (i=0; i<64; i++) { ibfly4(ytmpp,ytmpp+64,ytmpp+128,ytmpp+192, @@ -3673,6 +4238,7 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + for (i=0; i<16; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -3690,16 +4256,21 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); + y128+=16; } + } _mm_empty(); _m_empty(); + } #else //__AVX2__ -void dft1024(int16_t *x,int16_t *y,unsigned char scale) { +void dft1024(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[128],ytmp[128],*tw1024_256p=(simd256_q15_t *)tw1024,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -3708,21 +4279,23 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff_simd256(x256+i,xtmp+j,32); } - dft256((int16_t *)(xtmp),(int16_t *)(ytmp),1); - dft256((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); - dft256((int16_t *)(xtmp+64),(int16_t *)(ytmp+64),1); - dft256((int16_t *)(xtmp+96),(int16_t *)(ytmp+96),1); + + dft256((int16_t*)(xtmp),(int16_t*)(ytmp),1); + dft256((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); + dft256((int16_t*)(xtmp+64),(int16_t*)(ytmp+64),1); + dft256((int16_t*)(xtmp+96),(int16_t*)(ytmp+96),1); for (i=0; i<32; i++) { bfly4_256(ytmpp,ytmpp+32,ytmpp+64,ytmpp+96, - y256p,y256p+32,y256p+64,y256p+96, - tw1024_256p,tw1024_256p+32,tw1024_256p+64); + y256p,y256p+32,y256p+64,y256p+96, + tw1024_256p,tw1024_256p+32,tw1024_256p+64); tw1024_256p++; y256p++; ytmpp++; } if (scale>0) { + for (i=0; i<8; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -3740,15 +4313,20 @@ void dft1024(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); + y256+=16; } + } _mm_empty(); _m_empty(); + } -void idft1024(int16_t *x,int16_t *y,unsigned char scale) { +void idft1024(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[128],ytmp[128],*tw1024_256p=(simd256_q15_t *)tw1024,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -3757,21 +4335,23 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff_simd256(x256+i,xtmp+j,32); } - idft256((int16_t *)(xtmp),(int16_t *)(ytmp),1); - idft256((int16_t *)(xtmp+32),(int16_t *)(ytmp+32),1); - idft256((int16_t *)(xtmp+64),(int16_t *)(ytmp+64),1); - idft256((int16_t *)(xtmp+96),(int16_t *)(ytmp+96),1); + + idft256((int16_t*)(xtmp),(int16_t*)(ytmp),1); + idft256((int16_t*)(xtmp+32),(int16_t*)(ytmp+32),1); + idft256((int16_t*)(xtmp+64),(int16_t*)(ytmp+64),1); + idft256((int16_t*)(xtmp+96),(int16_t*)(ytmp+96),1); for (i=0; i<32; i++) { ibfly4_256(ytmpp,ytmpp+32,ytmpp+64,ytmpp+96, - y256p,y256p+32,y256p+64,y256p+96, - tw1024_256p,tw1024_256p+32,tw1024_256p+64); + y256p,y256p+32,y256p+64,y256p+96, + tw1024_256p,tw1024_256p+32,tw1024_256p+64); tw1024_256p++; y256p++; ytmpp++; } if (scale>0) { + for (i=0; i<8; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -3789,28 +4369,34 @@ void idft1024(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); + y256+=16; } + } _mm_empty(); _m_empty(); + } #endif int16_t tw2048[2048] __attribute__((aligned(32))); #ifndef __AVX2__ -void dft2048(int16_t *x,int16_t *y,unsigned char scale) { +void dft2048(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[1024],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[512],*tw2048_128p=(simd_q15_t *)tw2048,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<16; i++) { - transpose4_ooff(x64,xtmpp,512); + transpose4_ooff(x64 ,xtmpp,512); transpose4_ooff(x64+2,xtmpp+1,512); transpose4_ooff(x64+4,xtmpp+2,512); transpose4_ooff(x64+6,xtmpp+3,512); @@ -3846,8 +4432,9 @@ void dft2048(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - dft1024((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft1024((int16_t *)(xtmp+512),(int16_t *)(ytmp+256),1); + dft1024((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft1024((int16_t*)(xtmp+512),(int16_t*)(ytmp+256),1); + for (i=0; i<256; i++) { bfly2(ytmpp,ytmpp+256, @@ -3884,17 +4471,23 @@ void dft2048(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + + } -void idft2048(int16_t *x,int16_t *y,unsigned char scale) { +void idft2048(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[1024],*xtmpp,*x64 = (simdshort_q15_t *)x; - simd_q15_t ytmp[512],*tw2048_128p=(simd_q15_t *)tw2048,*y128=(simd_q15_t *)y; + simd_q15_t ytmp[512],*tw2048_128p=(simd_q15_t *)tw2048,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; + simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<16; i++) { - transpose4_ooff(x64,xtmpp,512); + transpose4_ooff(x64 ,xtmpp,512); transpose4_ooff(x64+2,xtmpp+1,512); transpose4_ooff(x64+4,xtmpp+2,512); transpose4_ooff(x64+6,xtmpp+3,512); @@ -3930,23 +4523,17 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - idft1024((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft1024((int16_t *)(xtmp+512),(int16_t *)(ytmp+256),1); + idft1024((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft1024((int16_t*)(xtmp+512),(int16_t*)(ytmp+256),1); - for (i=0, - simd_q15_t y128p=(simd_q15_t *)y, - simd_q15_t y128p256=((simd_q15_t *)y)+256, - simd_q15_t *ytmpp = ytmp, - simd_q15_t *ytmpp256= ytmp+256 ; - ; i<256; i++) { - ibfly2(ytmpp,ytmpp256, - y128p,y128p256, + + for (i=0; i<256; i++) { + ibfly2(ytmpp,ytmpp+256, + y128p,y128p+256, tw2048_128p); tw2048_128p++; y128p++; - y128p256++; ytmpp++; - ytmpp256++; } if (scale>0) { @@ -3975,18 +4562,25 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } #else // __AVX2__ -void dft2048(int16_t *x,int16_t *y,unsigned char scale) { +void dft2048(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[256],*xtmpp,*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[256],*tw2048_256p=(simd256_q15_t *)tw2048,*y256=(simd256_q15_t *)y; + simd256_q15_t ytmp[256],*tw2048_256p=(simd256_q15_t *)tw2048,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; + simd256_q15_t *ytmpp = &ytmp[0]; + int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); + + xtmpp = xtmp; - for (int i=0; i<4; i++) { - transpose4_ooff_simd256(x256,xtmpp,128); + for (i=0; i<4; i++) { + transpose4_ooff_simd256(x256 ,xtmpp,128); transpose4_ooff_simd256(x256+2,xtmpp+1,128); transpose4_ooff_simd256(x256+4,xtmpp+2,128); transpose4_ooff_simd256(x256+6,xtmpp+3,128); @@ -4022,109 +4616,22 @@ void dft2048(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - dft1024((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft1024((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); - simd256_q15_t *y256p=(simd256_q15_t *)y; - simd256_q15_t *y256p128=y256p+128; - simd256_q15_t *ytmpp = ytmp; - simd256_q15_t *ytmpp128 = ytmp+128; + dft1024((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft1024((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); - for (int i=0; i<128; i++) { - bfly2_256(ytmpp++,ytmpp128++, - y256p++,y256p128++, - tw2048_256p++); + + for (i=0; i<128; i++) { + bfly2_256(ytmpp,ytmpp+128, + y256p,y256p+128, + tw2048_256p); + tw2048_256p++; + y256p++; + ytmpp++; } if (scale>0) { y256p = y256; - for (int i=0; i<16; i++) { - y256p[0] = mulhi_int16_simd256(y256p[0],ONE_OVER_SQRT2_Q15_128); - y256p[1] = mulhi_int16_simd256(y256p[1],ONE_OVER_SQRT2_Q15_128); - y256p[2] = mulhi_int16_simd256(y256p[2],ONE_OVER_SQRT2_Q15_128); - y256p[3] = mulhi_int16_simd256(y256p[3],ONE_OVER_SQRT2_Q15_128); - y256p[4] = mulhi_int16_simd256(y256p[4],ONE_OVER_SQRT2_Q15_128); - y256p[5] = mulhi_int16_simd256(y256p[5],ONE_OVER_SQRT2_Q15_128); - y256p[6] = mulhi_int16_simd256(y256p[6],ONE_OVER_SQRT2_Q15_128); - y256p[7] = mulhi_int16_simd256(y256p[7],ONE_OVER_SQRT2_Q15_128); - y256p[8] = mulhi_int16_simd256(y256p[8],ONE_OVER_SQRT2_Q15_128); - y256p[9] = mulhi_int16_simd256(y256p[9],ONE_OVER_SQRT2_Q15_128); - y256p[10] = mulhi_int16_simd256(y256p[10],ONE_OVER_SQRT2_Q15_128); - y256p[11] = mulhi_int16_simd256(y256p[11],ONE_OVER_SQRT2_Q15_128); - y256p[12] = mulhi_int16_simd256(y256p[12],ONE_OVER_SQRT2_Q15_128); - y256p[13] = mulhi_int16_simd256(y256p[13],ONE_OVER_SQRT2_Q15_128); - y256p[14] = mulhi_int16_simd256(y256p[14],ONE_OVER_SQRT2_Q15_128); - y256p[15] = mulhi_int16_simd256(y256p[15],ONE_OVER_SQRT2_Q15_128); - y256p+=16; - } - } - - _mm_empty(); - _m_empty(); -} - -void idft2048(int16_t *x,int16_t *y,unsigned char scale) { - simd256_q15_t xtmp[256],*xtmpp,*x256 = (simd256_q15_t *)x; - simd256_q15_t ytmp[256],*tw2048_256p=(simd256_q15_t *)tw2048,*y256=(simd256_q15_t *)y; - int i; - simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); - xtmpp = xtmp; - - for (i=0; i<4; i++) { - transpose4_ooff_simd256(x256,xtmpp,128); - transpose4_ooff_simd256(x256+2,xtmpp+1,128); - transpose4_ooff_simd256(x256+4,xtmpp+2,128); - transpose4_ooff_simd256(x256+6,xtmpp+3,128); - transpose4_ooff_simd256(x256+8,xtmpp+4,128); - transpose4_ooff_simd256(x256+10,xtmpp+5,128); - transpose4_ooff_simd256(x256+12,xtmpp+6,128); - transpose4_ooff_simd256(x256+14,xtmpp+7,128); - transpose4_ooff_simd256(x256+16,xtmpp+8,128); - transpose4_ooff_simd256(x256+18,xtmpp+9,128); - transpose4_ooff_simd256(x256+20,xtmpp+10,128); - transpose4_ooff_simd256(x256+22,xtmpp+11,128); - transpose4_ooff_simd256(x256+24,xtmpp+12,128); - transpose4_ooff_simd256(x256+26,xtmpp+13,128); - transpose4_ooff_simd256(x256+28,xtmpp+14,128); - transpose4_ooff_simd256(x256+30,xtmpp+15,128); - transpose4_ooff_simd256(x256+32,xtmpp+16,128); - transpose4_ooff_simd256(x256+34,xtmpp+17,128); - transpose4_ooff_simd256(x256+36,xtmpp+18,128); - transpose4_ooff_simd256(x256+38,xtmpp+19,128); - transpose4_ooff_simd256(x256+40,xtmpp+20,128); - transpose4_ooff_simd256(x256+42,xtmpp+21,128); - transpose4_ooff_simd256(x256+44,xtmpp+22,128); - transpose4_ooff_simd256(x256+46,xtmpp+23,128); - transpose4_ooff_simd256(x256+48,xtmpp+24,128); - transpose4_ooff_simd256(x256+50,xtmpp+25,128); - transpose4_ooff_simd256(x256+52,xtmpp+26,128); - transpose4_ooff_simd256(x256+54,xtmpp+27,128); - transpose4_ooff_simd256(x256+56,xtmpp+28,128); - transpose4_ooff_simd256(x256+58,xtmpp+29,128); - transpose4_ooff_simd256(x256+60,xtmpp+30,128); - transpose4_ooff_simd256(x256+62,xtmpp+31,128); - x256+=64; - xtmpp+=32; - } - - idft1024((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft1024((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); - { - simd256_q15_t *y256p=(simd256_q15_t *)y; - simd256_q15_t *y256p128=y256p+128; - simd256_q15_t *ytmpp = ytmp; - simd256_q15_t *ytmpp128 = ytmp+128; - - for (i=0; i<128; i++) { - ibfly2_256(ytmpp++,ytmpp128++, - y256p++,y256p128++, - tw2048_256p++); - } - } - - if (scale>0) { - simd256_q15_t *y256p = y256; - for (i=0; i<16; i++) { y256p[0] = mulhi_int16_simd256(y256p[0],ONE_OVER_SQRT2_Q15_128); y256p[1] = mulhi_int16_simd256(y256p[1],ONE_OVER_SQRT2_Q15_128); @@ -4148,6 +4655,97 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + +} + +void idft2048(int16_t *x,int16_t *y,unsigned char scale) +{ + + simd256_q15_t xtmp[256],*xtmpp,*x256 = (simd256_q15_t *)x; + simd256_q15_t ytmp[256],*tw2048_256p=(simd256_q15_t *)tw2048,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; + simd256_q15_t *ytmpp = &ytmp[0]; + int i; + simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); + + xtmpp = xtmp; + + for (i=0; i<4; i++) { + transpose4_ooff_simd256(x256 ,xtmpp,128); + transpose4_ooff_simd256(x256+2,xtmpp+1,128); + transpose4_ooff_simd256(x256+4,xtmpp+2,128); + transpose4_ooff_simd256(x256+6,xtmpp+3,128); + transpose4_ooff_simd256(x256+8,xtmpp+4,128); + transpose4_ooff_simd256(x256+10,xtmpp+5,128); + transpose4_ooff_simd256(x256+12,xtmpp+6,128); + transpose4_ooff_simd256(x256+14,xtmpp+7,128); + transpose4_ooff_simd256(x256+16,xtmpp+8,128); + transpose4_ooff_simd256(x256+18,xtmpp+9,128); + transpose4_ooff_simd256(x256+20,xtmpp+10,128); + transpose4_ooff_simd256(x256+22,xtmpp+11,128); + transpose4_ooff_simd256(x256+24,xtmpp+12,128); + transpose4_ooff_simd256(x256+26,xtmpp+13,128); + transpose4_ooff_simd256(x256+28,xtmpp+14,128); + transpose4_ooff_simd256(x256+30,xtmpp+15,128); + transpose4_ooff_simd256(x256+32,xtmpp+16,128); + transpose4_ooff_simd256(x256+34,xtmpp+17,128); + transpose4_ooff_simd256(x256+36,xtmpp+18,128); + transpose4_ooff_simd256(x256+38,xtmpp+19,128); + transpose4_ooff_simd256(x256+40,xtmpp+20,128); + transpose4_ooff_simd256(x256+42,xtmpp+21,128); + transpose4_ooff_simd256(x256+44,xtmpp+22,128); + transpose4_ooff_simd256(x256+46,xtmpp+23,128); + transpose4_ooff_simd256(x256+48,xtmpp+24,128); + transpose4_ooff_simd256(x256+50,xtmpp+25,128); + transpose4_ooff_simd256(x256+52,xtmpp+26,128); + transpose4_ooff_simd256(x256+54,xtmpp+27,128); + transpose4_ooff_simd256(x256+56,xtmpp+28,128); + transpose4_ooff_simd256(x256+58,xtmpp+29,128); + transpose4_ooff_simd256(x256+60,xtmpp+30,128); + transpose4_ooff_simd256(x256+62,xtmpp+31,128); + x256+=64; + xtmpp+=32; + } + + idft1024((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft1024((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); + + + for (i=0; i<128; i++) { + ibfly2_256(ytmpp,ytmpp+128, + y256p,y256p+128, + tw2048_256p); + tw2048_256p++; + y256p++; + ytmpp++; + } + + if (scale>0) { + y256p = y256; + + for (i=0; i<16; i++) { + y256p[0] = mulhi_int16_simd256(y256p[0],ONE_OVER_SQRT2_Q15_128); + y256p[1] = mulhi_int16_simd256(y256p[1],ONE_OVER_SQRT2_Q15_128); + y256p[2] = mulhi_int16_simd256(y256p[2],ONE_OVER_SQRT2_Q15_128); + y256p[3] = mulhi_int16_simd256(y256p[3],ONE_OVER_SQRT2_Q15_128); + y256p[4] = mulhi_int16_simd256(y256p[4],ONE_OVER_SQRT2_Q15_128); + y256p[5] = mulhi_int16_simd256(y256p[5],ONE_OVER_SQRT2_Q15_128); + y256p[6] = mulhi_int16_simd256(y256p[6],ONE_OVER_SQRT2_Q15_128); + y256p[7] = mulhi_int16_simd256(y256p[7],ONE_OVER_SQRT2_Q15_128); + y256p[8] = mulhi_int16_simd256(y256p[8],ONE_OVER_SQRT2_Q15_128); + y256p[9] = mulhi_int16_simd256(y256p[9],ONE_OVER_SQRT2_Q15_128); + y256p[10] = mulhi_int16_simd256(y256p[10],ONE_OVER_SQRT2_Q15_128); + y256p[11] = mulhi_int16_simd256(y256p[11],ONE_OVER_SQRT2_Q15_128); + y256p[12] = mulhi_int16_simd256(y256p[12],ONE_OVER_SQRT2_Q15_128); + y256p[13] = mulhi_int16_simd256(y256p[13],ONE_OVER_SQRT2_Q15_128); + y256p[14] = mulhi_int16_simd256(y256p[14],ONE_OVER_SQRT2_Q15_128); + y256p[15] = mulhi_int16_simd256(y256p[15],ONE_OVER_SQRT2_Q15_128); + y256p+=16; + } + } + + _mm_empty(); + _m_empty(); + } #endif @@ -4157,7 +4755,9 @@ void idft2048(int16_t *x,int16_t *y,unsigned char scale) { int16_t tw4096[3*2*1024]; #ifndef __AVX2__ -void dft4096(int16_t *x,int16_t *y,unsigned char scale) { +void dft4096(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t xtmp[1024],ytmp[1024],*tw4096_128p=(simd_q15_t *)tw4096,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4166,10 +4766,11 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff(x128+i,xtmp+j,256); } - dft1024((int16_t *)(xtmp),(int16_t *)(ytmp),1); - dft1024((int16_t *)(xtmp+256),(int16_t *)(ytmp+256),1); - dft1024((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); - dft1024((int16_t *)(xtmp+768),(int16_t *)(ytmp+768),1); + + dft1024((int16_t*)(xtmp),(int16_t*)(ytmp),1); + dft1024((int16_t*)(xtmp+256),(int16_t*)(ytmp+256),1); + dft1024((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); + dft1024((int16_t*)(xtmp+768),(int16_t*)(ytmp+768),1); for (i=0; i<256; i++) { bfly4(ytmpp,ytmpp+256,ytmpp+512,ytmpp+768, @@ -4181,6 +4782,7 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + for (i=0; i<64; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -4198,17 +4800,22 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); + y128+=16; } + } _mm_empty(); _m_empty(); + } + +void idft4096(int16_t *x,int16_t *y,unsigned char scale) +{ -void idft4096(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[1024],ytmp[1024],*tw4096_128p=(simd_q15_t *)tw4096,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4217,10 +4824,11 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff(x128+i,xtmp+j,256); } - idft1024((int16_t *)(xtmp),(int16_t *)(ytmp),1); - idft1024((int16_t *)(xtmp+256),(int16_t *)(ytmp+256),1); - idft1024((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); - idft1024((int16_t *)(xtmp+768),(int16_t *)(ytmp+768),1); + + idft1024((int16_t*)(xtmp),(int16_t*)(ytmp),1); + idft1024((int16_t*)(xtmp+256),(int16_t*)(ytmp+256),1); + idft1024((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); + idft1024((int16_t*)(xtmp+768),(int16_t*)(ytmp+768),1); for (i=0; i<256; i++) { ibfly4(ytmpp,ytmpp+256,ytmpp+512,ytmpp+768, @@ -4232,6 +4840,7 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + for (i=0; i<64; i++) { y128[0] = shiftright_int16(y128[0],scale); y128[1] = shiftright_int16(y128[1],scale); @@ -4249,16 +4858,21 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],scale); y128[14] = shiftright_int16(y128[14],scale); y128[15] = shiftright_int16(y128[15],scale); + y128+=16; } + } _mm_empty(); _m_empty(); + } #else //__AVX2__ -void dft4096(int16_t *x,int16_t *y,unsigned char scale) { +void dft4096(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[512],ytmp[512],*tw4096_256p=(simd256_q15_t *)tw4096,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4267,21 +4881,23 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff_simd256(x256+i,xtmp+j,128); } - dft1024((int16_t *)(xtmp),(int16_t *)(ytmp),1); - dft1024((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); - dft1024((int16_t *)(xtmp+256),(int16_t *)(ytmp+256),1); - dft1024((int16_t *)(xtmp+384),(int16_t *)(ytmp+384),1); + + dft1024((int16_t*)(xtmp),(int16_t*)(ytmp),1); + dft1024((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); + dft1024((int16_t*)(xtmp+256),(int16_t*)(ytmp+256),1); + dft1024((int16_t*)(xtmp+384),(int16_t*)(ytmp+384),1); for (i=0; i<128; i++) { bfly4_256(ytmpp,ytmpp+128,ytmpp+256,ytmpp+384, - y256p,y256p+128,y256p+256,y256p+384, - tw4096_256p,tw4096_256p+128,tw4096_256p+256); + y256p,y256p+128,y256p+256,y256p+384, + tw4096_256p,tw4096_256p+128,tw4096_256p+256); tw4096_256p++; y256p++; ytmpp++; } if (scale>0) { + for (i=0; i<32; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -4299,15 +4915,20 @@ void dft4096(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); + y256+=16; } + } _mm_empty(); _m_empty(); + } -void idft4096(int16_t *x,int16_t *y,unsigned char scale) { +void idft4096(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[512],ytmp[512],*tw4096_256p=(simd256_q15_t *)tw4096,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4316,21 +4937,23 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff_simd256(x256+i,xtmp+j,128); } - idft1024((int16_t *)(xtmp),(int16_t *)(ytmp),1); - idft1024((int16_t *)(xtmp+128),(int16_t *)(ytmp+128),1); - idft1024((int16_t *)(xtmp+256),(int16_t *)(ytmp+256),1); - idft1024((int16_t *)(xtmp+384),(int16_t *)(ytmp+384),1); + + idft1024((int16_t*)(xtmp),(int16_t*)(ytmp),1); + idft1024((int16_t*)(xtmp+128),(int16_t*)(ytmp+128),1); + idft1024((int16_t*)(xtmp+256),(int16_t*)(ytmp+256),1); + idft1024((int16_t*)(xtmp+384),(int16_t*)(ytmp+384),1); for (i=0; i<128; i++) { ibfly4_256(ytmpp,ytmpp+128,ytmpp+256,ytmpp+384, - y256p,y256p+128,y256p+256,y256p+384, - tw4096_256p,tw4096_256p+128,tw4096_256p+256); + y256p,y256p+128,y256p+256,y256p+384, + tw4096_256p,tw4096_256p+128,tw4096_256p+256); tw4096_256p++; y256p++; ytmpp++; } if (scale>0) { + for (i=0; i<32; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -4348,12 +4971,15 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); + y256+=16; } + } _mm_empty(); _m_empty(); + } #endif //__AVX2__ @@ -4362,16 +4988,19 @@ void idft4096(int16_t *x,int16_t *y,unsigned char scale) { int16_t tw8192[2*4096] __attribute__((aligned(32))); #ifndef __AVX2__ -void dft8192(int16_t *x,int16_t *y,unsigned char scale) { +void dft8192(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[4096],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[1024],*tw8192_128p=(simd_q15_t *)tw8192,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<64; i++) { - transpose4_ooff(x64,xtmpp,2048); + transpose4_ooff(x64 ,xtmpp,2048); transpose4_ooff(x64+2,xtmpp+1,2048); transpose4_ooff(x64+4,xtmpp+2,2048); transpose4_ooff(x64+6,xtmpp+3,2048); @@ -4407,8 +5036,9 @@ void dft8192(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - dft4096((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft4096((int16_t *)(xtmp+2048),(int16_t *)(ytmp+1024),1); + dft4096((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+1024),1); + for (i=0; i<1024; i++) { bfly2(ytmpp,ytmpp+1024, @@ -4445,18 +5075,22 @@ void dft8192(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } -void idft8192(int16_t *x,int16_t *y,unsigned char scale) { +void idft8192(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[4096],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[2048],*tw8192_128p=(simd_q15_t *)tw8192,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<64; i++) { - transpose4_ooff(x64,xtmpp,2048); + transpose4_ooff(x64 ,xtmpp,2048); transpose4_ooff(x64+2,xtmpp+1,2048); transpose4_ooff(x64+4,xtmpp+2,2048); transpose4_ooff(x64+6,xtmpp+3,2048); @@ -4492,8 +5126,9 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - idft4096((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft4096((int16_t *)(xtmp+2048),(int16_t *)(ytmp+1024),1); + idft4096((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+1024),1); + for (i=0; i<1024; i++) { ibfly2(ytmpp,ytmpp+1024, @@ -4530,19 +5165,24 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } #else // __AVX2__ -void dft8192(int16_t *x,int16_t *y,unsigned char scale) { +void dft8192(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[1024],*xtmpp,*x256 = (simd256_q15_t *)x; simd256_q15_t ytmp[1024],*tw8192_256p=(simd256_q15_t *)tw8192,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; + simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<16; i++) { - transpose4_ooff_simd256(x256,xtmpp,512); + transpose4_ooff_simd256(x256 ,xtmpp,512); transpose4_ooff_simd256(x256+2,xtmpp+1,512); transpose4_ooff_simd256(x256+4,xtmpp+2,512); transpose4_ooff_simd256(x256+6,xtmpp+3,512); @@ -4578,13 +5218,14 @@ void dft8192(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - dft4096((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft4096((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); + dft4096((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); + for (i=0; i<512; i++) { bfly2_256(ytmpp,ytmpp+512, - y256p,y256p+512, - tw8192_256p); + y256p,y256p+512, + tw8192_256p); tw8192_256p++; y256p++; ytmpp++; @@ -4616,18 +5257,22 @@ void dft8192(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } -void idft8192(int16_t *x,int16_t *y,unsigned char scale) { +void idft8192(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[1024],*xtmpp,*x256 = (simd256_q15_t *)x; simd256_q15_t ytmp[1024],*tw8192_256p=(simd256_q15_t *)tw8192,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<16; i++) { - transpose4_ooff_simd256(x256,xtmpp,512); + transpose4_ooff_simd256(x256 ,xtmpp,512); transpose4_ooff_simd256(x256+2,xtmpp+1,512); transpose4_ooff_simd256(x256+4,xtmpp+2,512); transpose4_ooff_simd256(x256+6,xtmpp+3,512); @@ -4663,13 +5308,14 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - idft4096((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft4096((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); + idft4096((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); + for (i=0; i<512; i++) { ibfly2_256(ytmpp,ytmpp+512, - y256p,y256p+512, - tw8192_256p); + y256p,y256p+512, + tw8192_256p); tw8192_256p++; y256p++; ytmpp++; @@ -4701,6 +5347,7 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } @@ -4709,7 +5356,9 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale) { int16_t tw16384[3*2*4096]; #ifndef __AVX2__ -void dft16384(int16_t *x,int16_t *y,unsigned char scale) { +void dft16384(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t xtmp[4096],ytmp[4096],*tw16384_128p=(simd_q15_t *)tw16384,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4718,10 +5367,11 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff(x128+i,xtmp+j,1024); } - dft4096((int16_t *)(xtmp),(int16_t *)(ytmp),1); - dft4096((int16_t *)(xtmp+1024),(int16_t *)(ytmp+1024),1); - dft4096((int16_t *)(xtmp+2048),(int16_t *)(ytmp+2048),1); - dft4096((int16_t *)(xtmp+3072),(int16_t *)(ytmp+3072),1); + + dft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1); + dft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1); + dft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1); + dft4096((int16_t*)(xtmp+3072),(int16_t*)(ytmp+3072),1); for (i=0; i<1024; i++) { bfly4(ytmpp,ytmpp+1024,ytmpp+2048,ytmpp+3072, @@ -4733,6 +5383,7 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + for (i=0; i<256; i++) { y128[0] = shiftright_int16(y128[0],1); y128[1] = shiftright_int16(y128[1],1); @@ -4750,17 +5401,22 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],1); y128[14] = shiftright_int16(y128[14],1); y128[15] = shiftright_int16(y128[15],1); + y128+=16; } + } _mm_empty(); _m_empty(); + } + +void idft16384(int16_t *x,int16_t *y,unsigned char scale) +{ -void idft16384(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t xtmp[4096],ytmp[4096],*tw16384_128p=(simd_q15_t *)tw16384,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4769,10 +5425,11 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff(x128+i,xtmp+j,1024); } - idft4096((int16_t *)(xtmp),(int16_t *)(ytmp),1); - idft4096((int16_t *)(xtmp+1024),(int16_t *)(ytmp+1024),1); - idft4096((int16_t *)(xtmp+2048),(int16_t *)(ytmp+2048),1); - idft4096((int16_t *)(xtmp+3072),(int16_t *)(ytmp+3072),1); + + idft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1); + idft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1); + idft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1); + idft4096((int16_t*)(xtmp+3072),(int16_t*)(ytmp+3072),1); for (i=0; i<1024; i++) { ibfly4(ytmpp,ytmpp+1024,ytmpp+2048,ytmpp+3072, @@ -4784,6 +5441,7 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) { } if (scale>0) { + for (i=0; i<256; i++) { y128[0] = shiftright_int16(y128[0],scale); y128[1] = shiftright_int16(y128[1],scale); @@ -4801,16 +5459,21 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) { y128[13] = shiftright_int16(y128[13],scale); y128[14] = shiftright_int16(y128[14],scale); y128[15] = shiftright_int16(y128[15],scale); + y128+=16; } + } _mm_empty(); _m_empty(); + } #else //__AVX2__ -void dft16384(int16_t *x,int16_t *y,unsigned char scale) { +void dft16384(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[2048],ytmp[2048],*tw16384_256p=(simd256_q15_t *)tw16384,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4819,21 +5482,23 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff_simd256(x256+i,xtmp+j,512); } - dft4096((int16_t *)(xtmp),(int16_t *)(ytmp),1); - dft4096((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); - dft4096((int16_t *)(xtmp+1024),(int16_t *)(ytmp+1024),1); - dft4096((int16_t *)(xtmp+1536),(int16_t *)(ytmp+1536),1); + + dft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1); + dft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); + dft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1); + dft4096((int16_t*)(xtmp+1536),(int16_t*)(ytmp+1536),1); for (i=0; i<512; i++) { bfly4_256(ytmpp,ytmpp+512,ytmpp+1024,ytmpp+1536, - y256p,y256p+512,y256p+1024,y256p+1536, - tw16384_256p,tw16384_256p+512,tw16384_256p+1024); + y256p,y256p+512,y256p+1024,y256p+1536, + tw16384_256p,tw16384_256p+512,tw16384_256p+1024); tw16384_256p++; y256p++; ytmpp++; } if (scale>0) { + for (i=0; i<128; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -4851,15 +5516,20 @@ void dft16384(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); + y256+=16; } + } _mm_empty(); _m_empty(); + } -void idft16384(int16_t *x,int16_t *y,unsigned char scale) { +void idft16384(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[2048],ytmp[2048],*tw16384_256p=(simd256_q15_t *)tw16384,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i,j; @@ -4868,21 +5538,23 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) { transpose16_ooff_simd256(x256+i,xtmp+j,512); } - idft4096((int16_t *)(xtmp),(int16_t *)(ytmp),1); - idft4096((int16_t *)(xtmp+512),(int16_t *)(ytmp+512),1); - idft4096((int16_t *)(xtmp+1024),(int16_t *)(ytmp+1024),1); - idft4096((int16_t *)(xtmp+1536),(int16_t *)(ytmp+1536),1); + + idft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1); + idft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1); + idft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1); + idft4096((int16_t*)(xtmp+1536),(int16_t*)(ytmp+1536),1); for (i=0; i<512; i++) { ibfly4_256(ytmpp,ytmpp+512,ytmpp+1024,ytmpp+1536, - y256p,y256p+512,y256p+1024,y256p+1536, - tw16384_256p,tw16384_256p+512,tw16384_256p+1024); + y256p,y256p+512,y256p+1024,y256p+1536, + tw16384_256p,tw16384_256p+512,tw16384_256p+1024); tw16384_256p++; y256p++; ytmpp++; } if (scale>0) { + for (i=0; i<128; i++) { y256[0] = shiftright_int16_simd256(y256[0],1); y256[1] = shiftright_int16_simd256(y256[1],1); @@ -4900,12 +5572,15 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) { y256[13] = shiftright_int16_simd256(y256[13],1); y256[14] = shiftright_int16_simd256(y256[14],1); y256[15] = shiftright_int16_simd256(y256[15],1); + y256+=16; } + } _mm_empty(); _m_empty(); + } #endif //__AVX2__ @@ -4913,16 +5588,19 @@ void idft16384(int16_t *x,int16_t *y,unsigned char scale) { int16_t tw32768[2*16384] __attribute__((aligned(32))); #ifndef __AVX2__ -void dft32768(int16_t *x,int16_t *y,unsigned char scale) { +void dft32768(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[16384],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[8192],*tw32768_128p=(simd_q15_t *)tw32768,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<256; i++) { - transpose4_ooff(x64,xtmpp,8192); + transpose4_ooff(x64 ,xtmpp,8192); transpose4_ooff(x64+2,xtmpp+1,8192); transpose4_ooff(x64+4,xtmpp+2,8192); transpose4_ooff(x64+6,xtmpp+3,8192); @@ -4958,8 +5636,9 @@ void dft32768(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - dft16384((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft16384((int16_t *)(xtmp+8192),(int16_t *)(ytmp+4096),1); + dft16384((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft16384((int16_t*)(xtmp+8192),(int16_t*)(ytmp+4096),1); + for (i=0; i<4096; i++) { bfly2(ytmpp,ytmpp+4096, @@ -4996,18 +5675,22 @@ void dft32768(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } -void idft32768(int16_t *x,int16_t *y,unsigned char scale) { +void idft32768(int16_t *x,int16_t *y,unsigned char scale) +{ + simdshort_q15_t xtmp[16384],*xtmpp,*x64 = (simdshort_q15_t *)x; simd_q15_t ytmp[8192],*tw32768_128p=(simd_q15_t *)tw32768,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<256; i++) { - transpose4_ooff(x64,xtmpp,8192); + transpose4_ooff(x64 ,xtmpp,8192); transpose4_ooff(x64+2,xtmpp+1,8192); transpose4_ooff(x64+4,xtmpp+2,8192); transpose4_ooff(x64+6,xtmpp+3,8192); @@ -5043,8 +5726,9 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - idft16384((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft16384((int16_t *)(xtmp+8192),(int16_t *)(ytmp+4096),1); + idft16384((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft16384((int16_t*)(xtmp+8192),(int16_t*)(ytmp+4096),1); + for (i=0; i<4096; i++) { ibfly2(ytmpp,ytmpp+4096, @@ -5081,19 +5765,24 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } #else // __AVX2__ -void dft32768(int16_t *x,int16_t *y,unsigned char scale) { +void dft32768(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[4096],*xtmpp,*x256 = (simd256_q15_t *)x; simd256_q15_t ytmp[4096],*tw32768_256p=(simd256_q15_t *)tw32768,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; + simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<256; i++) { - transpose4_ooff_simd256(x256,xtmpp,2048); + transpose4_ooff_simd256(x256 ,xtmpp,2048); transpose4_ooff_simd256(x256+2,xtmpp+1,2048); transpose4_ooff_simd256(x256+4,xtmpp+2,2048); transpose4_ooff_simd256(x256+6,xtmpp+3,2048); @@ -5129,13 +5818,14 @@ void dft32768(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - dft16384((int16_t *)(xtmp),(int16_t *)ytmp,1); - dft16384((int16_t *)(xtmp+2048),(int16_t *)(ytmp+2048),1); + dft16384((int16_t*)(xtmp),(int16_t*)ytmp,1); + dft16384((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1); + for (i=0; i<2048; i++) { bfly2_256(ytmpp,ytmpp+2048, - y256p,y256p+2048, - tw32768_256p); + y256p,y256p+2048, + tw32768_256p); tw32768_256p++; y256p++; ytmpp++; @@ -5167,18 +5857,22 @@ void dft32768(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } -void idft32768(int16_t *x,int16_t *y,unsigned char scale) { +void idft32768(int16_t *x,int16_t *y,unsigned char scale) +{ + simd256_q15_t xtmp[4096],*xtmpp,*x256 = (simd256_q15_t *)x; simd256_q15_t ytmp[4096],*tw32768_256p=(simd256_q15_t *)tw32768,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y; simd256_q15_t *ytmpp = &ytmp[0]; int i; simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15); + xtmpp = xtmp; for (i=0; i<64; i++) { - transpose4_ooff_simd256(x256,xtmpp,2048); + transpose4_ooff_simd256(x256 ,xtmpp,2048); transpose4_ooff_simd256(x256+2,xtmpp+1,2048); transpose4_ooff_simd256(x256+4,xtmpp+2,2048); transpose4_ooff_simd256(x256+6,xtmpp+3,2048); @@ -5214,13 +5908,14 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) { xtmpp+=32; } - idft16384((int16_t *)(xtmp),(int16_t *)ytmp,1); - idft16384((int16_t *)(xtmp+2048),(int16_t *)(ytmp+2048),1); + idft16384((int16_t*)(xtmp),(int16_t*)ytmp,1); + idft16384((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1); + for (i=0; i<2048; i++) { ibfly2_256(ytmpp,ytmpp+2048, - y256p,y256p+2048, - tw32768_256p); + y256p,y256p+2048, + tw32768_256p); tw32768_256p++; y256p++; ytmpp++; @@ -5252,6 +5947,7 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) { _mm_empty(); _m_empty(); + } @@ -5261,11 +5957,12 @@ void idft32768(int16_t *x,int16_t *y,unsigned char scale) { int16_t twa1536[1024],twb1536[1024]; // 512 x 3 -void idft1536(int16_t *input, int16_t *output, unsigned char scale) { +void idft1536(int16_t *input, int16_t *output, unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][512 ]__attribute__((aligned(32))); uint32_t tmpo[3][512] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<512; i++) { @@ -5274,16 +5971,17 @@ void idft1536(int16_t *input, int16_t *output, unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft512((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - idft512((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - idft512((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + idft512((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + idft512((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + idft512((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); for (i=0,i2=0; i<1024; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+1024+i),(simd_q15_t *)(output+2048+i), - (simd_q15_t *)(twa1536+i),(simd_q15_t *)(twb1536+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+1024+i),(simd_q15_t*)(output+2048+i), + (simd_q15_t*)(twa1536+i),(simd_q15_t*)(twb1536+i)); } + if (scale==1) { for (i=0; i<24; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -5308,13 +6006,15 @@ void idft1536(int16_t *input, int16_t *output, unsigned char scale) { _mm_empty(); _m_empty(); + } -void dft1536(int16_t *input, int16_t *output, unsigned char scale) { +void dft1536(int16_t *input, int16_t *output, unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][512] __attribute__((aligned(32))); uint32_t tmpo[3][512] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<512; i++) { @@ -5323,9 +6023,9 @@ void dft1536(int16_t *input, int16_t *output, unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft512((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - dft512((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - dft512((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + dft512((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + dft512((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + dft512((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); /* for (i=1; i<512; i++) { @@ -5338,11 +6038,10 @@ void dft1536(int16_t *input, int16_t *output, unsigned char scale) { LOG_M("dft1536out1.m","o1",tmpo[1],2048,1,1); LOG_M("dft1536out2.m","o2",tmpo[2],2048,1,1); } - for (i=0,i2=0; i<1024; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+1024+i),(simd_q15_t *)(output+2048+i), - (simd_q15_t *)(twa1536+i),(simd_q15_t *)(twb1536+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+1024+i),(simd_q15_t*)(output+2048+i), + (simd_q15_t*)(twa1536+i),(simd_q15_t*)(twb1536+i)); } if (scale==1) { @@ -5369,16 +6068,18 @@ void dft1536(int16_t *input, int16_t *output, unsigned char scale) { _mm_empty(); _m_empty(); + } int16_t twa3072[2048] __attribute__((aligned(32))); int16_t twb3072[2048] __attribute__((aligned(32))); // 1024 x 3 -void dft3072(int16_t *input, int16_t *output,unsigned char scale) { +void dft3072(int16_t *input, int16_t *output,unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][1024] __attribute__((aligned(32))); uint32_t tmpo[3][1024] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<1024; i++) { @@ -5387,14 +6088,14 @@ void dft3072(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft1024((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - dft1024((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - dft1024((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + dft1024((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + dft1024((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + dft1024((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); for (i=0,i2=0; i<2048; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+2048+i),(simd_q15_t *)(output+4096+i), - (simd_q15_t *)(twa3072+i),(simd_q15_t *)(twb3072+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+2048+i),(simd_q15_t*)(output+4096+i), + (simd_q15_t*)(twa3072+i),(simd_q15_t*)(twb3072+i)); } if (scale==1) { @@ -5423,11 +6124,12 @@ void dft3072(int16_t *input, int16_t *output,unsigned char scale) { _m_empty(); } -void idft3072(int16_t *input, int16_t *output,unsigned char scale) { +void idft3072(int16_t *input, int16_t *output,unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][1024]__attribute__((aligned(32))); uint32_t tmpo[3][1024] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<1024; i++) { @@ -5435,17 +6137,17 @@ void idft3072(int16_t *input, int16_t *output,unsigned char scale) { tmp[1][i] = ((uint32_t *)input)[j++]; tmp[2][i] = ((uint32_t *)input)[j++]; } - - idft1024((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - idft1024((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - idft1024((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + idft1024((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + idft1024((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + idft1024((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); for (i=0,i2=0; i<2048; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+2048+i),(simd_q15_t *)(output+4096+i), - (simd_q15_t *)(twa3072+i),(simd_q15_t *)(twb3072+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+2048+i),(simd_q15_t*)(output+4096+i), + (simd_q15_t*)(twa3072+i),(simd_q15_t*)(twb3072+i)); } + if (scale==1) { for (i=0; i<48; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -5476,11 +6178,12 @@ void idft3072(int16_t *input, int16_t *output,unsigned char scale) { int16_t twa6144[4096] __attribute__((aligned(32))); int16_t twb6144[4096] __attribute__((aligned(32))); -void idft6144(int16_t *input, int16_t *output,unsigned char scale) { +void idft6144(int16_t *input, int16_t *output,unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][2048] __attribute__((aligned(32))); uint32_t tmpo[3][2048] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<2048; i++) { @@ -5489,9 +6192,9 @@ void idft6144(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft2048((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - idft2048((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - idft2048((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + idft2048((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + idft2048((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + idft2048((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("idft6144in.m","in",input,6144,1,1); @@ -5501,11 +6204,12 @@ void idft6144(int16_t *input, int16_t *output,unsigned char scale) { } for (i=0,i2=0; i<4096; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+4096+i),(simd_q15_t *)(output+8192+i), - (simd_q15_t *)(twa6144+i),(simd_q15_t *)(twb6144+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+4096+i),(simd_q15_t*)(output+8192+i), + (simd_q15_t*)(twa6144+i),(simd_q15_t*)(twb6144+i)); } + if (scale==1) { for (i=0; i<96; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -5530,14 +6234,16 @@ void idft6144(int16_t *input, int16_t *output,unsigned char scale) { _mm_empty(); _m_empty(); + } -void dft6144(int16_t *input, int16_t *output,unsigned char scale) { +void dft6144(int16_t *input, int16_t *output,unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][2048] __attribute__((aligned(32))); uint32_t tmpo[3][2048] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<2048; i++) { @@ -5546,9 +6252,9 @@ void dft6144(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft2048((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - dft2048((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - dft2048((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + dft2048((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + dft2048((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + dft2048((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); /* for (i=1; i<2048; i++) { @@ -5561,11 +6267,10 @@ void dft6144(int16_t *input, int16_t *output,unsigned char scale) { LOG_M("ft6144out1.m","o1",tmpo[1],2048,1,1); LOG_M("ft6144out2.m","o2",tmpo[2],2048,1,1); } - for (i=0,i2=0; i<4096; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+4096+i),(simd_q15_t *)(output+8192+i), - (simd_q15_t *)(twa6144+i),(simd_q15_t *)(twb6144+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+4096+i),(simd_q15_t*)(output+8192+i), + (simd_q15_t*)(twa6144+i),(simd_q15_t*)(twb6144+i)); } if (scale==1) { @@ -5589,30 +6294,33 @@ void dft6144(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } - _mm_empty(); _m_empty(); + } int16_t twa9216[6144] __attribute__((aligned(32))); int16_t twb9216[6144] __attribute__((aligned(32))); // 3072 x 3 void dft9216(int16_t *input, int16_t *output,uint8_t scale) { + AssertFatal(1==0,"Need to do this ..\n"); } void idft9216(int16_t *input, int16_t *output,uint8_t scale) { + AssertFatal(1==0,"Need to do this ..\n"); } int16_t twa12288[8192] __attribute__((aligned(32))); int16_t twb12288[8192] __attribute__((aligned(32))); // 4096 x 3 -void dft12288(int16_t *input, int16_t *output,unsigned char scale) { +void dft12288(int16_t *input, int16_t *output,unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][4096] __attribute__((aligned(32))); uint32_t tmpo[3][4096] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<4096; i++) { @@ -5621,10 +6329,9 @@ void dft12288(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft4096((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),scale); - dft4096((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),scale); - dft4096((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),scale); - + dft4096((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),scale); + dft4096((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),scale); + dft4096((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),scale); /* for (i=1; i<4096; i++) { tmpo[0][i] = tmpo[0][i<<1]; @@ -5636,11 +6343,10 @@ void dft12288(int16_t *input, int16_t *output,unsigned char scale) { LOG_M("dft12288out1.m","o1",tmpo[1],4096,1,1); LOG_M("dft12288out2.m","o2",tmpo[2],4096,1,1); } - for (i=0,i2=0; i<8192; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+8192+i),(simd_q15_t *)(output+16384+i), - (simd_q15_t *)(twa12288+i),(simd_q15_t *)(twb12288+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+8192+i),(simd_q15_t*)(output+16384+i), + (simd_q15_t*)(twa12288+i),(simd_q15_t*)(twb12288+i)); } if (scale==1) { @@ -5664,16 +6370,17 @@ void dft12288(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } - _mm_empty(); _m_empty(); + } -void idft12288(int16_t *input, int16_t *output,unsigned char scale) { +void idft12288(int16_t *input, int16_t *output,unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][4096] __attribute__((aligned(32))); uint32_t tmpo[3][4096] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<4096; i++) { @@ -5682,9 +6389,11 @@ void idft12288(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft4096((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),scale); - idft4096((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),scale); - idft4096((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),scale); + + + idft4096((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),scale); + idft4096((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),scale); + idft4096((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),scale); if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("idft12288in.m","in",input,12288,1,1); @@ -5694,9 +6403,9 @@ void idft12288(int16_t *input, int16_t *output,unsigned char scale) { } for (i=0,i2=0; i<8192; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+8192+i),(simd_q15_t *)(output+16384+i), - (simd_q15_t *)(twa12288+i),(simd_q15_t *)(twb12288+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+8192+i),(simd_q15_t*)(output+16384+i), + (simd_q15_t*)(twa12288+i),(simd_q15_t*)(twb12288+i)); } if (scale==1) { @@ -5720,12 +6429,10 @@ void idft12288(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } - _mm_empty(); _m_empty(); - if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("idft12288out.m","out",output,6144,1,1); + LOG_M("idft12288out.m","out",output,6144,1,1); } } @@ -5733,10 +6440,11 @@ int16_t twa18432[12288] __attribute__((aligned(32))); int16_t twb18432[12288] __attribute__((aligned(32))); // 6144 x 3 void dft18432(int16_t *input, int16_t *output,unsigned char scale) { + int i,i2,j; uint32_t tmp[3][6144] __attribute__((aligned(32))); uint32_t tmpo[3][6144] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<6144; i++) { @@ -5745,16 +6453,15 @@ void dft18432(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft6144((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),scale); - dft6144((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),scale); - dft6144((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),scale); + dft6144((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),scale); + dft6144((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),scale); + dft6144((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),scale); for (i=0,i2=0; i<12288; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+12288+i),(simd_q15_t *)(output+24576+i), - (simd_q15_t *)(twa18432+i),(simd_q15_t *)(twb18432+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+12288+i),(simd_q15_t*)(output+24576+i), + (simd_q15_t*)(twa18432+i),(simd_q15_t*)(twb18432+i)); } - if (scale==1) { for (i=0; i<288; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -5776,16 +6483,16 @@ void dft18432(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } - _mm_empty(); _m_empty(); } void idft18432(int16_t *input, int16_t *output,unsigned char scale) { + int i,i2,j; uint32_t tmp[3][6144] __attribute__((aligned(32))); uint32_t tmpo[3][6144] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<6144; i++) { @@ -5794,16 +6501,15 @@ void idft18432(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft6144((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),scale); - idft6144((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),scale); - idft6144((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),scale); + idft6144((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),scale); + idft6144((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),scale); + idft6144((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),scale); for (i=0,i2=0; i<12288; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+12288+i),(simd_q15_t *)(output+24576+i), - (simd_q15_t *)(twa18432+i),(simd_q15_t *)(twb18432+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+12288+i),(simd_q15_t*)(output+24576+i), + (simd_q15_t*)(twa18432+i),(simd_q15_t*)(twb18432+i)); } - if (scale==1) { for (i=0; i<288; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -5825,7 +6531,6 @@ void idft18432(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } - _mm_empty(); _m_empty(); } @@ -5834,11 +6539,12 @@ void idft18432(int16_t *input, int16_t *output,unsigned char scale) { int16_t twa24576[16384] __attribute__((aligned(32))); int16_t twb24576[16384] __attribute__((aligned(32))); // 8192 x 3 -void dft24576(int16_t *input, int16_t *output,unsigned char scale) { +void dft24576(int16_t *input, int16_t *output,unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][8192] __attribute__((aligned(32))); uint32_t tmpo[3][8192] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<8192; i++) { @@ -5847,10 +6553,9 @@ void dft24576(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft8192((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - dft8192((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - dft8192((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); - + dft8192((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + dft8192((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + dft8192((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); /* for (i=1; i<8192; i++) { tmpo[0][i] = tmpo[0][i<<1]; @@ -5862,13 +6567,13 @@ void dft24576(int16_t *input, int16_t *output,unsigned char scale) { LOG_M("dft24576out1.m","o1",tmpo[1],8192,1,1); LOG_M("dft24576out2.m","o2",tmpo[2],8192,1,1); } - for (i=0,i2=0; i<16384; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+16384+i),(simd_q15_t *)(output+32768+i), - (simd_q15_t *)(twa24576+i),(simd_q15_t *)(twb24576+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+16384+i),(simd_q15_t*)(output+32768+i), + (simd_q15_t*)(twa24576+i),(simd_q15_t*)(twb24576+i)); } + if (scale==1) { for (i=0; i<384; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -5890,20 +6595,19 @@ void dft24576(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } - _mm_empty(); _m_empty(); - if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("out.m","out",output,24576,1,1); + LOG_M("out.m","out",output,24576,1,1); } } -void idft24576(int16_t *input, int16_t *output,unsigned char scale) { +void idft24576(int16_t *input, int16_t *output,unsigned char scale) +{ int i,i2,j; uint32_t tmp[3][8192] __attribute__((aligned(32))); uint32_t tmpo[3][8192] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<8192; i++) { @@ -5912,10 +6616,10 @@ void idft24576(int16_t *input, int16_t *output,unsigned char scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft8192((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - idft8192((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - idft8192((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); - + idft8192((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + idft8192((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + idft8192((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); + if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("idft24576in.m","in",input,24576,1,1); LOG_M("idft24576out0.m","o0",tmpo[0],8192,1,1); @@ -5924,11 +6628,10 @@ void idft24576(int16_t *input, int16_t *output,unsigned char scale) { } for (i=0,i2=0; i<16384; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+16384+i),(simd_q15_t *)(output+32768+i), - (simd_q15_t *)(twa24576+i),(simd_q15_t *)(twb24576+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+16384+i),(simd_q15_t*)(output+32768+i), + (simd_q15_t*)(twa24576+i),(simd_q15_t*)(twb24576+i)); } - if (scale==1) { for (i=0; i<384; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -5950,7 +6653,6 @@ void idft24576(int16_t *input, int16_t *output,unsigned char scale) { y128p+=16; } } - _mm_empty(); _m_empty(); @@ -5964,10 +6666,11 @@ int16_t twb36864[24576] __attribute__((aligned(32))); // 12288 x 3 void dft36864(int16_t *input, int16_t *output,uint8_t scale) { + int i,i2,j; uint32_t tmp[3][12288] __attribute__((aligned(32))); uint32_t tmpo[3][12288] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<12288; i++) { @@ -5976,9 +6679,9 @@ void dft36864(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft12288((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - dft12288((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - dft12288((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + dft12288((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + dft12288((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + dft12288((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); if (LOG_DUMPFLAG(DEBUG_DFT)) { LOG_M("dft36864out0.m","o0",tmpo[0],12288,1,1); @@ -5987,9 +6690,9 @@ void dft36864(int16_t *input, int16_t *output,uint8_t scale) { } for (i=0,i2=0; i<24576; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),(simd_q15_t *)(&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+24576+i),(simd_q15_t *)(output+49152+i), - (simd_q15_t *)(twa36864+i),(simd_q15_t *)(twb36864+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+24576+i),(simd_q15_t*)(output+49152+i), + (simd_q15_t*)(twa36864+i),(simd_q15_t*)(twb36864+i)); } if (scale==1) { @@ -6013,20 +6716,19 @@ void dft36864(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } - _mm_empty(); _m_empty(); - if (LOG_DUMPFLAG(DEBUG_DFT)) { - LOG_M("out.m","out",output,36864,1,1); + LOG_M("out.m","out",output,36864,1,1); } } void idft36864(int16_t *input, int16_t *output,uint8_t scale) { + int i,i2,j; uint32_t tmp[3][12288] __attribute__((aligned(32))); uint32_t tmpo[3][12288] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<12288; i++) { @@ -6035,16 +6737,15 @@ void idft36864(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft12288((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - idft12288((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - idft12288((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + idft12288((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + idft12288((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + idft12288((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); for (i=0,i2=0; i<24576; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+24576+i),(simd_q15_t *)(output+49152+i), - (simd_q15_t *)(twa36864+i),(simd_q15_t *)(twb36864+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+24576+i),(simd_q15_t*)(output+49152+i), + (simd_q15_t*)(twa36864+i),(simd_q15_t*)(twb36864+i)); } - if (scale==1) { for (i=0; i<576; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6066,7 +6767,6 @@ void idft36864(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } - _mm_empty(); _m_empty(); } @@ -6076,10 +6776,11 @@ int16_t twb49152[32768] __attribute__((aligned(32))); // 16384 x 3 void dft49152(int16_t *input, int16_t *output,uint8_t scale) { + int i,i2,j; uint32_t tmp[3][16384] __attribute__((aligned(32))); uint32_t tmpo[3][16384] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<16384; i++) { @@ -6088,16 +6789,15 @@ void dft49152(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft16384((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - dft16384((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - dft16384((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + dft16384((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + dft16384((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + dft16384((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); for (i=0,i2=0; i<32768; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+32768+i),(simd_q15_t *)(output+65536+i), - (simd_q15_t *)(twa49152+i),(simd_q15_t *)(twb49152+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+32768+i),(simd_q15_t*)(output+65536+i), + (simd_q15_t*)(twa49152+i),(simd_q15_t*)(twb49152+i)); } - if (scale==1) { for (i=0; i<768; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6119,16 +6819,17 @@ void dft49152(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } - _mm_empty(); _m_empty(); + } void idft49152(int16_t *input, int16_t *output,uint8_t scale) { - int i,i2,j; + + int i,i2,j; uint32_t tmp[3][16384] __attribute__((aligned(32))); uint32_t tmpo[3][16384] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<16384; i++) { @@ -6137,16 +6838,15 @@ void idft49152(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft16384((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - idft16384((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - idft16384((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + idft16384((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + idft16384((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + idft16384((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); for (i=0,i2=0; i<32768; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+32768+i),(simd_q15_t *)(output+65536+i), - (simd_q15_t *)(twa49152+i),(simd_q15_t *)(twb49152+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+32768+i),(simd_q15_t*)(output+65536+i), + (simd_q15_t*)(twa49152+i),(simd_q15_t*)(twb49152+i)); } - if (scale==1) { for (i=0; i<768; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6168,7 +6868,6 @@ void idft49152(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } - _mm_empty(); _m_empty(); } @@ -6177,10 +6876,12 @@ int16_t twa73728[49152] __attribute__((aligned(32))); int16_t twb73728[49152] __attribute__((aligned(32))); // 24576 x 3 void dft73728(int16_t *input, int16_t *output,uint8_t scale) { + AssertFatal(1==0,"Need to do this ..\n"); } void idft73728(int16_t *input, int16_t *output,uint8_t scale) { + AssertFatal(1==0,"Need to do this ..\n"); } @@ -6189,10 +6890,11 @@ int16_t twa98304[65536] __attribute__((aligned(32))); int16_t twb98304[65536] __attribute__((aligned(32))); // 32768 x 3 void dft98304(int16_t *input, int16_t *output,uint8_t scale) { + int i,i2,j; uint32_t tmp[3][32768] __attribute__((aligned(32))); uint32_t tmpo[3][32768] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<32768; i++) { @@ -6201,16 +6903,15 @@ void dft98304(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - dft32768((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - dft32768((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - dft32768((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + dft32768((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + dft32768((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + dft32768((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); for (i=0,i2=0; i<65536; i+=8,i2+=4) { - bfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+65536+i),(simd_q15_t *)(output+131072+i), - (simd_q15_t *)(twa98304+i),(simd_q15_t *)(twb98304+i)); + bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+65536+i),(simd_q15_t*)(output+131072+i), + (simd_q15_t*)(twa98304+i),(simd_q15_t*)(twb98304+i)); } - if (scale==1) { for (i=0; i<1536; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6232,16 +6933,17 @@ void dft98304(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } - _mm_empty(); _m_empty(); + } void idft98304(int16_t *input, int16_t *output,uint8_t scale) { + int i,i2,j; uint32_t tmp[3][32768] __attribute__((aligned(32))); uint32_t tmpo[3][32768] __attribute__((aligned(32))); - simd_q15_t *y128p=(simd_q15_t *)output; + simd_q15_t *y128p=(simd_q15_t*)output; simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15); for (i=0,j=0; i<32768; i++) { @@ -6250,16 +6952,15 @@ void idft98304(int16_t *input, int16_t *output,uint8_t scale) { tmp[2][i] = ((uint32_t *)input)[j++]; } - idft32768((int16_t *)(tmp[0]),(int16_t *)(tmpo[0]),1); - idft32768((int16_t *)(tmp[1]),(int16_t *)(tmpo[1]),1); - idft32768((int16_t *)(tmp[2]),(int16_t *)(tmpo[2]),1); + idft32768((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1); + idft32768((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1); + idft32768((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1); for (i=0,i2=0; i<65536; i+=8,i2+=4) { - ibfly3((simd_q15_t *)(&tmpo[0][i2]),(simd_q15_t *)(&tmpo[1][i2]),((simd_q15_t *)&tmpo[2][i2]), - (simd_q15_t *)(output+i),(simd_q15_t *)(output+65536+i),(simd_q15_t *)(output+131072+i), - (simd_q15_t *)(twa98304+i),(simd_q15_t *)(twb98304+i)); + ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]), + (simd_q15_t*)(output+i),(simd_q15_t*)(output+65536+i),(simd_q15_t*)(output+131072+i), + (simd_q15_t*)(twa98304+i),(simd_q15_t*)(twb98304+i)); } - if (scale==1) { for (i=0; i<1536; i++) { y128p[0] = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128); @@ -6281,12 +6982,11 @@ void idft98304(int16_t *input, int16_t *output,uint8_t scale) { y128p+=16; } } - _mm_empty(); _m_empty(); } - + /// THIS SECTION IS FOR ALL PUSCH DFTS (i.e. radix 2^a * 3^b * 4^c * 5^d) /// They use twiddles for 4-way parallel DFTS (i.e. 4 DFTS with interleaved input/output) @@ -6353,10 +7053,16 @@ static inline void dft12f(simd_q15_t *x0, simd_q15_t *y8, simd_q15_t *y9, simd_q15_t *y10, - simd_q15_t *y11) { + simd_q15_t *y11) +{ + + simd_q15_t tmp_dft12[12]; + simd_q15_t *tmp_dft12_ptr = &tmp_dft12[0]; + // msg("dft12\n"); + bfly4_tw1(x0, x3, x6, @@ -6365,6 +7071,8 @@ static inline void dft12f(simd_q15_t *x0, tmp_dft12_ptr+3, tmp_dft12_ptr+6, tmp_dft12_ptr+9); + + bfly4_tw1(x1, x4, x7, @@ -6373,6 +7081,8 @@ static inline void dft12f(simd_q15_t *x0, tmp_dft12_ptr+4, tmp_dft12_ptr+7, tmp_dft12_ptr+10); + + bfly4_tw1(x2, x5, x8, @@ -6381,6 +7091,7 @@ static inline void dft12f(simd_q15_t *x0, tmp_dft12_ptr+5, tmp_dft12_ptr+8, tmp_dft12_ptr+11); + // k2=0; bfly3_tw1(tmp_dft12_ptr, tmp_dft12_ptr+1, @@ -6388,6 +7099,9 @@ static inline void dft12f(simd_q15_t *x0, y0, y4, y8); + + + // k2=1; bfly3(tmp_dft12_ptr+3, tmp_dft12_ptr+4, @@ -6397,6 +7111,9 @@ static inline void dft12f(simd_q15_t *x0, y9, W1_12, W2_12); + + + // k2=2; bfly3(tmp_dft12_ptr+6, tmp_dft12_ptr+7, @@ -6406,6 +7123,7 @@ static inline void dft12f(simd_q15_t *x0, y10, W2_12, W4_12); + // k2=3; bfly3(tmp_dft12_ptr+9, tmp_dft12_ptr+10, @@ -6415,12 +7133,15 @@ static inline void dft12f(simd_q15_t *x0, y11, W3_12, W6_12); + } -void dft12(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft12(int16_t *x,int16_t *y ,unsigned char scale_flag) +{ + simd_q15_t *x128 = (simd_q15_t *)x,*y128 = (simd_q15_t *)y; dft12f(&x128[0], &x128[1], @@ -6446,8 +7167,10 @@ void dft12(int16_t *x,int16_t *y,unsigned char scale_flag) { &y128[9], &y128[10], &y128[11]); + _mm_empty(); _m_empty(); + } #ifdef __AVX2__ @@ -6467,160 +7190,186 @@ simd256_q15_t *W6_12_256=(simd256_q15_t *)W6_12s_256; static inline void dft12f_simd256(simd256_q15_t *x0, - simd256_q15_t *x1, - simd256_q15_t *x2, - simd256_q15_t *x3, - simd256_q15_t *x4, - simd256_q15_t *x5, - simd256_q15_t *x6, - simd256_q15_t *x7, - simd256_q15_t *x8, - simd256_q15_t *x9, - simd256_q15_t *x10, - simd256_q15_t *x11, - simd256_q15_t *y0, - simd256_q15_t *y1, - simd256_q15_t *y2, - simd256_q15_t *y3, - simd256_q15_t *y4, - simd256_q15_t *y5, - simd256_q15_t *y6, - simd256_q15_t *y7, - simd256_q15_t *y8, - simd256_q15_t *y9, - simd256_q15_t *y10, - simd256_q15_t *y11) __attribute__((always_inline)); + simd256_q15_t *x1, + simd256_q15_t *x2, + simd256_q15_t *x3, + simd256_q15_t *x4, + simd256_q15_t *x5, + simd256_q15_t *x6, + simd256_q15_t *x7, + simd256_q15_t *x8, + simd256_q15_t *x9, + simd256_q15_t *x10, + simd256_q15_t *x11, + simd256_q15_t *y0, + simd256_q15_t *y1, + simd256_q15_t *y2, + simd256_q15_t *y3, + simd256_q15_t *y4, + simd256_q15_t *y5, + simd256_q15_t *y6, + simd256_q15_t *y7, + simd256_q15_t *y8, + simd256_q15_t *y9, + simd256_q15_t *y10, + simd256_q15_t *y11) __attribute__((always_inline)); static inline void dft12f_simd256(simd256_q15_t *x0, - simd256_q15_t *x1, - simd256_q15_t *x2, - simd256_q15_t *x3, - simd256_q15_t *x4, - simd256_q15_t *x5, - simd256_q15_t *x6, - simd256_q15_t *x7, - simd256_q15_t *x8, - simd256_q15_t *x9, - simd256_q15_t *x10, - simd256_q15_t *x11, - simd256_q15_t *y0, - simd256_q15_t *y1, - simd256_q15_t *y2, - simd256_q15_t *y3, - simd256_q15_t *y4, - simd256_q15_t *y5, - simd256_q15_t *y6, - simd256_q15_t *y7, - simd256_q15_t *y8, - simd256_q15_t *y9, - simd256_q15_t *y10, - simd256_q15_t *y11) { + simd256_q15_t *x1, + simd256_q15_t *x2, + simd256_q15_t *x3, + simd256_q15_t *x4, + simd256_q15_t *x5, + simd256_q15_t *x6, + simd256_q15_t *x7, + simd256_q15_t *x8, + simd256_q15_t *x9, + simd256_q15_t *x10, + simd256_q15_t *x11, + simd256_q15_t *y0, + simd256_q15_t *y1, + simd256_q15_t *y2, + simd256_q15_t *y3, + simd256_q15_t *y4, + simd256_q15_t *y5, + simd256_q15_t *y6, + simd256_q15_t *y7, + simd256_q15_t *y8, + simd256_q15_t *y9, + simd256_q15_t *y10, + simd256_q15_t *y11) +{ + + simd256_q15_t tmp_dft12[12]; + simd256_q15_t *tmp_dft12_ptr = &tmp_dft12[0]; + // msg("dft12\n"); + bfly4_tw1_256(x0, - x3, - x6, - x9, - tmp_dft12_ptr, - tmp_dft12_ptr+3, - tmp_dft12_ptr+6, - tmp_dft12_ptr+9); + x3, + x6, + x9, + tmp_dft12_ptr, + tmp_dft12_ptr+3, + tmp_dft12_ptr+6, + tmp_dft12_ptr+9); + + bfly4_tw1_256(x1, - x4, - x7, - x10, - tmp_dft12_ptr+1, - tmp_dft12_ptr+4, - tmp_dft12_ptr+7, - tmp_dft12_ptr+10); + x4, + x7, + x10, + tmp_dft12_ptr+1, + tmp_dft12_ptr+4, + tmp_dft12_ptr+7, + tmp_dft12_ptr+10); + + bfly4_tw1_256(x2, - x5, - x8, - x11, - tmp_dft12_ptr+2, - tmp_dft12_ptr+5, - tmp_dft12_ptr+8, - tmp_dft12_ptr+11); + x5, + x8, + x11, + tmp_dft12_ptr+2, + tmp_dft12_ptr+5, + tmp_dft12_ptr+8, + tmp_dft12_ptr+11); + // k2=0; bfly3_tw1_256(tmp_dft12_ptr, - tmp_dft12_ptr+1, - tmp_dft12_ptr+2, - y0, - y4, - y8); + tmp_dft12_ptr+1, + tmp_dft12_ptr+2, + y0, + y4, + y8); + + + // k2=1; bfly3_256(tmp_dft12_ptr+3, - tmp_dft12_ptr+4, - tmp_dft12_ptr+5, - y1, - y5, - y9, - W1_12_256, - W2_12_256); + tmp_dft12_ptr+4, + tmp_dft12_ptr+5, + y1, + y5, + y9, + W1_12_256, + W2_12_256); + + + // k2=2; bfly3_256(tmp_dft12_ptr+6, - tmp_dft12_ptr+7, - tmp_dft12_ptr+8, - y2, - y6, - y10, - W2_12_256, - W4_12_256); + tmp_dft12_ptr+7, + tmp_dft12_ptr+8, + y2, + y6, + y10, + W2_12_256, + W4_12_256); + // k2=3; bfly3_256(tmp_dft12_ptr+9, - tmp_dft12_ptr+10, - tmp_dft12_ptr+11, - y3, - y7, - y11, - W3_12_256, - W6_12_256); + tmp_dft12_ptr+10, + tmp_dft12_ptr+11, + y3, + y7, + y11, + W3_12_256, + W6_12_256); + } -void dft12_simd256(int16_t *x,int16_t *y) { +void dft12_simd256(int16_t *x,int16_t *y) +{ + simd256_q15_t *x256 = (simd256_q15_t *)x,*y256 = (simd256_q15_t *)y; dft12f_simd256(&x256[0], - &x256[1], - &x256[2], - &x256[3], - &x256[4], - &x256[5], - &x256[6], - &x256[7], - &x256[8], - &x256[9], - &x256[10], - &x256[11], - &y256[0], - &y256[1], - &y256[2], - &y256[3], - &y256[4], - &y256[5], - &y256[6], - &y256[7], - &y256[8], - &y256[9], - &y256[10], - &y256[11]); + &x256[1], + &x256[2], + &x256[3], + &x256[4], + &x256[5], + &x256[6], + &x256[7], + &x256[8], + &x256[9], + &x256[10], + &x256[11], + &y256[0], + &y256[1], + &y256[2], + &y256[3], + &y256[4], + &y256[5], + &y256[6], + &y256[7], + &y256[8], + &y256[9], + &y256[10], + &y256[11]); + _mm_empty(); _m_empty(); + } #endif static int16_t tw24[88]__attribute__((aligned(32))); -void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *tw128=(simd_q15_t *)&tw24[0]; simd_q15_t ytmp128[24];//=&ytmp128array[0]; int i,j,k; + // msg("dft24\n"); dft12f(x128, x128+2, @@ -6647,6 +7396,7 @@ void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) { ytmp128+20, ytmp128+22); // msg("dft24b\n"); + dft12f(x128+1, x128+3, x128+5, @@ -6671,7 +7421,9 @@ void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) { ytmp128+19, ytmp128+21, ytmp128+23); + // msg("dft24c\n"); + bfly2_tw1(ytmp128, ytmp128+1, y128, @@ -6680,6 +7432,7 @@ void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) { // msg("dft24d\n"); for (i=2,j=1,k=0; i<24; i+=2,j++,k++) { + bfly2(ytmp128+i, ytmp128+i+1, y128+j, @@ -6698,18 +7451,24 @@ void dft24(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa36[88]__attribute__((aligned(32))); static int16_t twb36[88]__attribute__((aligned(32))); -void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *twa128=(simd_q15_t *)&twa36[0]; simd_q15_t *twb128=(simd_q15_t *)&twb36[0]; simd_q15_t ytmp128[36];//&ytmp128array[0]; + + int i,j,k; + dft12f(x128, x128+3, x128+6, @@ -6734,6 +7493,7 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) { ytmp128+27, ytmp128+30, ytmp128+33); + dft12f(x128+1, x128+4, x128+7, @@ -6758,6 +7518,7 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) { ytmp128+28, ytmp128+31, ytmp128+34); + dft12f(x128+2, x128+5, x128+8, @@ -6782,6 +7543,8 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) { ytmp128+29, ytmp128+32, ytmp128+35); + + bfly3_tw1(ytmp128, ytmp128+1, ytmp128+2, @@ -6790,6 +7553,7 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) { y128+24); for (i=3,j=1,k=0; i<36; i+=3,j++,k++) { + bfly3(ytmp128+i, ytmp128+i+1, ytmp128+i+2, @@ -6810,13 +7574,16 @@ void dft36(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa48[88]__attribute__((aligned(32))); static int16_t twb48[88]__attribute__((aligned(32))); static int16_t twc48[88]__attribute__((aligned(32))); -void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { +void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) +{ + simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *twa128=(simd_q15_t *)&twa48[0]; @@ -6824,6 +7591,8 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { simd_q15_t *twc128=(simd_q15_t *)&twc48[0]; simd_q15_t ytmp128[48];//=&ytmp128array[0]; int i,j,k; + + dft12f(x128, x128+4, x128+8, @@ -6848,6 +7617,8 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { ytmp128+36, ytmp128+40, ytmp128+44); + + dft12f(x128+1, x128+5, x128+9, @@ -6872,6 +7643,8 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { ytmp128+37, ytmp128+41, ytmp128+45); + + dft12f(x128+2, x128+6, x128+10, @@ -6896,6 +7669,8 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { ytmp128+38, ytmp128+42, ytmp128+46); + + dft12f(x128+3, x128+7, x128+11, @@ -6920,6 +7695,9 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { ytmp128+39, ytmp128+43, ytmp128+47); + + + bfly4_tw1(ytmp128, ytmp128+1, ytmp128+2, @@ -6929,7 +7707,10 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { y128+24, y128+36); + + for (i=4,j=1,k=0; i<48; i+=4,j++,k++) { + bfly4(ytmp128+i, ytmp128+i+1, ytmp128+i+2, @@ -6941,6 +7722,7 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { twa128+k, twb128+k, twc128+k); + } if (scale_flag == 1) { @@ -6953,6 +7735,7 @@ void dft48(int16_t *x, int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa60[88]__attribute__((aligned(32))); @@ -6960,7 +7743,9 @@ static int16_t twb60[88]__attribute__((aligned(32))); static int16_t twc60[88]__attribute__((aligned(32))); static int16_t twd60[88]__attribute__((aligned(32))); -void dft60(int16_t *x,int16_t *y,unsigned char scale) { +void dft60(int16_t *x,int16_t *y,unsigned char scale) +{ + simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *twa128=(simd_q15_t *)&twa60[0]; @@ -6969,6 +7754,7 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) { simd_q15_t *twd128=(simd_q15_t *)&twd60[0]; simd_q15_t ytmp128[60];//=&ytmp128array[0]; int i,j,k; + dft12f(x128, x128+5, x128+10, @@ -6993,6 +7779,7 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) { ytmp128+45, ytmp128+50, ytmp128+55); + dft12f(x128+1, x128+6, x128+11, @@ -7017,6 +7804,7 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) { ytmp128+46, ytmp128+51, ytmp128+56); + dft12f(x128+2, x128+7, x128+12, @@ -7041,6 +7829,7 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) { ytmp128+47, ytmp128+52, ytmp128+57); + dft12f(x128+3, x128+8, x128+13, @@ -7065,6 +7854,7 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) { ytmp128+48, ytmp128+53, ytmp128+58); + dft12f(x128+4, x128+9, x128+14, @@ -7089,6 +7879,7 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) { ytmp128+49, ytmp128+54, ytmp128+59); + bfly5_tw1(ytmp128, ytmp128+1, ytmp128+2, @@ -7101,6 +7892,7 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) { y128+48); for (i=5,j=1,k=0; i<60; i+=5,j++,k++) { + bfly5(ytmp128+i, ytmp128+i+1, ytmp128+i+2, @@ -7122,22 +7914,26 @@ void dft60(int16_t *x,int16_t *y,unsigned char scale) { for (i=0; i<60; i++) { y128[i] = mulhi_int16(y128[i],norm128); - // printf("y[%d] = (%d,%d)\n",i,((int16_t*)&y128[i])[0],((int16_t*)&y128[i])[1]); +// printf("y[%d] = (%d,%d)\n",i,((int16_t*)&y128[i])[0],((int16_t*)&y128[i])[1]); } } _mm_empty(); _m_empty(); + } static int16_t tw72[280]__attribute__((aligned(32))); -void dft72(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft72(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; simd_q15_t *tw128=(simd_q15_t *)&tw72[0]; simd_q15_t x2128[72];// = (simd_q15_t *)&x2128array[0]; + simd_q15_t ytmp128[72];//=&ytmp128array2[0]; for (i=0,j=0; i<36; i++,j+=2) { @@ -7147,6 +7943,7 @@ void dft72(int16_t *x,int16_t *y,unsigned char scale_flag) { dft36((int16_t *)x2128,(int16_t *)ytmp128,1); dft36((int16_t *)(x2128+36),(int16_t *)(ytmp128+36),1); + bfly2_tw1(ytmp128,ytmp128+36,y128,y128+36); for (i=1,j=0; i<36; i++,j++) { @@ -7167,11 +7964,15 @@ void dft72(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t tw96[376]__attribute__((aligned(32))); -void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7179,6 +7980,7 @@ void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[96];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[96];//=&ytmp128array2[0]; + for (i=0,j=0; i<48; i++,j+=2) { x2128[i] = x128[j]; x2128[i+48] = x128[j+1]; @@ -7186,6 +7988,8 @@ void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) { dft48((int16_t *)x2128,(int16_t *)ytmp128,0); dft48((int16_t *)(x2128+48),(int16_t *)(ytmp128+48),0); + + bfly2_tw1(ytmp128,ytmp128+48,y128,y128+48); for (i=1,j=0; i<48; i++,j++) { @@ -7206,12 +8010,14 @@ void dft96(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa108[280]__attribute__((aligned(32))); static int16_t twb108[280]__attribute__((aligned(32))); -void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7220,6 +8026,7 @@ void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[108];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[108];//=&ytmp128array2[0]; + for (i=0,j=0; i<36; i++,j+=3) { x2128[i] = x128[j]; x2128[i+36] = x128[j+1]; @@ -7229,6 +8036,7 @@ void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) { dft36((int16_t *)x2128,(int16_t *)ytmp128,0); dft36((int16_t *)(x2128+36),(int16_t *)(ytmp128+36),0); dft36((int16_t *)(x2128+72),(int16_t *)(ytmp128+72),0); + bfly3_tw1(ytmp128,ytmp128+36,ytmp128+72,y128,y128+36,y128+72); for (i=1,j=0; i<36; i++,j++) { @@ -7240,6 +8048,7 @@ void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) { y128+72+i, twa128+j, twb128+j); + } if (scale_flag==1) { @@ -7252,10 +8061,12 @@ void dft108(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t tw120[472]__attribute__((aligned(32))); -void dft120(int16_t *x,int16_t *y, unsigned char scale_flag) { +void dft120(int16_t *x,int16_t *y, unsigned char scale_flag) +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7270,6 +8081,8 @@ void dft120(int16_t *x,int16_t *y, unsigned char scale_flag) { dft60((int16_t *)x2128,(int16_t *)ytmp128,0); dft60((int16_t *)(x2128+60),(int16_t *)(ytmp128+60),0); + + bfly2_tw1(ytmp128,ytmp128+60,y128,y128+60); for (i=1,j=0; i<60; i++,j++) { @@ -7290,12 +8103,14 @@ void dft120(int16_t *x,int16_t *y, unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa144[376]__attribute__((aligned(32))); static int16_t twb144[376]__attribute__((aligned(32))); -void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7304,6 +8119,8 @@ void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[144];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[144];//=&ytmp128array2[0]; + + for (i=0,j=0; i<48; i++,j+=3) { x2128[i] = x128[j]; x2128[i+48] = x128[j+1]; @@ -7313,6 +8130,7 @@ void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) { dft48((int16_t *)x2128,(int16_t *)ytmp128,1); dft48((int16_t *)(x2128+48),(int16_t *)(ytmp128+48),1); dft48((int16_t *)(x2128+96),(int16_t *)(ytmp128+96),1); + bfly3_tw1(ytmp128,ytmp128+48,ytmp128+96,y128,y128+48,y128+96); for (i=1,j=0; i<48; i++,j++) { @@ -7336,12 +8154,15 @@ void dft144(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa180[472]__attribute__((aligned(32))); static int16_t twb180[472]__attribute__((aligned(32))); -void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7350,6 +8171,8 @@ void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[180];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[180];//=&ytmp128array2[0]; + + for (i=0,j=0; i<60; i++,j+=3) { x2128[i] = x128[j]; x2128[i+60] = x128[j+1]; @@ -7359,6 +8182,7 @@ void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) { dft60((int16_t *)x2128,(int16_t *)ytmp128,1); dft60((int16_t *)(x2128+60),(int16_t *)(ytmp128+60),1); dft60((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); + bfly3_tw1(ytmp128,ytmp128+60,ytmp128+120,y128,y128+60,y128+120); for (i=1,j=0; i<60; i++,j++) { @@ -7382,13 +8206,16 @@ void dft180(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa192[376]__attribute__((aligned(32))); static int16_t twb192[376]__attribute__((aligned(32))); static int16_t twc192[376]__attribute__((aligned(32))); -void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7398,6 +8225,8 @@ void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[192];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[192];//=&ytmp128array2[0]; + + for (i=0,j=0; i<48; i++,j+=4) { x2128[i] = x128[j]; x2128[i+48] = x128[j+1]; @@ -7409,6 +8238,7 @@ void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) { dft48((int16_t *)(x2128+48),(int16_t *)(ytmp128+48),1); dft48((int16_t *)(x2128+96),(int16_t *)(ytmp128+96),1); dft48((int16_t *)(x2128+144),(int16_t *)(ytmp128+144),1); + bfly4_tw1(ytmp128,ytmp128+48,ytmp128+96,ytmp128+144,y128,y128+48,y128+96,y128+144); for (i=1,j=0; i<48; i++,j++) { @@ -7435,12 +8265,15 @@ void dft192(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa216[568]__attribute__((aligned(32))); static int16_t twb216[568]__attribute__((aligned(32))); -void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7449,6 +8282,8 @@ void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[216];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[216];//=&ytmp128array3[0]; + + for (i=0,j=0; i<72; i++,j+=3) { x2128[i] = x128[j]; x2128[i+72] = x128[j+1]; @@ -7458,6 +8293,7 @@ void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) { dft72((int16_t *)x2128,(int16_t *)ytmp128,1); dft72((int16_t *)(x2128+72),(int16_t *)(ytmp128+72),1); dft72((int16_t *)(x2128+144),(int16_t *)(ytmp128+144),1); + bfly3_tw1(ytmp128,ytmp128+72,ytmp128+144,y128,y128+72,y128+144); for (i=1,j=0; i<72; i++,j++) { @@ -7481,13 +8317,16 @@ void dft216(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa240[472]__attribute__((aligned(32))); static int16_t twb240[472]__attribute__((aligned(32))); static int16_t twc240[472]__attribute__((aligned(32))); -void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7497,6 +8336,8 @@ void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[240];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[240];//=&ytmp128array2[0]; + + for (i=0,j=0; i<60; i++,j+=4) { x2128[i] = x128[j]; x2128[i+60] = x128[j+1]; @@ -7508,6 +8349,7 @@ void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) { dft60((int16_t *)(x2128+60),(int16_t *)(ytmp128+60),1); dft60((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); dft60((int16_t *)(x2128+180),(int16_t *)(ytmp128+180),1); + bfly4_tw1(ytmp128,ytmp128+60,ytmp128+120,ytmp128+180,y128,y128+60,y128+120,y128+180); for (i=1,j=0; i<60; i++,j++) { @@ -7534,12 +8376,15 @@ void dft240(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa288[760]__attribute__((aligned(32))); static int16_t twb288[760]__attribute__((aligned(32))); -void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7548,6 +8393,8 @@ void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[288];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[288];//=&ytmp128array3[0]; + + for (i=0,j=0; i<96; i++,j+=3) { x2128[i] = x128[j]; x2128[i+96] = x128[j+1]; @@ -7557,6 +8404,7 @@ void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) { dft96((int16_t *)x2128,(int16_t *)ytmp128,1); dft96((int16_t *)(x2128+96),(int16_t *)(ytmp128+96),1); dft96((int16_t *)(x2128+192),(int16_t *)(ytmp128+192),1); + bfly3_tw1(ytmp128,ytmp128+96,ytmp128+192,y128,y128+96,y128+192); for (i=1,j=0; i<96; i++,j++) { @@ -7580,6 +8428,7 @@ void dft288(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa300[472]__attribute__((aligned(32))); @@ -7587,7 +8436,9 @@ static int16_t twb300[472]__attribute__((aligned(32))); static int16_t twc300[472]__attribute__((aligned(32))); static int16_t twd300[472]__attribute__((aligned(32))); -void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7598,6 +8449,8 @@ void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[300];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[300];//=&ytmp128array2[0]; + + for (i=0,j=0; i<60; i++,j+=5) { x2128[i] = x128[j]; x2128[i+60] = x128[j+1]; @@ -7611,6 +8464,7 @@ void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) { dft60((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); dft60((int16_t *)(x2128+180),(int16_t *)(ytmp128+180),1); dft60((int16_t *)(x2128+240),(int16_t *)(ytmp128+240),1); + bfly5_tw1(ytmp128,ytmp128+60,ytmp128+120,ytmp128+180,ytmp128+240,y128,y128+60,y128+120,y128+180,y128+240); for (i=1,j=0; i<60; i++,j++) { @@ -7640,12 +8494,14 @@ void dft300(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } static int16_t twa324[107*2*4]; static int16_t twb324[107*2*4]; -void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 3 +void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7654,6 +8510,8 @@ void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 3 simd_q15_t x2128[324];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[324];//=&ytmp128array3[0]; + + for (i=0,j=0; i<108; i++,j+=3) { x2128[i] = x128[j]; x2128[i+108] = x128[j+1]; @@ -7663,6 +8521,7 @@ void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 3 dft108((int16_t *)x2128,(int16_t *)ytmp128,1); dft108((int16_t *)(x2128+108),(int16_t *)(ytmp128+108),1); dft108((int16_t *)(x2128+216),(int16_t *)(ytmp128+216),1); + bfly3_tw1(ytmp128,ytmp128+108,ytmp128+216,y128,y128+108,y128+216); for (i=1,j=0; i<108; i++,j++) { @@ -7686,12 +8545,14 @@ void dft324(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 3 _mm_empty(); _m_empty(); + }; static int16_t twa360[119*2*4]; static int16_t twb360[119*2*4]; -void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 3 +void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7700,6 +8561,8 @@ void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 3 simd_q15_t x2128[360];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[360];//=&ytmp128array3[0]; + + for (i=0,j=0; i<120; i++,j+=3) { x2128[i] = x128[j]; x2128[i+120] = x128[j+1]; @@ -7709,6 +8572,7 @@ void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 3 dft120((int16_t *)x2128,(int16_t *)ytmp128,1); dft120((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); dft120((int16_t *)(x2128+240),(int16_t *)(ytmp128+240),1); + bfly3_tw1(ytmp128,ytmp128+120,ytmp128+240,y128,y128+120,y128+240); for (i=1,j=0; i<120; i++,j++) { @@ -7732,13 +8596,15 @@ void dft360(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 3 _mm_empty(); _m_empty(); + }; static int16_t twa384[95*2*4]; static int16_t twb384[95*2*4]; static int16_t twc384[95*2*4]; -void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) { // 96 x 4 +void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) // 96 x 4 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7748,6 +8614,8 @@ void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) { // 96 x 4 simd_q15_t x2128[384];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[384];//=&ytmp128array2[0]; + + for (i=0,j=0; i<96; i++,j+=4) { x2128[i] = x128[j]; x2128[i+96] = x128[j+1]; @@ -7759,6 +8627,7 @@ void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) { // 96 x 4 dft96((int16_t *)(x2128+96),(int16_t *)(ytmp128+96),1); dft96((int16_t *)(x2128+192),(int16_t *)(ytmp128+192),1); dft96((int16_t *)(x2128+288),(int16_t *)(ytmp128+288),1); + bfly4_tw1(ytmp128,ytmp128+96,ytmp128+192,ytmp128+288,y128,y128+96,y128+192,y128+288); for (i=1,j=0; i<96; i++,j++) { @@ -7785,13 +8654,15 @@ void dft384(int16_t *x,int16_t *y,unsigned char scale_flag) { // 96 x 4 _mm_empty(); _m_empty(); + }; static int16_t twa432[107*2*4]; static int16_t twb432[107*2*4]; static int16_t twc432[107*2*4]; -void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 4 +void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) // 108 x 4 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7801,6 +8672,7 @@ void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 4 simd_q15_t x2128[432];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[432];//=&ytmp128array2[0]; + for (i=0,j=0; i<108; i++,j+=4) { x2128[i] = x128[j]; x2128[i+108] = x128[j+1]; @@ -7812,6 +8684,7 @@ void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 4 dft108((int16_t *)(x2128+108),(int16_t *)(ytmp128+108),1); dft108((int16_t *)(x2128+216),(int16_t *)(ytmp128+216),1); dft108((int16_t *)(x2128+324),(int16_t *)(ytmp128+324),1); + bfly4_tw1(ytmp128,ytmp128+108,ytmp128+216,ytmp128+324,y128,y128+108,y128+216,y128+324); for (i=1,j=0; i<108; i++,j++) { @@ -7838,12 +8711,14 @@ void dft432(int16_t *x,int16_t *y,unsigned char scale_flag) { // 108 x 4 _mm_empty(); _m_empty(); + }; static int16_t twa480[119*2*4]; static int16_t twb480[119*2*4]; static int16_t twc480[119*2*4]; -void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 4 +void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) // 120 x 4 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7853,6 +8728,8 @@ void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 4 simd_q15_t x2128[480];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[480];//=&ytmp128array2[0]; + + for (i=0,j=0; i<120; i++,j+=4) { x2128[i] = x128[j]; x2128[i+120] = x128[j+1]; @@ -7864,6 +8741,7 @@ void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 4 dft120((int16_t *)(x2128+120),(int16_t *)(ytmp128+120),1); dft120((int16_t *)(x2128+240),(int16_t *)(ytmp128+240),1); dft120((int16_t *)(x2128+360),(int16_t *)(ytmp128+360),1); + bfly4_tw1(ytmp128,ytmp128+120,ytmp128+240,ytmp128+360,y128,y128+120,y128+240,y128+360); for (i=1,j=0; i<120; i++,j++) { @@ -7890,13 +8768,15 @@ void dft480(int16_t *x,int16_t *y,unsigned char scale_flag) { // 120 x 4 _mm_empty(); _m_empty(); + }; static int16_t twa540[179*2*4]; static int16_t twb540[179*2*4]; -void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 3 +void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7905,6 +8785,8 @@ void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 3 simd_q15_t x2128[540];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[540];//=&ytmp128array3[0]; + + for (i=0,j=0; i<180; i++,j+=3) { x2128[i] = x128[j]; x2128[i+180] = x128[j+1]; @@ -7914,6 +8796,7 @@ void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 3 dft180((int16_t *)x2128,(int16_t *)ytmp128,1); dft180((int16_t *)(x2128+180),(int16_t *)(ytmp128+180),1); dft180((int16_t *)(x2128+360),(int16_t *)(ytmp128+360),1); + bfly3_tw1(ytmp128,ytmp128+180,ytmp128+360,y128,y128+180,y128+360); for (i=1,j=0; i<180; i++,j++) { @@ -7937,12 +8820,14 @@ void dft540(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 3 _mm_empty(); _m_empty(); + }; static int16_t twa576[191*2*4]; static int16_t twb576[191*2*4]; -void dft576(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192 x 3 +void dft576(int16_t *x,int16_t *y,unsigned char scale_flag) // 192 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7951,15 +8836,19 @@ void dft576(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192 x 3 simd_q15_t x2128[576];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[576];//=&ytmp128array3[0]; + + for (i=0,j=0; i<192; i++,j+=3) { x2128[i] = x128[j]; x2128[i+192] = x128[j+1]; x2128[i+384] = x128[j+2]; } + dft192((int16_t *)x2128,(int16_t *)ytmp128,1); dft192((int16_t *)(x2128+192),(int16_t *)(ytmp128+192),1); dft192((int16_t *)(x2128+384),(int16_t *)(ytmp128+384),1); + bfly3_tw1(ytmp128,ytmp128+192,ytmp128+384,y128,y128+192,y128+384); for (i=1,j=0; i<192; i++,j++) { @@ -7988,7 +8877,8 @@ void dft576(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192 x 3 static int16_t twa600[299*2*4]; -void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 2 +void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 2 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -7996,6 +8886,7 @@ void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 2 simd_q15_t x2128[600];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[600];//=&ytmp128array2[0]; + for (i=0,j=0; i<300; i++,j+=2) { x2128[i] = x128[j]; x2128[i+300] = x128[j+1]; @@ -8003,6 +8894,8 @@ void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 2 dft300((int16_t *)x2128,(int16_t *)ytmp128,1); dft300((int16_t *)(x2128+300),(int16_t *)(ytmp128+300),1); + + bfly2_tw1(ytmp128,ytmp128+300,y128,y128+300); for (i=1,j=0; i<300; i++,j++) { @@ -8029,7 +8922,8 @@ void dft600(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 2 static int16_t twa648[215*2*4]; static int16_t twb648[215*2*4]; -void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) { // 216 x 3 +void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) // 216 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8038,6 +8932,8 @@ void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) { // 216 x 3 simd_q15_t x2128[648];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[648];//=&ytmp128array3[0]; + + for (i=0,j=0; i<216; i++,j+=3) { x2128[i] = x128[j]; x2128[i+216] = x128[j+1]; @@ -8047,6 +8943,7 @@ void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) { // 216 x 3 dft216((int16_t *)x2128,(int16_t *)ytmp128,1); dft216((int16_t *)(x2128+216),(int16_t *)(ytmp128+216),1); dft216((int16_t *)(x2128+432),(int16_t *)(ytmp128+432),1); + bfly3_tw1(ytmp128,ytmp128+216,ytmp128+432,y128,y128+216,y128+432); for (i=1,j=0; i<216; i++,j++) { @@ -8070,6 +8967,7 @@ void dft648(int16_t *x,int16_t *y,unsigned char scale_flag) { // 216 x 3 _mm_empty(); _m_empty(); + }; @@ -8078,7 +8976,8 @@ static int16_t twb720[179*2*4]; static int16_t twc720[179*2*4]; -void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 4 +void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) // 180 x 4 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8088,6 +8987,8 @@ void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 4 simd_q15_t x2128[720];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[720];//=&ytmp128array2[0]; + + for (i=0,j=0; i<180; i++,j+=4) { x2128[i] = x128[j]; x2128[i+180] = x128[j+1]; @@ -8099,6 +9000,7 @@ void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 4 dft180((int16_t *)(x2128+180),(int16_t *)(ytmp128+180),1); dft180((int16_t *)(x2128+360),(int16_t *)(ytmp128+360),1); dft180((int16_t *)(x2128+540),(int16_t *)(ytmp128+540),1); + bfly4_tw1(ytmp128,ytmp128+180,ytmp128+360,ytmp128+540,y128,y128+180,y128+360,y128+540); for (i=1,j=0; i<180; i++,j++) { @@ -8125,6 +9027,7 @@ void dft720(int16_t *x,int16_t *y,unsigned char scale_flag) { // 180 x 4 _mm_empty(); _m_empty(); + }; static int16_t twa768[191*2*4]; @@ -8132,6 +9035,7 @@ static int16_t twb768[191*2*4]; static int16_t twc768[191*2*4]; void dft768(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192x 4; + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8141,6 +9045,8 @@ void dft768(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192x 4; simd_q15_t x2128[768];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[768];//=&ytmp128array2[0]; + + for (i=0,j=0; i<192; i++,j+=4) { x2128[i] = x128[j]; x2128[i+192] = x128[j+1]; @@ -8152,6 +9058,7 @@ void dft768(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192x 4; dft192((int16_t *)(x2128+192),(int16_t *)(ytmp128+192),1); dft192((int16_t *)(x2128+384),(int16_t *)(ytmp128+384),1); dft192((int16_t *)(x2128+576),(int16_t *)(ytmp128+576),1); + bfly4_tw1(ytmp128,ytmp128+192,ytmp128+384,ytmp128+576,y128,y128+192,y128+384,y128+576); for (i=1,j=0; i<192; i++,j++) { @@ -8178,13 +9085,16 @@ void dft768(int16_t *x,int16_t *y,unsigned char scale_flag) { // 192x 4; _mm_empty(); _m_empty(); + + } static int16_t twa864[287*2*4]; static int16_t twb864[287*2*4]; -void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 3 +void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8193,6 +9103,8 @@ void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 3 simd_q15_t x2128[864];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[864];//=&ytmp128array3[0]; + + for (i=0,j=0; i<288; i++,j+=3) { x2128[i] = x128[j]; x2128[i+288] = x128[j+1]; @@ -8202,6 +9114,7 @@ void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 3 dft288((int16_t *)x2128,(int16_t *)ytmp128,1); dft288((int16_t *)(x2128+288),(int16_t *)(ytmp128+288),1); dft288((int16_t *)(x2128+576),(int16_t *)(ytmp128+576),1); + bfly3_tw1(ytmp128,ytmp128+288,ytmp128+576,y128,y128+288,y128+576); for (i=1,j=0; i<288; i++,j++) { @@ -8225,12 +9138,14 @@ void dft864(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 3 _mm_empty(); _m_empty(); + }; static int16_t twa900[299*2*4]; static int16_t twb900[299*2*4]; -void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 3 +void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) // 300 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8239,6 +9154,8 @@ void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 3 simd_q15_t x2128[900];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[900];//=&ytmp128array3[0]; + + for (i=0,j=0; i<300; i++,j+=3) { x2128[i] = x128[j]; x2128[i+300] = x128[j+1]; @@ -8248,6 +9165,7 @@ void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 3 dft300((int16_t *)x2128,(int16_t *)ytmp128,1); dft300((int16_t *)(x2128+300),(int16_t *)(ytmp128+300),1); dft300((int16_t *)(x2128+600),(int16_t *)(ytmp128+600),1); + bfly3_tw1(ytmp128,ytmp128+300,ytmp128+600,y128,y128+300,y128+600); for (i=1,j=0; i<300; i++,j++) { @@ -8271,6 +9189,7 @@ void dft900(int16_t *x,int16_t *y,unsigned char scale_flag) { // 300 x 3 _mm_empty(); _m_empty(); + }; @@ -8279,7 +9198,8 @@ static int16_t twb960[239*2*4]; static int16_t twc960[239*2*4]; -void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) { // 240 x 4 +void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) // 240 x 4 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8289,6 +9209,8 @@ void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) { // 240 x 4 simd_q15_t x2128[960];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[960];//=&ytmp128array2[0]; + + for (i=0,j=0; i<240; i++,j+=4) { x2128[i] = x128[j]; x2128[i+240] = x128[j+1]; @@ -8300,6 +9222,7 @@ void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) { // 240 x 4 dft240((int16_t *)(x2128+240),(int16_t *)(ytmp128+240),1); dft240((int16_t *)(x2128+480),(int16_t *)(ytmp128+480),1); dft240((int16_t *)(x2128+720),(int16_t *)(ytmp128+720),1); + bfly4_tw1(ytmp128,ytmp128+240,ytmp128+480,ytmp128+720,y128,y128+240,y128+480,y128+720); for (i=1,j=0; i<240; i++,j++) { @@ -8326,13 +9249,15 @@ void dft960(int16_t *x,int16_t *y,unsigned char scale_flag) { // 240 x 4 _mm_empty(); _m_empty(); + }; static int16_t twa972[323*2*4]; static int16_t twb972[323*2*4]; -void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) { // 324 x 3 +void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) // 324 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8341,6 +9266,8 @@ void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) { // 324 x 3 simd_q15_t x2128[972];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[972];//=&ytmp128array3[0]; + + for (i=0,j=0; i<324; i++,j+=3) { x2128[i] = x128[j]; x2128[i+324] = x128[j+1]; @@ -8350,6 +9277,7 @@ void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) { // 324 x 3 dft324((int16_t *)x2128,(int16_t *)ytmp128,1); dft324((int16_t *)(x2128+324),(int16_t *)(ytmp128+324),1); dft324((int16_t *)(x2128+648),(int16_t *)(ytmp128+648),1); + bfly3_tw1(ytmp128,ytmp128+324,ytmp128+648,y128,y128+324,y128+648); for (i=1,j=0; i<324; i++,j++) { @@ -8373,12 +9301,14 @@ void dft972(int16_t *x,int16_t *y,unsigned char scale_flag) { // 324 x 3 _mm_empty(); _m_empty(); + }; static int16_t twa1080[359*2*4]; static int16_t twb1080[359*2*4]; -void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) { // 360 x 3 +void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) // 360 x 3 +{ int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8387,6 +9317,8 @@ void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) { // 360 x 3 simd_q15_t x2128[1080];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[1080];//=&ytmp128array3[0]; + + for (i=0,j=0; i<360; i++,j+=3) { x2128[i] = x128[j]; x2128[i+360] = x128[j+1]; @@ -8396,6 +9328,7 @@ void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) { // 360 x 3 dft360((int16_t *)x2128,(int16_t *)ytmp128,1); dft360((int16_t *)(x2128+360),(int16_t *)(ytmp128+360),1); dft360((int16_t *)(x2128+720),(int16_t *)(ytmp128+720),1); + bfly3_tw1(ytmp128,ytmp128+360,ytmp128+720,y128,y128+360,y128+720); for (i=1,j=0; i<360; i++,j++) { @@ -8419,13 +9352,16 @@ void dft1080(int16_t *x,int16_t *y,unsigned char scale_flag) { // 360 x 3 _mm_empty(); _m_empty(); + }; static int16_t twa1152[287*2*4]; static int16_t twb1152[287*2*4]; static int16_t twc1152[287*2*4]; -void dft1152(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 4 +void dft1152(int16_t *x,int16_t *y,unsigned char scale_flag) // 288 x 4 +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8435,6 +9371,8 @@ void dft1152(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 4 simd_q15_t x2128[1152];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[1152];//=&ytmp128array2[0]; + + for (i=0,j=0; i<288; i++,j+=4) { x2128[i] = x128[j]; x2128[i+288] = x128[j+1]; @@ -8446,6 +9384,7 @@ void dft1152(int16_t *x,int16_t *y,unsigned char scale_flag) { // 288 x 4 dft288((int16_t *)(x2128+288),(int16_t *)(ytmp128+288),1); dft288((int16_t *)(x2128+576),(int16_t *)(ytmp128+576),1); dft288((int16_t *)(x2128+864),(int16_t *)(ytmp128+864),1); + bfly4_tw1(ytmp128,ytmp128+288,ytmp128+576,ytmp128+864,y128,y128+288,y128+576,y128+864); for (i=1,j=0; i<288; i++,j++) { @@ -8478,7 +9417,9 @@ int16_t twa1200[4784]; int16_t twb1200[4784]; int16_t twc1200[4784]; -void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) { +void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) +{ + int i,j; simd_q15_t *x128=(simd_q15_t *)x; simd_q15_t *y128=(simd_q15_t *)y; @@ -8488,6 +9429,8 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) { simd_q15_t x2128[1200];// = (simd_q15_t *)&x2128array[0]; simd_q15_t ytmp128[1200];//=&ytmp128array2[0]; + + for (i=0,j=0; i<300; i++,j+=4) { x2128[i] = x128[j]; x2128[i+300] = x128[j+1]; @@ -8499,6 +9442,7 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) { dft300((int16_t *)(x2128+300),(int16_t *)(ytmp128+300),1); dft300((int16_t *)(x2128+600),(int16_t *)(ytmp128+600),1); dft300((int16_t *)(x2128+900),(int16_t *)(ytmp128+900),1); + bfly4_tw1(ytmp128,ytmp128+300,ytmp128+600,ytmp128+900,y128,y128+300,y128+600,y128+900); for (i=1,j=0; i<300; i++,j++) { @@ -8517,7 +9461,6 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) { if (scale_flag==1) { norm128 = set1_int16(16384);//dft_norm_table[13]); - for (i=0; i<1200; i++) { y128[i] = mulhi_int16(y128[i],norm128); } @@ -8525,46 +9468,41 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag) { _mm_empty(); _m_empty(); + } void init_rad4(int N,int16_t *tw) { + int16_t *twa = tw; int16_t *twb = twa+(N/2); int16_t *twc = twb+(N/2); int i; - for (i=0; i<(N/4); i++) { - *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); - twa++; - *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); - twa++; - *twb = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); - twb++; - *twb = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); - twb++; - *twc = (int16_t)round(32767.0*cos(2*M_PI*3*i/N)); - twc++; - *twc = -(int16_t)round(32767.0*sin(2*M_PI*3*i/N)); - twc++; + for (i=0;i<(N/4);i++) { + *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa++; + *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twa++; + *twb = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb++; + *twb = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); twb++; + *twc = (int16_t)round(32767.0*cos(2*M_PI*3*i/N)); twc++; + *twc = -(int16_t)round(32767.0*sin(2*M_PI*3*i/N)); twc++; } } void init_rad4_rep(int N,int16_t *twa,int16_t *twb,int16_t *twc) { + int i,j; - for (i=1; i<(N/4); i++) { - twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + for (i=1;i<(N/4);i++) { + twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa[1] = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twb[0] = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb[1] = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); twc[0] = (int16_t)round(32767.0*cos(2*M_PI*3*i/N)); twc[1] = -(int16_t)round(32767.0*sin(2*M_PI*3*i/N)); - - for (j=1; j<4; j++) { - ((int32_t *)twa)[j]=((int32_t *)twa)[0]; - ((int32_t *)twb)[j]=((int32_t *)twb)[0]; - ((int32_t *)twc)[j]=((int32_t *)twc)[0]; + for (j=1;j<4;j++) { + ((int32_t*)twa)[j]=((int32_t*)twa)[0]; + ((int32_t*)twb)[j]=((int32_t*)twb)[0]; + ((int32_t*)twc)[j]=((int32_t*)twc)[0]; } - twa+=8; twb+=8; twc+=8; @@ -8572,71 +9510,66 @@ void init_rad4_rep(int N,int16_t *twa,int16_t *twb,int16_t *twc) { } void init_rad2(int N,int16_t *tw) { + int16_t *twa = tw; int i; - for (i=0; i<(N>>1); i++) { - *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); - twa++; - *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); - twa++; + for (i=0;i<(N>>1);i++) { + *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa++; + *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twa++; } } void init_rad2_rep(int N,int16_t *twa) { + int i,j; - for (i=1; i<(N/2); i++) { - twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + for (i=1;i<(N/2);i++) { + twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa[1] = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); - - for (j=1; j<4; j++) { - ((int32_t *)twa)[j]=((int32_t *)twa)[0]; + for (j=1;j<4;j++) { + ((int32_t*)twa)[j]=((int32_t*)twa)[0]; } - twa+=8; } } void init_rad3(int N,int16_t *twa,int16_t *twb) { + int i; - for (i=0; i<(N/3); i++) { - *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); - twa++; - *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); - twa++; - *twb = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); - twb++; - *twb = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); - twb++; + for (i=0;i<(N/3);i++) { + *twa = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa++; + *twa = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twa++; + *twb = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb++; + *twb = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); twb++; } } void init_rad3_rep(int N,int16_t *twa,int16_t *twb) { + int i,j; - for (i=1; i<(N/3); i++) { - twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + for (i=1;i<(N/3);i++) { + twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa[1] = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twb[0] = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb[1] = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); - - for (j=1; j<4; j++) { - ((int32_t *)twa)[j]=((int32_t *)twa)[0]; - ((int32_t *)twb)[j]=((int32_t *)twb)[0]; + for (j=1;j<4;j++) { + ((int32_t*)twa)[j]=((int32_t*)twa)[0]; + ((int32_t*)twb)[j]=((int32_t*)twb)[0]; } - twa+=8; twb+=8; } } void init_rad5_rep(int N,int16_t *twa,int16_t *twb,int16_t *twc,int16_t *twd) { + int i,j; - for (i=1; i<(N/5); i++) { - twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); + for (i=1;i<(N/5);i++) { + twa[0] = (int16_t)round(32767.0*cos(2*M_PI*i/N)); twa[1] = -(int16_t)round(32767.0*sin(2*M_PI*i/N)); twb[0] = (int16_t)round(32767.0*cos(2*M_PI*2*i/N)); twb[1] = -(int16_t)round(32767.0*sin(2*M_PI*2*i/N)); @@ -8644,30 +9577,30 @@ void init_rad5_rep(int N,int16_t *twa,int16_t *twb,int16_t *twc,int16_t *twd) { twc[1] = -(int16_t)round(32767.0*sin(2*M_PI*3*i/N)); twd[0] = (int16_t)round(32767.0*cos(2*M_PI*4*i/N)); twd[1] = -(int16_t)round(32767.0*sin(2*M_PI*4*i/N)); - - for (j=1; j<4; j++) { - ((int32_t *)twa)[j]=((int32_t *)twa)[0]; - ((int32_t *)twb)[j]=((int32_t *)twb)[0]; - ((int32_t *)twc)[j]=((int32_t *)twc)[0]; - ((int32_t *)twd)[j]=((int32_t *)twd)[0]; + for (j=1;j<4;j++) { + ((int32_t*)twa)[j]=((int32_t*)twa)[0]; + ((int32_t*)twb)[j]=((int32_t*)twb)[0]; + ((int32_t*)twc)[j]=((int32_t*)twc)[0]; + ((int32_t*)twd)[j]=((int32_t*)twd)[0]; } - twa+=8; twb+=8; twc+=8; - twd+=8; + twd+=8; } } /*----------------------------------------------------------------*/ /* dft library entry points: */ -int dfts_autoinit(void) { +int dfts_autoinit(void) +{ init_rad4(1024,tw1024); init_rad2(2048,tw2048); init_rad4(4096,tw4096); init_rad2(8192,tw8192); init_rad4(16384,tw16384); init_rad2(32768,tw32768); + init_rad3(1536,twa1536,twb1536); init_rad3(3072,twa3072,twb3072); init_rad3(6144,twa6144,twb6144); @@ -8677,6 +9610,8 @@ int dfts_autoinit(void) { init_rad3(36864,twa36864,twb36864); init_rad3(49152,twa49152,twb49152); init_rad3(98304,twa98304,twb98304); + + init_rad2_rep(24,tw24); init_rad3_rep(36,twa36,twb36); init_rad4_rep(48,twa48,twb48,twc48); @@ -8717,14 +9652,14 @@ int dfts_autoinit(void) { #ifndef MR_MAIN -void dft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag) { - AssertFatal((sizeidx>=0 && sizeidx<(int)DFT_SIZE_IDXTABLESIZE),"Invalid dft size index %i\n",sizeidx); - dft_ftab[sizeidx](sigF,sig,scale_flag); +void dft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){ + AssertFatal((sizeidx>=0 && sizeidx<(int)DFT_SIZE_IDXTABLESIZE),"Invalid dft size index %i\n",sizeidx); + dft_ftab[sizeidx](sigF,sig,scale_flag); }; -void idft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag) { - AssertFatal((sizeidx>=0 && sizeidx<(int)IDFT_SIZE_IDXTABLESIZE),"Invalid idft size index %i\n",sizeidx); - idft_ftab[sizeidx](sigF,sig,scale_flag); +void idft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){ + AssertFatal((sizeidx>=0 && sizeidx<(int)IDFT_SIZE_IDXTABLESIZE),"Invalid idft size index %i\n",sizeidx); + idft_ftab[sizeidx](sigF,sig,scale_flag); }; #endif @@ -8735,17 +9670,24 @@ void idft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag) #include #define LOG_M write_output -int write_output(const char *fname,const char *vname,void *data,int length,int dec,char format) { +int write_output(const char *fname,const char *vname,void *data,int length,int dec,char format) +{ + FILE *fp=NULL; int i; + + printf("Writing %d elements of type %d to %s\n",length,format,fname); + if (format == 10 || format ==11 || format == 12 || format == 13 || format == 14) { fp = fopen(fname,"a+"); } else if (format != 10 && format !=11 && format != 12 && format != 13 && format != 14) { fp = fopen(fname,"w+"); } + + if (fp== NULL) { printf("[OPENAIR][FILE OUTPUT] Cannot open file %s\n",fname); return(-1); @@ -8754,108 +9696,121 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d if (format != 10 && format !=11 && format != 12 && format != 13 && format != 14) fprintf(fp,"%s = [",vname); + switch (format) { - case 0: // real 16-bit - for (i=0; i 0)) - fprintf(fp,"%d + j*(%d),",((short *)data)[i],((short *)data)[i+1]); - else if (i == 2*(length-1)) - fprintf(fp,"%d + j*(%d);",((short *)data)[i],((short *)data)[i+1]); - else if (i == 0) - fprintf(fp,"\n%d + j*(%d),",((short *)data)[i],((short *)data)[i+1]); - } + case 8: // complex double + for (i=0; i 0)) - fprintf(fp,"%d,",((short *)data)[i]); - else if (i == (length-1)) - fprintf(fp,"%d;",((short *)data)[i]); - else if (i == 0) - fprintf(fp,"\n%d,",((short *)data)[i]); - } + case 9: // real unsigned 8-bit + for (i=0; i 0)) + fprintf(fp,"%d + j*(%d),",((short *)data)[i],((short *)data)[i+1]); + else if (i == 2*(length-1)) + fprintf(fp,"%d + j*(%d);",((short *)data)[i],((short *)data)[i+1]); + else if (i == 0) + fprintf(fp,"\n%d + j*(%d),",((short *)data)[i],((short *)data)[i+1]); + + + + } + + break; + + case 11 : //case eren 16 bit real for channel magnitudes: + for (i=0; i 0)) + fprintf(fp,"%d,",((short *)data)[i]); + else if (i == (length-1)) + fprintf(fp,"%d;",((short *)data)[i]); + else if (i == 0) + fprintf(fp,"\n%d,",((short *)data)[i]); + } + + printf("\n erennnnnnnnnnnnnnn: length :%d",length); + break; + + case 12 : // case eren for log2_maxh real unsigned 8 bit + fprintf(fp,"%d \n",((unsigned char *)&data)[0]); + break; - case 12 : // case eren for log2_maxh real unsigned 8 bit - fprintf(fp,"%d \n",((unsigned char *)&data)[0]); - break; } if (format != 10 && format !=11 && format !=12 && format != 13 && format != 15) { @@ -8871,7 +9826,10 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d } -int main(int argc, char **argv) { +int main(int argc, char**argv) +{ + + time_stats_t ts; #ifdef __AVX2__ simd256_q15_t x[16384],x2[16384],y[16384],tw0,tw1,tw2,tw3; @@ -8879,210 +9837,204 @@ int main(int argc, char **argv) { simd_q15_t x[32768],y[32768],tw0,tw1,tw2,tw3; #endif int i; - simd_q15_t *x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y; + simd_q15_t *x128=(simd_q15_t*)x,*y128=(simd_q15_t*)y; + dfts_autoinit(); + set_taus_seed(0); opp_enabled = 1; + /* + ((int16_t *)&tw0)[0] = 32767; + ((int16_t *)&tw0)[1] = 0; + ((int16_t *)&tw0)[2] = 32767; + ((int16_t *)&tw0)[3] = 0; + ((int16_t *)&tw0)[4] = 32767; + ((int16_t *)&tw0)[5] = 0; + ((int16_t *)&tw0)[6] = 32767; + ((int16_t *)&tw0)[7] = 0; - /* - ((int16_t *)&tw0)[0] = 32767; - ((int16_t *)&tw0)[1] = 0; - ((int16_t *)&tw0)[2] = 32767; - ((int16_t *)&tw0)[3] = 0; - ((int16_t *)&tw0)[4] = 32767; - ((int16_t *)&tw0)[5] = 0; - ((int16_t *)&tw0)[6] = 32767; - ((int16_t *)&tw0)[7] = 0; + ((int16_t *)&tw1)[0] = 32767; + ((int16_t *)&tw1)[1] = 0; + ((int16_t *)&tw1)[2] = 32767; + ((int16_t *)&tw1)[3] = 0; + ((int16_t *)&tw1)[4] = 32767; + ((int16_t *)&tw1)[5] = 0; + ((int16_t *)&tw1)[6] = 32767; + ((int16_t *)&tw1)[7] = 0; - ((int16_t *)&tw1)[0] = 32767; - ((int16_t *)&tw1)[1] = 0; - ((int16_t *)&tw1)[2] = 32767; - ((int16_t *)&tw1)[3] = 0; - ((int16_t *)&tw1)[4] = 32767; - ((int16_t *)&tw1)[5] = 0; - ((int16_t *)&tw1)[6] = 32767; - ((int16_t *)&tw1)[7] = 0; + ((int16_t *)&tw2)[0] = 32767; + ((int16_t *)&tw2)[1] = 0; + ((int16_t *)&tw2)[2] = 32767; + ((int16_t *)&tw2)[3] = 0; + ((int16_t *)&tw2)[4] = 32767; + ((int16_t *)&tw2)[5] = 0; + ((int16_t *)&tw2)[6] = 32767; + ((int16_t *)&tw2)[7] = 0; - ((int16_t *)&tw2)[0] = 32767; - ((int16_t *)&tw2)[1] = 0; - ((int16_t *)&tw2)[2] = 32767; - ((int16_t *)&tw2)[3] = 0; - ((int16_t *)&tw2)[4] = 32767; - ((int16_t *)&tw2)[5] = 0; - ((int16_t *)&tw2)[6] = 32767; - ((int16_t *)&tw2)[7] = 0; - - ((int16_t *)&tw3)[0] = 32767; - ((int16_t *)&tw3)[1] = 0; - ((int16_t *)&tw3)[2] = 32767; - ((int16_t *)&tw3)[3] = 0; - ((int16_t *)&tw3)[4] = 32767; - ((int16_t *)&tw3)[5] = 0; - ((int16_t *)&tw3)[6] = 32767; - ((int16_t *)&tw3)[7] = 0; - */ - for (i=0; i<300; i++) { + ((int16_t *)&tw3)[0] = 32767; + ((int16_t *)&tw3)[1] = 0; + ((int16_t *)&tw3)[2] = 32767; + ((int16_t *)&tw3)[3] = 0; + ((int16_t *)&tw3)[4] = 32767; + ((int16_t *)&tw3)[5] = 0; + ((int16_t *)&tw3)[6] = 32767; + ((int16_t *)&tw3)[7] = 0; + */ + for (i=0;i<300;i++) { #if defined(__x86_64__) || defined(__i386__) #ifndef __AVX2__ - x[i] = _mm_set1_epi32(taus()); - x[i] = _mm_srai_epi16(x[i],4); + x[i] = _mm_set1_epi32(taus()); + x[i] = _mm_srai_epi16(x[i],4); #else - x[i] = _mm256_set1_epi32(taus()); - x[i] = _mm256_srai_epi16(x[i],4); + x[i] = _mm256_set1_epi32(taus()); + x[i] = _mm256_srai_epi16(x[i],4); #endif #elif defined(__arm__) - x[i] = (int16x8_t)vdupq_n_s32(taus()); - x[i] = vshrq_n_s16(x[i],4); + x[i] = (int16x8_t)vdupq_n_s32(taus()); + x[i] = vshrq_n_s16(x[i],4); #endif - } + } + /* + bfly2_tw1(x,x+1,y,y+1); + printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1]); + printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3]); + printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5]); + printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7]); + bfly2(x,x+1,y,y+1, &tw0); + printf("0(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1]); + printf("1(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3]); + printf("2(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5]); + printf("3(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7]); + bfly2(x,x+1,y,y+1, &tw0); - /* - bfly2_tw1(x,x+1,y,y+1); - printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1]); - printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3]); - printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5]); - printf("(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7]); - bfly2(x,x+1,y,y+1, &tw0); - printf("0(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1]); - printf("1(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3]); - printf("2(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5]); - printf("3(%d,%d) (%d,%d) => (%d,%d) (%d,%d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7]); - bfly2(x,x+1,y,y+1, &tw0); + bfly3_tw1(x,x+1,x+2,y, y+1,y+2); + printf("0(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1],((int16_t*)&y[2])[0],((int16_t*)&y[2])[1]); + printf("1(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3],((int16_t*)&y[2])[2],((int16_t*)&y[2])[3]); + printf("2(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5],((int16_t*)&y[2])[4],((int16_t*)&y[2])[5]); + printf("3(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7],((int16_t*)&y[2])[6],((int16_t*)&y[2])[7]); + bfly3(x,x+1,x+2,y, y+1,y+2,&tw0,&tw1); - bfly3_tw1(x,x+1,x+2,y, y+1,y+2); - printf("0(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1],((int16_t*)&y[2])[0],((int16_t*)&y[2])[1]); - printf("1(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3],((int16_t*)&y[2])[2],((int16_t*)&y[2])[3]); - printf("2(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5],((int16_t*)&y[2])[4],((int16_t*)&y[2])[5]); - printf("3(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7],((int16_t*)&y[2])[6],((int16_t*)&y[2])[7]); - bfly3(x,x+1,x+2,y, y+1,y+2,&tw0,&tw1); - - printf("0(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1],((int16_t*)&y[2])[0],((int16_t*)&y[2])[1]); - printf("1(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3],((int16_t*)&y[2])[2],((int16_t*)&y[2])[3]); - printf("2(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5],((int16_t*)&y[2])[4],((int16_t*)&y[2])[5]); - printf("3(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7],((int16_t*)&y[2])[6],((int16_t*)&y[2])[7]); + printf("0(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1],((int16_t*)&y[2])[0],((int16_t*)&y[2])[1]); + printf("1(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3],((int16_t*)&y[2])[2],((int16_t*)&y[2])[3]); + printf("2(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5],((int16_t*)&y[2])[4],((int16_t*)&y[2])[5]); + printf("3(%d,%d) (%d,%d) (%d %d) => (%d,%d) (%d,%d) (%d %d)\n",((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1],((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7],((int16_t*)&y[2])[6],((int16_t*)&y[2])[7]); - bfly4_tw1(x,x+1,x+2,x+3,y, y+1,y+2,y+3); - printf("(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], - ((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1], - ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); + bfly4_tw1(x,x+1,x+2,x+3,y, y+1,y+2,y+3); + printf("(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], + ((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1], + ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); - bfly4(x,x+1,x+2,x+3,y, y+1,y+2,y+3,&tw0,&tw1,&tw2); - printf("0(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], - ((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1], - ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); - printf("1(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], - ((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3], - ((int16_t*)&y[2])[2],((int16_t*)&y[2])[3],((int16_t*)&y[3])[2],((int16_t*)&y[3])[3]); - printf("2(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], - ((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5], - ((int16_t*)&y[2])[4],((int16_t*)&y[2])[5],((int16_t*)&y[3])[4],((int16_t*)&y[3])[5]); - printf("3(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", - ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], - ((int16_t*)&x[2])[6],((int16_t*)&x[2])[7],((int16_t*)&x[3])[6],((int16_t*)&x[3])[7], - ((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7], - ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); + bfly4(x,x+1,x+2,x+3,y, y+1,y+2,y+3,&tw0,&tw1,&tw2); + printf("0(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], + ((int16_t*)&y[0])[0],((int16_t*)&y[0])[1],((int16_t*)&y[1])[0],((int16_t*)&y[1])[1], + ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); + printf("1(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], + ((int16_t*)&y[0])[2],((int16_t*)&y[0])[3],((int16_t*)&y[1])[2],((int16_t*)&y[1])[3], + ((int16_t*)&y[2])[2],((int16_t*)&y[2])[3],((int16_t*)&y[3])[2],((int16_t*)&y[3])[3]); + printf("2(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[0],((int16_t*)&x[2])[1],((int16_t*)&x[3])[0],((int16_t*)&x[3])[1], + ((int16_t*)&y[0])[4],((int16_t*)&y[0])[5],((int16_t*)&y[1])[4],((int16_t*)&y[1])[5], + ((int16_t*)&y[2])[4],((int16_t*)&y[2])[5],((int16_t*)&y[3])[4],((int16_t*)&y[3])[5]); + printf("3(%d,%d) (%d,%d) (%d %d) (%d,%d) => (%d,%d) (%d,%d) (%d %d) (%d,%d)\n", + ((int16_t*)&x[0])[0],((int16_t*)&x[0])[1],((int16_t*)&x[1])[0],((int16_t*)&x[1])[1], + ((int16_t*)&x[2])[6],((int16_t*)&x[2])[7],((int16_t*)&x[3])[6],((int16_t*)&x[3])[7], + ((int16_t*)&y[0])[6],((int16_t*)&y[0])[7],((int16_t*)&y[1])[6],((int16_t*)&y[1])[7], + ((int16_t*)&y[2])[0],((int16_t*)&y[2])[1],((int16_t*)&y[3])[0],((int16_t*)&y[3])[1]); - bfly5_tw1(x,x+1,x+2,x+3,x+4,y,y+1,y+2,y+3,y+4); + bfly5_tw1(x,x+1,x+2,x+3,x+4,y,y+1,y+2,y+3,y+4); - for (i=0;i<5;i++) - printf("%d,%d,", - ((int16_t*)&x[i])[0],((int16_t*)&x[i])[1]); - printf("\n"); - for (i=0;i<5;i++) - printf("%d,%d,", - ((int16_t*)&y[i])[0],((int16_t*)&y[i])[1]); - printf("\n"); + for (i=0;i<5;i++) + printf("%d,%d,", + ((int16_t*)&x[i])[0],((int16_t*)&x[i])[1]); + printf("\n"); + for (i=0;i<5;i++) + printf("%d,%d,", + ((int16_t*)&y[i])[0],((int16_t*)&y[i])[1]); + printf("\n"); - bfly5(x,x+1,x+2,x+3,x+4,y, y+1,y+2,y+3,y+4,&tw0,&tw1,&tw2,&tw3); - for (i=0;i<5;i++) - printf("%d,%d,", - ((int16_t*)&x[i])[0],((int16_t*)&x[i])[1]); - printf("\n"); - for (i=0;i<5;i++) - printf("%d,%d,", - ((int16_t*)&y[i])[0],((int16_t*)&y[i])[1]); - printf("\n"); + bfly5(x,x+1,x+2,x+3,x+4,y, y+1,y+2,y+3,y+4,&tw0,&tw1,&tw2,&tw3); + for (i=0;i<5;i++) + printf("%d,%d,", + ((int16_t*)&x[i])[0],((int16_t*)&x[i])[1]); + printf("\n"); + for (i=0;i<5;i++) + printf("%d,%d,", + ((int16_t*)&y[i])[0],((int16_t*)&y[i])[1]); + printf("\n"); - printf("\n\n12-point\n"); - dft12f(x, - x+1, - x+2, - x+3, - x+4, - x+5, - x+6, - x+7, - x+8, - x+9, - x+10, - x+11, - y, - y+1, - y+2, - y+3, - y+4, - y+5, - y+6, - y+7, - y+8, - y+9, - y+10, - y+11); + printf("\n\n12-point\n"); + dft12f(x, + x+1, + x+2, + x+3, + x+4, + x+5, + x+6, + x+7, + x+8, + x+9, + x+10, + x+11, + y, + y+1, + y+2, + y+3, + y+4, + y+5, + y+6, + y+7, + y+8, + y+9, + y+10, + y+11); - printf("X: "); - for (i=0;i<12;i++) - printf("%d,%d,",((int16_t*)(&x[i]))[0],((int16_t *)(&x[i]))[1]); - printf("\nY:"); - for (i=0;i<12;i++) - printf("%d,%d,",((int16_t*)(&y[i]))[0],((int16_t *)(&y[i]))[1]); - printf("\n"); + printf("X: "); + for (i=0;i<12;i++) + printf("%d,%d,",((int16_t*)(&x[i]))[0],((int16_t *)(&x[i]))[1]); + printf("\nY:"); + for (i=0;i<12;i++) + printf("%d,%d,",((int16_t*)(&y[i]))[0],((int16_t *)(&y[i]))[1]); + printf("\n"); - */ + */ - for (i=0; i<32; i++) { - ((int16_t *)x)[i] = (int16_t)((taus()&0xffff))>>5; - } - - memset((void *)&y[0],0,16*4); - idft16((int16_t *)x,(int16_t *)y); - printf("\n\n16-point\n"); - printf("X: "); - - for (i=0; i<4; i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t *)&x[i])[0],((int16_t *)&x[i])[1],((int16_t *)&x[i])[2],((int16_t *)&x[i])[3],((int16_t *)&x[i])[4],((int16_t *)&x[i])[5],((int16_t *)&x[i])[6], - ((int16_t *)&x[i])[7]); - - printf("\nY:"); - - for (i=0; i<4; i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t *)&y[i])[0],((int16_t *)&y[i])[1],((int16_t *)&y[i])[2],((int16_t *)&y[i])[3],((int16_t *)&y[i])[4],((int16_t *)&y[i])[5],((int16_t *)&y[i])[6], - ((int16_t *)&y[i])[7]); - - printf("\n"); - memset((void *)&x[0],0,2048*4); + for (i=0;i<32;i++) { + ((int16_t*)x)[i] = (int16_t)((taus()&0xffff))>>5; + } + memset((void*)&y[0],0,16*4); + idft16((int16_t *)x,(int16_t *)y); + printf("\n\n16-point\n"); + printf("X: "); + for (i=0;i<4;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); + printf("\nY:"); + for (i=0;i<4;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); + printf("\n"); + + memset((void*)&x[0],0,2048*4); + for (i=0; i<2048; i+=4) { - ((int16_t *)x)[i<<1] = 1024; - ((int16_t *)x)[1+(i<<1)] = 0; - ((int16_t *)x)[2+(i<<1)] = 0; - ((int16_t *)x)[3+(i<<1)] = 1024; - ((int16_t *)x)[4+(i<<1)] = -1024; - ((int16_t *)x)[5+(i<<1)] = 0; - ((int16_t *)x)[6+(i<<1)] = 0; - ((int16_t *)x)[7+(i<<1)] = -1024; - } - + ((int16_t*)x)[i<<1] = 1024; + ((int16_t*)x)[1+(i<<1)] = 0; + ((int16_t*)x)[2+(i<<1)] = 0; + ((int16_t*)x)[3+(i<<1)] = 1024; + ((int16_t*)x)[4+(i<<1)] = -1024; + ((int16_t*)x)[5+(i<<1)] = 0; + ((int16_t*)x)[6+(i<<1)] = 0; + ((int16_t*)x)[7+(i<<1)] = -1024; + } /* for (i=0; i<2048; i+=2) { ((int16_t*)x)[i<<1] = 1024; @@ -9090,40 +10042,41 @@ int main(int argc, char **argv) { ((int16_t*)x)[2+(i<<1)] = -1024; ((int16_t*)x)[3+(i<<1)] = 0; } - + for (i=0;i<2048*2;i++) { ((int16_t*)x)[i] = i/2;//(int16_t)((taus()&0xffff))>>5; } */ - memset((void *)&x[0],0,64*sizeof(int32_t)); - - for (i=2; i<36; i++) { + memset((void*)&x[0],0,64*sizeof(int32_t)); + for (i=2;i<36;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=(128-36); i<128; i++) { + for (i=(128-36);i<128;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - idft64((int16_t *)x,(int16_t *)y,1); + + printf("64-point\n"); printf("X: "); - - for (i=0; i<8; i++) + for (i=0;i<8;i++) print_shorts256("",((int16_t *)x)+(i*16)); printf("\nY:"); - for (i=0; i<8; i++) + for (i=0;i<8;i++) print_shorts256("",((int16_t *)y)+(i*16)); - printf("\n"); + + + + idft64((int16_t *)x,(int16_t *)y,1); idft64((int16_t *)x,(int16_t *)y,1); idft64((int16_t *)x,(int16_t *)y,1); @@ -9133,49 +10086,47 @@ int main(int argc, char **argv) { start_meas(&ts); idft64((int16_t *)x,(int16_t *)y,1); stop_meas(&ts); - } + } /* printf("\n\n64-point (%f cycles, #trials %d)\n",(double)ts.diff/(double)ts.trials,ts.trials); // LOG_M("x64.m","x64",x,64,1,1); LOG_M("y64.m","y64",y,64,1,1); LOG_M("x64.m","x64",x,64,1,1); */ - /* - printf("X: "); - for (i=0;i<16;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); - printf("\nY:"); +/* + printf("X: "); + for (i=0;i<16;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); + printf("\nY:"); - for (i=0;i<16;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); - printf("\n"); + for (i=0;i<16;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); + printf("\n"); - idft64((int16_t*)y,(int16_t*)x,1); - printf("X: "); - for (i=0;i<16;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); - - for (i=0; i<256; i++) { - ((int16_t*)x)[i] = (int16_t)((taus()&0xffff))>>5; - } - */ - memset((void *)&x[0],0,128*4); - - for (i=2; i<72; i++) { - if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; - else - ((int16_t *)x)[i] = -364; + idft64((int16_t*)y,(int16_t*)x,1); + printf("X: "); + for (i=0;i<16;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); + + for (i=0; i<256; i++) { + ((int16_t*)x)[i] = (int16_t)((taus()&0xffff))>>5; } - - for (i=(256-72); i<256; i++) { +*/ + + memset((void*)&x[0],0,128*4); + for (i=2;i<72;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; + } + for (i=(256-72);i<256;i++) { + if ((taus() & 1)==0) + ((int16_t*)x)[i] = 364; + else + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); for (i=0; i<10000; i++) { @@ -9187,39 +10138,37 @@ int main(int argc, char **argv) { printf("\n\n128-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y128.m","y128",y,128,1,1); LOG_M("x128.m","x128",x,128,1,1); - /* - printf("X: "); - for (i=0;i<32;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); - printf("\nY:"); +/* + printf("X: "); + for (i=0;i<32;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&x[i])[0],((int16_t *)&x[i])[1],((int16_t*)&x[i])[2],((int16_t *)&x[i])[3],((int16_t*)&x[i])[4],((int16_t*)&x[i])[5],((int16_t*)&x[i])[6],((int16_t*)&x[i])[7]); + printf("\nY:"); + + for (i=0;i<32;i++) + printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); + printf("\n"); +*/ - for (i=0;i<32;i++) - printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); - printf("\n"); - */ /* for (i=0; i<512; i++) { ((int16_t*)x)[i] = (int16_t)((taus()&0xffff))>>5; } - + memset((void*)&y[0],0,256*4); */ - memset((void *)&x[0],0,256*sizeof(int32_t)); - - for (i=2; i<144; i++) { + memset((void*)&x[0],0,256*sizeof(int32_t)); + for (i=2;i<144;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=(512-144); i<512; i++) { + for (i=(512-144);i<512;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); for (i=0; i<10000; i++) { @@ -9231,24 +10180,22 @@ int main(int argc, char **argv) { printf("\n\n256-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y256.m","y256",y,256,1,1); LOG_M("x256.m","x256",x,256,1,1); - memset((void *)&x[0],0,512*sizeof(int32_t)); - for (i=2; i<302; i++) { + memset((void*)&x[0],0,512*sizeof(int32_t)); + for (i=2;i<302;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=(1024-300); i<1024; i++) { + for (i=(1024-300);i<1024;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft512((int16_t *)x,(int16_t *)y,1); @@ -9268,22 +10215,20 @@ int main(int argc, char **argv) { printf("%d,%d,%d,%d,%d,%d,%d,%d,",((int16_t*)&y[i])[0],((int16_t *)&y[i])[1],((int16_t*)&y[i])[2],((int16_t *)&y[i])[3],((int16_t*)&y[i])[4],((int16_t *)&y[i])[5],((int16_t*)&y[i])[6],((int16_t *)&y[i])[7]); printf("\n"); */ - memset((void *)x,0,1024*sizeof(int32_t)); - for (i=2; i<602; i++) { + memset((void*)x,0,1024*sizeof(int32_t)); + for (i=2;i<602;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*724; i<2048; i++) { + for (i=2*724;i<2048;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); for (i=0; i<10000; i++) { @@ -9295,22 +10240,21 @@ int main(int argc, char **argv) { printf("\n\n1024-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y1024.m","y1024",y,1024,1,1); LOG_M("x1024.m","x1024",x,1024,1,1); - memset((void *)x,0,1536*sizeof(int32_t)); - for (i=2; i<1202; i++) { + + memset((void*)x,0,1536*sizeof(int32_t)); + for (i=2;i<1202;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(1536-600); i<3072; i++) { + for (i=2*(1536-600);i<3072;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); for (i=0; i<10000; i++) { @@ -9322,22 +10266,21 @@ int main(int argc, char **argv) { printf("\n\n1536-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); write_output("y1536.m","y1536",y,1536,1,1); write_output("x1536.m","x1536",x,1536,1,1); - memset((void *)x,0,2048*sizeof(int32_t)); - for (i=2; i<1202; i++) { + + memset((void*)x,0,2048*sizeof(int32_t)); + for (i=2;i<1202;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(2048-600); i<4096; i++) { + for (i=2*(2048-600);i<4096;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); for (i=0; i<10000; i++) { @@ -9349,21 +10292,20 @@ int main(int argc, char **argv) { printf("\n\n2048-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y2048.m","y2048",y,2048,1,1); LOG_M("x2048.m","x2048",x,2048,1,1); - // NR 80Mhz, 217 PRB, 3/4 sampling - memset((void *)x, 0, 3072*sizeof(int32_t)); - for (i=2; i<2506; i++) { +// NR 80Mhz, 217 PRB, 3/4 sampling + memset((void*)x, 0, 3072*sizeof(int32_t)); + for (i=2;i<2506;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(3072-1252); i<6144; i++) { + for (i=2*(3072-1252);i<6144;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } reset_meas(&ts); @@ -9377,22 +10319,21 @@ int main(int argc, char **argv) { printf("\n\n3072-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); write_output("y3072.m","y3072",y,3072,1,1); write_output("x3072.m","x3072",x,3072,1,1); - memset((void *)x,0,4096*sizeof(int32_t)); - for (i=0; i<2400; i++) { + + memset((void*)x,0,4096*sizeof(int32_t)); + for (i=0;i<2400;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(4096-1200); i<8192; i++) { + for (i=2*(4096-1200);i<8192;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); for (i=0; i<10000; i++) { @@ -9404,23 +10345,23 @@ int main(int argc, char **argv) { printf("\n\n4096-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y4096.m","y4096",y,4096,1,1); LOG_M("x4096.m","x4096",x,4096,1,1); + dft4096((int16_t *)y,(int16_t *)x2,1); LOG_M("x4096_2.m","x4096_2",x2,4096,1,1); - // NR 160Mhz, 434 PRB, 3/4 sampling - memset((void *)x, 0, 6144*sizeof(int32_t)); - for (i=2; i<5010; i++) { +// NR 160Mhz, 434 PRB, 3/4 sampling + memset((void*)x, 0, 6144*sizeof(int32_t)); + for (i=2;i<5010;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(6144-2504); i<12288; i++) { + for (i=2*(6144-2504);i<12288;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } reset_meas(&ts); @@ -9434,24 +10375,21 @@ int main(int argc, char **argv) { printf("\n\n6144-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); write_output("y6144.m","y6144",y,6144,1,1); write_output("x6144.m","x6144",x,6144,1,1); - memset((void *)x,0,8192*sizeof(int32_t)); - for (i=2; i<4802; i++) { + memset((void*)x,0,8192*sizeof(int32_t)); + for (i=2;i<4802;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(8192-2400); i<16384; i++) { + for (i=2*(8192-2400);i<16384;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft8192((int16_t *)x,(int16_t *)y,1); @@ -9461,24 +10399,21 @@ int main(int argc, char **argv) { printf("\n\n8192-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y8192.m","y8192",y,8192,1,1); LOG_M("x8192.m","x8192",x,8192,1,1); - memset((void *)x,0,16384*sizeof(int32_t)); - for (i=2; i<9602; i++) { + memset((void*)x,0,16384*sizeof(int32_t)); + for (i=2;i<9602;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(16384-4800); i<32768; i++) { + for (i=2*(16384-4800);i<32768;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); dft16384((int16_t *)x,(int16_t *)y,1); @@ -9488,24 +10423,21 @@ int main(int argc, char **argv) { printf("\n\n16384-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y16384.m","y16384",y,16384,1,1); LOG_M("x16384.m","x16384",x,16384,1,1); - memset((void *)x,0,1536*sizeof(int32_t)); - for (i=2; i<1202; i++) { + memset((void*)x,0,1536*sizeof(int32_t)); + for (i=2;i<1202;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(1536-600); i<3072; i++) { + for (i=2*(1536-600);i<3072;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft1536((int16_t *)x,(int16_t *)y,1); @@ -9515,27 +10447,25 @@ int main(int argc, char **argv) { printf("\n\n1536-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y1536.m","y1536",y,1536,1,1); LOG_M("x1536.m","x1536",x,1536,1,1); + printf("\n\n1536-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y8192.m","y8192",y,8192,1,1); LOG_M("x8192.m","x8192",x,8192,1,1); - memset((void *)x,0,3072*sizeof(int32_t)); - for (i=2; i<1202; i++) { + memset((void*)x,0,3072*sizeof(int32_t)); + for (i=2;i<1202;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(3072-600); i<3072; i++) { + for (i=2*(3072-600);i<3072;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft3072((int16_t *)x,(int16_t *)y,1); @@ -9545,24 +10475,21 @@ int main(int argc, char **argv) { printf("\n\n3072-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y3072.m","y3072",y,3072,1,1); LOG_M("x3072.m","x3072",x,3072,1,1); - memset((void *)x,0,6144*sizeof(int32_t)); - for (i=2; i<4802; i++) { + memset((void*)x,0,6144*sizeof(int32_t)); + for (i=2;i<4802;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(6144-2400); i<12288; i++) { + for (i=2*(6144-2400);i<12288;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft6144((int16_t *)x,(int16_t *)y,1); @@ -9572,24 +10499,21 @@ int main(int argc, char **argv) { printf("\n\n6144-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y6144.m","y6144",y,6144,1,1); LOG_M("x6144.m","x6144",x,6144,1,1); - memset((void *)x,0,12288*sizeof(int32_t)); - for (i=2; i<9602; i++) { + memset((void*)x,0,12288*sizeof(int32_t)); + for (i=2;i<9602;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(12288-4800); i<24576; i++) { + for (i=2*(12288-4800);i<24576;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft12288((int16_t *)x,(int16_t *)y,1); @@ -9599,24 +10523,21 @@ int main(int argc, char **argv) { printf("\n\n12288-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y12288.m","y12288",y,12288,1,1); LOG_M("x12288.m","x12288",x,12288,1,1); - memset((void *)x,0,18432*sizeof(int32_t)); - for (i=2; i<14402; i++) { + memset((void*)x,0,18432*sizeof(int32_t)); + for (i=2;i<14402;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(18432-7200); i<36864; i++) { + for (i=2*(18432-7200);i<36864;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft18432((int16_t *)x,(int16_t *)y,1); @@ -9626,24 +10547,21 @@ int main(int argc, char **argv) { printf("\n\n18432-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y18432.m","y18432",y,18432,1,1); LOG_M("x18432.m","x18432",x,18432,1,1); - memset((void *)x,0,24576*sizeof(int32_t)); - for (i=2; i<19202; i++) { + memset((void*)x,0,24576*sizeof(int32_t)); + for (i=2;i<19202;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(24576-19200); i<49152; i++) { + for (i=2*(24576-19200);i<49152;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft24576((int16_t *)x,(int16_t *)y,1); @@ -9653,24 +10571,22 @@ int main(int argc, char **argv) { printf("\n\n24576-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y24576.m","y24576",y,24576,1,1); LOG_M("x24576.m","x24576",x,24576,1,1); - memset((void *)x,0,2*18432*sizeof(int32_t)); - for (i=2; i<(2*14402); i++) { + + memset((void*)x,0,2*18432*sizeof(int32_t)); + for (i=2;i<(2*14402);i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - - for (i=2*(36864-14400); i<(36864*2); i++) { + for (i=2*(36864-14400);i<(36864*2);i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); dft36864((int16_t *)x,(int16_t *)y,1); @@ -9680,24 +10596,22 @@ int main(int argc, char **argv) { printf("\n\n36864-point(%f cycles)\n",(double)ts.diff/(double)ts.trials); LOG_M("y36864.m","y36864",y,36864,1,1); LOG_M("x36864.m","x36864",x,36864,1,1); - memset((void *)x,0,49152*sizeof(int32_t)); - for (i=2; i<28402; i++) { + + memset((void*)x,0,49152*sizeof(int32_t)); + for (i=2;i<28402;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; - } - - for (i=2*(49152-14400); i<98304; i++) { + ((int16_t*)x)[i] = -364; + } + for (i=2*(49152-14400);i<98304;i++) { if ((taus() & 1)==0) - ((int16_t *)x)[i] = 364; + ((int16_t*)x)[i] = 364; else - ((int16_t *)x)[i] = -364; + ((int16_t*)x)[i] = -364; } - reset_meas(&ts); - for (i=0; i<10000; i++) { start_meas(&ts); idft49152((int16_t *)x,(int16_t *)y,1); @@ -9715,22 +10629,22 @@ int main(int argc, char **argv) { memset((void*)x,0,dftsizes[n]*8*sizeof(int16_t)); for (i=0;i *(double *)p2; -} - double median(varArray_t *input) { return *(double *)((uint8_t *)(input+1)+(input->size/2)*input->atomSize); } diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 94214ab3b3..12aace577c 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -79,6 +79,9 @@ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ double DS_TDL = .03; +static int cmpdouble(const void *p1, const void *p2) { + return *(double *)p1 > *(double *)p2; +} int emulate_rf = 0; int split73=0; diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 37ce3a65d6..0443cde738 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -80,6 +80,9 @@ double t_tx_min = 1000000000; /*!< \brief initial min process time for tx */ double t_rx_min = 1000000000; /*!< \brief initial min process time for tx */ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ +static int cmpdouble(const void *p1, const void *p2) { + return *(double *)p1 > *(double *)p2; +} int split73=0; @@ -345,7 +348,7 @@ int main(int argc, char **argv) { unsigned short input_buffer_length; unsigned int ret; unsigned int coded_bits_per_codeword,nsymb; - unsigned int tx_lev=0,tx_lev_dB,trials,errs[4]= {0,0,0,0},round_trials[4]= {0,0,0,0}; + unsigned int tx_lev=0,tx_lev_dB,trials,errs[5]= {0,0,0,0,0},round_trials[4]= {0,0,0,0}; FILE *bler_fd=NULL; char bler_fname[512]; FILE *time_meas_fd=NULL; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 833b81f853..acfd5554ed 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -45,6 +45,7 @@ #include "openair1/SIMULATION/RF/rf.h" #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" +#include "openair1/PHY/MODULATION/nr_modulation.h" //#define DEBUG_NR_PBCHSIM diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 0d98840f5b..4ec2cf2b3e 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -19,6 +19,9 @@ * contact@openairinterface.org */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include "nr_pdcp_ue_manager.h" #include "NR_RadioBearerConfig.h" #include "NR_RLC-BearerConfig.h" @@ -43,6 +46,7 @@ static uint64_t pdcp_optmask; /* rlc_data_req queue - begin */ /****************************************************************************/ + #include /* NR PDCP and RLC both use "big locks". In some cases a thread may do @@ -92,6 +96,7 @@ static void *rlc_data_req_thread(void *_) { int i; + pthread_setname_np(pthread_self(), "RLC queue"); while (1) { if (pthread_mutex_lock(&q.m) != 0) abort(); while (q.length == 0) @@ -203,6 +208,7 @@ static void *enb_tun_read_thread(void *_) protocol_ctxt_t ctxt; int rb_id = 1; + pthread_setname_np( pthread_self(),"enb_tun_read"); while (1) { len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD); @@ -247,7 +253,7 @@ static void *ue_tun_read_thread(void *_) protocol_ctxt_t ctxt; int rb_id = 1; - + pthread_setname_np( pthread_self(),"ue_tun_read"); while (1) { len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD); if (len == -1) { diff --git a/openair3/NAS/COMMON/milenage.h b/openair3/NAS/COMMON/milenage.h index 24c02c406a..c5762a0d69 100644 --- a/openair3/NAS/COMMON/milenage.h +++ b/openair3/NAS/COMMON/milenage.h @@ -230,6 +230,8 @@ static bool milenage_generate(const u8 *opc, const u8 *amf, const u8 *k, Returns: 0 = success (sqn filled), -1 on failure */ #define p(a) printf("%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n", (int)((a)[0]), (int)((a)[1]), (int)((a)[2]), (int)((a)[3]),(int)((a)[4]), (int)((a)[5])); +// valid code but put in comment as it is not used right now +#if 0 static bool milenage_auts(const u8 *opc, const u8 *k, const u8 *_rand, const u8 *auts, u8 *sqn) { u8 amf[2] = { 0x00, 0x00 }; /* TS 33.102 v7.0.0, 6.3.3 */ @@ -350,3 +352,4 @@ static void milenage_opc_gen(const u8 *k, const u8 *op, u8 *opc) { opc[i] = opc[i] ^ op[i]; } #endif +#endif diff --git a/openair3/NAS/gNB/network_process_nas.c b/openair3/NAS/gNB/network_process_nas.c index a878d7c8a4..acd2f19fac 100644 --- a/openair3/NAS/gNB/network_process_nas.c +++ b/openair3/NAS/gNB/network_process_nas.c @@ -187,5 +187,6 @@ int securityModeCommand(void **msg, NRUEcontext_t *UE) { // KSI: N-NAS-int-alg 0x02 req->ngKSI=2; + *msg=req; return 0; } From c3f1029bdf546f3cfd9227dc19e2a6dd60752e62 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 22 Oct 2020 21:34:00 +0200 Subject: [PATCH 059/149] fixing bug for WORKER_ENABLE --- executables/nr-ru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index a093952dd0..478bba7833 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -2197,7 +2197,7 @@ void set_function_spec_param(RU_t *ru) { case REMOTE_IF4p5: ru->do_prach = 0; ru->feprx = NULL; // DFTs - ru->feptx_prec = (get_thread_worker_conf() == WORKER_ENABLE) ? NULL : nr_feptx_prec; // Precoding operation + ru->feptx_prec = nr_feptx_prec; // Precoding operation ru->feptx_ofdm = NULL; // no OFDM mod ru->fh_south_in = fh_if4p5_south_in; // synchronous IF4p5 reception ru->fh_south_out = fh_if4p5_south_out; // synchronous IF4p5 transmission From 32c8c8673079e3b6c45937412ca33c876d77479c Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 23 Oct 2020 13:28:48 +0200 Subject: [PATCH 060/149] fixing benetel drivers after introduction of multiple PRACH occastions --- targets/ARCH/ETHERNET/benetel/4g/benetel.c | 2 +- targets/ARCH/ETHERNET/benetel/5g/benetel.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/ARCH/ETHERNET/benetel/4g/benetel.c b/targets/ARCH/ETHERNET/benetel/4g/benetel.c index 37f55c689f..76855111e1 100644 --- a/targets/ARCH/ETHERNET/benetel/4g/benetel.c +++ b/targets/ARCH/ETHERNET/benetel/4g/benetel.c @@ -207,7 +207,7 @@ next: uint16_t *in; uint16_t *out; in = (uint16_t *)s->buffers.prach[*subframe]; - out = (uint16_t *)ru->prach_rxsigF[antenna]; + out = (uint16_t *)ru->prach_rxsigF[0][antenna]; for (i = 0; i < 840*2; i++) out[i] = ntohs(in[i]); s->buffers.prach_busy[*subframe] = 0; diff --git a/targets/ARCH/ETHERNET/benetel/5g/benetel.c b/targets/ARCH/ETHERNET/benetel/5g/benetel.c index c1ae1afcc7..72ecff6b34 100644 --- a/targets/ARCH/ETHERNET/benetel/5g/benetel.c +++ b/targets/ARCH/ETHERNET/benetel/5g/benetel.c @@ -215,7 +215,7 @@ next: uint16_t *in; uint16_t *out; in = (uint16_t *)s->buffers.prach[*slot]; - out = (uint16_t *)ru->prach_rxsigF[antenna]; + out = (uint16_t *)ru->prach_rxsigF[0][antenna]; for (i = 0; i < 839*2; i++) out[i] = ntohs(in[i]); s->buffers.prach_busy[*slot] = 0; From 3b56994113963128c6ce43c3ba428dc6a8cee714 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 23 Oct 2020 14:18:12 +0200 Subject: [PATCH 061/149] fixing warnings --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index e8b176b8ce..23d2274d58 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1670,7 +1670,7 @@ int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_ } else AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu); } - else AssertFatal(0==1, "Invalid Lmax %d for the synchronization block\n", Lmax); + else AssertFatal(0==1, "Invalid Lmax %u for the synchronization block\n", Lmax); } else return 0; @@ -1705,7 +1705,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; int slot_pbch; - int slot_ssb; + //int slot_ssb; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; fapi_nr_config_request_t *cfg = &ue->nrUE_config; @@ -1729,7 +1729,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, get_coreset_rballoc(pdcch_vars->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); slot_pbch = is_pbch_in_slot(cfg, frame_rx, nr_tti_rx, fp); - slot_ssb = is_ssb_in_slot(cfg, frame_rx, nr_tti_rx, fp); + //slot_ssb = is_ssb_in_slot(cfg, frame_rx, nr_tti_rx, fp); // looking for pbch only in slot where it is supposed to be if ((ue->decode_MIB == 1) && slot_pbch) From c737ea2f8f79637bfe12708d57a8347a5872aa67 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 23 Oct 2020 16:06:04 +0200 Subject: [PATCH 062/149] fixing issue with PRACH0 and multiple PRACH occasions --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 308 +++++++++--------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 4 +- 2 files changed, 156 insertions(+), 156 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index f968f1b926..e9b202188b 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -156,93 +156,93 @@ int16_t get_N_RA_RB (int delta_f_RA_PRACH,int delta_f_PUSCH) { // E.g. in row 20 and column 5 we have set value 66 ('0001000010') which means RACH can be sent at subframe 1 or 6 int64_t table_6_3_3_2_2_prachConfig_Index [256][9] = { //format, format, x, y, SFN_nbr, star_symb, slots_sfn, occ_slot, duration -{0, -1, 16, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{0, -1, 16, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{0, -1, 16, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{0, -1, 16, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{0, -1, 8, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{0, -1, 8, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{0, -1, 8, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{0, -1, 8, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{0, -1, 4, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{0, -1, 4, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{0, -1, 4, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{0, -1, 4, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{0, -1, 2, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{0, -1, 2, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{0, -1, 2, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{0, -1, 2, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{0, -1, 1, 0, 2, 0, -1, -1, 0}, // (subframe number) 1 -{0, -1, 1, 0, 16, 0, -1, -1, 0}, // (subframe number) 4 -{0, -1, 1, 0, 128, 0, -1, -1, 0}, // (subframe number) 7 -{0, -1, 1, 0, 66, 0, -1, -1, 0}, // (subframe number) 1,6 -{0, -1, 1, 0, 132, 0, -1, -1, 0}, // (subframe number) 2,7 -{0, -1, 1, 0, 264, 0, -1, -1, 0}, // (subframe number) 3,8 -{0, -1, 1, 0, 146, 0, -1, -1, 0}, // (subframe number) 1,4,7 -{0, -1, 1, 0, 292, 0, -1, -1, 0}, // (subframe number) 2,5,8 -{0, -1, 1, 0, 584, 0, -1, -1, 0}, // (subframe number) 3, 6, 9 -{0, -1, 1, 0, 341, 0, -1, -1, 0}, // (subframe number) 0,2,4,6,8 -{0, -1, 1, 0, 682, 0, -1, -1, 0}, // (subframe number) 1,3,5,7,9 -{0, -1, 1, 0, 1023, 0, -1, -1, 0}, // (subframe number) 0,1,2,3,4,5,6,7,8,9 -{1, -1, 16, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{1, -1, 16, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{1, -1, 16, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{1, -1, 16, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{1, -1, 8, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{1, -1, 8, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{1, -1, 8, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{1, -1, 8, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{1, -1, 4, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{1, -1, 4, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{1, -1, 4, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{1, -1, 4, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{1, -1, 2, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{1, -1, 2, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{1, -1, 2, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{1, -1, 2, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{1, -1, 1, 0, 2, 0, -1, -1, 0}, // (subframe number) 1 -{1, -1, 1, 0, 16, 0, -1, -1, 0}, // (subframe number) 4 -{1, -1, 1, 0, 128, 0, -1, -1, 0}, // (subframe number) 7 -{1, -1, 1, 0, 66, 0, -1, -1, 0}, // (subframe number) 1,6 -{1, -1, 1, 0, 132, 0, -1, -1, 0}, // (subframe number) 2,7 -{1, -1, 1, 0, 264, 0, -1, -1, 0}, // (subframe number) 3,8 -{1, -1, 1, 0, 146, 0, -1, -1, 0}, // (subframe number) 1,4,7 -{1, -1, 1, 0, 292, 0, -1, -1, 0}, // (subframe number) 2,5,8 -{1, -1, 1, 0, 584, 0, -1, -1, 0}, // (subframe number) 3,6,9 -{2, -1, 16, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{2, -1, 8, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{2, -1, 4, 0, 2, 0, -1, -1, 0}, // (subframe number) 1 -{2, -1, 2, 0, 2, 0, -1, -1, 0}, // (subframe number) 1 -{2, -1, 2, 0, 32, 0, -1, -1, 0}, // (subframe number) 5 -{2, -1, 1, 0, 2, 0, -1, -1, 0}, // (subframe number) 1 -{2, -1, 1, 0, 32, 0, -1, -1, 0}, // (subframe number) 5 -{3, -1, 16, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{3, -1, 16, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{3, -1, 16, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{3, -1, 16, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{3, -1, 8, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{3, -1, 8, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{3, -1, 8, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{3, -1, 4, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{3, -1, 4, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{3, -1, 4, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{3, -1, 4, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{3, -1, 2, 1, 2, 0, -1, -1, 0}, // (subframe number) 1 -{3, -1, 2, 1, 16, 0, -1, -1, 0}, // (subframe number) 4 -{3, -1, 2, 1, 128, 0, -1, -1, 0}, // (subframe number) 7 -{3, -1, 2, 1, 512, 0, -1, -1, 0}, // (subframe number) 9 -{3, -1, 1, 0, 2, 0, -1, -1, 0}, // (subframe number) 1 -{3, -1, 1, 0, 16, 0, -1, -1, 0}, // (subframe number) 4 -{3, -1, 1, 0, 128, 0, -1, -1, 0}, // (subframe number) 7 -{3, -1, 1, 0, 66, 0, -1, -1, 0}, // (subframe number) 1,6 -{3, -1, 1, 0, 132, 0, -1, -1, 0}, // (subframe number) 2,7 -{3, -1, 1, 0, 264, 0, -1, -1, 0}, // (subframe number) 3,8 -{3, -1, 1, 0, 146, 0, -1, -1, 0}, // (subframe number) 1,4,7 -{3, -1, 1, 0, 292, 0, -1, -1, 0}, // (subframe number) 2,5,8 -{3, -1, 1, 0, 584, 0, -1, -1, 0}, // (subframe number) 3, 6, 9 -{3, -1, 1, 0, 341, 0, -1, -1, 0}, // (subframe number) 0,2,4,6,8 -{3, -1, 1, 0, 682, 0, -1, -1, 0}, // (subframe number) 1,3,5,7,9 -{3, -1, 1, 0, 1023, 0, -1, -1, 0}, // (subframe number) 0,1,2,3,4,5,6,7,8,9 +{0, -1, 16, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{0, -1, 16, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{0, -1, 16, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{0, -1, 16, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{0, -1, 8, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{0, -1, 8, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{0, -1, 8, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{0, -1, 8, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{0, -1, 4, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{0, -1, 4, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{0, -1, 4, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{0, -1, 4, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{0, -1, 2, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{0, -1, 2, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{0, -1, 2, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{0, -1, 2, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{0, -1, 1, 0, 2, 0, 1, 1, 0}, // (subframe number) 1 +{0, -1, 1, 0, 16, 0, 1, 1, 0}, // (subframe number) 4 +{0, -1, 1, 0, 128, 0, 1, 1, 0}, // (subframe number) 7 +{0, -1, 1, 0, 66, 0, 1, 1, 0}, // (subframe number) 1,6 +{0, -1, 1, 0, 132, 0, 1, 1, 0}, // (subframe number) 2,7 +{0, -1, 1, 0, 264, 0, 1, 1, 0}, // (subframe number) 3,8 +{0, -1, 1, 0, 146, 0, 1, 1, 0}, // (subframe number) 1,4,7 +{0, -1, 1, 0, 292, 0, 1, 1, 0}, // (subframe number) 2,5,8 +{0, -1, 1, 0, 584, 0, 1, 1, 0}, // (subframe number) 3, 6, 9 +{0, -1, 1, 0, 341, 0, 1, 1, 0}, // (subframe number) 0,2,4,6,8 +{0, -1, 1, 0, 682, 0, 1, 1, 0}, // (subframe number) 1,3,5,7,9 +{0, -1, 1, 0, 1023, 0, 1, 1, 0}, // (subframe number) 0,1,2,3,4,5,6,7,8,9 +{1, -1, 16, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{1, -1, 16, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{1, -1, 16, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{1, -1, 16, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{1, -1, 8, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{1, -1, 8, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{1, -1, 8, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{1, -1, 8, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{1, -1, 4, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{1, -1, 4, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{1, -1, 4, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{1, -1, 4, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{1, -1, 2, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{1, -1, 2, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{1, -1, 2, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{1, -1, 2, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{1, -1, 1, 0, 2, 0, 1, 1, 0}, // (subframe number) 1 +{1, -1, 1, 0, 16, 0, 1, 1, 0}, // (subframe number) 4 +{1, -1, 1, 0, 128, 0, 1, 1, 0}, // (subframe number) 7 +{1, -1, 1, 0, 66, 0, 1, 1, 0}, // (subframe number) 1,6 +{1, -1, 1, 0, 132, 0, 1, 1, 0}, // (subframe number) 2,7 +{1, -1, 1, 0, 264, 0, 1, 1, 0}, // (subframe number) 3,8 +{1, -1, 1, 0, 146, 0, 1, 1, 0}, // (subframe number) 1,4,7 +{1, -1, 1, 0, 292, 0, 1, 1, 0}, // (subframe number) 2,5,8 +{1, -1, 1, 0, 584, 0, 1, 1, 0}, // (subframe number) 3,6,9 +{2, -1, 16, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{2, -1, 8, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{2, -1, 4, 0, 2, 0, 1, 1, 0}, // (subframe number) 1 +{2, -1, 2, 0, 2, 0, 1, 1, 0}, // (subframe number) 1 +{2, -1, 2, 0, 32, 0, 1, 1, 0}, // (subframe number) 5 +{2, -1, 1, 0, 2, 0, 1, 1, 0}, // (subframe number) 1 +{2, -1, 1, 0, 32, 0, 1, 1, 0}, // (subframe number) 5 +{3, -1, 16, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{3, -1, 16, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{3, -1, 16, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{3, -1, 16, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{3, -1, 8, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{3, -1, 8, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{3, -1, 8, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{3, -1, 4, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{3, -1, 4, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{3, -1, 4, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{3, -1, 4, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{3, -1, 2, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 +{3, -1, 2, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 +{3, -1, 2, 1, 128, 0, 1, 1, 0}, // (subframe number) 7 +{3, -1, 2, 1, 512, 0, 1, 1, 0}, // (subframe number) 9 +{3, -1, 1, 0, 2, 0, 1, 1, 0}, // (subframe number) 1 +{3, -1, 1, 0, 16, 0, 1, 1, 0}, // (subframe number) 4 +{3, -1, 1, 0, 128, 0, 1, 1, 0}, // (subframe number) 7 +{3, -1, 1, 0, 66, 0, 1, 1, 0}, // (subframe number) 1,6 +{3, -1, 1, 0, 132, 0, 1, 1, 0}, // (subframe number) 2,7 +{3, -1, 1, 0, 264, 0, 1, 1, 0}, // (subframe number) 3,8 +{3, -1, 1, 0, 146, 0, 1, 1, 0}, // (subframe number) 1,4,7 +{3, -1, 1, 0, 292, 0, 1, 1, 0}, // (subframe number) 2,5,8 +{3, -1, 1, 0, 584, 0, 1, 1, 0}, // (subframe number) 3, 6, 9 +{3, -1, 1, 0, 341, 0, 1, 1, 0}, // (subframe number) 0,2,4,6,8 +{3, -1, 1, 0, 682, 0, 1, 1, 0}, // (subframe number) 1,3,5,7,9 +{3, -1, 1, 0, 1023, 0, 1, 1, 0}, // (subframe number) 0,1,2,3,4,5,6,7,8,9 {0xa1, -1, 16, 0, 528, 0, 1, 6, 2}, // (subframe number) 4,9 {0xa1, -1, 16, 1, 16, 0, 2, 6, 2}, // (subframe number) 4 {0xa1, -1, 8, 0, 528, 0, 1, 6, 2}, // (subframe number) 4,9 @@ -416,73 +416,73 @@ int64_t table_6_3_3_2_2_prachConfig_Index [256][9] = { // Table 6.3.3.2-3: Random access configurations for FR1 and unpaired spectrum int64_t table_6_3_3_2_3_prachConfig_Index [256][9] = { //format, format, x, y, SFN_nbr, star_symb, slots_sfn, occ_slot, duration -{0, -1, 16, 1, 512, 0, -1, -1, 0}, // (subrame number 9) -{0, -1, 8, 1, 512, 0, -1, -1, 0}, // (subrame number 9) -{0, -1, 4, 1, 512, 0, -1, -1, 0}, // (subrame number 9) -{0, -1, 2, 0, 512, 0, -1, -1, 0}, // (subrame number 9) -{0, -1, 2, 1, 512, 0, -1, -1, 0}, // (subrame number 9) -{0, -1, 2, 0, 16, 0, -1, -1, 0}, // (subrame number 4) -{0, -1, 2, 1, 16, 0, -1, -1, 0}, // (subrame number 4) -{0, -1, 1, 0, 512, 0, -1, -1, 0}, // (subrame number 9) -{0, -1, 1, 0, 256, 0, -1, -1, 0}, // (subrame number 8) -{0, -1, 1, 0, 128, 0, -1, -1, 0}, // (subrame number 7) -{0, -1, 1, 0, 64, 0, -1, -1, 0}, // (subrame number 6) -{0, -1, 1, 0, 32, 0, -1, -1, 0}, // (subrame number 5) -{0, -1, 1, 0, 16, 0, -1, -1, 0}, // (subrame number 4) -{0, -1, 1, 0, 8, 0, -1, -1, 0}, // (subrame number 3) -{0, -1, 1, 0, 4, 0, -1, -1, 0}, // (subrame number 2) -{0, -1, 1, 0, 66, 0, -1, -1, 0}, // (subrame number 1,6) -{0, -1, 1, 0, 66, 7, -1, -1, 0}, // (subrame number 1,6) -{0, -1, 1, 0, 528, 0, -1, -1, 0}, // (subrame number 4,9) -{0, -1, 1, 0, 264, 0, -1, -1, 0}, // (subrame number 3,8) -{0, -1, 1, 0, 132, 0, -1, -1, 0}, // (subrame number 2,7) -{0, -1, 1, 0, 768, 0, -1, -1, 0}, // (subrame number 8,9) -{0, -1, 1, 0, 784, 0, -1, -1, 0}, // (subrame number 4,8,9) -{0, -1, 1, 0, 536, 0, -1, -1, 0}, // (subrame number 3,4,9) -{0, -1, 1, 0, 896, 0, -1, -1, 0}, // (subrame number 7,8,9) -{0, -1, 1, 0, 792, 0, -1, -1, 0}, // (subrame number 3,4,8,9) -{0, -1, 1, 0, 960, 0, -1, -1, 0}, // (subrame number 6,7,8,9) -{0, -1, 1, 0, 594, 0, -1, -1, 0}, // (subrame number 1,4,6,9) -{0, -1, 1, 0, 682, 0, -1, -1, 0}, // (subrame number 1,3,5,7,9) -{1, -1, 16, 1, 128, 0, -1, -1, 0}, // (subrame number 7) -{1, -1, 8, 1, 128, 0, -1, -1, 0}, // (subrame number 7) -{1, -1, 4, 1, 128, 0, -1, -1, 0}, // (subrame number 7) -{1, -1, 2, 0, 128, 0, -1, -1, 0}, // (subrame number 7) -{1, -1, 2, 1, 128, 0, -1, -1, 0}, // (subrame number 7) -{1, -1, 1, 0, 128, 0, -1, -1, 0}, // (subrame number 7) -{2, -1, 16, 1, 64, 0, -1, -1, 0}, // (subrame number 6) -{2, -1, 8, 1, 64, 0, -1, -1, 0}, // (subrame number 6) -{2, -1, 4, 1, 64, 0, -1, -1, 0}, // (subrame number 6) -{2, -1, 2, 0, 64, 7, -1, -1, 0}, // (subrame number 6) -{2, -1, 2, 1, 64, 7, -1, -1, 0}, // (subrame number 6) -{2, -1, 1, 0, 64, 7, -1, -1, 0}, // (subrame number 6) -{3, -1, 16, 1, 512, 0, -1, -1, 0}, // (subrame number 9) -{3, -1, 8, 1, 512, 0, -1, -1, 0}, // (subrame number 9) -{3, -1, 4, 1, 512, 0, -1, -1, 0}, // (subrame number 9) -{3, -1, 2, 0, 512, 0, -1, -1, 0}, // (subrame number 9) -{3, -1, 2, 1, 512, 0, -1, -1, 0}, // (subrame number 9) -{3, -1, 2, 0, 16, 0, -1, -1, 0}, // (subrame number 4) -{3, -1, 2, 1, 16, 0, -1, -1, 0}, // (subrame number 4) -{3, -1, 1, 0, 512, 0, -1, -1, 0}, // (subrame number 9) -{3, -1, 1, 0, 256, 0, -1, -1, 0}, // (subrame number 8) -{3, -1, 1, 0, 128, 0, -1, -1, 0}, // (subrame number 7) -{3, -1, 1, 0, 64, 0, -1, -1, 0}, // (subrame number 6) -{3, -1, 1, 0, 32, 0, -1, -1, 0}, // (subrame number 5) -{3, -1, 1, 0, 16, 0, -1, -1, 0}, // (subrame number 4) -{3, -1, 1, 0, 8, 0, -1, -1, 0}, // (subrame number 3) -{3, -1, 1, 0, 4, 0, -1, -1, 0}, // (subrame number 2) -{3, -1, 1, 0, 66, 0, -1, -1, 0}, // (subrame number 1,6) -{3, -1, 1, 0, 66, 7, -1, -1, 0}, // (subrame number 1,6) -{3, -1, 1, 0, 528, 0, -1, -1, 0}, // (subrame number 4,9) -{3, -1, 1, 0, 264, 0, -1, -1, 0}, // (subrame number 3,8) -{3, -1, 1, 0, 132, 0, -1, -1, 0}, // (subrame number 2,7) -{3, -1, 1, 0, 768, 0, -1, -1, 0}, // (subrame number 8,9) -{3, -1, 1, 0, 784, 0, -1, -1, 0}, // (subrame number 4,8,9) -{3, -1, 1, 0, 536, 0, -1, -1, 0}, // (subrame number 3,4,9) -{3, -1, 1, 0, 896, 0, -1, -1, 0}, // (subrame number 7,8,9) -{3, -1, 1, 0, 792, 0, -1, -1, 0}, // (subrame number 3,4,8,9) -{3, -1, 1, 0, 594, 0, -1, -1, 0}, // (subrame number 1,4,6,9) -{3, -1, 1, 0, 682, 0, -1, -1, 0}, // (subrame number 1,3,5,7,9) +{0, -1, 16, 1, 512, 0, 1, 1, 0}, // (subrame number 9) +{0, -1, 8, 1, 512, 0, 1, 1, 0}, // (subrame number 9) +{0, -1, 4, 1, 512, 0, 1, 1, 0}, // (subrame number 9) +{0, -1, 2, 0, 512, 0, 1, 1, 0}, // (subrame number 9) +{0, -1, 2, 1, 512, 0, 1, 1, 0}, // (subrame number 9) +{0, -1, 2, 0, 16, 0, 1, 1, 0}, // (subrame number 4) +{0, -1, 2, 1, 16, 0, 1, 1, 0}, // (subrame number 4) +{0, -1, 1, 0, 512, 0, 1, 1, 0}, // (subrame number 9) +{0, -1, 1, 0, 256, 0, 1, 1, 0}, // (subrame number 8) +{0, -1, 1, 0, 128, 0, 1, 1, 0}, // (subrame number 7) +{0, -1, 1, 0, 64, 0, 1, 1, 0}, // (subrame number 6) +{0, -1, 1, 0, 32, 0, 1, 1, 0}, // (subrame number 5) +{0, -1, 1, 0, 16, 0, 1, 1, 0}, // (subrame number 4) +{0, -1, 1, 0, 8, 0, 1, 1, 0}, // (subrame number 3) +{0, -1, 1, 0, 4, 0, 1, 1, 0}, // (subrame number 2) +{0, -1, 1, 0, 66, 0, 1, 1, 0}, // (subrame number 1,6) +{0, -1, 1, 0, 66, 7, 1, 1, 0}, // (subrame number 1,6) +{0, -1, 1, 0, 528, 0, 1, 1, 0}, // (subrame number 4,9) +{0, -1, 1, 0, 264, 0, 1, 1, 0}, // (subrame number 3,8) +{0, -1, 1, 0, 132, 0, 1, 1, 0}, // (subrame number 2,7) +{0, -1, 1, 0, 768, 0, 1, 1, 0}, // (subrame number 8,9) +{0, -1, 1, 0, 784, 0, 1, 1, 0}, // (subrame number 4,8,9) +{0, -1, 1, 0, 536, 0, 1, 1, 0}, // (subrame number 3,4,9) +{0, -1, 1, 0, 896, 0, 1, 1, 0}, // (subrame number 7,8,9) +{0, -1, 1, 0, 792, 0, 1, 1, 0}, // (subrame number 3,4,8,9) +{0, -1, 1, 0, 960, 0, 1, 1, 0}, // (subrame number 6,7,8,9) +{0, -1, 1, 0, 594, 0, 1, 1, 0}, // (subrame number 1,4,6,9) +{0, -1, 1, 0, 682, 0, 1, 1, 0}, // (subrame number 1,3,5,7,9) +{1, -1, 16, 1, 128, 0, 1, 1, 0}, // (subrame number 7) +{1, -1, 8, 1, 128, 0, 1, 1, 0}, // (subrame number 7) +{1, -1, 4, 1, 128, 0, 1, 1, 0}, // (subrame number 7) +{1, -1, 2, 0, 128, 0, 1, 1, 0}, // (subrame number 7) +{1, -1, 2, 1, 128, 0, 1, 1, 0}, // (subrame number 7) +{1, -1, 1, 0, 128, 0, 1, 1, 0}, // (subrame number 7) +{2, -1, 16, 1, 64, 0, 1, 1, 0}, // (subrame number 6) +{2, -1, 8, 1, 64, 0, 1, 1, 0}, // (subrame number 6) +{2, -1, 4, 1, 64, 0, 1, 1, 0}, // (subrame number 6) +{2, -1, 2, 0, 64, 7, 1, 1, 0}, // (subrame number 6) +{2, -1, 2, 1, 64, 7, 1, 1, 0}, // (subrame number 6) +{2, -1, 1, 0, 64, 7, 1, 1, 0}, // (subrame number 6) +{3, -1, 16, 1, 512, 0, 1, 1, 0}, // (subrame number 9) +{3, -1, 8, 1, 512, 0, 1, 1, 0}, // (subrame number 9) +{3, -1, 4, 1, 512, 0, 1, 1, 0}, // (subrame number 9) +{3, -1, 2, 0, 512, 0, 1, 1, 0}, // (subrame number 9) +{3, -1, 2, 1, 512, 0, 1, 1, 0}, // (subrame number 9) +{3, -1, 2, 0, 16, 0, 1, 1, 0}, // (subrame number 4) +{3, -1, 2, 1, 16, 0, 1, 1, 0}, // (subrame number 4) +{3, -1, 1, 0, 512, 0, 1, 1, 0}, // (subrame number 9) +{3, -1, 1, 0, 256, 0, 1, 1, 0}, // (subrame number 8) +{3, -1, 1, 0, 128, 0, 1, 1, 0}, // (subrame number 7) +{3, -1, 1, 0, 64, 0, 1, 1, 0}, // (subrame number 6) +{3, -1, 1, 0, 32, 0, 1, 1, 0}, // (subrame number 5) +{3, -1, 1, 0, 16, 0, 1, 1, 0}, // (subrame number 4) +{3, -1, 1, 0, 8, 0, 1, 1, 0}, // (subrame number 3) +{3, -1, 1, 0, 4, 0, 1, 1, 0}, // (subrame number 2) +{3, -1, 1, 0, 66, 0, 1, 1, 0}, // (subrame number 1,6) +{3, -1, 1, 0, 66, 7, 1, 1, 0}, // (subrame number 1,6) +{3, -1, 1, 0, 528, 0, 1, 1, 0}, // (subrame number 4,9) +{3, -1, 1, 0, 264, 0, 1, 1, 0}, // (subrame number 3,8) +{3, -1, 1, 0, 132, 0, 1, 1, 0}, // (subrame number 2,7) +{3, -1, 1, 0, 768, 0, 1, 1, 0}, // (subrame number 8,9) +{3, -1, 1, 0, 784, 0, 1, 1, 0}, // (subrame number 4,8,9) +{3, -1, 1, 0, 536, 0, 1, 1, 0}, // (subrame number 3,4,9) +{3, -1, 1, 0, 896, 0, 1, 1, 0}, // (subrame number 7,8,9) +{3, -1, 1, 0, 792, 0, 1, 1, 0}, // (subrame number 3,4,8,9) +{3, -1, 1, 0, 594, 0, 1, 1, 0}, // (subrame number 1,4,6,9) +{3, -1, 1, 0, 682, 0, 1, 1, 0}, // (subrame number 1,3,5,7,9) {0xa1, -1, 16, 1, 512, 0, 2, 6, 2}, // (subrame number 9) {0xa1, -1, 8, 1, 512, 0, 2, 6, 2}, // (subrame number 9) {0xa1, -1, 4, 1, 512, 0, 1, 6, 2}, // (subrame number 9) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index af40c9ccd8..d458f0f94b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -70,7 +70,7 @@ int16_t ssb_index_from_prach(module_id_t module_idP, float num_ssb_per_RO = ssb_per_rach_occasion[cfg->prach_config.ssb_per_rach.value]; uint16_t start_symbol_index = 0; - uint8_t mu,N_dur,N_t_slot,start_symbol = 0, temp_start_symbol = 0, N_RA_slot; + uint8_t mu,N_dur=0,N_t_slot=0,start_symbol = 0, temp_start_symbol = 0, N_RA_slot=0; uint16_t format,RA_sfn_index = -1; uint8_t config_period = 1; uint16_t prach_occasion_id = -1; @@ -139,7 +139,7 @@ void find_SSB_and_RO_available(module_id_t module_idP) { nfapi_nr_config_request_scf_t *cfg = &RC.nrmac[module_idP]->config[0]; uint8_t config_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex; - uint8_t mu,N_dur,N_t_slot,start_symbol,N_RA_slot = 0; + uint8_t mu,N_dur=0,N_t_slot=0,start_symbol=0,N_RA_slot = 0; uint16_t format,N_RA_sfn = 0,unused_RA_occasion,repetition = 0; uint8_t num_active_ssb = 0; uint8_t max_association_period = 1; From 29f7a5082ab7e7e2c6fb15353e5e329543c52deb Mon Sep 17 00:00:00 2001 From: cig Date: Fri, 11 Sep 2020 17:35:10 +0200 Subject: [PATCH 063/149] Introduced configuration of RU IF offset from configuration file - the RU now supports IF equipment with custom FR1 TX/RX frequencies - this configuration parameter together with the if_freq parameter allows to set a custom IF RX frequency for the gNB - if the IF offset is not specified, legacy code applies --- executables/nr-ru.c | 8 ++++++-- openair1/PHY/defs_RU.h | 2 ++ openair2/ENB_APP/enb_paramdef.h | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index ede6ff2458..38d8ee09be 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1149,8 +1149,11 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { if (ru->if_frequency == 0) { cfg->tx_freq[i] = (double)fp->dl_CarrierFreq; cfg->rx_freq[i] = (double)fp->ul_CarrierFreq; - } - else { + } else if (ru->if_freq_offset){ + cfg->tx_freq[i] = (double)(ru->if_frequency); + cfg->rx_freq[i] = (double)(ru->if_frequency + ru->if_freq_offset); + LOG_I(PHY, "Setting IF TX frequency to %lu Hz with IF RX frequency offset %d Hz\n", ru->if_frequency, ru->if_freq_offset); + } else { cfg->tx_freq[i] = (double)ru->if_frequency; cfg->rx_freq[i] = (double)(ru->if_frequency+fp->ul_CarrierFreq-fp->dl_CarrierFreq); } @@ -2494,6 +2497,7 @@ void RCconfig_RU(void) RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); RC.ru[j]->if_frequency = *(RUParamList.paramarray[j][RU_IF_FREQUENCY].u64ptr); + RC.ru[j]->if_freq_offset = *(RUParamList.paramarray[j][RU_IF_FREQ_OFFSET].iptr); if (config_isparamset(RUParamList.paramarray[j], RU_BF_WEIGHTS_LIST_IDX)) { RC.ru[j]->nb_bfw = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].numelt; diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h index 15300426f3..b465a51a2a 100644 --- a/openair1/PHY/defs_RU.h +++ b/openair1/PHY/defs_RU.h @@ -624,6 +624,8 @@ typedef struct RU_t_s { int wakeup_L1_sleep_cnt_max; /// DL IF frequency in Hz uint64_t if_frequency; + /// UL IF frequency offset to DL IF frequency in Hz + int if_freq_offset; } RU_t; diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index d2372c944c..24240e5ae1 100644 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -96,6 +96,7 @@ typedef enum { #define CONFIG_STRING_RU_OTA_SYNC_ENABLE "ota_sync_enabled" #define CONFIG_STRING_RU_BF_WEIGHTS_LIST "bf_weights" #define CONFIG_STRING_RU_IF_FREQUENCY "if_freq" +#define CONFIG_STRING_RU_IF_FREQ_OFFSET "if_offset" #define RU_LOCAL_IF_NAME_IDX 0 #define RU_LOCAL_ADDRESS_IDX 1 @@ -124,6 +125,7 @@ typedef enum { #define RU_OTA_SYNC_ENABLE_IDX 24 #define RU_BF_WEIGHTS_LIST_IDX 25 #define RU_IF_FREQUENCY 26 +#define RU_IF_FREQ_OFFSET 27 /*-----------------------------------------------------------------------------------------------------------------------------------------*/ /* RU configuration parameters */ @@ -157,6 +159,7 @@ typedef enum { {CONFIG_STRING_RU_OTA_SYNC_ENABLE, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \ {CONFIG_STRING_RU_BF_WEIGHTS_LIST, NULL, 0, iptr:NULL, defintarrayval:DEFBFW, TYPE_INTARRAY, 0}, \ {CONFIG_STRING_RU_IF_FREQUENCY, NULL, 0, u64ptr:NULL, defuintval:0, TYPE_UINT64, 0}, \ + {CONFIG_STRING_RU_IF_FREQ_OFFSET, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ } /*---------------------------------------------------------------------------------------------------------------------------------------*/ From 609844a37982f034de1d737d596acf0195cf3075 Mon Sep 17 00:00:00 2001 From: cig Date: Tue, 15 Sep 2020 13:40:06 +0200 Subject: [PATCH 064/149] Small code cleanup gNB - removed long-time commented out and unused code - fixed logging --- executables/nr-ru.c | 2 +- openair1/PHY/INIT/nr_init.c | 29 ----------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 38d8ee09be..61c8ff6b28 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1160,7 +1160,7 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->tx_gain[i] = ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx; cfg->configFilename = rf_config_file; - printf("channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", + LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %d Hz, rx_freq %d Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], cfg->tx_freq[i], diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 005ede615b..b1c197074e 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -434,35 +434,6 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { NR_DL_FRAME_PARMS *fp = &RC.gNB[Mod_id]->frame_parms; nfapi_nr_config_request_scf_t *gNB_config = &RC.gNB[Mod_id]->gNB_config; - /* - gNB_config->cell_config.phy_cell_id.value = phy_config->cfg->cell_config.phy_cell_id.value; - gNB_config->carrier_config.dl_frequency.value = phy_config->cfg->carrier_config.dl_frequency.value; - gNB_config->carrier_config.uplink_frequency.value = phy_config->cfg->carrier_config.uplink_frequency.value; - gNB_config->ssb_config.scs_common.value = phy_config->cfg->ssb_config.scs_common.value; - gNB_config->carrier_config.dl_bandwidth.value = phy_config->cfg->carrier_config.dl_bandwidth.value; - gNB_config->carrier_config.uplink_bandwidth.value = phy_config->cfg->carrier_config.uplink_bandwidth.value; - gNB_config->ssb_table.ssb_subcarrier_offset.value = phy_config->cfg->ssb_table.ssb_subcarrier_offset.value; - gNB_config->ssb_table.ssb_offset_point_a.value = phy_config->cfg->ssb_table.ssb_offset_point_a.value; - gNB_config->ssb_table.ssb_mask_list[0].ssb_mask.value = phy_config->cfg->ssb_table.ssb_mask_list[0].ssb_mask.value; - gNB_config->ssb_table.ssb_mask_list[1].ssb_mask.value = phy_config->cfg->ssb_table.ssb_mask_list[1].ssb_mask.value; - gNB_config->ssb_table.ssb_period.value = phy_config->cfg->ssb_table.ssb_period.value; - for (int i=0; i<5; i++) { - gNB_config->carrier_config.dl_grid_size[i].value = phy_config->cfg->carrier_config.dl_grid_size[i].value; - gNB_config->carrier_config.ul_grid_size[i].value = phy_config->cfg->carrier_config.ul_grid_size[i].value; - gNB_config->carrier_config.dl_k0[i].value = phy_config->cfg->carrier_config.dl_k0[i].value; - gNB_config->carrier_config.ul_k0[i].value = phy_config->cfg->carrier_config.ul_k0[i].value; - } - - - if (phy_config->cfg->cell_config.frame_duplex_type.value == 0) { - gNB_config->cell_config.frame_duplex_type.value = FDD; - } else { - gNB_config->cell_config.frame_duplex_type.value = TDD; - } - - memcpy((void*)&gNB_config->prach_config,(void*)&phy_config->cfg->prach_config,sizeof(phy_config->cfg->prach_config)); - memcpy((void*)&gNB_config->tdd_table,(void*)&phy_config->cfg->tdd_table,sizeof(phy_config->cfg->tdd_table)); - */ memcpy((void*)gNB_config,phy_config->cfg,sizeof(*phy_config->cfg)); RC.gNB[Mod_id]->mac_enabled = 1; From 60d81f231a0b82dc2b1b6be683cd73f0eae1fea1 Mon Sep 17 00:00:00 2001 From: cig Date: Tue, 15 Sep 2020 13:55:29 +0200 Subject: [PATCH 065/149] Configuration changes to support FDD - adapted the get_band function: the algorithm is now taking into account also the UL frequency in order to fetch the proper band (this was failing before as some NR bands have the same DL band, e.g. band 65 and 66) - added new bands to the NR table as per TS 38.101 V16.4.0 (2020) - made the from_nrarfcn function compatible with UL FDD (this function, used for both DL and UL was previously working with TDD only as it did not compute properly the frequency for the UL FDD, throwing asserts) - introduced common functions to get the NR table idx and the duplex mode, removing repeated code in the process - removed the unused function to get the uldl offset - improved some logging - other minor fixes to the relevant code --- executables/nr-ru.c | 6 +- openair1/PHY/INIT/nr_init.c | 13 +- openair1/PHY/INIT/nr_parms.c | 4 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 179 ++++++++++++------ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 4 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 1 + openair2/LAYER2/NR_MAC_gNB/config.c | 1 + openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 - 8 files changed, 136 insertions(+), 74 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 61c8ff6b28..64ca24204c 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1160,11 +1160,11 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->tx_gain[i] = ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %d Hz, rx_freq %d Hz\n", + LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %lu Hz, rx_freq %lu Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], - cfg->tx_freq[i], - cfg->rx_freq[i]); + (unsigned long)cfg->tx_freq[i], + (unsigned long)cfg->rx_freq[i]); } } diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index b1c197074e..0b4193a617 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -45,8 +45,6 @@ /* extern uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_nrarfcn); - -extern int32_t get_nr_uldl_offset(int nr_bandP); extern openair0_config_t openair0_cfg[MAX_CARDS]; */ @@ -433,22 +431,21 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { uint8_t short_sequence, num_sequences, rootSequenceIndex, fd_occasion; NR_DL_FRAME_PARMS *fp = &RC.gNB[Mod_id]->frame_parms; nfapi_nr_config_request_scf_t *gNB_config = &RC.gNB[Mod_id]->gNB_config; + int32_t dlul_offset = 0; + lte_frame_type_t frame_type = 0; memcpy((void*)gNB_config,phy_config->cfg,sizeof(*phy_config->cfg)); RC.gNB[Mod_id]->mac_enabled = 1; uint64_t dl_bw_khz = (12*gNB_config->carrier_config.dl_grid_size[gNB_config->ssb_config.scs_common.value].value)*(15<ssb_config.scs_common.value); fp->dl_CarrierFreq = ((dl_bw_khz>>1) + gNB_config->carrier_config.dl_frequency.value)*1000 ; - - int32_t dlul_offset = 0; - lte_frame_type_t frame_type = 0; - get_band(fp->dl_CarrierFreq,&fp->nr_band,&dlul_offset,&frame_type); - uint64_t ul_bw_khz = (12*gNB_config->carrier_config.ul_grid_size[gNB_config->ssb_config.scs_common.value].value)*(15<ssb_config.scs_common.value); fp->ul_CarrierFreq = ((ul_bw_khz>>1) + gNB_config->carrier_config.uplink_frequency.value)*1000 ; - AssertFatal(fp->ul_CarrierFreq==(fp->dl_CarrierFreq+dlul_offset), "Disagreement in uplink frequency for band %d\n", fp->nr_band); + get_band(fp->dl_CarrierFreq, fp->ul_CarrierFreq, &fp->nr_band, &dlul_offset, &frame_type); + + AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + dlul_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + dlul_offset); fp->threequarter_fs = openair0_cfg[0].threequarter_fs; LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 6045930b17..31b53ae1be 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -331,10 +331,10 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, int32_t uplink_frequency_offset = 0; - get_band(fp->dl_CarrierFreq, &fp->nr_band, &uplink_frequency_offset, &fp->frame_type); + get_band(fp->dl_CarrierFreq, fp->ul_CarrierFreq, &fp->nr_band, &uplink_frequency_offset, &fp->frame_type); AssertFatal(fp->frame_type==config->cell_config.frame_duplex_type, "Invalid duplex type in config request file for band %d\n", fp->nr_band); - AssertFatal(fp->ul_CarrierFreq==(fp->dl_CarrierFreq+uplink_frequency_offset), "Disagreement in uplink frequency for band %d\n", fp->nr_band); + AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + uplink_frequency_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + uplink_frequency_offset); #if DISABLE_LOG_X printf("Initializing UE frame parms for mu %d, N_RB %d, Ncp %d\n",fp->numerology_index, fp->N_RB_DL, Ncp); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index f968f1b926..817ccac785 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -49,6 +49,7 @@ uint16_t NCS_restricted_TypeB_delta_f_RA_5[14] = {36,57,60,63,65,68,71,77,81,8 uint16_t NCS_unrestricted_delta_f_RA_15[16] = {0,2,4,6,8,10,12,13,15,17,19,23,27,34,46,69}; const char *prachfmt[]={"0","1","2","3", "A1","A2","A3","B1","B4","C0","C2","A1/B1","A2/B2","A3/B3"}; +const char *duplex_mode[]={"FDD","TDD"}; uint16_t get_NCS(uint8_t index, uint16_t format0, uint8_t restricted_set_config) { @@ -1443,7 +1444,12 @@ uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config, } } - +// Table 5.2-1 NR operating bands in FR1 & FR2 (3GPP TS 38.101) +// Table 5.4.2.3-1 Applicable NR-ARFCN per operating band in FR1 & FR2 (3GPP TS 38.101) +// Notes: +// - N_OFFs for bands from 80 to 89 and band 95 is referred to UL +// - Frequencies are expressed in KHz +// - col: NR_band ul_min ul_max dl_min dl_max step N_OFFs_DL deltaf_raster nr_bandentry_t nr_bandtable[] = { {1, 1920000, 1980000, 2110000, 2170000, 20, 422000, 100}, {2, 1850000, 1910000, 1930000, 1990000, 20, 386000, 100}, @@ -1452,17 +1458,27 @@ nr_bandentry_t nr_bandtable[] = { {7, 2500000, 2570000, 2620000, 2690000, 20, 524000, 100}, {8, 880000, 915000, 925000, 960000, 20, 185000, 100}, {12, 698000, 716000, 728000, 746000, 20, 145800, 100}, + {14, 788000, 798000, 758000, 768000, 20, 151600, 100}, + {18, 815000, 830000, 860000, 875000, 20, 172000, 100}, {20, 832000, 862000, 791000, 821000, 20, 158200, 100}, {25, 1850000, 1915000, 1930000, 1995000, 20, 386000, 100}, + {26, 814000, 849000, 859000, 894000, 20, 171800, 100}, {28, 703000, 758000, 758000, 813000, 20, 151600, 100}, + {29, 000, 000, 717000, 728000, 20, 143400, 100}, + {30, 2305000, 2315000, 2350000, 2360000, 20, 470000, 100}, {34, 2010000, 2025000, 2010000, 2025000, 20, 402000, 100}, {38, 2570000, 2620000, 2570000, 2630000, 20, 514000, 100}, {39, 1880000, 1920000, 1880000, 1920000, 20, 376000, 100}, {40, 2300000, 2400000, 2300000, 2400000, 20, 460000, 100}, {41, 2496000, 2690000, 2496000, 2690000, 3, 499200, 15}, {41, 2496000, 2690000, 2496000, 2690000, 6, 499200, 30}, + {47, 5855000, 5925000, 5855000, 5925000, 1, 790334, 15}, + {48, 3550000, 3700000, 3550000, 3700000, 1, 636667, 15}, + {48, 3550000, 3700000, 3550000, 3700000, 2, 636668, 30}, {50, 1432000, 1517000, 1432000, 1517000, 20, 286400, 100}, {51, 1427000, 1432000, 1427000, 1432000, 20, 285400, 100}, + {53, 2483500, 2495000, 2483500, 2495000, 20, 496700, 100}, + {65, 1920000, 2010000, 2110000, 2200000, 20, 422000, 100}, {66, 1710000, 1780000, 2110000, 2200000, 20, 422000, 100}, {70, 1695000, 1710000, 1995000, 2020000, 20, 399000, 100}, {71, 663000, 698000, 617000, 652000, 20, 123400, 100}, @@ -1480,7 +1496,16 @@ nr_bandentry_t nr_bandtable[] = { {82, 832000, 862000, 000, 000, 20, 166400, 100}, {83, 703000, 748000, 000, 000, 20, 140600, 100}, {84, 1920000, 1980000, 000, 000, 20, 384000, 100}, - {86, 1710000, 1785000, 000, 000, 20, 342000, 100}, + {86, 1710000, 1780000, 000, 000, 20, 342000, 100}, + {89, 824000, 849000, 000, 000, 20, 342000, 100}, + {90, 2496000, 2690000, 2496000, 2690000, 3, 499200, 15}, + {90, 2496000, 2690000, 2496000, 2690000, 6, 499200, 30}, + {90, 2496000, 2690000, 2496000, 2690000, 20, 499200, 100}, + {91, 832000, 862000, 1427000, 1432000, 20, 285400, 100}, + {92, 832000, 862000, 1432000, 1517000, 20, 286400, 100}, + {93, 880000, 915000, 1427000, 1432000, 20, 285400, 100}, + {94, 880000, 915000, 1432000, 1517000, 20, 286400, 100}, + {95, 2010000, 2025000, 000, 000, 20, 402000, 100}, {257,26500000,29500000,26500000,29500000, 1,2054166, 60}, {257,26500000,29500000,26500000,29500000, 2,2054167, 120}, {258,24250000,27500000,24250000,27500000, 1,2016667, 60}, @@ -1534,7 +1559,44 @@ int32_t table_6_4_1_1_3_4_pusch_dmrs_positions_l [12][8] = { #define NR_BANDTABLE_SIZE (sizeof(nr_bandtable)/sizeof(nr_bandentry_t)) +// Computes the duplex spacing (either positive or negative) in KHz +void get_delta_duplex(int nr_table_idx, int32_t *delta_duplex){ + + int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95}; + size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]); + + for(int i = 0; i < s; i++){ + if (nr_table_idx == supplementary_bands[i]) + AssertFatal(0 == 1, "Band %d is a supplementary band. This is not supported yet.\n", nr_table_idx); + } + + *delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min); + + LOG_D(PHY, "NR band duplex spacing %d KHz (nr_bandtable[%d].band = %d)\n", *delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band); + +} + +// Returns the corresponding row index of the NR table +int get_nr_table_idx(int nr_bandP, uint8_t scs_index){ + + int scs_khz = 15 << scs_index; + int i; + + AssertFatal(nr_bandP <= nr_bandtable[NR_BANDTABLE_SIZE-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[NR_BANDTABLE_SIZE-1].band); + for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++); + + // selection of correct Deltaf raster according to SCS + if ((nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz)) + i++; + + LOG_D(PHY, "NR band table index %d (Band %d)\n", i, nr_bandtable[i].band); + + return i; + +} + void get_band(uint64_t downlink_frequency, + uint64_t ul_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) @@ -1543,6 +1605,7 @@ void get_band(uint64_t downlink_frequency, uint64_t center_frequency_khz; uint64_t center_freq_diff_khz; uint64_t dl_freq_khz = downlink_frequency/1000; + uint64_t ul_freq_khz = ul_frequency/1000; center_freq_diff_khz = 999999999999999999; // 2^64 *current_band = 0; @@ -1553,27 +1616,26 @@ void get_band(uint64_t downlink_frequency, LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", nr_bandtable[ind].band, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); - if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) { + if (nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz && nr_bandtable[ind].ul_min <= ul_freq_khz && nr_bandtable[ind].ul_max >= ul_freq_khz) { center_frequency_khz = (nr_bandtable[ind].dl_max + nr_bandtable[ind].dl_min)/2; if (abs(dl_freq_khz - center_frequency_khz) < center_freq_diff_khz){ *current_band = nr_bandtable[ind].band; - *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; + get_delta_duplex(ind, current_offset); + *current_offset *= 1000; center_freq_diff_khz = abs(dl_freq_khz - center_frequency_khz); - - if (*current_offset == 0) - *current_type = TDD; - else - *current_type = FDD; + if (*current_offset == 0) + *current_type = TDD; + else + *current_type = FDD; } } } - LOG_I( PHY, "DL frequency %"PRIu64": band %d, frame_type %d, UL frequency %"PRIu64"\n", - downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); + LOG_I(PHY, "DL frequency %"PRIu64" Hz, UL frequency %"PRIu64" Hz: band %d, uldl offset %d Hz, duplex mode %s\n", downlink_frequency, ul_frequency, *current_band, *current_offset, duplex_mode[*current_type]); + + AssertFatal(*current_band != 0, "Can't find NR band for frequency %lu\n", downlink_frequency); - AssertFatal(*current_band != 0, - "Can't find EUTRA band for frequency %lu\n", downlink_frequency); } uint16_t config_bandwidth(int mu, int nb_rb, int nr_band) @@ -1696,17 +1758,10 @@ uint32_t to_nrarfcn(int nr_bandP, { uint64_t dl_CarrierFreq_by_1k = dl_CarrierFreq / 1000; int bw_kHz = bw / 1000; - int scs_khz = 15< 260\n", nr_bandP); - for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++); - - // selection of correct Deltaf raster according to SCS - if ( (nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz)) - i++; AssertFatal(dl_CarrierFreq_by_1k >= nr_bandtable[i].dl_min, "Band %d, bw %u : DL carrier frequency %llu kHz < %llu\n", @@ -1735,55 +1790,63 @@ uint32_t to_nrarfcn(int nr_bandP, } +// this function applies to both DL and UL uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, - uint32_t dl_nrarfcn) + uint32_t nrarfcn) { - int i; int deltaFglobal = 5; - int scs_khz = 15< 599999 && dl_nrarfcn < 2016667) - deltaFglobal = 15; - if (dl_nrarfcn > 2016666 && dl_nrarfcn < 3279166) - deltaFglobal = 60; - - AssertFatal(nr_bandP <= 261, "nr_band %d > 260\n", nr_bandP); - for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++); - AssertFatal(dl_nrarfcn>=nr_bandtable[i].N_OFFs_DL,"dl_nrarfcn %u < N_OFFs_DL[%d] %llu\n",dl_nrarfcn, nr_bandtable[i].band,(long long unsigned int)nr_bandtable[i].N_OFFs_DL); - - // selection of correct Deltaf raster according to SCS - if ( (nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz)) - i++; + if (nrarfcn > 599999 && nrarfcn < 2016667) + deltaFglobal = 15; + if (nrarfcn > 2016666 && nrarfcn < 3279166) + deltaFglobal = 60; - delta_arfcn = dl_nrarfcn - nr_bandtable[i].N_OFFs_DL; + get_delta_duplex(i, &delta_duplex); + + if (delta_duplex <= 0){ // DL band >= UL band + if (nrarfcn >= nr_bandtable[i].N_OFFs_DL){ // is TDD of FDD DL + N_OFFs = nr_bandtable[i].N_OFFs_DL; + freq_min = nr_bandtable[i].dl_min; + } else {// is FDD UL + N_OFFs = nr_bandtable[i].N_OFFs_DL + delta_duplex/deltaFglobal; + freq_min = nr_bandtable[i].ul_min; + } + } else { // UL band > DL band + if (nrarfcn >= nr_bandtable[i].N_OFFs_DL + delta_duplex/deltaFglobal){ // is FDD UL + N_OFFs = nr_bandtable[i].N_OFFs_DL + delta_duplex/deltaFglobal; + freq_min = nr_bandtable[i].ul_min; + } else { // is FDD DL + N_OFFs = nr_bandtable[i].N_OFFs_DL; + freq_min = nr_bandtable[i].dl_min; + } + } + + LOG_D(PHY, "Frequency from NR-ARFCN for N_OFFs %lu, duplex spacing %d KHz, deltaFglobal %d KHz\n", N_OFFs, delta_duplex, deltaFglobal); + + AssertFatal(nrarfcn >= N_OFFs,"nrarfcn %u < N_OFFs[%d] %llu\n", nrarfcn, nr_bandtable[i].band, (long long unsigned int)N_OFFs); + + delta_arfcn = nrarfcn - N_OFFs; if(delta_arfcn%(nr_bandtable[i].step_size)!=0) - AssertFatal(1==0,"dl_nrarfcn %u is not on the raster for step size %lu",dl_nrarfcn,nr_bandtable[i].step_size); + AssertFatal(1 == 0, "nrarfcn %u is not on the raster for step size %lu", nrarfcn, nr_bandtable[i].step_size); - LOG_I(PHY,"Computing dl_frequency (pointA %llu => %llu (dlmin %llu, nr_bandtable[%d].N_OFFs_DL %llu))\n", - (unsigned long long)dl_nrarfcn, - (unsigned long long)(1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal)), - (unsigned long long)nr_bandtable[i].dl_min, - i, - (unsigned long long)nr_bandtable[i].N_OFFs_DL); + frequency = 1000*(freq_min + (nrarfcn - N_OFFs) * deltaFglobal); + + LOG_I(PHY, "Computing frequency (pointA %llu => %llu KHz (freq_min %llu KHz, NR band %d N_OFFs %llu))\n", + (unsigned long long)nrarfcn, + (unsigned long long)frequency/1000, + (unsigned long long)freq_min, + nr_bandP, + (unsigned long long)N_OFFs); + + return frequency; - return 1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal); } - -int32_t get_nr_uldl_offset(int nr_bandP) -{ - int i; - - for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++); - - AssertFatal(i < NR_BANDTABLE_SIZE, "i %d >= BANDTABLE_SIZE %ld\n", i, NR_BANDTABLE_SIZE); - - return (nr_bandtable[i].dl_min - nr_bandtable[i].ul_min); -} - - void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, int x_overhead, uint8_t numdmrscdmgroupnodata, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 0a5a8c110c..2d7f003d06 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -66,7 +66,9 @@ typedef enum { uint16_t config_bandwidth(int mu, int nb_rb, int nr_band); -void get_band(uint64_t downlink_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); +void get_band(uint64_t dl_frequency, uint64_t ul_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); + +void get_delta_duplex(int nr_table_idx, int32_t *delta_duplex); uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index bc98e16d39..eff98c19a4 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -205,6 +205,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, int32_t offset; get_band((cfg->carrier_config.dl_frequency)*1000, + (cfg->carrier_config.uplink_frequency)*1000, &band, &offset, &frame_type); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 6bd7940480..59f523a7cf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -129,6 +129,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm int32_t offset; get_band((cfg->carrier_config.dl_frequency.value)*1000, + (cfg->carrier_config.uplink_frequency.value)*1000, &band, &offset, &frame_type); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index f7e62c9755..605c328535 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -326,8 +326,6 @@ int get_ulscs(nfapi_nr_config_request_t *cfg); int get_symbolsperslot(nfapi_nr_config_request_t *cfg); -int32_t get_nr_uldl_offset(int nr_bandP); - void config_nr_mib(int Mod_idP, int CC_idP, int p_gNBP, From 1bacb91addab96c8ea7037ef2108a775c74b093c Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 7 Oct 2020 21:25:47 +0200 Subject: [PATCH 066/149] Bugfix: set freq_offet to static to avoid re-initialisation in frequency scanner --- executables/nr-ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index ee61df86e7..443d24d435 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -176,7 +176,7 @@ static void UE_synch(void *arg) { PHY_VARS_NR_UE *UE = syncD->UE; sync_mode_t sync_mode = pbch; int CC_id = UE->CC_id; - int freq_offset=0; + static int freq_offset=0; UE->is_synchronized = 0; if (UE->UE_scan == 0) { From 63e93528b9e437017bf66f29b89080d7d6701ba7 Mon Sep 17 00:00:00 2001 From: cig Date: Sat, 10 Oct 2020 11:03:39 +0200 Subject: [PATCH 067/149] Bypass the tdd_table in FDD mode - tdd_table is filled in only in TDD mode and should not be used in FDD mode --- executables/nr-ru.c | 42 ++++++++++------------- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 ++- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 64ca24204c..e2f2814677 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -727,31 +727,27 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { //nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame); if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT || IS_SOFTMODEM_RFSIM) { - if(slot_type == NR_MIXED_SLOT) { - txsymb = 0; - for(int symbol_count =0;symbol_counttdd_table.max_tdd_periodicity_list[slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==0) - txsymb++; + if (cfg->cell_config.frame_duplex_type.value == TDD){ + if(slot_type == NR_MIXED_SLOT) { + txsymb = 0; + for(int symbol_count = 0; symbol_counttdd_table.max_tdd_periodicity_list[slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value == 0) + txsymb++; + } + AssertFatal(txsymb>0,"illegal txsymb %d\n",txsymb); + if(slot%(fp->slots_per_subframe/2)) + siglen = txsymb * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + else + siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + //+ ru->end_of_burst_delay; + flags = 3; // end of burst } - AssertFatal(txsymb>0,"illegal txsymb %d\n",txsymb); - if(slot%(fp->slots_per_subframe/2)) - siglen = txsymb * (fp->ofdm_symbol_size + fp->nb_prefix_samples); - else - siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); - //+ ru->end_of_burst_delay; - flags=3; // end of burst - } - if (cfg->cell_config.frame_duplex_type.value == TDD && - slot_type == NR_DOWNLINK_SLOT && - prevslot_type == NR_UPLINK_SLOT) { - flags = 2; // start of burst - } + if (slot_type == NR_DOWNLINK_SLOT && prevslot_type == NR_UPLINK_SLOT) + flags = 2; // start of burst - if (cfg->cell_config.frame_duplex_type.value == TDD && - slot_type == NR_DOWNLINK_SLOT && - nextslot_type == NR_UPLINK_SLOT) { - flags = 3; // end of burst + if (slot_type == NR_DOWNLINK_SLOT && nextslot_type == NR_UPLINK_SLOT) + flags = 3; // end of burst } if (fp->freq_range==nr_FR2) { @@ -767,7 +763,7 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { */ flags |= beam<<8; } - + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS, flags ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, slot ); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 2d246101a6..e574221e33 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -526,7 +526,9 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_UESPEC_RX,1); LOG_D(PHY,"phy_procedures_gNB_uespec_RX frame %d, slot %d\n",frame_rx,slot_rx); - fill_ul_rb_mask(gNB, frame_rx, slot_rx); + if (gNB->frame_parms.frame_type == TDD) + fill_ul_rb_mask(gNB, frame_rx, slot_rx); + gNB_I0_measurements(gNB); for (int i=0;i Date: Fri, 9 Oct 2020 20:44:10 +0200 Subject: [PATCH 068/149] Set downlink carrier and uplink CO @ UE through command line - this reflects the implementation of IF and IF offset in the gNB RU - the RF frequencies are set at HW level while the target frequencies are stored in fp, therefore the values stored in fp should not be changed after sync as only the tx/rx freq is updated - removed overwritten dl/ul carrier frequencies in fp after sync - removed redundant set of tx/rx freq in ue_synch (done in init_openair0) - removed irrelevant set of dl/ul carrier freq in get_options --- executables/nr-ue.c | 44 +++++++++++++++++++++------------- executables/nr-uesoftmodem.c | 33 ++++++++++++++----------- executables/softmodem-common.h | 3 +++ 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 443d24d435..d3be1a03b8 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -170,6 +170,8 @@ typedef struct syncData_s { PHY_VARS_NR_UE *UE; } syncData_t; +extern const char *duplex_mode[]; + static void UE_synch(void *arg) { syncData_t *syncD=(syncData_t *) arg; int i, hw_slot_offset; @@ -180,19 +182,23 @@ static void UE_synch(void *arg) { UE->is_synchronized = 0; if (UE->UE_scan == 0) { - LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu64", UL %"PRIu64" (oai_exit %d, rx_num_channels %d)\n", - UE->frame_parms.dl_CarrierFreq, UE->frame_parms.ul_CarrierFreq, - oai_exit, openair0_cfg[0].rx_num_channels); for (i=0; irf_map.card].rx_num_channels; i++) { - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = UE->frame_parms.dl_CarrierFreq; - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = UE->frame_parms.ul_CarrierFreq; - openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; - if (UE->frame_parms.frame_type == FDD) + if (UE->frame_parms.frame_type == FDD) openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_FDD; - else + else openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_TDD; + + LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %f, UL %f duplex mode %s (RF card %d, oai_exit %d, channel %d, rx_num_channels %d)\n", + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i], + openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i], + duplex_mode[openair0_cfg[UE->rf_map.card].duplex_mode], + UE->rf_map.card, + oai_exit, + i, + openair0_cfg[0].rx_num_channels); + } sync_mode = pbch; @@ -251,13 +257,6 @@ static void UE_synch(void *arg) { freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync hw_slot_offset = ((UE->rx_offset<<1) / UE->frame_parms.samples_per_subframe * UE->frame_parms.slots_per_subframe) + round((float)((UE->rx_offset<<1) % UE->frame_parms.samples_per_subframe)/UE->frame_parms.samples_per_slot0); - LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %lu, UL %lu), UE_scan_carrier %d\n", - hw_slot_offset, - freq_offset, - UE->rx_total_gain_dB, - UE->frame_parms.dl_CarrierFreq+freq_offset, - UE->frame_parms.ul_CarrierFreq+freq_offset, - UE->UE_scan_carrier ); // rerun with new cell parameters and frequency-offset for (i=0; irf_map.card].rx_num_channels; i++) { @@ -268,11 +267,24 @@ static void UE_synch(void *arg) { else openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(freq_offset); + if (uplink_frequency_offset[0][0]) + openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] + uplink_frequency_offset[0][0]; + else openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+(UE->frame_parms.ul_CarrierFreq-UE->frame_parms.dl_CarrierFreq); - UE->frame_parms.dl_CarrierFreq = openair0_cfg[CC_id].rx_freq[i]; + + //UE->frame_parms.dl_CarrierFreq = openair0_cfg[CC_id].rx_freq[i]; } + LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %f Hz, UL %f Hz), UE_scan_carrier %d\n", + hw_slot_offset, + freq_offset, + UE->rx_total_gain_dB, + openair0_cfg[UE->rf_map.card].rx_freq[0], + openair0_cfg[UE->rf_map.card].tx_freq[0], + UE->UE_scan_carrier); + // reconfigure for potentially different bandwidth switch(UE->frame_parms.N_RB_DL) { case 6: diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index e6d644453c..b312955f00 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -353,10 +353,6 @@ static void get_options(void) { if (dumpframe > 0) mode = rx_dump_frame; - for (CC_id=0; CC_iddl_CarrierFreq = downlink_frequency[0][0]; - } - UE_scan=0; if (tddflag > 0) { @@ -544,16 +540,25 @@ void init_openair0(void) { openair0_cfg[card].rx_num_channels=min(2,PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx); for (i=0; i<4; i++) { - if (iul_CarrierFreq; - else - openair0_cfg[card].tx_freq[i]=0.0; - if (idl_CarrierFreq; + if (idl_CarrierFreq; + } else openair0_cfg[card].rx_freq[i]=0.0; + if (iul_CarrierFreq; + } + else + openair0_cfg[card].tx_freq[i]=0.0; + openair0_cfg[card].autocal[i] = 1; openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off; @@ -687,10 +692,10 @@ int main( int argc, char **argv ) { nr_init_frame_parms_ue(frame_parms[CC_id],nrUE_config,NORMAL); // Overwrite DL frequency (for FR2 testing) - if (downlink_frequency[0][0]!=0) { - frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; - frame_parms[CC_id]->ul_CarrierFreq = downlink_frequency[0][0]; - } + // if (downlink_frequency[0][0]!=0) { + // frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; + // frame_parms[CC_id]->ul_CarrierFreq = downlink_frequency[0][0]; + // } init_symbol_rotation(frame_parms[CC_id],frame_parms[CC_id]->dl_CarrierFreq); init_nr_ue_vars(UE[CC_id],frame_parms[CC_id],0,abstraction_flag); diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index 449d2e0957..feb020154b 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -63,6 +63,7 @@ extern "C" #define CONFIG_HLP_USIM "use XOR autentication algo in case of test usim mode\n" #define CONFIG_HLP_NOSNGLT "Disables single-thread mode in lte-softmodem\n" #define CONFIG_HLP_DLF "Set the downlink frequency for all component carriers\n" +#define CONFIG_HLP_ULF "Set the uplink frequency offset for all component carriers\n" #define CONFIG_HLP_CHOFF "Channel id offset\n" #define CONFIG_HLP_SOFTS "Enable soft scope and L1 and L2 stats (Xforms)\n" #define CONFIG_HLP_EXMCAL "Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n" @@ -123,6 +124,7 @@ extern "C" {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&WAIT_FOR_SYNC, defintval:0, TYPE_INT, 0}, \ {"single-thread-enable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG, defintval:0, TYPE_INT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, u64ptr:&(downlink_frequency[0][0]), defuintval:0, TYPE_UINT64, 0}, \ + {"CO" , CONFIG_HLP_ULF, 0, iptr:&(uplink_frequency_offset[0][0]), defintval:0, TYPE_INT, 0}, \ {"a" , CONFIG_HLP_CHOFF, 0, iptr:&CHAIN_OFFSET, defintval:0, TYPE_INT, 0}, \ {"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ @@ -230,6 +232,7 @@ extern char *get_softmodem_function(uint64_t *sofmodemfunc_mask_ptr); #define SOFTMODEM_RTSIGNAL (SIGRTMIN+1) extern void set_softmodem_sighandler(void); extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; +extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; #ifdef __cplusplus } #endif From 7e45f8be7a0fb0f501977e82321da5b2c987484f Mon Sep 17 00:00:00 2001 From: cig Date: Sat, 10 Oct 2020 10:36:13 +0200 Subject: [PATCH 069/149] Fix for scan carrier to make it compatible with custom DL/UL IF implementation --- executables/nr-ue.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index d3be1a03b8..1d68a3d966 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -343,21 +343,35 @@ static void UE_synch(void *arg) { // initial sync failed // calculate new offset and try again if (UE->UE_scan_carrier == 1) { + + uint64_t dl_carrier, ul_carrier; + if (freq_offset >= 0) freq_offset += 100; freq_offset *= -1; - LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %lu, UL %lu)\n", - freq_offset, - UE->rx_total_gain_dB, - UE->frame_parms.dl_CarrierFreq+freq_offset, - UE->frame_parms.ul_CarrierFreq+freq_offset ); + + if (downlink_frequency[0][0]) + dl_carrier = downlink_frequency[0][0]; + else + dl_carrier = UE->frame_parms.dl_CarrierFreq; + + if (uplink_frequency_offset[0][0]) + ul_carrier = dl_carrier + uplink_frequency_offset[0][0]; + else + ul_carrier = dl_carrier + UE->frame_parms.ul_CarrierFreq - UE->frame_parms.dl_CarrierFreq; for (i=0; irf_map.card].rx_num_channels; i++) { - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = UE->frame_parms.dl_CarrierFreq+freq_offset; - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = UE->frame_parms.ul_CarrierFreq+freq_offset; + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = dl_carrier + freq_offset; + openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = ul_carrier + freq_offset; openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; + LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %f, UL %f)\n", + freq_offset, + UE->rx_total_gain_dB, + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i], + openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i]); + if (UE->UE_scan_carrier==1) openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; } From c961e81ce9d3153b75b66a8b458744b2e3e2806d Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 19 Oct 2020 11:28:26 +0200 Subject: [PATCH 070/149] Broken down get_band into two functions to get duplex offset and frame type - the band is coming from the SI, therefore a function to get the band is not necessary - this solves also the limitations of the get_band algorithm with the NR bands overlapping in the NR operating bands table (e.g. band 78 and band 48) --- openair1/PHY/INIT/nr_init.c | 8 +- openair1/PHY/INIT/nr_parms.c | 6 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 85 +++++++------------ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 4 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 12 +-- openair2/LAYER2/NR_MAC_gNB/config.c | 10 +-- 6 files changed, 46 insertions(+), 79 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 0b4193a617..04d8b55511 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -432,7 +432,6 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { NR_DL_FRAME_PARMS *fp = &RC.gNB[Mod_id]->frame_parms; nfapi_nr_config_request_scf_t *gNB_config = &RC.gNB[Mod_id]->gNB_config; int32_t dlul_offset = 0; - lte_frame_type_t frame_type = 0; memcpy((void*)gNB_config,phy_config->cfg,sizeof(*phy_config->cfg)); RC.gNB[Mod_id]->mac_enabled = 1; @@ -443,10 +442,15 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { uint64_t ul_bw_khz = (12*gNB_config->carrier_config.ul_grid_size[gNB_config->ssb_config.scs_common.value].value)*(15<ssb_config.scs_common.value); fp->ul_CarrierFreq = ((ul_bw_khz>>1) + gNB_config->carrier_config.uplink_frequency.value)*1000 ; - get_band(fp->dl_CarrierFreq, fp->ul_CarrierFreq, &fp->nr_band, &dlul_offset, &frame_type); + fp->nr_band = *RC.nrmac[Mod_id]->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + + get_delta_duplex(fp->nr_band, gNB_config->ssb_config.scs_common.value, &dlul_offset); + dlul_offset *= 1000; AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + dlul_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + dlul_offset); + LOG_I(PHY, "DL frequency %lu Hz, UL frequency %lu Hz: band %d, uldl offset %d Hz\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq, fp->nr_band, dlul_offset); + fp->threequarter_fs = openair0_cfg[0].threequarter_fs; LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", Mod_id, diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 31b53ae1be..b95771e979 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -330,10 +330,14 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, fp->N_RB_DL = config->carrier_config.dl_grid_size[fp->numerology_index]; int32_t uplink_frequency_offset = 0; + get_delta_duplex(fp->nr_band, fp->numerology_index, &uplink_frequency_offset); + get_frame_type(fp->nr_band, fp->numerology_index, &fp->frame_type); + uplink_frequency_offset *= 1000; - get_band(fp->dl_CarrierFreq, fp->ul_CarrierFreq, &fp->nr_band, &uplink_frequency_offset, &fp->frame_type); + LOG_I(PHY, "DL frequency %lu Hz, UL frequency %lu Hz: band %d, uldl offset %d Hz\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq, fp->nr_band, uplink_frequency_offset); AssertFatal(fp->frame_type==config->cell_config.frame_duplex_type, "Invalid duplex type in config request file for band %d\n", fp->nr_band); + AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + uplink_frequency_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + uplink_frequency_offset); #if DISABLE_LOG_X diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 817ccac785..3226ccd992 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1473,8 +1473,8 @@ nr_bandentry_t nr_bandtable[] = { {41, 2496000, 2690000, 2496000, 2690000, 3, 499200, 15}, {41, 2496000, 2690000, 2496000, 2690000, 6, 499200, 30}, {47, 5855000, 5925000, 5855000, 5925000, 1, 790334, 15}, - {48, 3550000, 3700000, 3550000, 3700000, 1, 636667, 15}, - {48, 3550000, 3700000, 3550000, 3700000, 2, 636668, 30}, + //{48, 3550000, 3700000, 3550000, 3700000, 1, 636667, 15}, + //{48, 3550000, 3700000, 3550000, 3700000, 2, 636668, 30}, {50, 1432000, 1517000, 1432000, 1517000, 20, 286400, 100}, {51, 1427000, 1432000, 1427000, 1432000, 20, 285400, 100}, {53, 2483500, 2495000, 2483500, 2495000, 20, 496700, 100}, @@ -1559,28 +1559,18 @@ int32_t table_6_4_1_1_3_4_pusch_dmrs_positions_l [12][8] = { #define NR_BANDTABLE_SIZE (sizeof(nr_bandtable)/sizeof(nr_bandentry_t)) -// Computes the duplex spacing (either positive or negative) in KHz -void get_delta_duplex(int nr_table_idx, int32_t *delta_duplex){ - - int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95}; - size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]); - - for(int i = 0; i < s; i++){ - if (nr_table_idx == supplementary_bands[i]) - AssertFatal(0 == 1, "Band %d is a supplementary band. This is not supported yet.\n", nr_table_idx); - } - - *delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min); - - LOG_D(PHY, "NR band duplex spacing %d KHz (nr_bandtable[%d].band = %d)\n", *delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band); - -} - // Returns the corresponding row index of the NR table int get_nr_table_idx(int nr_bandP, uint8_t scs_index){ + int i, j; int scs_khz = 15 << scs_index; - int i; + int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95}; + size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]); + + for(j = 0; j < s; j++){ + if (nr_bandP == supplementary_bands[j]) + AssertFatal(0 == 1, "Band %d is a supplementary band (%d). This is not supported yet.\n", nr_bandP, supplementary_bands[j]); + } AssertFatal(nr_bandP <= nr_bandtable[NR_BANDTABLE_SIZE-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[NR_BANDTABLE_SIZE-1].band); for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++); @@ -1589,52 +1579,37 @@ int get_nr_table_idx(int nr_bandP, uint8_t scs_index){ if ((nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz)) i++; - LOG_D(PHY, "NR band table index %d (Band %d)\n", i, nr_bandtable[i].band); + LOG_D(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min); return i; } -void get_band(uint64_t downlink_frequency, - uint64_t ul_frequency, - uint16_t *current_band, - int32_t *current_offset, - lte_frame_type_t *current_type) -{ - int ind; - uint64_t center_frequency_khz; - uint64_t center_freq_diff_khz; - uint64_t dl_freq_khz = downlink_frequency/1000; - uint64_t ul_freq_khz = ul_frequency/1000; +// Computes the duplex spacing (either positive or negative) in KHz +void get_delta_duplex(int nr_bandP, uint8_t scs_index, int32_t *delta_duplex){ - center_freq_diff_khz = 999999999999999999; // 2^64 - *current_band = 0; + int nr_table_idx = get_nr_table_idx(nr_bandP, scs_index); - for ( ind=0; - ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); - ind++) { + *delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min); - LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", nr_bandtable[ind].band, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); + LOG_D(PHY, "NR band duplex spacing is %d KHz (nr_bandtable[%d].band = %d)\n", *delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band); - if (nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz && nr_bandtable[ind].ul_min <= ul_freq_khz && nr_bandtable[ind].ul_max >= ul_freq_khz) { +} - center_frequency_khz = (nr_bandtable[ind].dl_max + nr_bandtable[ind].dl_min)/2; - if (abs(dl_freq_khz - center_frequency_khz) < center_freq_diff_khz){ - *current_band = nr_bandtable[ind].band; - get_delta_duplex(ind, current_offset); - *current_offset *= 1000; - center_freq_diff_khz = abs(dl_freq_khz - center_frequency_khz); - if (*current_offset == 0) - *current_type = TDD; - else - *current_type = FDD; - } - } - } +void get_frame_type(uint16_t current_band, + uint8_t scs_index, + lte_frame_type_t *current_type){ - LOG_I(PHY, "DL frequency %"PRIu64" Hz, UL frequency %"PRIu64" Hz: band %d, uldl offset %d Hz, duplex mode %s\n", downlink_frequency, ul_frequency, *current_band, *current_offset, duplex_mode[*current_type]); + int32_t current_offset; + get_delta_duplex(current_band, scs_index, ¤t_offset); - AssertFatal(*current_band != 0, "Can't find NR band for frequency %lu\n", downlink_frequency); + current_offset *= 1000; + if (current_offset == 0) + *current_type = TDD; + else + *current_type = FDD; + + LOG_I(MAC, "NR band %d, duplex mode %s, duplex spacing = %d KHz\n", current_band, duplex_mode[*current_type], current_offset); } @@ -1806,7 +1781,7 @@ uint64_t from_nrarfcn(int nr_bandP, if (nrarfcn > 2016666 && nrarfcn < 3279166) deltaFglobal = 60; - get_delta_duplex(i, &delta_duplex); + get_delta_duplex(nr_bandP, scs_index, &delta_duplex); if (delta_duplex <= 0){ // DL band >= UL band if (nrarfcn >= nr_bandtable[i].N_OFFs_DL){ // is TDD of FDD DL diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 2d7f003d06..a67a676075 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -66,9 +66,9 @@ typedef enum { uint16_t config_bandwidth(int mu, int nb_rb, int nr_band); -void get_band(uint64_t dl_frequency, uint64_t ul_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); +void get_frame_type(uint16_t nr_bandP, uint8_t scs_index, lte_frame_type_t *current_type); -void get_delta_duplex(int nr_table_idx, int32_t *delta_duplex); +void get_delta_duplex(int nr_bandP, uint8_t scs_index, int32_t *delta_duplex); uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index eff98c19a4..1ea4d128f7 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -147,6 +147,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; NR_ServingCellConfigCommon_t *scc = mac->scc; int i; + lte_frame_type_t frame_type; mac->phy_config.Mod_id = module_id; mac->phy_config.CC_id = cc_idP; @@ -200,16 +201,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, } } - lte_frame_type_t frame_type; - uint16_t band; - int32_t offset; - - get_band((cfg->carrier_config.dl_frequency)*1000, - (cfg->carrier_config.uplink_frequency)*1000, - &band, - &offset, - &frame_type); - + get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing, &frame_type); // cell config diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 59f523a7cf..800631177f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -125,15 +125,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm } lte_frame_type_t frame_type; - uint16_t band; - int32_t offset; - - get_band((cfg->carrier_config.dl_frequency.value)*1000, - (cfg->carrier_config.uplink_frequency.value)*1000, - &band, - &offset, - &frame_type); - + get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing, &frame_type); RC.nrmac[Mod_idP]->common_channels[0].frame_type = frame_type; // Cell configuration From 8ee8b81043fcb7286c1cb6a4ed06a9d3ceffb848 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 19 Oct 2020 11:45:28 +0200 Subject: [PATCH 071/149] Cleaned up unused UE variables, members, commented out code --- executables/nr-ue.c | 3 +- executables/nr-uesoftmodem.c | 27 -- openair1/PHY/INIT/nr_init_ue.c | 265 ------------------ openair1/PHY/INIT/nr_parms.c | 2 - .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 3 - openair1/PHY/defs_nr_common.h | 2 - 6 files changed, 1 insertion(+), 301 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 1d68a3d966..fd306e7f7a 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -177,7 +177,7 @@ static void UE_synch(void *arg) { int i, hw_slot_offset; PHY_VARS_NR_UE *UE = syncD->UE; sync_mode_t sync_mode = pbch; - int CC_id = UE->CC_id; + //int CC_id = UE->CC_id; static int freq_offset=0; UE->is_synchronized = 0; @@ -327,7 +327,6 @@ static void UE_synch(void *arg) { //UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]); //UE->rfdevice.trx_stop_func(&UE->rfdevice); // sleep(1); - //nr_init_frame_parms_ue(&UE->frame_parms); /*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) { LOG_E(HW,"Could not start the device\n"); oai_exit=1; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index b312955f00..ca12a7ad02 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -363,31 +363,6 @@ static void get_options(void) { if (vcdflag > 0) ouput_vcd = 1; - /*if (frame_parms[0]->N_RB_DL !=0) { - if ( frame_parms[0]->N_RB_DL < 6 ) { - frame_parms[0]->N_RB_DL = 6; - printf ( "%i: Invalid number of resource blocks, adjusted to 6\n",frame_parms[0]->N_RB_DL); - } - if ( frame_parms[0]->N_RB_DL > 100 ) { - frame_parms[0]->N_RB_DL = 100; - printf ( "%i: Invalid number of resource blocks, adjusted to 100\n",frame_parms[0]->N_RB_DL); - } - if ( frame_parms[0]->N_RB_DL > 50 && frame_parms[0]->N_RB_DL < 100 ) { - frame_parms[0]->N_RB_DL = 50; - printf ( "%i: Invalid number of resource blocks, adjusted to 50\n",frame_parms[0]->N_RB_DL); - } - if ( frame_parms[0]->N_RB_DL > 25 && frame_parms[0]->N_RB_DL < 50 ) { - frame_parms[0]->N_RB_DL = 25; - printf ( "%i: Invalid number of resource blocks, adjusted to 25\n",frame_parms[0]->N_RB_DL); - } - UE_scan = 0; - frame_parms[0]->N_RB_UL=frame_parms[0]->N_RB_DL; - for (CC_id=1; CC_idN_RB_DL=frame_parms[0]->N_RB_DL; - frame_parms[CC_id]->N_RB_UL=frame_parms[0]->N_RB_UL; - } - }*/ - for (CC_id=1; CC_idnumerology_index = 0; frame_parms[CC_id]->ttis_per_subframe = 1; - frame_parms[CC_id]->slots_per_tti = 2; } } @@ -769,7 +743,6 @@ int main( int argc, char **argv ) { if(IS_SOFTMODEM_DOFORMS) { load_softscope("nr",PHY_vars_UE_g[0][0]); } - number_of_cards = 1; for(int CC_id=0; CC_idrf_map.card=0; diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 39e99e6ec3..d5a6b44a70 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -350,13 +350,6 @@ void phy_config_meas_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n } */ -#if defined(Rel10) || defined(Rel14) -void phy_config_dedicated_scell_ue(uint8_t Mod_id, - uint8_t eNB_index, - SCellToAddMod_r10_t *sCellToAddMod_r10, - int CC_id) { -} -#endif #if 0 void phy_config_harq_ue(module_id_t Mod_id, @@ -374,210 +367,6 @@ void phy_config_harq_ue(module_id_t Mod_id, extern uint16_t beta_cqi[16]; -/* -void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, - struct PhysicalConfigDedicated *physicalConfigDedicated ) -{ - - static uint8_t first_dedicated_configuration = 0; - PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; - - phy_vars_ue->total_TBS[eNB_id]=0; - phy_vars_ue->total_TBS_last[eNB_id]=0; - phy_vars_ue->bitrate[eNB_id]=0; - phy_vars_ue->total_received_bits[eNB_id]=0; - phy_vars_ue->dlsch_errors[eNB_id]=0; - phy_vars_ue->dlsch_errors_last[eNB_id]=0; - phy_vars_ue->dlsch_received[eNB_id]=0; - phy_vars_ue->dlsch_received_last[eNB_id]=0; - phy_vars_ue->dlsch_fer[eNB_id]=0; - - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; - - if (physicalConfigDedicated) { - LOG_D(PHY,"[UE %d] Received physicalConfigDedicated from eNB %d\n",Mod_id, eNB_id); - LOG_D(PHY,"------------------------------------------------------------------------\n"); - - if (physicalConfigDedicated->pdsch_ConfigDedicated) { - phy_vars_ue->pdsch_config_dedicated[eNB_id].p_a=physicalConfigDedicated->pdsch_ConfigDedicated->p_a; - LOG_D(PHY,"pdsch_config_dedicated.p_a %d\n",phy_vars_ue->pdsch_config_dedicated[eNB_id].p_a); - LOG_D(PHY,"\n"); - } - - if (physicalConfigDedicated->pucch_ConfigDedicated) { - if (physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.present==PUCCH_ConfigDedicated__ackNackRepetition_PR_release) - phy_vars_ue->pucch_config_dedicated[eNB_id].ackNackRepetition=0; - else { - phy_vars_ue->pucch_config_dedicated[eNB_id].ackNackRepetition=1; - } - - if (physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode) - phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode = *physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode; - else - phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode = bundling; - - if ( phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode == multiplexing) - LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = multiplexing\n"); - else - LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = bundling\n"); - } - - if (physicalConfigDedicated->pusch_ConfigDedicated) { - phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; - phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; - phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; - - - LOG_D(PHY,"pusch_config_dedicated.betaOffset_ACK_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index); - LOG_D(PHY,"pusch_config_dedicated.betaOffset_RI_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index); - LOG_D(PHY,"pusch_config_dedicated.betaOffset_CQI_Index %d => %d)\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index,beta_cqi[phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index]); - LOG_D(PHY,"\n"); - - - } - - if (physicalConfigDedicated->uplinkPowerControlDedicated) { - - phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH = physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUSCH; - phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled= physicalConfigDedicated->uplinkPowerControlDedicated->deltaMCS_Enabled; - phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled= physicalConfigDedicated->uplinkPowerControlDedicated->accumulationEnabled; - phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUCCH= physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUCCH; - phy_vars_ue->ul_power_control_dedicated[eNB_id].pSRS_Offset= physicalConfigDedicated->uplinkPowerControlDedicated->pSRS_Offset; - phy_vars_ue->ul_power_control_dedicated[eNB_id].filterCoefficient= *physicalConfigDedicated->uplinkPowerControlDedicated->filterCoefficient; - LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUSCH %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH); - LOG_D(PHY,"ul_power_control_dedicated.deltaMCS_Enabled %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled); - LOG_D(PHY,"ul_power_control_dedicated.accumulationEnabled %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled); - LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUCCH %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUCCH); - LOG_D(PHY,"ul_power_control_dedicated.pSRS_Offset %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].pSRS_Offset); - LOG_D(PHY,"ul_power_control_dedicated.filterCoefficient %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].filterCoefficient); - LOG_D(PHY,"\n"); - } - - if (physicalConfigDedicated->antennaInfo) { - phy_vars_ue->transmission_mode[eNB_id] = 1+(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode); - LOG_I(PHY,"Transmission Mode %d\n",phy_vars_ue->transmission_mode[eNB_id]); - switch(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode) { - case AntennaInfoDedicated__transmissionMode_tm1: - phy_vars_ue->transmission_mode[eNB_id] = 1; - break; - case AntennaInfoDedicated__transmissionMode_tm2: - phy_vars_ue->transmission_mode[eNB_id] = 2; - break; - case AntennaInfoDedicated__transmissionMode_tm3: - phy_vars_ue->transmission_mode[eNB_id] = 3; - break; - case AntennaInfoDedicated__transmissionMode_tm4: - phy_vars_ue->transmission_mode[eNB_id] = 4; - break; - case AntennaInfoDedicated__transmissionMode_tm5: - phy_vars_ue->transmission_mode[eNB_id] = 5; - break; - case AntennaInfoDedicated__transmissionMode_tm6: - phy_vars_ue->transmission_mode[eNB_id] = 6; - break; - case AntennaInfoDedicated__transmissionMode_tm7: - lte_gold_ue_spec_port5(phy_vars_ue->lte_gold_uespec_port5_table, phy_vars_ue->frame_parms.Nid_cell, phy_vars_ue->pdcch_vars[0][eNB_id]->crnti); - phy_vars_ue->transmission_mode[eNB_id] = 7; - break; - default: - LOG_E(PHY,"Unknown transmission mode!\n"); - break; - } - } else { - LOG_D(PHY,"[UE %d] Received NULL physicalConfigDedicated->antennaInfo from eNB %d\n",Mod_id, eNB_id); - } - - if (physicalConfigDedicated->schedulingRequestConfig) { - if (physicalConfigDedicated->schedulingRequestConfig->present == SchedulingRequestConfig_PR_setup) { - phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex = physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex; - phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex=physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_ConfigIndex; - phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax=physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax; - - LOG_D(PHY,"scheduling_request_config.sr_PUCCH_ResourceIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - LOG_D(PHY,"scheduling_request_config.sr_ConfigIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex); - LOG_D(PHY,"scheduling_request_config.dsr_TransMax %d\n",phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax); - } - - LOG_D(PHY,"------------------------------------------------------------\n"); - - } - - if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { - - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 0; - if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 1; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].cyclicShift = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].freqDomainPosition = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_Bandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_HoppingBandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].transmissionComb = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; - - - LOG_D(PHY,"soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n",phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex); - } - - LOG_D(PHY,"------------------------------------------------------------\n"); - - } - - - if (physicalConfigDedicated->cqi_ReportConfig) { - if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic) { - // configure PUSCH CQI reporting - phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; - if ((phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm12) && - (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm30) && - (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm31)) - LOG_E(PHY,"Unsupported Aperiodic CQI Feedback Mode : %d\n",phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic); - } - if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic) { - if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_setup) { - // configure PUCCH CQI reporting - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; - if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex) - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex; - } - else if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_release) { - // handle release - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; - } - } - } - - } else { - LOG_D(PHY,"[PHY][UE %d] Received NULL radioResourceConfigDedicated from eNB %d\n",Mod_id,eNB_id); - return; - } - - // fill cqi parameters for periodic CQI reporting - get_cqipmiri_params(phy_vars_ue,eNB_id); - - // disable MIB SIB decoding once we are on connected mode - first_dedicated_configuration ++; - if(first_dedicated_configuration > 1) - { - LOG_I(PHY,"Disable SIB MIB decoding \n"); - phy_vars_ue->decode_SIB = 0; - phy_vars_ue->decode_MIB = 0; - } - //phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; - if(phy_vars_ue->pdcch_vars[0][eNB_id]->crnti == 0x1234) - phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti; - else - phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; - - LOG_I(PHY,"C-RNTI %x %x \n", phy_vars_ue->pdcch_vars[0][eNB_id]->crnti, - phy_vars_ue->pdcch_vars[1][eNB_id]->crnti); - - -}*/ - /*! \brief Helper function to allocate memory for DLSCH data structures. * \param[out] pdsch Pointer to the LTE_UE_PDSCH structure to initialize. * \param[in] frame_parms LTE_DL_FRAME_PARMS structure. @@ -988,57 +777,3 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue) { //init_scrambling_lut(); //set_taus_seed(1328); } - -void set_default_frame_parms_single(nfapi_nr_config_request_t *config, - NR_DL_FRAME_PARMS *frame_parms) { - /* Set some default values that may be overwritten while reading options */ - frame_parms = (NR_DL_FRAME_PARMS*) malloc(sizeof(NR_DL_FRAME_PARMS)); - config = (nfapi_nr_config_request_t*) malloc(sizeof(nfapi_nr_config_request_t)); - config->subframe_config.numerology_index_mu.value =1; - config->subframe_config.duplex_mode.value = 1; //FDD - config->subframe_config.dl_cyclic_prefix_type.value = 0; //NORMAL - config->rf_config.dl_carrier_bandwidth.value = 100; - config->rf_config.ul_carrier_bandwidth.value = 100; - config->sch_config.physical_cell_id.value = 0; - - frame_parms->frame_type = FDD; - //frame_parms[CC_id]->tdd_config_S = 0; - frame_parms->N_RB_DL = 106; - frame_parms->N_RB_UL = 106; - frame_parms->Ncp = NORMAL; - //frame_parms[CC_id]->Ncp_UL = NORMAL; - frame_parms->Nid_cell = 0; - //frame_parms[CC_id]->num_MBSFN_config = 0; - frame_parms->nb_antenna_ports_gNB = 1; - frame_parms->nb_antennas_tx = 1; - frame_parms->nb_antennas_rx = 1; - - //frame_parms[CC_id]->nushift = 0; - - ///frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; - //frame_parms[CC_id]->phich_config_common.phich_duration = normal; - - // UL RS Config - /*frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = 1;//n_DMRS1 set to 0 - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 1; - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; - - frame_parms[CC_id]->pusch_config_common.n_SB = 1; - frame_parms[CC_id]->pusch_config_common.hoppingMode = 0; - frame_parms[CC_id]->pusch_config_common.pusch_HoppingOffset = 0; - frame_parms[CC_id]->pusch_config_common.enable64QAM = 0; - - frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0;*/ - - // NR: Init to legacy LTE 20Mhz params - frame_parms->numerology_index = 0; - frame_parms->ttis_per_subframe = 1; - frame_parms->slots_per_tti = 2; - - -} diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index b95771e979..67ea1f25dd 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -27,8 +27,6 @@ uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3, 120e3, 240e3}; uint16_t nr_slots_per_subframe[MAX_NUM_SUBCARRIER_SPACING] = {1, 2, 4, 8, 16}; - - int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 5c480d6646..2db188f532 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -297,9 +297,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode, rx_sss_nr(ue,&metric_tdd_ncp,&phase_tdd_ncp); - //FK: why do we need to do this again here? - //nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,n_ssb_crb,0); - nr_gold_pbch(ue); ret = nr_pbch_detection(proc, ue,1,mode); // start pbch detection at first symbol after pss diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index a21af3fa03..4caed624bf 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -311,8 +311,6 @@ struct NR_DL_FRAME_PARMS { uint8_t numerology_index; /// NR number of ttis per subframe deduced from numerology (cf 38.211): 1, 2, 4, 8(not supported),16(not supported),32(not supported) uint8_t ttis_per_subframe; - /// NR number of slots per tti . Assumption only 2 Slot per TTI is supported (Slot Config 1 in 38.211) - uint8_t slots_per_tti; //#endif /// Number of Physical transmit antennas in node uint8_t nb_antennas_tx; From eb3c6538ee2bfa2a3d8bbb054256d4d635ad6de9 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 19 Oct 2020 16:54:29 +0200 Subject: [PATCH 072/149] Moved N_TA offset setting to init function --- executables/nr-ue.c | 3 ++ executables/nr-uesoftmodem.c | 45 ---------------------------- openair1/PHY/INIT/nr_init_ue.c | 55 ++++++++++++++++++++++++++++++++++ openair1/PHY/INIT/phy_init.h | 1 + 4 files changed, 59 insertions(+), 45 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index fd306e7f7a..821ccd9943 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -158,6 +158,9 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, // intialize transport init_nr_ue_transport(ue, abstraction_flag); + + // init N_TA offset + init_N_TA_offset(ue); } /*! diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index ca12a7ad02..f931b59f98 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -685,51 +685,6 @@ int main( int argc, char **argv ) { UE[CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off; UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id]; - - if (UE[CC_id]->frame_parms.frame_type == FDD) { - UE[CC_id]->N_TA_offset = 0; - } else { - int N_RB = UE[CC_id]->frame_parms.N_RB_DL; - int N_TA_offset = UE[CC_id]->frame_parms.ul_CarrierFreq < 6e9 ? 400 : 431; // reference samples for 25600Tc @ 30.72 Ms/s for FR1, same @ 61.44 Ms/s for FR2 - double factor=1; - switch (UE[CC_id]->frame_parms.numerology_index) { - case 0: //15 kHz scs - AssertFatal(N_TA_offset == 400, "scs_common 15kHz only for FR1\n"); - if (N_RB <= 25) factor = .25; // 7.68 Ms/s - else if (N_RB <=50) factor = .5; // 15.36 Ms/s - else if (N_RB <=75) factor = 1.0; // 30.72 Ms/s - else if (N_RB <=100) factor = 1.0; // 30.72 Ms/s - else AssertFatal(1==0,"Too many PRBS for mu=0\n"); - break; - case 1: //30 kHz sc - AssertFatal(N_TA_offset == 400, "scs_common 30kHz only for FR1\n"); - if (N_RB <= 106) factor = 2.0; // 61.44 Ms/s - else if (N_RB <= 275) factor = 4.0; // 122.88 Ms/s - break; - case 2: //60 kHz scs - AssertFatal(1==0,"scs_common should not be 60 kHz\n"); - break; - case 3: //120 kHz scs - AssertFatal(N_TA_offset == 431, "scs_common 120kHz only for FR2\n"); - break; - case 4: //240 kHz scs - AssertFatal(1==0,"scs_common should not be 60 kHz\n"); - if (N_RB <= 32) factor = 1.0; // 61.44 Ms/s - else if (N_RB <= 66) factor = 2.0; // 122.88 Ms/s - else AssertFatal(1==0,"N_RB %d is too big for curretn FR2 implementation\n",N_RB); - break; - - if (N_RB == 100) - UE[CC_id]->N_TA_offset = 624; - else if (N_RB == 50) - UE[CC_id]->N_TA_offset = 624/2; - else if (N_RB == 25) - UE[CC_id]->N_TA_offset = 624/4; - } - if (UE[CC_id]->frame_parms.threequarter_fs == 1) factor = factor*.75; - UE[CC_id]->N_TA_offset = (int)(N_TA_offset * factor); - LOG_I(PHY,"UE %d Setting N_TA_offset to %d samples (factor %f, UL Freq %lu, N_RB %d)\n", UE[CC_id]->Mod_id, UE[CC_id]->N_TA_offset, factor, UE[CC_id]->frame_parms.ul_CarrierFreq, N_RB); - } } // printf("tx_max_power = %d -> amp %d\n",tx_max_power[0],get_tx_amp(tx_max_poHwer,tx_max_power)); diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index d5a6b44a70..dfc319a41b 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -760,6 +760,61 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue, ue->dlsch_MCH[0] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,MAX_LDPC_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0); } + +void init_N_TA_offset(PHY_VARS_NR_UE *ue){ + + NR_DL_FRAME_PARMS *fp = &ue->frame_parms; + + if (fp->frame_type == FDD) { + ue->N_TA_offset = 0; + } else { + int N_RB = fp->N_RB_DL; + int N_TA_offset = fp->ul_CarrierFreq < 6e9 ? 400 : 431; // reference samples for 25600Tc @ 30.72 Ms/s for FR1, same @ 61.44 Ms/s for FR2 + double factor = 1; + switch (fp->numerology_index) { + case 0: //15 kHz scs + AssertFatal(N_TA_offset == 400, "scs_common 15kHz only for FR1\n"); + if (N_RB <= 25) factor = .25; // 7.68 Ms/s + else if (N_RB <=50) factor = .5; // 15.36 Ms/s + else if (N_RB <=75) factor = 1.0; // 30.72 Ms/s + else if (N_RB <=100) factor = 1.0; // 30.72 Ms/s + else AssertFatal(1==0, "Too many PRBS for mu=0\n"); + break; + case 1: //30 kHz sc + AssertFatal(N_TA_offset == 400, "scs_common 30kHz only for FR1\n"); + if (N_RB <= 106) factor = 2.0; // 61.44 Ms/s + else if (N_RB <= 275) factor = 4.0; // 122.88 Ms/s + break; + case 2: //60 kHz scs + AssertFatal(1==0, "scs_common should not be 60 kHz\n"); + break; + case 3: //120 kHz scs + AssertFatal(N_TA_offset == 431, "scs_common 120kHz only for FR2\n"); + break; + case 4: //240 kHz scs + AssertFatal(1==0, "scs_common should not be 60 kHz\n"); + if (N_RB <= 32) factor = 1.0; // 61.44 Ms/s + else if (N_RB <= 66) factor = 2.0; // 122.88 Ms/s + else AssertFatal(1==0, "N_RB %d is too big for curretn FR2 implementation\n", N_RB); + break; + + if (N_RB == 100) + ue->N_TA_offset = 624; + else if (N_RB == 50) + ue->N_TA_offset = 624/2; + else if (N_RB == 25) + ue->N_TA_offset = 624/4; + } + + if (fp->threequarter_fs == 1) + factor = factor*.75; + + ue->N_TA_offset = (int)(N_TA_offset * factor); + + LOG_I(PHY,"UE %d Setting N_TA_offset to %d samples (factor %f, UL Freq %lu, N_RB %d)\n", ue->Mod_id, ue->N_TA_offset, factor, fp->ul_CarrierFreq, N_RB); + } +} + void phy_init_nr_top(PHY_VARS_NR_UE *ue) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; crcTableInit(); diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index 1862d5f8e0..5323136e2b 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -397,6 +397,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t *config, NR_DL_FRAME_PARMS int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,fapi_nr_config_request_t *config,int Ncp); int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag); void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag); +void init_N_TA_offset(PHY_VARS_NR_UE *ue); void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms); int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char abstraction_flag); void nr_phy_config_request(NR_PHY_Config_t *gNB); From 8e7d69989bf6777396551bd24213f657b9fc5e1a Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 19 Oct 2020 18:02:28 +0200 Subject: [PATCH 073/149] Cleanup initialisation frame params UE and command line options - got rid of global variable fp - code cleanup, removed redundant and unused code - removed unused command line options and variables - grouped command line setting in set_options function --- executables/nr-ue.c | 4 +- executables/nr-uesoftmodem.c | 330 ++++++++++++----------------------- executables/nr-uesoftmodem.h | 13 +- openair1/PHY/INIT/nr_parms.c | 24 ++- openair1/PHY/INIT/phy_init.h | 2 +- 5 files changed, 131 insertions(+), 242 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 821ccd9943..cce6977a9e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -135,17 +135,15 @@ typedef enum { void init_nr_ue_vars(PHY_VARS_NR_UE *ue, - NR_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag) { int nb_connected_gNB = 1, gNB_id; - memcpy(&(ue->frame_parms), frame_parms, sizeof(NR_DL_FRAME_PARMS)); - ue->Mod_id = UE_id; ue->mac_enabled = 1; + ue->if_inst = nr_ue_if_module_init(0); // Setting UE mode to NOT_SYNCHED by default for (gNB_id = 0; gNB_id < nb_connected_gNB; gNB_id++){ diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index f931b59f98..09db0ac7fe 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -85,7 +85,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "executables/softmodem-common.h" #include "executables/thread-common.h" -// Raphael : missing +// Thread variables pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex @@ -94,30 +94,40 @@ pthread_cond_t sync_cond; pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; +tpool_t *Tpool; +#ifdef UE_DLSCH_PARALLELISATION + tpool_t *Tpool_dl; +#endif RAN_CONTEXT_t RC; volatile int start_eNB = 0; volatile int start_UE = 0; volatile int oai_exit = 0; -int single_thread_flag=1; -static double snr_dB=20; +// Command line options -int threequarter_fs=0; +extern int16_t nr_dlsch_demod_shift; +static int tx_max_power[MAX_NUM_CCs] = {0}; -uint64_t downlink_frequency[MAX_NUM_CCs][4]; -int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; -//int32_t uplink_counter = 0; - - -extern int16_t nr_dlsch_demod_shift; - -int UE_scan = 0; -int UE_scan_carrier = 0; -int UE_fo_compensation = 0; +int single_thread_flag = 1; +int threequarter_fs = 0; +int UE_scan_carrier = 0; +int UE_fo_compensation = 0; int UE_no_timing_correction = 0; -runmode_t mode = normal_txrx; -openair0_config_t openair0_cfg[MAX_CARDS]; +int N_RB_DL = 0; +int tddflag = 0; +int vcdflag = 0; +uint8_t nb_antenna_tx = 1; +uint8_t nb_antenna_rx = 1; +double rx_gain_off = 0.0; +uint32_t timing_advance = 0; +char *usrp_args = NULL; +char *rrc_config_path = NULL; +int dumpframe = 0; + +uint64_t downlink_frequency[MAX_NUM_CCs][4]; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; +int rx_input_level_dBm; #if MAX_NUM_CCs == 1 rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}}; @@ -129,74 +139,25 @@ double tx_gain[MAX_NUM_CCs][4] = {{20,0,0,0},{20,0,0,0}}; double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0},{20,0,0,0}}; #endif -double rx_gain_off = 0.0; +// UE and OAI config variables -double sample_rate=30.72e6; -double bw = 10.0e6; +openair0_config_t openair0_cfg[MAX_CARDS]; +int16_t node_synch_ref[MAX_NUM_CCs]; +int otg_enabled; +double cpuf; -static int tx_max_power[MAX_NUM_CCs] = {0}; - - -int chain_offset=0; - - -uint8_t dci_Format = 0; -uint8_t agregation_Level =0xFF; - -uint8_t nb_antenna_tx = 1; -uint8_t nb_antenna_rx = 1; - -char ref[128] = "internal"; -char channels[128] = "0"; - - -int rx_input_level_dBm; - -//static int online_log_messages=0; - - -int otg_enabled; -//int number_of_cards = 1; - -static NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; -int16_t node_synch_ref[MAX_NUM_CCs]; - -uint32_t target_dl_mcs = 28; //maximum allowed mcs -uint32_t target_ul_mcs = 20; -uint32_t timing_advance = 0; -uint64_t num_missed_slots=0; // counter for the number of missed slots - - -int transmission_mode=1; -int numerology = 0; -int usrp_tx_thread = 0; - -/* flag set by eNB conf file to specify if the radio head is local or remote (default option is local) */ -//uint8_t local_remote_radio = BBU_LOCAL_RADIO_HEAD; -/* struct for ethernet specific parameters given in eNB conf file */ -//eth_params_t *eth_params; - -double cpuf; +runmode_t mode = normal_txrx; +int UE_scan = 0; +int chain_offset = 0; +uint64_t num_missed_slots = 0; // counter for the number of missed slots +int transmission_mode = 1; +int numerology = 0; +int usrp_tx_thread = 0; +int oaisim_flag = 0; +int emulate_rf = 0; char uecap_xer[1024],uecap_xer_in=0; -int oaisim_flag=0; -int emulate_rf = 0; - -tpool_t *Tpool; -#ifdef UE_DLSCH_PARALLELISATION - tpool_t *Tpool_dl; -#endif - - -char *usrp_args=NULL; - -char *rrc_config_path=NULL; - -/* forward declarations */ -void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); - - /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution */ @@ -245,37 +206,6 @@ void exit_function(const char *file, const char *function, const int line, const exit(1); } - -void reset_stats(long arg) { - //int i,j,k; - /*PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[0][0]; - - for (i=0; idlsch[i][0]->Mlimit; j++) { - phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; - phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; - phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; - } - - phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0; - phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0; - phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0; - - for (j=0; julsch[i]->Mlimit; j++) { - phy_vars_eNB->UE_stats[i].ulsch_decoding_attempts[k][j]=0; - phy_vars_eNB->UE_stats[i].ulsch_decoding_attempts_last[k][j]=0; - phy_vars_eNB->UE_stats[i].ulsch_round_errors[k][j]=0; - phy_vars_eNB->UE_stats[i].ulsch_round_fer[k][j]=0; - } - } - - phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0; - phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0; - phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0; - }*/ -} - void *l2l1_task(void *arg) { MessageDef *message_p = NULL; int result; @@ -316,21 +246,12 @@ void *l2l1_task(void *arg) { return NULL; } - -int16_t dlsch_demod_shift; - static void get_options(void) { - int CC_id; - int tddflag=0, nonbiotflag, vcdflag=0; + char *loopfile=NULL; - int dumpframe=0; - //uint32_t noS1; - //uint32_t nokrnmod; - //uint32_t nokrnmod; + paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC_UE ; config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); - - paramdef_t cmdline_uemodeparams[] = CMDLINE_UEMODEPARAMS_DESC; paramdef_t cmdline_ueparams[] = CMDLINE_NRUEPARAMS_DESC; config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); @@ -351,25 +272,12 @@ static void get_options(void) { if (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx; - if (dumpframe > 0) mode = rx_dump_frame; - - UE_scan=0; - - if (tddflag > 0) { - for (CC_id=0; CC_idframe_type = TDD; - } + if ((cmdline_uemodeparams[CMDLINE_DUMPMEMORY_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) + mode = rx_dump_frame; if (vcdflag > 0) ouput_vcd = 1; - for (CC_id=1; CC_idnr_band = 78; - frame_parms[CC_id]->frame_type = FDD; - frame_parms[CC_id]->tdd_config = 3; - //frame_parms[CC_id]->tdd_config_S = 0; - frame_parms[CC_id]->N_RB_DL = 106; - frame_parms[CC_id]->N_RB_UL = 106; - frame_parms[CC_id]->Ncp = NORMAL; - //frame_parms[CC_id]->Ncp_UL = NORMAL; - frame_parms[CC_id]->Nid_cell = 0; - //frame_parms[CC_id]->num_MBSFN_config = 0; - frame_parms[CC_id]->nb_antenna_ports_gNB = 1; - frame_parms[CC_id]->nb_antennas_tx = 1; - frame_parms[CC_id]->nb_antennas_rx = 1; - //frame_parms[CC_id]->nushift = 0; - // NR: Init to legacy LTE 20Mhz params - frame_parms[CC_id]->numerology_index = 0; - frame_parms[CC_id]->ttis_per_subframe = 1; + // Set UE variables + UE->UE_scan = UE_scan; + UE->UE_scan_carrier = UE_scan_carrier; + UE->UE_fo_compensation = UE_fo_compensation; + UE->no_timing_correction = UE_no_timing_correction; + UE->mode = mode; + UE->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off; + UE->tx_power_max_dBm = tx_max_power[CC_id]; + + LOG_I(PHY,"Set UE mode %d, UE_fo_compensation %d, UE_scan %d, UE_scan_carrier %d, UE_no_timing_correction %d \n", mode, UE_fo_compensation, UE_scan, UE_scan_carrier, UE_no_timing_correction); + + // Set FP variables + NR_DL_FRAME_PARMS *fp = &UE->frame_parms; + fp->nb_antennas_tx = nb_antenna_tx; + fp->nb_antennas_rx = nb_antenna_rx; + fp->threequarter_fs = threequarter_fs; + if (tddflag){ + fp->frame_type = TDD; + LOG_I(PHY, "Set UE frame_type %d\n", fp->frame_type); } + if (N_RB_DL){ + fp->N_RB_DL = N_RB_DL; + LOG_I(PHY, "Set UE N_RB_DL %d\n", N_RB_DL); + } + + LOG_I(PHY, "Set UE nb_rx_antenna %d , nb_tx_antenna %d, threequarter_fs %d\n", nb_antenna_rx, nb_antenna_tx, threequarter_fs); + } void init_openair0(void) { int card; int i; + NR_DL_FRAME_PARMS *frame_parms = &PHY_vars_UE_g[0][0]->frame_parms; for (card=0; cardthreequarter_fs; - numerology = frame_parms[0]->numerology_index; + openair0_cfg[card].threequarter_fs = frame_parms->threequarter_fs; + numerology = frame_parms->numerology_index; - if(frame_parms[0]->N_RB_DL == 66) { + if(frame_parms->N_RB_DL == 66) { if (numerology==3) { openair0_cfg[card].sample_rate=122.88e6; openair0_cfg[card].samples_per_frame = 1228800; @@ -423,7 +342,7 @@ void init_openair0(void) { LOG_E(PHY,"Unsupported numerology! FR2 supports only 120KHz SCS for now.\n"); exit(-1); } - }else if(frame_parms[0]->N_RB_DL == 32) { + }else if(frame_parms->N_RB_DL == 32) { if (numerology==3) { openair0_cfg[card].sample_rate=61.44e6; openair0_cfg[card].samples_per_frame = 614400; @@ -431,9 +350,9 @@ void init_openair0(void) { LOG_E(PHY,"Unsupported numerology! FR2 supports only 120KHz SCS for now.\n"); exit(-1); } - }else if(frame_parms[0]->N_RB_DL == 217) { + }else if(frame_parms->N_RB_DL == 217) { if (numerology==1) { - if (frame_parms[0]->threequarter_fs) { + if (frame_parms->threequarter_fs) { openair0_cfg[card].sample_rate=92.16e6; openair0_cfg[card].samples_per_frame = 921600; } @@ -445,9 +364,9 @@ void init_openair0(void) { LOG_E(PHY,"Unsupported numerology!\n"); exit(-1); } - } else if(frame_parms[0]->N_RB_DL == 273) { + } else if(frame_parms->N_RB_DL == 273) { if (numerology==1) { - if (frame_parms[0]->threequarter_fs) { + if (frame_parms->threequarter_fs) { AssertFatal(0 == 1,"three quarter sampling not supported for N_RB 273\n"); } else { @@ -458,9 +377,9 @@ void init_openair0(void) { LOG_E(PHY,"Unsupported numerology!\n"); exit(-1); } - } else if(frame_parms[0]->N_RB_DL == 106) { + } else if(frame_parms->N_RB_DL == 106) { if (numerology==0) { - if (frame_parms[0]->threequarter_fs) { + if (frame_parms->threequarter_fs) { openair0_cfg[card].sample_rate=23.04e6; openair0_cfg[card].samples_per_frame = 230400; } else { @@ -468,7 +387,7 @@ void init_openair0(void) { openair0_cfg[card].samples_per_frame = 307200; } } else if (numerology==1) { - if (frame_parms[0]->threequarter_fs) { + if (frame_parms->threequarter_fs) { openair0_cfg[card].sample_rate=46.08e6; openair0_cfg[card].samples_per_frame = 460800; } @@ -483,35 +402,37 @@ void init_openair0(void) { LOG_E(PHY,"Unsupported numerology!\n"); exit(-1); } - } else if(frame_parms[0]->N_RB_DL == 50) { + } else if(frame_parms->N_RB_DL == 50) { openair0_cfg[card].sample_rate=15.36e6; openair0_cfg[card].samples_per_frame = 153600; - } else if (frame_parms[0]->N_RB_DL == 25) { + } else if (frame_parms->N_RB_DL == 25) { openair0_cfg[card].sample_rate=7.68e6; openair0_cfg[card].samples_per_frame = 76800; - } else if (frame_parms[0]->N_RB_DL == 6) { + } else if (frame_parms->N_RB_DL == 6) { openair0_cfg[card].sample_rate=1.92e6; openair0_cfg[card].samples_per_frame = 19200; } else { - LOG_E(PHY,"Unknown NB_RB %d!\n",frame_parms[0]->N_RB_DL); + LOG_E(PHY,"Unknown NB_RB %d!\n",frame_parms->N_RB_DL); exit(-1); } - if (frame_parms[0]->frame_type==TDD) + if (frame_parms->frame_type==TDD) openair0_cfg[card].duplex_mode = duplex_mode_TDD; else //FDD openair0_cfg[card].duplex_mode = duplex_mode_FDD; - printf("HW: Configuring card %d, nb_antennas_tx/rx %hhu/%hhu\n",card, - PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx, - PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx); + LOG_I(PHY, "HW: Configuring card %d, nb_antennas_tx/rx %hhu/%hhu\n", + card, + frame_parms->nb_antennas_tx, + frame_parms->nb_antennas_rx); + openair0_cfg[card].Mod_id = 0; - openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; + openair0_cfg[card].num_rb_dl = frame_parms->N_RB_DL; openair0_cfg[card].clock_source = get_softmodem_params()->clock_source; openair0_cfg[card].time_source = get_softmodem_params()->timing_source; - openair0_cfg[card].tx_num_channels=min(2,PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx); - openair0_cfg[card].rx_num_channels=min(2,PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx); + openair0_cfg[card].tx_num_channels = min(2, frame_parms->nb_antennas_tx); + openair0_cfg[card].rx_num_channels = min(2, frame_parms->nb_antennas_rx); for (i=0; i<4; i++) { @@ -519,7 +440,7 @@ void init_openair0(void) { if (downlink_frequency[0][0]) openair0_cfg[card].rx_freq[i] = downlink_frequency[0][0]; else - openair0_cfg[card].rx_freq[i] = frame_parms[0]->dl_CarrierFreq; + openair0_cfg[card].rx_freq[i] = frame_parms->dl_CarrierFreq; } else openair0_cfg[card].rx_freq[i]=0.0; @@ -528,7 +449,7 @@ void init_openair0(void) { if (uplink_frequency_offset[0][0]) openair0_cfg[card].tx_freq[i] = openair0_cfg[card].rx_freq[i] + uplink_frequency_offset[0][0]; else - openair0_cfg[card].tx_freq[i] = frame_parms[0]->ul_CarrierFreq; + openair0_cfg[card].tx_freq[i] = frame_parms->ul_CarrierFreq; } else openair0_cfg[card].tx_freq[i]=0.0; @@ -586,14 +507,12 @@ int main( int argc, char **argv ) { } set_softmodem_sighandler(); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); - set_default_frame_parms(frame_parms); - mode = normal_txrx; memset(openair0_cfg,0,sizeof(openair0_config_t)*MAX_CARDS); memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs); // initialize logging logInit(); // get options and fill parameters from configuration file - get_options (); //Command-line options, enb_properties + get_options(); //Command-line options get_common_options(SOFTMODEM_5GUE_BIT ); #if T_TRACER T_Config_Init(); @@ -628,14 +547,6 @@ int main( int argc, char **argv ) { init_NR_UE(1,rrc_config_path); if(IS_SOFTMODEM_NOS1) init_pdcp(); -/* -#ifdef PDCP_USE_NETLINK - netlink_init(); -#if defined(PDCP_USE_NETLINK_QUEUES) - pdcp_netlink_init(); -#endif -#endif -*/ NB_UE_INST=1; NB_INST=1; @@ -646,48 +557,25 @@ int main( int argc, char **argv ) { AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); for (int CC_id=0; CC_idofdm_symbol_size); - frame_parms[CC_id]->nb_antennas_tx = nb_antenna_tx; - frame_parms[CC_id]->nb_antennas_rx = nb_antenna_rx; - frame_parms[CC_id]->nb_antenna_ports_gNB = 1; //initial value overwritten by initial sync later - frame_parms[CC_id]->threequarter_fs = threequarter_fs; - LOG_I(PHY,"Set nb_rx_antenna %d , nb_tx_antenna %d \n",frame_parms[CC_id]->nb_antennas_rx, frame_parms[CC_id]->nb_antennas_tx); PHY_vars_UE_g[0][CC_id] = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE)); - UE[CC_id] = PHY_vars_UE_g[0][CC_id]; memset(UE[CC_id],0,sizeof(PHY_VARS_NR_UE)); + set_options(CC_id, UE[CC_id]); + NR_UE_MAC_INST_t *mac = get_mac_inst(0); if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL) mac->if_module->phy_config_request(&mac->phy_config); fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; - nr_init_frame_parms_ue(frame_parms[CC_id],nrUE_config,NORMAL); - // Overwrite DL frequency (for FR2 testing) - // if (downlink_frequency[0][0]!=0) { - // frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; - // frame_parms[CC_id]->ul_CarrierFreq = downlink_frequency[0][0]; - // } - - init_symbol_rotation(frame_parms[CC_id],frame_parms[CC_id]->dl_CarrierFreq); - init_nr_ue_vars(UE[CC_id],frame_parms[CC_id],0,abstraction_flag); + nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config, *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]); + init_symbol_rotation(&UE[CC_id]->frame_parms, UE[CC_id]->frame_parms.dl_CarrierFreq); + init_nr_ue_vars(UE[CC_id], 0, abstraction_flag); - UE[CC_id]->mac_enabled = 1; - UE[CC_id]->if_inst = nr_ue_if_module_init(0); - UE[CC_id]->UE_scan = UE_scan; - UE[CC_id]->UE_scan_carrier = UE_scan_carrier; - UE[CC_id]->UE_fo_compensation = UE_fo_compensation; - UE[CC_id]->mode = mode; - UE[CC_id]->no_timing_correction = UE_no_timing_correction; - printf("UE[%d]->mode = %d\n",CC_id,mode); - - UE[CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off; - UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id]; } - // printf("tx_max_power = %d -> amp %d\n",tx_max_power[0],get_tx_amp(tx_max_poHwer,tx_max_power)); init_openair0(); // init UE_PF_PO and mutex lock pthread_mutex_init(&ue_pf_po_mutex, NULL); diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 418ed54fc6..b2d321ae29 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -48,13 +48,12 @@ {"ue-scan-carrier", CONFIG_HLP_UESCAN, PARAMFLAG_BOOL, iptr:&UE_scan_carrier, defintval:0, TYPE_INT, 0}, \ {"ue-fo-compensation", CONFIG_HLP_UEFO, PARAMFLAG_BOOL, iptr:&UE_fo_compensation, defintval:0, TYPE_INT, 0}, \ {"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:90, TYPE_INT, 0}, \ - {"r" , CONFIG_HLP_PRB, 0, iptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT, 0}, \ - {"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ + {"r" , CONFIG_HLP_PRB, 0, iptr:&(N_RB_DL), defintval:25, TYPE_UINT, 0}, \ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200", TYPE_STRING, 0} \ } /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* command line parameters common to eNodeB and UE */ +/* command line parameters common to gNB and UE */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_PARAMS_DESC_UE { \ @@ -62,22 +61,16 @@ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, iptr:&threequarter_fs, defintval:0, TYPE_INT, 0}, \ - {"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ - {"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ - {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ - {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0}, \ {"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, iptr:&UE_no_timing_correction, defintval:0, TYPE_INT, 0}, \ {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0} \ } - extern int T_port; extern int T_nowait; extern int T_dont_fork; - // In nr-ue.c extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern void fill_ue_band_info(void); @@ -86,7 +79,7 @@ extern void init_NR_UE_threads(int); extern void reset_opp_meas(void); extern void print_opp_meas(void); void *UE_thread(void *arg); -void init_nr_ue_vars(PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); +void init_nr_ue_vars(PHY_VARS_NR_UE *ue, uint8_t UE_id, uint8_t abstraction_flag); extern tpool_t *Tpool; extern tpool_t *Tpool_dl; #endif diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 67ea1f25dd..21acd6d31c 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -83,6 +83,9 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp) void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, uint16_t bw) { + + fp->ttis_per_subframe = 1; + switch(mu) { case NR_MU_0: //15kHz scs @@ -313,10 +316,22 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, } int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, - fapi_nr_config_request_t* config, - int Ncp) + fapi_nr_config_request_t* config, + uint16_t nr_band) { + uint8_t nb_ant_ports_gNB = 1; + uint8_t tdd_cfg = 3; + uint8_t Nid_cell = 0; + int Ncp = NORMAL; + + // default values until overwritten by RRCConnectionReconfiguration + fp->nb_antenna_ports_gNB = nb_ant_ports_gNB; + fp->tdd_config = tdd_cfg; + fp->Nid_cell = Nid_cell; + fp->nr_band = nr_band; + LOG_I(PHY, "Initializing frame parms: set nb_rx_antenna %d , nb_tx_antenna %d nb_antenna_ports_gNB %d\n", fp->nb_antennas_rx, fp->nb_antennas_tx, fp->nb_antenna_ports_gNB); + uint64_t dl_bw_khz = (12*config->carrier_config.dl_grid_size[config->ssb_config.scs_common])*(15<ssb_config.scs_common); fp->dl_CarrierFreq = ((dl_bw_khz>>1) + config->carrier_config.dl_frequency)*1000 ; @@ -352,11 +367,6 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, set_scs_parameters(fp,fp->numerology_index,config->carrier_config.dl_bandwidth); fp->slots_per_frame = 10* fp->slots_per_subframe; - - fp->nb_antenna_ports_gNB = 1; // default value until overwritten by RRCConnectionReconfiguration - fp->nb_antennas_rx = 1; // default value until overwritten by RRCConnectionReconfiguration - fp->nb_antennas_tx = 1; // default value until overwritten by RRCConnectionReconfiguration - fp->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats fp->samples_per_subframe_wCP = fp->ofdm_symbol_size * fp->symbols_per_slot * fp->slots_per_subframe; fp->samples_per_frame_wCP = 10 * fp->samples_per_subframe_wCP; diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index 5323136e2b..9c474264c8 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -394,7 +394,7 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf); void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms); int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp); int nr_init_frame_parms(nfapi_nr_config_request_scf_t *config, NR_DL_FRAME_PARMS *frame_parms); -int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,fapi_nr_config_request_t *config,int Ncp); +int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms, fapi_nr_config_request_t *config, uint16_t nr_band); int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag); void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag); void init_N_TA_offset(PHY_VARS_NR_UE *ue); From 3939406141a03eacc33973aee5ff2fd0adee371a Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 16 Sep 2020 20:59:07 +0200 Subject: [PATCH 074/149] Logging fixes at UE and gNB --- executables/nr-uesoftmodem.c | 2 +- openair1/PHY/INIT/nr_init_ue.c | 2 +- openair1/PHY/INIT/nr_parms.c | 5 +++-- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 8 ++++---- openair2/LAYER2/NR_MAC_UE/config_ue.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/config.c | 10 +++++----- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 09db0ac7fe..26d5887f76 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -320,7 +320,7 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ LOG_I(PHY, "Set UE N_RB_DL %d\n", N_RB_DL); } - LOG_I(PHY, "Set UE nb_rx_antenna %d , nb_tx_antenna %d, threequarter_fs %d\n", nb_antenna_rx, nb_antenna_tx, threequarter_fs); + LOG_I(PHY, "Set UE nb_rx_antenna %d, nb_tx_antenna %d, threequarter_fs %d\n", nb_antenna_rx, nb_antenna_tx, threequarter_fs); } diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index dfc319a41b..ac63718c4b 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -445,7 +445,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, fp->nb_antennas_rx=1; // dmrs_UplinkConfig_t *dmrs_Uplink_Config = &ue->pusch_config.dmrs_UplinkConfig; // ptrs_UplinkConfig_t *ptrs_Uplink_Config = &ue->pusch_config.dmrs_UplinkConfig.ptrs_UplinkConfig; - printf("Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx); + LOG_I(PHY, "Initializing UE vars (abstraction %u) for gNB TXant %u, UE RXant %u\n", abstraction_flag, fp->nb_antennas_tx, fp->nb_antennas_rx); //LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST); phy_init_nr_top(ue); // many memory allocation sizes are hard coded diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 21acd6d31c..29764e9051 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -330,7 +330,8 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, fp->tdd_config = tdd_cfg; fp->Nid_cell = Nid_cell; fp->nr_band = nr_band; - LOG_I(PHY, "Initializing frame parms: set nb_rx_antenna %d , nb_tx_antenna %d nb_antenna_ports_gNB %d\n", fp->nb_antennas_rx, fp->nb_antennas_tx, fp->nb_antenna_ports_gNB); + + LOG_I(PHY, "Initializing frame parms: set nb_antenna_ports_gNB %d, tdd_config, %d, Nid_cell %d\n", fp->nb_antenna_ports_gNB, fp->tdd_config, fp->Nid_cell); uint64_t dl_bw_khz = (12*config->carrier_config.dl_grid_size[config->ssb_config.scs_common])*(15<ssb_config.scs_common); fp->dl_CarrierFreq = ((dl_bw_khz>>1) + config->carrier_config.dl_frequency)*1000 ; @@ -347,7 +348,7 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, get_frame_type(fp->nr_band, fp->numerology_index, &fp->frame_type); uplink_frequency_offset *= 1000; - LOG_I(PHY, "DL frequency %lu Hz, UL frequency %lu Hz: band %d, uldl offset %d Hz\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq, fp->nr_band, uplink_frequency_offset); + LOG_I(PHY, "Initializing frame parms: DL frequency %lu Hz, UL frequency %lu Hz: band %d, uldl offset %d Hz\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq, fp->nr_band, uplink_frequency_offset); AssertFatal(fp->frame_type==config->cell_config.frame_duplex_type, "Invalid duplex type in config request file for band %d\n", fp->nr_band); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 3226ccd992..91c1c68a87 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1401,7 +1401,7 @@ uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config, else { r = L_ra/NCS; found_sequences = (nb_preambles/r) + (nb_preambles%r!=0); //ceil(nb_preambles/r) - printf(" found_sequences %u\n", found_sequences); + LOG_D(MAC, "Computing NR root sequences: found %u sequences\n", found_sequences); return (found_sequences); } } @@ -1439,7 +1439,7 @@ uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config, AssertFatal(1==0,"Procedure to find nb of sequences for restricted type B not implemented yet"); } } - printf(" found_sequences %u\n", found_sequences); + LOG_D(MAC, "Computing NR root sequences: found %u sequences\n", found_sequences); return found_sequences; } } @@ -1801,7 +1801,7 @@ uint64_t from_nrarfcn(int nr_bandP, } } - LOG_D(PHY, "Frequency from NR-ARFCN for N_OFFs %lu, duplex spacing %d KHz, deltaFglobal %d KHz\n", N_OFFs, delta_duplex, deltaFglobal); + LOG_D(MAC, "Frequency from NR-ARFCN for N_OFFs %lu, duplex spacing %d KHz, deltaFglobal %d KHz\n", N_OFFs, delta_duplex, deltaFglobal); AssertFatal(nrarfcn >= N_OFFs,"nrarfcn %u < N_OFFs[%d] %llu\n", nrarfcn, nr_bandtable[i].band, (long long unsigned int)N_OFFs); @@ -1811,7 +1811,7 @@ uint64_t from_nrarfcn(int nr_bandP, frequency = 1000*(freq_min + (nrarfcn - N_OFFs) * deltaFglobal); - LOG_I(PHY, "Computing frequency (pointA %llu => %llu KHz (freq_min %llu KHz, NR band %d N_OFFs %llu))\n", + LOG_I(MAC, "Computing frequency (pointA %llu => %llu KHz (freq_min %llu KHz, NR band %d N_OFFs %llu))\n", (unsigned long long)nrarfcn, (unsigned long long)frequency/1000, (unsigned long long)freq_min, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 1ea4d128f7..239d83728b 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -154,7 +154,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, // carrier config - LOG_I(MAC,"UE Config Common\n"); + LOG_I(MAC, "Entering UE Config Common\n"); cfg->carrier_config.dl_bandwidth = config_bandwidth(scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing, scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth, @@ -252,8 +252,8 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, "scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 is null\n"); cfg->tdd_table.tdd_period = *scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530; } - LOG_I(MAC,"Setting TDD configuration period to %d\n",cfg->tdd_table.tdd_period); if(cfg->cell_config.frame_duplex_type == TDD){ + LOG_I(MAC,"Setting TDD configuration period to %d\n", cfg->tdd_table.tdd_period); int return_tdd = set_tdd_config_nr_ue(cfg, scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing, scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots, diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 800631177f..943a3ef776 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -290,8 +290,8 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm "scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 is null\n"); cfg->tdd_table.tdd_period.value = *scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530; } - LOG_I(MAC,"Setting TDD configuration period to %d\n",cfg->tdd_table.tdd_period.value); if(cfg->cell_config.frame_duplex_type.value == TDD){ + LOG_I(MAC,"Setting TDD configuration period to %d\n",cfg->tdd_table.tdd_period.value); int return_tdd = set_tdd_config_nr(cfg, scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing, scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots, @@ -299,10 +299,10 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots, scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols); - if (return_tdd !=0){ - LOG_E(PHY,"TDD configuration can not be done\n"); - } - else LOG_I(PHY,"TDD has been properly configurated\n"); + if (return_tdd != 0) + LOG_E(MAC,"TDD configuration can not be done\n"); + else + LOG_I(MAC,"TDD has been properly configurated\n"); } } From a9096bc9ef799afd72af99b1c4200e9d283b11f3 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 26 Oct 2020 10:04:34 +0100 Subject: [PATCH 075/149] Moved downlink and uplink frequencies global variables to the relevant .h file --- openair1/PHY/phy_extern_nr_ue.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/phy_extern_nr_ue.h b/openair1/PHY/phy_extern_nr_ue.h index 2f2a0427f4..e06b0c913a 100644 --- a/openair1/PHY/phy_extern_nr_ue.h +++ b/openair1/PHY/phy_extern_nr_ue.h @@ -32,7 +32,8 @@ extern char fmageren_name2[512]; extern unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX]; extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; -//#include "PHY/LTE_TRANSPORT/transport_extern.h" +extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; +extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; extern const short conjugate[8],conjugate2[8]; extern int number_of_cards; From 95bd55d8b658adce4276378471f60e5b760b9063 Mon Sep 17 00:00:00 2001 From: cig Date: Fri, 23 Oct 2020 13:54:58 +0200 Subject: [PATCH 076/149] Cleanup redundant setting of duplex mode after sync --- executables/nr-ue.c | 10 +--------- executables/nr-uesoftmodem.c | 4 +++- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index cce6977a9e..60aa5af33c 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -171,8 +171,6 @@ typedef struct syncData_s { PHY_VARS_NR_UE *UE; } syncData_t; -extern const char *duplex_mode[]; - static void UE_synch(void *arg) { syncData_t *syncD=(syncData_t *) arg; int i, hw_slot_offset; @@ -186,15 +184,9 @@ static void UE_synch(void *arg) { for (i=0; irf_map.card].rx_num_channels; i++) { - if (UE->frame_parms.frame_type == FDD) - openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_FDD; - else - openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_TDD; - - LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %f, UL %f duplex mode %s (RF card %d, oai_exit %d, channel %d, rx_num_channels %d)\n", + LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %f, UL %f (RF card %d, oai_exit %d, channel %d, rx_num_channels %d)\n", openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i], openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i], - duplex_mode[openair0_cfg[UE->rf_map.card].duplex_mode], UE->rf_map.card, oai_exit, i, diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 26d5887f76..45475d194f 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -85,6 +85,8 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "executables/softmodem-common.h" #include "executables/thread-common.h" +extern const char *duplex_mode[]; + // Thread variables pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; @@ -419,7 +421,7 @@ void init_openair0(void) { if (frame_parms->frame_type==TDD) openair0_cfg[card].duplex_mode = duplex_mode_TDD; - else //FDD + else openair0_cfg[card].duplex_mode = duplex_mode_FDD; LOG_I(PHY, "HW: Configuring card %d, nb_antennas_tx/rx %hhu/%hhu\n", From 6862affdf4f778f2a967c080463e89dc24af2661 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 26 Oct 2020 09:55:09 +0100 Subject: [PATCH 077/149] Cleanup RF HW configuration at UE side - removed redundant initialisation of variables - introduced two "RF helpers" function that are replacing shared code in the sync routines - added a new .c file and updated the cmakelists and .h files --- cmake_targets/CMakeLists.txt | 1 + executables/nr-ue.c | 62 +++---------- executables/nr-uesoftmodem.c | 46 +++------- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 25 ++++++ .../PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c | 90 +++++++++++++++++++ 5 files changed, 141 insertions(+), 83 deletions(-) create mode 100644 openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 2ef5ab00df..024f7eb3df 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1628,6 +1628,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/sss_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/cic_filter_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_initial_sync.c + ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_pbch.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 60aa5af33c..e49cb1a613 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -246,37 +246,25 @@ static void UE_synch(void *arg) { case pbch: LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); + uint64_t dl_carrier, ul_carrier; + double rx_gain_off = 0; + nr_get_carrier_frequencies(&UE->frame_parms, &dl_carrier, &ul_carrier); + if (nr_initial_sync( &syncD->proc, UE, UE->mode,2) == 0) { freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync hw_slot_offset = ((UE->rx_offset<<1) / UE->frame_parms.samples_per_subframe * UE->frame_parms.slots_per_subframe) + round((float)((UE->rx_offset<<1) % UE->frame_parms.samples_per_subframe)/UE->frame_parms.samples_per_slot0); // rerun with new cell parameters and frequency-offset - for (i=0; irf_map.card].rx_num_channels; i++) { - openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; + // todo: the freq_offset computed on DL shall be scaled before being applied to UL + nr_rf_card_config(&openair0_cfg[UE->rf_map.card], rx_gain_off, ul_carrier, dl_carrier, freq_offset); - if (freq_offset >= 0) - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] += abs(freq_offset); - else - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(freq_offset); - - if (uplink_frequency_offset[0][0]) - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] + uplink_frequency_offset[0][0]; - else - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+(UE->frame_parms.ul_CarrierFreq-UE->frame_parms.dl_CarrierFreq); - - //UE->frame_parms.dl_CarrierFreq = openair0_cfg[CC_id].rx_freq[i]; - } - - LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %f Hz, UL %f Hz), UE_scan_carrier %d\n", + LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %f (DL %f Hz, UL %f Hz)\n", hw_slot_offset, freq_offset, - UE->rx_total_gain_dB, + openair0_cfg[UE->rf_map.card].rx_gain[0], openair0_cfg[UE->rf_map.card].rx_freq[0], - openair0_cfg[UE->rf_map.card].tx_freq[0], - UE->UE_scan_carrier); + openair0_cfg[UE->rf_map.card].tx_freq[0]); // reconfigure for potentially different bandwidth switch(UE->frame_parms.N_RB_DL) { @@ -332,45 +320,21 @@ static void UE_synch(void *arg) { UE->is_synchronized = 1; } } else { - // initial sync failed - // calculate new offset and try again - if (UE->UE_scan_carrier == 1) { - uint64_t dl_carrier, ul_carrier; + if (UE->UE_scan_carrier == 1) { if (freq_offset >= 0) freq_offset += 100; freq_offset *= -1; - if (downlink_frequency[0][0]) - dl_carrier = downlink_frequency[0][0]; - else - dl_carrier = UE->frame_parms.dl_CarrierFreq; + nr_rf_card_config(&openair0_cfg[UE->rf_map.card], rx_gain_off, ul_carrier, dl_carrier, freq_offset); - if (uplink_frequency_offset[0][0]) - ul_carrier = dl_carrier + uplink_frequency_offset[0][0]; - else - ul_carrier = dl_carrier + UE->frame_parms.ul_CarrierFreq - UE->frame_parms.dl_CarrierFreq; - - for (i=0; irf_map.card].rx_num_channels; i++) { - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = dl_carrier + freq_offset; - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = ul_carrier + freq_offset; - openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; - - LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %f, UL %f)\n", - freq_offset, - UE->rx_total_gain_dB, - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i], - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i]); - - if (UE->UE_scan_carrier==1) - openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; - } + LOG_I(PHY, "Initial sync failed: trying carrier off %d Hz\n", freq_offset); if (UE->mode != loop_through_memory) UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); - }// initial_sync=0 + } break; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 45475d194f..f3c5a4bea6 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -40,7 +40,7 @@ //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all #include "openair1/PHY/MODULATION/nr_modulation.h" #include "PHY/phy_vars_nr_ue.h" -#include "PHY/LTE_TRANSPORT/transport_vars.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "SCHED/sched_common_vars.h" #include "PHY/MODULATION/modulation_vars.h" //#include "../../SIMU/USER/init_lte.h" @@ -304,6 +304,7 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ UE->no_timing_correction = UE_no_timing_correction; UE->mode = mode; UE->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off; + UE->tx_total_gain_dB = (int)tx_gain[CC_id][0]; UE->tx_power_max_dBm = tx_max_power[CC_id]; LOG_I(PHY,"Set UE mode %d, UE_fo_compensation %d, UE_scan %d, UE_scan_carrier %d, UE_no_timing_correction %d \n", mode, UE_fo_compensation, UE_scan, UE_scan_carrier, UE_no_timing_correction); @@ -328,10 +329,11 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ void init_openair0(void) { int card; - int i; + int freq_off = 0; NR_DL_FRAME_PARMS *frame_parms = &PHY_vars_UE_g[0][0]->frame_parms; for (card=0; cardthreequarter_fs; numerology = frame_parms->numerology_index; @@ -424,11 +426,6 @@ void init_openair0(void) { else openair0_cfg[card].duplex_mode = duplex_mode_FDD; - LOG_I(PHY, "HW: Configuring card %d, nb_antennas_tx/rx %hhu/%hhu\n", - card, - frame_parms->nb_antennas_tx, - frame_parms->nb_antennas_rx); - openair0_cfg[card].Mod_id = 0; openair0_cfg[card].num_rb_dl = frame_parms->N_RB_DL; openair0_cfg[card].clock_source = get_softmodem_params()->clock_source; @@ -436,36 +433,17 @@ void init_openair0(void) { openair0_cfg[card].tx_num_channels = min(2, frame_parms->nb_antennas_tx); openair0_cfg[card].rx_num_channels = min(2, frame_parms->nb_antennas_rx); - for (i=0; i<4; i++) { + LOG_I(PHY, "HW: Configuring card %d, tx/rx num_channels %d/%d, duplex_mode %s\n", + card, + openair0_cfg[card].tx_num_channels, + openair0_cfg[card].rx_num_channels, + duplex_mode[openair0_cfg[card].duplex_mode]); - if (idl_CarrierFreq; - } - else - openair0_cfg[card].rx_freq[i]=0.0; + nr_get_carrier_frequencies(frame_parms, &dl_carrier, &ul_carrier); - if (iul_CarrierFreq; - } - else - openair0_cfg[card].tx_freq[i]=0.0; + nr_rf_card_config(&openair0_cfg[card], rx_gain_off, ul_carrier, dl_carrier, freq_off); - openair0_cfg[card].autocal[i] = 1; - openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; - openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off; - openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file; - printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", - card,i, openair0_cfg[card].tx_gain[i], - openair0_cfg[card].rx_gain[i], - openair0_cfg[card].tx_freq[i], - openair0_cfg[card].rx_freq[i]); - } + openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file; if (usrp_args) openair0_cfg[card].sdr_addrs = usrp_args; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 845eace8b6..746c7edfa9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1452,6 +1452,31 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, runmode_t mode, int n_frames); +/*! + \brief This function gets the carrier frequencies either from FP or command-line-set global variables, depending on the availability of the latter + @param fp Pointer to frame params + @param dl_Carrier Pointer to DL carrier to be set + @param ul_Carrier Pointer to UL carrier to be set +*/ +void nr_get_carrier_frequencies(NR_DL_FRAME_PARMS *fp, + uint64_t *dl_Carrier, + uint64_t *ul_Carrier); + +/*! + \brief This function sets the OAI RF card rx/tx params + @param openair0_cfg Pointer OAI config for a specific card + @param tx_gain_off Tx gain offset + @param rx_gain_off Rx gain offset + @param ul_Carrier UL carrier to be set + @param dl_Carrier DL carrier to be set + @param freq_offset Freq offset to be set +*/ +void nr_rf_card_config(openair0_config_t *openair0_cfg, + double rx_gain_off, + uint64_t ul_Carrier, + uint64_t dl_Carrier, + int freq_offset); + /*! \brief Encoding of PUSCH/ACK/RI/ACK from 36-212. diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c new file mode 100644 index 0000000000..7cf64b28bb --- /dev/null +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c @@ -0,0 +1,90 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/NR_UE_TRANSPORT/nr_ue_rf_config.c +* \brief Functional helpers to configure the RF boards at UE side +* \author Guido Casati +* \date 2020 +* \version 0.1 +* \company Fraunhofer IIS +* \email: guido.casati@iis.fraunhofer.de +*/ + +#include "PHY/defs_nr_UE.h" +#include "PHY/phy_extern_nr_ue.h" +#include "nr_transport_proto_ue.h" + +void nr_get_carrier_frequencies(NR_DL_FRAME_PARMS *fp, uint64_t *dl_carrier, uint64_t *ul_carrier){ + + if (downlink_frequency[0][0]) + *dl_carrier = downlink_frequency[0][0]; + else + *dl_carrier = fp->dl_CarrierFreq; + + if (uplink_frequency_offset[0][0]) + *ul_carrier = *dl_carrier + uplink_frequency_offset[0][0]; + else + *ul_carrier = *dl_carrier + fp->ul_CarrierFreq - fp->dl_CarrierFreq; + +} + +void nr_rf_card_config(openair0_config_t *openair0_cfg, + double rx_gain_offset, + uint64_t ul_carrier, + uint64_t dl_carrier, + int freq_offset){ + + uint8_t mod_id = 0; + uint8_t cc_id = 0; + PHY_VARS_NR_UE *ue = PHY_vars_UE_g[mod_id][cc_id]; + int rf_chain = ue->rf_map.chain; + double rx_gain = ue->rx_total_gain_dB; + double tx_gain = ue->tx_total_gain_dB; + + for (int i = rf_chain; i < rf_chain + 4; i++) { + + if (i < openair0_cfg->rx_num_channels) + openair0_cfg->rx_freq[i + rf_chain] = dl_carrier + freq_offset; + else + openair0_cfg->rx_freq[i] = 0.0; + + if (itx_num_channels) + openair0_cfg->tx_freq[i] = ul_carrier + freq_offset; + else + openair0_cfg->tx_freq[i] = 0.0; + + if (tx_gain) + openair0_cfg->tx_gain[i] = tx_gain; + if (rx_gain) + openair0_cfg->rx_gain[i] = rx_gain - rx_gain_offset; + + openair0_cfg->autocal[i] = 1; + + LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_gain %f, rx_gain %f, tx_freq %f Hz, rx_freq %f Hz\n", + i, + rf_chain, + openair0_cfg->tx_gain[i], + openair0_cfg->rx_gain[i], + openair0_cfg->tx_freq[i], + openair0_cfg->rx_freq[i]); + + } +} \ No newline at end of file From ae86b727e201a87f2285f41f54162a8f17bf1c47 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 26 Oct 2020 15:21:44 +0100 Subject: [PATCH 078/149] Update the time channel statistics "dl_ch_estimates" in nr_pbch_channel_estimation - it shall be updated at every last PBCH symbol - this fixes stability issues with the FDD mode --- openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index 71a5771f5b..71cd4c44e4 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -445,7 +445,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, assert(0); } - if( symbol == 3) + if( dmrss == 2) // update time statistics for last PBCH symbol { // do ifft of channel estimate for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) From 661dd53186313c247760b06fbec3d115b65e4f9b Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Tue, 27 Oct 2020 13:36:45 -0500 Subject: [PATCH 079/149] Minor changes + UL scheduler code restructure --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 246 +++++++++---------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 5 +- 2 files changed, 123 insertions(+), 128 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 4fd2c6b898..5301982d4d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -670,6 +670,53 @@ uint32_t get_ssb_frame(uint32_t test){ return test; } +/* + * This function returns the slot offset K2 corresponding to a given time domain + * indication value from RRC configuration. + */ +long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { + // Get K2 from RRC configuration + NR_PUSCH_Config_t *pusch_config=mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + if (pusch_config->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = pusch_config->pusch_TimeDomainAllocationList->choice.setup; + } + else if (mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + long k2 = *pusch_TimeDomainAllocationList->list.array[time_domain_ind]->k2; + + LOG_D(MAC, "get_k2(): k2 is %ld\n", k2); + return k2; +} + +/* + * This function returns the UL config corresponding to a given UL slot + * from MAC instance . + */ +fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot) { + //Check if request to access ul_config is for a UL slot + if (is_nr_UL_slot(mac->scc, slot) == 0) { + LOG_W(MAC, "Slot %d is not a UL slot. get_ul_config_request() called for wrong slot!!!\n", slot); + return NULL; + } + + // Calculate the index of the UL slot in mac->ul_config_request list. This is + // based on the TDD pattern (slot configuration period) and number of UL+mixed + // slots in the period. TS 38.213 Sec 11.1 + int mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; + NR_TDD_UL_DL_Pattern_t *tdd_pattern = &mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int num_slots_per_tdd = nr_slots_per_frame[mu] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity); + const int num_slots_ul = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); + int index = slot + num_slots_ul - num_slots_per_tdd; + LOG_D(MAC, "nr_ue_procedures: get_ul_config_request() slots per tdd %d, num_slots_ul %d, index %d\n", + num_slots_per_tdd, + num_slots_ul, + index); + + return &mac->ul_config_request[index]; +} + // Performs : // 1. TODO: Call RRC for link status return to PHY // 2. TODO: Perform SR/BSR procedures for scheduling feedback @@ -795,54 +842,34 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); uint8_t access_mode = SCHEDULED_ACCESS; - fapi_nr_ul_config_request_t *ul_config_req = &mac->ul_config_request[1]; // Temporary workaround due to change in the structure to accommodate multiple UL config requests - - // Schedule ULSCH only if the frame and slot are as indicated in ul_config_req. - // These values were set based on the values of slot in which UL DCI was received and K2. - if (ul_info->frame_tx == ul_config_req->sfn && ul_info->slot_tx == ul_config_req->slot) { + fapi_nr_ul_config_request_t *ul_config_req = get_ul_config_request(mac, slot_tx); + // Schedule ULSCH only if the current frame and slot match those in ul_config_req + // AND if a UL DCI has been received (as indicated by num_pdus). + if ((frame_tx == ul_config_req->sfn && slot_tx == ul_config_req->slot) && + ul_config_req->number_pdus > 0) { + // program PUSCH with UL DCI parameters - nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_body_t tx_req_body; - fapi_nr_ul_config_request_t *ul_config = &dcireq.ul_config_req; nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; - fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &mac->ul_config_request[1].ul_config_list[0]; // Temporary workaround + fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &ul_config_req->ul_config_list[0]; - uint16_t rnti = ulcfg_pdu->pusch_config_pdu.rnti; - uint32_t rb_size = ulcfg_pdu->pusch_config_pdu.rb_size; - uint32_t rb_start = ulcfg_pdu->pusch_config_pdu.rb_start; - uint8_t nr_of_symbols = ulcfg_pdu->pusch_config_pdu.nr_of_symbols; - uint8_t start_symbol_index = ulcfg_pdu->pusch_config_pdu.start_symbol_index; - uint8_t nrOfLayers = 1; - uint8_t mcs_index = ulcfg_pdu->pusch_config_pdu.mcs_index; - uint8_t mcs_table = ulcfg_pdu->pusch_config_pdu.mcs_table; - uint8_t harq_process_id = ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id; - uint8_t rv_index = ulcfg_pdu->pusch_config_pdu.pusch_data.rv_index; - uint16_t l_prime_mask = get_l_prime(nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); - uint8_t dmrs_config_type = 0; - uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; // These should come from RRC config!!! uint8_t ptrs_mcs1 = 2; uint8_t ptrs_mcs2 = 4; uint8_t ptrs_mcs3 = 10; uint16_t n_rb0 = 25; uint16_t n_rb1 = 75; - uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, mcs_index, mcs_table); - uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size); - uint16_t number_dmrs_symbols = 0; - uint16_t ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; + uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); + uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, ulcfg_pdu->pusch_config_pdu.rb_size); + uint16_t l_prime_mask = get_l_prime(ulcfg_pdu->pusch_config_pdu.nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); + uint16_t ul_dmrs_symb_pos = l_prime_mask << ulcfg_pdu->pusch_config_pdu.start_symbol_index; -#ifdef DEBUG_DCI - LOG_I(MAC, " UL config params \n rnti: %x \n rb_size: %d \n", - rnti, rb_size); - LOG_I(MAC, "rb_start: %x \n nr_of_symbols: %d \n start_symbol_index: %d \n nrOfLayers: %d \n mcs_index: %d \n \ - mcs_table: %d \n harq_process_id: %d \n rv_index: %d \n", - rb_start, nr_of_symbols, start_symbol_index, nrOfLayers, mcs_index, - mcs_table, harq_process_id, rv_index); -#endif + uint8_t dmrs_config_type = 0; + uint16_t number_dmrs_symbols = 0; // PTRS ports configuration // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised! @@ -854,48 +881,36 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in else N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; - ul_config->slot = ul_info->slot_tx; - ul_config->number_pdus = 1; - ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; - ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; - ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; - ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; - ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; - ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; - ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; - ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; - ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; - ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; - ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; - ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; - ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(mcs_index, mcs_table); - ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(mcs_index, mcs_table); + ulcfg_pdu->pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; + ulcfg_pdu->pusch_config_pdu.dmrs_config_type = dmrs_config_type; + ulcfg_pdu->pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; + ulcfg_pdu->pusch_config_pdu.nrOfLayers = 1; + ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator = 0; + ulcfg_pdu->pusch_config_pdu.pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; + ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; + ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; + ulcfg_pdu->pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); + ulcfg_pdu->pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); - if (1 << ptrs_time_density >= nr_of_symbols) { - ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS + if (1 << ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_time_density >= ulcfg_pdu->pusch_config_pdu.nr_of_symbols) { + ulcfg_pdu->pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS } - get_num_re_dmrs(&ul_config->ul_config_list[0].pusch_config_pdu, + get_num_re_dmrs(&ulcfg_pdu->pusch_config_pdu, &nb_dmrs_re_per_rb, &number_dmrs_symbols); - TBS = nr_compute_tbs(ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order, - ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate, - rb_size, - nr_of_symbols, - nb_dmrs_re_per_rb*number_dmrs_symbols, - N_PRB_oh, - 0, - nrOfLayers); + TBS = nr_compute_tbs(ulcfg_pdu->pusch_config_pdu.qam_mod_order, + ulcfg_pdu->pusch_config_pdu.target_code_rate, + ulcfg_pdu->pusch_config_pdu.rb_size, + ulcfg_pdu->pusch_config_pdu.nr_of_symbols, + nb_dmrs_re_per_rb*number_dmrs_symbols, + N_PRB_oh, + 0, + ulcfg_pdu->pusch_config_pdu.nrOfLayers); TBS_bytes = TBS/8; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS_bytes; + ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size = TBS_bytes; if (IS_SOFTMODEM_NOS1){ // Getting IP traffic to be transmitted @@ -937,12 +952,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in #endif - dcireq.module_id = mod_id; - dcireq.gNB_index = gNB_index; - dcireq.cc_id = cc_id; - dcireq.frame = rx_frame; - dcireq.slot = rx_slot; - // Config UL TX PDU tx_req.slot = slot_tx; tx_req.sfn = frame_tx; @@ -953,7 +962,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in tx_req_body.pdu = ulsch_input_buffer; tx_req.tx_request_body = &tx_req_body; - fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, rx_frame, rx_slot); + fill_scheduled_response(&scheduled_response, NULL, ul_config_req, &tx_req, mod_id, cc_id, rx_frame, rx_slot); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ mac->if_module->scheduled_response(&scheduled_response); } @@ -975,7 +984,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_body_t tx_req_body; - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[1]; // Temporary workaround + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, ul_info->slot_tx); fapi_nr_ul_config_request_pdu_t *ul_config_list = &ul_config->ul_config_list[ul_config->number_pdus]; uint16_t TBS_bytes = ul_config_list->pusch_config_pdu.pusch_data.tb_size; @@ -1087,7 +1096,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[1]; // Temporary workaround + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); fapi_nr_ul_config_prach_pdu *prach_config_pdu; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_prach_config_t *prach_config = &cfg->prach_config; @@ -2450,41 +2459,12 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in return (nr_ue_process_dci(module_id, cc_id, gNB_index, frame, slot, def_dci_pdu_rel15, dci->rnti, dci_format)); } -long get_ul_config_request(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, uint8_t time_domain_ind, fapi_nr_ul_config_request_t **ul_config) { - // Get offset K2 from RRC configuration - NR_PUSCH_Config_t *pusch_config=mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - if (pusch_config->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = pusch_config->pusch_TimeDomainAllocationList->choice.setup; - } - else if (mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - long k2 = *pusch_TimeDomainAllocationList->list.array[time_domain_ind]->k2; - - // Calculate the index of the UL slot in mac->ul_config_request list. This is - // based on the TDD pattern (slot configuration period) and number of UL+mixed - // slots in the period. TS 38.213 Sec 11.1 - NR_TDD_UL_DL_Pattern_t *tdd_pattern = &mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1; - const int num_slots_per_tdd = nr_slots_per_frame[*mac->scc->ssbSubcarrierSpacing] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity); - const int num_slots_ul = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); - int index = slot + k2 + num_slots_ul - num_slots_per_tdd; - LOG_D(MAC, "nr_ue_procedures: get_ul_config() k2 %ld, slots per tdd %d, num_slots_ul %d, index %d\n", - k2, - num_slots_per_tdd, - num_slots_ul, - index); - - *ul_config = &mac->ul_config_request[index]; - - return k2; -} - int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, frame_t frame, int slot, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){ int bwp_id = 1; int mu = 0; long k2 = 0; + uint16_t frame_tx = 0, slot_tx = 0; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; @@ -2518,8 +2498,20 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space * 50 SUL_IND_0_0: */ - // Get the UL config request for the slot in which PUSCH will be scheduled - k2 = get_ul_config_request(mac, frame, slot, dci->frequency_hopping_flag.val, &ul_config); + // Calculate the slot in which ULSCH should be scheduled. This is current slot + K2, + // where K2 is the offset between the slot in which UL DCI is received and the slot + // in which ULSCH should be scheduled. K2 is configured in RRC configuration. + + // Get the numerology to calculate the Tx frame and slot + mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; + // Get slot offset K2 which will be used to calculate TX slot + k2 = get_k2(mac, dci->frequency_hopping_flag.val); + // Calculate TX slot and frame + slot_tx = (slot + k2) % nr_slots_per_frame[mu]; + frame_tx = ((slot + k2) > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; + + // Get UL config request corresponding slot_tx + ul_config = get_ul_config_request(mac, slot_tx); AssertFatal(ul_config != NULL, "nr_ue_process_dci(): ul_config is NULL\n"); ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; @@ -2560,14 +2552,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } /* SUL_IND_0_0 */ // To be implemented, FIXME!!! - // Get the numerology to calculate the Tx frame and slot - mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; - - // Calculate the slot and frame for PUSCH transmission - ul_config->slot = (slot + k2) % nr_slots_per_frame[mu]; - ul_config->sfn = ((slot + k2) % nr_slots_per_frame[mu] > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; - LOG_D(MAC, "nr_ue_process_dci(): Calculated frame and slot for pusch Tx: %d.%d, number of pdus %d\n", ul_config->sfn, ul_config->slot, ul_config->number_pdus); + ul_config->slot = slot_tx; + ul_config->sfn = frame_tx; ul_config->number_pdus = ul_config->number_pdus + 1; + LOG_D(MAC, "nr_ue_process_dci(): Calculated frame and slot for pusch Tx: %d.%d, number of pdus %d\n", ul_config->sfn, ul_config->slot, ul_config->number_pdus); break; case NR_UL_DCI_FORMAT_0_1: @@ -2599,8 +2587,20 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr * 48 UL_SCH_IND * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space */ - // Get the UL config request for the slot in which PUSCH will be scheduled - k2 = get_ul_config_request(mac, frame, slot, dci->frequency_hopping_flag.val, &ul_config); + // Calculate the slot in which ULSCH should be scheduled. This is current slot + K2, + // where K2 is the offset between the slot in which UL DCI is received and the slot + // in which ULSCH should be scheduled. K2 is configured in RRC configuration. + + // Get the numerology to calculate the Tx frame and slot + mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; + // Get slot offset K2 which will be used to calculate TX slot + k2 = get_k2(mac, dci->frequency_hopping_flag.val); + // Calculate TX slot and frame + slot_tx = (slot + k2) % nr_slots_per_frame[mu]; + frame_tx = ((slot + k2) > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; + + // Get UL config request corresponding slot_tx + ul_config = get_ul_config_request(mac, slot_tx); AssertFatal(ul_config != NULL, "nr_ue_process_dci(): ul_config is NULL\n"); ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; @@ -2897,14 +2897,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // A value of "1" indicates UL-SCH shall be transmitted on the PUSCH and // a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH - // Get the numerology to calculate the Tx frame and slot - int mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; - - // Calculate the slot and frame for PUSCH transmission - ul_config->slot = (slot + k2) % nr_slots_per_frame[mu]; - ul_config->sfn = ((slot + k2) % nr_slots_per_frame[mu] > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; - LOG_I(MAC, "nr_ue_process_dci(): Calculated frame and slot for pusch Tx: %d.%d\n", ul_config->sfn, ul_config->slot); + ul_config->slot = slot_tx; + ul_config->sfn = frame_tx; ul_config->number_pdus = ul_config->number_pdus + 1; + LOG_D(MAC, "nr_ue_process_dci(): Calculated frame and slot for pusch Tx: %d.%d, number of pdus %d\n", ul_config->sfn, ul_config->slot, ul_config->number_pdus); break; case NR_DL_DCI_FORMAT_1_0: diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 55b30484c6..d680e454e8 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -135,8 +135,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ module_id_t module_id = dl_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[1]; // Temporary workaround - + if (!dl_info->dci_ind && !dl_info->rx_ind) { // UL indication to schedule DCI reception nr_ue_scheduler(dl_info, NULL); @@ -158,7 +157,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ if (ret >= 0) { AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n" ); AssertFatal( nr_ue_if_module_inst[module_id]->scheduled_response != NULL, "scheduled_response is NULL!\n" ); - fill_scheduled_response(&scheduled_response, dl_config, ul_config, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot); + fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot); nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response); } } From 36bbd2a068f9e5d41bd173ce706ea994b378073e Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Tue, 27 Oct 2020 21:07:13 +0100 Subject: [PATCH 080/149] adapting config file for band 261 --- .../CONF/gnb.band261.tm1.32PRB.usrpn300.conf | 58 ++++++++++++++----- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf index e171b2faa9..82b941ea0e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf @@ -13,7 +13,7 @@ gNBs = gNB_name = "gNB-Eurecom-5GNRBox"; // Tracking area code, 0x0000 and 0xfffe are reserved values - tracking_area_code = 600; + tracking_area_code = 1; plmn_list = ({mcc = 311; mnc = 480; mnc_length = 3;}); @@ -23,6 +23,8 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; + pusch_TargetSNRx10 = 200; + pucch_TargetSNRx10 = 200; servingCellConfigCommon = ( { @@ -71,6 +73,11 @@ gNBs = initialDLBWPmappingType_2 = 0; #this is SS=1,L=12 initialDLBWPstartSymbolAndLength_2 = 54; + + initialDLBWPk0_3 = 0; + initialDLBWPmappingType_3 = 0; + #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) + initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 261; @@ -89,7 +96,7 @@ gNBs = initialULBWPsubcarrierSpacing = 3; #rach-ConfigCommon #rach-ConfigGeneric - prach_ConfigurationIndex = 98; + prach_ConfigurationIndex = 52; #prach_msg1_FDM #0 = one, 1=two, 2=four, 3=eight prach_msg1_FDM = 0; @@ -103,12 +110,12 @@ gNBs = powerRampingStep = 1; #ra_ReponseWindow #1,2,4,8,10,20,40,80 - ra_ResponseWindow = 4; + ra_ResponseWindow = 7; #ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR #0=oneeighth,1=onefourth,2=half,3=one,4=two,5=four,6=eight,7=sixteen - ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; #oneHalf (0..15) 4,8,12,16,...60,64 - ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 7; #ra_ContentionResolutionTimer #(0..7) 8,16,24,32,40,48,56,64 ra_ContentionResolutionTimer = 7; @@ -119,7 +126,7 @@ gNBs = prach_RootSequenceIndex = 1; # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex # - msg1_SubcarrierSpacing = 1, + msg1_SubcarrierSpacing = 3, # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B @@ -135,6 +142,10 @@ gNBs = # this is SS=0 L=12 initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPk2_2 = 7; + initialULBWPmappingType_2 = 1; + # this is SS=10 L=4 + initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -148,7 +159,7 @@ gNBs = # ssb_PositionsInBurs_BitmapPR # 1=short, 2=medium, 3=long ssb_PositionsInBurst_PR = 3; - ssb_PositionsInBurst_Bitmap = 0x100000001L; + ssb_PositionsInBurst_Bitmap = 0x0001000100010001L; # ssb_periodicityServingCell # 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 @@ -170,11 +181,11 @@ gNBs = # pattern1 # dl_UL_TransmissionPeriodicity # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 - dl_UL_TransmissionPeriodicity = 5; - nrofDownlinkSlots = 10; - nrofDownlinkSymbols = 0; - nrofUplinkSlots = 10; - nrofUplinkSymbols = 0; + dl_UL_TransmissionPeriodicity = 3; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; ssPBCH_BlockPower = 10; } @@ -192,21 +203,36 @@ gNBs = ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.12.26"; + mme_ip_address = ( { ipv4 = "192.168.18.99"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; } ); + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + target_enb_x2_ip_address = ( + { ipv4 = "192.168.18.199"; + ipv6 = "192:168:30::17"; + preference = "ipv4"; + } + ); + NETWORK_INTERFACES : { GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.18.198/24"; GNB_INTERFACE_NAME_FOR_S1U = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.18.198/24"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 + GNB_IPV4_ADDRESS_FOR_X2C = "192.168.18.198/24"; + GNB_PORT_FOR_X2C = 36422; # Spec 36422 }; } ); @@ -239,6 +265,8 @@ RUs = ( eNB_instances = [0]; sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2"; if_freq = 5124520000L; + clock_src = "external"; + time_src = "external"; } ); From 41f4ed9eaf7e680376c3e9c33d2491918941702a Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 28 Oct 2020 09:53:38 +0100 Subject: [PATCH 081/149] synchronize gnb.band78.tm1.106PRB.usrpn300.conf file in ci-scripts and target directory --- .../gnb.band78.tm1.106PRB.usrpn300.conf | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index aa03e91fd0..60acb20ecb 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -46,7 +46,7 @@ gNBs = #initialDownlinkBWP #genericParameters # this is RBstart=0,L=50 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 13475; + initialDLBWPlocationAndBandwidth = 6366; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; @@ -59,7 +59,7 @@ gNBs = #initialULBWPmappingType #0=typeA,1=typeB initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 + #this is SS=1,L=13 initialDLBWPstartSymbolAndLength_0 = 40; initialDLBWPk0_1 = 0; @@ -89,7 +89,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 13475; + initialULBWPlocationAndBandwidth = 6366; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -126,10 +126,10 @@ gNBs = # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex # msg1_SubcarrierSpacing = 1, - # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, + # pusch-ConfigCommon (up to 16 elements) initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 @@ -141,11 +141,12 @@ gNBs = # this is SS=0 L=12 initialULBWPstartSymbolAndLength_1 = 69; - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; initialULBWPmappingType_2 = 1; # this is SS=10 L=4 initialULBWPstartSymbolAndLength_2 = 52; - + + msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -249,7 +250,7 @@ RUs = ( eNB_instances = [0]; #beamforming 1x4 matrix: bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; - sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2"; + sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2,second_addr=192.168.20.2"; clock_src = "external"; } ); From f4f9d3b4d72d563713e48462ca954431b1b1ec87 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 28 Oct 2020 11:06:35 +0100 Subject: [PATCH 082/149] hardcoding ra_rnti in case of long prach for benetel --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 4c17ee3a0f..442149062a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -248,8 +248,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, uint8_t ul_carrier_id = 0; // 0 for NUL 1 for SUL NR_SearchSpace_t *ss; int UE_id = 0; - // ra_rnti from 5.1.3 in 38.321 - uint16_t ra_rnti=1+symbol+(slotP*14)+(freq_index*14*80)+(ul_carrier_id*14*80*8); uint16_t msg2_frame, msg2_slot,monitoring_slot_period,monitoring_offset; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; @@ -259,6 +257,16 @@ void nr_initiate_ra_proc(module_id_t module_idP, NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_RA_t *ra = &cc->ra[0]; + uint16_t ra_rnti; + + // ra_rnti from 5.1.3 in 38.321 + // FK: in case of long PRACH the phone seems to expect the subframe number instead of the slot number here. + if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present==NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839) + ra_rnti=1+symbol+(9/*slotP*/*14)+(freq_index*14*80)+(ul_carrier_id*14*80*8); + else + ra_rnti=1+symbol+(slotP*14)+(freq_index*14*80)+(ul_carrier_id*14*80*8); + + // if the preamble received correspond to one of the listed // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries int pr_found=0; From 144e267541e95e0bbe039a627f3055c8e474da1a Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 28 Oct 2020 11:08:26 +0100 Subject: [PATCH 083/149] fixing PRACH bug in benetel_5g driver --- targets/ARCH/ETHERNET/benetel/5g/benetel.c | 1 + .../ARCH/ETHERNET/benetel/5g/dpdk_driver.c | 22 +++++------ targets/ARCH/ETHERNET/benetel/5g/low.c | 37 ++++++++++++++++++- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/targets/ARCH/ETHERNET/benetel/5g/benetel.c b/targets/ARCH/ETHERNET/benetel/5g/benetel.c index c1ae1afcc7..2b8e0dfbfb 100644 --- a/targets/ARCH/ETHERNET/benetel/5g/benetel.c +++ b/targets/ARCH/ETHERNET/benetel/5g/benetel.c @@ -275,6 +275,7 @@ void benetel_fh_if4p5_south_out(RU_t *ru, int slot, uint64_t timestamp) { + //printf("XXX benetel_fh_if4p5_south_out %d %d %ld\n", frame, slot, timestamp); benetel_eth_state_t *s = ru->ifdevice.priv; NR_DL_FRAME_PARMS *fp; diff --git a/targets/ARCH/ETHERNET/benetel/5g/dpdk_driver.c b/targets/ARCH/ETHERNET/benetel/5g/dpdk_driver.c index b90702d331..dd50603ec5 100644 --- a/targets/ARCH/ETHERNET/benetel/5g/dpdk_driver.c +++ b/targets/ARCH/ETHERNET/benetel/5g/dpdk_driver.c @@ -86,10 +86,9 @@ static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; static struct rte_eth_conf port_conf = { .rxmode = { .split_hdr_size = 0, - .offloads = DEV_RX_OFFLOAD_CRC_STRIP, - .offloads = DEV_RX_OFFLOAD_JUMBO_FRAME, - .split_hdr_size = 0, - .max_rx_pkt_len = 9500, + .offloads = DEV_RX_OFFLOAD_JUMBO_FRAME, + .split_hdr_size = 0, + .max_rx_pkt_len = 9500, }, .txmode = { .mq_mode = ETH_MQ_TX_NONE, @@ -234,7 +233,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) } // Trigger start send DL packets - if(PAYLOAD_1 == 0x13 && PAYLOAD_2 == 0xe4 && SYMBOL == 0x46 && ANT_NUM == 0x00 && SUBFRAME == 0x00 && dl_start == 0){ + if(PAYLOAD_1 == 0x13 && PAYLOAD_2 == 0xe4 && SYMBOL == 0x44 && ANT_NUM == 0x00 && SUBFRAME == 0x00 && dl_start == 0){ printf("\nU-Plane Started\n"); printf("\n====================================================\n"); @@ -253,7 +252,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) p.antenna = 0; memcpy(p.iq, IQ_ptr, 5088); store_ul(bs, &p); - //if (p.symbol==0) printf("store ul f.sl.sy %d.%d.%d\n", p.frame, p.slot, p.symbol); + // if (p.symbol==0) printf("store ul f.sl.sy %d.%d.%d\n", p.frame, p.slot, p.symbol); } // U-PLANE UL ANT_0 PROCESSING @@ -268,7 +267,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) int tx_frame = frame; int tx_subframe = subframe; int tx_slot = slot; - int tx_symbol = symbol + 8; + int tx_symbol = symbol + 10; if (tx_symbol > 13) { tx_symbol -= 14; @@ -286,7 +285,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) ANT_NUM = 0x00; // Mask the symbol bits from UL packet received and apply the shift. - SYMBOL = ((SYMBOL & 0b00111111) + 8) % 14; + SYMBOL = ((SYMBOL & 0b00111111) + 10) % 14; ANT_NUM = 0x00; SUBFRAME = sf; @@ -307,6 +306,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) memcpy(IQ_ptr, bs->buffers->dl[oai_slot] + tx_symbol * 1272*4, 1272*4); } +//printf("DL buffer f sf slot symbol %d %d %d %d (sf %d)\n", tx_frame, tx_subframe, tx_slot, tx_symbol, (int)sf); bs->buffers->dl_busy[oai_slot] &= ~(1 << tx_symbol); unlock_dl_buffer(bs->buffers, oai_slot); @@ -319,7 +319,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) { // Mask the symbol bits from UL packet received and apply the shift. - SYMBOL = ((SYMBOL & 0b00111111) + 8) % 14; + SYMBOL = ((SYMBOL & 0b00111111) +10) % 14; ANT_NUM = 0x01; SUBFRAME = sf; @@ -348,10 +348,10 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) else if(PAYLOAD_1 == 0x0d && PAYLOAD_2 == 0x28){ if (ANT_NUM == 0) { int subframe = SUBFRAME >> 4; - int slot = ((SUBFRAME & 0x0f) << 2) | ((SYMBOL >> 6) & 0x03); + //int slot = ((SUBFRAME & 0x0f) << 2) | ((SYMBOL >> 6) & 0x03); if (subframe==9) { //printf("store prach f.sf.sl %d.%d.%d %d\n", FRAME, subframe, slot, subframe * 2 + slot); - store_prach(bs, FRAME, slot /*subframe * 2 + slot*/, IQ_ptr); + store_prach(bs, FRAME, subframe * 2 + 1, IQ_ptr); } } rte_pktmbuf_free(m); diff --git a/targets/ARCH/ETHERNET/benetel/5g/low.c b/targets/ARCH/ETHERNET/benetel/5g/low.c index 984e401421..52c9f24127 100644 --- a/targets/ARCH/ETHERNET/benetel/5g/low.c +++ b/targets/ARCH/ETHERNET/benetel/5g/low.c @@ -27,17 +27,50 @@ void store_ul(benetel_t *bs, ul_packet_t *ul) { +#if 0 +struct timespec t; +static struct timespec old; +clock_gettime(CLOCK_REALTIME, &t); +printf("store_ul %d.%ld (%ld)\n", (int)(t.tv_sec % 60), t.tv_nsec, t.tv_nsec - old.tv_nsec); +old = t; +#endif + /* only antenna 0 for the moment */ if (ul->antenna != 0) return; if (ul->slot != bs->next_slot || ul->symbol != bs->next_symbol) { - printf("%s: fatal, expected frame.sl.symbol %d.%d.%d, got %d.%d.%d\n", + printf("%s: error, expected frame.sl.symbol %d.%d.%d, got %d.%d.%d\n", __FUNCTION__, bs->expected_benetel_frame, bs->next_slot, bs->next_symbol, ul->frame, ul->slot, ul->symbol); - exit(1); + } + + /* fill missing data with 0s */ + while (ul->slot != bs->next_slot || + ul->symbol != bs->next_symbol) { + lock_ul_buffer(bs->buffers, bs->next_slot); + if (bs->buffers->ul_busy[bs->next_slot] & (1 << bs->next_symbol)) { + printf("%s: warning, UL overflow (sl.symbol %d.%d)\n", __FUNCTION__, + bs->next_slot, bs->next_symbol); + } + + memset(bs->buffers->ul[bs->next_slot] + bs->next_symbol * 1272*4, + 0, 1272*4); + bs->buffers->ul_busy[bs->next_slot] |= (1 << bs->next_symbol); + signal_ul_buffer(bs->buffers, bs->next_slot); + unlock_ul_buffer(bs->buffers, bs->next_slot); + + bs->next_symbol++; + if (bs->next_symbol == 14) { + bs->next_symbol = 0; + bs->next_slot = (bs->next_slot + 1) % 20; + if (bs->next_slot == 0) { + bs->expected_benetel_frame++; + bs->expected_benetel_frame &= 255; + } + } } lock_ul_buffer(bs->buffers, bs->next_slot); From 638b5de1d246e6915452fc7ff1e9c9b2911e3d07 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 28 Oct 2020 11:28:00 +0100 Subject: [PATCH 084/149] updating config file for gNB --- targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf index 27fc90e5e3..b79dc52cff 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf @@ -203,7 +203,7 @@ gNBs = ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.61.195"; + mme_ip_address = ( { ipv4 = "192.168.18.99"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; @@ -225,9 +225,9 @@ gNBs = { GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.160.146/24"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.18.195/24"; GNB_INTERFACE_NAME_FOR_S1U = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1U = "192.168.160.146/24"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.18.195/24"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 GNB_IPV4_ADDRESS_FOR_X2C = "127.0.0.2/24"; GNB_PORT_FOR_X2C = 36422; # Spec 36422 @@ -265,7 +265,7 @@ RUs = ( clock_src = "external"; local_if_name = "dpdk"; - sdr_addrs = "softmodem -m 2048 -l 6 -n 3 -b 0000:3b:00.1 --proc-type auto --file-prefix hhh -- -p 0x1"; + sdr_addrs = "softmodem -m 2048 -l 34 -n 3 -b 0000:81:00.2 --proc-type auto --file-prefix hhh -- -p 0x1"; remote_address = "127.0.0.2"; local_address = "127.0.0.1"; local_portc = 50000; From a129f121cc2b1cede784393b09100d4a57758217 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 28 Oct 2020 13:07:41 +0100 Subject: [PATCH 085/149] dpdk changes for 18.11 --- targets/ARCH/ETHERNET/benetel/4g/dpdk_driver.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/targets/ARCH/ETHERNET/benetel/4g/dpdk_driver.c b/targets/ARCH/ETHERNET/benetel/4g/dpdk_driver.c index 9b64f01d44..42953d1d4a 100644 --- a/targets/ARCH/ETHERNET/benetel/4g/dpdk_driver.c +++ b/targets/ARCH/ETHERNET/benetel/4g/dpdk_driver.c @@ -86,10 +86,9 @@ static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; static struct rte_eth_conf port_conf = { .rxmode = { .split_hdr_size = 0, - .offloads = DEV_RX_OFFLOAD_CRC_STRIP, - .offloads = DEV_RX_OFFLOAD_JUMBO_FRAME, - .split_hdr_size = 0, - .max_rx_pkt_len = 9500, + .offloads = DEV_RX_OFFLOAD_JUMBO_FRAME, + .split_hdr_size = 0, + .max_rx_pkt_len = 9500, }, .txmode = { .mq_mode = ETH_MQ_TX_NONE, From ba6edde8255e4bc78f366f30fe65d422a504c213 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 28 Oct 2020 13:08:05 +0100 Subject: [PATCH 086/149] updating 4g config file --- targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-4g.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-4g.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-4g.conf index 716bfd3b6b..8e7b0f64b2 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-4g.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-4g.conf @@ -174,14 +174,14 @@ eNBs = ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.61.195"; + mme_ip_address = ( { ipv4 = "192.168.18.99"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; } ); - enable_measurement_reports = "no"; + enable_measurement_reports = "yes"; ///X2 enable_x2 = "yes"; @@ -191,9 +191,9 @@ eNBs = NETWORK_INTERFACES : { ENB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.160.46"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.18.196"; ENB_INTERFACE_NAME_FOR_S1U = "eth0"; - ENB_IPV4_ADDRESS_FOR_S1U = "192.168.160.46"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.18.196"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 ENB_IPV4_ADDRESS_FOR_X2C = "127.0.0.1"; ENB_PORT_FOR_X2C = 36422; # Spec 36422 @@ -224,7 +224,7 @@ RUs = ( { //local_if_name = "enp129s0f0"; local_if_name = "dpdk"; - sdr_addrs = "softmodem -m 2048 -l 8 -n 2 -b 0000:3b:00.0 --proc-type auto --file-prefix ggg -- -p 0x1"; + sdr_addrs = "softmodem -m 2048 -l 35 -n 2 -b 0000:81:00.3 --proc-type auto --file-prefix ggg -- -p 0x1"; #sdr_addrs = "softmodem -l 8 -n 2 -- -p 0x2"; remote_address = "127.0.0.2"; local_address = "127.0.0.1"; From eaf43790a09be699de861204f50a7af721926a89 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 28 Oct 2020 13:52:01 +0100 Subject: [PATCH 087/149] synchronize gnb.band78.tm1.106PRB.usrpx300.conf for USRP X300 with main version for URSP N310 --- .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 0b04dc82d1..d38fff4241 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -46,7 +46,7 @@ gNBs = #initialDownlinkBWP #genericParameters # this is RBstart=0,L=50 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 13475; + initialDLBWPlocationAndBandwidth = 6366; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; @@ -74,8 +74,9 @@ gNBs = initialDLBWPk0_3 = 0; initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 + #this is SS=1,L=4 initialDLBWPstartSymbolAndLength_3 = 57; + #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -88,7 +89,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 13475; + initialULBWPlocationAndBandwidth = 6366; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -125,21 +126,26 @@ gNBs = # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex # msg1_SubcarrierSpacing = 1, - # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, + # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 # this is SS=0 L=11 initialULBWPstartSymbolAndLength_0 = 55; - initialULBWPk2_1 = 2; + initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; # this is SS=0 L=12 initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPk2_2 = 7; + initialULBWPmappingType_2 = 1; + # this is SS=10 L=4 + initialULBWPstartSymbolAndLength_2 = 52; + msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -242,6 +248,8 @@ RUs = ( max_pdschReferenceSignalPower = -27; max_rxgain = 114; eNB_instances = [0]; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; sdr_addrs = "type=x300"; clock_src = "external"; } From 8ba0d28ace051a4e63fad4d8ff98511bbabe0548 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 28 Oct 2020 13:58:38 +0100 Subject: [PATCH 088/149] hardcoding measurement frequency to 3.6GHz. --- openair2/RRC/LTE/rrc_eNB.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 31a26d322d..9629b4399c 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -3281,7 +3281,7 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t MeasObj2->measObjectId = 2; MeasObj2->measObject.present = LTE_MeasObjectToAddMod__measObject_PR_measObjectNR_r15; - MeasObj2->measObject.choice.measObjectNR_r15.carrierFreq_r15 =641272; //634000; //(634000 = 3.51GHz) (640000 = 3.6GHz) (641272 = 3619.08MHz = 3600 + 30/1000*106*12/2) (642256 is for 3.6GHz and absoluteFrequencySSB = 642016) + MeasObj2->measObject.choice.measObjectNR_r15.carrierFreq_r15 =640000; //634000; //(634000 = 3.51GHz) (640000 = 3.6GHz) (641272 = 3619.08MHz = 3600 + 30/1000*106*12/2) (642256 is for 3.6GHz and absoluteFrequencySSB = 642016) MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.periodicityAndOffset_r15.present = LTE_MTC_SSB_NR_r15__periodicityAndOffset_r15_PR_sf20_r15; MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.periodicityAndOffset_r15.choice.sf20_r15 = 0; MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.ssb_Duration_r15 = LTE_MTC_SSB_NR_r15__ssb_Duration_r15_sf4; From 77b152ade597cbe72bd111e53398460567e6537f Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 28 Oct 2020 16:39:47 +0100 Subject: [PATCH 089/149] adding config file for band 13 --- .../CONF/testing_eNB_band13.conf | 285 ++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_eNB_band13.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_eNB_band13.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_eNB_band13.conf new file mode 100644 index 0000000000..1e32905733 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_eNB_band13.conf @@ -0,0 +1,285 @@ +Active_eNBs = ( "eNB-Eurecom-LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + # real_time choice in {hard, rt-preempt, no} + real_time = "no"; + ////////// Identification parameters: + eNB_ID = 0xe01; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB-Eurecom-LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ( + { mcc = 311; mnc = 480; mnc_length = 3; } + ); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + nb_antenna_ports = 1; + ue_TransmissionMode = 1; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 13; + downlink_frequency = 751000000L; + uplink_frequency_offset = 31000000; + Nid_cell = 0; + N_RB_DL = 25; //100; + Nid_cell_mbsfn = 0; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + prach_root = 0; + tx_gain = 90; + rx_gain = 115; + pbch_repetition = "FALSE"; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 0; + pucch_nCS_AN = 0; + pucch_n1_AN = 0; + pdsch_referenceSignalPower = -26; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -96; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; +/* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; +*/ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + + //Parameters for SIB18 + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf40"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 20; + rxPool_ResourceConfig_prb_Start = 5; + rxPool_ResourceConfig_prb_End = 44; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 0; + rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; +/* rxPool_dataHoppingConfig_hoppingParameter = 0; + rxPool_dataHoppingConfig_numSubbands = "ns1"; + rxPool_dataHoppingConfig_rbOffset = 0; + rxPool_commTxResourceUC-ReqAllowed = "TRUE"; +*/ + // Parameters for SIB19 + discRxPool_cp_Len = "normal" + discRxPool_discPeriod = "rf32" + discRxPool_numRetx = 1; + discRxPool_numRepetition = 2; + discRxPool_ResourceConfig_prb_Num = 5; + discRxPool_ResourceConfig_prb_Start = 3; + discRxPool_ResourceConfig_prb_End = 21; + discRxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + discRxPool_ResourceConfig_offsetIndicator_choice = 0; + discRxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "f0ffffffff"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + + //SSB central frequency of NR secondary cell group (for ENDC NSA) + nr_scg_ssb_freq = 2071241; + + } + ); + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + enable_measurement_reports = "yes"; + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.18.99"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "eth1"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.18.199/24"; + + ENB_INTERFACE_NAME_FOR_S1U = "eth1"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.18.199/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + + ENB_IPV4_ADDRESS_FOR_X2C = "192.168.18.199/24"; + ENB_PORT_FOR_X2C = 36422; # Spec 36422 + }; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="high"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="debug"; + rlc_log_verbosity ="high"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="high"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + phy_test_mode = 0; + puSch10xSnr = 160; + puCch10xSnr = 160; + } +); + +THREAD_STRUCT = ( + { + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + worker_config = "ENABLE"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -26; + max_rxgain = 130; + eNB_instances = [0]; + clock_src = "external"; + } +); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="high"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="high"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="high"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; From c0d123b9f7579797b0ec5d62c0c92828cb1c8933 Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Wed, 28 Oct 2020 20:54:18 -0500 Subject: [PATCH 090/149] Support for multiple PDUs in a UL slot --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 3 +- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 4 +- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 8 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 203 +++++++++--------- openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c | 2 +- 5 files changed, 112 insertions(+), 108 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 10058c441e..ee11d8a42b 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -23,6 +23,7 @@ #include "PHY/impl_defs_nr.h" #define NFAPI_UE_MAX_NUM_CB 8 +#define NFAPI_MAX_NUM_UL_PDU 8 /* typedef unsigned int uint32_t; @@ -155,7 +156,7 @@ typedef struct { uint16_t slot; fapi_nr_tx_config_t tx_config; uint16_t number_of_pdus; - fapi_nr_tx_request_body_t *tx_request_body; + fapi_nr_tx_request_body_t tx_request_body[NFAPI_MAX_NUM_UL_PDU]; } fapi_nr_tx_request_t; /// This struct replaces: diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 2df917d676..de7c4535f0 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -154,8 +154,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ ulsch0->f_pusch = pusch_config_pdu->absolute_delta_PUSCH; - if (scheduled_response->tx_request){ // TBR todo here it should loop through the number of tx pdus - fapi_nr_tx_request_body_t *tx_req_body = scheduled_response->tx_request->tx_request_body; + if (scheduled_response->tx_request){ + fapi_nr_tx_request_body_t *tx_req_body = &scheduled_response->tx_request->tx_request_body[i]; memcpy(harq_process_ul_ue->a, tx_req_body->pdu, tx_req_body->pdu_length); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 7bc1d13210..20e73073b9 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -57,10 +57,10 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) if (IS_SOFTMODEM_NOS1){ if (rlc_module_init(0) != 0) { - LOG_I(RLC, "Problem at RLC initiation \n"); - } - pdcp_layer_init(); - nr_DRB_preconfiguration(); + LOG_I(RLC, "Problem at RLC initiation \n"); + } + pdcp_layer_init(); + nr_DRB_preconfiguration(); } // Allocate memory for ul_config_request in the mac instance. This is now a pointer and will diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 5301982d4d..fbf891c7aa 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -852,116 +852,119 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in // program PUSCH with UL DCI parameters nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; - fapi_nr_tx_request_body_t tx_req_body; nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; - fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &ul_config_req->ul_config_list[0]; + for (int j = 0; j < ul_config_req->number_pdus; j++) { + fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &ul_config_req->ul_config_list[j]; - // These should come from RRC config!!! - uint8_t ptrs_mcs1 = 2; - uint8_t ptrs_mcs2 = 4; - uint8_t ptrs_mcs3 = 10; - uint16_t n_rb0 = 25; - uint16_t n_rb1 = 75; - uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); - uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, ulcfg_pdu->pusch_config_pdu.rb_size); - uint16_t l_prime_mask = get_l_prime(ulcfg_pdu->pusch_config_pdu.nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); - uint16_t ul_dmrs_symb_pos = l_prime_mask << ulcfg_pdu->pusch_config_pdu.start_symbol_index; + if (ulcfg_pdu->pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) { - uint8_t dmrs_config_type = 0; - uint16_t number_dmrs_symbols = 0; + // These should come from RRC config!!! + uint8_t ptrs_mcs1 = 2; + uint8_t ptrs_mcs2 = 4; + uint8_t ptrs_mcs3 = 10; + uint16_t n_rb0 = 25; + uint16_t n_rb1 = 75; + uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); + uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, ulcfg_pdu->pusch_config_pdu.rb_size); + uint16_t l_prime_mask = get_l_prime(ulcfg_pdu->pusch_config_pdu.nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); + uint16_t ul_dmrs_symb_pos = l_prime_mask << ulcfg_pdu->pusch_config_pdu.start_symbol_index; - // PTRS ports configuration - // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised! - ptrs_ports_list.ptrs_re_offset = 0; + uint8_t dmrs_config_type = 0; + uint16_t number_dmrs_symbols = 0; - // Num PRB Overhead from PUSCH-ServingCellConfig - if (mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead == NULL) - N_PRB_oh = 0; - else - N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; + // PTRS ports configuration + // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised! + ptrs_ports_list.ptrs_re_offset = 0; - ulcfg_pdu->pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; - ulcfg_pdu->pusch_config_pdu.dmrs_config_type = dmrs_config_type; - ulcfg_pdu->pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; - ulcfg_pdu->pusch_config_pdu.nrOfLayers = 1; - ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator = 0; - ulcfg_pdu->pusch_config_pdu.pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; - ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; - ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; - ulcfg_pdu->pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); - ulcfg_pdu->pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); + // Num PRB Overhead from PUSCH-ServingCellConfig + if (mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead == NULL) + N_PRB_oh = 0; + else + N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; - if (1 << ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_time_density >= ulcfg_pdu->pusch_config_pdu.nr_of_symbols) { - ulcfg_pdu->pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS - } + ulcfg_pdu->pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; + ulcfg_pdu->pusch_config_pdu.dmrs_config_type = dmrs_config_type; + ulcfg_pdu->pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; + ulcfg_pdu->pusch_config_pdu.nrOfLayers = 1; + ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator = 0; + ulcfg_pdu->pusch_config_pdu.pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; + ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; + ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; + ulcfg_pdu->pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); + ulcfg_pdu->pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); - get_num_re_dmrs(&ulcfg_pdu->pusch_config_pdu, - &nb_dmrs_re_per_rb, - &number_dmrs_symbols); + if (1 << ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_time_density >= ulcfg_pdu->pusch_config_pdu.nr_of_symbols) { + ulcfg_pdu->pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS + } - TBS = nr_compute_tbs(ulcfg_pdu->pusch_config_pdu.qam_mod_order, - ulcfg_pdu->pusch_config_pdu.target_code_rate, - ulcfg_pdu->pusch_config_pdu.rb_size, - ulcfg_pdu->pusch_config_pdu.nr_of_symbols, - nb_dmrs_re_per_rb*number_dmrs_symbols, - N_PRB_oh, - 0, - ulcfg_pdu->pusch_config_pdu.nrOfLayers); - TBS_bytes = TBS/8; - ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size = TBS_bytes; + get_num_re_dmrs(&ulcfg_pdu->pusch_config_pdu, + &nb_dmrs_re_per_rb, + &number_dmrs_symbols); - if (IS_SOFTMODEM_NOS1){ - // Getting IP traffic to be transmitted - data_existing = nr_ue_get_sdu(mod_id, - cc_id, - frame_tx, - slot_tx, - 0, - ulsch_input_buffer, - TBS_bytes, - &access_mode); - } + TBS = nr_compute_tbs(ulcfg_pdu->pusch_config_pdu.qam_mod_order, + ulcfg_pdu->pusch_config_pdu.target_code_rate, + ulcfg_pdu->pusch_config_pdu.rb_size, + ulcfg_pdu->pusch_config_pdu.nr_of_symbols, + nb_dmrs_re_per_rb*number_dmrs_symbols, + N_PRB_oh, + 0, + ulcfg_pdu->pusch_config_pdu.nrOfLayers); + TBS_bytes = TBS/8; + ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size = TBS_bytes; - //Random traffic to be transmitted if there is no IP traffic available for this Tx opportunity - if (!IS_SOFTMODEM_NOS1 || !data_existing) { - //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid - //and block this traffic from being forwarded to the upper layers at the gNB - LOG_D(PHY, "Random data to be tranmsitted: \n"); + if (IS_SOFTMODEM_NOS1){ + // Getting IP traffic to be transmitted + data_existing = nr_ue_get_sdu(mod_id, + cc_id, + frame_tx, + slot_tx, + 0, + ulsch_input_buffer, + TBS_bytes, + &access_mode); + } - //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) - //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should - //have a valid LCID (nr_process_mac_pdu function) - ulsch_input_buffer[0] = 0x31; + //Random traffic to be transmitted if there is no IP traffic available for this Tx opportunity + if (!IS_SOFTMODEM_NOS1 || !data_existing) { + //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid + //and block this traffic from being forwarded to the upper layers at the gNB + LOG_D(PHY, "Random data to be tranmsitted: \n"); - for (i = 1; i < TBS_bytes; i++) { - ulsch_input_buffer[i] = (unsigned char) rand(); - //printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); + //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) + //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should + //have a valid LCID (nr_process_mac_pdu function) + ulsch_input_buffer[0] = 0x31; + + for (i = 1; i < TBS_bytes; i++) { + ulsch_input_buffer[i] = (unsigned char) rand(); + //printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); + } + } + + #ifdef DEBUG_MAC_PDU + + LOG_D(PHY, "Is data existing ?: %d \n", data_existing); + LOG_I(PHY, "Printing MAC PDU to be encoded, TBS is: %d \n", TBS_bytes); + for (i = 0; i < TBS_bytes; i++) { + printf("%02x", ulsch_input_buffer[i]); + } + printf("\n"); + + #endif + + // Config UL TX PDU + tx_req.slot = slot_tx; + tx_req.sfn = frame_tx; + // tx_req->tx_config // TbD + tx_req.number_of_pdus++; + tx_req.tx_request_body[j].pdu_length = TBS_bytes; + tx_req.tx_request_body[j].pdu_index = j; + tx_req.tx_request_body[j].pdu = ulsch_input_buffer; } } -#ifdef DEBUG_MAC_PDU - - LOG_D(PHY, "Is data existing ?: %d \n", data_existing); - LOG_I(PHY, "Printing MAC PDU to be encoded, TBS is: %d \n", TBS_bytes); - for (i = 0; i < TBS_bytes; i++) { - printf("%02x", ulsch_input_buffer[i]); - } - printf("\n"); - -#endif - - // Config UL TX PDU - tx_req.slot = slot_tx; - tx_req.sfn = frame_tx; - // tx_req->tx_config // TbD - tx_req.number_of_pdus = 1; - tx_req_body.pdu_length = TBS_bytes; - tx_req_body.pdu_index = 0; - tx_req_body.pdu = ulsch_input_buffer; - tx_req.tx_request_body = &tx_req_body; - fill_scheduled_response(&scheduled_response, NULL, ul_config_req, &tx_req, mod_id, cc_id, rx_frame, rx_slot); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ mac->if_module->scheduled_response(&scheduled_response); @@ -983,8 +986,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES]; nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; - fapi_nr_tx_request_body_t tx_req_body; - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, ul_info->slot_tx); + //fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, ul_info->slot_tx); + fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[0]; fapi_nr_ul_config_request_pdu_t *ul_config_list = &ul_config->ul_config_list[ul_config->number_pdus]; uint16_t TBS_bytes = ul_config_list->pusch_config_pdu.pusch_data.tb_size; @@ -1025,10 +1028,9 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in tx_req.slot = ul_info->slot_tx; tx_req.sfn = ul_info->frame_tx; tx_req.number_of_pdus = 1; - tx_req_body.pdu_length = TBS_bytes; - tx_req_body.pdu_index = 0; - tx_req_body.pdu = ulsch_input_buffer; - tx_req.tx_request_body = &tx_req_body; + tx_req.tx_request_body[0].pdu_length = TBS_bytes; + tx_req.tx_request_body[0].pdu_index = 0; + tx_req.tx_request_body[0].pdu = ulsch_input_buffer; ul_config_list->pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->number_pdus++; // scheduled_response @@ -1096,7 +1098,8 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); + //fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); + fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[0]; fapi_nr_ul_config_prach_pdu *prach_config_pdu; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_prach_config_t *prach_config = &cfg->prach_config; diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c index 06db41df9c..d5f0480f43 100644 --- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c +++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c @@ -77,7 +77,7 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, uint8_t nb_dmrs_re_per_rb; uint16_t number_dmrs_symbols = 0; int N_PRB_oh; - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[0]; nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; From e37fb2ae05eb5a3ff41769347fe17bf71c3d838f Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 29 Oct 2020 10:01:02 +0100 Subject: [PATCH 091/149] Updated doc files with IF / FDD features --- doc/FEATURE_SET.md | 2 ++ doc/RUNMODEM.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/doc/FEATURE_SET.md b/doc/FEATURE_SET.md index 23d32effbb..1f8d8cfccf 100644 --- a/doc/FEATURE_SET.md +++ b/doc/FEATURE_SET.md @@ -254,9 +254,11 @@ The NAS layer is based on **3GPP 24.301** and implements the following functions The following features are valid for the gNB and the 5G-NR UE. * Static TDD, +* FDD * Normal CP * 30 kHz subcarrier spacing * Bandwidths up to 80MHz (217 Physical Resource Blocks) +* Intermediate downlink and uplink frequencies to interface with IF equipment * Single antenna port (single beam) * Slot format: 14 OFDM symbols in UL or DL * Highly efficient 3GPP compliant LDPC encoder and decoder (BG1 and BG2 supported) diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md index 5fb0824565..af4a57041f 100644 --- a/doc/RUNMODEM.md +++ b/doc/RUNMODEM.md @@ -132,6 +132,42 @@ With the RF simulator (on the same machine): `sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --do-ra --rfsim --parallel-config PARALLEL_SINGLE_THREAD` +## IF setup with OAI + +The -C and -CO flags can be used together at UE side to set custom downlink and uplink FR1 intermediate frequencies for the IF equipment. + +In order to run this setup, the following flags are needed at the UE side: + +`-C` + +`--CO` + +and the following parameters must be configured in the RUs section of the gNB configuration file: + +`if_freq` + +`if_offset` + +### Run OAI with custom DL/UL intermediate frequencies + +The following example uses DL frequency 2169.080 MHz and UL frequency offset -400 MHz, with a configuration file for band 66 at gNB side. + +From the `cmake_targets/ran_build/build` folder: + +gNB on machine 1: + +`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf` + +UE on machine 2: + +`sudo ./nr-uesoftmodem -C 2169080000 --CO -400000000` + + + + + + + [oai wiki home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) From a47f31a44afa7fd256c4747abc71dff02d73b0eb Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 29 Oct 2020 10:44:51 +0100 Subject: [PATCH 092/149] Added configuration files for FDD band 66 --- .../CONF/gnb.band66.tm1.106PRB.usrpn300.conf | 284 ++++++++++++++++++ .../CONF/gnb.band66.tm1.106PRB.usrpx300.conf | 284 ++++++++++++++++++ 2 files changed, 568 insertions(+) create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf new file mode 100644 index 0000000000..9e13d493a8 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf @@ -0,0 +1,284 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 2150 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 433096; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=50 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 13475; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; + #initialULBWPmappingType + #0=typeA,1=typeB + initialDLBWPmappingType_0 = 0; + #this is SS=1,L=13 + initialDLBWPstartSymbolAndLength_0 = 40; + + initialDLBWPk0_1 = 0; + initialDLBWPmappingType_1 = 0; + #this is SS=2,L=12 + initialDLBWPstartSymbolAndLength_1 = 53; + + initialDLBWPk0_2 = 0; + initialDLBWPmappingType_2 = 0; + #this is SS=1,L=12 + initialDLBWPstartSymbolAndLength_2 = 54; + + initialDLBWPk0_3 = 0; + initialDLBWPmappingType_3 = 0; + #this is SS=1,L=4 + initialDLBWPstartSymbolAndLength_3 = 57; + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 66; + ul_absoluteFrequencyPointA = 350000; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 13475; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, + +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 6; + initialULBWPmappingType_0 = 1 + # this is SS=0 L=11 + initialULBWPstartSymbolAndLength_0 = 55; + + initialULBWPk2_1 = 6; + initialULBWPmappingType_1 = 1; + # this is SS=0 L=12 + initialULBWPstartSymbolAndLength_1 = 69; + + initialULBWPk2_2 = 7; + initialULBWPmappingType_2 = 1; + # this is SS=10 L=4 + initialULBWPstartSymbolAndLength_2 = 52; + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = 10; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; + sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2,second_addr=192.168.20.2"; + clock_src = "external"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf new file mode 100644 index 0000000000..831f9c7978 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf @@ -0,0 +1,284 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 2150 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 433096; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=50 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 13475; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; + #initialULBWPmappingType + #0=typeA,1=typeB + initialDLBWPmappingType_0 = 0; + #this is SS=1,L=13 + initialDLBWPstartSymbolAndLength_0 = 40; + + initialDLBWPk0_1 = 0; + initialDLBWPmappingType_1 = 0; + #this is SS=2,L=12 + initialDLBWPstartSymbolAndLength_1 = 53; + + initialDLBWPk0_2 = 0; + initialDLBWPmappingType_2 = 0; + #this is SS=1,L=12 + initialDLBWPstartSymbolAndLength_2 = 54; + + initialDLBWPk0_3 = 0; + initialDLBWPmappingType_3 = 0; + #this is SS=1,L=4 + initialDLBWPstartSymbolAndLength_3 = 57; + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 66; + ul_absoluteFrequencyPointA = 350000; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 13475; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, + +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 6; + initialULBWPmappingType_0 = 1 + # this is SS=0 L=11 + initialULBWPstartSymbolAndLength_0 = 55; + + initialULBWPk2_1 = 6; + initialULBWPmappingType_1 = 1; + # this is SS=0 L=12 + initialULBWPstartSymbolAndLength_1 = 69; + + initialULBWPk2_2 = 7; + initialULBWPmappingType_2 = 1; + # this is SS=10 L=4 + initialULBWPstartSymbolAndLength_2 = 52; + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = 10; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; + sdr_addrs = "type=x300"; + clock_src = "external"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + From 1daebfbd863184feaf0d3962adccdece0f551161 Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 29 Oct 2020 11:09:57 +0100 Subject: [PATCH 093/149] Fixed CPPCHECK warning about potential null pointer dereference of cfg --- openair1/PHY/INIT/nr_parms.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 29764e9051..7199ffa71c 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -252,13 +252,15 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, NR_DL_FRAME_PARMS *fp) { + AssertFatal (cfg != NULL, "%s %s:%i Null pointer to cfg %p!\n", __FUNCTION__, __FILE__, __LINE__, cfg); + fp->frame_type = cfg->cell_config.frame_duplex_type.value; fp->L_ssb = (((uint64_t) cfg->ssb_table.ssb_mask_list[0].ssb_mask.value)<<32) | cfg->ssb_table.ssb_mask_list[1].ssb_mask.value ; fp->N_RB_DL = cfg->carrier_config.dl_grid_size[cfg->ssb_config.scs_common.value].value; fp->N_RB_UL = cfg->carrier_config.ul_grid_size[cfg->ssb_config.scs_common.value].value; int Ncp = NFAPI_CP_NORMAL; - int mu = cfg!= NULL ? cfg->ssb_config.scs_common.value : 0; + int mu = cfg->ssb_config.scs_common.value; #if DISABLE_LOG_X printf("Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, fp->N_RB_DL, Ncp); From f433c90efe53e91124787dedc5dd7093151a182e Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 29 Oct 2020 15:43:40 +0100 Subject: [PATCH 094/149] nr rlc: fix a bug The count was wrong. --- openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c index 78a49e4604..4ae2177313 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c @@ -1284,7 +1284,7 @@ static int missing_size(nr_rlc_entity_am_t *entity, missing_data_t *m, missing_data_t m_nack; /* be careful to limit a range to 255 SNs, that is: cut if needed */ - sn_count = m->sn_end - m->sn_start; + sn_count = m->sn_end - m->sn_start + 1; if (sn_count < 0) sn_count += entity->sn_modulus; From aec21aa234afd53e4db01d736b8957df7d7e53c9 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 29 Oct 2020 15:44:39 +0100 Subject: [PATCH 095/149] nr rlc: add a test --- openair2/LAYER2/nr_rlc/tests/run_tests.sh | 2 +- openair2/LAYER2/nr_rlc/tests/test14.h | 46 +++++++++++++++++++++ openair2/LAYER2/nr_rlc/tests/test14.txt.gz | Bin 0 -> 776 bytes 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 openair2/LAYER2/nr_rlc/tests/test14.h create mode 100644 openair2/LAYER2/nr_rlc/tests/test14.txt.gz diff --git a/openair2/LAYER2/nr_rlc/tests/run_tests.sh b/openair2/LAYER2/nr_rlc/tests/run_tests.sh index ac22516064..bf1b343d7e 100755 --- a/openair2/LAYER2/nr_rlc/tests/run_tests.sh +++ b/openair2/LAYER2/nr_rlc/tests/run_tests.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_count=13 +test_count=14 for i in `seq $test_count` do diff --git a/openair2/LAYER2/nr_rlc/tests/test14.h b/openair2/LAYER2/nr_rlc/tests/test14.h new file mode 100644 index 0000000000..9eb472b270 --- /dev/null +++ b/openair2/LAYER2/nr_rlc/tests/test14.h @@ -0,0 +1,46 @@ +/* + * am test (SN field size 18): + * test status reporting with missing packet + * at time 1, UE receives an SDU of 50 bytes + * at time 2, UE receives an SDU of 50 bytes + * at time 3, UE receives an SDU of 50 bytes + * at time 4, UE receives an SDU of 50 bytes + * transmission fails for first SDU, okay for the others + * then some time with transmission failing + * then at time 49, UE receives an SDU, transmission okay + * then at time 50, transmission failing again (we had a bug triggered by this) + * finally at time 55, transmission okay again to clear buffers + */ + +TIME, 1, + GNB_AM, 100000, 100000, 45, 35, 0, -1, -1, 8, 18, + UE_AM, 100000, 100000, 45, 35, 0, -1, -1, 8, 18, + GNB_RECV_FAILS, 1, + GNB_PDU_SIZE, 80, + UE_PDU_SIZE, 80, + UE_SDU, 0, 50, +TIME, 2, + GNB_RECV_FAILS, 0, + UE_SDU, 1, 50, +TIME, 3, + GNB_BUFFER_STATUS, + UE_SDU, 2, 50, +TIME, 4, + GNB_BUFFER_STATUS, + UE_SDU, 3, 50, +TIME, 5, + GNB_BUFFER_STATUS, + GNB_RECV_FAILS, 1, +TIME, 6, + GNB_BUFFER_STATUS, + UE_BUFFER_STATUS, +TIME, 49, + GNB_RECV_FAILS, 0, + UE_SDU, 4, 50, +TIME, 50, + GNB_RECV_FAILS, 1, + GNB_BUFFER_STATUS, + UE_BUFFER_STATUS, +TIME, 55, + GNB_RECV_FAILS, 0, +TIME, -1 diff --git a/openair2/LAYER2/nr_rlc/tests/test14.txt.gz b/openair2/LAYER2/nr_rlc/tests/test14.txt.gz new file mode 100644 index 0000000000000000000000000000000000000000..7ab2fc34310c5652ac1557be39da6d5641e0cdb8 GIT binary patch literal 776 zcmV+j1NZzNiwFp!j+tKq19W9`bTKq8ba-?C-Iq&iBu5a0@BS6v(Y~0f%B+`;#*1&h ztoCFUQBNZf#>`{=`1S6YMK;rnH7j(PS!n1wWK~6EL?qq!@7~|vvE7x;?wkAL`op_B z>>ZoYK0R#vo^KyJ=DVfl@$Z2*cl?4e7>jWj!6?RK0w!V-CSwYwVj5=II4~1yuommE zf>o@?25iJ8Y{nLB#Wrlm4(!AkoW(hu;1uU^0T*!zmvIGGaShjT12++a*pH|9e;vP# zP1%iy-~0X36=_IE1~O5DTGXL}D(caI zMl_)rEoem>+R=f|<$S!wyQO1z#e00fM|{F(e8E?I!*~1wW)cj+5*$HR_%EqoubahB zKmTx~(Z|!{r?KJvj~|{DxCH@ZWgvHIpr8a#2!u#TgiI)eN@#>m7=%eQL`!r;Au7=m z12Ga4F%t{15*x7-2XT@N$&wsNNJ{dgK#HV9%A`W7q(ZvXcEt>lXrb zKj+vyEE8(C-ySE`@_sn75O#llUYUjGzw6ZjXDlesL+tRZ8g|LC?l#(X-mzB={UCs@ z94n`e&4C=riJZxWT*-~x$%8y8hGHp>A{3=~N}xnaqGU>;R7#_C%AicDp<1e=3RS6| z8mN()sF_-*mD;GCI;ivDfM#iqCN!maTA;;~*6UjxtFLpcUUsb9M%&Ii_WGgww<_+x zT=8Rlc=1B>;)Msxymi0kRY>(Tq%F}htC=Cf(32-O+`vbWacTNKf=kFZ4=p z^uAbuJ{g8#8IB<6p7;KJ|)u`y>=4FBb3`8+>2GA~?xJ^)@;Cwv9}7dhNKjiVC|JkICf z2C&CV)8FceW=s8nqv4OTWxH=}Y`1g&^z_$r3r7F`Ouc<&y?bT7ys} Date: Thu, 29 Oct 2020 16:14:55 +0100 Subject: [PATCH 096/149] add documentation and code review comments --- cmake_targets/CMakeLists.txt | 2 +- doc/5Gnas.md | 107 ++++++++++++++++++ .../RRC/NR/{nr_rrc_gNB.c => nr_ngap_gNB.c} | 0 openair3/NAS/COMMON/NR_NAS_defs.h | 22 ++++ openair3/NAS/COMMON/nr_common.c | 22 ++++ openair3/NAS/NR_UE/ue_process_nas.c | 22 ++++ openair3/NAS/gNB/network_process_nas.c | 22 ++++ 7 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 doc/5Gnas.md rename openair2/RRC/NR/{nr_rrc_gNB.c => nr_ngap_gNB.c} (100%) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 7b1f48c074..73a9383857 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -485,7 +485,7 @@ add_custom_target ( add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source} ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c - ${OPENAIR2_DIR}/RRC/NR/nr_rrc_gNB.c + ${OPENAIR2_DIR}/RRC/NR/nr_ngap_gNB.c ) add_dependencies(NR_RRC_LIB nr_rrc_flag) include_directories ("${NR_RRC_FULL_DIR}") diff --git a/doc/5Gnas.md b/doc/5Gnas.md new file mode 100644 index 0000000000..3d33af426c --- /dev/null +++ b/doc/5Gnas.md @@ -0,0 +1,107 @@ + + + +This tuto for 5G gNB NAS design +{: .text-center} + +# source files + +executables/ocp-gnb.c: a main loop to create a debuggable gNB, see document SW_archi.md +openair2/RRC/NR/nr_ngap_gNB.c: skeleton for interface with NGAP +openair3/NAS/COMMON/milenage.h: a simple milenage implementation, depend only on crypto library +openair3/NAS/COMMON/NR_NAS_defs.h: messages defined for NAS implemented in C: C struct, C enums and automatic conversion to labels for debug messages +openair3/NAS/COMMON/nr_common.c: 5G NAS common code between gNB and UE +openair3/UICC/usim_interface.c: UICC simulation for USIM messages + +openair3/NAS/NR_UE/ue_process_nas.c: NAS code for UE + +openair3/NAS/gNB/network_process_nas.c: NAS code for gNB running without 5GC + +openair3/TEST/test5Gnas.c: unitary testing of NAS messages: encodes+decode a standard network entry, mixing code from UE and 5GC (or gNB in noCore) + +# USIM simulation +A new USIM simulation, that parameters are in regular OAI config files + +## To open the USIM +init_uicc() takes a parameter: the name of the block in the config file +In case we run several UEs in one process, the variable section name allows to make several UEs configurations in one config file. + +The NAS implementation uses this possibility. + +# UE side +UEprocessNAS() is the entry for all messages. +It decodes the message type and call the specific function for each messgae + +## Identityrequest + IdentityResponse +When the UE receives the request, it stores the 5GC request parameters in the UE context ( UE->uicc pointer) +It calls "scheduleNAS", that would trigger a answer (seeing general archtecture, it will probly be a itti message to future RRC or NGAP thread). + +When the scheduler wants to encode the answer, it calls identityResponse() +The UE search for a section in the config file called "uicc" +it encodes the NAS answer with the IMSI, as a 4G compatible authentication. +A future release would encode 5G SUPI as native 5G UICC. + +## Authenticationrequest + authenticationResponse +When the UE receives the request, it stores the 5GC request parameters in the UE context ( UE->uicc pointer) +It calls "scheduleNAS", that would trigger a answer (seeing general archtecture, it will probly be a itti message to future RRC or NGAP thread). + +When the scheduler wants to encode the answer, it calls authenticationResponse() +The UE search for a section in the config file called "uicc" +It uses the Milenage parameters of this section to encode a milenage response +A future release would encode 5G new authentication cyphering functions. + +## SecurityModeCommand + securityModeComplete +When the UE receives the request it will: +Selected NAS security algorithms: store it for future encoding +Replayed UE security capabilities: check if it is equal to UE capabilities it sent to the 5GC +IMEISV request: to implement +ngKSI: Key set Indicator, similator to 4G to select a ciphering keys set + +When the scheduler wants to encode the answer, it calls registrationComplete() + +## registrationComplete +To be defined in UE, this NAS message is done after RRC sequence completes + +# gNB side +gNB NGAP thread receives the NAS message from PHY layers +In normal mode, it send it to the core network with no decoding. + +Here after, the gNB mode "noCore" processing in gNB: NGAP calls the entry function: processNAS() instead of forwarding the packet to the 5GC + +## RRCModeComplete + Identityrequest +When the gNB completes RRC attach, it sends a first message to NGAP thread. +Normal processing sends NGAP initial UE message, in noCore mode, it should call: identityRequest() that encode the NAS identity request inside the gNB. +The gNB NGAP thread then should call the piece of code that forward the message to the UE as when it receives a NAS message from 5GC. + +## All NAS coming from UE +When NGAP thread receives a NAS message from lower layers, it encapsulates it to forward it to the 5GC. In "noCore" mode it calls processNAS(). + +This function stores in the gNB the NAS data, then it should encode the next message (identity, authentication, security mode) or do nothing (registration complete). + + +
+**Note** +{: .panel-heading} +
+ + +
+
+ diff --git a/openair2/RRC/NR/nr_rrc_gNB.c b/openair2/RRC/NR/nr_ngap_gNB.c similarity index 100% rename from openair2/RRC/NR/nr_rrc_gNB.c rename to openair2/RRC/NR/nr_ngap_gNB.c diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index 36af22fb5f..906c0cf504 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -1,3 +1,25 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Author and copyright: Laurent Thomas, open-cells.com + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ #ifndef NR_NAS_DEFS_H #define NR_NAS_DEFS_H diff --git a/openair3/NAS/COMMON/nr_common.c b/openair3/NAS/COMMON/nr_common.c index 9f5ff1d8ac..736d75f6cc 100644 --- a/openair3/NAS/COMMON/nr_common.c +++ b/openair3/NAS/COMMON/nr_common.c @@ -1,3 +1,25 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Author and copyright: Laurent Thomas, open-cells.com + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ #include #include diff --git a/openair3/NAS/NR_UE/ue_process_nas.c b/openair3/NAS/NR_UE/ue_process_nas.c index 74eba3e6df..a89a07218e 100644 --- a/openair3/NAS/NR_UE/ue_process_nas.c +++ b/openair3/NAS/NR_UE/ue_process_nas.c @@ -1,3 +1,25 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Author and copyright: Laurent Thomas, open-cells.com + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ #include #include diff --git a/openair3/NAS/gNB/network_process_nas.c b/openair3/NAS/gNB/network_process_nas.c index acd2f19fac..ce8897730b 100644 --- a/openair3/NAS/gNB/network_process_nas.c +++ b/openair3/NAS/gNB/network_process_nas.c @@ -1,3 +1,25 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Author and copyright: Laurent Thomas, open-cells.com + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ #include void SGSabortUE(void *msg, NRUEcontext_t *UE) { From 16b80425b8669f28d64c7a0d3e67ddd1c442862b Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Thu, 29 Oct 2020 21:32:51 -0500 Subject: [PATCH 097/149] Small fix --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index fbf891c7aa..b65d159515 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2508,7 +2508,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Get the numerology to calculate the Tx frame and slot mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; // Get slot offset K2 which will be used to calculate TX slot - k2 = get_k2(mac, dci->frequency_hopping_flag.val); + k2 = get_k2(mac, dci->time_domain_assignment.val); // Calculate TX slot and frame slot_tx = (slot + k2) % nr_slots_per_frame[mu]; frame_tx = ((slot + k2) > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; @@ -2597,7 +2597,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Get the numerology to calculate the Tx frame and slot mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; // Get slot offset K2 which will be used to calculate TX slot - k2 = get_k2(mac, dci->frequency_hopping_flag.val); + k2 = get_k2(mac, dci->time_domain_assignment.val); // Calculate TX slot and frame slot_tx = (slot + k2) % nr_slots_per_frame[mu]; frame_tx = ((slot + k2) > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; From 10202929848b8c78d4998be1c13347fc7fc0e2b3 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Fri, 30 Oct 2020 13:17:04 +0100 Subject: [PATCH 098/149] fix CPPCHECK warning regarding "cfg" in openair1/PHY/INIT/nr_parms.c --- openair1/PHY/INIT/nr_parms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 7199ffa71c..c37ba49308 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -308,7 +308,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, } fp->N_ssb = 0; - int num_tx_ant = (cfg == NULL) ? fp->Lmax : cfg->carrier_config.num_tx_ant.value; + int num_tx_ant = cfg->carrier_config.num_tx_ant.value; for (int p=0; pN_ssb += ((fp->L_ssb >> (63-p)) & 0x01); From ed2eb95c4a1bfba5991163fd13cef045767f4fa1 Mon Sep 17 00:00:00 2001 From: dongzhanyi Date: Sat, 31 Oct 2020 07:13:07 +0800 Subject: [PATCH 099/149] solved the problem that UE UL LDPC code can only process data within 8 code blocks --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index ee10c96c20..09decf17db 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -391,7 +391,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, printf("\n");*/ encoder_implemparams_t impp; impp.n_segments=harq_process->C; - impp.macro_num=0; impp.tinput = NULL; impp.tprep = NULL; impp.tparity = NULL; @@ -399,7 +398,11 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_IN); - nrLDPC_encoder(harq_process->c,harq_process->d,*pz,Kb,Kr,BG,&impp); + for(int j=0;j<(harq_process->C/8+1);j++) + { + impp.macro_num=j; + nrLDPC_encoder(harq_process->c,harq_process->d,*pz,Kb,Kr,BG,&impp); + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_OUT); From cad824099eb64e1c92b65432410194e2f1fb98a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= Date: Mon, 2 Nov 2020 10:40:48 +0100 Subject: [PATCH 100/149] fix(build_helper): use SUDO when we are a regular user root user is not tied to a container. Let the possibility to build when we run as a regular user in a container. --- cmake_targets/tools/build_helper | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 7c50bc106a..1ba3b225a6 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -42,12 +42,12 @@ KERNEL_MAJOR=$(uname -r | cut -d '.' -f2) #check if we run inside a container IS_CONTAINER=`egrep -c "docker|podman|kubepods" /proc/self/cgroup || true` -#sudo is not needed inside a container -if [ $IS_CONTAINER -eq 0 ] +#sudo is not needed when we are root +if [ "$UID" = 0 ] then - SUDO='sudo -S -E' -else SUDO='' +else + SUDO='sudo -S -E' fi ############################### @@ -251,18 +251,13 @@ install_protobuf_from_source(){ #wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz #tar -xzvf protobuf-2.6.1.tar.gz --owner $USER --group $USER --no-same-owner #cd protobuf-2.6.1/ - + if [ $IS_CONTAINER -eq 0 ] then rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $(groups | cut -d" " -f1) --no-same-owner cd protobuf-3.3.0/ - ./configure - echo "Compiling protobuf" - make -j`nproc` - $SUDO make install - $SUDO ldconfig else export LD_LIBRARY_PATH=/usr/local/lib #protoc needs to know where toclook for shared libs rm -rf /tmp/protobuf @@ -270,11 +265,12 @@ install_protobuf_from_source(){ cd /tmp/protobuf git submodule update --init --recursive ./autogen.sh - ./configure - make -j`nproc` - make install - ldconfig fi + ./configure + echo "Compiling protobuf" + make -j`nproc` + $SUDO make install + $SUDO ldconfig ) >& $protobuf_install_log } From 1426ee5ed61b82de2008a89e2dce2959d001ff71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= Date: Mon, 2 Nov 2020 17:16:29 +0100 Subject: [PATCH 101/149] feat: add optional parameter port for mme connection --- openair2/COMMON/s1ap_messages_types.h | 1 + openair2/ENB_APP/enb_config.c | 8 ++++++++ openair2/ENB_APP/enb_paramdef.h | 9 ++++++++- openair3/S1AP/s1ap_eNB.c | 5 ++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/openair2/COMMON/s1ap_messages_types.h b/openair2/COMMON/s1ap_messages_types.h index befab4ebdf..f6b4f3c4e2 100644 --- a/openair2/COMMON/s1ap_messages_types.h +++ b/openair2/COMMON/s1ap_messages_types.h @@ -386,6 +386,7 @@ typedef struct s1ap_register_enb_req_s { uint8_t nb_mme; /* List of MME to connect to */ net_ip_address_t mme_ip_address[S1AP_MAX_NB_MME_IP_ADDRESS]; + uint16_t mme_port[S1AP_MAX_NB_MME_IP_ADDRESS]; uint8_t broadcast_plmn_num[S1AP_MAX_NB_MME_IP_ADDRESS]; uint8_t broadcast_plmn_index[S1AP_MAX_NB_MME_IP_ADDRESS][PLMN_LIST_MAX_SIZE]; diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index cf8ba78a81..a0a506bf35 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -57,6 +57,7 @@ #include "enb_paramdef.h" #include "proto_agent.h" #include "executables/thread-common.h" +#include "s1ap_eNB_default_values.h" extern uint32_t to_earfcn_DL(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw); extern uint32_t to_earfcn_UL(int eutra_bandP, uint32_t ul_CarrierFreq, uint32_t bw); @@ -2511,6 +2512,13 @@ int RCconfig_S1( S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = 0; } + /* set S1-mme port (sctp) */ + if (S1ParamList.paramarray[l][ENB_MME_PORT_IDX].u16ptr) { + S1AP_REGISTER_ENB_REQ(msg_p).mme_port[l] = *S1ParamList.paramarray[l][ENB_MME_PORT_IDX].u16ptr; + } else { + S1AP_REGISTER_ENB_REQ(msg_p).mme_port[l] = S1AP_PORT_NUMBER; + } + AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] <= S1AP_REGISTER_ENB_REQ(msg_p).num_plmn, "List of broadcast PLMN to be sent to MME can not be longer than actual " "PLMN list (max %d, but is %d)\n", diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index d2372c944c..dd24964b4c 100644 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -907,6 +907,7 @@ typedef struct srb1_params_s { #define ENB_CONFIG_STRING_MME_IPV4_ADDRESS "ipv4" #define ENB_CONFIG_STRING_MME_IPV6_ADDRESS "ipv6" +#define ENB_CONFIG_STRING_MME_PORT "port" #define ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE "active" #define ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE "preference" #define ENB_CONFIG_STRING_MME_BROADCAST_PLMN_INDEX "broadcast_plmn_index" @@ -921,14 +922,20 @@ typedef struct srb1_params_s { {ENB_CONFIG_STRING_MME_IPV6_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_MME_BROADCAST_PLMN_INDEX, NULL, 0, uptr:NULL, defintarrayval:NULL, TYPE_UINTARRAY, 6} \ + {ENB_CONFIG_STRING_MME_BROADCAST_PLMN_INDEX, NULL, 0, uptr:NULL, defintarrayval:NULL, TYPE_UINTARRAY, 6}, \ + {ENB_CONFIG_STRING_MME_PORT, NULL, 0, u16ptr:NULL, defuintval:0, TYPE_UINT16, 0}, \ } + + + + #define ENB_MME_IPV4_ADDRESS_IDX 0 #define ENB_MME_IPV6_ADDRESS_IDX 1 #define ENB_MME_IP_ADDRESS_ACTIVE_IDX 2 #define ENB_MME_IP_ADDRESS_PREFERENCE_IDX 3 #define ENB_MME_BROADCAST_PLMN_INDEX 4 +#define ENB_MME_PORT_IDX 5 /*---------------------------------------------------------------------------------------------------------------------------------------*/ /* X2 configuration parameters section name */ diff --git a/openair3/S1AP/s1ap_eNB.c b/openair3/S1AP/s1ap_eNB.c index c703501847..2a153acaa2 100644 --- a/openair3/S1AP/s1ap_eNB.c +++ b/openair3/S1AP/s1ap_eNB.c @@ -89,6 +89,7 @@ uint32_t s1ap_generate_eNB_id(void) { static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p, net_ip_address_t *mme_ip_address, + uint16_t mme_port, net_ip_address_t *local_ip_addr, uint16_t in_streams, uint16_t out_streams, @@ -102,7 +103,7 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p, DevAssert(mme_ip_address != NULL); message_p = itti_alloc_new_message(TASK_S1AP, SCTP_NEW_ASSOCIATION_REQ); sctp_new_association_req_p = &message_p->ittiMsg.sctp_new_association_req; - sctp_new_association_req_p->port = S1AP_PORT_NUMBER; + sctp_new_association_req_p->port = mme_port; sctp_new_association_req_p->ppid = S1AP_SCTP_PPID; sctp_new_association_req_p->in_streams = in_streams; sctp_new_association_req_p->out_streams = out_streams; @@ -221,6 +222,7 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t * /* Trying to connect to provided list of MME ip address */ for (index = 0; index < s1ap_register_eNB->nb_mme; index++) { net_ip_address_t *mme_ip = &s1ap_register_eNB->mme_ip_address[index]; + uint16_t mme_port = s1ap_register_eNB->mme_port[index]; struct s1ap_eNB_mme_data_s *mme = NULL; RB_FOREACH(mme, s1ap_mme_map, &new_instance->s1ap_mme_head) { /* Compare whether IPv4 and IPv6 information is already present, in which @@ -235,6 +237,7 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t * continue; s1ap_eNB_register_mme(new_instance, mme_ip, + mme_port, &s1ap_register_eNB->enb_ip_address, s1ap_register_eNB->sctp_in_streams, s1ap_register_eNB->sctp_out_streams, From 93e34b7fd72a5ed8730f4ff1a135ff161f0977cc Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Mon, 2 Nov 2020 19:02:34 -0600 Subject: [PATCH 102/149] Fixes for a few UE failures due to invalid DCI received --- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 11 ++++- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 44 ++++++++++--------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 37 +++++++++++++--- 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index e8204ad0b5..da928d4244 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -242,6 +242,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, dlsch0_harq->Qm = nr_get_Qm_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); dlsch0_harq->R = nr_get_code_rate_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); + if (dlsch0_harq->Qm == 0 || dlsch0_harq->R == 0) { + LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); + return -1; + } #ifdef DEBUG_HARQ printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode); @@ -981,7 +985,12 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } if (dlsch1_harq) { - switch (nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table)) { + uint8_t Qm = nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table); + if (Qm == 0){ + LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); + return -1; + } + switch (Qm) { case 2 : if (rx_type==rx_standard) { nr_dlsch_qpsk_llr(frame_parms, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 8fe83dd40d..7dd6e380ed 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1616,7 +1616,7 @@ uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx) { case 0: if (Imcs > 28) { LOG_E(MAC, "Invalid MCS index %d for MCS table 0 (expected range [0,28])\n", Imcs); - Imcs = 28; + return 0; } return (Table_51311[Imcs][0]); break; @@ -1624,7 +1624,7 @@ uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx) { case 1: if (Imcs > 27) { LOG_E(MAC, "Invalid MCS index %d for MCS table 1 (expected range [0,27])\n", Imcs); - Imcs = 27; + return 0; } return (Table_51312[Imcs][0]); break; @@ -1632,13 +1632,14 @@ uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx) { case 2: if (Imcs > 28) { LOG_E(MAC, "Invalid MCS index %d for MCS table 2 (expected range [0,28])\n", Imcs); - Imcs = 28; + return 0; } return (Table_51313[Imcs][0]); break; default: - AssertFatal(0, "Invalid MCS table index %d (expected in range [0,2])\n", table_idx); + LOG_E(MAC, "Invalid MCS table index %d (expected in range [0,2])\n", table_idx); + return 0; } } @@ -1647,7 +1648,7 @@ uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx) { case 0: if (Imcs > 28) { LOG_E(MAC, "Invalid MCS index %d for MCS table 0 (expected range [0,28])\n", Imcs); - Imcs = 28; + return 0; } return (Table_51311[Imcs][1]); break; @@ -1655,7 +1656,7 @@ uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx) { case 1: if (Imcs > 27) { LOG_E(MAC, "Invalid MCS index %d for MCS table 1 (expected range [0,27])\n", Imcs); - Imcs = 27; + return 0; } return (Table_51312[Imcs][1]); break; @@ -1663,13 +1664,14 @@ uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx) { case 2: if (Imcs > 28) { LOG_E(MAC, "Invalid MCS index %d for MCS table 2 (expected range [0,28])\n", Imcs); - Imcs = 28; + return 0; } return (Table_51313[Imcs][1]); break; default: - AssertFatal(0, "Invalid MCS table index %d (expected in range [0,2])\n", table_idx); + LOG_E(MAC, "Invalid MCS table index %d (expected in range [0,2])\n", table_idx); + return 0; } } @@ -1678,7 +1680,7 @@ uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx) { case 0: if (Imcs > 28) { LOG_E(MAC, "Invalid MCS index %d for MCS table 0 (expected range [0,28])\n", Imcs); - Imcs = 28; + return 0; } return (Table_51311[Imcs][0]); break; @@ -1686,7 +1688,7 @@ uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx) { case 1: if (Imcs > 27) { LOG_E(MAC, "Invalid MCS index %d for MCS table 1 (expected range [0,27])\n", Imcs); - Imcs = 27; + return 0; } return (Table_51312[Imcs][0]); break; @@ -1694,7 +1696,7 @@ uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx) { case 2: if (Imcs > 28) { LOG_E(MAC, "Invalid MCS index %d for MCS table 2 (expected range [0,28])\n", Imcs); - Imcs = 28; + return 0; } return (Table_51313[Imcs][0]); break; @@ -1702,7 +1704,7 @@ uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx) { case 3: if (Imcs > 27) { LOG_E(MAC, "Invalid MCS index %d for MCS table 3 (expected range [0,27])\n", Imcs); - Imcs = 27; + return 0; } return (Table_61411[Imcs][0]); break; @@ -1710,13 +1712,14 @@ uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx) { case 4: if (Imcs > 27) { LOG_E(MAC, "Invalid MCS index %d for MCS table 4 (expected range [0,27])\n", Imcs); - Imcs = 27; + return 0; } return (Table_61412[Imcs][0]); break; default: - AssertFatal(0, "Invalid MCS table index %d (expected in range [0,4])\n", table_idx); + LOG_E(MAC, "Invalid MCS table index %d (expected in range [0,4])\n", table_idx); + return 0; } } @@ -1725,7 +1728,7 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx) { case 0: if (Imcs > 28) { LOG_E(MAC, "Invalid MCS index %d for MCS table 0 (expected range [0,28])\n", Imcs); - Imcs = 28; + return 0; } return (Table_51311[Imcs][1]); break; @@ -1733,7 +1736,7 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx) { case 1: if (Imcs > 27) { LOG_E(MAC, "Invalid MCS index %d for MCS table 1 (expected range [0,27])\n", Imcs); - Imcs = 27; + return 0; } return (Table_51312[Imcs][1]); break; @@ -1741,7 +1744,7 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx) { case 2: if (Imcs > 28) { LOG_E(MAC, "Invalid MCS index %d for MCS table 2 (expected range [0,28])\n", Imcs); - Imcs = 28; + return 0; } return (Table_51313[Imcs][1]); break; @@ -1749,7 +1752,7 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx) { case 3: if (Imcs > 27) { LOG_E(MAC, "Invalid MCS index %d for MCS table 3 (expected range [0,27])\n", Imcs); - Imcs = 27; + return 0; } return (Table_61411[Imcs][1]); break; @@ -1757,13 +1760,14 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx) { case 4: if (Imcs > 27) { LOG_E(MAC, "Invalid MCS index %d for MCS table 4 (expected range [0,27])\n", Imcs); - Imcs = 27; + return 0; } return (Table_61412[Imcs][1]); break; default: - AssertFatal(0, "Invalid MCS table index %d (expected in range [0,4])\n", table_idx); + LOG_E(MAC, "Invalid MCS table index %d (expected in range [0,4])\n", table_idx); + return 0; } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index b65d159515..2db0af743c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -675,6 +675,7 @@ uint32_t get_ssb_frame(uint32_t test){ * indication value from RRC configuration. */ long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { + long k2 = -1; // Get K2 from RRC configuration NR_PUSCH_Config_t *pusch_config=mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; @@ -684,7 +685,14 @@ long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { else if (mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; } - long k2 = *pusch_TimeDomainAllocationList->list.array[time_domain_ind]->k2; + if (pusch_TimeDomainAllocationList) { + if (time_domain_ind >= pusch_TimeDomainAllocationList->list.count) { + LOG_E(MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n", + time_domain_ind, pusch_TimeDomainAllocationList->list.count); + return -1; + } + k2 = *pusch_TimeDomainAllocationList->list.array[time_domain_ind]->k2; + } LOG_D(MAC, "get_k2(): k2 is %ld\n", k2); return k2; @@ -892,8 +900,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; - ulcfg_pdu->pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); - ulcfg_pdu->pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); + //ulcfg_pdu->pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); + //ulcfg_pdu->pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(ulcfg_pdu->pusch_config_pdu.mcs_index, ulcfg_pdu->pusch_config_pdu.mcs_table); if (1 << ulcfg_pdu->pusch_config_pdu.pusch_ptrs.ptrs_time_density >= ulcfg_pdu->pusch_config_pdu.nr_of_symbols) { ulcfg_pdu->pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS @@ -2509,13 +2517,19 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; // Get slot offset K2 which will be used to calculate TX slot k2 = get_k2(mac, dci->time_domain_assignment.val); + if (k2 < 0) // This can happen when a false DCI is received + return -1; // Calculate TX slot and frame slot_tx = (slot + k2) % nr_slots_per_frame[mu]; frame_tx = ((slot + k2) > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; // Get UL config request corresponding slot_tx ul_config = get_ul_config_request(mac, slot_tx); - AssertFatal(ul_config != NULL, "nr_ue_process_dci(): ul_config is NULL\n"); + //AssertFatal(ul_config != NULL, "nr_ue_process_dci(): ul_config is NULL\n"); + if (!ul_config) { + LOG_W(MAC, "nr_ue_process_dci(): ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n",frame,slot); + return -1; + } ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu.rnti = rnti; @@ -2598,13 +2612,19 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr mu = mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; // Get slot offset K2 which will be used to calculate TX slot k2 = get_k2(mac, dci->time_domain_assignment.val); + if (k2 < 0) // This can happen when a false DCI is received + return -1; // Calculate TX slot and frame slot_tx = (slot + k2) % nr_slots_per_frame[mu]; frame_tx = ((slot + k2) > nr_slots_per_frame[mu]) ? (frame + 1) % 1024 : frame; // Get UL config request corresponding slot_tx ul_config = get_ul_config_request(mac, slot_tx); - AssertFatal(ul_config != NULL, "nr_ue_process_dci(): ul_config is NULL\n"); + //AssertFatal(ul_config != NULL, "nr_ue_process_dci(): ul_config is NULL\n"); + if (!ul_config) { + LOG_W(MAC, "nr_ue_process_dci(): ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n",frame,slot); + return -1; + } ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu.rnti = rnti; @@ -2642,6 +2662,13 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr pusch_config_pdu_0_1->mcs_table = get_pusch_mcs_table(pusch_config->mcs_TableTransformPrecoder, 1, dci_format, NR_RNTI_C, NR_SearchSpace__searchSpaceType_PR_ue_Specific, false); + pusch_config_pdu_0_1->target_code_rate = nr_get_code_rate_ul(pusch_config_pdu_0_1->mcs_index, pusch_config_pdu_0_1->mcs_table); + pusch_config_pdu_0_1->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu_0_1->mcs_index, pusch_config_pdu_0_1->mcs_table); + if (pusch_config_pdu_0_1->target_code_rate == 0 || pusch_config_pdu_0_1->qam_mod_order == 0) { + LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected UL DCI. Ignoring DCI! \n"); + return -1; + } + /* NDI */ pusch_config_pdu_0_1->pusch_data.new_data_indicator = dci->ndi; /* RV */ From fd3d49bbe7e0902f4ae08c025fca01482ac460b7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 13 Oct 2020 19:32:19 +0200 Subject: [PATCH 103/149] Correctly check and apply the TA in DLSCH scheduler --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 13 --------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 29 ++++++++++++++++++- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 4e60bd2ab8..083692e0e3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -470,18 +470,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_schedule_reception_msg3(module_idP, 0, frame, slot); } - if (UE_info->active[UE_id]) { - // TbD once RACH is available, start ta_timer when UE is connected - if (ue_sched_ctl->ta_timer) - ue_sched_ctl->ta_timer--; - if (ue_sched_ctl->ta_timer == 0) { - ue_sched_ctl->ta_apply = true; - /* if time is up, then set the timer to not send it for 5 frames - // regardless of the TA value */ - ue_sched_ctl->ta_timer = 100; - } - } - // This schedules the DCI for Uplink and subsequently PUSCH // The decision about whether to schedule is done for each UE independently // inside @@ -499,7 +487,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, //nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched); //nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_info->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); nr_schedule_ue_spec(module_idP, frame, slot, num_slots_per_tdd); - ue_sched_ctl->ta_apply = false; } if (UE_info->active[UE_id]) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 640068ecae..abd866f9e7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -500,7 +500,9 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, 0, 0); sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; - if (sched_ctrl->num_total_bytes == 0 && !get_softmodem_params()->phy_test) + if (sched_ctrl->num_total_bytes == 0 + && !get_softmodem_params()->phy_test + && !sched_ctrl->ta_apply) /* If TA should be applied, give at least one RB */ return; LOG_D(MAC, "%d.%d, DTCH%d->DLSCH, RLC status %d bytes\n", @@ -632,10 +634,26 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_UE_info_t *UE_info = &gNB_mac->UE_info; const int CC_id = 0; + /* calculate number of slots since last DL scheduling, since the scheduler is + * not called in every slot. */ + const NR_COMMON_channels_t *cc = gNB_mac->common_channels; + const NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + const NR_TDD_UL_DL_Pattern_t *tdd_pattern = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int slot_diff = + (slot % num_slots_per_tdd) == 0 ? tdd_pattern->nrofUplinkSlots + 1 : 1; NR_UE_list_t *UE_list = &UE_info->list; for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + + /* update TA and set ta_apply upon expiry. If such UE is not scheduled now, + * it will be by the preprocessor later. If we add the CE, ta_apply will be + * reset */ + if (sched_ctrl->ta_timer > 0) + sched_ctrl->ta_timer -= slot_diff; + else + sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */ + if (sched_ctrl->rbSize <= 0 && !get_softmodem_params()->phy_test) continue; @@ -733,6 +751,15 @@ void nr_schedule_ue_spec(module_id_t module_id, /* reserve space for timing advance of UE if necessary, * nr_generate_dlsch_pdu() checks for ta_apply and add TA CE if necessary */ const int ta_len = (sched_ctrl->ta_apply) ? 2 : 0; + if (sched_ctrl->ta_apply) { + LOG_I(MAC, + "%d.%2d UE %d TA scheduled, resetting timer to 100\n", + frame, + slot, + UE_id); + sched_ctrl->ta_apply = false; + sched_ctrl->ta_timer = 100; + } /* Get RLC data TODO: remove random data retrieval */ int header_length_total = 0; From 8363849c3f3bb9fa57de9f7770ba6de741d3e282 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 26 Oct 2020 17:54:32 +0100 Subject: [PATCH 104/149] Modification of TA update procedure --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 40 ++++++++----------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 4 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 + openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index abd866f9e7..77f43c57ae 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -634,24 +634,15 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_UE_info_t *UE_info = &gNB_mac->UE_info; const int CC_id = 0; - /* calculate number of slots since last DL scheduling, since the scheduler is - * not called in every slot. */ - const NR_COMMON_channels_t *cc = gNB_mac->common_channels; - const NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - const NR_TDD_UL_DL_Pattern_t *tdd_pattern = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; - const int slot_diff = - (slot % num_slots_per_tdd) == 0 ? tdd_pattern->nrofUplinkSlots + 1 : 1; - NR_UE_list_t *UE_list = &UE_info->list; for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - /* update TA and set ta_apply upon expiry. If such UE is not scheduled now, - * it will be by the preprocessor later. If we add the CE, ta_apply will be - * reset */ - if (sched_ctrl->ta_timer > 0) - sched_ctrl->ta_timer -= slot_diff; - else + /* update TA and set ta_apply every 10 frames. + * Possible improvement: take the periodicity from input file. + * If such UE is not scheduled now, it will be by the preprocessor later. + * If we add the CE, ta_apply will be reset */ + if (frame >= (sched_ctrl->ta_frame + 10) % 1023) sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */ if (sched_ctrl->rbSize <= 0 && !get_softmodem_params()->phy_test) @@ -751,15 +742,6 @@ void nr_schedule_ue_spec(module_id_t module_id, /* reserve space for timing advance of UE if necessary, * nr_generate_dlsch_pdu() checks for ta_apply and add TA CE if necessary */ const int ta_len = (sched_ctrl->ta_apply) ? 2 : 0; - if (sched_ctrl->ta_apply) { - LOG_I(MAC, - "%d.%2d UE %d TA scheduled, resetting timer to 100\n", - frame, - slot, - UE_id); - sched_ctrl->ta_apply = false; - sched_ctrl->ta_timer = 100; - } /* Get RLC data TODO: remove random data retrieval */ int header_length_total = 0; @@ -803,7 +785,6 @@ void nr_schedule_ue_spec(module_id_t module_id, sdu_length_total += sdu_lengths[num_sdus]; header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); header_length_total += header_length_last; - num_sdus++; //ue_sched_ctl->uplane_inactivity_timer = 0; @@ -867,6 +848,17 @@ void nr_schedule_ue_spec(module_id_t module_id, retInfo->mcs = sched_ctrl->mcs; retInfo->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData; + // ta command is sent, values are reset + if (sched_ctrl->ta_apply) { + sched_ctrl->ta_apply = false; + sched_ctrl->ta_frame = frame; + LOG_D(MAC, + "%d.%2d UE %d TA scheduled, resetting TA frame\n", + frame, + slot, + UE_id); + } + T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti), T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_BUFFER(buf, TBS)); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index cc10f68842..86c16d76de 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1784,9 +1784,9 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ memset((void *) &UE_info->UE_sched_ctrl[UE_id], 0, sizeof(NR_UE_sched_ctrl_t)); - - UE_info->UE_sched_ctrl[UE_id].ta_timer = 100; + UE_info->UE_sched_ctrl[UE_id].ta_frame = 0; UE_info->UE_sched_ctrl[UE_id].ta_update = 31; + UE_info->UE_sched_ctrl[UE_id].ta_apply = false; UE_info->UE_sched_ctrl[UE_id].ul_rssi = 0; UE_info->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch **)malloc(num_slots_ul*sizeof(NR_sched_pucch *)); for (int s=0; srnti); + // re-initialize ta update variables afrer RA procedure completion + UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; } return; } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 896c52536f..889e50454c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -372,7 +372,7 @@ typedef struct { /// Retransmission-related information NR_UE_ret_info_t retInfo[NR_MAX_NB_HARQ_PROCESSES]; - uint16_t ta_timer; + uint16_t ta_frame; int16_t ta_update; bool ta_apply; uint8_t tpc0; From 14f15d7e77d031a8dc0c744212d71352a3fabe35 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Oct 2020 14:06:39 +0200 Subject: [PATCH 105/149] Fix: postprocessor resets UE scheduling condition --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 77f43c57ae..188f4f774f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -483,7 +483,6 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - sched_ctrl->rbSize = 0; /* Retrieve amount of data to send for this UE */ sched_ctrl->num_total_bytes = 0; @@ -874,5 +873,8 @@ void nr_schedule_ue_spec(module_id_t module_id, } #endif } + + /* mark UE as scheduled */ + sched_ctrl->rbSize = 0; } } From fd9f5d2d2cf73f5194875666fbbd94ddd1aa4d4f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Oct 2020 12:56:10 +0200 Subject: [PATCH 106/149] Use function pointer to call pre-processor --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 7 ++++--- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 6 ++++++ openair2/LAYER2/NR_MAC_gNB/main.c | 2 ++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 8 ++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 188f4f774f..31571a9666 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -626,10 +626,11 @@ void nr_schedule_ue_spec(module_id_t module_id, frame_t frame, sub_frame_t slot, int num_slots_per_tdd) { - /* PREPROCESSOR */ - nr_simple_dlsch_preprocessor(module_id, frame, slot, num_slots_per_tdd); - gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; + + /* PREPROCESSOR */ + gNB_mac->pre_processor_dl(module_id, frame, slot, num_slots_per_tdd); + NR_UE_info_t *UE_info = &gNB_mac->UE_info; const int CC_id = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index c67b7ce07b..118c68d91c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -80,6 +80,12 @@ void nr_schedule_ue_spec(module_id_t module_id, sub_frame_t slot, int num_slots_per_tdd); +/* \brief default preprocessor */ +void nr_simple_dlsch_preprocessor(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + int num_slots_per_tdd); + void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); /////// Random Access MAC-PHY interface functions and primitives /////// diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 7df00f15f1..eb28ef3770 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -82,6 +82,8 @@ void mac_top_init_gNB(void) RC.nrmac[i]->ul_handle = 0; + RC.nrmac[i]->pre_processor_dl = nr_simple_dlsch_preprocessor; + }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) AssertFatal(rlc_module_init(1) == 0,"Could not initialize RLC layer\n"); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 889e50454c..6e9c547276 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -427,6 +427,11 @@ typedef struct { uint8_t UE_beam_index[MAX_MOBILES_PER_GNB]; } NR_UE_info_t; +typedef void (*nr_pp_impl_dl)(module_id_t mod_id, + frame_t frame, + sub_frame_t slot, + int num_slots_per_tdd); + /*! \brief top level eNB MAC structure */ typedef struct gNB_MAC_INST_s { /// Ethernet parameters for northbound midhaul interface @@ -489,6 +494,9 @@ typedef struct gNB_MAC_INST_s { int cce_list[MAX_NUM_BWP][MAX_NUM_CORESET][MAX_NUM_CCE]; /// current slot int current_slot; + + /// DL preprocessor for differentiated scheduling + nr_pp_impl_dl pre_processor_dl; } gNB_MAC_INST; #endif /*__LAYER2_NR_MAC_GNB_H__ */ From b389e43eea47f84c941fe2d0fa2dec55ccc80d6b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Oct 2020 14:07:02 +0200 Subject: [PATCH 107/149] Add phytest preprocessor The phytest preprocessor schedules only one UE, as many RBs as possible (largest continuous RB region), with a fixed MCS and time domain allocation. --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 5 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 100 ++++++++++++++++++ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 7 ++ openair2/LAYER2/NR_MAC_gNB/main.c | 5 +- 4 files changed, 113 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 31571a9666..30bd41bb58 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -500,7 +500,6 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, 0); sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; if (sched_ctrl->num_total_bytes == 0 - && !get_softmodem_params()->phy_test && !sched_ctrl->ta_apply) /* If TA should be applied, give at least one RB */ return; LOG_D(MAC, @@ -645,7 +644,7 @@ void nr_schedule_ue_spec(module_id_t module_id, if (frame >= (sched_ctrl->ta_frame + 10) % 1023) sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */ - if (sched_ctrl->rbSize <= 0 && !get_softmodem_params()->phy_test) + if (sched_ctrl->rbSize <= 0) continue; const rnti_t rnti = UE_info->rnti[UE_id]; @@ -743,7 +742,7 @@ void nr_schedule_ue_spec(module_id_t module_id, * nr_generate_dlsch_pdu() checks for ta_apply and add TA CE if necessary */ const int ta_len = (sched_ctrl->ta_apply) ? 2 : 0; - /* Get RLC data TODO: remove random data retrieval */ + /* Get RLC data */ int header_length_total = 0; int header_length_last = 0; int sdu_length_total = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index b259b987cb..858245c096 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -252,6 +252,106 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, } } +/* schedules whole bandwidth for first user, all the time */ +void nr_preprocessor_phytest(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + int num_slots_per_tdd) +{ + if (slot != 1) + return; /* only schedule in slot 1 for now */ + NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + const int UE_id = 0; + const int CC_id = 0; + AssertFatal(UE_info->active[UE_id], + "%s(): expected UE %d to be active\n", + __func__, + UE_id); + + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + /* find largest unallocated chunk */ + const int bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + int rbStart = 0; + int tStart = 0; + int rbSize = 0; + uint8_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; + /* find largest unallocated RB region */ + do { + /* advance to first free RB */ + while (tStart < bwpSize && vrb_map[tStart]) + tStart++; + /* find maximum rbSize at current rbStart */ + int tSize = 1; + while (tStart + tSize < bwpSize && !vrb_map[tStart + tSize]) + tSize++; + if (tSize > rbSize) { + rbStart = tStart; + rbSize = tSize; + } + tStart += tSize; + } while (tStart < bwpSize); + + sched_ctrl->num_total_bytes = 0; + const int lcid = DL_SCH_LCID_DTCH; + const uint16_t rnti = UE_info->rnti[UE_id]; + /* update sched_ctrl->num_total_bytes so that postprocessor schedules data, + * if available */ + sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, + rnti, + module_id, + frame, + slot, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + 0, + 0); + sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; + + const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + sched_ctrl->search_space = get_searchspace(sched_ctrl->active_bwp, target_ss); + uint8_t nr_of_candidates; + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space); + sched_ctrl->coreset = get_coreset( + sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); + const int cid = sched_ctrl->coreset->controlResourceSetId; + const uint16_t Y = UE_info->Y[UE_id][cid][RC.nrmac[module_id]->current_slot]; + const int m = UE_info->num_pdcch_cand[UE_id][cid]; + sched_ctrl->cce_index = allocate_nr_CCEs(RC.nrmac[module_id], + sched_ctrl->active_bwp, + sched_ctrl->coreset, + sched_ctrl->aggregation_level, + Y, + m, + nr_of_candidates); + AssertFatal(sched_ctrl->cce_index >= 0, + "%s(): could not find CCE for UE %d\n", + __func__, + UE_id); + + nr_acknack_scheduling(module_id, + UE_id, + frame, + slot, + num_slots_per_tdd, + &sched_ctrl->pucch_sched_idx, + &sched_ctrl->pucch_occ_idx); + AssertFatal(sched_ctrl->pucch_sched_idx >= 0, "no uplink slot for PUCCH found!\n"); + + sched_ctrl->rbStart = rbStart; + sched_ctrl->rbSize = rbSize; + sched_ctrl->time_domain_allocation = 2; + sched_ctrl->mcsTableIdx = 0; + sched_ctrl->mcs = 9; + sched_ctrl->numDmrsCdmGrpsNoData = 1; + + /* mark the corresponding RBs as used */ + for (int rb = 0; rb < sched_ctrl->rbSize; rb++) + vrb_map[rb + sched_ctrl->rbStart] = 1; +} + int configure_fapi_dl_pdu_phytest(int Mod_idP, nfapi_nr_dl_tti_request_body_t *dl_req, NR_sched_pucch *pucch_sched, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 118c68d91c..86d97b2ce5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -130,6 +130,13 @@ uint16_t nr_mac_compute_RIV(uint16_t N_RB_DL, uint16_t RBstart, uint16_t Lcrbs); /////// Phy test scheduler /////// +/* \brief preprocessor for phytest: schedules UE_id 0 with fixed MCS on all + * freq resources */ +void nr_preprocessor_phytest(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + int num_slots_per_tdd); + void nr_schedule_css_dlsch_phytest(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index eb28ef3770..b7db1f67aa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -82,7 +82,10 @@ void mac_top_init_gNB(void) RC.nrmac[i]->ul_handle = 0; - RC.nrmac[i]->pre_processor_dl = nr_simple_dlsch_preprocessor; + if (get_softmodem_params()->phy_test) + RC.nrmac[i]->pre_processor_dl = nr_preprocessor_phytest; + else + RC.nrmac[i]->pre_processor_dl = nr_simple_dlsch_preprocessor; }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) From 0deb5d291d3e2ad985ddc5f94c11a1f0c43112ac Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 29 Oct 2020 16:29:01 +0100 Subject: [PATCH 108/149] Use special dlsim preprocessor --- openair1/SIMULATION/NR_PHY/dlsim.c | 72 +++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index a4ee4c8c6e..be20b779db 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -150,6 +150,42 @@ int is_x2ap_enabled(void) openair0_config_t openair0_cfg[MAX_CARDS]; +/* specific dlsim DL preprocessor: uses rbStart/rbSize/mcs from command line of + dlsim, does not search for CCE/PUCCH occasion but simply sets to 0 */ +int g_mcsIndex = -1, g_rbStart = -1, g_rbSize = -1; +void nr_dlsim_preprocessor(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + int num_slots_per_tdd) { + NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + AssertFatal(UE_info->num_UEs == 1, "can have only a single UE\n"); + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[0]; + + /* manually set free CCE to 0 */ + const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + sched_ctrl->search_space = get_searchspace(sched_ctrl->active_bwp, target_ss); + uint8_t nr_of_candidates; + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space); + sched_ctrl->coreset = get_coreset( + sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); + sched_ctrl->cce_index = 0; + + /* set "any" value for PUCCH (simulator evaluates PDSCH only) */ + sched_ctrl->pucch_sched_idx = 0; + sched_ctrl->pucch_occ_idx = 0; + + sched_ctrl->rbStart = g_rbStart; + sched_ctrl->rbSize = g_rbSize; + sched_ctrl->mcs = g_mcsIndex; + sched_ctrl->time_domain_allocation = 2; + sched_ctrl->mcsTableIdx = 0; + AssertFatal(sched_ctrl->rbStart >= 0, "invalid rbStart %d\n", sched_ctrl->rbStart); + AssertFatal(sched_ctrl->rbSize > 0, "invalid rbSize %d\n", sched_ctrl->rbSize); + AssertFatal(sched_ctrl->mcs >= 0, "invalid sched_ctrl->mcs %d\n", sched_ctrl->mcs); + sched_ctrl->numDmrsCdmGrpsNoData = 1; +} int main(int argc, char **argv) @@ -197,8 +233,6 @@ int main(int argc, char **argv) //double pbch_sinr; //int pbch_tx_ant; int N_RB_DL=106,mu=1; - nfapi_nr_dl_tti_pdsch_pdu_rel15_t dlsch_config; - NR_sched_pucch pucch_sched; //unsigned char frame_type = 0; @@ -227,7 +261,6 @@ int main(int argc, char **argv) randominit(0); - int mcsIndex_set=0,rbStart_set=0,rbSize_set=0; int print_perf = 0; FILE *scg_fd=NULL; @@ -393,18 +426,15 @@ int main(int argc, char **argv) case 'a': - dlsch_config.rbStart = atoi(optarg); - rbStart_set=1; + g_rbStart = atoi(optarg); break; case 'b': - dlsch_config.rbSize = atoi(optarg); - rbSize_set=1; + g_rbSize = atoi(optarg); break; case 'e': - dlsch_config.mcsIndex[0] = atoi(optarg); - mcsIndex_set=1; + g_mcsIndex = atoi(optarg); break; case 'm': @@ -483,6 +513,7 @@ int main(int argc, char **argv) RC.nb_nr_mac_CC[i] = 1; mac_top_init_gNB(); gNB_mac = RC.nrmac[0]; + gNB_mac->pre_processor_dl = nr_dlsim_preprocessor; gNB_RRC_INST rrc; memset((void*)&rrc,0,sizeof(rrc)); @@ -560,6 +591,12 @@ int main(int argc, char **argv) // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); // call MAC to configure common parameters + /* rrc_mac_config_req_gNB() has created one user, so set the scheduling + * parameters from command line in global variables that will be picked up by + * scheduling preprocessor */ + if (g_mcsIndex < 0) g_mcsIndex = 9; + if (g_rbStart < 0) g_rbStart=0; + if (g_rbSize < 0) g_rbSize = N_RB_DL - g_rbStart; double fs,bw; @@ -687,11 +724,6 @@ int main(int argc, char **argv) AssertFatal(input_fd==NULL,"Not ready for input signal file\n"); gNB->pbch_configured = 1; gNB->ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234; - - if (mcsIndex_set==0) dlsch_config.mcsIndex[0]=9; - - if (rbStart_set==0) dlsch_config.rbStart=0; - if (rbSize_set==0) dlsch_config.rbSize=N_RB_DL-dlsch_config.rbStart; //Configure UE rrc.carrier.MIB = (uint8_t*) malloc(4); @@ -788,8 +820,14 @@ int main(int argc, char **argv) for (int i=0; iUE_info.num_pdcch_cand[0][i] = 0; - if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot,&pucch_sched,&dlsch_config); - else nr_schedule_css_dlsch_phytest(0,frame,slot); + if (css_flag == 0) { + const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160}; + const NR_TDD_UL_DL_Pattern_t *tdd_pattern = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int num_slots_per_tdd = slots_per_frame[*scc->ssbSubcarrierSpacing] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity); + nr_schedule_ue_spec(0, frame, slot, num_slots_per_tdd); + } else { + nr_schedule_css_dlsch_phytest(0,frame,slot); + } Sched_INFO.module_id = 0; Sched_INFO.CC_id = 0; Sched_INFO.frame = frame; @@ -986,7 +1024,7 @@ int main(int argc, char **argv) if (print_perf==1) { printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d, Kr %d (Zc %d))\n", - 1000>>*scc->ssbSubcarrierSpacing,dlsch_config.rbSize,dlsch_config.mcsIndex[0], + 1000>>*scc->ssbSubcarrierSpacing, g_rbSize, g_mcsIndex, gNB->dlsch[0][0]->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3, gNB->dlsch[0][0]->harq_processes[0]->K, gNB->dlsch[0][0]->harq_processes[0]->K/((gNB->dlsch[0][0]->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10)); From 8651b7fd143d1b7e194bb514b4e42bcf95414dd1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Oct 2020 14:08:58 +0200 Subject: [PATCH 109/149] Remove commented/unused code in DLSCH/phytest scheduler --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 3 - .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 5 - .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 460 ------------------ .../NR_MAC_gNB/gNB_scheduler_primitives.c | 12 - openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 21 - 5 files changed, 501 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 083692e0e3..c89bbc8b67 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -483,9 +483,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, && (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot % num_slots_per_tdd)) && slot < 10) { ue_sched_ctl->current_harq_pid = slot % num_slots_per_tdd; - //int pucch_sched; - //nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched); - //nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_info->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); nr_schedule_ue_spec(module_idP, frame, slot, num_slots_per_tdd); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 30bd41bb58..cc5134677c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -785,8 +785,6 @@ void nr_schedule_ue_spec(module_id_t module_id, header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); header_length_total += header_length_last; num_sdus++; - - //ue_sched_ctl->uplane_inactivity_timer = 0; } else if (get_softmodem_params()->phy_test) { LOG_D(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); @@ -803,10 +801,7 @@ void nr_schedule_ue_spec(module_id_t module_id, UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += sdu_length_total; - // Check if there is data from RLC or CE const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len; - // padding param currently not in use - //padding = TBS - header_length_total - sdu_length_total - ta_len - 1; const int ntx_req = gNB_mac->TX_req[CC_id].Number_of_PDUs; nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[ntx_req]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 858245c096..665c12e691 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -352,241 +352,6 @@ void nr_preprocessor_phytest(module_id_t module_id, vrb_map[rb + sched_ctrl->rbStart] = 1; } -int configure_fapi_dl_pdu_phytest(int Mod_idP, - nfapi_nr_dl_tti_request_body_t *dl_req, - NR_sched_pucch *pucch_sched, - uint8_t *mcsIndex, - uint16_t *rbSize, - uint16_t *rbStart) { - gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; - NR_COMMON_channels_t *cc = nr_mac->common_channels; - NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu; - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu; - - int TBS; - int bwp_id=1; - int UE_id = 0; - - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - - NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; - AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", - secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; - - AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); - AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, - "searchPsacesToAddModList is empty\n"); - - dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; - memset((void*)dl_tti_pdcch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); - dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE; - dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); - - dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1]; - memset((void*)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); - dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE; - dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu)); - - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; - - - pdsch_pdu_rel15->pduBitmap = 0; - pdsch_pdu_rel15->rnti = UE_info->rnti[UE_id]; - pdsch_pdu_rel15->pduIndex = 0; - - // BWP - pdsch_pdu_rel15->BWPSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); - pdsch_pdu_rel15->BWPStart = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); - pdsch_pdu_rel15->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing; - if (bwp->bwp_Common->genericParameters.cyclicPrefix) pdsch_pdu_rel15->CyclicPrefix = *bwp->bwp_Common->genericParameters.cyclicPrefix; - else pdsch_pdu_rel15->CyclicPrefix=0; - - pdsch_pdu_rel15->NrOfCodewords = 1; - int mcs = (mcsIndex!=NULL) ? *mcsIndex : 9; - int current_harq_pid = UE_info->UE_sched_ctrl[UE_id].current_harq_pid; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0); - pdsch_pdu_rel15->qamModOrder[0] = 2; - pdsch_pdu_rel15->mcsIndex[0] = mcs; - pdsch_pdu_rel15->mcsTable[0] = 0; - pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]; - pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; - pdsch_pdu_rel15->nrOfLayers = 1; - pdsch_pdu_rel15->transmissionScheme = 0; - pdsch_pdu_rel15->refPoint = 0; // Point A - UE_info->mac_stats[UE_id].dlsch_rounds[UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++; - pdsch_pdu_rel15->dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; - pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; - pdsch_pdu_rel15->SCID = 0; - pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 1; - pdsch_pdu_rel15->dmrsPorts = 1; - pdsch_pdu_rel15->resourceAlloc = 1; - pdsch_pdu_rel15->rbStart = (rbStart!=NULL) ? *rbStart : 0; - pdsch_pdu_rel15->rbSize = (rbSize!=NULL) ? *rbSize : pdsch_pdu_rel15->BWPSize; - pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP - - int startSymbolAndLength=0; - int time_domain_assignment=2; - int StartSymbolIndex,NrOfSymbols; - - AssertFatal(time_domain_assignmentbwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count); - startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength,&StartSymbolIndex,&NrOfSymbols); - pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; - pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; - - // k0 = *bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; - pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(bwp->bwp_Dedicated->pdsch_Config->choice.setup, - scc->dmrs_TypeA_Position, - pdsch_pdu_rel15->NrOfSymbols); - - dci_pdu_rel15_t *dci_pdu_rel15 = calloc(MAX_DCI_CORESET,sizeof(dci_pdu_rel15_t)); - - // bwp indicator - int n_dl_bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; - if (n_dl_bwp < 4) - dci_pdu_rel15[0].bwp_indicator.val = bwp_id; - else - dci_pdu_rel15[0].bwp_indicator.val = bwp_id - 1; // as per table 7.3.1.1.2-1 in 38.212 - // frequency domain assignment - if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation==NR_PDSCH_Config__resourceAllocation_resourceAllocationType1) - dci_pdu_rel15[0].frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize, - pdsch_pdu_rel15->rbStart, - NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275)); - else - AssertFatal(1==0,"Only frequency resource allocation type 1 is currently supported\n"); - // time domain assignment - dci_pdu_rel15[0].time_domain_assignment.val = time_domain_assignment; // row index used here instead of SLIV; - // mcs and rv - dci_pdu_rel15[0].mcs = pdsch_pdu_rel15->mcsIndex[0]; - dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0]; - // harq pid and ndi - dci_pdu_rel15[0].harq_pid = current_harq_pid; - dci_pdu_rel15[0].ndi = UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi; - // DAI - dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3; - // TPC for PUCCH - dci_pdu_rel15[0].tpc = UE_info->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213 - // PUCCH resource indicator - dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator; - // PDSCH to HARQ TI - dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator.val = pucch_sched->timing_indicator; - UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].feedback_slot = pucch_sched->ul_slot; - UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].is_waiting = 1; - // antenna ports - dci_pdu_rel15[0].antenna_ports.val = 0; // nb of cdm groups w/o data 1 and dmrs port 0 - // dmrs sequence initialization - dci_pdu_rel15[0].dmrs_sequence_initialization.val = pdsch_pdu_rel15->SCID; - LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", - dci_pdu_rel15[0].frequency_domain_assignment.val, - pdsch_pdu_rel15->rbStart, - pdsch_pdu_rel15->rbSize, - NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275), - dci_pdu_rel15[0].time_domain_assignment.val, - dci_pdu_rel15[0].vrb_to_prb_mapping.val, - dci_pdu_rel15[0].mcs, - dci_pdu_rel15[0].tb_scaling, - dci_pdu_rel15[0].ndi, - dci_pdu_rel15[0].rv); - - NR_SearchSpace_t *ss; - int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - - AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); - AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, - "searchPsacesToAddModList is empty\n"); - - int found=0; - - for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { - ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; - AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); - AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); - if (ss->searchSpaceType->present == target_ss) { - found=1; - break; - } - } - AssertFatal(found==1,"Couldn't find an adequate searchspace\n"); - - uint8_t nr_of_candidates, aggregation_level; - find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); - NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 1 /* dedicated */); - const int cid = coreset->controlResourceSetId; - const uint16_t Y = UE_info->Y[UE_id][cid][nr_mac->current_slot]; - const int m = UE_info->num_pdcch_cand[UE_id][cid]; - int CCEIndex = allocate_nr_CCEs(nr_mac, - bwp, - coreset, - aggregation_level, - Y, - m, - nr_of_candidates); - if (CCEIndex < 0) { - LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PDSCH\n", __func__); - free(dci_pdu_rel15); - return 0; - } - UE_info->num_pdcch_cand[UE_id][cid]++; - - nr_configure_pdcch(nr_mac, - pdcch_pdu_rel15, - UE_info->rnti[UE_id], - ss, - coreset, - scc, - bwp, - aggregation_level, - CCEIndex); - - int dci_formats[2]; - int rnti_types[2]; - - if (ss->searchSpaceType->choice.ue_Specific->dci_Formats) - dci_formats[0] = NR_DL_DCI_FORMAT_1_1; - else - dci_formats[0] = NR_DL_DCI_FORMAT_1_0; - - rnti_types[0] = NR_RNTI_C; - - fill_dci_pdu_rel15(scc,secondaryCellGroup,pdcch_pdu_rel15,dci_pdu_rel15,dci_formats,rnti_types,pdsch_pdu_rel15->BWPSize,bwp_id); - - LOG_D(MAC, "DCI params: rnti %x, rnti_type %d, dci_format %d\n \ - coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n", - pdcch_pdu_rel15->dci_pdu.RNTI[0], - rnti_types[0], - dci_formats[0], - (unsigned long long)pdcch_pdu_rel15->FreqDomainResource, - pdcch_pdu_rel15->StartSymbolIndex, - pdcch_pdu_rel15->DurationSymbols); - - int x_Overhead = 0; // should be 0 for initialBWP - nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu,x_Overhead,pdsch_pdu_rel15->numDmrsCdmGrpsNoData,0); - - // Hardcode it for now - TBS = dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]; - if (UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0) - UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; - - LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d startSymbolAndLength %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS: %d\n", - pdsch_pdu_rel15->rbStart, - pdsch_pdu_rel15->rbSize, - startSymbolAndLength, - pdsch_pdu_rel15->StartSymbolIndex, - pdsch_pdu_rel15->NrOfSymbols, - pdsch_pdu_rel15->nrOfLayers, - pdsch_pdu_rel15->NrOfCodewords, - pdsch_pdu_rel15->mcsIndex[0], - TBS); - - free(dci_pdu_rel15); - return TBS; //Return TBS in bytes -} - void config_uldci(NR_BWP_Uplink_t *ubwp, nfapi_nr_pusch_pdu_t *pusch_pdu, nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, @@ -663,231 +428,6 @@ void config_uldci(NR_BWP_Uplink_t *ubwp, } - -void configure_fapi_dl_Tx(module_id_t Mod_idP, - frame_t frameP, - sub_frame_t slotP, - nfapi_nr_dl_tti_request_body_t *dl_req, - nfapi_nr_pdu_t *tx_req, - int tbs_bytes, - int16_t pdu_index){ - - int CC_id = 0; - - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1]; - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; - gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; - - LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS (bytes): %d\n", - pdsch_pdu_rel15->rbStart, - pdsch_pdu_rel15->rbSize, - pdsch_pdu_rel15->StartSymbolIndex, - pdsch_pdu_rel15->NrOfSymbols, - pdsch_pdu_rel15->nrOfLayers, - pdsch_pdu_rel15->NrOfCodewords, - pdsch_pdu_rel15->mcsIndex[0], - tbs_bytes); - - dl_req->nPDUs+=2; - - tx_req->PDU_length = pdsch_pdu_rel15->TBSize[0]; - tx_req->PDU_index = nr_mac->pdu_index[0]++; - tx_req->num_TLV = 1; - tx_req->TLVs[0].length = tbs_bytes +2; - - memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&nr_mac->UE_info.DLSCH_pdu[0][0].payload[0], tbs_bytes); - - nr_mac->TX_req[CC_id].Number_of_PDUs++; - nr_mac->TX_req[CC_id].SFN = frameP; - nr_mac->TX_req[CC_id].Slot = slotP; -} - -void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, - frame_t frameP, - sub_frame_t slotP, - NR_sched_pucch *pucch_sched, - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *dlsch_config){ - - LOG_D(MAC, "In nr_schedule_uss_dlsch_phytest frame %d slot %d\n",frameP,slotP); - - int post_padding = 0, header_length_total = 0, sdu_length_total = 0, num_sdus = 0; - int lcid, offset, i, header_length_last, TBS_bytes = 0; - int UE_id = 0, CC_id = 0; - - gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP]; - //NR_COMMON_channels_t *cc = nr_mac->common_channels; - //NR_ServingCellConfigCommon_t *scc=cc->ServingCellConfigCommon; - nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; - - mac_rlc_status_resp_t rlc_status; - - NR_UE_info_t *UE_info = &gNB_mac->UE_info; - - if (UE_info->num_UEs ==0) return; - - unsigned char sdu_lcids[NB_RB_MAX] = {0}; - uint16_t sdu_lengths[NB_RB_MAX] = {0}; - uint16_t rnti = UE_info->rnti[UE_id]; - NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_info->UE_sched_ctrl[UE_id]; - - uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; - - LOG_D(MAC, "Scheduling UE specific search space DCI type 1\n"); - - int ta_len = (ue_sched_ctl->ta_apply)?2:0; - - TBS_bytes = configure_fapi_dl_pdu_phytest( - module_idP, - dl_req, - pucch_sched, - dlsch_config != NULL ? dlsch_config->mcsIndex : NULL, - dlsch_config != NULL ? &dlsch_config->rbSize : NULL, - dlsch_config != NULL ? &dlsch_config->rbStart : NULL); - - if (TBS_bytes == 0) - return; - - lcid = DL_SCH_LCID_DTCH; - - //for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { - - // TODO: check if the lcid is active - - LOG_D(MAC, "[gNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (TBS %d bytes, len %d)\n", - module_idP, frameP, lcid, TBS_bytes, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3); - - //if (TBS_bytes - ta_len - header_length_total - sdu_length_total - 3 > 0) { - rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - slotP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - 0, - 0); - - if (rlc_status.bytes_in_buffer > 0) { - - LOG_I(MAC, "configure fapi due to data availability \n"); - - LOG_I(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS_bytes: %d \n \n", - module_idP, frameP, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3, - lcid, header_length_total, TBS_bytes); - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS_bytes - ta_len - header_length_total - sdu_length_total - 3, - (char *)&mac_sdus[sdu_length_total], - 0, - 0); - - LOG_W(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", module_idP, sdu_lengths[num_sdus], lcid); - - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); - header_length_total += header_length_last; - - num_sdus++; - - //ue_sched_ctl->uplane_inactivity_timer = 0; - } - - else { - - LOG_D(MAC,"Configuring DL_TX in %d.%d\n", frameP, slotP); - - // fill dlsch_buffer with random data - for (i = 0; i < TBS_bytes; i++){ - mac_sdus[i] = (unsigned char) (lrand48()&0xff); - //((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) (lrand48()&0xff); - } - //Sending SDUs with size 1 - //Initialize elements of sdu_lcids and sdu_lengths - sdu_lcids[0] = 0x3f; // DRB - sdu_lengths[0] = TBS_bytes - ta_len - 3; - header_length_total += 2 + (sdu_lengths[0] >= 128); - sdu_length_total += sdu_lengths[0]; - num_sdus +=1; - - #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - if (frameP%100 == 0){ - LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes); - for(int i = 0; i < 10; i++) { - LOG_I(MAC, "%x. ", ((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[CC_id][0][0].payload[0])[i]); - } - } - #endif - - } - - UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += sdu_length_total; - - // there is at least one SDU or TA command - // if (num_sdus > 0 ){ - if (ta_len + sdu_length_total + header_length_total > 0) { - - // Check if there is data from RLC or CE - if (TBS_bytes >= 2 + header_length_total + sdu_length_total + ta_len) { - // we have to consider padding - // padding param currently not in use - //padding = TBS_bytes - header_length_total - sdu_length_total - ta_len - 1; - post_padding = 1; - } else { - //padding = 0; - post_padding = 0; - } - - offset = nr_generate_dlsch_pdu(module_idP, - &UE_info->UE_sched_ctrl[UE_id], - (unsigned char *) mac_sdus, - (unsigned char *) gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], - num_sdus, //num_sdus - sdu_lengths, - sdu_lcids, - 255, // no drx - NULL, // contention res id - post_padding); - - // Padding: fill remainder of DLSCH with 0 - if (post_padding > 0){ - for (int j = 0; j < (TBS_bytes - offset); j++) - gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; // mac_pdu[offset + j] = 0; - } - - configure_fapi_dl_Tx(module_idP, frameP, slotP, dl_req, tx_req, TBS_bytes, gNB_mac->pdu_index[CC_id]); - - if(IS_SOFTMODEM_NOS1){ - #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n \n", frameP, slotP, TBS_bytes); - for(int i = 0; i < 10; i++) { // TBS_bytes dlsch_pdu_rel15->transport_block_size/8 6784/8 - LOG_I(MAC, "%x. ", mac_payload[i]); - } - #endif - } else { -#if defined(ENABLE_MAC_PAYLOAD_DEBUG) - if (frameP%100 == 0){ - LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes); - for(int i = 0; i < 10; i++) { - LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); //LOG_I(MAC, "%x. ", mac_payload[i]); - } - } -#endif - } - } - else { // There is no data from RLC or MAC header, so don't schedule - } - -} - int8_t select_ul_harq_pid(NR_UE_sched_ctrl_t *sched_ctrl) { uint8_t hrq_id; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 86c16d76de..6553a3572c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -525,7 +525,6 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; - // k0 = *bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(bwp->bwp_Dedicated->pdsch_Config->choice.setup, scc->dmrs_TypeA_Position, @@ -618,17 +617,6 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, pdcch_pdu_rel15->StartSymbolIndex, pdcch_pdu_rel15->DurationSymbols); - // I don't know why the following is not needed, but in this case we don't - // need additional calculations: - //const uint16_t N_RE_prime = NR_NB_SC_PER_RB * N_sh_symb - N_PRB_DMRS - N_PRB_oh; - //LOG_D(MAC, - // "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", - // N_RE_prime, - // N_sh_symb, - // N_PRB_DMRS, - // N_PRB_oh); - //pdsch_pdu_rel15->nb_mod_symbols = N_RE_prime*pdsch_pdu_rel15->n_prb*pdsch_pdu_rel15->nb_codewords; - LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d " "nb_layers %d nb_codewords %d mcs %d TBS: %d\n", diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 86d97b2ce5..1f6adea0aa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -167,13 +167,6 @@ void nr_fill_nfapi_dl_pdu(int Mod_id, int ndi, int round); -int configure_fapi_dl_pdu_phytest(int Mod_id, - nfapi_nr_dl_tti_request_body_t *dl_req, - NR_sched_pucch *pucch_sched, - uint8_t *mcsIndex, - uint16_t *rbSize, - uint16_t *rbStart); - void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch, nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_01, nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234, @@ -187,20 +180,6 @@ void config_uldci(NR_BWP_Uplink_t *ubwp, int time_domain_assignment, uint8_t tpc, int n_ubwp, int bwp_id); -void configure_fapi_dl_Tx(module_id_t Mod_idP, - frame_t frameP, - sub_frame_t slotP, - nfapi_nr_dl_tti_request_body_t *dl_req, - nfapi_nr_pdu_t *tx_req, - int tbs_bytes, - int16_t pdu_index); - -void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, - frame_t frameP, - sub_frame_t slotP, - NR_sched_pucch *pucch_sched, - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_config); - void nr_schedule_pusch(int Mod_idP, int UE_id, int num_slots_per_tdd, From 9125fc8d22e3be3d1bef781cbb1a6cab7d6065fe Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 15 Oct 2020 12:13:31 +0200 Subject: [PATCH 110/149] Refactor/shorten interface of nr_fill_nfapi_dl_pdu() --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 16 ++---- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 49 ++++++++----------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 16 ++---- 3 files changed, 26 insertions(+), 55 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index cc5134677c..084d35fe05 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -685,27 +685,17 @@ void nr_schedule_ue_spec(module_id_t module_id, nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; nr_fill_nfapi_dl_pdu(module_id, - UE_id, - sched_ctrl->active_bwp->bwp_Id, - sched_ctrl->search_space, - sched_ctrl->coreset, dl_req, + rnti, + UE_info->secondaryCellGroup[UE_id], + sched_ctrl, pucch, - 1 /* nrOfLayers */, - sched_ctrl->mcs, - sched_ctrl->rbSize, - sched_ctrl->rbStart, - sched_ctrl->numDmrsCdmGrpsNoData, getDmrsConfigType(sched_ctrl->active_bwp), - sched_ctrl->mcsTableIdx, nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), TBS, - sched_ctrl->time_domain_allocation, startSymbolIndex, nrOfSymbols, - sched_ctrl->aggregation_level, - sched_ctrl->cce_index, current_harq_pid, harq->ndi, harq->round); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 6553a3572c..a743b7078b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -432,27 +432,17 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } void nr_fill_nfapi_dl_pdu(int Mod_idP, - int UE_id, - int bwp_id, - NR_SearchSpace_t *ss, - NR_ControlResourceSet_t *coreset, nfapi_nr_dl_tti_request_body_t *dl_req, + rnti_t rnti, + NR_CellGroupConfig_t *secondaryCellGroup, + NR_UE_sched_ctrl_t *sched_ctrl, NR_sched_pucch *pucch_sched, - int nrOfLayers, - uint8_t mcs, - uint16_t rbSize, - uint16_t rbStart, - uint8_t numDmrsCdmGrpsNoData, nfapi_nr_dmrs_type_e dmrsConfigType, - uint8_t table_idx, uint16_t R, uint8_t Qm, uint32_t TBS, - int time_domain_assignment, int StartSymbolIndex, int NrOfSymbols, - uint8_t aggregation_level, - int CCEIndex, int harq_pid, int ndi, int round) { @@ -460,9 +450,10 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; + const int bwp_id = sched_ctrl->active_bwp->bwp_Id; + const int nrOfLayers = 1; + const int mcs = sched_ctrl->mcs; - NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); @@ -487,7 +478,7 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->pduBitmap = 0; - pdsch_pdu_rel15->rnti = UE_info->rnti[UE_id]; + pdsch_pdu_rel15->rnti = rnti; pdsch_pdu_rel15->pduIndex = nr_mac->pdu_index[0]++; // BWP @@ -512,16 +503,16 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->dmrsConfigType = dmrsConfigType; pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; pdsch_pdu_rel15->SCID = 0; - pdsch_pdu_rel15->numDmrsCdmGrpsNoData = numDmrsCdmGrpsNoData; + pdsch_pdu_rel15->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData; pdsch_pdu_rel15->dmrsPorts = 1; pdsch_pdu_rel15->resourceAlloc = 1; - pdsch_pdu_rel15->rbStart = rbStart; - pdsch_pdu_rel15->rbSize = rbSize; + pdsch_pdu_rel15->rbStart = sched_ctrl->rbStart; + pdsch_pdu_rel15->rbSize = sched_ctrl->rbSize; pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP pdsch_pdu_rel15->targetCodeRate[0] = R; pdsch_pdu_rel15->qamModOrder[0] = Qm; pdsch_pdu_rel15->TBSize[0] = TBS; - pdsch_pdu_rel15->mcsTable[0] = table_idx; + pdsch_pdu_rel15->mcsTable[0] = sched_ctrl->mcsTableIdx; pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; @@ -549,8 +540,8 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, 275)); else AssertFatal(1==0,"Only frequency resource allocation type 1 is currently supported\n"); - // time domain assignment - dci_pdu_rel15[0].time_domain_assignment.val = time_domain_assignment; // row index used here instead of SLIV; + // time domain assignment: row index used instead of SLIV + dci_pdu_rel15[0].time_domain_assignment.val = sched_ctrl->time_domain_allocation; // mcs and rv dci_pdu_rel15[0].mcs = mcs; dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0]; @@ -561,7 +552,7 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3; // TPC for PUCCH - dci_pdu_rel15[0].tpc = UE_info->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213 + dci_pdu_rel15[0].tpc = sched_ctrl->tpc1; // table 7.2.1-1 in 38.213 // PUCCH resource indicator dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator; // PDSCH to HARQ TI @@ -586,18 +577,18 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, - UE_info->rnti[UE_id], - ss, - coreset, + rnti, + sched_ctrl->search_space, + sched_ctrl->coreset, scc, bwp, - aggregation_level, - CCEIndex); + sched_ctrl->aggregation_level, + sched_ctrl->cce_index); int dci_formats[2]; int rnti_types[2]; - if (ss->searchSpaceType->choice.ue_Specific->dci_Formats) + if (sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats) dci_formats[0] = NR_DL_DCI_FORMAT_1_1; else dci_formats[0] = NR_DL_DCI_FORMAT_1_0; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 1f6adea0aa..fdc63f91db 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -142,27 +142,17 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, sub_frame_t subframeP); void nr_fill_nfapi_dl_pdu(int Mod_id, - int UE_id, - int bwp_id, - NR_SearchSpace_t *ss, - NR_ControlResourceSet_t *coreset, nfapi_nr_dl_tti_request_body_t *dl_req, + rnti_t rnti, + NR_CellGroupConfig_t *secondaryCellGroup, + NR_UE_sched_ctrl_t *sched_ctrl, NR_sched_pucch *pucch_sched, - int nrOfLayers, - uint8_t mcs, - uint16_t rbSize, - uint16_t rbStart, - uint8_t numDmrsCdmGrpsNoData, nfapi_nr_dmrs_type_e dmrsConfigType, - uint8_t table_idx, uint16_t R, uint8_t Qm, uint32_t tbs, - int time_domain_assignment, int StartSymbolIndex, int NrOfSymbols, - uint8_t aggregation_level, - int CCEIndex, int harq_pid, int ndi, int round); From a94da10deece46aaafa32aae2eac820a650dc687 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 15 Oct 2020 15:57:23 +0200 Subject: [PATCH 111/149] Remove UE from UE_list on disconnect --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index a743b7078b..41fafd268b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1685,6 +1685,21 @@ inline void add_nr_ue_list(NR_UE_list_t *listP, int UE_id) { *cur = UE_id; } +/* + * Remove a UE from NR_UE_list listP + */ +inline int remove_nr_ue_list(NR_UE_list_t *listP, int UE_id) { + int *cur = &listP->head; + while (*cur != -1 && *cur != UE_id) + cur = &listP->next[*cur]; + if (*cur == -1) + return 0; + int *next = &listP->next[*cur]; + *cur = listP->next[*cur]; + *next = -1; + return 1; +} + int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) //------------------------------------------------------------------------------ { @@ -1819,6 +1834,7 @@ void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti) UE_info->num_UEs--; UE_info->active[UE_id] = FALSE; UE_info->rnti[UE_id] = 0; + remove_nr_ue_list(&UE_info->list, UE_id); free(UE_info->UE_sched_ctrl[UE_id].sched_pucch); free(UE_info->UE_sched_ctrl[UE_id].sched_pusch); memset((void *) &UE_info->UE_sched_ctrl[UE_id], From 2bdcbe6c18a0f1f33b7ff1c75920256245f400ee Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 23 Oct 2020 15:38:31 +0200 Subject: [PATCH 112/149] Fix for filling vrb_map for ssb The SSB nFAPI message is only sent every 8 frames, and automatically repeated by the PHY layer in between. This commit sets the vrb_map structure in those frames in between nFAPI so that the scheduler does not schedule on such resources. --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 4 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 204 +++++++++++------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 4 +- 3 files changed, 127 insertions(+), 85 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index c89bbc8b67..bdab2c00fa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -447,9 +447,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if ((slot == 0) && (frame & 127) == 0) dump_mac_stats(RC.nrmac[module_idP]); // This schedules MIB - if((slot == 0) && (frame & 7) == 0){ - schedule_nr_mib(module_idP, frame, slot); - } + schedule_nr_mib(module_idP, frame, slot, slots_per_frame[*scc->ssbSubcarrierSpacing]); // This schedule PRACH if we are not in phy_test mode if (get_softmodem_params()->phy_test == 0) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index daa1fd9c82..3ef0cdd8b0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -56,7 +56,7 @@ extern RAN_CONTEXT_t RC; extern uint8_t SSB_Table[38]; -void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ +void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, uint8_t slots_per_frame){ gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc; @@ -67,93 +67,135 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ int mib_sdu_length; int CC_id; - AssertFatal(slotP == 0, "Subframe must be 0\n"); - AssertFatal((frameP & 7) == 0, "Frame must be a multiple of 8\n"); for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - - nfapi_nr_config_request_scf_t *cfg = &RC.nrmac[module_idP]->config[0]; - dl_tti_request = &gNB->DL_req[CC_id]; - dl_req = &dl_tti_request->dl_tti_request_body; cc = &gNB->common_channels[CC_id]; -#if 0 - //SSB is transmitted based on SSB periodicity - if((frameP % cfg->ssb_table.ssb_period.value) == 0) { - uint64_t L_ssb = (((uint64_t) cfg->ssb_table.ssb_mask_list[0].ssb_mask.value)<<32) | cfg->ssb_table.ssb_mask_list[1].ssb_mask.value ; - uint32_t ssb_index = -1; - for (int i=0; i<2; i++) { // max two SSB per slot - ssb_index = i + SSB_Table[slotP]; // computing the ssb_index - if ((ssb_index<64) && ((L_ssb >> (63-ssb_index)) & 0x01)) { // generating the ssb only if the bit of L_ssb at current ssb index is 1 -#endif - - mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]); // not used in this case - - LOG_D(MAC, "Frame %d, slot %d: BCH PDU length %d\n", frameP, slotP, mib_sdu_length); - - if (mib_sdu_length > 0) { - - LOG_D(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length); - - if ((frameP & 1023) < 80){ - LOG_I(MAC,"[gNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes\n",module_idP, frameP, CC_id, mib_sdu_length); - } - - dl_config_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; - memset((void *) dl_config_pdu, 0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); - dl_config_pdu->PDUType = NFAPI_NR_DL_TTI_SSB_PDU_TYPE; - dl_config_pdu->PDUSize =2 + sizeof(nfapi_nr_dl_tti_ssb_pdu_rel15_t); - - AssertFatal(cc->ServingCellConfigCommon->physCellId!=NULL,"cc->ServingCellConfigCommon->physCellId is null\n"); - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.PhysCellId = *cc->ServingCellConfigCommon->physCellId; - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.BetaPss = 0; - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = 0;//ssb_index ;//SSB index for each SSB - AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon!=NULL,"scc->downlinkConfigCommonL is null\n"); - AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL!=NULL,"scc->downlinkConfigCommon->frequencyInfoDL is null\n"); - AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB!=NULL,"scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB is null\n"); - AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count==1,"Frequency Band list does not have 1 element (%d)\n",cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count); - AssertFatal(cc->ServingCellConfigCommon->ssbSubcarrierSpacing,"ssbSubcarrierSpacing is null\n"); - AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0],"band is null\n"); - long band = *cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - uint32_t ssb_offset0 = *cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA; - int ratio; - switch (*cc->ServingCellConfigCommon->ssbSubcarrierSpacing) { - case NR_SubcarrierSpacing_kHz15: - AssertFatal(band <= 79, "Band %ld is not possible for SSB with 15 kHz SCS\n",band); - if (band<77) // below 3GHz - ratio=3; // NRARFCN step is 5 kHz - else - ratio=1; // NRARFCN step is 15 kHz - break; - case NR_SubcarrierSpacing_kHz30: - AssertFatal(band <= 79, "Band %ld is not possible for SSB with 15 kHz SCS\n",band); - if (band<77) // below 3GHz - ratio=6; // NRARFCN step is 5 kHz - else - ratio=2; // NRARFCN step is 15 kHz - break; - case NR_SubcarrierSpacing_kHz120: - AssertFatal(band >= 257, "Band %ld is not possible for SSB with 120 kHz SCS\n",band); + const long band = *cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + const uint32_t ssb_offset0 = *cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA; + int ratio; + switch (*cc->ServingCellConfigCommon->ssbSubcarrierSpacing) { + case NR_SubcarrierSpacing_kHz15: + AssertFatal(band <= 79, "Band %ld is not possible for SSB with 15 kHz SCS\n",band); + if (band<77) // below 3GHz + ratio=3; // NRARFCN step is 5 kHz + else + ratio=1; // NRARFCN step is 15 kHz + break; + case NR_SubcarrierSpacing_kHz30: + AssertFatal(band <= 79, "Band %ld is not possible for SSB with 15 kHz SCS\n",band); + if (band<77) // below 3GHz + ratio=6; // NRARFCN step is 5 kHz + else ratio=2; // NRARFCN step is 15 kHz - break; - case NR_SubcarrierSpacing_kHz240: - AssertFatal(band >= 257, "Band %ld is not possible for SSB with 240 kHz SCS\n",band); - ratio=4; // NRARFCN step is 15 kHz - break; - default: - AssertFatal(1==0,"SCS %ld not allowed for SSB \n", *cc->ServingCellConfigCommon->ssbSubcarrierSpacing); - } - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset = cfg->ssb_table.ssb_subcarrier_offset.value; //kSSB - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA = ssb_offset0/(ratio*12) - 10;/*cfg->ssb_table.ssb_offset_point_a.value;*/ // absoluteFrequencySSB is the center of SSB - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag = 1; - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload = (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1); - dl_req->nPDUs++; + break; + case NR_SubcarrierSpacing_kHz120: + AssertFatal(band >= 257, "Band %ld is not possible for SSB with 120 kHz SCS\n",band); + ratio=2; // NRARFCN step is 15 kHz + break; + case NR_SubcarrierSpacing_kHz240: + AssertFatal(band >= 257, "Band %ld is not possible for SSB with 240 kHz SCS\n",band); + ratio=4; // NRARFCN step is 15 kHz + break; + default: + AssertFatal(1==0,"SCS %ld not allowed for SSB \n", *cc->ServingCellConfigCommon->ssbSubcarrierSpacing); + } - uint8_t *vrb_map = cc[CC_id].vrb_map; - const int rbStart = dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA; - for (int rb = 0; rb < 20; rb++) - vrb_map[rbStart + rb] = 1; + // scheduling MIB every 8 frames, PHY repeats it in between + if((slotP == 0) && (frameP & 7) == 0) { + dl_tti_request = &gNB->DL_req[CC_id]; + dl_req = &dl_tti_request->dl_tti_request_body; + + mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]); // not used in this case + + LOG_D(MAC, "Frame %d, slot %d: BCH PDU length %d\n", frameP, slotP, mib_sdu_length); + + if (mib_sdu_length > 0) { + + LOG_D(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length); + + if ((frameP & 1023) < 80){ + LOG_I(MAC,"[gNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes\n",module_idP, frameP, CC_id, mib_sdu_length); + } + + dl_config_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; + memset((void *) dl_config_pdu, 0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); + dl_config_pdu->PDUType = NFAPI_NR_DL_TTI_SSB_PDU_TYPE; + dl_config_pdu->PDUSize =2 + sizeof(nfapi_nr_dl_tti_ssb_pdu_rel15_t); + + AssertFatal(cc->ServingCellConfigCommon->physCellId!=NULL,"cc->ServingCellConfigCommon->physCellId is null\n"); + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.PhysCellId = *cc->ServingCellConfigCommon->physCellId; + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.BetaPss = 0; + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = 0; + AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon!=NULL,"scc->downlinkConfigCommonL is null\n"); + AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL!=NULL,"scc->downlinkConfigCommon->frequencyInfoDL is null\n"); + AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB!=NULL,"scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB is null\n"); + AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count==1,"Frequency Band list does not have 1 element (%d)\n",cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count); + AssertFatal(cc->ServingCellConfigCommon->ssbSubcarrierSpacing,"ssbSubcarrierSpacing is null\n"); + AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0],"band is null\n"); + + const nfapi_nr_config_request_scf_t *cfg = &RC.nrmac[module_idP]->config[0]; + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset = cfg->ssb_table.ssb_subcarrier_offset.value; //kSSB + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA = ssb_offset0/(ratio*12) - 10; // absoluteFrequencySSB is the center of SSB + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag = 1; + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload = (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1); + dl_req->nPDUs++; + } + } + + // checking if there is any SSB in slot + const int abs_slot = (slots_per_frame * frameP) + slotP; + const int slot_per_period = (slots_per_frame>>1)<<(*cc->ServingCellConfigCommon->ssb_periodicityServingCell); + int eff_120_slot; + switch (cc->ServingCellConfigCommon->ssb_PositionsInBurst->present) { + case 1 : + // presence of ssbs possible in the first 2 slots of ssb period + if ((abs_slot%slot_per_period)<2){ + if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])>>(6-(slotP<<1)))&3)!=0) + fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); + } + break; + case 2 : + // presence of ssbs possible in the first 4 slots of ssb period + if ((abs_slot%slot_per_period)<4){ + if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])>>(6-(slotP<<1)))&3)!=0) + fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); + } + break; + case 3 : + if(*cc->ServingCellConfigCommon->ssbSubcarrierSpacing == NR_SubcarrierSpacing_kHz120){ + if ((abs_slot%slot_per_period)<8){ + eff_120_slot = slotP; + if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])>>(6-(eff_120_slot<<1)))&3)!=0) + fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); + } + else if ((abs_slot%slot_per_period)<17){ + eff_120_slot = slotP-9; + if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[1])>>(6-(eff_120_slot<<1)))&3)!=0) + fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); + } + else if ((abs_slot%slot_per_period)<26){ + eff_120_slot = slotP-18; + if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[2])>>(6-(eff_120_slot<<1)))&3)!=0) + fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); + } + else if ((abs_slot%slot_per_period)<35){ + eff_120_slot = slotP-27; + if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[3])>>(6-(eff_120_slot<<1)))&3)!=0) + fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); + } + } + else + AssertFatal(1==0,"240kHZ subcarrier spacing currently not supported for SSBs\n"); + break; + default: + AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", cc->ServingCellConfigCommon->ssb_PositionsInBurst->present); } } } +void fill_ssb_vrb_map (NR_COMMON_channels_t *cc, int rbStart, int CC_id) { + uint8_t *vrb_map = cc[CC_id].vrb_map; + for (int rb = 0; rb < 20; rb++) + vrb_map[rbStart + rb] = 1; +} diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index fdc63f91db..079e745ebb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -86,7 +86,7 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, sub_frame_t slot, int num_slots_per_tdd); -void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); +void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, uint8_t slots_per_frame); /////// Random Access MAC-PHY interface functions and primitives /////// @@ -374,6 +374,8 @@ int binomial(int n, int k); bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot); +void fill_ssb_vrb_map (NR_COMMON_channels_t *cc, int rbStart, int CC_id); + /* \brief Function to indicate a received SDU on ULSCH. @param Mod_id Instance ID of gNB From 40175d244a86560cd0753cf8155b65d5fb63496e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 28 Oct 2020 13:36:24 +0100 Subject: [PATCH 113/149] Format schedule_nr_mib() --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 111 ++++++++++-------- 1 file changed, 60 insertions(+), 51 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 3ef0cdd8b0..b92777f57c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -75,29 +75,38 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, int ratio; switch (*cc->ServingCellConfigCommon->ssbSubcarrierSpacing) { case NR_SubcarrierSpacing_kHz15: - AssertFatal(band <= 79, "Band %ld is not possible for SSB with 15 kHz SCS\n",band); - if (band<77) // below 3GHz - ratio=3; // NRARFCN step is 5 kHz + AssertFatal(band <= 79, + "Band %ld is not possible for SSB with 15 kHz SCS\n", + band); + if (band < 77) // below 3GHz + ratio = 3; // NRARFCN step is 5 kHz else - ratio=1; // NRARFCN step is 15 kHz + ratio = 1; // NRARFCN step is 15 kHz break; case NR_SubcarrierSpacing_kHz30: - AssertFatal(band <= 79, "Band %ld is not possible for SSB with 15 kHz SCS\n",band); - if (band<77) // below 3GHz - ratio=6; // NRARFCN step is 5 kHz + AssertFatal(band <= 79, + "Band %ld is not possible for SSB with 15 kHz SCS\n", + band); + if (band < 77) // below 3GHz + ratio = 6; // NRARFCN step is 5 kHz else - ratio=2; // NRARFCN step is 15 kHz + ratio = 2; // NRARFCN step is 15 kHz break; case NR_SubcarrierSpacing_kHz120: - AssertFatal(band >= 257, "Band %ld is not possible for SSB with 120 kHz SCS\n",band); - ratio=2; // NRARFCN step is 15 kHz + AssertFatal(band >= 257, + "Band %ld is not possible for SSB with 120 kHz SCS\n", + band); + ratio = 2; // NRARFCN step is 15 kHz break; case NR_SubcarrierSpacing_kHz240: - AssertFatal(band >= 257, "Band %ld is not possible for SSB with 240 kHz SCS\n",band); - ratio=4; // NRARFCN step is 15 kHz + AssertFatal(band >= 257, + "Band %ld is not possible for SSB with 240 kHz SCS\n", + band); + ratio = 4; // NRARFCN step is 15 kHz break; default: - AssertFatal(1==0,"SCS %ld not allowed for SSB \n", *cc->ServingCellConfigCommon->ssbSubcarrierSpacing); + AssertFatal(1 == 0, "SCS %ld not allowed for SSB \n", + *cc->ServingCellConfigCommon->ssbSubcarrierSpacing); } // scheduling MIB every 8 frames, PHY repeats it in between @@ -105,13 +114,17 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, dl_tti_request = &gNB->DL_req[CC_id]; dl_req = &dl_tti_request->dl_tti_request_body; - mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]); // not used in this case + mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]); LOG_D(MAC, "Frame %d, slot %d: BCH PDU length %d\n", frameP, slotP, mib_sdu_length); if (mib_sdu_length > 0) { - - LOG_D(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length); + LOG_D(MAC, + "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", + frameP, + slotP, + dl_req->nPDUs, + mib_sdu_length); if ((frameP & 1023) < 80){ LOG_I(MAC,"[gNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes\n",module_idP, frameP, CC_id, mib_sdu_length); @@ -146,49 +159,45 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, const int abs_slot = (slots_per_frame * frameP) + slotP; const int slot_per_period = (slots_per_frame>>1)<<(*cc->ServingCellConfigCommon->ssb_periodicityServingCell); int eff_120_slot; + const BIT_STRING_t *mediumBitmap = &cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap; + uint8_t buf = 0; switch (cc->ServingCellConfigCommon->ssb_PositionsInBurst->present) { - case 1 : + case 1: // presence of ssbs possible in the first 2 slots of ssb period - if ((abs_slot%slot_per_period)<2){ - if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])>>(6-(slotP<<1)))&3)!=0) - fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); - } + if ((abs_slot % slot_per_period) < 2 && + (((mediumBitmap->buf[0]) >> (6 - (slotP << 1))) & 3) != 0) + fill_ssb_vrb_map(cc, (ssb_offset0 / (ratio * 12) - 10), CC_id); break; - case 2 : + case 2: // presence of ssbs possible in the first 4 slots of ssb period - if ((abs_slot%slot_per_period)<4){ - if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])>>(6-(slotP<<1)))&3)!=0) - fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); - } + if ((abs_slot % slot_per_period) < 4 && + (((mediumBitmap->buf[0]) >> (6 - (slotP << 1))) & 3) != 0) + fill_ssb_vrb_map(cc, (ssb_offset0 / (ratio * 12) - 10), CC_id); break; - case 3 : - if(*cc->ServingCellConfigCommon->ssbSubcarrierSpacing == NR_SubcarrierSpacing_kHz120){ - if ((abs_slot%slot_per_period)<8){ - eff_120_slot = slotP; - if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])>>(6-(eff_120_slot<<1)))&3)!=0) - fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); - } - else if ((abs_slot%slot_per_period)<17){ - eff_120_slot = slotP-9; - if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[1])>>(6-(eff_120_slot<<1)))&3)!=0) - fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); - } - else if ((abs_slot%slot_per_period)<26){ - eff_120_slot = slotP-18; - if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[2])>>(6-(eff_120_slot<<1)))&3)!=0) - fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); - } - else if ((abs_slot%slot_per_period)<35){ - eff_120_slot = slotP-27; - if((((cc->ServingCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[3])>>(6-(eff_120_slot<<1)))&3)!=0) - fill_ssb_vrb_map(cc, (ssb_offset0/(ratio*12) - 10), CC_id); - } + case 3: + AssertFatal(*cc->ServingCellConfigCommon->ssbSubcarrierSpacing == + NR_SubcarrierSpacing_kHz120, + "240kHZ subcarrier spacing currently not supported for SSBs\n"); + if ((abs_slot % slot_per_period) < 8) { + eff_120_slot = slotP; + buf = mediumBitmap->buf[0]; + } else if ((abs_slot % slot_per_period) < 17) { + eff_120_slot = slotP - 9; + buf = mediumBitmap->buf[1]; + } else if ((abs_slot % slot_per_period) < 26) { + eff_120_slot = slotP - 18; + buf = mediumBitmap->buf[2]; + } else if ((abs_slot % slot_per_period) < 35) { + eff_120_slot = slotP - 27; + buf = mediumBitmap->buf[3]; } - else - AssertFatal(1==0,"240kHZ subcarrier spacing currently not supported for SSBs\n"); + if (((buf >> (6 - (eff_120_slot << 1))) & 3) != 0) + fill_ssb_vrb_map(cc, ssb_offset0 / (ratio * 12) - 10, CC_id); break; default: - AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", cc->ServingCellConfigCommon->ssb_PositionsInBurst->present); + AssertFatal(0, + "SSB bitmap size value %d undefined (allowed values 1,2,3)\n", + cc->ServingCellConfigCommon->ssb_PositionsInBurst->present); } } } From d94b1cd1a5087665e7e450a354afd438fb9314b0 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 27 Oct 2020 14:42:59 +0100 Subject: [PATCH 114/149] Track RB allocation in vrb_map{,_UL} on per-symbol basis --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index bdab2c00fa..60fd296c57 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -438,8 +438,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, //mbsfn_status[CC_id] = 0; // clear vrb_maps - memset(cc[CC_id].vrb_map, 0, 275); - memset(cc[CC_id].vrb_map_UL, 0, 275); + memset(cc[CC_id].vrb_map, 0, sizeof(uint16_t) * 275); + memset(cc[CC_id].vrb_map_UL, 0, sizeof(uint16_t) * 275); clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 03e0ffa6fd..a84bcd7229 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -926,9 +926,9 @@ void nr_generate_Msg2(module_id_t module_idP, T_BUFFER(&cc[CC_id].RAR_pdu.payload[0], tx_req->TLVs[0].length)); /* mark the corresponding RBs as used */ - uint8_t *vrb_map = cc[CC_id].vrb_map; + uint16_t *vrb_map = cc[CC_id].vrb_map; for (int rb = 0; rb < pdsch_pdu_rel15->rbSize; rb++) - vrb_map[rb + pdsch_pdu_rel15->rbStart] = 1; + vrb_map[rb + pdsch_pdu_rel15->rbStart] = 0x3fff; // mark all 14 symb } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index b92777f57c..46cf6deb58 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -204,7 +204,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, void fill_ssb_vrb_map (NR_COMMON_channels_t *cc, int rbStart, int CC_id) { - uint8_t *vrb_map = cc[CC_id].vrb_map; + uint16_t *vrb_map = cc[CC_id].vrb_map; for (int rb = 0; rb < 20; rb++) - vrb_map[rbStart + rb] = 1; + vrb_map[rbStart + rb] = 0xf; // mark the first four symbols as occupied } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 084d35fe05..a3c724e6f6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -545,7 +545,7 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, AssertFatal(sched_ctrl->pucch_sched_idx >= 0, "no uplink slot for PUCCH found!\n"); - uint8_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; + uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; const int current_harq_pid = sched_ctrl->current_harq_pid; NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 665c12e691..7306e169e1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -274,7 +274,7 @@ void nr_preprocessor_phytest(module_id_t module_id, int rbStart = 0; int tStart = 0; int rbSize = 0; - uint8_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; + uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; /* find largest unallocated RB region */ do { /* advance to first free RB */ diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 6e9c547276..36a0891841 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -188,9 +188,9 @@ typedef struct { /// Template for RA computations NR_RA_t ra[NR_NB_RA_PROC_MAX]; /// VRB map for common channels - uint8_t vrb_map[275]; + uint16_t vrb_map[275]; /// VRB map for common channels and retransmissions by PHICH - uint8_t vrb_map_UL[275]; + uint16_t vrb_map_UL[275]; /// number of subframe allocation pattern available for MBSFN sync area uint8_t num_sf_allocation_pattern; ///Number of active SSBs From ad0424cbba1a6f247a4dec3e4808004556eb7457 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 28 Oct 2020 14:15:00 +0100 Subject: [PATCH 115/149] Check all RA procs in nr_rx_sdu() if unknown RNTI --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 88 ++++++++++--------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 25d407f500..c43f7c63e6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -322,51 +322,12 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_info = &gNB_mac->UE_info; int target_snrx10 = gNB_mac->pusch_target_snrx10; - NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[0]; - if (sduP != NULL) { T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */, T_BUFFER(sduP, sdu_lenP)); } - // random access pusch with TC-RNTI - if (ra->state == WAIT_Msg3) { - if (sduP != NULL) { // if the CRC passed - - if (ra->rnti != current_rnti) { - LOG_E(MAC, - "expected TC-RNTI %04x to match current RNTI %04x\n", - ra->rnti, - current_rnti); - return; - } - free(ra->preambles.preamble_list); - ra->state = RA_IDLE; - LOG_I(MAC, "reset RA state information for RA-RNTI %04x\n", ra->rnti); - const int UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti); - UE_info->secondaryCellGroup[UE_id] = ra->secondaryCellGroup; - compute_csi_bitlen (ra->secondaryCellGroup, UE_info, UE_id); - UE_info->UE_beam_index[UE_id] = ra->beam_id; - struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; - AssertFatal(bwpList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", - bwpList->list.count); - const int bwp_id = 1; - UE_info->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1]; - LOG_I(MAC, - "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly, " - "adding UE MAC Context UE_id %d/RNTI %04x\n", - gnb_mod_idP, - current_rnti, - UE_id, - ra->rnti); - // re-initialize ta update variables afrer RA procedure completion - UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; - } - return; - } - if (UE_id != -1) { UE_scheduling_control = &(UE_info->UE_sched_ctrl[UE_id]); @@ -410,6 +371,53 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, else { } + } else { + if (!sduP) // check that CRC passed + return; + + /* we don't know this UE (yet). Check whether there is a ongoing RA (Msg 3) + * and check the corresponding UE's RNTI match, in which case we activate + * it. */ + for (int i = 0; i < NR_NB_RA_PROC_MAX; ++i) { + NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[i]; + if (ra->state != WAIT_Msg3) + continue; + + // random access pusch with TC-RNTI + if (ra->rnti != current_rnti) { + LOG_W(MAC, + "expected TC-RNTI %04x to match current RNTI %04x\n", + ra->rnti, + current_rnti); + continue; + } + const int UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti); + UE_info->secondaryCellGroup[UE_id] = ra->secondaryCellGroup; + compute_csi_bitlen(ra->secondaryCellGroup, UE_info, UE_id); + UE_info->UE_beam_index[UE_id] = ra->beam_id; + struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; + AssertFatal(bwpList->list.count == 1, + "downlinkBWP_ToAddModList has %d BWP!\n", + bwpList->list.count); + const int bwp_id = 1; + UE_info->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1]; + LOG_I(MAC, + "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly, " + "adding UE MAC Context UE_id %d/RNTI %04x\n", + gnb_mod_idP, + current_rnti, + UE_id, + ra->rnti); + // re-initialize ta update variables afrer RA procedure completion + UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; + + free(ra->preambles.preamble_list); + ra->state = RA_IDLE; + LOG_I(MAC, + "reset RA state information for RA-RNTI %04x/index %d\n", + ra->rnti, + i); + return; + } } } - From c4f8ff15615c85ff0a0712d745e9c77d76405011 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 29 Oct 2020 16:29:28 +0100 Subject: [PATCH 116/149] Assert on condition UE not found in UE_list --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 41fafd268b..f677b15576 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1692,8 +1692,7 @@ inline int remove_nr_ue_list(NR_UE_list_t *listP, int UE_id) { int *cur = &listP->head; while (*cur != -1 && *cur != UE_id) cur = &listP->next[*cur]; - if (*cur == -1) - return 0; + AssertFatal(*cur != -1, "UE %d not found in UE_list\n", UE_id); int *next = &listP->next[*cur]; *cur = listP->next[*cur]; *next = -1; From 2e03cbe7bf63341fda7b41dcbd39456d666ff58e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 3 Nov 2020 20:02:48 +0100 Subject: [PATCH 117/149] Track RBs in vrb_map as binary --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index a84bcd7229..6877a1bb69 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -928,7 +928,7 @@ void nr_generate_Msg2(module_id_t module_idP, /* mark the corresponding RBs as used */ uint16_t *vrb_map = cc[CC_id].vrb_map; for (int rb = 0; rb < pdsch_pdu_rel15->rbSize; rb++) - vrb_map[rb + pdsch_pdu_rel15->rbStart] = 0x3fff; // mark all 14 symb + vrb_map[rb + pdsch_pdu_rel15->rbStart] = 1; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 46cf6deb58..f3bf56c239 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -206,5 +206,5 @@ void fill_ssb_vrb_map (NR_COMMON_channels_t *cc, int rbStart, int CC_id) { uint16_t *vrb_map = cc[CC_id].vrb_map; for (int rb = 0; rb < 20; rb++) - vrb_map[rbStart + rb] = 0xf; // mark the first four symbols as occupied + vrb_map[rbStart + rb] = 1; } From 3c3593c6a63b5dc5e68fa50472fcdac9da96782a Mon Sep 17 00:00:00 2001 From: Eugene Bogush Date: Tue, 3 Nov 2020 14:26:25 +0200 Subject: [PATCH 118/149] fix for proc: e_rab_setup_resp --- openair3/S1AP/s1ap_eNB_nas_procedures.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.c b/openair3/S1AP/s1ap_eNB_nas_procedures.c index c668e32d1b..d931e76bb6 100644 --- a/openair3/S1AP/s1ap_eNB_nas_procedures.c +++ b/openair3/S1AP/s1ap_eNB_nas_procedures.c @@ -935,7 +935,7 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, /* Prepare the S1AP message to encode */ memset(&pdu, 0, sizeof(pdu)); pdu.present = S1AP_S1AP_PDU_PR_successfulOutcome; - pdu.choice.successfulOutcome.procedureCode = S1AP_ProcedureCode_id_E_RABModify; + pdu.choice.successfulOutcome.procedureCode = S1AP_ProcedureCode_id_E_RABSetup; pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject; pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_E_RABSetupResponse; out = &pdu.choice.successfulOutcome.value.choice.E_RABSetupResponse; @@ -1032,7 +1032,7 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, break; } - S1AP_DEBUG("e_rab_modify_resp: failed e_rab ID %ld\n", item->value.choice.E_RABItem.e_RAB_ID); + S1AP_DEBUG("e_rab_setup_resp: failed e_rab ID %ld\n", item->value.choice.E_RABItem.e_RAB_ID); ASN_SEQUENCE_ADD(&ie->value.choice.E_RABList.list, item); } From 46219d8c61e782e3f75f514b6ea34d62b6bcc7ef Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Wed, 4 Nov 2020 10:47:02 -0600 Subject: [PATCH 119/149] Fixed ulsim compilation error --- openair1/SIMULATION/NR_PHY/ulsim.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 4be07e426d..fc794b90ec 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -662,8 +662,7 @@ int main(int argc, char **argv) nr_scheduled_response_t scheduled_response; fapi_nr_ul_config_request_t ul_config; fapi_nr_tx_request_t tx_req; - fapi_nr_tx_request_body_t tx_req_body; - + uint8_t ptrs_mcs1 = 2; uint8_t ptrs_mcs2 = 4; uint8_t ptrs_mcs3 = 10; @@ -899,16 +898,15 @@ int main(int argc, char **argv) scheduled_response.dl_config = NULL; scheduled_response.ul_config = &ul_config; scheduled_response.tx_request = &tx_req; - scheduled_response.tx_request->tx_request_body = &tx_req_body; - + // Config UL TX PDU tx_req.slot = slot; tx_req.sfn = frame; // tx_req->tx_config // TbD tx_req.number_of_pdus = 1; - tx_req_body.pdu_length = TBS/8; - tx_req_body.pdu_index = 0; - tx_req_body.pdu = &ulsch_input_buffer[0]; + tx_req.tx_request_body[0].pdu_length = TBS/8; + tx_req.tx_request_body[0].pdu_index = 0; + tx_req.tx_request_body[0].pdu = &ulsch_input_buffer[0]; ul_config.slot = slot; ul_config.number_pdus = 1; From 53edb35eb7fd8f8824586c22addedca2a00876c1 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 5 Nov 2020 12:21:47 +0100 Subject: [PATCH 120/149] Fix whitespace changes --- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 09decf17db..5a8790802d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -390,20 +390,20 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, } printf("\n");*/ encoder_implemparams_t impp; - impp.n_segments=harq_process->C; - impp.tinput = NULL; - impp.tprep = NULL; - impp.tparity = NULL; - impp.toutput = NULL; + impp.n_segments = harq_process->C; + impp.tinput = NULL; + impp.tprep = NULL; + impp.tparity = NULL; + impp.toutput = NULL; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_IN); - - for(int j=0;j<(harq_process->C/8+1);j++) - { - impp.macro_num=j; - nrLDPC_encoder(harq_process->c,harq_process->d,*pz,Kb,Kr,BG,&impp); - } - + + for(int j = 0; j < (harq_process->C/8 + 1); j++) + { + impp.macro_num = j; + nrLDPC_encoder(harq_process->c,harq_process->d,*pz,Kb,Kr,BG,&impp); + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_OUT); //stop_meas(te_stats); From 7f70174cf806d687d7c9083b0dd86fdd63145703 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Fri, 6 Nov 2020 11:15:23 +0100 Subject: [PATCH 121/149] CI: added missing build artifacts in one of the pipeline; fix RA test Signed-off-by: Raphael Defosseux --- ci-scripts/Jenkinsfile-tmp-full-ran | 36 +++++++++++++++++++++++++++ ci-scripts/runTestOnVM.sh | 38 +++++++++++++++++------------ 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/ci-scripts/Jenkinsfile-tmp-full-ran b/ci-scripts/Jenkinsfile-tmp-full-ran index 15ad0379af..c3323f792d 100644 --- a/ci-scripts/Jenkinsfile-tmp-full-ran +++ b/ci-scripts/Jenkinsfile-tmp-full-ran @@ -266,6 +266,42 @@ pipeline { } stage('Log Collection') { parallel { + stage('Log Collection (eNB - Build)') { + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (eNB - Build)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollectBuild --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}" + + echo '\u2705 \u001B[32mLog Transfer (eNB - Build)\u001B[0m' + sh "sshpass -p \'${eNB_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress}:${eNB_SourceCodePath}/cmake_targets/build.log.zip ./build.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("build.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "build.log.${env.BUILD_ID}.zip" + } + } + } + } + stage('Log Collection (OAI UE - Build)') { + steps { + echo '\u2705 \u001B[32mLog Collection (OAI UE - Build)\u001B[0m' + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.UE_Credentials}", usernameVariable: 'UE_Username', passwordVariable: 'UE_Password'] + ]) { + sh "python3 ci-scripts/main.py --mode=LogCollectBuild --UEIPAddress=${params.UE_IPAddress} --UEUserName=${UE_Username} --UEPassword=${UE_Password} --UESourceCodePath=${params.UE_SourceCodePath}" + + echo '\u2705 \u001B[32mLog Transfer (UE - Build)\u001B[0m' + sh "sshpass -p \'${UE_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${UE_Username}@${params.UE_IPAddress}:${UE_SourceCodePath}/cmake_targets/build.log.zip ./build.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("build.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "build.log.${env.BUILD_ID}.zip" + } + } + } + } stage('Log Collection (eNB - Run)') { steps { withCredentials([ diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index 9f44e0ae91..6c87f5dac3 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -1220,6 +1220,8 @@ function start_rf_sim_gnb { echo "sudo apt-get --yes install daemon >> /home/ubuntu/tmp/cmake_targets/log/daemon-install.txt 2>&1" >> $1 echo "echo \"source oaienv\"" >> $1 echo "source oaienv" >> $1 + echo "echo \"export RFSIMULATOR=server\"" >> $1 + echo "export RFSIMULATOR=server" >> $1 echo "cd ci-scripts/conf_files/" >> $1 echo "cp $LOC_CONF_FILE ci-$LOC_CONF_FILE" >> $1 #echo "sed -i -e 's#N_RB_DL.*=.*;#N_RB_DL = $LOC_NB_RBS;#' -e 's#CI_MME_IP_ADDR#$LOC_EPC_IP_ADDR#' -e 's#CI_ENB_IP_ADDR#$LOC_ENB_VM_IP_ADDR#' -e 's#CI_UE_IP_ADDR#$LOC_UE_VM_IP_ADDR#' ci-$LOC_CONF_FILE" >> $1 @@ -1233,9 +1235,9 @@ function start_rf_sim_gnb { then if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option then - echo "echo \"RFSIMULATOR=server ./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test\" > ./my-nr-softmodem-run.sh " >> $1 else #RA test => use --do-ra option - echo "echo \"RFSIMULATOR=server ./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --rfsim --do-ra\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --rfsim --do-ra\" > ./my-nr-softmodem-run.sh " >> $1 fi fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 @@ -1320,30 +1322,25 @@ function start_rf_sim_nr_ue { local LOC_RA_TEST=$8 # Copy the RAW files from the gNB run - # In RA test mode, they were not copied from gNB VM - if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option - then - scp -o StrictHostKeyChecking=no rbconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp - scp -o StrictHostKeyChecking=no reconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp - fi + scp -o StrictHostKeyChecking=no rbconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp + scp -o StrictHostKeyChecking=no reconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp echo "echo \"sudo apt-get --yes --quiet install daemon \"" > $1 echo "sudo apt-get --yes install daemon >> /home/ubuntu/tmp/cmake_targets/log/daemon-install.txt 2>&1" >> $1 + echo "echo \"export RFSIMULATOR=${LOC_GNB_VM_IP_ADDR}\"" >> $1 + echo "export RFSIMULATOR=${LOC_GNB_VM_IP_ADDR}" >> $1 echo "echo \"cd /home/ubuntu/tmp/cmake_targets/ran_build/build/\"" >> $1 echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 - if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option - then - echo "sudo cp /home/ubuntu/tmp/r*config.raw /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 - echo "sudo chmod 666 /home/ubuntu/tmp/cmake_targets/ran_build/build/r*config.raw" >> $1 - fi + echo "sudo cp /home/ubuntu/tmp/r*config.raw /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 + echo "sudo chmod 666 /home/ubuntu/tmp/cmake_targets/ran_build/build/r*config.raw" >> $1 echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option then - echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 else #RA test => use --do-ra option - echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --rfsim --do-ra --log_config.global_log_options level,nocolor\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-uesoftmodem --rfsim --do-ra --log_config.global_log_options level,nocolor --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/\" > ./my-nr-softmodem-run.sh " >> $1 fi fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 @@ -2198,15 +2195,21 @@ function run_test_on_vm { PRB=106 FREQUENCY=3510 + if [ ! -d $ARCHIVES_LOC ] + then + mkdir --parents $ARCHIVES_LOC + fi + local try_cnt="0" NR_STATUS=0 ######### start of RA TEST loop - while [ $try_cnt -lt 10 ] #10 because it hardly succeed within CI + while [ $try_cnt -lt 5 ] #5 because it hardly succeed within CI do SYNC_STATUS=0 RA_STATUS=0 + rm -f $ARCHIVES_LOC/tdd_${PRB}prb_${CN_CONFIG}*ra_test.log echo "############################################################" echo "${CN_CONFIG} : Starting the gNB" @@ -2271,6 +2274,9 @@ function run_test_on_vm { SYNC_STATUS=0 PING_STATUS=0 IPERF_STATUS=0 + rm -f $ARCHIVES_LOC/tdd_${PRB}prb_${CN_CONFIG}_gnb.log $ARCHIVES_LOC/tdd_${PRB}prb_${CN_CONFIG}_ue.log + rm -f $ARCHIVES_LOC/tdd_${PRB}prb_${CN_CONFIG}_ping_gnb_from_nrue.log $ARCHIVES_LOC/tdd_${PRB}prb_${CN_CONFIG}_ping_from_gnb_nrue.log + rm -f $ARCHIVES_LOC/tdd_${PRB}prb_${CN_CONFIG}_iperf_dl*txt $ARCHIVES_LOC/tdd_${PRB}prb_${CN_CONFIG}_iperf_ul*txt echo "############################################################" echo "${CN_CONFIG} : Starting the gNB" From 8fee453c8e10bc8823f7c56a5820a1f9e0d6a0bd Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 6 Nov 2020 11:26:04 +0100 Subject: [PATCH 122/149] nr: rlc: hotfix - forgot to store frame and subframe... --- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 5048dd245e..3a46f913e9 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -917,6 +917,9 @@ rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const x) void nr_rlc_tick(int frame, int subframe) { if (frame != nr_rlc_current_time_last_frame || - subframe != nr_rlc_current_time_last_subframe) + subframe != nr_rlc_current_time_last_subframe) { + nr_rlc_current_time_last_frame = frame; + nr_rlc_current_time_last_subframe = subframe; nr_rlc_current_time++; + } } From 6056de78b33c8ad048d75bb329f3b81780cb49fa Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Sun, 8 Nov 2020 17:02:40 +0100 Subject: [PATCH 123/149] fixing dependency in CMakeLists.txt --- cmake_targets/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index fcca53abe9..26d23fee0e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -3181,7 +3181,7 @@ if (${T_TRACER}) SECU_OSA SECU_CN SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB default_sched remote_sched RAL NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX - L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE MAC_NR_COMMON MAC_NR MAC_UE_NR + L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_NR MAC_UE_NR CN_UTILS GTPV1U NR_GTPV1U SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB ldpc_orig ldpc_optim ldpc_optim8seg ldpc PROTO_AGENT dfts) if (TARGET ${i}) From 66323e0b1d430c8090725e668b7f7673c3950801 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Fri, 30 Oct 2020 21:19:49 +0100 Subject: [PATCH 124/149] BG selection bug fix The BG was set to its default for rounds > 0. This is now fixed by adding it to harq structure. Also a fix for wrong I_lbrm set in dlsch decoding. --- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 11 +++++------ openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 +- openair1/PHY/defs_gNB.h | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index a4a684c4e4..80d6d13d9e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -333,7 +333,6 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, uint8_t mod_order = rel15->qamModOrder[0]; uint16_t Kr=0,r; uint32_t r_offset=0; - uint8_t BG=1; uint32_t E; uint8_t Ilbrm = 1; uint32_t Tbslbrm = 950984; //max tbs @@ -431,9 +430,9 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, Coderate = (float) R /(float) 2048; if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) - BG = 2; + dlsch->harq_processes[harq_pid]->BG = 2; else - BG = 1; + dlsch->harq_processes[harq_pid]->BG = 1; start_meas(dlsch_segmentation_stats); Kb = nr_segmentation(dlsch->harq_processes[harq_pid]->b, @@ -443,7 +442,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, &dlsch->harq_processes[harq_pid]->K, Zc, &dlsch->harq_processes[harq_pid]->F, - BG); + dlsch->harq_processes[harq_pid]->BG); stop_meas(dlsch_segmentation_stats); F = dlsch->harq_processes[harq_pid]->F; @@ -480,7 +479,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) { impp.macro_num=j; - nrLDPC_encoder(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,&impp); + nrLDPC_encoder(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,dlsch->harq_processes[harq_pid]->BG,&impp); } @@ -532,7 +531,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, start_meas(dlsch_rate_matching_stats); nr_rate_matching_ldpc(Ilbrm, Tbslbrm, - BG, + dlsch->harq_processes[harq_pid]->BG, *Zc, dlsch->harq_processes[harq_pid]->d[r], dlsch->harq_processes[harq_pid]->e+r_offset, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 7378f69c27..c8e772384d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -259,7 +259,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, //__m128i l; //int16_t inv_d [68*384]; uint8_t kc; - uint8_t Ilbrm = 0; + uint8_t Ilbrm = 1; uint32_t Tbslbrm;// = 950984; uint16_t nb_rb;// = 30; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 3d73483dfd..b6ffd06c2b 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -110,6 +110,8 @@ typedef struct { uint32_t K; /// Number of "Filler" bits uint32_t F; + /// Encoder BG + uint8_t BG; } NR_DL_gNB_HARQ_t; typedef struct { From 2f769246713af8778b8aca33c84ea3fca9640aa3 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Tue, 3 Nov 2020 14:06:23 +0100 Subject: [PATCH 125/149] Enabled ACK/NACK logs for CI --- openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index c8e772384d..b0385c5337 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -675,14 +675,14 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if(is_crnti) { - LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", + LOG_I(PHY,"[UE %d] DLSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS); } return((1 + dlsch->max_ldpc_iterations)); } else { //#if UE_DEBUG_TRACE - LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n", + LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n", phy_vars_ue->Mod_id,nr_tti_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round); //#endif From a57136697fac7f3ada425ff73af387e7f4b85b26 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 5 Nov 2020 13:34:02 +0100 Subject: [PATCH 126/149] Skip decoding for false retransmission If UE receives retransmission for already decoded PDSCH, it skips decoding and sets ACK directly. And adding PDSCH decoding stats and printing then every 64 frames for CI purpose --- openair1/PHY/INIT/nr_init_ue.c | 3 +++ openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 3 +++ openair1/PHY/defs_nr_UE.h | 2 ++ openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 1 - openair1/SCHED_NR_UE/harq_nr.c | 2 ++ openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 3 +++ 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 39e99e6ec3..0e5222063f 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -969,6 +969,9 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue, //ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; ue->dlsch_MCH[0] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,MAX_LDPC_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0); + + for(int i=0; i<5; i++) + ue->dl_stats[i] = 0; } void phy_init_nr_top(PHY_VARS_NR_UE *ue) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index b0385c5337..f3565a0b58 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -253,6 +253,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf; + // HARQ stats + phy_vars_ue->dl_stats[harq_process->round]++; int16_t z [68*384]; int8_t l [68*384]; @@ -671,6 +673,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if (harq_process->round >= dlsch->Mlimit) { harq_process->status = SCH_IDLE; harq_process->round = 0; + phy_vars_ue->dl_stats[4]++; } if(is_crnti) diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index fff6a82047..6b81533896 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1121,6 +1121,8 @@ typedef struct { SLIST_HEAD(ral_thresholds_gen_poll_s, ral_threshold_phy_t) ral_thresholds_gen_polled[RAL_LINK_PARAM_GEN_MAX]; SLIST_HEAD(ral_thresholds_lte_poll_s, ral_threshold_phy_t) ral_thresholds_lte_polled[RAL_LINK_PARAM_LTE_MAX]; #endif + + int dl_stats[4]; } PHY_VARS_NR_UE; diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 2df917d676..dd207c935c 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -93,7 +93,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if (dlsch0_harq){ - dlsch0_harq->status = ACTIVE; dlsch0_harq->BWPStart = dlsch_config_pdu->BWPStart; dlsch0_harq->BWPSize = dlsch_config_pdu->BWPSize; dlsch0_harq->nb_rb = dlsch_config_pdu->number_rbs; diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index 3c3017d658..45170cc1f8 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -491,6 +491,8 @@ harq_result_t downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int dl_harq->round++; + if (dl_harq->harq_ack.ack) dl_harq->status = SCH_IDLE; + result_harq = RETRANSMISSION_HARQ; NR_TST_PHY_PRINTF("[HARQ-DL-PDSCH harqId : %d] reception of a retransmission \n", harq_pid); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index aadefd317e..5cc6af1e0c 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -936,6 +936,9 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, uint16_t bw_scaling, start_symbol; float tc_factor; + if ((frame_rx%64 == 0) && (nr_tti_rx==0)) + LOG_I(PHY,"Harq round stats for Downlink: %d/%d/%d/%d DLSCH errors: %d\n",ue->dl_stats[0],ue->dl_stats[1],ue->dl_stats[2],ue->dl_stats[3],ue->dl_stats[3]); + is_cw0_active = dlsch0->harq_processes[harq_pid]->status; nb_symb_sch = dlsch0->harq_processes[harq_pid]->nb_symbols; start_symbol = dlsch0->harq_processes[harq_pid]->start_symbol; From c61b47dc96bc2281d521a66cee22b9b41363aba6 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 5 Nov 2020 13:38:33 +0100 Subject: [PATCH 127/149] Revert "Enabled ACK/NACK logs for CI" This reverts commit 199ce5d953ed90e052a69f520b30b7253b163250. --- openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index f3565a0b58..1ec4d4b759 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -678,14 +678,14 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if(is_crnti) { - LOG_I(PHY,"[UE %d] DLSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", + LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS); } return((1 + dlsch->max_ldpc_iterations)); } else { //#if UE_DEBUG_TRACE - LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n", + LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n", phy_vars_ue->Mod_id,nr_tti_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round); //#endif From 7878e102e029e747c6533f59cc0fedf244c7fd58 Mon Sep 17 00:00:00 2001 From: hardy Date: Mon, 9 Nov 2020 14:33:59 +0100 Subject: [PATCH 128/149] improving markers for NSA FR1 test --- ci-scripts/ran.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index d5906e9567..f1a4ab3690 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -705,6 +705,9 @@ class RANManagement(): systemTime = '' maxPhyMemUsage = '' nbContextSwitches = '' + #NSA FR1 + NSA_RAPROC_PUSCH_check = 0 + for line in enb_log_file.readlines(): # Runtime statistics result = re.search('Run time:' ,str(line)) @@ -855,12 +858,19 @@ class RANManagement(): result = re.search('MBMS USER-PLANE.*Requesting.*bytes from RLC', str(line)) if result is not None: mbmsRequestMsg += 1 + #FR1 NSA test : add new markers to make sure gNB is used + result = re.search('\[gNB [0-9]+\]\[RAPROC\] PUSCH with TC_RNTI [0-9a-fA-F]+ received correctly, adding UE MAC Context UE_id [0-9]+\/RNTI [0-9a-fA-F]+', str(line)) + if result is not None: + NSA_RAPROC_PUSCH_check = 1 + + enb_log_file.close() logging.debug(' File analysis completed') if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): nodeB_prefix = 'e' else: nodeB_prefix = 'g' + if self.air_interface[self.eNB_instance] == 'nr-softmodem': if ulschReceiveOK > 0: statMsg = nodeB_prefix + 'NB showed ' + str(ulschReceiveOK) + ' "ULSCH received ok" message(s)' @@ -874,6 +884,14 @@ class RANManagement(): statMsg = nodeB_prefix + 'NB ran with TX Write thread enabled' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') htmleNBFailureMsg += statMsg + '\n' + #FR1 NSA test : add new markers to make sure gNB is used + if NSA_RAPROC_PUSCH_check: + statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : PASS ' + else + statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : FAIL ' + logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') + htmleNBFailureMsg += statMsg + '\n' + if uciStatMsgCount > 0: statMsg = nodeB_prefix + 'NB showed ' + str(uciStatMsgCount) + ' "uci->stat" message(s)' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') From 633883131526d0fedfd446bc01c0bf70cf8a408b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= Date: Mon, 9 Nov 2020 14:55:02 +0100 Subject: [PATCH 129/149] feat(build_helper): use 'id' command instead $USER variable When $USER is not set (Yes we did !), extracting protobuf fails. Wh avoid this by using the 'id' command both to get user and group ids. --- cmake_targets/tools/build_helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 1ba3b225a6..b066bc23d8 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -256,7 +256,7 @@ install_protobuf_from_source(){ then rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz - tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $(groups | cut -d" " -f1) --no-same-owner + tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $($id -u) --group $(id -g) --no-same-owner cd protobuf-3.3.0/ else export LD_LIBRARY_PATH=/usr/local/lib #protoc needs to know where toclook for shared libs From 7ce5aaa136af1fd02a4a58d98124ccebaa165c2c Mon Sep 17 00:00:00 2001 From: hardy Date: Mon, 9 Nov 2020 15:13:56 +0100 Subject: [PATCH 130/149] adding dlsch and ulsch statistics --- ci-scripts/ran.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index f1a4ab3690..9c2e2b423a 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -705,8 +705,10 @@ class RANManagement(): systemTime = '' maxPhyMemUsage = '' nbContextSwitches = '' - #NSA FR1 + #NSA FR1 check NSA_RAPROC_PUSCH_check = 0 + #dlsch and ulsch statistics (dictionary) + dlsch_ulsch_stats = {} for line in enb_log_file.readlines(): # Runtime statistics @@ -862,7 +864,15 @@ class RANManagement(): result = re.search('\[gNB [0-9]+\]\[RAPROC\] PUSCH with TC_RNTI [0-9a-fA-F]+ received correctly, adding UE MAC Context UE_id [0-9]+\/RNTI [0-9a-fA-F]+', str(line)) if result is not None: NSA_RAPROC_PUSCH_check = 1 - + #dlsch and ulsch statistics + #keys below are are the markers we are loooking for, looping over this keys list + #everytime these markers are found in the log file, the previous ones are overwritten in the dict + #eventually we record only the last one + keys = {'dlsch_rounds','dlsch_total_bytes','ulsch_rounds','ulsch_total_bytes_scheduled'} + for k in keys: + result = re.search(k, str(line)) + if result is not None: + dlsch_ulsch_stats[k]=str(line) enb_log_file.close() logging.debug(' File analysis completed') @@ -870,7 +880,7 @@ class RANManagement(): nodeB_prefix = 'e' else: nodeB_prefix = 'g' - + if self.air_interface[self.eNB_instance] == 'nr-softmodem': if ulschReceiveOK > 0: statMsg = nodeB_prefix + 'NB showed ' + str(ulschReceiveOK) + ' "ULSCH received ok" message(s)' @@ -890,7 +900,14 @@ class RANManagement(): else statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : FAIL ' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') - htmleNBFailureMsg += statMsg + '\n' + htmleNBFailureMsg += statMsg + '\n' + #ulsch and dlsch statistics + if len(dlsch_ulsch_stats)!=0: #check if dictionary is not empty + statMsg='' + for key in dlsch_ulsch_stats: #for each dictionary key + statMsg += dlsch_ulsch_stats[key] + '\n' + logging.debug('\u001B[1;30;43m ' + dlsch_ulsch_stats[key] + ' \u001B[0m') + htmleNBFailureMsg += statMsg + '\n' if uciStatMsgCount > 0: statMsg = nodeB_prefix + 'NB showed ' + str(uciStatMsgCount) + ' "uci->stat" message(s)' From 78fa6df3a4a2a39bb09ae77dde4a6c0663adb220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= Date: Mon, 9 Nov 2020 15:15:46 +0100 Subject: [PATCH 131/149] feat: add "port" parameter on configuration files Use default port 36412 for S1 --- ci-scripts/conf_files/cu.band7.tm1.100PRB.conf | 1 + ci-scripts/conf_files/cu.band7.tm1.25PRB.conf | 1 + ci-scripts/conf_files/cu.band7.tm1.50PRB.conf | 1 + ci-scripts/conf_files/enb.band13.tm1.25PRB.usrpb210.conf | 1 + ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf | 1 + ci-scripts/conf_files/enb.band17.tm1.25PRB.usrpb210.conf | 1 + ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf | 1 + .../conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf | 1 + .../conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf | 1 + .../conf_files/enb.band40.tm1.50PRB.FairScheduler.usrpb210.conf | 1 + .../conf_files/enb.band40.tm2.25PRB.FairScheduler.usrpb210.conf | 1 + ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf | 1 + ci-scripts/conf_files/enb.band7.tm1.25PRB.slave.usrpb210.conf | 1 + ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf | 1 + ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf | 1 + ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf | 1 + ci-scripts/conf_files/enb.band7.tm2.25PRB.usrpb210.conf | 1 + ci-scripts/conf_files/enb.slave.band13.tm1.25PRB.usrpb210.conf | 1 + ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf | 1 + ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf | 1 + ci-scripts/conf_files/lte-fdd-basic-sim.conf | 1 + ci-scripts/conf_files/lte-fdd-fembms-basic-sim.conf | 1 + ci-scripts/conf_files/lte-fdd-mbms-basic-sim.conf | 1 + ci-scripts/conf_files/lte-tdd-basic-sim.conf | 1 + ci-scripts/conf_files/rcc.band38.tm1.50PRB.multi.rru.conf | 1 + .../conf_files/rcc.band40.tm1.100PRB.FairScheduler.usrpb210.conf | 1 + .../conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf | 1 + .../conf_files/rcc.band40.tm1.50PRB.FairScheduler.usrpb210.conf | 1 + .../conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf | 1 + ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf | 1 + ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf | 1 + .../conf_files/rcc.band7.tm1.mbms-s1ap.if4p5.50PRB.lo.conf | 1 + ci-scripts/conf_files/rcc.band7.tm1.mbms.if4p5.50PRB.lo.conf | 1 + ci-scripts/conf_files/rcc.band7.tm1.nfapi.conf | 1 + 34 files changed, 34 insertions(+) diff --git a/ci-scripts/conf_files/cu.band7.tm1.100PRB.conf b/ci-scripts/conf_files/cu.band7.tm1.100PRB.conf index becd484c56..42cade271c 100644 --- a/ci-scripts/conf_files/cu.band7.tm1.100PRB.conf +++ b/ci-scripts/conf_files/cu.band7.tm1.100PRB.conf @@ -181,6 +181,7 @@ eNBs = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/cu.band7.tm1.25PRB.conf b/ci-scripts/conf_files/cu.band7.tm1.25PRB.conf index 7e4dfc6de6..51f7277267 100644 --- a/ci-scripts/conf_files/cu.band7.tm1.25PRB.conf +++ b/ci-scripts/conf_files/cu.band7.tm1.25PRB.conf @@ -181,6 +181,7 @@ eNBs = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/cu.band7.tm1.50PRB.conf b/ci-scripts/conf_files/cu.band7.tm1.50PRB.conf index b1c4774aba..9946713c3a 100644 --- a/ci-scripts/conf_files/cu.band7.tm1.50PRB.conf +++ b/ci-scripts/conf_files/cu.band7.tm1.50PRB.conf @@ -181,6 +181,7 @@ eNBs = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band13.tm1.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band13.tm1.25PRB.usrpb210.conf index 49926c3e60..0c247e9ef9 100644 --- a/ci-scripts/conf_files/enb.band13.tm1.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band13.tm1.25PRB.usrpb210.conf @@ -175,6 +175,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf b/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf index 673c506dfa..f560958e15 100644 --- a/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf +++ b/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf @@ -356,6 +356,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band17.tm1.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band17.tm1.25PRB.usrpb210.conf index cf508a1e95..ba81f832db 100644 --- a/ci-scripts/conf_files/enb.band17.tm1.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band17.tm1.25PRB.usrpb210.conf @@ -177,6 +177,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf index d26ab5d1b4..79bbd7ee6f 100644 --- a/ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf @@ -178,6 +178,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf b/ci-scripts/conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf index 55127e1c53..b5fd1255bb 100644 --- a/ci-scripts/conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf @@ -136,6 +136,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf b/ci-scripts/conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf index 88e4c88685..552dfd637b 100644 --- a/ci-scripts/conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf @@ -136,6 +136,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band40.tm1.50PRB.FairScheduler.usrpb210.conf b/ci-scripts/conf_files/enb.band40.tm1.50PRB.FairScheduler.usrpb210.conf index 5794310fad..d95d2b6ac1 100644 --- a/ci-scripts/conf_files/enb.band40.tm1.50PRB.FairScheduler.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band40.tm1.50PRB.FairScheduler.usrpb210.conf @@ -136,6 +136,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band40.tm2.25PRB.FairScheduler.usrpb210.conf b/ci-scripts/conf_files/enb.band40.tm2.25PRB.FairScheduler.usrpb210.conf index 5348c25c0e..e466a23ab0 100644 --- a/ci-scripts/conf_files/enb.band40.tm2.25PRB.FairScheduler.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band40.tm2.25PRB.FairScheduler.usrpb210.conf @@ -136,6 +136,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf index 7ea8839b8a..e3cdb033c9 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf @@ -173,6 +173,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.25PRB.slave.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.25PRB.slave.usrpb210.conf index 36f0fdf7b1..f95530b251 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.25PRB.slave.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.25PRB.slave.usrpb210.conf @@ -176,6 +176,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf index b61201440b..eddb34a579 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf @@ -176,6 +176,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf index 8a2cedfd05..b5d7f35a76 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf @@ -181,6 +181,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf index b2d5801efc..19e4abdcb0 100755 --- a/ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf @@ -183,6 +183,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.band7.tm2.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm2.25PRB.usrpb210.conf index 08dd300329..67cc5706ae 100644 --- a/ci-scripts/conf_files/enb.band7.tm2.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm2.25PRB.usrpb210.conf @@ -176,6 +176,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/enb.slave.band13.tm1.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.slave.band13.tm1.25PRB.usrpb210.conf index 371a6b4610..1b5376644b 100644 --- a/ci-scripts/conf_files/enb.slave.band13.tm1.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.slave.band13.tm1.25PRB.usrpb210.conf @@ -175,6 +175,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index aa03e91fd0..936c97b06a 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -204,6 +204,7 @@ gNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "192.168.12.26"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index 7a4b5f54c1..0b870fbb5c 100755 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -201,6 +201,7 @@ gNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/lte-fdd-basic-sim.conf b/ci-scripts/conf_files/lte-fdd-basic-sim.conf index 163047d7b9..a4d8e007dc 100644 --- a/ci-scripts/conf_files/lte-fdd-basic-sim.conf +++ b/ci-scripts/conf_files/lte-fdd-basic-sim.conf @@ -173,6 +173,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/lte-fdd-fembms-basic-sim.conf b/ci-scripts/conf_files/lte-fdd-fembms-basic-sim.conf index bb49d68bb4..458ab7cf89 100644 --- a/ci-scripts/conf_files/lte-fdd-fembms-basic-sim.conf +++ b/ci-scripts/conf_files/lte-fdd-fembms-basic-sim.conf @@ -174,6 +174,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/lte-fdd-mbms-basic-sim.conf b/ci-scripts/conf_files/lte-fdd-mbms-basic-sim.conf index 2e211d86b8..e80ff2b9cb 100644 --- a/ci-scripts/conf_files/lte-fdd-mbms-basic-sim.conf +++ b/ci-scripts/conf_files/lte-fdd-mbms-basic-sim.conf @@ -174,6 +174,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/lte-tdd-basic-sim.conf b/ci-scripts/conf_files/lte-tdd-basic-sim.conf index ad7e9d9f86..f443a907f2 100644 --- a/ci-scripts/conf_files/lte-tdd-basic-sim.conf +++ b/ci-scripts/conf_files/lte-tdd-basic-sim.conf @@ -136,6 +136,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band38.tm1.50PRB.multi.rru.conf b/ci-scripts/conf_files/rcc.band38.tm1.50PRB.multi.rru.conf index b3899fdb6a..502e3c548a 100644 --- a/ci-scripts/conf_files/rcc.band38.tm1.50PRB.multi.rru.conf +++ b/ci-scripts/conf_files/rcc.band38.tm1.50PRB.multi.rru.conf @@ -141,6 +141,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band40.tm1.100PRB.FairScheduler.usrpb210.conf b/ci-scripts/conf_files/rcc.band40.tm1.100PRB.FairScheduler.usrpb210.conf index 0547590c29..2bf79a3d7e 100644 --- a/ci-scripts/conf_files/rcc.band40.tm1.100PRB.FairScheduler.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band40.tm1.100PRB.FairScheduler.usrpb210.conf @@ -139,6 +139,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf b/ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf index 3441690e6d..6b0e7de659 100644 --- a/ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf @@ -139,6 +139,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band40.tm1.50PRB.FairScheduler.usrpb210.conf b/ci-scripts/conf_files/rcc.band40.tm1.50PRB.FairScheduler.usrpb210.conf index 23709444bd..6b41d78506 100644 --- a/ci-scripts/conf_files/rcc.band40.tm1.50PRB.FairScheduler.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band40.tm1.50PRB.FairScheduler.usrpb210.conf @@ -139,6 +139,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf index 33d00b8908..5df8f16f78 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf @@ -176,6 +176,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf index a939c66cba..ad753bb114 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf @@ -176,6 +176,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf index 473496defa..dbe3aff3dc 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf @@ -176,6 +176,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.mbms-s1ap.if4p5.50PRB.lo.conf b/ci-scripts/conf_files/rcc.band7.tm1.mbms-s1ap.if4p5.50PRB.lo.conf index bf2db71152..640b85930a 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.mbms-s1ap.if4p5.50PRB.lo.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.mbms-s1ap.if4p5.50PRB.lo.conf @@ -144,6 +144,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "192.168.15.130"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.mbms.if4p5.50PRB.lo.conf b/ci-scripts/conf_files/rcc.band7.tm1.mbms.if4p5.50PRB.lo.conf index 3bcd038d70..7fe682f29e 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.mbms.if4p5.50PRB.lo.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.mbms.if4p5.50PRB.lo.conf @@ -144,6 +144,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "127.0.0.3"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.nfapi.conf b/ci-scripts/conf_files/rcc.band7.tm1.nfapi.conf index ad113d0ffc..281f7433af 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.nfapi.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.nfapi.conf @@ -174,6 +174,7 @@ eNBs = ////////// MME parameters: mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; ipv6 = "192:168:30::17"; + port = 36412 ; active = "yes"; preference = "ipv4"; } From 89f7132685980141fd3084f91125d8522a818de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= Date: Mon, 9 Nov 2020 15:43:01 +0100 Subject: [PATCH 132/149] fix(config): set S1AP_PORT_NUMBER as default value for mme port --- openair2/ENB_APP/enb_config.c | 7 +------ openair2/ENB_APP/enb_paramdef.h | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index a0a506bf35..de77d783c7 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -57,7 +57,6 @@ #include "enb_paramdef.h" #include "proto_agent.h" #include "executables/thread-common.h" -#include "s1ap_eNB_default_values.h" extern uint32_t to_earfcn_DL(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw); extern uint32_t to_earfcn_UL(int eutra_bandP, uint32_t ul_CarrierFreq, uint32_t bw); @@ -2513,11 +2512,7 @@ int RCconfig_S1( } /* set S1-mme port (sctp) */ - if (S1ParamList.paramarray[l][ENB_MME_PORT_IDX].u16ptr) { - S1AP_REGISTER_ENB_REQ(msg_p).mme_port[l] = *S1ParamList.paramarray[l][ENB_MME_PORT_IDX].u16ptr; - } else { - S1AP_REGISTER_ENB_REQ(msg_p).mme_port[l] = S1AP_PORT_NUMBER; - } + S1AP_REGISTER_ENB_REQ(msg_p).mme_port[l] = *S1ParamList.paramarray[l][ENB_MME_PORT_IDX].u16ptr; AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] <= S1AP_REGISTER_ENB_REQ(msg_p).num_plmn, "List of broadcast PLMN to be sent to MME can not be longer than actual " diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index dd24964b4c..97317266e5 100644 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -34,6 +34,7 @@ #define ENB_PARAMDEF_H_ #include "common/config/config_paramdesc.h" #include "RRC_paramsvalues.h" +#include "s1ap_eNB_default_values.h" #define ENB_CONFIG_STRING_CC_NODE_FUNCTION "node_function" #define ENB_CONFIG_STRING_CC_NODE_TIMING "node_timing" @@ -923,7 +924,7 @@ typedef struct srb1_params_s { {ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_MME_BROADCAST_PLMN_INDEX, NULL, 0, uptr:NULL, defintarrayval:NULL, TYPE_UINTARRAY, 6}, \ - {ENB_CONFIG_STRING_MME_PORT, NULL, 0, u16ptr:NULL, defuintval:0, TYPE_UINT16, 0}, \ + {ENB_CONFIG_STRING_MME_PORT, NULL, 0, u16ptr:NULL, defuintval:S1AP_PORT_NUMBER, TYPE_UINT16, 0}, \ } From e8aeccad9f9fc89706b5b51c276fbf8dce1900c2 Mon Sep 17 00:00:00 2001 From: hardy Date: Mon, 9 Nov 2020 15:45:09 +0100 Subject: [PATCH 133/149] fix typo --- ci-scripts/ran.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 9c2e2b423a..d38ce4df25 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -897,7 +897,7 @@ class RANManagement(): #FR1 NSA test : add new markers to make sure gNB is used if NSA_RAPROC_PUSCH_check: statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : PASS ' - else + else: statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : FAIL ' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') htmleNBFailureMsg += statMsg + '\n' From 9d3304059a55ad8247c729034e7439bf255f461e Mon Sep 17 00:00:00 2001 From: hardy Date: Mon, 9 Nov 2020 16:51:58 +0100 Subject: [PATCH 134/149] for debug --- ci-scripts/ran.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index d38ce4df25..a7c4b54458 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -876,6 +876,9 @@ class RANManagement(): enb_log_file.close() logging.debug(' File analysis completed') + #RH debug + print(self.air_interface[self.eNB_instance]+'\n') + # if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): nodeB_prefix = 'e' else: @@ -895,14 +898,14 @@ class RANManagement(): logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') htmleNBFailureMsg += statMsg + '\n' #FR1 NSA test : add new markers to make sure gNB is used - if NSA_RAPROC_PUSCH_check: + if NSA_RAPROC_PUSCH_check: statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : PASS ' - else: + else: statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : FAIL ' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') htmleNBFailureMsg += statMsg + '\n' #ulsch and dlsch statistics - if len(dlsch_ulsch_stats)!=0: #check if dictionary is not empty + if len(dlsch_ulsch_stats)!=0: #check if dictionary is not empty statMsg='' for key in dlsch_ulsch_stats: #for each dictionary key statMsg += dlsch_ulsch_stats[key] + '\n' From 789e48fcd29708abc2e93b8690aa8e7189506bcd Mon Sep 17 00:00:00 2001 From: Remi Hardy Date: Mon, 9 Nov 2020 17:50:34 +0100 Subject: [PATCH 135/149] debug --- ci-scripts/ran.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index a7c4b54458..050eb5bb0d 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -568,6 +568,10 @@ class RANManagement(): mySSH = SSH.SSHConnection() mySSH.open(lIpAddr, lUserName, lPassWord) mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) + #RH debug + print(self.air_interface) + print(self.eNB_instance) + # if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): nodeB_prefix = 'e' else: @@ -877,7 +881,7 @@ class RANManagement(): enb_log_file.close() logging.debug(' File analysis completed') #RH debug - print(self.air_interface[self.eNB_instance]+'\n') + print(self.air_interface[self.eNB_instance]+'\n') # if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): nodeB_prefix = 'e' @@ -899,18 +903,18 @@ class RANManagement(): htmleNBFailureMsg += statMsg + '\n' #FR1 NSA test : add new markers to make sure gNB is used if NSA_RAPROC_PUSCH_check: - statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : PASS ' + statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : PASS ' else: - statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : FAIL ' - logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') - htmleNBFailureMsg += statMsg + '\n' - #ulsch and dlsch statistics + statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : FAIL ' + logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') + htmleNBFailureMsg += statMsg + '\n' + #ulsch and dlsch statistics if len(dlsch_ulsch_stats)!=0: #check if dictionary is not empty - statMsg='' - for key in dlsch_ulsch_stats: #for each dictionary key - statMsg += dlsch_ulsch_stats[key] + '\n' - logging.debug('\u001B[1;30;43m ' + dlsch_ulsch_stats[key] + ' \u001B[0m') - htmleNBFailureMsg += statMsg + '\n' + statMsg='' + for key in dlsch_ulsch_stats: #for each dictionary key + statMsg += dlsch_ulsch_stats[key] + '\n' + logging.debug('\u001B[1;30;43m ' + dlsch_ulsch_stats[key] + ' \u001B[0m') + htmleNBFailureMsg += statMsg + '\n' if uciStatMsgCount > 0: statMsg = nodeB_prefix + 'NB showed ' + str(uciStatMsgCount) + ' "uci->stat" message(s)' From 4c8ec44678f9b9ad5aaab0ba6d5b96d2b29e34c1 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Fri, 6 Nov 2020 13:25:43 +0100 Subject: [PATCH 136/149] Updated the stats message --- openair1/PHY/defs_nr_UE.h | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 6b81533896..2a808486f0 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1122,7 +1122,7 @@ typedef struct { SLIST_HEAD(ral_thresholds_lte_poll_s, ral_threshold_phy_t) ral_thresholds_lte_polled[RAL_LINK_PARAM_LTE_MAX]; #endif - int dl_stats[4]; + int dl_stats[5]; } PHY_VARS_NR_UE; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 5cc6af1e0c..b0d765b746 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -936,9 +936,6 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, uint16_t bw_scaling, start_symbol; float tc_factor; - if ((frame_rx%64 == 0) && (nr_tti_rx==0)) - LOG_I(PHY,"Harq round stats for Downlink: %d/%d/%d/%d DLSCH errors: %d\n",ue->dl_stats[0],ue->dl_stats[1],ue->dl_stats[2],ue->dl_stats[3],ue->dl_stats[3]); - is_cw0_active = dlsch0->harq_processes[harq_pid]->status; nb_symb_sch = dlsch0->harq_processes[harq_pid]->nb_symbols; start_symbol = dlsch0->harq_processes[harq_pid]->start_symbol; @@ -1779,6 +1776,12 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, } } + if ((frame_rx%64 == 0) && (nr_tti_rx==0)) { + printf("============================================\n"); + LOG_I(PHY,"Harq round stats for Downlink: %d/%d/%d/%d DLSCH errors: %d\n",ue->dl_stats[0],ue->dl_stats[1],ue->dl_stats[2],ue->dl_stats[3],ue->dl_stats[4]); + printf("============================================\n"); + } + #ifdef NR_PDCCH_SCHED nr_gold_pdcch(ue, 0, 2); From f36f724b04f927281656b698ae0299bb53597961 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Mon, 9 Nov 2020 23:44:55 +0100 Subject: [PATCH 137/149] The same BG related updates are added to UL --- openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 2 ++ openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index d1dd0f785b..a3e202d4fe 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -139,6 +139,8 @@ typedef struct { uint32_t num_of_mod_symbols; // decode phich uint8_t decode_phich; + // Encoder BG + uint8_t BG; } NR_UL_UE_HARQ_t; typedef struct { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index ee10c96c20..09b58ac584 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -232,7 +232,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, uint8_t mod_order; uint16_t Kr,r; uint32_t r_offset; - uint8_t BG; uint32_t E,Kb; uint8_t Ilbrm; uint32_t Tbslbrm; @@ -255,7 +254,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, R = nr_get_code_rate_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table); Kr=0; r_offset=0; - BG = 1; F=0; Ilbrm = 0; Tbslbrm = 950984; //max tbs @@ -327,10 +325,10 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, Coderate = (float) R /(float) 2048; if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ - BG = 2; + harq_process->BG = 2; } else{ - BG = 1; + harq_process->BG = 1; } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_IN); @@ -341,7 +339,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, &harq_process->K, pz, &harq_process->F, - BG); + harq_process->BG); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_OUT); F = harq_process->F; @@ -399,7 +397,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_IN); - nrLDPC_encoder(harq_process->c,harq_process->d,*pz,Kb,Kr,BG,&impp); + nrLDPC_encoder(harq_process->c,harq_process->d,*pz,Kb,Kr,harq_process->BG,&impp); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_OUT); @@ -448,7 +446,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RATE_MATCHING_LDPC, VCD_FUNCTION_IN); nr_rate_matching_ldpc(Ilbrm, Tbslbrm, - BG, + harq_process->BG, *pz, harq_process->d[r], harq_process->e+r_offset, From 122e18d0886f9f953983809c086caa86b3ed1d2d Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 9 Nov 2020 16:36:05 +0100 Subject: [PATCH 138/149] Common function to check the frequency channel raster --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index b0f0e70335..3dd79d4137 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1744,6 +1744,15 @@ uint16_t config_bandwidth(int mu, int nb_rb, int nr_band) } +void get_delta_arfcn(int i, uint32_t nrarfcn, uint64_t N_OFFs){ + + uint32_t delta_arfcn = nrarfcn - N_OFFs; + + if(delta_arfcn%(nr_bandtable[i].step_size)!=0) + AssertFatal(1 == 0, "nrarfcn %u is not on the channel raster for step size %lu", nrarfcn, nr_bandtable[i].step_size); + +} + uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, @@ -1751,7 +1760,7 @@ uint32_t to_nrarfcn(int nr_bandP, { uint64_t dl_CarrierFreq_by_1k = dl_CarrierFreq / 1000; int bw_kHz = bw / 1000; - uint32_t nrarfcn, delta_arfcn; + uint32_t nrarfcn; int i = get_nr_table_idx(nr_bandP, scs_index); LOG_I(MAC,"Searching for nr band %d DL Carrier frequency %llu bw %u\n",nr_bandP,(long long unsigned int)dl_CarrierFreq,bw); @@ -1783,16 +1792,12 @@ uint32_t to_nrarfcn(int nr_bandP, // This is equation before Table 5.4.2.1-1 in 38101-1-f30 // F_REF=F_REF_Offs + deltaF_Global(N_REF-NREF_REF_Offs) nrarfcn = (((dl_CarrierFreq_by_1k - F_REF_Offs_khz)/deltaFglobal)+N_REF_Offs); - - delta_arfcn = nrarfcn - nr_bandtable[i].N_OFFs_DL; - if(delta_arfcn%(nr_bandtable[i].step_size)!=0) - AssertFatal(1==0,"dl_CarrierFreq %lu corresponds to %u which is not on the raster for step size %lu", - dl_CarrierFreq,nrarfcn,nr_bandtable[i].step_size); + get_delta_arfcn(i, nrarfcn, nr_bandtable[i].N_OFFs_DL); return nrarfcn; } -// This function computes the frequency from the NR-ARFCN according to 5.4.2.1. of 3GPP TS 38.104 +// This function computes the RF reference frequency from the NR-ARFCN according to 5.4.2.1 of 3GPP TS 38.104 // this function applies to both DL and UL uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, @@ -1801,8 +1806,6 @@ uint64_t from_nrarfcn(int nr_bandP, int deltaFglobal = 5; uint32_t N_REF_Offs = 0; uint64_t F_REF_Offs_khz = 0; - int scs_khz = 15<= N_OFFs,"nrarfcn %u < N_OFFs[%d] %llu\n", nrarfcn, nr_bandtable[i].band, (long long unsigned int)N_OFFs); - - delta_arfcn = nrarfcn - N_OFFs; - if(delta_arfcn%(nr_bandtable[i].step_size)!=0) - AssertFatal(1 == 0, "nrarfcn %u is not on the raster for step size %lu", nrarfcn, nr_bandtable[i].step_size); + get_delta_arfcn(i, nrarfcn, N_OFFs); frequency = 1000*(F_REF_Offs_khz + (nrarfcn - N_REF_Offs) * deltaFglobal); From 4353880dbdc6726bc09737721569d6bc402e5065 Mon Sep 17 00:00:00 2001 From: Remi Hardy Date: Tue, 10 Nov 2020 16:53:01 +0100 Subject: [PATCH 139/149] gNB html + log update for nsa fr1 ok --- ci-scripts/ran.py | 49 +++++++++++------------- ci-scripts/xml_files/fr1_ran_ue_proc.xml | 6 ++- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 050eb5bb0d..32b2d7e919 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -133,7 +133,7 @@ class RANManagement(): self.air_interface[self.eNB_instance] = 'nr-softmodem' else: self.air_interface[self.eNB_instance] = 'lte-softmodem' - + # Worakround for some servers, we need to erase completely the workspace if self.Build_eNB_forced_workspace_cleanup: mySSH.command('echo ' + lPassWord + ' | sudo -S rm -Rf ' + lSourcePath, '\$', 15) @@ -427,7 +427,7 @@ class RANManagement(): # Launch eNB with the modified config file mySSH.command('source oaienv', '\$', 5) mySSH.command('cd cmake_targets', '\$', 5) - if self.air_interface == 'nr': + if self.air_interface[self.eNB_instance] == 'nr-softmodem': mySSH.command('if [ -e rbconfig.raw ]; then echo ' + lPassWord + ' | sudo -S rm rbconfig.raw; fi', '\$', 5) mySSH.command('if [ -e reconfig.raw ]; then echo ' + lPassWord + ' | sudo -S rm reconfig.raw; fi', '\$', 5) # NOTE: WE SHALL do a check if the executable is present (in case build went wrong) @@ -568,10 +568,6 @@ class RANManagement(): mySSH = SSH.SSHConnection() mySSH.open(lIpAddr, lUserName, lPassWord) mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) - #RH debug - print(self.air_interface) - print(self.eNB_instance) - # if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): nodeB_prefix = 'e' else: @@ -869,20 +865,17 @@ class RANManagement(): if result is not None: NSA_RAPROC_PUSCH_check = 1 #dlsch and ulsch statistics - #keys below are are the markers we are loooking for, looping over this keys list + #keys below are the markers we are loooking for, loop over this keys list #everytime these markers are found in the log file, the previous ones are overwritten in the dict - #eventually we record only the last one + #eventually we record only the last occurence keys = {'dlsch_rounds','dlsch_total_bytes','ulsch_rounds','ulsch_total_bytes_scheduled'} for k in keys: - result = re.search(k, str(line)) + result = re.search(k, line) if result is not None: - dlsch_ulsch_stats[k]=str(line) - + #remove all char before u(lsch) or d(lsch) + dlsch_ulsch_stats[k]=re.sub(r'^.*([du])', r'\g<1>' , line.rstrip()) enb_log_file.close() logging.debug(' File analysis completed') - #RH debug - print(self.air_interface[self.eNB_instance]+'\n') - # if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): nodeB_prefix = 'e' else: @@ -902,19 +895,21 @@ class RANManagement(): logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') htmleNBFailureMsg += statMsg + '\n' #FR1 NSA test : add new markers to make sure gNB is used - if NSA_RAPROC_PUSCH_check: - statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : PASS ' - else: - statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : FAIL ' - logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') - htmleNBFailureMsg += statMsg + '\n' - #ulsch and dlsch statistics - if len(dlsch_ulsch_stats)!=0: #check if dictionary is not empty - statMsg='' - for key in dlsch_ulsch_stats: #for each dictionary key - statMsg += dlsch_ulsch_stats[key] + '\n' - logging.debug('\u001B[1;30;43m ' + dlsch_ulsch_stats[key] + ' \u001B[0m') - htmleNBFailureMsg += statMsg + '\n' + if NSA_RAPROC_PUSCH_check: + statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : PASS ' + htmlMsg = statMsg+'\n' + else: + statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : FAIL ' + htmlMsg = statMsg+'\n' + logging.debug(statMsg) + htmleNBFailureMsg += htmlMsg + #ulsch and dlsch statistics + if len(dlsch_ulsch_stats)!=0: #check if dictionary is not empty + statMsg='' + for key in dlsch_ulsch_stats: #for each dictionary key + statMsg += dlsch_ulsch_stats[key] + logging.debug(dlsch_ulsch_stats[key]) + htmleNBFailureMsg += statMsg if uciStatMsgCount > 0: statMsg = nodeB_prefix + 'NB showed ' + str(uciStatMsgCount) + ' "uci->stat" message(s)' diff --git a/ci-scripts/xml_files/fr1_ran_ue_proc.xml b/ci-scripts/xml_files/fr1_ran_ue_proc.xml index e86a36d2db..330fb27f21 100644 --- a/ci-scripts/xml_files/fr1_ran_ue_proc.xml +++ b/ci-scripts/xml_files/fr1_ran_ue_proc.xml @@ -89,14 +89,14 @@ Ping Ping: 20pings in 20sec -c 20 - 0 + 50 Ping Ping: 5pings in 1sec -c 5 -i 0.2 - 0 + 50 @@ -104,6 +104,7 @@ Terminate eNB 0 0 + lte @@ -111,6 +112,7 @@ Terminate gNB 1 1 + nr From a452f74f0d7306a2288cdf18c82601e444124186 Mon Sep 17 00:00:00 2001 From: Remi Hardy Date: Tue, 10 Nov 2020 17:14:57 +0100 Subject: [PATCH 140/149] bug fix --- ci-scripts/ran.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 32b2d7e919..8e55b732f8 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -872,8 +872,9 @@ class RANManagement(): for k in keys: result = re.search(k, line) if result is not None: - #remove all char before u(lsch) or d(lsch) - dlsch_ulsch_stats[k]=re.sub(r'^.*([du])', r'\g<1>' , line.rstrip()) + #remove all char before u(lsch) or d(lsch) -> not working for the moment + #dlsch_ulsch_stats[k]=re.sub(r'^.*([du])', r'\g<1>' , line.rstrip()) + dlsch_ulsch_stats[k]=line.rstrip() enb_log_file.close() logging.debug(' File analysis completed') if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): @@ -907,7 +908,7 @@ class RANManagement(): if len(dlsch_ulsch_stats)!=0: #check if dictionary is not empty statMsg='' for key in dlsch_ulsch_stats: #for each dictionary key - statMsg += dlsch_ulsch_stats[key] + statMsg += dlsch_ulsch_stats[key] + '\n' logging.debug(dlsch_ulsch_stats[key]) htmleNBFailureMsg += statMsg From 55717204dccf207f8609b869926a58e20a839d76 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 10 Nov 2020 19:19:51 +0100 Subject: [PATCH 141/149] cleanup: remove TTI related parameters from NR_DL_FRAME_PARMS --- openair1/PHY/INIT/nr_parms.c | 2 -- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 6 ++-- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 20 ++---------- openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 4 --- .../PHY/NR_UE_TRANSPORT/srs_modulation_nr.c | 4 +-- openair1/PHY/defs_nr_common.h | 7 ---- openair1/PHY/thread_NR_UE.h | 4 +-- openair1/SCHED_NR/phy_frame_config_nr.c | 2 +- openair1/SCHED_NR_UE/harq_nr.c | 6 ++-- .../SCHED_NR_UE/pucch_power_control_ue_nr.c | 2 +- openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 6 ++-- openair1/SIMULATION/NR_PHY/prachsim.c | 2 +- .../unit_tests/src/frame_config_test.c | 13 ++++---- .../NR_UE_PHY/unit_tests/src/pucch_uci_test.c | 32 +++++++++++-------- .../NR_UE_PHY/unit_tests/src/srs_test.c | 9 +++--- 15 files changed, 48 insertions(+), 71 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index a9ea74ad87..92d8c2a1c6 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -84,8 +84,6 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp) void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, uint16_t bw) { - fp->ttis_per_subframe = 1; - switch(mu) { case NR_MU_0: //15kHz scs diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index 347c9c2ab9..fa09093306 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -59,7 +59,7 @@ -uint8_t nr_subframe2harq_pid(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t nr_tti_rx) { +uint8_t nr_subframe2harq_pid(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t slot) { /* #ifdef DEBUG_DCI if (frame_parms->frame_type == TDD) @@ -69,11 +69,11 @@ uint8_t nr_subframe2harq_pid(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8 #endif */ uint8_t ret = 255; - uint8_t subframe = nr_tti_rx>>((int)(log2 (frame_parms->ttis_per_subframe))); + uint8_t subframe = slot / frame_parms->slots_per_subframe; AssertFatal(1==0,"Not ready for this ...\n"); if (frame_parms->frame_type == FDD) { - ret = (((frame<<1)+nr_tti_rx)&7); + ret = (((frame<<1)+slot)&7); } else { } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 7378f69c27..43b2e9e3ce 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -296,7 +296,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, return(dlsch->max_ldpc_iterations + 1); } - /*if (nr_tti_rx> (10*frame_parms->ttis_per_subframe-1)) { + /*if (nr_tti_rx> (frame_parms->slots_per_subframe-1)) { printf("dlsch_decoding.c: Illegal subframe index %d\n",nr_tti_rx); return(dlsch->max_ldpc_iterations + 1); }*/ @@ -649,14 +649,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } } - int32_t frame_rx_prev = frame; - int32_t tti_rx_prev = nr_tti_rx - 1; - if (tti_rx_prev < 0) { - frame_rx_prev--; - tti_rx_prev += 10*frame_parms->ttis_per_subframe; - } - frame_rx_prev = frame_rx_prev%1024; - if (err_flag == 1) { //#if UE_DEBUG_TRACE LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n", @@ -843,7 +835,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, return(dlsch->max_ldpc_iterations); } - /* if (nr_tti_rx> (10*frame_parms->ttis_per_subframe-1)) { + /* if (nr_tti_rx> (frame_parms->slots_per_subframe-1)) { printf("dlsch_decoding.c: Illegal subframe index %d\n",nr_tti_rx); return(dlsch->max_ldpc_iterations); } @@ -1246,14 +1238,6 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, } //} //loop r - int32_t frame_rx_prev = frame; - int32_t tti_rx_prev = nr_tti_rx - 1; - if (tti_rx_prev < 0) { - frame_rx_prev--; - tti_rx_prev += 10*frame_parms->ttis_per_subframe; - } - frame_rx_prev = frame_rx_prev%1024; - if (err_flag == 1) { #if UE_DEBUG_TRACE LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n", diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index cf0fc716f9..4ac1c47b02 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -560,7 +560,6 @@ void set_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change { /* set new value according to rate_change */ frame_parms_ue->ofdm_symbol_size = (frame_parms_ue->ofdm_symbol_size / rate_change); - frame_parms_ue->samples_per_tti = (frame_parms_ue->samples_per_tti / rate_change); frame_parms_ue->samples_per_subframe = (frame_parms_ue->samples_per_subframe / rate_change); free_context_pss_nr(); @@ -588,7 +587,6 @@ void set_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change) { frame_parms_ue->ofdm_symbol_size = frame_parms_ue->ofdm_symbol_size * rate_change; - frame_parms_ue->samples_per_tti = frame_parms_ue->samples_per_tti * rate_change; frame_parms_ue->samples_per_subframe = frame_parms_ue->samples_per_subframe * rate_change; free_context_pss_nr(); @@ -620,8 +618,6 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **r NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); int samples_for_frame = 2*frame_parms->samples_per_frame; - AssertFatal(frame_parms->samples_per_tti > 3839,"Illegal samples_per_tti %d\n",frame_parms->samples_per_tti); - #if TEST_SYNCHRO_TIMING_PSS opp_enabled = 1; diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c index aba3c12636..fafe3b2873 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c @@ -278,7 +278,7 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, n_SRS = l/R; } else { - int8_t N_slot_frame = NR_NUMBER_OF_SUBFRAMES_PER_FRAME * frame_parms->ttis_per_subframe; + int8_t N_slot_frame = frame_parms->slots_per_frame; n_SRS = ((N_slot_frame*frame_number + slot_number - T_offset)/T_SRS)*(N_symb_SRS/R)+(l/R); } @@ -399,7 +399,7 @@ int is_srs_period_nr(SRS_Resource_t *p_SRS_Resource, NR_DL_FRAME_PARMS *frame_pa return (-1); } - int16_t N_slot_frame = NR_NUMBER_OF_SUBFRAMES_PER_FRAME * frame_parms->ttis_per_subframe; + int16_t N_slot_frame = frame_parms->slots_per_frame; if ((N_slot_frame*frame_tx + slot_tx - T_offset)%T_SRS == 0) { return (0); } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index a61ecea79f..e5678f894d 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -301,8 +301,6 @@ struct NR_DL_FRAME_PARMS { uint32_t samples_per_slot0; /// Number of samples in other slots of the subframe uint32_t samples_per_slotN0; - /// Number of OFDM/SC-FDMA symbols in one subframe (to be modified to account for potential different in UL/DL) - uint16_t symbols_per_tti; /// Number of samples in a radio frame uint32_t samples_per_frame; /// Number of samples in a subframe without CP @@ -311,13 +309,8 @@ struct NR_DL_FRAME_PARMS { uint32_t samples_per_slot_wCP; /// Number of samples in a radio frame without CP uint32_t samples_per_frame_wCP; - /// Number of samples in a tti (same as subrame in LTE, slot in NR) - uint32_t samples_per_tti; /// NR numerology index [0..5] as specified in 38.211 Section 4 (mu). 0=15khZ SCS, 1=30khZ, 2=60kHz, etc uint8_t numerology_index; - /// NR number of ttis per subframe deduced from numerology (cf 38.211): 1, 2, 4, 8(not supported),16(not supported),32(not supported) - uint8_t ttis_per_subframe; -//#endif /// Number of Physical transmit antennas in node uint8_t nb_antennas_tx; /// Number of Receive antennas in node diff --git a/openair1/PHY/thread_NR_UE.h b/openair1/PHY/thread_NR_UE.h index 94271ed55d..487f6f3d1f 100644 --- a/openair1/PHY/thread_NR_UE.h +++ b/openair1/PHY/thread_NR_UE.h @@ -11,9 +11,9 @@ typedef struct { /// timestamp transmitted to HW openair0_timestamp timestamp_tx; //#ifdef UE_NR_PHY_DEMO - /// NR TTI index within subframe_tx [0 .. ttis_per_subframe - 1] to act upon for transmission + /// NR TTI index within subframe_tx [0 .. slots_per_subframe - 1] to act upon for transmission int nr_tti_tx; - /// NR TTI index within subframe_rx [0 .. ttis_per_subframe - 1] to act upon for reception + /// NR TTI index within subframe_rx [0 .. slots_per_subframe - 1] to act upon for reception int nr_tti_rx; /// NR slot index within frame_tx [0 .. slots_per_frame - 1] to act upon for transmission int nr_slot_tx; diff --git a/openair1/SCHED_NR/phy_frame_config_nr.c b/openair1/SCHED_NR/phy_frame_config_nr.c index 9d34f496b3..f91ec73e5d 100644 --- a/openair1/SCHED_NR/phy_frame_config_nr.c +++ b/openair1/SCHED_NR/phy_frame_config_nr.c @@ -252,7 +252,7 @@ int set_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms) { while(p_current_TDD_UL_DL_SlotConfig != NULL) { int slot_index = p_current_TDD_UL_DL_SlotConfig->slotIndex; - if (slot_index < TDD_CONFIG_NB_FRAMES*(frame_parms->ttis_per_subframe * NR_NUMBER_OF_SUBFRAMES_PER_FRAME)) { + if (slot_index < TDD_CONFIG_NB_FRAMES * frame_parms->slots_per_frame) { if (p_current_TDD_UL_DL_SlotConfig->nrofDownlinkSymbols != 0) { if (p_current_TDD_UL_DL_SlotConfig->nrofDownlinkSymbols == NR_TDD_SET_ALL_SYMBOLS) { if (p_current_TDD_UL_DL_SlotConfig->nrofUplinkSymbols == 0) { diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index 3c3017d658..1a5afac5b5 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -114,7 +114,7 @@ *********************************************************************/ void get_dci_info_for_harq(PHY_VARS_NR_UE *ue, NR_DCI_INFO_EXTRACTED_t *nr_dci_info_extracted, - NR_UE_DLSCH_t **dlsch, NR_UE_ULSCH_t *ulsch, uint8_t nr_tti_rx, uint8_t tx_offset) + NR_UE_DLSCH_t **dlsch, NR_UE_ULSCH_t *ulsch, uint8_t slot, uint8_t tx_offset) { if (nr_dci_info_extracted->identifier_dci_formats == DL_DCI) { @@ -124,14 +124,14 @@ void get_dci_info_for_harq(PHY_VARS_NR_UE *ue, NR_DCI_INFO_EXTRACTED_t *nr_dci_i dl_harq->harq_ack.vDAI_DL = nr_dci_info_extracted->dai+1; dl_harq->harq_ack.pucch_resource_indicator = nr_dci_info_extracted->pucch_resource_ind; - dl_harq->harq_ack.slot_for_feedback_ack = (nr_tti_rx + nr_dci_info_extracted->pdsch_to_harq_feedback_time_ind)%ue->frame_parms.ttis_per_subframe; + dl_harq->harq_ack.slot_for_feedback_ack = (slot + nr_dci_info_extracted->pdsch_to_harq_feedback_time_ind)%ue->frame_parms.slots_per_subframe; dl_harq->harq_ack.harq_id = nr_dci_info_extracted->harq_process_number; dl_harq->harq_ack.rx_status = downlink_harq_process(dl_harq, dlsch[0]->current_harq_pid, nr_dci_info_extracted->ndi, dlsch[0]->rnti_type); } else if (nr_dci_info_extracted->identifier_dci_formats == UL_DCI) { /* store harq id for which pusch should be transmitted at rx_slot + tx_offset */ - set_tx_harq_id(ulsch, nr_dci_info_extracted->harq_process_number, (nr_tti_rx + tx_offset)%ue->frame_parms.ttis_per_subframe); + set_tx_harq_id(ulsch, nr_dci_info_extracted->harq_process_number, (slot + tx_offset)%ue->frame_parms.slots_per_subframe); ulsch->harq_processes[nr_dci_info_extracted->harq_process_number]->tx_status = uplink_harq_process(ulsch, nr_dci_info_extracted->harq_process_number, nr_dci_info_extracted->ndi, ulsch->rnti_type); } } diff --git a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c index b51c8afbb0..b1deb9191b 100644 --- a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c @@ -169,7 +169,7 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, //int K_PUCCH = 0; if (O_ACK != 0) { /* it assumes that PDCCH is in the first symbol of receive slot FFS TDDO NR */ - //int slots_gap = (proc->nr_tti_tx > proc->nr_tti_rx ? (proc->nr_tti_tx - proc->nr_tti_rx - 1) : ((proc->nr_tti_tx + ue->frame_parms.ttis_per_subframe) - proc->nr_tti_rx - 1)); + //int slots_gap = (proc->nr_tti_tx > proc->nr_tti_rx ? (proc->nr_tti_tx - proc->nr_tti_rx - 1) : ((proc->nr_tti_tx + ue->frame_parms.slots_per_subframe) - proc->nr_tti_rx - 1)); //K_PUCCH = (slots_gap * (ue->frame_parms.symbols_per_tti)) - 1; } else { diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index 85e315ecdd..a4ff68dd86 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -238,7 +238,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ /* update current context */ - int subframe_number = (proc->nr_tti_rx)/(ue->frame_parms.slots_per_subframe);//ttis_per_subframe); + int subframe_number = proc->nr_slot_rx / ue->frame_parms.slots_per_subframe; nb_pucch_format_4_in_subframes[subframe_number] = 0; /* reset pucch format 4 counter at current rx position */ int dl_harq_pid = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->current_harq_pid; @@ -490,7 +490,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ //} nb_symbols = nb_symbols_excluding_dmrs[nb_symbols_total-4][index_additional_dmrs][index_hopping]; nb_of_prbs = 1; - subframe_number = nr_tti_tx/(ue->frame_parms.slots_per_subframe);//ttis_per_subframe); + subframe_number = nr_tti_tx / ue->frame_parms.slots_per_subframe; nb_pucch_format_4_in_subframes[subframe_number]++; /* increment number of transmit pucch 4 in current subframe */ NR_TST_PHY_PRINTF("PUCCH Number of pucch format 4 in subframe %d is %d \n", subframe_number, nb_pucch_format_4_in_subframes[subframe_number]); N_sc_ctrl_RB = N_SC_RB/(nb_pucch_format_4_in_subframes[subframe_number]); @@ -1277,7 +1277,7 @@ int trigger_periodic_scheduling_request(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_n return (1); /* period is slot */ } - int16_t N_slot_frame = NR_NUMBER_OF_SUBFRAMES_PER_FRAME * ue->frame_parms.slots_per_subframe;//ttis_per_subframe; + int16_t N_slot_frame = ue->frame_parms.slots_per_frame; if (((proc->frame_tx * N_slot_frame) + proc->nr_tti_tx - SR_offset)%SR_periodicity == 0) { return (1); } diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index c5ad4467af..b4ccac7045 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -705,7 +705,7 @@ int main(int argc, char **argv){ // printf("Sigma2 %f (sigma2_dB %f)\n",sigma2,sigma2_dB); if (awgn_flag == 0) { - multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, frame_parms->samples_per_tti<<1, 0); + multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, frame_parms->samples_per_frame, 0); } if (n_frames==1) { diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c index 1ab935fcae..c88c261667 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c @@ -51,16 +51,16 @@ void display_frame_configuration(NR_DL_FRAME_PARMS *frame_parms) { - printf("\nTdd configuration tti %d downlink %d uplink %d period %d \n", frame_parms->ttis_per_subframe, frame_parms->p_tdd_UL_DL_Configuration->nrofDownlinkSlots, + printf("\nTdd configuration tti %d downlink %d uplink %d period %d \n", frame_parms->slots_per_subframe, frame_parms->p_tdd_UL_DL_Configuration->nrofDownlinkSlots, frame_parms->p_tdd_UL_DL_Configuration->nrofUplinkSlots, frame_parms->p_tdd_UL_DL_Configuration->dl_UL_TransmissionPeriodicity); int k = (TDD_CONFIG_NB_FRAMES * NR_NUMBER_OF_SUBFRAMES_PER_FRAME) - 1; //19; int tti = 0; - for (int j = 0; j < TDD_CONFIG_NB_FRAMES * frame_parms->ttis_per_subframe * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; j++) { + for (int j = 0; j < TDD_CONFIG_NB_FRAMES * frame_parms->slots_per_frame; j++) { int frame = 0; if (j != 0) { - frame = (frame_parms->ttis_per_subframe * NR_NUMBER_OF_SUBFRAMES_PER_FRAME)/j; - tti = (j)%(frame_parms->ttis_per_subframe * NR_NUMBER_OF_SUBFRAMES_PER_FRAME); + frame = j / frame_parms->slots_per_frame; + tti = j % frame_parms->slots_per_frame; } else { frame = 0; @@ -99,9 +99,10 @@ void display_frame_configuration(NR_DL_FRAME_PARMS *frame_parms) { * *********************************************************************/ -void set_tti_test(NR_DL_FRAME_PARMS *frame_parms, int ttis_per_subframe) +void set_tti_test(NR_DL_FRAME_PARMS *frame_parms, int slots_per_subframe) { - frame_parms->ttis_per_subframe = ttis_per_subframe; + frame_parms->slots_per_subframe = slots_per_subframe; + frame_parms->slots_per_frame = slots_per_subframe * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; } /******************************************************************* diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c index ff15dec6a4..403a035c96 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c @@ -182,7 +182,7 @@ int test_pucch_basic_error(PHY_VARS_NR_UE *ue, int gNB_id, UE_nr_rxtx_proc_t *pr /* set a tx slot with no ack */ NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[TST_DL_HARQ_PID_FIRST].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; printf("\n => Test : Error due to acknownlegment not set \n"); @@ -300,7 +300,7 @@ int test_pucch_common_config_single_transport_block(PHY_VARS_NR_UE *ue, int gNB_ harq_status->send_harq_status = 1; harq_status->vDAI_DL = 2; harq_status->ack = DL_ACK; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; printf("\n => Test : PUCCH format from common config in dedicated mode: two positive downlink ACKnowledgments \n"); @@ -567,7 +567,7 @@ int test_pucch_dedicated_single_transport_block(PHY_VARS_NR_UE *ue, int gNB_id, harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[TST_DL_HARQ_PID_FIRST].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = 1; harq_status->ack = DL_ACK; @@ -586,7 +586,7 @@ int test_pucch_dedicated_single_transport_block(PHY_VARS_NR_UE *ue, int gNB_id, NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[dl_harq_pid[i]].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = i+1; harq_status->ack = DL_ACK; @@ -620,7 +620,7 @@ int test_pucch_dedicated_single_transport_block(PHY_VARS_NR_UE *ue, int gNB_id, NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[dl_harq_pid[i]].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = i+1; harq_status->ack = DL_ACK; @@ -684,7 +684,7 @@ int test_pucch_dedicated_two_transport_blocks(PHY_VARS_NR_UE *ue, int gNB_id, UE NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid[i]].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = i+1; harq_status->ack = DL_ACK; @@ -727,7 +727,7 @@ int test_pucch_dedicated_two_transport_blocks(PHY_VARS_NR_UE *ue, int gNB_id, UE NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid[i]].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = i+1; harq_status->ack = DL_ACK; @@ -761,7 +761,7 @@ int test_pucch_dedicated_two_transport_blocks(PHY_VARS_NR_UE *ue, int gNB_id, UE NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid[i]].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = i+1; harq_status->ack = DL_ACK; @@ -980,7 +980,7 @@ int test_sr_ack_dedicated(PHY_VARS_NR_UE *ue, int gNB_id, UE_nr_rxtx_proc_t *pro harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[TST_DL_HARQ_PID_FIRST].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = 1; harq_status->ack = DL_ACK; @@ -1019,7 +1019,7 @@ int test_sr_ack_dedicated(PHY_VARS_NR_UE *ue, int gNB_id, UE_nr_rxtx_proc_t *pro harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[TST_DL_HARQ_PID_SECOND].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = 2; harq_status->ack = DL_ACK; @@ -1094,7 +1094,7 @@ int test_csi_dedicated(PHY_VARS_NR_UE *ue, int gNB_id, UE_nr_rxtx_proc_t *proc) harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[TST_DL_HARQ_PID_FIRST].harq_ack; - harq_status->slot_for_feedback_ack = proc->nr_tti_tx; + harq_status->slot_for_feedback_ack = proc->nr_slot_tx; harq_status->send_harq_status = 1; harq_status->vDAI_DL = 1; harq_status->ack = DL_ACK; @@ -1168,9 +1168,13 @@ int test_pucch(PHY_VARS_NR_UE *ue) assert(0); } - proc->frame_tx = 0; - proc->nr_tti_rx = 0; - proc->nr_tti_tx = (proc->nr_tti_rx + NR_UE_CAPABILITY_SLOT_RX_TO_TX)%(ue->frame_parms.ttis_per_subframe*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); + proc->frame_rx = 0; + proc->nr_slot_rx = 0; + proc->nr_tti_rx = 0; + + proc->frame_tx = proc->frame_rx + (proc->nr_slot_rx + NR_UE_CAPABILITY_SLOT_RX_TO_TX) / ue->frame_parms.slots_per_frame; + proc->nr_slot_tx = (proc->nr_slot_rx + NR_UE_CAPABILITY_SLOT_RX_TO_TX) % ue->frame_parms.slots_per_frame; + proc->nr_tti_tx = proc->nr_slot_tx % ue->frame_parms.slots_per_subframe; init_pucch_power_configuration( ue, gNB_id); diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c index 0bbe7cac7f..8451e78fd6 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c @@ -223,12 +223,13 @@ int test_srs_periodicity(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc) } printf("srs period %d offset %d \n", srs_current_period, p_srs_resource->SRS_Offset); - int duration = (10 * srs_current_period)/(NR_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->ttis_per_subframe); + int duration = (10 * srs_current_period) / frame_parms->slots_per_frame; for (int frame_tx = 0; frame_tx < duration; frame_tx++) { - for (int slot_tx = 0; slot_tx < (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->ttis_per_subframe); slot_tx++) { - proc->frame_tx = frame_tx; - proc->nr_tti_tx = slot_tx; + for (int slot_tx = 0; slot_tx < frame_parms->slots_per_frame; slot_tx++) { + proc->frame_tx = frame_tx; + proc->nr_slot_tx = slot_tx; + proc->nr_tti_tx = slot_tx % frame_parms->slots_per_subframe; if (ue_srs_procedure_nr( ue, proc, 0) == 0) { printf("test_srs_periodicity srs at frame %d slot %d \n", frame_tx, slot_tx); } From 06aefa589f2a01dd2d96bfb097f18f85163fff6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= Date: Tue, 10 Nov 2020 20:39:21 +0100 Subject: [PATCH 142/149] fix(build_helper): fix superfluous $ in protobuf extraction command --- cmake_targets/tools/build_helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index b066bc23d8..f76eae7f28 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -256,7 +256,7 @@ install_protobuf_from_source(){ then rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz - tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $($id -u) --group $(id -g) --no-same-owner + tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $(id -u) --group $(id -g) --no-same-owner cd protobuf-3.3.0/ else export LD_LIBRARY_PATH=/usr/local/lib #protoc needs to know where toclook for shared libs From f2502eebab8d07447766339af6addcf676a3fcbc Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 10 Nov 2020 21:10:55 +0100 Subject: [PATCH 143/149] fix some compile warnings --- openair1/SIMULATION/NR_PHY/prachsim.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index b4ccac7045..fc02cf5ece 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -116,9 +116,9 @@ int main(int argc, char **argv){ int i, aa, aarx, **txdata, trial, n_frames = 1, prach_start, rx_prach_start; //, ntrials=1; int N_RB_UL = 106, delay = 0, NCS_config = 13, rootSequenceIndex = 1, threequarter_fs = 0, mu = 1, fd_occasion = 0, loglvl = OAILOG_INFO, numRA = 0, prachStartSymbol = 0; uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format=0; - uint8_t frame = 1, subframe = 9, slot=19, slot_gNB=19, config_index = 98, prach_sequence_length = 1, num_root_sequences = 16, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; + uint8_t frame = 1, subframe = 9, slot=19, slot_gNB=19, config_index = 98, prach_sequence_length = 1, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; uint16_t Nid_cell = 0, preamble_tx = 0, preamble_delay, format, format0, format1; - uint32_t tx_lev = 10000, prach_errors = 0, samp_count; //,tx_lev_dB; + uint32_t tx_lev = 10000, prach_errors = 0; //,tx_lev_dB; uint64_t SSB_positions = 0x01, absoluteFrequencyPointA = 640000; uint16_t RA_sfn_index; uint8_t N_RA_slot; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 148f77c768..8e49403c71 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -449,7 +449,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, break; default: - AssertFatal(1==0,"Undefined tdd period %d\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + AssertFatal(1==0,"Undefined tdd period %ld\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); } int num_slots_per_tdd = (slots_per_frame[*scc->ssbSubcarrierSpacing])/nb_periods_per_frame; From 434186fd9f1cd60d7b469c9be276fbf7465dce2d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 11 Nov 2020 16:42:46 +0100 Subject: [PATCH 144/149] Correct TA timer condition - wrap around 1024 (frame number is 0-1023) - check for equality of frames with high numbers will trigger every 10ms --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index a3c724e6f6..6a04e06073 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -641,7 +641,7 @@ void nr_schedule_ue_spec(module_id_t module_id, * Possible improvement: take the periodicity from input file. * If such UE is not scheduled now, it will be by the preprocessor later. * If we add the CE, ta_apply will be reset */ - if (frame >= (sched_ctrl->ta_frame + 10) % 1023) + if (frame == (sched_ctrl->ta_frame + 10) % 1024) sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */ if (sched_ctrl->rbSize <= 0) From 67d63111437b7ab9e92afea8d7a021343b5cb0ab Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 11 Nov 2020 16:47:18 +0100 Subject: [PATCH 145/149] Hotfix: disable TA to keep RTT low + HARQ retx intact --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 6a04e06073..7a7fe1288c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -642,7 +642,7 @@ void nr_schedule_ue_spec(module_id_t module_id, * If such UE is not scheduled now, it will be by the preprocessor later. * If we add the CE, ta_apply will be reset */ if (frame == (sched_ctrl->ta_frame + 10) % 1024) - sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */ + sched_ctrl->ta_apply = false; /* the timer is reset once TA CE is scheduled */ if (sched_ctrl->rbSize <= 0) continue; From 308de3b68d7c2dc3e619a2c7671839fe874c5222 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 11 Nov 2020 16:48:40 +0100 Subject: [PATCH 146/149] Lower PHY/HARQ log level --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 6 +++--- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 1fd89ea568..83a66b55fb 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -412,7 +412,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0; uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1); uci_pdu->harq->harq_list[0].harq_value = index&0x01; - LOG_I(PHY, "Slot %d HARQ value %d with confidence level (0 is good, 1 is bad) %d\n", + LOG_D(PHY, "Slot %d HARQ value %d with confidence level (0 is good, 1 is bad) %d\n", slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); @@ -427,7 +427,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2); uci_pdu->harq->harq_list[1].harq_value = index&0x01; uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01; - LOG_I(PHY, "Slot %d HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n", + LOG_D(PHY, "Slot %d HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n", slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); @@ -1464,7 +1464,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, } } // cw loop corr_dB = dB_fixed64((uint64_t)corr); - LOG_I(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB); + LOG_D(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB); decodedPayload[0]=(uint64_t)cw_ML; } else { // polar coded case diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 148f77c768..74eee7077f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -372,7 +372,7 @@ void nr_schedule_pucch(int Mod_idP, memset(pucch_pdu,0,sizeof(nfapi_nr_pucch_pdu_t)); UL_tti_req->n_pdus+=1; - LOG_I(MAC,"Scheduling pucch reception for frame %d slot %d with (%d, %d, %d) (SR ACK, CSI) bits\n", + LOG_D(MAC,"Scheduling pucch reception for frame %d slot %d with (%d, %d, %d) (SR ACK, CSI) bits\n", frameP,slotP,O_sr,O_ack,curr_pucch->csi_bits); nr_configure_pucch(pucch_pdu, From fe6f7244df16a451e3aaa25d2839507e57001cb6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 6 Nov 2020 16:59:37 +0100 Subject: [PATCH 147/149] Fix compiler warning: %ld in printf --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 74eee7077f..5d701bf5b8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -449,7 +449,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, break; default: - AssertFatal(1==0,"Undefined tdd period %d\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + AssertFatal(1==0,"Undefined tdd period %ld\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); } int num_slots_per_tdd = (slots_per_frame[*scc->ssbSubcarrierSpacing])/nb_periods_per_frame; From 0ea4378bd8ba1e3f780da6598e80f1cd63e4135c Mon Sep 17 00:00:00 2001 From: Remi Hardy Date: Thu, 12 Nov 2020 10:40:16 +0100 Subject: [PATCH 148/149] fixing reporting appearance --- ci-scripts/ran.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 8e55b732f8..6425d55c8f 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -867,14 +867,13 @@ class RANManagement(): #dlsch and ulsch statistics #keys below are the markers we are loooking for, loop over this keys list #everytime these markers are found in the log file, the previous ones are overwritten in the dict - #eventually we record only the last occurence + #eventually we record and print only the last occurence keys = {'dlsch_rounds','dlsch_total_bytes','ulsch_rounds','ulsch_total_bytes_scheduled'} for k in keys: result = re.search(k, line) if result is not None: - #remove all char before u(lsch) or d(lsch) -> not working for the moment - #dlsch_ulsch_stats[k]=re.sub(r'^.*([du])', r'\g<1>' , line.rstrip()) - dlsch_ulsch_stats[k]=line.rstrip() + #remove 1- all useless char before relevant info (ulsch or dlsch) 2- trailing char + dlsch_ulsch_stats[k]=re.sub(r'^.*\]\s+', r'' , line.rstrip()) enb_log_file.close() logging.debug(' File analysis completed') if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): From 7b48f894962a43bc13815d7a309fe33f48853254 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 16 Nov 2020 10:25:58 +0100 Subject: [PATCH 149/149] minor: remove a CPPCHECK error for NR RLC This "error" is not a real error. openair2/LAYER2/nr_rlc/tests/test.c includes testXX.h to define the array int test[] and by design test[2] always exists. Let's simply suppress the reporting of this error. --- ci-scripts/cppcheck_suppressions.list | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci-scripts/cppcheck_suppressions.list b/ci-scripts/cppcheck_suppressions.list index 4b9fb97427..f8438a4276 100644 --- a/ci-scripts/cppcheck_suppressions.list +++ b/ci-scripts/cppcheck_suppressions.list @@ -84,6 +84,12 @@ nullPointer:common/utils/T/tracer/multi.c:265 arrayIndexOutOfBounds:openair2/LAYER2/rlc_v2/tests/test.c:401 // //----------------------------------------------------------------------------- +// this file is used for testing the NR RLC implementation, this error is +// not a problem, the programmer has to know what she does when writing +// the tests +arrayIndexOutOfBounds:openair2/LAYER2/nr_rlc/tests/test.c:451 +// +//----------------------------------------------------------------------------- // cppcheck does not understand the different lengths of arrays arrayIndexOutOfBounds:openair1/SIMULATION/TOOLS/random_channel.c:705 arrayIndexOutOfBounds:openair1/SIMULATION/TOOLS/random_channel.c:706