From 56c900055831418e89f90df9f73249d6c2d9ccd3 Mon Sep 17 00:00:00 2001 From: Lionel Gauthier <lionel.gauthier@eurecom.fr> Date: Fri, 10 Apr 2015 13:18:11 +0000 Subject: [PATCH] branch LG_PRE_RELEASE_0.3 reintegration git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7117 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- common/utils/itti/assertions.h | 11 +- oaienv | 1 + openair1/EMOS/GPS/read_iw.c | 3 +- openair2/ENB_APP/enb_app.c | 11 +- openair2/ENB_APP/enb_config.c | 380 +-- openair2/LAYER2/MAC/config.c | 68 +- openair2/LAYER2/MAC/eNB_scheduler.c | 34 +- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 15 +- openair2/LAYER2/MAC/eNB_scheduler_bch.c | 38 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 247 +- openair2/LAYER2/MAC/eNB_scheduler_mch.c | 112 +- .../LAYER2/MAC/eNB_scheduler_primitives.c | 112 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 139 +- openair2/LAYER2/MAC/l1_helpers.c | 3 +- openair2/LAYER2/MAC/lte_transport_init.c | 11 +- openair2/LAYER2/MAC/main.c | 22 +- openair2/LAYER2/MAC/openair2_proc.c | 29 +- openair2/LAYER2/MAC/pre_processor.c | 134 +- openair2/LAYER2/MAC/proto.h | 49 +- openair2/LAYER2/MAC/ra_procedures.c | 58 +- openair2/LAYER2/MAC/rar_tools.c | 36 +- openair2/LAYER2/MAC/ue_procedures.c | 314 ++- openair2/LAYER2/Makefile.inc | 1 + openair2/LAYER2/PDCP/pdcp.c | 80 +- openair2/LAYER2/PDCP/pdcp.h | 4 +- openair2/LAYER2/PDCP/pdcp_fifo.c | 95 +- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 1050 ++++---- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 48 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 610 ++--- openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c | 64 +- .../LAYER2/PDCP_v10.1.0/pdcp_primitives.c | 21 +- .../PDCP_v10.1.0/pdcp_sequence_manager.c | 30 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c | 5 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c | 3 +- openair2/LAYER2/RLC/AM/rlc_am.c | 15 +- .../LAYER2/RLC/AM/rlc_am_control_primitives.c | 187 +- openair2/LAYER2/RLC/AM/rlc_am_discard_notif.c | 112 +- openair2/LAYER2/RLC/AM/rlc_am_discard_rx.c | 102 +- openair2/LAYER2/RLC/AM/rlc_am_discard_tx.c | 158 +- openair2/LAYER2/RLC/AM/rlc_am_fsm.c | 15 +- openair2/LAYER2/RLC/AM/rlc_am_mac_status.c | 14 +- openair2/LAYER2/RLC/AM/rlc_am_mux.c | 435 ++- openair2/LAYER2/RLC/AM/rlc_am_reassembly.c | 18 +- openair2/LAYER2/RLC/AM/rlc_am_receiver.c | 116 +- openair2/LAYER2/RLC/AM/rlc_am_reset.c | 62 +- openair2/LAYER2/RLC/AM/rlc_am_retrans.c | 192 +- openair2/LAYER2/RLC/AM/rlc_am_segment.c | 152 +- openair2/LAYER2/RLC/AM/rlc_am_util.c | 111 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 404 +-- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h | 13 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h | 4 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c | 8 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c | 48 +- .../LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c | 167 +- .../LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c | 125 +- .../LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h | 10 +- .../LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c | 372 +-- .../LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c | 368 +-- .../LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c | 192 +- .../RLC/AM_v9.3.0/rlc_am_segments_holes.c | 81 +- .../RLC/AM_v9.3.0/rlc_am_status_report.c | 223 +- .../LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h | 6 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c | 23 +- .../AM_v9.3.0/rlc_am_timer_poll_retransmit.c | 63 +- .../RLC/AM_v9.3.0/rlc_am_timer_reordering.c | 71 +- .../AM_v9.3.0/rlc_am_timer_status_prohibit.c | 67 +- openair2/LAYER2/RLC/TM/rlc_tm.c | 135 +- openair2/LAYER2/RLC/TM/rlc_tm_segment.c | 68 +- openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c | 48 +- openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.h | 4 + openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h | 2 - openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c | 30 +- openair2/LAYER2/RLC/UM/rlc_um.c | 162 +- openair2/LAYER2/RLC/UM/rlc_um_receiver.c | 141 +- openair2/LAYER2/RLC/UM/rlc_um_segment.c | 247 +- openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um.c | 131 +- .../RLC/UM_v6.1.0_LITE/rlc_um_receiver.c | 94 +- .../RLC/UM_v6.1.0_LITE/rlc_um_segment.c | 247 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c | 273 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h | 11 + .../RLC/UM_v9.3.0/rlc_um_control_primitives.c | 95 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c | 596 ++--- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h | 10 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h | 8 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c | 65 +- .../LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c | 106 +- .../LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c | 27 +- .../LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c | 292 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c | 23 +- openair2/LAYER2/RLC/rlc.c | 215 +- openair2/LAYER2/RLC/rlc.h | 46 +- openair2/LAYER2/RLC/rlc_mac.c | 183 +- openair2/LAYER2/RLC/rlc_rrc.c | 323 +-- openair2/LAYER2/openair2_proc.c | 36 +- openair2/Makefile | 24 +- openair2/NAS/DRIVER/CELLULAR/NASMT/Makefile | 10 +- .../DRIVER/CELLULAR/NASMT/nasmt_ascontrol.c | 32 +- .../NAS/DRIVER/CELLULAR/NASMT/nasmt_common.c | 16 +- .../DRIVER/CELLULAR/NASMT/nasmt_constant.h | 2 +- .../NAS/DRIVER/CELLULAR/NASMT/nasmt_device.c | 30 +- .../NAS/DRIVER/CELLULAR/NASMT/nasmt_netlink.c | 2 +- .../NAS/DRIVER/CELLULAR/NASMT/nasmt_proto.h | 2 +- .../NAS/DRIVER/CELLULAR/NASMT/nasmt_sap.h | 2 +- openair2/NAS/DRIVER/CELLULAR/NASRG/Makefile | 10 +- .../DRIVER/CELLULAR/NASRG/nasrg_ascontrol.c | 36 +- .../NAS/DRIVER/CELLULAR/NASRG/nasrg_common.c | 24 +- .../DRIVER/CELLULAR/NASRG/nasrg_constant.h | 2 +- .../NAS/DRIVER/CELLULAR/NASRG/nasrg_device.c | 30 +- .../NAS/DRIVER/CELLULAR/NASRG/nasrg_netlink.c | 2 +- .../NAS/DRIVER/CELLULAR/NASRG/nasrg_proto.h | 2 +- .../NAS/DRIVER/CELLULAR/NASRG/nasrg_sap.h | 2 +- .../NAS/DRIVER/CELLULAR/NETLTEST/netltest.c | 4 +- .../DRIVER/CELLULAR/NETLTEST/nettestPDCP.c | 4 +- openair2/NAS/DRIVER/LITE/Makefile | 4 +- openair2/NAS/DRIVER/LITE/netlink.c | 6 +- openair2/NAS/DRIVER/MESH/Makefile | 17 +- .../NAS/DRIVER/MESH/TESTBENCH/testbench.c | 4 +- openair2/NAS/DRIVER/MESH/common.c | 28 +- openair2/NAS/DRIVER/MESH/device.c | 26 +- openair2/NAS/DRIVER/MESH/local.h | 4 +- openair2/NAS/DRIVER/MESH/mesh.c | 24 +- openair2/NAS/DRIVER/MESH/netlink.c | 10 +- openair2/NAS/DRIVER/MESH/proto_extern.h | 49 +- openair2/NAS/SIMU_CELLULAR/Makefile | 2 +- openair2/NETWORK_DRIVER/UE_IP/README | 1 + openair2/NETWORK_DRIVER/UE_IP/common.c | 11 +- openair2/NETWORK_DRIVER/UE_IP/device.c | 26 +- openair2/NETWORK_DRIVER/UE_IP/local.h | 2 +- openair2/NETWORK_DRIVER/UE_IP/netlink.c | 23 +- openair2/RRC/CELLULAR/Makefile | 2 +- openair2/RRC/CELLULAR/rrc_constant.h | 4 +- openair2/RRC/CELLULAR/rrc_nas_sap.h | 4 +- .../L2_INTERFACE/openair_rrc_L2_interface.c | 199 +- .../L2_INTERFACE/openair_rrc_L2_interface.h | 119 +- openair2/RRC/LITE/L2_interface.c | 403 +-- openair2/RRC/LITE/MESSAGES/Makefile | 2 +- openair2/RRC/LITE/MESSAGES/asn1_msg.c | 238 +- openair2/RRC/LITE/MESSAGES/asn1_msg.h | 66 +- openair2/RRC/LITE/MESSAGES/bsearch.c | 10 +- openair2/RRC/LITE/MESSAGES/rtai_mem.c | 4 +- openair2/RRC/LITE/defs.h | 182 +- openair2/RRC/LITE/mesh_top.c | 3 +- openair2/RRC/LITE/proto.h | 425 ++- openair2/RRC/LITE/rrc_2_rrm_msg.c | 5 +- openair2/RRC/LITE/rrc_UE.c | 1607 +++++++----- openair2/RRC/LITE/rrc_common.c | 352 ++- openair2/RRC/LITE/rrc_config.c | 13 +- openair2/RRC/LITE/rrc_eNB.c | 2337 +++++++++++------ openair2/RRC/LITE/rrc_eNB_GTPV1U.c | 35 +- openair2/RRC/LITE/rrc_eNB_GTPV1U.h | 15 +- openair2/RRC/LITE/rrc_eNB_S1AP.c | 680 +++-- openair2/RRC/LITE/rrc_eNB_S1AP.h | 98 +- openair2/RRC/LITE/rrc_eNB_UE_context.c | 202 ++ openair2/RRC/LITE/rrc_eNB_UE_context.h | 88 + openair2/RRC/LITE/rrc_eNB_ral.h | 3 +- openair2/RRC/LITE/rrc_rrm_interface.c | 15 +- openair2/RRC/LITE/rrm_2_rrc_msg.c | 24 +- openair2/RRC/LITE/utils.c | 14 +- openair2/RRC/NAS/nas_config.c | 6 +- openair2/UTIL/MEM/mem_block.c | 53 +- openair2/UTIL/MEM/mem_block.h | 5 +- openair2/UTIL/MEM/mem_mngt.c | 15 +- openair2/UTIL/OCG/OCG.c | 3 - openair2/UTIL/OCG/OCG.h | 5 + openair2/UTIL/OCG/OCG_create_dir.c | 4 - openair2/UTIL/OCG/OCG_detect_file.c | 2 - openair2/UTIL/OCG/OCG_generate_report.c | 2 - openair2/UTIL/OCG/OCG_parse_XML.c | 2 - openair2/UTIL/OCG/OCG_parse_filename.c | 4 - openair2/UTIL/OCG/OCG_save_XML.c | 3 - openair2/UTIL/OCG/makefile | 6 +- openair2/UTIL/OMG/makefile | 4 +- openair2/UTIL/OMG/makefile_old | 4 +- openair2/UTIL/OMG/socket_traci_OMG.c | 2 - openair2/UTIL/OTG/otg_defs.h | 174 +- openair2/UTIL/OTG/otg_models.c | 1 + openair2/UTIL/OTG/otg_rx.c | 390 ++- openair2/UTIL/OTG/otg_rx.h | 19 +- openair2/UTIL/OTG/otg_tx.c | 1066 +++++--- openair2/UTIL/OTG/otg_tx.h | 95 +- openair3/MESH/RRM/Makefile | 2 +- targets/ARCH/EXMIMO/DRIVER/eurecom/Makefile | 2 +- .../ARCH/EXMIMO/DRIVER/eurecom/module_main.c | 15 +- targets/ARCH/EXMIMO/DRIVER/exmimo3/Makefile | 2 +- .../ARCH/EXMIMO/DRIVER/exmimo3/module_main.c | 15 +- .../ARCH/EXMIMO/USERSPACE/LIB/gain_control.c | 6 +- .../ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.c | 6 +- .../EXMIMO/USERSPACE/OAI_FW_INIT/updatefw.c | 18 +- targets/Makefile.common | 63 +- targets/PROJECTS/E-MBMS/build_all.bash | 4 +- targets/PROJECTS/E-MBMS/utils.bash | 6 +- .../start_enb_and_ue_virt.bash | 2 +- targets/PROJECTS/GENERIC-LTE-EPC/utils.bash | 4 +- .../PROJECTS/GENERIC-LTE-EPC/virtual_box.bash | 2 +- .../clientSensing/client/spectra_client.c | 9 +- .../common/openair_scripts/build_all.bash | 4 +- .../common/openair_scripts/utils.bash | 3 - targets/PROJECTS/SPECTRA/build_all.bash | 4 +- targets/PROJECTS/SPECTRA/utils.bash | 3 - targets/README.txt | 12 +- targets/RT/Makefile | 2 +- targets/RT/USER/Makefile | 16 +- targets/RT/USER/Makefile.agilent | 2 +- targets/RT/USER/emos-raw.c | 2 +- targets/RT/USER/init_exmimo2.sh | 32 +- targets/RT/USER/lte-softmodem.c | 26 +- targets/RT/USER/synctest.c | 2 +- targets/SCRIPTS/msc_gen.py | 165 +- .../SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE/Makefile | 2 +- .../Makefile | 2 +- .../SIMU/EXAMPLES/ETH_EMUL_1eNB_2UE/Makefile | 2 +- targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/Makefile | 4 +- .../VIRT_EMUL_1eNB/start_one_eNB_multi_UE_nas | 4 +- .../EXAMPLES/VIRT_EMUL_1eNB_OAI_LITE/Makefile | 2 +- targets/SIMU/USER/Makefile | 26 +- targets/SIMU/USER/event_handler.c | 5 +- targets/SIMU/USER/oaisim.c | 36 +- targets/TEST/AT_COMMANDS/Makefile | 6 +- targets/TEST/OAI/case01.py | 12 +- targets/TEST/PACKET_TRACER/Makefile | 4 +- targets/TEST/PDCP/Makefile | 6 +- targets/TEST/PDCP/test_pdcp.c | 8 +- targets/TEST/PDCP/test_pdcp.h | 23 +- .../TEST/PDCP/with_rlc/Makefile.data_bearer | 6 +- targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c | 3 +- targets/TEST/RLC_AM_V9.3.0/Makefile | 4 +- targets/TEST/RLC_UM_V9.3.0/Makefile | 4 +- 227 files changed, 11369 insertions(+), 10096 deletions(-) create mode 100755 openair2/NETWORK_DRIVER/UE_IP/README create mode 100644 openair2/RRC/LITE/rrc_eNB_UE_context.c create mode 100644 openair2/RRC/LITE/rrc_eNB_UE_context.h diff --git a/common/utils/itti/assertions.h b/common/utils/itti/assertions.h index 4a33a090f2d..df14404c79e 100644 --- a/common/utils/itti/assertions.h +++ b/common/utils/itti/assertions.h @@ -29,6 +29,7 @@ #include <stdio.h> #include <stdlib.h> +#include <inttypes.h> #ifdef CMAKER #include <platform_types.h> #endif @@ -67,9 +68,13 @@ do { \ -#define DevCheck(cOND, vALUE1, vALUE2, vALUE3) \ -_Assert_(cOND, _Assert_Exit_, #vALUE1": %d\n"#vALUE2": %d\n"#vALUE3": %d\n\n", \ - (int)vALUE1, (int)vALUE2, (int)vALUE3) +#define DevCheck(cOND, vALUE1, vALUE2, vALUE3) \ +_Assert_(cOND, _Assert_Exit_, #vALUE1 ": %" PRIdMAX "\n" #vALUE2 ": %" PRIdMAX "\n" #vALUE3 ": %" PRIdMAX "\n\n", \ + (intmax_t)vALUE1, (intmax_t)vALUE2, (intmax_t)vALUE3) + +#define DevCheck4(cOND, vALUE1, vALUE2, vALUE3, vALUE4) \ +_Assert_(cOND, _Assert_Exit_, #vALUE1": %"PRIdMAX"\n"#vALUE2": %"PRIdMAX"\n"#vALUE3": %"PRIdMAX"\n"#vALUE4": %"PRIdMAX"\n\n", \ + (intmax_t)vALUE1, (intmax_t)vALUE2, (intmax_t)vALUE3, (intmax_t)vALUE4) #define DevParam(vALUE1, vALUE2, vALUE3) DevCheck(0, vALUE1, vALUE2, vALUE3) diff --git a/oaienv b/oaienv index ebddf796706..9b5af56b933 100644 --- a/oaienv +++ b/oaienv @@ -1,5 +1,6 @@ export OPENAIR_HOME=$(pwd) +export OPENAIR_DIR=$(pwd) export OPENAIR1_DIR=$OPENAIR_HOME/openair1 export OPENAIR2_DIR=$OPENAIR_HOME/openair2 export OPENAIR3_DIR=$OPENAIR_HOME/openair3 diff --git a/openair1/EMOS/GPS/read_iw.c b/openair1/EMOS/GPS/read_iw.c index ca34fe7d5d9..fbd75e5d355 100644 --- a/openair1/EMOS/GPS/read_iw.c +++ b/openair1/EMOS/GPS/read_iw.c @@ -150,8 +150,9 @@ int main(int argc, char *argv[]) iw_field.rx_gi2); //printf("read set %d, time %d:%d:%d\n",i,iw_field.hour,iw_field.min,iw_field.sec); - if (i==0) + if (i==0) { printf("num, date; inactive_time; rx_bytes; rx_packets; tx_bytes; tx_packets; tx_retries; tx_failed; signal; signal0; signal1; tx_bitrate; tx_mcs; rx_bitrate; rx_mcs\n"); + } printf("%d; %d-%s-%d %d:%d:%d; %d; %d; %d; %d; %d; %d; %d; %d; %d; %d; %e; %d; %e; %d\n", i, diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index c12e8b2139a..b4eb87e8f37 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -68,7 +68,7 @@ extern unsigned char NB_eNB_INST; # endif /*------------------------------------------------------------------------------*/ -static void configure_phy(uint32_t enb_id, const Enb_properties_array_t *enb_properties) +static void configure_phy(module_id_t enb_id, const Enb_properties_array_t* enb_properties) { MessageDef *msg_p; int CC_id; @@ -86,7 +86,7 @@ static void configure_phy(uint32_t enb_id, const Enb_properties_array_t *enb_pro PHY_CONFIGURATION_REQ (msg_p).rx_gain[CC_id] = enb_properties->properties[enb_id]->rx_gain[CC_id]; } - itti_send_msg_to_task (TASK_PHY_ENB, enb_id, msg_p); + itti_send_msg_to_task (TASK_PHY_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); } /*------------------------------------------------------------------------------*/ @@ -189,7 +189,7 @@ static void configure_rrc(uint32_t enb_id, const Enb_properties_array_t *enb_pro RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[CC_id] = enb_properties->properties[enb_id]->ue_TimersAndConstants_n311[CC_id]; } - itti_send_msg_to_task (TASK_RRC_ENB, enb_id, msg_p); + itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); } /*------------------------------------------------------------------------------*/ @@ -231,7 +231,8 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, con s1ap_register_eNB->default_drx = enb_properties->properties[enb_id]->pcch_defaultPagingCycle[0]; s1ap_register_eNB->nb_mme = enb_properties->properties[enb_id]->nb_mme; - AssertFatal (s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS, "Too many MME for eNB %d (%d/%d)!", enb_id, s1ap_register_eNB->nb_mme, S1AP_MAX_NB_MME_IP_ADDRESS); + AssertFatal (s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS, "Too many MME for eNB %d (%d/%d)!", enb_id, s1ap_register_eNB->nb_mme, + S1AP_MAX_NB_MME_IP_ADDRESS); for (mme_id = 0; mme_id < s1ap_register_eNB->nb_mme; mme_id++) { s1ap_register_eNB->mme_ip_address[mme_id].ipv4 = enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv4; @@ -250,7 +251,7 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, con str = inet_ntoa(addr); strcpy(s1ap_register_eNB->enb_ip_address.ipv4_address, str); - itti_send_msg_to_task (TASK_S1AP, enb_id, msg_p); + itti_send_msg_to_task (TASK_S1AP, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); register_enb_pending++; } diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 00c1ce0766a..875dec04ccd 100755 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -56,6 +56,7 @@ # include "sctp_eNB_task.h" # endif #endif +#include "SystemInformationBlockType2.h" #include "LAYER2/MAC/extern.h" #define ENB_CONFIG_STRING_ACTIVE_ENBS "Active_eNBs" @@ -256,10 +257,11 @@ static void enb_config_display(void) printf( "\tTAC: \t%"PRIu16":\n",enb_properties.properties[i]->tac); printf( "\tMCC: \t%"PRIu16":\n",enb_properties.properties[i]->mcc); - if (enb_properties.properties[i]->mnc_digit_length == 3) + if (enb_properties.properties[i]->mnc_digit_length == 3) { printf( "\tMNC: \t%03"PRIu16":\n",enb_properties.properties[i]->mnc); - else + } else { printf( "\tMNC: \t%02"PRIu16":\n",enb_properties.properties[i]->mnc); + } for (j=0; j< enb_properties.properties[i]->nb_cc; j++) { printf( "\teutra band for CC %d: \t%"PRId16":\n",j,enb_properties.properties[i]->eutra_band[j]); @@ -445,12 +447,12 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) config_setting_t *subsetting_otg = NULL; int num_enb_properties = 0; int enb_properties_index = 0; - int num_enbs; - int num_mme_address; + int num_enbs = 0; + int num_mme_address = 0; int num_otg_elements =0; int num_component_carriers =0; - int i; - int j; + int i = 0; + int j = 0; int parse_errors = 0; libconfig_int enb_id = 0; const char* cell_type = NULL; @@ -458,79 +460,79 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) const char* enb_name = NULL; const char* mcc = 0; const char* mnc = 0; - const char* frame_type; - libconfig_int tdd_config; - libconfig_int tdd_config_s; + const char* frame_type = NULL; + libconfig_int tdd_config = 0; + libconfig_int tdd_config_s = 0; const char* prefix_type = NULL; - libconfig_int eutra_band; - long long int downlink_frequency; - libconfig_int uplink_frequency_offset; - libconfig_int Nid_cell; - libconfig_int Nid_cell_mbsfn; - libconfig_int N_RB_DL; - libconfig_int nb_antennas_tx; - libconfig_int nb_antennas_rx; - libconfig_int tx_gain; - libconfig_int rx_gain; - libconfig_int prach_root; - libconfig_int prach_config_index; + libconfig_int eutra_band = 0; + long long int downlink_frequency = 0; + libconfig_int uplink_frequency_offset = 0; + libconfig_int Nid_cell = 0; + libconfig_int Nid_cell_mbsfn = 0; + libconfig_int N_RB_DL = 0; + libconfig_int nb_antennas_tx = 0; + libconfig_int nb_antennas_rx = 0; + libconfig_int tx_gain = 0; + libconfig_int rx_gain = 0; + libconfig_int prach_root = 0; + libconfig_int prach_config_index = 0; const char* prach_high_speed = NULL; - libconfig_int prach_zero_correlation; - libconfig_int prach_freq_offset; - libconfig_int pucch_delta_shift; - libconfig_int pucch_nRB_CQI; - libconfig_int pucch_nCS_AN; + libconfig_int prach_zero_correlation = 0; + libconfig_int prach_freq_offset = 0; + libconfig_int pucch_delta_shift = 0; + libconfig_int pucch_nRB_CQI = 0; + libconfig_int pucch_nCS_AN = 0; #ifndef Rel10 - libconfig_int pucch_n1_AN; + libconfig_int pucch_n1_AN = 0; #endif - libconfig_int pdsch_referenceSignalPower; - libconfig_int pdsch_p_b; - libconfig_int pusch_n_SB; + libconfig_int pdsch_referenceSignalPower = 0; + libconfig_int pdsch_p_b = 0; + libconfig_int pusch_n_SB = 0; const char * pusch_hoppingMode = NULL; - libconfig_int pusch_hoppingOffset; + libconfig_int pusch_hoppingOffset = 0; const char* pusch_enable64QAM = NULL; const char* pusch_groupHoppingEnabled = NULL; - libconfig_int pusch_groupAssignment; + libconfig_int pusch_groupAssignment = 0; const char* pusch_sequenceHoppingEnabled = NULL; - libconfig_int pusch_nDMRS1; - const char* phich_duration; - const char* phich_resource; - const char* srs_enable; - libconfig_int srs_BandwidthConfig; - libconfig_int srs_SubframeConfig; - const char* srs_ackNackST; - const char* srs_MaxUpPts; - libconfig_int pusch_p0_Nominal; - const char* pusch_alpha; - libconfig_int pucch_p0_Nominal; - libconfig_int msg3_delta_Preamble; - libconfig_int ul_CyclicPrefixLength; - const char* pucch_deltaF_Format1; - const char* pucch_deltaF_Format1a; - const char* pucch_deltaF_Format1b; - const char* pucch_deltaF_Format2; - const char* pucch_deltaF_Format2a; - const char* pucch_deltaF_Format2b; - libconfig_int rach_numberOfRA_Preambles; - const char* rach_preamblesGroupAConfig; - libconfig_int rach_sizeOfRA_PreamblesGroupA; - libconfig_int rach_messageSizeGroupA; - const char* rach_messagePowerOffsetGroupB; - libconfig_int rach_powerRampingStep; - libconfig_int rach_preambleInitialReceivedTargetPower; - libconfig_int rach_preambleTransMax; - libconfig_int rach_raResponseWindowSize; - libconfig_int rach_macContentionResolutionTimer; - libconfig_int rach_maxHARQ_Msg3Tx; - libconfig_int pcch_defaultPagingCycle; - const char* pcch_nB; - libconfig_int bcch_modificationPeriodCoeff; - libconfig_int ue_TimersAndConstants_t300; - libconfig_int ue_TimersAndConstants_t301; - libconfig_int ue_TimersAndConstants_t310; - libconfig_int ue_TimersAndConstants_t311; - libconfig_int ue_TimersAndConstants_n310; - libconfig_int ue_TimersAndConstants_n311; + libconfig_int pusch_nDMRS1 = 0; + const char* phich_duration = NULL; + const char* phich_resource = NULL; + const char* srs_enable = NULL; + libconfig_int srs_BandwidthConfig = 0; + libconfig_int srs_SubframeConfig = 0; + const char* srs_ackNackST = NULL; + const char* srs_MaxUpPts = NULL; + libconfig_int pusch_p0_Nominal = 0; + const char* pusch_alpha = NULL; + libconfig_int pucch_p0_Nominal = 0; + libconfig_int msg3_delta_Preamble = 0; + libconfig_int ul_CyclicPrefixLength = 0; + const char* pucch_deltaF_Format1 = NULL; + const char* pucch_deltaF_Format1a = NULL; + const char* pucch_deltaF_Format1b = NULL; + const char* pucch_deltaF_Format2 = NULL; + const char* pucch_deltaF_Format2a = NULL; + const char* pucch_deltaF_Format2b = NULL; + libconfig_int rach_numberOfRA_Preambles = 0; + const char* rach_preamblesGroupAConfig = NULL; + libconfig_int rach_sizeOfRA_PreamblesGroupA = 0; + libconfig_int rach_messageSizeGroupA = 0; + const char* rach_messagePowerOffsetGroupB = NULL; + libconfig_int rach_powerRampingStep = 0; + libconfig_int rach_preambleInitialReceivedTargetPower = 0; + libconfig_int rach_preambleTransMax = 0; + libconfig_int rach_raResponseWindowSize = 0; + libconfig_int rach_macContentionResolutionTimer = 0; + libconfig_int rach_maxHARQ_Msg3Tx = 0; + libconfig_int pcch_defaultPagingCycle = 0; + const char* pcch_nB = NULL; + libconfig_int bcch_modificationPeriodCoeff = 0; + libconfig_int ue_TimersAndConstants_t300 = 0; + libconfig_int ue_TimersAndConstants_t301 = 0; + libconfig_int ue_TimersAndConstants_t310 = 0; + libconfig_int ue_TimersAndConstants_t311 = 0; + libconfig_int ue_TimersAndConstants_n310 = 0; + libconfig_int ue_TimersAndConstants_n311 = 0; @@ -793,7 +795,11 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!", lib_config_file_name_pP, i, tdd_config_s, TDD_Config__specialSubframePatterns_ssp8); - if (strcmp(prefix_type, "NORMAL") == 0) { + if (!prefix_type) + AssertError (0, parse_errors ++, + "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n", + lib_config_file_name_pP, i, ENB_CONFIG_STRING_PREFIX_TYPE); + else if (strcmp(prefix_type, "NORMAL") == 0) { enb_properties.properties[enb_properties_index]->prefix_type[j] = NORMAL; } else if (strcmp(prefix_type, "EXTENDED") == 0) { enb_properties.properties[enb_properties_index]->prefix_type[j] = EXTENDED; @@ -926,11 +932,11 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n", lib_config_file_name_pP, i, ENB_CONFIG_STRING_PRACH_HIGH_SPEED); - else if (strcmp(prach_high_speed, "ENABLE") == 0) + else if (strcmp(prach_high_speed, "ENABLE") == 0) { enb_properties.properties[enb_properties_index]->prach_high_speed[j] = TRUE; - else if (strcmp(prach_high_speed, "DISABLE") == 0) + } else if (strcmp(prach_high_speed, "DISABLE") == 0) { enb_properties.properties[enb_properties_index]->prach_high_speed[j] = FALSE; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prach_config choice: ENABLE,DISABLE !\n", lib_config_file_name_pP, i, prach_high_speed); @@ -1005,10 +1011,11 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d define %s: interSubframe,intraAndInterSubframe!\n", lib_config_file_name_pP, i, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE); - else if (strcmp(pusch_hoppingMode,"interSubFrame")==0) + else if (strcmp(pusch_hoppingMode,"interSubFrame")==0) { enb_properties.properties[enb_properties_index]->pusch_hoppingMode[j] = PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame; - else if (strcmp(pusch_hoppingMode,"intraAndInterSubFrame")==0) + } else if (strcmp(pusch_hoppingMode,"intraAndInterSubFrame")==0) { enb_properties.properties[enb_properties_index]->pusch_hoppingMode[j] = PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame; + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingMode choice: interSubframe,intraAndInterSubframe!\n", @@ -1025,10 +1032,11 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n", lib_config_file_name_pP, i, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM); - else if (strcmp(pusch_enable64QAM, "ENABLE") == 0) + else if (strcmp(pusch_enable64QAM, "ENABLE") == 0) { enb_properties.properties[enb_properties_index]->pusch_enable64QAM[j] = TRUE; - else if (strcmp(pusch_enable64QAM, "DISABLE") == 0) + } else if (strcmp(pusch_enable64QAM, "DISABLE") == 0) { enb_properties.properties[enb_properties_index]->pusch_enable64QAM[j] = FALSE; + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n", @@ -1038,10 +1046,11 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n", lib_config_file_name_pP, i, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN); - else if (strcmp(pusch_groupHoppingEnabled, "ENABLE") == 0) + else if (strcmp(pusch_groupHoppingEnabled, "ENABLE") == 0) { enb_properties.properties[enb_properties_index]->pusch_groupHoppingEnabled[j] = TRUE; - else if (strcmp(pusch_groupHoppingEnabled, "DISABLE") == 0) + } else if (strcmp(pusch_groupHoppingEnabled, "DISABLE") == 0) { enb_properties.properties[enb_properties_index]->pusch_groupHoppingEnabled[j] = FALSE; + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n", @@ -1059,11 +1068,11 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n", lib_config_file_name_pP, i, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN); - else if (strcmp(pusch_sequenceHoppingEnabled, "ENABLE") == 0) + else if (strcmp(pusch_sequenceHoppingEnabled, "ENABLE") == 0) { enb_properties.properties[enb_properties_index]->pusch_sequenceHoppingEnabled[j] = TRUE; - else if (strcmp(pusch_sequenceHoppingEnabled, "DISABLE") == 0) + } else if (strcmp(pusch_sequenceHoppingEnabled, "DISABLE") == 0) { enb_properties.properties[enb_properties_index]->pusch_sequenceHoppingEnabled[j] = FALSE; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_sequenceHoppingEnabled choice: ENABLE,DISABLE!\n", lib_config_file_name_pP, i, pusch_sequenceHoppingEnabled); @@ -1075,32 +1084,33 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_nDMRS1 choice: 0..7!\n", lib_config_file_name_pP, i, pusch_nDMRS1); - if (strcmp(phich_duration,"NORMAL")==0) + if (strcmp(phich_duration,"NORMAL")==0) { enb_properties.properties[enb_properties_index]->phich_duration[j] = normal; - else if (strcmp(phich_duration,"EXTENDED")==0) + } else if (strcmp(phich_duration,"EXTENDED")==0) { enb_properties.properties[enb_properties_index]->phich_duration[j] = extended; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_duration choice: NORMAL,EXTENDED!\n", lib_config_file_name_pP, i, phich_duration); - if (strcmp(phich_resource,"ONESIXTH")==0) + if (strcmp(phich_resource,"ONESIXTH")==0) { enb_properties.properties[enb_properties_index]->phich_resource[j] = oneSixth; - else if (strcmp(phich_duration,"HALF")==0) + } else if (strcmp(phich_duration,"HALF")==0) { enb_properties.properties[enb_properties_index]->phich_resource[j] = half; - else if (strcmp(phich_duration,"ONE")==0) + } else if (strcmp(phich_duration,"ONE")==0) { enb_properties.properties[enb_properties_index]->phich_resource[j] = one; - else if (strcmp(phich_duration,"TWO")==0) + } else if (strcmp(phich_duration,"TWO")==0) { enb_properties.properties[enb_properties_index]->phich_resource[j] = two; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n", lib_config_file_name_pP, i, phich_resource); - if (strcmp(srs_enable, "ENABLE") == 0) + if (strcmp(srs_enable, "ENABLE") == 0) { enb_properties.properties[enb_properties_index]->srs_enable[j] = TRUE; - else if (strcmp(srs_enable, "DISABLE") == 0) + } else if (strcmp(srs_enable, "DISABLE") == 0) { enb_properties.properties[enb_properties_index]->srs_enable[j] = FALSE; + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n", @@ -1112,8 +1122,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_ACKNACKST_CONFIG, &srs_ackNackST) && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_MAXUPPTS, &srs_MaxUpPts) )) - AssertError(0, parse_errors++,"Failed to parse eNB configuration file %s, enb %d unknown values for srs_BandwidthConfig, srs_SubframeConfig, srs_ackNackST, srs_MaxUpPts\n", - // lib_config_file_name_pP, i, srs_BandwidthConfig); + AssertError(0, + parse_errors++, + "Failed to parse eNB configuration file %s, enb %d unknown values for srs_BandwidthConfig, srs_SubframeConfig, srs_ackNackST, srs_MaxUpPts\n", lib_config_file_name_pP, i); enb_properties.properties[enb_properties_index]->srs_BandwidthConfig[j] = srs_BandwidthConfig; @@ -1129,20 +1140,20 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for srs_SubframeConfig choice: 0..15 !\n", lib_config_file_name_pP, i, srs_SubframeConfig); - if (strcmp(srs_ackNackST, "ENABLE") == 0) + if (strcmp(srs_ackNackST, "ENABLE") == 0) { enb_properties.properties[enb_properties_index]->srs_ackNackST[j] = TRUE; - else if (strcmp(srs_ackNackST, "DISABLE") == 0) + } else if (strcmp(srs_ackNackST, "DISABLE") == 0) { enb_properties.properties[enb_properties_index]->srs_ackNackST[j] = FALSE; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n", lib_config_file_name_pP, i, srs_ackNackST); - if (strcmp(srs_MaxUpPts, "ENABLE") == 0) + if (strcmp(srs_MaxUpPts, "ENABLE") == 0) { enb_properties.properties[enb_properties_index]->srs_MaxUpPts[j] = TRUE; - else if (strcmp(srs_MaxUpPts, "DISABLE") == 0) + } else if (strcmp(srs_MaxUpPts, "DISABLE") == 0) { enb_properties.properties[enb_properties_index]->srs_MaxUpPts[j] = FALSE; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n", lib_config_file_name_pP, i, srs_MaxUpPts); @@ -1155,23 +1166,23 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n", lib_config_file_name_pP, i, pusch_p0_Nominal); - if (strcmp(pusch_alpha,"AL0")==0) + if (strcmp(pusch_alpha,"AL0")==0) { enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al0; - else if (strcmp(pusch_alpha,"AL04")==0) + } else if (strcmp(pusch_alpha,"AL04")==0) { enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al04; - else if (strcmp(pusch_alpha,"AL05")==0) + } else if (strcmp(pusch_alpha,"AL05")==0) { enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al05; - else if (strcmp(pusch_alpha,"AL06")==0) + } else if (strcmp(pusch_alpha,"AL06")==0) { enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al06; - else if (strcmp(pusch_alpha,"AL07")==0) + } else if (strcmp(pusch_alpha,"AL07")==0) { enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al07; - else if (strcmp(pusch_alpha,"AL08")==0) + } else if (strcmp(pusch_alpha,"AL08")==0) { enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al08; - else if (strcmp(pusch_alpha,"AL09")==0) + } else if (strcmp(pusch_alpha,"AL09")==0) { enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al09; - else if (strcmp(pusch_alpha,"AL1")==0) + } else if (strcmp(pusch_alpha,"AL1")==0) { enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al1; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_p0_Nominal choice: AL0,AL04,AL05,AL06,AL07,AL08,AL09,AL1!\n", lib_config_file_name_pP, i, pusch_alpha); @@ -1191,60 +1202,60 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) lib_config_file_name_pP, i, msg3_delta_Preamble); - if (strcmp(pucch_deltaF_Format1,"deltaF_2")==0) + if (strcmp(pucch_deltaF_Format1,"deltaF_2")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2; - else if (strcmp(pucch_deltaF_Format1,"deltaF0")==0) + } else if (strcmp(pucch_deltaF_Format1,"deltaF0")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0; - else if (strcmp(pucch_deltaF_Format1,"deltaF2")==0) + } else if (strcmp(pucch_deltaF_Format1,"deltaF2")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1 choice: deltaF_2,dltaF0,deltaF2!\n", lib_config_file_name_pP, i, pucch_deltaF_Format1); - if (strcmp(pucch_deltaF_Format1b,"deltaF1")==0) + if (strcmp(pucch_deltaF_Format1b,"deltaF1")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1; - else if (strcmp(pucch_deltaF_Format1b,"deltaF3")==0) + } else if (strcmp(pucch_deltaF_Format1b,"deltaF3")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3; - else if (strcmp(pucch_deltaF_Format1b,"deltaF5")==0) + } else if (strcmp(pucch_deltaF_Format1b,"deltaF5")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1b choice: deltaF1,dltaF3,deltaF5!\n", lib_config_file_name_pP, i, pucch_deltaF_Format1b); - if (strcmp(pucch_deltaF_Format2,"deltaF_2")==0) + if (strcmp(pucch_deltaF_Format2,"deltaF_2")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2; - else if (strcmp(pucch_deltaF_Format2,"deltaF0")==0) + } else if (strcmp(pucch_deltaF_Format2,"deltaF0")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0; - else if (strcmp(pucch_deltaF_Format2,"deltaF1")==0) + } else if (strcmp(pucch_deltaF_Format2,"deltaF1")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1; - else if (strcmp(pucch_deltaF_Format2,"deltaF2")==0) + } else if (strcmp(pucch_deltaF_Format2,"deltaF2")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2 choice: deltaF_2,dltaF0,deltaF1,deltaF2!\n", lib_config_file_name_pP, i, pucch_deltaF_Format2); - - if (strcmp(pucch_deltaF_Format2a,"deltaF_2")==0) + if (strcmp(pucch_deltaF_Format2a,"deltaF_2")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2; - else if (strcmp(pucch_deltaF_Format2a,"deltaF0")==0) + } else if (strcmp(pucch_deltaF_Format2a,"deltaF0")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0; - else if (strcmp(pucch_deltaF_Format2a,"deltaF2")==0) + } else if (strcmp(pucch_deltaF_Format2a,"deltaF2")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2a choice: deltaF_2,dltaF0,deltaF2!\n", lib_config_file_name_pP, i, pucch_deltaF_Format2a); - if (strcmp(pucch_deltaF_Format2b,"deltaF_2")==0) + if (strcmp(pucch_deltaF_Format2b,"deltaF_2")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2; - else if (strcmp(pucch_deltaF_Format2b,"deltaF0")==0) + } else if (strcmp(pucch_deltaF_Format2b,"deltaF0")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0; - else if (strcmp(pucch_deltaF_Format2b,"deltaF2")==0) + } else if (strcmp(pucch_deltaF_Format2b,"deltaF2")==0) { enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2; + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2b choice: deltaF_2,dltaF0,deltaF2!\n", @@ -1268,7 +1279,6 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB, &rach_messagePowerOffsetGroupB))) AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d rach_sizeOfRA_PreamblesGroupA, messageSizeGroupA,messagePowerOffsetGroupB!\n", - // lib_config_file_name_pP, i, pucch_deltaF_Format2b); lib_config_file_name_pP, i); enb_properties.properties[enb_properties_index]->rach_sizeOfRA_PreamblesGroupA[j] = (rach_sizeOfRA_PreamblesGroupA/4)-1; @@ -1303,30 +1313,45 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) break; } - if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0) + if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0) { enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity; - else if (strcmp(rach_messagePowerOffsetGroupB,"dB0")==0) + } + + else if (strcmp(rach_messagePowerOffsetGroupB,"dB0")==0) { enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0; - else if (strcmp(rach_messagePowerOffsetGroupB,"dB5")==0) + } + + else if (strcmp(rach_messagePowerOffsetGroupB,"dB5")==0) { enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5; - else if (strcmp(rach_messagePowerOffsetGroupB,"dB8")==0) + } + + else if (strcmp(rach_messagePowerOffsetGroupB,"dB8")==0) { enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8; - else if (strcmp(rach_messagePowerOffsetGroupB,"dB10")==0) + } + + else if (strcmp(rach_messagePowerOffsetGroupB,"dB10")==0) { enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10; - else if (strcmp(rach_messagePowerOffsetGroupB,"dB12")==0) + } + + else if (strcmp(rach_messagePowerOffsetGroupB,"dB12")==0) { enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12; - else if (strcmp(rach_messagePowerOffsetGroupB,"dB15")==0) + } + + else if (strcmp(rach_messagePowerOffsetGroupB,"dB15")==0) { enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15; - else if (strcmp(rach_messagePowerOffsetGroupB,"dB18")==0) + } + + else if (strcmp(rach_messagePowerOffsetGroupB,"dB18")==0) { enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18; + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n", lib_config_file_name_pP, i, rach_messagePowerOffsetGroupB); - } else if (strcmp(rach_preamblesGroupAConfig, "DISABLE") == 0) + } else if (strcmp(rach_preamblesGroupAConfig, "DISABLE") == 0) { enb_properties.properties[enb_properties_index]->rach_preamblesGroupAConfig[j] = FALSE; - else + } else AssertError (0, parse_errors ++, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_preamblesGroupAConfig choice: ENABLE,DISABLE !\n", lib_config_file_name_pP, i, rach_preamblesGroupAConfig); @@ -1826,22 +1851,24 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) for (j = 0; j < num_otg_elements; j++) { subsetting_otg=config_setting_get_elem(setting_otg, j); - if(config_setting_lookup_int(subsetting_otg, ENB_CONF_STRING_OTG_UE_ID, &otg_ue_id)) + if(config_setting_lookup_int(subsetting_otg, ENB_CONF_STRING_OTG_UE_ID, &otg_ue_id)) { enb_properties.properties[enb_properties_index]->otg_ue_id[j] = otg_ue_id; - else + } else { enb_properties.properties[enb_properties_index]->otg_ue_id[j] = 1; + } if(config_setting_lookup_string(subsetting_otg, ENB_CONF_STRING_OTG_APP_TYPE, (const char **)&otg_app_type)) { - if ((enb_properties.properties[enb_properties_index]->otg_app_type[j] = map_str_to_int(otg_app_type_names,otg_app_type))== -1) + if ((enb_properties.properties[enb_properties_index]->otg_app_type[j] = map_str_to_int(otg_app_type_names,otg_app_type))== -1) { enb_properties.properties[enb_properties_index]->otg_app_type[j] = BCBR; - } else + } + } else { enb_properties.properties[enb_properties_index]->otg_app_type[j] = NO_PREDEFINED_TRAFFIC; // 0 + } if(config_setting_lookup_string(subsetting_otg, ENB_CONF_STRING_OTG_BG_TRAFFIC, (const char **)&otg_bg_traffic)) { if ((enb_properties.properties[enb_properties_index]->otg_bg_traffic[j] = map_str_to_int(switch_names,otg_bg_traffic)) == -1) { enb_properties.properties[enb_properties_index]->otg_bg_traffic[j]=0; - } } else { enb_properties.properties[enb_properties_index]->otg_bg_traffic[j] = 0; @@ -1859,8 +1886,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) if(subsetting != NULL) { // global if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GLOBAL_LOG_LEVEL, (const char **) &glog_level)) { - if ((enb_properties.properties[enb_properties_index]->glog_level = map_str_to_int(log_level_names, glog_level)) == -1) + if ((enb_properties.properties[enb_properties_index]->glog_level = map_str_to_int(log_level_names, glog_level)) == -1) { enb_properties.properties[enb_properties_index]->glog_level = LOG_INFO; + } //printf( "\tGlobal log level :\t%s->%d\n",glog_level, enb_properties.properties[enb_properties_index]->glog_level); } else { @@ -1868,8 +1896,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GLOBAL_LOG_VERBOSITY,(const char **) &glog_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->glog_verbosity = map_str_to_int(log_verbosity_names, glog_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->glog_verbosity = map_str_to_int(log_verbosity_names, glog_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->glog_verbosity = LOG_MED; + } //printf( "\tGlobal log verbosity:\t%s->%d\n",glog_verbosity, enb_properties.properties[enb_properties_index]->glog_verbosity); } else { @@ -1878,8 +1907,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) // HW if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_HW_LOG_LEVEL, (const char **) &hw_log_level)) { - if ((enb_properties.properties[enb_properties_index]->hw_log_level = map_str_to_int(log_level_names,hw_log_level)) == -1) + if ((enb_properties.properties[enb_properties_index]->hw_log_level = map_str_to_int(log_level_names,hw_log_level)) == -1) { enb_properties.properties[enb_properties_index]->hw_log_level = LOG_INFO; + } //printf( "\tHW log level :\t%s->%d\n",hw_log_level,enb_properties.properties[enb_properties_index]->hw_log_level); } else { @@ -1887,8 +1917,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_HW_LOG_VERBOSITY, (const char **) &hw_log_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->hw_log_verbosity = map_str_to_int(log_verbosity_names,hw_log_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->hw_log_verbosity = map_str_to_int(log_verbosity_names,hw_log_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->hw_log_verbosity = LOG_MED; + } //printf( "\tHW log verbosity:\t%s->%d\n",hw_log_verbosity, enb_properties.properties[enb_properties_index]->hw_log_verbosity); } else { @@ -1897,8 +1928,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) // phy if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PHY_LOG_LEVEL,(const char **) &phy_log_level)) { - if ((enb_properties.properties[enb_properties_index]->phy_log_level = map_str_to_int(log_level_names,phy_log_level)) == -1) + if ((enb_properties.properties[enb_properties_index]->phy_log_level = map_str_to_int(log_level_names,phy_log_level)) == -1) { enb_properties.properties[enb_properties_index]->phy_log_level = LOG_INFO; + } //printf( "\tPHY log level :\t%s->%d\n",phy_log_level,enb_properties.properties[enb_properties_index]->phy_log_level); } else { @@ -1906,8 +1938,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PHY_LOG_VERBOSITY, (const char **)&phy_log_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->phy_log_verbosity = map_str_to_int(log_verbosity_names,phy_log_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->phy_log_verbosity = map_str_to_int(log_verbosity_names,phy_log_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->phy_log_verbosity = LOG_MED; + } //printf( "\tPHY log verbosity:\t%s->%d\n",phy_log_level,enb_properties.properties[enb_properties_index]->phy_log_verbosity); } else { @@ -1916,8 +1949,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) //mac if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_MAC_LOG_LEVEL, (const char **)&mac_log_level)) { - if ((enb_properties.properties[enb_properties_index]->mac_log_level = map_str_to_int(log_level_names,mac_log_level)) == -1 ) + if ((enb_properties.properties[enb_properties_index]->mac_log_level = map_str_to_int(log_level_names,mac_log_level)) == -1 ) { enb_properties.properties[enb_properties_index]->mac_log_level = LOG_INFO; + } //printf( "\tMAC log level :\t%s->%d\n",mac_log_level,enb_properties.properties[enb_properties_index]->mac_log_level); } else { @@ -1925,8 +1959,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_MAC_LOG_VERBOSITY, (const char **)&mac_log_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->mac_log_verbosity = map_str_to_int(log_verbosity_names,mac_log_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->mac_log_verbosity = map_str_to_int(log_verbosity_names,mac_log_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->mac_log_verbosity = LOG_MED; + } //printf( "\tMAC log verbosity:\t%s->%d\n",mac_log_verbosity,enb_properties.properties[enb_properties_index]->mac_log_verbosity); } else { @@ -1935,8 +1970,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) //rlc if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RLC_LOG_LEVEL, (const char **)&rlc_log_level)) { - if ((enb_properties.properties[enb_properties_index]->rlc_log_level = map_str_to_int(log_level_names,rlc_log_level)) == -1) + if ((enb_properties.properties[enb_properties_index]->rlc_log_level = map_str_to_int(log_level_names,rlc_log_level)) == -1) { enb_properties.properties[enb_properties_index]->rlc_log_level = LOG_INFO; + } //printf( "\tRLC log level :\t%s->%d\n",rlc_log_level, enb_properties.properties[enb_properties_index]->rlc_log_level); } else { @@ -1944,8 +1980,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RLC_LOG_VERBOSITY, (const char **)&rlc_log_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->rlc_log_verbosity = map_str_to_int(log_verbosity_names,rlc_log_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->rlc_log_verbosity = map_str_to_int(log_verbosity_names,rlc_log_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->rlc_log_verbosity = LOG_MED; + } //printf( "\tRLC log verbosity:\t%s->%d\n",rlc_log_verbosity, enb_properties.properties[enb_properties_index]->rlc_log_verbosity); } else { @@ -1954,8 +1991,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) //pdcp if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PDCP_LOG_LEVEL, (const char **)&pdcp_log_level)) { - if ((enb_properties.properties[enb_properties_index]->pdcp_log_level = map_str_to_int(log_level_names,pdcp_log_level)) == -1) + if ((enb_properties.properties[enb_properties_index]->pdcp_log_level = map_str_to_int(log_level_names,pdcp_log_level)) == -1) { enb_properties.properties[enb_properties_index]->pdcp_log_level = LOG_INFO; + } //printf( "\tPDCP log level :\t%s->%d\n",pdcp_log_level, enb_properties.properties[enb_properties_index]->pdcp_log_level); } else { @@ -1971,8 +2009,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) //rrc if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RRC_LOG_LEVEL, (const char **)&rrc_log_level)) { - if ((enb_properties.properties[enb_properties_index]->rrc_log_level = map_str_to_int(log_level_names,rrc_log_level)) == -1 ) + if ((enb_properties.properties[enb_properties_index]->rrc_log_level = map_str_to_int(log_level_names,rrc_log_level)) == -1 ) { enb_properties.properties[enb_properties_index]->rrc_log_level = LOG_INFO; + } //printf( "\tRRC log level :\t%s->%d\n",rrc_log_level,enb_properties.properties[enb_properties_index]->rrc_log_level); } else { @@ -1980,8 +2019,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RRC_LOG_VERBOSITY, (const char **)&rrc_log_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->rrc_log_verbosity = map_str_to_int(log_verbosity_names,rrc_log_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->rrc_log_verbosity = map_str_to_int(log_verbosity_names,rrc_log_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->rrc_log_verbosity = LOG_MED; + } //printf( "\tRRC log verbosity:\t%s->%d\n",rrc_log_verbosity,enb_properties.properties[enb_properties_index]->rrc_log_verbosity); } else { @@ -1989,8 +2029,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GTPU_LOG_LEVEL, (const char **)>pu_log_level)) { - if ((enb_properties.properties[enb_properties_index]->gtpu_log_level = map_str_to_int(log_level_names,gtpu_log_level)) == -1 ) + if ((enb_properties.properties[enb_properties_index]->gtpu_log_level = map_str_to_int(log_level_names,gtpu_log_level)) == -1 ) { enb_properties.properties[enb_properties_index]->gtpu_log_level = LOG_INFO; + } //printf( "\tGTPU log level :\t%s->%d\n",gtpu_log_level,enb_properties.properties[enb_properties_index]->gtpu_log_level); } else { @@ -1998,8 +2039,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GTPU_LOG_VERBOSITY, (const char **)>pu_log_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->gtpu_log_verbosity = map_str_to_int(log_verbosity_names,gtpu_log_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->gtpu_log_verbosity = map_str_to_int(log_verbosity_names,gtpu_log_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->gtpu_log_verbosity = LOG_MED; + } //printf( "\tGTPU log verbosity:\t%s->%d\n",gtpu_log_verbosity,enb_properties.properties[enb_properties_index]->gtpu_log_verbosity); } else { @@ -2007,8 +2049,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_UDP_LOG_LEVEL, (const char **)&udp_log_level)) { - if ((enb_properties.properties[enb_properties_index]->udp_log_level = map_str_to_int(log_level_names,udp_log_level)) == -1 ) + if ((enb_properties.properties[enb_properties_index]->udp_log_level = map_str_to_int(log_level_names,udp_log_level)) == -1 ) { enb_properties.properties[enb_properties_index]->udp_log_level = LOG_INFO; + } //printf( "\tUDP log level :\t%s->%d\n",udp_log_level,enb_properties.properties[enb_properties_index]->udp_log_level); } else { @@ -2016,8 +2059,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_UDP_LOG_VERBOSITY, (const char **)&udp_log_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->udp_log_verbosity = map_str_to_int(log_verbosity_names,udp_log_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->udp_log_verbosity = map_str_to_int(log_verbosity_names,udp_log_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->udp_log_verbosity = LOG_MED; + } //printf( "\tUDP log verbosity:\t%s->%d\n",udp_log_verbosity,enb_properties.properties[enb_properties_index]->gtpu_log_verbosity); } else { @@ -2025,8 +2069,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_OSA_LOG_LEVEL, (const char **)&osa_log_level)) { - if ((enb_properties.properties[enb_properties_index]->osa_log_level = map_str_to_int(log_level_names,osa_log_level)) == -1 ) + if ((enb_properties.properties[enb_properties_index]->osa_log_level = map_str_to_int(log_level_names,osa_log_level)) == -1 ) { enb_properties.properties[enb_properties_index]->osa_log_level = LOG_INFO; + } //printf( "\tOSA log level :\t%s->%d\n",osa_log_level,enb_properties.properties[enb_properties_index]->osa_log_level); } else { @@ -2034,8 +2079,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } if(config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_OSA_LOG_VERBOSITY, (const char **)&osa_log_verbosity)) { - if ((enb_properties.properties[enb_properties_index]->osa_log_verbosity = map_str_to_int(log_verbosity_names,osa_log_verbosity)) == -1) + if ((enb_properties.properties[enb_properties_index]->osa_log_verbosity = map_str_to_int(log_verbosity_names,osa_log_verbosity)) == -1) { enb_properties.properties[enb_properties_index]->osa_log_verbosity = LOG_MED; + } //printf( "\tOSA log verbosity:\t%s->%d\n",osa_log_verbosity,enb_properties.properties[enb_properties_index]->gosa_log_verbosity); } else { diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 79d6d6d1f29..6156a5e96a8 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -88,7 +88,12 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index) } -int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,uint8_t UE_id,uint8_t eNB_index, +int +rrc_mac_config_req( + module_id_t Mod_id, + eNB_flag_t eNB_flagP, + rnti_t rntiP, + uint8_t eNB_index, RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, struct PhysicalConfigDedicated *physicalConfigDedicated, #ifdef Rel10 @@ -122,14 +127,17 @@ int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,uint8_t UE_id,ui int i,CC_id=0; + int UE_id = -1; vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN); if (eNB_flagP==0) { LOG_I(MAC,"[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n",Mod_id,eNB_index); - if (tdd_Config != NULL) + if (tdd_Config != NULL) { UE_mac_inst[Mod_id].tdd_Config = tdd_Config; + } } else { + UE_id = find_UE_id(Mod_id, rntiP); if (physicalConfigDedicated == NULL) { LOG_I(MAC,"[CONFIG][eNB %d] Configuring MAC/PHY\n",Mod_id); } else { @@ -138,10 +146,11 @@ int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,uint8_t UE_id,ui } if (tdd_Config && SIwindowsize && SIperiod) { - if (eNB_flagP == ENB_FLAG_YES) + if (eNB_flagP == ENB_FLAG_YES) { mac_xface->phy_config_sib1_eNB(Mod_id,0,tdd_Config,*SIwindowsize,*SIperiod); - else + } else { mac_xface->phy_config_sib1_ue(Mod_id,0,eNB_index,tdd_Config,*SIwindowsize,*SIperiod); + } } if (radioResourceConfigCommon!=NULL) { @@ -189,28 +198,32 @@ int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,uint8_t UE_id,ui if (mac_MainConfig->ul_SCH_Config) { - if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) + if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) { UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer = (uint16_t) *mac_MainConfig->ul_SCH_Config->periodicBSR_Timer; - else + } else { UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer = (uint16_t) MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity; + } - if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) + if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) { UE_mac_inst[Mod_id].scheduling_info.maxHARQ_Tx = (uint16_t) *mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; - else + } else { UE_mac_inst[Mod_id].scheduling_info.maxHARQ_Tx = (uint16_t) MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + } - if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) + if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) { UE_mac_inst[Mod_id].scheduling_info.retxBSR_Timer = (uint16_t) mac_MainConfig->ul_SCH_Config->retxBSR_Timer; - else + } else { UE_mac_inst[Mod_id].scheduling_info.retxBSR_Timer = (uint16_t)MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; } + } #ifdef Rel10 - if (mac_MainConfig->sr_ProhibitTimer_r9) + if (mac_MainConfig->sr_ProhibitTimer_r9) { UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer = (uint16_t) *mac_MainConfig->sr_ProhibitTimer_r9; - else + } else { UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer = (uint16_t) 0; + } #endif UE_mac_inst[Mod_id].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer); @@ -485,8 +498,9 @@ int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,uint8_t UE_id,ui eNB_mac_inst[Mod_id].common_channels[CC_id].num_active_cba_groups=num_active_cba_groups; for (i=0; i < num_active_cba_groups; i ++) { - if (eNB_mac_inst[Mod_id].common_channels[CC_id].cba_rnti[i] != cba_rnti + i) + if (eNB_mac_inst[Mod_id].common_channels[CC_id].cba_rnti[i] != cba_rnti + i) { eNB_mac_inst[Mod_id].common_channels[CC_id].cba_rnti[i] = cba_rnti + i; + } //only configure UE ids up to num_active_cba_groups //we use them as candidates for the transmission of dci format0) @@ -505,28 +519,32 @@ int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,uint8_t UE_id,ui return(0); } #ifdef LOCALIZATION +//------------------------------------------------------------------------------ double -rrc_get_estimated_ue_distance(module_id_t Mod_id, const frame_t frameP, uint8_t UE_id, int CC_id, uint8_t loc_type) +rrc_get_estimated_ue_distance( + const protocol_ctxt_t* const ctxt_pP, + const int CC_idP, + const uint8_t loc_typeP +) +//------------------------------------------------------------------------------ { // localization types: // 0: power based // 1: time based LTE_eNB_UE_stats *eNB_UE_stats = NULL; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; + UE_list_t* UE_list = &eNB_mac_inst[ctxt_pP->module_id].UE_list; int pCCid; + int UE_id; - uint16_t rnti; - - //for (UE_id=UE_list->head;UE_id>=0;UE_id=UE_list->next[UE_id]) { - pCCid = UE_PCCID(Mod_id,UE_id); - rnti = UE_list->UE_template[pCCid][UE_id].rnti; - - if(rnti == 0) + if(ctxt_pP->rnti == NOT_A_RNTI) { return -1; + } - eNB_UE_stats = mac_xface->get_eNB_UE_stats(Mod_id,pCCid,rnti); + UE_id = find_UE_id(ctxt_pP->module_id,ctxt_pP->rnti); + pCCid = UE_PCCID(ctxt_pP->module_id,UE_id); + eNB_UE_stats = mac_xface->get_eNB_UE_stats(ctxt_pP->module_id,pCCid,ctxt_pP->rnti); - switch (loc_type) { + switch (loc_typeP) { case 0: return eNB_UE_stats->distance.power_based; break; @@ -539,7 +557,7 @@ rrc_get_estimated_ue_distance(module_id_t Mod_id, const frame_t frameP, uint8_t return eNB_UE_stats->distance.power_based; } - // LOG_D(LOCALIZE, "DEBUG ME, dist = %d\n", &eNB_mac_inst[Mod_id].UE_list.UE_template[CC_id][UE_id].distance.power_based); + // LOG_D(LOCALIZE, "DEBUG ME, dist = %d\n", &eNB_mac_inst[ctxt_pP->module_id].UE_list.UE_template[CC_id][UE_id].distance.power_based); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 9332957a7bf..b0550deebed 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -97,6 +97,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, DCI_PDU *DCI_pdu[MAX_NUM_CCs]; int CC_id,i,next_i; UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list; + rnti_t rnti; LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head); @@ -112,12 +113,18 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } // refresh UE list based on UEs dropped by PHY in previous subframe - for (i=UE_list->head; i>=0; i=i=next_i) { - LOG_D(MAC,"UE %d: rnti %x (%p)\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))); + i = UE_list->head; + + while (i>=0) { + + rnti = UE_RNTI(module_idP,i); + LOG_D(MAC,"UE %d: rnti %x (%p)\n",i,rnti,mac_xface->get_eNB_UE_stats(module_idP,0,rnti)); next_i= UE_list->next[i]; - if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) - mac_remove_ue(module_idP,i,frameP); + if (mac_xface->get_eNB_UE_stats(module_idP,0,rnti)==NULL) { + mac_remove_ue(module_idP,i,frameP, subframeP); + } + i = next_i; } #if defined(ENABLE_ITTI) @@ -190,18 +197,13 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, //if (subframeP%5 == 0) //#ifdef EXMIMO - ctxt.enb_module_id = module_idP; - ctxt.ue_module_id = 0; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_YES; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0); pdcp_run(&ctxt); //#endif // check HO - rrc_rx_tx(module_idP, - frameP, - 1, - module_idP, + rrc_rx_tx(&ctxt, + 0, // eNB index, unused in eNB CC_id); #ifdef Rel10 @@ -235,7 +237,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6) // Schedule Normal DLSCH - // + schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE); if (mac_xface->lte_frame_parms->frame_type == FDD) { //FDD schedule_ulsch(module_idP,frameP,cooperation_flag,0,4,nCCE);//,calibration_flag); @@ -247,8 +249,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, // schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); - //schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE); - //fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); break; @@ -531,8 +532,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { DCI_pdu[CC_id]->nCCE = nCCE[CC_id]; + } LOG_D(MAC,"frameP %d, subframeP %d nCCE %d\n",frameP,subframeP,nCCE[0]); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 10d1ab6edc7..ed8273bcd1b 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -27,7 +27,7 @@ *******************************************************************************/ -/*! \file eNB_scheduler_RAs.c +/*! \file eNB_scheduler_RA.c * \brief primitives used for random access * \author Navid Nikaein and Raymond Knopp * \date 2010 - 2014 @@ -38,6 +38,7 @@ */ #include "assertions.h" +#include "platform_types.h" #include "PHY/defs.h" #include "PHY/extern.h" @@ -108,9 +109,10 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un // Get RRCConnectionSetup for Piggyback rrc_sdu_length = mac_rrc_data_req(module_idP, frameP, - CCCH,1, + CCCH, + 1, // 1 transport block &eNB->common_channels[CC_id].CCCH_pdu.payload[0], - 1, + ENB_FLAG_YES, module_idP, 0); // not used in this case @@ -381,8 +383,9 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un memcpy((void*)&eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0][(unsigned char)offset], &eNB->common_channels[CC_id].CCCH_pdu.payload[0], rrc_sdu_length); +#if defined(USER_MODE) && defined(OAI_EMU) - if (opt_enabled==1) { + if (oai_emulation.info.opt_enabled) { trace_pdu(1, (uint8_t *)eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0], rrc_sdu_length, UE_id, 3, UE_RNTI(module_idP, UE_id), eNB->subframe,0,0); @@ -390,6 +393,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un module_idP, frameP, UE_RNTI(module_idP,UE_id), rrc_sdu_length); } +#endif nprb[CC_id]= nprb[CC_id] + 3; nCCE[CC_id] = nCCE[CC_id] + 4; } @@ -416,7 +420,8 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un stop_meas(&eNB->schedule_ra); } -void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t preamble_index,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframeP,uint8_t f_id) +void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t preamble_index,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframeP, + uint8_t f_id) { uint8_t i; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c index 35c81ac6c59..6cbc3aa6d08 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c @@ -67,7 +67,15 @@ #define DEBUG_eNB_SCHEDULER 1 -void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsigned int *nCCEP) +//------------------------------------------------------------------------------ +void +schedule_SI( + module_id_t module_idP, + frame_t frameP, + unsigned int* nprbP, + unsigned int* nCCEP +) +//------------------------------------------------------------------------------ { @@ -96,24 +104,25 @@ void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsi LOG_D(MAC,"[eNB %d] Frame %d : BCCH->DLSCH CC_id %d, Received %d bytes \n",module_idP,CC_id,frameP,bcch_sdu_length); - if (bcch_sdu_length <= (mac_xface->get_TBS_DL(0,3))) + if (bcch_sdu_length <= (mac_xface->get_TBS_DL(0,3))) { mcs=0; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(1,3))) + } else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(1,3))) { mcs=1; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(2,3))) + } else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(2,3))) { mcs=2; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(3,3))) + } else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(3,3))) { mcs=3; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(4,3))) + } else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(4,3))) { mcs=4; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(5,3))) + } else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(5,3))) { mcs=5; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(6,3))) + } else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(6,3))) { mcs=6; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(7,3))) + } else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(7,3))) { mcs=7; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(8,3))) + } else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(8,3))) { mcs=8; + } if (PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.frame_type == TDD) { switch (PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.N_RB_DL) { @@ -132,8 +141,8 @@ void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsi case 100: ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; break; - } + } else { switch (PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.N_RB_DL) { case 6: @@ -155,7 +164,9 @@ void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsi } } - if (opt_enabled == 1) { +#if defined(USER_MODE) && defined(OAI_EMU) + + if (oai_emulation.info.opt_enabled) { trace_pdu(1, &eNB->common_channels[CC_id].BCCH_pdu.payload[0], bcch_sdu_length, @@ -165,9 +176,10 @@ void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsi eNB->subframe, 0, 0); + } LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for rnti %x with size %d\n", module_idP, frameP, 0xffff, bcch_sdu_length); - } +#endif if (PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.frame_type == TDD) { LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (TDD) for SI %d bytes (mcs %d, rb 3, TBS %d)\n", diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 811e136a8a5..c31804bf868 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -69,7 +69,16 @@ extern inline unsigned int taus(void); -void add_ue_dlsch_info(module_id_t module_idP, int CC_id, int UE_id, sub_frame_t subframeP, UE_DLSCH_STATUS status) +//------------------------------------------------------------------------------ +void +add_ue_dlsch_info( + module_id_t module_idP, + int CC_id, + int UE_id, + sub_frame_t subframeP, + UE_DLSCH_STATUS status +) +//------------------------------------------------------------------------------ { eNB_dlsch_info[module_idP][CC_id][UE_id].rnti = UE_RNTI(module_idP,UE_id); @@ -81,15 +90,23 @@ void add_ue_dlsch_info(module_id_t module_idP, int CC_id, int UE_id, sub_frame_t } -int schedule_next_dlue(module_id_t module_idP, int CC_id, sub_frame_t subframeP) +//------------------------------------------------------------------------------ +int +schedule_next_dlue( + module_id_t module_idP, + int CC_id, + sub_frame_t subframeP +) +//------------------------------------------------------------------------------ { int next_ue; UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list; for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ) { - if (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_WAITING) + if (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_WAITING) { return next_ue; + } } for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ) { @@ -102,15 +119,20 @@ int schedule_next_dlue(module_id_t module_idP, int CC_id, sub_frame_t subframeP) } -unsigned char generate_dlsch_header(unsigned char *mac_header, - unsigned char num_sdus, - unsigned short *sdu_lengths, - unsigned char *sdu_lcids, - unsigned char drx_cmd, - short timing_advance_cmd, - unsigned char *ue_cont_res_id, - unsigned char short_padding, - unsigned short post_padding) +//------------------------------------------------------------------------------ +unsigned char +generate_dlsch_header( + unsigned char* mac_header, + unsigned char num_sdus, + unsigned short *sdu_lengths, + unsigned char *sdu_lcids, + unsigned char drx_cmd, + short timing_advance_cmd, + unsigned char *ue_cont_res_id, + unsigned char short_padding, + unsigned short post_padding +) +//------------------------------------------------------------------------------ { SCH_SUBHEADER_FIXED *mac_header_ptr = (SCH_SUBHEADER_FIXED *)mac_header; @@ -291,7 +313,17 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, } -void set_ul_DAI(int module_idP,int UE_idP, int CC_idP, int frameP, int subframeP, LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) +//------------------------------------------------------------------------------ +void +set_ul_DAI( + int module_idP, + int UE_idP, + int CC_idP, + int frameP, + int subframeP, + LTE_DL_FRAME_PARMS* frame_parms[MAX_NUM_CCs] +) +//------------------------------------------------------------------------------ { eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP]; @@ -383,12 +415,17 @@ void set_ul_DAI(int module_idP,int UE_idP, int CC_idP, int frameP, int subframe } -void schedule_ue_spec(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - unsigned int *nb_rb_used0, - unsigned int *nCCE_used, - int *mbsfn_flag) +//------------------------------------------------------------------------------ +void +schedule_ue_spec( + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + unsigned int *nb_rb_used0, + unsigned int *nCCE_used, + int* mbsfn_flag +) +//------------------------------------------------------------------------------ { uint8_t CC_id; @@ -420,8 +457,9 @@ void schedule_ue_spec(module_id_t module_idP, LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; int continue_flag=0; - if (UE_list->head==-1) + if (UE_list->head==-1) { return; + } start_meas(&eNB->schedule_dlsch); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); @@ -472,7 +510,7 @@ void schedule_ue_spec(module_id_t module_idP, rnti = UE_RNTI(module_idP,UE_id); eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); - if (rnti==0) { + if (rnti==NOT_A_RNTI) { LOG_D(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n",UE_id,UE_list->num_UEs); // mac_xface->macphy_exit("Cannot find rnti for UE_id"); continue_flag=1; @@ -515,7 +553,7 @@ void schedule_ue_spec(module_id_t module_idP, nb_available_rb = pre_nb_available_rbs[CC_id][UE_id]; UE_list->eNB_UE_stats[CC_id][UE_id].crnti= rnti; - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status=mac_get_rrc_status(module_idP,1,UE_id); + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status=mac_eNB_get_rrc_status(module_idP,rnti); mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; @@ -533,8 +571,9 @@ void schedule_ue_spec(module_id_t module_idP, #ifdef EXMIMO - if (mac_xface->get_transmission_mode(module_idP,CC_id, rnti)==5) + if (mac_xface->get_transmission_mode(module_idP,CC_id, rnti)==5) { eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1,16); + } #endif @@ -574,8 +613,9 @@ void schedule_ue_spec(module_id_t module_idP, if (nb_rb <= nb_available_rb) { if(nb_rb == pre_nb_available_rbs[CC_id][UE_id]) { - for(j=0; j<frame_parms[CC_id]->N_RBG; j++) // for indicating the rballoc for each sub-band + for(j=0; j<frame_parms[CC_id]->N_RBG; j++) { // for indicating the rballoc for each sub-band UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = rballoc_sub_UE[CC_id][UE_id][j]; + } } else { nb_rb_temp = nb_rb; j = 0; @@ -586,10 +626,11 @@ void schedule_ue_spec(module_id_t module_idP, if((j == frame_parms[CC_id]->N_RBG-1) && ((frame_parms[CC_id]->N_RB_DL == 25)|| - (frame_parms[CC_id]->N_RB_DL == 50))) + (frame_parms[CC_id]->N_RB_DL == 50))) { nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; - else + } else { nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; + } } j = j+1; @@ -605,8 +646,9 @@ void schedule_ue_spec(module_id_t module_idP, PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[CC_id][UE_id]; - for(j=0; j<frame_parms[CC_id]->N_RBG; j++) + for(j=0; j<frame_parms[CC_id]->N_RBG; j++) { PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } switch (mac_xface->get_transmission_mode(module_idP,CC_id,rnti)) { case 1: @@ -619,7 +661,8 @@ void schedule_ue_spec(module_id_t module_idP, ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rv = round&3; ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(UE_list->UE_template[CC_id][UE_id].DAI-1),((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->mcs); + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(UE_list->UE_template[CC_id][UE_id].DAI-1), + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->mcs); } else { // ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->ndi = 0; ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; @@ -636,7 +679,8 @@ void schedule_ue_spec(module_id_t module_idP, ((DCI1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rv = round&3; ((DCI1_5MHz_TDD_t*)DLSCH_dci)->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(UE_list->UE_template[CC_id][UE_id].DAI-1),((DCI1_5MHz_TDD_t*)DLSCH_dci)->mcs); + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(UE_list->UE_template[CC_id][UE_id].DAI-1), + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->mcs); } else { // ((DCI1_5MHz_FDD_t*)DLSCH_dci)->ndi = 0; ((DCI1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; @@ -653,7 +697,8 @@ void schedule_ue_spec(module_id_t module_idP, ((DCI1_10MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rv = round&3; ((DCI1_10MHz_TDD_t*)DLSCH_dci)->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(UE_list->UE_template[CC_id][UE_id].DAI-1),((DCI1_10MHz_TDD_t*)DLSCH_dci)->mcs); + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(UE_list->UE_template[CC_id][UE_id].DAI-1), + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->mcs); } else { // ((DCI1_10MHz_FDD_t*)DLSCH_dci)->ndi = 0; ((DCI1_10MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; @@ -670,7 +715,8 @@ void schedule_ue_spec(module_id_t module_idP, ((DCI1_20MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rv = round&3; ((DCI1_20MHz_TDD_t*)DLSCH_dci)->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(UE_list->UE_template[CC_id][UE_id].DAI-1),((DCI1_20MHz_TDD_t*)DLSCH_dci)->mcs); + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(UE_list->UE_template[CC_id][UE_id].DAI-1), + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->mcs); } else { // ((DCI1_20MHz_FDD_t*)DLSCH_dci)->ndi = 0; ((DCI1_20MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; @@ -706,8 +752,9 @@ void schedule_ue_spec(module_id_t module_idP, ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - if(dl_pow_off[CC_id][UE_id] == 2) + if(dl_pow_off[CC_id][UE_id] == 2) { dl_pow_off[CC_id][UE_id] = 1; + } ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = dl_pow_off[CC_id][UE_id]; // } @@ -780,7 +827,7 @@ void schedule_ue_spec(module_id_t module_idP, if ( TBS-ta_len-header_len_dcch > 0 ) { rlc_status = mac_rlc_status_ind( module_idP, - UE_id, + rnti, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, @@ -793,7 +840,7 @@ void schedule_ue_spec(module_id_t module_idP, LOG_D(MAC,"[eNB %d] Frame %d, DL-DCCH->DLSCH, Requesting %d bytes from RLC (RRC message)\n",module_idP,frameP,TBS-header_len_dcch); sdu_lengths[0] += mac_rlc_data_req( module_idP, - UE_id, + rnti, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, @@ -809,8 +856,9 @@ void schedule_ue_spec(module_id_t module_idP, #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC,"[eNB %d][DCCH] Got %d bytes :",module_idP,sdu_lengths[0]); - for (j=0; j<sdu_lengths[0]; j++) + for (j=0; j<sdu_lengths[0]; j++) { LOG_T(MAC,"%x ",dlsch_buffer[j]); + } LOG_T(MAC,"\n"); #endif @@ -824,7 +872,7 @@ void schedule_ue_spec(module_id_t module_idP, if (TBS-ta_len-header_len_dcch-sdu_length_total > 0 ) { rlc_status = mac_rlc_status_ind( module_idP, - UE_id, + rnti, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, @@ -837,7 +885,7 @@ void schedule_ue_spec(module_id_t module_idP, module_idP,frameP,TBS-header_len_dcch-sdu_length_total); sdu_lengths[num_sdus] += mac_rlc_data_req( module_idP, - UE_id, + rnti, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, @@ -866,7 +914,7 @@ void schedule_ue_spec(module_id_t module_idP, if (TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch > 0 ) { rlc_status = mac_rlc_status_ind( module_idP, - UE_id, + rnti, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, @@ -879,7 +927,7 @@ void schedule_ue_spec(module_id_t module_idP, module_idP,frameP,TBS-header_len_dcch-sdu_length_total-header_len_dtch,header_len_dtch); sdu_lengths[num_sdus] = mac_rlc_data_req( module_idP, - UE_id, + rnti, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, @@ -920,8 +968,11 @@ void schedule_ue_spec(module_id_t module_idP, mcs = eNB_UE_stats->dlsch_mcs1; - if (mcs==0) nb_rb = 4; // don't let the TBS get too small - else nb_rb=min_rb_unit[CC_id]; + if (mcs==0) { + nb_rb = 4; // don't let the TBS get too small + } else { + nb_rb=min_rb_unit[CC_id]; + } TBS = mac_xface->get_TBS_DL(mcs,nb_rb); @@ -952,10 +1003,11 @@ void schedule_ue_spec(module_id_t module_idP, if ((j == frame_parms[CC_id]->N_RBG-1) && ((frame_parms[CC_id]->N_RB_DL == 25)|| - (frame_parms[CC_id]->N_RB_DL == 50))) + (frame_parms[CC_id]->N_RB_DL == 50))) { nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; - else + } else { nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; + } } j = j+1; @@ -965,9 +1017,10 @@ void schedule_ue_spec(module_id_t module_idP, PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[CC_id][UE_id]; - for(j=0; j<frame_parms[CC_id]->N_RBG; j++) + for(j=0; j<frame_parms[CC_id]->N_RBG; j++) { PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } // decrease mcs until TBS falls below required length while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs>0)) { @@ -976,7 +1029,8 @@ void schedule_ue_spec(module_id_t module_idP, } // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && ((( dl_pow_off[CC_id][UE_id]>0) && (mcs<28)) || ( (dl_pow_off[CC_id][UE_id]==0) && (mcs<=15)))) { + while ((TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && ((( dl_pow_off[CC_id][UE_id]>0) && (mcs<28)) + || ( (dl_pow_off[CC_id][UE_id]==0) && (mcs<=15)))) { mcs++; TBS = mac_xface->get_TBS_DL(mcs,nb_rb); } @@ -997,10 +1051,11 @@ void schedule_ue_spec(module_id_t module_idP, padding = 0; // adjust the header len - if (header_len_dtch==0) + if (header_len_dtch==0) { header_len_dcch = header_len_dcch_tmp; - else //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) + } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) header_len_dtch = header_len_dtch_tmp; + } post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len ; // 1 is for the postpadding header } @@ -1022,18 +1077,20 @@ void schedule_ue_spec(module_id_t module_idP, padding, post_padding); //#ifdef DEBUG_eNB_SCHEDULER - // if (ta_update) { - LOG_D(MAC, + if (ta_update) { + LOG_I(MAC, "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", module_idP,frameP, UE_id, CC_id, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset, ta_update,padding,post_padding,mcs,TBS,nb_rb,header_len_dcch,header_len_dtch); + } //#endif #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC,"[eNB %d] First 16 bytes of DLSCH : \n"); - for (i=0; i<16; i++) + for (i=0; i<16; i++) { LOG_T(MAC,"%x.",dlsch_buffer[i]); + } LOG_T(MAC,"\n"); #endif @@ -1042,19 +1099,21 @@ void schedule_ue_spec(module_id_t module_idP, // memcpy(&eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); // fill remainder of DLSCH with random data - for (j=0; j<(TBS-sdu_length_total-offset); j++) + for (j=0; j<(TBS-sdu_length_total-offset); j++) { UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff); + } //eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff); +#if defined(USER_MODE) && defined(OAI_EMU) /* Tracing of PDU is done on UE side */ - if (opt_enabled == 1) { + if (oai_emulation.info.opt_enabled) trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS, module_idP, 3, UE_RNTI(module_idP,UE_id), eNB->subframe,0,0); LOG_D(OPT,"[eNB %d][DLSCH] Frame %d rnti %x with size %d\n", module_idP, frameP, UE_RNTI(module_idP,UE_id), TBS); - } +#endif aggregation = process_ue_cqi(module_idP,UE_id); nCCE[CC_id]-=(1<<aggregation); // adjust the remaining nCCE @@ -1329,8 +1388,9 @@ void schedule_ue_spec(module_id_t module_idP, ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - if(dl_pow_off[CC_id][UE_id] == 2) + if(dl_pow_off[CC_id][UE_id] == 2) { dl_pow_off[CC_id][UE_id] = 1; + } ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = dl_pow_off[CC_id][UE_id]; ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->tpmi = 5; @@ -1351,9 +1411,7 @@ void schedule_ue_spec(module_id_t module_idP, LOG_D(MAC,"Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n",frameP,subframeP,UE_id, UE_list->UE_template[CC_id][UE_id].rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - } - - else { // There is no data from RLC or MAC header, so don't schedule + } else { // There is no data from RLC or MAC header, so don't schedule } } @@ -1372,7 +1430,17 @@ void schedule_ue_spec(module_id_t module_idP, } -void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,uint32_t *RBallocP,uint8_t RA_scheduledP,int *mbsfn_flagP) +//------------------------------------------------------------------------------ +void +fill_DLSCH_dci( + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + uint32_t* RBallocP, + uint8_t RA_scheduledP, + int* mbsfn_flagP +) +//------------------------------------------------------------------------------ { // loop over all allocated UEs and compute frequency allocations for PDSCH @@ -1941,10 +2009,11 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP if (round>0) { //RA_template->wait_ack_Msg4++; // we have to schedule a retransmission - if (PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.frame_type == TDD) + if (PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.frame_type == TDD) { ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->ndi=1; - else + } else { ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->ndi=1; + } // randomize frequency allocation for RA while (1) { @@ -2017,10 +2086,11 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP for(i=0; i<PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.N_RBG; i++) { rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; - if(rballoc_sub[i] == 1) + if(rballoc_sub[i] == 1) { rballoc[CC_id] |= (0x0001<<i); // TO be FIXED!!!!!! } + } switch(mac_xface->get_transmission_mode(module_idP,CC_id,rnti)) { default: @@ -2276,9 +2346,19 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,VCD_FUNCTION_OUT); } -unsigned char *get_dlsch_sdu(module_id_t module_idP, int CC_id, frame_t frameP, rnti_t rntiP, uint8_t TBindex) +//------------------------------------------------------------------------------ +unsigned char* +get_dlsch_sdu( + module_id_t module_idP, + int CC_id, + frame_t frameP, + rnti_t rntiP, + uint8_t TBindex +) +//------------------------------------------------------------------------------ { + int UE_id; eNB_MAC_INST *eNB=&eNB_mac_inst[module_idP]; if (rntiP==SI_RNTI) { @@ -2287,7 +2367,7 @@ unsigned char *get_dlsch_sdu(module_id_t module_idP, int CC_id, frame_t frameP, return((unsigned char *)&eNB->common_channels[CC_id].BCCH_pdu.payload[0]); } - int UE_id = find_UE_id(module_idP,rntiP); + UE_id = find_UE_id(module_idP,rntiP); if (UE_id != -1) { LOG_D(MAC,"[eNB %d] Frame %d: CC_id %d Get DLSCH sdu for rnti %x => UE_id %d\n",module_idP,frameP,CC_id,rntiP,UE_id); @@ -2300,7 +2380,14 @@ unsigned char *get_dlsch_sdu(module_id_t module_idP, int CC_id, frame_t frameP, } -void update_ul_dci(module_id_t module_idP,uint8_t CC_id,rnti_t rnti,uint8_t dai) +//------------------------------------------------------------------------------ +void +update_ul_dci( + module_id_t module_idP, + uint8_t CC_id, + rnti_t rnti, + uint8_t dai) +//------------------------------------------------------------------------------ { DCI_PDU *DCI_pdu = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu; @@ -2311,8 +2398,9 @@ void update_ul_dci(module_id_t module_idP,uint8_t CC_id,rnti_t rnti,uint8_t dai) for (i=0; i<DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci; i++) { ULSCH_dci = (DCI0_5MHz_TDD_1_6_t *)DCI_pdu->dci_alloc[i].dci_pdu; - if ((DCI_pdu->dci_alloc[i].format == format0) && (DCI_pdu->dci_alloc[i].rnti == rnti)) + if ((DCI_pdu->dci_alloc[i].format == format0) && (DCI_pdu->dci_alloc[i].rnti == rnti)) { ULSCH_dci->dai = (dai-1)&3; + } } } @@ -2320,53 +2408,64 @@ void update_ul_dci(module_id_t module_idP,uint8_t CC_id,rnti_t rnti,uint8_t dai) } -void set_ue_dai(sub_frame_t subframeP, +//------------------------------------------------------------------------------ +void set_ue_dai( + sub_frame_t subframeP, uint8_t tdd_config, int UE_id, uint8_t CC_id, - UE_list_t *UE_list) + UE_list_t* UE_list +) +//------------------------------------------------------------------------------ { switch (tdd_config) { case 0: - if ((subframeP==0)||(subframeP==1)||(subframeP==3)||(subframeP==5)||(subframeP==6)||(subframeP==8)) + if ((subframeP==0)||(subframeP==1)||(subframeP==3)||(subframeP==5)||(subframeP==6)||(subframeP==8)) { UE_list->UE_template[CC_id][UE_id].DAI = 0; + } break; case 1: - if ((subframeP==0)||(subframeP==4)||(subframeP==5)||(subframeP==9)) + if ((subframeP==0)||(subframeP==4)||(subframeP==5)||(subframeP==9)) { UE_list->UE_template[CC_id][UE_id].DAI = 0; + } break; case 2: - if ((subframeP==4)||(subframeP==5)) + if ((subframeP==4)||(subframeP==5)) { UE_list->UE_template[CC_id][UE_id].DAI = 0; + } break; case 3: - if ((subframeP==5)||(subframeP==7)||(subframeP==9)) + if ((subframeP==5)||(subframeP==7)||(subframeP==9)) { UE_list->UE_template[CC_id][UE_id].DAI = 0; + } break; case 4: - if ((subframeP==0)||(subframeP==6)) + if ((subframeP==0)||(subframeP==6)) { UE_list->UE_template[CC_id][UE_id].DAI = 0; + } break; case 5: - if (subframeP==9) + if (subframeP==9) { UE_list->UE_template[CC_id][UE_id].DAI = 0; + } break; case 6: - if ((subframeP==0)||(subframeP==1)||(subframeP==5)||(subframeP==6)||(subframeP==9)) + if ((subframeP==0)||(subframeP==1)||(subframeP==5)||(subframeP==6)||(subframeP==9)) { UE_list->UE_template[CC_id][UE_id].DAI = 0; + } break; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c index 1ad4b147a12..63c5eb22cc2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c @@ -75,8 +75,9 @@ int8_t get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t CC_id, uint8_t mb if (mbsfn_sync_area > MAX_MBSFN_AREA) { LOG_W(MAC,"[eNB %d] MBSFN synchronization area %d out of range\n ", module_idP, mbsfn_sync_area); return -1; - } else if (eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) + } else if (eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) { return mbsfn_sync_area; + } else { LOG_W(MAC,"[eNB %d] MBSFN Subframe Config pattern %d not found \n ", module_idP, mbsfn_sync_area); return -1; @@ -108,8 +109,9 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra i< eNB_mac_inst[module_idP].common_channels[CC_id].num_active_mbsfn_area; i++ ) { // assume, that there is always a mapping - if ((j=get_mbsfn_sf_alloction(module_idP,CC_id,i)) == -1) + if ((j=get_mbsfn_sf_alloction(module_idP,CC_id,i)) == -1) { return 0; + } mbsfn_period = 1<<(eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->radioframeAllocationPeriod); mcch_period = 32<<(eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); @@ -158,12 +160,14 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra case 1: if (mac_xface->lte_frame_parms->frame_type == FDD) { if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { - if (msi_pos == 1) + if (msi_pos == 1) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -174,12 +178,14 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra case 2: if (mac_xface->lte_frame_parms->frame_type == FDD) { if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { - if (msi_pos == 2) + if (msi_pos == 2) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -190,23 +196,27 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra case 3: if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { - if (msi_pos == 1) + if (msi_pos == 1) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) { mcch_flag = 1; + } mtch_flag = 1; } } else { // FDD if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { - if (msi_pos == 3) + if (msi_pos == 3) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -217,12 +227,14 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra case 4: if (mac_xface->lte_frame_parms->frame_type == TDD) { if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { - if (msi_pos == 2) + if (msi_pos == 2) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -233,12 +245,14 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra case 6: if (mac_xface->lte_frame_parms->frame_type == FDD) { if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { - if (msi_pos == 4) + if (msi_pos == 4) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -249,23 +263,27 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra case 7: if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { - if (msi_pos == 3) + if (msi_pos == 3) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) { mcch_flag = 1; + } mtch_flag = 1; } } else { // FDD if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { - if (msi_pos == 5) + if (msi_pos == 5) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -276,23 +294,27 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra case 8: if (mac_xface->lte_frame_parms->frame_type == TDD) { //TDD if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { - if (msi_pos == 4) + if (msi_pos == 4) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) { mcch_flag = 1; + } mtch_flag = 1; } } else { // FDD if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { - if (msi_pos == 6) + if (msi_pos == 6) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -303,12 +325,14 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra case 9: if (mac_xface->lte_frame_parms->frame_type == TDD) { if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { - if (msi_pos == 5) + if (msi_pos == 5) { msi_flag = 1; + } if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) + ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -372,10 +396,11 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra msi_length = msi_ptr-msi_control_element; - if (msi_length<128) + if (msi_length<128) { header_len_msi = 2; - else + } else { header_len_msi = 3; + } LOG_D(MAC,"[eNB %d] Frame %d : MSI->MCH, length of MSI is %d bytes \n",module_idP,frameP,msi_length); //LOG_D(MAC,"Scheduler: MSI is transmitted in this subframeP \n" ); @@ -434,8 +459,9 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra sdu_lcids[num_sdus] = MCCH_LCHANID; sdu_lengths[num_sdus] = mcch_sdu_length; - if (sdu_lengths[num_sdus]>128) + if (sdu_lengths[num_sdus]>128) { header_len_mcch = 3; + } sdu_length_total += sdu_lengths[num_sdus]; LOG_D(MAC,"[eNB %d] Got %d bytes for MCCH from RRC \n",module_idP,sdu_lengths[num_sdus]); @@ -505,8 +531,9 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra sdu_lcids[num_sdus] = MTCH; sdu_length_total += sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) + if (sdu_lengths[num_sdus] < 128) { header_len_mtch = 2; + } num_sdus++; } else { @@ -532,11 +559,13 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra header_len_mcch_temp = header_len_mcch; header_len_msi_temp = header_len_msi; - if (header_len_mtch>0) + if (header_len_mtch>0) { header_len_mtch=1; // remove Length field in the subheader for the last PDU - else if (header_len_mcch>0) + } else if (header_len_mcch>0) { header_len_mcch=1; - else header_len_msi=1; + } else { + header_len_msi=1; + } // Calculate the padding if ((TBS - header_len_mtch - header_len_mcch - header_len_msi - sdu_length_total) < 0) { @@ -549,11 +578,13 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra } else { // using post_padding, give back the Length field of subheader for the last PDU padding = 0; - if (header_len_mtch>0) + if (header_len_mtch>0) { header_len_mtch = header_len_mtch_temp; - else if (header_len_mcch>0) + } else if (header_len_mcch>0) { header_len_mcch = header_len_mcch_temp; - else header_len_msi = header_len_msi_temp; + } else { + header_len_msi = header_len_msi_temp; + } post_padding = TBS - sdu_length_total - header_len_msi - header_len_mcch - header_len_mtch; } @@ -579,23 +610,26 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcch_active,eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mtch_active ); LOG_I(MAC, "[eNB %d][MBMS USER-PLANE ] Generate header : sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,padding %d,post_padding %d (mcs %d, TBS %d), header MTCH %d, header MCCH %d, header MSI %d\n", - module_idP,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset,padding,post_padding,eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcs,TBS,header_len_mtch, header_len_mcch, - header_len_msi); + module_idP,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset,padding,post_padding,eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcs,TBS, + header_len_mtch, header_len_mcch, header_len_msi); // copy SDU to mch_pdu after the MAC Header memcpy(&eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload[offset],mch_buffer,sdu_length_total); // filling remainder of MCH with random data if necessery - for (j=0; j<(TBS-sdu_length_total-offset); j++) + for (j=0; j<(TBS-sdu_length_total-offset); j++) { eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff); + } + +#if defined(USER_MODE) && defined(OAI_EMU) /* Tracing of PDU is done on UE side */ - if (opt_enabled ==1 ) { + if (oai_emulation.info.opt_enabled) trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload, TBS, module_idP, 6, 0xffff, // M_RNTI = 6 in wirehsark eNB_mac_inst[module_idP].subframe,0,0); LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n", module_idP, frameP, TBS); - } +#endif /* for (j=0;j<sdu_length_total;j++) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 1786053b9c9..2254c857256 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -68,7 +68,9 @@ #define DEBUG_eNB_SCHEDULER 1 +//------------------------------------------------------------------------------ void init_ue_sched_info(void) +//------------------------------------------------------------------------------ { module_id_t i,j,k; @@ -91,21 +93,27 @@ void init_ue_sched_info(void) +//------------------------------------------------------------------------------ unsigned char get_ue_weight(module_id_t module_idP, int CC_id, int ue_idP) +//------------------------------------------------------------------------------ { return(eNB_dlsch_info[module_idP][CC_id][ue_idP].weight); } +//------------------------------------------------------------------------------ DCI_PDU *get_dci_sdu(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframeP) +//------------------------------------------------------------------------------ { return(&eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu); } +//------------------------------------------------------------------------------ int find_UE_id(module_id_t mod_idP, rnti_t rntiP) +//------------------------------------------------------------------------------ { int UE_id; @@ -121,30 +129,39 @@ int find_UE_id(module_id_t mod_idP, rnti_t rntiP) } +//------------------------------------------------------------------------------ int UE_num_active_CC(UE_list_t *listP,int ue_idP) +//------------------------------------------------------------------------------ { return(listP->numactiveCCs[ue_idP]); } +//------------------------------------------------------------------------------ int UE_PCCID(module_id_t mod_idP,int ue_idP) +//------------------------------------------------------------------------------ { return(eNB_mac_inst[mod_idP].UE_list.pCC_id[ue_idP]); } +//------------------------------------------------------------------------------ rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP) +//------------------------------------------------------------------------------ { rnti_t rnti = eNB_mac_inst[mod_idP].UE_list.UE_template[UE_PCCID(mod_idP,ue_idP)][ue_idP].rnti; - if (rnti>0) + if (rnti>0) { return (rnti); + } - LOG_W(MAC,"[eNB %d] Couldn't find RNTI for UE %d\n",mod_idP,ue_idP); - //mac_xface->macphy_exit("UE_RNTI: Couldn't find RNTI for UE"); - return(0); + LOG_E(MAC,"[eNB %d] Couldn't find RNTI for UE %d\n",mod_idP,ue_idP); + //display_backtrace(); + return(NOT_A_RNTI); } +//------------------------------------------------------------------------------ boolean_t is_UE_active(module_id_t mod_idP, int ue_idP) +//------------------------------------------------------------------------------ { return(eNB_mac_inst[mod_idP].UE_list.active[ue_idP]); } @@ -235,6 +252,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) if (UE_list->avail>=0) { UE_id = UE_list->avail; + AssertFatal( UE_id < NUMBER_OF_UE_MAX, "BAD UE_id %u > NUMBER_OF_UE_MAX",UE_id ); UE_list->avail = UE_list->next[UE_list->avail]; UE_list->next[UE_id] = UE_list->head; UE_list->next_ul[UE_id] = UE_list->head_ul; @@ -267,15 +285,19 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) return(-1); } -int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP) +//------------------------------------------------------------------------------ +int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subframeP) +//------------------------------------------------------------------------------ { int prev,i, ret=-1; + rnti_t rnti; UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list; int pCC_id = UE_PCCID(mod_idP,ue_idP); - LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",ue_idP,pCC_id, UE_list->UE_template[pCC_id][ue_idP].rnti); + rnti = UE_list->UE_template[pCC_id][ue_idP].rnti; + LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",ue_idP,pCC_id, rnti); dump_ue_list(UE_list,0); // clear all remaining pending transmissions @@ -285,14 +307,18 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP) UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID3] = 0; UE_list->UE_template[pCC_id][ue_idP].ul_SR = 0; - UE_list->UE_template[pCC_id][ue_idP].rnti = 0; + UE_list->UE_template[pCC_id][ue_idP].rnti = NOT_A_RNTI; UE_list->UE_template[pCC_id][ue_idP].ul_active = FALSE; - eNB_ulsch_info[mod_idP][pCC_id][ue_idP].rnti = 0; + eNB_ulsch_info[mod_idP][pCC_id][ue_idP].rnti = NOT_A_RNTI; eNB_ulsch_info[mod_idP][pCC_id][ue_idP].status = S_UL_NONE; - eNB_dlsch_info[mod_idP][pCC_id][ue_idP].rnti = 0; + eNB_dlsch_info[mod_idP][pCC_id][ue_idP].rnti = NOT_A_RNTI; eNB_dlsch_info[mod_idP][pCC_id][ue_idP].status = S_DL_NONE; - rrc_eNB_free_UE_index(mod_idP,ue_idP,frameP); + rrc_eNB_free_UE( + mod_idP, + rnti, + frameP, + subframeP); prev = UE_list->head; @@ -300,10 +326,11 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP) if (i == ue_idP) { // link prev to next in Active list //if (prev==UE_list->head) - if (i==UE_list->head) + if (i==UE_list->head) { UE_list->head = UE_list->next[i]; - else + } else { UE_list->next[prev] = UE_list->next[i]; + } // add UE id (i)to available UE_list->next[i] = UE_list->avail; @@ -323,10 +350,11 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP) for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { if (i == ue_idP) { // link prev to next in Active list - if (prev==UE_list->head_ul) + if (prev==UE_list->head_ul) { UE_list->head_ul = UE_list->next_ul[i]; - else + } else { UE_list->next_ul[prev] = UE_list->next_ul[i]; + } // add UE id (i)to available UE_list->next_ul[i] = UE_list->avail; @@ -337,8 +365,9 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP) prev=i; } - if (ret == 0) + if (ret == 0) { return (0); + } LOG_E(MAC,"error in mac_remove_ue(), could not find previous to %d in UE_list, should never happen, Dumping UE list\n",ue_idP); dump_ue_list(UE_list,0); @@ -354,25 +383,27 @@ int prev(UE_list_t *listP, int nodeP, int ul_flag) int j; if (ul_flag == 0 ) { - if (nodeP==listP->head) + if (nodeP==listP->head) { return(nodeP); + } for (j=listP->head; j>=0; j=listP->next[j]) { - if (listP->next[j]==nodeP) + if (listP->next[j]==nodeP) { return(j); } + } } else { - if (nodeP==listP->head_ul) + if (nodeP==listP->head_ul) { return(nodeP); + } for (j=listP->head_ul; j>=0; j=listP->next_ul[j]) { - if (listP->next_ul[j]==nodeP) + if (listP->next_ul[j]==nodeP) { return(j); + } } } - - LOG_E(MAC,"error in prev(), could not find previous to %d in UE_list %s, should never happen, Dumping UE list\n", nodeP, (ul_flag == 0)? "DL" : "UL"); dump_ue_list(listP, ul_flag); @@ -417,21 +448,22 @@ void swap_UEs(UE_list_t *listP,int nodeiP, int nodejP, int ul_flag) listP->next[nodeiP] = next_j; listP->next[nodejP] = nodeiP; - if (nodeiP==listP->head) // case i j n(j) + if (nodeiP==listP->head) { // case i j n(j) listP->head = nodejP; - else + } else { listP->next[prev_i] = nodejP; + } } else if (next_j == nodeiP) { // case ... p(j) j i n(i) ... => ... p(i) i j n(j) ... LOG_T(MAC,"Case ... p(j) j i n(i) ... => ... p(i) i j n(j) ...\n"); listP->next[nodejP] = next_i; listP->next[nodeiP] = nodejP; - if (nodejP==listP->head) // case j i n(i) + if (nodejP==listP->head) { // case j i n(i) listP->head = nodeiP; - else + } else { listP->next[prev_j] = nodeiP; + } } else { // case ... p(i) i n(i) ... p(j) j n(j) ... - listP->next[nodejP] = next_i; listP->next[nodeiP] = next_j; @@ -457,19 +489,21 @@ void swap_UEs(UE_list_t *listP,int nodeiP, int nodejP, int ul_flag) listP->next_ul[nodeiP] = next_j; listP->next_ul[nodejP] = nodeiP; - if (nodeiP==listP->head_ul) // case i j n(j) + if (nodeiP==listP->head_ul) { // case i j n(j) listP->head_ul = nodejP; - else + } else { listP->next_ul[prev_i] = nodejP; + } } else if (next_j == nodeiP) { // case ... p(j) j i n(i) ... => ... p(i) i j n(j) ... LOG_T(MAC,"[UL]Case ... p(j) j i n(i) ... => ... p(i) i j n(j) ...\n"); listP->next_ul[nodejP] = next_i; listP->next_ul[nodeiP] = nodejP; - if (nodejP==listP->head_ul) // case j i n(i) + if (nodejP==listP->head_ul) { // case j i n(i) listP->head_ul = nodeiP; - else + } else { listP->next_ul[prev_j] = nodeiP; + } } else { // case ... p(i) i n(i) ... p(j) j n(j) ... listP->next_ul[nodejP] = next_i; @@ -681,10 +715,11 @@ uint8_t UE_is_to_be_scheduled(module_id_t module_idP,int CC_id,uint8_t UE_id) (UE_template->bsr_info[LCGID1]>0) || (UE_template->bsr_info[LCGID2]>0) || (UE_template->bsr_info[LCGID3]>0) || - (UE_template->ul_SR>0)) // uplink scheduling request + (UE_template->ul_SR>0)) { // uplink scheduling request return(1); - else + } else { return(0); + } } @@ -704,8 +739,9 @@ uint32_t allocate_prbs(int UE_id,unsigned char nb_rb, uint32_t *rballoc) nb_rb_alloc+=2; } - if (nb_rb_alloc==nb_rb) + if (nb_rb_alloc==nb_rb) { return(rballoc_dci); + } } if ((mac_xface->lte_frame_parms->N_RB_DL&1)==1) { @@ -771,18 +807,20 @@ uint32_t allocate_prbs_sub(int nb_rb, uint8_t *rballoc) break; case 25: - if (check == mac_xface->lte_frame_parms->N_RBG-1) + if ((check == mac_xface->lte_frame_parms->N_RBG-1)) { nb_rb--; - else + } else { nb_rb-=2; + } break; case 50: - if (check == mac_xface->lte_frame_parms->N_RBG-1) + if ((check == mac_xface->lte_frame_parms->N_RBG-1)) { nb_rb-=2; - else + } else { nb_rb-=3; + } break; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index d8c5ba70cce..b549a7bc97e 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -83,7 +83,9 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 start_meas(&eNB->rx_ulsch_sdu); if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1) ) - for(ii=0; ii<NB_RB_MAX; ii++) rx_lengths[ii] = 0; + for(ii=0; ii<NB_RB_MAX; ii++) { + rx_lengths[ii] = 0; + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,1); @@ -118,8 +120,9 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 rx_ces[i], lcgid, payload_ptr[0] & 0x3f); UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid] = (payload_ptr[0] & 0x3f); - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] == 0 ) + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] == 0 ) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid]=frameP; + } } payload_ptr += 1;//sizeof(SHORT_BSR); // fixme @@ -142,26 +145,30 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2], UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]); - if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0] == 0 ) + if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0] == 0 ) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0]=0; - else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] == 0) + } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] == 0) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0]=frameP; + } - if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1] == 0 ) + if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1] == 0 ) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1]=0; - else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] == 0) + } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] == 0) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1]=frameP; + } - if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2] == 0 ) + if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2] == 0 ) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2]=0; - else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] == 0) + } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] == 0) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2]=frameP; + } - if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] == 0 ) + if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] == 0 ) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3]= 0; - else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] == 0) + } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] == 0) { UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3]=frameP; + } } payload_ptr += 3;////sizeof(LONG_BSR); @@ -197,9 +204,9 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 LOG_I(MAC,"[eNB %d][RAPROC] Frame %d CCCH: Received RRCConnectionRequest: length %d, offset %d\n", enb_mod_idP,frameP,rx_lengths[ii],payload_ptr-sduP); - if ((UE_id=add_new_ue(enb_mod_idP,CC_idP,eNB->common_channels[CC_idP].RA_template[ii].rnti,harq_pidP)) == -1 ) + if ((UE_id=add_new_ue(enb_mod_idP,CC_idP,eNB->common_channels[CC_idP].RA_template[ii].rnti,harq_pidP)) == -1 ) { mac_xface->macphy_exit("[MAC][eNB] Max user count reached\n"); - else + } else LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Added user with rnti %x => UE %d\n", enb_mod_idP,frameP,eNB->common_channels[CC_idP].RA_template[ii].rnti,UE_id); } else { @@ -208,7 +215,16 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 } if (Is_rrc_registered == 1) - mac_rrc_data_ind(enb_mod_idP,frameP,CCCH,(uint8_t *)payload_ptr,rx_lengths[ii],1,enb_mod_idP,0); + mac_rrc_data_ind( + enb_mod_idP, + frameP, + rntiP, + CCCH, + (uint8_t*)payload_ptr, + rx_lengths[ii], + ENB_FLAG_YES, + enb_mod_idP, + 0); if (num_ce >0) { // handle msg3 which is not RRCConnectionRequest @@ -232,8 +248,9 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 #if defined(ENABLE_MAC_PAYLOAD_DEBUG) LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sduP)); - for (j=0; j<32; j++) + for (j=0; j<32; j++) { LOG_T(MAC,"%x ",payload_ptr[j]); + } LOG_T(MAC,"\n"); #endif @@ -243,7 +260,12 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n", enb_mod_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]); - mac_rlc_data_ind(enb_mod_idP,UE_id, frameP,ENB_FLAG_YES,MBMS_FLAG_NO, + mac_rlc_data_ind( + enb_mod_idP, + rntiP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, rx_lcids[i], (char *)payload_ptr, rx_lengths[i], @@ -263,8 +285,9 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 #if defined(ENABLE_MAC_PAYLOAD_DEBUG) LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sduP)); - for (j=0; j<32; j++) + for (j=0; j<32; j++) { LOG_T(MAC,"%x ",payload_ptr[j]); + } LOG_T(MAC,"\n"); #endif @@ -273,7 +296,12 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8 enb_mod_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i]); if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0) ) { // MAX SIZE OF transport block - mac_rlc_data_ind(enb_mod_idP,UE_id, frameP,ENB_FLAG_YES,MBMS_FLAG_NO, + mac_rlc_data_ind( + enb_mod_idP, + rntiP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, DTCH, (char *)payload_ptr, rx_lengths[i], @@ -321,8 +349,9 @@ uint32_t bytes_to_bsr_index(int32_t nbytes) uint32_t i=0; - if (nbytes<0) + if (nbytes<0) { return(0); + } while ((i<BSR_TABLE_SIZE)&& (BSR_TABLE[i]<=nbytes)) { @@ -464,8 +493,9 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, while (not_done==1) { - if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) + if (((SCH_SUBHEADER_FIXED*)mac_header_ptr)->E == 0) { not_done = 0; + } lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; @@ -474,8 +504,9 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, mac_header_ptr++; length = tb_length-(mac_header_ptr-mac_header)-ce_len; - for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) + for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) { length -= rx_lengths[num_sdu_cnt]; + } } else { if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; @@ -499,13 +530,13 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, num_ces++; mac_header_ptr++; - if (lcid==LONG_BSR) + if (lcid==LONG_BSR) { ce_len+=3; - else if (lcid==CRNTI) + } else if (lcid==CRNTI) { ce_len+=2; - else if ((lcid==POWER_HEADROOM) || (lcid==TRUNCATED_BSR)|| (lcid== SHORT_BSR)) + } else if ((lcid==POWER_HEADROOM) || (lcid==TRUNCATED_BSR)|| (lcid== SHORT_BSR)) { ce_len++; - else { + } else { LOG_E(MAC,"unknown CE %d \n", lcid); mac_xface->macphy_exit("unknown CE"); } @@ -623,12 +654,13 @@ void schedule_ulsch_rnti(module_id_t module_idP, for (UE_id=UE_list->head_ul; UE_id>=0; UE_id=UE_list->next_ul[UE_id]) { // don't schedule if Msg4 is not received yet - if (UE_list->UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured==FALSE) + if (UE_list->UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured==FALSE) { continue; + } rnti = UE_RNTI(module_idP,UE_id); - if (rnti==0) { + if (rnti==NOT_A_RNTI) { LOG_W(MAC,"[eNB %d] frame %d subfarme %d, UE %d CC %d: no RNTI \n", module_idP,frameP,subframeP,UE_id,CC_id); continue; } @@ -679,7 +711,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, // reset the scheduling request UE_template->ul_SR = 0; aggregation = process_ue_cqi(module_idP,UE_id); // =2 by default!! - status = mac_get_rrc_status(module_idP,1,UE_id); + status = mac_eNB_get_rrc_status(module_idP,rnti); cqi_req = (status < RRC_CONNECTED)? 0:1; //power control @@ -697,13 +729,16 @@ void schedule_ulsch_rnti(module_id_t module_idP, } else if (normalized_rx_power<(target_rx_power-1)) { tpc = 2; //+1 tpc_accumulated++; - } else + } else { tpc = 1; //0 - } else + } + + } else { tpc = 1; //0 + } - LOG_D(MAC,"[eNB %d] ULSCH scheduler: subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",module_idP,subframeP,harq_pid,tpc,tpc_accumulated,normalized_rx_power, - target_rx_power); + LOG_D(MAC,"[eNB %d] ULSCH scheduler: subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",module_idP,subframeP,harq_pid,tpc, + tpc_accumulated,normalized_rx_power,target_rx_power); // new transmission @@ -715,9 +750,9 @@ void schedule_ulsch_rnti(module_id_t module_idP, UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->pre_assigned_mcs_ul; mcs = cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS - if (UE_template->pre_allocated_rb_table_index_ul >=0) + if (UE_template->pre_allocated_rb_table_index_ul >=0) { rb_table_index=UE_template->pre_allocated_rb_table_index_ul; - else { + } else { mcs=10; rb_table_index=5; // for PHR } @@ -753,11 +788,12 @@ void schedule_ulsch_rnti(module_id_t module_idP, ndi = UE_template->oldNDI_UL[harq_pid]; - if ((round&3)==0) + if ((round&3)==0) { mcs = openair_daq_vars.target_ue_ul_mcs; - else + } else { mcs = rvidx_tab[round&3] + 28; //not correct for round==4! + } LOG_D(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, TBS %d, harq_pid %d, round %d)\n", module_idP,UE_id,rnti,frameP,subframeP,mcs, @@ -773,12 +809,14 @@ void schedule_ulsch_rnti(module_id_t module_idP, // Cyclic shift for DM RS if(cooperation_flag == 2) { - if(UE_id == 1)// For Distriibuted Alamouti, cyclic shift applied to 2nd UE + if(UE_id == 1) { // For Distriibuted Alamouti, cyclic shift applied to 2nd UE cshift = 1; - else + } else { cshift = 0; - } else + } + } else { cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) + } if (frame_parms->frame_type == TDD) { switch (frame_parms->N_RB_UL) { @@ -1070,20 +1108,22 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f //weight[cba_group] = floor(total_UEs/active_groups);//find_num_active_UEs_in_cbagroup(module_idP, cba_group); for (UE_id=UE_list->head_ul; UE_id>=0; UE_id=UE_list->next_ul[UE_id]) { - if (UE_RNTI(module_idP,UE_id)==0) + if (UE_RNTI(module_idP,UE_id)==NOT_A_RNTI) continue; // simple UE identity based grouping if ((UE_id % total_groups) == cba_group) { // this could be simplifed to active_UEs[UE_id % total_groups]++; if ((mac_get_rrc_status(module_idP,1,UE_id) > RRC_CONNECTED) && - (UE_is_to_be_scheduled(module_idP,CC_id,UE_id) == 0)) + (UE_is_to_be_scheduled(module_idP,CC_id,UE_id) == 0)) { active_UEs[cba_group]++; + } } - if (UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul <= 2) + if (UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul <= 2) { mcs[cba_group]= 8; // apply fixed scheduling - else if ((UE_id % total_groups) == cba_group) + } else if ((UE_id % total_groups) == cba_group) { mcs[cba_group]= cmin(mcs[cba_group],UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul); + } } mcs[cba_group]= cmin(mcs[cba_group],openair_daq_vars.target_ue_ul_mcs); @@ -1157,8 +1197,9 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f cba_group++; } - if (total_cba_resources <= 0) + if (total_cba_resources <= 0) { return; + } // increase rb if any left: to be done cba_group=0; @@ -1172,7 +1213,8 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f // phase 3: for (cba_group=0; cba_group<total_groups; cba_group++) { - LOG_N(MAC,"[eNB %d] Frame %d, subframe %d: cba group %d active_ues %d total groups %d mcs %d, available/required rb (%d/%d), num resources %d, ncce (%d/%d required %d \n", + LOG_N(MAC, + "[eNB %d] Frame %d, subframe %d: cba group %d active_ues %d total groups %d mcs %d, available/required rb (%d/%d), num resources %d, ncce (%d/%d required %d \n", module_idP, frameP, subframeP, cba_group,active_UEs[cba_group],total_groups, mcs[cba_group], available_rbs,required_rbs[cba_group], num_cba_resources[cba_group], @@ -1185,11 +1227,13 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f if (required_rbs[cba_group] == 0 ) continue; - while (rb_table[rb_table_index] < (uint8_t) ceil(required_rbs[cba_group] / num_cba_resources[cba_group]) ) + while (rb_table[rb_table_index] < (uint8_t) ceil(required_rbs[cba_group] / num_cba_resources[cba_group]) ) { rb_table_index++; + } - while (rb_table[rb_table_index] > remaining_rbs ) + while (rb_table[rb_table_index] > remaining_rbs ) { rb_table_index--; + } remaining_rbs-=rb_table[rb_table_index]; allocated_rbs=rb_table[rb_table_index]; @@ -1199,7 +1243,8 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f rb_table[rb_table_index]); first_rb[CC_id]+=rb_table[rb_table_index]; - LOG_N(MAC,"[eNB %d] Frame %d, subframeP %d: schedule CBA access %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), mcs %d, rballoc %d, nCCE (%d/%d)\n", + LOG_N(MAC, + "[eNB %d] Frame %d, subframeP %d: schedule CBA access %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), mcs %d, rballoc %d, nCCE (%d/%d)\n", module_idP, frameP, subframeP, cba_group,eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], available_rbs, required_rbs[cba_group], allocated_rbs, remaining_rbs, mcs[cba_group],rballoc,nCCE_available[CC_id],nCCE[CC_id]); diff --git a/openair2/LAYER2/MAC/l1_helpers.c b/openair2/LAYER2/MAC/l1_helpers.c index c269f6fdd12..89314b82009 100644 --- a/openair2/LAYER2/MAC/l1_helpers.c +++ b/openair2/LAYER2/MAC/l1_helpers.c @@ -51,8 +51,9 @@ int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP,uint8_t CC_id) return 0; // not reached } - if (UE_mac_inst[module_idP].radioResourceConfigCommon) + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; + } else { LOG_E(MAC,"[UE %d] CCid %d FATAL radioResourceConfigCommon is NULL !!!\n",module_idP,CC_id); mac_xface->macphy_exit("FATAL radioResourceConfigCommon is NULL"); diff --git a/openair2/LAYER2/MAC/lte_transport_init.c b/openair2/LAYER2/MAC/lte_transport_init.c index 5a31ee43f4a..47493f50868 100755 --- a/openair2/LAYER2/MAC/lte_transport_init.c +++ b/openair2/LAYER2/MAC/lte_transport_init.c @@ -115,10 +115,11 @@ void init_transport_channels(unsigned char transmission_mode) DLSCH_alloc_pdu1.rv1 = 0; // Forget second codeword - if (transmission_mode == 6) + if (transmission_mode == 6) { DLSCH_alloc_pdu1.tpmi = 5; // PUSCH_PRECODING0 - else + } else { DLSCH_alloc_pdu1.tpmi = 0; + } DLSCH_alloc_pdu2.rah = 0; DLSCH_alloc_pdu2.rballoc = DLSCH_RB_ALLOC; @@ -131,9 +132,9 @@ void init_transport_channels(unsigned char transmission_mode) DLSCH_alloc_pdu2.rv1 = 0; // Forget second codeword - if (transmission_mode == 6) + if (transmission_mode == 6) { DLSCH_alloc_pdu2.tpmi = 5; // PUSCH_PRECODING0 - else + } else { DLSCH_alloc_pdu2.tpmi = 0; - + } } diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index 1a58792006b..1a549d14428 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -142,11 +142,12 @@ int mac_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, ui bzero(UE_mac_inst,NB_UE_INST*sizeof(UE_MAC_INST)); - for(i=0; i<NB_UE_INST; i++) + for(i=0; i<NB_UE_INST; i++) { ue_init_mac(i); - - } else + } + } else { UE_mac_inst = NULL; + } LOG_I(MAC,"[MAIN] Init function start:Nb_eNB_INST=%d\n",NB_eNB_INST); @@ -160,8 +161,9 @@ int mac_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, ui LOG_D(MAC,"[MAIN] ALLOCATE %d Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST),NB_eNB_INST,eNB_mac_inst); bzero(eNB_mac_inst,NB_eNB_INST*sizeof(eNB_MAC_INST)); } - } else + } else { eNB_mac_inst = NULL; + } // Initialize Linked-List for Active UEs for(Mod_id=0; Mod_id<NB_eNB_INST; Mod_id++) { @@ -335,8 +337,9 @@ int mac_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, ui eNB_mac_inst[j][CC_id].sbmap_conf.sb_size=SB_size; eNB_mac_inst[j][CC_id].sbmap_conf.nb_active_sb=1; - for(i=0; i<NUMBER_OF_SUBBANDS; i++) + for(i=0; i<NUMBER_OF_SUBBANDS; i++) { eNB_mac_inst[j][CC_id].sbmap_conf.sbmap[i]=1; + } eNB_mac_inst[j][CC_id].sbmap_conf.sbmap[rand()%NUMBER_OF_SUBBANDS]=0; @@ -359,8 +362,9 @@ int mac_init_global_param(void) Mac_rlc_xface = NULL; LOG_I(MAC,"[MAIN] CALLING RLC_MODULE_INIT...\n"); - if (rlc_module_init()!=0) + if (rlc_module_init()!=0) { return(-1); + } LOG_I(MAC,"[MAIN] RLC_MODULE_INIT OK, malloc16 for mac_rlc_xface...\n"); @@ -421,11 +425,13 @@ void mac_top_cleanup(void) pdcp_module_cleanup (); #endif - if (NB_UE_INST>0) + if (NB_UE_INST>0) { free (UE_mac_inst); + } - if (NB_eNB_INST>0) + if (NB_eNB_INST>0) { free(eNB_mac_inst); + } free( Mac_rlc_xface); } diff --git a/openair2/LAYER2/MAC/openair2_proc.c b/openair2/LAYER2/MAC/openair2_proc.c index fb3ef8a3468..5e0b8d5c026 100644 --- a/openair2/LAYER2/MAC/openair2_proc.c +++ b/openair2/LAYER2/MAC/openair2_proc.c @@ -107,8 +107,9 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) len+=sprintf(&buffer[len],"CH %d: Subband SINR (dB) :", CH_index); - for (fg=0; fg<NUMBER_OF_MEASUREMENT_SUBBANDS; fg++) + for (fg=0; fg<NUMBER_OF_MEASUREMENT_SUBBANDS; fg++) { len+=sprintf(&buffer[len],"%d ",UE_mac_inst[Mod_id].Def_meas[CH_index].Sinr_meas[0][fg]); + } len+=sprintf(&buffer[len],"\n"); @@ -141,7 +142,9 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) if(Overhead<0) { Overhead=-Overhead; Sign=-1; - } else Sign=1; + } else { + Sign=1; + } len+=sprintf(&buffer[len],"[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s) , LAYER2 TX OVERHEAD: %d Kbits/s\n", UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, @@ -215,8 +218,9 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_RX_ERRORS); len+=sprintf(&buffer[len]," TX per TB: "); - for(kk=0; kk<MAX_NUMBER_TB_PER_LCHAN/2; kk++) + for(kk=0; kk<MAX_NUMBER_TB_PER_LCHAN/2; kk++) { len+=sprintf(&buffer[len],"%d . ",UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_TX_TB[kk]); + } len+=sprintf(&buffer[len],"\n"); len+=sprintf(&buffer[len]," RXerr per TB: "); @@ -241,7 +245,8 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) else if(Mac_rlc_xface->Is_cluster_head[k] ==1) { Mod_id=k; - len+=sprintf(&buffer[len],"-------------------------------------------------------------------CH %d: TTI: %d------------------------------------------------------------------\n", + len+=sprintf(&buffer[len], + "-------------------------------------------------------------------CH %d: TTI: %d------------------------------------------------------------------\n", NODE_ID[Mod_id],Mac_rlc_xface->frame); for(i=1; i<=NB_CNX_CH; i++) { @@ -251,7 +256,8 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) CH_mac_inst[Mod_id].Def_meas[i].Wideband_sinr); //print_cqi(CH_mac_inst[Mod_id].Def_meas[i].cqi)); - len+=sprintf(&buffer[len],"[MAC] LCHAN %d (DCCH), NB_TX_MAC= %d (%d bits/TTI, %d kbits/s), NB_RX_MAC= %d (errors %d, sacch errors %d, sach errors %d, sach_missing %d)\n\n", + len+=sprintf(&buffer[len], + "[MAC] LCHAN %d (DCCH), NB_TX_MAC= %d (%d bits/TTI, %d kbits/s), NB_RX_MAC= %d (errors %d, sacch errors %d, sach errors %d, sach_missing %d)\n\n", CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.Lchan_id.Index, CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.NB_TX, CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.output_rate, @@ -269,9 +275,12 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) if(Overhead<0) { Overhead=-Overhead; Sign=-1; - } else Sign=1; + } else { + Sign=1; + } - len+=sprintf(&buffer[len],"[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s), LAYER2 TX OVERHEAD= %d Kbits/s\n", + len+=sprintf(&buffer[len], + "[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s), LAYER2 TX OVERHEAD= %d Kbits/s\n", CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, Pdcp_stats_tx[k][i][j], Pdcp_stats_tx_rate[k][i][j], @@ -317,7 +326,8 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) rx_error_pdu); } */ - len+=sprintf(&buffer[len],"[MAC]LCHAN %d (CNX %d,RAB %d), NB_TX_MAC= %d (%d bits/TTI, %d kbit/s), NB_RX_MAC= %d (errors %d, sacch_errors %d, sach_errors %d, sach_missing %d)\n", + len+=sprintf(&buffer[len], + "[MAC]LCHAN %d (CNX %d,RAB %d), NB_TX_MAC= %d (%d bits/TTI, %d kbit/s), NB_RX_MAC= %d (errors %d, sacch_errors %d, sach_errors %d, sach_missing %d)\n", CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, i,j, CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_TX, @@ -373,8 +383,9 @@ int add_openair2_stats() // pde = proc_create_entry("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root); pde = create_proc_read_entry("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root, (read_proc_t*)&openair2_stats_read, NULL); - if (!pde) + if (!pde) { printk("[OPENAIR][ERROR] can't create proc entry !\n"); + } //#else //create_proc_info_entry("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root, openair2_stats_read); diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 5777445cbd0..ea86e4867fd 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -52,6 +52,7 @@ #include "OCG_extern.h" #include "RRC/LITE/extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +#include "rlc.h" @@ -101,7 +102,7 @@ void store_dlsch_buffer (module_id_t Mod_id, for(i=0; i< MAX_NUM_LCID; i++) { // loop over all the logical channels - rlc_status = mac_rlc_status_ind(Mod_id,UE_id, frameP,ENB_FLAG_YES,MBMS_FLAG_NO,i,0 ); + rlc_status = mac_rlc_status_ind(Mod_id,rnti, frameP,ENB_FLAG_YES,MBMS_FLAG_NO,i,0 ); UE_template->dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel UE_template->dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; UE_template->dl_buffer_head_sdu_creation_time[i] = rlc_status.head_sdu_creation_time ; @@ -118,7 +119,8 @@ void store_dlsch_buffer (module_id_t Mod_id, * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent */ if (UE_template->dl_buffer_info[i]>0) - LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", + LOG_D(MAC, + "[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", Mod_id, frameP, subframeP, UE_id, i, UE_template->dl_pdus_in_buffer[i],UE_template->dl_buffer_info[i], UE_template->dl_buffer_head_sdu_creation_time[i], @@ -212,8 +214,11 @@ void assign_rbs_required (module_id_t Mod_id, frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id,CC_id); eNB_UE_stats[CC_id] = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti); - if (eNB_UE_stats[CC_id]->dlsch_mcs1==0) nb_rbs_required[CC_id][UE_id] = 4; // don't let the TBS get too small - else nb_rbs_required[CC_id][UE_id] = min_rb_unit[CC_id]; + if (eNB_UE_stats[CC_id]->dlsch_mcs1==0) { + nb_rbs_required[CC_id][UE_id] = 4; // don't let the TBS get too small + } else { + nb_rbs_required[CC_id][UE_id] = min_rb_unit[CC_id]; + } TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); @@ -253,8 +258,9 @@ int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uin for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frame,subframe,&harq_pid,&round,ul_flag); - if (round > round_max) + if (round > round_max) { round_max = round; + } } return round_max; @@ -279,8 +285,9 @@ int maxcqi(module_id_t Mod_id,int32_t UE_id) return 0; // not reached } - if (eNB_UE_stats->DL_cqi[0] > CQI) + if (eNB_UE_stats->DL_cqi[0] > CQI) { CQI = eNB_UE_stats->DL_cqi[0]; + } } return(CQI); @@ -307,7 +314,7 @@ void sort_UEs (module_id_t Mod_idP, rnti1 = UE_RNTI(Mod_idP,i); - if(rnti1 == 0) + if(rnti1 == NOT_A_RNTI) continue; UE_id1 = i; @@ -321,7 +328,7 @@ void sort_UEs (module_id_t Mod_idP, UE_id2 = ii; rnti2 = UE_RNTI(Mod_idP,UE_id2); - if(rnti2 == 0) + if(rnti2 == NOT_A_RNTI) continue; cqi2 = maxcqi(Mod_idP,UE_id2); @@ -403,7 +410,8 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, UE_id = i; // Initialize scheduling information for all active UEs - dlsch_scheduler_pre_processor_reset(UE_id, + dlsch_scheduler_pre_processor_reset( + UE_id, CC_id, N_RBG[CC_id], dl_pow_off, @@ -440,7 +448,7 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, for (i=UE_list->head; i>=0; i=UE_list->next[i]) { rnti = UE_RNTI(Mod_id,i); - if(rnti == 0) + if(rnti == NOT_A_RNTI) continue; UE_id = i; @@ -454,8 +462,9 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); - if(round>0) + if(round>0) { nb_rbs_required[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + } //nb_rbs_required_remaining[UE_id] = nb_rbs_required[UE_id]; if (nb_rbs_required[CC_id][UE_id] > 0) { @@ -473,25 +482,27 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, * per user by a coefficient which represents the degree of priority. */ - if (total_ue_count == 0) + if (total_ue_count == 0) { average_rbs_per_user[CC_id] = 0; - else if( (min_rb_unit[CC_id] * total_ue_count) <= (frame_parms[CC_id]->N_RB_DL) ) + } else if( (min_rb_unit[CC_id] * total_ue_count) <= (frame_parms[CC_id]->N_RB_DL) ) { average_rbs_per_user[CC_id] = (uint16_t) floor(frame_parms[CC_id]->N_RB_DL/total_ue_count); - else + } else { average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; // consider the total number of use that can be scheduled UE + } } } // note: nb_rbs_required is assigned according to total_buffer_dl // extend nb_rbs_required to capture per LCID RB required for(i=UE_list->head; i>=0; i=UE_list->next[i]) { + rnti = UE_RNTI(Mod_id,i); for (ii=0; ii<UE_num_active_CC(UE_list,i); ii++) { CC_id = UE_list->ordered_CCids[ii][i]; // control channel - if (mac_get_rrc_status(Mod_id,1,i) < RRC_RECONFIGURED) + if (mac_eNB_get_rrc_status(Mod_id,rnti) < RRC_RECONFIGURED) { nb_rbs_required_remaining_1[CC_id][i] = nb_rbs_required[CC_id][i]; - else { + } else { nb_rbs_required_remaining_1[CC_id][i] = cmin(average_rbs_per_user[CC_id],nb_rbs_required[CC_id][i]); } @@ -507,10 +518,11 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, for (ii=0; ii<UE_num_active_CC(UE_list,i); ii++) { CC_id = UE_list->ordered_CCids[ii][i]; - if(r1 == 0) + if(r1 == 0) { nb_rbs_required_remaining[CC_id][i] = nb_rbs_required_remaining_1[CC_id][i]; - else // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round + } else { // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round nb_rbs_required_remaining[CC_id][i] = nb_rbs_required[CC_id][i]-nb_rbs_required_remaining_1[CC_id][i]+nb_rbs_required_remaining[CC_id][i]; + } if (nb_rbs_required[CC_id][i]> 0 ) LOG_D(MAC,"round %d : nb_rbs_required_remaining[%d][%d]= %d (remaining_1 %d, required %d, pre_nb_available_rbs %d, N_RBG %d, rb_unit %d)\n", @@ -535,12 +547,12 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, rnti = UE_RNTI(Mod_id,UE_id); // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); - if(rnti == 0) + if(rnti == NOT_A_RNTI) continue; transmission_mode = mac_xface->get_transmission_mode(Mod_id,CC_id,rnti); mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); - rrc_status = mac_get_rrc_status(Mod_id,1,UE_id); + rrc_status = mac_eNB_get_rrc_status(Mod_id,rnti); /* 1st allocate for the retx */ // retransmission in data channels @@ -580,13 +592,13 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, UE_id2 = ii; rnti2 = UE_RNTI(Mod_id,UE_id2); - if(rnti2 == 0) + if(rnti2 == NOT_A_RNTI) continue; eNB_UE_stats2 = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti2); mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti2,frameP,subframeP,&harq_pid2,&round2,0); - if ((mac_get_rrc_status(Mod_id,1,UE_id2) >= RRC_RECONFIGURED) && + if ((mac_eNB_get_rrc_status(Mod_id,rnti2) >= RRC_RECONFIGURED) && (round2==0) && (mac_xface->get_transmission_mode(Mod_id,CC_id,rnti2)==5) && (dl_pow_off[CC_id][UE_id2] != 1)) { @@ -651,22 +663,26 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, i3=0; for (j=0; j<N_RBG[CC_id]; j++) { - if(MIMO_mode_indicator[CC_id][j] == 2) + if(MIMO_mode_indicator[CC_id][j] == 2) { i1 = i1+1; - else if(MIMO_mode_indicator[CC_id][j] == 1) + } else if(MIMO_mode_indicator[CC_id][j] == 1) { i2 = i2+1; - else if(MIMO_mode_indicator[CC_id][j] == 0) + } else if(MIMO_mode_indicator[CC_id][j] == 0) { i3 = i3+1; + } } - if((i1 < N_RBG[CC_id]) && (i2>0) && (i3==0)) + if((i1 < N_RBG[CC_id]) && (i2>0) && (i3==0)) { PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions + 1; + } - if(i3 == N_RBG[CC_id] && i1==0 && i2==0) + if(i3 == N_RBG[CC_id] && i1==0 && i2==0) { PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + 1; + } - if((i1 < N_RBG[CC_id]) && (i3 > 0)) + if((i1 < N_RBG[CC_id]) && (i3 > 0)) { PHY_vars_eNB_g[Mod_id][CC_id]->check_for_MUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_MUMIMO_transmissions + 1; + } PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + 1; @@ -756,8 +772,9 @@ void dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, rballoc_sub_UE[CC_id][UE_id][i] = 1; MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5 ) + if (transmission_mode == 5 ) { dl_pow_off[CC_id][UE_id] = 1; + } if ((i == N_RBG-1) && ((N_RB_DL == 25) || (N_RB_DL == 50))) { nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit+1; @@ -831,7 +848,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, rnti = UE_RNTI(module_idP,i); - if (rnti==0) + if (rnti==NOT_A_RNTI) continue; UE_id = i; @@ -852,15 +869,16 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, max_num_ue_to_be_scheduled+=1; } - if (total_ue_count == 0) + if (total_ue_count == 0) { average_rbs_per_user[CC_id] = 0; - else if (total_ue_count == 1 ) // increase the available RBs, special case, + } else if (total_ue_count == 1 ) { // increase the available RBs, special case, average_rbs_per_user[CC_id] = frame_parms->N_RB_UL-first_rb[CC_id]+1; - else if( (total_ue_count <= (frame_parms->N_RB_DL-first_rb[CC_id])) && - (total_ue_count <= max_num_ue_to_be_scheduled)) + } else if( (total_ue_count <= (frame_parms->N_RB_DL-first_rb[CC_id])) && + (total_ue_count <= max_num_ue_to_be_scheduled)) { average_rbs_per_user[CC_id] = (uint16_t) floor((frame_parms->N_RB_UL-first_rb[CC_id])/total_ue_count); - else if (max_num_ue_to_be_scheduled > 0 ) + } else if (max_num_ue_to_be_scheduled > 0 ) { average_rbs_per_user[CC_id] = (uint16_t) floor((frame_parms->N_RB_UL-first_rb[CC_id])/max_num_ue_to_be_scheduled); + } else { average_rbs_per_user[CC_id]=1; LOG_W(MAC,"[eNB %d] frame %d subframe %d: UE %d CC %d: can't get average rb per user (should not be here)\n", @@ -878,7 +896,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { rnti = UE_RNTI(module_idP,i); - if (rnti==0) + if (rnti==NOT_A_RNTI) continue; UE_id = i; @@ -889,10 +907,11 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,1); - if(round>0) + if(round>0) { nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; - else + } else { nb_allocated_rbs[CC_id][UE_id] = cmin(UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul, average_rbs_per_user[CC_id]); + } total_allocated_rbs[CC_id]+= nb_allocated_rbs[CC_id][UE_id]; @@ -905,7 +924,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { rnti = UE_RNTI(module_idP,i); - if (rnti==0) + if (rnti==NOT_A_RNTI) continue; UE_id = i; @@ -917,8 +936,9 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); total_remaining_rbs[CC_id]=frame_parms->N_RB_UL - first_rb[CC_id] - total_allocated_rbs[CC_id]; - if (total_ue_count == 1 ) + if (total_ue_count == 1 ) { total_remaining_rbs[CC_id]+=1; + } if ( r == 0 ) { while ( (UE_template->pre_allocated_nb_rb_ul > 0 ) && @@ -940,10 +960,10 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { frame_parms= mac_xface->get_lte_frame_parms(module_idP,CC_id); - if (total_allocated_rbs[CC_id]>0) + if (total_allocated_rbs[CC_id]>0) { LOG_D(MAC,"[eNB %d] total RB allocated for all UEs = %d/%d\n", module_idP, total_allocated_rbs[CC_id], frame_parms->N_RB_UL - first_rb[CC_id]); + } } - } @@ -977,8 +997,9 @@ void store_ulsch_buffer(module_id_t module_idP, int frameP, sub_frame_t subframe UE_template->ul_buffer_info[LCGID3], UE_template->ul_total_buffer); else if (UE_is_to_be_scheduled(module_idP,UE_PCCID(module_idP,UE_id),UE_id) > 0 ) { - if (UE_template->ul_total_buffer == 0 ) + if (UE_template->ul_total_buffer == 0 ) { UE_template->ul_total_buffer = BSR_TABLE[11]; + } LOG_D(MAC,"[eNB %d] Frame %d subframe %d UE %d CC id %d: SR active, set BO to %d \n", module_idP, frameP,subframeP, UE_id, UE_PCCID(module_idP,UE_id), @@ -1008,7 +1029,7 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra rnti = UE_RNTI(module_idP,i); - if (rnti==0) + if (rnti==NOT_A_RNTI) continue; UE_id = i; @@ -1016,6 +1037,21 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; + if (CC_id >= MAX_NUM_CCs) { + LOG_E( MAC, "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", + CC_id, + MAX_NUM_CCs, + n, + UE_id, + UE_list->numactiveULCCs[UE_id]); + } + + AssertFatal( CC_id < MAX_NUM_CCs, "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", + CC_id, + MAX_NUM_CCs, + n, + UE_id, + UE_list->numactiveULCCs[UE_id]); frame_parms=mac_xface->get_lte_frame_parms(module_idP,CC_id); UE_template = &UE_list->UE_template[CC_id][UE_id]; @@ -1051,8 +1087,9 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra } // 1 or 2 PRB with cqi enabled does not work well! - if (rb_table[rb_table_index]<3) + if (rb_table[rb_table_index]<3) { rb_table_index=2; //3PRB + } UE_template->pre_assigned_mcs_ul=mcs; UE_template->pre_allocated_rb_table_index_ul=rb_table_index; @@ -1089,7 +1126,7 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) rnti1 = UE_RNTI(module_idP,i); - if(rnti1 == 0) + if(rnti1 == NOT_A_RNTI) continue; UE_id1 = i; @@ -1102,7 +1139,7 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) rnti2 = UE_RNTI(module_idP,ii); - if(rnti2 == 0) + if(rnti2 == NOT_A_RNTI) continue; UE_id2 = ii; @@ -1117,8 +1154,9 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) } else if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer < UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) { swap_UEs(UE_list,UE_id1,UE_id2,1); } else if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul < UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) { - if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0 ) + if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0 ) { swap_UEs(UE_list,UE_id1,UE_id2,1); + } } } } diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index cf7b9330b9e..1a01f98e26d 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -253,12 +253,14 @@ void initiate_ra_proc(module_id_t module_idP,int CC_id,frame_t frameP, uint16_t @param N_RB_UL Number of UL resource blocks @returns t_CRNTI */ -uint16_t fill_rar(module_id_t module_idP, - int CC_id, - frame_t frameP, - uint8_t *dlsch_buffer, - uint16_t N_RB_UL, - uint8_t input_buffer_length); +unsigned short fill_rar( + const module_id_t module_idP, + const int CC_id, + const frame_t frameP, + uint8_t * const dlsch_buffer, + const uint16_t N_RB_UL, + const uint8_t input_buffer_length +); /* \brief Function to indicate a failed RA response. It removes all temporary variables related to the initial connection of a UE @param Mod_id Instance ID of eNB @@ -420,7 +422,15 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,u random-access procedure @returns timing advance or 0xffff if preamble doesn't match */ -uint16_t ue_process_rar(module_id_t module_idP, int CC_id,frame_t frameP,uint8_t *dlsch_buffer,uint16_t *t_crnti,uint8_t preamble_index); +uint16_t +ue_process_rar( + const module_id_t module_idP, + const int CC_id, + const frame_t frameP, + uint8_t * const dlsch_buffer, + rnti_t * const t_crnti, + const uint8_t preamble_index +); /* \brief Generate header for UL-SCH. This function parses the desired control elements and sdus and generates the header as described @@ -474,7 +484,7 @@ uint8_t *parse_ulsch_header(uint8_t *mac_header, int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); int mac_init(void); int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti,int harq_pid); -int mac_remove_ue(module_id_t Mod_id, int UE_id,int frameP); +int mac_remove_ue(module_id_t Mod_id, int UE_id,int frameP, sub_frame_t subframeP); int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uint8_t ul_flag); @@ -492,7 +502,7 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP); void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subframeP,uint16_t *first_rb); void adjust_bsr_info(int buffer_occupancy, uint16_t TBS, UE_TEMPLATE *UE_template); -/*! \fn UE_L2_state_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t subframe, lte_subframe_t direction,uint8_t eNB_index) +/*! \fn UE_L2_state_t ue_scheduler(const module_id_t module_idP,const frame_t frameP, const sub_frame_t subframe, const lte_subframe_t direction,const uint8_t eNB_index) \brief UE scheduler where all the ue background tasks are done. This function performs the following: 1) Trigger PDCP every 5ms 2) Call RRC for link status return to PHY3) Perform SR/BSR procedures for scheduling feedback 4) Perform PHR procedures. \param[in] module_idP instance of the UE \param[in] subframe t the subframe number @@ -500,7 +510,13 @@ void adjust_bsr_info(int buffer_occupancy, uint16_t TBS, UE_TEMPLATE *UE_templat \param[in] eNB_index instance of eNB @returns L2 state (CONNETION_OK or CONNECTION_LOST or PHY_RESYNCH) */ -UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t subframe, lte_subframe_t direction,uint8_t eNB_index,int CC_id); +UE_L2_STATE_t ue_scheduler( + const module_id_t module_idP, + const frame_t frameP, + const sub_frame_t subframe, + const lte_subframe_t direction, + const uint8_t eNB_index, + const int CC_id); /*! \fn int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen); \brief determine whether to use cba resource to transmit or not @@ -685,7 +701,7 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, /** \brief RRC Configuration primitive for PHY/MAC. Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages. @param Mod_id Instance ID of eNB @param eNB_flag Indicates if this is a eNB or UE configuration -@param UE_id Index of UE if this is an eNB configuration +@param rntiP id of UE if this is an eNB configuration @param eNB_id Index of eNB if this is a UE configuration @param radioResourceConfigCommon Structure from SIB2 for common radio parameters (if NULL keep existing configuration) @param physcialConfigDedicated Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated PHY parameters (if NULL keep existing configuration) @@ -705,7 +721,7 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, */ int rrc_mac_config_req(module_id_t module_idP, eNB_flag_t eNB_flag, - uint8_t UE_id, + rnti_t rntiP, uint8_t eNB_index, RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, struct PhysicalConfigDedicated *physicalConfigDedicated, @@ -748,11 +764,10 @@ int rrc_mac_config_req(module_id_t module_idP, @return the estimated distance in meters */ double -rrc_get_estimated_ue_distance(module_id_t Mod_id, - const frame_t frameP, - uint8_t UE_id, - int CC_id, - uint8_t loc_type); +rrc_get_estimated_ue_distance( + const protocol_ctxt_t * const ctxt_pP, + const int CC_idP, + const uint8_t loc_typeP); #endif diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index eb1f3ff746e..12ec5663e0b 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -70,16 +70,17 @@ int8_t get_DELTA_PREAMBLE(module_id_t module_idP,int CC_id) uint8_t preambleformat; if (UE_mac_inst[module_idP].tdd_Config) { // TDD - if (prachConfigIndex < 20) + if (prachConfigIndex < 20) { preambleformat = 0; - else if (prachConfigIndex < 30) + } else if (prachConfigIndex < 30) { preambleformat = 1; - else if (prachConfigIndex < 40) + } else if (prachConfigIndex < 40) { preambleformat = 2; - else if (prachConfigIndex < 48) + } else if (prachConfigIndex < 48) { preambleformat = 3; - else + } else { preambleformat = 4; + } } else { // FDD preambleformat = prachConfigIndex>>2; } @@ -127,8 +128,9 @@ void get_prach_resources(module_id_t module_idP, return; } - if (UE_mac_inst[module_idP].radioResourceConfigCommon) + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; + } else { LOG_E(MAC,"[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n",module_idP); mac_xface->macphy_exit("MAC FATAL radioResourceConfigCommon is NULL"); @@ -148,8 +150,9 @@ void get_prach_resources(module_id_t module_idP, } else { if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA == - rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) + rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) { noGroupB = 1; + } } if (first_Msg3 == 1) { @@ -176,10 +179,11 @@ void get_prach_resources(module_id_t module_idP, UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(module_idP,CC_id); } else { // Msg3 is being retransmitted if (UE_mac_inst[module_idP].RA_usedGroupA == 1) { - if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) + if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())%rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; - else + } else { UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())&0x3f; + } UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; } else { @@ -195,8 +199,9 @@ void get_prach_resources(module_id_t module_idP, if (UE_mac_inst[module_idP].tdd_Config) { num_prach = mac_xface->get_num_prach_tdd(mac_xface->lte_frame_parms); - if ((num_prach>0) && (num_prach<6)) + if ((num_prach>0) && (num_prach<6)) { UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index = (taus()%num_prach); + } f_id = mac_xface->get_fid_prach_tdd(mac_xface->lte_frame_parms, UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index); @@ -217,14 +222,16 @@ void Msg1_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id // start contention resolution timer UE_mac_inst[module_idP].RA_attempt_number++; +#if defined(USER_MODE) && defined(OAI_EMU) - if (opt_enabled == 1) { + if (oai_emulation.info.opt_enabled) { trace_pdu(0, NULL, 0, module_idP, 3, UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex, UE_mac_inst[module_idP].subframe, 0, UE_mac_inst[module_idP].RA_attempt_number); LOG_D(OPT,"[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n", module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size); } +#endif } @@ -241,15 +248,16 @@ void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n",module_idP,frameP); UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0; UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1; +#if defined(USER_MODE) && defined(OAI_EMU) - // msg3 - if (opt_enabled == 1 ) { + if (oai_emulation.info.opt_enabled) { // msg3 trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size, module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0); LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n", module_idP, frameP, UE_mac_inst[module_idP].crnti /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[module_idP].RA_Msg3_size); } +#endif } @@ -275,9 +283,9 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, } if (UE_mode == PRACH) { - if (UE_mac_inst[module_idP].radioResourceConfigCommon) + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; - else { + } else { return(NULL); } @@ -311,8 +319,9 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, if (rach_ConfigCommon) { UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - if (UE_mac_inst[module_idP].RA_window_cnt == 9) + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } } else { LOG_D(MAC,"[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); mac_xface->macphy_exit("MAC rach_ConfigCommon is NULL"); @@ -336,8 +345,8 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, NULL, // short bsr NULL, // long_bsr 1); //post_padding - return(&UE_mac_inst[module_idP].RA_prach_resources); + } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DCCH] > 0) { // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element @@ -346,7 +355,8 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, 6); if (UE_mac_inst[module_idP].crnti_before_ho) - LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", module_idP,frameP, UE_mac_inst[module_idP].crnti,UE_mac_inst[module_idP].crnti_before_ho, rlc_status.bytes_in_buffer,dcch_header_len); else LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", @@ -369,8 +379,9 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, if (rach_ConfigCommon) { UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - if (UE_mac_inst[module_idP].RA_window_cnt == 9) + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } } else { LOG_D(MAC,"[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); mac_xface->macphy_exit("MAC rach_ConfigCommon is NULL"); @@ -405,8 +416,9 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, if (UE_mac_inst[module_idP].RA_backoff_cnt>0) { frame_diff = (sframe_t)frameP - UE_mac_inst[module_idP].RA_backoff_frame; - if (frame_diff < 0) + if (frame_diff < 0) { frame_diff = -frame_diff; + } UE_mac_inst[module_idP].RA_backoff_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_backoff_subframe)); @@ -418,8 +430,9 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, if (UE_mac_inst[module_idP].RA_window_cnt>0) { frame_diff = (frame_t)frameP - UE_mac_inst[module_idP].RA_tx_frame; - if (frame_diff < 0) + if (frame_diff < 0) { frame_diff = -frame_diff; + } UE_mac_inst[module_idP].RA_window_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_tx_subframe)); LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n",module_idP, @@ -432,7 +445,8 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, UE_mac_inst[module_idP].RA_tx_frame = frameP; UE_mac_inst[module_idP].RA_tx_subframe = subframeP; UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; - UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += + (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition if (UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER == rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax) { LOG_D(MAC,"[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",module_idP,frameP,rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax); diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index af94c85e4c6..d17f6130916 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -56,12 +56,16 @@ extern unsigned short RIV2first_rb_LUT25[512]; extern inline unsigned int taus(void); -unsigned short fill_rar(module_id_t module_idP, - int CC_id, - frame_t frameP, - uint8_t *dlsch_buffer, - uint16_t N_RB_UL, - uint8_t input_buffer_length) +//------------------------------------------------------------------------------ +unsigned short fill_rar( + const module_id_t module_idP, + const int CC_id, + const frame_t frameP, + uint8_t* const dlsch_buffer, + const uint16_t N_RB_UL, + const uint8_t input_buffer_length +) +//------------------------------------------------------------------------------ { RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer; @@ -70,6 +74,7 @@ unsigned short fill_rar(module_id_t module_idP, int i,ra_idx = -1; uint16_t rballoc; uint8_t mcs,TPC,ULdelay,cqireq; + AssertFatal(CC_id < MAX_NUM_CCs, "CC_id %u < MAX_NUM_CCs %u", CC_id, MAX_NUM_CCs); for (i=0; i<NB_RA_PROC_MAX; i++) { if (eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[i].generate_rar == 1) { @@ -112,14 +117,16 @@ unsigned short fill_rar(module_id_t module_idP, rar[2] |= ((mcs&0x8)>>3); // mcs 10 rar[3] = (((mcs&0x7)<<5)) | ((TPC&7)<<2) | ((ULdelay&1)<<1) | (cqireq&1); - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Generating RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ra_idx %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n",module_idP,frameP, + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Generating RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ra_idx %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n",module_idP, + frameP, *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5], ra_idx, eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti, rarh->RAPID,eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[0].preamble_index, eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset); +#if defined(USER_MODE) && defined(OAI_EMU) - if (opt_enabled == 1) { + if (oai_emulation.info.opt_enabled) { trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1, eNB_mac_inst[module_idP].subframe, 0, 0); LOG_D(OPT,"[eNB %d][RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", @@ -127,10 +134,21 @@ unsigned short fill_rar(module_id_t module_idP, rarh->RAPID, input_buffer_length); } +#endif return(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti); } -uint16_t ue_process_rar(module_id_t module_idP, int CC_id,frame_t frameP, uint8_t *dlsch_buffer,rnti_t *t_crnti,uint8_t preamble_index) +//------------------------------------------------------------------------------ +uint16_t +ue_process_rar( + const module_id_t module_idP, + const int CC_id, + const frame_t frameP, + uint8_t* const dlsch_buffer, + rnti_t* const t_crnti, + const uint8_t preamble_index +) +//------------------------------------------------------------------------------ { RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer; diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 087effae9a5..1c1d134fba4 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -74,7 +74,7 @@ #include "assertions.h" #define DEBUG_HEADER_PARSING 1 -#define ENABLE_MAC_PAYLOAD_DEBUG +#define ENABLE_MAC_PAYLOAD_DEBUG 1 /* #ifndef USER_MODE @@ -123,18 +123,20 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.Bj[i]=-1; UE_mac_inst[module_idP].scheduling_info.bucket_size[i]=-1; - if (i < DTCH) // initilize all control channels lcgid to 0 + if (i < DTCH) { // initilize all control channels lcgid to 0 UE_mac_inst[module_idP].scheduling_info.LCGID[i]=0; - else // initialize all the data channels lcgid to 1 + } else { // initialize all the data channels lcgid to 1 UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1; + } UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=0; } #ifdef CBA - for (i=0; i <NUM_MAX_CBA_GROUP; i++) + for (i=0; i <NUM_MAX_CBA_GROUP; i++) { UE_mac_inst[module_idP].cba_last_access[i]= round(uniform_rngen(1,30)); + } #endif } @@ -168,8 +170,9 @@ unsigned char *parse_header(unsigned char *mac_header, mac_header_ptr++; length = tb_length-(mac_header_ptr-mac_header)-ce_len; - for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) + for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) { length -= rx_lengths[num_sdu_cnt]; + } } else { if (((SCH_SUBHEADER_LONG *)mac_header_ptr)->F == 1) { length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); @@ -199,10 +202,11 @@ unsigned char *parse_header(unsigned char *mac_header, num_ces++; mac_header_ptr ++; - if (lcid==TIMING_ADV_CMD) + if (lcid==TIMING_ADV_CMD) { ce_len++; - else if (lcid==UE_CONT_RES) + } else if (lcid==UE_CONT_RES) { ce_len+=6; + } } #ifdef DEBUG_HEADER_PARSING @@ -274,8 +278,9 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i if (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer > 0) { // timer configured UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer--; UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=1; - } else + } else { UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; + } LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", module_idP,rnti,frameP,subframe, @@ -284,7 +289,6 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i UE_mac_inst[module_idP].scheduling_info.SR_pending); //UE_mac_inst[module_idP].ul_active =1; - return(1); //instruct phy to signal SR } else { // notify RRC to relase PUCCH/SRS @@ -296,7 +300,17 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i } } -void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frameP,uint8_t *sdu,uint16_t sdu_len,uint8_t eNB_index) +//------------------------------------------------------------------------------ +void +ue_send_sdu( + module_id_t module_idP, + uint8_t CC_id, + frame_t frameP, + uint8_t* sdu, + uint16_t sdu_len, + uint8_t eNB_index +) +//------------------------------------------------------------------------------ { unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; @@ -308,12 +322,14 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frameP,uint8_t *s vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN); LOG_T(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]); +#if defined(USER_MODE) && defined(OAI_EMU) - if (opt_enabled == 1) { + if (oai_emulation.info.opt_enabled) { trace_pdu(1, sdu, sdu_len, module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0); } +#endif payload_ptr = parse_header(sdu,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_len); #ifdef DEBUG_HEADER_PARSING @@ -324,8 +340,9 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frameP,uint8_t *s #if defined(ENABLE_MAC_PAYLOAD_DEBUG) LOG_T(MAC,"[eNB %d] First 32 bytes of DLSCH : \n"); - for (i=0; i<32; i++) + for (i=0; i<32; i++) { LOG_T(MAC,"%x.",sdu[i]); + } LOG_T(MAC,"\n"); #endif @@ -387,25 +404,36 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frameP,uint8_t *s if (rx_lcids[i] == CCCH) { - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n",module_idP,frameP, eNB_index, rx_lengths[i]); + LOG_D(MAC,"[UE %d] rnti %x Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n", + module_idP, + UE_mac_inst[module_idP].crnti, + frameP, + eNB_index, + rx_lengths[i]); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) int j; - for (j=0; j<rx_lengths[i]; j++) + for (j=0; j<rx_lengths[i]; j++) { LOG_T(MAC,"%x.",(uint8_t)payload_ptr[j]); + } LOG_T(MAC,"\n"); #endif mac_rrc_data_ind(module_idP, frameP, + UE_mac_inst[module_idP].crnti, CCCH, - (uint8_t *)payload_ptr,rx_lengths[i],0,eNB_index,0); + (uint8_t*)payload_ptr, + rx_lengths[i], + ENB_FLAG_NO, + eNB_index, + 0); } else if (rx_lcids[i] == DCCH) { LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i],eNB_index,rx_lengths[i]); - mac_rlc_data_ind(eNB_index, - module_idP, + mac_rlc_data_ind(module_idP, + UE_mac_inst[module_idP].crnti, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, @@ -416,8 +444,8 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frameP,uint8_t *s NULL); } else if (rx_lcids[i] == DCCH1) { LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i], eNB_index,rx_lengths[i]); - mac_rlc_data_ind(eNB_index, - module_idP, + mac_rlc_data_ind(module_idP, + UE_mac_inst[module_idP].crnti, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, @@ -432,14 +460,15 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frameP,uint8_t *s #if defined(ENABLE_MAC_PAYLOAD_DEBUG) int j; - for (j=0; j<rx_lengths[i]; j++) + for (j=0; j<rx_lengths[i]; j++) { LOG_T(MAC,"%x.",(unsigned char)payload_ptr[j]); + } LOG_T(MAC,"\n"); #endif - mac_rlc_data_ind(eNB_index, - module_idP, + mac_rlc_data_ind(module_idP, + UE_mac_inst[module_idP].crnti, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, @@ -467,10 +496,11 @@ void ue_decode_si(module_id_t module_idP,int CC_id,frame_t frameP, uint8_t eNB_i mac_rrc_data_ind(module_idP, frameP, + SI_RNTI, BCCH, (uint8_t *)pdu, len, - 0, + ENB_FLAG_NO, eNB_index, 0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT); @@ -500,8 +530,9 @@ unsigned char *parse_mch_header(unsigned char *mac_header, mac_header_ptr++; length = tb_length- (mac_header_ptr - mac_header); - for (i=0; i<num_sdus; i++) + for (i=0; i<num_sdus; i++) { length -= rx_lengths[i]; + } } else { // not the last MAC SDU if ( ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F == 1) {// subheader has length of 3octets // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L; @@ -557,6 +588,7 @@ void ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, uint LOG_I(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, i, sync_area, eNB_index, rx_lengths[i]); mac_rrc_data_ind(module_idP, frameP, + M_RNTI, MCCH, payload_ptr, rx_lengths[i], 0, eNB_index, sync_area); } else if (rx_lcids[i] == MTCH) { @@ -564,8 +596,8 @@ void ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, uint LOG_I(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, sync_area, eNB_index, rx_lengths[i]); mac_rlc_data_ind( - 0, module_idP, + UE_mac_inst[module_idP].crnti, frameP, ENB_FLAG_NO, MBMS_FLAG_YES, @@ -599,8 +631,9 @@ int8_t ue_get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t mbsfn_sync_are if (mbsfn_sync_area > MAX_MBSFN_AREA) { LOG_W(MAC,"[UE %d] MBSFN synchronization area %d out of range for eNB %d\n ", module_idP, mbsfn_sync_area, eNB_index); return -1; - } else if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) + } else if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) { return mbsfn_sync_area; + } else { LOG_W(MAC,"[UE %d] MBSFN Subframe Config pattern %d not found \n ", module_idP, mbsfn_sync_area); return -1; @@ -618,22 +651,25 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ start_meas(&UE_mac_inst[module_idP].ue_query_mch); - if (UE_mac_inst[module_idP].pmch_Config[0]) + if (UE_mac_inst[module_idP].pmch_Config[0]) { mch_scheduling_period = 8<<(UE_mac_inst[module_idP].pmch_Config[0]->mch_SchedulingPeriod_r9); + } for (i=0; i< UE_mac_inst[module_idP].num_active_mbsfn_area; i++ ) { // assume, that there is always a mapping - if ((j=ue_get_mbsfn_sf_alloction(module_idP,i,eNB_index)) == -1) + if ((j=ue_get_mbsfn_sf_alloction(module_idP,i,eNB_index)) == -1) { return -1; // continue; + } ii=0; msi_pos=0; mbsfn_period = 1<<(UE_mac_inst[module_idP].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); mcch_period = 32<<(UE_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - LOG_D(MAC,"[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d,mac sched period (%d,%d))\n", + LOG_D(MAC, + "[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d,mac sched period (%d,%d))\n", module_idP,frameP, subframe,i,UE_mac_inst[module_idP].num_active_mbsfn_area, j,UE_mac_inst[module_idP].num_sf_allocation_pattern,mbsfn_period,mcch_period, mch_scheduling_period,UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset); @@ -675,12 +711,14 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ case 1: if (mac_xface->lte_frame_parms->frame_type == FDD) { if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { - if (msi_pos == 1) + if (msi_pos == 1) { msi_flag = 1; + } if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -691,12 +729,14 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ case 2: if (mac_xface->lte_frame_parms->frame_type == FDD) { if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { - if (msi_pos == 2) + if (msi_pos == 2) { msi_flag = 1; + } if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -707,23 +747,27 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ case 3: if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { - if (msi_pos == 1) + if (msi_pos == 1) { msi_flag = 1; + } if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) { mcch_flag = 1; + } mtch_flag = 1; } } else { // FDD if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { - if (msi_pos == 3) + if (msi_pos == 3) { msi_flag = 1; + } if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -734,12 +778,14 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ case 4: if (mac_xface->lte_frame_parms->frame_type == TDD) { if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { - if (msi_pos == 2) + if (msi_pos == 2) { msi_flag = 1; + } if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -750,12 +796,14 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ case 6: if (mac_xface->lte_frame_parms->frame_type == FDD) { if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { - if (msi_pos == 4) + if (msi_pos == 4) { msi_flag = 1; + } if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -766,23 +814,27 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ case 7: if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { - if (msi_pos == 3) + if (msi_pos == 3) { msi_flag = 1; + } if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) { mcch_flag = 1; + } mtch_flag = 1; } } else { // FDD if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { - if (msi_pos == 5) + if (msi_pos == 5) { msi_flag = 1; + } if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -793,23 +845,27 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ case 8: if (mac_xface->lte_frame_parms->frame_type == TDD) { //TDD if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { - if (msi_pos == 4) + if (msi_pos == 4) { msi_flag = 1; + } if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) { mcch_flag = 1; + } mtch_flag = 1; } } else { // FDD if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { - if (msi_pos == 6) + if (msi_pos == 6) { msi_flag = 1; + } if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -820,12 +876,14 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ case 9: if (mac_xface->lte_frame_parms->frame_type == TDD) { if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { - if (msi_pos == 5) + if (msi_pos == 5) { msi_flag = 1; + } if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) { mcch_flag = 1; + } mtch_flag = 1; } @@ -849,15 +907,17 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ stop_meas(&UE_mac_inst[module_idP].ue_query_mch); - if ( (mcch_flag==1))// || (msi_flag==1)) + if ( (mcch_flag==1)) { // || (msi_flag==1)) *mcch_active=1; + } if ( (mcch_flag==1) || ((msi_flag==1) && (UE_mac_inst[module_idP].mcch_status==1)) ) { return mcch_mcs; - } else if ((mtch_flag==1) && (UE_mac_inst[module_idP].msi_status==1)) + } else if ((mtch_flag==1) && (UE_mac_inst[module_idP].msi_status==1)) { return UE_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9; - else + } else { return -1; + } } #endif @@ -882,8 +942,9 @@ unsigned char generate_ulsch_header(uint8_t *mac_header, LOG_D(MAC,"[UE] Generate ULSCH : num_sdus %d\n",num_sdus); #ifdef DEBUG_HEADER_PARSING - for (i=0; i<num_sdus; i++) + for (i=0; i<num_sdus; i++) { LOG_T(MAC,"[UE] sdu %d : lcid %d length %d",i,sdu_lcids[i],sdu_lengths[i]); + } LOG_T(MAC,"\n"); #endif @@ -967,8 +1028,8 @@ unsigned char generate_ulsch_header(uint8_t *mac_header, last_size=1; *((BSR_TRUNCATED *)ce_ptr)=(*truncated_bsr); ce_ptr+=sizeof(BSR_TRUNCATED); - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + } else if (short_bsr) { if (first_element>0) { mac_header_ptr->E = 1; @@ -1102,8 +1163,9 @@ unsigned char generate_ulsch_header(uint8_t *mac_header, #ifdef DEBUG_HEADER_PARSING LOG_T(MAC," [UE %d] header : ", crnti); - for (i=0; i<((unsigned char*)mac_header_ptr - mac_header); i++) + for (i=0; i<((unsigned char*)mac_header_ptr - mac_header); i++) { LOG_T(MAC,"%2x.",mac_header[i]); + } LOG_T(MAC,"\n"); #endif @@ -1174,8 +1236,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf phr_len = phr_ce_len + phr_header_len; LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", module_idP, phr_len, phr_ce_len, phr_header_len, buflen); - } else + } else { phr_len=0; + } bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); @@ -1199,14 +1262,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] == LCID_NOT_EMPTY) { - rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index DCCH, (buflen-dcch_header_len-bsr_len-phr_len)); LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to " "send (Transport Block size %d, mac header len %d)\n", module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dcch_header_len); - sdu_lengths[0] += mac_rlc_data_req(0, module_idP,frameP,ENB_FLAG_NO, MBMS_FLAG_NO, + sdu_lengths[0] += mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, (char *)&ulsch_buff[sdu_lengths[0]]); @@ -1228,7 +1291,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf // DCCH1 if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] == LCID_NOT_EMPTY) { - rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index DCCH1, (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total)); @@ -1236,7 +1299,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf " send (Transport Block size %d, mac header len %d)\n", module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dcch1_header_len); - sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, DCCH1, (char *)&ulsch_buff[sdu_lengths[0]]); sdu_length_total += sdu_lengths[num_sdus]; @@ -1261,7 +1324,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf else dtch_header_len = 2;//sizeof(SCH_SUBHEADER_SHORT); */ - rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index DTCH, buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total); @@ -1269,7 +1332,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dtch_header_len, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH]); - sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frameP, ENB_FLAG_NO, MBMS_FLAG_NO, // eNB_index + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,UE_mac_inst[module_idP].crnti,frameP, ENB_FLAG_NO, MBMS_FLAG_NO, // eNB_index DTCH, (char *)&ulsch_buff[sdu_length_total]); @@ -1318,8 +1381,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf LOG_D(MAC,"[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n", module_idP,frameP, mac_xface->get_PHR(module_idP,CC_id,eNB_index), phr_p->PH,POWER_HEADROOM); update_phr(module_idP,CC_id); - } else + } else { phr_p=NULL; + } LOG_T(MAC,"[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", module_idP,frameP,bsr_s, bsr_l, phr_p); @@ -1327,10 +1391,11 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dcch_header_len_tmp = dcch_header_len; dtch_header_len_tmp = dtch_header_len; - if (dtch_header_len==0) + if (dtch_header_len==0) { dcch_header_len = (dcch_header_len>0)? 1: dcch_header_len; - else + } else { dtch_header_len= (dtch_header_len >0)? 1: dtch_header_len; // for short and long, cut the length+F fields + } if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) <= 2) { short_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; @@ -1342,10 +1407,11 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf short_padding = 0; - if (dtch_header_len==0) + if (dtch_header_len==0) { dcch_header_len = dcch_header_len_tmp; - else + } else { dtch_header_len= dtch_header_len_tmp; + } post_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total -1 ; } @@ -1373,15 +1439,19 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf memcpy(&ulsch_buffer[payload_offset],ulsch_buff,sdu_length_total); // fill remainder of DLSCH with random data - for (j=0; j<(buflen-sdu_length_total-payload_offset); j++) + for (j=0; j<(buflen-sdu_length_total-payload_offset); j++) { ulsch_buffer[payload_offset+sdu_length_total+j] = (char)(taus()&0xff); + } - if (opt_enabled==1) { +#if defined(USER_MODE) && defined(OAI_EMU) + + if (oai_emulation.info.opt_enabled) { trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, subframe, 0, 0); + } LOG_D(OPT,"[UE %d][ULSCH] Frame %d trace pdu for rnti %x with size %d\n", module_idP, frameP, UE_mac_inst[module_idP].crnti, buflen); - } +#endif LOG_D(MAC,"[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", module_idP,payload_offset, sdu_length_total); @@ -1391,6 +1461,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); } +//------------------------------------------------------------------------------ // called at each subframe // Performs : // 1. Trigger PDCP every 5ms @@ -1398,7 +1469,15 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf // 3. Perform SR/BSR procedures for scheduling feedback // 4. Perform PHR procedures -UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP, lte_subframe_t directionP,uint8_t eNB_indexP,int CC_id) +UE_L2_STATE_t +ue_scheduler( + const module_id_t module_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const lte_subframe_t directionP, + const uint8_t eNB_indexP, + const int CC_id) +//------------------------------------------------------------------------------ { int lcid; // lcid index @@ -1408,10 +1487,7 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su // mac_rlc_status_resp_t rlc_status[MAX_NUM_LCGID]; // 4 // int8_t lcg_id; struct RACH_ConfigCommon *rach_ConfigCommon = (struct RACH_ConfigCommon *)NULL; -#ifdef EXMIMO protocol_ctxt_t ctxt; - int ret; -#endif #if defined(ENABLE_ITTI) MessageDef *msg_p; const char *msg_name; @@ -1421,6 +1497,7 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su start_meas(&UE_mac_inst[module_idP].ue_scheduler); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_IN); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_NO, UE_mac_inst[module_idP].crnti, frameP, subframeP); #if defined(ENABLE_ITTI) do { @@ -1456,13 +1533,9 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su //Mac_rlc_xface->frameP=frameP; //Rrc_xface->Frame_index=Mac_rlc_xface->frameP; //if (subframe%5 == 0) -#ifdef EXMIMO - ctxt.enb_module_id = eNB_indexP; - ctxt.ue_module_id = module_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_NO; + //LG#ifdef EXMIMO pdcp_run(&ctxt); -#endif + //#endif UE_mac_inst[module_idP].frame = frameP; UE_mac_inst[module_idP].subframe = subframeP; @@ -1470,9 +1543,7 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su rrc_rx_tx(module_idP, frameP, 0, eNB_indexP); #else - switch (rrc_rx_tx(module_idP, - frameP, - 0, + switch (rrc_rx_tx(&ctxt, eNB_indexP, CC_id)) { case RRC_OK: @@ -1513,9 +1584,9 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su // Check Contention resolution timer (put in a function later) if (UE_mac_inst[module_idP].RA_contention_resolution_timer_active == 1) { - if (UE_mac_inst[module_idP].radioResourceConfigCommon) + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; - else { + } else { LOG_E(MAC,"FATAL: radioResourceConfigCommon is NULL!!!\n"); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); stop_meas(&UE_mac_inst[module_idP].ue_scheduler); @@ -1556,10 +1627,11 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su mac_xface->macphy_exit(""); } - if ( UE_mac_inst[module_idP].scheduling_info.Bj[lcid] > bucketsizeduration_max ) + if ( UE_mac_inst[module_idP].scheduling_info.Bj[lcid] > bucketsizeduration_max ) { UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = bucketsizeduration_max; - else + } else { UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = bucketsizeduration; + } } if (update_bsr(module_idP,frameP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) { @@ -1573,7 +1645,7 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su } // UE has no valid phy config dedicated || no valid/released SR - if (UE_mac_inst[module_idP].physicalConfigDedicated == NULL) { + if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) { // cancel all pending SRs UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].ul_active=0; @@ -1607,16 +1679,20 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su ((mac_xface->get_PL(module_idP,0,eNB_indexP) < UE_mac_inst[module_idP].scheduling_info.PathlossChange_db) || (UE_mac_inst[module_idP].power_backoff_db[eNB_indexP] > UE_mac_inst[module_idP].scheduling_info.PathlossChange_db))) // trigger PHR and reset the timer later when the PHR report is sent + { UE_mac_inst[module_idP].PHR_reporting_active = 1; - else if (UE_mac_inst[module_idP].PHR_reporting_active ==0 ) + } else if (UE_mac_inst[module_idP].PHR_reporting_active ==0 ) { UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF--; + } if (UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF <= 0 ) // trigger PHR and reset the timer later when the PHR report is sent + { UE_mac_inst[module_idP].PHR_reporting_active = 1; - else if (UE_mac_inst[module_idP].PHR_reporting_active == 0 ) + } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0 ) { UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF--; } + } } else { // release / nothing UE_mac_inst[module_idP].PHR_reporting_active = 0; // release PHR } @@ -1675,13 +1751,15 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 UE_mac_inst[module_idP].cba_last_access[0]-=1; }*/ - if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]<64) ) + if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]<64) ) { return 0; + } if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] <= 0 ) && (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] <= 0 ) && - (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0 ) ) + (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0 ) ) { return 0; + } if (cba_backoff == 0 ) { // apply probablisitc method UE_mac_inst[module_idP].cba_last_access[0]= uniform_rngen(0,1); @@ -1702,7 +1780,7 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 rv = 1; /* - rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index DTCH, 0); @@ -1741,7 +1819,7 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 rv = 1; - rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index DTCH, 0); @@ -1790,12 +1868,13 @@ int get_bsr_lcgid (module_id_t module_idP) } } - if (num_active_lcgid == 0) + if (num_active_lcgid == 0) { return -1; - else if (num_active_lcgid == 1) + } else if (num_active_lcgid == 1) { return lcgid_tmp; - else + } else { return MAX_NUM_LCGID; + } } uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) @@ -1807,11 +1886,13 @@ uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) { pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + bsr_len + 2); //2 = sizeof(SCH_SUBHEADER_SHORT) + } - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) // long header size: adjust the header size + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size pdu += 1; + } // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid @@ -1838,8 +1919,9 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, uint8_t lcid, uint boolean_t sr_pending = FALSE; - if ((lcg_id < 0) || (lcg_id >= MAX_NUM_LCGID) ) + if ((lcg_id < 0) || (lcg_id >= MAX_NUM_LCGID) ) { return sr_pending; + } // fixme: need a better way to reset if ((lcid == DCCH) || (lcid == DTCH)) { @@ -1849,7 +1931,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, uint8_t lcid, uint // for (lcid =0 ; lcid < MAX_NUM_LCID; lcid++) { if (UE_mac_inst[module_idP].scheduling_info.LCGID[lcid] == lcg_id) { - rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, lcid, 0); @@ -1861,8 +1943,9 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, uint8_t lcid, uint // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); - } else + } else { UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY; + } } //} @@ -1878,7 +1961,9 @@ uint8_t locate (const uint32_t *table, int size, int value) DevAssert( size > 0 ); DevAssert( size <= 256 ); - if (value == 0) return 0; //elseif (value > 150000) return 63; + if (value == 0) { + return 0; //elseif (value > 150000) return 63; + } jl = 0; // lower bound ju = size - 1; // upper bound @@ -1887,16 +1972,20 @@ uint8_t locate (const uint32_t *table, int size, int value) while (ju-jl > 1) { //If we are not yet done, jm = (ju+jl) >> 1; //compute a midpoint, - if ((value >= table[jm]) == ascend) + if ((value >= table[jm]) == ascend) { jl=jm; // replace the lower limit - else + } else { ju=jm; //replace the upper limit + } LOG_T(MAC,"[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", jm, table[jm], value); } - if (value == table[jl]) return jl; - else return jl+1; //equally ju + if (value == table[jl]) { + return jl; + } else { + return jl+1; //equally ju + } } @@ -2059,13 +2148,14 @@ uint8_t get_phr_mapping (module_id_t module_idP, int CC_id, uint8_t eNB_index) //power headroom reporting range is from -23 ...+40 dB, as described in 36313 //note: mac_xface->get_Po_NOMINAL_PUSCH(module_idP) is float - if (mac_xface->get_PHR(module_idP,CC_id,eNB_index) < -23) + if (mac_xface->get_PHR(module_idP,CC_id,eNB_index) < -23) { return 0; - else if (mac_xface->get_PHR(module_idP,CC_id,eNB_index) >= 40) + } else if (mac_xface->get_PHR(module_idP,CC_id,eNB_index) >= 40) { return 63; - else // -23 to 40 + } else { // -23 to 40 return (uint8_t) mac_xface->get_PHR(module_idP,CC_id,eNB_index) + PHR_MAPPING_OFFSET; + } } int get_sf_perioidicPHR_Timer(uint8_t perioidicPHR_Timer) { diff --git a/openair2/LAYER2/Makefile.inc b/openair2/LAYER2/Makefile.inc index c6c40ade23d..660875b204e 100644 --- a/openair2/LAYER2/Makefile.inc +++ b/openair2/LAYER2/Makefile.inc @@ -70,6 +70,7 @@ RRC_OBJS += $(RRC_DIR)/rrc_eNB_ral.o endif RRC_OBJS += $(RRC_DIR)/rrc_eNB.o +RRC_OBJS += $(RRC_DIR)/rrc_eNB_UE_context.o RRC_OBJS += $(RRC_DIR)/rrc_eNB_S1AP.o ifdef USE_MME RRC_OBJS += $(RRC_DIR)/rrc_eNB_GTPV1U.o diff --git a/openair2/LAYER2/PDCP/pdcp.c b/openair2/LAYER2/PDCP/pdcp.c index 7e6f8cfbaf9..349ff42c225 100755 --- a/openair2/LAYER2/PDCP/pdcp.c +++ b/openair2/LAYER2/PDCP/pdcp.c @@ -59,8 +59,8 @@ void pdcp_data_req (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, char* sduP) { //----------------------------------------------------------------------------- + mem_block_t* new_sdu = NULL; - mem_block_t *new_sdu = NULL; // int i; if ((data_sizeP > 0)) { @@ -89,10 +89,10 @@ pdcp_data_req (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, c if(Mac_rlc_xface->Is_cluster_head[module_idP]==1) { Pdcp_stats_tx[module_idP][(rab_idP & RAB_OFFSET2 )>> RAB_SHIFT2][(rab_idP & RAB_OFFSET)-DTCH]++; Pdcp_stats_tx_bytes[module_idP][(rab_idP & RAB_OFFSET2 )>> RAB_SHIFT2][(rab_idP & RAB_OFFSET)-DTCH]+=data_sizeP; + } else { Pdcp_stats_tx[module_idP][(rab_idP & RAB_OFFSET2 )>> RAB_SHIFT2][(rab_idP & RAB_OFFSET)-DTCH]++; Pdcp_stats_tx_bytes[module_idP][(rab_idP & RAB_OFFSET2 )>> RAB_SHIFT2][(rab_idP & RAB_OFFSET)-DTCH]+=data_sizeP; - } } else { @@ -107,47 +107,45 @@ pdcp_data_req (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, c } //----------------------------------------------------------------------------- void -pdcp_data_ind (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, mem_block_t * sduP) +pdcp_data_ind (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, mem_block_t* sduP) { //----------------------------------------------------------------------------- - mem_block_t *new_sdu = NULL; + mem_block_t* new_sdu = NULL; int i; if ((data_sizeP > 0)) { - // if(Mac_rlc_xface->Is_cluster_head[0]==1 && Mac_rlc_xface->frame%10==0) //msg("[PDCP][RAB %d][INST %d] PDCP_DATA_IND size %d\n", rab_idP,module_idP,data_sizeP); - #ifdef PDCP_DATA_IND_DEBUG msg("[PDCP][RAB %d][INST %d] TTI %d PDCP_DATA_IND size %d\n", rab_idP,module_idP,Mac_rlc_xface->frame,data_sizeP); - for (i=0; i<20; i++) + for (i=0; i<20; i++) { msg("%02X.",(unsigned char)sduP->data[i]); + } msg("\n"); - #endif //PDCP_DATA_IND_DEBUG - new_sdu = get_free_mem_block (data_sizeP + sizeof (pdcp_data_ind_header_t)); if (new_sdu) { memset (new_sdu->data, 0, sizeof (pdcp_data_ind_header_t)); - ((pdcp_data_ind_header_t *) new_sdu->data)->rb_id = rab_idP; - ((pdcp_data_ind_header_t *) new_sdu->data)->data_size = data_sizeP; - + ((pdcp_data_ind_header_t*) new_sdu->data)->rb_id = rab_idP; + ((pdcp_data_ind_header_t*) new_sdu->data)->data_size = data_sizeP; // Here there is no virtualization possible #ifdef IDROMEL_NEMO - if (Mac_rlc_xface->Is_cluster_head[module_idP] == 0) - ((pdcp_data_ind_header_t *) new_sdu->data)->inst = rab_idP/8; - else - ((pdcp_data_ind_header_t *) new_sdu->data)->inst = 0; + if (Mac_rlc_xface->Is_cluster_head[module_idP] == 0) { + ((pdcp_data_ind_header_t*) new_sdu->data)->inst = rab_idP/8; + } + + else { + ((pdcp_data_ind_header_t*) new_sdu->data)->inst = 0; + } #else - ((pdcp_data_ind_header_t *) new_sdu->data)->inst = module_idP; + ((pdcp_data_ind_header_t*) new_sdu->data)->inst = module_idP; #endif - // PROCESS OF DECOMPRESSION HERE: memcpy (&new_sdu->data[sizeof (pdcp_data_ind_header_t)], &sduP->data[0], data_sizeP); list_add_tail_eurecom (new_sdu, &pdcp_sdu_list); @@ -158,11 +156,9 @@ pdcp_data_ind (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, m } else { Pdcp_stats_rx[module_idP][(rab_idP & RAB_OFFSET2 )>> RAB_SHIFT2][(rab_idP & RAB_OFFSET)-DTCH]++; Pdcp_stats_rx_bytes[module_idP][(rab_idP & RAB_OFFSET2 )>> RAB_SHIFT2][(rab_idP & RAB_OFFSET)-DTCH]+=data_sizeP; - } } - free_mem_block (sduP); } } @@ -172,16 +168,11 @@ pdcp_run (void) { //----------------------------------------------------------------------------- // NAS -> PDCP traffic - -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK #ifdef USER_MODE //#define PDCP_DUMMY_BUFFER_SIZE 38 // unsigned char pdcp_dummy_buffer[PDCP_DUMMY_BUFFER_SIZE]; - - //msg("[PDCP] PDCP Run Id %d\n",modId); - - /* if(Mac_rlc_xface->frame %1 == 0 && (Mac_rlc_xface->frame > 30)) { if (Mac_rlc_xface->Is_cluster_head[0] ==0){ @@ -205,7 +196,6 @@ pdcp_run (void) // pdcp_data_req(0,36,PDCP_DUMMY_BUFFER_SIZE,pdcp_dummy_buffer); }*/ - #endif #endif unsigned int diff,i,k,j; @@ -218,20 +208,16 @@ pdcp_run (void) diff = Pdcp_stats_tx_bytes[i][j][k]; Pdcp_stats_tx_bytes[i][j][k]=0; Pdcp_stats_tx_rate[i][j][k] = (diff*8)>>7;// (Pdcp_stats_tx_rate[i][k]*1+(7*diff*8)>>7)/8; - - diff = Pdcp_stats_rx_bytes[i][j][k]; Pdcp_stats_rx_bytes[i][j][k]=0; Pdcp_stats_rx_rate[i][j][k] =(diff*8)>>7;//(Pdcp_stats_rx_rate[i][k]*1 + (7*diff*8)>>7)/8; } } - // printf("[PDCP]Read sdus from NAS\n"); pdcp_fifo_read_input_sdus(); // PDCP -> NAS traffic pdcp_fifo_flush_sdus(); - /*printf("PDCP TTI %d\n", Mac_rlc_xface->frame); for (i = 0; i < 3; i++) { printf("[RLC_RRC][MOD ID %d] AM:", i); @@ -263,50 +249,45 @@ pdcp_config_release (module_id_t module_idP, rb_id_t rab_idP) int pdcp_module_init () { - //----------------------------------------------------------------------------- #ifndef USER_MODE int ret; - - ret=rtf_create(PDCP2NAS_FIFO,32768); + ret=rtf_create(PDCP2NW_DRIVER_FIFO,32768); if (ret < 0) { - printk("[openair][MAC][INIT] Cannot create PDCP2NAS fifo %d (ERROR %d)\n",PDCP2NAS_FIFO,ret); - + printk("[openair][MAC][INIT] Cannot create PDCP2NAS fifo %d (ERROR %d)\n",PDCP2NW_DRIVER_FIFO,ret); return(-1); + } else { - printk("[openair][MAC][INIT] Created PDCP2NAS fifo %d\n",PDCP2NAS_FIFO); - rtf_reset(PDCP2NAS_FIFO); + printk("[openair][MAC][INIT] Created PDCP2NAS fifo %d\n",PDCP2NW_DRIVER_FIFO); + rtf_reset(PDCP2NW_DRIVER_FIFO); } - ret=rtf_create(NAS2PDCP_FIFO,32768); + ret=rtf_create(NW_DRIVER2PDCP_FIFO,32768); if (ret < 0) { - printk("[openair][MAC][INIT] Cannot create NAS2PDCP fifo %d (ERROR %d)\n",NAS2PDCP_FIFO,ret); - + printk("[openair][MAC][INIT] Cannot create NAS2PDCP fifo %d (ERROR %d)\n",NW_DRIVER2PDCP_FIFO,ret); return(-1); + } else { - printk("[openair][MAC][INIT] Created NAS2PDCP fifo %d\n",NAS2PDCP_FIFO); - rtf_reset(NAS2PDCP_FIFO); + printk("[openair][MAC][INIT] Created NAS2PDCP fifo %d\n",NW_DRIVER2PDCP_FIFO); + rtf_reset(NW_DRIVER2PDCP_FIFO); } pdcp_2_nas_irq = 0; pdcp_input_sdu_remaining_size_to_read=0; pdcp_input_sdu_size_read=0; #endif - return(0); - } //----------------------------------------------------------------------------- void pdcp_module_cleanup () //----------------------------------------------------------------------------- { - #ifndef USER_MODE - rtf_destroy(NAS2PDCP_FIFO); - rtf_destroy(PDCP2NAS_FIFO); + rtf_destroy(NW_DRIVER2PDCP_FIFO); + rtf_destroy(PDCP2NW_DRIVER_FIFO); #endif } //----------------------------------------------------------------------------- @@ -316,7 +297,6 @@ pdcp_layer_init () //----------------------------------------------------------------------------- unsigned int i,j,k; list_init (&pdcp_sdu_list, NULL); - msg("[PDCP] pdcp_layer_init \n "); pdcp_output_sdu_bytes_to_write=0; pdcp_output_header_bytes_to_write=0; @@ -330,13 +310,11 @@ pdcp_layer_init () Pdcp_stats_tx_bytes[i][k][j]=0; Pdcp_stats_tx_bytes_last[i][k][j]=0; Pdcp_stats_tx_rate[i][k][j]=0; - Pdcp_stats_rx[i][k][j]=0; Pdcp_stats_rx_bytes[i][k][j]=0; Pdcp_stats_rx_bytes_last[i][k][j]=0; Pdcp_stats_rx_rate[i][k][j]=0; } - } //----------------------------------------------------------------------------- void diff --git a/openair2/LAYER2/PDCP/pdcp.h b/openair2/LAYER2/PDCP/pdcp.h index 30c573a3b0d..b71616fe688 100755 --- a/openair2/LAYER2/PDCP/pdcp.h +++ b/openair2/LAYER2/PDCP/pdcp.h @@ -69,8 +69,8 @@ public_pdcp(void pdcp_module_cleanup ();) public_pdcp(void pdcp_layer_init ();) public_pdcp(void pdcp_layer_cleanup ();) -#define PDCP2NAS_FIFO 21 -#define NAS2PDCP_FIFO 22 +#define PDCP2NW_DRIVER_FIFO 21 +#define NW_DRIVER2PDCP_FIFO 22 protected_pdcp_fifo(int pdcp_fifo_flush_sdus ();) protected_pdcp_fifo(int pdcp_fifo_read_input_sdus_remaining_bytes ();) diff --git a/openair2/LAYER2/PDCP/pdcp_fifo.c b/openair2/LAYER2/PDCP/pdcp_fifo.c index c833c4c92b3..9e6c185b9e9 100755 --- a/openair2/LAYER2/PDCP/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP/pdcp_fifo.c @@ -64,7 +64,7 @@ #include "UTIL/OCG/OCG_extern.h" #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK @@ -74,7 +74,7 @@ extern struct sockaddr_nl nas_src_addr, nas_dest_addr; -extern struct nlmsghdr *nas_nlh; +extern struct nlmsghdr* nas_nlh; extern struct iovec nas_iov; extern int nas_sock_fd; extern struct msghdr nas_msg; @@ -92,33 +92,28 @@ int pdcp_fifo_flush_sdus () { //----------------------------------------------------------------------------- - - mem_block_t *sdu = list_get_head (&pdcp_sdu_list); + mem_block_t* sdu = list_get_head (&pdcp_sdu_list); int bytes_wrote = 0; int pdcp_nb_sdu_sent = 0; uint8_t cont = 1; int ret; - while ((sdu) && (cont)) { - #ifdef USER_MODE // asjust the instance id when passing sdu to IP - ((pdcp_data_ind_header_t *)(sdu->data))->inst = (((pdcp_data_ind_header_t *)(sdu->data))->inst >= NB_eNB_INST) ? - ((pdcp_data_ind_header_t *)(sdu->data))->inst - NB_eNB_INST +oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local :// UE - ((pdcp_data_ind_header_t *)(sdu->data))->inst - oai_emulation.info.first_ue_local; // ENB + ((pdcp_data_ind_header_t*)(sdu->data))->inst = (((pdcp_data_ind_header_t*)(sdu->data))->inst >= NB_eNB_INST) ? + ((pdcp_data_ind_header_t*)(sdu->data))->inst - NB_eNB_INST +oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local : // UE + ((pdcp_data_ind_header_t*)(sdu->data))->inst - oai_emulation.info.first_ue_local; // ENB #else - ((pdcp_data_ind_header_t *)(sdu->data))->inst = 0; + ((pdcp_data_ind_header_t*)(sdu->data))->inst = 0; #endif - #ifdef PDCP_DEBUG msg("[PDCP][INFO] PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n", Mac_rlc_xface->frame, - ((pdcp_data_ind_header_t *)(sdu->data))->inst, - ((pdcp_data_ind_header_t *)(sdu->data))->data_size, - ((pdcp_data_ind_header_t *)(sdu->data))->rb_id); + ((pdcp_data_ind_header_t*)(sdu->data))->inst, + ((pdcp_data_ind_header_t*)(sdu->data))->data_size, + ((pdcp_data_ind_header_t*)(sdu->data))->rb_id); #endif //PDCP_DEBUG - cont = 0; if (!pdcp_output_sdu_bytes_to_write) { @@ -127,23 +122,19 @@ pdcp_fifo_flush_sdus () } #ifndef USER_MODE - bytes_wrote = rtf_put (PDCP2NAS_FIFO, - &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), + bytes_wrote = rtf_put (PDCP2NW_DRIVER_FIFO, + &(((uint8_t*) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), pdcp_output_header_bytes_to_write); - #else -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #ifdef LINUX - memcpy(NLMSG_DATA(nas_nlh), &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), + memcpy(NLMSG_DATA(nas_nlh), &(((uint8_t*) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), pdcp_output_header_bytes_to_write); nas_nlh->nlmsg_len = pdcp_output_header_bytes_to_write; #endif //LINUX -#endif //NAS_NETLINK - +#endif //PDCP_USE_NETLINK bytes_wrote = pdcp_output_header_bytes_to_write; #endif //USER_MODE - - #ifdef PDCP_DEBUG msg("[PDCP][INFO] TTI %d Sent %d Bytes of header to Nas_mesh\n", Mac_rlc_xface->frame, @@ -154,14 +145,11 @@ pdcp_fifo_flush_sdus () pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote; if (!pdcp_output_header_bytes_to_write) { // continue with sdu - - pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu->data)->data_size; - + pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t*) sdu->data)->data_size; #ifndef USER_MODE - bytes_wrote = rtf_put (PDCP2NAS_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); + bytes_wrote = rtf_put (PDCP2NW_DRIVER_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); #else - -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #ifdef LINUX memcpy(NLMSG_DATA(nas_nlh)+sizeof(pdcp_data_ind_header_t), &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); nas_nlh->nlmsg_len += pdcp_output_sdu_bytes_to_write; @@ -175,16 +163,15 @@ pdcp_fifo_flush_sdus () } #endif // LINUX -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK bytes_wrote= pdcp_output_sdu_bytes_to_write; #endif // USER_MODE - #ifdef PDCP_DEBUG msg("[PDCP][INFO] PDCP->IP TTI %d INST %d: Sent %d Bytes of data from rab %d to Nas_mesh\n", Mac_rlc_xface->frame, - ((pdcp_data_ind_header_t *)(sdu->data))->inst, + ((pdcp_data_ind_header_t*)(sdu->data))->inst, bytes_wrote, - ((pdcp_data_ind_header_t *)(sdu->data))->rb_id); + ((pdcp_data_ind_header_t*)(sdu->data))->rb_id); #endif //PDCP_DEBUG if (bytes_wrote > 0) { @@ -192,25 +179,27 @@ pdcp_fifo_flush_sdus () if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU // msg("rb sent a sdu qos_sap %d\n",sapiP); - list_remove_head (&pdcp_sdu_list); free_mem_block (sdu); cont = 1; pdcp_nb_sdu_sent += 1; sdu = list_get_head (&pdcp_sdu_list); } + } else { msg ("[PDCP] RADIO->IP SEND SDU CONGESTION!\n"); } + } else { msg ("[PDCP] RADIO->IP SEND SDU CONGESTION!\n"); } } + } else { // continue writing sdu #ifndef USER_MODE - bytes_wrote = rtf_put (PDCP2NAS_FIFO, - (uint8_t *) (&(sdu->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu->data)->data_size - pdcp_output_sdu_bytes_to_write])), + bytes_wrote = rtf_put (PDCP2NW_DRIVER_FIFO, + (uint8_t*) (&(sdu->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t*) sdu->data)->data_size - pdcp_output_sdu_bytes_to_write])), pdcp_output_sdu_bytes_to_write); #else // USER_MODE bytes_wrote = pdcp_output_sdu_bytes_to_write; @@ -240,8 +229,8 @@ pdcp_fifo_flush_sdus () msg("[PDCP][INFO] TTI %d : Trigger NAS RX interrupt\n", Mac_rlc_xface->frame); #endif //PDCP_DEBUG - rt_pend_linux_srq (pdcp_2_nas_irq); + } else { msg ("[PDCP] TTI %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n", Mac_rlc_xface->frame, @@ -250,7 +239,6 @@ pdcp_fifo_flush_sdus () } #endif //USER_MODE - return pdcp_nb_sdu_sent; } @@ -267,22 +255,20 @@ pdcp_fifo_read_input_sdus_remaining_bytes () sdu_size_t bytes_read=0; if (pdcp_input_sdu_remaining_size_to_read > 0) { - // printk("[PDCP][INFO] read_input_sdus pdcp_input_sdu_remaining_size_to_read = %d \n", pdcp_input_sdu_remaining_size_to_read); - bytes_read = rtf_get (NAS2PDCP_FIFO, + bytes_read = rtf_get (NW_DRIVER2PDCP_FIFO, &(pdcp_input_sdu_buffer[pdcp_input_sdu_size_read]), pdcp_input_sdu_remaining_size_to_read); //printk("[PDCP][INFO] read fifo returned %d \n", bytes_read); if (bytes_read > 0) { - //msg("[PDCP_FIFOS] Read %d remaining Bytes of data from Nas_mesh\n",bytes_read); - pdcp_input_sdu_remaining_size_to_read = pdcp_input_sdu_remaining_size_to_read - bytes_read; pdcp_input_sdu_size_read = pdcp_input_sdu_size_read + bytes_read; if (pdcp_input_sdu_remaining_size_to_read != 0) { return 0; + } else { #ifdef PDCP_DEBUG msg("[PDCP][INFO] TTI %d: IP->RADIO RECEIVED COMPLETE SDU size %d inst %d rb %d\n", @@ -299,11 +285,11 @@ pdcp_fifo_read_input_sdus_remaining_bytes () pdcp_input_header.rb_id, pdcp_input_header.data_size, pdcp_input_sdu_buffer); - // not necessary //memset(pdcp_input_sdu_buffer, 0, MAX_IP_PACKET_SIZE); return 1; } + } else { return bytes_read; } @@ -312,7 +298,7 @@ pdcp_fifo_read_input_sdus_remaining_bytes () return 1; } -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //----------------------------------------------------------------------------- int @@ -329,8 +315,8 @@ pdcp_fifo_read_input_sdus () cont = 1; while (cont > 0) { - bytes_read = rtf_get (NAS2PDCP_FIFO, - &(((uint8_t *) & pdcp_input_header)[pdcp_input_index_header]), + bytes_read = rtf_get (NW_DRIVER2PDCP_FIFO, + &(((uint8_t*) & pdcp_input_header)[pdcp_input_index_header]), sizeof (pdcp_data_req_header_t) - pdcp_input_index_header); if (bytes_read > 0) { @@ -360,11 +346,13 @@ pdcp_fifo_read_input_sdus () pdcp_input_sdu_size_read = 0; // we know the size of the sdu, so read the sdu; cont = pdcp_fifo_read_input_sdus_remaining_bytes (); + } else { cont = 0; } // error while reading rt fifo + } else { cont = 0; } @@ -374,7 +362,7 @@ pdcp_fifo_read_input_sdus () return 0; } -#else //NAS_NETLINK +#else //PDCP_USE_NETLINK @@ -413,8 +401,8 @@ pdcp_fifo_read_input_sdus () if (nas_nlh->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { pdcp_read_state = 1; //get - memcpy((void *)&pdcp_read_header, - (void *)NLMSG_DATA(nas_nlh), + memcpy((void*)&pdcp_read_header, + (void*)NLMSG_DATA(nas_nlh), sizeof(pdcp_data_req_header_t)); } @@ -424,7 +412,6 @@ pdcp_fifo_read_input_sdus () } if (pdcp_read_state == 1) { - #ifdef LINUX len = recvmsg(nas_sock_fd, &nas_msg, 0); #else @@ -436,20 +423,17 @@ pdcp_fifo_read_input_sdus () } else { pdcp_read_state = 0; //print_active_requests() - #ifdef LINUX memcpy(pdcp_read_payload, - (unsigned char *)NLMSG_DATA(nas_nlh), + (unsigned char*)NLMSG_DATA(nas_nlh), nas_nlh->nlmsg_len - sizeof(struct nlmsghdr)); #endif - #ifdef IDROMEL_NEMO pdcp_read_header.inst = 0; #endif pdcp_read_header.inst = (pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) ? pdcp_read_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : pdcp_read_header.inst + oai_emulation.info.first_enb_local; - #ifdef PDCP_DEBUG printf("[PDCP][NETLINK][IP->PDCP] TTI %d, INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n", Mac_rlc_xface->frame, @@ -458,7 +442,6 @@ pdcp_fifo_read_input_sdus () nas_nlh->nlmsg_len-sizeof(struct nlmsghdr), pdcp_read_header.rb_id); #endif PDCP_DEBUG - pdcp_data_req(pdcp_read_header.inst, pdcp_read_header.rb_id, pdcp_read_header.data_size, diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 5766b1e632e..bc7bd5ef464 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -39,6 +39,7 @@ #include <rtai_fifos.h> #endif #include "assertions.h" +#include "hashtable.h" #include "pdcp.h" #include "pdcp_util.h" #include "pdcp_sequence_manager.h" @@ -48,6 +49,7 @@ #include "pdcp_primitives.h" #include "OCG.h" #include "OCG_extern.h" +#include "otg_rx.h" #include "UTIL/LOG/log.h" #include <inttypes.h> #include "platform_constants.h" @@ -61,7 +63,7 @@ # include "intertask_interface.h" #endif -#if defined(LINK_PDCP_TO_GTPV1U) +#if defined(LINK_ENB_PDCP_TO_GTPV1U) # include "gtpv1u_eNB_task.h" # include "gtpv1u.h" #endif @@ -70,8 +72,6 @@ extern int otg_enabled; #endif -//extern char *packet_gen(int src, int dst, int ctime, int *pkt_size); -extern int otg_rx_pkt( int src, int dst, int ctime, char *buffer_tx, unsigned int size); //----------------------------------------------------------------------------- /* @@ -89,9 +89,11 @@ boolean_t pdcp_data_req( const confirm_t confirmP, const sdu_size_t sdu_buffer_sizeP, unsigned char *const sdu_buffer_pP, - const pdcp_transmission_mode_t modeP) + const pdcp_transmission_mode_t modeP +) +//----------------------------------------------------------------------------- { - //----------------------------------------------------------------------------- + pdcp_t *pdcp_p = NULL; uint8_t i = 0; uint8_t pdcp_header_len = 0; @@ -103,46 +105,32 @@ boolean_t pdcp_data_req( boolean_t ret = TRUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_IN); - - AssertError (ctxt_pP->enb_module_id < NUMBER_OF_eNB_MAX, return FALSE, "eNB id is too high (%u/%d) %u %u!\n", ctxt_pP->enb_module_id, NUMBER_OF_eNB_MAX, ctxt_pP->ue_module_id, rb_idP); - AssertError (ctxt_pP->ue_module_id < NUMBER_OF_UE_MAX, return FALSE, "UE id is too high (%u/%d) %u %u!\n", ctxt_pP->ue_module_id, NUMBER_OF_UE_MAX, ctxt_pP->enb_module_id, rb_idP); + CHECK_CTXT_ARGS(ctxt_pP); if (modeP == PDCP_TRANSMISSION_MODE_TRANSPARENT) { - AssertError (rb_idP < NB_RB_MBMS_MAX, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, NB_RB_MBMS_MAX, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); + AssertError (rb_idP < NB_RB_MBMS_MAX, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, NB_RB_MBMS_MAX, ctxt_pP->module_id, ctxt_pP->rnti); } else { if (srb_flagP) { - AssertError (rb_idP < 2, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, 2, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); + AssertError (rb_idP < 2, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, 2, ctxt_pP->module_id, ctxt_pP->rnti); } else { - AssertError (rb_idP < maxDRB, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, maxDRB, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); + AssertError (rb_idP < maxDRB, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, maxDRB, ctxt_pP->module_id, ctxt_pP->rnti); } } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - if (srb_flagP) { - pdcp_p = &pdcp_array_srb_ue[ctxt_pP->ue_module_id][rb_idP-1]; - } else { - pdcp_p = &pdcp_array_drb_ue[ctxt_pP->ue_module_id][rb_idP-1]; - } - } else { - if (srb_flagP) { - pdcp_p = &pdcp_array_srb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][rb_idP-1]; - } else { - pdcp_p = &pdcp_array_drb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][rb_idP-1]; - } - } - - if ((pdcp_p->instanciated_instance == FALSE) && (modeP != PDCP_TRANSMISSION_MODE_TRANSPARENT)) { - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_W(PDCP, "[UE %d] Instance is not configured for eNB %d, rb_id %d Ignoring SDU...\n", - ctxt_pP->ue_module_id, ctxt_pP->enb_module_id, rb_idP); - } else { - LOG_W(PDCP, "[eNB %d] Instance is not configured for UE %d, rb_id %d Ignoring SDU...\n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, rb_idP); - } + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + if (h_rc != HASH_TABLE_OK) { + if (modeP != PDCP_TRANSMISSION_MODE_TRANSPARENT) { + LOG_W(PDCP, PROTOCOL_CTXT_FMT" Instance is not configured for rb_id %d Ignoring SDU...\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), + rb_idP); return FALSE; } + } if (sdu_buffer_sizeP == 0) { LOG_W(PDCP, "Handed SDU is of size 0! Ignoring...\n"); @@ -160,10 +148,11 @@ boolean_t pdcp_data_req( mac_xface->macphy_exit("PDCP sdu buffer size > MAX_IP_PACKET_SIZE"); } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - start_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_req); - else - start_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_req); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); + } // PDCP transparent mode for MBMS traffic @@ -182,18 +171,11 @@ boolean_t pdcp_data_req( rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_YES, rb_idP, muiP, confirmP, sdu_buffer_sizeP, pdcp_pdu_p); } else { rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES; - LOG_W(PDCP,"[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rb_idP); + LOG_W(PDCP,PROTOCOL_CTXT_FMT" PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", + PROTOCOL_CTXT_ARGS(ctxt_pP)); #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - AssertFatal(0, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + AssertFatal(0, PROTOCOL_CTXT_FMT"[RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); #endif } @@ -209,11 +191,8 @@ boolean_t pdcp_data_req( pdcp_pdu_size = sdu_buffer_sizeP + pdcp_header_len + pdcp_tailer_len; - LOG_D(PDCP, "Data request notification for PDCP entity %s enb id %u ue_id %u and radio bearer ID %d pdu size %d (header%d, trailer%d)\n", - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rb_idP, + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT"Data request notification pdu size %d (header%d, trailer%d)\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), pdcp_pdu_size, pdcp_header_len, pdcp_tailer_len); @@ -221,7 +200,6 @@ boolean_t pdcp_data_req( /* * Allocate a new block for the new PDU (i.e. PDU header and SDU payload) */ - LOG_D(PDCP, "Asking for a new mem_block of size %d\n", pdcp_pdu_size); pdcp_pdu_p = get_free_mem_block(pdcp_pdu_size); if (pdcp_pdu_p != NULL) { @@ -239,12 +217,14 @@ boolean_t pdcp_data_req( memset(&pdcp_pdu_p->data[sdu_buffer_sizeP + pdcp_header_len],0,PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE); if (pdcp_serialize_control_plane_data_pdu_with_SRB_sn_buffer((unsigned char*)pdcp_pdu_p->data, &pdu_header) == FALSE) { - LOG_E(PDCP, "Cannot fill PDU buffer with relevant header fields!\n"); + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Cannot fill PDU buffer with relevant header fields!\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p)); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_req); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_req); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); return FALSE; @@ -256,12 +236,14 @@ boolean_t pdcp_data_req( current_sn = pdu_header.sn ; if (pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer((unsigned char*)pdcp_pdu_p->data, &pdu_header) == FALSE) { - LOG_E(PDCP, "Cannot fill PDU buffer with relevant header fields!\n"); + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Cannot fill PDU buffer with relevant header fields!\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p)); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_req); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_req); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); return FALSE; @@ -272,15 +254,18 @@ boolean_t pdcp_data_req( * Validate incoming sequence number, there might be a problem with PDCP initialization */ if (current_sn > pdcp_calculate_max_seq_num_for_given_size(pdcp_p->seq_num_size)) { - LOG_E(PDCP, "Generated sequence number (%lu) is greater than a sequence number could ever be!\n", current_sn); - LOG_E(PDCP, "There must be a problem with PDCP initialization, ignoring this PDU...\n"); + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Generated sequence number (%lu) is greater than a sequence number could ever be!\n"\ + "There must be a problem with PDCP initialization, ignoring this PDU...\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), + current_sn); free_mem_block(pdcp_pdu_p); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_req); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_req); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); return FALSE; @@ -294,8 +279,9 @@ boolean_t pdcp_data_req( //For control plane data that are not integrity protected, // the MAC-I field is still present and should be padded with padding bits set to 0. // NOTE: user-plane data are never integrity protected - for (i=0; i<pdcp_tailer_len; i++) + for (i=0; i<pdcp_tailer_len; i++) { pdcp_pdu_p->data[pdcp_header_len + sdu_buffer_sizeP + i] = 0x00;// pdu_header.mac_i[i]; + } #if defined(ENABLE_SECURITY) @@ -303,10 +289,11 @@ boolean_t pdcp_data_req( (((pdcp_p->cipheringAlgorithm) != 0) || ((pdcp_p->integrityProtAlgorithm) != 0))) { - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - start_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].apply_security); - else - start_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].apply_security); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].apply_security); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].apply_security); + } pdcp_apply_security(ctxt_pP, pdcp_p, @@ -317,10 +304,11 @@ boolean_t pdcp_data_req( pdcp_pdu_p->data, sdu_buffer_sizeP); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].apply_security); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].apply_security); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].apply_security); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].apply_security); + } } #endif @@ -333,10 +321,11 @@ boolean_t pdcp_data_req( } else { LOG_E(PDCP, "Cannot create a mem_block for a PDU!\n"); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_req); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_req); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); + } #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) AssertFatal(0, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", @@ -358,8 +347,9 @@ boolean_t pdcp_data_req( int i=0; LOG_F(PDCP,"[MSG] PDCP DL %s PDU on rb_id %d\n", (srb_flagP)? "CONTROL" : "DATA", rb_idP); - for (i = 0; i < pdcp_pdu_size; i++) + for (i = 0; i < pdcp_pdu_size; i++) { LOG_F(PDCP,"%02x ", ((uint8_t*)pdcp_pdu_p->data)[i]); + } LOG_F(PDCP,"\n"); #endif @@ -394,10 +384,11 @@ boolean_t pdcp_data_req( break; } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_req); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_req); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); + } /* * Control arrives here only if rlc_data_req() returns RLC_OP_STATUS_OK @@ -419,15 +410,18 @@ boolean_t pdcp_data_req( } -boolean_t pdcp_data_ind( +//----------------------------------------------------------------------------- +boolean_t +pdcp_data_ind( const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, const sdu_size_t sdu_buffer_sizeP, - mem_block_t* const sdu_buffer_pP) + mem_block_t* const sdu_buffer_pP +) +//----------------------------------------------------------------------------- { - //----------------------------------------------------------------------------- pdcp_t *pdcp_p = NULL; list_t *sdu_list_p = NULL; mem_block_t *new_sdu_p = NULL; @@ -437,7 +431,9 @@ boolean_t pdcp_data_ind( volatile sdu_size_t payload_offset = 0; rb_id_t rb_id = rb_idP; boolean_t packet_forwarded = FALSE; -#if defined(LINK_PDCP_TO_GTPV1U) + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; +#if defined(LINK_ENB_PDCP_TO_GTPV1U) MessageDef *message_p = NULL; uint8_t *gtpu_buffer_p = NULL; #endif @@ -447,92 +443,70 @@ boolean_t pdcp_data_ind( #ifdef OAI_EMU - if (ctxt_pP->enb_flag) { - AssertFatal ((ctxt_pP->enb_module_id == oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal ((ctxt_pP->enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ctxt_pP->ue_module_id < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ctxt_pP->ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ctxt_pP->ue_module_id >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(ctxt_pP); #endif #ifdef PDCP_MSG_PRINT int i=0; LOG_F(PDCP,"[MSG] PDCP UL %s PDU on rb_id %d\n", (srb_flagP)? "CONTROL" : "DATA", rb_idP); - for (i = 0; i < sdu_buffer_sizeP; i++) + for (i = 0; i < sdu_buffer_sizeP; i++) { LOG_F(PDCP,"%02x ", ((uint8_t*)sdu_buffer_pP->data)[i]); + } LOG_F(PDCP,"\n"); #endif if (MBMS_flagP) { - AssertError (rb_idP < NB_RB_MBMS_MAX, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, NB_RB_MBMS_MAX, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); + AssertError (rb_idP < NB_RB_MBMS_MAX, return FALSE, + "RB id is too high (%u/%d) %u rnti %x!\n", + rb_idP, + NB_RB_MBMS_MAX, + ctxt_pP->module_id, + ctxt_pP->rnti); if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_I(PDCP, "e-MBMS Data indication notification for PDCP entity from eNB %u to UE %u " + LOG_D(PDCP, "e-MBMS Data indication notification for PDCP entity from eNB %u to UE %x " "and radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d\n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, rb_idP, sdu_buffer_sizeP, ctxt_pP->enb_flag); - } else { - LOG_I(PDCP, "Data indication notification for PDCP entity from UE %u to eNB %u " - "and radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d eNB_id %d\n", - ctxt_pP->ue_module_id, ctxt_pP->enb_module_id , rb_idP, sdu_buffer_sizeP, ctxt_pP->enb_flag, ctxt_pP->enb_module_id); - } - } else { - rb_id = rb_idP % maxDRB; - AssertError (rb_id < maxDRB, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_id, maxDRB, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); - AssertError (rb_id > 0, return FALSE, "RB id is too low (%u/%d) %u %u!\n", rb_id, maxDRB, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); + ctxt_pP->module_id, + ctxt_pP->rnti, + rb_idP, + sdu_buffer_sizeP, + ctxt_pP->enb_flag); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - if (srb_flagP) { - pdcp_p = &pdcp_array_srb_ue[ctxt_pP->ue_module_id][rb_id-1]; -#if 0 - LOG_D(PDCP, "Data indication notification for PDCP entity from eNB %u to UE %u " - "and signalling radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d\n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, rb_id, sdu_buffer_sizeP, ctxt_pP->enb_flag); -#endif } else { - pdcp_p = &pdcp_array_drb_ue[ctxt_pP->ue_module_id][rb_id-1]; -#if 0 - LOG_D(PDCP, "Data indication notification for PDCP entity from eNB %u to UE %u " - "and data radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d\n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, rb_id, sdu_buffer_sizeP, ctxt_pP->enb_flag); -#endif + LOG_D(PDCP, "Data indication notification for PDCP entity from UE %x to eNB %u " + "and radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d\n", + ctxt_pP->rnti, + ctxt_pP->module_id , + rb_idP, + sdu_buffer_sizeP, + ctxt_pP->enb_flag); } } else { - if (srb_flagP) { - pdcp_p = &pdcp_array_srb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][rb_id-1]; -#if 0 - LOG_D(PDCP, "Data indication notification for PDCP entity from UE %u to eNB %u " - "and signalling radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d eNB_id %d\n", - ctxt_pP->ue_module_id, ctxt_pP->enb_module_id , rb_id, sdu_buffer_sizeP, ctxt_pP->enb_flag, ctxt_pP->enb_module_id); -#endif - } else { - pdcp_p = &pdcp_array_drb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][rb_id-1]; -#if 0 - LOG_D(PDCP, "Data indication notification for PDCP entity from UE %u to eNB %u " - "and data radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d eNB_id %d\n", - ctxt_pP->ue_module_id, ctxt_pP->enb_module_id , rb_id, sdu_buffer_sizeP, ctxt_pP->enb_flag, ctxt_pP->enb_module_id); -#endif - } - + rb_id = rb_idP % maxDRB; + AssertError (rb_id < maxDRB, return FALSE, "RB id is too high (%u/%d) %u UE %x!\n", + rb_id, + maxDRB, + ctxt_pP->module_id, + ctxt_pP->rnti); + AssertError (rb_id > 0, return FALSE, "RB id is too low (%u/%d) %u UE %x!\n", + rb_id, + maxDRB, + ctxt_pP->module_id, + ctxt_pP->rnti); + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_id, srb_flagP); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + + if (h_rc != HASH_TABLE_OK) { + LOG_W(PDCP, + PROTOCOL_CTXT_FMT"Could not get PDCP instance key 0x%"PRIx64"\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), + key); + free_mem_block(sdu_buffer_pP); + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_OUT); + return FALSE; } } @@ -543,10 +517,11 @@ boolean_t pdcp_data_ind( return FALSE; } - if (ctxt_pP->enb_flag) - start_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_ind); - else - start_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_ind); + if (ctxt_pP->enb_flag) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_ind); + } /* * Parse the PDU placed at the beginning of SDU to check @@ -569,7 +544,10 @@ boolean_t pdcp_data_ind( sequence_number = pdcp_get_sequence_number_of_pdu_with_long_sn((unsigned char*)sdu_buffer_pP->data); } else { //sequence_number = 4095; - LOG_E(PDCP,"wrong sequence number (%d) for this pdcp entity \n", pdcp_p->seq_num_size); + LOG_E(PDCP, + PROTOCOL_PDCP_CTXT_FMT"wrong sequence number (%d) for this pdcp entity \n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + pdcp_p->seq_num_size); } //uint8_t dc = pdcp_get_dc_filed((unsigned char*)sdu_buffer_pP->data); @@ -579,13 +557,17 @@ boolean_t pdcp_data_ind( * Check if incoming SDU is long enough to carry a PDU header */ if (sdu_buffer_sizeP < pdcp_header_len + pdcp_tailer_len ) { - LOG_W(PDCP, "Incoming (from RLC) SDU is short of size (size:%d)! Ignoring...\n", sdu_buffer_sizeP); + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"Incoming (from RLC) SDU is short of size (size:%d)! Ignoring...\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + sdu_buffer_sizeP); free_mem_block(sdu_buffer_pP); - if (ctxt_pP->enb_flag) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_ind); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_ind); + if (ctxt_pP->enb_flag) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_ind); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_OUT); return FALSE; @@ -600,7 +582,10 @@ boolean_t pdcp_data_ind( else LOG_D(PDCP, "Passing piggybacked SDU to RRC ...\n");*/ } else { - LOG_W(PDCP, "Incoming PDU has an unexpected sequence number (%d), RX window synchronisation have probably been lost!\n", sequence_number); + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"Incoming PDU has an unexpected sequence number (%d), RX window synchronisation have probably been lost!\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + sequence_number); /* * XXX Till we implement in-sequence delivery and duplicate discarding * mechanism all out-of-order packets will be delivered to RRC/IP @@ -619,10 +604,11 @@ boolean_t pdcp_data_ind( #if defined(ENABLE_SECURITY) if (pdcp_p->security_activated == 1) { - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - start_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].validate_security); - else - start_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].validate_security); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } pdcp_validate_security(ctxt_pP, pdcp_p, @@ -633,28 +619,27 @@ boolean_t pdcp_data_ind( sdu_buffer_pP->data, sdu_buffer_sizeP - pdcp_tailer_len); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].validate_security); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].validate_security); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } } #endif //rrc_lite_data_ind(module_id, //Modified MW - L2 Interface - pdcp_rrc_data_ind(ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - ctxt_pP->frame, - ctxt_pP->enb_flag, + pdcp_rrc_data_ind(ctxt_pP, rb_id, sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len, (uint8_t*)&sdu_buffer_pP->data[pdcp_header_len]); free_mem_block(sdu_buffer_pP); // free_mem_block(new_sdu); - if (ctxt_pP->enb_flag) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_ind); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_ind); + if (ctxt_pP->enb_flag) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_ind); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_OUT); return TRUE; @@ -667,10 +652,11 @@ boolean_t pdcp_data_ind( #if defined(ENABLE_SECURITY) if (pdcp_p->security_activated == 1) { - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - start_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].validate_security); - else - start_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].validate_security); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } pdcp_validate_security( ctxt_pP, @@ -682,10 +668,11 @@ boolean_t pdcp_data_ind( sdu_buffer_pP->data, sdu_buffer_sizeP - pdcp_tailer_len); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].validate_security); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].validate_security); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } } @@ -697,11 +684,9 @@ boolean_t pdcp_data_ind( #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.otg_enabled == 1) { - module_id_t src_id, dst_id; + unsigned int dst_instance; int ctime; - DevAssert(pdcp_p); - if (pdcp_p->rlc_mode == RLC_MODE_AM ) { pdcp_p->last_submitted_pdcp_rx_sn = sequence_number; } @@ -712,20 +697,24 @@ boolean_t pdcp_data_ind( sdu_buffer_sizeP - payload_offset); #endif - src_id = (ctxt_pP->enb_flag == ENB_FLAG_NO) ? ctxt_pP->enb_module_id : ctxt_pP->ue_module_id + NB_eNB_INST; - dst_id = (ctxt_pP->enb_flag == ENB_FLAG_NO) ? ctxt_pP->ue_module_id + NB_eNB_INST: ctxt_pP->enb_module_id; ctime = oai_emulation.info.time_ms; // avg current simulation time in ms : we may get the exact time through OCG? - LOG_D(PDCP, "Check received buffer : enb_flag %d rab id %d (src %d, dst %d)\n", - ctxt_pP->enb_flag, rb_id, src_id, dst_id); - - if (otg_rx_pkt(src_id, dst_id,ctime,&sdu_buffer_pP->data[payload_offset], + LOG_D(PDCP, + PROTOCOL_PDCP_CTXT_FMT"Check received buffer : (dst %d)\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + ctxt_pP->instance); + + if (otg_rx_pkt( + ctxt_pP->instance, + ctime, + (const char*)(&sdu_buffer_pP->data[payload_offset]), sdu_buffer_sizeP - payload_offset ) == 0 ) { free_mem_block(sdu_buffer_pP); - if (ctxt_pP->enb_flag) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_ind); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_ind); + if (ctxt_pP->enb_flag) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_ind); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_OUT); return TRUE; @@ -738,10 +727,11 @@ boolean_t pdcp_data_ind( LOG_D(OTG,"Discarding received packed\n"); free_mem_block(sdu_buffer_pP); - if (ctxt_pP->enb_flag) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_ind); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_ind); + if (ctxt_pP->enb_flag) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_ind); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_OUT); return TRUE; @@ -758,7 +748,7 @@ boolean_t pdcp_data_ind( * from its second byte (skipping 0th and 1st octets, i.e. * PDCP header) */ -#if defined(LINK_PDCP_TO_GTPV1U) +#if defined(LINK_ENB_PDCP_TO_GTPV1U) if ((TRUE == ctxt_pP->enb_flag) && (FALSE == srb_flagP)) { //LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset); @@ -771,7 +761,7 @@ boolean_t pdcp_data_ind( GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p; GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = sdu_buffer_sizeP - payload_offset; GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).ue_index = ctxt_pP->ue_module_id; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti; GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4; itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); packet_forwarded = TRUE; @@ -800,12 +790,12 @@ boolean_t pdcp_data_ind( if (ctxt_pP->enb_flag == ENB_FLAG_NO) { ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id; #if defined(OAI_EMU) - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->ue_module_id + oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local; + ((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id + oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local; #endif } else { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->ue_module_id * maxDRB); + ((pdcp_data_ind_header_t*) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * maxDRB); #if defined(OAI_EMU) - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->enb_module_id - oai_emulation.info.first_enb_local; + ((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id - oai_emulation.info.first_enb_local; #endif } @@ -838,31 +828,31 @@ boolean_t pdcp_data_ind( #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) else { - AssertFatal(0, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u] PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rb_id); + AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); } #endif free_mem_block(sdu_buffer_pP); - if (ctxt_pP->enb_flag) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].data_ind); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].data_ind); + if (ctxt_pP->enb_flag) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_ind); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_OUT); return TRUE; } //----------------------------------------------------------------------------- -void pdcp_run (const protocol_ctxt_t* const ctxt_pP) +void +pdcp_run ( + const protocol_ctxt_t* const ctxt_pP +) +//----------------------------------------------------------------------------- { - //----------------------------------------------------------------------------- #if defined(ENABLE_ITTI) MessageDef *msg_p; const char *msg_name; @@ -871,10 +861,11 @@ void pdcp_run (const protocol_ctxt_t* const ctxt_pP) protocol_ctxt_t ctxt; #endif - if (ctxt_pP->enb_flag) - start_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].pdcp_run); - else - start_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].pdcp_run); + if (ctxt_pP->enb_flag) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_run); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN); @@ -890,15 +881,21 @@ void pdcp_run (const protocol_ctxt_t* const ctxt_pP) switch (ITTI_MSG_ID(msg_p)) { case RRC_DCCH_DATA_REQ: - LOG_D(PDCP, "Received %s from %s: instance %d, frame %d, ctxt_pP->enb_flag %d, rb_id %d, muiP %d, confirmP %d, mode %d\n", - msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, - RRC_DCCH_DATA_REQ (msg_p).frame, RRC_DCCH_DATA_REQ (msg_p).enb_flag, RRC_DCCH_DATA_REQ (msg_p).rb_id, - RRC_DCCH_DATA_REQ (msg_p).muip, RRC_DCCH_DATA_REQ (msg_p).confirmp, RRC_DCCH_DATA_REQ (msg_p).mode); - - ctxt.enb_module_id = RRC_DCCH_DATA_REQ (msg_p).eNB_index; - ctxt.ue_module_id = RRC_DCCH_DATA_REQ (msg_p).ue_index; - ctxt.frame = RRC_DCCH_DATA_REQ (msg_p).frame; - ctxt.enb_flag = RRC_DCCH_DATA_REQ (msg_p).enb_flag; + PROTOCOL_CTXT_SET_BY_MODULE_ID( + &ctxt, + RRC_DCCH_DATA_REQ (msg_p).module_id, + RRC_DCCH_DATA_REQ (msg_p).enb_flag, + RRC_DCCH_DATA_REQ (msg_p).rnti, + RRC_DCCH_DATA_REQ (msg_p).frame, 0); + LOG_D(PDCP, PROTOCOL_CTXT_FMT"Received %s from %s: instance %d, rb_id %d, muiP %d, confirmP %d, mode %d\n", + PROTOCOL_CTXT_ARGS(&ctxt), + msg_name, + ITTI_MSG_ORIGIN_NAME(msg_p), + instance, + RRC_DCCH_DATA_REQ (msg_p).rb_id, + RRC_DCCH_DATA_REQ (msg_p).muip, + RRC_DCCH_DATA_REQ (msg_p).confirmp, + RRC_DCCH_DATA_REQ (msg_p).mode); result = pdcp_data_req (&ctxt, SRB_FLAG_YES, @@ -951,30 +948,12 @@ void pdcp_run (const protocol_ctxt_t* const ctxt_pP) #endif #if defined(USER_MODE) && defined(OAI_EMU) - pdcp_t *pdcp_p = NULL; - int drb_id=1 ; - int ue_id=0; - int read_otg=1; - - // add check for other rb_ids later - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - if (pdcp_array_drb_ue[ctxt_pP->ue_module_id][drb_id-1].instanciated_instance != TRUE ) - read_otg=0; - } else { - for (ue_id=0; ue_id < NB_UE_INST; ue_id++) - if (pdcp_array_drb_eNB[ctxt_pP->enb_module_id][ue_id][drb_id-1].instanciated_instance != TRUE ) { - read_otg =0; - break; - } - } - - if (read_otg == 1 ) pdcp_fifo_read_input_sdus_from_otg(ctxt_pP); #endif // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer -#if defined(LINK_PDCP_TO_GTPV1U) +#if defined(LINK_ENB_PDCP_TO_GTPV1U) if (ctxt_pP->enb_flag == ENB_FLAG_NO) #endif @@ -983,106 +962,53 @@ void pdcp_run (const protocol_ctxt_t* const ctxt_pP) } // PDCP -> NAS/IP traffic: RX - if (ctxt_pP->enb_flag) - start_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].pdcp_ip); - else - start_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].pdcp_ip); + if (ctxt_pP->enb_flag) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_ip); + } - pdcp_fifo_flush_sdus(ctxt_pP); + else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip); + } - if (ctxt_pP->enb_flag) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].pdcp_ip); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].pdcp_ip); + pdcp_fifo_flush_sdus(ctxt_pP); - if (ctxt_pP->enb_flag) - stop_meas(&eNB_pdcp_stats[ctxt_pP->enb_module_id].pdcp_run); - else - stop_meas(&UE_pdcp_stats[ctxt_pP->ue_module_id].pdcp_run); + if (ctxt_pP->enb_flag) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_ip); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip); + } + if (ctxt_pP->enb_flag) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_run); + } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT); - } -boolean_t pdcp_remove_UE(const protocol_ctxt_t* const ctxt_pP) -{ - - pdcp_t *pdcp_p = NULL; +//----------------------------------------------------------------------------- +boolean_t +pdcp_remove_UE( + const protocol_ctxt_t* const ctxt_pP +) +//----------------------------------------------------------------------------- +{ DRB_Identity_t srb_id = 0; DRB_Identity_t drb_id = 0; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; // check and remove SRBs first for (srb_id=0; srb_id<2; srb_id++) { - AssertFatal( srb_id-1 > 0, "Array index below zero (hard coded). FIXME!" ); - pdcp_p = &pdcp_array_srb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][srb_id-1]; - - if (pdcp_p->instanciated_instance == TRUE) { - pdcp_p->instanciated_instance = FALSE; - pdcp_p->lcid = 0; - pdcp_p->header_compression_profile = 0x0; - pdcp_p->cipheringAlgorithm = 0xff; - pdcp_p->integrityProtAlgorithm = 0xff; - pdcp_p->status_report = 0; - pdcp_p->rlc_mode = RLC_MODE_NONE; - pdcp_p->next_pdcp_tx_sn = 0; - pdcp_p->next_pdcp_rx_sn = 0; - pdcp_p->tx_hfn = 0; - pdcp_p->rx_hfn = 0; - pdcp_p->last_submitted_pdcp_rx_sn = 4095; - pdcp_p->seq_num_size = 0; - pdcp_p->first_missing_pdu = -1; - pdcp_p->security_activated = 0; - - /* Security keys */ - if (pdcp_p->kUPenc != NULL) { - free(pdcp_p->kUPenc); - } - - if (pdcp_p->kRRCint != NULL) { - free(pdcp_p->kRRCint); - } - - if (pdcp_p->kRRCenc != NULL) { - free(pdcp_p->kRRCenc); - } - } + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_YES); + h_rc = hashtable_remove(pdcp_coll_p, key); } for (drb_id=0; drb_id<maxDRB; drb_id++) { - pdcp_p = &pdcp_array_drb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][drb_id-1]; - - if (pdcp_p->instanciated_instance == TRUE) { - pdcp_p->instanciated_instance = FALSE; - pdcp_p->lcid = 0; - pdcp_p->header_compression_profile = 0x0; - pdcp_p->cipheringAlgorithm = 0xff; - pdcp_p->integrityProtAlgorithm = 0xff; - pdcp_p->status_report = 0; - pdcp_p->rlc_mode = RLC_MODE_NONE; - pdcp_p->next_pdcp_tx_sn = 0; - pdcp_p->next_pdcp_rx_sn = 0; - pdcp_p->tx_hfn = 0; - pdcp_p->rx_hfn = 0; - pdcp_p->last_submitted_pdcp_rx_sn = 4095; - pdcp_p->seq_num_size = 0; - pdcp_p->first_missing_pdu = -1; - pdcp_p->security_activated = 0; - - /* Security keys */ - if (pdcp_p->kUPenc != NULL) { - free(pdcp_p->kUPenc); - } - - if (pdcp_p->kRRCint != NULL) { - free(pdcp_p->kRRCint); - } - - if (pdcp_p->kRRCenc != NULL) { - free(pdcp_p->kRRCenc); - } - } + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO); + h_rc = hashtable_remove(pdcp_coll_p, key); } @@ -1090,7 +1016,9 @@ boolean_t pdcp_remove_UE(const protocol_ctxt_t* const ctxt_pP) } -boolean_t rrc_pdcp_config_asn1_req ( +//----------------------------------------------------------------------------- +boolean_t +rrc_pdcp_config_asn1_req ( const protocol_ctxt_t* const ctxt_pP, SRB_ToAddModList_t *const srb2add_list_pP, DRB_ToAddModList_t *const drb2add_list_pP, @@ -1103,6 +1031,7 @@ boolean_t rrc_pdcp_config_asn1_req ( ,PMCH_InfoList_r9_t* const pmch_InfoList_r9_pP #endif ) +//----------------------------------------------------------------------------- { long int lc_id = 0; DRB_Identity_t srb_id = 0; @@ -1120,17 +1049,20 @@ boolean_t rrc_pdcp_config_asn1_req ( DRB_ToAddMod_t *drb_toaddmod_p = NULL; pdcp_t *pdcp_p = NULL; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; #ifdef Rel10 int i,j; MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL; #endif - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_D(PDCP, "[UE %u] CONFIG REQ ASN1 for eNB %u\n", ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); - } else { - LOG_D(PDCP, "[eNB %u] CONFIG REQ ASN1 for UE %u\n", ctxt_pP->enb_module_id, ctxt_pP->ue_module_id); - } + LOG_T(PDCP, PROTOCOL_CTXT_FMT" %s() SRB2ADD %p DRB2ADD %p DRB2RELEASE %p\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), + __FUNCTION__, + srb2add_list_pP, + drb2add_list_pP, + drb2release_list_pP); // srb2add_list does not define pdcp config, we use rlc info to setup the pdcp dcch0 and dcch1 channels @@ -1140,18 +1072,31 @@ boolean_t rrc_pdcp_config_asn1_req ( srb_toaddmod_p = srb2add_list_pP->list.array[cnt]; rlc_type = RLC_MODE_AM; lc_id = srb_id + 2; + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_YES); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - pdcp_p = &pdcp_array_srb_ue[ctxt_pP->ue_module_id][srb_id-1]; + if (h_rc == HASH_TABLE_OK) { + action = CONFIG_ACTION_MODIFY; + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_MODIFY key 0x%"PRIx64"\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + key); } else { - pdcp_p = &pdcp_array_srb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][srb_id-1]; - } + action = CONFIG_ACTION_ADD; + pdcp_p = calloc(1, sizeof(pdcp_t)); + h_rc = hashtable_insert(pdcp_coll_p, key, pdcp_p); + if (h_rc != HASH_TABLE_OK) { + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64" FAILED\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + key); + free(pdcp_p); + return TRUE; - if (pdcp_p->instanciated_instance == TRUE) { - action = CONFIG_ACTION_MODIFY; } else { - action = CONFIG_ACTION_ADD; + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64"\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + key); + } } if (srb_toaddmod_p->rlc_Config) { @@ -1191,7 +1136,7 @@ boolean_t rrc_pdcp_config_asn1_req ( break; default: - DevParam(srb_toaddmod_p->rlc_Config->present, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); + DevParam(srb_toaddmod_p->rlc_Config->present, ctxt_pP->module_id, ctxt_pP->rnti); break; } } @@ -1208,20 +1153,33 @@ boolean_t rrc_pdcp_config_asn1_req ( drb_id = drb_toaddmod_p->drb_Identity;// + drb_id_offset; lc_id = drb_id + 2; + DevCheck4(drb_id < maxDRB, drb_id, maxDRB, ctxt_pP->module_id, ctxt_pP->rnti); + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + if (h_rc == HASH_TABLE_OK) { + action = CONFIG_ACTION_MODIFY; + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_MODIFY key 0x%"PRIx64"\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + key); - DevCheck4(drb_id < maxDRB, drb_id, maxDRB, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); - - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - pdcp_p = &pdcp_array_drb_ue[ctxt_pP->ue_module_id][drb_id-1]; } else { - pdcp_p = &pdcp_array_drb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][drb_id-1]; - } - - if (pdcp_p->instanciated_instance == TRUE) - action = CONFIG_ACTION_MODIFY; - else action = CONFIG_ACTION_ADD; + pdcp_p = calloc(1, sizeof(pdcp_t)); + h_rc = hashtable_insert(pdcp_coll_p, key, pdcp_p); + + if (h_rc != HASH_TABLE_OK) { + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD ADD key 0x%"PRIx64" FAILED\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + key); + free(pdcp_p); + return TRUE; + } else { + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD ADD key 0x%"PRIx64"\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + key); + } + } if (drb_toaddmod_p->pdcp_Config) { if (drb_toaddmod_p->pdcp_Config->discardTimer) { @@ -1248,25 +1206,25 @@ boolean_t rrc_pdcp_config_asn1_req ( case PDCP_Config__headerCompression_PR_rohc: // parse the struc and get the rohc profile - if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0001) + if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0001) { header_compression_profile=0x0001; - else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0002) + } else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0002) { header_compression_profile=0x0002; - else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0003) + } else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0003) { header_compression_profile=0x0003; - else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0004) + } else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0004) { header_compression_profile=0x0004; - else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0006) + } else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0006) { header_compression_profile=0x0006; - else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0101) + } else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0101) { header_compression_profile=0x0101; - else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0102) + } else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0102) { header_compression_profile=0x0102; - else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0103) + } else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0103) { header_compression_profile=0x0103; - else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0104) + } else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0104) { header_compression_profile=0x0104; - else { + } else { header_compression_profile=0x0; LOG_W(PDCP,"unknown header compresion profile\n"); } @@ -1276,7 +1234,7 @@ boolean_t rrc_pdcp_config_asn1_req ( default: LOG_W(PDCP,"[MOD_id %u/%u][RB %u] unknown drb_toaddmod->PDCP_Config->headerCompression->present \n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, drb_id); + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), drb_id); break; } @@ -1305,11 +1263,14 @@ boolean_t rrc_pdcp_config_asn1_req ( pdrb_id_p = drb2release_list_pP->list.array[cnt]; drb_id = *pdrb_id_p; lc_id = drb_id + 2; - - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - pdcp_p = &pdcp_array_drb_ue[ctxt_pP->ue_module_id][drb_id-1]; - } else { - pdcp_p = &pdcp_array_drb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][drb_id-1]; + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + + if (h_rc != HASH_TABLE_OK) { + LOG_E(PDCP, PROTOCOL_CTXT_FMT" PDCP REMOVE FAILED drb_id %u\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), + drb_id); + continue; } action = CONFIG_ACTION_REMOVE; @@ -1329,6 +1290,7 @@ boolean_t rrc_pdcp_config_asn1_req ( kRRCenc_pP, kRRCint_pP, kUPenc_pP); + h_rc = hashtable_remove(pdcp_coll_p, key); } } @@ -1347,7 +1309,7 @@ boolean_t rrc_pdcp_config_asn1_req ( if (ctxt_pP->enb_flag) { drb_id = (mch_id * maxSessionPerPMCH ) + lc_id ;//+ (maxDRB + 3)*MAX_MOBILES_PER_ENB; // 1 - if (pdcp_mbms_array_eNB[ctxt_pP->enb_module_id][mch_id][lc_id].instanciated_instance == TRUE) { + if (pdcp_mbms_array_eNB[ctxt_pP->module_id][mch_id][lc_id].instanciated_instance == TRUE) { action = CONFIG_ACTION_MBMS_MODIFY; } else { action = CONFIG_ACTION_MBMS_ADD; @@ -1355,7 +1317,7 @@ boolean_t rrc_pdcp_config_asn1_req ( } else { drb_id = (mch_id * maxSessionPerPMCH ) + lc_id; // + (maxDRB + 3); // 15 - if (pdcp_mbms_array_ue[ctxt_pP->ue_module_id][mch_id][lc_id].instanciated_instance == TRUE) { + if (pdcp_mbms_array_ue[ctxt_pP->module_id][mch_id][lc_id].instanciated_instance == TRUE) { action = CONFIG_ACTION_MBMS_MODIFY; } else { action = CONFIG_ACTION_MBMS_ADD; @@ -1383,11 +1345,11 @@ boolean_t rrc_pdcp_config_asn1_req ( } #endif - - return 1; - + return 0; } + +//----------------------------------------------------------------------------- boolean_t pdcp_config_req_asn1 ( const protocol_ctxt_t* const ctxt_pP, @@ -1405,13 +1367,21 @@ pdcp_config_req_asn1 ( uint8_t *const kRRCenc_pP, uint8_t *const kRRCint_pP, uint8_t *const kUPenc_pP) +//----------------------------------------------------------------------------- { switch (actionP) { case CONFIG_ACTION_ADD: DevAssert(pdcp_pP != NULL); - pdcp_pP->instanciated_instance = TRUE; - pdcp_pP->is_ue = (ctxt_pP->enb_flag == ENB_FLAG_NO) ? TRUE : FALSE; + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { +#warning "TODO pdcp_module_id_to_rnti" + pdcp_pP->is_ue = FALSE; + //pdcp_eNB_module_id_to_rnti[ctxt_pP.module_id][] = ctxt_pP->rnti; + + } else { + pdcp_pP->is_ue = TRUE; + pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti; + } pdcp_pP->is_srb = (srb_flagP == SRB_FLAG_YES) ? TRUE : FALSE; pdcp_pP->lcid = lc_idP; pdcp_pP->rb_id = rb_idP; @@ -1437,18 +1407,13 @@ pdcp_config_req_asn1 ( pdcp_pP->first_missing_pdu = -1; pdcp_pP->rx_hfn_offset = 0; - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_I(PDCP, "[UE %d] Config request : Action ADD for eNB %d: Frame %d LCID %d (rb id %d) " + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" Action ADD LCID %d (rb id %d) " "configured with SN size %d bits and RLC %s\n", - ctxt_pP->ue_module_id, ctxt_pP->enb_module_id, ctxt_pP->frame, lc_idP, rb_idP, pdcp_pP->seq_num_size, + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), + lc_idP, + rb_idP, + pdcp_pP->seq_num_size, (rlc_modeP == RLC_MODE_AM ) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM"); - } else { - LOG_D(PDCP, "[eNB %d] Config request : Action ADD for UE %d: Frame %d LCID %d (rb id %d) " - "configured with SN size %d bits and RLC %s\n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->frame, lc_idP, rb_idP, pdcp_pP->seq_num_size, - (rlc_modeP == RLC_MODE_AM) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM"); - } - /* Setup security */ if (security_modeP != 0xff) { pdcp_config_set_security( @@ -1461,8 +1426,6 @@ pdcp_config_req_asn1 ( kRRCint_pP, kUPenc_pP); } - - LOG_D(PDCP, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u]\n", ctxt_pP->frame, (ctxt_pP->enb_flag == ENB_FLAG_NO) ? "UE" : "eNB", ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, rb_idP); break; case CONFIG_ACTION_MODIFY: @@ -1492,45 +1455,23 @@ pdcp_config_req_asn1 ( pdcp_pP->seq_num_size=5; } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_I(PDCP,"[UE %d] Config request : Action MODIFY for eNB %d: Frame %d LCID %d " + LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Action MODIFY LCID %d " "RB id %d configured with SN size %d and RLC %s \n", - ctxt_pP->ue_module_id, ctxt_pP->enb_module_id, ctxt_pP->frame, lc_idP, rb_idP, rb_snP, - (rlc_modeP == RLC_MODE_AM) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM"); - } else { - LOG_D(PDCP,"[eNB %d] Config request : Action MODIFY for UE %d: Frame %d LCID %d " - "RB id %d configured with SN size %d and RLC %s \n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->frame, lc_idP, rb_idP, rb_snP, + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), + lc_idP, + rb_idP, + rb_snP, (rlc_modeP == RLC_MODE_AM) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM"); - } - break; case CONFIG_ACTION_REMOVE: DevAssert(pdcp_pP != NULL); - pdcp_pP->instanciated_instance = FALSE; - pdcp_pP->lcid = 0; - pdcp_pP->header_compression_profile = 0x0; - pdcp_pP->cipheringAlgorithm = 0xff; - pdcp_pP->integrityProtAlgorithm = 0xff; - pdcp_pP->status_report = 0; - pdcp_pP->rlc_mode = RLC_MODE_NONE; - pdcp_pP->next_pdcp_tx_sn = 0; - pdcp_pP->next_pdcp_rx_sn = 0; - pdcp_pP->tx_hfn = 0; - pdcp_pP->rx_hfn = 0; - pdcp_pP->last_submitted_pdcp_rx_sn = 4095; - pdcp_pP->seq_num_size = 0; - pdcp_pP->first_missing_pdu = -1; - pdcp_pP->security_activated = 0; - - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_I(PDCP, "[UE %d] Config request : CONFIG_ACTION_REMOVE for eNB %d: Frame %d LCID %d RBID %d configured\n", - ctxt_pP->ue_module_id, ctxt_pP->enb_module_id, ctxt_pP->frame, lc_idP, rb_idP); - } else { - LOG_D(PDCP, "[eNB %d] Config request : CONFIG_ACTION_REMOVE for UE %d: Frame %d LCID %d RBID %d configured\n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->frame, lc_idP, rb_idP); - } +#warning "TODO pdcp_module_id_to_rnti" + //pdcp_module_id_to_rnti[ctxt_pP.module_id ][dst_id] = NOT_A_RNTI; + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_REMOVE LCID %d RBID %d configured\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), + lc_idP, + rb_idP); /* Security keys */ if (pdcp_pP->kUPenc != NULL) { @@ -1545,25 +1486,25 @@ pdcp_config_req_asn1 ( free(pdcp_pP->kRRCenc); } + memset(pdcp_pP, 0, sizeof(pdcp_t)); break; #if defined(Rel10) case CONFIG_ACTION_MBMS_ADD: case CONFIG_ACTION_MBMS_MODIFY: - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_I(PDCP,"[UE %d] Config request for eNB %d: %s: Frame %d service_id/mch index %d, session_id/lcid %d, rbid %d configured\n", - ctxt_pP->ue_module_id, ctxt_pP->enb_module_id, actionP == CONFIG_ACTION_MBMS_ADD ? "CONFIG_ACTION_MBMS_ADD" : "CONFIG_ACTION_MBMS_MODIFY", ctxt_pP->frame, mch_idP, lc_idP, rb_idP); - } else { - LOG_D(PDCP,"[eNB %d] Config request for UE %d: %s: Frame %d service_id/mch index %d, session_id/lcid %d, rbid %d configured\n", - ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, actionP == CONFIG_ACTION_MBMS_ADD ? "CONFIG_ACTION_MBMS_ADD" : "CONFIG_ACTION_MBMS_MODIFY", ctxt_pP->frame, mch_idP, lc_idP, rb_idP); - } - - if (ctxt_pP->enb_flag == 1) { - pdcp_mbms_array_eNB[ctxt_pP->enb_module_id][mch_idP][lc_idP].instanciated_instance = TRUE ; - pdcp_mbms_array_eNB[ctxt_pP->enb_module_id][mch_idP][lc_idP].rb_id = rb_idP; + LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" %s service_id/mch index %d, session_id/lcid %d, rbid %d configured\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), + actionP == CONFIG_ACTION_MBMS_ADD ? "CONFIG_ACTION_MBMS_ADD" : "CONFIG_ACTION_MBMS_MODIFY", + mch_idP, + lc_idP, + rb_idP); + + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { + pdcp_mbms_array_eNB[ctxt_pP->module_id][mch_idP][lc_idP].instanciated_instance = TRUE ; + pdcp_mbms_array_eNB[ctxt_pP->module_id][mch_idP][lc_idP].rb_id = rb_idP; } else { - pdcp_mbms_array_ue[ctxt_pP->ue_module_id][mch_idP][lc_idP].instanciated_instance = TRUE ; - pdcp_mbms_array_ue[ctxt_pP->ue_module_id][mch_idP][lc_idP].rb_id = rb_idP; + pdcp_mbms_array_ue[ctxt_pP->module_id][mch_idP][lc_idP].instanciated_instance = TRUE ; + pdcp_mbms_array_ue[ctxt_pP->module_id][mch_idP][lc_idP].rb_id = rb_idP; } break; @@ -1582,14 +1523,16 @@ pdcp_config_req_asn1 ( break; default: - DevParam(actionP, ctxt_pP->enb_module_id, ctxt_pP->ue_module_id); + DevParam(actionP, ctxt_pP->module_id, ctxt_pP->rnti); break; } return 0; } -void pdcp_config_set_security( +//----------------------------------------------------------------------------- +void +pdcp_config_set_security( const protocol_ctxt_t* const ctxt_pP, pdcp_t * const pdcp_pP, const rb_id_t rb_idP, @@ -1598,6 +1541,7 @@ void pdcp_config_set_security( uint8_t * const kRRCenc, uint8_t * const kRRCint, uint8_t * const kUPenc) +//----------------------------------------------------------------------------- { DevAssert(pdcp_pP != NULL); @@ -1605,24 +1549,10 @@ void pdcp_config_set_security( pdcp_pP->cipheringAlgorithm = security_modeP & 0x0f; pdcp_pP->integrityProtAlgorithm = (security_modeP>>4) & 0xf; - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_D(PDCP,"[UE %d][RB %02d] Set security mode : CONFIG_ACTION_SET_SECURITY_MODE: " - "Frame %d cipheringAlgorithm %d integrityProtAlgorithm %d\n", - ctxt_pP->ue_module_id, - rb_idP, - ctxt_pP->frame, - pdcp_pP->cipheringAlgorithm, - pdcp_pP->integrityProtAlgorithm); - } else { - LOG_D(PDCP,"[eNB %d][UE %d][RB %02d] Set security mode : CONFIG_ACTION_SET_SECURITY_MODE: " - "Frame %d cipheringAlgorithm %d integrityProtAlgorithm %d\n", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rb_idP, - ctxt_pP->frame, + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_SET_SECURITY_MODE: cipheringAlgorithm %d integrityProtAlgorithm %d\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), pdcp_pP->cipheringAlgorithm, pdcp_pP->integrityProtAlgorithm); - } pdcp_pP->kRRCenc = kRRCenc; pdcp_pP->kRRCint = kRRCint; @@ -1631,10 +1561,13 @@ void pdcp_config_set_security( /* Activate security */ pdcp_pP->security_activated = 1; } else { - LOG_E(PDCP,"[%s %d] bad security mode %d", security_modeP); + LOG_E(PDCP,PROTOCOL_PDCP_CTXT_FMT" bad security mode %d", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), + security_modeP); } } +//----------------------------------------------------------------------------- void rrc_pdcp_config_req ( const protocol_ctxt_t* const ctxt_pP, @@ -1642,29 +1575,20 @@ rrc_pdcp_config_req ( const uint32_t actionP, const rb_id_t rb_idP, const uint8_t security_modeP) +//----------------------------------------------------------------------------- { pdcp_t *pdcp_p = NULL; + hash_key_t key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); + hashtable_rc_t h_rc; + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - if (srb_flagP) { - pdcp_p = &pdcp_array_srb_ue[ctxt_pP->ue_module_id][rb_idP-1]; - } else { - pdcp_p = &pdcp_array_drb_ue[ctxt_pP->ue_module_id][rb_idP-1]; - } - } else { - if (srb_flagP) { - pdcp_p = &pdcp_array_srb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][rb_idP-1]; - } else { - pdcp_p = &pdcp_array_drb_eNB[ctxt_pP->enb_module_id][ctxt_pP->ue_module_id][rb_idP-1]; - } - } + if (h_rc == HASH_TABLE_OK) { /* * Initialize sequence number state variables of relevant PDCP entity */ switch (actionP) { case CONFIG_ACTION_ADD: - pdcp_p->instanciated_instance = TRUE; pdcp_p->is_srb = srb_flagP; pdcp_p->rb_id = rb_idP; @@ -1688,15 +1612,18 @@ rrc_pdcp_config_req ( } pdcp_p->first_missing_pdu = -1; - LOG_D(PDCP,"[%s %d] Config request : Action ADD: Frame %d radio bearer id %d configured\n", - (ctxt_pP->enb_flag) ? "eNB" : "UE", (ctxt_pP->enb_flag) ? ctxt_pP->enb_module_id : ctxt_pP->ue_module_id, ctxt_pP->frame, rb_idP); + LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), + rb_idP); break; case CONFIG_ACTION_MODIFY: break; case CONFIG_ACTION_REMOVE: - pdcp_p->instanciated_instance = FALSE; + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_REMOVE: radio bearer id %d configured\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), + rb_idP); pdcp_p->next_pdcp_tx_sn = 0; pdcp_p->next_pdcp_rx_sn = 0; pdcp_p->tx_hfn = 0; @@ -1705,8 +1632,7 @@ rrc_pdcp_config_req ( pdcp_p->seq_num_size = 0; pdcp_p->first_missing_pdu = -1; pdcp_p->security_activated = 0; - LOG_D(PDCP,"[%s %d] Config request : CONFIG_ACTION_REMOVE: Frame %d radio bearer id %d configured\n", - (ctxt_pP->enb_flag) ? "eNB" : "UE", (ctxt_pP->enb_flag) ? ctxt_pP->enb_module_id : ctxt_pP->ue_module_id, ctxt_pP->frame, rb_idP); + h_rc = hashtable_remove(pdcp_coll_p, key); break; @@ -1714,49 +1640,109 @@ rrc_pdcp_config_req ( if ((security_modeP >= 0) && (security_modeP <= 0x77)) { pdcp_p->cipheringAlgorithm= security_modeP & 0x0f; pdcp_p->integrityProtAlgorithm = (security_modeP>>4) & 0xf; - LOG_D(PDCP,"[%s %d]Set security mode : CONFIG_ACTION_SET_SECURITY_MODE: Frame %d cipheringAlgorithm %d integrityProtAlgorithm %d\n", - (ctxt_pP->enb_flag) ? "eNB" : "UE", (ctxt_pP->enb_flag) ? ctxt_pP->enb_module_id : ctxt_pP->ue_module_id, ctxt_pP->frame, + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_SET_SECURITY_MODE: cipheringAlgorithm %d integrityProtAlgorithm %d\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), pdcp_p->cipheringAlgorithm, pdcp_p->integrityProtAlgorithm ); } else { - LOG_D(PDCP,"[%s %d] bad security mode %d", security_modeP); + LOG_W(PDCP,"[%s %d] bad security mode %d", security_modeP); } break; default: - DevParam(actionP, ctxt_pP->ue_module_id, ctxt_pP->enb_module_id); + DevParam(actionP, ctxt_pP->module_id, ctxt_pP->rnti); break; } + } else { + switch (actionP) { + case CONFIG_ACTION_ADD: + pdcp_p = calloc(1, sizeof(pdcp_t)); + h_rc = hashtable_insert(pdcp_coll_p, key, pdcp_p); + + if (h_rc != HASH_TABLE_OK) { + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" PDCP ADD FAILED\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + free(pdcp_p); + + } else { + pdcp_p->is_srb = srb_flagP; + pdcp_p->rb_id = rb_idP; + + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + pdcp_p->is_ue = TRUE; + + } else { + pdcp_p->is_ue = FALSE; } + pdcp_p->next_pdcp_tx_sn = 0; + pdcp_p->next_pdcp_rx_sn = 0; + pdcp_p->tx_hfn = 0; + pdcp_p->rx_hfn = 0; + /* SN of the last PDCP SDU delivered to upper layers */ + pdcp_p->last_submitted_pdcp_rx_sn = 4095; + + if (rb_idP < DTCH) { // SRB + pdcp_p->seq_num_size = 5; + + } else { // DRB + pdcp_p->seq_num_size = 12; + } + + pdcp_p->first_missing_pdu = -1; + LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Inserting PDCP instance in collection key 0x%"PRIx64"\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), key); + LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d configured\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), + rb_idP); + } + + break; + + case CONFIG_ACTION_REMOVE: + LOG_D(PDCP, PROTOCOL_CTXT_FMT" CONFIG_REQ PDCP CONFIG_ACTION_REMOVE PDCP instance not found\n", + PROTOCOL_CTXT_ARGS(ctxt_pP)); + break; + + default: + LOG_E(PDCP, PROTOCOL_CTXT_FMT" CONFIG_REQ PDCP NOT FOUND\n", + PROTOCOL_CTXT_ARGS(ctxt_pP)); + } + } +} + + +//----------------------------------------------------------------------------- // TODO PDCP module initialization code might be removed -int pdcp_module_init (void) +int +pdcp_module_init ( + void +) +//----------------------------------------------------------------------------- { - //----------------------------------------------------------------------------- -#ifdef NAS_FIFO +#ifdef PDCP_USE_RT_FIFO int ret; - ret=rtf_create(PDCP2NAS_FIFO,32768); + ret=rtf_create(PDCP2NW_DRIVER_FIFO,32768); if (ret < 0) { - LOG_E(PDCP, "Cannot create PDCP2NAS fifo %d (ERROR %d)\n", PDCP2NAS_FIFO, ret); - + LOG_E(PDCP, "Cannot create PDCP2NW_DRIVER_FIFO fifo %d (ERROR %d)\n", PDCP2NW_DRIVER_FIFO, ret); return -1; } else { - LOG_D(PDCP, "Created PDCP2NAS fifo %d\n", PDCP2NAS_FIFO); - rtf_reset(PDCP2NAS_FIFO); + LOG_D(PDCP, "Created PDCP2NAS fifo %d\n", PDCP2NW_DRIVER_FIFO); + rtf_reset(PDCP2NW_DRIVER_FIFO); } - ret=rtf_create(NAS2PDCP_FIFO,32768); + ret=rtf_create(NW_DRIVER2PDCP_FIFO,32768); if (ret < 0) { - LOG_E(PDCP, "Cannot create NAS2PDCP fifo %d (ERROR %d)\n", NAS2PDCP_FIFO, ret); + LOG_E(PDCP, "Cannot create NW_DRIVER2PDCP_FIFO fifo %d (ERROR %d)\n", NW_DRIVER2PDCP_FIFO, ret); return -1; } else { - LOG_D(PDCP, "Created NAS2PDCP fifo %d\n", NAS2PDCP_FIFO); - rtf_reset(NAS2PDCP_FIFO); + LOG_D(PDCP, "Created NW_DRIVER2PDCP_FIFO fifo %d\n", NW_DRIVER2PDCP_FIFO); + rtf_reset(NW_DRIVER2PDCP_FIFO); } pdcp_2_nas_irq = 0; @@ -1765,26 +1751,51 @@ int pdcp_module_init (void) #endif return 0; +} + +//----------------------------------------------------------------------------- +void +pdcp_free ( + void* pdcp_pP +) +//----------------------------------------------------------------------------- +{ + pdcp_t* pdcp_p = (pdcp_t*)pdcp_pP; + if (pdcp_p != NULL) { + if (pdcp_p->kUPenc != NULL) { + free(pdcp_p->kUPenc); + } + + if (pdcp_p->kRRCint != NULL) { + free(pdcp_p->kRRCint); + } + + if (pdcp_p->kRRCenc != NULL) { + free(pdcp_p->kRRCenc); + } + + memset(pdcp_pP, 0, sizeof(pdcp_t)); + free(pdcp_pP); + } } //----------------------------------------------------------------------------- void pdcp_module_cleanup (void) //----------------------------------------------------------------------------- { -#ifdef NAS_FIFO - rtf_destroy(NAS2PDCP_FIFO); - rtf_destroy(PDCP2NAS_FIFO); +#ifdef PDCP_USE_RT_FIFO + rtf_destroy(NW_DRIVER2PDCP_FIFO); + rtf_destroy(PDCP2NW_DRIVER_FIFO); #endif } //----------------------------------------------------------------------------- void pdcp_layer_init(void) +//----------------------------------------------------------------------------- { - //----------------------------------------------------------------------------- + module_id_t instance; - module_id_t instance2; - rb_id_t rb_id; #if defined(Rel10) mbms_session_id_t session_id; mbms_service_id_t service_id; @@ -1793,16 +1804,10 @@ void pdcp_layer_init(void) * Initialize SDU list */ list_init(&pdcp_sdu_list, NULL); + pdcp_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, pdcp_free); + AssertFatal(pdcp_coll_p != NULL, "UNRECOVERABLE error, PDCP hashtable_create failed"); for (instance = 0; instance < NUMBER_OF_UE_MAX; instance++) { - for (rb_id = 0; rb_id < maxDRB; rb_id++) { - memset(&pdcp_array_drb_ue[instance][rb_id], 0, sizeof(pdcp_t)); - } - - for (rb_id = 0; rb_id < 2; rb_id++) { - memset(&pdcp_array_srb_ue[instance][rb_id], 0, sizeof(pdcp_t)); - } - #if defined(Rel10) for (service_id = 0; service_id < maxServiceCount; service_id++) { @@ -1815,16 +1820,6 @@ void pdcp_layer_init(void) } for (instance = 0; instance < NUMBER_OF_eNB_MAX; instance++) { - for (instance2 = 0; instance2 < NUMBER_OF_UE_MAX; instance2++) { - for (rb_id = 0; rb_id < maxDRB; rb_id++) { - memset(&pdcp_array_drb_eNB[instance][instance2][rb_id], 0, sizeof(pdcp_t)); - } - - for (rb_id = 0; rb_id < 2; rb_id++) { - memset(&pdcp_array_srb_eNB[instance][instance2][rb_id], 0, sizeof(pdcp_t)); - } - } - #if defined(Rel10) for (service_id = 0; service_id < maxServiceCount; service_id++) { @@ -1858,8 +1853,9 @@ void pdcp_layer_cleanup (void) //----------------------------------------------------------------------------- { list_free (&pdcp_sdu_list); + hashtable_destroy(pdcp_coll_p); } -#ifdef NAS_FIFO +#ifdef PDCP_USE_RT_FIFO EXPORT_SYMBOL(pdcp_2_nas_irq); -#endif //NAS_FIFO +#endif //PDCP_USE_RT_FIFO diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 2592560a4dc..33d410c87bb 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -89,6 +89,11 @@ extern pthread_mutex_t pdcp_mutex; extern pthread_cond_t pdcp_cond; extern int pdcp_instance_cnt; +#define PROTOCOL_PDCP_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u] " + +#define PROTOCOL_PDCP_CTXT_ARGS(CTXT_Pp, pDCP_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ + (pDCP_Pp->is_srb) ? "SRB" : "DRB",\ + pDCP_Pp->rb_id int init_pdcp_thread(void); void cleanup_pdcp_thread(void); @@ -102,7 +107,7 @@ public_pdcp(unsigned int Pdcp_stats_rx_bytes[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_M public_pdcp(unsigned int Pdcp_stats_rx_bytes_last[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_MAX]); public_pdcp(unsigned int Pdcp_stats_rx_rate[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_MAX]); -typedef struct pdcp_stats_t { +typedef struct pdcp_stats_s { time_stats_t pdcp_run; time_stats_t data_req; time_stats_t data_ind; @@ -113,8 +118,8 @@ typedef struct pdcp_stats_t { } pdcp_stats_t; // common to eNB and UE -typedef struct pdcp_t { - boolean_t instanciated_instance; +typedef struct pdcp_s { + //boolean_t instanciated_instance; uint16_t header_compression_profile; /* SR: added this flag to distinguish UE/eNB instance as pdcp_run for virtual @@ -183,7 +188,7 @@ typedef struct pdcp_t { } pdcp_t; #if defined(Rel10) -typedef struct pdcp_mbms_t { +typedef struct pdcp_mbms_s { boolean_t instanciated_instance; rb_id_t rb_id; } pdcp_mbms_t; @@ -355,10 +360,12 @@ public_pdcp(int pdcp_module_init (void);) public_pdcp(void pdcp_module_cleanup (void);) public_pdcp(void pdcp_layer_init (void);) public_pdcp(void pdcp_layer_cleanup (void);) +#if defined(USE_PDCP_NETLINK_QUEUES) public_pdcp(int pdcp_netlink_init (void);) -#define PDCP2NAS_FIFO 21 -#define NAS2PDCP_FIFO 22 +#endif +#define PDCP2NW_DRIVER_FIFO 21 +#define NW_DRIVER2PDCP_FIFO 22 protected_pdcp_fifo(int pdcp_fifo_flush_sdus ( const protocol_ctxt_t* const ctxt_pP);) @@ -433,10 +440,13 @@ typedef struct pdcp_missing_pdu_info_t { protected_pdcp(signed int pdcp_2_nas_irq;) public_pdcp(pdcp_stats_t UE_pdcp_stats[NUMBER_OF_UE_MAX];) public_pdcp(pdcp_stats_t eNB_pdcp_stats[NUMBER_OF_eNB_MAX];) -protected_pdcp(pdcp_t pdcp_array_srb_ue[NUMBER_OF_UE_MAX][2];) -protected_pdcp(pdcp_t pdcp_array_drb_ue[NUMBER_OF_UE_MAX][maxDRB];) -public_pdcp(pdcp_t pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][2];) -protected_pdcp(pdcp_t pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][maxDRB];) +//protected_pdcp(pdcp_t pdcp_array_srb_ue[NUMBER_OF_UE_MAX][2];) +//protected_pdcp(pdcp_t pdcp_array_drb_ue[NUMBER_OF_UE_MAX][maxDRB];) +//public_pdcp(pdcp_t pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][2];) +//protected_pdcp(pdcp_t pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][maxDRB];) + +// for UE code conly +protected_pdcp(rnti_t pdcp_UE_UE_module_id_to_rnti[NUMBER_OF_UE_MAX];) #if defined(Rel10) public_pdcp(pdcp_mbms_t pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h public_pdcp(pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h @@ -450,5 +460,23 @@ protected_pdcp(unsigned char pdcp_input_sdu_buffer[MAX_IP_PACKET_SIZE]; protected_pdcp(sdu_size_t pdcp_input_index_header;) protected_pdcp(sdu_size_t pdcp_input_sdu_size_read;) protected_pdcp(sdu_size_t pdcp_input_sdu_remaining_size_to_read;) +#define PDCP_COLL_KEY_VALUE(mODULE_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \ + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(rB_iD)) << 25) | \ + (((hash_key_t)(iS_sRB)) << 33)) + +// service id max val is maxServiceCount = 16 (asn1_constants.h) + +#define PDCP_COLL_KEY_MBMS_VALUE(mODULE_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \ + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(sERVICE_ID)) << 32) | \ + (((hash_key_t)(sESSION_ID)) << 37) | \ + (((hash_key_t)(0x0000000000000001)) << 63)) + +public_pdcp(hash_table_t *pdcp_coll_p;) #endif diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 9e110ad6322..a731f17917d 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -38,7 +38,6 @@ #define PDCP_FIFO_C #define PDCP_DEBUG 1 -//#define IDROMEL_NEMO 1 #ifndef OAI_EMU extern int otg_enabled; @@ -71,7 +70,7 @@ extern int otg_enabled; #include "assertions.h" -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #include <sys/socket.h> #include <linux/netlink.h> @@ -85,15 +84,12 @@ extern int nas_sock_fd; extern struct msghdr nas_msg_tx; extern struct msghdr nas_msg_rx; -#define MAX_PAYLOAD 1600 - unsigned char pdcp_read_state_g = 0; -//unsigned char pdcp_read_payload[MAX_PAYLOAD]; #endif extern Packet_OTG_List_t *otg_pdcp_buffer; -#if defined(LINK_PDCP_TO_GTPV1U) +#if defined(LINK_ENB_PDCP_TO_GTPV1U) # include "gtpv1u_eNB_task.h" #endif @@ -108,11 +104,11 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) int bytes_wrote = 0; int pdcp_nb_sdu_sent = 0; uint8_t cont = 1; -#if defined(LINK_PDCP_TO_GTPV1U) +#if defined(LINK_ENB_PDCP_TO_GTPV1U) //MessageDef *message_p = NULL; #endif -#if defined(NAS_NETLINK) && defined(LINUX) +#if defined(PDCP_USE_NETLINK) && defined(LINUX) int ret = 0; #endif @@ -122,20 +118,14 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; #endif -#if defined(LINK_PDCP_TO_GTPV1U) +#if defined(LINK_ENB_PDCP_TO_GTPV1U) if (ctxt_pP->enb_flag) { AssertFatal(0, "Now execution should not go here"); LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size); - /*message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_TUNNEL_DATA_REQ); - GTPV1U_TUNNEL_DATA_REQ(message_p).buffer = &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]); - GTPV1U_TUNNEL_DATA_REQ(message_p).length = ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size; - GTPV1U_TUNNEL_DATA_REQ(message_p).ue_module_id = ctxt_pP->ue_module_id; - GTPV1U_TUNNEL_DATA_REQ(message_p).rab_id; = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; - */ gtpv1u_new_data_req( - ctxt_pP->enb_module_id, //gtpv1u_data_t *gtpv1u_data_p, - ctxt_pP->ue_module_id,//rb_id/maxDRB, TO DO UE ID + ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p, + ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4, &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]), ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size); @@ -151,7 +141,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) #endif /* defined(ENABLE_USE_MME) */ #ifdef PDCP_DEBUG - LOG_D(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to higher layers\n", + LOG_D(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n", ctxt_pP->frame, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); #endif //PDCP_DEBUG @@ -162,25 +152,25 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t); } -#ifdef NAS_FIFO - bytes_wrote = rtf_put (PDCP2NAS_FIFO, +#ifdef PDCP_USE_RT_FIFO + bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), pdcp_output_header_bytes_to_write); #else -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #ifdef LINUX memcpy(NLMSG_DATA(nas_nlh_tx), &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), pdcp_output_header_bytes_to_write); nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write; #endif //LINUX -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK bytes_wrote = pdcp_output_header_bytes_to_write; -#endif //NAS_FIFO +#endif //PDCP_USE_RT_FIFO #ifdef PDCP_DEBUG - LOG_D(PDCP, "Frame %d Sent %d Bytes of header to higher layers\n", + LOG_D(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n", ctxt_pP->frame, bytes_wrote); #endif //PDCP_DEBUG @@ -191,11 +181,11 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) if (!pdcp_output_header_bytes_to_write) { // continue with sdu pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; -#ifdef NAS_FIFO - bytes_wrote = rtf_put (PDCP2NAS_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); +#ifdef PDCP_USE_RT_FIFO + bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); #else -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #ifdef LINUX memcpy(NLMSG_DATA(nas_nlh_tx)+sizeof(pdcp_data_ind_header_t), &(sdu_p->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write; @@ -208,9 +198,9 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) } #endif // LINUX -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK bytes_wrote= pdcp_output_sdu_bytes_to_write; -#endif // NAS_FIFO +#endif // PDCP_USE_RT_FIFO #ifdef PDCP_DEBUG LOG_D(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to higher layers\n", @@ -248,13 +238,13 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) } } else { // continue writing sdu -#ifdef NAS_FIFO - bytes_wrote = rtf_put (PDCP2NAS_FIFO, +#ifdef PDCP_USE_RT_FIFO + bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, (uint8_t *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])), pdcp_output_sdu_bytes_to_write); -#else // NAS_FIFO +#else // PDCP_USE_RT_FIFO bytes_wrote = pdcp_output_sdu_bytes_to_write; -#endif // NAS_FIFO +#endif // PDCP_USE_RT_FIFO if (bytes_wrote > 0) { pdcp_output_sdu_bytes_to_write -= bytes_wrote; @@ -272,16 +262,16 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) } } -#ifdef NAS_FIFO +#ifdef PDCP_USE_RT_FIFO if ((pdcp_nb_sdu_sent)) { if ((pdcp_2_nas_irq > 0)) { #ifdef PDCP_DEBUG - LOG_I(PDCP, "Frame %d : Trigger NAS RX interrupt\n", + LOG_D(PDCP, "Frame %d : Trigger NAS RX interrupt\n", ctxt_pP->frame); #endif //PDCP_DEBUG - rt_pend_linux_srq (pdcp_2_nas_irq); + } else { LOG_E(PDCP, "Frame %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n", ctxt_pP->frame, @@ -289,291 +279,90 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) } } -#endif //NAS_FIFO +#endif //PDCP_USE_RT_FIFO return pdcp_nb_sdu_sent; } -//----------------------------------------------------------------------------- -/* - * returns a positive value if whole bytes that had to be read were read - * returns zero value if whole bytes that had to be read were not read at all - * returns a negative value if an error was encountered while reading the rt fifo - */ -int pdcp_fifo_read_input_sdus_remaining_bytes (const protocol_ctxt_t* const ctxt_pP) -{ - //----------------------------------------------------------------------------- - sdu_size_t bytes_read = 0; - rb_id_t rab_id = 0; - pdcp_t *pdcp_p = NULL; - module_id_t ue_inst = 0; - module_id_t enb_inst = 0; - rb_id_t rb_id = 0; - int result = -1; - - // if remaining bytes to read - if (pdcp_input_sdu_remaining_size_to_read > 0) { - bytes_read = rtf_get (NAS2PDCP_FIFO, - &(pdcp_input_sdu_buffer[pdcp_input_sdu_size_read]), - pdcp_input_sdu_remaining_size_to_read); - - if (bytes_read > 0) { - LOG_D(PDCP, "[PDCP_FIFOS] Read %d remaining bytes of data from Nas_mesh\n", bytes_read); - - pdcp_input_sdu_remaining_size_to_read = pdcp_input_sdu_remaining_size_to_read - bytes_read; - pdcp_input_sdu_size_read = pdcp_input_sdu_size_read + bytes_read; - - if (pdcp_input_sdu_remaining_size_to_read != 0) { - return 0; - } else { -#ifdef PDCP_DEBUG - LOG_D(PDCP, "Frame %d: IP->RADIO RECEIVED COMPLETE SDU size %d inst %d rb %d\n", - ctxt_pP->frame, - pdcp_input_sdu_size_read, - pdcp_input_header.inst, - pdcp_input_header.rb_id); -#endif //PDCP_DEBUG - pdcp_input_sdu_size_read = 0; -#ifdef IDROMEL_NEMO - pdcp_read_header_g.inst = 0; -#endif - - if (ctxt_pP->enb_flag == 0) { - ue_inst = pdcp_read_header_g.inst; - rb_id = pdcp_read_header_g.rb_id; - enb_inst = 0; - pdcp_p = &pdcp_array_drb_ue[ue_inst][rb_id-1]; - } else { - ue_inst = pdcp_read_header_g.rb_id / maxDRB; - rb_id = pdcp_read_header_g.rb_id % maxDRB; - enb_inst = pdcp_read_header_g.inst; - pdcp_p = &pdcp_array_drb_eNB[enb_inst][ue_inst][rb_id-1]; - } - - AssertFatal (enb_inst < NB_eNB_INST, "eNB module id is too high (%u/%d)!\n", enb_inst, NB_eNB_INST); - AssertFatal (ue_inst >= NB_eNB_INST, - "UE module id is too low (%u/%d)!\n", - ue_inst, - NB_eNB_INST); - AssertFatal (ue_inst < (NB_eNB_INST + NB_UE_INST), - "UE module id is too high (%u/%d)!\n", - ue_inst, - NB_eNB_INST + NB_UE_INST); - AssertFatal (rb_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); - AssertFatal (rb_id > 0 , "RB id is too low (%u/%d)!\n", rab_id, maxDRB); - - if (pdcp_input_header.rb_id != 0) { - LOG_D(PDCP, "[FRAME %5u][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - enb_inst, - ue_inst, - rb_id); - - if (pdcp_p->instanciated_instance) { - result = pdcp_data_req ( - ctxt_pP, - SRB_FLAG_NO, - rb_id % maxDRB, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_input_header.data_size, - pdcp_input_sdu_buffer, - PDCP_TRANSMISSION_MODE_DATA); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - - } else if ((pdcp_input_header.traffic_type == TRAFFIC_IPV6_TYPE_MULTICAST) || (pdcp_input_header.traffic_type == TRAFFIC_IPV4_TYPE_MULTICAST)) { - LOG_D(PDCP, "[FRAME %5u][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ on MBMS bearer/ %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - enb_inst, - ue_inst, - rb_id); - - if (pdcp_p->instanciated_instance) { - result = pdcp_data_req ( - ctxt_pP, - SRB_FLAG_NO, - rb_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_input_header.data_size, - pdcp_input_sdu_buffer, - PDCP_TRANSMISSION_MODE_TRANSPARENT); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - - } else if (ctxt_pP->enb_flag) { - // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs - LOG_D(PDCP, "Checking if could sent on default rabs\n"); - - for (ue_inst = 0; ue_inst < NUMBER_OF_UE_MAX; ue_inst++) { - LOG_D(PDCP, "Checking if could sent on default rab id %d\n", DEFAULT_RAB_ID); - pdcp_p = &pdcp_array_drb_eNB[enb_inst][ue_inst][DEFAULT_RAB_ID-1]; - - if (pdcp_p->instanciated_instance) { - LOG_D(PDCP, "[FRAME %5u][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB DEFAULT_RAB_ID %u]\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - enb_inst, - ue_inst, - DEFAULT_RAB_ID); - result = pdcp_data_req ( - ctxt_pP, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_input_header.data_size, - pdcp_input_sdu_buffer, - PDCP_TRANSMISSION_MODE_DATA); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - } - } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - LOG_D(PDCP, "[FRAME %5u][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB DEFAULT_RAB_ID %u]\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - enb_inst, - ue_inst, - DEFAULT_RAB_ID); - result = pdcp_data_req ( - ctxt_pP, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_input_header.data_size, - pdcp_input_sdu_buffer, - PDCP_TRANSMISSION_MODE_DATA); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - - // not necessary - //memset(pdcp_input_sdu_buffer, 0, MAX_IP_PACKET_SIZE); - return 1; - } - } else { - return bytes_read; - } - } - - return 1; -} - //----------------------------------------------------------------------------- int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) { -#ifdef NAS_NETLINK -# if defined(ENABLE_PDCP_NETLINK_FIFO) +#ifdef PDCP_USE_NETLINK + protocol_ctxt_t ctxt_cpy; + protocol_ctxt_t ctxt; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + struct pdcp_netlink_element_s* data_p = NULL; module_id_t ue_id = 0; + pdcp_t* pdcp_p = NULL; +# if defined(USE_PDCP_NETLINK_QUEUES) rb_id_t rab_id = 0; - pdcp_t *pdcp = NULL; + pdcp_transmission_mode_t pdcp_mode = PDCP_TRANSMISSION_MODE_UNKNOWN; - struct pdcp_netlink_element_s *data = NULL; - protocol_ctxt_t ctxt_cpy; - protocol_ctxt_t ctxt; ctxt_cpy = *ctxt_pP; - while (pdcp_netlink_dequeue_element(ctxt_pP, &data) != 0) { + while (pdcp_netlink_dequeue_element(ctxt_pP, &data_p) != 0) { DevAssert(data != NULL); - - if (ctxt_cpy.enb_flag == ENB_FLAG_NO) { - rab_id = data->pdcp_read_header.rb_id % maxDRB; - pdcp = &pdcp_array_drb_ue[ctxt_cpy.ue_module_id][rab_id-1]; - } else { - rab_id = data->pdcp_read_header.rb_id % maxDRB; - ctxt_cpy.ue_module_id = data->pdcp_read_header.rb_id / maxDRB; - pdcp = &pdcp_array_drb_eNB[ctxt_cpy.enb_module_id][ctxt_cpy.ue_module_id][rab_id-1]; + rab_id = data_p->pdcp_read_header.rb_id % maxDRB; + // ctxt_pP->rnti is NOT_A_RNTI + ctxt_cpy.rnti = pdcp_module_id_to_rnti[ctxt_cpy.module_id][data_p->pdcp_read_header.inst]; + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_cpy.rnti, ctxt_pP->enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + + if (h_rc != HASH_TABLE_OK) { + LOG_W(PDCP, PROTOCOL_CTXT_FMT" Dropped IP PACKET cause no PDCP instanciated\n", + PROTOCOL_CTXT_ARGS(ctxt_pP)); + free(data_p->data); + free(data_p); + data_p = NULL; + continue; } - if (ctxt_cpy.enb_flag) { - AssertFatal ((ctxt_cpy.enb_module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - ctxt_cpy.enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal ((ctxt_cpy.enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - ctxt_cpy.enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ctxt_cpy.ue_module_id < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ctxt_cpy.ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ctxt_cpy.ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ctxt_cpy.ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ctxt_cpy.ue_module_id >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ctxt_cpy.ue_module_id, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(&ctxt_cpy); AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); if (rab_id != 0) { - if (pdcp->instanciated_instance) { LOG_D(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ " - "/ %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", + "/ %d Bytes --->][PDCP][MOD %u][RB %u]\n", ctxt_cpy.frame, (ctxt_cpy.enb_flag) ? "eNB" : "UE", - data->pdcp_read_header.inst, - data->pdcp_read_header.rb_id, - data->pdcp_read_header.data_size, - ctxt_cpy.enb_module_id, - ctxt_cpy.ue_module_id, + data_p->pdcp_read_header.inst, + data_p->pdcp_read_header.rb_id, + data_p->pdcp_read_header.data_size, + ctxt_cpy.module_id, rab_id); #ifdef OAI_NW_DRIVER_TYPE_ETHERNET - if ((data->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_MULTICAST) /*TRAFFIC_IPV6_TYPE_MULTICAST */ || - (data->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_MULTICAST) /*TRAFFIC_IPV4_TYPE_MULTICAST */ || - (data->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_BROADCAST) /*TRAFFIC_IPV4_TYPE_BROADCAST */ ) { + if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_MULTICAST) /*TRAFFIC_IPV6_TYPE_MULTICAST */ || + (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_MULTICAST) /*TRAFFIC_IPV4_TYPE_MULTICAST */ || + (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_BROADCAST) /*TRAFFIC_IPV4_TYPE_BROADCAST */ ) { #if defined (Rel10) PDCP_TRANSMISSION_MODE_TRANSPARENT; #else pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; #endif - } else if ((data->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_UNICAST) /* TRAFFIC_IPV6_TYPE_UNICAST */ || - (data->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_UNICAST) /*TRAFFIC_IPV4_TYPE_UNICAST*/ ) { + } else if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_UNICAST) /* TRAFFIC_IPV6_TYPE_UNICAST */ || + (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_UNICAST) /*TRAFFIC_IPV4_TYPE_UNICAST*/ ) { pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; } else { pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; LOG_W(PDCP,"unknown IP traffic type \n"); } -#else // NASMESH driver does not curreenlty support multicast traffic +#else // OAI_NW_DRIVER_TYPE_ETHERNET NASMESH driver does not curreenlty support multicast traffic pdcp_mode = PDCP_TRANSMISSION_MODE_DATA; #endif - pdcp_data_req(ctxt_pP, + pdcp_data_req(&ctxt_cpy, SRB_FLAG_NO, rab_id % maxDRB, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, - data->pdcp_read_header.data_size, - data->data, + data_p->pdcp_read_header.data_size, + data_p->data, pdcp_mode); - } else { - LOG_E(PDCP, "Received packet for non-instanciated instance %u with rb_id %u, UE_index %d, ctxt_cpy.enb_flag %d eNB_index %d\n", - data->pdcp_read_header.inst, data->pdcp_read_header.rb_id, ctxt_cpy.ue_module_id, ctxt_cpy.enb_flag,ctxt_cpy.enb_module_id); - } } else if (ctxt_cpy.enb_flag) { /* rb_id = 0, thus interpreated as broadcast and transported as * multiple unicast is a broadcast packet, we have to send this @@ -582,12 +371,10 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID first_ue_local %u nb_ue_local %u\n", oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local); for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { - pdcp = &pdcp_array_drb_eNB[ctxt_cpy.enb_module_id][ue_id][DEFAULT_RAB_ID-1]; - - if (pdcp->instanciated_instance) { + if (pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID UE %d\n", ue_id); - ctxt.enb_module_id = ctxt_cpy.enb_module_id; - ctxt.ue_module_id = ue_id; + ctxt.module_id = ctxt_cpy.module_id; + ctxt.rnti = ctxt_cpy.pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; ctxt.frame = ctxt_cpy.frame; ctxt.enb_flag = ctxt_cpy.enb_flag; @@ -597,8 +384,8 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) DEFAULT_RAB_ID, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, - data->pdcp_read_header.data_size, - data->data, + data_p->pdcp_read_header.data_size, + data_p->data, PDCP_TRANSMISSION_MODE_DATA); } } @@ -610,62 +397,58 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) DEFAULT_RAB_ID, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, - data->pdcp_read_header.data_size, - data->data, + data_p->pdcp_read_header.data_size, + data_p->data, PDCP_TRANSMISSION_MODE_DATA); } - free(data->data); - free(data); - data = NULL; + free(data_p->data); + free(data_p); + data_p = NULL; } return 0; -# else /* ENABLE_PDCP_NETLINK_FIFO*/ +# else /* USE_PDCP_NETLINK_QUEUES*/ int len = 1; rb_id_t rab_id = 0; - protocol_ctxt_t ctxt_cpy; - protocol_ctxt_t ctxt; - ctxt_cpy = *ctxt_pP; while (len > 0) { len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); if (len<=0) { // nothing in pdcp NAS socket - //LOG_I(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); + //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); } else { for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; NLMSG_OK (nas_nlh_rx, len); nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) { if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { - LOG_D(PDCP, "[PDCP][FIFO] RX NLMSG_DONE\n"); + LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); //return; } if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { - LOG_E(PDCP, "[PDCP][FIFO] RX NLMSG_ERROR\n"); + LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); } if (pdcp_read_state_g == 0) { if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { pdcp_read_state_g = 1; //get memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); - LOG_D(PDCP, "[PDCP][FIFO] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d\n", + LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d\n", pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size); } else { - LOG_E(PDCP, "[PDCP][FIFO] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", + LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", nas_nlh_rx->nlmsg_len); } } else { pdcp_read_state_g = 0; // print_active_requests() #ifdef PDCP_DEBUG - LOG_D(PDCP, "[PDCP][FIFO] Something in socket, length %d \n", + LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %d \n", nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); #endif - //memcpy(pdcp_read_payload, (unsigned char *)NLMSG_DATA(nas_nlh_rx), nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); #ifdef OAI_EMU @@ -673,51 +456,33 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) { ctxt.frame = ctxt_cpy.frame; ctxt.enb_flag = ENB_FLAG_YES; - ctxt.ue_module_id = pdcp_read_header_g.rb_id / maxDRB + oai_emulation.info.first_ue_local; - ctxt.enb_module_id = pdcp_read_header_g.inst + oai_emulation.info.first_enb_local; + ctxt.module_id = pdcp_read_header_g.inst + oai_emulation.info.first_enb_local; + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pdcp_read_header_g.rb_id / maxDRB + oai_emulation.info.first_ue_local]; rab_id = pdcp_read_header_g.rb_id % maxDRB; } else { ctxt.frame = ctxt_cpy.frame; ctxt.enb_flag = ENB_FLAG_NO; - ctxt.ue_module_id = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; - ctxt.enb_module_id = 0; + ctxt.module_id = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; + ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; rab_id = pdcp_read_header_g.rb_id; } - AssertFatal (ctxt.enb_module_id >= oai_emulation.info.first_enb_local, - "eNB inst is too low (%u/%d)!\n", - ctxt.enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal (ctxt.enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), - "eNB inst is too high (%u/%d)!\n", - ctxt.enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ctxt.ue_module_id >= oai_emulation.info.first_ue_local, - "UE inst is too low (%u/%d)!\n", - ctxt.ue_module_id, - oai_emulation.info.first_ue_local); - AssertFatal (ctxt.ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE inst is too high (%u/%d)!\n", - ctxt.ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); + CHECK_CTXT_ARGS(&ctxt); AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); /*LGpdcp_read_header.inst = (pdcp_read_header_g.inst >= oai_emulation.info.nb_enb_local) ? \ pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;*/ -#else +#else // OAI_EMU pdcp_read_header_g.inst = 0; #warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ctxt_cpy.enb_flag; if (ctxt_cpy.enb_flag) { - ctxt.enb_flag = ENB_FLAG_YES; - ctxt.ue_module_id = 0; - ctxt.enb_module_id = 0; + ctxt.module_id = 0; rab_id = pdcp_read_header_g.rb_id % maxDRB; } else { - ctxt.enb_flag = ENB_FLAG_NO; - ctxt.ue_module_id = 0; - ctxt.enb_module_id = 0; + ctxt.module_id = 0; rab_id = pdcp_read_header_g.rb_id % maxDRB; } @@ -726,8 +491,10 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) if (ctxt.enb_flag) { if (rab_id != 0) { rab_id = rab_id % maxDRB; + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - if (pdcp_array_drb_eNB[ctxt.enb_module_id][ctxt.ue_module_id][rab_id-1].instanciated_instance) { + if (h_rc == HASH_TABLE_OK) { #ifdef PDCP_DEBUG LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n", ctxt.frame, @@ -737,13 +504,13 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) pdcp_read_header_g.rb_id); #endif - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", ctxt_cpy.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size, - ctxt.enb_module_id, - ctxt.ue_module_id, + ctxt.module_id, + ctxt.rnti, rab_id); pdcp_data_req(&ctxt, @@ -755,27 +522,28 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) (unsigned char *)NLMSG_DATA(nas_nlh_rx), PDCP_TRANSMISSION_MODE_DATA); } else { - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u/%u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", ctxt.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size, - ctxt.enb_module_id, - ctxt.ue_module_id, + ctxt.module_id, + ctxt.rnti, rab_id); } } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs #warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES - for (ctxt.ue_module_id = 0; ctxt.ue_module_id < NB_UE_INST; ctxt.ue_module_id++) { - if (pdcp_array_drb_eNB[ctxt.enb_module_id][ctxt.ue_module_id][rab_id-1].instanciated_instance == TRUE) { - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB DEFAULT_RAB_ID %u]\n", + for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { + if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", ctxt.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size, - ctxt.enb_module_id, - ctxt.ue_module_id, + ctxt.module_id, + ctxt.rnti, DEFAULT_RAB_ID); pdcp_data_req ( &ctxt, @@ -789,9 +557,13 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) } } } - } else { + } else { // enb_flag if (rab_id != 0) { - if (pdcp_array_drb_ue[ctxt.ue_module_id][rab_id-1].instanciated_instance) { + rab_id = rab_id % maxDRB; + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + + if (h_rc == HASH_TABLE_OK) { #ifdef PDCP_DEBUG LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n", ctxt.frame, @@ -800,13 +572,13 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), pdcp_read_header_g.rb_id); - LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", ctxt.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size, - ctxt.enb_module_id, - ctxt.ue_module_id, + ctxt.module_id, + ctxt.rnti, rab_id); #endif @@ -820,24 +592,26 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) (unsigned char *)NLMSG_DATA(nas_nlh_rx), PDCP_TRANSMISSION_MODE_DATA); } else { - LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u/%u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", ctxt.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size, - ctxt.enb_module_id, - ctxt.ue_module_id, - rab_id); + ctxt.module_id, + ctxt.rnti, + rab_id, + key); } } else { LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB DEFAULT_RAB_ID %u]\n", + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", ctxt.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size, - ctxt.enb_module_id, - ctxt.ue_module_id, + ctxt.module_id, + ctxt.rnti, DEFAULT_RAB_ID); pdcp_data_req ( &ctxt, @@ -858,42 +632,43 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) return len; # endif -#else // neither NAS_NETLINK nor NAS_FIFO +#else // neither PDCP_USE_NETLINK nor PDCP_USE_RT_FIFO return 0; -#endif // NAS_NETLINK +#endif // PDCP_USE_NETLINK } void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) { unsigned char *otg_pkt=NULL; - module_id_t src_id; // src for otg module_id_t dst_id; // dst for otg rb_id_t rb_id; - signed long pkt_size=0; - protocol_ctxt_t ctxt; - - src_id = ctxt_pP->enb_module_id; - - // we need to add conditions to avoid transmitting data when the UE is not RRC connected. + unsigned int pkt_size=0; #if defined(USER_MODE) && defined(OAI_EMU) - module_id_t module_id; + module_id_t src_id; static unsigned int pkt_cnt_enb=0, pkt_cnt_ue=0; - uint8_t pdcp_mode, is_ue=0; + Packet_otg_elt_t *otg_pkt_info=NULL; int result; + uint8_t pdcp_mode, is_ue=0; +#endif + protocol_ctxt_t ctxt; + // we need to add conditions to avoid transmitting data when the UE is not RRC connected. +#if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.otg_enabled ==1 ) { - module_id = (ctxt_pP->enb_flag == 1) ? ctxt_pP->enb_module_id : ctxt_pP->ue_module_id+NB_eNB_INST; - //rb_id = (ctxt_pP->enb_flag == 1) ? ctxt_pP->enb_module_id * MAX_NUM_RB + DTCH : (NB_eNB_INST + UE_index -1 ) * MAX_NUM_RB + DTCH ; - src_id = module_id; - - while ((otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id]))) != NULL) { - LOG_D(OTG,"Mod_id %d Frame %d Got a packet (%p), HEAD of otg_pdcp_buffer[%d] is %p and Nb elements is %d\n", - module_id,ctxt_pP->frame, otg_pkt_info, module_id, pkt_list_get_head(&(otg_pdcp_buffer[module_id])), otg_pdcp_buffer[module_id].nb_elements); + // module_id is source id + while ((otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[ctxt_pP->instance]))) != NULL) { + LOG_I(OTG,"Mod_id %d Frame %d Got a packet (%p), HEAD of otg_pdcp_buffer[%d] is %p and Nb elements is %d\n", + ctxt_pP->module_id, + ctxt_pP->frame, + otg_pkt_info, + ctxt_pP->instance, + pkt_list_get_head(&(otg_pdcp_buffer[ctxt_pP->instance])), + otg_pdcp_buffer[ctxt_pP->instance].nb_elements); //otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id])); - dst_id = (otg_pkt_info->otg_pkt).dst_id; - module_id = (otg_pkt_info->otg_pkt).module_id; + dst_id = (otg_pkt_info->otg_pkt).dst_id; // type is module_id_t + src_id = (otg_pkt_info->otg_pkt).module_id; // type is module_id_t rb_id = (otg_pkt_info->otg_pkt).rb_id; is_ue = (otg_pkt_info->otg_pkt).is_ue; pdcp_mode = (otg_pkt_info->otg_pkt).mode; @@ -906,18 +681,24 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) if (otg_pkt != NULL) { if (is_ue == 0 ) { - /*rlc_util_print_hex_octets(PDCP, - otg_pkt, - pkt_size); - */ - //rb_id = (/*NB_eNB_INST +*/ dst_id -1 ) * MAX_NUM_RB + DTCH; - ctxt.enb_module_id = ctxt_pP->enb_module_id; - ctxt.ue_module_id = dst_id; - ctxt.frame = ctxt_pP->frame; - ctxt.enb_flag = ctxt_pP->enb_flag; + PROTOCOL_CTXT_SET_BY_MODULE_ID( + &ctxt, + src_id, + ENB_FLAG_YES, + oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id], + ctxt_pP->frame, + ctxt_pP->subframe); LOG_D(OTG,"[eNB %d] Frame %d sending packet %d from module %d on rab id %d (src %d, dst %d) pkt size %d for pdcp mode %d\n", - ctxt_pP->enb_module_id, ctxt_pP->frame, pkt_cnt_enb++, module_id, rb_id, module_id, dst_id, pkt_size, pdcp_mode); + ctxt.module_id, + ctxt.frame, + pkt_cnt_enb++, + src_id, + rb_id, + src_id, + dst_id, + pkt_size, + pdcp_mode); result = pdcp_data_req(&ctxt, SRB_FLAG_NO, rb_id, @@ -926,18 +707,29 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) pkt_size, otg_pkt, pdcp_mode); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); + if (result != TRUE) { + LOG_W(OTG,"PDCP data request failed!\n"); + } } else { //rb_id= eNB_index * MAX_NUM_RB + DTCH; LOG_D(OTG,"[UE %d] Frame %d: sending packet %d from module %d on rab id %d (src %d, dst %d) pkt size %d\n", - ctxt_pP->ue_module_id, ctxt_pP->frame, pkt_cnt_ue++, src_id, rb_id, src_id, dst_id, pkt_size); - - ctxt.enb_module_id = dst_id; - ctxt.ue_module_id = ctxt_pP->ue_module_id; - ctxt.frame = ctxt_pP->frame; - ctxt.enb_flag = ctxt_pP->enb_flag; + ctxt_pP->module_id, + ctxt_pP->frame, + pkt_cnt_ue++, + ctxt_pP->module_id, + rb_id, + ctxt_pP->module_id, + dst_id, + pkt_size); + PROTOCOL_CTXT_SET_BY_MODULE_ID( + &ctxt, + src_id, + ENB_FLAG_NO, + pdcp_UE_UE_module_id_to_rnti[src_id], + ctxt_pP->frame, + ctxt_pP->subframe); result = pdcp_data_req( &ctxt, SRB_FLAG_NO, @@ -947,7 +739,9 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) pkt_size, otg_pkt, PDCP_TRANSMISSION_MODE_DATA); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); + if (result != TRUE) { + LOG_W(OTG,"PDCP data request failed!\n"); + } } free(otg_pkt); @@ -961,25 +755,36 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) #else - if ((otg_enabled==1) && (ctxt_pP->enb_flag == 1)) { // generate DL traffic + if ((otg_enabled==1) && (ctxt_pP->enb_flag == ENB_FLAG_YES)) { // generate DL traffic unsigned int ctime=0; ctime = ctxt_pP->frame * 100; /*if ((mac_get_rrc_status(eNB_index, ctxt_pP->enb_flag, 0 ) > 2) && (mac_get_rrc_status(eNB_index, ctxt_pP->enb_flag, 1 ) > 2)) { */ - ctxt.enb_module_id = ctxt_pP->enb_module_id; - ctxt.frame = ctxt_pP->frame; - ctxt.enb_flag = ctxt_pP->enb_flag; + PROTOCOL_CTXT_SET_BY_MODULE_ID( + &ctxt, + ctxt_pP->module_id, + ctxt_pP->enb_flag, + NOT_A_RNTI, + ctxt_pP->frame, + ctxt_pP->subframe); for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) { - if (mac_get_rrc_status(ctxt_pP->enb_module_id, ctxt_pP->enb_flag, dst_id ) > 2) { + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id]; + + if (ctxt.rnti != NOT_A_RNTI) { + if (mac_eNB_get_rrc_status(ctxt.module_id, ctxt.rnti ) > 2 /*RRC_SI_RECEIVED*/) { unsigned int temp = 0; - otg_pkt = packet_gen( src_id, dst_id, 0, ctime, &temp ); + otg_pkt=packet_gen( + ENB_MODULE_ID_TO_INSTANCE(ctxt.module_id), + UE_MODULE_ID_TO_INSTANCE(dst_id), + 0, + ctime, + &temp); pkt_size = temp; if (otg_pkt != NULL) { rb_id = dst_id * maxDRB + DTCH; - ctxt.ue_module_id = dst_id; pdcp_data_req(&ctxt, SRB_FLAG_NO, rb_id, @@ -988,18 +793,13 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) pkt_size, otg_pkt, PDCP_TRANSMISSION_MODE_DATA); - LOG_D(OTG,"send packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", ctxt_pP->enb_module_id, rb_id, src_id, dst_id, pkt_size); - free(otg_pkt); + LOG_I(OTG, + "send packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", + ctxt_pP->module_id, rb_id, ctxt_pP->module_id, dst_id, pkt_size); + free(otg_pkt); + } } - - /*else { - LOG_I(OTG,"nothing generated (src %d, dst %d)\n",src_id, dst_id); - }*/ } - - /*else { - LOG_I(OTG,"rrc_status (src %d, dst %d) = %d\n",src_id, dst_id, mac_get_rrc_status(src_id, ctxt_pP->enb_flag, dst_id )); - }*/ } } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c index 24adbddbd9f..2da31bda1fc 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c @@ -76,6 +76,7 @@ extern struct iovec nas_iov_rx; extern int nas_sock_fd; extern struct msghdr nas_msg_rx; +#if defined(USE_PDCP_NETLINK_QUEUES) static pthread_t pdcp_netlink_thread; /* We use lock-free queues between the User-plane driver running in kernel-space @@ -91,7 +92,12 @@ time_stats_t ip_pdcp_stats_tmp; static void *pdcp_netlink_thread_fct(void *arg); -int pdcp_netlink_init(void) +//----------------------------------------------------------------------------- +int +pdcp_netlink_init( + void +) +//----------------------------------------------------------------------------- { int i; @@ -109,10 +115,11 @@ int pdcp_netlink_init(void) nb_inst_ue = 1; #endif -#if defined(LINK_PDCP_TO_GTPV1U) +#if defined(LINK_ENB_PDCP_TO_GTPV1U) nb_inst_enb = 0; LOG_I(PDCP, "[NETLINK] Creating 0 queues for eNB Netlink -> PDCP communication\n"); #else +#warning " LG: When there will be handover in, there will problems because dim is based on local nums of ues" pdcp_netlink_queue_enb = calloc(nb_inst_enb, sizeof(struct lfds611_queue_state*)); pdcp_netlink_nb_element_enb = malloc(nb_inst_enb * sizeof(uint32_t)); LOG_I(PDCP, "[NETLINK] Creating %d queues for eNB Netlink -> PDCP communication\n", nb_inst_enb); @@ -172,36 +179,43 @@ int pdcp_netlink_init(void) return 0; } -int pdcp_netlink_dequeue_element(const protocol_ctxt_t* const ctxt_pP, - struct pdcp_netlink_element_s **data_ppP) +//----------------------------------------------------------------------------- +int +pdcp_netlink_dequeue_element( + const protocol_ctxt_t* const ctxt_pP, + struct pdcp_netlink_element_s** data_ppP +) +//----------------------------------------------------------------------------- { int ret = 0; if (ctxt_pP->enb_flag) { - ret = lfds611_queue_dequeue(pdcp_netlink_queue_enb[ctxt_pP->enb_module_id], (void **)data_ppP); + ret = lfds611_queue_dequeue(pdcp_netlink_queue_enb[ctxt_pP->module_id], (void**)data_ppP); if (ret != 0) { - LOG_D(PDCP,"[NETLINK]De-queueing packet for eNB instance %d\n", ctxt_pP->enb_module_id); + LOG_D(PDCP,"[NETLINK]De-queueing packet for eNB instance %d\n", ctxt_pP->module_id); } } else { - ret = lfds611_queue_dequeue(pdcp_netlink_queue_ue[ctxt_pP->ue_module_id], (void **)data_ppP); + ret = lfds611_queue_dequeue(pdcp_netlink_queue_ue[ctxt_pP->module_id], (void**)data_ppP); if (ret != 0) { - LOG_D(PDCP, "[NETLINK]De-queueing packet for UE instance %d\n", ctxt_pP->ue_module_id); + LOG_D(PDCP, "[NETLINK]De-queueing packet for UE instance %d\n", ctxt_pP->module_id); } } return ret; } +//----------------------------------------------------------------------------- static void *pdcp_netlink_thread_fct(void *arg) +//----------------------------------------------------------------------------- { int len = 0; struct pdcp_netlink_element_s *new_data_p = NULL; uint8_t pdcp_thread_read_state ; eNB_flag_t eNB_flag = 0; - + module_id_t module_id = 0; pdcp_thread_read_state = 0; memset(nl_rx_buf, 0, NL_MAX_PAYLOAD); LOG_I(PDCP, "[NETLINK_THREAD] binding to fd %d\n",nas_sock_fd); @@ -254,50 +268,51 @@ void *pdcp_netlink_thread_fct(void *arg) #ifdef OAI_EMU + // LG: new_data_p->pdcp_read_header.inst will contain in fact a module id if (new_data_p->pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) { - new_data_p->pdcp_read_header.inst = new_data_p->pdcp_read_header.inst + module_id = new_data_p->pdcp_read_header.inst - oai_emulation.info.nb_enb_local + + oai_emulation.info.first_ue_local; eNB_flag = 0; } else { - new_data_p->pdcp_read_header.inst = new_data_p->pdcp_read_header.inst + module_id = new_data_p->pdcp_read_header.inst + oai_emulation.info.first_enb_local; eNB_flag = 1; } #else - new_data_p->pdcp_read_header.inst = 0; + module_id = 0; #endif new_data_p->data = malloc(sizeof(uint8_t) * new_data_p->pdcp_read_header.data_size); /* Copy the data */ memcpy(new_data_p->data, NLMSG_DATA(nas_nlh_rx), new_data_p->pdcp_read_header.data_size); if (eNB_flag) { - if (pdcp_netlink_nb_element_enb[new_data_p->pdcp_read_header.inst] + if (pdcp_netlink_nb_element_enb[module_id] > PDCP_QUEUE_NB_ELEMENTS) { - LOG_E(PDCP, "[NETLINK_THREAD][Inst %02x] We reached maximum number of elements in eNB pdcp queue (%d)\n", - new_data_p->pdcp_read_header.inst, pdcp_netlink_nb_element_enb); + LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in eNB pdcp queue (%d)\n", + module_id, pdcp_netlink_nb_element_enb); } - LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for eNB instance %d\n", new_data_p->pdcp_read_header.inst); + LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for eNB module id %d\n", module_id); /* Enqueue the element in the right queue */ - lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_enb[new_data_p->pdcp_read_header.inst], new_data_p); + lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_enb[module_id], new_data_p); stop_meas(&ip_pdcp_stats_tmp); - copy_meas(&eNB_pdcp_stats[new_data_p->pdcp_read_header.inst].pdcp_ip,&ip_pdcp_stats_tmp); + copy_meas(&eNB_pdcp_stats[module_id].pdcp_ip,&ip_pdcp_stats_tmp); } else { - if (pdcp_netlink_nb_element_ue[new_data_p->pdcp_read_header.inst] + if (pdcp_netlink_nb_element_ue[module_id] > PDCP_QUEUE_NB_ELEMENTS) { - LOG_E(PDCP, "[NETLINK_THREAD][Inst %02x] We reached maximum number of elements in UE pdcp queue (%d)\n", - new_data_p->pdcp_read_header.inst, pdcp_netlink_nb_element_ue); + LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in UE pdcp queue (%d)\n", + module_id, pdcp_netlink_nb_element_ue); } - LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for UE instance %d\n", new_data_p->pdcp_read_header.inst); + LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for UE module id %d\n", module_id); /* Enqueue the element in the right queue */ - lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_ue[new_data_p->pdcp_read_header.inst], new_data_p); + lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_ue[module_id], new_data_p); stop_meas(&ip_pdcp_stats_tmp); - copy_meas(&UE_pdcp_stats[new_data_p->pdcp_read_header.inst].pdcp_ip,&ip_pdcp_stats_tmp); + copy_meas(&UE_pdcp_stats[module_id].pdcp_ip,&ip_pdcp_stats_tmp); } } } @@ -306,3 +321,4 @@ void *pdcp_netlink_thread_fct(void *arg) return NULL; } +#endif diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.c index a2765c2a116..7ecf4833321 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.c @@ -53,8 +53,9 @@ uint8_t pdcp_get_dc_filed(unsigned char* pdu_buffer) { uint8_t dc = 0x00; - if (pdu_buffer == NULL) + if (pdu_buffer == NULL) { return 0; + } dc = (uint8_t)pdu_buffer[0] & 0xF0; // Reset D/C field dc >>= 8; // FIXME this is broken!!! returns 0 all the time @@ -73,8 +74,9 @@ uint16_t pdcp_get_sequence_number_of_pdu_with_long_sn(unsigned char* pdu_buffer) { uint16_t sequence_number = 0x00; - if (pdu_buffer == NULL) + if (pdu_buffer == NULL) { return 0; + } /* * First octet carries the first 4 bits of SN (see 6.2.3) @@ -98,8 +100,9 @@ uint16_t pdcp_get_sequence_number_of_pdu_with_long_sn(unsigned char* pdu_buffer) */ uint8_t pdcp_get_sequence_number_of_pdu_with_short_sn(unsigned char* pdu_buffer) { - if (pdu_buffer == NULL) + if (pdu_buffer == NULL) { return 0; + } /* * First octet carries all 7 bits of SN (see 6.2.4) @@ -115,8 +118,9 @@ uint8_t pdcp_get_sequence_number_of_pdu_with_short_sn(unsigned char* pdu_buffer) */ uint8_t pdcp_get_sequence_number_of_pdu_with_SRB_sn(unsigned char* pdu_buffer) { - if (pdu_buffer == NULL) + if (pdu_buffer == NULL) { return 0; + } /* * First octet carries all 5 bits of SN (see 6.2.4) @@ -132,8 +136,9 @@ uint8_t pdcp_get_sequence_number_of_pdu_with_SRB_sn(unsigned char* pdu_buffer) boolean_t pdcp_serialize_control_plane_data_pdu_with_SRB_sn_buffer(unsigned char* pdu_buffer, \ pdcp_control_plane_data_pdu_header* pdu) { - if (pdu_buffer == NULL || pdu == NULL) + if (pdu_buffer == NULL || pdu == NULL) { return FALSE; + } /* * Fill the Sequence Number field @@ -153,8 +158,9 @@ boolean_t pdcp_serialize_control_plane_data_pdu_with_SRB_sn_buffer(unsigned char boolean_t pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer(unsigned char* pdu_buffer, \ pdcp_user_plane_data_pdu_header_with_long_sn* pdu) { - if (pdu_buffer == NULL || pdu == NULL) + if (pdu_buffer == NULL || pdu == NULL) { return FALSE; + } /* * Fill the Sequence Number field @@ -185,8 +191,9 @@ boolean_t pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer(unsigned char* boolean_t pdcp_serialize_control_pdu_for_pdcp_status_report(unsigned char* pdu_buffer, \ uint8_t bitmap[512], pdcp_control_pdu_for_pdcp_status_report* pdu) { - if (pdu_buffer == NULL || pdu == NULL) + if (pdu_buffer == NULL || pdu == NULL) { return FALSE; + } /* * Data or Control field and PDU type (already 0x00, noop) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c index db47a674744..fcfcfb58ae8 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c @@ -45,8 +45,9 @@ */ boolean_t pdcp_init_seq_numbers(pdcp_t* pdcp_entity) { - if (pdcp_entity == NULL) + if (pdcp_entity == NULL) { return FALSE; + } /* Sequence number state variables */ @@ -67,8 +68,9 @@ boolean_t pdcp_init_seq_numbers(pdcp_t* pdcp_entity) boolean_t pdcp_is_seq_num_size_valid(pdcp_t* pdcp_entity) { - if (pdcp_entity == NULL) + if (pdcp_entity == NULL) { return FALSE; + } // Check if the size of SN is valid (see 3GPP TS 36.323 v10.1.0 item 6.3.2) if (pdcp_entity->seq_num_size != 5 && pdcp_entity->seq_num_size != 7 && pdcp_entity->seq_num_size != 12) { @@ -84,8 +86,9 @@ boolean_t pdcp_is_seq_num_size_valid(pdcp_t* pdcp_entity) */ boolean_t pdcp_is_seq_num_valid(uint16_t seq_num, uint8_t seq_num_size) { - if (seq_num >= 0 && seq_num <= pdcp_calculate_max_seq_num_for_given_size(seq_num_size)) + if (seq_num >= 0 && seq_num <= pdcp_calculate_max_seq_num_for_given_size(seq_num_size)) { return TRUE; + } return FALSE; } @@ -101,8 +104,9 @@ uint16_t pdcp_calculate_max_seq_num_for_given_size(uint8_t seq_num_size) uint16_t pdcp_get_next_tx_seq_number(pdcp_t* pdcp_entity) { - if (pdcp_is_seq_num_size_valid(pdcp_entity) == FALSE) + if (pdcp_is_seq_num_size_valid(pdcp_entity) == FALSE) { return -1; + } // Sequence number should be incremented after it is assigned for a PDU uint16_t pdcp_seq_num = pdcp_entity->next_pdcp_tx_sn; @@ -124,8 +128,9 @@ uint16_t pdcp_get_next_tx_seq_number(pdcp_t* pdcp_entity) boolean_t pdcp_advance_rx_window(pdcp_t* pdcp_entity) { - if (pdcp_is_seq_num_size_valid(pdcp_entity) == FALSE) + if (pdcp_is_seq_num_size_valid(pdcp_entity) == FALSE) { return FALSE; + } /* * Update sequence numbering state and Hyper Frame Number if SN has already reached @@ -159,8 +164,9 @@ boolean_t pdcp_is_rx_seq_number_valid(uint16_t seq_num, pdcp_t* pdcp_entity,srb_ LOG_D(PDCP, "Incoming RX Sequence number is %04d\n", seq_num); #endif - if (pdcp_is_seq_num_size_valid(pdcp_entity) == FALSE || pdcp_is_seq_num_valid(seq_num, pdcp_entity->seq_num_size) == FALSE) + if (pdcp_is_seq_num_size_valid(pdcp_entity) == FALSE || pdcp_is_seq_num_valid(seq_num, pdcp_entity->seq_num_size) == FALSE) { return FALSE; + } /* * Mark received sequence numbers to keep track of missing ones @@ -196,8 +202,9 @@ boolean_t pdcp_is_rx_seq_number_valid(uint16_t seq_num, pdcp_t* pdcp_entity,srb_ pdcp_entity->next_pdcp_rx_sn_before_integrity = pdcp_entity->next_pdcp_rx_sn; #if 0 - if (seq_num != pdcp_entity->next_pdcp_rx_sn) + if (seq_num != pdcp_entity->next_pdcp_rx_sn) { LOG_D(PDCP,"Re-adjusting the sequence number to %d\n", seq_num); + } #endif //set Next_PDCP_RX_SN to the received PDCP SN +1 ; @@ -206,10 +213,11 @@ boolean_t pdcp_is_rx_seq_number_valid(uint16_t seq_num, pdcp_t* pdcp_entity,srb_ } else { // DRB - if (pdcp_entity->seq_num_size == PDCP_SN_7BIT) + if (pdcp_entity->seq_num_size == PDCP_SN_7BIT) { reordering_window = REORDERING_WINDOW_SN_7BIT; - else + } else { reordering_window = REORDERING_WINDOW_SN_12BIT; + } switch (pdcp_entity->rlc_mode) { case RLC_MODE_AM: @@ -232,7 +240,6 @@ boolean_t pdcp_is_rx_seq_number_valid(uint16_t seq_num, pdcp_t* pdcp_entity,srb_ // discard this PDCP SDU; LOG_W(PDCP, "Out of the reordering window (Incoming SN:%d, Expected SN:%d): discard this PDCP SDU\n", seq_num, pdcp_entity->next_pdcp_rx_sn); - return FALSE; } else if (pdcp_entity->next_pdcp_rx_sn - seq_num > reordering_window) { pdcp_entity->rx_hfn++; @@ -259,8 +266,9 @@ boolean_t pdcp_is_rx_seq_number_valid(uint16_t seq_num, pdcp_t* pdcp_entity,srb_ break; case RLC_MODE_UM : - if (seq_num < pdcp_entity->next_pdcp_rx_sn) + if (seq_num < pdcp_entity->next_pdcp_rx_sn) { pdcp_entity->rx_hfn++; + } // decipher the PDCP Data PDU using COUNT based on RX_HFN and the received PDCP SN as specified in the subclause 5.6; //set Next_PDCP_RX_SN to the received PDCP SN +1 ; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c index bd9449270f2..936566c8e17 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c @@ -149,10 +149,11 @@ void cleanup_pdcp_thread(void) pdcp_instance_cnt = 0; - if (pthread_cond_signal(&pdcp_cond) != 0) + if (pthread_cond_signal(&pdcp_cond) != 0) { LOG_I(PDCP,"ERROR pthread_cond_signal\n"); - else + } else { LOG_I(PDCP,"Signalled PDCP thread to exit\n"); + } pthread_join(pdcp_thread,&status_p); LOG_I(PDCP,"PDCP thread exited\n"); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c index 3fbba66460e..0790244fbb3 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c @@ -79,8 +79,9 @@ void util_print_hex_octets(comp_name_t component, unsigned char* data, unsigned */ unsigned char index; - for (index = octet_index; index < 16; ++index) + for (index = octet_index; index < 16; ++index) { LOG_T(component, " "); + } LOG_T(component, " \n"); } diff --git a/openair2/LAYER2/RLC/AM/rlc_am.c b/openair2/LAYER2/RLC/AM/rlc_am.c index b6f35c38e80..bea1cfff8d9 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am.c +++ b/openair2/LAYER2/RLC/AM/rlc_am.c @@ -98,7 +98,8 @@ rlc_am_get_buffer_occupancy_in_bytes_ch2 (struct rlc_am_entity * rlcP) { //----------------------------------------------------------------------------- #ifdef DEBUG_RLC_AM_BO - msg ("[RLC_AM][RB %d] DCCH BO: CONTROL %d DCCH %d\n", rlcP->rb_id, rlcP->control.nb_elements * rlcP->pdu_size, rlcP->pdus_to_mac_layer_ch2.nb_elements * rlcP->pdu_size); + msg ("[RLC_AM][RB %d] DCCH BO: CONTROL %d DCCH %d\n", rlcP->rb_id, rlcP->control.nb_elements * rlcP->pdu_size, + rlcP->pdus_to_mac_layer_ch2.nb_elements * rlcP->pdu_size); #endif return rlcP->control.nb_elements * rlcP->pdu_size + rlcP->pdus_to_mac_layer_ch2.nb_elements * rlcP->pdu_size; } @@ -172,7 +173,8 @@ rlc_am_get_pdus (void *argP, uint8_t traffic_typeP) if (rlc_am_send_status (rlc) > 0) { rlc->send_status_pdu_requested = 0; } - } else if ((rlc->timer_status_periodic) && ((Mac_rlc_xface->frame % (rlc->timer_status_periodic / 10)) == 0) && (rlc->last_tx_status_frame != Mac_rlc_xface->frame)) { + } else if ((rlc->timer_status_periodic) && ((Mac_rlc_xface->frame % (rlc->timer_status_periodic / 10)) == 0) + && (rlc->last_tx_status_frame != Mac_rlc_xface->frame)) { // may be MAC can poll RLC more than once in a time frame //msg ("[RLC_AM][RB %d] SEND STATUS PERIODIC frame %d\n", rlc->rb_id, Mac_rlc_xface->frame); if (rlc_am_send_status (rlc) > 0) { @@ -390,7 +392,8 @@ rlc_am_mac_status_indication (void *rlcP, uint16_t no_tbP, uint16_t tb_sizeP, st status_resp.buffer_occupancy_in_bytes = status_resp.buffer_occupancy_in_pdus * (rlc)->pdu_size; status_resp.rlc_info.rlc_protocol_state = (rlc)->protocol_state; #ifdef DEBUG_RLC_AM_TX - msg ("[RLC_AM][RB %d] MAC_STATUS_INDICATION %d TBs -> MAC_STATUS_RESPONSE %d TBs FRAME %d\n", rlc->rb_id, no_tbP, status_resp.buffer_occupancy_in_pdus,Mac_rlc_xface->frame); + msg ("[RLC_AM][RB %d] MAC_STATUS_INDICATION %d TBs -> MAC_STATUS_RESPONSE %d TBs FRAME %d\n", rlc->rb_id, no_tbP, status_resp.buffer_occupancy_in_pdus, + Mac_rlc_xface->frame); #endif return status_resp; } @@ -411,7 +414,8 @@ rlc_am_mac_status_indication_on_first_channel (void *rlcP, uint16_t no_tbP, uint status_resp.buffer_occupancy_in_bytes = status_resp.buffer_occupancy_in_pdus * ((struct rlc_am_entity *) rlcP)->pdu_size; status_resp.rlc_info.rlc_protocol_state = ((struct rlc_am_entity *) rlcP)->protocol_state; #ifdef DEBUG_RLC_AM_TX - msg ("[RLC_AM][RB %d] CHANNEL 1 MAC_STATUS_INDICATION (DATA) %d TBs -> MAC_STATUS_RESPONSE %d TBs\n", ((struct rlc_am_entity *) rlcP)->rb_id, no_tbP, status_resp.buffer_occupancy_in_pdus); + msg ("[RLC_AM][RB %d] CHANNEL 1 MAC_STATUS_INDICATION (DATA) %d TBs -> MAC_STATUS_RESPONSE %d TBs\n", ((struct rlc_am_entity*) rlcP)->rb_id, no_tbP, + status_resp.buffer_occupancy_in_pdus); #endif return status_resp; } @@ -432,7 +436,8 @@ rlc_am_mac_status_indication_on_second_channel (void *rlcP, uint16_t no_tbP, uin status_resp.buffer_occupancy_in_bytes = status_resp.buffer_occupancy_in_pdus * ((struct rlc_am_entity *) rlcP)->pdu_size; status_resp.rlc_info.rlc_protocol_state = ((struct rlc_am_entity *) rlcP)->protocol_state; #ifdef DEBUG_RLC_AM_TX - msg ("[RLC_AM][RB %d] CHANNEL 2 MAC_STATUS_INDICATION (CONTROL) %d TBs -> MAC_STATUS_RESPONSE %d TBs\n", ((struct rlc_am_entity *) rlcP)->rb_id, no_tbP, status_resp.buffer_occupancy_in_pdus); + msg ("[RLC_AM][RB %d] CHANNEL 2 MAC_STATUS_INDICATION (CONTROL) %d TBs -> MAC_STATUS_RESPONSE %d TBs\n", ((struct rlc_am_entity*) rlcP)->rb_id, no_tbP, + status_resp.buffer_occupancy_in_pdus); #endif return status_resp; } diff --git a/openair2/LAYER2/RLC/AM/rlc_am_control_primitives.c b/openair2/LAYER2/RLC/AM/rlc_am_control_primitives.c index 6b66a7b93d4..24d17e26b88 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_control_primitives.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_control_primitives.c @@ -47,15 +47,15 @@ #include "rrm_config_structs.h" #include "LAYER2/MAC/extern.h" //----------------------------------------------------------------------------- -void config_req_rlc_am (struct rlc_am_entity *rlcP, module_id_t module_idP, rlc_am_info_t * config_amP, uint8_t rb_idP, rb_type_t rb_typeP); -void send_rlc_am_control_primitive (struct rlc_am_entity *rlcP, module_id_t module_idP, mem_block_t * cprimitiveP); -void init_rlc_am (struct rlc_am_entity *rlcP); -void rlc_am_reset_state_variables (struct rlc_am_entity *rlcP); -void rlc_am_alloc_buffers_after_establishment (struct rlc_am_entity *rlcP); -void rlc_am_discard_all_pdus (struct rlc_am_entity *rlcP); -void rlc_am_stop_all_timers (struct rlc_am_entity *rlcP); -void rlc_am_free_all_resources (struct rlc_am_entity *rlcP); -void rlc_am_set_configured_parameters (struct rlc_am_entity *rlcP, mem_block_t * cprimitiveP); +void config_req_rlc_am (struct rlc_am_entity* rlcP, module_id_t module_idP, rlc_am_info_t* config_amP, uint8_t rb_idP, rb_type_t rb_typeP); +void send_rlc_am_control_primitive (struct rlc_am_entity* rlcP, module_id_t module_idP, mem_block_t* cprimitiveP); +void init_rlc_am (struct rlc_am_entity* rlcP); +void rlc_am_reset_state_variables (struct rlc_am_entity* rlcP); +void rlc_am_alloc_buffers_after_establishment (struct rlc_am_entity* rlcP); +void rlc_am_discard_all_pdus (struct rlc_am_entity* rlcP); +void rlc_am_stop_all_timers (struct rlc_am_entity* rlcP); +void rlc_am_free_all_resources (struct rlc_am_entity* rlcP); +void rlc_am_set_configured_parameters (struct rlc_am_entity* rlcP, mem_block_t* cprimitiveP); //void rlc_am_probing_get_buffer_occupancy_measurements (struct rlc_am_entity *rlcP, probing_report_traffic_rb_parameters *reportP, int measurement_indexP); //----------------------------------------------------------------------------- /*void @@ -70,51 +70,48 @@ rlc_am_probing_get_buffer_occupancy_measurements (struct rlc_am_entity *rlcP, pr }*/ //----------------------------------------------------------------------------- void -config_req_rlc_am (struct rlc_am_entity *rlcP, module_id_t module_idP, rlc_am_info_t * config_amP, uint8_t rb_idP, rb_type_t rb_typeP) +config_req_rlc_am (struct rlc_am_entity* rlcP, module_id_t module_idP, rlc_am_info_t* config_amP, uint8_t rb_idP, rb_type_t rb_typeP) { //----------------------------------------------------------------------------- - mem_block_t *mb; - + mem_block_t* mb; mb = get_free_mem_block (sizeof (struct crlc_primitive)); - ((struct crlc_primitive *) mb->data)->type = CRLC_CONFIG_REQ; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.e_r = RLC_E_R_ESTABLISHMENT; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.stop = 0; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.cont = 1; - + ((struct crlc_primitive*) mb->data)->type = CRLC_CONFIG_REQ; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.e_r = RLC_E_R_ESTABLISHMENT; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.stop = 0; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.cont = 1; // timers - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_poll = config_amP->timer_poll; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_poll_prohibit = config_amP->timer_poll_prohibit; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_discard = config_amP->timer_discard; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_poll_periodic = config_amP->timer_poll_periodic; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_status_prohibit = config_amP->timer_status_prohibit; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_status_periodic = config_amP->timer_status_periodic; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_rst = config_amP->timer_rst; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.max_rst = config_amP->max_rst; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_mrw = config_amP->timer_mrw; - + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_poll = config_amP->timer_poll; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_poll_prohibit = config_amP->timer_poll_prohibit; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_discard = config_amP->timer_discard; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_poll_periodic = config_amP->timer_poll_periodic; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_status_prohibit = config_amP->timer_status_prohibit; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_status_periodic = config_amP->timer_status_periodic; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_rst = config_amP->timer_rst; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.max_rst = config_amP->max_rst; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.timer_mrw = config_amP->timer_mrw; // protocol_parameters - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.pdu_size = config_amP->pdu_size; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.max_dat = config_amP->max_dat; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.poll_pdu = config_amP->poll_pdu; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.poll_sdu = config_amP->poll_sdu; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.poll_window = config_amP->poll_window; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.configured_tx_window_size = config_amP->tx_window_size; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.configured_rx_window_size = config_amP->rx_window_size; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.max_mrw = config_amP->max_mrw; - - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.last_transmission_pdu_poll_trigger = config_amP->last_transmission_pdu_poll_trigger; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.last_retransmission_pdu_poll_trigger = config_amP->last_retransmission_pdu_poll_trigger; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.sdu_discard_mode = config_amP->sdu_discard_mode; - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.send_mrw = config_amP->send_mrw; - - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.frame_tick_milliseconds = &mac_xface->frame; - - ((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.am_parameters.rb_id = rb_idP; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.pdu_size = config_amP->pdu_size; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.max_dat = config_amP->max_dat; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.poll_pdu = config_amP->poll_pdu; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.poll_sdu = config_amP->poll_sdu; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.poll_window = config_amP->poll_window; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.configured_tx_window_size = config_amP->tx_window_size; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.configured_rx_window_size = config_amP->rx_window_size; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.max_mrw = config_amP->max_mrw; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.last_transmission_pdu_poll_trigger = + config_amP->last_transmission_pdu_poll_trigger; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.last_retransmission_pdu_poll_trigger = + config_amP->last_retransmission_pdu_poll_trigger; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.sdu_discard_mode = config_amP->sdu_discard_mode; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.send_mrw = config_amP->send_mrw; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.frame_tick_milliseconds = &mac_xface->frame; + ((struct crlc_primitive*) mb->data)->primitive.c_config_req.parameters.am_parameters.rb_id = rb_idP; send_rlc_am_control_primitive (rlcP, module_idP, mb); if (rb_typeP != SIGNALLING_RADIO_BEARER) { rlcP->data_plane = 1; msg ("[RLC AM][RB %d] DATA PLANE\n", rlcP->rb_id); + } else { rlcP->data_plane = 0; msg ("[RLC AM][RB %d] CONTROL PLANE\n", rlcP->rb_id); @@ -122,16 +119,14 @@ config_req_rlc_am (struct rlc_am_entity *rlcP, module_id_t module_idP, rlc_am_in } //----------------------------------------------------------------------------- void -send_rlc_am_control_primitive (struct rlc_am_entity *rlcP, module_id_t module_idP, mem_block_t * cprimitiveP) +send_rlc_am_control_primitive (struct rlc_am_entity* rlcP, module_id_t module_idP, mem_block_t* cprimitiveP) { //----------------------------------------------------------------------------- rlcP->module_id = module_idP; - switch (((struct crlc_primitive *) cprimitiveP->data)->type) { + switch (((struct crlc_primitive*) cprimitiveP->data)->type) { case CRLC_CONFIG_REQ: - - switch (((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.e_r) { - + switch (((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.e_r) { case RLC_E_R_ESTABLISHMENT: if (rlc_am_fsm_notify_event (rlcP, RLC_AM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { rlc_am_set_configured_parameters (rlcP, cprimitiveP); // the order of the calling of procedures... @@ -191,7 +186,6 @@ send_rlc_am_control_primitive (struct rlc_am_entity *rlcP, module_id_t module_id // - not send AMD PDUs with sequence number SNVT(S)+N. if (rlc_am_fsm_notify_event (rlcP, RLC_AM_RECEIVE_CRLC_SUSPEND_REQ_EVENT)) { if ((rlcP->protocol_state == RLC_LOCAL_SUSPEND_STATE) || (rlcP->protocol_state == RLC_LOCAL_SUSPEND_STATE)) { - // TO DO IN FUTURE, BUT IT SEEMS THERE IS NO NEED TO IMPLEMENT THIS FUNCTION IN THE CURRENTLY DEFINED ARCHITECTURE // SO DISPLAY ERROR MESSAGE msg ("[RLC_AM[RB %d] ERROR RECEIVED CRLC_SUSPEND_REQ NOT IMPLEMENTED AT ALL, RLC_AM MAY NOT WORK AS EXPECTED IN THE 3GPP SPECIFICATION\n", rlcP->rb_id); @@ -211,7 +205,6 @@ send_rlc_am_control_primitive (struct rlc_am_entity *rlcP, module_id_t module_id // - resume the RLC reset procedure according to subclause 11.4. if (rlc_am_fsm_notify_event (rlcP, RLC_AM_RECEIVE_CRLC_RESUME_REQ_EVENT)) { if ((rlcP->protocol_state == RLC_RESET_PENDING_STATE) || (rlcP->protocol_state == RLC_DATA_TRANSFER_READY_STATE)) { - // TO DO IN FUTURE, BUT IT SEEMS THERE IS NO NEED TO IMPLEMENT THIS FUNCTION IN THE CURRENTLY DEFINED ARCHITECTURE // SO DISPLAY ERROR MESSAGE msg ("[RLC_AM][RB %d] ERROR RECEIVED CRLC_RESUME_REQ NOT IMPLEMENTED AT ALL, RLC_AM MAY NOT WORK AS EXPECTED IN THE 3GPP SPECIFICATION\n", rlcP->rb_id); @@ -229,12 +222,10 @@ send_rlc_am_control_primitive (struct rlc_am_entity *rlcP, module_id_t module_id //----------------------------------------------------------------------------- void -init_rlc_am (struct rlc_am_entity *rlcP) +init_rlc_am (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- memset (rlcP, 0, sizeof (struct rlc_am_entity)); - - list2_init (&rlcP->retransmission_buffer_to_send, NULL); list_init (&rlcP->pdus_to_mac_layer_ch1, NULL); list_init (&rlcP->pdus_to_mac_layer_ch2, NULL); @@ -245,17 +236,13 @@ init_rlc_am (struct rlc_am_entity *rlcP) list2_init (&rlcP->sdu_discard_segmented, NULL); list2_init (&rlcP->sdu_discarded, NULL); list2_init (&rlcP->rlc_am_timer_list, NULL); - rlcP->protocol_state = RLC_NULL_STATE; - rlcP->next_sdu_index = 0; rlcP->current_sdu_index = 0; rlcP->last_received_rsn = 0xFF; - //-------------------------------------------------------------------------- rlcP->discard_reassembly_after_li = RLC_AM_DISCARD_REASSEMBLY_AT_LI_INDEX_0; rlcP->discard_reassembly_start_sn = RLC_AM_SN_INVALID; // =>not activated - rlcP->stat_tx_pdcp_sdu = 0; rlcP->stat_tx_pdcp_sdu_discarded = 0; rlcP->stat_tx_retransmit_pdu_unblock = 0; @@ -271,7 +258,7 @@ init_rlc_am (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_alloc_buffers_after_establishment (struct rlc_am_entity *rlcP) +rlc_am_alloc_buffers_after_establishment (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- rlcP->recomputed_configured_tx_window_size = 1; @@ -280,37 +267,34 @@ rlc_am_alloc_buffers_after_establishment (struct rlc_am_entity *rlcP) rlcP->recomputed_configured_tx_window_size = rlcP->recomputed_configured_tx_window_size << 1; } - rlcP->retransmission_buffer_alloc = get_free_mem_block (rlcP->recomputed_configured_tx_window_size * sizeof (mem_block_t *)); - rlcP->retransmission_buffer = (mem_block_t **) (rlcP->retransmission_buffer_alloc->data); + rlcP->retransmission_buffer_alloc = get_free_mem_block (rlcP->recomputed_configured_tx_window_size * sizeof (mem_block_t*)); + rlcP->retransmission_buffer = (mem_block_t**) (rlcP->retransmission_buffer_alloc->data); //memset (rlcP->retransmission_buffer, 0, rlcP->recomputed_configured_tx_window_size * sizeof (mem_block_t *)); - rlcP->recomputed_configured_rx_window_size = 1; while (rlcP->recomputed_configured_rx_window_size < rlcP->configured_rx_window_size) { rlcP->recomputed_configured_rx_window_size = rlcP->recomputed_configured_rx_window_size << 1; } - rlcP->receiver_buffer_alloc = get_free_mem_block (rlcP->recomputed_configured_rx_window_size * sizeof (mem_block_t *)); - rlcP->receiver_buffer = (mem_block_t **) (rlcP->receiver_buffer_alloc->data); + rlcP->receiver_buffer_alloc = get_free_mem_block (rlcP->recomputed_configured_rx_window_size * sizeof (mem_block_t*)); + rlcP->receiver_buffer = (mem_block_t**) (rlcP->receiver_buffer_alloc->data); msg("[RLC AM][RB %d] Window size %d\n",rlcP->rb_id,rlcP->recomputed_configured_rx_window_size); //memset (rlcP->receiver_buffer, 0, rlcP->recomputed_configured_rx_window_size * sizeof (mem_block_t *)); - rlcP->holes_alloc = get_free_mem_block ((rlcP->recomputed_configured_rx_window_size * sizeof (struct rlc_am_hole)) >> 1); - rlcP->holes = (struct rlc_am_hole *) (rlcP->holes_alloc->data); + rlcP->holes = (struct rlc_am_hole*) (rlcP->holes_alloc->data); //memset (rlcP->holes_alloc->data, 0, (rlcP->recomputed_configured_rx_window_size * sizeof (mem_block_t *)) >> 1); - rlcP->size_input_sdus_buffer = rlcP->recomputed_configured_tx_window_size * 4; if ((rlcP->input_sdus_alloc == NULL)) { - rlcP->input_sdus_alloc = get_free_mem_block (rlcP->size_input_sdus_buffer * sizeof (void *)); - rlcP->input_sdus = (mem_block_t **) (rlcP->input_sdus_alloc->data); + rlcP->input_sdus_alloc = get_free_mem_block (rlcP->size_input_sdus_buffer * sizeof (void*)); + rlcP->input_sdus = (mem_block_t**) (rlcP->input_sdus_alloc->data); //memset (rlcP->input_sdus, 0, rlcP->size_input_sdus_buffer * sizeof (void *)); } } //----------------------------------------------------------------------------- void -rlc_am_reset_state_variables (struct rlc_am_entity *rlcP) +rlc_am_reset_state_variables (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- rlcP->vt_s = 0; @@ -351,13 +335,12 @@ rlc_am_reset_state_variables (struct rlc_am_entity *rlcP) rlcP->current_sdu_index = 0; rlcP->nb_pdu_requested_by_mac_on_ch1 = 0; rlcP->nb_pdu_requested_by_mac_on_ch2 = 0; - rlcP->running_timer_status_prohibit = rlcP->timer_status_prohibit/10; } //----------------------------------------------------------------------------- void -rlc_am_stop_all_timers (struct rlc_am_entity *rlcP) +rlc_am_stop_all_timers (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- list2_free (&rlcP->rlc_am_timer_list); @@ -365,11 +348,10 @@ rlc_am_stop_all_timers (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_discard_all_pdus (struct rlc_am_entity *rlcP) +rlc_am_discard_all_pdus (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- uint16_t index; - index = 0; while (index < rlcP->recomputed_configured_rx_window_size) { @@ -405,7 +387,7 @@ rlc_am_discard_all_pdus (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_free_all_resources (struct rlc_am_entity *rlcP) +rlc_am_free_all_resources (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- int index; @@ -444,54 +426,57 @@ rlc_am_free_all_resources (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_set_configured_parameters (struct rlc_am_entity *rlcP, mem_block_t * cprimitiveP) +rlc_am_set_configured_parameters (struct rlc_am_entity* rlcP, mem_block_t* cprimitiveP) { //----------------------------------------------------------------------------- // timers //rlcP->timer_poll_trigger = ((struct crlc_primitive *)cprimitiveP->data)->cprimitive.c_config_req.parameters.am_parameters.timer_poll; //rlcP-> = ((struct crlc_primitive *)cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_poll_prohibit; - rlcP->timer_discard_init = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_discard; - rlcP->timer_poll_periodic_init = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_poll_periodic; - rlcP-> timer_status_prohibit = ((struct crlc_primitive *)cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_status_prohibit; - rlcP->timer_status_periodic = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_status_periodic; - rlcP->timer_rst_init = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_rst; - rlcP->max_rst = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.max_rst; - rlcP->timer_mrw_init = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_mrw; - + rlcP->timer_discard_init = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_discard; + rlcP->timer_poll_periodic_init = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_poll_periodic; + rlcP-> timer_status_prohibit = ((struct crlc_primitive*)cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_status_prohibit; + rlcP->timer_status_periodic = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_status_periodic; + rlcP->timer_rst_init = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_rst; + rlcP->max_rst = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.max_rst; + rlcP->timer_mrw_init = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.timer_mrw; // protocol_parameters - rlcP->pdu_size = (((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.pdu_size + 7) >> 3; - rlcP->max_dat = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.max_dat; - rlcP->missing_pdu_indicator = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.missing_pdu_indicator; - rlcP->poll_pdu_trigger = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.poll_pdu; - rlcP->poll_sdu_trigger = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.poll_sdu; - rlcP->last_transmission_pdu_poll_trigger = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.last_transmission_pdu_poll_trigger; - rlcP->last_retransmission_pdu_poll_trigger = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.last_retransmission_pdu_poll_trigger; - rlcP->poll_window_trigger = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.poll_window; - rlcP->configured_tx_window_size = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.configured_tx_window_size; - rlcP->configured_rx_window_size = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.configured_rx_window_size; - rlcP->max_mrw = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.max_mrw; - rlcP->sdu_discard_mode = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.sdu_discard_mode; - rlcP->send_mrw = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.send_mrw; - + rlcP->pdu_size = (((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.pdu_size + 7) >> 3; + rlcP->max_dat = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.max_dat; + rlcP->missing_pdu_indicator = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.missing_pdu_indicator; + rlcP->poll_pdu_trigger = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.poll_pdu; + rlcP->poll_sdu_trigger = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.poll_sdu; + rlcP->last_transmission_pdu_poll_trigger = ((struct crlc_primitive*) + cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.last_transmission_pdu_poll_trigger; + rlcP->last_retransmission_pdu_poll_trigger = ((struct crlc_primitive*) + cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.last_retransmission_pdu_poll_trigger; + rlcP->poll_window_trigger = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.poll_window; + rlcP->configured_tx_window_size = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.configured_tx_window_size; + rlcP->configured_rx_window_size = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.configured_rx_window_size; + rlcP->max_mrw = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.max_mrw; + rlcP->sdu_discard_mode = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.sdu_discard_mode; + rlcP->send_mrw = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.send_mrw; // SPARE : not 3GPP - rlcP->rb_id = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.rb_id; - rlcP->frame_tick_milliseconds = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.frame_tick_milliseconds; + rlcP->rb_id = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.rb_id; + rlcP->frame_tick_milliseconds = ((struct crlc_primitive*) cprimitiveP->data)->primitive.c_config_req.parameters.am_parameters.frame_tick_milliseconds; rlcP->nb_logical_channels_per_rlc =1; if (rlcP->pdu_size > 126) { rlcP->rlc_segment = rlc_am_segment_15; + } else { rlcP->rlc_segment = rlc_am_segment_7; } if (rlcP->sdu_discard_mode == SDU_DISCARD_MODE_RESET) { msg ("[RLC AM][RB %d] SDU DISCARD RESET CONFIGURED\n", rlcP->rb_id); + } else if (rlcP->sdu_discard_mode == SDU_DISCARD_MODE_TIMER_BASED_EXPLICIT) { msg ("[RLC AM][RB %d] SDU DISCARD TIMER BASED EXPLICIT SIGNALING CONFIGURED\n", rlcP->rb_id); + } else if (rlcP->sdu_discard_mode == SDU_DISCARD_MODE_MAX_DAT_RETRANSMISSION) { msg ("[RLC AM][RB %d] SDU DISCARD MAX RETRANSMISSION CONFIGURED\n", rlcP->rb_id); + } else if (rlcP->sdu_discard_mode == SDU_DISCARD_MODE_NOT_CONFIGURED) { msg ("[RLC AM][RB %d] SDU DISCARD NOT CONFIGURED\n", rlcP->rb_id); } - } diff --git a/openair2/LAYER2/RLC/AM/rlc_am_discard_notif.c b/openair2/LAYER2/RLC/AM/rlc_am_discard_notif.c index 409791c67e1..5955284e88f 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_discard_notif.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_discard_notif.c @@ -46,14 +46,14 @@ #include "rlc_am_reset_proto_extern.h" #include "LAYER2/MAC/extern.h" //----------------------------------------------------------------------------- -void rlc_am_discard_notify_mrw_ack_time_out (struct rlc_am_entity *rlcP, mem_block_t * discard_procedureP); -void rlc_am_discard_notify_sdu_time_out (struct rlc_am_entity *rlcP, mem_block_t * sduP); -void rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * mbP); +void rlc_am_discard_notify_mrw_ack_time_out (struct rlc_am_entity* rlcP, mem_block_t* discard_procedureP); +void rlc_am_discard_notify_sdu_time_out (struct rlc_am_entity* rlcP, mem_block_t* sduP); +void rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity* rlcP, mem_block_t* mbP); //----------------------------------------------------------------------------- // handler for timer //----------------------------------------------------------------------------- void -rlc_am_discard_notify_mrw_ack_time_out (struct rlc_am_entity *rlcP, mem_block_t * discard_procedureP) +rlc_am_discard_notify_mrw_ack_time_out (struct rlc_am_entity* rlcP, mem_block_t* discard_procedureP) { //----------------------------------------------------------------------------- /* from 3GPP TS 25.322 V5.5.0 @@ -70,7 +70,6 @@ rlc_am_discard_notify_mrw_ack_time_out (struct rlc_am_entity *rlcP, mem_block_t - stop the timer Timer_MRW; - deliver an error indication to upper layers; - initiate the RLC RESET procedure */ - rlcP->timer_mrw = NULL; #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d][DISCARD] NOTIF MRW_ACK TIME OUT VT(MRW) %d PROCEDURE %p\n", rlcP->rb_id, rlcP->vt_mrw, discard_procedureP); @@ -84,6 +83,7 @@ rlc_am_discard_notify_mrw_ack_time_out (struct rlc_am_entity *rlcP, mem_block_t msg ("[RLC_AM %p][DISCARD] NOTIF MRW_ACK TIME OUT REARM TIMER\n", rlcP); #endif rlcP->vt_mrw += 1; + } else { // TO DO : "deliver an error indication to upper layers" #ifdef DEBUG_RESET @@ -97,17 +97,18 @@ rlc_am_discard_notify_mrw_ack_time_out (struct rlc_am_entity *rlcP, mem_block_t // handler for timer //----------------------------------------------------------------------------- void -rlc_am_discard_check_sdu_time_out (struct rlc_am_entity *rlcP) +rlc_am_discard_check_sdu_time_out (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - mem_block_t *sdu; - mem_block_t *pdu; + mem_block_t* sdu; + mem_block_t* pdu; int discard_go_on; int last_removed_pdu_sn; int sn; // TIMER BASED DISCARD - if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_TIMER_BASED_EXPLICIT) && ((rlcP->protocol_state & (RLC_RESET_PENDING_STATE | RLC_RESET_AND_SUSPEND_STATE)) == 0)) { + if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_TIMER_BASED_EXPLICIT) + && ((rlcP->protocol_state & (RLC_RESET_PENDING_STATE | RLC_RESET_AND_SUSPEND_STATE)) == 0)) { /* from 3GPP TS 25.322 V5.0.0 p68 - if "Timer based SDU discard with explicit signalling" is configured: - discard all SDUs up to and including the SDU for which the timer Timer_Discard expired. @@ -131,37 +132,35 @@ rlc_am_discard_check_sdu_time_out (struct rlc_am_entity *rlcP) MRW SUFIs shall be sent before the current SDU discard with explicit signalling procedure is terminated by one of the termination criteria. */ - discard_go_on = 1; last_removed_pdu_sn = -1; while ((sdu = rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) { - if ((*rlcP->frame_tick_milliseconds - ((struct rlc_am_tx_sdu_management *) (sdu->data))->sdu_creation_time) >= rlcP->timer_discard_init) { + if ((*rlcP->frame_tick_milliseconds - ((struct rlc_am_tx_sdu_management*) (sdu->data))->sdu_creation_time) >= rlcP->timer_discard_init) { // buffer occupancy is not updated at each generation of pdu, it is only updated for a sdu when the // segmentation of this one is finished. - rlcP->buffer_occupancy -= ((struct rlc_am_tx_sdu_management *) (sdu->data))->sdu_remaining_size; + rlcP->buffer_occupancy -= ((struct rlc_am_tx_sdu_management*) (sdu->data))->sdu_remaining_size; rlcP->nb_sdu -= 1; if ((rlcP->send_mrw & RLC_AM_SEND_MRW_ON) || // the condition says if the sdu has generated one or more pdus - (((struct rlc_am_tx_sdu_management *) (sdu->data))->sdu_size != ((struct rlc_am_tx_sdu_management *) (sdu->data))->sdu_remaining_size)) { - - ((struct rlc_am_tx_sdu_management *) (sdu->data))->last_pdu_sn = rlcP->vt_s; - ((struct rlc_am_tx_sdu_management *) (sdu->data))->no_new_sdu_segmented_in_last_pdu = 1; + (((struct rlc_am_tx_sdu_management*) (sdu->data))->sdu_size != ((struct rlc_am_tx_sdu_management*) (sdu->data))->sdu_remaining_size)) { + ((struct rlc_am_tx_sdu_management*) (sdu->data))->last_pdu_sn = rlcP->vt_s; + ((struct rlc_am_tx_sdu_management*) (sdu->data))->no_new_sdu_segmented_in_last_pdu = 1; rlcP->vt_s = (rlcP->vt_s + 1) & SN_12BITS_MASK; - list2_add_tail (sdu, &rlcP->sdu_discarded); #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] SDU DISCARDED SIGNALLING YES, TIMED OUT %ld ms frame %d ", rlcP->rb_id, - (*rlcP->frame_tick_milliseconds - ((struct rlc_am_tx_sdu_management *) (sdu->data))->sdu_creation_time), Mac_rlc_xface->frame); + (*rlcP->frame_tick_milliseconds - ((struct rlc_am_tx_sdu_management*) (sdu->data))->sdu_creation_time), Mac_rlc_xface->frame); msg ("BO %d, NB SDU %d\n", rlcP->buffer_occupancy, rlcP->nb_sdu); display_protocol_vars_rlc_am (rlcP); #endif - if (((struct rlc_am_tx_sdu_management *) (sdu->data))->sdu_size != ((struct rlc_am_tx_sdu_management *) (sdu->data))->sdu_remaining_size) { + if (((struct rlc_am_tx_sdu_management*) (sdu->data))->sdu_size != ((struct rlc_am_tx_sdu_management*) (sdu->data))->sdu_remaining_size) { // some pdu have to be removed if a sdu discarded generated almost one pdu if (last_removed_pdu_sn == -1) { sn = rlcP->vt_a; + } else { sn = last_removed_pdu_sn; } @@ -170,15 +169,14 @@ rlc_am_discard_check_sdu_time_out (struct rlc_am_entity *rlcP) pdu = rlcP->retransmission_buffer[sn % rlcP->recomputed_configured_tx_window_size]; if ((pdu)) { - // now check if a copy of the pdu is not present in the retransmission_buffer_to_send - if ((((struct rlc_am_tx_data_pdu_management *) (pdu->data))->copy)) { - list2_remove_element (((struct rlc_am_tx_data_pdu_management *) (pdu->data))->copy, &rlcP->retransmission_buffer_to_send); - free_mem_block (((struct rlc_am_tx_data_pdu_management *) (pdu->data))->copy); + if ((((struct rlc_am_tx_data_pdu_management*) (pdu->data))->copy)) { + list2_remove_element (((struct rlc_am_tx_data_pdu_management*) (pdu->data))->copy, &rlcP->retransmission_buffer_to_send); + free_mem_block (((struct rlc_am_tx_data_pdu_management*) (pdu->data))->copy); } // if this pdu has been retransmitted, remove its size from buffer occupancy - if (((struct rlc_am_tx_data_pdu_management *) (pdu->data))->vt_dat > 0) { + if (((struct rlc_am_tx_data_pdu_management*) (pdu->data))->vt_dat > 0) { rlcP->buffer_occupancy_retransmission_buffer -= 1; } @@ -191,9 +189,11 @@ rlc_am_discard_check_sdu_time_out (struct rlc_am_entity *rlcP) last_removed_pdu_sn = sn; } + } else { #ifdef DEBUG_RLC_AM_DISCARD - msg ("[RLC_AM][RB %d] SDU DISCARDED SIGNALLING NO, TIMED OUT %ld ms ", rlcP->rb_id, (*rlcP->frame_tick_milliseconds - ((struct rlc_am_tx_sdu_management *) (sdu->data))->sdu_creation_time)); + msg ("[RLC_AM][RB %d] SDU DISCARDED SIGNALLING NO, TIMED OUT %ld ms ", rlcP->rb_id, + (*rlcP->frame_tick_milliseconds - ((struct rlc_am_tx_sdu_management*) (sdu->data))->sdu_creation_time)); msg ("BO %d, NB SDU %d\n", rlcP->buffer_occupancy, rlcP->nb_sdu); #endif free_mem_block (sdu); @@ -201,15 +201,15 @@ rlc_am_discard_check_sdu_time_out (struct rlc_am_entity *rlcP) if (!(rlcP->data_plane)) { #ifdef DEBUG_RLC_AM_SEND_CONFIRM - msg ("[RLC_AM][RB %d][CONFIRM] SDU MUI %d LOST IN DISCARD\n", rlcP->rb_id, ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->mui); + msg ("[RLC_AM][RB %d][CONFIRM] SDU MUI %d LOST IN DISCARD\n", rlcP->rb_id, + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->mui); #endif - rlc_data_conf (0, rlcP->rb_id, ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->mui, RLC_TX_CONFIRM_FAILURE, rlcP->data_plane); + rlc_data_conf (0, rlcP->rb_id, ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->mui, RLC_TX_CONFIRM_FAILURE, + rlcP->data_plane); } rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; - // reset variables for segmentation rlcP->li_exactly_filled_to_add_in_next_pdu = 0; rlcP->li_one_byte_short_to_add_in_next_pdu = 0; @@ -223,28 +223,23 @@ rlc_am_discard_check_sdu_time_out (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pduP) +rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity* rlcP, mem_block_t* pduP) { //----------------------------------------------------------------------------- - - struct rlc_am_tx_data_pdu_management *pdu_mngt; - struct rlc_am_tx_sdu_management *sdu_mngt; - mem_block_t *pdu; - mem_block_t *pdu2; - mem_block_t *sdu; + struct rlc_am_tx_data_pdu_management* pdu_mngt; + struct rlc_am_tx_sdu_management* sdu_mngt; + mem_block_t* pdu; + mem_block_t* pdu2; + mem_block_t* sdu; int sdu_index; int sdu_index2; int pdu_index; int last_sdu_index; int sn; - - pdu_mngt = (struct rlc_am_tx_data_pdu_management *) pduP->data; - + pdu_mngt = (struct rlc_am_tx_data_pdu_management*) pduP->data; // should never occur //if (pdu_mngt->nb_sdu == 0) return; - // discard previous SDUS - #ifdef DEBUG_RLC_AM_DISCARD_MAX_DAT msg ("[RLC_AM][RB %d] DISCARD MAX DAT PDU FRAME %d SN 0x%03X CONTAINS SDU INDEX ", rlcP->rb_id, Mac_rlc_xface->frame, pdu_mngt->sn); sdu_index = 0; @@ -255,16 +250,13 @@ rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pdu } msg ("\n"); - #endif - // From 3GPP TS25.322 V5.0.0 (2002-03) page 68 // - if "SDU discard after MaxDAT number of retransmissions" is configured: // - discard all SDUs that have segments in AMD PDUs with SN inside the interval // VT(A) <= SN <= X, where X is the value of the SN of the AMD PDU with VT(DAT) >= MaxDAT; // - if requested // - inform the upper layers of the discarded SDUs. - //--------------------------------------------------------------- // here delete all SDUs before the last sdu that have segments in the pdu discarded sdu_index = rlcP->next_sdu_index; @@ -276,15 +268,13 @@ rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pdu if (!(rlcP->data_plane)) { #ifdef DEBUG_RLC_AM_SEND_CONFIRM - - msg ("[RLC_AM][RB %d][CONFIRM] SDU MUI %d LOST IN DISCARD\n", rlcP->rb_id, ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[sdu_index]->data))->mui); + msg ("[RLC_AM][RB %d][CONFIRM] SDU MUI %d LOST IN DISCARD\n", rlcP->rb_id, ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[sdu_index]->data))->mui); #endif - rlc_data_conf (0, rlcP->rb_id, ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[sdu_index]->data))->mui, RLC_TX_CONFIRM_FAILURE, rlcP->data_plane); + rlc_data_conf (0, rlcP->rb_id, ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[sdu_index]->data))->mui, RLC_TX_CONFIRM_FAILURE, rlcP->data_plane); } rlcP->input_sdus[sdu_index] = NULL; rlcP->nb_sdu -= 1; - #ifdef DEBUG_RLC_AM_FREE_SDU msg ("[RLC_AM][RB %d] DISCARD MAX DAT FREE_SDU INDEX %d\n", rlcP->rb_id, sdu_index); #endif @@ -296,8 +286,7 @@ rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pdu //--------------------------------------------------------------- // here delete all PDUs up to and except the last of the last sdu discarded sdu = rlcP->input_sdus[sdu_index]; - sdu_mngt = (struct rlc_am_tx_sdu_management *) (sdu->data); - + sdu_mngt = (struct rlc_am_tx_sdu_management*) (sdu->data); sn = rlcP->vt_a; while (sn != sdu_mngt->last_pdu_sn) { @@ -307,16 +296,16 @@ rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pdu #endif // check if a copy of the pdu is not present in the retransmission_buffer_to_send - if ((((struct rlc_am_tx_data_pdu_management *) (pdu2->data))->copy)) { + if ((((struct rlc_am_tx_data_pdu_management*) (pdu2->data))->copy)) { #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] FREE PDU COPY ALSO\n", rlcP->rb_id); #endif - list2_remove_element (((struct rlc_am_tx_data_pdu_management *) (pdu2->data))->copy, &rlcP->retransmission_buffer_to_send); - free_mem_block (((struct rlc_am_tx_data_pdu_management *) (pdu2->data))->copy); + list2_remove_element (((struct rlc_am_tx_data_pdu_management*) (pdu2->data))->copy, &rlcP->retransmission_buffer_to_send); + free_mem_block (((struct rlc_am_tx_data_pdu_management*) (pdu2->data))->copy); } // if this pdu has been retransmitted, remove its size from buffer occupancy - if (((struct rlc_am_tx_data_pdu_management *) (pdu2->data))->vt_dat > 0) { + if (((struct rlc_am_tx_data_pdu_management*) (pdu2->data))->vt_dat > 0) { rlcP->buffer_occupancy_retransmission_buffer -= 1; } @@ -335,7 +324,7 @@ rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pdu if ((pdu)) { // search the index of the sdu passed in parameter - pdu_mngt = (struct rlc_am_tx_data_pdu_management *) pdu->data; + pdu_mngt = (struct rlc_am_tx_data_pdu_management*) pdu->data; if (pdu_mngt->sdu[pdu_mngt->nb_sdu - 1] == sdu_index) { //---------------------------------------------- @@ -353,22 +342,23 @@ rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pdu //---------------- // discard the pdu // if this pdu has been retransmitted, remove its size from buffer occupancy - if (((struct rlc_am_tx_data_pdu_management *) (pdu->data))->vt_dat > 0) { + if (((struct rlc_am_tx_data_pdu_management*) (pdu->data))->vt_dat > 0) { rlcP->buffer_occupancy_retransmission_buffer -= 1; } pdu_index = pdu_mngt->sn % rlcP->recomputed_configured_tx_window_size; free_mem_block (rlcP->retransmission_buffer[pdu_index]); rlcP->retransmission_buffer[pdu_index] = NULL; + } else { // if this pdu is not discarded, mark the sdu discarded by writing "-1" for their index : used in retransmission #ifdef DEBUG_RLC_AM_DISCARD - msg ("[RLC_AM][RB %d] DISCARD LAST PDU SN 0x%03X, CONTAINS OTHER SDUS (LAST SDU INDEX=%d): NOT CLEARED\n", rlcP->rb_id, sdu_mngt->last_pdu_sn, pdu_mngt->sdu[pdu_mngt->nb_sdu - 1]); + msg ("[RLC_AM][RB %d] DISCARD LAST PDU SN 0x%03X, CONTAINS OTHER SDUS (LAST SDU INDEX=%d): NOT CLEARED\n", rlcP->rb_id, sdu_mngt->last_pdu_sn, + pdu_mngt->sdu[pdu_mngt->nb_sdu - 1]); #endif sdu_index2 = 0; while (pdu_mngt->sdu[sdu_index2] != sdu_index) { - #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD LAST PDU SN 0x%03X, MARK SDU index % AS DISCARDED\n", rlcP->rb_id, pdu_mngt->sn, pdu_mngt->sdu[sdu_index2]); #endif @@ -384,6 +374,7 @@ rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pdu } #ifdef DEBUG_RLC_AM_DISCARD + else { msg ("[RLC_AM][RB %d] DISCARD LAST PDU SN 0x%03X, ALREADY CLEARED\n", rlcP->rb_id, sdu_mngt->last_pdu_sn); } @@ -393,11 +384,10 @@ rlc_am_discard_notify_max_dat_pdu (struct rlc_am_entity *rlcP, mem_block_t * pdu //---------------- // discard the sdu if ((rlcP->input_sdus[sdu_index])) { // may be removed by "free_retransmission_buffer_no_confirmation" - if (sdu_index == rlcP->current_sdu_index) { // sdu under segmentation - rlcP->buffer_occupancy -= ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[sdu_index]->data))->sdu_remaining_size; - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[sdu_index]->data))->no_new_sdu_segmented_in_last_pdu = 1; + rlcP->buffer_occupancy -= ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[sdu_index]->data))->sdu_remaining_size; + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[sdu_index]->data))->no_new_sdu_segmented_in_last_pdu = 1; rlcP->li_exactly_filled_to_add_in_next_pdu = 0; rlcP->li_one_byte_short_to_add_in_next_pdu = 0; #ifdef DEBUG_RLC_AM_DISCARD diff --git a/openair2/LAYER2/RLC/AM/rlc_am_discard_rx.c b/openair2/LAYER2/RLC/AM/rlc_am_discard_rx.c index 7cabf88f8d7..7566cfaa171 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_discard_rx.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_discard_rx.c @@ -51,19 +51,19 @@ #include "umts_timer_proto_extern.h" #include "mem_block.h" //----------------------------------------------------------------------------- -void rlc_am_received_sufi_ack_check_discard_procedures (struct rlc_am_entity *rlcP); -void rlc_am_free_discard_procedure (mem_block_t * mb_current_procedureP); -inline void rlc_am_discard_free_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t sn_mrw_iP, uint8_t nlengthP); -uint8_t *retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte1P, uint8_t * byte_alignedP); -uint8_t *retransmission_buffer_management_mrw_ack (struct rlc_am_entity *rlcP, uint8_t * byte1P, uint8_t * byte_alignedP); +void rlc_am_received_sufi_ack_check_discard_procedures (struct rlc_am_entity* rlcP); +void rlc_am_free_discard_procedure (mem_block_t* mb_current_procedureP); +inline void rlc_am_discard_free_receiver_buffer (struct rlc_am_entity* rlcP, uint16_t sn_mrw_iP, uint8_t nlengthP); +uint8_t* retransmission_buffer_management_mrw (struct rlc_am_entity* rlcP, uint8_t* byte1P, uint8_t* byte_alignedP); +uint8_t* retransmission_buffer_management_mrw_ack (struct rlc_am_entity* rlcP, uint8_t* byte1P, uint8_t* byte_alignedP); //----------------------------------------------------------------------------- void -rlc_am_received_sufi_ack_check_discard_procedures (struct rlc_am_entity *rlcP) +rlc_am_received_sufi_ack_check_discard_procedures (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - mem_block_t *mb_proc; - mem_block_t *tmp_proc; - struct rlc_am_discard_procedure *procedure; + mem_block_t* mb_proc; + mem_block_t* tmp_proc; + struct rlc_am_discard_procedure* procedure; /* From 3GPP 25.322 V5.0.0 (2002-03) The Sender shall terminate the SDU discard with explicit signalling procedure if one of the following criteria is fulfilled: @@ -85,19 +85,16 @@ rlc_am_received_sufi_ack_check_discard_procedures (struct rlc_am_entity *rlcP) - update VT(A) and VT(MS) according to the received STATUS PDU/piggybacked STATUS PDU; The Sender shall not confirm to upper layers the SDUs that are requested to be discarded. */ - - mb_proc = rlcP->discard_procedures.head; while ((mb_proc)) { - procedure = (struct rlc_am_discard_procedure *) (mb_proc->data); + procedure = (struct rlc_am_discard_procedure*) (mb_proc->data); if (rlc_am_comp_sn (rlcP, rlcP->vt_a, rlcP->vt_a, procedure->last_pdu_sn) > 0) { #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD TRANSMIT NEW VT(A) 0x%04X REMOVE PROCEDURE SN_MRWlength 0x%04X\n", rlcP->rb_id, rlcP->vt_a, procedure->last_pdu_sn); msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ACK\n", rlcP->rb_id); #endif - tmp_proc = mb_proc->next; list2_remove_element (mb_proc, &rlcP->discard_procedures); @@ -105,10 +102,12 @@ rlc_am_received_sufi_ack_check_discard_procedures (struct rlc_am_entity *rlcP) if ((procedure->running) && (rlcP->timer_mrw)) { if (rlcP->timer_mrw == list2_remove_element (rlcP->timer_mrw, &rlcP->rlc_am_timer_list)) { #ifdef DEBUG_RLC_AM_DISCARD - msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ACK->TERMINATE PROCEDURE: REMOVE TIMER mrw id %p\n", rlcP->rb_id, ((struct timer_unit *) (rlcP->timer_mrw->data))->timer_id); + msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ACK->TERMINATE PROCEDURE: REMOVE TIMER mrw id %p\n", rlcP->rb_id, + ((struct timer_unit*) (rlcP->timer_mrw->data))->timer_id); #endif free_mem_block (rlcP->timer_mrw); rlcP->timer_mrw = NULL; + } else { #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD TRANSMIT REMOVE TIMER FAILED\n", rlcP->rb_id); @@ -117,9 +116,9 @@ rlc_am_received_sufi_ack_check_discard_procedures (struct rlc_am_entity *rlcP) } rlc_am_free_discard_procedure (mb_proc); - mb_proc = tmp_proc; rlcP->vt_mrw = 0; + } else { mb_proc = mb_proc->next; } @@ -131,14 +130,14 @@ rlc_am_received_sufi_ack_check_discard_procedures (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_free_discard_procedure (mem_block_t * mb_current_procedureP) +rlc_am_free_discard_procedure (mem_block_t* mb_current_procedureP) { //----------------------------------------------------------------------------- // be carefull : the timer is not free here, it should be done before - struct rlc_am_discard_procedure *procedure; + struct rlc_am_discard_procedure* procedure; if (mb_current_procedureP) { - procedure = (struct rlc_am_discard_procedure *) (mb_current_procedureP->data); + procedure = (struct rlc_am_discard_procedure*) (mb_current_procedureP->data); list_free (&procedure->sdu_list); if (procedure->control_pdu) { @@ -151,22 +150,19 @@ rlc_am_free_discard_procedure (mem_block_t * mb_current_procedureP) //----------------------------------------------------------------------------- inline void -rlc_am_discard_free_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t sn_mrw_iP, uint8_t nlengthP) +rlc_am_discard_free_receiver_buffer (struct rlc_am_entity* rlcP, uint16_t sn_mrw_iP, uint8_t nlengthP) { //----------------------------------------------------------------------------- uint16_t working_sn; uint16_t working_sn_index; // index in buffer - // should start reassembly with sn working_sn working_sn = rlcP->last_reassemblied_sn; working_sn_index = working_sn % rlcP->recomputed_configured_rx_window_size; - #ifdef DEBUG_RLC_AM_DISCARD display_receiver_buffer (rlcP); #endif while (working_sn != sn_mrw_iP) { - #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD RECEIVER FREE RECEIVER BUFFER pdu sn 0x%04X VR(R) 0x%04X\n", rlcP->rb_id, working_sn, rlcP->vr_r); #endif @@ -181,12 +177,12 @@ rlc_am_discard_free_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t sn_mrw // NLENGTH indicates which LI in the PDU with sequence number SN_MRWLENGTH corresponds to the last SDU to be discarded in the receiver. // NLENGTH = 0 indicates that the last SDU ended in the PDU with sequence number SN_MRWLENGTH -1 and that the first data octet // in the PDU with sequence number SN_MRWLENGTH is the first data octet to be reassembled next. - // erase previous sdu in construction rlcP->output_sdu_size_to_write = 0; if ((nlengthP)) { rlcP->discard_reassembly_after_li = nlengthP; // will be used by process_receiver_buffer + } else { #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD RECEIVER rlc_am_discard_free_receiver_buffer pdu sn 0x%04X (nlength=0)\n", rlcP->rb_id, working_sn); @@ -198,12 +194,12 @@ rlc_am_discard_free_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t sn_mrw } //----------------------------------------------------------------------------- -uint8_t * -retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte1P, uint8_t * byte_alignedP) +uint8_t* +retransmission_buffer_management_mrw (struct rlc_am_entity* rlcP, uint8_t* byte1P, uint8_t* byte_alignedP) { //----------------------------------------------------------------------------- - mem_block_t *mb; - uint8_t *p8; + mem_block_t* mb; + uint8_t* p8; uint16_t sn_mrw_i[15]; uint16_t new_vr_r; uint16_t working_sn; @@ -252,12 +248,12 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte - include the MRW_ACK SUFI in the next STATUS PDU/piggybacked STATUS PDU to be transmitted, according to subclause 11.5.2. */ - p8 = byte1P; sn_mrw_i_index = 0; if (*byte_alignedP) { mrw_length = *p8++ & 0X0F; // number of SN_MRWi + } else { p8 = p8 + 1; mrw_length = (*p8 & 0XF0) >> 4; // number of SN_MRWi @@ -265,11 +261,11 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte if (!(mrw_length)) { if (*byte_alignedP) { - // sn_mrw_i is SN_MRW length sn_mrw_i[0] = (*p8++) << 4; sn_mrw_i[0] += (*p8) >> 4; *byte_alignedP = 0; + } else { // sn_mrw_i is SN_MRW length sn_mrw_i[0] = (*p8++) << 8; @@ -279,6 +275,7 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte } sn_mrw_i_index += 1; + } else { // get all sn_mrw_i while (mrw_length != sn_mrw_i_index) { @@ -286,6 +283,7 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte sn_mrw_i[sn_mrw_i_index] = (*p8++) << 4; sn_mrw_i[sn_mrw_i_index] += (*p8) >> 4; *byte_alignedP = 0; + } else { sn_mrw_i[sn_mrw_i_index] = ((*p8++) & 0x0F) << 8; sn_mrw_i[sn_mrw_i_index] += (*p8++); @@ -300,6 +298,7 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte if (*byte_alignedP) { nlength = (*p8 & 0xF0) >> 4; *byte_alignedP = 0; + } else { nlength = *p8++ & 0x0F; *byte_alignedP = 1; @@ -357,7 +356,6 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte #endif while (working_sn != new_vr_r) { - #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD RECEIVER FREE RECEIVER BUFFER pdu sn 0x%04X VR(R) 0x%04X\n", rlcP->rb_id, working_sn, rlcP->vr_r); #endif @@ -372,10 +370,8 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte // NLENGTH indicates which LI in the PDU with sequence number SN_MRWLENGTH corresponds to the last SDU to be discarded in the receiver. // NLENGTH = 0 indicates that the last SDU ended in the PDU with sequence number SN_MRWLENGTH -1 and that the first data octet // in the PDU with sequence number SN_MRWLENGTH is the first data octet to be reassembled next. - // erase previous sdu in construction rlcP->output_sdu_size_to_write = 0; - rlcP->discard_reassembly_start_sn = new_vr_r; rlcP->discard_reassembly_after_li = nlength; // will be used by process_receiver_buffer @@ -403,6 +399,7 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte if (rlcP->pdu_size <= 126) { process_receiver_buffer_7 (rlcP); + } else { process_receiver_buffer_15 (rlcP); } @@ -418,9 +415,9 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte - set the N field in the MRW_ACK SUFI to "0000"; - include the MRW_ACK SUFI in the next STATUS PDU/piggybacked STATUS PDU to be transmitted, according to subclause 11.5.2. */ - if (sn_mrw_i[sn_mrw_i_index - 1] == rlcP->vr_r) { mb = rlc_am_create_status_pdu_mrw_ack (rlcP, nlength, rlcP->vr_r); + } else { mb = rlc_am_create_status_pdu_mrw_ack (rlcP, 0, rlcP->vr_r); } @@ -435,20 +432,18 @@ retransmission_buffer_management_mrw (struct rlc_am_entity *rlcP, uint8_t * byte } //----------------------------------------------------------------------------- -uint8_t * -retransmission_buffer_management_mrw_ack (struct rlc_am_entity * rlcP, uint8_t * byte1P, uint8_t * byte_alignedP) +uint8_t* +retransmission_buffer_management_mrw_ack (struct rlc_am_entity* rlcP, uint8_t* byte1P, uint8_t* byte_alignedP) { //----------------------------------------------------------------------------- - mem_block_t *mb; - mem_block_t *mb_current_procedure; - struct rlc_am_tx_data_pdu_management *rlc_header; - struct rlc_am_discard_procedure *procedure; - uint8_t *p8; - + mem_block_t* mb; + mem_block_t* mb_current_procedure; + struct rlc_am_tx_data_pdu_management* rlc_header; + struct rlc_am_discard_procedure* procedure; + uint8_t* p8; uint16_t sn_ack; uint16_t index; uint8_t n; // field of mrw_ack sufi - //------------------------------------- // DECODE SUFI MRW_ACK //------------------------------------- @@ -460,6 +455,7 @@ retransmission_buffer_management_mrw_ack (struct rlc_am_entity * rlcP, uint8_t * sn_ack = (*p8++) << 4; sn_ack += (*p8) >> 4; *byte_alignedP = 0; + } else { p8 = p8 + 1; n = (*p8 & 0XF0) >> 4; @@ -476,11 +472,10 @@ retransmission_buffer_management_mrw_ack (struct rlc_am_entity * rlcP, uint8_t * // compare to current running procedure if ((mb_current_procedure = rlcP->discard_procedures.head)) { - - procedure = (struct rlc_am_discard_procedure *) (mb_current_procedure->data); - + procedure = (struct rlc_am_discard_procedure*) (mb_current_procedure->data); #ifdef DEBUG_RLC_AM_DISCARD - msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ... procedure->last_pdu_sn 0x%04X procedure->nlength 0x%04X \n", rlcP->rb_id, procedure->last_pdu_sn, procedure->nlength); + msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ... procedure->last_pdu_sn 0x%04X procedure->nlength 0x%04X \n", rlcP->rb_id, procedure->last_pdu_sn, + procedure->nlength); #endif /* From 3GPP TS 25.322 V5.0.0 @@ -500,11 +495,11 @@ retransmission_buffer_management_mrw_ack (struct rlc_am_entity * rlcP, uint8_t * (rlc_am_comp_sn (rlcP, rlcP->vt_a, procedure->last_pdu_sn, sn_ack) > 0) || ((rlc_am_comp_sn (rlcP, rlcP->vt_a, procedure->last_pdu_sn, sn_ack) == 0) && (n != procedure->nlength)) || ((rlc_am_comp_sn (rlcP, rlcP->vt_a, procedure->last_pdu_sn, sn_ack) < 0) && (n != 0))) { - #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ERROR RX OBSOLETE MRW_ACK VT(A) 0x%04X VT(S) 0x%04X SN_MRWlength 0x%04X N %d SN_ACK 0x%04X\n", rlcP->rb_id, rlcP->vt_a, rlcP->vt_s, procedure->last_pdu_sn, n, sn_ack); #endif + } else if ( /* From 3GPP 25.322 V5.0.0 (2002-03) The Sender shall terminate the SDU discard with explicit signalling procedure if one of the @@ -532,20 +527,20 @@ retransmission_buffer_management_mrw_ack (struct rlc_am_entity * rlcP, uint8_t * #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD PROCEDURE %p TERMINATED\n", rlcP->rb_id, mb_current_procedure); #endif - rlcP->vt_mrw = 0; // remove timer if ((rlcP->timer_mrw)) { if (rlcP->timer_mrw == list2_remove_element (rlcP->timer_mrw, &rlcP->rlc_am_timer_list)) { #ifdef DEBUG_RLC_AM_DISCARD - msg ("[RLC_AM][RB %d] DISCARD TRANSMIT TERMINATE PROCEDURE: REMOVE TIMER mrw id %p\n", rlcP->rb_id, ((struct timer_unit *) (rlcP->timer_mrw->data))->timer_id); + msg ("[RLC_AM][RB %d] DISCARD TRANSMIT TERMINATE PROCEDURE: REMOVE TIMER mrw id %p\n", rlcP->rb_id, ((struct timer_unit*) (rlcP->timer_mrw->data))->timer_id); #endif free_mem_block (rlcP->timer_mrw); rlcP->timer_mrw = NULL; } #ifdef DEBUG_RLC_AM_DISCARD + else { msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ERROR TERMINATION PROCEDURE : TIMER MRW IS WRONG\n", rlcP->rb_id); // in fact : no, the lists are not protected against an element that is not inside the list @@ -555,28 +550,24 @@ retransmission_buffer_management_mrw_ack (struct rlc_am_entity * rlcP, uint8_t * } #ifdef DEBUG_RLC_AM_DISCARD + else { msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ERROR TERMINATION PROCEDURE : NO TIMER MRW WAS FOUND\n", rlcP->rb_id); } #endif - mb_current_procedure = list2_remove_head (&rlcP->discard_procedures); //update VT(A) if (rlc_am_comp_sn (rlcP, rlcP->vt_a, sn_ack, rlcP->vt_a) > 0) { - // free resources that may be in retransmission buffer while (rlcP->vt_a != sn_ack) { - index = rlcP->vt_a % rlcP->recomputed_configured_tx_window_size; if ((mb = rlcP->retransmission_buffer[index])) { - - rlc_header = (struct rlc_am_tx_data_pdu_management *) (mb->data); + rlc_header = (struct rlc_am_tx_data_pdu_management*) (mb->data); if (rlc_header->nb_sdu > 0) { - #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD TRANSMIT CASE 1 MRW_ACK\n", rlcP->rb_id); #endif @@ -609,6 +600,7 @@ retransmission_buffer_management_mrw_ack (struct rlc_am_entity * rlcP, uint8_t * rlc_am_free_discard_procedure (mb_current_procedure); rlc_am_schedule_procedure (rlcP); + } else { msg ("[RLC_AM][RB %d] DISCARD TRANSMIT ERROR RX MRW_ACK CASE NOT TAKEN IN ACCOUNT : NO ACTION !\n", rlcP->rb_id); } diff --git a/openair2/LAYER2/RLC/AM/rlc_am_discard_tx.c b/openair2/LAYER2/RLC/AM/rlc_am_discard_tx.c index 28785cd8056..ec3dcfbf8f4 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_discard_tx.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_discard_tx.c @@ -48,23 +48,22 @@ #include "rlc_am_structs.h" #include "umts_timer_proto_extern.h" //----------------------------------------------------------------------------- -void rlc_am_schedule_procedure (struct rlc_am_entity *rlcP); -void rlc_am_process_sdu_discarded (struct rlc_am_entity *rlcP); -void rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struct rlc_am_entity *rlcP); -void rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (struct rlc_am_entity *rlcP); +void rlc_am_schedule_procedure (struct rlc_am_entity* rlcP); +void rlc_am_process_sdu_discarded (struct rlc_am_entity* rlcP); +void rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struct rlc_am_entity* rlcP); +void rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (struct rlc_am_entity* rlcP); //----------------------------------------------------------------------------- void -rlc_am_schedule_procedure (struct rlc_am_entity *rlcP) +rlc_am_schedule_procedure (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - mem_block_t *pdu_status; - struct rlc_am_discard_procedure *procedure; + mem_block_t* pdu_status; + struct rlc_am_discard_procedure* procedure; // if a procedure is running do nothing if (!(rlcP->timer_mrw) && (rlcP->discard_procedures.head)) { // launch remaining procedures (only 1 procedure running) - procedure = (struct rlc_am_discard_procedure *) ((rlcP->discard_procedures.head)->data); - + procedure = (struct rlc_am_discard_procedure*) ((rlcP->discard_procedures.head)->data); /* sn_mrw_length = procedure->last_pdu_sn; if (rlc_am_comp_sn(rlcP, rlcP->vt_s, sn_mrw_length, rlcP->vt_s) > 0) { @@ -81,13 +80,12 @@ rlc_am_schedule_procedure (struct rlc_am_entity *rlcP) pdu_status = get_free_mem_block (rlcP->pdu_size + sizeof (struct rlc_am_tx_control_pdu_allocation) + GUARD_CRC_LIH_SIZE); memcpy (pdu_status->data, procedure->control_pdu->data, rlcP->pdu_size + sizeof (struct rlc_am_tx_control_pdu_allocation)); list_add_tail_eurecom (pdu_status, &rlcP->control); - } } //----------------------------------------------------------------------------- void -rlc_am_process_sdu_discarded (struct rlc_am_entity *rlcP) +rlc_am_process_sdu_discarded (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- // We assume that the list sdu_discarded contains sdu(s) @@ -101,10 +99,10 @@ rlc_am_process_sdu_discarded (struct rlc_am_entity *rlcP) - "SDU discard after MaxDAT number of transmissions" is configured, and MaxDAT number of transmissions is reached (i.e. VT(DAT) � MaxDAT) for an AMD PDU. */ - // discard procedure if ((rlcP->send_mrw & RLC_AM_SEND_MRW_ON)) { rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (rlcP); + } else { // RLC_AM_SEND_MRW_OFF rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (rlcP); } @@ -114,7 +112,7 @@ rlc_am_process_sdu_discarded (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struct rlc_am_entity *rlcP) +rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- /* From 3GPP TS 25.322 V5.0.0 (2002-03) @@ -140,12 +138,12 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struc - set the LENGTH field in the MRW SUFI to the number of SN_MRWi fields in the same MRW SUFI. In this case, SN_MRW1 shall be in the interval VT(A) SN_MRW1 < VT(A)+Configured_Tx_Window_Size. */ - mem_block_t *mb_discard_procedure = NULL; - mem_block_t *sdu_discarded; - struct rlc_am_tx_sdu_management *last_sdu_discarded_mngt; - mem_block_t *le; - struct rlc_am_status_header *pdu; - uint8_t *p8; + mem_block_t* mb_discard_procedure = NULL; + mem_block_t* sdu_discarded; + struct rlc_am_tx_sdu_management* last_sdu_discarded_mngt; + mem_block_t* le; + struct rlc_am_status_header* pdu; + uint8_t* p8; int last_sn_mrw_length; uint8_t count_sdu_discarded; uint8_t byte_aligned; @@ -154,14 +152,11 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struc #endif while (rlcP->sdu_discarded.head) { - // alloc a discard procedure mb_discard_procedure = get_free_mem_block (sizeof (struct rlc_am_discard_procedure)); memset (mb_discard_procedure->data, 0, sizeof (struct rlc_am_discard_procedure)); - list_init (&((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->sdu_list, NULL); - + list_init (&((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->sdu_list, NULL); count_sdu_discarded = 0; - // assign sdu discarded to discard procedure // sdu headers are registered in discard procedure last_sn_mrw_length = -1; @@ -171,45 +166,44 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struc // this test is done to avoid signalling n times the same SN_MRW_length if a pdu contains n sdu // so it can save some discard procedures. - if (last_sn_mrw_length != ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn) { - + if (last_sn_mrw_length != ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn) { #ifdef DEBUG_RLC_AM_DISCARD - msg ("[RLC_AM][RB %d] DISCARD IN PROCEDURE %p ADD SDU SN_MRWlength 0x%03X\n", rlcP->rb_id, mb_discard_procedure, ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn); + msg ("[RLC_AM][RB %d] DISCARD IN PROCEDURE %p ADD SDU SN_MRWlength 0x%03X\n", rlcP->rb_id, mb_discard_procedure, + ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn); #endif - list_add_tail_eurecom (sdu_discarded, &((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->sdu_list); - last_sn_mrw_length = ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn; + list_add_tail_eurecom (sdu_discarded, &((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->sdu_list); + last_sn_mrw_length = ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn; count_sdu_discarded += 1; + } else { free_mem_block (sdu_discarded); } } - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->length = count_sdu_discarded; - + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->length = count_sdu_discarded; //((struct rlc_am_discard_procedure*)(mb_discard_procedure->data))->nlength = ((struct rlc_am_sdu_discard_management*)((mem_block_t*)(sdu_header_copy_copy->data))->data)->li_index_for_discard; - - last_sdu_discarded_mngt = (struct rlc_am_tx_sdu_management *) (sdu_discarded->data); + last_sdu_discarded_mngt = (struct rlc_am_tx_sdu_management*) (sdu_discarded->data); if ((last_sdu_discarded_mngt->no_new_sdu_segmented_in_last_pdu)) { #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD NO NEW SDU SEGMENTED IN LAST PDU DISCARDED\n", rlcP->rb_id); #endif last_sdu_discarded_mngt->last_pdu_sn = (last_sdu_discarded_mngt->last_pdu_sn + 1) & SN_12BITS_MASK; - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength = 0; + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength = 0; + } else { #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD OTHER SDU(s) SEGMENTED IN LAST PDU DISCARDED\n", rlcP->rb_id); #endif - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength = last_sdu_discarded_mngt->li_index_for_discard + 1; // +1 since numerotation begins at 1 + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength = last_sdu_discarded_mngt->li_index_for_discard + + 1; // +1 since numerotation begins at 1 } #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD SET SN_MRW_LENGTH 0x%04X NLENGTH = %d \n", rlcP->rb_id, last_sdu_discarded_mngt->last_pdu_sn, - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength); + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength); sn_mrw_length = last_sdu_discarded_mngt->last_pdu_sn; #endif - - // make status pdu le = get_free_mem_block (rlcP->pdu_size + sizeof (struct rlc_am_tx_control_pdu_allocation) + GUARD_CRC_LIH_SIZE); @@ -217,10 +211,10 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struc // be carefull : lost resources in mb_discard : TO DO msg ("[RLC_AM][RB %d] FATAL ERROR : OUT OF MEMORY\n", rlcP->rb_id); return; - } else { - ((struct rlc_am_tx_control_pdu_management *) (le->data))->rlc_tb_type = RLC_AM_MRW_STATUS_PDU_TYPE; - pdu = (struct rlc_am_status_header *) (&le->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]); + } else { + ((struct rlc_am_tx_control_pdu_management*) (le->data))->rlc_tb_type = RLC_AM_MRW_STATUS_PDU_TYPE; + pdu = (struct rlc_am_status_header*) (&le->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]); pdu->byte1 = RLC_PDU_TYPE_STATUS; p8 = &(pdu->byte1); *p8 = *p8 | RLC_AM_SUFI_MRW; @@ -228,23 +222,23 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struc // fill field LENGTH *p8 = (count_sdu_discarded << 4); byte_aligned = 0; - // fill fields SN_MRWi - sdu_discarded = (((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->sdu_list.head); // reuse of var sdu_discarded + sdu_discarded = (((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->sdu_list.head); // reuse of var sdu_discarded while ((count_sdu_discarded)) { count_sdu_discarded -= 1; if (byte_aligned) { - *p8 = ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn >> 4; + *p8 = ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn >> 4; p8 = p8 + 1; - *p8 = ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn << 4; + *p8 = ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn << 4; byte_aligned = 0; + } else { //*p8 = 0 << 4 | (temp_sn >> 8); - *p8 |= (((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn >> 8); + *p8 |= (((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn >> 8); p8 = p8 + 1; - *p8 = ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn; + *p8 = ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn; p8 = p8 + 1; byte_aligned = 1; } @@ -254,28 +248,29 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_configured (struc // fill field Nlength if (byte_aligned) { - *p8 = (((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength << 4) | RLC_AM_SUFI_NO_MORE; + *p8 = (((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength << 4) | RLC_AM_SUFI_NO_MORE; + } else { - *p8 |= (((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength); + *p8 |= (((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength); p8 = p8 + 1; *p8 = (RLC_AM_SUFI_NO_MORE << 4); } - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->control_pdu = le; + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->control_pdu = le; list2_add_tail (mb_discard_procedure, &rlcP->discard_procedures); } } #ifdef DEBUG_RLC_AM_DISCARD msg ("[RLC_AM][RB %d] DISCARD QUEUED NEW PROCEDURE SEND_MRW IS CONFIGURED SN_MRW_length = 0x%04X length %d nlength %d\n", - rlcP->rb_id, sn_mrw_length, ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->length, ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength); + rlcP->rb_id, sn_mrw_length, ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->length, + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength); #endif - } //----------------------------------------------------------------------------- void -rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (struct rlc_am_entity *rlcP) +rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- /* From 3GPP TS 25.322 V5.0.0 (2002-03) @@ -301,13 +296,13 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (s - set the LENGTH field in the MRW SUFI to the number of SN_MRWi fields in the same MRW SUFI. In this case, SN_MRW1 shall be in the interval VT(A) SN_MRW1 < VT(A)+Configured_Tx_Window_Size. */ - mem_block_t *mb_discard_procedure = NULL; - mem_block_t *sdu_discarded; - struct rlc_am_tx_sdu_management *last_sdu_discarded_mngt; - mem_block_t *le; - struct rlc_am_status_header *pdu; + mem_block_t* mb_discard_procedure = NULL; + mem_block_t* sdu_discarded; + struct rlc_am_tx_sdu_management* last_sdu_discarded_mngt; + mem_block_t* le; + struct rlc_am_status_header* pdu; int last_sn_mrw_length; - uint8_t *p8; + uint8_t* p8; uint8_t count_sdu_discarded; uint8_t byte_aligned; #ifdef DEBUG_RLC_AM_DISCARD @@ -315,48 +310,44 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (s #endif while (rlcP->sdu_discarded.head) { - // alloc a discard procedure mb_discard_procedure = get_free_mem_block (sizeof (struct rlc_am_discard_procedure)); memset (mb_discard_procedure->data, 0, sizeof (struct rlc_am_discard_procedure)); - list_init (&((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->sdu_list, NULL); - + list_init (&((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->sdu_list, NULL); count_sdu_discarded = 0; - // assign sdu discarded to discard procedure // sdu headers are registered in discard procedure last_sn_mrw_length = -1; while ((rlcP->sdu_discarded.head) && (count_sdu_discarded < 15)) { // max 15 sdu discarded per procedure - sdu_discarded = list2_remove_head (&rlcP->sdu_discarded); // this test is done to avoid signalling n times the same SN_MRW_length if a pdu contains n sdu // so it can save some discard procedures. - if (last_sn_mrw_length != ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn) { + if (last_sn_mrw_length != ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn) { #ifdef DEBUG_RLC_AM_DISCARD - msg ("[RLC_AM][RB %d] DISCARD IN PROCEDURE %p ADD SDU SN_MRWlength %03X hex\n", rlcP->rb_id, mb_discard_procedure, ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn); + msg ("[RLC_AM][RB %d] DISCARD IN PROCEDURE %p ADD SDU SN_MRWlength %03X hex\n", rlcP->rb_id, mb_discard_procedure, + ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn); #endif - list_add_tail_eurecom (sdu_discarded, &((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->sdu_list); - last_sn_mrw_length = ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn; + list_add_tail_eurecom (sdu_discarded, &((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->sdu_list); + last_sn_mrw_length = ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn; count_sdu_discarded = 1; + } else { free_mem_block (sdu_discarded); } } - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->length = count_sdu_discarded; - - + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->length = count_sdu_discarded; //((struct rlc_am_discard_procedure*)(mb_discard_procedure->data))->nlength = ((struct rlc_am_sdu_discard_management*)((mem_block_t*)(sdu_header_copy_copy->data))->data)->li_index_for_discard; - - last_sdu_discarded_mngt = (struct rlc_am_tx_sdu_management *) (sdu_discarded->data); + last_sdu_discarded_mngt = (struct rlc_am_tx_sdu_management*) (sdu_discarded->data); if ((last_sdu_discarded_mngt->no_new_sdu_segmented_in_last_pdu)) { last_sdu_discarded_mngt->last_pdu_sn = (last_sdu_discarded_mngt->last_pdu_sn + 1) & SN_12BITS_MASK; - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength = 0; + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength = 0; + } else { - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength = last_sdu_discarded_mngt->li_index_for_discard; + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength = last_sdu_discarded_mngt->li_index_for_discard; } #ifdef DEBUG_RLC_AM_DISCARD @@ -365,9 +356,8 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (s // make status pdu if ((le = get_free_mem_block (rlcP->pdu_size + sizeof (struct rlc_am_tx_control_pdu_allocation) + GUARD_CRC_LIH_SIZE))) { - ((struct rlc_am_tx_control_pdu_management *) (le->data))->rlc_tb_type = RLC_AM_MRW_STATUS_PDU_TYPE; - - pdu = (struct rlc_am_status_header *) (&le->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]); + ((struct rlc_am_tx_control_pdu_management*) (le->data))->rlc_tb_type = RLC_AM_MRW_STATUS_PDU_TYPE; + pdu = (struct rlc_am_status_header*) (&le->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]); pdu->byte1 = RLC_PDU_TYPE_STATUS; p8 = &(pdu->byte1); *p8 = *p8 | RLC_AM_SUFI_MRW; @@ -375,21 +365,19 @@ rlc_am_sdu_discard_with_explicit_signalling_procedure_send_mrw_not_configured (s // fill field LENGTH *p8 = (count_sdu_discarded << 4); byte_aligned = 0; - // fill fields SN_MRWi - sdu_discarded = (((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->sdu_list.head); // reuse of var sdu_discarded - + sdu_discarded = (((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->sdu_list.head); // reuse of var sdu_discarded //*p8 = 0 << 4 | (temp_sn >> 8); - *p8 |= (((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn >> 8); + *p8 |= (((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn >> 8); p8 = p8 + 1; - *p8 = ((struct rlc_am_tx_sdu_management *) (sdu_discarded->data))->last_pdu_sn; + *p8 = ((struct rlc_am_tx_sdu_management*) (sdu_discarded->data))->last_pdu_sn; p8 = p8 + 1; byte_aligned = 1; - // fill field Nlength - *p8 = (((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->nlength << 4) | RLC_AM_SUFI_NO_MORE; - ((struct rlc_am_discard_procedure *) (mb_discard_procedure->data))->control_pdu = le; + *p8 = (((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->nlength << 4) | RLC_AM_SUFI_NO_MORE; + ((struct rlc_am_discard_procedure*) (mb_discard_procedure->data))->control_pdu = le; list2_add_tail (mb_discard_procedure, &rlcP->discard_procedures); + } else { // out of memory return; diff --git a/openair2/LAYER2/RLC/AM/rlc_am_fsm.c b/openair2/LAYER2/RLC/AM/rlc_am_fsm.c index 182677710ae..ea1e9d489c4 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_fsm.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_fsm.c @@ -44,10 +44,9 @@ #include "LAYER2/MAC/extern.h" //----------------------------------------------------------------------------- int -rlc_am_fsm_notify_event (struct rlc_am_entity *rlcP, uint8_t eventP) +rlc_am_fsm_notify_event (struct rlc_am_entity* rlcP, uint8_t eventP) { //----------------------------------------------------------------------------- - switch (rlcP->protocol_state) { //------------------------------- // RLC_NULL_STATE @@ -105,7 +104,8 @@ rlc_am_fsm_notify_event (struct rlc_am_entity *rlcP, uint8_t eventP) break; default: - msg ("[RLC_AM][RB %d][FSM] WARNING PROTOCOL ERROR - EVENT 0x%02X NOT EXPECTED FROM DATA_TRANSFER_READY_STATE frame %d\n", rlcP->rb_id, eventP, Mac_rlc_xface->frame); + msg ("[RLC_AM][RB %d][FSM] WARNING PROTOCOL ERROR - EVENT 0x%02X NOT EXPECTED FROM DATA_TRANSFER_READY_STATE frame %d\n", rlcP->rb_id, eventP, + Mac_rlc_xface->frame); return 0; } @@ -148,7 +148,8 @@ rlc_am_fsm_notify_event (struct rlc_am_entity *rlcP, uint8_t eventP) break; default: - msg ("[RLC_AM][RB %d][FSM] WARNING PROTOCOL ERROR - EVENT 0x%02X NOT EXPECTED FROM RLC_RESET_PENDING_STATE frame %d\n", rlcP->rb_id, eventP, Mac_rlc_xface->frame); + msg ("[RLC_AM][RB %d][FSM] WARNING PROTOCOL ERROR - EVENT 0x%02X NOT EXPECTED FROM RLC_RESET_PENDING_STATE frame %d\n", rlcP->rb_id, eventP, + Mac_rlc_xface->frame); return 0; } @@ -184,7 +185,8 @@ rlc_am_fsm_notify_event (struct rlc_am_entity *rlcP, uint8_t eventP) break; default: - msg ("[RLC_AM][RB %d][FSM] WARNING PROTOCOL ERROR - EVENT 0x%02X NOT EXPECTED FROM RLC_RESET_AND_SUSPEND_STATE frame %d\n", rlcP->rb_id, eventP, Mac_rlc_xface->frame); + msg ("[RLC_AM][RB %d][FSM] WARNING PROTOCOL ERROR - EVENT 0x%02X NOT EXPECTED FROM RLC_RESET_AND_SUSPEND_STATE frame %d\n", rlcP->rb_id, eventP, + Mac_rlc_xface->frame); return 0; } @@ -220,7 +222,8 @@ rlc_am_fsm_notify_event (struct rlc_am_entity *rlcP, uint8_t eventP) break; default: - msg ("[RLC_AM][RB %d][FSM] WARNING PROTOCOL ERROR - EVENT 0x%02X NOT EXPECTED FROM RLC_LOCAL_SUSPEND_STATE frame %d\n", rlcP->rb_id, eventP, Mac_rlc_xface->frame); + msg ("[RLC_AM][RB %d][FSM] WARNING PROTOCOL ERROR - EVENT 0x%02X NOT EXPECTED FROM RLC_LOCAL_SUSPEND_STATE frame %d\n", rlcP->rb_id, eventP, + Mac_rlc_xface->frame); return 0; } diff --git a/openair2/LAYER2/RLC/AM/rlc_am_mac_status.c b/openair2/LAYER2/RLC/AM/rlc_am_mac_status.c index c5d3b95e1c5..2a18ae020bc 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_mac_status.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_mac_status.c @@ -45,11 +45,10 @@ #include "umts_timer_proto_extern.h" //----------------------------------------------------------------------------- void -rlc_am_status_report_from_mac (void *rlcP, uint16_t eventP) +rlc_am_status_report_from_mac (void* rlcP, uint16_t eventP) { //----------------------------------------------------------------------------- - - struct rlc_am_entity *rlc = (struct rlc_am_entity *) rlcP; + struct rlc_am_entity* rlc = (struct rlc_am_entity*) rlcP; //---------------------------------------- // STATUS @@ -83,11 +82,11 @@ rlc_am_status_report_from_mac (void *rlcP, uint16_t eventP) //---------------------------------------- if ((eventP & RLC_AM_RESET_PDU_TYPE)) { #ifdef DEBUG_RESET - msg ("[RLC_AM %p][MAC_STATUS] EVENT RLC_AM_RESET_PDU_TYPE SENT ARMING RESET TIMER %d frames frame %d\n", rlcP, (uint32_t) rlc->timer_rst_init, *rlc->frame_tick_milliseconds); + msg ("[RLC_AM %p][MAC_STATUS] EVENT RLC_AM_RESET_PDU_TYPE SENT ARMING RESET TIMER %d frames frame %d\n", rlcP, (uint32_t) rlc->timer_rst_init, + *rlc->frame_tick_milliseconds); #endif - - rlc->timer_rst = umts_add_timer_list_up (&rlc->rlc_am_timer_list, rlc_am_reset_time_out, rlcP, NULL, (uint32_t) rlc->timer_rst_init, *rlc->frame_tick_milliseconds); - + rlc->timer_rst = umts_add_timer_list_up (&rlc->rlc_am_timer_list, rlc_am_reset_time_out, rlcP, NULL, (uint32_t) rlc->timer_rst_init, + *rlc->frame_tick_milliseconds); return; } @@ -101,5 +100,4 @@ rlc_am_status_report_from_mac (void *rlcP, uint16_t eventP) rlc_am_fsm_notify_event (rlc, RLC_AM_TRANSMIT_RESET_ACK_EVENT); return; } - } diff --git a/openair2/LAYER2/RLC/AM/rlc_am_mux.c b/openair2/LAYER2/RLC/AM/rlc_am_mux.c index 7f092cb7b6b..249d0f42a7d 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_mux.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_mux.c @@ -57,14 +57,13 @@ */ //----------------------------------------------------------------------------- void -rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) +rlc_am_mux_ue (struct rlc_am_entity* rlcP, unsigned int traffic_typeP) { //----------------------------------------------------------------------------- - - mem_block_t *pdu; - mem_block_t *sdu; - mem_block_t *copy_pdu; - struct rlc_am_pdu_header *rlc_header; + mem_block_t* pdu; + mem_block_t* sdu; + mem_block_t* copy_pdu; + struct rlc_am_pdu_header* rlc_header; int pool_is_set; int index; int sdu_index; @@ -80,7 +79,6 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) nb_pdu_to_transmit_ch1 = rlcP->nb_pdu_requested_by_mac_on_ch1; nb_pdu_to_transmit_ch2 = rlcP->nb_pdu_requested_by_mac_on_ch2; - // discard if ((rlcP->sdu_discarded.head) && (traffic_typeP & RLC_AM_TRAFFIC_ALLOWED_FOR_STATUS)) { rlc_am_process_sdu_discarded (rlcP); @@ -99,9 +97,11 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) if ((traffic_typeP & RLC_AM_TRAFFIC_ALLOWED_FOR_STATUS)) { tx_pdu = 1; + } else { - if (((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { + if (((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { tx_pdu = 1; + } else { tx_pdu = 0; } @@ -111,30 +111,34 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) nb_pdu_to_transmit_ch1--; // for polling rlcP->vt_pdu++; - ((struct mac_tb_req *) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct mac_tb_req*) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer_ch1); # ifdef DEBUG_MUX msg ("[RLC_AM][RB %d][MUX] TX CONTROL PDU CH1 VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif + } else { free_mem_block (pdu); } } + } else if (rlcP->nb_logical_channels_per_rlc == 2) { while ((rlcP->control.head) && (nb_pdu_to_transmit_ch2)) { pdu = list_remove_head (&rlcP->control); if ((traffic_typeP & RLC_AM_TRAFFIC_ALLOWED_FOR_STATUS)) { tx_pdu = 1; + } else { - if (((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { + if (((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { tx_pdu = 1; + } else { tx_pdu = 0; } @@ -144,17 +148,18 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) nb_pdu_to_transmit_ch2--; // for polling rlcP->vt_pdu++; - ((struct mac_tb_req *) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct mac_tb_req*) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer_ch2); # ifdef DEBUG_MUX msg ("[RLC_AM][RB %d][MUX] TX CONTROL PDU CH2 VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X \n", rlcP->rb_id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif + } else { free_mem_block (pdu); } @@ -169,21 +174,19 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) while ((rlcP->retransmission_buffer_to_send.head) && (nb_pdu_to_transmit_ch1) && !(rlcP->protocol_state & RLC_RESET_PENDING_STATE)) { // each retransmission may send RLC in RESET STATE if no discard is configured copy_pdu = list2_remove_head (&rlcP->retransmission_buffer_to_send); - // unlink the pdu in retransmission buffer and its copy (mechanism avoiding multi-retransmission of the same // pdu in the same queue) - pdu = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->copy; + pdu = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->copy; # ifdef DEBUG_MUX rlc_am_display_data_pdu7(copy_pdu); # endif - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->copy = NULL; - - ((struct mac_tb_req *) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (copy_pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - ((struct mac_tb_req *) (copy_pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->copy = NULL; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (copy_pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; + ((struct mac_tb_req*) (copy_pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (copy_pdu, &rlcP->pdus_to_mac_layer_ch1); nb_pdu_to_transmit_ch1--; data_pdu_tx++; @@ -194,19 +197,19 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) if (rlcP->vt_pdu >= rlcP->poll_pdu_trigger) { // set poll bit - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; rlcP->vt_pdu = 0; + } else { // reset poll bit - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 = - (((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2) & ~RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 = + (((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2) & ~RLC_AM_P_STATUS_REPORT_REQUESTED; } } # ifdef DEBUG_MUX - id = (((uint16_t) (((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | - ((((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); - + id = (((uint16_t) (((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | + ((((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); msg ("[RLC_AM][RB %d][MUX] RETRANSMIT DATA PDU %04X VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif @@ -219,10 +222,8 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) segmentation_returned_pdu = 1; while ((nb_pdu_to_transmit_ch1) && (rlcP->vt_s != rlcP->vt_ms) && (segmentation_returned_pdu) && !(rlcP->protocol_state & RLC_RESET_PENDING_STATE)) { - if ((pdu = rlcP->rlc_segment (rlcP))) { - - rlc_header = (struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]); + rlc_header = (struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]); // check polling pool_is_set = 0; @@ -231,7 +232,7 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) // test every poll_PDU trigger if (rlcP->vt_pdu >= rlcP->poll_pdu_trigger) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; rlc_header->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; rlcP->vt_pdu = 0; pool_is_set = 1; @@ -242,24 +243,25 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) } // test every poll_SDU trigger - if ((rlcP->poll_sdu_trigger) && (((struct rlc_am_tx_data_pdu_management *) (pdu->data))->last_pdu_of_sdu)) { + if ((rlcP->poll_sdu_trigger) && (((struct rlc_am_tx_data_pdu_management*) (pdu->data))->last_pdu_of_sdu)) { if (rlcP->vt_sdu >= rlcP->poll_sdu_trigger) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; rlc_header->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; rlcP->vt_sdu = 0; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL msg ("[RLC_AM %p] POOL SET BY poll_sdu trigger\n", rlcP); # endif + } else { - rlcP->vt_sdu += ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->last_pdu_of_sdu; + rlcP->vt_sdu += ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->last_pdu_of_sdu; } } if (!pool_is_set) { // test last pdu in transmission buffer trigger == last sdu in input buffer in this implementation of RLC AM if ((rlcP->last_transmission_pdu_poll_trigger > 0) && (rlcP->nb_sdu == 0)) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; rlc_header->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL @@ -269,8 +271,9 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) if (!pool_is_set) { // test last pdu in retransmission buffer trigger - if ((rlcP->retransmission_buffer_to_send.head) && (rlcP->retransmission_buffer_to_send.head == rlcP->retransmission_buffer_to_send.tail) && (rlcP->last_retransmission_pdu_poll_trigger)) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + if ((rlcP->retransmission_buffer_to_send.head) && (rlcP->retransmission_buffer_to_send.head == rlcP->retransmission_buffer_to_send.tail) + && (rlcP->last_retransmission_pdu_poll_trigger)) { + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; rlc_header->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL @@ -284,7 +287,7 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) j = (unsigned int) (((rlcP->vt_s + 4096) - rlcP->vt_a) % 4096) * 100 / rlcP->vt_ws; if (j >= rlcP->poll_window_trigger) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; rlc_header->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL @@ -298,55 +301,54 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) rlc_header->byte1 |= (rlcP->vt_s >> 5); rlc_header->byte2 |= ((uint8_t) rlcP->vt_s << 3); - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sn = rlcP->vt_s; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sn = rlcP->vt_s; insert_into_retransmission_buffer (rlcP, rlcP->vt_s % rlcP->recomputed_configured_tx_window_size, pdu); - // check if timer based discard configured if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_TIMER_BASED_EXPLICIT)) { - for (index = 0; index < ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->nb_sdu; index++) { - sdu_index = ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index]; + for (index = 0; index < ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->nb_sdu; index++) { + sdu_index = ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index]; sdu = rlcP->input_sdus[sdu_index]; // mark the sdu as invalid except if confirm requested - if (!((struct rlc_am_tx_sdu_management *) (sdu->data))->confirm) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index] = -1; // tag sdu as non valid + if (!((struct rlc_am_tx_sdu_management*) (sdu->data))->confirm) { + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index] = -1; // tag sdu as non valid } - ((struct rlc_am_tx_sdu_management *) (sdu->data))->nb_pdus_time += 1; + ((struct rlc_am_tx_sdu_management*) (sdu->data))->nb_pdus_time += 1; - if ((((struct rlc_am_tx_sdu_management *) (sdu->data))->nb_pdus_time == - ((struct rlc_am_tx_sdu_management *) (sdu->data))->nb_pdus) && - !(((struct rlc_am_tx_sdu_management *) (sdu->data))->confirm) && (((struct rlc_am_tx_sdu_management *) (sdu->data))->segmented) + if ((((struct rlc_am_tx_sdu_management*) (sdu->data))->nb_pdus_time == + ((struct rlc_am_tx_sdu_management*) (sdu->data))->nb_pdus) && + !(((struct rlc_am_tx_sdu_management*) (sdu->data))->confirm) && (((struct rlc_am_tx_sdu_management*) (sdu->data))->segmented) ) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index] = -1; // tag sdu as non valid - + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index] = -1; // tag sdu as non valid // we can remove the sdu if timer based discard and all pdus submitted to lower layers and no confirm running free_mem_block (sdu); rlcP->input_sdus[sdu_index] = NULL; # ifdef DEBUG_RLC_AM_FREE_SDU msg ("[RLC_AM][RB %d] MUX FREE_SDU INDEX %d\n", rlcP->rb_id, sdu_index); # endif + } else { - ((struct rlc_am_tx_sdu_management *) (sdu->data))->last_pdu_sn = rlcP->vt_s; + ((struct rlc_am_tx_sdu_management*) (sdu->data))->last_pdu_sn = rlcP->vt_s; } } + } else if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_MAX_DAT_RETRANSMISSION)) { - for (index = 0; index < ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->nb_sdu; index++) { + for (index = 0; index < ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->nb_sdu; index++) { // update the sn of the last transmitted pdu were this sdu was segmented - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index]]->data))->last_pdu_sn = rlcP->vt_s; + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index]]->data))->last_pdu_sn = rlcP->vt_s; // register the sn of the pdus where the sdu was segmented - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index]]->data))-> - pdus_index[((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index]]->data))->nb_pdus_internal_use++] = rlcP->vt_s; + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index]]->data))-> + pdus_index[((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management*) ( + pdu->data))->sdu[index]]->data))->nb_pdus_internal_use++] = rlcP->vt_s; # ifdef DEBUG_MUX - msg ("[RLC_AM][RB %d] MUX SDU INDEX %d LINK PDU SN 0x%04X\n", rlcP->rb_id, ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index], rlcP->vt_s); + msg ("[RLC_AM][RB %d] MUX SDU INDEX %d LINK PDU SN 0x%04X\n", rlcP->rb_id, ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index], rlcP->vt_s); # endif } } rlcP->vt_s = (rlcP->vt_s + 1) & SN_12BITS_MASK; - - copy_pdu = get_free_mem_block (rlcP->pdu_size + sizeof (struct rlc_am_tx_data_pdu_allocation) + GUARD_CRC_LIH_SIZE); if (copy_pdu) { @@ -354,19 +356,15 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) # ifdef DEBUG_MUX rlc_am_display_data_pdu7(pdu); # endif - - - ((struct mac_tb_req *) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (copy_pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - ((struct mac_tb_req *) (copy_pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (copy_pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; + ((struct mac_tb_req*) (copy_pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (copy_pdu, &rlcP->pdus_to_mac_layer_ch1); nb_pdu_to_transmit_ch1--; data_pdu_tx++; - - # ifdef DEBUG_MUX id = (((uint16_t) (rlc_header->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | ((rlc_header->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); msg ("[RLC_AM][RB %d][MUX] TX DATA PDU 0x%04X VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", @@ -377,9 +375,11 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) msg("\n"); */ # endif + } else { msg ("[RLC_AM][RB %d][MUX] OUT OF MEMORY \n", rlcP->rb_id); } + } else { // segmentation returned no PDU segmentation_returned_pdu = 0; } @@ -396,7 +396,6 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) // - select the AMD PDU with "Sequence Number" equal to VT(S)-1; or // - select an AMD PDU that has not yet been acknowledged by the peer entity; // - schedule the selected AMD PDU for retransmission (in order to transmit a poll). - // The Sender may also schedule an AMD PDU for retransmission even if none of the criteria above is fulfilled. In this case, the Sender may: // - if the value of "Configured_Tx_Window_Size" is larger than or equal to "2048": // - select the AMD PDU with "Sequence Number" equal to VT(S)-1. @@ -404,11 +403,11 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) // - select the AMD PDU with "Sequence Number" equal to VT(S)-1; or // - select an AMD PDU that has not yet been acknowledged by the peer entity; // - schedule the selected AMD PDU for retransmission. - // TO DO : triggers "Poll timer" or "Timer based" if (!(data_pdu_tx)) { if (rlcP->configured_tx_window_size < 2048) { rlc_am_get_not_acknowledged_pdu_optimized (rlcP); + } else if (rlcP->vt_s != rlcP->vt_a) { rlc_am_get_not_acknowledged_pdu_optimized (rlcP);//rlc_am_get_not_acknowledged_pdu_vt_s_minus_1 (rlcP); } @@ -419,30 +418,27 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) if ((copy_pdu)) { // unlink the pdu in retransmission buffer and its copy (mechanism avoiding multi-retransmission of the same // pdu in the same queue) - pdu = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->copy; + pdu = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->copy; # ifdef DEBUG_MUX rlc_am_display_data_pdu7(copy_pdu); # endif - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->copy = NULL; - - ((struct mac_tb_req *) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (copy_pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - ((struct mac_tb_req *) (copy_pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->copy = NULL; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (copy_pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; + ((struct mac_tb_req*) (copy_pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (copy_pdu, &rlcP->pdus_to_mac_layer_ch1); nb_pdu_to_transmit_ch1--; data_pdu_tx++; // for polling rlcP->vt_pdu++; // set poll bit - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; - + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; # ifdef DEBUG_MUX - id = (((uint16_t) (((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | - ((((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); - + id = (((uint16_t) (((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | + ((((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); msg ("[RLC_AM][RB %d][MUX] RETRANSMIT DATA PDU 0x%04X VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif @@ -459,14 +455,13 @@ rlc_am_mux_ue (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) */ //----------------------------------------------------------------------------- void -rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) +rlc_am_mux_rg (struct rlc_am_entity* rlcP, unsigned int traffic_typeP) { //----------------------------------------------------------------------------- - - mem_block_t *pdu; - mem_block_t *sdu; - mem_block_t *copy_pdu = NULL; - struct rlc_am_pdu_header *rlc_header; + mem_block_t* pdu; + mem_block_t* sdu; + mem_block_t* copy_pdu = NULL; + struct rlc_am_pdu_header* rlc_header; int pool_is_set; int index; int sdu_index; @@ -474,7 +469,6 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) unsigned int data_pdu_tx; // data pdu effectively transmitted unsigned int tx_pdu; static unsigned int last_scheduled; - int16_t nb_pdu_to_transmit_ch1; int16_t nb_pdu_to_transmit_ch2; # ifdef DEBUG_MUX @@ -501,9 +495,11 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) if ((traffic_typeP & RLC_AM_TRAFFIC_ALLOWED_FOR_STATUS)) { tx_pdu = 1; + } else { - if (((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { + if (((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { tx_pdu = 1; + } else { tx_pdu = 0; } @@ -513,31 +509,35 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) nb_pdu_to_transmit_ch1--; // for polling rlcP->vt_pdu++; - ((struct mac_tb_req *) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct mac_tb_req*) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer_ch1); rlcP->stat_tx_control_pdu += 1; # ifdef DEBUG_MUX msg ("[RLC_AM][RB %d][MUX] TX CONTROL PDU CH1 VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif + } else { free_mem_block (pdu); } } + } else if (rlcP->nb_logical_channels_per_rlc == 2) { while ((rlcP->control.head) && (nb_pdu_to_transmit_ch2)) { pdu = list_remove_head (&rlcP->control); if ((traffic_typeP & RLC_AM_TRAFFIC_ALLOWED_FOR_STATUS)) { tx_pdu = 1; + } else { - if (((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { + if (((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { tx_pdu = 1; + } else { tx_pdu = 0; } @@ -547,19 +547,19 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) nb_pdu_to_transmit_ch2--; // for polling rlcP->vt_pdu++; - ((struct mac_tb_req *) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct mac_tb_req*) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer_ch2); rlcP->stat_tx_control_pdu += 1; - # ifdef DEBUG_MUX msg ("[RLC_AM][RB %d][MUX] TX CONTROL PDU CH2 VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif + } else { free_mem_block (pdu); } @@ -570,9 +570,11 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) if ((traffic_typeP & RLC_AM_TRAFFIC_ALLOWED_FOR_STATUS)) { tx_pdu = 1; + } else { - if (((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { + if (((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type & (RLC_AM_RESET_PDU_TYPE | RLC_AM_RESET_ACK_PDU_TYPE)) { tx_pdu = 1; + } else { tx_pdu = 0; } @@ -582,20 +584,19 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) nb_pdu_to_transmit_ch1--; // for polling rlcP->vt_pdu++; - ((struct mac_tb_req *) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management *) (copy_pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct mac_tb_req*) (pdu->data))->rlc_tb_type = ((struct rlc_am_tx_control_pdu_management*) (copy_pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer_ch1); rlcP->stat_tx_control_pdu += 1; - - # ifdef DEBUG_MUX msg ("[RLC_AM][RB %d][MUX] TX CONTROL PDU CH1 VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif + } else { free_mem_block (pdu); } @@ -609,25 +610,21 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) while ((rlcP->retransmission_buffer_to_send.head) && (nb_pdu_to_transmit_ch1) && !(rlcP->protocol_state & RLC_RESET_PENDING_STATE)) { // each retransmission may send RLC in RESET STATE if no discard is configured copy_pdu = list2_remove_head (&rlcP->retransmission_buffer_to_send); - // unlink the pdu in retransmission buffer and its copy (mechanism avoiding multi-retransmission of the same // pdu in the same queue) - pdu = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->copy; + pdu = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->copy; # ifdef DEBUG_MUX rlc_am_display_data_pdu7(copy_pdu); # endif - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->copy = NULL; - - ((struct mac_tb_req *) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (copy_pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - ((struct mac_tb_req *) (copy_pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; - + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->copy = NULL; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (copy_pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; + ((struct mac_tb_req*) (copy_pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (copy_pdu, &rlcP->pdus_to_mac_layer_ch1); rlcP->stat_tx_retransmit_pdu += 1; - nb_pdu_to_transmit_ch1--; data_pdu_tx++; @@ -637,19 +634,19 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) if (rlcP->vt_pdu >= rlcP->poll_pdu_trigger) { // set poll bit - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; rlcP->vt_pdu = 0; + } else { // reset poll bit - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 = - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & ~RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 = + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & ~RLC_AM_P_STATUS_REPORT_REQUESTED; } } # ifdef DEBUG_MUX - id = (((uint16_t) (((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | - ((((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); - + id = (((uint16_t) (((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | + ((((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); msg ("[RLC_AM][RB %d][MUX] RETRANSMIT DATA PDU %04X VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif @@ -658,22 +655,19 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) while ((rlcP->retransmission_buffer_to_send.head) && (nb_pdu_to_transmit_ch2) && !(rlcP->protocol_state & RLC_RESET_PENDING_STATE)) { // each retransmission may send RLC in RESET STATE if no discard is configured copy_pdu = list2_remove_head (&rlcP->retransmission_buffer_to_send); - // unlink the pdu in retransmission buffer and its copy (mechanism avoiding multi-retransmission of the same // pdu in the same queue) - pdu = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->copy; + pdu = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->copy; # ifdef DEBUG_MUX rlc_am_display_data_pdu7(copy_pdu); # endif - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->copy = NULL; - - ((struct mac_tb_req *) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (copy_pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - ((struct mac_tb_req *) (copy_pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; - + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->copy = NULL; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (copy_pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; + ((struct mac_tb_req*) (copy_pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (copy_pdu, &rlcP->pdus_to_mac_layer_ch2); rlcP->stat_tx_retransmit_pdu += 1; nb_pdu_to_transmit_ch2--; @@ -688,19 +682,19 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) # ifdef DEBUG_RLC_AM_POLL msg ("[RLC_AM %p] POOL SET BY poll_pdu trigger RETRANS PDU\n", rlcP); # endif - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; rlcP->vt_pdu = 0; + } else { // reset poll bit - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 = - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & ~RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 = + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & ~RLC_AM_P_STATUS_REPORT_REQUESTED; } } # ifdef DEBUG_MUX - id = (((uint16_t) (((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | - ((((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); - + id = (((uint16_t) (((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | + ((((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); msg ("[RLC_AM][RB %d][MUX] RETRANSMIT DATA PDU 0x%04X VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif @@ -713,10 +707,8 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) segmentation_returned_pdu = 1; while (((nb_pdu_to_transmit_ch1) || (nb_pdu_to_transmit_ch2)) && (rlcP->vt_s != rlcP->vt_ms) && (segmentation_returned_pdu)) { - if ((pdu = rlcP->rlc_segment (rlcP))) { - - rlc_header = (struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]); + rlc_header = (struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]); // check polling pool_is_set = 0; @@ -725,8 +717,8 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) // test every poll_PDU trigger if (rlcP->vt_pdu >= rlcP->poll_pdu_trigger) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; - ((struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; rlcP->vt_pdu = 0; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL @@ -736,25 +728,26 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) } // test every poll_SDU trigger - if ((rlcP->poll_sdu_trigger) && (((struct rlc_am_tx_data_pdu_management *) (pdu->data))->last_pdu_of_sdu)) { + if ((rlcP->poll_sdu_trigger) && (((struct rlc_am_tx_data_pdu_management*) (pdu->data))->last_pdu_of_sdu)) { if (rlcP->vt_sdu >= rlcP->poll_sdu_trigger) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; - ((struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; rlcP->vt_sdu = 0; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL msg ("[RLC_AM %p] POOL SET BY poll_sdu trigger\n", rlcP); # endif + } else { - rlcP->vt_sdu += ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->last_pdu_of_sdu; + rlcP->vt_sdu += ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->last_pdu_of_sdu; } } if (!pool_is_set) { // test last pdu in transmission buffer trigger == last sdu in input buffer in this implementation of RLC AM if ((rlcP->last_transmission_pdu_poll_trigger > 0) && (rlcP->nb_sdu == 0)) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; - ((struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL msg ("[RLC_AM %p] POOL SET BY last pdu in tr buffer trigger\n", rlcP); @@ -763,9 +756,10 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) if (!pool_is_set) { // test last pdu in retransmission buffer trigger - if ((rlcP->retransmission_buffer_to_send.head) && (rlcP->retransmission_buffer_to_send.head == rlcP->retransmission_buffer_to_send.tail) && (rlcP->last_retransmission_pdu_poll_trigger)) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; - ((struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; + if ((rlcP->retransmission_buffer_to_send.head) && (rlcP->retransmission_buffer_to_send.head == rlcP->retransmission_buffer_to_send.tail) + && (rlcP->last_retransmission_pdu_poll_trigger)) { + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL msg ("[RLC_AM %p] POOL SET BY last pdu in retrans buffer trigger\n", rlcP); @@ -778,8 +772,8 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) j = (unsigned int) (((rlcP->vt_s + 4096) - rlcP->vt_a) % 4096) * 100 / rlcP->vt_ws; if (j >= rlcP->poll_window_trigger) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; - ((struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_DATA_POLL_PDU_TYPE; + ((struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; pool_is_set = 1; # ifdef DEBUG_RLC_AM_POLL msg ("[RLC_AM %p] POOL SET BY window based trigger J=%d\n", rlcP, j); @@ -792,54 +786,54 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) rlc_header->byte1 |= (rlcP->vt_s >> 5); rlc_header->byte2 |= ((uint8_t) rlcP->vt_s << 3); - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sn = rlcP->vt_s; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sn = rlcP->vt_s; insert_into_retransmission_buffer (rlcP, rlcP->vt_s % rlcP->recomputed_configured_tx_window_size, pdu); // check if timer based discard configured if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_TIMER_BASED_EXPLICIT)) { - for (index = 0; index < ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->nb_sdu; index++) { - sdu_index = ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index]; + for (index = 0; index < ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->nb_sdu; index++) { + sdu_index = ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index]; sdu = rlcP->input_sdus[sdu_index]; // mark the sdu as invalid except if confirm requested - if (!((struct rlc_am_tx_sdu_management *) (sdu->data))->confirm) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index] = -1; // tag sdu as non valid + if (!((struct rlc_am_tx_sdu_management*) (sdu->data))->confirm) { + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index] = -1; // tag sdu as non valid } - ((struct rlc_am_tx_sdu_management *) (sdu->data))->nb_pdus_time += 1; + ((struct rlc_am_tx_sdu_management*) (sdu->data))->nb_pdus_time += 1; - if ((((struct rlc_am_tx_sdu_management *) (sdu->data))->nb_pdus_time == - ((struct rlc_am_tx_sdu_management *) (sdu->data))->nb_pdus) && - !(((struct rlc_am_tx_sdu_management *) (sdu->data))->confirm) && (((struct rlc_am_tx_sdu_management *) (sdu->data))->segmented) + if ((((struct rlc_am_tx_sdu_management*) (sdu->data))->nb_pdus_time == + ((struct rlc_am_tx_sdu_management*) (sdu->data))->nb_pdus) && + !(((struct rlc_am_tx_sdu_management*) (sdu->data))->confirm) && (((struct rlc_am_tx_sdu_management*) (sdu->data))->segmented) ) { - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index] = -1; // tag sdu as non valid - + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index] = -1; // tag sdu as non valid // we can remove the sdu if timer based discard and all pdus submitted to lower layers and no confirm running free_mem_block (sdu); rlcP->input_sdus[sdu_index] = NULL; # ifdef DEBUG_RLC_AM_FREE_SDU msg ("[RLC_AM][RB %d] MUX FREE_SDU INDEX %d\n", rlcP->rb_id, sdu_index); # endif + } else { - ((struct rlc_am_tx_sdu_management *) (sdu->data))->last_pdu_sn = rlcP->vt_s; + ((struct rlc_am_tx_sdu_management*) (sdu->data))->last_pdu_sn = rlcP->vt_s; } } + } else if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_MAX_DAT_RETRANSMISSION)) { - for (index = 0; index < ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->nb_sdu; index++) { + for (index = 0; index < ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->nb_sdu; index++) { // update the sn of the last transmitted pdu were this sdu was segmented - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index]]->data))->last_pdu_sn = rlcP->vt_s; + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index]]->data))->last_pdu_sn = rlcP->vt_s; // register the sn of the pdus where the sdu was segmented - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index]]->data))-> - pdus_index[((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index]]->data))->nb_pdus_internal_use++] = rlcP->vt_s; + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index]]->data))-> + pdus_index[((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[((struct rlc_am_tx_data_pdu_management*) ( + pdu->data))->sdu[index]]->data))->nb_pdus_internal_use++] = rlcP->vt_s; # ifdef DEBUG_MUX - msg ("[RLC_AM][RB %d] MUX SDU INDEX %d LINK PDU SN 0x%04X\n", rlcP->rb_id, ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->sdu[index], rlcP->vt_s); + msg ("[RLC_AM][RB %d] MUX SDU INDEX %d LINK PDU SN 0x%04X\n", rlcP->rb_id, ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->sdu[index], rlcP->vt_s); # endif } } rlcP->vt_s = (rlcP->vt_s + 1) & SN_12BITS_MASK; - - copy_pdu = get_free_mem_block (rlcP->pdu_size + sizeof (struct rlc_am_tx_data_pdu_allocation) + GUARD_CRC_LIH_SIZE); if (copy_pdu) { @@ -847,17 +841,18 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) # ifdef DEBUG_MUX rlc_am_display_data_pdu7(copy_pdu); # endif - ((struct mac_tb_req *) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (copy_pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - ((struct mac_tb_req *) (copy_pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (copy_pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; + ((struct mac_tb_req*) (copy_pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; if ((nb_pdu_to_transmit_ch1)) { list_add_tail_eurecom (copy_pdu, &rlcP->pdus_to_mac_layer_ch1); rlcP->stat_tx_data_pdu += 1; nb_pdu_to_transmit_ch1--; + } else if ((nb_pdu_to_transmit_ch2)) { list_add_tail_eurecom (copy_pdu, &rlcP->pdus_to_mac_layer_ch2); rlcP->stat_tx_data_pdu += 1; @@ -865,11 +860,9 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) } data_pdu_tx++; - - # ifdef DEBUG_MUX - id = (((uint16_t) (((struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | - ((((struct rlc_am_pdu_header *) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); + id = (((uint16_t) (((struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | + ((((struct rlc_am_pdu_header*) (&pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); msg ("[RLC_AM][RB %d][MUX] TX DATA PDU 0x%04X VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); /* for (index = 0; index < 32 ; index++) { @@ -878,9 +871,11 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) msg("\n"); */ # endif + } else { msg ("[RLC_AM][RB %d][MUX] OUT OF MEMORY \n", rlcP->rb_id); } + } else { // segmentation returned no PDU segmentation_returned_pdu = 0; } @@ -897,7 +892,6 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) // - select the AMD PDU with "Sequence Number" equal to VT(S)-1; or // - select an AMD PDU that has not yet been acknowledged by the peer entity; // - schedule the selected AMD PDU for retransmission (in order to transmit a poll). - // The Sender may also schedule an AMD PDU for retransmission even if none of the criteria above is fulfilled. In this case, the Sender may: // - if the value of "Configured_Tx_Window_Size" is larger than or equal to "2048": // - select the AMD PDU with "Sequence Number" equal to VT(S)-1. @@ -905,42 +899,39 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) // - select the AMD PDU with "Sequence Number" equal to VT(S)-1; or // - select an AMD PDU that has not yet been acknowledged by the peer entity; // - schedule the selected AMD PDU for retransmission. - // TO DO : triggers "Poll timer" or "Timer based" if (!(data_pdu_tx)) { // this variable last_scheduled is used because a RLC may be scheduled // when several DSCH are configured in the RG if ((last_scheduled != (unsigned int) Mac_rlc_xface->frame) && (((unsigned int) Mac_rlc_xface->frame) % 48 == 0) ) { - if (rlcP->configured_tx_window_size < 2048) { // rlc_am_get_not_acknowledged_pdu(rlcP); rlc_am_get_not_acknowledged_pdu_optimized (rlcP); //rlc_am_get_not_acknowledged_pdu_vt_s_minus_1 (rlcP); // LG JUST FOR TEST + } else if (rlcP->vt_s != rlcP->vt_a) { rlc_am_get_not_acknowledged_pdu_optimized (rlcP);//rlc_am_get_not_acknowledged_pdu_vt_s_minus_1 (rlcP); } } last_scheduled = (unsigned int) Mac_rlc_xface->frame; - // each retransmission may send RLC in RESET STATE if no discard is configured copy_pdu = list2_remove_head (&rlcP->retransmission_buffer_to_send); if ((copy_pdu)) { // unlink the pdu in retransmission buffer and its copy (mechanism avoiding multi-retransmission of the same // pdu in the same queue) - pdu = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->copy; + pdu = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->copy; # ifdef DEBUG_MUX rlc_am_display_data_pdu7(copy_pdu); # endif - ((struct rlc_am_tx_data_pdu_management *) (pdu->data))->copy = NULL; - - ((struct mac_tb_req *) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management *) (copy_pdu->data))->rlc_tb_type; - ((struct mac_tb_req *) (copy_pdu->data))->rlc = rlcP; - ((struct mac_tb_req *) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; - ((struct mac_tb_req *) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - ((struct mac_tb_req *) (copy_pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; + ((struct rlc_am_tx_data_pdu_management*) (pdu->data))->copy = NULL; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_tb_type = ((struct rlc_am_tx_data_pdu_management*) (copy_pdu->data))->rlc_tb_type; + ((struct mac_tb_req*) (copy_pdu->data))->rlc = rlcP; + ((struct mac_tb_req*) (copy_pdu->data))->rlc_callback = rlc_am_status_report_from_mac; + ((struct mac_tb_req*) (copy_pdu->data))->data_ptr = ©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; + ((struct mac_tb_req*) (copy_pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (copy_pdu->data))->tb_size_in_bits = rlcP->pdu_size << 3; list_add_tail_eurecom (copy_pdu, &rlcP->pdus_to_mac_layer_ch1); rlcP->stat_tx_retransmit_pdu += 1; nb_pdu_to_transmit_ch1--; @@ -948,12 +939,10 @@ rlc_am_mux_rg (struct rlc_am_entity *rlcP, unsigned int traffic_typeP) // for polling rlcP->vt_pdu++; // set poll bit - ((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; - + ((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 |= RLC_AM_P_STATUS_REPORT_REQUESTED; # ifdef DEBUG_MUX - id = (((uint16_t) (((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | - ((((struct rlc_am_pdu_header *) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); - + id = (((uint16_t) (((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | + ((((struct rlc_am_pdu_header*) (©_pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]))->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); msg ("[RLC_AM][RB %d][MUX] RETRANSMIT DATA PDU 0x%04X VT(A) 0x%03X VT(S) 0x%03X VT(MS) 0x%03X VR(R) 0x%03X VR(MR) 0x%03X\n", rlcP->rb_id, id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vr_r, rlcP->vr_mr); # endif diff --git a/openair2/LAYER2/RLC/AM/rlc_am_reassembly.c b/openair2/LAYER2/RLC/AM/rlc_am_reassembly.c index 77ef165bc70..89705460266 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_reassembly.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_reassembly.c @@ -52,7 +52,7 @@ //----------------------------------------------------------------------------- void -reassembly (uint8_t * srcP, uint16_t lengthP, struct rlc_am_entity *rlcP) +reassembly (uint8_t* srcP, uint16_t lengthP, struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- int sdu_max_size_allowed; @@ -65,6 +65,7 @@ reassembly (uint8_t * srcP, uint16_t lengthP, struct rlc_am_entity *rlcP) if ((rlcP->data_plane)) { sdu_max_size_allowed = RLC_SDU_MAX_SIZE_DATA_PLANE; + } else { sdu_max_size_allowed = RLC_SDU_MAX_SIZE_CONTROL_PLANE; } @@ -92,19 +93,20 @@ reassembly (uint8_t * srcP, uint16_t lengthP, struct rlc_am_entity *rlcP) // OOOPS if ((lengthP + rlcP->output_sdu_size_to_write) <= sdu_max_size_allowed) { - memcpy (&rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write], srcP, lengthP); rlcP->output_sdu_size_to_write += lengthP; + } else { rlcP->output_sdu_size_to_write = 0; #ifdef DEBUG_REASSEMBLY - msg ("[RLC_AM %p][REASSEMBLY] ERROR SDU IN CONSTRUCTION TOO BIG %d Bytes MAX SIZE ALLOWED %d\n", rlcP, lengthP + rlcP->output_sdu_size_to_write, sdu_max_size_allowed); + msg ("[RLC_AM %p][REASSEMBLY] ERROR SDU IN CONSTRUCTION TOO BIG %d Bytes MAX SIZE ALLOWED %d\n", rlcP, lengthP + rlcP->output_sdu_size_to_write, + sdu_max_size_allowed); #endif } - } #ifdef DEBUG_REASSEMBLY + else { msg ("[RLC_AM %p][REASSEMBLY] ERROR OUTPUT SDU IS NULL\n", rlcP); } @@ -114,22 +116,16 @@ reassembly (uint8_t * srcP, uint16_t lengthP, struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -send_sdu (struct rlc_am_entity *rlcP) +send_sdu (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- if ((rlcP->output_sdu_in_construction) && (rlcP->output_sdu_size_to_write)) { - #ifdef DEBUG_RLC_AM_SEND_SDU msg ("[RLC_AM][RB %d][SEND_SDU] send_SDU() %d bytes\n", rlcP->rb_id, rlcP->output_sdu_size_to_write); #endif - - - - #ifdef BENCH_QOS_L2 fprintf (bench_l2, "[SDU DELIVERY] FRAME %d SIZE %d RB %d RLC-AM %p\n", Mac_rlc_xface->frame, rlcP->output_sdu_size_to_write, rlcP->rb_id, rlcP); #endif - rlc_data_ind (rlcP->module_id, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction, rlcP->data_plane); rlcP->output_sdu_in_construction = NULL; rlcP->output_sdu_size_to_write = 0; diff --git a/openair2/LAYER2/RLC/AM/rlc_am_receiver.c b/openair2/LAYER2/RLC/AM/rlc_am_receiver.c index 3f1254e1f73..fcbd565c8a6 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_receiver.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_receiver.c @@ -50,20 +50,18 @@ //#define DEBUG_REASSEMBLY //#define DEBUG_STATUS //----------------------------------------------------------------------------- -void receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pduP, struct rlc_am_pdu_header *rlc_headerP); -void free_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t indexP); -void insert_into_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t indexP, mem_block_t * pduP); -void process_receiver_buffer_15 (struct rlc_am_entity *rlcP); -void process_receiver_buffer_7 (struct rlc_am_entity *rlcP); +void receiver_retransmission_management (struct rlc_am_entity* rlcP, mem_block_t* pduP, struct rlc_am_pdu_header* rlc_headerP); +void free_receiver_buffer (struct rlc_am_entity* rlcP, uint16_t indexP); +void insert_into_receiver_buffer (struct rlc_am_entity* rlcP, uint16_t indexP, mem_block_t* pduP); +void process_receiver_buffer_15 (struct rlc_am_entity* rlcP); +void process_receiver_buffer_7 (struct rlc_am_entity* rlcP); //----------------------------------------------------------------------------- void -receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pduP, struct rlc_am_pdu_header *rlc_headerP) +receiver_retransmission_management (struct rlc_am_entity* rlcP, mem_block_t* pduP, struct rlc_am_pdu_header* rlc_headerP) { //----------------------------------------------------------------------------- - uint16_t id; uint16_t id_index; - /* From TS25.3222 V5.0.0 Upon reception of an AMD PDU, the Receiver shall: - update VR(R), VR(H) and VR(MR) state variables for each received AMD PDU (see clause 9.4); @@ -76,19 +74,14 @@ receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pd the peer entity) to upper layers through the AM-SAP. - otherwise: (NOT IMPLEMENTED) - deliver the RLC SDUs in arbitrary order to upper layers through the AM-SAP. */ - #ifdef DEBUG_RECEIVER_BUFFER msg("[RLC_AM][DEBUG] receiver_retransmission_management() received PDU %p\n", pduP); display_protocol_vars_rlc_am(rlcP); #endif - id = (((uint16_t) (rlc_headerP->byte1 & RLC_AM_SN_1ST_PART_MASK)) << 5) | ((rlc_headerP->byte2 & RLC_AM_SN_2ND_PART_MASK) >> 3); - // general case - ((struct rlc_am_rx_pdu_management *) (pduP->data))->sn = id; - + ((struct rlc_am_rx_pdu_management*) (pduP->data))->sn = id; id_index = id % rlcP->recomputed_configured_rx_window_size; - #ifdef DEBUG_RECEIVER_BUFFER msg("[RLC][RB %d][DEBUG] receiver_retransmission_management() received PDU %04X :\n", rlcP->rb_id, id); //display_protocol_vars_rlc_am(rlcP); @@ -103,7 +96,6 @@ receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pd } if (id == rlcP->vr_r) { - #ifdef DEBUG_RECEIVER_BUFFER msg ("[RLC_AM][RB %d][RECEIVER_BUFFER] RECEIVED %p VR(R)=0x%04X id_index=0x%02X VR(H)=0x%04X\n", rlcP->rb_id, pduP, rlcP->vr_r, id_index, rlcP->vr_h); #endif @@ -115,11 +107,12 @@ receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pd } adjust_vr_r_mr (rlcP); - } else { + } else { rlcP->send_status_pdu_requested = 1; #ifdef DEBUG_RECEIVER_BUFFER - msg ("[RLC_AM][RB %d][RECEIVER_BUFFER] RECEIVED %p sn=0x%04X id_index=0x%02X VR(R)=0x%04X VR(H)=0x%04X WILL SEND STATUS\n", rlcP->rb_id, pduP, id, id_index, rlcP->vr_r, rlcP->vr_h); + msg ("[RLC_AM][RB %d][RECEIVER_BUFFER] RECEIVED %p sn=0x%04X id_index=0x%02X VR(R)=0x%04X VR(H)=0x%04X WILL SEND STATUS\n", rlcP->rb_id, pduP, id, id_index, + rlcP->vr_r, rlcP->vr_h); #endif //------------------------------------; @@ -140,8 +133,9 @@ receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pd // CASE id<VR(MR)<VR(R)<VR(H); //------------------------------------; // CASE VR(MR)<VR(R)<VR(H)<id; - } else if (((rlcP->vr_mr < rlcP->vr_r) && (rlcP->vr_h >= rlcP->vr_r) && (id < rlcP->vr_mr)) || ((rlcP->vr_mr < rlcP->vr_r) && (rlcP->vr_h >= rlcP->vr_r) && (id > rlcP->vr_r))) { + } else if (((rlcP->vr_mr < rlcP->vr_r) && (rlcP->vr_h >= rlcP->vr_r) && (id < rlcP->vr_mr)) || ((rlcP->vr_mr < rlcP->vr_r) && (rlcP->vr_h >= rlcP->vr_r) + && (id > rlcP->vr_r))) { #ifdef DEBUG_RECEIVER_BUFFER msg ("[RLC_AM][RB %d][RECEIVER_BUFFER] RECEIVED %p sn 0x%04X IN REVERSED WINDOW\n", rlcP->rb_id, pduP, id); #endif @@ -154,6 +148,7 @@ receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pd //------------------------------------; // CASE VR(H)<VR(MR)<VR(R); //------------------------------------; + } else if ((rlcP->vr_h <= rlcP->vr_mr) && (rlcP->vr_mr < rlcP->vr_r)) { if (id < rlcP->vr_mr) { #ifdef DEBUG_RECEIVER_BUFFER @@ -164,11 +159,13 @@ receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pd if (id >= rlcP->vr_h) { rlcP->vr_h = (id + 1) & SN_12BITS_MASK; } + } else if (id > rlcP->vr_r) { #ifdef DEBUG_RECEIVER_BUFFER msg ("[RLC_AM][RB %d][RECEIVER_BUFFER] RECEIVED %p sn 0x%04X IN REVERSED WINDOW\n", rlcP->rb_id, pduP, id); #endif insert_into_receiver_buffer (rlcP, id_index, pduP); + } else { // discard this PDU; #ifdef DEBUG_RECEIVER_BUFFER @@ -181,6 +178,7 @@ receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pd //------------------------------------; // REJECT; //------------------------------------; + } else { // discard this PDU; #ifdef DEBUG_RECEIVER_BUFFER @@ -194,7 +192,7 @@ receiver_retransmission_management (struct rlc_am_entity *rlcP, mem_block_t * pd //----------------------------------------------------------------------------- void -free_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t indexP) +free_receiver_buffer (struct rlc_am_entity* rlcP, uint16_t indexP) { //----------------------------------------------------------------------------- if (indexP < rlcP->recomputed_configured_rx_window_size) { @@ -214,7 +212,7 @@ free_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t indexP) //----------------------------------------------------------------------------- void -insert_into_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t indexP, mem_block_t * pduP) +insert_into_receiver_buffer (struct rlc_am_entity* rlcP, uint16_t indexP, mem_block_t* pduP) { //----------------------------------------------------------------------------- if (pduP) { @@ -246,46 +244,39 @@ insert_into_receiver_buffer (struct rlc_am_entity *rlcP, uint16_t indexP, mem_bl //----------------------------------------------------------------------------- void -process_receiver_buffer_15 (struct rlc_am_entity *rlcP) +process_receiver_buffer_15 (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - - struct rlc_am_pdu_header *rlc_header; - mem_block_t *pdu; + struct rlc_am_pdu_header* rlc_header; + mem_block_t* pdu; uint16_t vr_r; uint16_t working_sn; uint16_t working_sn_index; // index in buffer - uint8_t *data_pdu; + uint8_t* data_pdu; uint16_t li[RLC_AM_SEGMENT_NB_MAX_LI_PER_PDU]; uint16_t remaining_data_size; uint8_t nb_li; uint8_t li_index; uint8_t li_start_index; uint8_t reassembly_after_discard; - - // should start reassembly with sn working_sn working_sn = (rlcP->last_reassemblied_sn + 1) & SN_12BITS_MASK; working_sn_index = working_sn % rlcP->recomputed_configured_rx_window_size; - vr_r = rlcP->vr_r; reassembly_after_discard = 0; while (rlcP->receiver_buffer[working_sn_index]) { - pdu = rlcP->receiver_buffer[working_sn_index]; nb_li = 0; li_index = 0; - rlc_header = (struct rlc_am_pdu_header *) (((struct rlc_am_rx_pdu_management *) (pdu->data))->first_byte); - - if ((rlcP->discard_reassembly_start_sn == ((struct rlc_am_rx_pdu_management *) (pdu->data))->sn)) { + rlc_header = (struct rlc_am_pdu_header*) (((struct rlc_am_rx_pdu_management*) (pdu->data))->first_byte); + if ((rlcP->discard_reassembly_start_sn == ((struct rlc_am_rx_pdu_management*) (pdu->data))->sn)) { rlcP->output_sdu_size_to_write = 0; reassembly_after_discard = 1; // keep trace of entering in this block if (!(rlc_header->byte2 & RLC_HE_MASK) == RLC_HE_SUCC_BYTE_CONTAINS_DATA) { while ((li[nb_li] = ((((uint16_t) rlc_header->li_data_7[nb_li << 1]) << 8) + rlc_header->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { - li[nb_li] = li[nb_li] & (~(uint16_t) RLC_E_NEXT_FIELD_IS_LI_E); nb_li++; } @@ -298,10 +289,8 @@ process_receiver_buffer_15 (struct rlc_am_entity *rlcP) li_start_index = rlcP->discard_reassembly_after_li; // reassembly will start at this index // after reception of sufi mrw the starting index for li will be 0 rlcP->discard_reassembly_after_li = RLC_AM_DISCARD_REASSEMBLY_AT_LI_INDEX_0; // =-1 - - remaining_data_size = rlcP->pdu_size - 2 - (nb_li << 1); - data_pdu = (uint8_t *) (&rlc_header->li_data_7[nb_li << 1]); + data_pdu = (uint8_t*) (&rlc_header->li_data_7[nb_li << 1]); while (li_index < nb_li) { switch (li[li_index]) { @@ -333,7 +322,7 @@ process_receiver_buffer_15 (struct rlc_am_entity *rlcP) send_sdu (rlcP); } - data_pdu = (uint8_t *) ((uint32_t) data_pdu + (li[li_index] >> 1)); + data_pdu = (uint8_t*) ((uint32_t) data_pdu + (li[li_index] >> 1)); } li_index++; @@ -344,7 +333,6 @@ process_receiver_buffer_15 (struct rlc_am_entity *rlcP) remaining_data_size = 0; } - free_receiver_buffer (rlcP, working_sn_index); rlcP->discard_reassembly_start_sn = RLC_AM_SN_INVALID; rlcP->last_reassemblied_sn = working_sn; @@ -363,7 +351,8 @@ process_receiver_buffer_15 (struct rlc_am_entity *rlcP) } else { // exploit HE field info if ((rlc_header->byte2 & RLC_HE_MASK) == RLC_HE_SUCC_BYTE_CONTAINS_DATA) { - reassembly ((uint8_t *) (rlc_header->li_data_7), rlcP->pdu_size - 2, rlcP); + reassembly ((uint8_t*) (rlc_header->li_data_7), rlcP->pdu_size - 2, rlcP); + } else { while ((li[nb_li] = ((((uint16_t) rlc_header->li_data_7[nb_li << 1]) << 8) + rlc_header->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { //while ((li[nb_li] = (rlc_header->li.li_data_15[nb_li].optional)) & RLC_E_NEXT_FIELD_IS_LI_E) { @@ -372,9 +361,8 @@ process_receiver_buffer_15 (struct rlc_am_entity *rlcP) } nb_li++; - remaining_data_size = rlcP->pdu_size - 2 - (nb_li << 1); - data_pdu = (uint8_t *) (&rlc_header->li_data_7[nb_li << 1]); + data_pdu = (uint8_t*) (&rlc_header->li_data_7[nb_li << 1]); while (li_index < nb_li) { switch (li[li_index]) { @@ -395,7 +383,7 @@ process_receiver_buffer_15 (struct rlc_am_entity *rlcP) default: // li is length remaining_data_size = remaining_data_size - (li[li_index] >> 1); reassembly (data_pdu, (li[li_index] >> 1), rlcP); - data_pdu = (uint8_t *) ((uint32_t) data_pdu + (li[li_index] >> 1)); + data_pdu = (uint8_t*) ((uint32_t) data_pdu + (li[li_index] >> 1)); send_sdu (rlcP); } @@ -422,7 +410,6 @@ process_receiver_buffer_15 (struct rlc_am_entity *rlcP) #ifdef DEBUG_REASSEMBLY msg ("[RLC_AM][RB %d][REASSEMBLY] DETECTED PDU AFTER DISCARD ADJUST VR(R) 0x%04X\n", rlcP->rb_id, rlcP->vr_r); #endif - rlcP->vr_mr = (rlcP->vr_r + rlcP->configured_rx_window_size - 1) & SN_12BITS_MASK; } } @@ -432,15 +419,15 @@ process_receiver_buffer_15 (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -process_receiver_buffer_7 (struct rlc_am_entity *rlcP) +process_receiver_buffer_7 (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - struct rlc_am_pdu_header *rlc_header; - mem_block_t *pdu; + struct rlc_am_pdu_header* rlc_header; + mem_block_t* pdu; uint16_t vr_r; uint16_t working_sn; uint16_t working_sn_index; // index in buffer - uint8_t *data_pdu; + uint8_t* data_pdu; uint8_t li[RLC_AM_SEGMENT_NB_MAX_LI_PER_PDU]; uint16_t remaining_data_size; int8_t nb_li; @@ -448,27 +435,22 @@ process_receiver_buffer_7 (struct rlc_am_entity *rlcP) int8_t li_start_index; uint8_t reassembly_after_discard; uint8_t sdu_sent=0; - // should start reassembly with sn working_sn working_sn = (rlcP->last_reassemblied_sn + 1) & SN_12BITS_MASK; working_sn_index = working_sn % rlcP->recomputed_configured_rx_window_size; - vr_r = rlcP->vr_r; - reassembly_after_discard = 0; while (rlcP->receiver_buffer[working_sn_index]) { - pdu = rlcP->receiver_buffer[working_sn_index]; nb_li = 0; li_index = 0; - rlc_header = (struct rlc_am_pdu_header *) (((struct rlc_am_rx_pdu_management *) (pdu->data))->first_byte); - + rlc_header = (struct rlc_am_pdu_header*) (((struct rlc_am_rx_pdu_management*) (pdu->data))->first_byte); #ifdef DEBUG_REASSEMBLY msg ("[RLC_AM][RB %d][REASSEMBLY] PDU %p SN 0x%04X (sdu_sent %d)\n", rlcP->rb_id, pdu, working_sn,sdu_sent); #endif - if ((rlcP->discard_reassembly_start_sn == ((struct rlc_am_rx_pdu_management *) (pdu->data))->sn)) { + if ((rlcP->discard_reassembly_start_sn == ((struct rlc_am_rx_pdu_management*) (pdu->data))->sn)) { rlcP->output_sdu_size_to_write = 0; reassembly_after_discard = 1; // keep trace of entering in this block @@ -482,24 +464,23 @@ process_receiver_buffer_7 (struct rlc_am_entity *rlcP) } #ifdef DEBUG_REASSEMBLY - msg ("[RLC_AM][RB %d][REASSEMBLY] DETECTED PDU TO BE REASSEMBLIED AFTER DISCARD, START SN 0x%04X hex VR(R) 0x%04X\n", rlcP->rb_id, rlcP->discard_reassembly_start_sn, rlcP->vr_r); + msg ("[RLC_AM][RB %d][REASSEMBLY] DETECTED PDU TO BE REASSEMBLIED AFTER DISCARD, START SN 0x%04X hex VR(R) 0x%04X\n", rlcP->rb_id, + rlcP->discard_reassembly_start_sn, rlcP->vr_r); #endif - // this variable may be changed by the reception of a mrw sufi //li_start_index = rlcP->discard_reassembly_after_li + 1; // reassembly will start at this index li_start_index = rlcP->discard_reassembly_after_li; // reassembly will start at this index // after reception of sufi mrw the starting index for li will be 0 rlcP->discard_reassembly_after_li = RLC_AM_DISCARD_REASSEMBLY_AT_LI_INDEX_0; // =-1 - remaining_data_size = rlcP->pdu_size - 2 - (nb_li); - data_pdu = (uint8_t *) (&rlc_header->li_data_7[nb_li]); + data_pdu = (uint8_t*) (&rlc_header->li_data_7[nb_li]); while (li_index < nb_li) { switch (li[li_index]) { case (uint8_t) RLC_LI_LAST_PDU_EXACTLY_FILLED: #ifdef DEBUG_REASSEMBLY - msg ("[RLC_AM][RB %d][REASSEMBLY] PDU SN 0x%04X GET LI RLC_LI_LAST_PDU_EXACTLY_FILLED REMAINING DATA SIZE %d, li_index %d, li_start_index %d\n", rlcP->rb_id, working_sn, remaining_data_size, li_index, - li_start_index); + msg ("[RLC_AM][RB %d][REASSEMBLY] PDU SN 0x%04X GET LI RLC_LI_LAST_PDU_EXACTLY_FILLED REMAINING DATA SIZE %d, li_index %d, li_start_index %d\n", rlcP->rb_id, + working_sn, remaining_data_size, li_index, li_start_index); #endif if (li_index >= li_start_index) { @@ -529,7 +510,7 @@ process_receiver_buffer_7 (struct rlc_am_entity *rlcP) sdu_sent=1; } - data_pdu = (uint8_t *) ((uint32_t) data_pdu + (li[li_index] >> 1)); + data_pdu = (uint8_t*) ((uint32_t) data_pdu + (li[li_index] >> 1)); } li_index++; @@ -554,7 +535,6 @@ process_receiver_buffer_7 (struct rlc_am_entity *rlcP) #ifdef DEBUG_REASSEMBLY msg ("[RLC_AM][RB %d][REASSEMBLY] DETECTED PDU AFTER DISCARD ADJUST VR(R) 0x%04X hex\n", rlcP->rb_id, rlcP->vr_r); #endif - rlcP->vr_mr = (rlcP->vr_r + rlcP->configured_rx_window_size - 1) & SN_12BITS_MASK; } @@ -566,7 +546,8 @@ process_receiver_buffer_7 (struct rlc_am_entity *rlcP) // exploit HE field info if ((rlc_header->byte2 & RLC_HE_MASK) == RLC_HE_SUCC_BYTE_CONTAINS_DATA) { msg("WILL REASSEMBLY INDEX %04X\n", working_sn_index); - reassembly ((uint8_t *) (rlc_header->li_data_7), rlcP->pdu_size - 2, rlcP); + reassembly ((uint8_t*) (rlc_header->li_data_7), rlcP->pdu_size - 2, rlcP); + } else { while ((li[nb_li] = (rlc_header->li_data_7[nb_li])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(uint8_t) RLC_E_NEXT_FIELD_IS_LI_E); @@ -574,19 +555,16 @@ process_receiver_buffer_7 (struct rlc_am_entity *rlcP) } nb_li++; - remaining_data_size = rlcP->pdu_size - 2 - nb_li; - data_pdu = (uint8_t *) (&rlc_header->li_data_7[nb_li]); + data_pdu = (uint8_t*) (&rlc_header->li_data_7[nb_li]); while (li_index < nb_li) { - switch (li[li_index]) { case (uint8_t) RLC_LI_LAST_PDU_EXACTLY_FILLED: #ifdef DEBUG_REASSEMBLY msg ("[RLC_AM][RB %d][REASSEMBLY] PDU SN 0x%04X GET LI RLC_LI_LAST_PDU_EXACTLY_FILLED NUM LI %d\n", rlcP->rb_id, working_sn,nb_li); #endif send_sdu (rlcP); - sdu_sent=1; break; @@ -603,9 +581,8 @@ process_receiver_buffer_7 (struct rlc_am_entity *rlcP) msg ("[RLC_AM][RB %d][REASSEMBLY] PDU SN 0x%04X GET LI SIZE %d Bytes\n", rlcP->rb_id, working_sn, li[li_index] >> 1); #endif remaining_data_size = remaining_data_size - (li[li_index] >> 1); - reassembly (data_pdu, (li[li_index] >> 1), rlcP); - data_pdu = (uint8_t *) ((uint32_t) data_pdu + (li[li_index] >> 1)); + data_pdu = (uint8_t*) ((uint32_t) data_pdu + (li[li_index] >> 1)); send_sdu (rlcP); sdu_sent=1; } @@ -634,7 +611,6 @@ process_receiver_buffer_7 (struct rlc_am_entity *rlcP) #ifdef DEBUG_REASSEMBLY msg ("[RLC_AM][RB %d][REASSEMBLY] DETECTED PDU AFTER DISCARD ADJUST VR(R) 0x%04X\n", rlcP->rb_id, rlcP->vr_r); #endif - rlcP->vr_mr = (rlcP->vr_r + rlcP->configured_rx_window_size - 1) & SN_12BITS_MASK; } } diff --git a/openair2/LAYER2/RLC/AM/rlc_am_reset.c b/openair2/LAYER2/RLC/AM/rlc_am_reset.c index 0ad2a089eed..06366671c5e 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_reset.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_reset.c @@ -61,14 +61,14 @@ The RESET PDUs and the RESET ACK PDUs have higher priority than AMD PDUs. #include "LAYER2/MAC/extern.h" #define DEBUG_RESET //----------------------------------------------------------------------------- -void send_reset_ack_pdu (uint8_t rsnP, struct rlc_am_entity *rlcP); -void send_reset_pdu (struct rlc_am_entity *rlcP); -void reset_rlc_am (struct rlc_am_entity *rlcP); -void process_reset_ack (mem_block_t * pduP, struct rlc_am_reset_header *controlP, struct rlc_am_entity *rlcP); -void process_reset (mem_block_t * pduP, struct rlc_am_reset_header *controlP, struct rlc_am_entity *rlcP); +void send_reset_ack_pdu (uint8_t rsnP, struct rlc_am_entity* rlcP); +void send_reset_pdu (struct rlc_am_entity* rlcP); +void reset_rlc_am (struct rlc_am_entity* rlcP); +void process_reset_ack (mem_block_t* pduP, struct rlc_am_reset_header* controlP, struct rlc_am_entity* rlcP); +void process_reset (mem_block_t* pduP, struct rlc_am_reset_header* controlP, struct rlc_am_entity* rlcP); //----------------------------------------------------------------------------- void -rlc_am_reset_time_out (struct rlc_am_entity *rlcP, mem_block_t * not_usedP) +rlc_am_reset_time_out (struct rlc_am_entity* rlcP, mem_block_t* not_usedP) { //----------------------------------------------------------------------------- /* from 3GPP TS 25.322 V5.0.0 (2002-03) @@ -94,6 +94,7 @@ rlc_am_reset_time_out (struct rlc_am_entity *rlcP, mem_block_t * not_usedP) if (rlcP->vt_rst < rlcP->max_rst - 1) { send_reset_pdu (rlcP); rlcP->vt_rst += 1; + } else { //rrc_indication_unrecoverable_error_from_rlc_am(rlcP); // notification not raised to RRC, continue. (TO DO) @@ -101,7 +102,6 @@ rlc_am_reset_time_out (struct rlc_am_entity *rlcP, mem_block_t * not_usedP) msg ("[RLC_AM][RB %d] RESET TIME OUT VT(RST) >= max_rst frame %d REPORT TO RRC\n", rlcP->rb_id, Mac_rlc_xface->frame); msg ("\n******************************************************************\n"); send_reset_pdu (rlcP); - rlcP->vt_rst += 1; rlc_data_conf (0, rlcP->rb_id, 0,RLC_TX_CONFIRM_FAILURE, rlcP->data_plane); // mui, rb_ib, status #ifdef NODE_MT @@ -114,11 +114,11 @@ rlc_am_reset_time_out (struct rlc_am_entity *rlcP, mem_block_t * not_usedP) //----------------------------------------------------------------------------- void -send_reset_pdu (struct rlc_am_entity *rlcP) +send_reset_pdu (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - mem_block_t *pdu; - struct rlc_am_reset_header *header; + mem_block_t* pdu; + struct rlc_am_reset_header* header; /* From TS 25.322 V5.0.0 (2002-03) RESET PDU contents to set @@ -130,7 +130,6 @@ send_reset_pdu (struct rlc_am_entity *rlcP) a new RESET PDU is transmitted, but not when a RESET PDU is retransmitted. */ if (!(rlcP->timer_rst)) { - if (rlcP->vt_rst == 0) { // first transmission of reset PDU rlcP->reset_sequence_number ^= 1; } @@ -139,11 +138,9 @@ send_reset_pdu (struct rlc_am_entity *rlcP) pdu = get_free_mem_block (rlcP->pdu_size + sizeof (struct rlc_am_tx_control_pdu_allocation) + GUARD_CRC_LIH_SIZE); if ((pdu)) { - ((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_RESET_PDU_TYPE; - header = (struct rlc_am_reset_header *) (&pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]); + ((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_RESET_PDU_TYPE; + header = (struct rlc_am_reset_header*) (&pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]); header->byte1 = RLC_PDU_TYPE_RESET | (rlcP->reset_sequence_number << 3); - - #ifdef DEBUG_RESET msg ("\n******************************************************************\n"); msg ("[RLC_AM][RB %d] TX RESET RSN %d VT(RST) %d frame %d\n", rlcP->rb_id, rlcP->reset_sequence_number, rlcP->vt_rst, Mac_rlc_xface->frame); @@ -154,9 +151,9 @@ send_reset_pdu (struct rlc_am_entity *rlcP) header->hfni[1] = 0; header->hfni[2] = 0; */ - list_add_head (pdu, &rlcP->control); rlc_am_fsm_notify_event (rlcP, RLC_AM_TRANSMIT_RESET_EVENT); // not yet submitted to lower layers + } else { msg ("[RLC_AM][RB %d] ERROR SEND RESET OUT OF MEMORY ERROR\n", rlcP->rb_id); } @@ -165,11 +162,11 @@ send_reset_pdu (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -send_reset_ack_pdu (uint8_t rsnP, struct rlc_am_entity *rlcP) +send_reset_ack_pdu (uint8_t rsnP, struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - mem_block_t *pdu; - struct rlc_am_reset_header *header; + mem_block_t* pdu; + struct rlc_am_reset_header* header; /* From 3GPP TS 25.322 V5.0.0 (2002-03) RESET ACK PDU contents to set @@ -184,14 +181,14 @@ send_reset_ack_pdu (uint8_t rsnP, struct rlc_am_entity *rlcP) msg ("[RLC_AM][RB %d] TX RESET ACK RSN %d frame %d\n", rlcP->rb_id, rsnP, Mac_rlc_xface->frame); msg ("\n******************************************************************\n"); #endif - ((struct rlc_am_tx_control_pdu_management *) (pdu->data))->rlc_tb_type = RLC_AM_RESET_ACK_PDU_TYPE; - header = (struct rlc_am_reset_header *) (&pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]); + ((struct rlc_am_tx_control_pdu_management*) (pdu->data))->rlc_tb_type = RLC_AM_RESET_ACK_PDU_TYPE; + header = (struct rlc_am_reset_header*) (&pdu->data[sizeof (struct rlc_am_tx_control_pdu_allocation)]); header->byte1 = RLC_PDU_TYPE_RESET_ACK | (rsnP << 3); - list_add_head (pdu, &rlcP->control); } #ifdef DEBUG_RESET + else { msg ("[RLC_AM][RB %d] SEND RESET ACK OUT OF MEMORY ERROR\n", rlcP->rb_id); } @@ -201,10 +198,9 @@ send_reset_ack_pdu (uint8_t rsnP, struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -process_reset_ack (mem_block_t * pduP, struct rlc_am_reset_header *controlP, struct rlc_am_entity *rlcP) +process_reset_ack (mem_block_t* pduP, struct rlc_am_reset_header* controlP, struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - /* from 3GPP TS 25.322 V5.0.0 (2002-03) Upon reception of a RESET ACK PDU, the Sender shall: - if the Sender has already transmitted a RESET PDU which has not been yet acknowledged by a RESET ACK @@ -233,7 +229,6 @@ process_reset_ack (mem_block_t * pduP, struct rlc_am_reset_header *controlP, str */ if (rlc_am_fsm_notify_event (rlcP, RLC_AM_RECEIVE_RESET_ACK_EVENT)) { if (((controlP->byte1 & RLC_AM_RESET_SEQUENCE_NUMBER_MASK) >> 3) == rlcP->reset_sequence_number) { - #ifdef DEBUG_RESET msg ("\n******************************************************************\n"); msg ("[RLC_AM][RB %d] RX RESET ACK RSN %d frame %d\n", rlcP->rb_id, ((controlP->byte1 & RLC_AM_RESET_SEQUENCE_NUMBER_MASK) >> 3), Mac_rlc_xface->frame); @@ -246,9 +241,11 @@ process_reset_ack (mem_block_t * pduP, struct rlc_am_reset_header *controlP, str } #ifdef DEBUG_RESET + else { msg ("\n******************************************************************\n"); - msg ("[RLC_AM][RB %d] RX RESET ACK WRONG RSN %d != %d frame %d\n", rlcP->rb_id, (controlP->byte1 & RLC_AM_RESET_SEQUENCE_NUMBER_MASK) >> 3, rlcP->reset_sequence_number, Mac_rlc_xface->frame); + msg ("[RLC_AM][RB %d] RX RESET ACK WRONG RSN %d != %d frame %d\n", rlcP->rb_id, (controlP->byte1 & RLC_AM_RESET_SEQUENCE_NUMBER_MASK) >> 3, + rlcP->reset_sequence_number, Mac_rlc_xface->frame); msg ("\n******************************************************************\n"); } @@ -256,6 +253,7 @@ process_reset_ack (mem_block_t * pduP, struct rlc_am_reset_header *controlP, str } #ifdef DEBUG_RESET + else { msg ("\n******************************************************************\n"); msg ("[RLC_AM][RB %d] RX RESET ACK NOT EXPECTED frame %d\n", rlcP->rb_id, Mac_rlc_xface->frame); @@ -268,12 +266,11 @@ process_reset_ack (mem_block_t * pduP, struct rlc_am_reset_header *controlP, str //----------------------------------------------------------------------------- void -process_reset (mem_block_t * pduP, struct rlc_am_reset_header *controlP, struct rlc_am_entity *rlcP) +process_reset (mem_block_t* pduP, struct rlc_am_reset_header* controlP, struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- uint8_t rsn; uint8_t saved_vt_rst; - /* From 25.322 V5.0.0 (2002-03) Reception of the RESET PDU by the Receiver Upon reception of a RESET PDU the Receiver shall: @@ -336,9 +333,11 @@ process_reset (mem_block_t * pduP, struct rlc_am_reset_header *controlP, struct if (!(rlcP->timer_rst)) { umts_stop_all_timers (&rlcP->rlc_am_timer_list); rlc_am_reset_time_out (rlcP, NULL); + } else { umts_stop_all_timers_except (&rlcP->rlc_am_timer_list, rlc_am_reset_time_out); } + } else { // receiver #ifdef DEBUG_RESET @@ -370,19 +369,18 @@ process_reset (mem_block_t * pduP, struct rlc_am_reset_header *controlP, struct //----------------------------------------------------------------------------- void -reset_rlc_am (struct rlc_am_entity *rlcP) +reset_rlc_am (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- int index; for (index = 0; index < rlcP->size_input_sdus_buffer; index++) { if (rlcP->input_sdus[index]) { - if (!(rlcP->data_plane)) { #ifdef DEBUG_RLC_AM_SEND_CONFIRM - msg ("[RLC_AM][RB %d][CONFIRM] SDU MUI %d LOST IN RESET\n", rlcP->rb_id, ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[index]->data))->mui); + msg ("[RLC_AM][RB %d][CONFIRM] SDU MUI %d LOST IN RESET\n", rlcP->rb_id, ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[index]->data))->mui); #endif - rlc_data_conf (0, rlcP->rb_id, ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[index]->data))->mui, RLC_TX_CONFIRM_FAILURE, rlcP->data_plane); + rlc_data_conf (0, rlcP->rb_id, ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[index]->data))->mui, RLC_TX_CONFIRM_FAILURE, rlcP->data_plane); } free_mem_block (rlcP->input_sdus[index]); diff --git a/openair2/LAYER2/RLC/AM/rlc_am_retrans.c b/openair2/LAYER2/RLC/AM/rlc_am_retrans.c index 917bc280dab..3d270d03099 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_retrans.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_retrans.c @@ -57,23 +57,25 @@ //#define DEBUG_BITMAP //#define DEBUG_LIST //----------------------------------------------------------------------------- -inline int16_t retransmission_buffer_management_ack (struct rlc_am_entity *rlcP, uint8_t * sufiP, uint8_t byte_alignedP, int16_t * first_error_indicated_snP); -inline uint8_t *retransmission_buffer_management_bitmap (struct rlc_am_entity *rlcP, uint8_t * bitmap_sufiP, uint8_t byte_alignedP, int16_t * first_error_indicated_snP); -inline uint8_t *retransmission_buffer_management_list (struct rlc_am_entity *rlcP, uint8_t * bitmap_sufiP, uint8_t byte_alignedP, int16_t * first_error_indicated_snP); -inline void free_retransmission_buffer (struct rlc_am_entity *rlcP, uint16_t indexP); -inline void free_retransmission_buffer_no_confirmation (struct rlc_am_entity *rlcP, uint16_t indexP); -inline void insert_into_retransmission_buffer (struct rlc_am_entity *rlcP, uint16_t indexP, mem_block_t * pduP); -inline uint8_t retransmit_pdu (struct rlc_am_entity *rlcP, uint16_t snP); -inline uint8_t add_to_transmission_buffer_unack_pdu (struct rlc_am_entity *rlcP, int16_t * nb_pdu_to_transmit); +inline int16_t retransmission_buffer_management_ack (struct rlc_am_entity* rlcP, uint8_t* sufiP, uint8_t byte_alignedP, + int16_t* first_error_indicated_snP); +inline uint8_t* retransmission_buffer_management_bitmap (struct rlc_am_entity* rlcP, uint8_t* bitmap_sufiP, uint8_t byte_alignedP, + int16_t* first_error_indicated_snP); +inline uint8_t* retransmission_buffer_management_list (struct rlc_am_entity* rlcP, uint8_t* bitmap_sufiP, uint8_t byte_alignedP, + int16_t* first_error_indicated_snP); +inline void free_retransmission_buffer (struct rlc_am_entity* rlcP, uint16_t indexP); +inline void free_retransmission_buffer_no_confirmation (struct rlc_am_entity* rlcP, uint16_t indexP); +inline void insert_into_retransmission_buffer (struct rlc_am_entity* rlcP, uint16_t indexP, mem_block_t* pduP); +inline uint8_t retransmit_pdu (struct rlc_am_entity* rlcP, uint16_t snP); +inline uint8_t add_to_transmission_buffer_unack_pdu (struct rlc_am_entity* rlcP, int16_t* nb_pdu_to_transmit); //----------------------------------------------------------------------------- /* * remove all mem_block_t(s) having sn <= snP */ int16_t -retransmission_buffer_management_ack (struct rlc_am_entity *rlcP, uint8_t * sufiP, uint8_t byte_alignedP, int16_t * first_error_indicated_snP) +retransmission_buffer_management_ack (struct rlc_am_entity* rlcP, uint8_t* sufiP, uint8_t byte_alignedP, int16_t* first_error_indicated_snP) { //----------------------------------------------------------------------------- - uint16_t lsn; // sequence number acknowledged uint16_t current_sn; uint16_t upper_bound; @@ -86,6 +88,7 @@ retransmission_buffer_management_ack (struct rlc_am_entity *rlcP, uint8_t * sufi lsn = (*sufiP++ & 0x0F); lsn = lsn << 8; lsn += *sufiP; + } else { // get next 12 bits; sufiP++; @@ -98,8 +101,8 @@ retransmission_buffer_management_ack (struct rlc_am_entity *rlcP, uint8_t * sufi #ifdef DEBUG_ACK msg ("[RLC_AM][RB %d][ACK] RX SUFI ACK 0x%04X VT(A) 0x%04X VT(S) 0x%04X VT(MS) 0x%04X\n", rlcP->rb_id, lsn, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms); #endif - current_sn = rlcP->vt_a; + // From 3GPP TS 25.322 V4.3.0 // LSN acknowledges the reception of all PDUs with "Sequence Number" < LSN (Last Sequence Number) // that are not indicated to be erroneous in earlier parts of the STATUS PDU. @@ -111,26 +114,26 @@ retransmission_buffer_management_ack (struct rlc_am_entity *rlcP, uint8_t * sufi // otherwise VT(A) will be updated according to the first error indicated in the STATUS PDU. // VT(A) is only updated based on STATUS PDUs where ACK SUFI (or MRW_ACK SUFI) is included. // The LSN shall not be set to a value > VR(H) nor < VR(R). - //-------------------------; // if ack lsn <= first error => vt_a = lsn; // else vt_a = first error indicated; - // check lsn is valid if (rlc_am_comp_sn (rlcP, rlcP->vt_a, lsn, rlcP->vt_a) >= 0) { - if (*first_error_indicated_snP >= 0) { if (rlc_am_comp_sn (rlcP, rlcP->vt_a, lsn, (uint16_t) * first_error_indicated_snP) <= 0) { #ifdef DEBUG_ACK msg ("[RLC_AM][RB %d][ACK] VT(A) 0x%04X -> 0x%04X VT(S) 0x%04X CASE LSN <= FIRST PDU IN ERROR IN STATUS PDU\n", rlcP->rb_id, rlcP->vt_a, lsn, rlcP->vt_s); #endif rlcP->vt_a = lsn; + } else { #ifdef DEBUG_ACK - msg ("[RLC_AM][RB %d][ACK] VT(A) 0x%04X -> 0x%04X VT(S) 0x%04X CASE LSN > FIRST PDU IN ERROR IN STATUS PDU \n", rlcP->rb_id, rlcP->vt_a, (uint16_t) * first_error_indicated_snP, rlcP->vt_s); + msg ("[RLC_AM][RB %d][ACK] VT(A) 0x%04X -> 0x%04X VT(S) 0x%04X CASE LSN > FIRST PDU IN ERROR IN STATUS PDU \n", rlcP->rb_id, rlcP->vt_a, + (uint16_t) * first_error_indicated_snP, rlcP->vt_s); #endif rlcP->vt_a = (uint16_t) * first_error_indicated_snP; } + } else { #ifdef DEBUG_ACK msg ("[RLC_AM][RB %d][ACK] VT(A) 0x%04X -> 0x%04X VT(S) 0x%04X CASE SUFI ACK ALONE IN CONTROL PDU\n", rlcP->rb_id, rlcP->vt_a, lsn, rlcP->vt_s); @@ -139,7 +142,6 @@ retransmission_buffer_management_ack (struct rlc_am_entity *rlcP, uint8_t * sufi } rlcP->vt_ms = (rlcP->vt_a + rlcP->vt_ws - 1) & SN_12BITS_MASK; - current_index = current_sn % (uint16_t) rlcP->recomputed_configured_tx_window_size; upper_bound = lsn % (uint16_t) rlcP->recomputed_configured_tx_window_size; @@ -147,18 +149,20 @@ retransmission_buffer_management_ack (struct rlc_am_entity *rlcP, uint8_t * sufi while (upper_bound != current_index) { // free all pdus that have not been stamped as missing; if (rlcP->retransmission_buffer[current_index] != NULL) { - if (((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[current_index]->data))->ack != RLC_AM_PDU_NACK_EVENT) { + if (((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[current_index]->data))->ack != RLC_AM_PDU_NACK_EVENT) { #ifdef DEBUG_ACK msg ("[RLC_AM][RB %d][ACK] FREE PDU SN 0x%04X BECAUSE FIELD ACK=%d\n", rlcP->rb_id, current_sn, - ((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[current_index]->data))->ack); + ((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[current_index]->data))->ack); #endif free_retransmission_buffer (rlcP, (uint16_t) current_index); + } else { #ifdef DEBUG_ACK - msg ("[RLC_AM][RB %d][ACK] CLEAR NACK EVENT (%d) PDU SN 0x%04X\n", rlcP->rb_id, ((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[current_index]->data))->ack, + msg ("[RLC_AM][RB %d][ACK] CLEAR NACK EVENT (%d) PDU SN 0x%04X\n", rlcP->rb_id, + ((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[current_index]->data))->ack, current_sn); #endif - ((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[current_index]->data))->ack = RLC_AM_PDU_ACK_NO_EVENT; + ((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[current_index]->data))->ack = RLC_AM_PDU_ACK_NO_EVENT; } } @@ -195,11 +199,10 @@ retransmission_buffer_management_ack (struct rlc_am_entity *rlcP, uint8_t * sufi * @param bitmap_sufiP pointer on byte containing field "sufi type" * @param byte_alignedP tells if sufi type quartet is on MSByte (1) or LSByte (0) */ -inline uint8_t * -retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * bitmap_sufiP, uint8_t byte_alignedP, int16_t * first_error_indicated_snP) +inline uint8_t* +retransmission_buffer_management_bitmap (struct rlc_am_entity* rlcP, uint8_t* bitmap_sufiP, uint8_t byte_alignedP, int16_t* first_error_indicated_snP) { //----------------------------------------------------------------------------- - uint16_t id_index; uint16_t fsn; uint8_t length, tmp; @@ -207,7 +210,6 @@ retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * uint8_t bit_mask; uint8_t end_bit; - if (byte_alignedP) { // get next 4 bits : length length = (*bitmap_sufiP++ & 0x0F) + 1; @@ -217,6 +219,7 @@ retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * tmp = *bitmap_sufiP; fsn += tmp >> 4; bit_mask = 8; + } else { bitmap_sufiP++; // get 4 bits length @@ -226,20 +229,16 @@ retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * fsn = fsn << 8; fsn = fsn + *bitmap_sufiP; bitmap_sufiP++; - bit_mask = 128; } end_bit = length << 3; // *8 - #ifdef DEBUG_BITMAP msg ("[RLC_AM][RB %d][BITMAP] SUFI BITMAP fsn 0x%04X length 0x%04X\n", rlcP->rb_id, fsn, length); #endif if (rlc_am_comp_sn (rlcP, rlcP->vt_a, fsn, rlcP->vt_a) >= 0) { - while (end_bit) { - id_index = fsn % (uint16_t) (rlcP->recomputed_configured_tx_window_size); // found a matching pdu @@ -247,11 +246,11 @@ retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * // pdu correctly received // remove it from retransmission buffer free_retransmission_buffer (rlcP, id_index); - one_pdu_removed = 1; #ifdef DEBUG_BITMAP msg ("[RLC_AM][RB %d][BITMAP] SUFI BITMAP ACK 0x%04x \n", rlcP->rb_id, fsn); #endif + } else { // pdu not correctly received; // retransmit it; @@ -260,7 +259,7 @@ retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * #endif if (rlcP->retransmission_buffer[id_index]) { - ((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[id_index]->data))->ack = RLC_AM_PDU_NACK_EVENT; + ((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[id_index]->data))->ack = RLC_AM_PDU_NACK_EVENT; retransmit_pdu (rlcP, fsn); rlcP->stat_tx_retransmit_pdu_by_status += 1; /* @@ -281,9 +280,7 @@ retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * // inc searched sequence number fsn++; fsn = fsn & SN_12BITS_MASK; - bit_mask = bit_mask >> 1; - // remaining nb bits to process end_bit--; @@ -294,6 +291,7 @@ retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * } return bitmap_sufiP; + } else { #ifdef DEBUG_RESET msg ("[RLC_AM][RB %d][BITMAP] ERROR SUFI BITMAP INVALID sn 0x%02X vt(a) 0x%04X vt(s) 0x%04X send RESET requested\n", rlcP->rb_id, fsn, rlcP->vt_a, rlcP->vt_s); @@ -310,19 +308,16 @@ retransmission_buffer_management_bitmap (struct rlc_am_entity * rlcP, uint8_t * * @param bitmap_sufiP pointer on byte containing field "sufi type" * @param byte_alignedP tells if sufi type quartet is on MSByte (1) or LSByte (0) */ -inline uint8_t * -retransmission_buffer_management_list (struct rlc_am_entity * rlcP, uint8_t * bitmap_sufiP, uint8_t byte_alignedP, int16_t * first_error_indicated_snP) +inline uint8_t* +retransmission_buffer_management_list (struct rlc_am_entity* rlcP, uint8_t* bitmap_sufiP, uint8_t byte_alignedP, int16_t* first_error_indicated_snP) { //----------------------------------------------------------------------------- - - uint8_t *p8; + uint8_t* p8; uint16_t start_marking_sn; uint8_t nb_missing_pdu; uint8_t nb_pairs; - p8 = bitmap_sufiP; - if (byte_alignedP) { nb_pairs = *p8++ & 0X0F; // number of (SNi, Li) pairs in the sufi type LIST the value 0000 @@ -338,6 +333,7 @@ retransmission_buffer_management_list (struct rlc_am_entity * rlcP, uint8_t * bi #endif return p8; return p8; + } else { while (nb_pairs) { start_marking_sn = ((uint16_t) (*p8++)) << 4; @@ -352,25 +348,28 @@ retransmission_buffer_management_list (struct rlc_am_entity * rlcP, uint8_t * bi } #ifdef DEBUG_LIST - msg ("[RLC_AM][RB %d][LIST] SUFI LIST SN 0x%04X MISSING %d VT(A) 0x%04X VT(S) 0x%04X\n", rlcP->rb_id, start_marking_sn, nb_missing_pdu, rlcP->vt_a, rlcP->vt_s); + msg ("[RLC_AM][RB %d][LIST] SUFI LIST SN 0x%04X MISSING %d VT(A) 0x%04X VT(S) 0x%04X\n", rlcP->rb_id, start_marking_sn, nb_missing_pdu, rlcP->vt_a, + rlcP->vt_s); #endif while (nb_missing_pdu) { if (rlc_am_comp_sn (rlcP, rlcP->vt_a, start_marking_sn, rlcP->vt_a) >= 0) { - if (rlcP->retransmission_buffer[start_marking_sn % rlcP->recomputed_configured_tx_window_size] != NULL) { - #ifdef DEBUG_LIST - msg ("[RLC_AM][RB %d][LIST] MARK SN 0x%04X INDEX 0x%04X TO RLC_AM_PDU_NACK_EVENT\n", rlcP->rb_id, start_marking_sn, start_marking_sn % rlcP->recomputed_configured_tx_window_size); + msg ("[RLC_AM][RB %d][LIST] MARK SN 0x%04X INDEX 0x%04X TO RLC_AM_PDU_NACK_EVENT\n", rlcP->rb_id, start_marking_sn, + start_marking_sn % rlcP->recomputed_configured_tx_window_size); #endif - ((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[start_marking_sn % rlcP->recomputed_configured_tx_window_size]->data))->ack = RLC_AM_PDU_NACK_EVENT; + ((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[start_marking_sn % rlcP->recomputed_configured_tx_window_size]->data))->ack = + RLC_AM_PDU_NACK_EVENT; retransmit_pdu (rlcP, start_marking_sn); rlcP->stat_tx_retransmit_pdu_by_status += 1; } + } else { send_reset_pdu (rlcP); #ifdef DEBUG_RESET - msg ("[RLC_AM][RB %d][LIST] ERROR SUFI LIST INVALID SN 0x%02X VT(A) 0x%04X VT(S) 0x%04X send RESET requested \n", rlcP->rb_id, start_marking_sn, rlcP->vt_a, rlcP->vt_s); + msg ("[RLC_AM][RB %d][LIST] ERROR SUFI LIST INVALID SN 0x%02X VT(A) 0x%04X VT(S) 0x%04X send RESET requested \n", rlcP->rb_id, start_marking_sn, rlcP->vt_a, + rlcP->vt_s); #endif #ifdef DEBUG_LIST display_protocol_vars_rlc_am (rlcP); @@ -387,6 +386,7 @@ retransmission_buffer_management_list (struct rlc_am_entity * rlcP, uint8_t * bi return p8; } + } else { p8++; nb_pairs = *p8 >> 4; // number of (SNi, Li) pairs in the sufi type LIST the value 0000 @@ -401,8 +401,8 @@ retransmission_buffer_management_list (struct rlc_am_entity * rlcP, uint8_t * bi #ifdef DEBUG_LIST display_protocol_vars_rlc_am (rlcP); #endif - return p8; + } else { while (nb_pairs) { start_marking_sn = ((uint16_t) (*p8++) & 0x0F) << 8; @@ -417,25 +417,28 @@ retransmission_buffer_management_list (struct rlc_am_entity * rlcP, uint8_t * bi } #ifdef DEBUG_LIST - msg ("[RLC_AM][RB %d][RETRANSMISSION] SUFI LIST SN 0x%04X MISSING %d VT(A) 0x%04X VT(S) 0x%04X\n", rlcP->rb_id, start_marking_sn, nb_missing_pdu, rlcP->vt_a, rlcP->vt_s); + msg ("[RLC_AM][RB %d][RETRANSMISSION] SUFI LIST SN 0x%04X MISSING %d VT(A) 0x%04X VT(S) 0x%04X\n", rlcP->rb_id, start_marking_sn, nb_missing_pdu, rlcP->vt_a, + rlcP->vt_s); #endif while (nb_missing_pdu) { if (rlc_am_comp_sn (rlcP, rlcP->vt_a, start_marking_sn, rlcP->vt_a) >= 0) { - if (rlcP->retransmission_buffer[start_marking_sn % rlcP->recomputed_configured_tx_window_size] != NULL) { #ifdef DEBUG_LIST - msg ("[RLC_AM][RB %d][LIST] MARK SN 0x%04X INDEX 0x%04X TO RLC_AM_PDU_NACK_EVENT\n", rlcP->rb_id, start_marking_sn, start_marking_sn % rlcP->recomputed_configured_tx_window_size); + msg ("[RLC_AM][RB %d][LIST] MARK SN 0x%04X INDEX 0x%04X TO RLC_AM_PDU_NACK_EVENT\n", rlcP->rb_id, start_marking_sn, + start_marking_sn % rlcP->recomputed_configured_tx_window_size); #endif - ((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[start_marking_sn % rlcP->recomputed_configured_tx_window_size]->data))->ack = RLC_AM_PDU_NACK_EVENT; - + ((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[start_marking_sn % rlcP->recomputed_configured_tx_window_size]->data))->ack = + RLC_AM_PDU_NACK_EVENT; retransmit_pdu (rlcP, start_marking_sn); rlcP->stat_tx_retransmit_pdu_by_status += 1; } + } else { send_reset_pdu (rlcP); #ifdef DEBUG_RESET - msg ("[RLC_AM][RB %d][LIST] ERROR SUFI LIST invalid sn 0x%02X send RESET requested vt(a) 0x%04X vt(s) 0x%04X\n", rlcP->rb_id, start_marking_sn, rlcP->vt_a, rlcP->vt_s); + msg ("[RLC_AM][RB %d][LIST] ERROR SUFI LIST invalid sn 0x%02X send RESET requested vt(a) 0x%04X vt(s) 0x%04X\n", rlcP->rb_id, start_marking_sn, rlcP->vt_a, + rlcP->vt_s); #endif #ifdef DEBUG_LIST display_protocol_vars_rlc_am (rlcP); @@ -457,44 +460,39 @@ retransmission_buffer_management_list (struct rlc_am_entity * rlcP, uint8_t * bi //----------------------------------------------------------------------------- inline void -free_retransmission_buffer (struct rlc_am_entity *rlcP, uint16_t indexP) +free_retransmission_buffer (struct rlc_am_entity* rlcP, uint16_t indexP) { //----------------------------------------------------------------------------- - - mem_block_t *sdu_confirm; - struct rlc_am_tx_data_pdu_management *pdu; - mem_block_t *le = NULL; - + mem_block_t* sdu_confirm; + struct rlc_am_tx_data_pdu_management* pdu; + mem_block_t* le = NULL; unsigned int index; unsigned int sdu_index; - index = indexP; if (index < (uint16_t) rlcP->recomputed_configured_tx_window_size) { - le = rlcP->retransmission_buffer[index]; if (le != NULL) { // ??? - pdu = (struct rlc_am_tx_data_pdu_management *) (le->data); + pdu = (struct rlc_am_tx_data_pdu_management*) (le->data); // test if the sender of the sdu requested a confirmation of the reception of the sdu by the receiving RLC // or if mode discard is on for (sdu_index = 0; sdu_index < pdu->nb_sdu; sdu_index++) { if (pdu->sdu[sdu_index] != -1) { // may be discarded - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus_ack += 1; - - if ((((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus_ack == - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus) && - (((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->segmented)) { + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus_ack += 1; - if (((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->confirm) { + if ((((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus_ack == + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus) && + (((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->segmented)) { + if (((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->confirm) { // send confirmation to upper layers - #ifdef DEBUG_RLC_AM_SEND_CONFIRM - msg ("[RLC_AM][RB %d][CONFIRM] SDU MUI %d ACK BY PEER\n", rlcP->rb_id, ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->mui); + msg ("[RLC_AM][RB %d][CONFIRM] SDU MUI %d ACK BY PEER\n", rlcP->rb_id, ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->mui); #endif - rlc_data_conf (0, rlcP->rb_id, ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->mui, RLC_TX_CONFIRM_SUCCESSFULL, rlcP->data_plane); + rlc_data_conf (0, rlcP->rb_id, ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->mui, RLC_TX_CONFIRM_SUCCESSFULL, + rlcP->data_plane); } // FREE SDU : we can remove the sdu if timer based discard and all pdus submitted to lower layers and no confirm running @@ -538,33 +536,30 @@ free_retransmission_buffer (struct rlc_am_entity *rlcP, uint16_t indexP) //----------------------------------------------------------------------------- inline void -free_retransmission_buffer_no_confirmation (struct rlc_am_entity *rlcP, uint16_t indexP) +free_retransmission_buffer_no_confirmation (struct rlc_am_entity* rlcP, uint16_t indexP) { //----------------------------------------------------------------------------- - struct rlc_am_tx_data_pdu_management *pdu; - mem_block_t *le = NULL; + struct rlc_am_tx_data_pdu_management* pdu; + mem_block_t* le = NULL; unsigned int index; unsigned int sdu_index; - index = indexP; if (index < (uint16_t) rlcP->recomputed_configured_tx_window_size) { - le = rlcP->retransmission_buffer[index]; if (le != NULL) { - pdu = (struct rlc_am_tx_data_pdu_management *) (le->data); + pdu = (struct rlc_am_tx_data_pdu_management*) (le->data); // test if the sender of the sdu requested a confirmation of the reception of the sdu by the receiving RLC // or if mode discard is on for (sdu_index = 0; sdu_index < pdu->nb_sdu; sdu_index++) { if (pdu->sdu[sdu_index] != -1) { // may be discarded - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus_ack += 1; - - if ((((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus_ack == - ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus) && - (((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->segmented)) { + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus_ack += 1; + if ((((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus_ack == + ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->nb_pdus) && + (((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[pdu->sdu[sdu_index]]->data))->segmented)) { // FREE SDU : we can remove the sdu if timer based discard and all pdus submitted to lower layers and no confirm running #ifdef DEBUG_RLC_AM_FREE_SDU msg ("[RLC_AM][RB %d][RETRANS] FREE PDU NO_CONF INDEX 0x%04X FREE_SDU INDEX %d\n", rlcP->rb_id, indexP, pdu->sdu[sdu_index]); @@ -606,7 +601,7 @@ free_retransmission_buffer_no_confirmation (struct rlc_am_entity *rlcP, uint16_t //----------------------------------------------------------------------------- inline void -insert_into_retransmission_buffer (struct rlc_am_entity *rlcP, uint16_t indexP, mem_block_t * pduP) +insert_into_retransmission_buffer (struct rlc_am_entity* rlcP, uint16_t indexP, mem_block_t* pduP) { //----------------------------------------------------------------------------- uint16_t index; @@ -636,11 +631,11 @@ insert_into_retransmission_buffer (struct rlc_am_entity *rlcP, uint16_t indexP, //----------------------------------------------------------------------------- inline uint8_t -retransmit_pdu (struct rlc_am_entity * rlcP, uint16_t snP) +retransmit_pdu (struct rlc_am_entity* rlcP, uint16_t snP) { //----------------------------------------------------------------------------- - mem_block_t *pdu, *copy; - struct rlc_am_tx_data_pdu_management *pdu_mngt; + mem_block_t* pdu, *copy; + struct rlc_am_tx_data_pdu_management* pdu_mngt; uint16_t index; if ((rlcP->protocol_state & RLC_DATA_TRANSFER_READY_STATE)) { @@ -648,7 +643,7 @@ retransmit_pdu (struct rlc_am_entity * rlcP, uint16_t snP) pdu = rlcP->retransmission_buffer[index]; if (pdu) { - pdu_mngt = (struct rlc_am_tx_data_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_am_tx_data_pdu_management*) (pdu->data); pdu_mngt->vt_dat += 1; // if first retransmission, add to buffer occupancy @@ -657,7 +652,6 @@ retransmit_pdu (struct rlc_am_entity * rlcP, uint16_t snP) } if ((pdu_mngt->vt_dat < rlcP->max_dat) || ((rlcP->sdu_discard_mode & SDU_DISCARD_MODE_TIMER_BASED_EXPLICIT))) { - // now check if a copy of the pdu is not already present in the retransmission buffer if (pdu_mngt->copy == NULL) { copy = get_free_mem_block (rlcP->pdu_size + sizeof (struct rlc_am_tx_data_pdu_allocation) + GUARD_CRC_LIH_SIZE); @@ -667,35 +661,37 @@ retransmit_pdu (struct rlc_am_entity * rlcP, uint16_t snP) list2_add_tail (copy, &rlcP->retransmission_buffer_to_send); // make link between the original pdu and its copy pdu_mngt->copy = copy; - ((struct rlc_am_tx_data_pdu_management *) (copy->data))->copy = pdu; - - + ((struct rlc_am_tx_data_pdu_management*) (copy->data))->copy = pdu; #ifdef BENCH_QOS_L2 fprintf (bench_l2, "[PDU RETRANS] FRAME %d SN %d VT_DAT %d RLC-AM %p\n", Mac_rlc_xface->frame, snP, pdu_mngt->vt_dat, rlcP); #endif - #ifdef DEBUG_RETRANSMISSION msg ("[RLC_AM][RB %d][RETRANSMISSION] PDU SN = 0x%04X hex VT(DAT) %d frame %d\n", rlcP->rb_id, snP, pdu_mngt->vt_dat, Mac_rlc_xface->frame); #endif return 0; + } else { msg ("[RLC_AM][RB %d][RETRANSMISSION] ERROR retransmit_pdu() retransmited copy of pdu is NULL index in array %04X\n", rlcP->rb_id, index); return RLC_AM_OUT_OF_MEMORY_ERROR; } + } else { #ifdef DEBUG_RETRANSMISSION msg ("[RLC_AM][RB %d][RETRANSMISSION] PDU SN = 0x%04X hex VT(DAT) %d already in retransmission buffer to send\n", rlcP->rb_id, snP, pdu_mngt->vt_dat); #endif return RLC_AM_RETRANS_REQ_PDU_DONE_BEFORE; } + } else { if ((rlcP->sdu_discard_mode & SDU_DISCARD_MODE_TIMER_BASED_EXPLICIT)) { // DO NOTHING } else if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_MAX_DAT_RETRANSMISSION)) { #ifdef DEBUG_RETRANSMISSION - msg ("[RLC_AM][RB %d][RETRANSMISSION] VT(DAT) %d REACHED MAX_DAT, DISCARD PROCEDURE WILL BE STARTED frame %d\n", rlcP->rb_id, pdu_mngt->vt_dat, Mac_rlc_xface->frame); + msg ("[RLC_AM][RB %d][RETRANSMISSION] VT(DAT) %d REACHED MAX_DAT, DISCARD PROCEDURE WILL BE STARTED frame %d\n", rlcP->rb_id, pdu_mngt->vt_dat, + Mac_rlc_xface->frame); #endif rlc_am_discard_notify_max_dat_pdu (rlcP, pdu); + } else { // if No_discard after MaxDat number of retransmissions is used, the sender shall initiate the // RLC reset procedure when VT(DAT) >= MaxDAT (from 3GPP TS 25.322 V5.0.0 ) // max transmission reached for this PDU, reset RLC entities @@ -707,6 +703,7 @@ retransmit_pdu (struct rlc_am_entity * rlcP, uint16_t snP) return -1; } + } else { return RLC_AM_RETRANS_REQ_PDU_NULL; } @@ -717,15 +714,14 @@ retransmit_pdu (struct rlc_am_entity * rlcP, uint16_t snP) //----------------------------------------------------------------------------- void -rlc_am_get_not_acknowledged_pdu_optimized (struct rlc_am_entity *rlcP) +rlc_am_get_not_acknowledged_pdu_optimized (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- uint16_t vt_dat_min = 255; uint16_t sn; uint16_t sn_min; - mem_block_t *pdu; - struct rlc_am_tx_data_pdu_management *pdu_mngt; - + mem_block_t* pdu; + struct rlc_am_tx_data_pdu_management* pdu_mngt; sn = rlcP->vt_s; sn_min = sn; @@ -734,7 +730,7 @@ rlc_am_get_not_acknowledged_pdu_optimized (struct rlc_am_entity *rlcP) pdu = rlcP->retransmission_buffer[sn % rlcP->recomputed_configured_tx_window_size]; if ((pdu)) { - pdu_mngt = (struct rlc_am_tx_data_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_am_tx_data_pdu_management*) (pdu->data); if (pdu_mngt->vt_dat < vt_dat_min) { sn_min = sn; @@ -752,7 +748,7 @@ rlc_am_get_not_acknowledged_pdu_optimized (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_get_not_acknowledged_pdu (struct rlc_am_entity *rlcP) +rlc_am_get_not_acknowledged_pdu (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- uint16_t sn; @@ -771,7 +767,7 @@ rlc_am_get_not_acknowledged_pdu (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_get_not_acknowledged_pdu_vt_s_minus_1 (struct rlc_am_entity *rlcP) +rlc_am_get_not_acknowledged_pdu_vt_s_minus_1 (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- if (rlcP->retransmission_buffer[((rlcP->vt_s - 1) & SN_12BITS_MASK) % rlcP->recomputed_configured_tx_window_size]) { diff --git a/openair2/LAYER2/RLC/AM/rlc_am_segment.c b/openair2/LAYER2/RLC/AM/rlc_am_segment.c index e0fd0168c41..69255a6a344 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_segment.c @@ -46,15 +46,14 @@ //#define DEBUG_RLC_AM_SEGMENT_FILL_DATA //#define DEBUG_MEM_MNGT //----------------------------------------------------------------------------- -mem_block_t *rlc_am_segment_15 (struct rlc_am_entity *rlcP); -mem_block_t *rlc_am_segment_7 (struct rlc_am_entity *rlcP); +mem_block_t* rlc_am_segment_15 (struct rlc_am_entity* rlcP); +mem_block_t* rlc_am_segment_7 (struct rlc_am_entity* rlcP); //----------------------------------------------------------------------------- inline void -rlc_am_encode_pdu_15 (struct rlc_am_pdu_header *rlc_headerP, struct rlc_am_tx_data_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP) +rlc_am_encode_pdu_15 (struct rlc_am_pdu_header* rlc_headerP, struct rlc_am_tx_data_pdu_management* pdu_mngtP, uint16_t* li_arrayP, uint8_t nb_liP) { //----------------------------------------------------------------------------- uint8_t li_index; - #ifdef DEBUG_RLC_AM_SEGMENT int index; msg ("[RLC_AM] SEGMENT_15 PDU SET LIs: "); @@ -67,9 +66,8 @@ rlc_am_encode_pdu_15 (struct rlc_am_pdu_header *rlc_headerP, struct rlc_am_tx_da #endif rlc_headerP->byte1 = RLC_DC_DATA_PDU; rlc_headerP->byte2 = 0; - nb_liP = nb_liP << 1; - pdu_mngtP->payload = (uint8_t *) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); + pdu_mngtP->payload = (uint8_t*) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); if (nb_liP) { rlc_headerP->byte2 |= RLC_E_NEXT_FIELD_IS_LI_E; @@ -89,11 +87,10 @@ rlc_am_encode_pdu_15 (struct rlc_am_pdu_header *rlc_headerP, struct rlc_am_tx_da //----------------------------------------------------------------------------- inline void -rlc_am_encode_pdu_7 (struct rlc_am_pdu_header *rlc_headerP, struct rlc_am_tx_data_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP) +rlc_am_encode_pdu_7 (struct rlc_am_pdu_header* rlc_headerP, struct rlc_am_tx_data_pdu_management* pdu_mngtP, uint16_t* li_arrayP, uint8_t nb_liP) { //----------------------------------------------------------------------------- uint8_t li_index; - #ifdef DEBUG_RLC_AM_SEGMENT int index; msg ("[RLC_AM] SEGMENT_7 PDU %p SET LIs: ", pdu_mngtP); @@ -104,11 +101,9 @@ rlc_am_encode_pdu_7 (struct rlc_am_pdu_header *rlc_headerP, struct rlc_am_tx_dat msg ("\n"); #endif - rlc_headerP->byte1 = RLC_DC_DATA_PDU; rlc_headerP->byte2 = 0; - - pdu_mngtP->payload = (uint8_t *) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); + pdu_mngtP->payload = (uint8_t*) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); if (nb_liP) { rlc_headerP->byte2 |= RLC_E_NEXT_FIELD_IS_LI_E; @@ -126,31 +121,26 @@ rlc_am_encode_pdu_7 (struct rlc_am_pdu_header *rlc_headerP, struct rlc_am_tx_dat //----------------------------------------------------------------------------- inline void -rlc_am_fill_pdu (mem_block_t * pduP, list_t * segmented_sdusP) +rlc_am_fill_pdu (mem_block_t* pduP, list_t* segmented_sdusP) { //----------------------------------------------------------------------------- - mem_block_t *sdu; - uint8_t *data_sdu; - uint8_t *data_pdu; - struct rlc_am_pdu_header *rlc_header; - struct rlc_am_tx_data_pdu_management *pdu_mngt; - struct rlc_am_tx_sdu_management *sdu_mngt; + mem_block_t* sdu; + uint8_t* data_sdu; + uint8_t* data_pdu; + struct rlc_am_pdu_header* rlc_header; + struct rlc_am_tx_data_pdu_management* pdu_mngt; + struct rlc_am_tx_sdu_management* sdu_mngt; int continue_fill; uint16_t pdu_remaining_size; uint16_t sdu_available_size; - - sdu = NULL; - - pdu_mngt = (struct rlc_am_tx_data_pdu_management *) (pduP->data); - rlc_header = (struct rlc_am_pdu_header *) (pdu_mngt->first_byte); - + pdu_mngt = (struct rlc_am_tx_data_pdu_management*) (pduP->data); + rlc_header = (struct rlc_am_pdu_header*) (pdu_mngt->first_byte); pdu_remaining_size = pdu_mngt->data_size; - data_pdu = (uint8_t *) pdu_mngt->payload; + data_pdu = (uint8_t*) pdu_mngt->payload; #ifdef DEBUG_RLC_AM_SEGMENT_FILL_DATA msg ("[RLC_AM] SEGMENT FILL GET PDU %p REMAINING SIZE=%d\n", pduP, pdu_remaining_size); #endif - continue_fill = 1; while ((continue_fill)) { @@ -162,7 +152,7 @@ rlc_am_fill_pdu (mem_block_t * pduP, list_t * segmented_sdusP) return; // case pdu only 2 LIs : exactly_filled or one_byte_short + paddind } - sdu_mngt = (struct rlc_am_tx_sdu_management *) (sdu->data); + sdu_mngt = (struct rlc_am_tx_sdu_management*) (sdu->data); data_sdu = &sdu->data[sizeof (struct rlc_am_tx_sdu_management) + sdu_mngt->sdu_segmented_size]; sdu_available_size = sdu_mngt->sdu_size - sdu_mngt->sdu_remaining_size - sdu_mngt->sdu_segmented_size; #ifdef DEBUG_RLC_AM_SEGMENT_FILL_DATA @@ -180,15 +170,15 @@ rlc_am_fill_pdu (mem_block_t * pduP, list_t * segmented_sdusP) #endif pdu_remaining_size -= sdu_available_size; sdu_mngt->sdu_segmented_size += sdu_available_size; - data_pdu = (uint8_t *) ((uint32_t) data_pdu + sdu_available_size); + data_pdu = (uint8_t*) ((uint32_t) data_pdu + sdu_available_size); sdu_available_size = 0; - // dispatch the sdu sdu = NULL; // dispatch the pdu if (pdu_remaining_size == 0) { continue_fill = 0; + } else { } @@ -201,7 +191,7 @@ rlc_am_fill_pdu (mem_block_t * pduP, list_t * segmented_sdusP) #endif sdu_mngt->sdu_segmented_size += pdu_remaining_size; sdu_available_size -= pdu_remaining_size; - data_sdu = (uint8_t *) ((uint32_t) data_sdu + (uint32_t) pdu_remaining_size); + data_sdu = (uint8_t*) ((uint32_t) data_sdu + (uint32_t) pdu_remaining_size); continue_fill = 0; pdu_remaining_size = 0; } @@ -211,28 +201,23 @@ rlc_am_fill_pdu (mem_block_t * pduP, list_t * segmented_sdusP) } //----------------------------------------------------------------------------- -mem_block_t * -rlc_am_segment_15 (struct rlc_am_entity *rlcP) +mem_block_t* +rlc_am_segment_15 (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - list_t segmented_sdus; // the copying of sdu data is done after identification of all LIs to put in pdu - - struct rlc_am_tx_sdu_management *sdu_mngt; - struct rlc_am_tx_data_pdu_management *pdu_mngt; - struct rlc_am_pdu_header *rlc_header; - mem_block_t *pdu; + struct rlc_am_tx_sdu_management* sdu_mngt; + struct rlc_am_tx_data_pdu_management* pdu_mngt; + struct rlc_am_pdu_header* rlc_header; + mem_block_t* pdu; int continue_segment = 1; int16_t pdu_remaining_size; uint8_t li_index = 0; - pdu = NULL; - list_init (&segmented_sdus, NULL); // param string identifying the list is NULL while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (continue_segment)) { - - sdu_mngt = ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); + sdu_mngt = ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); if (!(sdu_mngt->segmented)) { // pdu management @@ -246,32 +231,28 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) li_index = 0; pdu_remaining_size = rlcP->pdu_size - 2; // 2= size of header, minimum - pdu_mngt = (struct rlc_am_tx_data_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_am_tx_data_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_am_tx_data_pdu_allocation)); pdu_mngt->rlc_tb_type = RLC_AM_DATA_PDU_TYPE; pdu_mngt->first_byte = &pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - rlc_header = (struct rlc_am_pdu_header *) (pdu_mngt->first_byte); + rlc_header = (struct rlc_am_pdu_header*) (pdu_mngt->first_byte); } if (sdu_mngt->sdu_remaining_size > 0) { // think RLC_LI_LAST_PDU_ONE_BYTE_SHORT, RLC_LI_LAST_PDU_EXACTLY_FILLED - if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) < 0) { pdu_mngt->data_size += pdu_remaining_size; - rlc_am_encode_pdu_15 (rlc_header, pdu_mngt, rlcP->li, li_index); continue_segment = 0; sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; - sdu_mngt->nb_pdus += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; - } else { + } else { // From 3GPP TS 25.322 V4.2.0 (2001-09) p28 // If "SDU discard with explicit signalling" is configured: // - an AMD PDU can contain a maximum number of 15 "Length Indicators" indicating the end // of 15 corresponding SDUs; and // - the rest of the AMD PDU space shall be used as padding or as piggybacked STATUS PDU. - // implementation limitation : we limit the number of li to 15 even if // no "SDU discard with explicit signalling" is configured. if (li_index >= 14) { @@ -279,29 +260,24 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) rlc_am_encode_pdu_15 (rlc_header, pdu_mngt, rlcP->li, li_index); continue_segment = 0; sdu_mngt->no_new_sdu_segmented_in_last_pdu = 1; - } else { // nb li have not reached the limit + } else { // nb li have not reached the limit if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) >= 2) { - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size - 2; // size of li length pdu_mngt->data_size += sdu_mngt->sdu_remaining_size; - sdu_mngt->li_index_for_discard = li_index; rlcP->li[li_index++] = sdu_mngt->sdu_remaining_size << 1; - sdu_mngt->sdu_remaining_size = 0; sdu_mngt->segmented = 1; - sdu_mngt->nb_pdus += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; pdu_mngt->last_pdu_of_sdu += 1; - list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); - rlcP->buffer_occupancy -= sdu_mngt->sdu_size; rlcP->nb_sdu -= 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; //} else the while loop continue with the same pdu + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 0) { // from 3GPP TS 25.322 V4.2.0 //In the case where the end of the last segment of an RLC SDU exactly ends at the end of @@ -316,12 +292,11 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) rlc_am_encode_pdu_15 (rlc_header, pdu_mngt, rlcP->li, li_index); continue_segment = 0; sdu_mngt->sdu_remaining_size = 0; - sdu_mngt->nb_pdus += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; - list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->li_exactly_filled_to_add_in_next_pdu = 1; + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 1) { // one byte remaining // from 3GPP TS 25.322 V4.2.0 // In the case where a PDU contains a 15-bit "Length Indicator" indicating that an RLC SDU ends with @@ -329,7 +304,6 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) // - be padded by the Sender and ignored by the Receiver though there is no "Length Indicator" // indicating the existence of Padding; and // - not be filled with the first octet of the next RLC SDU data. - // In the case where 15-bit "Length Indicators" are used for the previous PDU and // the last segment of an RLC SDU is one octet short of exactly filling the PDU: // - if a 15-bit "Length Indicator" is used for the following PDU: @@ -346,10 +320,8 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) rlc_am_encode_pdu_15 (rlc_header, pdu_mngt, rlcP->li, li_index); continue_segment = 0; sdu_mngt->sdu_remaining_size = 0; - sdu_mngt->nb_pdus += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; - list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->li_one_byte_short_to_add_in_next_pdu = 1; } @@ -369,40 +341,35 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) // - a RLC PDU consisting of an RLC Header with "Length Indicator" // "111 1111 1111 1011" followed by a padding "Length Indicator" and padding // may be transmitted; + } else if ((rlcP->li_one_byte_short_to_add_in_next_pdu)) { sdu_mngt->li_index_for_discard = li_index; rlcP->li[li_index++] = RLC_LI_LAST_PDU_ONE_BYTE_SHORT; rlcP->li_one_byte_short_to_add_in_next_pdu = 0; sdu_mngt->segmented = 1; pdu_remaining_size -= 2; - pdu_mngt->last_pdu_of_sdu += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; sdu_mngt->nb_pdus += 1; - rlcP->buffer_occupancy -= sdu_mngt->sdu_size; rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + } else if ((rlcP->li_exactly_filled_to_add_in_next_pdu)) { sdu_mngt->li_index_for_discard = li_index; rlcP->li[li_index++] = RLC_LI_LAST_PDU_EXACTLY_FILLED; rlcP->li_exactly_filled_to_add_in_next_pdu = 0; sdu_mngt->segmented = 1; pdu_remaining_size -= 2; - pdu_mngt->last_pdu_of_sdu += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; sdu_mngt->nb_pdus += 1; - rlcP->buffer_occupancy -= sdu_mngt->sdu_size; rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; } } - if (sdu_mngt->sdu_remaining_size > 0) { list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); } @@ -413,8 +380,10 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) if (pdu_remaining_size >= 2) { rlcP->li[li_index++] = RLC_LI_PDU_PADDING; sdu_mngt->no_new_sdu_segmented_in_last_pdu = 1; + } else if (pdu_remaining_size == 0) { rlcP->li_exactly_filled_to_add_in_next_pdu = 1; + } else if (pdu_remaining_size == 1) { rlcP->li_one_byte_short_to_add_in_next_pdu = 1; } @@ -423,6 +392,7 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) } rlc_am_fill_pdu (pdu, &segmented_sdus); + } else { // patch for max dat discard : avoid waiting sdu pointed by current_sdu_index <> NULL // (this sdu may have been segmented not at all then discarded) @@ -436,28 +406,24 @@ rlc_am_segment_15 (struct rlc_am_entity *rlcP) } //----------------------------------------------------------------------------- -mem_block_t * -rlc_am_segment_7 (struct rlc_am_entity * rlcP) +mem_block_t* +rlc_am_segment_7 (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - list_t segmented_sdus; // the copying of sdu data is done after identification of all LIs to put in pdu - - struct rlc_am_tx_sdu_management *sdu_mngt = NULL; - struct rlc_am_tx_data_pdu_management *pdu_mngt; - struct rlc_am_pdu_header *rlc_header; - mem_block_t *pdu = NULL; + struct rlc_am_tx_sdu_management* sdu_mngt = NULL; + struct rlc_am_tx_data_pdu_management* pdu_mngt; + struct rlc_am_pdu_header* rlc_header; + mem_block_t* pdu = NULL; int continue_segment = 1; int16_t pdu_remaining_size; uint8_t li_index = 0; - list_init (&segmented_sdus, NULL); // param string identifying the list is NULL while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (continue_segment)) { - sdu_mngt = ((struct rlc_am_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); + sdu_mngt = ((struct rlc_am_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); if (!(sdu_mngt->segmented)) { - #ifdef DEBUG_RLC_AM_SEGMENT msg ("[RLC_AM][RB %d] SEGMENT GET NEW SDU %p INDEX %d AVAILABLE SIZE %d Bytes\n", rlcP->rb_id, sdu_mngt, rlcP->current_sdu_index, sdu_mngt->sdu_remaining_size); #endif @@ -473,11 +439,11 @@ rlc_am_segment_7 (struct rlc_am_entity * rlcP) li_index = 0; pdu_remaining_size = rlcP->pdu_size - 2; // 2= size of header, minimum - pdu_mngt = (struct rlc_am_tx_data_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_am_tx_data_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_am_tx_data_pdu_allocation)); pdu_mngt->rlc_tb_type = RLC_AM_DATA_PDU_TYPE; pdu_mngt->first_byte = &pdu->data[sizeof (struct rlc_am_tx_data_pdu_allocation)]; - rlc_header = (struct rlc_am_pdu_header *) (pdu_mngt->first_byte); + rlc_header = (struct rlc_am_pdu_header*) (pdu_mngt->first_byte); if ((rlcP->li_exactly_filled_to_add_in_next_pdu)) { pdu_remaining_size -= 1; @@ -494,25 +460,23 @@ rlc_am_segment_7 (struct rlc_am_entity * rlcP) if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) < 0) { pdu_mngt->data_size += pdu_remaining_size; rlcP->buffer_occupancy -= pdu_remaining_size; - sdu_mngt->nb_pdus += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; - rlc_am_encode_pdu_7 (rlc_header, pdu_mngt, rlcP->li, li_index); continue_segment = 0; sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; pdu_remaining_size = 0; #ifdef DEBUG_RLC_AM_SEGMENT - msg ("[RLC_AM][RB %d][SEGMENT7] PDU %p %p FILLED WITH SDU index %d SDU REMAINING %d\n", rlcP->rb_id, pdu, pdu_mngt, rlcP->current_sdu_index, sdu_mngt->sdu_remaining_size); + msg ("[RLC_AM][RB %d][SEGMENT7] PDU %p %p FILLED WITH SDU index %d SDU REMAINING %d\n", rlcP->rb_id, pdu, pdu_mngt, rlcP->current_sdu_index, + sdu_mngt->sdu_remaining_size); #endif - } else { + } else { // From 3GPP TS 25.322 V4.2.0 (2001-09) p28 // If "SDU discard with explicit signalling" is configured: // - an AMD PDU can contain a maximum number of 15 "Length Indicators" indicating the end // of 15 corresponding SDUs; and // - the rest of the AMD PDU space shall be used as padding or as piggybacked STATUS PDU. - // implementation limitation : we limit the number of li to 15 even if // no "SDU discard with explicit signalling" is configured. if (li_index >= 14) { @@ -523,24 +487,20 @@ rlc_am_segment_7 (struct rlc_am_entity * rlcP) #ifdef DEBUG_RLC_AM_SEGMENT msg ("[RLC_AM][RB %d][SEGMENT7] NB MAX LI REACHED\n", rlcP->rb_id); #endif + } else { // nb li have not reached the limit if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) >= 1) { - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size - 1; // size of li length pdu_mngt->data_size += sdu_mngt->sdu_remaining_size; sdu_mngt->li_index_for_discard = li_index; rlcP->li[li_index++] = sdu_mngt->sdu_remaining_size << 1; - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; sdu_mngt->sdu_remaining_size = 0; sdu_mngt->segmented = 1; - sdu_mngt->nb_pdus += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; pdu_mngt->last_pdu_of_sdu += 1; - list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); - rlcP->nb_sdu -= 1; #ifdef DEBUG_RLC_AM_SEGMENT msg ("[RLC_AM][RB %d][SEGMENT7] SDU index %d->%d ENDING IN PDU %p %p PDU REMAINING SIZE %d\n", rlcP->rb_id, @@ -557,6 +517,7 @@ rlc_am_segment_7 (struct rlc_am_entity * rlcP) /* } else { // else:if (!last_sdu) } // the while loop continue with the same pdu */ + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 0) { // from 3GPP TS 25.322 V4.2.0 //In the case where the end of the last segment of an RLC SDU exactly ends at the end of @@ -573,12 +534,9 @@ rlc_am_segment_7 (struct rlc_am_entity * rlcP) rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; sdu_mngt->sdu_remaining_size = 0; pdu_remaining_size = 0; - sdu_mngt->nb_pdus += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; - list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; #ifdef DEBUG_RLC_AM_SEGMENT msg ("[RLC_AM][RB %d][SEGMENT7] SDU index %d EXACTLY ENDING IN PDU %p %p\n", rlcP->rb_id, rlcP->current_sdu_index, pdu, pdu_mngt); @@ -605,20 +563,18 @@ rlc_am_segment_7 (struct rlc_am_entity * rlcP) // - the "Length Indicator" with value "000 0000" shall be placed as the first // "Length indicator" in the following PDU and its SN shall be incremented by 2 // before it is transmitted. + } else if ((rlcP->li_exactly_filled_to_add_in_next_pdu)) { sdu_mngt->li_index_for_discard = li_index; rlcP->li[li_index++] = RLC_LI_LAST_PDU_EXACTLY_FILLED; rlcP->li_exactly_filled_to_add_in_next_pdu = 0; sdu_mngt->segmented = 1; //pdu_remaining_size -= 1; - pdu_mngt->last_pdu_of_sdu += 1; pdu_mngt->sdu[pdu_mngt->nb_sdu++] = rlcP->current_sdu_index; sdu_mngt->nb_pdus += 1; - //rlcP->buffer_occupancy -= sdu_mngt->sdu_size; rlcP->nb_sdu -= 1; - #ifdef DEBUG_RLC_AM_SEGMENT msg ("[RLC_AM][RB %d][SEGMENT7] RLC_LI_LAST_PDU_EXACTLY_FILLED -> PDU %p, %p, sdu index %d->%d \n", rlcP->rb_id, pdu, pdu_mngt, rlcP->current_sdu_index, (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer); @@ -637,6 +593,7 @@ rlc_am_segment_7 (struct rlc_am_entity * rlcP) if (pdu_remaining_size >= 1) { rlcP->li[li_index++] = RLC_LI_PDU_PADDING; sdu_mngt->no_new_sdu_segmented_in_last_pdu = 1; + } else { rlcP->li_exactly_filled_to_add_in_next_pdu = 1; } @@ -645,6 +602,7 @@ rlc_am_segment_7 (struct rlc_am_entity * rlcP) } rlc_am_fill_pdu (pdu, &segmented_sdus); + } else { // patch for max dat discard : avoid waiting sdu pointed by current_sdu_index <> NULL // (this sdu may have been segmented not at all then discarded) diff --git a/openair2/LAYER2/RLC/AM/rlc_am_util.c b/openair2/LAYER2/RLC/AM/rlc_am_util.c index 1b1c241af8b..129fb075ad3 100755 --- a/openair2/LAYER2/RLC/AM/rlc_am_util.c +++ b/openair2/LAYER2/RLC/AM/rlc_am_util.c @@ -42,23 +42,23 @@ #include "rlc_am_structs.h" #include "mem_block.h" //----------------------------------------------------------------------------- -inline int rlc_am_comp_sn (struct rlc_am_entity *rlcP, uint16_t low_boundaryP, uint16_t sn1P, uint16_t sn2P); -void adjust_vr_r_mr (struct rlc_am_entity *rlcP); -void adjust_vt_a_ms (struct rlc_am_entity *rlcP); -void display_protocol_vars_rlc_am (struct rlc_am_entity *rlcP); -void display_retransmission_buffer (struct rlc_am_entity *rlcP); -void display_receiver_buffer (struct rlc_am_entity *rlcP); -void rlc_am_check_retransmission_buffer (struct rlc_am_entity *rlcP, uint8_t * messageP); -void rlc_am_check_receiver_buffer (struct rlc_am_entity *rlcP, uint8_t * messageP); -void rlc_am_display_data_pdu7 (mem_block_t * pduP); +inline int rlc_am_comp_sn (struct rlc_am_entity* rlcP, uint16_t low_boundaryP, uint16_t sn1P, uint16_t sn2P); +void adjust_vr_r_mr (struct rlc_am_entity* rlcP); +void adjust_vt_a_ms (struct rlc_am_entity* rlcP); +void display_protocol_vars_rlc_am (struct rlc_am_entity* rlcP); +void display_retransmission_buffer (struct rlc_am_entity* rlcP); +void display_receiver_buffer (struct rlc_am_entity* rlcP); +void rlc_am_check_retransmission_buffer (struct rlc_am_entity* rlcP, uint8_t* messageP); +void rlc_am_check_receiver_buffer (struct rlc_am_entity* rlcP, uint8_t* messageP); +void rlc_am_display_data_pdu7 (mem_block_t* pduP); //----------------------------------------------------------------------------- #ifdef DEBUG_RLC_AM_CONFIRM //----------------------------------------------------------------------------- void -debug_rlc_am_confirm (struct rlc_am_entity *rlcP, mem_block_t * confP) +debug_rlc_am_confirm (struct rlc_am_entity* rlcP, mem_block_t* confP) { //----------------------------------------------------------------------------- - msg ("[RLC_AM][RB %d] CONFIRM SDU MUI %d\n", rlcP->rb_id, ((struct rlc_output_primitive *) (confP->data))->primitive.conf.mui); + msg ("[RLC_AM][RB %d] CONFIRM SDU MUI %d\n", rlcP->rb_id, ((struct rlc_output_primitive*) (confP->data))->primitive.conf.mui); free_mem_block_t (confP); } #endif /* DEBUG_RLC_AM_CONFIRM */ @@ -68,7 +68,7 @@ debug_rlc_am_confirm (struct rlc_am_entity *rlcP, mem_block_t * confP) // return -1 if sn1 < sn2 //----------------------------------------------------------------------------- inline int -rlc_am_comp_sn (struct rlc_am_entity *rlcP, uint16_t low_boundaryP, uint16_t sn1P, uint16_t sn2P) +rlc_am_comp_sn (struct rlc_am_entity* rlcP, uint16_t low_boundaryP, uint16_t sn1P, uint16_t sn2P) { //----------------------------------------------------------------------------- // we require that sn are in tx window, if they are not we consider that they are always @@ -84,58 +84,76 @@ rlc_am_comp_sn (struct rlc_am_entity *rlcP, uint16_t low_boundaryP, uint16_t sn1 if ((sn2P >= low_boundaryP) && (sn2P <= bound)) { if (sn1P > sn2P) { return 1; + } else { return -1; } + } else { // not in tx window return 1; } + } else { // not in tx window if ((sn2P >= low_boundaryP) && (sn2P <= bound)) { return -1; + } else { if ((sn1P > sn2P) && (sn1P <= low_boundaryP)) { return 1; + } else if ((sn2P > sn1P) && (sn2P <= low_boundaryP)) { return -1; + } else if ((sn1P > sn2P) && (sn1P > bound)) { return -1; + } else { return 1; } } } + } else { if (sn1P >= low_boundaryP) { if (sn2P <= bound) { return -1; + } else if ((sn2P >= low_boundaryP)) { if (sn1P > sn2P) { return 1; + } else { return -1; } + } else { // not in tx window return -1; } + } else if (sn1P <= bound) { if (sn2P > bound) { return 1; + } else { if (sn1P > sn2P) { return 1; + } else { return -1; } } + } else { // bound < sn1< vt_a if (sn2P >= low_boundaryP) { return -1; + } else if (sn2P <= bound) { return -1; + } else { if (sn1P > sn2P) { return 1; + } else { return -1; } @@ -146,12 +164,10 @@ rlc_am_comp_sn (struct rlc_am_entity *rlcP, uint16_t low_boundaryP, uint16_t sn1 //----------------------------------------------------------------------------- void -adjust_vt_a_ms (struct rlc_am_entity *rlcP) +adjust_vt_a_ms (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - uint16_t vt_a_index, vt_s_index; - vt_a_index = rlcP->vt_a % rlcP->recomputed_configured_tx_window_size; vt_s_index = rlcP->vt_s % rlcP->recomputed_configured_tx_window_size; @@ -165,12 +181,10 @@ adjust_vt_a_ms (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -adjust_vr_r_mr (struct rlc_am_entity *rlcP) +adjust_vr_r_mr (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - uint16_t vr_r_index, vr_h_index; - vr_r_index = rlcP->vr_r % rlcP->recomputed_configured_rx_window_size; vr_h_index = rlcP->vr_h % rlcP->recomputed_configured_rx_window_size; @@ -180,7 +194,6 @@ adjust_vr_r_mr (struct rlc_am_entity *rlcP) } rlcP->ack.vr_r_modified = 1; - #ifdef DEBUG_RECEIVER_BUFFER msg ("[RLC_AM][RB %d][RECEIVER_BUFFER] ADJUST VR(R)->0x%04X VR(H)=0x%04X\n", rlcP->rb_id, rlcP->vr_r, rlcP->vr_h); #endif @@ -189,35 +202,31 @@ adjust_vr_r_mr (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -display_protocol_vars_rlc_am (struct rlc_am_entity *rlcP) +display_protocol_vars_rlc_am (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - msg ("[RLC_AM][RB %d] VT(A) 0x%04X VT(S) 0x%04X VT(MS) 0x%04X VT(PDU) 0x%04X VT(SDU) 0x%04X VR(R) 0x%04X VR(H) 0x%04X VR(MR) 0x%04X\n", rlcP->rb_id, rlcP->vt_a, rlcP->vt_s, rlcP->vt_ms, rlcP->vt_pdu, rlcP->vt_sdu, rlcP->vr_r, rlcP->vr_h, rlcP->vr_mr); } //----------------------------------------------------------------------------- void -display_retransmission_buffer (struct rlc_am_entity *rlcP) +display_retransmission_buffer (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - uint16_t working_sn, working_sn_index; uint16_t end_sn, end_sn_index; - working_sn = rlcP->vt_a; working_sn_index = working_sn % rlcP->recomputed_configured_tx_window_size; - end_sn = (rlcP->vt_a + rlcP->recomputed_configured_tx_window_size - 1) & SN_12BITS_MASK; end_sn_index = end_sn % rlcP->recomputed_configured_tx_window_size; - - msg ("-------------------------------------------\nRetrans Buf rlc %p: VT(A) 0x%04X VT(S) 0x%04X XXX = sn based on index, (XXX) = sn read from pdu\n", rlcP, rlcP->vt_a, rlcP->vt_s); + msg ("-------------------------------------------\nRetrans Buf rlc %p: VT(A) 0x%04X VT(S) 0x%04X XXX = sn based on index, (XXX) = sn read from pdu\n", rlcP, + rlcP->vt_a, rlcP->vt_s); while (working_sn_index != end_sn_index) { - if (rlcP->retransmission_buffer[working_sn_index] != NULL) { - msg ("%03X(%03X).", working_sn, ((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[working_sn_index]->data))->sn); + msg ("%03X(%03X).", working_sn, ((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[working_sn_index]->data))->sn); + } else { msg ("_."); } @@ -235,25 +244,21 @@ display_retransmission_buffer (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -display_receiver_buffer (struct rlc_am_entity *rlcP) +display_receiver_buffer (struct rlc_am_entity* rlcP) { //----------------------------------------------------------------------------- - uint16_t working_sn, working_sn_index; uint16_t end_sn, end_sn_index; - working_sn = rlcP->vr_r; working_sn_index = working_sn % rlcP->recomputed_configured_rx_window_size; - end_sn = rlcP->vr_mr; end_sn_index = end_sn % rlcP->recomputed_configured_rx_window_size; - msg ("-------------------------------\nRec Buf rlc %p VR(R) 0x%04X: ", rlcP, rlcP->vr_r); while (working_sn_index != end_sn_index) { - if (rlcP->receiver_buffer[working_sn_index] != NULL) { - msg ("%03X(%03X)", working_sn, ((struct rlc_am_rx_pdu_management *) (rlcP->receiver_buffer[working_sn_index]->data))->sn); + msg ("%03X(%03X)", working_sn, ((struct rlc_am_rx_pdu_management*) (rlcP->receiver_buffer[working_sn_index]->data))->sn); + } else { msg ("_."); } @@ -271,25 +276,21 @@ display_receiver_buffer (struct rlc_am_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_am_check_retransmission_buffer (struct rlc_am_entity *rlcP, uint8_t * messageP) +rlc_am_check_retransmission_buffer (struct rlc_am_entity* rlcP, uint8_t* messageP) { //----------------------------------------------------------------------------- - int error_found = 0; uint16_t working_sn, working_sn_index; uint16_t end_sn, end_sn_index; - //--------------------------------------------- // check if pdu remaining outside the window //--------------------------------------------- working_sn = rlcP->vt_s; working_sn_index = working_sn % rlcP->recomputed_configured_tx_window_size; - end_sn = rlcP->vt_a; end_sn_index = end_sn % rlcP->recomputed_configured_tx_window_size; while (working_sn_index != end_sn_index) { - if (rlcP->retransmission_buffer[working_sn_index] != NULL) { msg ("[RLC_AM][RB %d] CHECK RETRANSMISSION BUFFER ERROR %s : REMAINING PDU INDEX %d=0x%04X\n", rlcP->rb_id, messageP, working_sn_index, working_sn_index); rlc_am_display_data_pdu7 (rlcP->retransmission_buffer[working_sn_index]); @@ -305,16 +306,14 @@ rlc_am_check_retransmission_buffer (struct rlc_am_entity *rlcP, uint8_t * messag //--------------------------------------------- end_sn = rlcP->vt_s; end_sn_index = end_sn % rlcP->recomputed_configured_tx_window_size; - working_sn = rlcP->vt_a; working_sn_index = working_sn % rlcP->recomputed_configured_tx_window_size; while (working_sn_index != end_sn_index) { - if (rlcP->retransmission_buffer[working_sn_index] != NULL) { - if (((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[working_sn_index]->data))->ack != RLC_AM_PDU_ACK_NO_EVENT) { + if (((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[working_sn_index]->data))->ack != RLC_AM_PDU_ACK_NO_EVENT) { msg ("[RLC_AM][RB %d] CHECK RETRANSMISSION BUFFER ERROR %s EVENT (%d) IN PDU SN 0x%04X\n", rlcP->rb_id, messageP, - ((struct rlc_am_tx_data_pdu_management *) (rlcP->retransmission_buffer[working_sn_index]->data))->ack, working_sn); + ((struct rlc_am_tx_data_pdu_management*) (rlcP->retransmission_buffer[working_sn_index]->data))->ack, working_sn); rlc_am_display_data_pdu7 (rlcP->retransmission_buffer[working_sn_index]); error_found = 1; } @@ -328,6 +327,7 @@ rlc_am_check_retransmission_buffer (struct rlc_am_entity *rlcP, uint8_t * messag display_protocol_vars_rlc_am (rlcP); while (1); + } else { msg ("[RLC_AM][RB %d] CHECK RETRANSMISSION BUFFER OK\n", rlcP->rb_id); } @@ -335,22 +335,18 @@ rlc_am_check_retransmission_buffer (struct rlc_am_entity *rlcP, uint8_t * messag //----------------------------------------------------------------------------- void -rlc_am_check_receiver_buffer (struct rlc_am_entity *rlcP, uint8_t * messageP) +rlc_am_check_receiver_buffer (struct rlc_am_entity* rlcP, uint8_t* messageP) { //----------------------------------------------------------------------------- - int error_found = 0; uint16_t working_sn, working_sn_index; uint16_t end_sn, end_sn_index; - working_sn = rlcP->vr_h; working_sn_index = working_sn % rlcP->recomputed_configured_tx_window_size; - end_sn = rlcP->vr_r; end_sn_index = end_sn % rlcP->recomputed_configured_tx_window_size; while (working_sn_index != end_sn_index) { - if (rlcP->receiver_buffer[working_sn_index] != NULL) { msg ("[RLC_AM][RB %d] CHECK RECEIVER BUFFER ERROR %s : REMAINING PDU INDEX %d=0x%04X\n", rlcP->rb_id, messageP, working_sn_index, working_sn_index); error_found = 1; @@ -367,19 +363,18 @@ rlc_am_check_receiver_buffer (struct rlc_am_entity *rlcP, uint8_t * messageP) //----------------------------------------------------------------------------- void -rlc_am_display_data_pdu7 (mem_block_t * pduP) +rlc_am_display_data_pdu7 (mem_block_t* pduP) { //----------------------------------------------------------------------------- - struct rlc_am_tx_data_pdu_management *pdu_mngt; - struct rlc_am_pdu_header *rlc_header; + struct rlc_am_tx_data_pdu_management* pdu_mngt; + struct rlc_am_pdu_header* rlc_header; int index; int nb_li = 0; int li_index = 0; uint16_t li[32]; if ((pduP)) { - pdu_mngt = (struct rlc_am_tx_data_pdu_management *) (pduP->data); - + pdu_mngt = (struct rlc_am_tx_data_pdu_management*) (pduP->data); msg ("[RLC_AM] DISPLAY DATA PDU %p SN 0x%04X LAST_PDU_OF_SDU %d\n", pduP, pdu_mngt->sn, pdu_mngt->last_pdu_of_sdu); msg ("[RLC_AM] DISPLAY DATA PDU HEADER "); @@ -401,7 +396,7 @@ rlc_am_display_data_pdu7 (mem_block_t * pduP) //-------------------------------------- // LENGTH INDICATORS //-------------------------------------- - rlc_header = (struct rlc_am_pdu_header *) (pdu_mngt->first_byte); + rlc_header = (struct rlc_am_pdu_header*) (pdu_mngt->first_byte); if ((rlc_header->byte2 & RLC_HE_MASK) != RLC_HE_SUCC_BYTE_CONTAINS_DATA) { msg ("[RLC_AM] DISPLAY DATA PDU CONTAINS LI(s) "); @@ -438,12 +433,12 @@ rlc_am_display_data_pdu7 (mem_block_t * pduP) li_index++; } + } else { msg ("[RLC_AM] DISPLAY DATA PDU CONTAINS NO LI(s) "); } msg ("\n"); - //-------------------------------------- // DATA //-------------------------------------- @@ -461,7 +456,7 @@ rlc_am_display_data_pdu7 (mem_block_t * pduP) } //----------------------------------------------------------------------------- void -rlc_am_stat_req (struct rlc_am_entity *rlcP, +rlc_am_stat_req (struct rlc_am_entity* rlcP, unsigned int* tx_pdcp_sdu, unsigned int* tx_pdcp_sdu_discarded, unsigned int* tx_retransmit_pdu_unblock, diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 862945bf26e..e2b8eee3a6d 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -47,6 +47,9 @@ #include "UTIL/LOG/log.h" #include "UL-AM-RLC.h" #include "DL-AM-RLC.h" +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif //#define TRACE_RLC_AM_DATA_REQUEST //#define TRACE_RLC_AM_TX_STATUS //#define TRACE_RLC_AM_TX @@ -72,8 +75,7 @@ rlc_am_get_buffer_occupancy_in_bytes ( if (((15 + rlc_pP->num_nack_sn*(10+1) + rlc_pP->num_nack_so*(15+15+1) + 7) >> 3) > 0) { LOG_D(RLC, PROTOCOL_CTXT_FMT RB_AM_FMT" BO : CONTROL PDU %d bytes \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - RB_AM_ARGS(rlc_pP), + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), ((15 + rlc_pP->num_nack_sn*(10+1) + rlc_pP->num_nack_so*(15+15+1) + 7) >> 3)); } @@ -99,11 +101,10 @@ rlc_am_get_buffer_occupancy_in_bytes ( #ifdef TRACE_RLC_AM_BO if ((rlc_pP->status_buffer_occupancy + rlc_pP->retransmission_buffer_occupancy + rlc_pP->sdu_buffer_occupancy + max_li_overhead + header_overhead) > 0) { - LOG_D(RLC, PROTOCOL_CTXT_FMT RB_AM_FMT" BO : STATUS BUFFER %d bytes \n", PROTOCOL_CTXT_ARGS(ctxt_pP), RB_AM_ARGS(rlc_pP), rlc_pP->status_buffer_occupancy); - LOG_D(RLC, PROTOCOL_CTXT_FMT RB_AM_FMT" BO : RETRANS BUFFER %d bytes \n", PROTOCOL_CTXT_ARGS(ctxt_pP), RB_AM_ARGS(rlc_pP), rlc_pP->retransmission_buffer_occupancy); - LOG_D(RLC, PROTOCOL_CTXT_FMT RB_AM_FMT" BO : SDU BUFFER %d bytes + li_overhead %d bytes header_overhead %d bytes (nb sdu not segmented %d)\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - RB_AM_ARGS(rlc_pP), + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" BO : STATUS BUFFER %d bytes \n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->status_buffer_occupancy); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" BO : RETRANS BUFFER %d bytes \n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->retransmission_buffer_occupancy); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" BO : SDU BUFFER %d bytes + li_overhead %d bytes header_overhead %d bytes (nb sdu not segmented %d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->sdu_buffer_occupancy, max_li_overhead, header_overhead, @@ -135,7 +136,7 @@ config_req_rlc_am ( //----------------------------------------------------------------------------- rlc_union_t *rlc_union_p = NULL; rlc_am_entity_t *l_rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, rb_idP, srb_flagP); + hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); hashtable_rc_t h_rc; h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -143,9 +144,8 @@ config_req_rlc_am ( if (h_rc == HASH_TABLE_OK) { l_rlc_p = &rlc_union_p->rlc.am; LOG_D(RLC, - PROTOCOL_CTXT_FMT RB_AM_FMT" CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d)\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - RB_AM_ARGS(l_rlc_p), + PROTOCOL_RLC_AM_CTXT_FMT" CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), config_am_pP->max_retx_threshold, config_am_pP->poll_pdu, config_am_pP->poll_byte, @@ -162,8 +162,8 @@ config_req_rlc_am ( config_am_pP->t_reordering, config_am_pP->t_status_prohibit); } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT RB_AM_FMT" CONFIG_REQ RLC NOT FOUND\n", - PROTOCOL_CTXT_ARGS(ctxt_pP) ); + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" CONFIG_REQ RLC NOT FOUND\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p)); } } uint32_t pollPDU_tab[PollPDU_pInfinity+1]= {4,8,16,32,64,128,256,1024}; // What is PollPDU_pInfinity??? 1024 for now @@ -183,7 +183,7 @@ void config_req_rlc_am_asn1 ( //----------------------------------------------------------------------------- rlc_union_t *rlc_union_p = NULL; rlc_am_entity_t *l_rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, rb_idP, srb_flagP); + hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); hashtable_rc_t h_rc; h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -198,9 +198,21 @@ void config_req_rlc_am_asn1 ( (config_am_pP->dl_AM_RLC.t_Reordering<T_Reordering_spare1) && (config_am_pP->dl_AM_RLC.t_StatusProhibit<T_StatusProhibit_spare8) ) { - LOG_D(RLC, PROTOCOL_CTXT_FMT RB_AM_FMT" CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d)\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - RB_AM_ARGS(l_rlc_p), +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RRC_ENB:MSC_RRC_UE, + NULL, + 0, + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" CONFIG-REQ t_PollRetx %u t_Reord %u t_StatusPro %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, l_rlc_p), + PollRetransmit_tab[config_am_pP->ul_AM_RLC.t_PollRetransmit], + am_t_Reordering_tab[config_am_pP->dl_AM_RLC.t_Reordering], + t_StatusProhibit_tab[config_am_pP->dl_AM_RLC.t_StatusProhibit]); +#endif + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), maxRetxThreshold_tab[config_am_pP->ul_AM_RLC.maxRetxThreshold], pollPDU_tab[config_am_pP->ul_AM_RLC.pollPDU], pollByte_tab[config_am_pP->ul_AM_RLC.pollByte], @@ -218,10 +230,19 @@ void config_req_rlc_am_asn1 ( am_t_Reordering_tab[config_am_pP->dl_AM_RLC.t_Reordering], t_StatusProhibit_tab[config_am_pP->dl_AM_RLC.t_StatusProhibit]); } else { +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_discarded_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RRC_ENB:MSC_RRC_UE, + NULL, + 0, + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" CONFIG-REQ", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, l_rlc_p)); +#endif LOG_D(RLC, - PROTOCOL_CTXT_FMT RB_AM_FMT "ILLEGAL CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d), RLC-AM NOT CONFIGURED\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - RB_AM_ARGS(l_rlc_p), + PROTOCOL_RLC_AM_CTXT_FMT"ILLEGAL CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d), RLC-AM NOT CONFIGURED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), config_am_pP->ul_AM_RLC.maxRetxThreshold, config_am_pP->ul_AM_RLC.pollPDU, config_am_pP->ul_AM_RLC.pollByte, @@ -230,8 +251,8 @@ void config_req_rlc_am_asn1 ( config_am_pP->dl_AM_RLC.t_StatusProhibit); } } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT RB_AM_FMT "CONFIG_REQ RLC NOT FOUND\n", - PROTOCOL_CTXT_ARGS(ctxt_pP) ); + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"CONFIG_REQ RLC NOT FOUND\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p)); } } @@ -344,13 +365,9 @@ rlc_am_get_pdus ( return; } } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] DELAYED SENT STATUS PDU BECAUSE T-STATUS-PROHIBIT RUNNING (TIME-OUT FRAME %5u)\n", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, - rlc_pP->t_status_prohibit.frame_time_out); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" DELAYED SENT STATUS PDU BECAUSE T-STATUS-PROHIBIT RUNNING (TIME-OUT %u)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + rlc_pP->t_status_prohibit.ms_time_out); } } @@ -382,15 +399,11 @@ rlc_am_get_pdus ( tx_data_pdu_management = &rlc_pP->pdu_retrans_buffer[rlc_pP->first_retrans_pdu_sn]; - if ((tx_data_pdu_management->header_and_payload_size <= rlc_pP->nb_bytes_requested_by_mac) && (tx_data_pdu_management->retx_count >= 0) && (tx_data_pdu_management->nack_so_start == 0) - && (tx_data_pdu_management->nack_so_stop == 0x7FFF)) { + if ((tx_data_pdu_management->header_and_payload_size <= rlc_pP->nb_bytes_requested_by_mac) && (tx_data_pdu_management->retx_count >= 0) + && (tx_data_pdu_management->nack_so_start == 0) && (tx_data_pdu_management->nack_so_stop == 0x7FFF)) { mem_block_t* copy = rlc_am_retransmit_get_copy(ctxt_pP, rlc_pP, rlc_pP->first_retrans_pdu_sn); - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RE-SEND DATA PDU SN %04d %d BYTES\n", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RE-SEND DATA PDU SN %04d %d BYTES\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->first_retrans_pdu_sn, tx_data_pdu_management->header_and_payload_size); rlc_pP->stat_tx_data_pdu += 1; @@ -406,12 +419,8 @@ rlc_am_get_pdus ( tx_data_pdu_management->retx_count += 1; return; } else if ((tx_data_pdu_management->retx_count >= 0) && (rlc_pP->nb_bytes_requested_by_mac >= RLC_AM_MIN_SEGMENT_SIZE_REQUEST)) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] SEND SEGMENT OF DATA PDU SN %04d MAC BYTES %d SIZE %d RTX COUNT %d nack_so_start %d nack_so_stop %04X(hex)\n", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" SEND SEGMENT OF DATA PDU SN %04d MAC BYTES %d SIZE %d RTX COUNT %d nack_so_start %d nack_so_stop %04X(hex)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->first_retrans_pdu_sn, rlc_pP->nb_bytes_requested_by_mac, tx_data_pdu_management->header_and_payload_size, @@ -424,12 +433,8 @@ rlc_am_get_pdus ( rlc_pP, rlc_pP->first_retrans_pdu_sn, &rlc_pP->nb_bytes_requested_by_mac); - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] SEND SEGMENT OF DATA PDU SN %04d (NEW SO %05d)\n", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" SEND SEGMENT OF DATA PDU SN %04d (NEW SO %05d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->first_retrans_pdu_sn, tx_data_pdu_management->nack_so_start); @@ -448,12 +453,8 @@ rlc_am_get_pdus ( while ((rlc_pP->first_retrans_pdu_sn != rlc_pP->vt_s) && (!(rlc_pP->pdu_retrans_buffer[rlc_pP->first_retrans_pdu_sn].flags.retransmit))) { rlc_pP->first_retrans_pdu_sn = (rlc_pP->first_retrans_pdu_sn+1) & RLC_AM_SN_MASK; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] UPDATED first_retrans_pdu_sn SN %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" UPDATED first_retrans_pdu_sn SN %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->first_retrans_pdu_sn); }; @@ -463,21 +464,13 @@ rlc_am_get_pdus ( // no more pdu to be retransmited rlc_pP->first_retrans_pdu_sn = -1; display_flag = 0; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] CLEAR first_retrans_pdu_sn\n", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" CLEAR first_retrans_pdu_sn\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } if (display_flag > 0) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] UPDATED first_retrans_pdu_sn %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" UPDATED first_retrans_pdu_sn %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->first_retrans_pdu_sn); } @@ -510,20 +503,16 @@ rlc_am_get_pdus ( rlc_am_retransmit_any_pdu(ctxt_pP, rlc_pP); return; } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] COULD NOT RETRANSMIT ANY PDU BECAUSE ", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" COULD NOT RETRANSMIT ANY PDU BECAUSE ", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); if (rlc_pP->pdus_to_mac_layer.head != NULL) { LOG_D(RLC, "THERE ARE SOME PDUS READY TO TRANSMIT "); } if (!(rlc_am_is_timer_poll_retransmit_timed_out(ctxt_pP, rlc_pP))) { - LOG_D(RLC, "TIMER POLL DID NOT TIMED OUT (RUNNING = %d NUM PDUS TO RETRANS = %d NUM BYTES TO RETRANS = %d) ", rlc_pP->t_poll_retransmit.running, rlc_pP->retrans_num_pdus, - rlc_pP->retrans_num_bytes_to_retransmit); + LOG_D(RLC, "TIMER POLL DID NOT TIMED OUT (RUNNING = %d NUM PDUS TO RETRANS = %d NUM BYTES TO RETRANS = %d) ", rlc_pP->t_poll_retransmit.running, + rlc_pP->retrans_num_pdus, rlc_pP->retrans_num_bytes_to_retransmit); } if (rlc_pP->nb_bytes_requested_by_mac <= 2) { @@ -536,12 +525,8 @@ rlc_am_get_pdus ( break; default: - LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] MAC_DATA_REQ UNKNOWN PROTOCOL STATE 0x%02X\n", - ctxt_pP->frame, - (ctxt_pP->enb_module_id) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" MAC_DATA_REQ UNKNOWN PROTOCOL STATE 0x%02X\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->protocol_state); } } @@ -560,7 +545,7 @@ rlc_am_rx ( switch (rlc->protocol_state) { case RLC_NULL_STATE: - LOG_N(RLC, "[RLC_AM %p] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", arg_pP); + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT" ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", arg_pP); list_free (&data_indP.data); break; @@ -569,7 +554,7 @@ rlc_am_rx ( break; default: - LOG_E(RLC, "[RLC_AM %p] TX UNKNOWN PROTOCOL STATE 0x%02X\n", rlc, rlc->protocol_state); + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" TX UNKNOWN PROTOCOL STATE 0x%02X\n", rlc, rlc->protocol_state); } } @@ -633,12 +618,8 @@ rlc_am_mac_status_indication ( #ifdef TRACE_RLC_AM_TX_STATUS if (tb_sizeP > 0) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] MAC_STATUS_INDICATION (DATA) %d bytes -> %d bytes\n", - ctxt_pP->frame, - (rlc->is_enb) ? "eNB" : "UE", - rlc->enb_module_id, - rlc->ue_module_id, - rlc->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" MAC_STATUS_INDICATION (DATA) %d bytes -> %d bytes\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), tb_sizeP, status_resp.buffer_occupancy_in_bytes); /*if ((tx_statusP.tx_status == MAC_TX_STATUS_SUCCESSFUL) && (tx_statusP.no_pdu)) { @@ -665,7 +646,7 @@ rlc_am_mac_data_request ( struct mac_data_req data_req; rlc_am_entity_t *l_rlc_p = (rlc_am_entity_t *) rlc_pP; unsigned int nb_bytes_requested_by_mac = ((rlc_am_entity_t *) rlc_pP)->nb_bytes_requested_by_mac; -#ifdef TRACE_RLC_AM_PDU +#if defined(TRACE_RLC_AM_PDU) || defined(MESSAGE_CHART_GENERATOR) rlc_am_pdu_info_t pdu_info; rlc_am_pdu_sn_10_t *rlc_am_pdu_sn_10_p; mem_block_t *tb_p; @@ -679,19 +660,14 @@ rlc_am_mac_data_request ( int octet_index, index; #endif - rlc_am_get_pdus (ctxt_pP, rlc_pP); - list_init (&data_req.data, NULL); + rlc_am_get_pdus (ctxt_pP, l_rlc_p); list_add_list (&l_rlc_p->pdus_to_mac_layer, &data_req.data); //((rlc_am_entity_t *) rlc_pP)->tx_pdus += data_req.data.nb_elements; if ((nb_bytes_requested_by_mac + data_req.data.nb_elements) > 0) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] MAC_DATA_REQUEST %05d BYTES REQUESTED -> %d TBs\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - l_rlc_p->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" MAC_DATA_REQUEST %05d BYTES REQUESTED -> %d TBs\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), nb_bytes_requested_by_mac, data_req.data.nb_elements); } @@ -699,7 +675,7 @@ rlc_am_mac_data_request ( data_req.buffer_occupancy_in_bytes = rlc_am_get_buffer_occupancy_in_bytes(ctxt_pP, l_rlc_p); data_req.rlc_info.rlc_protocol_state = l_rlc_p->protocol_state; -#ifdef TRACE_RLC_AM_PDU +#if defined(TRACE_RLC_AM_PDU) || defined(MESSAGE_CHART_GENERATOR) if (data_req.data.nb_elements > 0) { @@ -711,8 +687,42 @@ rlc_am_mac_data_request ( tb_size_in_bytes = ((struct mac_tb_req *) (tb_p->data))->tb_size; if ((((struct mac_tb_req *) (tb_p->data))->data_ptr[0] & RLC_DC_MASK) == RLC_DC_DATA_PDU ) { - if (rlc_am_get_data_pdu_infos(ctxt_pP,rlc_am_pdu_sn_10_p, tb_size_in_bytes, &pdu_info) >= 0) { + if (rlc_am_get_data_pdu_infos(ctxt_pP,l_rlc_p,rlc_am_pdu_sn_10_p, tb_size_in_bytes, &pdu_info) >= 0) { +#ifdef MESSAGE_CHART_GENERATOR + message_string_size = 0; + message_string_size += sprintf(&message_string[message_string_size], + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" DATA SN %u size %u RF %u P %u FI %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, l_rlc_p), + pdu_info.sn, + tb_size_in_bytes, + pdu_info.rf, + pdu_info.p, + pdu_info.fi); + + if (pdu_info.rf) { + message_string_size += sprintf(&message_string[message_string_size], " LSF %u\n", pdu_info.lsf); + message_string_size += sprintf(&message_string[message_string_size], " SO %u\n", pdu_info.so); + } + + if (pdu_info.e) { + message_string_size += sprintf(&message_string[message_string_size], "| HE:"); + + for (index=0; index < pdu_info.num_li; index++) { + message_string_size += sprintf(&message_string[message_string_size], " LI %u\n", pdu_info.li_list[index]); + } + } + + msc_log_tx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_UE:MSC_RLC_ENB, + (char*)rlc_am_pdu_sn_10_p, + tb_size_in_bytes, + message_string); + +#endif # if defined(ENABLE_ITTI) + message_string_size = 0; message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); @@ -781,11 +791,7 @@ rlc_am_mac_data_request ( msg_p->ittiMsg.rlc_am_data_pdu_req.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_am_data_pdu_req.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); # else rlc_am_display_data_pdu_infos(ctxt_pP, l_rlc_p, &pdu_info); @@ -794,8 +800,39 @@ rlc_am_mac_data_request ( } else { if (rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_p, &tb_size_in_bytes, &g_rlc_am_control_pdu_info) >= 0) { tb_size_in_bytes = ((struct mac_tb_req *) (tb_p->data))->tb_size; //tb_size_in_bytes modified by rlc_am_get_control_pdu_infos! +#ifdef MESSAGE_CHART_GENERATOR + message_string_size = 0; + message_string_size += sprintf(&message_string[message_string_size], + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" STATUS size %u D/C %u ACK_SN %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, l_rlc_p), + tb_size_in_bytes, + g_rlc_am_control_pdu_info.d_c, + g_rlc_am_control_pdu_info.ack_sn); + for (num_nack = 0; num_nack < g_rlc_am_control_pdu_info.num_nack; num_nack++) { + if (g_rlc_am_control_pdu_info.nack_list[num_nack].e2) { + message_string_size += sprintf(&message_string[message_string_size], " NACK SN %u SO START %u SO END %u", + g_rlc_am_control_pdu_info.nack_list[num_nack].nack_sn, + g_rlc_am_control_pdu_info.nack_list[num_nack].so_start, + g_rlc_am_control_pdu_info.nack_list[num_nack].so_end); + + } else { + message_string_size += sprintf(&message_string[message_string_size], " NACK SN %u", + g_rlc_am_control_pdu_info.nack_list[num_nack].nack_sn); + } + } + + msc_log_tx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_UE:MSC_RLC_ENB, + (char*)rlc_am_pdu_sn_10_p, + tb_size_in_bytes, + message_string); + +#endif # if defined(ENABLE_ITTI) + message_string_size = 0; message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC AM DATA REQ: STATUS PDU\n\n"); @@ -820,11 +857,7 @@ rlc_am_mac_data_request ( msg_p->ittiMsg.rlc_am_status_pdu_req.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_am_status_pdu_req.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); # endif } @@ -846,11 +879,11 @@ rlc_am_mac_data_indication ( ) { //----------------------------------------------------------------------------- - // rlc_am_entity_t *l_rlc_p = (rlc_am_entity_t *) rlc_pP; + rlc_am_entity_t* l_rlc_p = (rlc_am_entity_t*) rlc_pP; /*rlc_am_control_pdu_info_t control_pdu_info; int num_li; int16_t tb_size;*/ -#ifdef TRACE_RLC_AM_PDU +#if defined(TRACE_RLC_AM_PDU) || defined(MESSAGE_CHART_GENERATOR) rlc_am_pdu_info_t pdu_info; rlc_am_pdu_sn_10_t *rlc_am_pdu_sn_10_p; mem_block_t *tb_p; @@ -864,7 +897,7 @@ rlc_am_mac_data_indication ( int octet_index, index; #endif -#ifdef TRACE_RLC_AM_PDU +#if defined(TRACE_RLC_AM_PDU) || defined(MESSAGE_CHART_GENERATOR) if (data_indP.data.nb_elements > 0) { @@ -876,8 +909,42 @@ rlc_am_mac_data_indication ( tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; if ((((struct mac_tb_ind *) (tb_p->data))->data_ptr[0] & RLC_DC_MASK) == RLC_DC_DATA_PDU ) { - if (rlc_am_get_data_pdu_infos(ctxt_pP,rlc_am_pdu_sn_10_p, tb_size_in_bytes, &pdu_info) >= 0) { -# if defined(ENABLE_ITTI) + if (rlc_am_get_data_pdu_infos(ctxt_pP,l_rlc_p,rlc_am_pdu_sn_10_p, tb_size_in_bytes, &pdu_info) >= 0) { +#ifdef MESSAGE_CHART_GENERATOR + message_string_size = 0; + message_string_size += sprintf(&message_string[message_string_size], + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" DATA SN %u size %u RF %u P %u FI %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, l_rlc_p), + pdu_info.sn, + tb_size_in_bytes, + pdu_info.rf, + pdu_info.p, + pdu_info.fi); + + if (pdu_info.rf) { + message_string_size += sprintf(&message_string[message_string_size], " LSF %u\n", pdu_info.lsf); + message_string_size += sprintf(&message_string[message_string_size], " SO %u\n", pdu_info.so); + } + + if (pdu_info.e) { + message_string_size += sprintf(&message_string[message_string_size], "| HE:"); + + for (index=0; index < pdu_info.num_li; index++) { + message_string_size += sprintf(&message_string[message_string_size], " LI %u\n", pdu_info.li_list[index]); + } + } + + msc_log_rx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_UE:MSC_RLC_ENB, + (char*)rlc_am_pdu_sn_10_p, + tb_size_in_bytes, + message_string); + +#endif + +# if defined(ENABLE_ITTI) && defined(TRACE_RLC_AM_PDU) message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); @@ -946,11 +1013,7 @@ rlc_am_mac_data_indication ( msg_p->ittiMsg.rlc_am_data_pdu_ind.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_am_data_pdu_ind.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); # else rlc_am_display_data_pdu_infos(ctxt_pP, l_rlc_p, &pdu_info); @@ -958,8 +1021,40 @@ rlc_am_mac_data_indication ( } } else { if (rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_p, &tb_size_in_bytes, &g_rlc_am_control_pdu_info) >= 0) { +#ifdef MESSAGE_CHART_GENERATOR + message_string_size = 0; + message_string_size += sprintf(&message_string[message_string_size], + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" STATUS size %u D/C %u ACK_SN %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, l_rlc_p), + tb_size_in_bytes, + g_rlc_am_control_pdu_info.d_c, + g_rlc_am_control_pdu_info.ack_sn); -# if defined(ENABLE_ITTI) + for (num_nack = 0; num_nack < g_rlc_am_control_pdu_info.num_nack; num_nack++) { + if (g_rlc_am_control_pdu_info.nack_list[num_nack].e2) { + message_string_size += sprintf(&message_string[message_string_size], " NACK SN %u SO START %u SO END %u", + g_rlc_am_control_pdu_info.nack_list[num_nack].nack_sn, + g_rlc_am_control_pdu_info.nack_list[num_nack].so_start, + g_rlc_am_control_pdu_info.nack_list[num_nack].so_end); + + } else { + message_string_size += sprintf(&message_string[message_string_size], " NACK SN %u", + g_rlc_am_control_pdu_info.nack_list[num_nack].nack_sn); + } + } + + msc_log_rx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_UE:MSC_RLC_ENB, + (char*)rlc_am_pdu_sn_10_p, + tb_size_in_bytes, + message_string); + +#endif + +# if defined(ENABLE_ITTI) && defined(TRACE_RLC_AM_PDU) + message_string_size = 0; message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", ((struct mac_tb_ind *) (tb_p->data))->size); message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC AM DATA IND: STATUS PDU\n\n"); @@ -984,11 +1079,7 @@ rlc_am_mac_data_indication ( msg_p->ittiMsg.rlc_am_status_pdu_ind.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_am_status_pdu_ind.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); # endif } @@ -1038,6 +1129,18 @@ rlc_am_data_req ( data_offset = ((struct rlc_am_data_req *) (sdu_pP->data))->data_offset; data_size = ((struct rlc_am_data_req *) (sdu_pP->data))->data_size; conf = ((struct rlc_am_data_req *) (sdu_pP->data))->conf; +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (const char*)(&sdu_pP->data[data_offset]), + data_size, + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" DATA-REQ size %u mui %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, l_rlc_p), + data_size, + mui); +#endif #if defined(TRACE_RLC_AM_PDU) message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); @@ -1082,11 +1185,7 @@ rlc_am_data_req ( msg_p->ittiMsg.rlc_am_sdu_req.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_am_sdu_req.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); # else LOG_T(RLC, "%s", message_string); @@ -1118,12 +1217,8 @@ rlc_am_data_req ( l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.no_new_sdu_segmented_in_last_pdu = 0; //l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].li_index_for_discard = -1; l_rlc_p->next_sdu_index = (l_rlc_p->next_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; - LOG_I(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_REQ size %d Bytes, NB SDU %d current_sdu_index=%d next_sdu_index=%d conf %d mui %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - l_rlc_p->rb_id, + LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_REQ size %d Bytes, NB SDU %d current_sdu_index=%d next_sdu_index=%d conf %d mui %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), data_size, l_rlc_p->nb_sdu, l_rlc_p->current_sdu_index, @@ -1131,28 +1226,35 @@ rlc_am_data_req ( conf, mui); } else { - LOG_W(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_REQ BUFFER FULL, NB SDU %d current_sdu_index=%d next_sdu_index=%d size_input_sdus_buffer=%d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - l_rlc_p->rb_id, +#ifdef MESSAGE_CHART_GENERATOR + mui = ((struct rlc_am_data_req*) (sdu_pP->data))->mui; + data_offset = ((struct rlc_am_data_req*) (sdu_pP->data))->data_offset; + data_size = ((struct rlc_am_data_req*) (sdu_pP->data))->data_size; + msc_log_rx_discarded_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (const char*)(&sdu_pP->data[data_offset]), + data_size, + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" DATA-REQ size %u mui %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, l_rlc_p), + data_size, + mui); +#endif + LOG_W(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_REQ BUFFER FULL, NB SDU %d current_sdu_index=%d next_sdu_index=%d size_input_sdus_buffer=%d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), l_rlc_p->nb_sdu, l_rlc_p->current_sdu_index, l_rlc_p->next_sdu_index, RLC_AM_SDU_CONTROL_BUFFER_SIZE); - LOG_W(RLC, " input_sdus[].mem_block=%p next input_sdus[].flags.segmented=%d\n", l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].mem_block, - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.segmented); + LOG_W(RLC, " input_sdus[].mem_block=%p next input_sdus[].flags.segmented=%d\n", + l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].mem_block, l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.segmented); l_rlc_p->stat_tx_pdcp_sdu_discarded += 1; l_rlc_p->stat_tx_pdcp_bytes_discarded += ((struct rlc_am_data_req *) (sdu_pP->data))->data_size; free_mem_block (sdu_pP); #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - AssertFatal(0, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_REQ size %d Bytes, SDU DROPPED, INPUT BUFFER OVERFLOW NB SDU %d current_sdu_index=%d next_sdu_index=%d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - l_rlc_p->rb_id, + AssertFatal(0, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_REQ size %d Bytes, SDU DROPPED, INPUT BUFFER OVERFLOW NB SDU %d current_sdu_index=%d next_sdu_index=%d \n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), data_size, l_rlc_p->nb_sdu, l_rlc_p->current_sdu_index, diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h index 07adee66690..c3a10fd2cef 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h @@ -85,11 +85,16 @@ #endif +#define PROTOCOL_RLC_AM_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u]" +#define PROTOCOL_RLC_AM_CTXT_ARGS(CTXT_Pp, rLC_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ + (rLC_Pp->is_data_plane) ? "DRB AM" : "SRB AM",\ + rLC_Pp->rb_id -#define RB_AM_FMT "[%s %02u]" -#define RB_AM_ARGS(RLC_Pp) \ - (RLC_Pp->is_data_plane == TRUE) ? "DRB AM":"SRB AM", \ - RLC_Pp->rb_id +#define PROTOCOL_RLC_AM_MSC_FMT "[RNTI %"PRIx16" %s %02u]" +#define PROTOCOL_RLC_AM_MSC_ARGS(CTXT_Pp, rLC_Pp) \ + CTXT_Pp->rnti,\ + (rLC_Pp->is_data_plane) ? "DRB AM" : "SRB AM",\ + rLC_Pp->rb_id /*! \fn void rlc_am_release (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP) * \brief Empty function, TO DO. diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h index 1edf0d35cea..ff8b7a0da1d 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h @@ -57,8 +57,8 @@ * \brief Structure containing a RLC AM instance protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables. */ typedef struct rlc_am_entity_s { - //module_id_t enb_module_id; /*!< \brief eNB Virtualization index for this protocol instance. */ - //module_id_t ue_module_id; /*!< \brief UE Virtualization index for this protocol instance. */ + + rb_id_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ logical_chan_id_t channel_id; /*!< \brief Transport channel identifier. */ boolean_t is_data_plane; /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */ diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c index d34596061f5..d7f34ddc003 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c @@ -71,12 +71,8 @@ void rlc_am_free_in_sdu( } #ifdef TRACE_RLC_AM_FREE_SDU - LOG_D(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][FREE SDU] SDU INDEX %03d current_sdu_index=%d next_sdu_index=%d nb_sdu_no_segmented=%d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlcP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[FREE SDU] SDU INDEX %03u current_sdu_index=%u next_sdu_index=%u nb_sdu_no_segmented=%u\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlcP), index_in_bufferP, rlcP->current_sdu_index, rlcP->next_sdu_index, diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c index dc92bd9fa04..642f4c8d08e 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c @@ -43,11 +43,11 @@ rlc_am_init( //----------------------------------------------------------------------------- { if (rlc_pP->initialized == TRUE) { - LOG_D(RLC, PROTOCOL_CTXT_FMT"[AM INIT] INITIALIZATION ALREADY DONE, DOING NOTHING\n", - PROTOCOL_CTXT_ARGS(ctxt_pP)); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] INITIALIZATION ALREADY DONE, DOING NOTHING\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } else { - LOG_D(RLC, PROTOCOL_CTXT_FMT"[AM INIT] INITIALIZATION: STATE VARIABLES, BUFFERS, LISTS\n", - PROTOCOL_CTXT_ARGS(ctxt_pP)); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] INITIALIZATION: STATE VARIABLES, BUFFERS, LISTS\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); memset(rlc_pP, 0, sizeof(rlc_am_entity_t)); list2_init(&rlc_pP->receiver_buffer, "RX BUFFER"); @@ -60,13 +60,14 @@ rlc_am_init( rlc_pP->input_sdus = calloc(1, RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t)); #warning "cast the rlc retrans buffer to uint32" // rlc_pP->pdu_retrans_buffer = calloc(1, (uint16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t))); - rlc_pP->pdu_retrans_buffer = calloc(1, (uint32_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t))); - LOG_D(RLC, PROTOCOL_CTXT_FMT"[AM INIT] input_sdus[] = %p element size=%d\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), + rlc_pP->pdu_retrans_buffer = calloc(1, (uint32_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof( + rlc_am_tx_data_pdu_management_t))); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] input_sdus[] = %p element size=%d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->input_sdus, sizeof(rlc_am_tx_sdu_management_t)); - LOG_D(RLC, PROTOCOL_CTXT_FMT"[AM INIT] pdu_retrans_buffer[] = %p element size=%d\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] pdu_retrans_buffer[] = %p element size=%d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->pdu_retrans_buffer, sizeof(rlc_am_tx_data_pdu_management_t)); @@ -112,8 +113,8 @@ rlc_am_reestablish( * - stop and reset all timers; * - reset all state variables to their initial values. */ - LOG_D(RLC, PROTOCOL_CTXT_FMT"[AM REESTABLISH] RE-INIT STATE VARIABLES, BUFFERS, LISTS\n", - PROTOCOL_CTXT_ARGS(ctxt_pP)); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM REESTABLISH] RE-INIT STATE VARIABLES, BUFFERS, LISTS\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); #warning TODO when possible reassemble RLC SDUs from any byte segments of AMD PDUs with SN inf VR(MR) list2_free(&rlc_pP->receiver_buffer); @@ -154,10 +155,6 @@ rlc_am_cleanup( ) //----------------------------------------------------------------------------- { - LOG_I(RLC, RB_AM_FMT"[CLEANUP %p]\n", - RB_AM_ARGS(rlc_pP), - rlc_pP); - list2_free(&rlc_pP->receiver_buffer); list_free(&rlc_pP->pdus_to_mac_layer); list_free(&rlc_pP->control_pdu_list); @@ -213,9 +210,8 @@ rlc_am_configure( //----------------------------------------------------------------------------- { if (rlc_pP->configured == TRUE) { - LOG_I(RLC, PROTOCOL_CTXT_FMT"[RB AM %u][RECONFIGURE] max_retx_threshold %d poll_pdu %d poll_byte %d t_poll_retransmit %d t_reordering %d t_status_prohibit %d\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rlc_pP->rb_id, + LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RECONFIGURE] max_retx_threshold %d poll_pdu %d poll_byte %d t_poll_retransmit %d t_reordering %d t_status_prohibit %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_retx_thresholdP, poll_pduP, poll_byteP, @@ -227,14 +223,13 @@ rlc_am_configure( rlc_pP->poll_pdu = poll_pduP; rlc_pP->poll_byte = poll_byteP; rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; + rlc_pP->t_poll_retransmit.ms_duration = t_poll_retransmitP; + rlc_pP->t_reordering.ms_duration = t_reorderingP; + rlc_pP->t_status_prohibit.ms_duration = t_status_prohibitP; - rlc_pP->t_poll_retransmit.time_out = t_poll_retransmitP; - rlc_pP->t_reordering.time_out = t_reorderingP; - rlc_pP->t_status_prohibit.time_out = t_status_prohibitP; } else { - LOG_I(RLC, PROTOCOL_CTXT_FMT"[RB AM %u][CONFIGURE] max_retx_threshold %d poll_pdu %d poll_byte %d t_poll_retransmit %d t_reordering %d t_status_prohibit %d\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rlc_pP->rb_id, + LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[CONFIGURE] max_retx_threshold %d poll_pdu %d poll_byte %d t_poll_retransmit %d t_reordering %d t_status_prohibit %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_retx_thresholdP, poll_pduP, poll_byteP, @@ -274,8 +269,7 @@ rlc_am_set_debug_infos( rlc_pP->is_data_plane = 1; } - LOG_D(RLC, PROTOCOL_CTXT_FMT RB_AM_FMT "[SET DEBUG INFOS]\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - RB_AM_ARGS(rlc_pP)); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SET DEBUG INFOS]\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c index 3a8347cf16e..d5c5a3d7ddb 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c @@ -39,6 +39,9 @@ #include "list.h" #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif //#define TRACE_RLC_AM_RX_DECODE //----------------------------------------------------------------------------- @@ -59,12 +62,8 @@ rlc_am_reassembly ( const int32_t lengthP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PAYLOAD] reassembly() %d bytes\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PAYLOAD] reassembly() %d bytes\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), lengthP); if (rlc_pP->output_sdu_in_construction == NULL) { @@ -78,40 +77,23 @@ rlc_am_reassembly ( // check if no overflow in size if ((rlc_pP->output_sdu_size_to_write + lengthP) <= RLC_SDU_MAX_SIZE) { memcpy (&rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write], src_pP, lengthP); - rlc_pP->output_sdu_size_to_write += lengthP; } else { - LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PAYLOAD] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PAYLOAD] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - AssertFatal(0, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_IND, SDU SIZE OVERFLOW SDU GARBAGED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + AssertFatal(0, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_IND, SDU SIZE OVERFLOW SDU GARBAGED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif // erase SDU rlc_pP->output_sdu_size_to_write = 0; } } else { - LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PAYLOAD] ERROR OUTPUT SDU IS NULL\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PAYLOAD] ERROR OUTPUT SDU IS NULL\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - AssertFatal(0, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + AssertFatal(0, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif } } @@ -125,17 +107,15 @@ rlc_am_send_sdu ( # if defined(TRACE_RLC_UM_PDU) char message_string[7000]; size_t message_string_size = 0; +#if defined(ENABLE_ITTI) MessageDef *msg_p; +#endif int octet_index, index; #endif if ((rlc_pP->output_sdu_in_construction)) { - LOG_D(RLC, "\n\n\n[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND_SDU] %d bytes sdu %p\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND_SDU] %d bytes sdu %p\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); @@ -186,6 +166,18 @@ rlc_am_send_sdu ( message_string_size += sprintf(&message_string[message_string_size], " |\n"); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (const char*)(rlc_pP->output_sdu_in_construction->data), + rlc_pP->output_sdu_size_to_write, + MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" DATA-IND size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP,rlc_pP), + rlc_pP->output_sdu_size_to_write + ); +#endif # if defined(ENABLE_ITTI) msg_p = itti_alloc_new_message_sized (ctxt_pP->enb_flag > 0 ? TASK_RLC_ENB:TASK_RLC_UE , RLC_AM_SDU_IND, @@ -193,41 +185,34 @@ rlc_am_send_sdu ( msg_p->ittiMsg.rlc_am_sdu_ind.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_am_sdu_ind.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); # else LOG_T(RLC, "%s", message_string); # endif # endif +#if !defined(ENABLE_ITTI) + pthread_mutex_unlock(&rlc_pP->lock_input_sdus); +#endif rlc_data_ind (ctxt_pP, BOOL_NOT(rlc_pP->is_data_plane), MBMS_FLAG_NO, rlc_pP->rb_id, rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); +#if !defined(ENABLE_ITTI) + pthread_mutex_lock(&rlc_pP->lock_input_sdus); +#endif #endif rlc_pP->output_sdu_in_construction = NULL; } else { - LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); //msg("[RLC_AM][MOD %d] Freeing mem_block ...\n", rlc_pP->module_id); //free_mem_block (rlc_pP->output_sdu_in_construction); AssertFatal(3==4, - "[FRAME %5u][%s][RLC_AM][MOD %u/%u][%s %u] SEND SDU REQUESTED %d bytes", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + PROTOCOL_RLC_AM_CTXT_FMT" SEND SDU REQUESTED %d bytes", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->output_sdu_size_to_write); } @@ -245,12 +230,8 @@ rlc_am_reassemble_pdu( int i,j; rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU SN=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU SN=%03d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info->sn); #ifdef TRACE_RLC_AM_RX_DECODE rlc_am_display_data_pdu_infos(ctxt_pP, rlc_pP, pdu_info); @@ -259,12 +240,8 @@ rlc_am_reassemble_pdu( if (pdu_info->e == RLC_E_FIXED_PART_DATA_FIELD_FOLLOW) { switch (pdu_info->fi) { case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); // one complete SDU rlc_am_send_sdu(ctxt_pP, rlc_pP); // may be not necessary rlc_am_reassembly (ctxt_pP, rlc_pP, pdu_info->payload, pdu_info->payload_size); @@ -273,12 +250,8 @@ rlc_am_reassemble_pdu( break; case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); // one beginning segment of SDU in PDU rlc_am_send_sdu(ctxt_pP, rlc_pP); // may be not necessary rlc_am_reassembly (ctxt_pP, rlc_pP,pdu_info->payload, pdu_info->payload_size); @@ -286,12 +259,8 @@ rlc_am_reassemble_pdu( break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); // one last segment of SDU //if (rlc_pP->reassembly_missing_sn_detected == 0) { rlc_am_reassembly (ctxt_pP, rlc_pP, pdu_info->payload, pdu_info->payload_size); @@ -301,12 +270,8 @@ rlc_am_reassemble_pdu( break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); //if (rlc_pP->reassembly_missing_sn_detected == 0) { // one whole segment of SDU in PDU rlc_am_reassembly (ctxt_pP, rlc_pP, pdu_info->payload, pdu_info->payload_size); @@ -324,12 +289,8 @@ rlc_am_reassemble_pdu( } else { switch (pdu_info->fi) { case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=11 (00) Li=", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU FI=11 (00) Li=", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); for (i=0; i < pdu_info->num_li; i++) { LOG_D(RLC, "%d ",pdu_info->li_list[i]); @@ -357,12 +318,8 @@ rlc_am_reassemble_pdu( break; case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=10 (01) Li=", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU FI=10 (01) Li=", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); for (i=0; i < pdu_info->num_li; i++) { LOG_D(RLC, "%d ",pdu_info->li_list[i]); @@ -389,12 +346,8 @@ rlc_am_reassemble_pdu( break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=01 (10) Li=", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU FI=01 (10) Li=", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); for (i=0; i < pdu_info->num_li; i++) { LOG_D(RLC, "%d ",pdu_info->li_list[i]); @@ -421,12 +374,8 @@ rlc_am_reassemble_pdu( break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=00 (11) Li=", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU FI=00 (11) Li=", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); for (i=0; i < pdu_info->num_li; i++) { LOG_D(RLC, "%d ",pdu_info->li_list[i]); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c index 06050f0260f..5d79ac68355 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c @@ -45,6 +45,7 @@ signed int rlc_am_get_data_pdu_infos( const protocol_ctxt_t* const ctxt_pP, + const rlc_am_entity_t* const rlc_pP, rlc_am_pdu_sn_10_t* header_pP, int16_t total_sizeP, rlc_am_pdu_info_t* pdu_info_pP) @@ -106,8 +107,8 @@ rlc_am_get_data_pdu_infos( pdu_info_pP->num_li = pdu_info_pP->num_li + 1; if (pdu_info_pP->num_li > RLC_AM_MAX_SDU_IN_PDU) { - LOG_E(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][GET PDU INFO] SN %04d TOO MANY LIs ", - ctxt_pP->frame, + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs ", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info_pP->sn); return -2; } @@ -128,8 +129,8 @@ rlc_am_get_data_pdu_infos( return 0; } else { - LOG_W(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][GET DATA PDU INFO] SN %04d ERROR CONTROL PDU ", - ctxt_pP->frame, + LOG_W(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[GET DATA PDU INFO] SN %04d ERROR CONTROL PDU ", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info_pP->sn); return -1; } @@ -146,23 +147,15 @@ rlc_am_display_data_pdu_infos( if (pdu_info_pP->d_c) { if (pdu_info_pP->rf) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d SO %05d LSF %01d POLL %1d ", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d SO %05d LSF %01d POLL %1d ", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info_pP->sn, pdu_info_pP->fi, pdu_info_pP->so, pdu_info_pP->lsf, pdu_info_pP->p); } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d POLL %1d ", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d POLL %1d ", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info_pP->sn, pdu_info_pP->fi, pdu_info_pP->p); @@ -178,12 +171,8 @@ rlc_am_display_data_pdu_infos( LOG_D(RLC, "\n"); } else { - LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][DISPLAY DATA PDU] ERROR RX CONTROL PDU\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[DISPLAY DATA PDU] ERROR RX CONTROL PDU\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } } // assumed the sn of the tb_p is equal to VR(MS) @@ -207,12 +196,8 @@ rlc_am_rx_update_vr_ms( if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received == 0) { #ifdef TRACE_RLC_AM_RX - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_ms, pdu_info_cursor_p->sn); #endif rlc_pP->vr_ms = pdu_info_cursor_p->sn; @@ -223,12 +208,8 @@ rlc_am_rx_update_vr_ms( } while (cursor_p != NULL); #ifdef TRACE_RLC_AM_RX - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_ms, (pdu_info_cursor_p->sn + 1) & RLC_AM_SN_MASK); #endif @@ -259,12 +240,8 @@ rlc_am_rx_update_vr_r( } #ifdef TRACE_RLC_AM_RX - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][UPDATE VR(R)] UPDATED VR(R) %04d -> %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[UPDATE VR(R)] UPDATED VR(R) %04d -> %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_r, (pdu_info_cursor_p->sn + 1) & RLC_AM_SN_MASK); #endif @@ -294,6 +271,7 @@ rlc_am_receive_routing ( mem_block_t *tb_p = NULL; uint8_t *first_byte_p = NULL; sdu_size_t tb_size_in_bytes; + pthread_mutex_lock(&rlc_pP->lock_input_sdus); while ((tb_p = list_remove_head (&data_indP.data))) { first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; @@ -314,16 +292,13 @@ rlc_am_receive_routing ( tb_size_in_bytes); } - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RX ROUTING] VR(R)=%03d VR(MR)=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RX ROUTING] VR(R)=%03d VR(MR)=%03d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_r, rlc_pP->vr_mr); } } // end while + pthread_mutex_unlock(&rlc_pP->lock_input_sdus); } //----------------------------------------------------------------------------- void @@ -364,28 +339,20 @@ rlc_am_receive_process_data_pdu ( rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10_p = (rlc_am_pdu_sn_10_t*)first_byte_pP; - if (rlc_am_get_data_pdu_infos(ctxt_pP,rlc_am_pdu_sn_10_p, tb_size_in_bytesP, pdu_info_p) >= 0) { + if (rlc_am_get_data_pdu_infos(ctxt_pP,rlc_pP, rlc_am_pdu_sn_10_p, tb_size_in_bytesP, pdu_info_p) >= 0) { ((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received = 0; if (rlc_am_in_rx_window(ctxt_pP, rlc_pP, pdu_info_p->sn)) { if (pdu_info_p->p) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] POLL BIT SET, STATUS REQUESTED:\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] POLL BIT SET, STATUS REQUESTED:\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_pP->status_requested = 1; } - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] VR(R) %04d VR(H) %04d VR(MR) %04d VR(MS) %04d VR(X) %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] VR(R) %04d VR(H) %04d VR(MR) %04d VR(MS) %04d VR(X) %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_r, rlc_pP->vr_h, rlc_pP->vr_mr, @@ -396,21 +363,13 @@ rlc_am_receive_process_data_pdu ( rlc_pP->stat_rx_data_pdu_dropped += 1; rlc_pP->stat_rx_data_bytes_dropped += tb_size_in_bytesP; free_mem_block (tb_pP); - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] PDU DISCARDED, STATUS REQUESTED:\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] PDU DISCARDED, STATUS REQUESTED:\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_pP->status_requested = 1; #if defined(RLC_STOP_ON_LOST_PDU) AssertFatal( 0 == 1, - "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] LOST PDU DETECTED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + PROTOCOL_RLC_AM_CTXT_FMT" LOST PDU DETECTED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif } else { // 5.1.3.2.3 @@ -446,12 +405,8 @@ rlc_am_receive_process_data_pdu ( #ifdef TRACE_RLC_AM_RX - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] RX LIST AFTER INSERTION:\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] RX LIST AFTER INSERTION:\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_am_rx_list_display(rlc_pP, "rlc_am_receive_process_data_pdu AFTER INSERTION "); #endif @@ -488,12 +443,8 @@ rlc_am_receive_process_data_pdu ( } } - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] VR(R) %04d VR(H) %04d VR(MS) %04d VR(MR) %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] VR(R) %04d VR(H) %04d VR(MS) %04d VR(MR) %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_r, rlc_pP->vr_h, rlc_pP->vr_ms, @@ -502,12 +453,8 @@ rlc_am_receive_process_data_pdu ( rlc_pP->stat_rx_data_pdu_out_of_window += 1; rlc_pP->stat_rx_data_bytes_out_of_window += tb_size_in_bytesP; free_mem_block (tb_pP); - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] PDU OUT OF RX WINDOW, DISCARDED, STATUS REQUESTED:\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] PDU OUT OF RX WINDOW, DISCARDED, STATUS REQUESTED:\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_pP->status_requested = 1; } } else { diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h index aec8a0a91b8..18a34235649 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h @@ -56,15 +56,21 @@ # define public_rlc_am_receiver(x) extern x # endif # endif -/*! \fn signed int rlc_am_get_data_pdu_infos( const protocol_ctxt_t* const ctxt_pP, rlc_am_pdu_sn_10_t* headerP, int16_t sizeP, rlc_am_pdu_info_t* pdu_infoP) +/*! \fn signed int rlc_am_get_data_pdu_infos( const protocol_ctxt_t* const ctxt_pP, const rlc_am_entity_t * const rlc_pP,rlc_am_pdu_sn_10_t* headerP, int16_t sizeP, rlc_am_pdu_info_t* pdu_infoP) * \brief Extract PDU informations (header fields, data size, etc) from the serialized PDU. * \param[in] ctxt_pP Running context. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] headerP RLC AM header PDU pointer. * \param[in] sizeP Size of RLC AM PDU. * \param[in] pdu_infoP Structure containing extracted informations from PDU. * \return 0 if no error was encountered during the parsing of the PDU, else -1; */ -protected_rlc_am_receiver( signed int rlc_am_get_data_pdu_infos(const protocol_ctxt_t* const ctxt_pP, rlc_am_pdu_sn_10_t* headerP, int16_t sizeP, rlc_am_pdu_info_t* pdu_infoP)); +protected_rlc_am_receiver( signed int rlc_am_get_data_pdu_infos( + const protocol_ctxt_t* const ctxt_pP, + const rlc_am_entity_t * const rlc_pP, + rlc_am_pdu_sn_10_t* headerP, + int16_t sizeP, + rlc_am_pdu_info_t* pdu_infoP)); /*! \fn void rlc_am_display_data_pdu_infos(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, rlc_am_pdu_info_t* pdu_infoP) * \brief Display RLC AM PDU informations. diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c index 201e9b9bd05..c38a71cde40 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c @@ -92,12 +92,8 @@ void rlc_am_nack_pdu ( rlc_pP->first_retrans_pdu_sn = snP; } - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][NACK-PDU] NACK PDU SN %04d previous retx_count %d 1ST_RETRANS_PDU %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[NACK-PDU] NACK PDU SN %04d previous retx_count %d 1ST_RETRANS_PDU %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, rlc_pP->pdu_retrans_buffer[snP].retx_count, rlc_pP->first_retrans_pdu_sn); @@ -131,12 +127,8 @@ void rlc_am_nack_pdu ( } } } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][NACK-PDU] ERROR NACK MISSING PDU SN %05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[NACK-PDU] ERROR NACK MISSING PDU SN %05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP); //assert(2==3); } @@ -158,12 +150,8 @@ void rlc_am_ack_pdu ( //if (mb_pP != NULL) { free_mem_block(mb_p); rlc_pP->pdu_retrans_buffer[snP].mem_block = NULL; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] ACK PDU SN %05d previous retx_count %d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[ACK-PDU] ACK PDU SN %05d previous retx_count %d \n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, rlc_pP->pdu_retrans_buffer[snP].retx_count); rlc_pP->retrans_num_pdus -= 1; @@ -220,12 +208,8 @@ void rlc_am_ack_pdu ( rlc_pP->vt_ms = (rlc_pP->vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] UPDATED VT(A) %04d VT(MS) %04d VT(S) %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[ACK-PDU] UPDATED VT(A) %04d VT(MS) %04d VT(S) %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vt_a, rlc_pP->vt_ms, rlc_pP->vt_s); @@ -236,12 +220,8 @@ void rlc_am_ack_pdu ( rlc_pP->first_retrans_pdu_sn = (rlc_pP->first_retrans_pdu_sn + 1) & RLC_AM_SN_MASK; if (rlc_pP->pdu_retrans_buffer[rlc_pP->first_retrans_pdu_sn].retx_count >= 0) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] UPDATED first_retrans_pdu_sn -> %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[ACK-PDU] UPDATED first_retrans_pdu_sn -> %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->first_retrans_pdu_sn); break; } @@ -249,22 +229,14 @@ void rlc_am_ack_pdu ( if (rlc_pP->vt_s == rlc_pP->first_retrans_pdu_sn) { rlc_pP->first_retrans_pdu_sn = -1; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] UPDATED first_retrans_pdu_sn -> %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[ACK-PDU] UPDATED first_retrans_pdu_sn -> %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->first_retrans_pdu_sn); } } } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] WARNING ACK PDU SN %05d -> NO PDU TO ACK\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[ACK-PDU] WARNING ACK PDU SN %05d -> NO PDU TO ACK\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP); if (mb_p != NULL) { @@ -286,12 +258,8 @@ void rlc_am_ack_pdu ( } while ((rlc_pP->pdu_retrans_buffer[rlc_pP->vt_a].flags.ack == 1) && (rlc_pP->vt_a != rlc_pP->vt_s)); rlc_pP->vt_ms = (rlc_pP->vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] UPDATED VT(A) %04d VT(MS) %04d VT(S) %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[ACK-PDU] UPDATED VT(A) %04d VT(MS) %04d VT(S) %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vt_a, rlc_pP->vt_ms, rlc_pP->vt_s); @@ -392,17 +360,13 @@ mem_block_t* rlc_am_retransmit_get_subsegment( ((struct mac_tb_req*)(mb_sub_segment_p->data))->data_ptr = (uint8_t*)&(mb_sub_segment_p->data[sizeof(struct mac_tb_req)]); - if (rlc_am_get_data_pdu_infos(ctxt_pP,pdu_original_p, rlc_pP->pdu_retrans_buffer[snP].header_and_payload_size, &pdu_info) >= 0) { + if (rlc_am_get_data_pdu_infos(ctxt_pP, rlc_pP, pdu_original_p, rlc_pP->pdu_retrans_buffer[snP].header_and_payload_size, &pdu_info) >= 0) { int li_index = 0; int start_offset = rlc_pP->pdu_retrans_buffer[snP].nack_so_start; int stop_offset = rlc_pP->pdu_retrans_buffer[snP].nack_so_stop; - LOG_D(RLC, "\n[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ORIGINAL PDU SN %04d:\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] ORIGINAL PDU SN %04d:\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP); rlc_am_display_data_pdu_infos(ctxt_pP, rlc_pP, &pdu_info); @@ -411,13 +375,10 @@ mem_block_t* rlc_am_retransmit_get_subsegment( if (stop_offset == 0x7FFF) { rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = rlc_pP->pdu_retrans_buffer[snP].payload_size - 1; stop_offset = rlc_pP->pdu_retrans_buffer[snP].nack_so_stop; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] UPDATED RETRANS PDU SN %04d nack_so_stop FROM 0x7FFF to %05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, - snP, stop_offset); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] UPDATED RETRANS PDU SN %04d nack_so_stop FROM 0x7FFF to %05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + snP, + stop_offset); } // FIXED PART AMD PDU SEGMENT HEADER @@ -466,30 +427,18 @@ mem_block_t* rlc_am_retransmit_get_subsegment( max_copy_payload_size = stop_offset - start_offset + 1; assert(max_copy_payload_size > 0); assert(test_pdu_remaining_size > 0); - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] HOLE FOUND SO %d -> %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] HOLE FOUND SO %d -> %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), start_offset, stop_offset); - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ORIGINAL FI %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] ORIGINAL FI %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), (pdu_original_p->b1 & 0x18) >> 3); // second constraint the size of the pdu_p requested by MAC layer if (max_copy_payload_size > test_pdu_remaining_size) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_copy_payload_size, test_pdu_remaining_size); max_copy_payload_size = test_pdu_remaining_size; @@ -504,30 +453,18 @@ mem_block_t* rlc_am_retransmit_get_subsegment( //.find the li corresponding to the nack_so_start (start_offset) if (pdu_info.num_li > 0) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ORIGINAL NUM LI %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] ORIGINAL NUM LI %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info.num_li); while ((li_index < pdu_info.num_li) && (continue_fill_pdu_with_pdu)) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] FIND LI %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] FIND LI %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info.li_list[li_index]); if (max_copy_payload_size > test_pdu_remaining_size) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_copy_payload_size, test_pdu_remaining_size); max_copy_payload_size = test_pdu_remaining_size; @@ -541,12 +478,8 @@ mem_block_t* rlc_am_retransmit_get_subsegment( //--------------------------------------------------------------- if (test_start_offset < test_li_sum) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] test_start_offset < test_li_sum %d < %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] test_start_offset < test_li_sum %d < %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), test_start_offset, test_li_sum); /*if (test_max_copy_payload_size > (test_li_sum - test_start_offset)) { @@ -557,21 +490,13 @@ mem_block_t* rlc_am_retransmit_get_subsegment( }*/ if ((max_copy_payload_size + test_start_offset) < test_li_sum) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (max_copy_payload_size %d + test_start_offset %d) < test_li_sum %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] (max_copy_payload_size %d + test_start_offset %d) < test_li_sum %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_copy_payload_size, test_start_offset, test_li_sum); - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), test_start_offset , test_start_offset + max_copy_payload_size - 1, max_copy_payload_size ); @@ -583,20 +508,12 @@ mem_block_t* rlc_am_retransmit_get_subsegment( max_copy_payload_size = 0; } else if ((max_copy_payload_size + test_start_offset) == test_li_sum) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (max_copy_payload_size + test_start_offset) == test_li_sum %d == %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] (max_copy_payload_size + test_start_offset) == test_li_sum %d == %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), (max_copy_payload_size + test_start_offset) , test_li_sum); - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), test_start_offset , test_start_offset + max_copy_payload_size - 1, max_copy_payload_size ); @@ -608,21 +525,14 @@ mem_block_t* rlc_am_retransmit_get_subsegment( max_copy_payload_size = 0; } else if ((max_copy_payload_size + test_start_offset - (test_li_length_in_bytes ^ 3)) > test_li_sum) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (max_copy_payload_size + test_start_offset - (test_li_length_in_bytes ^ 3)) > test_li_sum %d > %d\n SET LI %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, + PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] (max_copy_payload_size + test_start_offset - (test_li_length_in_bytes ^ 3)) > test_li_sum %d > %d\n SET LI %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), (max_copy_payload_size + test_start_offset) + (test_li_length_in_bytes ^ 3), test_li_sum, test_li_sum - test_start_offset); - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), test_start_offset , test_li_sum - 1, test_li_sum - test_start_offset ); @@ -635,12 +545,8 @@ mem_block_t* rlc_am_retransmit_get_subsegment( test_li_length_in_bytes; max_copy_payload_size = max_copy_payload_size - test_li_sum + test_start_offset - test_li_length_in_bytes; - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] NOW max_copy_payload_size %d BYTES test_start_offset %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] NOW max_copy_payload_size %d BYTES test_start_offset %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_copy_payload_size, test_li_sum); // normally the next while itereation will add bytes to PDU @@ -648,20 +554,12 @@ mem_block_t* rlc_am_retransmit_get_subsegment( test_start_offset = test_li_sum; } else { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (test_max_copy_payload_size + test_start_offset ) > test_li_sum %d > %d\n NO REMAINING SIZE FOR LI", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] (test_max_copy_payload_size + test_start_offset ) > test_li_sum %d > %d\n NO REMAINING SIZE FOR LI", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), (max_copy_payload_size + test_start_offset), test_li_sum); - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), test_start_offset , test_li_sum - 1, test_li_sum - test_start_offset ); @@ -680,12 +578,8 @@ mem_block_t* rlc_am_retransmit_get_subsegment( // start offset start at the begining of a SDU // and it cant be the first data field of the original PDU } else if (test_start_offset == test_li_sum) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (test_start_offset == test_li_sum) %d == %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] (test_start_offset == test_li_sum) %d == %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), test_start_offset , test_li_sum); @@ -704,12 +598,8 @@ mem_block_t* rlc_am_retransmit_get_subsegment( (max_copy_payload_size > 0) ) { if (max_copy_payload_size > test_pdu_remaining_size) { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] TRYING HIDDEN SIZE...CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] TRYING HIDDEN SIZE...CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_copy_payload_size, test_pdu_remaining_size); max_copy_payload_size = test_pdu_remaining_size; @@ -719,12 +609,8 @@ mem_block_t* rlc_am_retransmit_get_subsegment( if ((max_copy_payload_size + test_start_offset) >= (pdu_info.hidden_size + test_li_sum)) { test_pdu_copy_size += (pdu_info.hidden_size + test_li_sum - test_start_offset); LOG_T(RLC, - "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPYING WHOLE REMAINING SIZE %d (max_copy_payload_size %d, test_start_offset %d, pdu_info.hidden_size %d test_li_sum %d test_pdu_copy_size %d)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] COPYING WHOLE REMAINING SIZE %d (max_copy_payload_size %d, test_start_offset %d, pdu_info.hidden_size %d test_li_sum %d test_pdu_copy_size %d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info.hidden_size + test_li_sum - test_start_offset, max_copy_payload_size, test_start_offset, @@ -734,12 +620,8 @@ mem_block_t* rlc_am_retransmit_get_subsegment( test_start_offset = pdu_info.hidden_size + test_li_sum; not_test_fi = (not_test_fi & 0x2) | (not_fi_original & 0x1); // set b0 idendical to the b0 of the non segmented PDU } else { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPYING REMAINING SIZE %d (/%d)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] COPYING REMAINING SIZE %d (/%d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_copy_payload_size, pdu_info.hidden_size); test_pdu_copy_size += max_copy_payload_size; @@ -748,12 +630,8 @@ mem_block_t* rlc_am_retransmit_get_subsegment( } } } else { // num_li == 0 - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (num_li == 0)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] (num_li == 0)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); test_pdu_copy_size = max_copy_payload_size; if ((stop_offset == (start_offset + max_copy_payload_size - 1)) && (stop_offset == rlc_pP->pdu_retrans_buffer[snP].payload_size - 1)) { @@ -774,7 +652,7 @@ mem_block_t* rlc_am_retransmit_get_subsegment( //--------------------------------------------------------------- // fill the segment pdu_p with Lis and data //--------------------------------------------------------------- - LOG_T(RLC, "[FRAME XXXXX][RLC_AM][MOD XX][RB XX][RE-SEGMENT] fill the segment pdu_p with Lis and data, test_num_li %d\n", + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] fill the segment pdu_p with Lis and data, test_num_li %d\n", test_num_li); if (test_num_li > 0) { @@ -807,21 +685,13 @@ mem_block_t* rlc_am_retransmit_get_subsegment( *sizeP = *sizeP - 1; } - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ADD LI %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RB %u][RE-SEGMENT] ADD LI %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), test_li_list[fill_num_li]); } } else { - LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ADD NO LI\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RB %u][RE-SEGMENT] ADD NO LI\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); fill_payload_p = (uint8_t*)e_li_sub_segment; } @@ -840,30 +710,23 @@ mem_block_t* rlc_am_retransmit_get_subsegment( rlc_pP->pdu_retrans_buffer[snP].flags.retransmit = 0; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] RE-SEND DATA PDU SN %04d SO %d %d BYTES PAYLOAD %d BYTES LSF!\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] RE-SEND DATA PDU SN %04d SO %d %d BYTES PAYLOAD %d BYTES LSF!\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, start_offset, ((struct mac_tb_req*)(mb_sub_segment_p->data))->tb_size, test_pdu_copy_size); } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] RE-SEND DATA PDU SN %04d SO %d %d BYTES PAYLOAD %d BYTES\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] RE-SEND DATA PDU SN %04d SO %d %d BYTES PAYLOAD %d BYTES\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, start_offset, ((struct mac_tb_req*)(mb_sub_segment_p->data))->tb_size, test_pdu_copy_size); } - LOG_T(RLC, "[FRAME XXXXX][RLC_AM][MOD XX][RB XX][RE-SEGMENT] *sizeP %d = *sizeP %d - test_pdu_copy_size %d\n", + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] *sizeP %d = *sizeP %d - test_pdu_copy_size %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), *sizeP - test_pdu_copy_size, *sizeP, test_pdu_copy_size); @@ -873,12 +736,8 @@ mem_block_t* rlc_am_retransmit_get_subsegment( //--------------------------------------------------------------- rlc_am_remove_hole(ctxt_pP, rlc_pP, snP, start_offset, test_pdu_copy_size+start_offset - 1); //rlc_pP->pdu_retrans_buffer[snP].nack_so_start = rlc_pP->pdu_retrans_buffer[snP].nack_so_start + test_pdu_copy_size; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] RE-SEND DATA PDU SN %04d NOW nack_so_start %d nack_so_stop %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] RE-SEND DATA PDU SN %04d NOW nack_so_start %d nack_so_stop %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, rlc_pP->pdu_retrans_buffer[snP].nack_so_start, rlc_pP->pdu_retrans_buffer[snP].nack_so_stop); @@ -887,25 +746,17 @@ mem_block_t* rlc_am_retransmit_get_subsegment( rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; }*/ } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COULD NOT GET INFO FOR DATA PDU SN %04d -> RETURN NULL\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, snP); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] COULD NOT GET INFO FOR DATA PDU SN %04d -> RETURN NULL\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + snP); return NULL; } rlc_am_pdu_polling(ctxt_pP, rlc_pP, pdu_sub_segment_p, test_pdu_copy_size); - return mb_sub_segment_p; } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] RE-SEND DATA PDU SN %04d BUT NO PDU AVAILABLE -> RETURN NULL\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] RE-SEND DATA PDU SN %04d BUT NO PDU AVAILABLE -> RETURN NULL\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP); assert(3==4); return NULL; @@ -922,22 +773,14 @@ void rlc_am_tx_buffer_display ( int i, loop = 0; if (message_pP) { - LOG_D(RLC, "\n[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] Retransmission buffer %s VT(A)=%04d VT(S)=%04d:", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" Retransmission buffer %s VT(A)=%04d VT(S)=%04d:", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), message_pP, rlc_pP->vt_a, rlc_pP->vt_s); } else { - LOG_D(RLC, "\n[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] Retransmission buffer VT(A)=%04d VT(S)=%04d:", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" Retransmission buffer VT(A)=%04d VT(S)=%04d:", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vt_a, rlc_pP->vt_s); } @@ -949,9 +792,11 @@ void rlc_am_tx_buffer_display ( } if (rlc_pP->pdu_retrans_buffer[sn].flags.retransmit) { - LOG_D(RLC, "%04d %d/%d Bytes (NACK RTX:%02d ",sn, rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size, rlc_pP->pdu_retrans_buffer[sn].payload_size, rlc_pP->pdu_retrans_buffer[sn].retx_count); + LOG_D(RLC, "%04d %d/%d Bytes (NACK RTX:%02d ",sn, rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size, rlc_pP->pdu_retrans_buffer[sn].payload_size, + rlc_pP->pdu_retrans_buffer[sn].retx_count); } else { - LOG_D(RLC, "%04d %d/%d Bytes (RTX:%02d ",sn, rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size, rlc_pP->pdu_retrans_buffer[sn].payload_size, rlc_pP->pdu_retrans_buffer[sn].retx_count); + LOG_D(RLC, "%04d %d/%d Bytes (RTX:%02d ",sn, rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size, rlc_pP->pdu_retrans_buffer[sn].payload_size, + rlc_pP->pdu_retrans_buffer[sn].retx_count); } if (rlc_pP->pdu_retrans_buffer[sn].num_holes == 0) { @@ -984,12 +829,8 @@ void rlc_am_retransmit_any_pdu( mem_block_t* pdu_p = NULL; rlc_am_pdu_sn_10_t* pdu_sn_10_p = NULL; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][FORCE-TRAFFIC] rlc_am_retransmit_any_pdu()\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[FORCE-TRAFFIC] rlc_am_retransmit_any_pdu()\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); while (sn != sn_end) { if (rlc_pP->pdu_retrans_buffer[sn].mem_block != NULL) { @@ -999,12 +840,9 @@ void rlc_am_retransmit_any_pdu( } if (rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size <= rlc_pP->nb_bytes_requested_by_mac) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][FORCE-TRAFFIC] RE-SEND DATA PDU SN %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, sn); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[FORCE-TRAFFIC] RE-SEND DATA PDU SN %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + sn); rlc_am_nack_pdu (ctxt_pP, rlc_pP, sn, 0, 0x7FFF); // no need for update rlc_pP->nb_bytes_requested_by_mac pdu_p = rlc_am_retransmit_get_copy(ctxt_pP, rlc_pP, sn); @@ -1030,12 +868,8 @@ void rlc_am_retransmit_any_pdu( // no pdu_p with correct size has been found // so re-segment a pdu_p if possible if (found_pdu) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][FORCE-TRAFFIC] SEND SEGMENT OF DATA PDU SN %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[FORCE-TRAFFIC] SEND SEGMENT OF DATA PDU SN %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), found_pdu_sn); if (rlc_pP->nb_bytes_requested_by_mac > 4) { @@ -1055,12 +889,8 @@ void rlc_am_retransmit_any_pdu( list_add_tail_eurecom (pdu_p, &rlc_pP->pdus_to_mac_layer); return; } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][FORCE-TRAFFIC] ... BUT NOT ENOUGH BYTES ALLOWED BY MAC %0d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[FORCE-TRAFFIC] ... BUT NOT ENOUGH BYTES ALLOWED BY MAC %0d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->nb_bytes_requested_by_mac); } } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c index 6988592f286..d57791dcf7c 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c @@ -56,7 +56,6 @@ rlc_am_rx_list_insert_pdu( rlc_am_pdu_info_t* pdu_info_previous_cursor_p = NULL; mem_block_t* cursor_p = NULL; mem_block_t* previous_cursor_p = NULL; - cursor_p = rlc_pP->receiver_buffer.head; // it is assumed this pdu is in rx window @@ -72,23 +71,16 @@ rlc_am_rx_list_insert_pdu( if (pdu_info_previous_cursor_p->sn == pdu_info_p->sn) { if (pdu_info_p->rf != pdu_info_previous_cursor_p->rf) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; } else if (pdu_info_p->rf == 1) { if ((pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1) >= pdu_info_p->so) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -97,12 +89,8 @@ rlc_am_rx_list_insert_pdu( } } - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); @@ -110,12 +98,8 @@ rlc_am_rx_list_insert_pdu( } else if (pdu_info_p->sn == pdu_info_cursor_p->sn) { if (pdu_info_cursor_p->rf == 0) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -128,24 +112,16 @@ rlc_am_rx_list_insert_pdu( if (pdu_info_previous_cursor_p->sn == pdu_info_cursor_p->sn) { if ((pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1) < pdu_info_p->so) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn, pdu_info_p->so); list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -153,12 +129,8 @@ rlc_am_rx_list_insert_pdu( } } - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn, pdu_info_p->so); @@ -166,23 +138,15 @@ rlc_am_rx_list_insert_pdu( return 0; } else if (pdu_info_p->so <= pdu_info_cursor_p->so) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; } } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -198,58 +162,38 @@ rlc_am_rx_list_insert_pdu( } if (cursor_p != NULL) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { if (pdu_info_cursor_p->rf == 0) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } else if ((pdu_info_p->rf == 1) && (pdu_info_cursor_p->rf == 1) && (pdu_info_p->sn == pdu_info_cursor_p->sn)) { if ((pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1) < pdu_info_p->so) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; } } else if (pdu_info_p->sn != pdu_info_cursor_p->sn) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); @@ -257,12 +201,8 @@ rlc_am_rx_list_insert_pdu( } } - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -278,22 +218,14 @@ rlc_am_rx_list_insert_pdu( if (pdu_info_previous_cursor_p->sn == pdu_info_cursor_p->sn) { if (pdu_info_p->rf != pdu_info_previous_cursor_p->rf) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; } else if (pdu_info_p->rf == 1) { if ((pdu_info_p->so + pdu_info_p->payload_size - 1) >= pdu_info_previous_cursor_p->so) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -302,24 +234,16 @@ rlc_am_rx_list_insert_pdu( } } - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_insert_after_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else if (pdu_info_p->sn == pdu_info_cursor_p->sn) { if (pdu_info_cursor_p->rf == 0) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -332,24 +256,16 @@ rlc_am_rx_list_insert_pdu( if (pdu_info_previous_cursor_p->sn == pdu_info_cursor_p->sn) { if ((pdu_info_p->so + pdu_info_p->payload_size - 1) < pdu_info_previous_cursor_p->so) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn < vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn < vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn, pdu_info_p->so); list2_insert_after_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -357,12 +273,8 @@ rlc_am_rx_list_insert_pdu( } } - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn < vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn < vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn, pdu_info_p->so); @@ -370,23 +282,15 @@ rlc_am_rx_list_insert_pdu( return 0; } else if (pdu_info_cursor_p->so <= pdu_info_p->so) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; } } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -402,58 +306,38 @@ rlc_am_rx_list_insert_pdu( } if (cursor_p != NULL) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and sn < vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and sn < vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_insert_after_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { if (pdu_info_cursor_p->rf == 0) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } else if ((pdu_info_p->rf == 1) && (pdu_info_cursor_p->rf == 1) && (pdu_info_p->sn == pdu_info_cursor_p->sn)) { if ((pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1) < pdu_info_p->so) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; } } else if (pdu_info_p->sn != pdu_info_cursor_p->sn) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); @@ -461,12 +345,8 @@ rlc_am_rx_list_insert_pdu( } } - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -484,23 +364,15 @@ rlc_am_rx_list_insert_pdu( if (pdu_info_previous_cursor_p->sn == pdu_info_p->sn) { if (pdu_info_p->rf != pdu_info_previous_cursor_p->rf) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) > vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) > vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; } else if (pdu_info_p->rf == 1) { if ((pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1) >= pdu_info_p->so) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) > vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) > vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -509,12 +381,8 @@ rlc_am_rx_list_insert_pdu( } } - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); @@ -522,12 +390,8 @@ rlc_am_rx_list_insert_pdu( } else if (pdu_info_p->sn == pdu_info_cursor_p->sn) { if (pdu_info_cursor_p->rf == 0) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) > vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) > vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -541,32 +405,20 @@ rlc_am_rx_list_insert_pdu( if (pdu_info_previous_cursor_p->sn == pdu_info_cursor_p->sn) { if ((pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1) < pdu_info_p->so) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) > vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) > vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn, pdu_info_p->so); - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] PREVIOUS SO %d PAYLOAD SIZE %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] PREVIOUS SO %d PAYLOAD SIZE %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_info_previous_cursor_p->so, pdu_info_previous_cursor_p->payload_size); list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -574,35 +426,23 @@ rlc_am_rx_list_insert_pdu( } } - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) > vr(r) and sn >= vr(r))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) > vr(r) and sn >= vr(r))\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn, pdu_info_p->so); list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else if (pdu_info_p->so <= pdu_info_cursor_p->so) { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; } } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -613,12 +453,8 @@ rlc_am_rx_list_insert_pdu( cursor_p = cursor_p->next; } - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))(last inserted)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))(last inserted)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); @@ -628,12 +464,8 @@ rlc_am_rx_list_insert_pdu( list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -2; @@ -644,24 +476,16 @@ rlc_am_rx_list_insert_pdu( } } } else { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (only inserted)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (only inserted)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); list2_add_head(tb_pP, &rlc_pP->receiver_buffer); return 0; } - LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED @4\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d DROPPED @4\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_info_p->sn); return -1; @@ -770,12 +594,8 @@ rlc_am_rx_mark_all_segments_received( cursor_p = fisrt_segment_tbP; if (cursor_p) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] ALL SEGMENTS RECEIVED SN %04d:\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] ALL SEGMENTS RECEIVED SN %04d:\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sn); do { @@ -826,12 +646,8 @@ rlc_am_rx_list_reassemble_rlc_sdus( if (list2_get_head(&rlc_pP->receiver_buffer) != cursor_p) { AssertFatal( 0 == 1, - "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u] LOST PDU DETECTED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + PROTOCOL_RLC_AM_CTXT_FMT" LOST PDU DETECTED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c index 4be0faf83fd..81f027fce67 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c @@ -87,41 +87,25 @@ void rlc_am_pdu_polling ( ) { if (rlc_pP->c_pdu_without_poll >= rlc_pP->poll_pdu) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE TX NUM PDU THRESHOLD %d HAS BEEN REACHED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[POLL] SET POLL BECAUSE TX NUM PDU THRESHOLD %d HAS BEEN REACHED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->poll_pdu); } if (rlc_pP->c_byte_without_poll >= rlc_pP->poll_byte) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE TX NUM BYTES THRESHOLD %d HAS BEEN REACHED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[POLL] SET POLL BECAUSE TX NUM BYTES THRESHOLD %d HAS BEEN REACHED\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->poll_byte); } if ((rlc_pP->sdu_buffer_occupancy == 0) && (rlc_pP->retrans_num_bytes_to_retransmit == 0)) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE TX BUFFERS ARE EMPTY\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[POLL] SET POLL BECAUSE TX BUFFERS ARE EMPTY\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } if (rlc_pP->vt_s == rlc_pP->vt_ms) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE OF WINDOW STALLING\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[POLL] SET POLL BECAUSE OF WINDOW STALLING\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } pdu_pP->b1 = pdu_pP->b1 | 0x20; @@ -175,12 +159,8 @@ void rlc_am_segment_10 ( signed int max_li_overhead = 0; LOG_T(RLC, - "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] rlc_pP->current_sdu_index %d rlc_pP->next_sdu_index %d rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block %p sdu_buffer_occupancy %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] rlc_pP->current_sdu_index %d rlc_pP->next_sdu_index %d rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block %p sdu_buffer_occupancy %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->current_sdu_index, rlc_pP->next_sdu_index, rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block, @@ -198,12 +178,8 @@ void rlc_am_segment_10 ( pthread_mutex_lock(&rlc_pP->lock_input_sdus); while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block) && (nb_bytes_to_transmit > 0) ) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] nb_bytes_to_transmit %d BO %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] nb_bytes_to_transmit %d BO %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), nb_bytes_to_transmit, rlc_pP->sdu_buffer_occupancy); @@ -215,51 +191,31 @@ void rlc_am_segment_10 ( max_li_overhead = (((rlc_pP->nb_sdu_no_segmented - 1) * 3) / 2) + ((rlc_pP->nb_sdu_no_segmented - 1) % 2); } - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] max_li_overhead %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] max_li_overhead %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), max_li_overhead); if (nb_bytes_to_transmit >= (rlc_pP->sdu_buffer_occupancy + RLC_AM_HEADER_MIN_SIZE + max_li_overhead)) { data_pdu_size = rlc_pP->sdu_buffer_occupancy + RLC_AM_HEADER_MIN_SIZE + max_li_overhead; - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); } else { data_pdu_size = nb_bytes_to_transmit; - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); } if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { - LOG_C(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_C(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); pthread_mutex_unlock(&rlc_pP->lock_input_sdus); return; } - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] get new PDU %d bytes\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] get new PDU %d bytes\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); pdu_remaining_size = data_pdu_size - RLC_AM_HEADER_MIN_SIZE; pdu_p = (rlc_am_pdu_sn_10_t*) (&pdu_mem_p->data[sizeof(struct mac_tb_req)]); @@ -326,12 +282,8 @@ void rlc_am_segment_10 ( test_li_length_in_bytes = test_li_length_in_bytes ^ 3; } } else { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, test_pdu_remaining_size, test_li_length_in_bytes ^ 3); @@ -359,12 +311,8 @@ void rlc_am_segment_10 ( //---------------------------------------- // Do the real filling of the pdu_p //---------------------------------------- - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u] data shift %d Bytes num_li %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT" data shift %d Bytes num_li %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), ((test_num_li*3) +1) >> 1, test_num_li); data = ((unsigned char*)(&pdu_p->data[((test_num_li*3) +1) >> 1])); @@ -385,21 +333,13 @@ void rlc_am_segment_10 ( sdu_mngt_p = &rlc_pP->input_sdus[rlc_pP->current_sdu_index]; if (sdu_mngt_p->sdu_segmented_size == 0) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p, sdu_mngt_p->sdu_remaining_size); } else { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes LENGTH \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes LENGTH \n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p, sdu_mngt_p->sdu_remaining_size, sdu_mngt_p->sdu_size); @@ -408,12 +348,8 @@ void rlc_am_segment_10 ( data_sdu_p = &sdu_mngt_p->first_byte[sdu_mngt_p->sdu_segmented_size]; if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] Filling all remaining PDU with %d bytes\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Filling all remaining PDU with %d bytes\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_remaining_size); //msg ("[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] pdu_mem_p %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame, pdu_mem_p, pdu_p, pdu_p->data, data, data_sdu_p,pdu_remaining_size); @@ -426,21 +362,13 @@ void rlc_am_segment_10 ( rlc_pP->sdu_buffer_occupancy -= pdu_remaining_size; continue_fill_pdu_with_sdu = 0; pdu_remaining_size = 0; - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] sdu_remaining_size %d bytes sdu_segmented_size %d bytes\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] sdu_remaining_size %d bytes sdu_segmented_size %d bytes\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, sdu_mngt_p->sdu_segmented_size); } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] Exactly Filling remaining PDU with %d remaining bytes of SDU\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Exactly Filling remaining PDU with %d remaining bytes of SDU\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_remaining_size); memcpy(data, data_sdu_p, pdu_remaining_size); pdu_mngt_p->payload_size += pdu_remaining_size; @@ -459,12 +387,8 @@ void rlc_am_segment_10 ( pdu_remaining_size = 0; } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { if (fill_num_li == (RLC_AM_MAX_SDU_IN_PDU - 1)) { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] [SIZE %d] REACHING RLC_AM_MAX_SDU_IN_PDU LIs -> STOP SEGMENTATION FOR THIS PDU SDU\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] [SIZE %d] REACHING RLC_AM_MAX_SDU_IN_PDU LIs -> STOP SEGMENTATION FOR THIS PDU SDU\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size); memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; @@ -480,12 +404,8 @@ void rlc_am_segment_10 ( continue_fill_pdu_with_sdu = 0; fi_last_byte_pdu_is_last_byte_sdu = 1; } else { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] Filling PDU with %d all remaining bytes of SDU\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Filling PDU with %d all remaining bytes of SDU\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size); memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; @@ -505,12 +425,8 @@ void rlc_am_segment_10 ( //e_li_p->li1 = sdu_mngt_p->sdu_remaining_size; e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] set e_li_p->b1=0x%02X set e_li_p->b2=0x%02X fill_num_li=%d test_num_li=%d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] set e_li_p->b1=0x%02X set e_li_p->b2=0x%02X fill_num_li=%d test_num_li=%d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), e_li_p->b1, e_li_p->b2, fill_num_li, @@ -524,12 +440,8 @@ void rlc_am_segment_10 ( //e_li_p->li2 = sdu_mngt_p->sdu_remaining_size; e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] set e_li_p->b2=0x%02X set e_li_p->b3=0x%02X fill_num_li=%d test_num_li=%d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] set e_li_p->b2=0x%02X set e_li_p->b3=0x%02X fill_num_li=%d test_num_li=%d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), e_li_p->b2, e_li_p->b3, fill_num_li, @@ -549,12 +461,8 @@ void rlc_am_segment_10 ( rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; } } else { - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); #ifdef USER_MODE @@ -594,12 +502,8 @@ void rlc_am_segment_10 ( pdu_p->b1 = pdu_p->b1 | 0x04; } - LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] SEND PDU SN %04d SIZE %d BYTES PAYLOAD SIZE %d BYTES\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] SEND PDU SN %04d SIZE %d BYTES PAYLOAD SIZE %d BYTES\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vt_s, data_pdu_size - pdu_remaining_size, pdu_mngt_p->payload_size); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c index 6fb198a15bf..94e88ffeb8a 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c @@ -91,12 +91,8 @@ void rlc_am_remove_hole ( int i; #ifdef TRACE_RLC_AM_HOLE LOG_D(RLC, - "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] REMOVE HOLE SN %04d so_startP %05d so_stopP %05d rlc_pP->pdu_retrans_buffer[snP].nack_so_start %05d rlc_pP->pdu_retrans_buffer[snP].nack_so_stop %05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] REMOVE HOLE SN %04d so_startP %05d so_stopP %05d rlc_pP->pdu_retrans_buffer[snP].nack_so_start %05d rlc_pP->pdu_retrans_buffer[snP].nack_so_stop %05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, so_startP, so_stopP, @@ -109,12 +105,8 @@ void rlc_am_remove_hole ( assert(so_startP == rlc_pP->pdu_retrans_buffer[snP].nack_so_start); assert(so_stopP <= rlc_pP->pdu_retrans_buffer[snP].nack_so_stop); #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] REMOVE HOLE SN %04d MODIFIED nack_so_start %05d->%05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] REMOVE HOLE SN %04d MODIFIED nack_so_start %05d->%05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, rlc_pP->pdu_retrans_buffer[snP].nack_so_start, so_stopP+1); @@ -144,12 +136,8 @@ void rlc_am_remove_hole ( } #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] REMOVE HOLE SN %04d NOW nack_so_start %05d nack_so_stop %05d num holes %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] REMOVE HOLE SN %04d NOW nack_so_start %05d nack_so_stop %05d num holes %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, rlc_pP->pdu_retrans_buffer[snP].nack_so_start, rlc_pP->pdu_retrans_buffer[snP].nack_so_stop, @@ -164,7 +152,6 @@ void rlc_am_remove_hole ( rlc_am_shift_up_holes(ctxt_pP, rlc_pP, snP, i+1); rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i+1] = so_startP+1; rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i+1] = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i]; - rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i] = so_startP - 1; } else { rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i] = so_startP; @@ -183,12 +170,8 @@ void rlc_am_remove_hole ( } #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] REMOVE HOLE SN %04d NOW nack_so_start %05d nack_so_stop %05d num holes %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] REMOVE HOLE SN %04d NOW nack_so_start %05d nack_so_stop %05d num holes %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, rlc_pP->pdu_retrans_buffer[snP].nack_so_start, rlc_pP->pdu_retrans_buffer[snP].nack_so_stop, @@ -209,12 +192,8 @@ void rlc_am_get_next_hole ( *so_startP = rlc_pP->pdu_retrans_buffer[snP].nack_so_start; *so_stopP = rlc_pP->pdu_retrans_buffer[snP].nack_so_stop; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] rlc_am_get_next_hole(SN %04d) %05d->%05d (NUM HOLES == 0)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] rlc_am_get_next_hole(SN %04d) %05d->%05d (NUM HOLES == 0)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, *so_startP, *so_stopP); @@ -223,12 +202,8 @@ void rlc_am_get_next_hole ( *so_startP = rlc_pP->pdu_retrans_buffer[snP].hole_so_start[0]; *so_stopP = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[0]; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] rlc_am_get_next_hole(SN %04d) %05d->%05d (NUM HOLES == %d)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] rlc_am_get_next_hole(SN %04d) %05d->%05d (NUM HOLES == %d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, *so_startP, *so_stopP, @@ -258,12 +233,8 @@ void rlc_am_add_hole ( rlc_pP->pdu_retrans_buffer[snP].nack_so_start = so_startP; rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] SN %04d GLOBAL NACK 0->%05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] SN %04d GLOBAL NACK 0->%05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, so_stopP); #endif @@ -285,12 +256,8 @@ void rlc_am_add_hole ( rlc_pP->pdu_retrans_buffer[snP].nack_so_start = so_startP; rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] FIRST HOLE SN %04d GLOBAL NACK %05d->%05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] FIRST HOLE SN %04d GLOBAL NACK %05d->%05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), snP, so_startP, so_stopP); @@ -324,12 +291,8 @@ void rlc_am_add_hole ( rlc_pP->pdu_retrans_buffer[snP].num_holes += 1; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] INSERT %d th HOLE SN %04d GLOBAL NACK %05d->%05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] INSERT %d th HOLE SN %04d GLOBAL NACK %05d->%05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->pdu_retrans_buffer[snP].num_holes, snP, so_startP, @@ -352,12 +315,8 @@ void rlc_am_add_hole ( // update nack "window" vars nack_so_start, nack_so_stop rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] INSERT THE %d th LAST HOLE SN %04d GLOBAL NACK %05d->%05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] INSERT THE %d th LAST HOLE SN %04d GLOBAL NACK %05d->%05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->pdu_retrans_buffer[snP].num_holes, snP, so_startP, diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index c3470abe468..676a5403d91 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -42,7 +42,7 @@ #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" -//#define TRACE_STATUS_CREATION 1 +//#define TRACE_RLC_AM_STATUS_CREATION 1 rlc_am_control_pdu_info_t g_rlc_am_control_pdu_info; @@ -82,11 +82,7 @@ rlc_am_itti_display_status_ind_infos( msg_p->ittiMsg.rlc_am_status_pdu_ind.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_am_status_pdu_ind.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } @@ -199,7 +195,9 @@ rlc_am_get_control_pdu_infos( if (!pdu_info_pP->d_c) { pdu_info_pP->cpt = (header_pP->b1 >> 4) & 0x07; - if (pdu_info_pP->cpt != 0x00) return -3; + if (pdu_info_pP->cpt != 0x00) { + return -3; + } pdu_info_pP->ack_sn = ((header_pP->b2 >> 2) & 0x3F) | (((uint16_t)(header_pP->b1 & 0x0F)) << 6); pdu_info_pP->e1 = (header_pP->b2 >> 1) & 0x01; @@ -293,12 +291,8 @@ rlc_am_receive_process_control_pdu( if (rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_p, tb_size_in_bytes_pP, &g_rlc_am_control_pdu_info) >= 0) { rlc_am_tx_buffer_display(ctxt_pP, rlc_pP, " TX BUFFER BEFORE PROCESS OF STATUS PDU"); - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RX CONTROL PDU VT(A) %04d VT(S) %04d POLL_SN %04d ACK_SN %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RX CONTROL PDU VT(A) %04d VT(S) %04d POLL_SN %04d ACK_SN %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vt_a, rlc_pP->vt_s, rlc_pP->poll_sn, @@ -385,20 +379,12 @@ rlc_am_receive_process_control_pdu( } } } else { - LOG_N(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] WARNING CONTROL PDU ACK SN OUT OF WINDOW\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT" WARNING CONTROL PDU ACK SN OUT OF WINDOW\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } } else { - LOG_W(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] ERROR IN DECODING CONTROL PDU\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_W(RLC, PROTOCOL_RLC_AM_CTXT_FMT" ERROR IN DECODING CONTROL PDU\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } *first_byte_ppP = (uint8_t*)((uint64_t)*first_byte_ppP + initial_pdu_size - *tb_size_in_bytes_pP); @@ -447,9 +433,10 @@ rlc_am_write_status_pdu( num_bytes += 1; } -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX] WROTE STATUS PDU %d BYTES\n", - ctxt_pP->frame, num_bytes); +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" WROTE STATUS PDU %d BYTES\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + num_bytes); #endif return num_bytes; } @@ -497,13 +484,9 @@ rlc_am_send_status_pdu( memset(&control_pdu_info, 0, sizeof(rlc_am_control_pdu_info_t)); // header size nb_bits_to_transmit = nb_bits_to_transmit - 15; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] nb_bits_to_transmit %d (15 already allocated for header)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] nb_bits_to_transmit %d (15 already allocated for header)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), nb_bits_to_transmit); rlc_am_rx_list_display(rlc_pP, " DISPLAY BEFORE CONSTRUCTION OF STATUS REPORT"); #endif @@ -518,13 +501,9 @@ rlc_am_send_status_pdu( pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; sn_cursor = pdu_info_cursor_p->sn; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d FIND VR(R) <= SN sn_cursor %04d -> %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d FIND VR(R) <= SN sn_cursor %04d -> %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, previous_sn_cursor, sn_cursor); @@ -537,13 +516,9 @@ rlc_am_send_status_pdu( pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; all_segments_received = ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received; sn_cursor = pdu_info_cursor_p->sn; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d LOOPING sn_cursor %04d previous sn_cursor %04d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d LOOPING sn_cursor %04d previous sn_cursor %04d \n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, sn_cursor, previous_sn_cursor); @@ -560,38 +535,26 @@ rlc_am_send_status_pdu( pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; all_segments_received = ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received; sn_cursor = pdu_info_cursor_p->sn; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d NOW sn_cursor %04d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d NOW sn_cursor %04d \n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, sn_cursor); #endif } else { if (all_segments_received) { control_pdu_info.ack_sn = (sn_cursor + 1) & RLC_AM_SN_MASK; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING ACK SN %04d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING ACK SN %04d \n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, control_pdu_info.ack_sn); #endif } else { control_pdu_info.ack_sn = (previous_sn_cursor + 1) & RLC_AM_SN_MASK; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING ACK SN %04d (CASE PREVIOUS SN)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING ACK SN %04d (CASE PREVIOUS SN)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, control_pdu_info.ack_sn); #endif @@ -615,25 +578,17 @@ rlc_am_send_status_pdu( control_pdu_info.nack_list[control_pdu_info.num_nack].e2 = 0; control_pdu_info.num_nack += 1; nb_bits_to_transmit = nb_bits_to_transmit - 12; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING NACK %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, previous_sn_cursor); #endif } else { control_pdu_info.ack_sn = (previous_sn_cursor + 1) & RLC_AM_SN_MASK; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d NO MORE BITS FOR SENDING NACK %04d -> ABORT AND SET FINAL ACK %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d NO MORE BITS FOR SENDING NACK %04d -> ABORT AND SET FINAL ACK %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, previous_sn_cursor, control_pdu_info.ack_sn); @@ -647,13 +602,9 @@ rlc_am_send_status_pdu( // ------------------------------------------------------------------------------- if (all_segments_received == 0) { waited_so = 0; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] if (all_segments_received == 0) \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] if (all_segments_received == 0) \n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif do { @@ -666,13 +617,9 @@ rlc_am_send_status_pdu( control_pdu_info.nack_list[control_pdu_info.num_nack].e2 = 1; control_pdu_info.num_nack += 1; nb_bits_to_transmit = nb_bits_to_transmit - 42; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d (CASE SO %d > WAITED SO %d)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d (CASE SO %d > WAITED SO %d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, sn_cursor, waited_so, @@ -684,25 +631,17 @@ rlc_am_send_status_pdu( if (pdu_info_cursor_p->lsf == 1) { // last segment flag //waited_so = 0x7FF; waited_so = 0x7FFF; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d SN %04d SET WAITED SO 0x7FFF)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d SN %04d SET WAITED SO 0x7FFF)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, sn_cursor); #endif //break; } else { waited_so = pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d SN %04d SET WAITED SO %d @1\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d SN %04d SET WAITED SO %d @1\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, sn_cursor, waited_so); @@ -720,13 +659,9 @@ rlc_am_send_status_pdu( waited_so = 0x7FFF; } -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d SN %04d SET WAITED SO %d @2\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d SN %04d SET WAITED SO %d @2\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, sn_cursor, waited_so); #endif @@ -758,13 +693,9 @@ rlc_am_send_status_pdu( control_pdu_info.nack_list[control_pdu_info.num_nack].e2 = 1; control_pdu_info.num_nack += 1; nb_bits_to_transmit = nb_bits_to_transmit - 42; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, previous_sn_cursor, waited_so, @@ -787,13 +718,9 @@ rlc_am_send_status_pdu( control_pdu_info.ack_sn = (previous_sn_cursor + 1) & RLC_AM_SN_MASK; } else { control_pdu_info.ack_sn = rlc_pP->vr_r; -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING ACK %04d = VR(R)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING ACK %04d = VR(R)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, control_pdu_info.ack_sn); #endif @@ -808,13 +735,9 @@ end_push_nack: //msg ("[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] nb_bits_to_transmit %d\n", // rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame,nb_bits_to_transmit); -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING ACK %04d NUM NACK %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING ACK %04d NUM NACK %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, control_pdu_info.ack_sn, control_pdu_info.num_nack); @@ -822,13 +745,9 @@ end_push_nack: // encode the control pdu pdu_size = rlc_pP->nb_bytes_requested_by_mac - ((nb_bits_to_transmit - 7 )>> 3); -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d forecast pdu_size %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d forecast pdu_size %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), __LINE__, pdu_size); #endif @@ -842,13 +761,9 @@ end_push_nack: ((struct mac_tb_req*)(tb_p->data))->tb_size = pdu_size; //assert((((struct mac_tb_req*)(tb_p->data))->tb_size) < 3000); -#ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] SEND STATUS PDU SIZE %d, rlc_pP->nb_bytes_requested_by_mac %d, nb_bits_to_transmit>>3 %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, +#ifdef TRACE_RLC_AM_STATUS_CREATION + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] SEND STATUS PDU SIZE %d, rlc_pP->nb_bytes_requested_by_mac %d, nb_bits_to_transmit>>3 %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_size, rlc_pP->nb_bytes_requested_by_mac, nb_bits_to_transmit >> 3); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h index 36d9ecb88f7..d887168fb8f 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h @@ -218,9 +218,9 @@ typedef struct rlc_am_pdu_info { * \brief Generic structure for implementing a timer. */ typedef struct rlc_am_timer { - frame_t frame_time_out;/*!< \brief When set, indicate the frame number the timer will time-out. */ - frame_t frame_start; /*!< \brief indicate the frame number the timer has been started. */ - frame_t time_out; /*!< \brief Configured timer duration in frames. */ + uint32_t ms_time_out; /*!< \brief When set, indicate the time in milliseconds the timer will time-out. */ + uint32_t ms_start; /*!< \brief indicate the time in milliseconds the timer has been started. */ + uint32_t ms_duration; /*!< \brief Configured timer duration in milliseconds. */ uint32_t running:1; /*!< \brief The timer is running. */ uint32_t timed_out:1; /*!< \brief The timer has timed-out. */ uint32_t dummy:30; /*!< \brief Bits not used. */ diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c index b38061633c1..5d7225fcede 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c @@ -668,11 +668,12 @@ void rlc_am_v9_3_0_test_data_ind (module_id_t module_idP, rb_id_t rb_idP, sdu_si if (g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1] != i) { - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-2, g_send_sdu_ids[g_send_id_read_index[rb_idP]-2][rb_idP^1]); - - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-1, g_send_sdu_ids[g_send_id_read_index[rb_idP]-1][rb_idP^1]); - - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1]); + printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-2, + g_send_sdu_ids[g_send_id_read_index[rb_idP]-2][rb_idP^1]); + printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-1, + g_send_sdu_ids[g_send_id_read_index[rb_idP]-1][rb_idP^1]); + printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], + g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1]); printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_id_read_index = %d sdu sent = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], i); } @@ -894,8 +895,9 @@ void rlc_am_v9_3_0_test_tx_rx() rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - for (i = 0; i < 30; i++) + for (i = 0; i < 30; i++) { rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 500, 200); + } // Purge for (i = 0; i < 24; i++) { @@ -1108,7 +1110,8 @@ void rlc_am_v9_3_0_test_tx_rx() rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("REAL BLER TX=%d (TARGET=%d) BLER RX=%d (TARGET=%d) \n",(g_dropped_tx_packets*100)/g_tx_packets, g_target_tx_error_rate, (g_dropped_rx_packets*100)/g_rx_packets, g_target_rx_error_rate); + printf("REAL BLER TX=%d (TARGET=%d) BLER RX=%d (TARGET=%d) \n",(g_dropped_tx_packets*100)/g_tx_packets, g_target_tx_error_rate, + (g_dropped_rx_packets*100)/g_rx_packets, g_target_rx_error_rate); } } @@ -1180,7 +1183,8 @@ void rlc_am_v9_3_0_test_tx_rx() rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); assert (g_send_id_read_index[1] == g_send_id_write_index[0]); assert (g_send_id_read_index[0] == g_send_id_write_index[1]); - printf("REAL BLER TX=%d (TARGET=%d) BLER RX=%d (TARGET=%d) \n",(g_dropped_tx_packets*100)/g_tx_packets, g_target_tx_error_rate, (g_dropped_rx_packets*100)/g_rx_packets, g_target_rx_error_rate); + printf("REAL BLER TX=%d (TARGET=%d) BLER RX=%d (TARGET=%d) \n",(g_dropped_tx_packets*100)/g_tx_packets, g_target_tx_error_rate, + (g_dropped_rx_packets*100)/g_rx_packets, g_target_rx_error_rate); } } @@ -1202,8 +1206,9 @@ void rlc_am_v9_3_0_test_print_trace (void) printf ("Obtained %d stack frames.\n", size); - for (i = 0; i < size; i++) + for (i = 0; i < size; i++) { printf ("%s\n", strings[i]); + } free (strings); } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c index 1dc1dae9265..66b1a67abf6 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c @@ -60,31 +60,28 @@ rlc_am_check_timer_poll_retransmit( // | |******************| | // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX - ((rlc_pP->t_poll_retransmit.frame_start < rlc_pP->t_poll_retransmit.frame_time_out) && - ((ctxt_pP->frame >= rlc_pP->t_poll_retransmit.frame_time_out) || - (ctxt_pP->frame < rlc_pP->t_poll_retransmit.frame_start))) || + ((rlc_pP->t_poll_retransmit.ms_start < rlc_pP->t_poll_retransmit.ms_time_out) && + ((PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_poll_retransmit.ms_time_out) || + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_poll_retransmit.ms_start))) || // CASE 2: time out start // +-----------+------------------+----------+ // |***********| |**********| // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX VALUE - ((rlc_pP->t_poll_retransmit.frame_start > rlc_pP->t_poll_retransmit.frame_time_out) && - (ctxt_pP->frame < rlc_pP->t_poll_retransmit.frame_start) && (ctxt_pP->frame >= rlc_pP->t_poll_retransmit.frame_time_out)) + ((rlc_pP->t_poll_retransmit.ms_start > rlc_pP->t_poll_retransmit.ms_time_out) && + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_poll_retransmit.ms_start) && + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_poll_retransmit.ms_time_out)) ) { //if (rlc_pP->t_poll_retransmit.frame_time_out <= ctxt_pP->frame) { rlc_pP->t_poll_retransmit.running = 0; rlc_pP->t_poll_retransmit.timed_out = 1; rlc_pP->stat_timer_poll_retransmit_timed_out += 1; - LOG_D(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][T_POLL_RETRANSMIT] TIME-OUT\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] TIME-OUT\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); //#warning TO DO rlc_am_check_timer_poll_retransmit - rlc_pP->t_poll_retransmit.frame_time_out = ctxt_pP->frame + rlc_pP->t_poll_retransmit.time_out; + rlc_pP->t_poll_retransmit.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_poll_retransmit.ms_duration; } } } @@ -106,15 +103,11 @@ rlc_am_stop_and_reset_timer_poll_retransmit( ) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][T_POLL_RETRANSMIT] STOPPED AND RESET\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] STOPPED AND RESET\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_pP->t_poll_retransmit.running = 0; - rlc_pP->t_poll_retransmit.frame_time_out = 0; - rlc_pP->t_poll_retransmit.frame_start = 0; + rlc_pP->t_poll_retransmit.ms_time_out = 0; + rlc_pP->t_poll_retransmit.ms_start = 0; rlc_pP->t_poll_retransmit.timed_out = 0; } //----------------------------------------------------------------------------- @@ -125,29 +118,31 @@ rlc_am_start_timer_poll_retransmit( ) //----------------------------------------------------------------------------- { - rlc_pP->t_poll_retransmit.running = 1; - rlc_pP->t_poll_retransmit.frame_time_out = ctxt_pP->frame + rlc_pP->t_poll_retransmit.time_out; - rlc_pP->t_poll_retransmit.frame_start = ctxt_pP->frame; rlc_pP->t_poll_retransmit.timed_out = 0; - LOG_D(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][T_POLL_RETRANSMIT] STARTED (TIME-OUT = FRAME %05d)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, - rlc_pP->t_poll_retransmit.frame_time_out); + + if (rlc_pP->t_poll_retransmit.ms_duration > 0) { + rlc_pP->t_poll_retransmit.running = 1; + rlc_pP->t_poll_retransmit.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_poll_retransmit.ms_duration; + rlc_pP->t_poll_retransmit.ms_start = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] STARTED (TIME-OUT = FRAME %05d)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + rlc_pP->t_poll_retransmit.ms_time_out); + } else { + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] NOT STARTED, CAUSE CONFIGURED 0 ms\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); + } } //----------------------------------------------------------------------------- void rlc_am_init_timer_poll_retransmit( const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, - const uint32_t time_outP) + const uint32_t ms_durationP) //----------------------------------------------------------------------------- { rlc_pP->t_poll_retransmit.running = 0; - rlc_pP->t_poll_retransmit.frame_time_out = 0; - rlc_pP->t_poll_retransmit.frame_start = 0; - rlc_pP->t_poll_retransmit.time_out = time_outP; + rlc_pP->t_poll_retransmit.ms_time_out = 0; + rlc_pP->t_poll_retransmit.ms_start = 0; + rlc_pP->t_poll_retransmit.ms_duration = ms_durationP; rlc_pP->t_poll_retransmit.timed_out = 0; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c index 1801b6d2c06..8054f2c42fb 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c @@ -51,16 +51,17 @@ rlc_am_check_timer_reordering( // | |******************| | // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX - ((rlc_pP->t_reordering.frame_start < rlc_pP->t_reordering.frame_time_out) && - ((ctxt_pP->frame >= rlc_pP->t_reordering.frame_time_out) || - (ctxt_pP->frame < rlc_pP->t_reordering.frame_start))) || + ((rlc_pP->t_reordering.ms_start < rlc_pP->t_reordering.ms_time_out) && + ((PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_reordering.ms_time_out) || + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_reordering.ms_start))) || // CASE 2: time out start // +-----------+------------------+----------+ // |***********| |**********| // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX VALUE - ((rlc_pP->t_reordering.frame_start > rlc_pP->t_reordering.frame_time_out) && - (ctxt_pP->frame < rlc_pP->t_reordering.frame_start) && (ctxt_pP->frame >= rlc_pP->t_reordering.frame_time_out)) + ((rlc_pP->t_reordering.ms_start > rlc_pP->t_reordering.ms_time_out) && + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_reordering.ms_start) && + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_reordering.ms_time_out)) ) { //if (rlc_pP->t_reordering.frame_time_out == ctxt_pP->frame) { // 5.1.3.2.4 Actions when t-Reordering expires @@ -97,24 +98,16 @@ rlc_am_check_timer_reordering( cursor = cursor->next; } while (cursor != NULL); - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-REORDERING] TIME-OUT UPDATED VR(MS) %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] TIME-OUT UPDATED VR(MS) %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_ms); } if (rlc_am_sn_gt_vr_ms(ctxt_pP, rlc_pP, rlc_pP->vr_h)) { rlc_pP->vr_x = rlc_pP->vr_h; - rlc_pP->t_reordering.frame_time_out = ctxt_pP->frame + rlc_pP->t_reordering.time_out; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-REORDERING] TIME-OUT, RESTARTED T-REORDERING, UPDATED VR(X) to VR(R) %04d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, + rlc_pP->t_reordering.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_reordering.ms_duration; + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] TIME-OUT, RESTARTED T-REORDERING, UPDATED VR(X) to VR(R) %04d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_x); } @@ -129,15 +122,11 @@ rlc_am_stop_and_reset_timer_reordering( rlc_am_entity_t * const rlc_pP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-REORDERING] STOPPED AND RESET\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] STOPPED AND RESET\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.frame_time_out = 0; - rlc_pP->t_reordering.frame_start = 0; + rlc_pP->t_reordering.ms_time_out = 0; + rlc_pP->t_reordering.ms_start = 0; rlc_pP->t_reordering.timed_out = 0; } //----------------------------------------------------------------------------- @@ -147,29 +136,31 @@ rlc_am_start_timer_reordering( rlc_am_entity_t * const rlc_pP) //----------------------------------------------------------------------------- { - rlc_pP->t_reordering.running = 1; - rlc_pP->t_reordering.frame_time_out = ctxt_pP->frame + rlc_pP->t_reordering.time_out; - rlc_pP->t_reordering.frame_start = ctxt_pP->frame; rlc_pP->t_reordering.timed_out = 0; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-REORDERING] STARTED (TIME-OUT = FRAME %5u)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, - rlc_pP->t_reordering.frame_time_out); + + if (rlc_pP->t_reordering.ms_duration > 0) { + rlc_pP->t_reordering.running = 1; + rlc_pP->t_reordering.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_reordering.ms_duration; + rlc_pP->t_reordering.ms_start = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] STARTED (TIME-OUT = FRAME %5u)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + rlc_pP->t_reordering.ms_time_out); + } else { + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] NOT STARTED, CAUSE CONFIGURED 0 ms\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); + } } //----------------------------------------------------------------------------- void rlc_am_init_timer_reordering( const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, - const uint32_t time_outP) + const uint32_t ms_durationP) //----------------------------------------------------------------------------- { rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.frame_time_out = 0; - rlc_pP->t_reordering.frame_start = 0; - rlc_pP->t_reordering.time_out = time_outP; + rlc_pP->t_reordering.ms_time_out = 0; + rlc_pP->t_reordering.ms_start = 0; + rlc_pP->t_reordering.ms_duration = ms_durationP; rlc_pP->t_reordering.timed_out = 0; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c index 4d303e2ab05..bef2043a758 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c @@ -43,7 +43,7 @@ rlc_am_check_timer_status_prohibit( rlc_am_entity_t * const rlc_pP) //----------------------------------------------------------------------------- { - if (rlc_pP->t_status_prohibit.time_out > 0) { + if (rlc_pP->t_status_prohibit.ms_duration > 0) { if (rlc_pP->t_status_prohibit.running) { if ( // CASE 1: start time out @@ -51,16 +51,17 @@ rlc_am_check_timer_status_prohibit( // | |******************| | // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX - ((rlc_pP->t_status_prohibit.frame_start < rlc_pP->t_status_prohibit.frame_time_out) && - ((ctxt_pP->frame >= rlc_pP->t_status_prohibit.frame_time_out) || - (ctxt_pP->frame < rlc_pP->t_status_prohibit.frame_start))) || + ((rlc_pP->t_status_prohibit.ms_start < rlc_pP->t_status_prohibit.ms_time_out) && + ((PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_status_prohibit.ms_time_out) || + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_status_prohibit.ms_start))) || // CASE 2: time out start // +-----------+------------------+----------+ // |***********| |**********| // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX VALUE - ((rlc_pP->t_status_prohibit.frame_start > rlc_pP->t_status_prohibit.frame_time_out) && - (ctxt_pP->frame < rlc_pP->t_status_prohibit.frame_start) && (ctxt_pP->frame >= rlc_pP->t_status_prohibit.frame_time_out)) + ((rlc_pP->t_status_prohibit.ms_start > rlc_pP->t_status_prohibit.ms_time_out) && + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_status_prohibit.ms_start) && + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_status_prohibit.ms_time_out)) ) { //if ((rlc_pP->t_status_prohibit.frame_time_out <= ctxt_pP->frame) && (rlc_pP->t_status_prohibit.frame_start)) { @@ -68,12 +69,8 @@ rlc_am_check_timer_status_prohibit( rlc_pP->t_status_prohibit.timed_out = 1; rlc_pP->stat_timer_status_prohibit_timed_out += 1; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-STATUS-PROHIBIT] TIME-OUT\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-STATUS-PROHIBIT] TIME-OUT\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); //#warning TO DO rlc_am_check_timer_status_prohibit rlc_am_stop_and_reset_timer_status_prohibit(ctxt_pP, rlc_pP); //rlc_pP->t_status_prohibit.frame_time_out = ctxt_pP->frame + rlc_pP->t_status_prohibit.time_out; @@ -89,16 +86,12 @@ rlc_am_stop_and_reset_timer_status_prohibit( ) //----------------------------------------------------------------------------- { - if (rlc_pP->t_status_prohibit.time_out > 0) { - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-STATUS-PROHIBIT] STOPPED AND RESET\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id); + if (rlc_pP->t_status_prohibit.ms_duration > 0) { + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-STATUS-PROHIBIT] STOPPED AND RESET\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_pP->t_status_prohibit.running = 0; - rlc_pP->t_status_prohibit.frame_time_out = 0; - rlc_pP->t_status_prohibit.frame_start = 0; + rlc_pP->t_status_prohibit.ms_time_out = 0; + rlc_pP->t_status_prohibit.ms_start = 0; rlc_pP->t_status_prohibit.timed_out = 0; } } @@ -110,31 +103,31 @@ rlc_am_start_timer_status_prohibit( ) //----------------------------------------------------------------------------- { - if (rlc_pP->t_status_prohibit.time_out > 0) { + rlc_pP->t_status_prohibit.timed_out = 0; + + if (rlc_pP->t_status_prohibit.ms_duration > 0) { rlc_pP->t_status_prohibit.running = 1; - rlc_pP->t_status_prohibit.frame_time_out = rlc_pP->t_status_prohibit.time_out + ctxt_pP->frame; - rlc_pP->t_status_prohibit.frame_start = ctxt_pP->frame; - rlc_pP->t_status_prohibit.timed_out = 0; - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-STATUS-PROHIBIT] STARTED (TIME-OUT = FRAME %5u)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rlc_pP->rb_id, - rlc_pP->t_status_prohibit.frame_time_out); - LOG_D(RLC, "TIME-OUT = FRAME %5u\n", rlc_pP->t_status_prohibit.frame_time_out); + rlc_pP->t_status_prohibit.ms_time_out = rlc_pP->t_status_prohibit.ms_duration + PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); + rlc_pP->t_status_prohibit.ms_start = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); + LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-STATUS-PROHIBIT] STARTED (TIME-OUT = TIME %u)\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + rlc_pP->t_status_prohibit.ms_time_out); + LOG_D(RLC, "TIME-OUT = FRAME %u\n", rlc_pP->t_status_prohibit.ms_time_out); + } else { + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-STATUS-PROHIBIT] NOT STARTED, CAUSE CONFIGURED 0 ms\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } } //----------------------------------------------------------------------------- void rlc_am_init_timer_status_prohibit( const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *const rlc_pP, - const uint32_t time_outP) + const uint32_t ms_durationP) //----------------------------------------------------------------------------- { rlc_pP->t_status_prohibit.running = 0; - rlc_pP->t_status_prohibit.frame_time_out = 0; - rlc_pP->t_status_prohibit.frame_start = 0; - rlc_pP->t_status_prohibit.time_out = time_outP; + rlc_pP->t_status_prohibit.ms_time_out = 0; + rlc_pP->t_status_prohibit.ms_start = 0; + rlc_pP->t_status_prohibit.ms_duration = ms_durationP; rlc_pP->t_status_prohibit.timed_out = 0; } diff --git a/openair2/LAYER2/RLC/TM/rlc_tm.c b/openair2/LAYER2/RLC/TM/rlc_tm.c index f06c96a3037..9501d803bc2 100755 --- a/openair2/LAYER2/RLC/TM/rlc_tm.c +++ b/openair2/LAYER2/RLC/TM/rlc_tm.c @@ -48,19 +48,17 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void *rlc_tm_tx (void *arg_pP); -void rlc_tm_rx_no_segment (void *arg_pP, struct mac_data_ind data_indP); -void rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP); +void* rlc_tm_tx (void* arg_pP); +void rlc_tm_rx_no_segment (void* arg_pP, struct mac_data_ind data_indP); +void rlc_tm_rx_segment (void* arg_pP, struct mac_data_ind data_indP); //----------------------------------------------------------------------------- void -rlc_tm_get_pdus (void *arg_pP) +rlc_tm_get_pdus (void* arg_pP) { //----------------------------------------------------------------------------- - - struct rlc_tm_entity *rlc = (struct rlc_tm_entity *) arg_pP; + struct rlc_tm_entity* rlc = (struct rlc_tm_entity*) arg_pP; switch (rlc->protocol_state) { - case RLC_NULL_STATE: // from 3GPP TS 25.322 V4.2.0 // In the NULL state the RLC entity does not exist and therefore it is not possible to transfer any data through it. @@ -70,7 +68,6 @@ rlc_tm_get_pdus (void *arg_pP) break; case RLC_DATA_TRANSFER_READY_STATE: - rlc->segmentation (rlc); break; @@ -81,20 +78,18 @@ rlc_tm_get_pdus (void *arg_pP) //----------------------------------------------------------------------------- void -rlc_tm_rx_no_segment (void *arg_pP, struct mac_data_ind data_indP) +rlc_tm_rx_no_segment (void* arg_pP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - - struct rlc_tm_entity *rlc = (struct rlc_tm_entity *) arg_pP; - mem_block_t *tb_p; - uint8_t *first_byte; + struct rlc_tm_entity* rlc = (struct rlc_tm_entity*) arg_pP; + mem_block_t* tb_p; + uint8_t* first_byte; uint8_t tb_size_in_bytes; uint8_t first_bit; uint8_t bits_to_shift; uint8_t bits_to_shift_last_loop; switch (rlc->protocol_state) { - case RLC_NULL_STATE: // from 3GPP TS 25.322 V4.2.0 // In the NULL state the RLC entity does not exist and therefore it is not possible to transfer any data through it. @@ -109,10 +104,9 @@ rlc_tm_rx_no_segment (void *arg_pP, struct mac_data_ind data_indP) rlc->output_sdu_size_to_write = 0; // size of sdu reassemblied while ((tb_p = list_remove_head (&data_indP.data))) { - first_byte = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; - + first_byte = ((struct mac_tb_ind*) (tb_p->data))->data_ptr; tb_size_in_bytes = (data_indP.tb_size + 7) >> 3; - first_bit = ((struct mac_tb_ind *) (tb_p->data))->first_bit; + first_bit = ((struct mac_tb_ind*) (tb_p->data))->first_bit; if (first_bit > 0) { // shift data of transport_block TO CHECK @@ -127,14 +121,16 @@ rlc_tm_rx_no_segment (void *arg_pP, struct mac_data_ind data_indP) } } - ((struct rlc_tm_rx_pdu_management *) (tb_p->data))->first_byte = first_byte; + ((struct rlc_tm_rx_pdu_management*) (tb_p->data))->first_byte = first_byte; if (rlc->delivery_of_erroneous_sdu == RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_NO_DETECT) { rlc_tm_send_sdu_no_segment (rlc, 0, first_byte, data_indP.tb_size); + } else if (rlc->delivery_of_erroneous_sdu == RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_YES) { - rlc_tm_send_sdu_no_segment (rlc, (((struct mac_tb_ind *) (tb_p->data))->error_indication), first_byte, data_indP.tb_size); + rlc_tm_send_sdu_no_segment (rlc, (((struct mac_tb_ind*) (tb_p->data))->error_indication), first_byte, data_indP.tb_size); + } else { //RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_NO - if (!(((struct mac_tb_ind *) (tb_p->data))->error_indication)) { + if (!(((struct mac_tb_ind*) (tb_p->data))->error_indication)) { rlc_tm_send_sdu_no_segment (rlc, 0, first_byte, data_indP.tb_size); } } @@ -151,25 +147,21 @@ rlc_tm_rx_no_segment (void *arg_pP, struct mac_data_ind data_indP) //----------------------------------------------------------------------------- void -rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) +rlc_tm_rx_segment (void* arg_pP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - - struct rlc_tm_entity *rlc = (struct rlc_tm_entity_s *) arg_pP; - mem_block_t *tb_p = NULL; + struct rlc_tm_entity* rlc = (struct rlc_tm_entity_s*) arg_pP; + mem_block_t* tb_p = NULL; sdu_size_t tb_size_in_bits = 0; - uint8_t *first_byte_p = NULL; + uint8_t* first_byte_p = NULL; uint8_t error_in_sdu = 0; sdu_size_t tb_size_in_bytes= 0; uint8_t first_bit = 0; uint8_t byte = 0; - - //just for debug - uint8_t *debug = NULL; + uint8_t* debug = NULL; switch (rlc->protocol_state) { - case RLC_NULL_STATE: // from 3GPP TS 25.322 V4.2.0 // In the NULL state the RLC entity does not exist and therefore it is not possible to transfer any data through it. @@ -184,7 +176,6 @@ rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) rlc->output_sdu_size_to_write = 0; // size of sdu reassemblied switch (rlc->delivery_of_erroneous_sdu) { - case RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_NO_DETECT: break; @@ -192,8 +183,7 @@ rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) error_in_sdu = 0; while ((tb_p = list_remove_head (&data_indP.data))) { - - if ((((struct mac_tb_ind *) (tb_p->data))->error_indication)) { + if ((((struct mac_tb_ind*) (tb_p->data))->error_indication)) { error_in_sdu = 1; } } @@ -212,18 +202,16 @@ rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) debug = (uint8_t*)&rlc->output_sdu_in_construction->data[0]; while ((tb_p = list_remove_head (&data_indP.data))) { - - if ((((struct mac_tb_ind *) (tb_p->data))->error_indication) && (error_in_sdu)) { + if ((((struct mac_tb_ind*) (tb_p->data))->error_indication) && (error_in_sdu)) { error_in_sdu = 1; - } else { - first_byte = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; + } else { + first_byte = ((struct mac_tb_ind*) (tb_p->data))->data_ptr; tb_size_in_bytes = (data_indP.tb_size + 7) >> 3; tb_size_in_bits = data_indP.tb_size; - first_bit = ((struct mac_tb_ind *) (tb_p->data))->first_bit; + first_bit = ((struct mac_tb_ind*) (tb_p->data))->first_bit; while (tb_size_in_bits > 0) { - if ((first_bit == 0) && (rlc->last_bit_position_reassemblied == 0)) { memcpy (&rlc->output_sdu_in_construction->data[rlc->output_sdu_size_to_write >> 3], first_byte, tb_size_in_bytes); rlc->output_sdu_size_to_write += tb_size_in_bits; @@ -234,8 +222,8 @@ rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) } tb_size_in_bits = 0; - } else { + } else { if (rlc->last_bit_position_reassemblied == 0) { byte = first_byte[0]; rlc->output_sdu_in_construction->data[((rlc->output_sdu_size_to_write + 7) >> 3) ] @@ -253,6 +241,7 @@ rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) if ((8 - rlc->last_bit_position_reassemblied) < tb_size_in_bits) { rlc->output_sdu_size_to_write += (8 - rlc->last_bit_position_reassemblied); + } else { rlc->output_sdu_size_to_write += tb_size_in_bits; } @@ -260,8 +249,8 @@ rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) first_bit = 8 - rlc->last_bit_position_reassemblied; tb_size_in_bits -= (8 - rlc->last_bit_position_reassemblied); rlc->last_bit_position_reassemblied = rlc->output_sdu_size_to_write & 0x07; - // NEVER GO IN THAT BLOCK + } else if ((rlc->last_bit_position_reassemblied <= first_bit) && (rlc->last_bit_position_reassemblied > 0)) { byte = first_byte[0]; rlc->output_sdu_in_construction->data[((rlc->output_sdu_size_to_write + 7) >> 3)] @@ -272,8 +261,8 @@ rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) first_bit = 0; first_byte += 1; // now the case is last_bit_position_reassemblied != 0 && first_bit = 0 - // NEVER GO IN THAT BLOCK + } else if ((rlc->last_bit_position_reassemblied > first_bit) && (rlc->last_bit_position_reassemblied > 0)) { byte = first_byte[0]; rlc->output_sdu_in_construction->data[((rlc->output_sdu_size_to_write + 7) >> 3)] @@ -310,58 +299,52 @@ rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP) //----------------------------------------------------------------------------- struct mac_status_resp -rlc_tm_mac_status_indication (void *rlcP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP) +rlc_tm_mac_status_indication (void* rlcP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP) { //----------------------------------------------------------------------------- struct mac_status_resp status_resp; - - ((struct rlc_tm_entity *) rlcP)->nb_pdu_requested_by_mac = 1; - ((struct rlc_tm_entity *) rlcP)->rlc_pdu_size = tb_sizeP; - - status_resp.buffer_occupancy_in_bytes = ((struct rlc_tm_entity *) rlcP)->buffer_occupancy; - status_resp.buffer_occupancy_in_pdus = status_resp.buffer_occupancy_in_bytes / ((struct rlc_tm_entity *) rlcP)->rlc_pdu_size; - status_resp.rlc_info.rlc_protocol_state = ((struct rlc_tm_entity *) rlcP)->protocol_state; + ((struct rlc_tm_entity*) rlcP)->nb_pdu_requested_by_mac = 1; + ((struct rlc_tm_entity*) rlcP)->rlc_pdu_size = tb_sizeP; + status_resp.buffer_occupancy_in_bytes = ((struct rlc_tm_entity*) rlcP)->buffer_occupancy; + status_resp.buffer_occupancy_in_pdus = status_resp.buffer_occupancy_in_bytes / ((struct rlc_tm_entity*) rlcP)->rlc_pdu_size; + status_resp.rlc_info.rlc_protocol_state = ((struct rlc_tm_entity*) rlcP)->protocol_state; return status_resp; } //----------------------------------------------------------------------------- struct mac_data_req -rlc_tm_mac_data_request (void *rlcP) +rlc_tm_mac_data_request (void* rlcP) { //----------------------------------------------------------------------------- struct mac_data_req data_req; - rlc_tm_get_pdus (rlcP); list_init (&data_req.data, NULL); - list_add_list (&((struct rlc_tm_entity *) rlcP)->pdus_to_mac_layer, &data_req.data); - - data_req.buffer_occupancy_in_bytes = ((struct rlc_tm_entity *) rlcP)->buffer_occupancy; - data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / ((struct rlc_tm_entity *) rlcP)->rlc_pdu_size; - data_req.rlc_info.rlc_protocol_state = ((struct rlc_tm_entity *) rlcP)->protocol_state; - ((struct rlc_tm_entity *) rlcP)->last_tti = *((struct rlc_tm_entity *) rlcP)->frame_tick_milliseconds; + list_add_list (&((struct rlc_tm_entity*) rlcP)->pdus_to_mac_layer, &data_req.data); + data_req.buffer_occupancy_in_bytes = ((struct rlc_tm_entity*) rlcP)->buffer_occupancy; + data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / ((struct rlc_tm_entity*) rlcP)->rlc_pdu_size; + data_req.rlc_info.rlc_protocol_state = ((struct rlc_tm_entity*) rlcP)->protocol_state; + ((struct rlc_tm_entity*) rlcP)->last_tti = *((struct rlc_tm_entity*) rlcP)->frame_tick_milliseconds; return data_req; } //----------------------------------------------------------------------------- void -rlc_tm_mac_data_indication (void *rlcP, struct mac_data_ind data_indP) +rlc_tm_mac_data_indication (void* rlcP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - ((struct rlc_tm_entity *) rlcP)->rx (rlcP, data_indP); + ((struct rlc_tm_entity*) rlcP)->rx (rlcP, data_indP); } //----------------------------------------------------------------------------- void -rlc_tm_data_req (void *rlcP, mem_block_t *sduP) +rlc_tm_data_req (void* rlcP, mem_block_t* sduP) { //----------------------------------------------------------------------------- - struct rlc_tm_entity *rlc = (struct rlc_tm_entity *) rlcP; + struct rlc_tm_entity* rlc = (struct rlc_tm_entity*) rlcP; uint8_t discard_go_on; - - #ifdef DEBUG_RLC_TM_DATA_REQUEST - msg ("[RLC_TM %p] RLC_TM_DATA_REQ size %d Bytes, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", rlc, ((struct rlc_um_data_req *) (sduP->data))->data_size, rlc->buffer_occupancy, - rlc->nb_sdu, rlc->current_sdu_index, rlc->next_sdu_index); + msg ("[RLC_TM %p] RLC_TM_DATA_REQ size %d Bytes, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", rlc, + ((struct rlc_um_data_req*) (sduP->data))->data_size, rlc->buffer_occupancy, rlc->nb_sdu, rlc->current_sdu_index, rlc->next_sdu_index); #endif // From 3GPP TS 25.322 V4.2.0 @@ -373,22 +356,22 @@ rlc_tm_data_req (void *rlcP, mem_block_t *sduP) discard_go_on = 1; while ((rlc->input_sdus[rlc->current_sdu_index]) && discard_go_on) { - if (rlc->last_tti >= ((struct rlc_tm_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_creation_time) { + if (rlc->last_tti >= ((struct rlc_tm_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_creation_time) { #ifdef DEBUG_RLC_TM_DISCARD_SDU msg ("[RLC_TM %p] SDU DISCARDED NOT SUBMITTED IN THIS TTI %ld ms > ", rlc, rlc->last_tti); - msg ("%ld ms ", ((struct rlc_tm_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_creation_time); + msg ("%ld ms ", ((struct rlc_tm_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_creation_time); msg ("BO %d, NB SDU %d\n", rlc->buffer_occupancy, rlc->nb_sdu); #endif - rlc->nb_sdu -= 1; if (!(rlc->segmentation_indication & RLC_TM_SEGMENTATION_ALLOWED)) { - rlc->buffer_occupancy -= ((struct rlc_tm_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size; + rlc->buffer_occupancy -= ((struct rlc_tm_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size; } free_mem_block (rlc->input_sdus[rlc->current_sdu_index]); rlc->input_sdus[rlc->current_sdu_index] = NULL; rlc->current_sdu_index = (rlc->current_sdu_index + 1) % rlc->size_input_sdus_buffer; + } else { discard_go_on = 0; } @@ -397,20 +380,22 @@ rlc_tm_data_req (void *rlcP, mem_block_t *sduP) // not in 3GPP specification but the buffer may be full if not correctly configured if (rlc->input_sdus[rlc->next_sdu_index] == NULL) { - ((struct rlc_tm_tx_sdu_management *) (sduP->data))->sdu_size = ((struct rlc_tm_data_req *) (sduP->data))->data_size; + ((struct rlc_tm_tx_sdu_management*) (sduP->data))->sdu_size = ((struct rlc_tm_data_req*) (sduP->data))->data_size; if ((rlc->segmentation_indication & RLC_TM_SEGMENTATION_ALLOWED)) { - rlc->buffer_occupancy = ((struct rlc_tm_tx_sdu_management *) (sduP->data))->sdu_size >> 3; + rlc->buffer_occupancy = ((struct rlc_tm_tx_sdu_management*) (sduP->data))->sdu_size >> 3; + } else { - rlc->buffer_occupancy += (((struct rlc_tm_tx_sdu_management *) (sduP->data))->sdu_size >> 3); + rlc->buffer_occupancy += (((struct rlc_tm_tx_sdu_management*) (sduP->data))->sdu_size >> 3); } rlc->nb_sdu += 1; - ((struct rlc_tm_tx_sdu_management *) (sduP->data))->first_byte = (uint8_t*)&sduP->data[sizeof (struct rlc_tm_data_req_alloc)]; - ((struct rlc_tm_tx_sdu_management *) (sduP->data))->sdu_segmented_size = 0; - ((struct rlc_tm_tx_sdu_management *) (sduP->data))->sdu_creation_time = *rlc->frame_tick_milliseconds; + ((struct rlc_tm_tx_sdu_management*) (sduP->data))->first_byte = (uint8_t*)&sduP->data[sizeof (struct rlc_tm_data_req_alloc)]; + ((struct rlc_tm_tx_sdu_management*) (sduP->data))->sdu_segmented_size = 0; + ((struct rlc_tm_tx_sdu_management*) (sduP->data))->sdu_creation_time = *rlc->frame_tick_milliseconds; rlc->input_sdus[rlc->next_sdu_index] = sduP; rlc->next_sdu_index = (rlc->next_sdu_index + 1) % rlc->size_input_sdus_buffer; + } else { free_mem_block (sduP); } diff --git a/openair2/LAYER2/RLC/TM/rlc_tm_segment.c b/openair2/LAYER2/RLC/TM/rlc_tm_segment.c index ef871031e8a..5035377e886 100755 --- a/openair2/LAYER2/RLC/TM/rlc_tm_segment.c +++ b/openair2/LAYER2/RLC/TM/rlc_tm_segment.c @@ -47,15 +47,14 @@ //----------------------------------------------------------------------------- void -rlc_tm_no_segment (struct rlc_tm_entity *rlcP) +rlc_tm_no_segment (struct rlc_tm_entity* rlcP) { //----------------------------------------------------------------------------- - mem_block_t *pdu; - struct rlc_tm_tx_sdu_management *sdu_mngt; - struct rlc_tm_tx_pdu_management *pdu_mngt; + mem_block_t* pdu; + struct rlc_tm_tx_sdu_management* sdu_mngt; + struct rlc_tm_tx_pdu_management* pdu_mngt; int discard_go_on; int nb_pdu_to_transmit; - nb_pdu_to_transmit = rlcP->nb_pdu_requested_by_mac; pdu = NULL; @@ -63,17 +62,19 @@ rlc_tm_no_segment (struct rlc_tm_entity *rlcP) discard_go_on = 1; while ((rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) { - if ((*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= rlcP->timer_discard_init) { + if ((*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= + rlcP->timer_discard_init) { #ifdef DEBUG_RLC_TM_DISCARD_SDU - msg("[RLC_TM %p] SDU DISCARDED TIMED OUT %ld ms ", rlcP, (*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management *) ( - rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time)); + msg("[RLC_TM %p] SDU DISCARDED TIMED OUT %ld ms ", rlcP, + (*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time)); msg("BO %d, NB SDU %d\n", rlcP->buffer_occupancy, rlcP->nb_sdu); #endif - rlcP->buffer_occupancy -= (((struct rlc_tm_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_size >> 3); + rlcP->buffer_occupancy -= (((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_size >> 3); rlcP->nb_sdu -= 1; free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + } else { discard_go_on = 0; } @@ -82,27 +83,24 @@ rlc_tm_no_segment (struct rlc_tm_entity *rlcP) // only one SDU per TTI while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (nb_pdu_to_transmit > 0)) { + sdu_mngt = ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); - sdu_mngt = ((struct rlc_tm_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); //PRINT_RLC_TM_SEGMENT("[RLC_TM %p] SEGMENT GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", rlcP, sdu_mngt, sdu_mngt->sdu_remaining_size); - if (!(pdu = get_free_mem_block (((rlcP->rlc_pdu_size + 7) >> 3) + sizeof (struct rlc_tm_tx_data_pdu_struct) + GUARD_CRC_LIH_SIZE))) { msg ("[RLC_TM %p][SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", rlcP); return; } // SHOULD BE OPTIMIZED...SOON - pdu_mngt = (struct rlc_tm_tx_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_tm_tx_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_tm_tx_pdu_management)); pdu_mngt->first_byte = (uint8_t*)&pdu->data[sizeof (struct rlc_tm_tx_data_pdu_struct)]; - memcpy (pdu_mngt->first_byte, sdu_mngt->first_byte, ((rlcP->rlc_pdu_size + 7) >> 3)); - ((struct mac_tb_req *) (pdu->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu->data))->data_ptr = pdu_mngt->first_byte; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->rlc_pdu_size; + ((struct mac_tb_req*) (pdu->data))->rlc = NULL; + ((struct mac_tb_req*) (pdu->data))->data_ptr = pdu_mngt->first_byte; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->rlc_pdu_size; list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer); - rlcP->buffer_occupancy -= (sdu_mngt->sdu_size >> 3); free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; @@ -114,15 +112,14 @@ rlc_tm_no_segment (struct rlc_tm_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_tm_segment (struct rlc_tm_entity *rlcP) +rlc_tm_segment (struct rlc_tm_entity* rlcP) { //----------------------------------------------------------------------------- - mem_block_t *pdu; - struct rlc_tm_tx_sdu_management *sdu_mngt; - struct rlc_tm_tx_pdu_management *pdu_mngt; + mem_block_t* pdu; + struct rlc_tm_tx_sdu_management* sdu_mngt; + struct rlc_tm_tx_pdu_management* pdu_mngt; int discard_go_on; int nb_pdu_to_transmit; - nb_pdu_to_transmit = rlcP->nb_pdu_requested_by_mac; pdu = NULL; @@ -130,15 +127,18 @@ rlc_tm_segment (struct rlc_tm_entity *rlcP) discard_go_on = 1; while ((rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) { - if ((*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= rlcP->timer_discard_init) { + if ((*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= + rlcP->timer_discard_init) { #ifdef DEBUG_RLC_TM_DISCARD_SDU - msg("[RLC_TM %p] SDU DISCARDED TIMED OUT %ld ms ", rlcP,(*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time)); + msg("[RLC_TM %p] SDU DISCARDED TIMED OUT %ld ms ", rlcP, + (*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time)); msg ("BO %d, NB SDU %d\n", rlcP->buffer_occupancy, rlcP->nb_sdu); #endif rlcP->nb_sdu -= 1; free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + } else { discard_go_on = 0; } @@ -147,27 +147,24 @@ rlc_tm_segment (struct rlc_tm_entity *rlcP) // only one SDU per TTI if ((rlcP->input_sdus[rlcP->current_sdu_index])) { - sdu_mngt = (struct rlc_tm_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data); + sdu_mngt = (struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data); //PRINT_RLC_TM_SEGMENT("[RLC_TM %p] SEGMENT GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", rlcP, sdu_mngt, sdu_mngt->sdu_remaining_size); while ((nb_pdu_to_transmit > 0) && (sdu_mngt->sdu_segmented_size < sdu_mngt->sdu_size)) { - if (!(pdu = get_free_mem_block (((rlcP->rlc_pdu_size + 7) >> 3) + 1 + sizeof (struct rlc_tm_tx_data_pdu_struct) + GUARD_CRC_LIH_SIZE))) { msg ("[RLC_TM %p][SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", rlcP); return; } // SHOULD BE OPTIMIZED...SOON - pdu_mngt = (struct rlc_tm_tx_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_tm_tx_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_tm_tx_pdu_management)); pdu_mngt->first_byte = (uint8_t*)&pdu->data[sizeof (struct rlc_tm_tx_data_pdu_struct)]; - memcpy (pdu_mngt->first_byte, &sdu_mngt->first_byte[sdu_mngt->sdu_segmented_size >> 3], ((rlcP->rlc_pdu_size + 7) >> 3)); - - ((struct mac_tb_req *) (pdu->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu->data))->data_ptr = pdu_mngt->first_byte; - ((struct mac_tb_req *) (pdu->data))->first_bit = sdu_mngt->sdu_segmented_size & 0x07; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->rlc_pdu_size; + ((struct mac_tb_req*) (pdu->data))->rlc = NULL; + ((struct mac_tb_req*) (pdu->data))->data_ptr = pdu_mngt->first_byte; + ((struct mac_tb_req*) (pdu->data))->first_bit = sdu_mngt->sdu_segmented_size & 0x07; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->rlc_pdu_size; list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer); sdu_mngt->sdu_segmented_size += rlcP->rlc_pdu_size; nb_pdu_to_transmit -= 1; @@ -180,7 +177,8 @@ rlc_tm_segment (struct rlc_tm_entity *rlcP) } if ((rlcP->input_sdus[rlcP->current_sdu_index])) { - rlcP->buffer_occupancy = ((struct rlc_tm_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_size >> 3; + rlcP->buffer_occupancy = ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_size >> 3; + } else { rlcP->buffer_occupancy = 0; } diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c index ede94a6935f..1a81748712d 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c @@ -52,7 +52,9 @@ rlc_tm_send_sdu ( int index; #endif #ifdef DEBUG_RLC_TM_REASSEMBLY - msg ("[RLC_TM %p][SEND_SDU] %d bits\n", rlc_pP, length_in_bitsP); + LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT"[SEND_SDU] %d bits\n", + PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_pP), + length_in_bitsP); #endif length_in_bytes = (length_in_bitsP + 7) >> 3; @@ -62,7 +64,8 @@ rlc_tm_send_sdu ( if ((rlc_pP->output_sdu_in_construction)) { #ifdef DEBUG_RLC_TM_DISPLAY_ASCII_DATA - msg ("[RLC_TM %p][SEND_SDU] DATA :", rlc_pP); + LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT"[SEND_SDU] DATA :", + PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_pP)); for (index = 0; index < length_in_bytes; index++) { msg ("%c", srcP[index]); @@ -102,10 +105,10 @@ rlc_tm_no_segment ( while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (nb_pdu_to_transmit > 0)) { sdu_mngt_p = ((struct rlc_tm_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data)); - //PRINT_RLC_TM_SEGMENT("[RLC_TM %p] SEGMENT GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", rlc_pP, sdu_mngt_p, sdu_mngt_p->sdu_remaining_size); if (!(pdu_p = get_free_mem_block (((rlc_pP->rlc_pdu_size + 7) >> 3) + sizeof (struct rlc_tm_tx_data_pdu_struct) + GUARD_CRC_LIH_SIZE))) { - msg ("[RLC_TM %p][SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", rlc_pP); + LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT"[SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", + PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_pP)); return; } @@ -179,24 +182,19 @@ rlc_tm_mac_data_request ( void * const rlc_pP) { //----------------------------------------------------------------------------- - rlc_tm_entity_t *l_rlc_p = (rlc_tm_entity_t *) rlc_pP; + rlc_tm_entity_t* rlc_p = (rlc_tm_entity_t*) rlc_pP; struct mac_data_req data_req; - rlc_tm_no_segment (ctxt_pP, l_rlc_p); + rlc_tm_no_segment (ctxt_pP, rlc_p); list_init (&data_req.data, NULL); - list_add_list (&l_rlc_p->pdus_to_mac_layer, &data_req.data); - - data_req.buffer_occupancy_in_bytes = l_rlc_p->buffer_occupancy; - data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / l_rlc_p->rlc_pdu_size; - data_req.rlc_info.rlc_protocol_state = l_rlc_p->protocol_state; + list_add_list (&rlc_p->pdus_to_mac_layer, &data_req.data); + data_req.buffer_occupancy_in_bytes = rlc_p->buffer_occupancy; + data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / rlc_p->rlc_pdu_size; + data_req.rlc_info.rlc_protocol_state = rlc_p->protocol_state; if (data_req.data.nb_elements > 0) { - LOG_D(RLC, "[RLC_TM][%s][MOD %02u/%02u][RB %d][FRAME %05d] MAC_DATA_REQUEST %d TBs\n", - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - l_rlc_p->rb_id, - ctxt_pP->frame, + LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT" MAC_DATA_REQUEST %d TBs\n", + PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), data_req.data.nb_elements); } @@ -211,15 +209,11 @@ rlc_tm_mac_data_indication ( struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - rlc_tm_entity_t *l_rlc_p = (rlc_tm_entity_t *) rlc_pP; + rlc_tm_entity_t* rlc_p = (rlc_tm_entity_t*) rlc_pP; if (data_indP.data.nb_elements > 0) { - LOG_D(RLC, "[RLC_TM][%s][MOD %02u/%02u][RB %d][FRAME %05d] MAC_DATA_IND %d TBs\n", - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - l_rlc_p->rb_id, - ctxt_pP->frame, + LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT" MAC_DATA_IND %d TBs\n", + PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), data_indP.data.nb_elements); } @@ -237,10 +231,8 @@ rlc_tm_data_req ( rlc_tm_entity_t *rlc_p = (rlc_tm_entity_t *) rlc_pP; #ifdef DEBUG_RLC_TM_DATA_REQUEST - LOG_D (RLC, "[RLC_TM][%s][MOD %02u/%02u] RLC_TM_DATA_REQ size %d Bytes, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D (RLC, PROTOCOL_RLC_TM_CTXT_FMT" RLC_TM_DATA_REQ size %d Bytes, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", + PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), ((struct rlc_um_data_req *) (sdu_pP->data))->data_size, rlc_p->buffer_occupancy, rlc_p->nb_sdu, diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.h index 920fc909911..a55971ae9b6 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.h +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.h @@ -64,6 +64,10 @@ # include "mem_block.h" # include "rlc_tm_init.h" +#define PROTOCOL_RLC_TM_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u]" +#define PROTOCOL_RLC_TM_CTXT_ARGS(CTXT_Pp, rLC_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ + (rLC_Pp->is_data_plane) ? "DRB TM" : "SRB TM",\ + rLC_Pp->rb_id /*! \fn void rlc_tm_send_sdu ( diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h index 11f24a5ad3d..2e9e8820c26 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h @@ -47,8 +47,6 @@ * \brief Structure containing a RLC TM instance protocol variables, allocation variables, buffers and other miscellaneous variables. */ typedef struct rlc_tm_entity { - //module_id_t enb_module_id; /*!< \brief eNB Virtualization index for this protocol instance, meaningful if is_enb is set. */ - //module_id_t ue_module_id; /*!< \brief UE Virtualization index for this protocol instance, meaningful if is_enb is set. */ boolean_t allocation; /*!< \brief Boolean for rlc_tm_entity_t struct allocation. */ rlc_protocol_state_t protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */ boolean_t is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */ diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c index 8354fe94da6..ddf6bc08edb 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c @@ -42,21 +42,16 @@ void config_req_rlc_tm ( //----------------------------------------------------------------------------- rlc_union_t *rlc_union_p = NULL; rlc_tm_entity_t *rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, rb_idP, srb_flagP); + hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); hashtable_rc_t h_rc; h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { rlc_p = &rlc_union_p->rlc.tm; - LOG_D(RLC, "[FRAME %05d][%s][RRC][MOD %u/%u][][--- CONFIG_REQ (is_uplink_downlink=%d) --->][RLC_TM][MOD %u/%u][RB %u]\n", - ctxt_pP->frame, - ( ctxt_pP->enb_flag > 0) ? "eNB":"UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT" CONFIG_REQ (is_uplink_downlink=%d) RB %u\n", + PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), config_tmP->is_uplink_downlink, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, rb_idP); rlc_tm_init(ctxt_pP, rlc_p); @@ -64,13 +59,8 @@ void config_req_rlc_tm ( rlc_tm_set_debug_infos(ctxt_pP, rlc_p, rb_idP, srb_flagP); rlc_tm_configure(ctxt_pP, rlc_p, config_tmP->is_uplink_downlink); } else { - LOG_E(RLC, "[FRAME %05d][%s][RRC][MOD %u/%u][][--- CONFIG_REQ --->][RLC_TM][MOD %u/%u][RB %u], RLC NOT FOUND\n", - ctxt_pP->frame, - ( ctxt_pP->enb_flag > 0) ? "eNB":"UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_RLC_TM_CTXT_FMT" CONFIG_REQ RB %u RLC NOT FOUND\n", + PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), rb_idP); } } @@ -169,16 +159,6 @@ void rlc_tm_set_debug_infos( const rb_id_t rb_idP) //----------------------------------------------------------------------------- { - msg ("[FRAME %05d][%s][RLC_TM][MOD %02u/%02u][RB %u][SET DEBUG INFOS] rb_id %d srb_flag %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rb_idP, - rb_idP, - srb_flagP); - - rlcP->rb_id = rb_idP; if (srb_flagP) { diff --git a/openair2/LAYER2/RLC/UM/rlc_um.c b/openair2/LAYER2/RLC/UM/rlc_um.c index 9e8f21c733a..8350d128a17 100755 --- a/openair2/LAYER2/RLC/UM/rlc_um.c +++ b/openair2/LAYER2/RLC/UM/rlc_um.c @@ -33,36 +33,36 @@ EMAIL : Lionel.Gauthier@eurecom.fr *******************************************************************************/ #ifndef USER_MODE -# define __NO_VERSION__ +#define __NO_VERSION__ -# include "rt_compat.h" +#include "rt_compat.h" -# ifdef RTAI -# include <rtai.h> -# include <rtai_posix.h> -# include <rtai_fifos.h> -# else +#ifdef RTAI +#include <rtai.h> +#include <rtai_posix.h> +#include <rtai_fifos.h> +#else /* RTLINUX */ -# include <rtl.h> -# include <time.h> -# include <rtl_sched.h> -# include <rtl_sync.h> -# include <pthread.h> -# include <rtl_debug.h> -# include <rtl_core.h> -# include <rtl_fifo.h> -# endif +#include <rtl.h> +#include <time.h> +#include <rtl_sched.h> +#include <rtl_sync.h> +#include <pthread.h> +#include <rtl_debug.h> +#include <rtl_core.h> +#include <rtl_fifo.h> +#endif -# include <asm/page.h> +#include <asm/page.h> #else -# include <stdlib.h> -# include <stdio.h> -# include <fcntl.h> -# include <signal.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <pthread.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <pthread.h> #endif #include "print.h" @@ -79,16 +79,16 @@ #include "LAYER2/MAC/extern.h" #define DEBUG_RLC_UM_DISPLAY_ASCII_DATA //----------------------------------------------------------------------------- -uint32_t rlc_um_get_buffer_occupancy (struct rlc_um_entity *rlcP); -void rlc_um_get_pdus (void *argP); -void rlc_um_rx (void *argP, struct mac_data_ind data_indP); -struct mac_status_resp rlc_um_mac_status_indication (void *rlcP, uint16_t no_tbP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP); -struct mac_data_req rlc_um_mac_data_request (void *rlcP); -void rlc_um_mac_data_indication (void *rlcP, struct mac_data_ind data_indP); -void rlc_um_data_req (void *rlcP, struct mem_block *sduP); +uint32_t rlc_um_get_buffer_occupancy (struct rlc_um_entity* rlcP); +void rlc_um_get_pdus (void* argP); +void rlc_um_rx (void* argP, struct mac_data_ind data_indP); +struct mac_status_resp rlc_um_mac_status_indication (void* rlcP, uint16_t no_tbP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP); +struct mac_data_req rlc_um_mac_data_request (void* rlcP); +void rlc_um_mac_data_indication (void* rlcP, struct mac_data_ind data_indP); +void rlc_um_data_req (void* rlcP, struct mem_block* sduP); //----------------------------------------------------------------------------- uint32_t -rlc_um_get_buffer_occupancy (struct rlc_um_entity *rlcP) +rlc_um_get_buffer_occupancy (struct rlc_um_entity* rlcP) { //----------------------------------------------------------------------------- return rlcP->buffer_occupancy; @@ -96,13 +96,12 @@ rlc_um_get_buffer_occupancy (struct rlc_um_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_um_get_pdus (void *argP) +rlc_um_get_pdus (void* argP) { //----------------------------------------------------------------------------- - struct rlc_um_entity *rlc = (struct rlc_um_entity *) argP; + struct rlc_um_entity* rlc = (struct rlc_um_entity*) argP; switch (rlc->protocol_state) { - case RLC_NULL_STATE: // from 3GPP TS 25.322 V4.2.0 // In the NULL state the RLC entity does not exist and therefore it is not possible to transfer any data through it. @@ -129,6 +128,7 @@ rlc_um_get_pdus (void *argP) if (rlc->data_pdu_size > 125) { rlc_um_segment_15 (rlc); + } else { rlc_um_segment_7 (rlc); } @@ -147,7 +147,6 @@ rlc_um_get_pdus (void *argP) // Upon reception of a CRLC-CONFIG-Req from upper layer indicating modification, the RLC entity: // - stays in the LOCAL_SUSPEND state; // - modifies only the protocol parameters and timers as indicated by upper layers. - // TO DO TAKE CARE OF SN : THE IMPLEMENTATION OF THIS FUNCTIONNALITY IS NOT CRITICAL break; @@ -158,14 +157,12 @@ rlc_um_get_pdus (void *argP) //----------------------------------------------------------------------------- void -rlc_um_rx (void *argP, struct mac_data_ind data_indP) +rlc_um_rx (void* argP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - - struct rlc_um_entity *rlc = (struct rlc_um_entity *) argP; + struct rlc_um_entity* rlc = (struct rlc_um_entity*) argP; switch (rlc->protocol_state) { - case RLC_NULL_STATE: // from 3GPP TS 25.322 V4.2.0 // In the NULL state the RLC entity does not exist and therefore it is not possible to transfer any data through it. @@ -191,6 +188,7 @@ rlc_um_rx (void *argP, struct mac_data_ind data_indP) if (data_indP.tb_size <= 125) { rlc_um_receive_7 (rlc, data_indP); + } else { rlc_um_receive_15 (rlc, data_indP); } @@ -216,29 +214,27 @@ rlc_um_rx (void *argP, struct mac_data_ind data_indP) //----------------------------------------------------------------------------- struct mac_status_resp -rlc_um_mac_status_indication (void *rlcP, uint16_t no_tbP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP) +rlc_um_mac_status_indication (void* rlcP, uint16_t no_tbP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP) { //----------------------------------------------------------------------------- struct mac_status_resp status_resp; + ((struct rlc_um_entity*) rlcP)->nb_pdu_requested_by_mac = no_tbP - ((struct rlc_um_entity*) rlcP)->pdus_to_mac_layer.nb_elements; + ((struct rlc_um_entity*) rlcP)->data_pdu_size = (tb_sizeP + 7) >> 3; + ((struct rlc_um_entity*) rlcP)->data_pdu_size_in_bits = tb_sizeP; + status_resp.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy ((struct rlc_um_entity*) rlcP); + status_resp.buffer_occupancy_in_pdus = status_resp.buffer_occupancy_in_bytes / ((struct rlc_um_entity*) rlcP)->data_pdu_size; + status_resp.rlc_info.rlc_protocol_state = ((struct rlc_um_entity*) rlcP)->protocol_state; +#ifdef TRACE_RLC_UM_TX_STATUS - ((struct rlc_um_entity *) rlcP)->nb_pdu_requested_by_mac = no_tbP - ((struct rlc_um_entity *) rlcP)->pdus_to_mac_layer.nb_elements; - ((struct rlc_um_entity *) rlcP)->data_pdu_size = (tb_sizeP + 7) >> 3; - ((struct rlc_um_entity *) rlcP)->data_pdu_size_in_bits = tb_sizeP; - - status_resp.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy ((struct rlc_um_entity *) rlcP); - status_resp.buffer_occupancy_in_pdus = status_resp.buffer_occupancy_in_bytes / ((struct rlc_um_entity *) rlcP)->data_pdu_size; - status_resp.rlc_info.rlc_protocol_state = ((struct rlc_um_entity *) rlcP)->protocol_state; -#ifdef DEBUG_RLC_UM_TX_STATUS - - if (((struct rlc_um_entity *) rlcP)->rb_id > 0) { - msg ("[RLC_UM][RB %d] MAC_STATUS_INDICATION (DATA) %d TBs -> %d TBs\n", ((struct rlc_um_entity *) rlcP)->rb_id, no_tbP, status_resp.buffer_occupancy_in_pdus); + if (((struct rlc_um_entity*) rlcP)->rb_id > 0) { + msg ("[RLC_UM][RB %d] MAC_STATUS_INDICATION (DATA) %d TBs -> %d TBs\n", ((struct rlc_um_entity*) rlcP)->rb_id, no_tbP, status_resp.buffer_occupancy_in_pdus); if ((tx_statusP.tx_status == MAC_TX_STATUS_SUCCESSFUL) && (tx_statusP.no_pdu)) { - msg ("[RLC_UM][RB %d] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n", ((struct rlc_um_entity *) rlcP)->rb_id, tx_statusP.no_pdu); + msg ("[RLC_UM][RB %d] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n", ((struct rlc_um_entity*) rlcP)->rb_id, tx_statusP.no_pdu); } if ((tx_statusP.tx_status == MAC_TX_STATUS_UNSUCCESSFUL) && (tx_statusP.no_pdu)) { - msg ("[RLC_UM][RB %d] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n", ((struct rlc_um_entity *) rlcP)->rb_id, tx_statusP.no_pdu); + msg ("[RLC_UM][RB %d] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n", ((struct rlc_um_entity*) rlcP)->rb_id, tx_statusP.no_pdu); } } @@ -248,35 +244,32 @@ rlc_um_mac_status_indication (void *rlcP, uint16_t no_tbP, uint16_t tb_sizeP, st //----------------------------------------------------------------------------- struct mac_data_req -rlc_um_mac_data_request (void *rlcP) +rlc_um_mac_data_request (void* rlcP) { //----------------------------------------------------------------------------- struct mac_data_req data_req; - rlc_um_get_pdus (rlcP); - init_cnt_up (&data_req.data, NULL); - add_cnt_up (&((struct rlc_um_entity *) rlcP)->pdus_to_mac_layer, &data_req.data); + add_cnt_up (&((struct rlc_um_entity*) rlcP)->pdus_to_mac_layer, &data_req.data); #ifdef DEBUG_RLC_STATS - ((struct rlc_um_entity *) rlcP)->tx_pdus += data_req.data.nb_elements; + ((struct rlc_um_entity*) rlcP)->tx_pdus += data_req.data.nb_elements; #endif - #ifdef DEBUG_RLC_UM_MAC_DATA_REQUEST - if (((struct rlc_um_entity *) rlcP)->rb_id > 0) { + if (((struct rlc_um_entity*) rlcP)->rb_id > 0) { // msg ("[RLC_UM][RB %d] MAC_DATA_REQUEST %d TBs\n", ((struct rlc_um_entity *) rlcP)->rb_id, data_req.data.nb_elements); } #endif - data_req.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy ((struct rlc_um_entity *) rlcP); - data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / ((struct rlc_um_entity *) rlcP)->data_pdu_size; - data_req.rlc_info.rlc_protocol_state = ((struct rlc_um_entity *) rlcP)->protocol_state; + data_req.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy ((struct rlc_um_entity*) rlcP); + data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / ((struct rlc_um_entity*) rlcP)->data_pdu_size; + data_req.rlc_info.rlc_protocol_state = ((struct rlc_um_entity*) rlcP)->protocol_state; return data_req; } //----------------------------------------------------------------------------- void -rlc_um_mac_data_indication (void *rlcP, struct mac_data_ind data_indP) +rlc_um_mac_data_indication (void* rlcP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- rlc_um_rx (rlcP, data_indP); @@ -284,10 +277,10 @@ rlc_um_mac_data_indication (void *rlcP, struct mac_data_ind data_indP) //----------------------------------------------------------------------------- void -rlc_um_data_req (void *rlcP, struct mem_block *sduP) +rlc_um_data_req (void* rlcP, struct mem_block* sduP) { //----------------------------------------------------------------------------- - struct rlc_um_entity *rlc = (struct rlc_um_entity *) rlcP; + struct rlc_um_entity* rlc = (struct rlc_um_entity*) rlcP; uint8_t use_special_li; uint8_t insert_sdu = 0; #ifdef DEBUG_RLC_UM_DISCARD_SDU @@ -297,11 +290,9 @@ rlc_um_data_req (void *rlcP, struct mem_block *sduP) int index; # endif #endif - #ifndef NO_THREAD_SAFE pthread_mutex_lock (&rlc->mutex_input_buffer); #endif - #ifdef DEBUG_RLC_UM_DATA_REQUEST //msg ("[RLC_UM][RB %d] RLC_UM_DATA_REQ size %d Bytes, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", // rlc->rb_id, ((struct rlc_um_data_req *) (sduP->data))->data_size, rlc->buffer_occupancy, rlc->nb_sdu, rlc->current_sdu_index, rlc->next_sdu_index); @@ -309,6 +300,7 @@ rlc_um_data_req (void *rlcP, struct mem_block *sduP) if (rlc->input_sdus[rlc->next_sdu_index] == NULL) { insert_sdu = 1; + } else { // from 3GPP TS 25.322 V4.2.0 // If SDU discard has not been configured for an unacknowledged mode RLC entity, SDUs in the @@ -324,17 +316,18 @@ rlc_um_data_req (void *rlcP, struct mem_block *sduP) msg ("[RLC_UM][RB %d] SDU DISCARDED : BUFFER OVERFLOW, BO %ld , NB SDU %d\n", rlc->rb_id, rlc->buffer_occupancy, rlc->nb_sdu); #endif - if (((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_remaining_size != - ((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size) { + if (((struct rlc_um_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_remaining_size != + ((struct rlc_um_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size) { #ifdef DEBUG_RLC_UM_VT_US msg ("[RLC_UM][RB %d] Inc VT(US) in rlc_um_data_req()/discarding SDU\n", rlc->rb_id); #endif rlc->vt_us = (rlc->vt_us + 1) & 0x7F; rlc->li_one_byte_short_to_add_in_next_pdu = 0; rlc->li_exactly_filled_to_add_in_next_pdu = 1; - rlc->buffer_occupancy -= ((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_remaining_size; + rlc->buffer_occupancy -= ((struct rlc_um_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_remaining_size; + } else { - rlc->buffer_occupancy -= ((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size; + rlc->buffer_occupancy -= ((struct rlc_um_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size; } rlc->nb_sdu -= 1; @@ -351,6 +344,7 @@ rlc_um_data_req (void *rlcP, struct mem_block *sduP) } #endif + } else { #ifdef DEBUG_RLC_UM_DISCARD_SDU msg ("[RLC_UM][RB %d] DISCARD : BUFFER OVERFLOW ERROR : SHOULD FIND A SDU\n", rlc->rb_id); @@ -367,25 +361,25 @@ rlc_um_data_req (void *rlcP, struct mem_block *sduP) if ((insert_sdu)) { #ifdef BENCH_QOS_L2 - fprintf (bench_l2, "[SDU REQUEST] FRAME %d SIZE %d RB %d RLC-UM %p\n", mac_xface->frame, ((struct rlc_um_data_req *) (sduP->data))->data_size, rlc->rb_id, rlc); + fprintf (bench_l2, "[SDU REQUEST] FRAME %d SIZE %d RB %d RLC-UM %p\n", mac_xface->frame, ((struct rlc_um_data_req*) (sduP->data))->data_size, rlc->rb_id, rlc); #endif rlc->input_sdus[rlc->next_sdu_index] = sduP; // IMPORTANT : do not change order of affectations - use_special_li = ((struct rlc_um_data_req *) (sduP->data))->use_special_li; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size = ((struct rlc_um_data_req *) (sduP->data))->data_size; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->use_special_li = use_special_li; - rlc->buffer_occupancy += ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size; + use_special_li = ((struct rlc_um_data_req*) (sduP->data))->use_special_li; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_size = ((struct rlc_um_data_req*) (sduP->data))->data_size; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->use_special_li = use_special_li; + rlc->buffer_occupancy += ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_size; rlc->nb_sdu += 1; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->first_byte = &sduP->data[sizeof (struct rlc_um_data_req_alloc)]; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_segmented_size = 0; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_creation_time = *rlc->frame_tick_milliseconds; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->first_byte = &sduP->data[sizeof (struct rlc_um_data_req_alloc)]; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_remaining_size = ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_size; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_segmented_size = 0; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_creation_time = *rlc->frame_tick_milliseconds; rlc->next_sdu_index = (rlc->next_sdu_index + 1) % rlc->size_input_sdus_buffer; #ifdef DEBUG_RLC_UM_DISPLAY_ASCII_DATA //msg ("[RLC_UM][RB %d]SDU REQUEST DATA :", rlc->rb_id); - for (index = 0; index < ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_remaining_size; index++) { - msg ("%02X-", ((struct rlc_um_tx_sdu_management *) (sduP->data))->first_byte[index]); + for (index = 0; index < ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_remaining_size; index++) { + msg ("%02X-", ((struct rlc_um_tx_sdu_management*) (sduP->data))->first_byte[index]); } msg ("\n"); diff --git a/openair2/LAYER2/RLC/UM/rlc_um_receiver.c b/openair2/LAYER2/RLC/UM/rlc_um_receiver.c index 2e0227babc7..33d3e2e914a 100755 --- a/openair2/LAYER2/RLC/UM/rlc_um_receiver.c +++ b/openair2/LAYER2/RLC/UM/rlc_um_receiver.c @@ -33,14 +33,14 @@ EMAIL : Lionel.Gauthier@eurecom.fr *******************************************************************************/ #ifndef USER_MODE -# define __NO_VERSION__ +#define __NO_VERSION__ -# ifdef RTAI -# include <rtai.h> -# else +#ifdef RTAI +#include <rtai.h> +#else /* RTLINUX */ -# include <rtl.h> -# endif +#include <rtl.h> +#endif #endif //----------------------------------------------------------------------------- @@ -57,32 +57,33 @@ #include "debug_l2.h" #include "LAYER2/MAC/extern.h" //----------------------------------------------------------------------------- -#ifdef DEBUG_RLC_UM_RX_DECODE_LI -# define PRINT_RLC_UM_RX_DECODE_LI msg +#ifdef TRACE_RLC_UM_RX_DECODE_LI +#define PRINT_RLC_UM_RX_DECODE_LI msg #else -# define PRINT_RLC_UM_RX_DECODE_LI // +#define PRINT_RLC_UM_RX_DECODE_LI // #endif -#ifdef DEBUG_RLC_UM_RX -# define PRINT_RLC_UM_RX msg +#ifdef TRACE_RLC_UM_RX +#define PRINT_RLC_UM_RX msg #else -# define PRINT_RLC_UM_RX // +#define PRINT_RLC_UM_RX // #endif //----------------------------------------------------------------------------- inline void -rlc_um_receive_15_process_waited_pdu (struct rlc_um_entity *rlc_pP, - struct rlc_um_rx_pdu_management *pdu_mngt_pP, - struct rlc_um_rx_data_pdu_struct *data_pP, +rlc_um_receive_15_process_waited_pdu (struct rlc_um_entity* rlc_pP, + struct rlc_um_rx_pdu_management* pdu_mngt_pP, + struct rlc_um_rx_data_pdu_struct* data_pP, sdu_size_t tb_sizeP) { //----------------------------------------------------------------------------- - uint8_t *data_pdu_p = NULL; + uint8_t* data_pdu_p = NULL; sdu_size_t remaining_data_size = 0; int nb_li = 0; int li_index = 0; sdu_size_t li[32]; if ((data_pP->byte1 & RLC_E_MASK) == (uint8_t) RLC_E_NEXT_FIELD_IS_DATA) { - rlc_um_reassembly ((uint8_t *) (&data_pP->li_data_7[0]), tb_sizeP - 1, rlc_pP, 0); + rlc_um_reassembly ((uint8_t*) (&data_pP->li_data_7[0]), tb_sizeP - 1, rlc_pP, 0); + } else { while ((li[nb_li] = ((((uint16_t) data_pP->li_data_7[nb_li << 1]) << 8) + data_pP->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(uint16_t) RLC_E_NEXT_FIELD_IS_LI_E); @@ -90,9 +91,8 @@ rlc_um_receive_15_process_waited_pdu (struct rlc_um_entity *rlc_pP, } nb_li++; // count the last li - remaining_data_size = tb_sizeP - 1 - (nb_li << 1); - data_pdu_p = (uint8_t *) (&data_pP->li_data_7[nb_li << 1]); + data_pdu_p = (uint8_t*) (&data_pP->li_data_7[nb_li << 1]); while (li_index < nb_li) { switch (li[li_index]) { @@ -117,7 +117,7 @@ rlc_um_receive_15_process_waited_pdu (struct rlc_um_entity *rlc_pP, default: // li is length remaining_data_size = remaining_data_size - (li[li_index] >> 1); rlc_um_reassembly (data_pdu_p, (li[li_index] >> 1), rlc_pP); - data_pdu_p = (uint8_t *) ((uint64_t) data_pdu_p + (li[li_index] >> 1)); + data_pdu_p = (uint8_t*) ((uint64_t) data_pdu_p + (li[li_index] >> 1)); rlc_um_send_sdu (rlc_pP); } @@ -135,17 +135,19 @@ rlc_um_receive_15_process_waited_pdu (struct rlc_um_entity *rlc_pP, //----------------------------------------------------------------------------- inline void -rlc_um_receive_7_process_waited_pdu (struct rlc_um_entity *rlc_pP, struct rlc_um_rx_pdu_management *pdu_mngtP, struct rlc_um_rx_data_pdu_struct *dataP, uint16_t tb_sizeP) +rlc_um_receive_7_process_waited_pdu (struct rlc_um_entity* rlc_pP, struct rlc_um_rx_pdu_management* pdu_mngtP, struct rlc_um_rx_data_pdu_struct* dataP, + uint16_t tb_sizeP) { //----------------------------------------------------------------------------- - uint8_t *data_pdu_p = NULL; + uint8_t* data_pdu_p = NULL; sdu_size_t remaining_data_size = 0; int nb_li = 0; int li_index = 0; sdu_size_t li[32]; if ((dataP->byte1 & RLC_E_MASK) == (uint8_t) RLC_E_NEXT_FIELD_IS_DATA) { - rlc_um_reassembly ((uint8_t *) (&dataP->li_data_7[0]), tb_sizeP - 1, rlc_pP, 0); + rlc_um_reassembly ((uint8_t*) (&dataP->li_data_7[0]), tb_sizeP - 1, rlc_pP, 0); + } else { while ((li[nb_li] = ((uint16_t) dataP->li_data_7[nb_li])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(uint8_t) RLC_E_NEXT_FIELD_IS_LI_E); @@ -153,9 +155,8 @@ rlc_um_receive_7_process_waited_pdu (struct rlc_um_entity *rlc_pP, struct rlc_um } nb_li++; // count the last li - remaining_data_size = tb_sizeP - 1 - nb_li; - data_pdu_p = (uint8_t *) (&dataP->li_data_7[nb_li]); + data_pdu_p = (uint8_t*) (&dataP->li_data_7[nb_li]); while (li_index < nb_li) { switch (li[li_index]) { @@ -185,7 +186,7 @@ rlc_um_receive_7_process_waited_pdu (struct rlc_um_entity *rlc_pP, struct rlc_um PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li LI_SIZE %d Bytes\n", rlc_pP, pdu_mngtP, li[li_index] >> 1); remaining_data_size = remaining_data_size - (li[li_index] >> 1); rlc_um_reassembly (data_pdu_p, (li[li_index] >> 1), rlc_pP); - data_pdu_p = (uint8_t *) ((uint64_t) data_pdu_p + (li[li_index] >> 1)); + data_pdu_p = (uint8_t*) ((uint64_t) data_pdu_p + (li[li_index] >> 1)); rlc_um_send_sdu (rlc_pP); } @@ -203,23 +204,23 @@ rlc_um_receive_7_process_waited_pdu (struct rlc_um_entity *rlc_pP, struct rlc_um //----------------------------------------------------------------------------- inline void -rlc_um_receive_15_process_unsynchronized_pdu (struct rlc_um_entity *rlc_pP, - struct rlc_um_rx_pdu_management *pdu_mngt_pP, - struct rlc_um_rx_data_pdu_struct *data_pP, +rlc_um_receive_15_process_unsynchronized_pdu (struct rlc_um_entity* rlc_pP, + struct rlc_um_rx_pdu_management* pdu_mngt_pP, + struct rlc_um_rx_data_pdu_struct* data_pP, sdu_size_t tb_sizeP) { //----------------------------------------------------------------------------- - uint8_t *data_pdu_p = NULL; + uint8_t* data_pdu_p = NULL; int nb_li = 0; int li_index = 0; sdu_size_t remaining_data_size = 0; sdu_size_t li[32]; uint8_t start_processing = 0; - rlc_pP->output_sdu_size_to_write = 0; if ((data_pP->byte1 & RLC_E_MASK) == (uint8_t) RLC_E_NEXT_FIELD_IS_DATA) { return; + } else { while ((li[nb_li] = ((((uint16_t) data_pP->li_data_7[nb_li << 1]) << 8) + data_pP->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(uint16_t) RLC_E_NEXT_FIELD_IS_LI_E); @@ -227,9 +228,8 @@ rlc_um_receive_15_process_unsynchronized_pdu (struct rlc_um_entity * } nb_li++; // count the last li - remaining_data_size = tb_sizeP - 1 - (nb_li << 1); - data_pdu_p = (uint8_t *) (&data_pP->li_data_7[nb_li << 1]); + data_pdu_p = (uint8_t*) (&data_pP->li_data_7[nb_li << 1]); while (li_index < nb_li) { switch (li[li_index]) { @@ -257,7 +257,7 @@ rlc_um_receive_15_process_unsynchronized_pdu (struct rlc_um_entity * } start_processing = 1; - data_pdu_p = (uint8_t *) ((uint64_t) data_pdu_p + (li[li_index] >> 1)); + data_pdu_p = (uint8_t*) ((uint64_t) data_pdu_p + (li[li_index] >> 1)); } li_index++; @@ -274,23 +274,23 @@ rlc_um_receive_15_process_unsynchronized_pdu (struct rlc_um_entity * //----------------------------------------------------------------------------- inline void -rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity *rlc_pP, - struct rlc_um_rx_pdu_management *pdu_mngt_pP, - struct rlc_um_rx_data_pdu_struct *data_pP, +rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity* rlc_pP, + struct rlc_um_rx_pdu_management* pdu_mngt_pP, + struct rlc_um_rx_data_pdu_struct* data_pP, sdu_size_t tb_sizeP) { //----------------------------------------------------------------------------- - uint8_t *data_pdu_p = NULL; + uint8_t* data_pdu_p = NULL; int nb_li = 0; int li_index = 0; sdu_size_t remaining_data_size = 0; sdu_size_t li[32]; uint8_t start_processing = 0; - rlc_pP->output_sdu_size_to_write = 0; if ((data_pP->byte1 & RLC_E_MASK) == (uint8_t) RLC_E_NEXT_FIELD_IS_DATA) { return; + } else { while ((li[nb_li] = ((uint16_t) data_pP->li_data_7[nb_li])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(uint8_t) RLC_E_NEXT_FIELD_IS_LI_E); @@ -298,10 +298,8 @@ rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity *rl } nb_li++; // count the last li - remaining_data_size = tb_sizeP - 1 - nb_li; - - data_pdu_p = (uint8_t *) (&data_pP->li_data_7[nb_li]); + data_pdu_p = (uint8_t*) (&data_pP->li_data_7[nb_li]); while (li_index < nb_li) { switch (li[li_index]) { @@ -329,7 +327,7 @@ rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity *rl } start_processing = 1; - data_pdu_p = (uint8_t *) ((uint64_t) data_pdu_p + (li[li_index] >> 1)); + data_pdu_p = (uint8_t*) ((uint64_t) data_pdu_p + (li[li_index] >> 1)); } li_index++; @@ -346,28 +344,24 @@ rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity *rl //----------------------------------------------------------------------------- void -rlc_um_receive_15 (struct rlc_um_entity *rlc_pP, struct mac_data_ind data_indP) +rlc_um_receive_15 (struct rlc_um_entity* rlc_pP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - - struct rlc_um_rx_data_pdu_struct *data_p = NULL; - struct rlc_um_rx_pdu_management *pdu_mngt_p = NULL; - struct mem_block *tb_p = NULL; - uint8_t *first_byte_p = NULL; + struct rlc_um_rx_data_pdu_struct* data_p = NULL; + struct rlc_um_rx_pdu_management* pdu_mngt_p = NULL; + struct mem_block* tb_p = NULL; + uint8_t* first_byte_p = NULL; sdu_size_t tb_size_in_bytes = 0; uint8_t first_bit = 0; uint8_t bits_to_shift = 0; uint8_t bits_to_shift_last_loop = 0; while ((tb_p = remove_up_head (&data_indP.data))) { - - if (!(((struct mac_tb_ind *) (tb_p->data))->error_indication)) { - - first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; - pdu_mngt_p = (struct rlc_um_rx_pdu_management *) (tb_p->data); - + if (!(((struct mac_tb_ind*) (tb_p->data))->error_indication)) { + first_byte_p = ((struct mac_tb_ind*) (tb_p->data))->data_ptr; + pdu_mngt_p = (struct rlc_um_rx_pdu_management*) (tb_p->data); tb_size_in_bytes = data_indP.tb_size; - first_bit = ((struct mac_tb_ind *) (tb_p->data))->first_bit; + first_bit = ((struct mac_tb_ind*) (tb_p->data))->first_bit; if (first_bit > 0) { // shift data of transport_block TO CHECK @@ -384,15 +378,17 @@ rlc_um_receive_15 (struct rlc_um_entity *rlc_pP, struct mac_data_ind data_indP) } pdu_mngt_p->first_byte = first_byte_p; - data_p = (struct rlc_um_rx_data_pdu_struct *) (first_byte_p); + data_p = (struct rlc_um_rx_data_pdu_struct*) (first_byte_p); pdu_mngt_p->sn = data_p->byte1 >> 1; PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX PDU SN %02X hex\n", rlc_pP->rb_id, pdu_mngt_p->sn); if (pdu_mngt_p->sn == rlc_pP->vr_us) { rlc_um_receive_15_process_waited_pdu (rlc_pP, pdu_mngt_p, data_p, data_indP.tb_size); + } else { rlc_um_receive_15_process_unsynchronized_pdu (rlc_pP, pdu_mngt_p, data_p, data_indP.tb_size); } + } else { PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX PDU WITH ERROR INDICATED BY LOWER LAYERS -> GARBAGE\n", rlc_pP->rb_id); } @@ -403,32 +399,27 @@ rlc_um_receive_15 (struct rlc_um_entity *rlc_pP, struct mac_data_ind data_indP) //----------------------------------------------------------------------------- void -rlc_um_receive_7 (struct rlc_um_entity *rlc_pP, struct mac_data_ind data_indP) +rlc_um_receive_7 (struct rlc_um_entity* rlc_pP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - - struct rlc_um_rx_data_pdu_struct *data_p = NULL; - struct rlc_um_rx_pdu_management *pdu_mngt_p = NULL; - struct mem_block *tb_p = NULL; - uint8_t *first_byte_p = NULL; + struct rlc_um_rx_data_pdu_struct* data_p = NULL; + struct rlc_um_rx_pdu_management* pdu_mngt_p = NULL; + struct mem_block* tb_p = NULL; + uint8_t* first_byte_p = NULL; sdu_size_t tb_size_in_bytes = 0; uint8_t first_bit = 0; uint8_t bits_to_shift = 0; uint8_t bits_to_shift_last_loop = 0; while ((tb_p = remove_up_head (&data_indP.data))) { - - - if (!(((struct mac_tb_ind *) (tb_p->data))->error_indication)) { - + if (!(((struct mac_tb_ind*) (tb_p->data))->error_indication)) { #ifdef DEBUG_RLC_STATS rlc_pP->rx_pdus += 1; #endif - first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; - pdu_mngt_p = (struct rlc_um_rx_pdu_management *) (tb_p->data); - + first_byte_p = ((struct mac_tb_ind*) (tb_p->data))->data_ptr; + pdu_mngt_p = (struct rlc_um_rx_pdu_management*) (tb_p->data); tb_size_in_bytes = data_indP.tb_size; - first_bit = ((struct mac_tb_ind *) (tb_p->data))->first_bit; + first_bit = ((struct mac_tb_ind*) (tb_p->data))->first_bit; if (first_bit > 0) { // shift data of transport_block TO CHECK @@ -445,21 +436,23 @@ rlc_um_receive_7 (struct rlc_um_entity *rlc_pP, struct mac_data_ind data_indP) } pdu_mngt_p->first_byte = first_byte_p; - data_p = (struct rlc_um_rx_data_pdu_struct *) (first_byte_p); + data_p = (struct rlc_um_rx_data_pdu_struct*) (first_byte_p); pdu_mngt_p->sn = data_p->byte1 >> 1; PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX7 PDU SN %d VR(US) %d\n", rlc_pP->rb_id, pdu_mngt_p->sn, rlc_pP->vr_us); if (pdu_mngt_p->sn == rlc_pP->vr_us) { rlc_um_receive_7_process_waited_pdu (rlc_pP, pdu_mngt_p, data_p, data_indP.tb_size); + } else { rlc_um_receive_7_process_unsynchronized_pdu (rlc_pP, pdu_mngt_p, data_p, data_indP.tb_size); } + } else { #ifdef DEBUG_RLC_STATS rlc_pP->rx_pdus_in_error += 1; #endif -#ifdef DEBUG_RLC_UM_RX - pdu_mngt_p = (struct rlc_um_rx_pdu_management *) (tb->data); +#ifdef TRACE_RLC_UM_RX + pdu_mngt_p = (struct rlc_um_rx_pdu_management*) (tb->data); PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX7 PDU SN %02X hex??? WITH ERROR INDICATED BY LOWER LAYERS -> GARBAGE\n", rlc_pP->rb_id, pdu_mngt_p->sn); #endif } diff --git a/openair2/LAYER2/RLC/UM/rlc_um_segment.c b/openair2/LAYER2/RLC/UM/rlc_um_segment.c index cf555e201a6..b09f4db696c 100755 --- a/openair2/LAYER2/RLC/UM/rlc_um_segment.c +++ b/openair2/LAYER2/RLC/UM/rlc_um_segment.c @@ -33,14 +33,14 @@ EMAIL : Lionel.Gauthier@eurecom.fr *******************************************************************************/ #ifndef USER_MODE -# define __NO_VERSION__ +#define __NO_VERSION__ -# ifdef RTAI -# include <rtai.h> -# else +#ifdef RTAI +#include <rtai.h> +#else /* RTLINUX */ -# include <rtl.h> -# endif +#include <rtl.h> +#endif #endif @@ -54,41 +54,43 @@ #include "debug_l2.h" #ifdef DEBUG_RLC_UM_SEGMENT -# define PRINT_RLC_UM_SEGMENT msg +#define PRINT_RLC_UM_SEGMENT msg #else -# define PRINT_RLC_UM_SEGMENT +#define PRINT_RLC_UM_SEGMENT // #endif #ifdef DEBUG_RLC_UM_SEGMENT_ENCODE -# define PRINT_RLC_UM_SEGMENT_ENCODE msg +#define PRINT_RLC_UM_SEGMENT_ENCODE msg #else -# define PRINT_RLC_UM_SEGMENT_ENCODE +#define PRINT_RLC_UM_SEGMENT_ENCODE // #endif #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA -# define PRINT_RLC_UM_SEGMENT_FILL_DATA msg +#define PRINT_RLC_UM_SEGMENT_FILL_DATA msg #else -# define PRINT_RLC_UM_SEGMENT_FILL_DATA // +#define PRINT_RLC_UM_SEGMENT_FILL_DATA // #endif #ifdef DEBUG_RLC_UM_DISCARD_SDU -# define PRINT_RLC_UM_DISCARD_SDU msg +#define PRINT_RLC_UM_DISCARD_SDU msg #else -# define PRINT_RLC_UM_DISCARD_SDU // +#define PRINT_RLC_UM_DISCARD_SDU // #endif //----------------------------------------------------------------------------- -mem_block *rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint16_t li1P); -inline void rlc_um_encode_pdu_15 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struct *rlc_headerP, struct rlc_um_tx_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP); -inline void rlc_um_encode_pdu_7 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struct *rlc_headerP, struct rlc_um_tx_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP); -inline void rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_up * pdusP, list_up * segmented_sdusP); -void rlc_um_segment_15 (struct rlc_um_entity *rlcP); +mem_block* rlc_um_build_pdu_with_only_2li (struct rlc_um_entity* rlcP, uint16_t li0P, uint16_t li1P); +inline void rlc_um_encode_pdu_15 (struct rlc_um_entity* rlcP, struct rlc_um_tx_data_pdu_struct* rlc_headerP, struct rlc_um_tx_pdu_management* pdu_mngtP, + uint16_t* li_arrayP, uint8_t nb_liP); +inline void rlc_um_encode_pdu_7 (struct rlc_um_entity* rlcP, struct rlc_um_tx_data_pdu_struct* rlc_headerP, struct rlc_um_tx_pdu_management* pdu_mngtP, + uint16_t* li_arrayP, uint8_t nb_liP); +inline void rlc_um_fill_pdus (struct rlc_um_entity* rlcP, list_up* pdusP, list_up* segmented_sdusP); +void rlc_um_segment_15 (struct rlc_um_entity* rlcP); //----------------------------------------------------------------------------- -mem_block * -rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint16_t li1P) +mem_block* +rlc_um_build_pdu_with_only_2li (struct rlc_um_entity* rlcP, uint16_t li0P, uint16_t li1P) { //----------------------------------------------------------------------------- - struct rlc_um_tx_data_pdu_struct *rlc_header; - struct rlc_um_tx_pdu_management *pdu_mngt; - mem_block *pdu; + struct rlc_um_tx_data_pdu_struct* rlc_header; + struct rlc_um_tx_pdu_management* pdu_mngt; + mem_block* pdu; if (!(pdu = get_free_mem_block (rlcP->data_pdu_size + sizeof (struct rlc_um_tx_data_pdu_management) + GUARD_CRC_LIH_SIZE))) { msg ("[RLC_UM][RB %d] BUILD PDU 2 LI ERROR COULD NOT GET NEW PDU, EXIT...BEFORE CRASH\n", rlcP->rb_id); @@ -96,8 +98,8 @@ rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint1 } PRINT_RLC_UM_SEGMENT ("[RLC_UM][RB %d] SEGMENT PDU SN %d SET LIs %04X %04X\n", rlcP->rb_id, rlcP->vt_us, li0P, li1P); - rlc_header = (struct rlc_um_tx_data_pdu_struct *) (&pdu->data[sizeof (struct rlc_um_tx_data_pdu_management)]); - pdu_mngt = (struct rlc_um_tx_pdu_management *) (pdu->data); + rlc_header = (struct rlc_um_tx_data_pdu_struct*) (&pdu->data[sizeof (struct rlc_um_tx_data_pdu_management)]); + pdu_mngt = (struct rlc_um_tx_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_um_tx_pdu_management)); if (rlcP->data_pdu_size > 125) { @@ -106,6 +108,7 @@ rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint1 rlc_header->li_data_7[2] = (uint8_t) (li1P >> 8); rlc_header->li_data_7[3] = (uint8_t) li1P; rlcP->li_length_15_was_used_for_previous_pdu = 1; + } else { rlc_header->li_data_7[0] = (uint8_t) (li0P | RLC_E_NEXT_FIELD_IS_LI_E); rlc_header->li_data_7[1] = (uint8_t) li1P; @@ -118,21 +121,19 @@ rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint1 msg ("[RLC_UM][RB %d] Inc VT(US) in rlc_um_build_pdu_with_only_2li()\n", rlcP->rb_id); #endif rlcP->vt_us = (rlcP->vt_us + 1) & 0x7F; - - pdu_mngt->first_byte = (uint8_t *) rlc_header; + pdu_mngt->first_byte = (uint8_t*) rlc_header; pdu_mngt->data_size = 0; pdu_mngt->payload = NULL; - return pdu; } //----------------------------------------------------------------------------- inline void -rlc_um_encode_pdu_15 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struct *rlc_headerP, struct rlc_um_tx_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP) +rlc_um_encode_pdu_15 (struct rlc_um_entity* rlcP, struct rlc_um_tx_data_pdu_struct* rlc_headerP, struct rlc_um_tx_pdu_management* pdu_mngtP, + uint16_t* li_arrayP, uint8_t nb_liP) { //----------------------------------------------------------------------------- uint8_t li_index; - #ifdef DEBUG_RLC_UM_SEGMENT int index; msg ("[RLC_UM %p] SEGMENT_15 PDU SN %d SET LIs: ", rlcP, rlcP->vt_us); @@ -149,9 +150,8 @@ rlc_um_encode_pdu_15 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_stru msg ("[RLC_UM %p] Inc VT(US) in rlc_um_encode_pdu_15\n", rlcP); #endif rlcP->vt_us = (rlcP->vt_us + 1) & 127; - nb_liP = nb_liP << 1; - pdu_mngtP->payload = (uint8_t *) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); + pdu_mngtP->payload = (uint8_t*) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); if (nb_liP) { rlc_headerP->byte1 |= RLC_E_NEXT_FIELD_IS_LI_E; @@ -171,11 +171,11 @@ rlc_um_encode_pdu_15 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_stru //----------------------------------------------------------------------------- inline void -rlc_um_encode_pdu_7 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struct *rlc_headerP, struct rlc_um_tx_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP) +rlc_um_encode_pdu_7 (struct rlc_um_entity* rlcP, struct rlc_um_tx_data_pdu_struct* rlc_headerP, struct rlc_um_tx_pdu_management* pdu_mngtP, uint16_t* li_arrayP, + uint8_t nb_liP) { //----------------------------------------------------------------------------- uint8_t li_index; - #ifdef DEBUG_RLC_UM_SEGMENT_ENCODE int index; msg ("[RLC_UM %p] SEGMENT_7 PDU %p SN %d SET LIs: ", rlcP, pdu_mngtP, rlcP->vt_us); @@ -186,15 +186,13 @@ rlc_um_encode_pdu_7 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struc msg ("\n"); #endif - rlc_headerP->byte1 = (rlcP->vt_us << 1); // inc vt_us #ifdef DEBUG_RLC_UM_VT_US msg ("[RLC_UM %p] Inc VT(US) in rlc_um_encode_pdu_7()\n", rlcP); #endif rlcP->vt_us = (rlcP->vt_us + 1) & 127; - - pdu_mngtP->payload = (uint8_t *) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); + pdu_mngtP->payload = (uint8_t*) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); if (nb_liP) { rlc_headerP->byte1 |= RLC_E_NEXT_FIELD_IS_LI_E; @@ -212,31 +210,27 @@ rlc_um_encode_pdu_7 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struc //----------------------------------------------------------------------------- inline void -rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_up * pdusP, list_up * segmented_sdusP) +rlc_um_fill_pdus (struct rlc_um_entity* rlcP, list_up* pdusP, list_up* segmented_sdusP) { //----------------------------------------------------------------------------- - mem_block *pdu; - mem_block *sdu; - uint8_t *data_sdu = NULL; - uint8_t *data_pdu; - struct rlc_um_tx_data_pdu_struct *rlc_header; - struct rlc_um_tx_pdu_management *pdu_mngt; - struct rlc_um_tx_sdu_management *sdu_mngt; - + mem_block* pdu; + mem_block* sdu; + uint8_t* data_sdu = NULL; + uint8_t* data_pdu; + struct rlc_um_tx_data_pdu_struct* rlc_header; + struct rlc_um_tx_pdu_management* pdu_mngt; + struct rlc_um_tx_sdu_management* sdu_mngt; uint16_t pdu_remaining_size; uint16_t sdu_available_size; - pdu = NULL; sdu = NULL; // dispatch sdus while ((pdu = remove_up_head (pdusP))) { - - pdu_mngt = (struct rlc_um_tx_pdu_management *) (pdu->data); - rlc_header = (struct rlc_um_tx_data_pdu_struct *) (pdu_mngt->first_byte); - + pdu_mngt = (struct rlc_um_tx_pdu_management*) (pdu->data); + rlc_header = (struct rlc_um_tx_data_pdu_struct*) (pdu_mngt->first_byte); pdu_remaining_size = pdu_mngt->data_size; - data_pdu = (uint8_t *) pdu_mngt->payload; + data_pdu = (uint8_t*) pdu_mngt->payload; #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA msg ("[RLC_UM %p] SEGMENT FILL GET PDU %p REMAINING SIZE=%d\n", rlcP, pdu, pdu_remaining_size); #endif @@ -246,7 +240,7 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_up * pdusP, list_up * segment while (pdu) { if (sdu == NULL) { sdu = remove_up_head (segmented_sdusP); - sdu_mngt = (struct rlc_um_tx_sdu_management *) (sdu->data); + sdu_mngt = (struct rlc_um_tx_sdu_management*) (sdu->data); data_sdu = &sdu->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt->sdu_segmented_size]; sdu_available_size = sdu_mngt->sdu_size - sdu_mngt->sdu_remaining_size - sdu_mngt->sdu_segmented_size; #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA @@ -259,26 +253,27 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_up * pdusP, list_up * segment if (pdu_remaining_size >= sdu_available_size) { memcpy (data_pdu, data_sdu, sdu_available_size); #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA - msg ("[RLC_UM %p] SEGMENT FILL PDU %p WITH SDU %p %p <- %p %d bytes (SZ %d REMAIN_SZ %d SEGMENT_SZ %d)\n", rlcP, pdu, sdu, data_pdu, data_sdu, sdu_available_size, + msg ("[RLC_UM %p] SEGMENT FILL PDU %p WITH SDU %p %p <- %p %d bytes (SZ %d REMAIN_SZ %d SEGMENT_SZ %d)\n", rlcP, pdu, sdu, data_pdu, data_sdu, + sdu_available_size, sdu_mngt->sdu_size, sdu_mngt->sdu_remaining_size, sdu_mngt->sdu_segmented_size); #endif pdu_remaining_size -= sdu_available_size; sdu_mngt->sdu_segmented_size += sdu_available_size; - data_pdu = (uint8_t *) ((uint32_t) data_pdu + sdu_available_size); + data_pdu = (uint8_t*) ((uint32_t) data_pdu + sdu_available_size); sdu_available_size = 0; - // dispatch the sdu free_mem_block (sdu); sdu = NULL; // dispatch the pdu if (pdu_remaining_size == 0) { - ((struct mac_tb_req *) (pdu->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &rlc_header->byte1; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; + ((struct mac_tb_req*) (pdu->data))->rlc = NULL; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &rlc_header->byte1; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; add_cnt_up_tail (pdu, &rlcP->pdus_to_mac_layer); pdu = NULL; + } else { } @@ -286,28 +281,30 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_up * pdusP, list_up * segment } else { memcpy (data_pdu, data_sdu, pdu_remaining_size); #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA - msg ("[RLC_UM %p] SEGMENT FILL PDU %p WITH SDU %p %p <- %p %d bytes (SZ %d REMAIN_SZ %d SEGMENT_SZ %d)\n", rlcP, pdu, sdu, data_pdu, data_sdu, pdu_remaining_size, + msg ("[RLC_UM %p] SEGMENT FILL PDU %p WITH SDU %p %p <- %p %d bytes (SZ %d REMAIN_SZ %d SEGMENT_SZ %d)\n", rlcP, pdu, sdu, data_pdu, data_sdu, + pdu_remaining_size, sdu_mngt->sdu_size, sdu_mngt->sdu_remaining_size, sdu_mngt->sdu_segmented_size); #endif sdu_mngt->sdu_segmented_size += pdu_remaining_size; sdu_available_size -= pdu_remaining_size; - data_sdu = (uint8_t *) ((uint32_t) data_sdu + (uint32_t) pdu_remaining_size); + data_sdu = (uint8_t*) ((uint32_t) data_sdu + (uint32_t) pdu_remaining_size); // dispatch the pdu - ((struct mac_tb_req *) (pdu->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &rlc_header->byte1; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; + ((struct mac_tb_req*) (pdu->data))->rlc = NULL; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &rlc_header->byte1; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; add_cnt_up_tail (pdu, &rlcP->pdus_to_mac_layer); pdu = NULL; pdu_remaining_size = 0; } } + } else { // end if pdu_remaining_size > 0 if (pdu) { - ((struct mac_tb_req *) (pdu->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &rlc_header->byte1; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; + ((struct mac_tb_req*) (pdu->data))->rlc = NULL; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &rlc_header->byte1; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; add_cnt_up_tail (pdu, &rlcP->pdus_to_mac_layer); pdu = NULL; } @@ -319,26 +316,22 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_up * pdusP, list_up * segment //----------------------------------------------------------------------------- void -rlc_um_segment_15 (struct rlc_um_entity *rlcP) +rlc_um_segment_15 (struct rlc_um_entity* rlcP) { //----------------------------------------------------------------------------- - list_up segmented_sdus; // the copying of sdu data is done after identification of all LIs to put in pdu list_up pdus; - - struct rlc_um_tx_sdu_management *sdu_mngt; - struct rlc_um_tx_pdu_management *pdu_mngt; - struct rlc_um_tx_data_pdu_struct *rlc_header; - mem_block *pdu; - mem_block *sdu_copy; + struct rlc_um_tx_sdu_management* sdu_mngt; + struct rlc_um_tx_pdu_management* pdu_mngt; + struct rlc_um_tx_data_pdu_struct* rlc_header; + mem_block* pdu; + mem_block* sdu_copy; int16_t pdu_remaining_size; uint16_t li[RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU]; uint8_t discard_go_on = 1; uint8_t li_index = 0; uint8_t nb_pdu_to_transmit = rlcP->nb_pdu_requested_by_mac; - pdu = NULL; - init_up (&segmented_sdus, NULL); // param string identifying the list is NULL init_up (&pdus, NULL); // param string identifying the list is NULL @@ -357,9 +350,10 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) discard_go_on = 1; while ((rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) { - if ((*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= rlcP->timer_discard_init) { + if ((*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= + rlcP->timer_discard_init) { PRINT_RLC_UM_DISCARD_SDU ("[RLC_UM %p] SDU DISCARDED : TIMED OUT %d ms\n", rlcP, - *rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time); + *rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time); free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; #ifdef DEBUG_RLC_UM_VT_US @@ -369,6 +363,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) rlcP->li_one_byte_short_to_add_in_next_pdu = 0; rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + } else { discard_go_on = 0; } @@ -376,8 +371,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) } while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (nb_pdu_to_transmit > 0)) { - - sdu_mngt = ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); + sdu_mngt = ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); // pdu management if (!pdu) { @@ -388,10 +382,10 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) li_index = 0; pdu_remaining_size = rlcP->data_pdu_size - 2; // 2= size of header, minimum - pdu_mngt = (struct rlc_um_tx_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_um_tx_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_um_tx_pdu_management)); pdu_mngt->first_byte = &pdu->data[sizeof (struct rlc_um_tx_data_pdu_management)]; - rlc_header = (struct rlc_um_tx_data_pdu_struct *) (pdu_mngt->first_byte); + rlc_header = (struct rlc_um_tx_data_pdu_struct*) (pdu_mngt->first_byte); // management of previous pdu // In the case where 15-bit "Length Indicators" are used for the previous PDU and the last segment @@ -416,6 +410,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) li[li_index++] = RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU; pdu_remaining_size -= 2; } + } else if (rlcP->li_exactly_filled_to_add_in_next_pdu) { li[li_index++] = RLC_LI_LAST_PDU_EXACTLY_FILLED; rlcP->li_exactly_filled_to_add_in_next_pdu = 0; @@ -430,7 +425,6 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) < 0) { pdu_mngt->data_size += pdu_remaining_size; - rlc_um_encode_pdu_15 (rlcP, rlc_header, pdu_mngt, li, li_index); add_up_tail (pdu, &pdus); rlcP->li_length_15_was_used_for_previous_pdu = 1; @@ -438,14 +432,12 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) nb_pdu_to_transmit -= 1; sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; sdu_mngt->use_special_li = 0; // this field is not active when the sdu does not start at the begining of a pdu - } else { + } else { if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) >= 2) { - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size - 2; // size of li length pdu_mngt->data_size += sdu_mngt->sdu_remaining_size; li[li_index++] = sdu_mngt->sdu_remaining_size << 1; - sdu_mngt->sdu_remaining_size = 0; add_up_tail (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; @@ -461,16 +453,15 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) rlcP->li_length_15_was_used_for_previous_pdu = 1; pdu = NULL; nb_pdu_to_transmit -= 1; + } else { if (pdu_remaining_size == 0) { rlc_um_encode_pdu_15 (rlcP, rlc_header, pdu_mngt, li, li_index); add_up_tail (pdu, &pdus); pdu = NULL; nb_pdu_to_transmit -= 1; - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->li_length_15_was_used_for_previous_pdu = 1; - // In the case where 15-bit "Length Indicators" are used for the previous PDU and the last segment // of an RLC SDU is one octet short of exactly filling the PDU: // - if a 15-bit "Length Indicator" is used for the following PDU: @@ -480,6 +471,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) // - in case this SDU was the last one to be transmitted: // - a RLC PDU consisting of an RLC Header with "Length Indicator" "111 1111 1111 1011" followed by a padding // "Length Indicator" and padding may be transmitted; + } else if (pdu_remaining_size == 1) { // one byte remaining rlc_um_encode_pdu_15 (rlcP, rlc_header, pdu_mngt, li, li_index); add_up_tail (pdu, &pdus); @@ -494,6 +486,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) /* } else { // else:if (!last_sdu) } // the while loop continue with the same pdu */ + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 0) { // from 3GPP TS 25.322 V4.2.0 //In the case where the end of the last segment of an RLC SDU exactly ends at the end of a PDU and there is @@ -507,16 +500,15 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) add_up_tail (pdu, &pdus); pdu = NULL; nb_pdu_to_transmit -= 1; - sdu_mngt->sdu_remaining_size = 0; add_up_tail (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; rlcP->buffer_occupancy -= sdu_mngt->sdu_size; rlcP->nb_sdu -= 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->li_length_15_was_used_for_previous_pdu = 1; + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 1) { // one byte remaining // from 3GPP TS 25.322 V4.2.0 // In the case where a PDU contains a 15-bit "Length Indicator" indicating that an RLC SDU ends with @@ -524,7 +516,6 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) // - be padded by the Sender and ignored by the Receiver though there is no "Length Indicator" // indicating the existence of Padding; and // - not be filled with the first octet of the next RLC SDU data. - // In the case where 15-bit "Length Indicators" are used for the previous PDU and the last segment // of an RLC SDU is one octet short of exactly filling the PDU: // - if a 15-bit "Length Indicator" is used for the following PDU: @@ -539,14 +530,12 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) add_up_tail (pdu, &pdus); pdu = NULL; nb_pdu_to_transmit -= 1; - sdu_mngt->sdu_remaining_size = 0; add_up_tail (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; rlcP->buffer_occupancy -= sdu_mngt->sdu_size; rlcP->nb_sdu -= 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; - rlcP->li_one_byte_short_to_add_in_next_pdu = 1; rlcP->li_length_15_was_used_for_previous_pdu = 1; } @@ -558,6 +547,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) pdu = rlc_um_build_pdu_with_only_2li (rlcP, RLC_LI_LAST_PDU_ONE_BYTE_SHORT, RLC_LI_PDU_PADDING); add_up_tail (pdu, &pdus); rlcP->li_one_byte_short_to_add_in_next_pdu = 0; + } else if (rlcP->li_exactly_filled_to_add_in_next_pdu) { pdu = rlc_um_build_pdu_with_only_2li (rlcP, RLC_LI_LAST_PDU_EXACTLY_FILLED, RLC_LI_PDU_PADDING); add_up_tail (pdu, &pdus); @@ -572,7 +562,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) if ((sdu_mngt)) { if (sdu_mngt->sdu_remaining_size > 0) { sdu_copy = get_free_copy_mem_block (); - sdu_copy->data = (uint8_t *) sdu_mngt; + sdu_copy->data = (uint8_t*) sdu_mngt; add_up_tail (sdu_copy, &segmented_sdus); } @@ -582,26 +572,22 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_um_segment_7 (struct rlc_um_entity *rlcP) +rlc_um_segment_7 (struct rlc_um_entity* rlcP) { //----------------------------------------------------------------------------- - list_up segmented_sdus; // the copying of sdu data is done after identification of all LIs to put in pdu list_up pdus; - - struct rlc_um_tx_sdu_management *sdu_mngt = NULL; - struct rlc_um_tx_pdu_management *pdu_mngt; - struct rlc_um_tx_data_pdu_struct *rlc_header; - mem_block *pdu; - mem_block *sdu_copy; + struct rlc_um_tx_sdu_management* sdu_mngt = NULL; + struct rlc_um_tx_pdu_management* pdu_mngt; + struct rlc_um_tx_data_pdu_struct* rlc_header; + mem_block* pdu; + mem_block* sdu_copy; int16_t pdu_remaining_size; uint16_t li[RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU]; uint8_t discard_go_on = 1; uint8_t li_index = 0; uint8_t nb_pdu_to_transmit = rlcP->nb_pdu_requested_by_mac; - pdu = NULL; - init_up (&segmented_sdus, NULL); // param string identifying the list is NULL init_up (&pdus, NULL); // param string identifying the list is NULL @@ -620,11 +606,12 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) discard_go_on = 1; while ((rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) { - if ((*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= rlcP->timer_discard_init) { + if ((*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= + rlcP->timer_discard_init) { PRINT_RLC_UM_DISCARD_SDU ("[RLC_UM %p] SDU DISCARDED TIMED OUT %ld ms ", rlcP, - (*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time)); + (*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time)); PRINT_RLC_UM_DISCARD_SDU ("BO %d, NB SDU %d\n", rlcP->buffer_occupancy, rlcP->nb_sdu); - rlcP->buffer_occupancy -= ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_remaining_size; + rlcP->buffer_occupancy -= ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_remaining_size; rlcP->nb_sdu -= 1; free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; @@ -635,6 +622,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) rlcP->li_one_byte_short_to_add_in_next_pdu = 0; rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + } else { discard_go_on = 0; } @@ -642,8 +630,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) } while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (nb_pdu_to_transmit > 0)) { - - sdu_mngt = ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); + sdu_mngt = ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); PRINT_RLC_UM_SEGMENT ("[RLC_UM %p] SEGMENT GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", rlcP, sdu_mngt, sdu_mngt->sdu_remaining_size); // pdu management @@ -655,11 +642,10 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) li_index = 0; pdu_remaining_size = rlcP->data_pdu_size - 1; // 1= size of header, minimum - pdu_mngt = (struct rlc_um_tx_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_um_tx_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_um_tx_pdu_management)); pdu_mngt->first_byte = &pdu->data[sizeof (struct rlc_um_tx_data_pdu_management)]; - rlc_header = (struct rlc_um_tx_data_pdu_struct *) (pdu_mngt->first_byte); - + rlc_header = (struct rlc_um_tx_data_pdu_struct*) (pdu_mngt->first_byte); PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7] CONSTRUCT NEW PDU\n", rlcP); // management of previous pdu @@ -686,6 +672,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) pdu_remaining_size -= 1; sdu_mngt->use_special_li = 0; // this field is not active when the sdu does not start at the begining of a pdu } + } else if (rlcP->li_one_byte_short_to_add_in_next_pdu) { li[li_index++] = RLC_LI_LAST_PDU_ONE_BYTE_SHORT; rlcP->li_one_byte_short_to_add_in_next_pdu = 0; @@ -709,24 +696,22 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) < 0) { pdu_mngt->data_size += pdu_remaining_size; - rlcP->buffer_occupancy -= pdu_remaining_size; rlc_um_encode_pdu_7 (rlcP, rlc_header, pdu_mngt, li, li_index); add_up_tail (pdu, &pdus); rlcP->li_length_15_was_used_for_previous_pdu = 0; - PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @0\n", rlcP, pdu, pdu_mngt->data_size, sdu_mngt->sdu_remaining_size); + PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @0\n", rlcP, pdu, pdu_mngt->data_size, + sdu_mngt->sdu_remaining_size); pdu = NULL; nb_pdu_to_transmit -= 1; sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; sdu_mngt->use_special_li = 0; // this field is not active when the sdu does not start at the begining of a pdu - } else { + } else { if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) >= 1) { - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size - 1; // size of li length pdu_mngt->data_size += sdu_mngt->sdu_remaining_size; li[li_index++] = sdu_mngt->sdu_remaining_size << 1; - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; sdu_mngt->sdu_remaining_size = 0; add_up_tail (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); @@ -739,18 +724,20 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) li[li_index++] = RLC_LI_PDU_PADDING; rlc_um_encode_pdu_7 (rlcP, rlc_header, pdu_mngt, li, li_index); add_up_tail (pdu, &pdus); - PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @1\n", rlcP, pdu, pdu_mngt->data_size, sdu_mngt->sdu_remaining_size); + PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @1\n", rlcP, pdu, pdu_mngt->data_size, + sdu_mngt->sdu_remaining_size); rlcP->li_length_15_was_used_for_previous_pdu = 0; pdu = NULL; nb_pdu_to_transmit -= 1; + } else { if (pdu_remaining_size == 0) { rlc_um_encode_pdu_7 (rlcP, rlc_header, pdu_mngt, li, li_index); add_up_tail (pdu, &pdus); - PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7]PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @2\n", rlcP, pdu, pdu_mngt->data_size, sdu_mngt->sdu_remaining_size); + PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7]PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @2\n", rlcP, pdu, pdu_mngt->data_size, + sdu_mngt->sdu_remaining_size); pdu = NULL; nb_pdu_to_transmit -= 1; - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->li_length_15_was_used_for_previous_pdu = 0; } @@ -760,6 +747,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) /* } else { // else:if (!last_sdu) } // the while loop continue with the same pdu */ + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 0) { // from 3GPP TS 25.322 V4.2.0 //In the case where the end of the last segment of an RLC SDU exactly ends at the end of a PDU and there is @@ -771,18 +759,16 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) pdu_mngt->data_size += pdu_remaining_size; rlc_um_encode_pdu_7 (rlcP, rlc_header, pdu_mngt, li, li_index); add_up_tail (pdu, &pdus); - PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @3\n", rlcP, pdu, pdu_mngt->data_size, sdu_mngt->sdu_remaining_size); + PRINT_RLC_UM_SEGMENT ("[RLC_UM %p][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @3\n", rlcP, pdu, pdu_mngt->data_size, + sdu_mngt->sdu_remaining_size); pdu = NULL; nb_pdu_to_transmit -= 1; - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; sdu_mngt->sdu_remaining_size = 0; - add_up_tail (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; rlcP->nb_sdu -= 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->li_length_15_was_used_for_previous_pdu = 0; } @@ -794,6 +780,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) pdu = rlc_um_build_pdu_with_only_2li (rlcP, RLC_LI_LAST_PDU_ONE_BYTE_SHORT, RLC_LI_PDU_PADDING); add_up_tail (pdu, &pdus); rlcP->li_one_byte_short_to_add_in_next_pdu = 0; + } else if (rlcP->li_exactly_filled_to_add_in_next_pdu) { pdu = rlc_um_build_pdu_with_only_2li (rlcP, RLC_LI_LAST_PDU_EXACTLY_FILLED, RLC_LI_PDU_PADDING); add_up_tail (pdu, &pdus); @@ -808,7 +795,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) if ((sdu_mngt)) { if (sdu_mngt->sdu_remaining_size > 0) { sdu_copy = get_free_copy_mem_block (); - sdu_copy->data = (uint8_t *) sdu_mngt; + sdu_copy->data = (uint8_t*) sdu_mngt; add_up_tail (sdu_copy, &segmented_sdus); } diff --git a/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um.c b/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um.c index 85caefdc331..82e4a6ad88f 100755 --- a/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um.c @@ -51,17 +51,17 @@ //#define DEBUG_RLC_UM_MAC_DATA_INDICATION //#define DEBUG_RLC_UM_DISCARD_SDU //----------------------------------------------------------------------------- -uint32_t rlc_um_get_buffer_occupancy (struct rlc_um_entity *rlcP); -void rlc_um_get_pdus (void *argP); -void rlc_um_rx (void *argP, struct mac_data_ind data_indP); -struct mac_status_resp rlc_um_mac_status_indication (void *rlcP, uint16_t no_tbP, uint16_t tb_sizeP, struct mac_status_ind +uint32_t rlc_um_get_buffer_occupancy (struct rlc_um_entity* rlcP); +void rlc_um_get_pdus (void* argP); +void rlc_um_rx (void* argP, struct mac_data_ind data_indP); +struct mac_status_resp rlc_um_mac_status_indication (void* rlcP, uint16_t no_tbP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP); -struct mac_data_req rlc_um_mac_data_request (void *rlcP); -void rlc_um_mac_data_indication (void *rlcP, struct mac_data_ind data_indP); -void rlc_um_data_req (void *rlcP, mem_block_t *sduP); +struct mac_data_req rlc_um_mac_data_request (void* rlcP); +void rlc_um_mac_data_indication (void* rlcP, struct mac_data_ind data_indP); +void rlc_um_data_req (void* rlcP, mem_block_t* sduP); //----------------------------------------------------------------------------- void -rlc_um_stat_req (struct rlc_um_entity *rlcP, +rlc_um_stat_req (struct rlc_um_entity* rlcP, unsigned int* tx_pdcp_sdu, unsigned int* tx_pdcp_sdu_discarded, unsigned int* tx_data_pdu, @@ -81,16 +81,18 @@ rlc_um_stat_req (struct rlc_um_entity *rlcP, } //----------------------------------------------------------------------------- uint32_t -rlc_um_get_buffer_occupancy (struct rlc_um_entity *rlcP) +rlc_um_get_buffer_occupancy (struct rlc_um_entity* rlcP) { //----------------------------------------------------------------------------- if (rlcP->buffer_occupancy > 0) { return rlcP->buffer_occupancy; + } else { if ((rlcP->li_one_byte_short_to_add_in_next_pdu) || (rlcP->li_exactly_filled_to_add_in_next_pdu)) { // WARNING LG WE ASSUME TRANSPORT BLOCKS ARE < 125 bytes return 3; // so this is the exact size of the next TB to be sent (SN + 2LIs) + } else { return 0; } @@ -99,13 +101,12 @@ rlc_um_get_buffer_occupancy (struct rlc_um_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_um_get_pdus (void *argP) +rlc_um_get_pdus (void* argP) { //----------------------------------------------------------------------------- - struct rlc_um_entity *rlc = (struct rlc_um_entity *) argP; + struct rlc_um_entity* rlc = (struct rlc_um_entity*) argP; switch (rlc->protocol_state) { - case RLC_NULL_STATE: // from 3GPP TS 25.322 V6.1.0 // In the NULL state the RLC entity does not exist and therefore it is not possible to transfer any data through @@ -131,6 +132,7 @@ rlc_um_get_pdus (void *argP) // SEND DATA TO MAC if (rlc->data_pdu_size > 125) { rlc_um_segment_15 (rlc); + } else { rlc_um_segment_7 (rlc); } @@ -147,7 +149,6 @@ rlc_um_get_pdus (void *argP) // Upon reception of a CRLC-CONFIG-Req from upper layer indicating modification, the RLC entity: // - stays in the LOCAL_SUSPEND state; // - modifies only the protocol parameters and timers as indicated by upper layers. - // TO DO TAKE CARE OF SN : THE IMPLEMENTATION OF THIS FUNCTIONNALITY IS NOT CRITICAL break; @@ -158,14 +159,12 @@ rlc_um_get_pdus (void *argP) //----------------------------------------------------------------------------- void -rlc_um_rx (void *argP, struct mac_data_ind data_indP) +rlc_um_rx (void* argP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - - struct rlc_um_entity *rlc = (struct rlc_um_entity *) argP; + struct rlc_um_entity* rlc = (struct rlc_um_entity*) argP; switch (rlc->protocol_state) { - case RLC_NULL_STATE: // from 3GPP TS 25.322 V4.2.0 // In the NULL state the RLC entity does not exist and therefore it is not possible to transfer any data through @@ -216,97 +215,97 @@ rlc_um_rx (void *argP, struct mac_data_ind data_indP) //----------------------------------------------------------------------------- struct mac_status_resp -rlc_um_mac_status_indication (void *rlcP, uint16_t no_tbP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP) +rlc_um_mac_status_indication (void* rlcP, uint16_t no_tbP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP) { //----------------------------------------------------------------------------- struct mac_status_resp status_resp; if (rlcP) { - ((struct rlc_um_entity *) rlcP)->nb_pdu_requested_by_mac = no_tbP - ((struct rlc_um_entity *) + ((struct rlc_um_entity*) rlcP)->nb_pdu_requested_by_mac = no_tbP - ((struct rlc_um_entity*) rlcP)->pdus_to_mac_layer.nb_elements; //((struct rlc_um_entity *) rlcP)->data_pdu_size = (tb_sizeP + 7) >> 3; - ((struct rlc_um_entity *) rlcP)->data_pdu_size = tb_sizeP >> 3; - ((struct rlc_um_entity *) rlcP)->data_pdu_size_in_bits = tb_sizeP; - + ((struct rlc_um_entity*) rlcP)->data_pdu_size = tb_sizeP >> 3; + ((struct rlc_um_entity*) rlcP)->data_pdu_size_in_bits = tb_sizeP; #ifdef NODE_RG // msg("[RLC_UM_LITE][RB %d] MAC_STATUS_INDICATION data_pdu_size_in_bits = %d\n", ((struct rlc_um_entity *) rlcP)->rb_id, tb_sizeP); #endif - - status_resp.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy ((struct rlc_um_entity *) rlcP); + status_resp.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy ((struct rlc_um_entity*) rlcP); // LG + HA : approximation of num of transport blocks 21/10/2008 if (status_resp.buffer_occupancy_in_bytes == 0 ) { status_resp.buffer_occupancy_in_pdus = 0; - } else if ((status_resp.buffer_occupancy_in_bytes + 1) <= ((struct rlc_um_entity *) rlcP)->data_pdu_size) { + + } else if ((status_resp.buffer_occupancy_in_bytes + 1) <= ((struct rlc_um_entity*) rlcP)->data_pdu_size) { status_resp.buffer_occupancy_in_pdus = 1; + } else { - status_resp.buffer_occupancy_in_pdus = status_resp.buffer_occupancy_in_bytes / (((struct rlc_um_entity *) + status_resp.buffer_occupancy_in_pdus = status_resp.buffer_occupancy_in_bytes / (((struct rlc_um_entity*) rlcP)->data_pdu_size - 1); - if ( ( status_resp.buffer_occupancy_in_bytes % (((struct rlc_um_entity *)rlcP)->data_pdu_size - 1)) > 0 ) { + if ( ( status_resp.buffer_occupancy_in_bytes % (((struct rlc_um_entity*)rlcP)->data_pdu_size - 1)) > 0 ) { status_resp.buffer_occupancy_in_pdus += 1; } } - status_resp.rlc_info.rlc_protocol_state = ((struct rlc_um_entity *) rlcP)->protocol_state; -#ifdef DEBUG_RLC_UM_TX_STATUS + status_resp.rlc_info.rlc_protocol_state = ((struct rlc_um_entity*) rlcP)->protocol_state; +#ifdef TRACE_RLC_UM_TX_STATUS - if (((struct rlc_um_entity *) rlcP)->rb_id > 0) { - msg ("[RLC_UM_LITE][RB %d] MAC_STATUS_INDICATION (DATA) %d TBs -> %d TBs\n", ((struct rlc_um_entity *) rlcP)->rb_id, no_tbP, status_resp.buffer_occupancy_in_pdus); + if (((struct rlc_um_entity*) rlcP)->rb_id > 0) { + msg ("[RLC_UM_LITE][RB %d] MAC_STATUS_INDICATION (DATA) %d TBs -> %d TBs\n", ((struct rlc_um_entity*) rlcP)->rb_id, no_tbP, + status_resp.buffer_occupancy_in_pdus); if ((tx_statusP.tx_status == MAC_TX_STATUS_SUCCESSFUL) && (tx_statusP.no_pdu)) { - msg ("[RLC_UM_LITE][RB %d] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n", ((struct rlc_um_entity *) + msg ("[RLC_UM_LITE][RB %d] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n", ((struct rlc_um_entity*) rlcP)->rb_id, tx_statusP.no_pdu); } if ((tx_statusP.tx_status == MAC_TX_STATUS_UNSUCCESSFUL) && (tx_statusP.no_pdu)) { - msg ("[RLC_UM_LITE][RB %d] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n", ((struct rlc_um_entity *) + msg ("[RLC_UM_LITE][RB %d] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n", ((struct rlc_um_entity*) rlcP)->rb_id, tx_statusP.no_pdu); } } #endif - } else + + } else { msg("[RLC] RLCp not defined!!!\n"); + } return status_resp; } //----------------------------------------------------------------------------- struct mac_data_req -rlc_um_mac_data_request (void *rlcP) +rlc_um_mac_data_request (void* rlcP) { //----------------------------------------------------------------------------- struct mac_data_req data_req; - rlc_um_get_pdus (rlcP); - list_init (&data_req.data, NULL); - list_add_list (&((struct rlc_um_entity *) rlcP)->pdus_to_mac_layer, &data_req.data); + list_add_list (&((struct rlc_um_entity*) rlcP)->pdus_to_mac_layer, &data_req.data); #ifdef DEBUG_RLC_STATS - ((struct rlc_um_entity *) rlcP)->tx_pdus += data_req.data.nb_elements; + ((struct rlc_um_entity*) rlcP)->tx_pdus += data_req.data.nb_elements; #endif - #ifdef DEBUG_RLC_UM_MAC_DATA_REQUEST - if (((struct rlc_um_entity *) rlcP)->rb_id > 10) { + if (((struct rlc_um_entity*) rlcP)->rb_id > 10) { msg ("[RLC_UM_LITE] TTI %d: MAC_DATA_REQUEST %d TBs on RB %d\n", Mac_rlc_xface->frame, data_req.data.nb_elements, - ((struct rlc_um_entity *) rlcP)->rb_id); + ((struct rlc_um_entity*) rlcP)->rb_id); } #endif - data_req.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy ((struct rlc_um_entity *) rlcP); - data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / ((struct rlc_um_entity *) + data_req.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy ((struct rlc_um_entity*) rlcP); + data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / ((struct rlc_um_entity*) rlcP)->data_pdu_size; - data_req.rlc_info.rlc_protocol_state = ((struct rlc_um_entity *) rlcP)->protocol_state; + data_req.rlc_info.rlc_protocol_state = ((struct rlc_um_entity*) rlcP)->protocol_state; return data_req; } //----------------------------------------------------------------------------- void -rlc_um_mac_data_indication (void *rlcP, struct mac_data_ind data_indP) +rlc_um_mac_data_indication (void* rlcP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- rlc_um_rx (rlcP, data_indP); @@ -314,10 +313,10 @@ rlc_um_mac_data_indication (void *rlcP, struct mac_data_ind data_indP) //----------------------------------------------------------------------------- void -rlc_um_data_req (void *rlcP, mem_block_t *sduP) +rlc_um_data_req (void* rlcP, mem_block_t* sduP) { //----------------------------------------------------------------------------- - struct rlc_um_entity *rlc = (struct rlc_um_entity *) rlcP; + struct rlc_um_entity* rlc = (struct rlc_um_entity*) rlcP; uint8_t use_special_li; uint8_t insert_sdu = 0; #ifdef DEBUG_RLC_UM_DISCARD_SDU @@ -327,13 +326,12 @@ rlc_um_data_req (void *rlcP, mem_block_t *sduP) unsigned long int rlc_um_time_us; int min, sec, usec; #endif - #ifdef DEBUG_RLC_UM_DATA_REQUEST if (rlc->rb_id > 10) msg ("[RLC_UM_LITE] TTI %d RLC_UM_DATA_REQ size %d Bytes, rb %d, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", Mac_rlc_xface->frame, - ((struct rlc_um_data_req *) (sduP->data))->data_size, + ((struct rlc_um_data_req*) (sduP->data))->data_size, rlc->rb_id, rlc->buffer_occupancy, rlc->nb_sdu, @@ -352,6 +350,7 @@ rlc_um_data_req (void *rlcP, mem_block_t *sduP) if (rlc->input_sdus[rlc->next_sdu_index] == NULL) { insert_sdu = 1; + } else { // from 3GPP TS 25.322 V4.2.0 // If SDU discard has not been configured for an unacknowledged mode RLC entity, SDUs in the @@ -367,18 +366,19 @@ rlc_um_data_req (void *rlcP, mem_block_t *sduP) msg ("[RLC_UM_LITE][RB %d] SDU DISCARDED : BUFFER OVERFLOW, BO %ld , NB SDU %d\n", rlc->rb_id, rlc->buffer_occupancy, rlc->nb_sdu); #endif - if (((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_remaining_size != - ((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size) { + if (((struct rlc_um_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_remaining_size != + ((struct rlc_um_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size) { #ifdef DEBUG_RLC_UM_VT_US msg ("[RLC_UM_LITE][RB %d] Inc VT(US) in rlc_um_data_req()/discarding SDU\n", rlc->rb_id); #endif rlc->vt_us = (rlc->vt_us + 1) & 0x7F; rlc->li_one_byte_short_to_add_in_next_pdu = 0; rlc->li_exactly_filled_to_add_in_next_pdu = 1; - rlc->buffer_occupancy -= ((struct rlc_um_tx_sdu_management *) + rlc->buffer_occupancy -= ((struct rlc_um_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_remaining_size; + } else { - rlc->buffer_occupancy -= ((struct rlc_um_tx_sdu_management *) + rlc->buffer_occupancy -= ((struct rlc_um_tx_sdu_management*) (rlc->input_sdus[rlc->current_sdu_index]->data))->sdu_size; } @@ -394,10 +394,12 @@ rlc_um_data_req (void *rlcP, mem_block_t *sduP) //msg ("[RLC_UM_LITE][RB %d] BUFFER[%d]=%p\n", rlc->rb_id, index, rlc->input_sdus[index]); //} #endif + } else { #ifdef DEBUG_RLC_UM_DISCARD_SDU msg ("[RLC_UM_LITE][RB %d] DISCARD : BUFFER OVERFLOW ERROR : SHOULD FIND A SDU\n", rlc->rb_id); - msg ("[RLC_UM_LITE][RB %d] size input buffer=%d current_sdu_index=%d next_sdu_index=%d\n", rlc->rb_id, rlc->size_input_sdus_buffer, rlc->current_sdu_index, rlc->next_sdu_index); + msg ("[RLC_UM_LITE][RB %d] size input buffer=%d current_sdu_index=%d next_sdu_index=%d\n", rlc->rb_id, rlc->size_input_sdus_buffer, rlc->current_sdu_index, + rlc->next_sdu_index); for (index = 0; index < rlc->size_input_sdus_buffer; index++) { msg ("[RLC_UM_LITE][rb %d] BUFFER[%d]=%p\n", rlc->rb_id, index, rlc->input_sdus[index]); @@ -411,18 +413,19 @@ rlc_um_data_req (void *rlcP, mem_block_t *sduP) if ((insert_sdu)) { rlc->input_sdus[rlc->next_sdu_index] = sduP; // IMPORTANT : do not change order of affectations - use_special_li = ((struct rlc_um_data_req *) (sduP->data))->use_special_li; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size = ((struct rlc_um_data_req *) (sduP->data))->data_size; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->use_special_li = use_special_li; - rlc->buffer_occupancy += ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size; + use_special_li = ((struct rlc_um_data_req*) (sduP->data))->use_special_li; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_size = ((struct rlc_um_data_req*) (sduP->data))->data_size; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->use_special_li = use_special_li; + rlc->buffer_occupancy += ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_size; rlc->nb_sdu += 1; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->first_byte = &sduP->data[sizeof (struct rlc_um_data_req_alloc)]; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) + ((struct rlc_um_tx_sdu_management*) (sduP->data))->first_byte = &sduP->data[sizeof (struct rlc_um_data_req_alloc)]; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_remaining_size = ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_size; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_segmented_size = 0; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_creation_time = *rlc->frame_tick_milliseconds; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_creation_time = 0; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_segmented_size = 0; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_creation_time = *rlc->frame_tick_milliseconds; + ((struct rlc_um_tx_sdu_management*) (sduP->data))->sdu_creation_time = 0; rlc->next_sdu_index = (rlc->next_sdu_index + 1) % rlc->size_input_sdus_buffer; + } else { // msg("[RLC][UM] Freeing sduP (%p)\n",sduP); free_mem_block (sduP); diff --git a/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_receiver.c b/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_receiver.c index 3fc13cb8b60..9440c3f47af 100755 --- a/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_receiver.c +++ b/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_receiver.c @@ -46,18 +46,18 @@ #include "list.h" #include "rlc_um_reassembly_proto_extern.h" #include "rlc_um_segment_proto_extern.h" -//#define DEBUG_RLC_UM_RX 1 -//#define DEBUG_RLC_UM_RX_DECODE_LI 1 +//#define TRACE_RLC_UM_RX 1 +//#define TRACE_RLC_UM_RX_DECODE_LI 1 //#define DEBUG_RLC_UM_DISPLAY_TB_DATA 1 //#define TEST_EXIT_HICHAM 1 //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void -rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_management *pdu_mngtP, struct - rlc_um_rx_data_pdu_struct *dataP, uint16_t tb_sizeP, uint16_t bad_crc_l1P) +rlc_um_receive_process_pdu (struct rlc_um_entity* rlcP, struct rlc_um_rx_pdu_management* pdu_mngtP, struct + rlc_um_rx_data_pdu_struct* dataP, uint16_t tb_sizeP, uint16_t bad_crc_l1P) { //----------------------------------------------------------------------------- - uint8_t *data_pdu; + uint8_t* data_pdu; int32_t remaining_data_size; uint32_t rlc_um_crc; int nb_li; @@ -65,11 +65,8 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man uint16_t li[RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU]; uint16_t li_synched; uint16_t rlc_crc_to_check; - pdu_mngtP->sn = dataP->byte1 >> 1; - - -#ifdef DEBUG_RLC_UM_RX +#ifdef TRACE_RLC_UM_RX msg ("[RLC_UM_LITE][MOD ID %d][RB %d] RX PDU SN %d VR(US) %d TBsize %d\n", rlcP->module_id, rlcP->rb_id, pdu_mngtP->sn, rlcP->vr_us,tb_sizeP); #endif @@ -78,12 +75,12 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man if (pdu_mngtP->sn == rlcP->vr_us) { li_synched = 1; + } else { // if the sn is not synched, then garbage the previous SDU in construction if any //msg ("[RLC_UM_LITE][RB %d] RX7 OUT OF SYNC -> GARBAGE\n", rlcP->rb_id); rlc_um_clear_rx_sdu (rlcP); li_synched = 0; - //#ifdef TEST_EXIT_HICHAM //#warning TEST_EXIT_HICHAM //#ifdef USER_MODE @@ -91,19 +88,22 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man //#endif //#endif } + } else if ((rlcP->crc_on_header)) { rlc_crc_to_check = 1; if (pdu_mngtP->sn == rlcP->vr_us) { li_synched = 1; + } else { // if the sn is not synched, then garbage the previous SDU in construction if any //msg ("[RLC_UM_LITE][RB %d] RX7 OUT OF SYNC -> GARBAGE\n", rlcP->rb_id); rlc_um_clear_rx_sdu (rlcP); li_synched = 0; } + } else { -#ifdef DEBUG_RLC_UM_RX +#ifdef TRACE_RLC_UM_RX msg ("[RLC_UM_LITE][RB %d] RX7 PDU SN %02X hex??? WITH ERROR INDICATED BY LOWER LAYERS -> GARBAGE\n", rlcP->rb_id, pdu_mngtP->sn); #endif return; @@ -120,22 +120,26 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man rlc_um_crc = rlc_um_crc8_xor (&dataP->byte1, 1); // >> 24; if (rlc_um_crc != dataP->li_data_7[tb_sizeP - 2]) { - msg ("[RLC_UM_LITE][RB %d] BAD CRC ON RLC HEADER 1 byte crc computed %d, crc %d, byte %d \n", rlcP->rb_id, rlc_um_crc, dataP->li_data_7[tb_sizeP - 2], dataP->byte1); + msg ("[RLC_UM_LITE][RB %d] BAD CRC ON RLC HEADER 1 byte crc computed %d, crc %d, byte %d \n", rlcP->rb_id, rlc_um_crc, dataP->li_data_7[tb_sizeP - 2], + dataP->byte1); return; + } else { msg ("[RLC_UM_LITE][RB %d] GOOD CRC ON RLC HEADER 1 byte\n", rlcP->rb_id); } } - rlc_um_reassembly ((uint8_t *) (&dataP->li_data_7[0]), tb_sizeP - 2, rlcP, 0); + rlc_um_reassembly ((uint8_t*) (&dataP->li_data_7[0]), tb_sizeP - 2, rlcP, 0); + } else { - rlc_um_reassembly ((uint8_t *) (&dataP->li_data_7[0]), tb_sizeP - 1, rlcP, 0); + rlc_um_reassembly ((uint8_t*) (&dataP->li_data_7[0]), tb_sizeP - 1, rlcP, 0); } } //--------------------------------- // 1 OR MORE LENGTH INDICATOR IN PDU //--------------------------------- + } else { nb_li = 0; @@ -147,6 +151,7 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man } nb_li++; // count the last li + } else { while ((li[nb_li] = ((((uint16_t) dataP->li_data_7[nb_li << 1]) << 8) + dataP->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { @@ -157,17 +162,17 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man nb_li++; // count the last li } - - //--------------------------------- // CHECK CRC ON RLC UM HEADER //--------------------------------- if ((rlc_crc_to_check)) { if (nb_li > RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { return; // must be corrupted not necessary to check CRC + } else { if (tb_sizeP <= 125) { rlc_um_crc = rlc_um_crc8_xor (&dataP->byte1, nb_li + 1) ; //>> 24; + } else { rlc_um_crc = rlc_um_crc8_xor (&dataP->byte1, (nb_li << 1) + 1); // >> 24; } @@ -175,11 +180,13 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man if (rlc_um_crc != dataP->li_data_7[tb_sizeP - 2]) { msg ("[RLC_UM_LITE][RB %d] BAD CRC ON RLC HEADER %d LI TB size %d\n", rlcP->rb_id, nb_li, tb_sizeP); return; + } else { msg ("[RLC_UM_LITE][RB %d] GOOD CRC ON RLC HEADER %d LI TB size %d\n", rlcP->rb_id, nb_li, tb_sizeP); if (pdu_mngtP->sn == rlcP->vr_us) { li_synched = 1; + } else { // if the sn is not synched, then garbage the previous SDU in construction if any rlc_um_clear_rx_sdu (rlcP); @@ -192,18 +199,21 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man if ((rlcP->crc_on_header)) { if (tb_sizeP <= 125) { remaining_data_size = tb_sizeP - 2 - nb_li; - data_pdu = (uint8_t *) (&dataP->li_data_7[nb_li]); + data_pdu = (uint8_t*) (&dataP->li_data_7[nb_li]); + } else { remaining_data_size = tb_sizeP - 2 - (nb_li << 1); - data_pdu = (uint8_t *) (&dataP->li_data_7[nb_li << 1]); + data_pdu = (uint8_t*) (&dataP->li_data_7[nb_li << 1]); } + } else { if (tb_sizeP <= 125) { remaining_data_size = tb_sizeP - 1 - nb_li; - data_pdu = (uint8_t *) (&dataP->li_data_7[nb_li]); + data_pdu = (uint8_t*) (&dataP->li_data_7[nb_li]); + } else { remaining_data_size = tb_sizeP - 1 - (nb_li << 1); - data_pdu = (uint8_t *) (&dataP->li_data_7[nb_li << 1]); + data_pdu = (uint8_t*) (&dataP->li_data_7[nb_li << 1]); } } @@ -212,7 +222,7 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man while (li_index < nb_li) { switch (li[li_index]) { case (uint8_t) RLC_LI_LAST_PDU_EXACTLY_FILLED: -#ifdef DEBUG_RLC_UM_RX_DECODE_LI +#ifdef TRACE_RLC_UM_RX_DECODE_LI msg ("[RLC_UM_LITE][RB %d] RX_7 PDU %p Li RLC_LI_LAST_PDU_EXACTLY_FILLED\n", rlcP->rb_id, pdu_mngtP); #endif @@ -224,7 +234,7 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man break; case (uint8_t) RLC_LI_LAST_PDU_ONE_BYTE_SHORT: -#ifdef DEBUG_RLC_UM_RX_DECODE_LI +#ifdef TRACE_RLC_UM_RX_DECODE_LI msg ("[RLC_UM_LITE][RB %d] RX_7 PDU %p Li RLC_LI_LAST_PDU_ONE_BYTE_SHORT\n", rlcP->rb_id, pdu_mngtP); #endif @@ -237,14 +247,14 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man case (uint8_t) RLC_LI_PDU_PIGGY_BACKED_STATUS: // ignore for RLC-AM case (uint8_t) RLC_LI_PDU_PADDING: -#ifdef DEBUG_RLC_UM_RX_DECODE_LI +#ifdef TRACE_RLC_UM_RX_DECODE_LI msg ("[RLC_UM_LITE][RB %d] RX_7 PDU %p Li RLC_LI_PDU_PADDING\n", rlcP->rb_id, pdu_mngtP); #endif remaining_data_size = 0; break; case (uint8_t) RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU: -#ifdef DEBUG_RLC_UM_RX_DECODE_LI +#ifdef TRACE_RLC_UM_RX_DECODE_LI msg ("[RLC_UM_LITE][RB %d] RX_7 PDU %p Li RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU\n", rlcP->rb_id, pdu_mngtP); #endif rlc_um_clear_rx_sdu (rlcP); @@ -252,7 +262,7 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man break; default: // li is length -#ifdef DEBUG_RLC_UM_RX_DECODE_LI +#ifdef TRACE_RLC_UM_RX_DECODE_LI msg ("[RLC_UM_LITE][RB %d] RX_7 PDU %p Li LI_SIZE %d Bytes\n", rlcP->rb_id, pdu_mngtP, li[li_index] >> 1); #endif remaining_data_size = remaining_data_size - (li[li_index] >> 1); @@ -263,7 +273,7 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man } li_synched = 1; - data_pdu = (uint8_t *) ((uint32_t) data_pdu + (li[li_index] >> 1)); + data_pdu = (uint8_t*) ((uint32_t) data_pdu + (li[li_index] >> 1)); } li_index++; @@ -280,33 +290,29 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man //----------------------------------------------------------------------------- void -rlc_um_receive (struct rlc_um_entity *rlcP, struct mac_data_ind data_indP) +rlc_um_receive (struct rlc_um_entity* rlcP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - - struct rlc_um_rx_data_pdu_struct *data; - struct rlc_um_rx_pdu_management *pdu_mngt; - mem_block_t *tb; - uint8_t *first_byte; + struct rlc_um_rx_data_pdu_struct* data; + struct rlc_um_rx_pdu_management* pdu_mngt; + mem_block_t* tb; + uint8_t* first_byte; uint8_t tb_size_in_bytes; uint8_t first_bit; uint8_t bits_to_shift; uint8_t bits_to_shift_last_loop; - while ((tb = list_remove_head (&data_indP.data))) { #ifdef DEBUG_RLC_STATS rlcP->rx_pdus += 1; #endif - - #ifdef DEBUG_RLC_UM_DISPLAY_TB_DATA // if (rlcP->rb_id == 4) { // if ((((struct mac_tb_ind *) (tb->data))->error_indication) && (rlcP->crc_on_header)) { msg ("[RLC_UM_LITE][RB %d] DUMP RX PDU:", rlcP->rb_id); for (tb_size_in_bytes = 0; tb_size_in_bytes < data_indP.tb_size; tb_size_in_bytes++) { - msg ("%02X.", ((struct mac_tb_ind *) (tb->data))->data_ptr[tb_size_in_bytes]); + msg ("%02X.", ((struct mac_tb_ind*) (tb->data))->data_ptr[tb_size_in_bytes]); } msg("\n"); @@ -314,17 +320,16 @@ rlc_um_receive (struct rlc_um_entity *rlcP, struct mac_data_ind data_indP) // } #endif - if (!(((struct mac_tb_ind *) (tb->data))->error_indication) || (rlcP->crc_on_header)) { + if (!(((struct mac_tb_ind*) (tb->data))->error_indication) || (rlcP->crc_on_header)) { //msg("YES\n"); //---------------------------------- // align on byte boundary if not //---------------------------------- - first_byte = ((struct mac_tb_ind *) (tb->data))->data_ptr; - pdu_mngt = (struct rlc_um_rx_pdu_management *) (tb->data); - + first_byte = ((struct mac_tb_ind*) (tb->data))->data_ptr; + pdu_mngt = (struct rlc_um_rx_pdu_management*) (tb->data); tb_size_in_bytes = data_indP.tb_size; // msg("[RLC_RECEIVE] RX_size %d\n",data_indP.tb_size); - first_bit = ((struct mac_tb_ind *) (tb->data))->first_bit; + first_bit = ((struct mac_tb_ind*) (tb->data))->first_bit; if (first_bit > 0) { // shift data of transport_block TO CHECK @@ -341,16 +346,15 @@ rlc_um_receive (struct rlc_um_entity *rlcP, struct mac_data_ind data_indP) } pdu_mngt->first_byte = first_byte; - data = (struct rlc_um_rx_data_pdu_struct *) (first_byte); - + data = (struct rlc_um_rx_data_pdu_struct*) (first_byte); + rlc_um_receive_process_pdu (rlcP, pdu_mngt, data, data_indP.tb_size, ((struct mac_tb_ind*) (tb->data))->error_indication); - rlc_um_receive_process_pdu (rlcP, pdu_mngt, data, data_indP.tb_size, ((struct mac_tb_ind *) (tb->data))->error_indication); } else { //msg("NO\n"); #ifdef DEBUG_RLC_STATS rlcP->rx_pdus_in_error += 1; #endif -#ifdef DEBUG_RLC_UM_RX +#ifdef TRACE_RLC_UM_RX msg ("[RLC_UM_LITE][RB %d] RX PDU WITH ERROR INDICATED BY LOWER LAYERS -> GARBAGE\n", rlcP->rb_id); #endif } diff --git a/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_segment.c b/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_segment.c index 9933e2d333f..b1a83b642a1 100755 --- a/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_segment.c +++ b/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_segment.c @@ -197,34 +197,34 @@ //#define DEBUG_RLC_UM_VT_US #ifdef DEBUG_RLC_UM_SEGMENT -# define PRINT_RLC_UM_SEGMENT msg +#define PRINT_RLC_UM_SEGMENT msg #else -# define PRINT_RLC_UM_SEGMENT // +#define PRINT_RLC_UM_SEGMENT // #endif #ifdef DEBUG_RLC_UM_SEGMENT_ENCODE -# define PRINT_RLC_UM_SEGMENT_ENCODE msg +#define PRINT_RLC_UM_SEGMENT_ENCODE msg #else -# define PRINT_RLC_UM_SEGMENT_ENCODE // +#define PRINT_RLC_UM_SEGMENT_ENCODE // #endif #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA -# define PRINT_RLC_UM_SEGMENT_FILL_DATA msg +#define PRINT_RLC_UM_SEGMENT_FILL_DATA msg #else -# define PRINT_RLC_UM_SEGMENT_FILL_DATA // +#define PRINT_RLC_UM_SEGMENT_FILL_DATA // #endif #ifdef DEBUG_RLC_UM_DISCARD_SDU -# define PRINT_RLC_UM_DISCARD_SDU msg +#define PRINT_RLC_UM_DISCARD_SDU msg #else -# define PRINT_RLC_UM_DISCARD_SDU // +#define PRINT_RLC_UM_DISCARD_SDU // #endif //----------------------------------------------------------------------------- uint8_t rlc_um_crc8_xor(char*, signed int); -mem_block_t *rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint16_t li1P); -inline void rlc_um_encode_pdu_7 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struct *rlc_headerP, struct - rlc_um_tx_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP); -inline void rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_t * pdusP, list_t * segmented_sdusP); -void rlc_um_segment_15 (struct rlc_um_entity *rlcP); +mem_block_t* rlc_um_build_pdu_with_only_2li (struct rlc_um_entity* rlcP, uint16_t li0P, uint16_t li1P); +inline void rlc_um_encode_pdu_7 (struct rlc_um_entity* rlcP, struct rlc_um_tx_data_pdu_struct* rlc_headerP, struct + rlc_um_tx_pdu_management* pdu_mngtP, uint16_t* li_arrayP, uint8_t nb_liP); +inline void rlc_um_fill_pdus (struct rlc_um_entity* rlcP, list_t* pdusP, list_t* segmented_sdusP); +void rlc_um_segment_15 (struct rlc_um_entity* rlcP); //----------------------------------------------------------------------------- -uint8_t rlc_um_crc8_xor (char *mem_areaP, signed int num_bytesP) +uint8_t rlc_um_crc8_xor (char* mem_areaP, signed int num_bytesP) { //----------------------------------------------------------------------------- uint8_t crc = 0; @@ -237,13 +237,13 @@ uint8_t rlc_um_crc8_xor (char *mem_areaP, signed int num_bytesP) return crc; } //----------------------------------------------------------------------------- -mem_block_t * -rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint16_t li1P) +mem_block_t* +rlc_um_build_pdu_with_only_2li (struct rlc_um_entity* rlcP, uint16_t li0P, uint16_t li1P) { //----------------------------------------------------------------------------- - struct rlc_um_tx_data_pdu_struct *rlc_header; - struct rlc_um_tx_pdu_management *pdu_mngt; - mem_block_t *pdu; + struct rlc_um_tx_data_pdu_struct* rlc_header; + struct rlc_um_tx_pdu_management* pdu_mngt; + mem_block_t* pdu; uint32_t rlc_um_crc; if (!(pdu = get_free_mem_block (rlcP->data_pdu_size + sizeof (struct rlc_um_tx_data_pdu_management) + GUARD_CRC_LIH_SIZE))) { @@ -254,10 +254,9 @@ rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint1 #ifdef DEBUG_RLC_UM_SEGMENT msg ("[RLC_UM_LITE][RB %d] SEGMENT PDU SN %d SET LIs %04X %04X\n", rlcP->rb_id, rlcP->vt_us, li0P, li1P); #endif - rlc_header = (struct rlc_um_tx_data_pdu_struct *) (&pdu->data[sizeof (struct rlc_um_tx_data_pdu_management)]); - pdu_mngt = (struct rlc_um_tx_pdu_management *) (pdu->data); + rlc_header = (struct rlc_um_tx_data_pdu_struct*) (&pdu->data[sizeof (struct rlc_um_tx_data_pdu_management)]); + pdu_mngt = (struct rlc_um_tx_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_um_tx_pdu_management)); - rlc_header->byte1 = (rlcP->vt_us << 1) | RLC_E_NEXT_FIELD_IS_LI_E; if (rlcP->data_pdu_size > 125) { @@ -274,6 +273,7 @@ rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint1 rlc_um_crc = rlc_um_crc8_xor (&rlc_header->byte1, 5);// * 8); rlc_header->li_data_7[rlcP->data_pdu_size - 2] = (uint8_t) (rlc_um_crc ) ; //>> 24); } + } else { rlc_header->li_data_7[0] = (uint8_t) (li0P | RLC_E_NEXT_FIELD_IS_LI_E); rlc_header->li_data_7[1] = (uint8_t) li1P; @@ -293,22 +293,20 @@ rlc_um_build_pdu_with_only_2li (struct rlc_um_entity *rlcP, uint16_t li0P, uint1 msg ("[RLC_UM_LITE][RB %d] Inc VT(US) in rlc_um_build_pdu_with_only_2li()\n", rlcP->rb_id); #endif rlcP->vt_us = (rlcP->vt_us + 1) & 0x7F; - pdu_mngt->first_byte = (uint8_t *) rlc_header; + pdu_mngt->first_byte = (uint8_t*) rlc_header; pdu_mngt->data_size = 0; pdu_mngt->payload = NULL; - return pdu; } //----------------------------------------------------------------------------- inline void -rlc_um_encode_pdu_15 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struct *rlc_headerP, struct - rlc_um_tx_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP) +rlc_um_encode_pdu_15 (struct rlc_um_entity* rlcP, struct rlc_um_tx_data_pdu_struct* rlc_headerP, struct + rlc_um_tx_pdu_management* pdu_mngtP, uint16_t* li_arrayP, uint8_t nb_liP) { //----------------------------------------------------------------------------- uint8_t li_index; uint32_t rlc_um_crc; - #ifdef DEBUG_RLC_UM_SEGMENT int index; msg ("[RLC_UM_LITE][RB %d] SEGMENT_15 PDU SN %d SET LIs: ", rlcP->rb_id, rlcP->vt_us); @@ -325,9 +323,8 @@ rlc_um_encode_pdu_15 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_stru msg ("[RLC_UM_LITE %p] Inc VT(US) in rlc_um_encode_pdu_15\n", rlcP); #endif rlcP->vt_us = (rlcP->vt_us + 1) & 127; - nb_liP = nb_liP << 1; - pdu_mngtP->payload = (uint8_t *) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); + pdu_mngtP->payload = (uint8_t*) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); if (nb_liP) { rlc_headerP->byte1 |= RLC_E_NEXT_FIELD_IS_LI_E; @@ -351,18 +348,16 @@ rlc_um_encode_pdu_15 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_stru rlc_um_crc = rlc_um_crc8_xor (&rlc_headerP->byte1, (nb_liP + 1));// * 8); rlc_headerP->li_data_7[rlcP->data_pdu_size - 2] = (uint8_t) (rlc_um_crc); // >> 24); } - } //----------------------------------------------------------------------------- inline void -rlc_um_encode_pdu_7 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struct *rlc_headerP, struct - rlc_um_tx_pdu_management *pdu_mngtP, uint16_t * li_arrayP, uint8_t nb_liP) +rlc_um_encode_pdu_7 (struct rlc_um_entity* rlcP, struct rlc_um_tx_data_pdu_struct* rlc_headerP, struct + rlc_um_tx_pdu_management* pdu_mngtP, uint16_t* li_arrayP, uint8_t nb_liP) { //----------------------------------------------------------------------------- uint8_t li_index; uint32_t rlc_um_crc; - #ifdef DEBUG_RLC_UM_SEGMENT_ENCODE int index; msg ("[RLC_UM_LITE][RB %d] SEGMENT_7 PDU %p SN %d SET LIs: ", rlcP->rb_id, pdu_mngtP, rlcP->vt_us); @@ -373,15 +368,13 @@ rlc_um_encode_pdu_7 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struc msg ("\n"); #endif - rlc_headerP->byte1 = (rlcP->vt_us << 1); // inc vt_us #ifdef DEBUG_RLC_UM_VT_US msg ("[RLC_UM_LITE][RB %d] Encode VT(US) %d and Inc VT(US) in rlc_um_encode_pdu_7()\n", rlcP->rb_id, rlcP->vt_us); #endif rlcP->vt_us = (rlcP->vt_us + 1) & 127; - - pdu_mngtP->payload = (uint8_t *) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); + pdu_mngtP->payload = (uint8_t*) ((uint32_t) (&rlc_headerP->li_data_7[nb_liP])); if (nb_liP) { rlc_headerP->byte1 |= RLC_E_NEXT_FIELD_IS_LI_E; @@ -407,35 +400,30 @@ rlc_um_encode_pdu_7 (struct rlc_um_entity *rlcP, struct rlc_um_tx_data_pdu_struc //----------------------------------------------------------------------------- inline void -rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_t * pdusP, list_t * segmented_sdusP) +rlc_um_fill_pdus (struct rlc_um_entity* rlcP, list_t* pdusP, list_t* segmented_sdusP) { //----------------------------------------------------------------------------- - mem_block_t *pdu; - mem_block_t *sdu; - uint8_t *data_sdu = NULL; - uint8_t *data_pdu; - struct rlc_um_tx_data_pdu_struct *rlc_header; - struct rlc_um_tx_pdu_management *pdu_mngt; - struct rlc_um_tx_sdu_management *sdu_mngt; - + mem_block_t* pdu; + mem_block_t* sdu; + uint8_t* data_sdu = NULL; + uint8_t* data_pdu; + struct rlc_um_tx_data_pdu_struct* rlc_header; + struct rlc_um_tx_pdu_management* pdu_mngt; + struct rlc_um_tx_sdu_management* sdu_mngt; uint16_t pdu_remaining_size; uint16_t sdu_available_size; - #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA int tb_size_in_bytes; #endif - pdu = NULL; sdu = NULL; // dispatch sdus while ((pdu = list_remove_head (pdusP))) { - - pdu_mngt = (struct rlc_um_tx_pdu_management *) (pdu->data); - rlc_header = (struct rlc_um_tx_data_pdu_struct *) (pdu_mngt->first_byte); - + pdu_mngt = (struct rlc_um_tx_pdu_management*) (pdu->data); + rlc_header = (struct rlc_um_tx_data_pdu_struct*) (pdu_mngt->first_byte); pdu_remaining_size = pdu_mngt->data_size; - data_pdu = (uint8_t *) pdu_mngt->payload; + data_pdu = (uint8_t*) pdu_mngt->payload; #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA msg ("[RLC_UM_LITE][RB %d] SEGMENT FILL GET PDU %p REMAINING SIZE=%d\n", rlcP->rb_id, pdu, pdu_remaining_size); #endif @@ -445,7 +433,7 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_t * pdusP, list_t * segmented while (pdu) { if (sdu == NULL) { sdu = list_remove_head (segmented_sdusP); - sdu_mngt = (struct rlc_um_tx_sdu_management *) (sdu->data); + sdu_mngt = (struct rlc_um_tx_sdu_management*) (sdu->data); data_sdu = &sdu->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt->sdu_segmented_size]; sdu_available_size = sdu_mngt->sdu_size - sdu_mngt->sdu_remaining_size - sdu_mngt->sdu_segmented_size; #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA @@ -463,30 +451,30 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_t * pdusP, list_t * segmented #endif pdu_remaining_size -= sdu_available_size; sdu_mngt->sdu_segmented_size += sdu_available_size; - data_pdu = (uint8_t *) ((uint32_t) data_pdu + sdu_available_size); + data_pdu = (uint8_t*) ((uint32_t) data_pdu + sdu_available_size); sdu_available_size = 0; - // dispatch the sdu free_mem_block (sdu); sdu = NULL; // dispatch the pdu if (pdu_remaining_size == 0) { - ((struct mac_tb_req *) (pdu->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &rlc_header->byte1; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; + ((struct mac_tb_req*) (pdu->data))->rlc = NULL; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &rlc_header->byte1; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA msg ("[RLC_UM_LITE][RB %d] DUMP TX PDU:", rlcP->rb_id); for (tb_size_in_bytes = 0; tb_size_in_bytes < (rlcP->data_pdu_size_in_bits >> 3); tb_size_in_bytes++) { - msg ("%02X.", (((struct mac_tb_req *) (pdu->data))->data_ptr)[tb_size_in_bytes]); + msg ("%02X.", (((struct mac_tb_req*) (pdu->data))->data_ptr)[tb_size_in_bytes]); } msg("\n"); #endif list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer); pdu = NULL; + } else { } @@ -499,17 +487,17 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_t * pdusP, list_t * segmented #endif sdu_mngt->sdu_segmented_size += pdu_remaining_size; sdu_available_size -= pdu_remaining_size; - data_sdu = (uint8_t *) ((uint32_t) data_sdu + (uint32_t) pdu_remaining_size); + data_sdu = (uint8_t*) ((uint32_t) data_sdu + (uint32_t) pdu_remaining_size); // dispatch the pdu - ((struct mac_tb_req *) (pdu->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &rlc_header->byte1; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; + ((struct mac_tb_req*) (pdu->data))->rlc = NULL; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &rlc_header->byte1; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA msg ("[RLC_UM_LITE][RB %d] DUMP TX PDU:", rlcP->rb_id); for (tb_size_in_bytes = 0; tb_size_in_bytes < (rlcP->data_pdu_size_in_bits >> 3); tb_size_in_bytes++) { - msg ("%02X.", (((struct mac_tb_req *) (pdu->data))->data_ptr)[tb_size_in_bytes]); + msg ("%02X.", (((struct mac_tb_req*) (pdu->data))->data_ptr)[tb_size_in_bytes]); } msg("\n"); @@ -519,17 +507,18 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_t * pdusP, list_t * segmented pdu_remaining_size = 0; } } + } else { // end if pdu_remaining_size > 0 if (pdu) { - ((struct mac_tb_req *) (pdu->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu->data))->data_ptr = &rlc_header->byte1; - ((struct mac_tb_req *) (pdu->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; + ((struct mac_tb_req*) (pdu->data))->rlc = NULL; + ((struct mac_tb_req*) (pdu->data))->data_ptr = &rlc_header->byte1; + ((struct mac_tb_req*) (pdu->data))->first_bit = 0; + ((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->data_pdu_size_in_bits; #ifdef DEBUG_RLC_UM_SEGMENT_FILL_DATA msg ("[RLC_UM_LITE][RB %d] DUMP TX PDU:", rlcP->rb_id); for (tb_size_in_bytes = 0; tb_size_in_bytes < (rlcP->data_pdu_size_in_bits >> 3); tb_size_in_bytes++) { - msg ("%02X.", (((struct mac_tb_req *) (pdu->data))->data_ptr)[tb_size_in_bytes]); + msg ("%02X.", (((struct mac_tb_req*) (pdu->data))->data_ptr)[tb_size_in_bytes]); } msg("\n"); @@ -541,32 +530,27 @@ rlc_um_fill_pdus (struct rlc_um_entity *rlcP, list_t * pdusP, list_t * segmented } list_display (&rlcP->pdus_to_mac_layer); - list_free (segmented_sdusP); } //----------------------------------------------------------------------------- void -rlc_um_segment_15 (struct rlc_um_entity *rlcP) +rlc_um_segment_15 (struct rlc_um_entity* rlcP) { //----------------------------------------------------------------------------- - list_t segmented_sdus; // the copying of sdu data is done after identification of all LIs to put in pdu list_t pdus; - - struct rlc_um_tx_sdu_management *sdu_mngt; - struct rlc_um_tx_pdu_management *pdu_mngt; - struct rlc_um_tx_data_pdu_struct *rlc_header; - mem_block_t *pdu; - mem_block_t *sdu_copy; + struct rlc_um_tx_sdu_management* sdu_mngt; + struct rlc_um_tx_pdu_management* pdu_mngt; + struct rlc_um_tx_data_pdu_struct* rlc_header; + mem_block_t* pdu; + mem_block_t* sdu_copy; int16_t pdu_remaining_size; uint16_t li[RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU]; uint8_t discard_go_on = 1; uint8_t li_index = 0; uint8_t nb_pdu_to_transmit = rlcP->nb_pdu_requested_by_mac; - pdu = NULL; - list_init (&segmented_sdus, NULL); // param string identifying the list is NULL list_init (&pdus, NULL); // param string identifying the list is NULL @@ -580,7 +564,6 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) // When the transmission time exceeds the configured value for a SDU, the Sender shall: // - discard the SDU without explicit signalling (for RLC entities operating in unacknowledged mode // apply subclause 11.2.4.3 for updating the state variables). - // from 3GPP TS 25.322 V6.1.0 page 61 // Upon expiry of the timer Timer_Discard in the Sender, the Sender shall: // - discard the associated SDU; @@ -597,10 +580,10 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) discard_go_on = 1; while ((rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) { - if ((*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management *) + if ((*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= rlcP->timer_discard_init) { #ifdef DEBUG_RLC_UM_DISCARD_SDU - msg ("[RLC_UM_LITE][RB %d] SDU DISCARDED : TIMED OUT %d ms\n", rlcP->rb_id, *rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management *) + msg ("[RLC_UM_LITE][RB %d] SDU DISCARDED : TIMED OUT %d ms\n", rlcP->rb_id, *rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time); #endif free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); @@ -612,6 +595,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) rlcP->li_one_byte_short_to_add_in_next_pdu = 0; rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + } else { discard_go_on = 0; } @@ -619,8 +603,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) } while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (nb_pdu_to_transmit > 0)) { - - sdu_mngt = ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); + sdu_mngt = ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); // pdu management if (!pdu) { @@ -633,14 +616,15 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) if ((rlcP->crc_on_header)) { pdu_remaining_size = rlcP->data_pdu_size - 2; // 4= size of header + size of CRC on RLC header + } else { pdu_remaining_size = rlcP->data_pdu_size - 1; // 2= size of header, minimum = sequence number } - pdu_mngt = (struct rlc_um_tx_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_um_tx_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_um_tx_pdu_management)); pdu_mngt->first_byte = &pdu->data[sizeof (struct rlc_um_tx_data_pdu_management)]; - rlc_header = (struct rlc_um_tx_data_pdu_struct *) (pdu_mngt->first_byte); + rlc_header = (struct rlc_um_tx_data_pdu_struct*) (pdu_mngt->first_byte); // -if the RLC SDU begins in the beginning of the RLC PDU; and // -if the RLC PDU is transmitted in uplink; and @@ -650,7 +634,6 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) // -the "Length Indicator" with value "111 1100" shall be used; // -if 15-bit "Length Indicator" is used: // -the "Length Indicator" with value "111 1111 1111 1100" shall be used. - if ((rlcP->li_length_15_was_used_for_previous_pdu) && (rlcP->li_one_byte_short_to_add_in_next_pdu)) { #ifdef DEBUG_RLC_UM_SEGMENT_LI msg ("[RLC_UM_LITE][RB %d][SEGMENT 15] ADD RLC_LI_LAST_PDU_ONE_BYTE_SHORT\n", rlcP->rb_id); @@ -699,7 +682,6 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) < 0) { pdu_mngt->data_size += pdu_remaining_size; - rlc_um_encode_pdu_15 (rlcP, rlc_header, pdu_mngt, li, li_index); list_add_tail_eurecom (pdu, &pdus); rlcP->li_length_15_was_used_for_previous_pdu = 1; @@ -707,14 +689,12 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) nb_pdu_to_transmit -= 1; sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; sdu_mngt->use_special_li = 0; // this field is not active when the sdu does not start at the begining of a pdu - } else { + } else { if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) >= 2) { - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size - 2; // size of li length pdu_mngt->data_size += sdu_mngt->sdu_remaining_size; li[li_index++] = sdu_mngt->sdu_remaining_size << 1; - sdu_mngt->sdu_remaining_size = 0; list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; @@ -730,16 +710,15 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) rlcP->li_length_15_was_used_for_previous_pdu = 1; pdu = NULL; nb_pdu_to_transmit -= 1; + } else { if (pdu_remaining_size == 0) { rlc_um_encode_pdu_15 (rlcP, rlc_header, pdu_mngt, li, li_index); list_add_tail_eurecom (pdu, &pdus); pdu = NULL; nb_pdu_to_transmit -= 1; - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->li_length_15_was_used_for_previous_pdu = 1; - // In the case where 15-bit "Length Indicators" are used for the previous PDU and the last segment // of an RLC SDU is one octet short of exactly filling the PDU: // - if a 15-bit "Length Indicator" is used for the following PDU: @@ -749,6 +728,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) // - in case this SDU was the last one to be transmitted: // - a RLC PDU consisting of an RLC Header with "Length Indicator" "111 1111 1111 1011" followed by a padding // "Length Indicator" and padding may be transmitted; + } else if (pdu_remaining_size == 1) { // one byte remaining rlc_um_encode_pdu_15 (rlcP, rlc_header, pdu_mngt, li, li_index); list_add_tail_eurecom (pdu, &pdus); @@ -763,6 +743,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) // // } else { // else:if (!last_sdu) // } // the while loop continue with the same pdu + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 0) { // from 3GPP TS 25.322 V6.1.0 //In the case where the end of the last segment of an RLC SDU exactly ends at the end of a PDU and there is @@ -776,16 +757,15 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) list_add_tail_eurecom (pdu, &pdus); pdu = NULL; nb_pdu_to_transmit -= 1; - sdu_mngt->sdu_remaining_size = 0; list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; rlcP->buffer_occupancy -= sdu_mngt->sdu_size; rlcP->nb_sdu -= 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; rlcP->li_length_15_was_used_for_previous_pdu = 1; + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 1) { // one byte remaining // from 3GPP TS 25.322 V6.1.0 // In the case where a PDU contains a 15-bit "Length Indicator" indicating that an RLC SDU ends with @@ -793,7 +773,6 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) // - be padded by the Sender and ignored by the Receiver though there is no "Length Indicator" // indicating the existence of Padding; and // - not be filled with the first octet of the next RLC SDU data. - // In the case where 15-bit "Length Indicators" are used for the previous PDU and the last segment // of an RLC SDU is one octet short of exactly filling the PDU: // - if a 15-bit "Length Indicator" is used for the following PDU: @@ -808,14 +787,12 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) list_add_tail_eurecom (pdu, &pdus); pdu = NULL; nb_pdu_to_transmit -= 1; - sdu_mngt->sdu_remaining_size = 0; list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; rlcP->buffer_occupancy -= sdu_mngt->sdu_size; rlcP->nb_sdu -= 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; - rlcP->li_one_byte_short_to_add_in_next_pdu = 1; rlcP->li_length_15_was_used_for_previous_pdu = 1; } @@ -827,6 +804,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) pdu = rlc_um_build_pdu_with_only_2li (rlcP, RLC_LI_LAST_PDU_ONE_BYTE_SHORT, RLC_LI_PDU_PADDING); list_add_tail_eurecom (pdu, &pdus); rlcP->li_one_byte_short_to_add_in_next_pdu = 0; + } else if (rlcP->li_exactly_filled_to_add_in_next_pdu) { pdu = rlc_um_build_pdu_with_only_2li (rlcP, RLC_LI_LAST_PDU_EXACTLY_FILLED, RLC_LI_PDU_PADDING); list_add_tail_eurecom (pdu, &pdus); @@ -841,7 +819,7 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) if ((sdu_mngt)) { if (sdu_mngt->sdu_remaining_size > 0) { sdu_copy = get_free_copy_mem_block (); - sdu_copy->data = (uint8_t *) sdu_mngt; + sdu_copy->data = (uint8_t*) sdu_mngt; list_add_tail_eurecom (sdu_copy, &segmented_sdus); } @@ -851,27 +829,23 @@ rlc_um_segment_15 (struct rlc_um_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_um_segment_7 (struct rlc_um_entity *rlcP) +rlc_um_segment_7 (struct rlc_um_entity* rlcP) { //----------------------------------------------------------------------------- - list_t segmented_sdus; // the copying of sdu data is done after identification of all LIs to put in pdu list_t pdus; - - struct rlc_um_tx_sdu_management *sdu_mngt = NULL; - struct rlc_um_tx_pdu_management *pdu_mngt; - struct rlc_um_tx_data_pdu_struct *rlc_header; - mem_block_t *pdu; - mem_block_t *sdu_copy; + struct rlc_um_tx_sdu_management* sdu_mngt = NULL; + struct rlc_um_tx_pdu_management* pdu_mngt; + struct rlc_um_tx_data_pdu_struct* rlc_header; + mem_block_t* pdu; + mem_block_t* sdu_copy; int16_t pdu_remaining_size; uint16_t li[RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU]; uint8_t discard_go_on = 1; uint8_t sdu_discarded = 0; uint8_t li_index = 0; uint8_t nb_pdu_to_transmit = rlcP->nb_pdu_requested_by_mac; - pdu = NULL; - list_init (&segmented_sdus, NULL); // param string identifying the list is NULL list_init (&pdus, NULL); // param string identifying the list is NULL @@ -885,7 +859,6 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) // When the transmission time exceeds the configured value for a SDU, the Sender shall: // - discard the SDU without explicit signalling (for RLC entities operating in unacknowledged mode // apply subclause 11.2.4.3 for updating the state variables). - // from 3GPP TS 25.322 V6.1.0 page 61 // Upon expiry of the timer Timer_Discard in the Sender, the Sender shall: // - discard the associated SDU; @@ -902,18 +875,20 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) discard_go_on = 1; while ((rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) { - if ((*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= rlcP->timer_discard_init) { + if ((*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >= + rlcP->timer_discard_init) { #ifdef DEBUG_RLC_UM_DISCARD_SDU msg ("[RLC_UM_LITE %p] SDU DISCARDED TIMED OUT %ld ms ", rlcP, - (*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time)); + (*rlcP->frame_tick_milliseconds - ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time)); msg ("BO %d, NB SDU %d\n", rlcP->buffer_occupancy, rlcP->nb_sdu); #endif - rlcP->buffer_occupancy -= ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_remaining_size; + rlcP->buffer_occupancy -= ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_remaining_size; rlcP->nb_sdu -= 1; free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; sdu_discarded = 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + } else { discard_go_on = 0; } @@ -931,10 +906,8 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) } // DO SEGMENTATION - while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (nb_pdu_to_transmit > 0)) { - - sdu_mngt = ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); + sdu_mngt = ((struct rlc_um_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); #ifdef DEBUG_RLC_UM_SEGMENT msg ("[RLC_UM_LITE][RB %d] SEGMENT GET NEW SDU %p AVAILABLE SIZE %d Bytes crc %d\n", rlcP->rb_id, sdu_mngt, sdu_mngt->sdu_remaining_size, rlcP->crc_on_header); #endif @@ -950,15 +923,15 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) if ((rlcP->crc_on_header)) { pdu_remaining_size = rlcP->data_pdu_size - 2; // 2= minimum size of header + size of CRC on RLC header + } else { pdu_remaining_size = rlcP->data_pdu_size - 1; // 1= minimum size of header = sequence number } - pdu_mngt = (struct rlc_um_tx_pdu_management *) (pdu->data); + pdu_mngt = (struct rlc_um_tx_pdu_management*) (pdu->data); memset (pdu->data, 0, sizeof (struct rlc_um_tx_pdu_management)); pdu_mngt->first_byte = &pdu->data[sizeof (struct rlc_um_tx_data_pdu_management)]; - rlc_header = (struct rlc_um_tx_data_pdu_struct *) (pdu_mngt->first_byte); - + rlc_header = (struct rlc_um_tx_data_pdu_struct*) (pdu_mngt->first_byte); #ifdef DEBUG_RLC_UM_SEGMENT msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] CONSTRUCT NEW PDU\n", rlcP->rb_id); #endif @@ -971,7 +944,6 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) // -the "Length Indicator" with value "111 1100" shall be used; // -if 15-bit "Length Indicator" is used: // -the "Length Indicator" with value "111 1111 1111 1100" shall be used. - if ((rlcP->li_length_15_was_used_for_previous_pdu) && (rlcP->li_one_byte_short_to_add_in_next_pdu)) { #ifdef DEBUG_RLC_UM_SEGMENT_LI msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] ADD RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU\n", rlcP->rb_id); @@ -1021,36 +993,32 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) rlcP->li_one_byte_short_to_add_in_next_pdu = 0; rlcP->li_length_15_was_used_for_previous_pdu = 0; - // SDU fills more than a PDU if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) < 0) { pdu_mngt->data_size += pdu_remaining_size; - rlcP->buffer_occupancy -= pdu_remaining_size; rlc_um_encode_pdu_7 (rlcP, rlc_header, pdu_mngt, li, li_index); list_add_tail_eurecom (pdu, &pdus); //rlcP->li_length_15_was_used_for_previous_pdu = 0; #ifdef DEBUG_RLC_UM_SEGMENT_LI - msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @0\n", rlcP->rb_id, pdu, pdu_mngt->data_size, sdu_mngt->sdu_remaining_size); + msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @0\n", rlcP->rb_id, pdu, pdu_mngt->data_size, + sdu_mngt->sdu_remaining_size); #endif pdu = NULL; nb_pdu_to_transmit -= 1; sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; sdu_mngt->use_special_li = 0; // this field is not active when the sdu does not start at the begining of a pdu - // SDU does not fill a PDU - } else { + } else { // more than one byte left if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) >= 1) { - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size - 1; // size of li length pdu_mngt->data_size += sdu_mngt->sdu_remaining_size; li[li_index++] = sdu_mngt->sdu_remaining_size << 1; #ifdef DEBUG_RLC_UM_SEGMENT_LI msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] ADD LI LENGTH %d\n", rlcP->rb_id, sdu_mngt->sdu_remaining_size); #endif - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; sdu_mngt->sdu_remaining_size = 0; list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); @@ -1067,7 +1035,6 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) // after the end of the last RLC SDU: // -indicate the presence of padding by including a "Length Indicator" with value "111 1111 1111 1111" as the // last "Length Indicator" in the PDU. - if (rlcP->nb_sdu == 0) { if (pdu_remaining_size >= 1) { li[li_index++] = RLC_LI_PDU_PADDING; @@ -1077,20 +1044,22 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) rlc_um_encode_pdu_7 (rlcP, rlc_header, pdu_mngt, li, li_index); list_add_tail_eurecom (pdu, &pdus); #ifdef DEBUG_RLC_UM_SEGMENT - msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @1\n", rlcP->rb_id, pdu, pdu_mngt->data_size, sdu_mngt->sdu_remaining_size); + msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @1\n", rlcP->rb_id, pdu, pdu_mngt->data_size, + sdu_mngt->sdu_remaining_size); #endif pdu = NULL; nb_pdu_to_transmit -= 1; + } else { if (pdu_remaining_size == 0) { rlc_um_encode_pdu_7 (rlcP, rlc_header, pdu_mngt, li, li_index); list_add_tail_eurecom (pdu, &pdus); #ifdef DEBUG_RLC_UM_SEGMENT - msg ("[RLC_UM_LITE][RB %d][SEGMENT 7]PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @2\n", rlcP->rb_id, pdu, pdu_mngt->data_size, sdu_mngt->sdu_remaining_size); + msg ("[RLC_UM_LITE][RB %d][SEGMENT 7]PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @2\n", rlcP->rb_id, pdu, pdu_mngt->data_size, + sdu_mngt->sdu_remaining_size); #endif pdu = NULL; nb_pdu_to_transmit -= 1; - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; } } @@ -1100,6 +1069,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) } else { // else:if (!last_sdu) } // the while loop continue with the same pdu */ // the SDU fills exactly the PDU + } else if ((pdu_remaining_size - sdu_mngt->sdu_remaining_size) == 0) { // from 3GPP TS 25.322 V6.1.0 //In the case where the end of the last segment of an RLC SDU exactly ends at the end of a PDU and there is @@ -1112,19 +1082,17 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) rlc_um_encode_pdu_7 (rlcP, rlc_header, pdu_mngt, li, li_index); list_add_tail_eurecom (pdu, &pdus); #ifdef DEBUG_RLC_UM_SEGMENT - msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @3\n", rlcP->rb_id, pdu, pdu_mngt->data_size, sdu_mngt->sdu_remaining_size); + msg ("[RLC_UM_LITE][RB %d][SEGMENT 7] PDU %p CONSTRUCTED WITH PAYLOAD %d Bytes offset_end_sdu %d @3\n", rlcP->rb_id, pdu, pdu_mngt->data_size, + sdu_mngt->sdu_remaining_size); #endif pdu = NULL; nb_pdu_to_transmit -= 1; - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; sdu_mngt->sdu_remaining_size = 0; - list_add_tail_eurecom (rlcP->input_sdus[rlcP->current_sdu_index], &segmented_sdus); rlcP->input_sdus[rlcP->current_sdu_index] = NULL; rlcP->nb_sdu -= 1; rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; - rlcP->li_exactly_filled_to_add_in_next_pdu = 1; //rlcP->li_length_15_was_used_for_previous_pdu = 0; } @@ -1138,6 +1106,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) pdu = rlc_um_build_pdu_with_only_2li (rlcP, RLC_LI_LAST_PDU_EXACTLY_FILLED, RLC_LI_PDU_PADDING); list_add_tail_eurecom (pdu, &pdus); rlcP->li_one_byte_short_to_add_in_next_pdu = 0; + } else if (rlcP->li_exactly_filled_to_add_in_next_pdu) { pdu = rlc_um_build_pdu_with_only_2li (rlcP, RLC_LI_LAST_PDU_EXACTLY_FILLED, RLC_LI_PDU_PADDING); list_add_tail_eurecom (pdu, &pdus); @@ -1153,7 +1122,7 @@ rlc_um_segment_7 (struct rlc_um_entity *rlcP) if ((sdu_mngt)) { if (sdu_mngt->sdu_remaining_size > 0) { sdu_copy = get_free_copy_mem_block (); - sdu_copy->data = (uint8_t *) sdu_mngt; + sdu_copy->data = (uint8_t*) sdu_mngt; list_add_tail_eurecom (sdu_copy, &segmented_sdus); } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c index 7dad5e9d709..ccf82f3979e 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -43,16 +43,13 @@ #include "mac_primitives.h" #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif #include "rlc_um_very_simple_test.h" -//#define DEBUG_RLC_UM_TX_STATUS 1 - - -#ifdef TRACE_RLC_UM_PDU -char message_string[10000]; -#endif //----------------------------------------------------------------------------- void rlc_um_stat_req (rlc_um_entity_t *rlc_pP, unsigned int* stat_tx_pdcp_sdu, @@ -173,13 +170,8 @@ rlc_um_get_pdus (const protocol_ctxt_t* const ctxt_pP, void *argP) break; default: - LOG_E(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] MAC_DATA_REQ UNKNOWN PROTOCOL STATE %02X hex\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_p->is_data_plane) ? "DRB" : "SRB", - rlc_p->rb_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_DATA_REQ UNKNOWN PROTOCOL STATE %02X hex\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), rlc_p->protocol_state); } } @@ -190,15 +182,19 @@ rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind { //----------------------------------------------------------------------------- rlc_um_entity_t *l_rlc_p = (rlc_um_entity_t *) argP; -#ifdef TRACE_RLC_UM_PDU +#if defined(TRACE_RLC_UM_PDU) || defined(MESSAGE_CHART_GENERATOR) + char message_string[10000]; mem_block_t *tb_p; int16_t tb_size_in_bytes; size_t message_string_size = 0; + rlc_um_pdu_info_t pdu_info; + int index; +#endif +#if defined(TRACE_RLC_UM_PDU) + int octet_index; # if defined(ENABLE_ITTI) MessageDef *msg_p; # endif - rlc_um_pdu_info_t pdu_info; - int octet_index, index; #endif switch (l_rlc_p->protocol_state) { @@ -211,33 +207,45 @@ rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind // establishment, the RLC entity: // - is created; and // - enters the DATA_TRANSFER_READY state. - LOG_N(RLC, "[RLC_UM][MOD %02u/%02u] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", ctxt_pP->enb_module_id, ctxt_pP->ue_module_id); + LOG_N(RLC, PROTOCOL_RLC_UM_CTXT_FMT" ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p)); +#if defined(MESSAGE_CHART_GENERATOR) - /*if (data_indP.data.nb_elements > 0) { - LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_DATA_IND %d TBs\n", l_rlc_p->module_id, l_rlc_p->rb_id, ctxt_pP->frame, data_indP.data.nb_elements); - rlc_p[l_rlc_p->module_id].m_mscgen_trace_length = sprintf(rlc_p[l_rlc_p->module_id].m_mscgen_trace, "[MSC_MSG][FRAME %05d][MAC_%s][MOD %02d][][--- MAC_DATA_IND/ %d TB(s) ", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB":"UE", - l_rlc_p->module_id, - data_indP.data.nb_elements); + if (data_indP.data.nb_elements > 0) { + tb_p = data_indP.data.head; - tb = data_indP.data.head; - while (tb != NULL) { - rlc_p[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length], " SN %d %c%c%c %d Bytes ", - (((struct mac_tb_ind *) (tb->data))->data_ptr[1]) + (((uint16_t)((((struct mac_tb_ind *) (tb->data))->data_ptr[0]) & 0x03)) << 8), - (((struct mac_tb_ind *) (tb->data))->data_ptr[0] & 0x10) ? '}':'{', - (((struct mac_tb_ind *) (tb->data))->data_ptr[0] & 0x08) ? '{':'}', - (((struct mac_tb_ind *) (tb->data))->data_ptr[0] & 0x04) ? 'E':'_', - ((struct mac_tb_ind *) (tb->data))->size); - tb = tb->next; + while (tb_p != NULL) { + tb_size_in_bytes = ((struct mac_tb_ind*) (tb_p->data))->size; + rlc_um_get_pdu_infos(ctxt_pP,l_rlc_p,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_ind*) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); + message_string_size = 0; + message_string_size += sprintf(&message_string[message_string_size], + MSC_AS_TIME_FMT" "PROTOCOL_RLC_UM_MSC_FMT"DATA SN %u size %u FI %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_UM_MSC_ARGS(ctxt_pP, l_rlc_p), + pdu_info.sn, + tb_size_in_bytes, + pdu_info.fi); + + if (pdu_info.e) { + message_string_size += sprintf(&message_string[message_string_size], "| HE:"); + + for (index=0; index < pdu_info.num_li; index++) { + message_string_size += sprintf(&message_string[message_string_size], " LI %u\n", pdu_info.li_list[index]); + } } - rlc_p[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length], " DROPPED RLC NULL STATE ---X][RLC_UM][MOD %02d][RB %02d]\n", - l_rlc_p->module_id, - l_rlc_p->rb_id); - rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length] = 0; - LOG_D(RLC, "%s", rlc_p[l_rlc_p->module_id].m_mscgen_trace); - }*/ + msc_log_rx_discarded_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_UE:MSC_RLC_ENB, + (const char*)pdu_info.payload, + tb_size_in_bytes, + message_string); + + tb_p = tb_p->next; + } + } + +#endif list_free (&data_indP.data); break; @@ -259,24 +267,51 @@ rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind // - enters the LOCAL_SUSPEND state. data_indP.tb_size = data_indP.tb_size >> 3; -#ifdef TRACE_RLC_UM_PDU +#if defined(TRACE_RLC_UM_PDU) || defined(MESSAGE_CHART_GENERATOR) if (data_indP.data.nb_elements > 0) { - LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] MAC_DATA_IND %d TBs\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (l_rlc_p->is_data_plane) ? "DRB" : "SRB", - l_rlc_p->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_DATA_IND %d TBs\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p), data_indP.data.nb_elements); tb_p = data_indP.data.head; while (tb_p != NULL) { tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; + rlc_um_get_pdu_infos(ctxt_pP, + l_rlc_p,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_ind*) (tb_p->data))->data_ptr, + tb_size_in_bytes, + &pdu_info, + l_rlc_p->rx_sn_length); + +#if defined(MESSAGE_CHART_GENERATOR) + message_string_size = 0; + message_string_size += sprintf(&message_string[message_string_size], + MSC_AS_TIME_FMT" "PROTOCOL_RLC_UM_MSC_FMT"DATA SN %u size %u FI %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_UM_MSC_ARGS(ctxt_pP, l_rlc_p), + pdu_info.sn, + tb_size_in_bytes, + pdu_info.fi); + + if (pdu_info.e) { + message_string_size += sprintf(&message_string[message_string_size], "| HE:"); + + for (index=0; index < pdu_info.num_li; index++) { + message_string_size += sprintf(&message_string[message_string_size], " LI %u\n", pdu_info.li_list[index]); + } + } + + msc_log_rx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_UE:MSC_RLC_ENB, + (char*)pdu_info.payload, + tb_size_in_bytes, + message_string); - rlc_um_get_pdu_infos(ctxt_pP->frame,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_ind *) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); +#endif +#if defined(TRACE_RLC_UM_PDU) + message_string_size = 0; message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); @@ -333,15 +368,12 @@ rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind msg_p->ittiMsg.rlc_um_data_pdu_ind.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_um_data_pdu_ind.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); # else LOG_T(RLC, "%s", message_string); -# endif +# endif // defined(ENABLE_ITTI) +#endif // defined(TRACE_RLC_UM_PDU) tb_p = tb_p->next; } @@ -368,13 +400,8 @@ rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind // - stays in the LOCAL_SUSPEND state; // - modifies only the protocol parameters and timers as indicated by // upper layers. - LOG_N(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] RLC_LOCAL_SUSPEND_STATE\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (l_rlc_p->is_data_plane) ? "DRB" : "SRB", - l_rlc_p->rb_id); + LOG_N(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RLC_LOCAL_SUSPEND_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p)); /*if (data_indP.data.nb_elements > 0) { LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_DATA_IND %d TBs\n", l_rlc_p->module_id, l_rlc_p->rb_id, ctxt_pP->frame, data_indP.data.nb_elements); rlc_p[l_rlc_p->module_id].m_mscgen_trace_length = sprintf(rlc_p[l_rlc_p->module_id].m_mscgen_trace, "[MSC_MSG][FRAME %05d][MAC_%s][MOD %02d][][--- MAC_DATA_IND/ %d TB(s) ", @@ -404,13 +431,8 @@ rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind break; default: - LOG_E(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] TX UNKNOWN PROTOCOL STATE %02X hex\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (l_rlc_p->is_data_plane) ? "DRB" : "SRB", - l_rlc_p->rb_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TX UNKNOWN PROTOCOL STATE %02X hex\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p), l_rlc_p->protocol_state); } } @@ -434,9 +456,9 @@ rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP status_resp.head_sdu_is_segmented = 0; if (rlc_pP) { - status_resp.rlc_info.rlc_protocol_state = ((rlc_um_entity_t *) rlc_pP)->protocol_state; rlc_p = (rlc_um_entity_t *) rlc_pP; + status_resp.rlc_info.rlc_protocol_state = rlc_p->protocol_state; rlc_um_check_timer_dar_time_out(ctxt_pP, rlc_p); rlc_p->nb_bytes_requested_by_mac = tbs_sizeP; @@ -469,38 +491,23 @@ rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP //msg("[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_STATUS_INDICATION BO = %d\n", ((rlc_um_entity_t *) rlc_pP)->module_id, ((rlc_um_entity_t *) rlc_pP)->rb_id, status_resp.buffer_occupancy_in_bytes); status_resp.rlc_info.rlc_protocol_state = ((rlc_um_entity_t *) rlc_pP)->protocol_state; -#ifdef DEBUG_RLC_UM_TX_STATUS +#ifdef TRACE_RLC_UM_TX_STATUS if ((((rlc_um_entity_t *) rlc_pP)->rb_id > 0) && (status_resp.buffer_occupancy_in_bytes > 0)) { - LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] MAC_STATUS_INDICATION (DATA) %d bytes requested -> %d bytes available\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_p->is_data_plane) ? "DRB" : "SRB", - rlc_p->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_STATUS_INDICATION (DATA) %d bytes requested -> %d bytes available\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), tbs_sizeP, status_resp.buffer_occupancy_in_bytes); if ((tx_statusP.tx_status == MAC_TX_STATUS_SUCCESSFUL) && (tx_statusP.no_pdu)) { - LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_p->is_data_plane) ? "DRB" : "SRB", - rlc_p->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), tx_statusP.no_pdu); } if ((tx_statusP.tx_status == MAC_TX_STATUS_UNSUCCESSFUL) && (tx_statusP.no_pdu)) { - LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_p->is_data_plane) ? "DRB" : "SRB", - rlc_p->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), tx_statusP.no_pdu); } } @@ -521,7 +528,8 @@ rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP) struct mac_data_req data_req; int16_t tb_size_in_bytes; mem_block_t *tb_p; -#ifdef TRACE_RLC_UM_PDU +#if defined(TRACE_RLC_UM_PDU) || defined(MESSAGE_CHART_GENERATOR) + char message_string[10000]; size_t message_string_size = 0; # if defined(ENABLE_ITTI) MessageDef *msg_p; @@ -531,7 +539,7 @@ rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP) #endif rlc_um_entity_t *l_rlc_p = (rlc_um_entity_t *) rlc_pP; - rlc_um_get_pdus (ctxt_pP, rlc_pP); + rlc_um_get_pdus(ctxt_pP, l_rlc_p); list_init (&data_req.data, NULL); list_add_list (&l_rlc_p->pdus_to_mac_layer, &data_req.data); @@ -551,21 +559,44 @@ rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP) while (tb_p != NULL) { tb_size_in_bytes = ((struct mac_tb_req *) (tb_p->data))->tb_size; - LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] MAC_DATA_REQUEST TB SIZE %u\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (l_rlc_p->is_data_plane) ? "DRB" : "SRB", - l_rlc_p->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_DATA_REQUEST TB SIZE %u\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p), ((struct mac_tb_req *) (tb_p->data))->tb_size); l_rlc_p->stat_tx_data_pdu += 1; l_rlc_p->stat_tx_data_bytes += tb_size_in_bytes; AssertFatal( tb_size_in_bytes > 0 , "RLC UM PDU LENGTH %d", tb_size_in_bytes); +#if defined(TRACE_RLC_UM_PDU) || defined(MESSAGE_CHART_GENERATOR) + rlc_um_get_pdu_infos(ctxt_pP, l_rlc_p,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_req*) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); +#endif +#ifdef MESSAGE_CHART_GENERATOR + message_string_size = 0; + message_string_size += sprintf(&message_string[message_string_size], + MSC_AS_TIME_FMT" "PROTOCOL_RLC_UM_MSC_FMT" DATA SN %u size %u FI %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_UM_MSC_ARGS(ctxt_pP, l_rlc_p), + pdu_info.sn, + tb_size_in_bytes, + pdu_info.fi); + if (pdu_info.e) { + message_string_size += sprintf(&message_string[message_string_size], "|HE:"); + + for (index=0; index < pdu_info.num_li; index++) { + message_string_size += sprintf(&message_string[message_string_size], " LI %u\n", pdu_info.li_list[index]); + } + } + + msc_log_tx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_UE:MSC_RLC_ENB, + (const char*)pdu_info.payload, + pdu_info.payload_size, + message_string); + +#endif #ifdef TRACE_RLC_UM_PDU - rlc_um_get_pdu_infos(ctxt_pP->frame,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); + message_string_size = 0; message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); @@ -622,11 +653,7 @@ rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP) msg_p->ittiMsg.rlc_um_data_pdu_req.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_um_data_pdu_req.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); # else LOG_T(RLC, "%s", message_string); @@ -659,22 +686,19 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t unsigned long int rlc_um_time_us; int min, sec, usec; #endif +#if defined(TRACE_RLC_UM_PDU) #if defined(ENABLE_ITTI) - char message_string[7000]; - size_t message_string_size = 0; MessageDef *msg_p; - int octet_index, index; +# endif uint16_t data_offset; uint16_t data_size; + size_t message_string_size = 0; + int octet_index, index; + char message_string[7000]; #endif - LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][%s %02d] RLC_UM_DATA_REQ size %d Bytes, BO %d , NB SDU %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_p->is_data_plane) ? "DRB" : "SRB", - rlc_p->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RLC_UM_DATA_REQ size %d Bytes, BO %d , NB SDU %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), ((struct rlc_um_data_req *) (sdu_pP->data))->data_size, rlc_p->buffer_occupancy, rlc_p->input_sdus.nb_elements); @@ -696,6 +720,17 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t rlc_p->stat_tx_pdcp_sdu += 1; rlc_p->stat_tx_pdcp_bytes += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size; +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (const char *)((struct rlc_um_tx_sdu_management*) (sdu_pP->data))->first_byte, + ((struct rlc_um_tx_sdu_management*) (sdu_pP->data))->sdu_size, + MSC_AS_TIME_FMT" "PROTOCOL_RLC_UM_MSC_FMT" DATA-REQ size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_UM_MSC_ARGS(ctxt_pP, rlc_p), + ((struct rlc_um_tx_sdu_management*) (sdu_pP->data))->sdu_size); +#endif # if defined(TRACE_RLC_UM_PDU) data_offset = sizeof (struct rlc_um_data_req_alloc); data_size = ((struct rlc_um_tx_sdu_management *)(sdu_pP->data))->sdu_size; @@ -739,11 +774,7 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t msg_p->ittiMsg.rlc_um_sdu_req.size = message_string_size; memcpy(&msg_p->ittiMsg.rlc_um_sdu_req.text, message_string, message_string_size); - if (ctxt_pP->enb_flag) { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->enb_module_id, msg_p); - } else { - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->ue_module_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); #else LOG_T(RLC, "%s", message_string); diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h index a4d33b08a94..07b9fd28f50 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h @@ -74,6 +74,17 @@ //# include "rlc_um_very_simple_test.h" #endif +#define PROTOCOL_RLC_UM_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u] %s()" +#define PROTOCOL_RLC_UM_CTXT_ARGS(CTXT_Pp, rLC_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ + (rLC_Pp->is_data_plane) ? "DRB UM" : "SRB UM",\ + rLC_Pp->rb_id,\ + __FUNCTION__ + +#define PROTOCOL_RLC_UM_MSC_FMT "[%s %02u]" +#define PROTOCOL_RLC_UM_MSC_ARGS(CTXT_Pp, rLC_Pp) \ + CTXT_Pp->rnti,\ + (rLC_Pp->is_data_plane) ? "DRB UM" : "SRB UM",\ + rLC_Pp->rb_id /*! \fn void rlc_um_stat_req (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, unsigned int* stat_tx_pdcp_sdu, diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c index 5bcd048d611..075fad9631e 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c @@ -51,23 +51,18 @@ void config_req_rlc_um ( //----------------------------------------------------------------------------- rlc_union_t *rlc_union_p = NULL; rlc_um_entity_t *rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, rb_idP, srb_flagP); + hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); hashtable_rc_t h_rc; h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { rlc_p = &rlc_union_p->rlc.um; - LOG_D(RLC, "[FRAME %05d][%s][RRC][MOD %u/%u][][--- CONFIG_REQ timer_reordering=%d sn_field_length=%d is_mXch=%d --->][RLC_UM][MOD %u/%u][RB %u] \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ timer_reordering=%d sn_field_length=%d is_mXch=%d RB %u\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), config_um_pP->timer_reordering, config_um_pP->sn_field_length, config_um_pP->is_mXch, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, rb_idP); rlc_um_init(ctxt_pP, rlc_p); @@ -83,18 +78,13 @@ void config_req_rlc_um ( config_um_pP->is_mXch); } } else { - LOG_E(RLC, "[FRAME %05d][%s][RRC][MOD %u/%u][][--- CONFIG_REQ --->][RLC_UM][MOD %u/%u][RB %u] RLC NOT FOUND\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ RB %u RLC UM NOT FOUND\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), rb_idP); } } //----------------------------------------------------------------------------- -const uint32_t t_Reordering_tab[T_Reordering_spare1] = {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200}; +const uint32_t const t_Reordering_tab[T_Reordering_spare1] = {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200}; void config_req_rlc_um_asn1 ( const protocol_ctxt_t* const ctxt_pP, @@ -111,7 +101,7 @@ void config_req_rlc_um_asn1 ( uint32_t t_Reordering = 0; rlc_union_t *rlc_union_p = NULL; rlc_um_entity_t *rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, rb_idP, srb_flagP); + hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); hashtable_rc_t h_rc; #if defined(Rel10) @@ -119,11 +109,11 @@ void config_req_rlc_um_asn1 ( if (mbms_flagP) { AssertFatal(dl_rlc_pP, "No RLC UM DL config"); AssertFatal(ul_rlc_pP == NULL, "RLC UM UL config present"); - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, mbms_service_idP, mbms_session_idP); + key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_service_idP, mbms_session_idP); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); - AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u ue id %i enb flag %u service id %u, session id %u", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u rnti %i enb flag %u service id %u, session id %u", + ctxt_pP->module_id, + ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_service_idP, mbms_session_idP); @@ -131,11 +121,11 @@ void config_req_rlc_um_asn1 ( } else #endif { - key = RLC_COLL_KEY_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, rb_idP, srb_flagP); + key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u ue id %i enb flag %u rb id %u, srb flag %u", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + ctxt_pP->module_id, + ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); @@ -143,14 +133,9 @@ void config_req_rlc_um_asn1 ( } //----------------------------------------------------------------------------- - LOG_D(RLC, "[FRAME %05d][%s][RRC][MOD %u/%u][][--- CONFIG_REQ timer_reordering=%dms sn_field_length= --->][RLC_UM][MOD %u/%u][RB %u] \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ timer_reordering=%dms sn_field_length= RB %u \n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), (dl_rlc_pP && dl_rlc_pP->t_Reordering<31)?t_Reordering_tab[dl_rlc_pP->t_Reordering]:-1, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, rb_idP); rlc_um_init(ctxt_pP, rlc_p); @@ -169,11 +154,8 @@ void config_req_rlc_um_asn1 ( break; default: - LOG_E(RLC,"[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u][CONFIGURE] INVALID Uplink sn_FieldLength %d, RLC NOT CONFIGURED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %u INVALID Uplink sn_FieldLength %d, RLC NOT CONFIGURED\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), rlc_p->rb_id, ul_rlc_pP->sn_FieldLength); return; @@ -191,11 +173,8 @@ void config_req_rlc_um_asn1 ( break; default: - LOG_E(RLC,"[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u][CONFIGURE] INVALID Downlink sn_FieldLength %d, RLC NOT CONFIGURED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %u INVALID Downlink sn_FieldLength %d, RLC NOT CONFIGURED\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), rlc_p->rb_id, dl_rlc_pP->sn_FieldLength); return; @@ -204,11 +183,8 @@ void config_req_rlc_um_asn1 ( if (dl_rlc_pP->t_Reordering<T_Reordering_spare1) { t_Reordering = t_Reordering_tab[dl_rlc_pP->t_Reordering]; } else { - LOG_E(RLC,"[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u][CONFIGURE] INVALID T_Reordering %d, RLC NOT CONFIGURED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %u INVALID T_Reordering %d, RLC NOT CONFIGURED\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), rlc_p->rb_id, dl_rlc_pP->t_Reordering); return; @@ -242,9 +218,11 @@ rlc_um_init ( AssertFatal(rlc_pP, "Bad RLC UM pointer (NULL)"); if (rlc_pP->initialized) { - LOG_D(RLC, "[FRAME XXXXX][RLC_UM][MOD XX][RB XX][INIT] ALREADY DONE, DOING NOTHING\n"); + LOG_D(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [INIT] ALREADY DONE, DOING NOTHING\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); } else { - LOG_D(RLC, "[FRAME XXXXX][RLC_UM][MOD XX][RB XX][INIT] STATE VARIABLES, BUFFERS, LISTS\n"); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [INIT] STATE VARIABLES, BUFFERS, LISTS\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); memset (rlc_pP, 0, sizeof (rlc_um_entity_t)); // TX SIDE list_init (&rlc_pP->pdus_to_mac_layer, NULL); @@ -351,11 +329,8 @@ void rlc_um_configure( rlc_pP->rx_um_window_size = RLC_UM_WINDOW_SIZE_SN_5_BITS; rlc_pP->rx_header_min_length_in_bytes = 1; } else if (rx_sn_field_lengthP != 0) { - LOG_E(RLC, "[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u][CONFIGURE] INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %u INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->rb_id, rx_sn_field_lengthP); return; @@ -372,11 +347,8 @@ void rlc_um_configure( rlc_pP->tx_um_window_size = RLC_UM_WINDOW_SIZE_SN_5_BITS; rlc_pP->tx_header_min_length_in_bytes = 1; } else if (tx_sn_field_lengthP != 0) { - LOG_E(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02d/%02][RB %u][CONFIGURE] INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %u INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->rb_id, tx_sn_field_lengthP); return; @@ -407,11 +379,8 @@ void rlc_um_set_debug_infos( const rb_id_t rb_idP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][SET DEBUG INFOS] enb_module_id %u ue_module_id %u rb_id %d srb_flag %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [SET DEBUG INFOS] rb_id %d srb_flag %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), rb_idP, srb_flagP); rlc_pP->rb_id = rb_idP; diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c index 4fdb5760570..cc7719923b6 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c @@ -45,6 +45,7 @@ //----------------------------------------------------------------------------- signed int rlc_um_get_pdu_infos( const protocol_ctxt_t* const ctxt_pP, + const rlc_um_entity_t* const rlc_pP, rlc_um_pdu_sn_10_t * const header_pP, const sdu_size_t total_sizeP, rlc_um_pdu_info_t * const pdu_info_pP, @@ -103,8 +104,8 @@ signed int rlc_um_get_pdu_infos( } AssertFatal( pdu_info_pP->num_li <= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU, - "[FRAME %05u][RLC_UM][MOD XX][RB XX][GET PDU INFO] SN %04d TOO MANY LIs ", - ctxt_pP->frame, + PROTOCOL_RLC_UM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs ", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), pdu_info_pP->sn); sum_li += pdu_info_pP->li_list[pdu_info_pP->num_li]; @@ -199,22 +200,22 @@ rlc_um_try_reassembly( vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_TRY_REASSEMBLY,VCD_FUNCTION_IN); - if (end_snP < 0) end_snP = end_snP + rlc_pP->rx_sn_modulo; + if (end_snP < 0) { + end_snP = end_snP + rlc_pP->rx_sn_modulo; + } - if (start_snP < 0) start_snP = start_snP + rlc_pP->rx_sn_modulo; + if (start_snP < 0) { + start_snP = start_snP + rlc_pP->rx_sn_modulo; + } #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY FROM PDU SN=%03d+1 TO PDU SN=%03d SN Length = %d bits\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY FROM PDU SN=%03d+1 TO PDU SN=%03d SN Length = %d bits (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->last_reassemblied_sn, end_snP, - rlc_pP->rx_sn_length); + rlc_pP->rx_sn_length, + __FILE__, + __LINE__); #endif // nothing to be reassemblied @@ -234,16 +235,13 @@ rlc_um_try_reassembly( if ((rlc_pP->last_reassemblied_sn+1)%rlc_pP->rx_sn_modulo != sn) { #if defined (TRACE_RLC_UM_DAR) - LOG_W(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u FINDING a HOLE in RLC UM SN: CLEARING OUTPUT SDU BECAUSE NEW SN (%03d) TO REASSEMBLY NOT CONTIGUOUS WITH LAST REASSEMBLIED SN (%03d)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, + LOG_W(RLC, + PROTOCOL_RLC_UM_CTXT_FMT" FINDING a HOLE in RLC UM SN: CLEARING OUTPUT SDU BECAUSE NEW SN (%03d) TO REASSEMBLY NOT CONTIGUOUS WITH LAST REASSEMBLIED SN (%03d) (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn, - rlc_pP->last_reassemblied_sn); + rlc_pP->last_reassemblied_sn, + __FILE__, + __LINE__); #endif rlc_um_clear_rx_sdu(ctxt_pP, rlc_pP); } @@ -253,15 +251,11 @@ rlc_um_try_reassembly( if (rlc_pP->rx_sn_length == 10) { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY 10 PDU SN=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, - sn); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY 10 PDU SN=%03d\n (%s:%u)", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + sn, + __FILE__, + __LINE__); #endif e = (((rlc_um_pdu_sn_10_t*)(tb_ind_p->data_ptr))->b1 & 0x04) >> 2; fi = (((rlc_um_pdu_sn_10_t*)(tb_ind_p->data_ptr))->b1 & 0x18) >> 3; @@ -270,16 +264,12 @@ rlc_um_try_reassembly( data_p = &tb_ind_p->data_ptr[2]; } else { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line TRY REASSEMBLY 5 PDU SN=%03d Byte 0=%02X\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY 5 PDU SN=%03d Byte 0=%02X (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn, - ((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1); + ((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1, + __FILE__, + __LINE__); #endif e = (((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1 & 0x00000020) >> 5; fi = (((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1 & 0x000000C0) >> 6; @@ -287,16 +277,12 @@ rlc_um_try_reassembly( size = tb_ind_p->size - 1; data_p = &tb_ind_p->data_ptr[1]; #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u e=%01X fi=%01X\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" e=%01X fi=%01X\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), e, - fi); + fi, + __FILE__, + __LINE__); #endif } @@ -304,13 +290,9 @@ rlc_um_try_reassembly( switch (fi) { case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=11 (00) (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, __LINE__); #endif // one complete SDU @@ -324,13 +306,9 @@ rlc_um_try_reassembly( case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=10 (01) (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, __LINE__); #endif // one beginning segment of SDU in PDU @@ -342,13 +320,9 @@ rlc_um_try_reassembly( case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=01 (10) (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, __LINE__); #endif @@ -367,13 +341,9 @@ rlc_um_try_reassembly( case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=00 (11) (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, __LINE__); #endif @@ -382,13 +352,9 @@ rlc_um_try_reassembly( rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); } else { #if defined (TRACE_RLC_UM_DAR) - LOG_W(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU NO E_LI FI=00 (11) MISSING SN DETECTED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_W(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=00 (11) MISSING SN DETECTED (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, __LINE__); #endif //LOG_D(RLC, "[MSC_NBOX][FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u][Missing SN detected][RLC_UM][MOD %u/%u][RB %u]\n", @@ -398,40 +364,28 @@ rlc_um_try_reassembly( rlc_pP->stat_rx_data_bytes_dropped += tb_ind_p->size; #if defined(RLC_STOP_ON_LOST_PDU) AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, - "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] MISSING PDU DETECTED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + PROTOCOL_RLC_UM_CTXT_FMT" MISSING PDU DETECTED (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, + __LINE__); #endif } break; default: - AssertFatal( 0 , "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] TRY REASSEMBLY SHOULD NOT GO HERE\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + AssertFatal( 0 , PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY SHOULD NOT GO HERE (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, + __LINE__); } } else { if (rlc_um_read_length_indicators(&data_p, e_li_p, li_array, &num_li, &size ) >= 0) { switch (fi) { case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU FI=11 (00) Li=", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU FI=11 (00) Li=", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); for (i=0; i < num_li; i++) { LOG_D(RLC, "%d ",li_array[i]); @@ -460,14 +414,8 @@ rlc_um_try_reassembly( case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU FI=10 (01) Li=", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU FI=10 (01) Li=", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); for (i=0; i < num_li; i++) { LOG_D(RLC, "%d ",li_array[i]); @@ -495,14 +443,8 @@ rlc_um_try_reassembly( case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU FI=01 (10) Li=", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU FI=01 (10) Li=", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); for (i=0; i < num_li; i++) { LOG_D(RLC, "%d ",li_array[i]); @@ -538,14 +480,8 @@ rlc_um_try_reassembly( case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRY REASSEMBLY PDU FI=00 (11) Li=", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU FI=00 (11) Li=", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); for (i=0; i < num_li; i++) { LOG_D(RLC, "%d ",li_array[i]); @@ -556,15 +492,11 @@ rlc_um_try_reassembly( if (rlc_pP->reassembly_missing_sn_detected) { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u DISCARD FIRST LI %d", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, - li_array[0]); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" DISCARD FIRST LI %d (%s:%u)", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + li_array[0], + __FILE__, + __LINE__); #endif reassembly_start_index = 1; data_p = &data_p[li_array[0]]; @@ -584,13 +516,10 @@ rlc_um_try_reassembly( // data_p is already ok, done by last loop above rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); } else { - AssertFatal( 0 !=0, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] SHOULD NOT GO HERE\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + AssertFatal( 0 !=0, PROTOCOL_RLC_UM_CTXT_FMT" SHOULD NOT GO HERE (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, + __LINE__); //rlc_pP->stat_rx_data_pdu_dropped += 1; rlc_pP->stat_rx_data_bytes_dropped += size; } @@ -600,13 +529,9 @@ rlc_um_try_reassembly( default: #if defined (TRACE_RLC_UM_DAR) - LOG_W(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u Missing SN detected\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_W(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Missing SN detected (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, __LINE__); #endif rlc_pP->stat_rx_data_pdu_dropped += 1; @@ -615,55 +540,41 @@ rlc_um_try_reassembly( rlc_pP->reassembly_missing_sn_detected = 1; #if defined(RLC_STOP_ON_LOST_PDU) AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, - "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] MISSING PDU DETECTED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + PROTOCOL_RLC_UM_CTXT_FMT" MISSING PDU DETECTED (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, + __LINE__); #endif } } } #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u REMOVE PDU FROM DAR BUFFER SN=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, - sn); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" REMOVE PDU FROM DAR BUFFER SN=%03d (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + sn, + __FILE__, + __LINE__); #endif free_mem_block(rlc_pP->dar_buffer[sn]); rlc_pP->dar_buffer[sn] = NULL; } else { rlc_pP->last_reassemblied_missing_sn = sn; #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u Missing SN %04d detected, clearing RX SDU\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, - sn); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Missing SN %04d detected, clearing RX SDU (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + sn, + __FILE__, + __LINE__); #endif rlc_pP->reassembly_missing_sn_detected = 1; rlc_um_clear_rx_sdu(ctxt_pP, rlc_pP); #if defined(RLC_STOP_ON_LOST_PDU) AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, - "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] MISSING PDU DETECTED\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + PROTOCOL_RLC_UM_CTXT_FMT" MISSING PDU DETECTED (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + __FILE__, + __LINE__); #endif } @@ -675,17 +586,13 @@ rlc_um_try_reassembly( } #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] Line %u TRIED REASSEMBLY VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, - __LINE__, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRIED REASSEMBLY VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->vr_ur, rlc_pP->vr_ux, - rlc_pP->vr_uh); + rlc_pP->vr_uh, + __FILE__, + __LINE__); #endif vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_TRY_REASSEMBLY,VCD_FUNCTION_OUT); @@ -698,17 +605,12 @@ rlc_um_stop_and_reset_timer_reordering( //----------------------------------------------------------------------------- { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u][T-REORDERING] STOPPED AND RESET\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [T-REORDERING] STOPPED AND RESET\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); #endif rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.frame_time_out = 0; - rlc_pP->t_reordering.frame_start = 0; + rlc_pP->t_reordering.ms_time_out = 0; + rlc_pP->t_reordering.ms_start = 0; rlc_pP->t_reordering.timed_out = 0; } //----------------------------------------------------------------------------- @@ -718,33 +620,34 @@ rlc_um_start_timer_reordering( rlc_um_entity_t * rlc_pP) //----------------------------------------------------------------------------- { - rlc_pP->t_reordering.running = 1; - rlc_pP->t_reordering.frame_time_out = ctxt_pP->frame + rlc_pP->t_reordering.time_out; - rlc_pP->t_reordering.frame_start = ctxt_pP->frame; rlc_pP->t_reordering.timed_out = 0; + + if (rlc_pP->t_reordering.ms_duration > 0) { + rlc_pP->t_reordering.running = 1; + rlc_pP->t_reordering.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_reordering.ms_duration; + rlc_pP->t_reordering.ms_start = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u][T-REORDERING] STARTED (TIME-OUT = FRAME %05u)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [T-REORDERING] STARTED (TIME-OUT = FRAME %05u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->t_reordering.frame_time_out); #endif + } else { + LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] NOT STARTED, CAUSE CONFIGURED 0 ms\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); + } } //----------------------------------------------------------------------------- void rlc_um_init_timer_reordering( const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, - uint32_t time_outP) + const uint32_t ms_durationP) //----------------------------------------------------------------------------- { rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.frame_time_out = 0; - rlc_pP->t_reordering.frame_start = 0; - rlc_pP->t_reordering.time_out = time_outP; + rlc_pP->t_reordering.ms_time_out = 0; + rlc_pP->t_reordering.ms_start = 0; + rlc_pP->t_reordering.ms_duration = ms_durationP; rlc_pP->t_reordering.timed_out = 0; } //----------------------------------------------------------------------------- @@ -766,16 +669,17 @@ void rlc_um_check_timer_dar_time_out( // | |******************| | // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX - ((rlc_pP->t_reordering.frame_start < rlc_pP->t_reordering.frame_time_out) && - ((ctxt_pP->frame >= rlc_pP->t_reordering.frame_time_out) || - (ctxt_pP->frame < rlc_pP->t_reordering.frame_start))) || + ((rlc_pP->t_reordering.ms_start < rlc_pP->t_reordering.ms_time_out) && + ((PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_reordering.ms_time_out) || + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_reordering.ms_start))) || // CASE 2: time out start // +-----------+------------------+----------+ // |***********| |**********| // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX VALUE - ((rlc_pP->t_reordering.frame_start > rlc_pP->t_reordering.frame_time_out) && - (ctxt_pP->frame < rlc_pP->t_reordering.frame_start) && (ctxt_pP->frame >= rlc_pP->t_reordering.frame_time_out)) + ((rlc_pP->t_reordering.ms_start > rlc_pP->t_reordering.ms_time_out) && + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_reordering.ms_start) && + (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_reordering.ms_time_out)) ) { //if ((uint32_t)((uint32_t)rlc_pP->timer_reordering + (uint32_t)rlc_pP->timer_reordering_init) <= ctxt_pP->frame) { @@ -788,51 +692,21 @@ void rlc_um_check_timer_dar_time_out( // -set VR(UX) to VR(UH). rlc_pP->stat_timer_reordering_timed_out += 1; #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u]*****************************************************\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u]* T I M E - O U T *\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u]*****************************************************\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] TIMER t-Reordering expiration\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] timer_reordering=%d ctxt_pP->frame=%d expire ctxt_pP->frame %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"*****************************************************\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"* T I M E - O U T *\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"*****************************************************\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TIMER t-Reordering expiration\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" timer_reordering=%d frame=%d expire ms %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->t_reordering.time_out, - rlc_pP->t_reordering.frame_time_out, - ctxt_pP->frame); - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] set VR(UR)=%03d to", ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + rlc_pP->t_reordering.ms_time_out); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set VR(UR)=%03d to", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->vr_ur); #endif @@ -857,24 +731,14 @@ void rlc_um_check_timer_dar_time_out( rlc_um_start_timer_reordering(ctxt_pP, rlc_pP); rlc_pP->vr_ux = rlc_pP->vr_uh; #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] restarting t-Reordering set VR(UX) to %d (VR(UH)>VR(UR))\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" restarting t-Reordering set VR(UX) to %d (VR(UH)>VR(UR))\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->vr_ux); #endif } else { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] STOP t-Reordering VR(UX) = %03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" STOP t-Reordering VR(UX) = %03d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->vr_ux); #endif rlc_um_stop_and_reset_timer_reordering(ctxt_pP, rlc_pP); @@ -888,7 +752,7 @@ void rlc_um_check_timer_dar_time_out( vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_CHECK_TIMER_DAR_TIME_OUT,VCD_FUNCTION_OUT); } //----------------------------------------------------------------------------- -inline mem_block_t * +mem_block_t* rlc_um_remove_pdu_from_dar_buffer( const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, @@ -897,26 +761,22 @@ rlc_um_remove_pdu_from_dar_buffer( //----------------------------------------------------------------------------- mem_block_t * pdu_p = rlc_pP->dar_buffer[snP]; #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME ?????][%s][RLC_UM][MOD %u/%u][%s %u] REMOVE PDU FROM DAR BUFFER SN=%03d\n", - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" REMOVE PDU FROM DAR BUFFER SN=%03d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), snP); #endif rlc_pP->dar_buffer[snP] = NULL; return pdu_p; } //----------------------------------------------------------------------------- -inline mem_block_t * +mem_block_t* rlc_um_get_pdu_from_dar_buffer(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, rlc_usn_t snP) { //----------------------------------------------------------------------------- return rlc_pP->dar_buffer[snP]; } //----------------------------------------------------------------------------- -static inline void +void rlc_um_store_pdu_in_dar_buffer( const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, @@ -925,13 +785,8 @@ rlc_um_store_pdu_in_dar_buffer( { //----------------------------------------------------------------------------- #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] STORE PDU IN DAR BUFFER SN=%03d VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" STORE PDU IN DAR BUFFER SN=%03d VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), snP, rlc_pP->vr_ur, rlc_pP->vr_ux, @@ -946,7 +801,7 @@ rlc_um_store_pdu_in_dar_buffer( // returns 1 if lower_bound == sn // returns 2 if higher_bound == sn // returns 3 if higher_bound == sn == lower_bound -inline signed int +signed int rlc_um_in_window( const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, @@ -968,13 +823,8 @@ rlc_um_in_window( if ( lower_boundP > snP) { #ifdef TRACE_RLC_UM_RX - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] %d not in WINDOW[%03d:%03d] (SN<LOWER BOUND)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d not in WINDOW[%03d:%03d] (SN<LOWER BOUND)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn, lower_bound, higher_bound); @@ -984,13 +834,8 @@ rlc_um_in_window( if ( higher_boundP < snP) { #ifdef TRACE_RLC_UM_RX - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] %d not in WINDOW[%03d:%03d] (SN>HIGHER BOUND) <=> %d not in WINDOW[%03d:%03d]\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d not in WINDOW[%03d:%03d] (SN>HIGHER BOUND) <=> %d not in WINDOW[%03d:%03d]\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn, lower_bound, higher_bound, @@ -1004,13 +849,8 @@ rlc_um_in_window( if ( lower_boundP == snP) { if ( higher_boundP == snP) { #ifdef TRACE_RLC_UM_RX - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND=LOWER BOUND)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND=LOWER BOUND)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn, lower_bound, higher_bound); @@ -1019,13 +859,8 @@ rlc_um_in_window( } #ifdef TRACE_RLC_UM_RX - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] %d in WINDOW[%03d:%03d] (SN=LOWER BOUND)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d in WINDOW[%03d:%03d] (SN=LOWER BOUND)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn, lower_bound, higher_bound); @@ -1035,13 +870,8 @@ rlc_um_in_window( if ( higher_boundP == snP) { #ifdef TRACE_RLC_UM_RX - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn, lower_bound, higher_bound); @@ -1053,7 +883,7 @@ rlc_um_in_window( } //----------------------------------------------------------------------------- -inline signed int +signed int rlc_um_in_reordering_window( const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, @@ -1066,13 +896,8 @@ rlc_um_in_reordering_window( if ( 0 <= sn_mod) { if (sn_mod < rlc_pP->rx_um_window_size) { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] %d IN REORDERING WINDOW[%03d:%03d[ SN %d IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d IN REORDERING WINDOW[%03d:%03d[ SN %d IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn_mod, 0, rlc_pP->rx_um_window_size, @@ -1089,13 +914,8 @@ rlc_um_in_reordering_window( #if defined (TRACE_RLC_UM_DAR) if (modulus < 0) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn_mod, modulus + 1024, rlc_pP->rx_um_window_size, @@ -1105,13 +925,8 @@ rlc_um_in_reordering_window( rlc_pP->vr_ur, rlc_pP->vr_uh); } else { - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn_mod, modulus, rlc_pP->rx_um_window_size, @@ -1172,7 +987,7 @@ rlc_um_receive_process_dar ( in_window = rlc_um_in_window(ctxt_pP, rlc_pP, rlc_pP->vr_uh - rlc_pP->rx_um_window_size, sn, rlc_pP->vr_ur); -#if defined(DEBUG_RLC_PAYLOAD) +#if defined(TRACE_RLC_PAYLOAD) rlc_util_print_hex_octets(RLC, &pdu_pP->b1, tb_sizeP); #endif @@ -1184,13 +999,8 @@ rlc_um_receive_process_dar ( // rlc_um_in_window() returns 3 if higher_bound == sn == lower_bound if ((in_window == 1) || (in_window == 0)) { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] RX PDU VR(UH) – UM_Window_Size) <= SN %d < VR(UR) -> GARBAGE\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RX PDU VR(UH) – UM_Window_Size) <= SN %d < VR(UR) -> GARBAGE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn); #endif rlc_pP->stat_rx_data_pdu_out_of_window += 1; @@ -1207,13 +1017,8 @@ rlc_um_receive_process_dar ( if (in_window == 0) { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] RX PDU VR(UR) < SN %d < VR(UH) and RECEIVED BEFORE-> GARBAGE\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RX PDU VR(UR) < SN %d < VR(UH) and RECEIVED BEFORE-> GARBAGE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn); #endif //discard the PDU @@ -1230,13 +1035,8 @@ rlc_um_receive_process_dar ( rlc_pP->stat_rx_data_pdus_duplicate += 1; rlc_pP->stat_rx_data_bytes_duplicate += tb_sizeP; #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] RX PDU SN %03d REMOVE OLD PDU BEFORE STORING NEW PDU\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RX PDU SN %03d REMOVE OLD PDU BEFORE STORING NEW PDU\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn); #endif mem_block_t *pdu = rlc_um_remove_pdu_from_dar_buffer(ctxt_pP, rlc_pP, sn); @@ -1257,13 +1057,8 @@ rlc_um_receive_process_dar ( // -set VR(UR) to (VR(UH) – UM_Window_Size); if (rlc_um_in_reordering_window(ctxt_pP, rlc_pP, sn) < 0) { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] RX PDU SN %d OUTSIDE REORDERING WINDOW VR(UH)=%d UM_Window_Size=%d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RX PDU SN %d OUTSIDE REORDERING WINDOW VR(UH)=%d UM_Window_Size=%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), sn, rlc_pP->vr_uh, rlc_pP->rx_um_window_size); @@ -1283,13 +1078,8 @@ rlc_um_receive_process_dar ( if (rlc_um_in_reordering_window(ctxt_pP, rlc_pP, rlc_pP->vr_ur) < 0) { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] VR(UR) %d OUTSIDE REORDERING WINDOW SET TO VR(UH) – UM_Window_Size = %d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" VR(UR) %d OUTSIDE REORDERING WINDOW SET TO VR(UH) – UM_Window_Size = %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->vr_ur, in_window); #endif @@ -1325,13 +1115,8 @@ rlc_um_receive_process_dar ( if (in_window < 0) { #if defined (TRACE_RLC_UM_DAR) LOG_D(RLC, - "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d -or- VR(UX) <= VR(UR)\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + PROTOCOL_RLC_UM_CTXT_FMT" STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d -or- VR(UX) <= VR(UR)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->vr_ux, rlc_pP->vr_uh); #endif @@ -1345,13 +1130,9 @@ rlc_um_receive_process_dar ( if ((in_window == -2) || (in_window == 1)) { #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, + PROTOCOL_RLC_UM_CTXT_FMT" STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->vr_ux, rlc_pP->vr_uh); #endif @@ -1371,13 +1152,8 @@ rlc_um_receive_process_dar ( rlc_um_start_timer_reordering(ctxt_pP, rlc_pP); rlc_pP->vr_ux = rlc_pP->vr_uh; #if defined (TRACE_RLC_UM_DAR) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] RESTART t-Reordering set VR(UX) to VR(UH) =%d\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RESTART t-Reordering set VR(UX) to VR(UH) =%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->vr_ux); #endif } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h index 5149b0b63ab..b31d803c64c 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h @@ -62,9 +62,10 @@ # define public_rlc_um_dar(x) extern x # endif # endif -/*! \fn signed int rlc_um_get_pdu_infos(const protocol_ctxt_t* const ctxt_pP,rlc_um_pdu_sn_10_t* header_pP, int16_t total_sizeP, rlc_um_pdu_info_t* pdu_info_pP, uint8_t sn_lengthP) +/*! \fn signed int rlc_um_get_pdu_infos(const protocol_ctxt_t* const ctxt_pP,const rlc_um_entity_t * const rlc_pP,rlc_um_pdu_sn_10_t* header_pP, int16_t total_sizeP, rlc_um_pdu_info_t* pdu_info_pP, uint8_t sn_lengthP) * \brief Extract PDU informations (header fields, data size, etc) from the serialized PDU. * \param[in] ctxt_pP Running context. +* \param[in] rlc_pP RLC UM protocol instance pointer.. * \param[in] header_pP RLC UM header PDU pointer. * \param[in] total_sizeP Size of RLC UM PDU. * \param[in] pdu_info_pP Structure containing extracted informations from PDU. @@ -73,6 +74,7 @@ */ protected_rlc_um_dar( signed int rlc_um_get_pdu_infos( const protocol_ctxt_t* const ctxt_pP, + const rlc_um_entity_t * const rlc_pP, rlc_um_pdu_sn_10_t * const header_pP, const sdu_size_t total_sizeP, rlc_um_pdu_info_t * const pdu_info_pP, @@ -123,13 +125,13 @@ protected_rlc_um_dar(void rlc_um_stop_and_reset_timer_reordering(const protocol_ */ protected_rlc_um_dar(void rlc_um_start_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP);) -/*! \fn void rlc_um_init_timer_reordering(rlc_um_entity_t * const rlc_pP, uint32_t time_outP) +/*! \fn void rlc_um_init_timer_reordering(rlc_um_entity_t * const rlc_pP, const uint32_t ms_durationP) * \brief Initialize the timer reordering with RLC UM time-out config parameter. * \param[in] ctxt_pP Running context. * \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] time_outP Time-out in frameP units. +* \param[in] ms_durationP Duration in milliseconds units. */ -protected_rlc_um_dar(void rlc_um_init_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const uint32_t time_outP);) +protected_rlc_um_dar(void rlc_um_init_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const uint32_t ms_durationP);) /*! \fn void rlc_um_check_timer_dar_time_out(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP,) * \brief Check if t-Reordering expires and take the appropriate actions as described in 3GPP specifications. diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h index 1f98473ae63..8aed136494e 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h @@ -46,9 +46,9 @@ # include "rlc_def.h" typedef struct rlc_um_timer_s { - uint32_t frame_time_out;/*!< \brief When set, indicate the frame number the timer will time-out. */ - uint32_t frame_start; /*!< \brief indicate the frame number the timer has been started. */ - uint32_t time_out; /*!< \brief Configured timer duration in frames. */ + uint32_t ms_time_out; /*!< \brief When set, indicate the time the timer will time-out. */ + uint32_t ms_start; /*!< \brief indicate the time the timer has been started. */ + uint32_t ms_duration; /*!< \brief Configured timer duration in frames. */ uint32_t running:1; /*!< \brief The timer is running. */ uint32_t timed_out:1; /*!< \brief The timer has timed-out. */ uint32_t dummy:30; /*!< \brief Bits not used. */ @@ -60,8 +60,6 @@ typedef struct rlc_um_timer_s { */ typedef struct rlc_um_entity_s { - //module_id_t enb_module_id; /*!< \brief eNB Virtualization index for this protocol instance. */ - //module_id_t ue_module_id; /*!< \brief UE Virtualization index for this protocol instance. */ boolean_t initialized; /*!< \brief Boolean for rlc_am_entity_t struct initialization. */ boolean_t is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */ rlc_protocol_state_t protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */ diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c index 8f0571d197d..5e8dd557d8b 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c @@ -39,7 +39,7 @@ //----------------------------------------------------------------------------- int rlc_um_fsm_notify_event ( - const protocol_ctxt_t* const ctxtP, + const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP, uint8_t eventP) { //----------------------------------------------------------------------------- @@ -51,21 +51,15 @@ rlc_um_fsm_notify_event ( case RLC_NULL_STATE: switch (eventP) { case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT: - LOG_D(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_NULL_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_NULL_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; return 1; break; default: - LOG_E(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM NULL_STATE\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM NULL_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), eventP); mac_xface->macphy_exit("RLC-UM FSM WARNING PROTOCOL ERROR - EVENT NOT EXPECTED FROM NULL_STATE"); return 0; @@ -79,32 +73,23 @@ rlc_um_fsm_notify_event ( case RLC_DATA_TRANSFER_READY_STATE: switch (eventP) { case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT: - LOG_D(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_NULL_STATE\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_NULL_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); rlc_pP->protocol_state = RLC_NULL_STATE; return 1; break; case RLC_UM_RECEIVE_CRLC_SUSPEND_REQ_EVENT: case RLC_UM_TRANSMIT_CRLC_SUSPEND_CNF_EVENT: - LOG_N(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_LOCAL_SUSPEND_STATE\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); + LOG_N(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_LOCAL_SUSPEND_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); rlc_pP->protocol_state = RLC_LOCAL_SUSPEND_STATE; return 1; break; default: - LOG_E(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM DATA_TRANSFER_READY_STATE\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM DATA_TRANSFER_READY_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), eventP); return 0; } @@ -117,31 +102,22 @@ rlc_um_fsm_notify_event ( case RLC_LOCAL_SUSPEND_STATE: switch (eventP) { case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT: - LOG_N(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_LOCAL_SUSPEND_STATE -> RLC_NULL_STATE\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); + LOG_N(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_LOCAL_SUSPEND_STATE -> RLC_NULL_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); rlc_pP->protocol_state = RLC_NULL_STATE; return 1; break; case RLC_UM_RECEIVE_CRLC_RESUME_REQ_EVENT: - LOG_N(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_LOCAL_SUSPEND_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); + LOG_N(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_LOCAL_SUSPEND_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; return 1; break; default: - LOG_E(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM RLC_LOCAL_SUSPEND_STATE\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM RLC_LOCAL_SUSPEND_STATE\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), eventP); return 0; } @@ -149,11 +125,8 @@ rlc_um_fsm_notify_event ( break; default: - LOG_E(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM ERROR UNKNOWN STATE %d\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM ERROR UNKNOWN STATE %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), rlc_pP->protocol_state); return 0; } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c index 07e4b6d2f39..737089dd0ac 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c @@ -43,12 +43,15 @@ #include "list.h" #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif //#define TRACE_RLC_UM_DISPLAY_ASCII_DATA 1 //----------------------------------------------------------------------------- inline void -rlc_um_clear_rx_sdu (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) +rlc_um_clear_rx_sdu (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t* rlc_pP) { //----------------------------------------------------------------------------- rlc_pP->output_sdu_size_to_write = 0; @@ -56,18 +59,13 @@ rlc_um_clear_rx_sdu (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP //----------------------------------------------------------------------------- void -rlc_um_reassembly (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP, uint8_t * src_pP, int32_t lengthP) +rlc_um_reassembly (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP, uint8_t * src_pP, int32_t lengthP) { //----------------------------------------------------------------------------- sdu_size_t sdu_max_size; - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u][REASSEMBLY] reassembly() %d bytes %d bytes already reassemblied\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] reassembly() %d bytes %d bytes already reassemblied\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), lengthP, rlc_pP->output_sdu_size_to_write); @@ -94,93 +92,70 @@ rlc_um_reassembly (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP, rlc_pP->output_sdu_size_to_write += lengthP; #ifdef TRACE_RLC_UM_DISPLAY_ASCII_DATA rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write] = 0; - LOG_T(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u][REASSEMBLY] DATA :", - ctxtP->frame - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + LOG_T(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] DATA :", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_util_print_hex_octets(RLC, (unsigned char*)rlc_pP->output_sdu_in_construction->data, rlc_pP->output_sdu_size_to_write); #endif } else { #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - AssertFatal(0, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] RLC_UM_DATA_IND, SDU TOO BIG, DROPPED\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + AssertFatal(0, PROTOCOL_RLC_UM_CTXT_FMT" RLC_UM_DATA_IND, SDU TOO BIG, DROPPED\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif - LOG_E(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u][REASSEMBLY] [max_sdu size %d] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] [max_sdu size %d] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_max_size); // erase SDU rlc_pP->output_sdu_size_to_write = 0; } } else { - LOG_E(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u][REASSEMBLY]ERROR OUTPUT SDU IS NULL\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY]ERROR OUTPUT SDU IS NULL\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - AssertFatal(0, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] RLC_UM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + AssertFatal(0, PROTOCOL_RLC_UM_CTXT_FMT" RLC_UM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif } } //----------------------------------------------------------------------------- void -rlc_um_send_sdu (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) +rlc_um_send_sdu (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) { //----------------------------------------------------------------------------- if ((rlc_pP->output_sdu_in_construction)) { - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] SEND_SDU to upper layers %d bytes sdu %p\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" SEND_SDU to upper layers %d bytes sdu %p\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); if (rlc_pP->output_sdu_size_to_write > 0) { rlc_pP->stat_rx_pdcp_sdu += 1; rlc_pP->stat_rx_pdcp_bytes += rlc_pP->output_sdu_size_to_write; +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (const char*)(rlc_pP->output_sdu_in_construction->data), + rlc_pP->output_sdu_size_to_write, + MSC_AS_TIME_FMT" "PROTOCOL_RLC_UM_CTXT_FMT" DATA-IND size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), + rlc_pP->output_sdu_size_to_write + ); +#endif #ifdef TEST_RLC_UM #ifdef TRACE_RLC_UM_DISPLAY_ASCII_DATA rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write] = 0; - LOG_T(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u][SEND_SDU] DATA :", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + LOG_T(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[SEND_SDU] DATA :", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_util_print_hex_octets(RLC, rlc_pP->output_sdu_in_construction->data, rlc_pP->output_sdu_size_to_write); #endif rlc_um_v9_3_0_test_data_ind (rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); #else - // msg("[RLC] DATA IND ON MOD_ID %d RB ID %d, size %d\n",rlc_pP->module_id, rlc_pP->rb_id, ctxtP->frame,rlc_pP->output_sdu_size_to_write); + // msg("[RLC] DATA IND ON MOD_ID %d RB ID %d, size %d\n",rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame,rlc_pP->output_sdu_size_to_write); rlc_data_ind ( - ctxtP, + ctxt_pP, BOOL_NOT(rlc_pP->is_data_plane), rlc_pP->is_mxch, rlc_pP->rb_id, @@ -189,13 +164,8 @@ rlc_um_send_sdu (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) #endif rlc_pP->output_sdu_in_construction = NULL; } else { - LOG_E(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u][SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id); + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); } rlc_pP->output_sdu_size_to_write = 0; diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c index f008103c388..fe46acf26f7 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c @@ -39,12 +39,12 @@ #include "MAC_INTERFACE/extern.h" #include "UTIL/LOG/log.h" -//#define DEBUG_RLC_UM_RX 1 +//#define TRACE_RLC_UM_RX 1 //----------------------------------------------------------------------------- void rlc_um_display_rx_window( - const protocol_ctxt_t* const ctxtP, + const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP ) //----------------------------------------------------------------------------- @@ -59,7 +59,7 @@ rlc_um_display_rx_window( LOG_T(RLC, "\n"); LOG_T(RLC, "+-------------------------------------------------------------------------------------------------------+"); LOG_T(RLC, "\n"); - sprintf(time_out_str, "%010d", rlc_pP->t_reordering.frame_time_out); + sprintf(time_out_str, "%010d", rlc_pP->t_reordering.ms_duration); time_out_str[10] = 0; LOG_T(RLC, "| RLC UM RB %02d VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d t-Reordering: %s %s %s |", rlc_pP->rb_id, rlc_pP->vr_ur, rlc_pP->vr_ux, rlc_pP->vr_uh, @@ -114,9 +114,11 @@ rlc_um_display_rx_window( strcpy(color, RLC_FG_COLOR_RED); } - if (rlc_um_get_pdu_from_dar_buffer(ctxtP, rlc_pP, sn)) { + if (rlc_um_get_pdu_from_dar_buffer(ctxt_pP, rlc_pP, sn)) { // test RLC_REVERSE_VIDEO - if (str_index <= 2) str[str_index] = '.'; + if (str_index <= 2) { + str[str_index] = '.'; + } LOG_T(RLC, "%s%s%s", color, RLC_REVERSE_VIDEO, str); } else { @@ -133,7 +135,7 @@ rlc_um_display_rx_window( //----------------------------------------------------------------------------- void rlc_um_receive ( - const protocol_ctxt_t* const ctxtP, + const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, struct mac_data_ind data_indP) { @@ -152,15 +154,10 @@ rlc_um_receive ( rlc_pP->stat_rx_data_pdu += 1; if (tb_size_in_bytes > 0) { - rlc_um_receive_process_dar (ctxtP, rlc_pP, tb_p, (rlc_um_pdu_sn_10_t *)first_byte_p, tb_size_in_bytes); -#if defined(DEBUG_RLC_UM_RX) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][%s %u] VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", - frameP, - (rlc_pP->is_enb) ? "eNB" : "UE", - rlc_pP->enb_module_id, - rlc_pP->ue_module_id, - (rlc_pP->is_data_plane) ? "DRB" : "SRB", - rlc_pP->rb_id, + rlc_um_receive_process_dar (ctxt_pP, rlc_pP, tb_p, (rlc_um_pdu_sn_10_t*)first_byte_p, tb_size_in_bytes); +#if defined(TRACE_RLC_UM_RX) + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->vr_ur, rlc_pP->vr_ux, rlc_pP->vr_uh); diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c index a4c2a2267a0..c5deba88386 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c @@ -78,25 +78,13 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) if (nb_bytes_to_transmit < 3) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] NO SEGMENTATION nb_bytes to transmit = %d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" NO SEGMENTATION nb_bytes to transmit = %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), nb_bytes_to_transmit); #endif return; } -#if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); -#endif list_init (&pdus, NULL); // param string identifying the list is NULL pdu_mem_p = NULL; @@ -106,12 +94,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 nb_bytes_to_transmit %d BO %d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" nb_bytes_to_transmit %d BO %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), nb_bytes_to_transmit, rlc_pP->buffer_occupancy); #endif @@ -127,47 +111,31 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) if (nb_bytes_to_transmit >= (rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead)) { data_pdu_size = rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead; #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); #endif } else { data_pdu_size = nb_bytes_to_transmit; #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); #endif } if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_E(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 ERROR COULD NOT GET NEW PDU, EXIT\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" ERROR COULD NOT GET NEW PDU, EXIT\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif pthread_mutex_unlock(&rlc_pP->lock_input_sdus); return; } #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 get new PDU %d bytes\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" get new PDU %d bytes\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); #endif pdu_remaining_size = data_pdu_size - 2; @@ -225,12 +193,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) test_li_length_in_bytes = test_li_length_in_bytes ^ 3; } else { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, test_pdu_remaining_size, test_li_length_in_bytes ^ 3); @@ -257,12 +221,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) // Do the real filling of the pdu_p //---------------------------------------- #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] data shift %d Bytes num_li %d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" data shift %d Bytes num_li %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), ((test_num_li*3) +1) >> 1, test_num_li); #endif @@ -288,23 +248,15 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) if (sdu_mngt_p->sdu_segmented_size == 0) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p, sdu_mngt_p->sdu_remaining_size); #endif } else { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p, sdu_mngt_p->sdu_remaining_size, sdu_mngt_p->sdu_size); @@ -315,19 +267,11 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Filling all remaining PDU with %d bytes\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling all remaining PDU with %d bytes\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_remaining_size); - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 pdu_mem_p %p pdu_mem_p->data %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" pdu_mem_p %p pdu_mem_p->data %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_mem_p, pdu_mem_p->data, pdu_p, @@ -347,12 +291,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) pdu_remaining_size = 0; } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Exactly Filling remaining PDU with %d remaining bytes of SDU\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Exactly Filling remaining PDU with %d remaining bytes of SDU\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_remaining_size); #endif memcpy(data, data_sdu_p, pdu_remaining_size); @@ -371,12 +311,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) pdu_remaining_size = 0; } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Filling PDU with %d all remaining bytes of SDU\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size); #endif memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); @@ -397,12 +333,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 set e_li_p->b1=%02X set e_li_p->b2=%02X fill_num_li=%d test_num_li=%d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set e_li_p->b1=%02X set e_li_p->b2=%02X fill_num_li=%d test_num_li=%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), e_li_p->b1, e_li_p->b2, fill_num_li, @@ -418,12 +350,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 set e_li_p->b2=%02X set e_li_p->b3=%02X fill_num_li=%d test_num_li=%d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set e_li_p->b2=%02X set e_li_p->b3=%02X fill_num_li=%d test_num_li=%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), e_li_p->b2, e_li_p->b3, fill_num_li, @@ -443,12 +371,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) } else { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); #endif @@ -497,7 +421,7 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; list_add_tail_eurecom (pdu_mem_p, &rlc_pP->pdus_to_mac_layer); -#if defined(DEBUG_RLC_PAYLOAD) +#if defined(TRACE_RLC_PAYLOAD) rlc_util_print_hex_octets(RLC, pdu_mem_p->data, data_pdu_size); #endif AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT10: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); @@ -545,25 +469,13 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) if (nb_bytes_to_transmit < 2) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] NO SEGMENTATION5 nb_bytes to transmit = %d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" NO SEGMENTATION5 nb_bytes to transmit = %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), nb_bytes_to_transmit); #endif return; } -#if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); -#endif list_init (&pdus, NULL); // param string identifying the list is NULL pdu_mem_p = NULL; @@ -571,12 +483,8 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 nb_bytes_to_transmit %d BO %d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"nb_bytes_to_transmit %d BO %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), nb_bytes_to_transmit, rlc_pP->buffer_occupancy); #endif @@ -592,47 +500,31 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) if (nb_bytes_to_transmit >= (rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead)) { data_pdu_size = rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead; #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); #endif } else { data_pdu_size = nb_bytes_to_transmit; #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); #endif } if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_E(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 ERROR COULD NOT GET NEW PDU, EXIT\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id); + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" ERROR COULD NOT GET NEW PDU, EXIT\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif pthread_mutex_unlock(&rlc_pP->lock_input_sdus); return; } #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 get new PDU %d bytes\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" get new PDU %d bytes\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), data_pdu_size); #endif pdu_remaining_size = data_pdu_size - 1; @@ -691,12 +583,8 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) test_li_length_in_bytes = test_li_length_in_bytes ^ 3; } else { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, test_pdu_remaining_size, test_li_length_in_bytes ^ 3); @@ -724,12 +612,8 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) // Do the real filling of the pdu_p //---------------------------------------- #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] data shift %d Bytes num_li %d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" data shift %d Bytes num_li %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), ((test_num_li*3) +1) >> 1, test_num_li); #endif @@ -755,23 +639,15 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) if (sdu_mngt_p->sdu_segmented_size == 0) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p, sdu_mngt_p->sdu_remaining_size); #endif } else { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p, sdu_mngt_p->sdu_remaining_size, sdu_mngt_p->sdu_size); @@ -782,19 +658,11 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Filling all remaining PDU with %d bytes\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling all remaining PDU with %d bytes\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_remaining_size); - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 pdu_mem_p %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" pdu_mem_p %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_mem_p, pdu_p, pdu_p->data, @@ -813,12 +681,8 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) pdu_remaining_size = 0; } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Exactly Filling remaining PDU with %d remaining bytes of SDU\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Exactly Filling remaining PDU with %d remaining bytes of SDU\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_remaining_size); #endif memcpy(data, data_sdu_p, pdu_remaining_size); @@ -835,12 +699,8 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) pdu_remaining_size = 0; } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Filling PDU with %d all remaining bytes of SDU\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size); #endif memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); @@ -861,12 +721,8 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 set e_li_p->b1=%02X set e_li_p->b2=%02X fill_num_li=%d test_num_li=%d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set e_li_p->b1=%02X set e_li_p->b2=%02X fill_num_li=%d test_num_li=%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), e_li_p->b1, e_li_p->b2, fill_num_li, @@ -882,12 +738,8 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 set e_li_p->b2=%02X set e_li_p->b3=%02X fill_num_li=%d test_num_li=%d\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set e_li_p->b2=%02X set e_li_p->b3=%02X fill_num_li=%d test_num_li=%d\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), e_li_p->b2, e_li_p->b3, fill_num_li, @@ -907,12 +759,8 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) } else { #if defined(TRACE_RLC_UM_SEGMENT) - LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rlc_pP->rb_id, + LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); #endif @@ -957,7 +805,7 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; list_add_tail_eurecom (pdu_mem_p, &rlc_pP->pdus_to_mac_layer); -#if defined(DEBUG_RLC_PAYLOAD) +#if defined(TRACE_RLC_PAYLOAD) rlc_util_print_hex_octets(RLC, (unsigned char*)pdu_mem_p->data, data_pdu_size); #endif AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT5: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c index a77dde5923e..aaa4c80e55b 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c @@ -171,8 +171,9 @@ void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* dataP, uns /* * Append enough spaces and put final pipe */ - for (aindex = octet_index; aindex < 16; ++aindex) + for (aindex = octet_index; aindex < 16; ++aindex) { buffer_marker+=snprintf(&rlc_2_print_buffer[buffer_marker], RLC_2_PRINT_BUFFER_LEN - buffer_marker, " "); + } // LOG_D(RLC, " "); buffer_marker+=snprintf(&rlc_2_print_buffer[buffer_marker], RLC_2_PRINT_BUFFER_LEN - buffer_marker, " |\n"); @@ -387,7 +388,8 @@ void rlc_um_v9_3_0_buffer_delayed_tx_mac_data_ind(struct mac_data_ind* data_indP } //----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_data_req *data_requestP, int* drop_countP, int *tx_packetsP, int* dropped_tx_packetsP) +void rlc_um_v9_3_0_test_mac_rlc_loop (struct mac_data_ind* data_indP, struct mac_data_req* data_requestP, int* drop_countP, int* tx_packetsP, + int* dropped_tx_packetsP) //----------------------------------------------------------------------------- { @@ -571,11 +573,12 @@ void rlc_um_v9_3_0_test_data_ind (module_id_t module_idP, rb_id_t rb_idP, sdu_si if (g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1] != i) { - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-2, g_send_sdu_ids[g_send_id_read_index[rb_idP]-2][rb_idP^1]); - - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-1, g_send_sdu_ids[g_send_id_read_index[rb_idP]-1][rb_idP^1]); - - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1]); + printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-2, + g_send_sdu_ids[g_send_id_read_index[rb_idP]-2][rb_idP^1]); + printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-1, + g_send_sdu_ids[g_send_id_read_index[rb_idP]-1][rb_idP^1]); + printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], + g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1]); printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_id_read_index = %d sdu sent = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], i); } @@ -916,7 +919,8 @@ void rlc_um_v9_3_0_test_tx_rx_10(void) rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 500, 500); } - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 3: END OF TEST RANDOM (SEED=%d ) TX ONLY :\n\n\n\n",r); + printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 3: END OF TEST RANDOM (SEED=%d ) TX ONLY :\n\n\n\n", + r); assert (g_send_id_read_index[1] == g_send_id_write_index[0]); #endif #ifdef TEST4 @@ -1388,8 +1392,9 @@ void rlc_um_v9_3_0_test_print_trace (void) printf ("Obtained %d stack frames.\n", size); - for (i = 0; i < size; i++) + for (i = 0; i < size; i++) { printf ("%s\n", strings[i]); + } free (strings); } diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index 01a7c3e51ce..3ec38bd1042 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -52,10 +52,10 @@ extern boolean_t pdcp_data_ind( mem_block_t* const sdu_buffer_pP); #define DEBUG_RLC_PDCP_INTERFACE 1 -//#define DEBUG_RLC_PAYLOAD 1 +//#define TRACE_RLC_PAYLOAD 1 #define DEBUG_RLC_DATA_REQ 1 -#if defined(DEBUG_RLC_PAYLOAD) +#if defined(TRACE_RLC_PAYLOAD) //----------------------------------------------------------------------------- void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* dataP, const signed long sizeP) //----------------------------------------------------------------------------- @@ -96,15 +96,16 @@ void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* dataP, con */ unsigned char index; - for (index = octet_index; index < 16; ++index) + for (index = octet_index; index < 16; ++index) { LOG_T(componentP, " "); + } LOG_T(componentP, " |\n"); } #endif //----------------------------------------------------------------------------- rlc_op_status_t rlc_stat_req ( - const protocol_ctxt_t* const ctxtP, + const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, unsigned int* stat_tx_pdcp_sdu, @@ -138,38 +139,16 @@ rlc_op_status_t rlc_stat_req ( //----------------------------------------------------------------------------- rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_QUESTIONABLE_KEY_VALUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; #ifdef OAI_EMU - if (ctxtP->enb_flag) { - AssertFatal ((ctxtP->enb_module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - ctxtP->enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal ((ctxtP->enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - ctxtP->enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ctxtP->ue_module_id < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ctxtP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ctxtP->ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ctxtP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ctxtP->ue_module_id >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ctxtP->ue_module_id, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(ctxt_pP) #endif AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); - key = RLC_COLL_KEY_VALUE(ctxtP->enb_module_id, ctxtP->ue_module_id, ctxtP->enb_flag, rb_idP, srb_flagP); + key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { @@ -209,7 +188,7 @@ rlc_op_status_t rlc_stat_req ( break; case RLC_MODE_AM: - rlc_am_stat_req(ctxtP, + rlc_am_stat_req(ctxt_pP, &rlc_union_p->rlc.am, stat_tx_pdcp_sdu, stat_tx_pdcp_bytes, @@ -254,7 +233,7 @@ rlc_op_status_t rlc_stat_req ( *stat_rx_data_bytes_out_of_window = 0; *stat_timer_poll_retransmit_timed_out = 0; *stat_timer_status_prohibit_timed_out = 0; - rlc_um_stat_req (ctxtP, + rlc_um_stat_req (ctxt_pP, &rlc_union_p->rlc.um, stat_tx_pdcp_sdu, stat_tx_pdcp_bytes, @@ -340,7 +319,7 @@ rlc_op_status_t rlc_stat_req ( } //----------------------------------------------------------------------------- -rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, +rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, @@ -353,7 +332,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, mem_block_t *new_sdu_p = NULL; rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_QUESTIONABLE_KEY_VALUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; #ifdef Rel10 @@ -361,10 +340,8 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, logical_chan_id_t log_ch_id = 0; #endif #ifdef DEBUG_RLC_DATA_REQ - LOG_D(RLC,"rlc_data_req: %s enb id %u ue id %u, rb_id %u (MAX %d), muip %d, confirmP %d, sud_sizeP %d, sdu_pP %p\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, + LOG_D(RLC,PROTOCOL_CTXT_FMT"rlc_data_req: rb_id %u (MAX %d), muip %d, confirmP %d, sud_sizeP %d, sdu_pP %p\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP, NB_RAB_MAX, muiP, @@ -378,29 +355,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, #endif #ifdef OAI_EMU - if (ctxtP->enb_flag) { - AssertFatal ((ctxtP->enb_module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - ctxtP->enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal ((ctxtP->enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - ctxtP->enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ctxtP->ue_module_id < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ctxtP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ctxtP->ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ctxtP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ctxtP->ue_module_id >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ctxtP->ue_module_id, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(ctxt_pP) #endif @@ -422,19 +377,19 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, #ifdef Rel10 if (MBMS_flagP == TRUE) { - if (ctxtP->enb_flag) { - log_ch_id = rlc_mbms_enb_get_lcid_by_rb_id(ctxtP->enb_module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxtP->enb_module_id][log_ch_id]; + if (ctxt_pP->enb_flag) { + log_ch_id = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); + mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][log_ch_id]; } else { - log_ch_id = rlc_mbms_ue_get_lcid_by_rb_id(ctxtP->ue_module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxtP->ue_module_id][log_ch_id]; + log_ch_id = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->rnti,rb_idP); + mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->rnti][log_ch_id]; } - key = RLC_COLL_KEY_MBMS_VALUE(ctxtP->enb_module_id, ctxtP->ue_module_id, ctxtP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); + key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); } else #endif { - key = RLC_COLL_KEY_VALUE(ctxtP->enb_module_id, ctxtP->ue_module_id, ctxtP->enb_flag, rb_idP, srb_flagP); + key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -447,13 +402,10 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, } if (MBMS_flagP == 0) { - LOG_D(RLC, "[FRAME %5u][%s][RLC][INST %u/%u][RB %u] Display of rlc_data_req:\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, + LOG_D(RLC, PROTOCOL_CTXT_FMT"[RB %u] Display of rlc_data_req:\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); -#if defined(DEBUG_RLC_PAYLOAD) +#if defined(TRACE_RLC_PAYLOAD) rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP); #endif @@ -464,10 +416,8 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, switch (rlc_mode) { case RLC_MODE_NONE: free_mem_block(sdu_pP); - LOG_E(RLC, "Received RLC_MODE_NONE as rlc_type for %s eNB id %u, ue id %u, rb_id %u\n", - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT" Received RLC_MODE_NONE as rlc_type for rb_id %u\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); return RLC_OP_STATUS_BAD_PARAMETER; @@ -488,23 +438,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, ((struct rlc_am_data_req *) (new_sdu_p->data))->mui = muiP; ((struct rlc_am_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_am_data_req_alloc); free_mem_block(sdu_pP); - LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - - LOG_D(RLC, "[FRAME %5u][%s][%s][INST %u/%u][%s %u][--- RLC_AM_DATA_REQ/%d Bytes --->][RLC_AM][INST %u/%u][%s %u]\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - (srb_flagP) ? "RRC" : "PDCP", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - sdu_sizeP, - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP); - LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_am_data_req(ctxtP, &rlc_union_p->rlc.am, new_sdu_p); + rlc_am_data_req(ctxt_pP, &rlc_union_p->rlc.am, new_sdu_p); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); return RLC_OP_STATUS_OK; } else { @@ -526,22 +460,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, ((struct rlc_um_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_um_data_req_alloc); free_mem_block(sdu_pP); - //LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - LOG_D(RLC, "[FRAME %5u][%s][%s][INST %u/%u][%s %u][--- RLC_UM_DATA_REQ/%d Bytes --->][RLC_UM][INST %u/%u][%s %u]\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - (srb_flagP) ? "RRC" : "PDCP", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - sdu_sizeP, - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP); - //LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_um_data_req(ctxtP, &rlc_union_p->rlc.um, new_sdu_p); + rlc_um_data_req(ctxt_pP, &rlc_union_p->rlc.um, new_sdu_p); //free_mem_block(new_sdu); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); @@ -564,22 +483,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, ((struct rlc_tm_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP; ((struct rlc_tm_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_tm_data_req_alloc); free_mem_block(sdu_pP); - LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - LOG_D(RLC, "[FRAME %5u][%s][%s][INST %u/%u][%s %u][--- RLC_TM_DATA_REQ/%d Bytes --->][RLC_TM][INST %u/%u][%s %u]\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - (srb_flagP) ? "RRC" : "PDCP", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - sdu_sizeP, - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP); - LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_tm_data_req(ctxtP, &rlc_union_p->rlc.tm, new_sdu_p); + rlc_tm_data_req(ctxt_pP, &rlc_union_p->rlc.tm, new_sdu_p); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); return RLC_OP_STATUS_OK; } else { @@ -612,20 +516,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, ((struct rlc_um_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP; ((struct rlc_um_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_um_data_req_alloc); free_mem_block(sdu_pP); - LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - LOG_D(RLC, "[FRAME %5u][%s][%s][INST %u/%u][RB %u][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][INST %u/%u][RB %u]\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - (srb_flagP) ? "RRC" : "PDCP", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rb_idP, - sdu_sizeP, - ctxtP->enb_module_id, - ctxtP->ue_module_id, - rb_idP); - LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_um_data_req(ctxtP, &rlc_union_p->rlc.um, new_sdu_p); + rlc_um_data_req(ctxt_pP, &rlc_union_p->rlc.um, new_sdu_p); //free_mem_block(new_sdu); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); @@ -660,7 +551,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxtP, //----------------------------------------------------------------------------- void rlc_data_ind ( - const protocol_ctxt_t* const ctxtP, + const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, @@ -670,33 +561,18 @@ void rlc_data_ind ( //----------------------------------------------------------------------------- -#if defined(DEBUG_RLC_PAYLOAD) - LOG_D(RLC, "[FRAME %5u][%s][RLC][INST %u/%u][%s %u] Display of rlc_data_ind: size %u\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, +#if defined(TRACE_RLC_PAYLOAD) + LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u] Display of rlc_data_ind: size %u\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, sdu_sizeP); rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP); #endif - LOG_D(RLC, "[FRAME %5u][%s][RLC][INST %u/%u][%s %u][--- RLC_DATA_IND/%d Bytes --->][PDCP][INST %u/%u][%s %u]\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - sdu_sizeP, - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP); pdcp_data_ind ( - ctxtP, + ctxt_pP, srb_flagP, MBMS_flagP, rb_idP, @@ -704,7 +580,7 @@ void rlc_data_ind ( sdu_pP); } //----------------------------------------------------------------------------- -void rlc_data_conf (const protocol_ctxt_t* const ctxtP, +void rlc_data_conf (const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, const mui_t muiP, @@ -714,22 +590,7 @@ void rlc_data_conf (const protocol_ctxt_t* const ctxtP, if (srb_flagP) { if (rlc_rrc_data_conf != NULL) { - LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][INST %u/%u][%s %u][--- RLC_DATA_CONF /MUI %d --->][%s][INST %u/%u][][RLC_DATA_CONF/ MUI %d]\n", - ctxtP->frame, - (ctxtP->enb_flag) ? "eNB" : "UE", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - muiP, - (srb_flagP) ? "RRC" : "PDCP", - ctxtP->enb_module_id, - ctxtP->ue_module_id, - muiP); - - LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_rrc_data_conf (ctxtP, rb_idP , muiP, statusP); + rlc_rrc_data_conf (ctxt_pP, rb_idP , muiP, statusP); } } } diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index aaf48598ae6..90d469c9eb1 100755 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -66,7 +66,7 @@ #ifdef CMAKER typedef uint64_t hash_key_t; -#define HASHTABLE_QUESTIONABLE_KEY_VALUE ((uint64_t)-1) +#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1) #endif //----------------------------------------------------------------------------- # ifdef RLC_MAC_C @@ -262,21 +262,21 @@ public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_ue [NUMBER_OF_UE_MAX][NB_RB_M public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_eNB[NUMBER_OF_eNB_MAX][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ -#define RLC_COLL_KEY_VALUE(eNB_iD, uE_iD, iS_eNB, rB_iD, iS_sRB) \ +#define RLC_COLL_KEY_VALUE(eNB_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \ ((hash_key_t)eNB_iD | \ - (((hash_key_t)(uE_iD)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 16) | \ - (((hash_key_t)(rB_iD)) << 17) | \ - (((hash_key_t)(iS_sRB)) << 25)) + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(rB_iD)) << 25) | \ + (((hash_key_t)(iS_sRB)) << 33)) // service id max val is maxServiceCount = 16 (asn1_constants.h) -#define RLC_COLL_KEY_MBMS_VALUE(eNB_iD, uE_iD, iS_eNB, sERVICE_ID, sESSION_ID) \ +#define RLC_COLL_KEY_MBMS_VALUE(eNB_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \ ((hash_key_t)eNB_iD | \ - (((hash_key_t)(uE_iD)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 16) | \ - (((hash_key_t)(sERVICE_ID)) << 24) | \ - (((hash_key_t)(sESSION_ID)) << 29) | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(sERVICE_ID)) << 32) | \ + (((hash_key_t)(sESSION_ID)) << 37) | \ (((hash_key_t)(0x0000000000000001)) << 63)) public_rlc(hash_table_t *rlc_coll_p;) @@ -422,10 +422,10 @@ public_rlc_rrc(void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_d //----------------------------------------------------------------------------- // PUBLIC INTERFACE WITH MAC //----------------------------------------------------------------------------- -/*! \fn tbs_size_t mac_rlc_data_req (const module_id_t enb_mod_idP, const module_id_t ue_mod_idP, const frame_t frameP, const MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, char* bufferP) +/*! \fn tbs_size_t mac_rlc_data_req (const module_id_t mod_idP, const rnti_t rntiP, const frame_t frameP, const MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, char* bufferP) * \brief Interface with MAC layer, map data request to the RLC corresponding to the radio bearer. -* \param [in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. -* \param [in] ue_mod_idP Virtualized ue module identifier. +* \param [in] mod_idP Virtualized module identifier. +* \param [in] rntiP UE identifier. * \param [in] frameP Frame index * \param [in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param [in] MBMS_flagP Flag to indicate whether this is the MBMS service (1) or not (0) @@ -433,12 +433,12 @@ public_rlc_rrc(void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_d * \param [in,out] bufferP Memory area to fill with the bytes requested by MAC. * \return A status about the processing, OK or error code. */ -public_rlc_mac(tbs_size_t mac_rlc_data_req (const module_id_t, const module_id_t, const frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, char*);) +public_rlc_mac(tbs_size_t mac_rlc_data_req (const module_id_t, const rnti_t, const frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, char*);) -/*! \fn void mac_rlc_data_ind (const module_id_t enb_mod_idP, const module_id_t ue_mod_idP, const frame_t frameP, const eNB_flag_t eNB_flagP, const MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, uint32_t frameP, char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs) +/*! \fn void mac_rlc_data_ind (const module_id_t mod_idP, const rnti_t rntiP, const frame_t frameP, const eNB_flag_t eNB_flagP, const MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, uint32_t frameP, char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs) * \brief Interface with MAC layer, deserialize the transport blocks sent by MAC, then map data indication to the RLC instance corresponding to the radio bearer identifier. -* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. -* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] mod_idP Virtualized module identifier. +* \param[in] rntiP UE identifier. * \param[in] frameP Frame index * \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] MBMS_flagP Flag to indicate whether this is the MBMS service (1) or not (0) @@ -448,13 +448,13 @@ public_rlc_mac(tbs_size_t mac_rlc_data_req (const module_id_t, co * \param[in] num_tbP Number of transport blocks. * \param[in] crcs Array of CRC decoding. */ -public_rlc_mac(void mac_rlc_data_ind (const module_id_t, const module_id_t, const frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, char*, tb_size_t, num_tb_t, +public_rlc_mac(void mac_rlc_data_ind (const module_id_t, const rnti_t, const frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, char*, tb_size_t, num_tb_t, crc_t* );) -/*! \fn mac_rlc_status_resp_t mac_rlc_status_ind (const module_id_t enb_mod_idP, const module_id_t ue_mod_idP, const frame_t frameP, const eNB_flag_t eNB_flagP, const MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, tb_size_t tb_sizeP) +/*! \fn mac_rlc_status_resp_t mac_rlc_status_ind (const module_id_t mod_idP, const rnti_t rntiP, const frame_t frameP, const eNB_flag_t eNB_flagP, const MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, tb_size_t tb_sizeP) * \brief Interface with MAC layer, request and set the number of bytes scheduled for transmission by the RLC instance corresponding to the radio bearer identifier. -* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. -* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] mod_idP Virtualized module identifier. +* \param[in] rntiP UE identifier. * \param[in] frameP Frame index. * \param[in] eNB_flagP Flag to indicate eNB operation (1 true, 0 false) * \param[in] MBMS_flagP Flag to indicate whether this is the MBMS service (1) or not (0) @@ -462,7 +462,7 @@ public_rlc_mac(void mac_rlc_data_ind (const module_id_t, co * \param[in] tb_sizeP Size of a transport block set in bytes. * \return The maximum number of bytes that the RLC instance can send in the next transmission sequence. */ -public_rlc_mac(mac_rlc_status_resp_t mac_rlc_status_ind (const module_id_t, const module_id_t, const frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, tb_size_t );) +public_rlc_mac(mac_rlc_status_resp_t mac_rlc_status_ind (const module_id_t, const rnti_t, const frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, tb_size_t );) //----------------------------------------------------------------------------- // RLC methods //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index f0d54ccf457..db4a5e9a89e 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -71,15 +71,16 @@ struct mac_data_ind mac_rlc_deserialize_tb ( ((struct mac_tb_ind *) (tb_p->data))->data_ptr = (uint8_t*)&tb_p->data[sizeof (mac_rlc_max_rx_header_size_t)]; ((struct mac_tb_ind *) (tb_p->data))->size = tb_sizeP; - if (crcs_pP) + if (crcs_pP) { ((struct mac_tb_ind *) (tb_p->data))->error_indication = crcs_pP[nb_tb_read]; - else + } else { ((struct mac_tb_ind *) (tb_p->data))->error_indication = 0; + } memcpy(((struct mac_tb_ind *) (tb_p->data))->data_ptr, &buffer_pP[tbs_size], tb_sizeP); #ifdef DEBUG_MAC_INTERFACE -#if defined(DEBUG_RLC_PAYLOAD) +#if defined(TRACE_RLC_PAYLOAD) LOG_T(RLC, "[MAC-RLC] DUMP RX PDU(%d bytes):\n", tb_sizeP); rlc_util_print_hex_octets(RLC, ((struct mac_tb_ind *) (tb_p->data))->data_ptr, tb_sizeP); #endif @@ -113,7 +114,7 @@ tbs_size_t mac_rlc_serialize_tb (char* buffer_pP, list_t transport_blocksP) if (tb_p != NULL) { tb_size = ((struct mac_tb_req *) (tb_p->data))->tb_size; #ifdef DEBUG_MAC_INTERFACE -#if defined(DEBUG_RLC_PAYLOAD) +#if defined(TRACE_RLC_PAYLOAD) LOG_T(RLC, "[MAC-RLC] DUMP TX PDU(%d bytes):\n", tb_size); rlc_util_print_hex_octets(RLC, ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size); #endif @@ -128,8 +129,8 @@ tbs_size_t mac_rlc_serialize_tb (char* buffer_pP, list_t transport_blocksP) } //----------------------------------------------------------------------------- tbs_size_t mac_rlc_data_req( - const module_id_t enb_module_idP, - const module_id_t ue_module_idP, + const module_id_t module_idP, + const rnti_t rntiP, const frame_t frameP, const eNB_flag_t enb_flagP, const MBMS_flag_t MBMS_flagP, @@ -142,63 +143,40 @@ tbs_size_t mac_rlc_data_req( rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_QUESTIONABLE_KEY_VALUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; srb_flag_t srb_flag = (channel_idP <= 2) ? SRB_FLAG_YES : SRB_FLAG_NO; tbs_size_t ret_tb_size = 0; protocol_ctxt_t ctxt; - ctxt.enb_module_id = enb_module_idP; - ctxt.ue_module_id = ue_module_idP; - ctxt.frame = frameP; - ctxt.enb_flag = enb_flagP; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, enb_flagP, rntiP, frameP, 0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_REQ,VCD_FUNCTION_IN); #ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, "\n[RLC] Inst %s enb id %d ue id %d: MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d, Num_tb %d\n", - (enb_flagP) ? "eNB" : "UE", enb_module_idP, ue_module_idP, channel_idP, RLC_MAX_LC, NB_RB_MAX); + LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d, Num_tb %d\n", + PROTOCOL_CTXT_ARGS((&ctxt)), + channel_idP, + RLC_MAX_LC, + NB_RB_MAX); #endif // DEBUG_MAC_INTERFACE - if (MBMS_flagP) + if (MBMS_flagP) { AssertFatal (channel_idP < RLC_MAX_MBMS_LC, "channel id is too high (%u/%d)!\n", channel_idP, RLC_MAX_MBMS_LC); - else + } else { AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); + } -#if defined(USER_MODE) && defined(OAI_EMU) - - if (enb_flagP) { - AssertFatal ((enb_module_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - enb_module_idP, - oai_emulation.info.first_enb_local); - AssertFatal ((enb_module_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - enb_module_idP, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ue_module_idP < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { +#ifdef OAI_EMU + CHECK_CTXT_ARGS(&ctxt); AssertFatal (MBMS_flagP == MBMS_FLAG_NO ," MBMS FLAG SHOULD NOT BE SET IN mac_rlc_data_req in UE\n"); - AssertFatal (ue_module_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ue_module_idP >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local); - } - #endif if (MBMS_flagP) { if (enb_flagP) { - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[enb_module_idP][channel_idP]; - key = RLC_COLL_KEY_MBMS_VALUE(enb_module_idP, ue_module_idP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); + mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[module_idP][channel_idP]; + key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); } else { return (tbs_size_t)0; } @@ -209,7 +187,7 @@ tbs_size_t mac_rlc_data_req( rb_id = channel_idP; } - key = RLC_COLL_KEY_VALUE(enb_module_idP, ue_module_idP, enb_flagP, rb_id, srb_flag); + key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -218,7 +196,7 @@ tbs_size_t mac_rlc_data_req( rlc_mode = rlc_union_p->mode; } else { rlc_mode = RLC_MODE_NONE; - AssertFatal (0 , "RLC not configured rb id %u lcid %u module %u!\n", rb_id, channel_idP, ue_module_idP); + AssertFatal (0 , "RLC not configured rb id %u lcid %u RNTI %x!\n", rb_id, channel_idP, rntiP); } switch (rlc_mode) { @@ -250,8 +228,8 @@ tbs_size_t mac_rlc_data_req( } //----------------------------------------------------------------------------- void mac_rlc_data_ind ( - const module_id_t enb_module_idP, - const module_id_t ue_module_idP, + const module_id_t module_idP, + const rnti_t rntiP, const frame_t frameP, const eNB_flag_t enb_flagP, const MBMS_flag_t MBMS_flagP, @@ -266,25 +244,19 @@ void mac_rlc_data_ind ( rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_QUESTIONABLE_KEY_VALUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; srb_flag_t srb_flag = (channel_idP <= 2) ? SRB_FLAG_YES : SRB_FLAG_NO; protocol_ctxt_t ctxt; - ctxt.enb_module_id = enb_module_idP; - ctxt.ue_module_id = ue_module_idP; - ctxt.frame = frameP; - ctxt.enb_flag = enb_flagP; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, enb_flagP, rntiP, frameP, 0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_IND,VCD_FUNCTION_IN); #ifdef DEBUG_MAC_INTERFACE if (num_tbP) { - LOG_D(RLC, "[Frame %5u][%s][RLC][MOD %u/%u] MAC_RLC_DATA_IND on channel %d (%d), rb max %d, Num_tb %d\n", - frameP, - (enb_flagP) ? "eNB" : "UE", - enb_module_idP, - ue_module_idP, + LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_IND on channel %d (%d), rb max %d, Num_tb %d\n", + PROTOCOL_CTXT_ARGS(&ctxt), channel_idP, RLC_MAX_LC, NB_RB_MAX, @@ -301,38 +273,15 @@ void mac_rlc_data_ind ( AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); - if (enb_flagP) { - AssertFatal ((enb_module_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - enb_module_idP, - oai_emulation.info.first_enb_local); - AssertFatal ((enb_module_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - enb_module_idP, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ue_module_idP < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (MBMS_flagP == MBMS_FLAG_NO ," MBMS FLAG SHOULD NOT BE SET IN mac_rlc_data_ind in eNB\n"); - } else { - AssertFatal (ue_module_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ue_module_idP >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(&ctxt); #endif if (MBMS_flagP) { if (BOOL_NOT(enb_flagP)) { - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[enb_module_idP][channel_idP]; - key = RLC_COLL_KEY_MBMS_VALUE(enb_module_idP, ue_module_idP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); + mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[module_idP][channel_idP]; + key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); } else { return; } @@ -343,7 +292,7 @@ void mac_rlc_data_ind ( rb_id = channel_idP; } - key = RLC_COLL_KEY_VALUE(enb_module_idP, ue_module_idP, enb_flagP, rb_id, srb_flag); + key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -363,23 +312,14 @@ void mac_rlc_data_ind ( break; case RLC_MODE_AM: -#ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, "MAC DATA IND TO RLC_AM MOD_ID %s enb id %u ue id %u \n", (enb_flagP) ? "eNB" : "UE", enb_module_idP, ue_module_idP); -#endif rlc_am_mac_data_indication(&ctxt, &rlc_union_p->rlc.am, data_ind); break; case RLC_MODE_UM: -#ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, "MAC DATA IND TO RLC_UM MOD_ID %s enb id %u ue id %u \n", (enb_flagP) ? "eNB" : "UE", enb_module_idP, ue_module_idP); -#endif rlc_um_mac_data_indication(&ctxt, &rlc_union_p->rlc.um, data_ind); break; case RLC_MODE_TM: -#ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, "MAC DATA IND TO RLC_TM MOD_ID %s enb id %u ue id %u \n", (enb_flagP) ? "eNB" : "UE", enb_module_idP, ue_module_idP); -#endif rlc_tm_mac_data_indication(&ctxt, &rlc_union_p->rlc.tm, data_ind); break; } @@ -389,8 +329,8 @@ void mac_rlc_data_ind ( } //----------------------------------------------------------------------------- mac_rlc_status_resp_t mac_rlc_status_ind( - const module_id_t enb_module_idP, - const module_id_t ue_module_idP, + const module_id_t module_idP, + const rnti_t rntiP, const frame_t frameP, const eNB_flag_t enb_flagP, const MBMS_flag_t MBMS_flagP, @@ -405,15 +345,12 @@ mac_rlc_status_resp_t mac_rlc_status_ind( rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_QUESTIONABLE_KEY_VALUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; srb_flag_t srb_flag = (channel_idP <= 2) ? SRB_FLAG_YES : SRB_FLAG_NO; protocol_ctxt_t ctxt; - ctxt.enb_module_id = enb_module_idP; - ctxt.ue_module_id = ue_module_idP; - ctxt.frame = frameP; - ctxt.enb_flag = enb_flagP; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, enb_flagP, rntiP, frameP, 0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_STATUS_IND,VCD_FUNCTION_IN); memset (&mac_rlc_status_resp, 0, sizeof(mac_rlc_status_resp_t)); @@ -423,44 +360,22 @@ mac_rlc_status_resp_t mac_rlc_status_ind( if (MBMS_flagP) AssertFatal (channel_idP < RLC_MAX_MBMS_LC, - "%s channel id is too high (%u/%d) enb module id %u ue module id %u!\n", + "%s channel id is too high (%u/%d) enb module id %u ue %u!\n", (enb_flagP) ? "eNB" : "UE", channel_idP, RLC_MAX_MBMS_LC, - enb_module_idP, - ue_module_idP); + module_idP, + rntiP); else AssertFatal (channel_idP < NB_RB_MAX, - "%s channel id is too high (%u/%d) enb module id %u ue module id %u!\n", + "%s channel id is too high (%u/%d) enb module id %u ue %u!\n", (enb_flagP) ? "eNB" : "UE", channel_idP, NB_RB_MAX, - enb_module_idP, - ue_module_idP); - - if (enb_flagP) { - AssertFatal ((enb_module_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - enb_module_idP, - oai_emulation.info.first_enb_local); - AssertFatal ((enb_module_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - enb_module_idP, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ue_module_idP < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ue_module_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ue_module_idP >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ue_module_idP, - oai_emulation.info.first_ue_local); - } + module_idP, + rntiP); + + CHECK_CTXT_ARGS(&ctxt); #endif @@ -468,12 +383,12 @@ mac_rlc_status_resp_t mac_rlc_status_ind( if (MBMS_flagP) { if (enb_flagP) { - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[enb_module_idP][channel_idP]; + mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[module_idP][channel_idP]; } else { - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ue_module_idP][channel_idP]; + mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[module_idP][channel_idP]; } - key = RLC_COLL_KEY_MBMS_VALUE(enb_module_idP, ue_module_idP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); + key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); } else { if (channel_idP > 2) { rb_id = channel_idP - 2; @@ -481,7 +396,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( rb_id = channel_idP; } - key = RLC_COLL_KEY_VALUE(enb_module_idP, ue_module_idP, enb_flagP, rb_id, srb_flag); + key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index 0e763261af7..a2be5cc3cd3 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -74,7 +74,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP const SRB_ToAddMod_t *srb_toaddmod_p = NULL; const DRB_ToAddMod_t *drb_toaddmod_p = NULL; rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_QUESTIONABLE_KEY_VALUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; #if defined(Rel10) int i, j; @@ -87,37 +87,12 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP #endif - LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] CONFIG REQ ASN1 \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id); + LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ ASN1 \n", + PROTOCOL_CTXT_ARGS(ctxt_pP)); #ifdef OAI_EMU - if (ctxt_pP->enb_flag) { - AssertFatal ((ctxt_pP->enb_module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal ((ctxt_pP->enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ctxt_pP->ue_module_id < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ctxt_pP->ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ctxt_pP->ue_module_id >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(ctxt_pP) #endif @@ -147,11 +122,8 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.am, rb_id); } else { - LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_id); } @@ -169,11 +141,8 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.dl_UM_RLC, rb_id); } else { - LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_id); } @@ -191,11 +160,8 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP NULL, rb_id); } else { - LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_id); } @@ -213,22 +179,16 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_DL.dl_UM_RLC, rb_id); } else { - LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_id); } break; default: - LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] UNKNOWN RLC CONFIG %d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT" UNKNOWN RLC CONFIG %d \n", + PROTOCOL_CTXT_ARGS(ctxt_pP), srb_toaddmod_p->rlc_Config->choice.explicitValue.present); break; } @@ -248,11 +208,8 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP NULL, // TO DO DEFAULT CONFIG rb_id); } else { - LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_id); } @@ -338,11 +295,8 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP break; default: - LOG_W(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u][RB %u] unknown drb_toaddmod_p->rlc_Config->present \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_W(RLC, PROTOCOL_CTXT_FMT"[RB %u] unknown drb_toaddmod_p->rlc_Config->present \n", + PROTOCOL_CTXT_ARGS(ctxt_pP), drb_id); } } @@ -375,18 +329,18 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP // can set the mch_id = i if (ctxt_pP->enb_flag) { rb_id = (mbms_service_id * maxSessionPerPMCH ) + mbms_session_id;//+ (maxDRB + 3) * MAX_MOBILES_PER_ENB; // 1 - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->enb_module_id][lc_id].service_id = mbms_service_id; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->enb_module_id][lc_id].session_id = mbms_session_id; + rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lc_id].service_id = mbms_service_id; + rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lc_id].session_id = mbms_session_id; + rlc_mbms_enb_set_lcid_by_rb_id(ctxt_pP->module_id,rb_id,lc_id); - rlc_mbms_enb_set_lcid_by_rb_id(ctxt_pP->enb_module_id,rb_id,lc_id); } else { rb_id = (mbms_service_id * maxSessionPerPMCH ) + mbms_session_id; // + (maxDRB + 3); // 15 - rlc_mbms_lcid2service_session_id_ue[ctxt_pP->ue_module_id][lc_id].service_id = mbms_service_id; - rlc_mbms_lcid2service_session_id_ue[ctxt_pP->ue_module_id][lc_id].session_id = mbms_session_id; - rlc_mbms_ue_set_lcid_by_rb_id(ctxt_pP->ue_module_id,rb_id,lc_id); + rlc_mbms_lcid2service_session_id_ue[ctxt_pP->module_id][lc_id].service_id = mbms_service_id; + rlc_mbms_lcid2service_session_id_ue[ctxt_pP->module_id][lc_id].session_id = mbms_session_id; + rlc_mbms_ue_set_lcid_by_rb_id(ctxt_pP->module_id,rb_id,lc_id); } - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, mbms_service_id, mbms_session_id); + key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->module_id, ctxt_pP->enb_flag, mbms_service_id, mbms_session_id); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -401,11 +355,8 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP AssertFatal(rlc_union_p != NULL, "ADD MBMS RLC UM FAILED"); } - LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] CONFIG REQ MBMS ASN1 LC ID %u RB ID %u SESSION ID %u SERVICE ID %u\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ MBMS ASN1 LC ID %u RB ID %u SESSION ID %u SERVICE ID %u\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), lc_id, rb_id, mbms_session_id, @@ -429,12 +380,8 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP #endif - LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] CONFIG REQ ASN1 END \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_flag, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id); + LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ ASN1 END \n", + PROTOCOL_CTXT_ARGS(ctxt_pP)); return RLC_OP_STATUS_OK; } //----------------------------------------------------------------------------- @@ -505,37 +452,14 @@ rlc_op_status_t rrc_rlc_remove_rlc ( { //----------------------------------------------------------------------------- logical_chan_id_t lcid = 0; - hash_key_t key = HASHTABLE_QUESTIONABLE_KEY_VALUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; rlc_union_t *rlc_union_p = NULL; #ifdef Rel10 rlc_mbms_id_t *mbms_id_p = NULL; #endif #ifdef OAI_EMU - AssertFatal ((ctxt_pP->enb_module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal (ctxt_pP->enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), - "eNB module id is too high (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - - if (ctxt_pP->enb_flag) { - AssertFatal (ctxt_pP->ue_module_id < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ctxt_pP->ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ctxt_pP->ue_module_id >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(ctxt_pP) #endif @@ -543,26 +467,25 @@ rlc_op_status_t rrc_rlc_remove_rlc ( if (MBMS_flagP == TRUE) { if (ctxt_pP->enb_flag) { - lcid = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->enb_module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->enb_module_id][lcid]; + lcid = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); + mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid]; + rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].service_id = 0; + rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].session_id = 0; + rlc_mbms_rbid2lcid_ue[ctxt_pP->module_id][rb_idP] = RLC_LC_UNALLOCATED; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->enb_module_id][lcid].service_id = 0; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->enb_module_id][lcid].session_id = 0; - rlc_mbms_rbid2lcid_ue[ctxt_pP->enb_module_id][rb_idP] = RLC_LC_UNALLOCATED; } else { - lcid = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->ue_module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->ue_module_id][lcid]; - - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->ue_module_id][lcid].service_id = 0; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->ue_module_id][lcid].session_id = 0; - rlc_mbms_rbid2lcid_ue[ctxt_pP->ue_module_id][rb_idP] = RLC_LC_UNALLOCATED; + lcid = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); + mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->module_id][lcid]; + rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].service_id = 0; + rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].session_id = 0; + rlc_mbms_rbid2lcid_ue[ctxt_pP->module_id][rb_idP] = RLC_LC_UNALLOCATED; } - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); + key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); } else #endif { - key = RLC_COLL_KEY_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, rb_idP, srb_flagP); + key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); } @@ -572,29 +495,20 @@ rlc_op_status_t rrc_rlc_remove_rlc ( if (h_rc == HASH_TABLE_OK) { h_rc = hashtable_remove(rlc_coll_p, key); - LOG_D(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] RELEASED %s\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u] RELEASED %s\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, (srb_flagP) ? "SRB" : "DRB"); } else if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) { - LOG_D(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] RELEASE : RLC NOT FOUND %s\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u] RELEASE : RLC NOT FOUND %s\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, (srb_flagP) ? "SRB" : "DRB"); } else { - LOG_E(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] RELEASE : INTERNAL ERROR %s\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %u] RELEASE : INTERNAL ERROR %s\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, (srb_flagP) ? "SRB" : "DRB"); @@ -612,7 +526,7 @@ rlc_union_t* rrc_rlc_add_rlc ( const rlc_mode_t rlc_modeP) { //----------------------------------------------------------------------------- - hash_key_t key = HASHTABLE_QUESTIONABLE_KEY_VALUE; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; rlc_union_t *rlc_union_p = NULL; #ifdef Rel10 @@ -622,29 +536,7 @@ rlc_union_t* rrc_rlc_add_rlc ( #ifdef OAI_EMU - if (ctxt_pP->enb_flag) { - AssertFatal ((ctxt_pP->enb_module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal ((ctxt_pP->enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ctxt_pP->ue_module_id < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ctxt_pP->ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ctxt_pP->ue_module_id >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(ctxt_pP) #endif @@ -657,40 +549,32 @@ rlc_union_t* rrc_rlc_add_rlc ( if (MBMS_flagP == TRUE) { if (ctxt_pP->enb_flag) { - lcid = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->enb_module_id,rb_idP); - LOG_I(RLC, - "[Frame %05u] lcid %d = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->enb_module_id %u, rb_idP %u)\n", - ctxt_pP->frame,lcid, ctxt_pP->enb_module_id, rb_idP); - - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->enb_module_id][lcid]; + lcid = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); + mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid]; + //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].service_id = 0; + //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].session_id = 0; + //LG 2014-04-15rlc_mbms_rbid2lcid_eNB[ctxt_pP->module_id][rb_idP] = RLC_LC_UNALLOCATED; - //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->enb_module_id][lcid].service_id = 0; - //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->enb_module_id][lcid].session_id = 0; - //LG 2014-04-15rlc_mbms_rbid2lcid_eNB[ctxt_pP->enb_module_id][rb_idP] = RLC_LC_UNALLOCATED; } else { - lcid = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->ue_module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->ue_module_id][lcid]; - - //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->ue_module_id][lcid].service_id = 0; - //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->ue_module_id][lcid].session_id = 0; - //LG 2014-04-15rlc_mbms_rbid2lcid_ue[ctxt_pP->ue_module_id][rb_idP] = RLC_LC_UNALLOCATED; + lcid = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); + mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->module_id][lcid]; + //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].service_id = 0; + //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].session_id = 0; + //LG 2014-04-15rlc_mbms_rbid2lcid_ue[ctxt_pP->module_id][rb_idP] = RLC_LC_UNALLOCATED; } - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); + key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); } else #endif { - key = RLC_COLL_KEY_VALUE(ctxt_pP->enb_module_id, ctxt_pP->ue_module_id, ctxt_pP->enb_flag, rb_idP, srb_flagP); + key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { - LOG_W(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] rrc_rlc_add_rlc , already exist %s\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_W(RLC, PROTOCOL_CTXT_FMT"[%s %u] rrc_rlc_add_rlc , already exist %s\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, (srb_flagP) ? "SRB" : "DRB"); @@ -704,21 +588,15 @@ rlc_union_t* rrc_rlc_add_rlc ( #ifdef Rel10 if (MBMS_flagP == TRUE) { - LOG_I(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u] RLC service id %u session id %u rrc_rlc_add_rlc\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_I(RLC, PROTOCOL_CTXT_FMT" RLC service id %u session id %u rrc_rlc_add_rlc\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), mbms_id_p->service_id, mbms_id_p->session_id); } else #endif { - LOG_I(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] rrc_rlc_add_rlc %s\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_I(RLC, PROTOCOL_CTXT_FMT" [%s %u] rrc_rlc_add_rlc %s\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, (srb_flagP) ? "SRB" : "DRB"); @@ -727,11 +605,8 @@ rlc_union_t* rrc_rlc_add_rlc ( rlc_union_p->mode = rlc_modeP; return rlc_union_p; } else { - LOG_E(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] rrc_rlc_add_rlc FAILED %s\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %u] rrc_rlc_add_rlc FAILED %s\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, (srb_flagP) ? "SRB" : "DRB"); @@ -740,11 +615,8 @@ rlc_union_t* rrc_rlc_add_rlc ( return NULL; } } else { - LOG_E(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] rrc_rlc_add_rlc , INTERNAL ERROR %s\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %u] rrc_rlc_add_rlc , INTERNAL ERROR %s\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, (srb_flagP) ? "SRB" : "DRB"); @@ -764,38 +636,13 @@ rlc_op_status_t rrc_rlc_config_req ( //----------------------------------------------------------------------------- rlc_op_status_t status; - LOG_D(RLC, "[FRAME %05u][%s][RLC][MOD %u/%u] CONFIG_REQ for Rab %u\n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG_REQ for RAB %u\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); #ifdef OAI_EMU - if (ctxt_pP->enb_flag) { - AssertFatal ((ctxt_pP->enb_module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too low (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local); - AssertFatal ((ctxt_pP->enb_module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0), - "eNB module id is too high (%u/%d)!\n", - ctxt_pP->enb_module_id, - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); - AssertFatal (ctxt_pP->ue_module_id < NB_UE_INST, - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - } else { - AssertFatal (ctxt_pP->ue_module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), - "UE module id is too high (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - AssertFatal (ctxt_pP->ue_module_id >= oai_emulation.info.first_ue_local, - "UE module id is too low (%u/%d)!\n", - ctxt_pP->ue_module_id, - oai_emulation.info.first_ue_local); - } + CHECK_CTXT_ARGS(ctxt_pP) #endif AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); @@ -811,10 +658,8 @@ rlc_op_status_t rrc_rlc_config_req ( case CONFIG_ACTION_MODIFY: switch (rlc_infoP.rlc_mode) { case RLC_MODE_AM: - LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB AM\n", - ctxt_pP->frame, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_I(RLC, PROTOCOL_CTXT_FMT"[RB %u] MODIFY RB AM\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); config_req_rlc_am( @@ -825,10 +670,8 @@ rlc_op_status_t rrc_rlc_config_req ( break; case RLC_MODE_UM: - LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB UM\n", - ctxt_pP->frame, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_I(RLC, PROTOCOL_CTXT_FMT"[RB %u] MODIFY RB UM\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); config_req_rlc_um( ctxt_pP, @@ -838,10 +681,8 @@ rlc_op_status_t rrc_rlc_config_req ( break; case RLC_MODE_TM: - LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB TM\n", - ctxt_pP->frame, - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, + LOG_I(RLC, PROTOCOL_CTXT_FMT"[RB %u] MODIFY RB TM\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); config_req_rlc_tm( ctxt_pP, diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c index 0afce072508..309f6313011 100644 --- a/openair2/LAYER2/openair2_proc.c +++ b/openair2/LAYER2/openair2_proc.c @@ -211,8 +211,9 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) len+=sprintf(&buffer[len],"CH %d: Subband SINR (dB) :", CH_index); - for (fg=0; fg<NUMBER_OF_MEASUREMENT_SUBBANDS; fg++) + for (fg=0; fg<NUMBER_OF_MEASUREMENT_SUBBANDS; fg++) { len+=sprintf(&buffer[len],"%d ",UE_mac_inst[Mod_id].Def_meas[CH_index].Sinr_meas[0][fg]); + } len+=sprintf(&buffer[len],"\n"); @@ -245,9 +246,12 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) if(Overhead<0) { Overhead=-Overhead; Sign=-1; - } else Sign=1; + } else { + Sign=1; + } - len+=sprintf(&buffer[len],"[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s) , LAYER2 TX OVERHEAD: %d Kbits/s\n", + len+=sprintf(&buffer[len], + "[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s) , LAYER2 TX OVERHEAD: %d Kbits/s\n", UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, Pdcp_stats_tx[k][CH_index][i], Pdcp_stats_tx_rate[k][CH_index][i], @@ -304,8 +308,9 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_RX_ERRORS); len+=sprintf(&buffer[len]," TX per TB: "); - for(kk=0; kk<MAX_NUMBER_TB_PER_LCHAN/2; kk++) + for(kk=0; kk<MAX_NUMBER_TB_PER_LCHAN/2; kk++) { len+=sprintf(&buffer[len],"%d . ",UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_TX_TB[kk]); + } len+=sprintf(&buffer[len],"\n"); len+=sprintf(&buffer[len]," RXerr per TB: "); @@ -325,12 +330,11 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) } #endif //PHY_EMUL_ONE_MACHINE - } - - else if(Mac_rlc_xface->Is_cluster_head[k] ==1) { + } else if(Mac_rlc_xface->Is_cluster_head[k] ==1) { Mod_id=k; - len+=sprintf(&buffer[len],"-------------------------------------------------------------------CH %d: TTI: %d------------------------------------------------------------------\n", + len+=sprintf(&buffer[len], + "-------------------------------------------------------------------CH %d: TTI: %d------------------------------------------------------------------\n", NODE_ID[Mod_id],Mac_rlc_xface->frame); for(i=1; i<=NB_CNX_CH; i++) { @@ -340,7 +344,8 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) CH_mac_inst[Mod_id].Def_meas[i].Wideband_sinr, print_cqi(CH_mac_inst[Mod_id].Def_meas[i].cqi)); - len+=sprintf(&buffer[len],"[MAC] LCHAN %d (DCCH), NB_TX_MAC= %d (%d bits/TTI, %d kbits/s), NB_RX_MAC= %d (errors %d, sacch errors %d, sach errors %d, sach_missing %d)\n\n", + len+=sprintf(&buffer[len], + "[MAC] LCHAN %d (DCCH), NB_TX_MAC= %d (%d bits/TTI, %d kbits/s), NB_RX_MAC= %d (errors %d, sacch errors %d, sach errors %d, sach_missing %d)\n\n", CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.Lchan_id.Index, CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.NB_TX, CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.output_rate, @@ -358,9 +363,12 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) if(Overhead<0) { Overhead=-Overhead; Sign=-1; - } else Sign=1; + } else { + Sign=1; + } - len+=sprintf(&buffer[len],"[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s), LAYER2 TX OVERHEAD= %d Kbits/s\n", + len+=sprintf(&buffer[len], + "[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s), LAYER2 TX OVERHEAD= %d Kbits/s\n", CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, Pdcp_stats_tx[k][i][j], Pdcp_stats_tx_rate[k][i][j], @@ -406,7 +414,8 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) rx_error_pdu); } */ - len+=sprintf(&buffer[len],"[MAC]LCHAN %d (CNX %d,RAB %d), NB_TX_MAC= %d (%d bits/TTI, %d kbit/s), NB_RX_MAC= %d (errors %d, sacch_errors %d, sach_errors %d, sach_missing %d)\n", + len+=sprintf(&buffer[len], + "[MAC]LCHAN %d (CNX %d,RAB %d), NB_TX_MAC= %d (%d bits/TTI, %d kbit/s), NB_RX_MAC= %d (errors %d, sacch_errors %d, sach_errors %d, sach_missing %d)\n", CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, i,j, CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_TX, @@ -459,8 +468,9 @@ int add_openair2_stats() // pde = proc_create_entry("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root); pde = proc_create_data("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root, NULL,openair2_stats_read); - if (!pde) + if (!pde) { printk("[OPENAIR][ERROR] can't create proc entry !\n"); + } return 0; } diff --git a/openair2/Makefile b/openair2/Makefile index b07b75fa4a7..829e2547db8 100755 --- a/openair2/Makefile +++ b/openair2/Makefile @@ -37,7 +37,7 @@ #LM_LICENSE_FILE= #export LM_LICENSE_FILE -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc KERNEL_NAME:=$(shell uname -r) NUM_CORES=$(shell getconf _NPROCESSORS_CONF) @@ -143,40 +143,40 @@ nasmesh.ko: # automatically detect the linux header files for driver compilation nasmesh_netlink.ko: - (cd NAS/DRIVER/MESH && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NAS/DRIVER/MESH && $(MAKE) -j$(NUM_CORES) $(SET_UM) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) naslite_netlink_ether.ko: - (cd NAS/DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 NAS_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NAS/DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) oai_nw_ether.ko: - (cd NAS/DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 NAS_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NAS/DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) oai_nw_drv.ko: - (cd NAS/DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 NAS_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NAS/DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) nasmesh_netlink_address_fix.ko: - (cd NAS/DRIVER/MESH && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_NETLINK=1 ADDRESS_FIX=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NAS/DRIVER/MESH && $(MAKE) -j$(NUM_CORES) $(SET_UM) PDCP_USE_NETLINK=1 ADDRESS_FIX=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) nasmesh_netlink_loopback.ko: - (cd NAS/DRIVER/MESH && $(MAKE) $(SET_UM) NAS_NETLINK=1 LOOPBACK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NAS/DRIVER/MESH && $(MAKE) $(SET_UM) PDCP_USE_NETLINK=1 LOOPBACK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) # drivers cellular version nascellmt_netlink.ko: - (cd NAS/DRIVER/CELLULAR/NASMT && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 NAS_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NAS/DRIVER/CELLULAR/NASMT && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) nascellmt_clean.ko: - (cd NAS/DRIVER/CELLULAR/NASMT && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 NAS_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` clean) + (cd NAS/DRIVER/CELLULAR/NASMT && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` clean) nascellrg_netlink.ko: - (cd NAS/DRIVER/CELLULAR/NASRG && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 NAS_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NAS/DRIVER/CELLULAR/NASRG && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) nascellrg_clean.ko: - (cd NAS/DRIVER/CELLULAR/NASRG && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 NAS_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` clean) + (cd NAS/DRIVER/CELLULAR/NASRG && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` clean) # Driver for UE using LTE core network (MME, S+P-GW) ue_ip.ko: - (cd NETWORK_DRIVER/UE_IP && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) + (cd NETWORK_DRIVER/UE_IP && $(MAKE) -j$(NUM_CORES) $(SET_UM) PDCP_USE_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) rt_emul: diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/Makefile b/openair2/NAS/DRIVER/CELLULAR/NASMT/Makefile index 4e3f412addf..ec14990d632 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/Makefile +++ b/openair2/NAS/DRIVER/CELLULAR/NASMT/Makefile @@ -1,6 +1,6 @@ # NAS CELLULAR Driver makefile # -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc NAS_UPDIR := $(shell /bin/pwd) #################################################### @@ -21,8 +21,8 @@ EXTRA_CFLAGS += -DNAS_DRIVER_TYPE_ETHERNET endif -ifdef NAS_NETLINK -EXTRA_CFLAGS += -DNAS_NETLINK +ifdef PDCP_USE_NETLINK +EXTRA_CFLAGS += -DPDCP_USE_NETLINK else EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall endif @@ -52,7 +52,7 @@ nascellmt-objs += nasmt_iocontrol.o nascellmt-objs += nasmt_classifier.o nascellmt-objs += nasmt_tool.o nascellmt-objs += nasmt_ascontrol.o -ifdef NAS_NETLINK +ifdef PDCP_USE_NETLINK nascellmt-objs += nasmt_netlink.o endif @@ -61,7 +61,7 @@ endif #################################################### #netlink.ko: - #make $(x)$(y) NAS_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules + #make $(x)$(y) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules #nasmesh.ko: # make V=1 -C $(KERNEL_DIR) M=`pwd` modules diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_ascontrol.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_ascontrol.c index 3424142150b..8e946f04e21 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_ascontrol.c +++ b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_ascontrol.c @@ -59,7 +59,7 @@ int nasmt_ASCTL_write(int sap, unsigned char *data_buffer, unsigned int data_len { //--------------------------------------------------------------------------- int bytes_wrote = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK unsigned char xmit_buffer [NAS_MESSAGE_MAXLEN]; //MT xmit on DC-SAP only xmit_buffer[0] = RRC_NAS_DC0_IN; @@ -68,7 +68,7 @@ int nasmt_ASCTL_write(int sap, unsigned char *data_buffer, unsigned int data_len #else //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version bytes_wrote = rtf_put(sap, data_buffer, data_length); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK return bytes_wrote; } @@ -443,7 +443,7 @@ void nasmt_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity struct nas_ue_dc_element *p; char data_type = 'A'; int bytes_wrote = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; int count=0; #endif @@ -472,7 +472,7 @@ void nasmt_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity p->nasUEDCPrimitive.data_transfer_req.nasDataLength = (skb->len)+1; //adds category character //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(xbuffer,(unsigned char *)p, p->length); count = p->length; bytes_wrote = count; @@ -486,7 +486,7 @@ void nasmt_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity return; } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(&(xbuffer[count]),(unsigned char *)&data_type, 1); count += 1; bytes_wrote = count; @@ -494,7 +494,7 @@ void nasmt_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity bytes_wrote += nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)&data_type, 1); #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(&(xbuffer[count]),(unsigned char *)skb->data, skb->len); count += skb->len; bytes_wrote = nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], xbuffer, count); @@ -524,7 +524,7 @@ void nasmt_ASCTL_DC_send_peer_sig_data_request(struct cx_entity *cx, uint8_t sig unsigned int nasmt_length; char data_type = 'Z'; int bytes_wrote = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; int count=0; #endif @@ -559,7 +559,7 @@ void nasmt_ASCTL_DC_send_peer_sig_data_request(struct cx_entity *cx, uint8_t sig p->nasUEDCPrimitive.data_transfer_req.nasDataLength = (nasmt_length)+1; //adds category character //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(xbuffer,(unsigned char *)p, p->length); count = p->length; bytes_wrote = count; @@ -573,14 +573,14 @@ void nasmt_ASCTL_DC_send_peer_sig_data_request(struct cx_entity *cx, uint8_t sig return; } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(&(xbuffer[count]),(unsigned char *)&data_type, 1); count += 1; #else bytes_wrote += nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)&data_type, 1); #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(&(xbuffer[count]),(unsigned char *)nasmt_data, nasmt_length); count += nasmt_length; bytes_wrote = nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], xbuffer, count); @@ -720,7 +720,7 @@ void nasmt_ASCTL_DC_decode_sig_data_ind(struct cx_entity *cx, struct nas_ue_dc_e #endif //nasmt_COMMON_receive(p->length, p->nasUEDCPrimitive.data_transfer_ind.nasDataLength, cx->sap[GRAAL_DC_OUTPUT_SAPI]); // original -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); // data_buffer is NULL because FIFO should be read directly in the skbuff (LITE has an intermediary buffer) nasmt_COMMON_receive(p->length, p->nasUEDCPrimitive.data_transfer_ind.nasDataLength, NULL, 2, cx->sap[NAS_DC_OUTPUT_SAPI]); @@ -945,7 +945,7 @@ int nasmt_ASCTL_DC_receive(struct cx_entity *cx, char *buffer) // End debug information -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK bytes_read = rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI] , gpriv->rbuffer, NAS_TL_SIZE); #else bytes_read = NAS_TL_SIZE; @@ -955,7 +955,7 @@ int nasmt_ASCTL_DC_receive(struct cx_entity *cx, char *buffer) if (bytes_read>0) { struct nas_ue_dc_element *p; -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK p= (struct nas_ue_dc_element *)(gpriv->rbuffer); //get the rest of the primitive bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], (uint8_t *)p+NAS_TL_SIZE, p->length-NAS_TL_SIZE); @@ -1105,7 +1105,7 @@ int nasmt_ASCTL_GC_receive(char *buffer) #endif // End debug information -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK bytes_read = rtf_get(gpriv->sap[NAS_GC_SAPI], gpriv->rbuffer, NAS_TL_SIZE); #else bytes_read = NAS_TL_SIZE; @@ -1114,7 +1114,7 @@ int nasmt_ASCTL_GC_receive(char *buffer) // if (bytes_read>0) { struct nas_ue_gc_element *p; -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK p= (struct nas_ue_gc_element *)(gpriv->rbuffer); //get the rest of the primitive bytes_read += rtf_get(gpriv->sap[NAS_GC_SAPI], (uint8_t *)p+NAS_TL_SIZE, p->length-NAS_TL_SIZE); @@ -1132,7 +1132,7 @@ int nasmt_ASCTL_GC_receive(char *buffer) // start decoding message switch (p->type) { case INFO_BROADCAST_IND : -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK bytes_read += rtf_get(gpriv->sap[NAS_GC_SAPI], (uint8_t *)p+p->length, p->nasUEGCPrimitive.broadcast_ind.nasDataLength); if (bytes_read!=p->length+p->nasUEGCPrimitive.broadcast_ind.nasDataLength) { diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_common.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_common.c index 8bdaff1cc84..8006cccc749 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_common.c +++ b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_common.c @@ -57,7 +57,7 @@ void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *da #ifdef NAS_DEBUG_RECEIVE printk("nasmt_COMMON_receive: begin\n"); #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK // data_buffer is NULL if FIFOs if (!data_buffer) { @@ -77,7 +77,7 @@ void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *da skb_reserve(skb,2); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK bytes_read += rtf_get(sap, skb_put(skb, payload_length), payload_length); if (bytes_read != NAS_PDCPH_SIZE + payload_length) { @@ -247,14 +247,14 @@ void nasmt_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct cla pdcph.rb_id = ((gc->rb)->rab_id+(32*cx->lcr))-NAS_SIG_NUM_SRB; pdcph.inst = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK bytes_wrote = nasmt_netlink_send((unsigned char *)&pdcph,NAS_PDCPH_SIZE, NASNL_DEST_PDCP); //printk("nasmt_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n", bytes_wrote,skb->len); #else //bytes_wrote = rtf_put(gpriv->sap[(gc->rb)->sapi], &pdcph, NAS_PDCPH_SIZE); bytes_wrote = rtf_put(NAS2PDCP_FIFO, &pdcph, NAS_PDCPH_SIZE); //printk("nasmt_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP fifo\n", bytes_wrote,skb->len); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK if (bytes_wrote != NAS_PDCPH_SIZE) { printk("nasmt_COMMON_QOS_send: problem while writing PDCP's header\n"); @@ -263,12 +263,12 @@ void nasmt_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct cla return; } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK bytes_wrote += nasmt_netlink_send((unsigned char *)skb->data,skb->len, NASNL_DEST_PDCP); #else //bytes_wrote += rtf_put(gpriv->sap[(gc->rb)->sapi], skb->data, skb->len); bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK if (bytes_wrote != skb->len + NAS_PDCPH_SIZE) { printk("nasmt_COMMON_QOS_send: problem while writing PDCP's data\n"); // congestion @@ -287,7 +287,7 @@ void nasmt_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct cla #endif } -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //--------------------------------------------------------------------------- void nasmt_COMMON_QOS_receive(struct cx_entity *cx) { @@ -361,7 +361,7 @@ void nasmt_COMMON_QOS_receive(struct nlmsghdr *nlh) nasmt_COMMON_receive(NAS_PDCPH_SIZE + pdcph->data_size, pdcph->data_size, (unsigned char *)NLMSG_DATA(nlh) + NAS_PDCPH_SIZE, pdcph->rb_id, 0); } -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK //--------------------------------------------------------------------------- diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_constant.h b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_constant.h index 0ea762a01da..c7728049494 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_constant.h +++ b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_constant.h @@ -203,7 +203,7 @@ /**********************************************************/ /* Constants related with Netlink sockets */ /**********************************************************/ -#define NAS_NETLINK_ID 31 +#define OAI_IP_DRIVER_NETLINK_ID 31 #define NL_DEST_PID 1 // defined in rrc_nas_sap.h diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_device.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_device.c index 10f4221283f..91fb934e0ae 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_device.c +++ b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_device.c @@ -35,12 +35,12 @@ * \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr */ /*******************************************************************************/ -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK #ifdef RTAI #include "rtai_posix.h" #define RTAI_IRQ 30 //try to get this irq with RTAI #endif // RTAI -#endif // NAS_NETLINK +#endif // PDCP_USE_NETLINK //:::::::::::::::::::::::::::::::::::::::;; #include "nasmt_variables.h" #include "nasmt_proto.h" @@ -81,14 +81,14 @@ static unsigned char nas_IMEI[14]; static int m_arg=0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK extern void nasmt_netlink_release(void); extern int nasmt_netlink_init(void); #endif extern void nasmt_ASCTL_timer(unsigned long data); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //--------------------------------------------------------------------------- //void nasmt_interrupt(void){ void *nasmt_interrupt(void) @@ -121,7 +121,7 @@ int nasmt_open(struct net_device *dev) gpriv=netdev_priv(dev); // Address has already been set at init -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK if (gpriv->irq==-EBUSY) { printk("nasmt_open: irq failure\n"); @@ -169,26 +169,26 @@ void nasmt_teardown(struct net_device *dev) { //--------------------------------------------------------------------------- int cxi; -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK struct nas_priv *priv = netdev_priv(dev); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK printk("nasmt_teardown: begin\n"); // priv=(struct nas_priv *)(gdev.priv); if (dev) { -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK if (priv->irq!=-EBUSY) { *pt_nas_ue_irq=-1; rt_free_srq(priv->irq); } -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK nasmt_netlink_release(); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK // for (sapi=0; sapi<NAS_SAPI_MAX; ++sapi) // close(priv->sap[sapi]); nasmt_CLASS_flush_rclassifier(); @@ -395,7 +395,7 @@ void nasmt_init(struct net_device *dev) //gpriv->sap[NAS_CO_INPUT_SAPI] = QOS_DEVICE_CONVERSATIONAL_INPUT; //gpriv->sap[NAS_CO_OUTPUT_SAPI] = QOS_DEVICE_CONVERSATIONAL_OUTPUT; - gpriv->sap[NAS_DRB_INPUT_SAPI] = PDCP2NAS_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; + gpriv->sap[NAS_DRB_INPUT_SAPI] = PDCP2PDCP_USE_RT_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; gpriv->sap[NAS_DRB_OUTPUT_SAPI] = NAS2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT; gpriv->retry_limit = NAS_RETRY_LIMIT_DEFAULT; @@ -469,7 +469,7 @@ int init_module (void) printk("\n"); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK // Initialize parameters shared with RRC (done first to avoid going further) if (pt_nas_ue_irq==NULL) { @@ -491,7 +491,7 @@ int init_module (void) #endif priv = netdev_priv(gdev); //// -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK priv->irq=rt_request_srq(0, nasmt_interrupt, NULL); if (priv->irq == -EBUSY || priv->irq == -EINVAL) { @@ -514,7 +514,7 @@ int init_module (void) #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK if ((err=nasmt_netlink_init()) == -1) printk("init_module: NETLINK failed\n"); diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_netlink.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_netlink.c index bf27d0a26e2..17e94bb3c08 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_netlink.c +++ b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_netlink.c @@ -133,7 +133,7 @@ int nasmt_netlink_init(void) //--------------------------------------------------------------------------- printk("nasmt_netlink_init - begin \n"); - nas_nl_sk = netlink_kernel_create(&init_net,NAS_NETLINK_ID, 0, nasmt_nl_data_ready, + nas_nl_sk = netlink_kernel_create(&init_net,OAI_IP_DRIVER_NETLINK_ID, 0, nasmt_nl_data_ready, &nasmt_mutex, // NULL THIS_MODULE); diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_proto.h b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_proto.h index d846fa33ea9..cabc5150342 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_proto.h +++ b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_proto.h @@ -71,7 +71,7 @@ void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *da void nasmt_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); void nasmt_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK void nasmt_COMMON_QOS_receive(struct cx_entity *cx); #else void nasmt_COMMON_QOS_receive(struct nlmsghdr *nlh); diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_sap.h b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_sap.h index 4dfa88b0b35..a9af1ca4caf 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_sap.h +++ b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_sap.h @@ -45,7 +45,7 @@ //#define QOS_DEVICE_CONVERSATIONAL_INPUT QOS_SAPI_CONVERSATIONAL_INPUT_MT //#define QOS_DEVICE_CONVERSATIONAL_OUTPUT QOS_SAPI_CONVERSATIONAL_OUTPUT_MT -#define PDCP2NAS_FIFO 21 +#define PDCP2PDCP_USE_RT_FIFO 21 #define NAS2PDCP_FIFO 22 //FIFO indexes in control blocks diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/Makefile b/openair2/NAS/DRIVER/CELLULAR/NASRG/Makefile index 285f07aeb6a..758fa0420b0 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/Makefile +++ b/openair2/NAS/DRIVER/CELLULAR/NASRG/Makefile @@ -1,6 +1,6 @@ # NAS CELLULAR Driver makefile # -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc NAS_UPDIR := $(shell /bin/pwd) @@ -22,8 +22,8 @@ EXTRA_CFLAGS += -DNAS_DRIVER_TYPE_ETHERNET endif -ifdef NAS_NETLINK -EXTRA_CFLAGS += -DNAS_NETLINK +ifdef PDCP_USE_NETLINK +EXTRA_CFLAGS += -DPDCP_USE_NETLINK else EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall endif @@ -53,7 +53,7 @@ nascellrg-objs += nasrg_iocontrol.o nascellrg-objs += nasrg_classifier.o nascellrg-objs += nasrg_tool.o nascellrg-objs += nasrg_ascontrol.o -ifdef NAS_NETLINK +ifdef PDCP_USE_NETLINK nascellrg-objs += nasrg_netlink.o endif @@ -62,7 +62,7 @@ endif #################################################### #netlink.ko: - #make $(x)$(y) NAS_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules + #make $(x)$(y) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules #nasmesh.ko: # make V=1 -C $(KERNEL_DIR) M=`pwd` modules diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_ascontrol.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_ascontrol.c index a9b549ad4ec..53d0e14aeb9 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_ascontrol.c +++ b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_ascontrol.c @@ -64,7 +64,7 @@ int nasrg_ASCTL_write(int sap, unsigned char *data_buffer, unsigned int data_len { //--------------------------------------------------------------------------- int bytes_wrote = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK unsigned char xmit_buffer [NAS_MESSAGE_MAXLEN]; //write SAP_Id @@ -102,7 +102,7 @@ int nasrg_ASCTL_write(int sap, unsigned char *data_buffer, unsigned int data_len #else //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version bytes_wrote = rtf_put(sap, data_buffer, data_length+1); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK return bytes_wrote-1; } @@ -410,7 +410,7 @@ int nasrg_ASCTL_GC_send_broadcast_request(uint8_t category) //--------------------------------------------------------------------------- char *xmit_data = "TESTING BROADCASTING ROUTER ADVERTISEMENT. TESTING BROADCASTING ROUTER ADVERTISEMENT. BROADCASTING ROUTER.\0"; int bytes_wrote = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; int count=0; #endif @@ -425,7 +425,7 @@ int nasrg_ASCTL_GC_send_broadcast_request(uint8_t category) p->nasRGGCPrimitive.broadcast_req.nasDataLength = strlen(xmit_data)+1; // TBD //bytes_wrote = rtf_put(gpriv->sap[NAS_GC_SAPI], p, p->length); //original version -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(xbuffer,(unsigned char *)p, p->length); count = p->length; bytes_wrote = count; @@ -435,7 +435,7 @@ int nasrg_ASCTL_GC_send_broadcast_request(uint8_t category) //printk("nasrg_ASCTL_GC_send_broadcast_request - Wrote %d bytes to RRC NAS_GC_SAPII\n", bytes_wrote); //bytes_wrote += rtf_put(gpriv->sap[NAS_GC_SAPI], xmit_data, p->nasRGGCPrimitive.broadcast_req.nasDataLength); -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(&(xbuffer[count]),(unsigned char *)xmit_data, p->nasRGGCPrimitive.broadcast_req.nasDataLength); count += p->nasRGGCPrimitive.broadcast_req.nasDataLength; bytes_wrote += nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], xbuffer, count); @@ -462,7 +462,7 @@ int nasrg_ASCTL_GC_send_SIB1_broadcast_request(struct sk_buff *skb) struct nas_rg_gc_element *p; char sib1_flag; // will be used for reception in nas_ue int bytes_wrote = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; int count=0; #endif @@ -488,7 +488,7 @@ int nasrg_ASCTL_GC_send_SIB1_broadcast_request(struct sk_buff *skb) sib1_flag = 1; // send header //bytes_wrote = rtf_put(gpriv->sap[NAS_GC_SAPI], p, p->length); //original version -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(xbuffer,(unsigned char *)p, p->length); count = p->length; bytes_wrote = count; @@ -505,7 +505,7 @@ int nasrg_ASCTL_GC_send_SIB1_broadcast_request(struct sk_buff *skb) // send sib1_flag //bytes_wrote += rtf_put(gpriv->sap[NAS_GC_SAPI], &sib1_flag, 1); -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(&(xbuffer[count]),(unsigned char *)&sib1_flag, 1); count += 1; bytes_wrote = count; @@ -520,7 +520,7 @@ int nasrg_ASCTL_GC_send_SIB1_broadcast_request(struct sk_buff *skb) // send data //bytes_wrote += rtf_put(gpriv->sap[NAS_GC_SAPI], skb->data, skb->len); -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(&(xbuffer[count]),skb->data, skb->len); count += skb->len; bytes_wrote = nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], xbuffer, count); @@ -827,7 +827,7 @@ void nasrg_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity //--------------------------------------------------------------------------- struct nas_rg_dc_element *p; int bytes_wrote = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; int count=0; #endif @@ -857,7 +857,7 @@ void nasrg_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity p->nasRGDCPrimitive.data_transfer_req.nasDataLength = skb->len; // //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(xbuffer,(unsigned char *)p, p->length); count = p->length; bytes_wrote = count; @@ -871,7 +871,7 @@ void nasrg_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity } //bytes_wrote += rtf_put(cx->sap[NAS_DC_INPUT_SAPI], skb->data, skb->len); -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK memcpy(&(xbuffer[count]),(unsigned char *)skb->data, skb->len); count += skb->len; bytes_wrote = nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], xbuffer, count); @@ -1110,7 +1110,7 @@ void nasrg_ASCTL_DC_decode_data_transfer_ind(struct cx_entity *cx, struct nas_rg bytes_read=p->length; // Get first character nas_length = (p->nasRGDCPrimitive.data_transfer_ind.nasDataLength) -1; -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], &data_type, 1); #else memcpy (&data_type, (char *)(&buffer[bytes_read]), 1); @@ -1121,7 +1121,7 @@ void nasrg_ASCTL_DC_decode_data_transfer_ind(struct cx_entity *cx, struct nas_rg if (data_type =='A') { // receive in a skbuff //nasrg_COMMON_receive((p->length) + 1, nas_length, cx->sap[NAS_DC_OUTPUT_SAPI]); // original -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); // data_buffer is NULL because FIFO should be read directly in the skbuff (LITE has an intermediary buffer) nasrg_COMMON_receive((p->length) + 1, nas_length, NULL, 2, cx->sap[NAS_DC_OUTPUT_SAPI]); @@ -1131,12 +1131,12 @@ void nasrg_ASCTL_DC_decode_data_transfer_ind(struct cx_entity *cx, struct nas_rg #endif } else { // if FIFO, empty remaining data -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], (gpriv->rbuffer)+ (p->length), nas_length); #endif if (data_type=='Z') { -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK memcpy (&nasrg_data, (char *)(gpriv->rbuffer)+ (p->length), 10); #else memcpy (&nasrg_data, (char *)(&buffer[bytes_read]), 10); @@ -1350,7 +1350,7 @@ int nasrg_ASCTL_DC_receive(struct cx_entity *cx, char *buffer) // End debug information -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK bytes_read = rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI] , gpriv->rbuffer, NAS_TL_SIZE); #else bytes_read = NAS_TL_SIZE; @@ -1358,7 +1358,7 @@ int nasrg_ASCTL_DC_receive(struct cx_entity *cx, char *buffer) if (bytes_read>0) { struct nas_rg_dc_element *p; -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK p= (struct nas_rg_dc_element *)(gpriv->rbuffer); //get the rest of the primitive bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], (uint8_t *)p+NAS_TL_SIZE, p->length-NAS_TL_SIZE); diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_common.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_common.c index 63da03fba60..9857d11ec89 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_common.c +++ b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_common.c @@ -56,7 +56,7 @@ void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *da #ifdef NAS_DEBUG_RECEIVE printk("nasrg_COMMON_receive: begin\n"); #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK // data_buffer is NULL if FIFOs if (!data_buffer) { @@ -76,7 +76,7 @@ void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *da skb_reserve(skb,2); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK bytes_read += rtf_get(sap, skb_put(skb, payload_length), payload_length); if (bytes_read != NAS_PDCPH_SIZE + payload_length) { @@ -244,7 +244,7 @@ void nasrg_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct cla pdcph.rb_id = ((gc->rb)->rab_id)-NAS_SIG_NUM_SRB; pdcph.inst = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK bytes_wrote = nasrg_netlink_send((unsigned char *)&pdcph,NAS_PDCPH_SIZE, NASNL_DEST_PDCP); #ifdef NAS_DEBUG_SEND_DETAIL printk("nasrg_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n", bytes_wrote,skb->len); @@ -255,7 +255,7 @@ void nasrg_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct cla #ifdef NAS_DEBUG_SEND_DETAIL printk("nasrg_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP fifo\n", bytes_wrote,skb->len); #endif -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK if (bytes_wrote != NAS_PDCPH_SIZE) { printk("nasrg_COMMON_QOS_send: problem while writing PDCP's header\n"); @@ -269,12 +269,12 @@ void nasrg_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct cla printk("Header bytes written : %d\n", bytes_wrote); #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK bytes_wrote += nasrg_netlink_send((unsigned char *)skb->data,skb->len, NASNL_DEST_PDCP); #else //bytes_wrote += rtf_put(gpriv->sap[(gc->rb)->sapi], skb->data, skb->len); bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK if (bytes_wrote != skb->len+NAS_PDCPH_SIZE) { printk("nasrg_COMMON_QOS_send: problem while writing PDCP's data\n"); // congestion @@ -330,14 +330,14 @@ void nasrg_COMMON_QOS_send_test_netlink(struct sk_buff *skb) pdcph.rb_id = 6; pdcph.inst = 0; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK bytes_wrote = nasrg_netlink_send((unsigned char *)&pdcph,NAS_PDCPH_SIZE, NASNL_DEST_PDCP); //printk("nasrg_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n", bytes_wrote,skb->len); #else //bytes_wrote = rtf_put(gpriv->sap[(gc->rb)->sapi], &pdcph, NAS_PDCPH_SIZE); bytes_wrote = rtf_put(NAS2PDCP_FIFO, &pdcph, NAS_PDCPH_SIZE); //printk("nasrg_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP fifo\n", bytes_wrote,skb->len); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK if (bytes_wrote != NAS_PDCPH_SIZE) { printk("nasrg_COMMON_QOS_send: problem while writing PDCP's header\n"); @@ -351,12 +351,12 @@ void nasrg_COMMON_QOS_send_test_netlink(struct sk_buff *skb) printk("Header bytes wrote : %d\n", bytes_wrote); #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK bytes_wrote += nasrg_netlink_send((unsigned char *)skb->data,skb->len, NASNL_DEST_PDCP); #else //bytes_wrote += rtf_put(gpriv->sap[(gc->rb)->sapi], skb->data, skb->len); bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK if (bytes_wrote != skb->len+NAS_PDCPH_SIZE) { printk("nasrg_COMMON_QOS_send: problem while writing PDCP's data\n"); // congestion @@ -376,7 +376,7 @@ void nasrg_COMMON_QOS_send_test_netlink(struct sk_buff *skb) #endif } -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //--------------------------------------------------------------------------- void nasrg_COMMON_QOS_receive(struct cx_entity *cx) { @@ -445,7 +445,7 @@ void nasrg_COMMON_QOS_receive(struct nlmsghdr *nlh) //void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); nasrg_COMMON_receive(NAS_PDCPH_SIZE + pdcph->data_size, pdcph->data_size, (unsigned char *)NLMSG_DATA(nlh) + NAS_PDCPH_SIZE, pdcph->rb_id, 0); } -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK //--------------------------------------------------------------------------- struct cx_entity *nasrg_COMMON_search_cx(nasLocalConnectionRef_t lcr) diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_constant.h b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_constant.h index c35d3c4ccd7..d0e81aa4e65 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_constant.h +++ b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_constant.h @@ -214,7 +214,7 @@ /**********************************************************/ /* Constants related with Netlink sockets */ /**********************************************************/ -#define NAS_NETLINK_ID 31 +#define OAI_IP_DRIVER_NETLINK_ID 31 #define NL_DEST_PID 1 // defined in rrc_nas_sap.h diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_device.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_device.c index 9a2d0838c67..10dc7025404 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_device.c +++ b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_device.c @@ -35,12 +35,12 @@ * \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr */ /*******************************************************************************/ -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK #ifdef RTAI #include "rtai_posix.h" #define RTAI_IRQ 30 //try to get this irq with RTAI #endif // RTAI -#endif // NAS_NETLINK +#endif // PDCP_USE_NETLINK //:::::::::::::::::::::::::::::::::::::::;; #include "nasrg_variables.h" #include "nasrg_proto.h" @@ -75,13 +75,13 @@ uint8_t NAS_NULL_IMEI[14]= {0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x00, 0x00 uint16_t local_rg_cell_id; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK extern void nasrg_netlink_release(void); extern int nasrg_netlink_init(void); #endif extern void nasrg_ASCTL_timer(unsigned long data); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //--------------------------------------------------------------------------- void *nasrg_interrupt(void) { @@ -116,7 +116,7 @@ int nasrg_open(struct net_device *dev) gpriv=netdev_priv(dev); // Address has already been set at init -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK if (gpriv->irq==-EBUSY) { printk("nasrg_open: irq failure\n"); @@ -160,25 +160,25 @@ void nasrg_teardown(struct net_device *dev) { //--------------------------------------------------------------------------- int cxi; -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK struct nas_priv *priv = netdev_priv(dev); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK printk("nasrg_teardown: begin\n"); if (dev) { -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK if (priv->irq!=-EBUSY) { *pt_nas_rg_irq=-1; rt_free_srq(priv->irq); } -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK nasrg_netlink_release(); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK // for (sapi=0; sapi<NAS_SAPI_MAX; ++sapi) // close(priv->sap[sapi]); @@ -385,7 +385,7 @@ void nasrg_init(struct net_device *dev) gpriv->cx[1].sap[NAS_DC_OUTPUT_SAPI] = RRC_DEVICE_DC_OUTPUT1; // gpriv->sap[NAS_CO_INPUT_SAPI] = QOS_DEVICE_CONVERSATIONAL_INPUT; // gpriv->sap[NAS_CO_OUTPUT_SAPI] = QOS_DEVICE_CONVERSATIONAL_OUTPUT; - gpriv->sap[NAS_DRB_INPUT_SAPI] = PDCP2NAS_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; + gpriv->sap[NAS_DRB_INPUT_SAPI] = PDCP2PDCP_USE_RT_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; gpriv->sap[NAS_DRB_OUTPUT_SAPI] = NAS2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT; // gpriv->retry_limit=NAS_RETRY_LIMIT_DEFAULT; @@ -444,7 +444,7 @@ int init_module (void) printk("\n\n\n\nnasrg_init_module: begin \n"); // Initialize parameters shared with RRC -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK if (pt_nas_rg_irq==NULL) { printk("nasrg_init_module: shared irq parameter not initialised\n"); @@ -479,7 +479,7 @@ int init_module (void) priv = netdev_priv(gdev); //// // -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK priv->irq=rt_request_srq(0, nasrg_interrupt, NULL); if (priv->irq == -EBUSY || priv->irq == -EINVAL) { @@ -503,7 +503,7 @@ int init_module (void) #endif // ////// -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK if ((err=nasrg_netlink_init()) < 0) printk("nasrg_init_module: NETLINK failed\n"); diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_netlink.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_netlink.c index 560cc3d4322..3736bc3fcf8 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_netlink.c +++ b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_netlink.c @@ -141,7 +141,7 @@ int nasrg_netlink_init(void) //--------------------------------------------------------------------------- printk("nasrg_netlink_init - begin \n"); - nas_nl_sk = netlink_kernel_create(&init_net,NAS_NETLINK_ID, 0, nasrg_nl_data_ready, + nas_nl_sk = netlink_kernel_create(&init_net,OAI_IP_DRIVER_NETLINK_ID, 0, nasrg_nl_data_ready, &nasrg_mutex, // NULL THIS_MODULE); diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_proto.h b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_proto.h index 4e2109020c0..bc872182d5e 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_proto.h +++ b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_proto.h @@ -72,7 +72,7 @@ void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *da void nasrg_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); void nasrg_COMMON_QOS_send_test_netlink(struct sk_buff *skb); void nasrg_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK void nasrg_COMMON_QOS_receive(struct cx_entity *cx); #else void nasrg_COMMON_QOS_receive(struct nlmsghdr *nlh); diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_sap.h b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_sap.h index a5727eb26b4..f30fb35d951 100755 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_sap.h +++ b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_sap.h @@ -49,7 +49,7 @@ //#define QOS_DEVICE_CONVERSATIONAL_INPUT QOS_SAPI_CONVERSATIONAL_INPUT_RG //#define QOS_DEVICE_CONVERSATIONAL_OUTPUT QOS_SAPI_CONVERSATIONAL_OUTPUT_RG -#define PDCP2NAS_FIFO 21 +#define PDCP2PDCP_USE_RT_FIFO 21 #define NAS2PDCP_FIFO 22 //FIFO indexes in control blocks diff --git a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest.c b/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest.c index 3b04bbae200..673a5a0b5d5 100644 --- a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest.c +++ b/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest.c @@ -56,7 +56,7 @@ struct nlmsghdr *nlh = NULL; struct iovec iov; int sock_fd; struct msghdr msg; -#define NAS_NETLINK_ID 31 +#define OAI_IP_DRIVER_NETLINK_ID 31 //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -85,7 +85,7 @@ int main() perror("Could not install the new signal handler"); // create both sockets - sock_fd = socket(PF_NETLINK, SOCK_RAW,NAS_NETLINK_ID); + sock_fd = socket(PF_NETLINK, SOCK_RAW,OAI_IP_DRIVER_NETLINK_ID); printf("Opened socket with fd %d\n",sock_fd); ret = fcntl(sock_fd,F_SETFL,O_NONBLOCK); printf("fcntl returns %d\n",ret); diff --git a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/nettestPDCP.c b/openair2/NAS/DRIVER/CELLULAR/NETLTEST/nettestPDCP.c index 61209e2a6e0..bccfa9552a4 100644 --- a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/nettestPDCP.c +++ b/openair2/NAS/DRIVER/CELLULAR/NETLTEST/nettestPDCP.c @@ -40,7 +40,7 @@ void foo( int sig ) } -#define NAS_NETLINK_ID 31 +#define OAI_IP_DRIVER_NETLINK_ID 31 void main() { @@ -56,7 +56,7 @@ void main() if ( sigaction( SIGINT, &newaction, NULL ) == -1) perror("Could not install the new signal handler"); - sock_fd = socket(PF_NETLINK, SOCK_RAW,NAS_NETLINK_ID); + sock_fd = socket(PF_NETLINK, SOCK_RAW,OAI_IP_DRIVER_NETLINK_ID); printf("Opened socket with fd %d\n",sock_fd); diff --git a/openair2/NAS/DRIVER/LITE/Makefile b/openair2/NAS/DRIVER/LITE/Makefile index 2a6efc2e0ef..76ba3b5bdb3 100755 --- a/openair2/NAS/DRIVER/LITE/Makefile +++ b/openair2/NAS/DRIVER/LITE/Makefile @@ -1,6 +1,6 @@ # NASMESH Driver makefile # -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc NAS_UPDIR := $(shell /bin/pwd) KERNEL_ARCH:=$(shell echo `uname -m`) @@ -54,7 +54,7 @@ endif #################################################### #netlink.ko: - #make $(x)$(y) NAS_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules + #make $(x)$(y) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules #oai_nw_drv.ko: # make V=1 -C $(KERNEL_DIR) M=`pwd` modules diff --git a/openair2/NAS/DRIVER/LITE/netlink.c b/openair2/NAS/DRIVER/LITE/netlink.c index 1eb238dcfcc..bf8030f667a 100755 --- a/openair2/NAS/DRIVER/LITE/netlink.c +++ b/openair2/NAS/DRIVER/LITE/netlink.c @@ -52,7 +52,7 @@ //#define NETLINK_DEBUG 1 -#define NAS_NETLINK_ID 31 +#define OAI_IP_DRIVER_NETLINK_ID 31 #define NL_DEST_PID 1 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) @@ -110,7 +110,7 @@ int oai_nw_drv_netlink_init(void) nas_nl_sk = netlink_kernel_create( &init_net, - NAS_NETLINK_ID, + OAI_IP_DRIVER_NETLINK_ID, # if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) THIS_MODULE, # endif @@ -118,7 +118,7 @@ int oai_nw_drv_netlink_init(void) #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ nas_nl_sk = netlink_kernel_create( &init_net, - NAS_NETLINK_ID, + OAI_IP_DRIVER_NETLINK_ID, 0, nas_nl_data_ready, &nasmesh_mutex, // NULL diff --git a/openair2/NAS/DRIVER/MESH/Makefile b/openair2/NAS/DRIVER/MESH/Makefile index bd91c08de27..f4bf87f3185 100755 --- a/openair2/NAS/DRIVER/MESH/Makefile +++ b/openair2/NAS/DRIVER/MESH/Makefile @@ -1,6 +1,6 @@ # NASMESH Driver makefile # -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc NAS_UPDIR := $(shell /bin/pwd) #################################################### @@ -17,8 +17,8 @@ NAS_UPDIR := $(shell /bin/pwd) #################################################### #EXTRA_CFLAGS = -fno-common -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) EXTRA_CFLAGS += -I$(OPENAIR2_DIR) -ifdef NAS_NETLINK -EXTRA_CFLAGS += -DNAS_NETLINK +ifdef PDCP_USE_NETLINK +EXTRA_CFLAGS += -DPDCP_USE_NETLINK else EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall endif @@ -30,6 +30,13 @@ endif ifdef ADDRESS_FIX EXTRA_CFLAGS += -DNAS_ADDRESS_FIX endif +ifdef NAS_DEBUG_RECEIVE +EXTRA_CFLAGS += -DNAS_DEBUG_RECEIVE +endif + +ifdef NAS_DEBUG_SEND +EXTRA_CFLAGS += -DNAS_DEBUG_SEND +endif ccflags-y := $(CFLAGS) $(EXTRA_CFLAGS) CFLAGS= @@ -44,7 +51,7 @@ nasmesh-objs += ioctl.o nasmesh-objs += classifier.o nasmesh-objs += tool.o nasmesh-objs += mesh.o -ifdef NAS_NETLINK +ifdef PDCP_USE_NETLINK nasmesh-objs += netlink.o endif @@ -53,7 +60,7 @@ endif #################################################### #netlink.ko: -# make NAS_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules +# make PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules #nasmesh.ko: # make V=1 -C $(KERNEL_DIR) M=`pwd` modules diff --git a/openair2/NAS/DRIVER/MESH/TESTBENCH/testbench.c b/openair2/NAS/DRIVER/MESH/TESTBENCH/testbench.c index 61209e2a6e0..bccfa9552a4 100644 --- a/openair2/NAS/DRIVER/MESH/TESTBENCH/testbench.c +++ b/openair2/NAS/DRIVER/MESH/TESTBENCH/testbench.c @@ -40,7 +40,7 @@ void foo( int sig ) } -#define NAS_NETLINK_ID 31 +#define OAI_IP_DRIVER_NETLINK_ID 31 void main() { @@ -56,7 +56,7 @@ void main() if ( sigaction( SIGINT, &newaction, NULL ) == -1) perror("Could not install the new signal handler"); - sock_fd = socket(PF_NETLINK, SOCK_RAW,NAS_NETLINK_ID); + sock_fd = socket(PF_NETLINK, SOCK_RAW,OAI_IP_DRIVER_NETLINK_ID); printf("Opened socket with fd %d\n",sock_fd); diff --git a/openair2/NAS/DRIVER/MESH/common.c b/openair2/NAS/DRIVER/MESH/common.c index 6aa7fc00d68..d5c51a78561 100755 --- a/openair2/NAS/DRIVER/MESH/common.c +++ b/openair2/NAS/DRIVER/MESH/common.c @@ -38,7 +38,7 @@ //#include "nas_common.h" #include "local.h" #include "proto_extern.h" -#ifndef NAS_NETLINK +#ifdef RTAI #include "rtai_fifos.h" #endif @@ -402,7 +402,7 @@ void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct class pdcph.inst = inst; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK bytes_wrote = nas_netlink_send((char *)&pdcph,NAS_PDCPH_SIZE); #ifdef NAS_DEBUG_SEND printk("[NAS] Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n", @@ -414,22 +414,22 @@ void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct class printk("[NAS] Wrote %d bytes (header for %d byte skb) to PDCP fifo\n", bytes_wrote,skb->len); #endif -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK if (bytes_wrote != NAS_PDCPH_SIZE) { printk("NAS_COMMON_QOS_SEND: problem while writing PDCP's header (bytes wrote = %d )\n",bytes_wrote); printk("rb_id %d, Wrote %d, Header Size %lu\n", pdcph.rb_id , bytes_wrote, NAS_PDCPH_SIZE); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK rtf_reset(NAS2PDCP_FIFO); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK return; } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK bytes_wrote += nas_netlink_send((char *)skb->data,skb->len); #else bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK if (bytes_wrote != skb->len+NAS_PDCPH_SIZE) { printk("NAS_COMMON_QOS_SEND: Inst %d, RB_ID %d: problem while writing PDCP's data, bytes_wrote = %d, Data_len %d, PDCPH_SIZE %lu\n", @@ -438,9 +438,9 @@ void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct class bytes_wrote, skb->len, NAS_PDCPH_SIZE); // congestion -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK rtf_reset(NAS2PDCP_FIFO); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK return; } @@ -460,7 +460,7 @@ void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct class #endif } -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //--------------------------------------------------------------------------- void nas_COMMON_QOS_receive() { @@ -479,7 +479,7 @@ void nas_COMMON_QOS_receive() // End debug information - bytes_read = rtf_get(PDCP2NAS_FIFO,&pdcph, NAS_PDCPH_SIZE); + bytes_read = rtf_get(PDCP2PDCP_USE_RT_FIFO,&pdcph, NAS_PDCPH_SIZE); while (bytes_read>0) { if (bytes_read != NAS_PDCPH_SIZE) { @@ -490,7 +490,7 @@ void nas_COMMON_QOS_receive() priv=netdev_priv(nasdev[pdcph.inst]); rclass = nas_COMMON_search_class_for_rb(pdcph.rb_id,priv); - bytes_read+= rtf_get(PDCP2NAS_FIFO, + bytes_read+= rtf_get(PDCP2PDCP_USE_RT_FIFO, data_buffer, pdcph.data_size); @@ -512,7 +512,7 @@ void nas_COMMON_QOS_receive() pdcph.rb_id); } - bytes_read = rtf_get(PDCP2NAS_FIFO, &pdcph, NAS_PDCPH_SIZE); + bytes_read = rtf_get(PDCP2PDCP_USE_RT_FIFO, &pdcph, NAS_PDCPH_SIZE); } @@ -553,7 +553,7 @@ void nas_COMMON_QOS_receive(struct nlmsghdr *nlh) } } -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK //--------------------------------------------------------------------------- struct cx_entity *nas_COMMON_search_cx(nasLocalConnectionRef_t lcr,struct nas_priv *priv) diff --git a/openair2/NAS/DRIVER/MESH/device.c b/openair2/NAS/DRIVER/MESH/device.c index 148146447b0..c7492064db2 100755 --- a/openair2/NAS/DRIVER/MESH/device.c +++ b/openair2/NAS/DRIVER/MESH/device.c @@ -36,12 +36,12 @@ */ /*******************************************************************************/ -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK #ifdef RTAI #include "rtai_posix.h" #define RTAI_IRQ 30 //try to get this irq with RTAI #endif // RTAI -#endif // NAS_NETLINK +#endif // PDCP_USE_NETLINK #include "constant.h" #include "local.h" @@ -68,7 +68,7 @@ struct net_device *nasdev[NB_INSTANCES_MAX]; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK extern void nas_netlink_release(void); extern int nas_netlink_init(void); #endif @@ -97,7 +97,7 @@ int find_inst(struct net_device *dev) //--------------------------------------------------------------------------- -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK //void interrupt(void){ void *nas_interrupt(void) { @@ -116,7 +116,7 @@ void *nas_interrupt(void) cxi=0; // mesh_GC_receive(); // mesh_DC_receive(naspriv->cx+cxi); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK nas_COMMON_QOS_receive(); #endif // spin_unlock_irqrestore(&priv->lock,flags); @@ -138,14 +138,14 @@ int nas_open(struct net_device *dev) // MOD_INC_USE_COUNT; // Address has already been set at init -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK if (pdcp_2_nas_irq==-EBUSY) { printk("OPEN: irq failure\n"); return -EBUSY; } -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK /* netif_start_queue(dev); @@ -366,7 +366,7 @@ void nas_init(struct net_device *dev) // Initialize private structure // priv->sap[NAS_GC_SAPI] = RRC_DEVICE_GC; // priv->sap[NAS_NT_SAPI] = RRC_DEVICE_NT; - priv->sap[NAS_RAB_INPUT_SAPI] = PDCP2NAS_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; + priv->sap[NAS_RAB_INPUT_SAPI] = PDCP2PDCP_USE_RT_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; priv->sap[NAS_RAB_OUTPUT_SAPI] = NAS2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT; // priv->retry_limit=RETRY_LIMIT_DEFAULT; @@ -450,7 +450,7 @@ int init_module (void) printk("Starting NASMESH, number of IMEI paramters %d, IMEI %X%X\n",m_arg,nas_IMEI[0],nas_IMEI[1]); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK #ifdef RTAI //with RTAI you have to indicate which irq# you want @@ -505,7 +505,7 @@ int init_module (void) } } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK if ((err=nas_netlink_init()) == -1) printk("[NAS][INIT] NETLINK failed\n"); @@ -528,7 +528,7 @@ void cleanup_module(void) printk("[NAS][CLEANUP]nasmesh_cleanup_module: begin\n"); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK if (pdcp_2_nas_irq!=-EBUSY) { pdcp_2_nas_irq=0; @@ -559,9 +559,9 @@ void cleanup_module(void) free_netdev(nasdev[inst]); } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK nas_netlink_release(); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK printk("nasmesh_cleanup_module: end\n"); } diff --git a/openair2/NAS/DRIVER/MESH/local.h b/openair2/NAS/DRIVER/MESH/local.h index e4ddd2fbffc..85399604700 100755 --- a/openair2/NAS/DRIVER/MESH/local.h +++ b/openair2/NAS/DRIVER/MESH/local.h @@ -63,7 +63,7 @@ //#include "rrc_nas_primitives.h" //#include "rrc_sap.h" -#define PDCP2NAS_FIFO 21 +#define PDCP2PDCP_USE_RT_FIFO 21 #define NAS2PDCP_FIFO 22 #include "constant.h" @@ -185,7 +185,7 @@ extern struct net_device *nasdev[NB_INSTANCES_MAX]; extern uint8_t NAS_NULL_IMEI[14]; //global variables shared with RRC -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK extern int pdcp_2_nas_irq; #endif //extern uint8_t nas_IMEI[14]; diff --git a/openair2/NAS/DRIVER/MESH/mesh.c b/openair2/NAS/DRIVER/MESH/mesh.c index 0b29ac30aa9..b53caf219ec 100755 --- a/openair2/NAS/DRIVER/MESH/mesh.c +++ b/openair2/NAS/DRIVER/MESH/mesh.c @@ -288,7 +288,7 @@ int nas_mesh_DC_send_cx_establish_request(struct cx_entity *cx,struct nas_priv * nas_tool_print_buffer((char *)p,p->length); #endif ++cx->retry; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); #endif @@ -348,7 +348,7 @@ int nas_mesh_DC_send_cx_release_request(struct cx_entity *cx, p->length = NAS_TL_SIZE + sizeof(struct NASConnReleaseReq); p->nasUEDCPrimitive.conn_release_req.localConnectionRef = cx->lcr; p->nasUEDCPrimitive.conn_release_req.releaseCause = NAS_CX_RELEASE_UNDEF_CAUSE; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); @@ -435,7 +435,7 @@ void nas_mesh_DC_send_sig_data_request(struct sk_buff *skb, p->nasUEDCPrimitive.data_transfer_req.localConnectionRef = cx->lcr; p->nasUEDCPrimitive.data_transfer_req.priority = 3; // TBD p->nasUEDCPrimitive.data_transfer_req.nasDataLength = (skb->len)+1; //adds category character -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); #endif @@ -445,7 +445,7 @@ void nas_mesh_DC_send_sig_data_request(struct sk_buff *skb, return; } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_wrote += rtf_put(cx->sap[NAS_DC_INPUT_SAPI], &data_type, 1); // bytes_wrote += rtf_put(cx->sap[NAS_DC_INPUT_SAPI], skb->data, skb->len); @@ -505,7 +505,7 @@ void nas_mesh_DC_send_peer_sig_data_request(struct cx_entity *cx, uint8_t sig_ca p->nasUEDCPrimitive.data_transfer_req.localConnectionRef = cx->lcr; p->nasUEDCPrimitive.data_transfer_req.priority = 3; // TBD p->nasUEDCPrimitive.data_transfer_req.nasDataLength = (nas_length)+1; //adds category character -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); #endif @@ -515,7 +515,7 @@ void nas_mesh_DC_send_peer_sig_data_request(struct cx_entity *cx, uint8_t sig_ca return; } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_wrote += rtf_put(cx->sap[NAS_DC_INPUT_SAPI], &data_type, 1); // bytes_wrote += rtf_put(cx->sap[NAS_DC_INPUT_SAPI], (char *)nas_data, nas_length); @@ -659,7 +659,7 @@ void nas_mesh_DC_decode_sig_data_ind(struct cx_entity *cx, struct nas_ue_dc_elem } // End debug information -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK // nas_COMMON_receive(p->length, p->nasUEDCPrimitive.data_transfer_ind.nasDataLength, cx->sap[NAS_DC_OUTPUT_SAPI]); #endif #ifdef NAS_DEBUG_DC @@ -836,7 +836,7 @@ int nas_mesh_DC_receive(struct cx_entity *cx,struct nas_priv *gpriv) } // End debug information -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_read = rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI] , gpriv->rbuffer, NAS_TL_SIZE); #endif @@ -846,7 +846,7 @@ int nas_mesh_DC_receive(struct cx_entity *cx,struct nas_priv *gpriv) p= (struct nas_ue_dc_element *)(gpriv->rbuffer); //get the rest of the primitive -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], (uint8_t *)p+NAS_TL_SIZE, p->length-NAS_TL_SIZE); #endif @@ -975,7 +975,7 @@ int nas_mesh_GC_receive(struct nas_priv *gpriv) #ifdef NAS_DEBUG_GC printk("NAS_MESH_GC_RECEIVE - begin \n"); #endif -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_read = rtf_get(gpriv->sap[NAS_GC_SAPI], gpriv->rbuffer, NAS_TL_SIZE); #endif @@ -984,7 +984,7 @@ int nas_mesh_GC_receive(struct nas_priv *gpriv) struct nas_ue_gc_element *p; p= (struct nas_ue_gc_element *)(gpriv->rbuffer); //get the rest of the primitive -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_read += rtf_get(gpriv->sap[NAS_GC_SAPI], (uint8_t *)p+NAS_TL_SIZE, p->length-NAS_TL_SIZE); #endif @@ -997,7 +997,7 @@ int nas_mesh_GC_receive(struct nas_priv *gpriv) // start decoding message switch (p->type) { case INFO_BROADCAST_IND : -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK #else // bytes_read += rtf_get(gpriv->sap[NAS_GC_SAPI], (uint8_t *)p+p->length, p->nasUEGCPrimitive.broadcast_ind.nasDataLength); #endif diff --git a/openair2/NAS/DRIVER/MESH/netlink.c b/openair2/NAS/DRIVER/MESH/netlink.c index 8fadbad9347..ac6b9014cfa 100644 --- a/openair2/NAS/DRIVER/MESH/netlink.c +++ b/openair2/NAS/DRIVER/MESH/netlink.c @@ -52,7 +52,7 @@ //#define NETLINK_DEBUG 1 -#define NAS_NETLINK_ID 31 +#define OAI_IP_DRIVER_NETLINK_ID 31 #define NL_DEST_PID 1 @@ -113,7 +113,7 @@ int nas_netlink_init() nas_nl_sk = netlink_kernel_create( &init_net, - NAS_NETLINK_ID, + OAI_IP_DRIVER_NETLINK_ID, # if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) THIS_MODULE, # endif @@ -121,7 +121,7 @@ int nas_netlink_init() #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ nas_nl_sk = netlink_kernel_create( &init_net, - NAS_NETLINK_ID, + OAI_IP_DRIVER_NETLINK_ID, 0, nas_nl_data_ready, &nasmesh_mutex, // NULL @@ -185,9 +185,9 @@ int nas_netlink_send(unsigned char *data,unsigned int len) #endif #ifdef NETLINK_DEBUG - printk("[NAS][NETLINK] In nas_netlink_send, nl_skb %p, nl_sk %x, nlh %p, nlh->nlmsg_len %d (NAS_NETLINK_ID %d)\n", + printk("[NAS][NETLINK] In nas_netlink_send, nl_skb %p, nl_sk %x, nlh %p, nlh->nlmsg_len %d (OAI_IP_DRIVER_NETLINK_ID %d)\n", nl_skb,nas_nl_sk,nlh,nlh->nlmsg_len, - NAS_NETLINK_ID); + OAI_IP_DRIVER_NETLINK_ID); #endif //DEBUG_NETLINK if (nas_nl_sk) { diff --git a/openair2/NAS/DRIVER/MESH/proto_extern.h b/openair2/NAS/DRIVER/MESH/proto_extern.h index 2dd815ab1ee..7dd52c7682b 100755 --- a/openair2/NAS/DRIVER/MESH/proto_extern.h +++ b/openair2/NAS/DRIVER/MESH/proto_extern.h @@ -101,7 +101,9 @@ void nas_COMMON_receive(unsigned short dlen, @param gc pointer to classifier entity for SDU @param inst device instance */ -void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst); +void nas_COMMON_QOS_send(struct sk_buff *skb, + struct cx_entity *cx, + struct classifier_entity *gc,int inst); /** \fn void nas_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst) @@ -111,15 +113,17 @@ void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct class @param gc pointer to classifier entity for SDU @param inst device instance */ -void nas_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst); +void nas_COMMON_del_send(struct sk_buff *skb, + struct cx_entity *cx, + struct classifier_entity *gc,int inst); -#ifndef NAS_NETLINK +#ifndef PDCP_USE_NETLINK /** \fn void nas_COMMON_QOS_receive() \brief Retrieve PDU from PDCP for connection */ void nas_COMMON_QOS_receive(void); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK /** \fn struct rb_entity *nas_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rabi, nasQoSTrafficClass_t qos) @@ -128,7 +132,9 @@ void nas_COMMON_QOS_receive(void); @param rabi radio-bearer index @param qos NAS QOS traffic class */ -struct rb_entity *nas_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rabi, nasQoSTrafficClass_t qos); +struct rb_entity *nas_COMMON_add_rb( + struct cx_entity *cx, nasRadioBearerId_t rabi, + nasQoSTrafficClass_t qos); /** \fn struct rb_entity *nas_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rabi) @@ -137,7 +143,8 @@ struct rb_entity *nas_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rab @param rabi radio-bearer index @returns A pointer to the radio-bearer entity */ -struct rb_entity *nas_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rabi); +struct rb_entity *nas_COMMON_search_rb( + struct cx_entity *cx, nasRadioBearerId_t rabi); /** \fn struct cx_entity *nas_COMMON_search_cx(nasLocalConnectionRef_t lcr,struct nas_priv *gpriv) @@ -146,7 +153,9 @@ struct rb_entity *nas_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t @param gpriv pointer to nas_priv for device @returns A pointer to the connection entity */ -struct cx_entity *nas_COMMON_search_cx(nasLocalConnectionRef_t lcr,struct nas_priv *gpriv); +struct cx_entity *nas_COMMON_search_cx( + nasLocalConnectionRef_t lcr, + struct nas_priv *gpriv); /** \fn struct classifier_entity *nas_COMMON_search_class_for_rb(nasRadioBearerId_t rab_id,struct nas_priv *priv) @@ -155,7 +164,9 @@ struct cx_entity *nas_COMMON_search_cx(nasLocalConnectionRef_t lcr,struct nas_pr @param priv pointer to nas_priv for device @returns A pointer to the corresponding RX classifier entity */ -struct classifier_entity *nas_COMMON_search_class_for_rb(nasRadioBearerId_t rab_id,struct nas_priv *priv); +struct classifier_entity +*nas_COMMON_search_class_for_rb(nasRadioBearerId_t + rab_id,struct nas_priv *priv); /** \fn void nas_COMMON_flush_rb(struct cx_entity *cx) @@ -164,7 +175,7 @@ struct classifier_entity *nas_COMMON_search_class_for_rb(nasRadioBearerId_t rab_ */ void nas_COMMON_flush_rb(struct cx_entity *cx); -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK /** \fn int nas_netlink_send(unsigned char *data,unsigned int len) \brief Request the transfer of data by PDCP via netlink socket @@ -181,7 +192,7 @@ int nas_netlink_send(unsigned char *data,unsigned int len); */ void nas_COMMON_QOS_receive(struct nlmsghdr *nlh); -#endif //NAS_NETLINK +#endif //PDCP_USE_NETLINK //nasmesh.c /** @@ -191,7 +202,8 @@ void nas_mesh_init(int inst //!< Instance ID ); -void nas_mesh_timer(unsigned long data,struct nas_priv *gpriv); +void nas_mesh_timer(unsigned long data, + struct nas_priv *gpriv); int nas_mesh_DC_receive(struct cx_entity *cx,struct nas_priv *gpriv); int nas_mesh_GC_receive(struct nas_priv *gpriv); @@ -200,9 +212,12 @@ int nas_mesh_DC_send_cx_release_request(struct cx_entity *cx,struct nas_priv *g void nas_mesh_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,struct nas_priv *gpriv); // iocontrol.c -void nas_CTL_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); +void nas_CTL_send(struct sk_buff *skb, + struct cx_entity *cx, + struct classifier_entity *gc); //int nas_CTL_receive_authentication(struct ipv6hdr *iph, struct cx-entity *cx, unsigned char sapi); -int nas_CTL_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); +int nas_CTL_ioctl(struct net_device *dev, + struct ifreq *ifr, int cmd); // classifier.c @@ -220,7 +235,8 @@ struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, unsign /** \brief Send a socket received from IP to classifier for a particular instance ID. */ -struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, +struct classifier_entity +*nas_CLASS_add_fclassifier(struct cx_entity *cx, unsigned char dscp, unsigned short classref ); @@ -228,7 +244,8 @@ struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, /** \brief Send a socket received from IP to classifier for a particular instance ID. */ -struct classifier_entity *nas_CLASS_add_rclassifier(unsigned char dscp, +struct classifier_entity +*nas_CLASS_add_rclassifier(unsigned char dscp, unsigned short classref, struct nas_priv* ); @@ -297,7 +314,7 @@ void nas_tool_print_buffer(char * buffer,int length); void nas_print_rb_entity(struct rb_entity *rb); void nas_print_classifier(struct classifier_entity *gc); -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK // nas_netlink.c void nas_netlink_release(void); diff --git a/openair2/NAS/SIMU_CELLULAR/Makefile b/openair2/NAS/SIMU_CELLULAR/Makefile index 32feeae08b1..26af978a4ef 100755 --- a/openair2/NAS/SIMU_CELLULAR/Makefile +++ b/openair2/NAS/SIMU_CELLULAR/Makefile @@ -7,7 +7,7 @@ # You can modify the below as well, but probably # won't need to. -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc #UPDIR := /homes/mwett/rh_mw/RHODOS COMMON_DIR = $(OPENAIR2_DIR)/COMMON RRC_CELL_DIR = $(OPENAIR2_DIR)/RRC/CELLULAR diff --git a/openair2/NETWORK_DRIVER/UE_IP/README b/openair2/NETWORK_DRIVER/UE_IP/README new file mode 100755 index 00000000000..e889a081021 --- /dev/null +++ b/openair2/NETWORK_DRIVER/UE_IP/README @@ -0,0 +1 @@ +This the driver for the UE when NAS layer is running in the UE (EPC setting). \ No newline at end of file diff --git a/openair2/NETWORK_DRIVER/UE_IP/common.c b/openair2/NETWORK_DRIVER/UE_IP/common.c index 390c9e244db..47d2786fa4f 100755 --- a/openair2/NETWORK_DRIVER/UE_IP/common.c +++ b/openair2/NETWORK_DRIVER/UE_IP/common.c @@ -115,8 +115,9 @@ ue_ip_common_class_wireless2ip( #ifdef OAI_DRV_DEBUG_RECEIVE printk("[UE_IP_DRV][%s] Receiving packet of size %d from PDCP \n",__FUNCTION__, skb_p->len); - for (i=0; i<skb_p->len; i++) + for (i=0; i<skb_p->len; i++) { printk("%2x ",((unsigned char *)(skb_p->data))[i]); + } printk("\n"); #endif @@ -131,7 +132,7 @@ ue_ip_common_class_wireless2ip( skb_p->ip_summed = CHECKSUM_UNNECESSARY; - ipv_p = (ipversion_t *)((void*)&(skb_p->data[hard_header_len])); + ipv_p = (struct ipversion*)((void*)&(skb_p->data[hard_header_len])); switch (ipv_p->version) { @@ -224,8 +225,9 @@ ue_ip_common_class_wireless2ip( #ifdef OAI_DRV_DEBUG_RECEIVE printk("[UE_IP_DRV][%s] sending packet of size %d to kernel\n",__FUNCTION__,skb_p->len); - for (i=0; i<skb_p->len; i++) + for (i=0; i<skb_p->len; i++) { printk("%2x ",((unsigned char *)(skb_p->data))[i]); + } printk("\n"); #endif //OAI_DRV_DEBUG_RECEIVE @@ -318,8 +320,9 @@ ue_ip_common_ip2wireless( #ifdef OAI_DRV_DEBUG_SEND printk("[UE_IP_DRV][%s] Sending packet of size %d to PDCP \n",__FUNCTION__,skb_pP->len); - for (j=0; j<skb_pP->len; j++) + for (j=0; j<skb_pP->len; j++) { printk("%2x ",((unsigned char *)(skb_pP->data))[j]); + } printk("\n"); #endif diff --git a/openair2/NETWORK_DRIVER/UE_IP/device.c b/openair2/NETWORK_DRIVER/UE_IP/device.c index 72fdcaf8c5d..c02165174ff 100755 --- a/openair2/NETWORK_DRIVER/UE_IP/device.c +++ b/openair2/NETWORK_DRIVER/UE_IP/device.c @@ -77,8 +77,9 @@ int ue_ip_find_inst(struct net_device *dev_pP) int i; for (i=0; i<UE_IP_NB_INSTANCES_MAX; i++) - if (ue_ip_dev[i] == dev_pP) + if (ue_ip_dev[i] == dev_pP) { return(i); + } return(-1); } @@ -145,10 +146,11 @@ int ue_ip_open(struct net_device *dev_pP) #endif //OAI_NW_DRIVER_USE_NETLINK - if(!netif_queue_stopped(dev_pP)) + if(!netif_queue_stopped(dev_pP)) { netif_start_queue(dev_pP); - else + } else { netif_wake_queue(dev_pP); + } init_timer(&priv_p->timer); (priv_p->timer).expires = jiffies+UE_IP_TIMER_TICK; @@ -206,16 +208,18 @@ int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP) //--------------------------------------------------------------------------- printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__); - if (dev_pP->flags & IFF_UP) + if (dev_pP->flags & IFF_UP) { return -EBUSY; + } if (map_pP->base_addr != dev_pP->base_addr) { printk(KERN_WARNING "[UE_IP_DRV][%s] Can't change I/O address\n", __FUNCTION__); return -EOPNOTSUPP; } - if (map_pP->irq != dev_pP->irq) + if (map_pP->irq != dev_pP->irq) { dev_pP->irq = map_pP->irq; + } printk("[UE_IP_DRV][%s] End\n", __FUNCTION__); return 0; @@ -293,8 +297,9 @@ int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP) //--------------------------------------------------------------------------- printk("[UE_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtuP); - if ((mtuP<50) || (mtuP>1500)) + if ((mtuP<50) || (mtuP>1500)) { return -EINVAL; + } dev_pP->mtu = mtuP; return 0; @@ -397,8 +402,9 @@ int init_module (void) printk("[UE_IP_DRV][%s] NETLINK INIT\n", __FUNCTION__); - if ((err=ue_ip_netlink_init()) == -1) + if ((err=ue_ip_netlink_init()) == -1) { printk("[UE_IP_DRV][%s] NETLINK failed\n", __FUNCTION__); + } return err; @@ -410,11 +416,11 @@ void cleanup_module(void) //--------------------------------------------------------------------------- int inst; - printk("[UE_IP_DRV][CLEANUP]nasmesh_cleanup_module: begin\n"); + printk("[UE_IP_DRV][CLEANUP] begin\n"); for (inst=0; inst<UE_IP_NB_INSTANCES_MAX; inst++) { #ifdef OAI_DRV_DEBUG_DEVICE - printk("nasmesh_cleanup_module: unregister and free net device instance %d\n",inst); + printk("[UE_IP_DRV][CLEANUP] unregister and free net device instance %d\n",inst); #endif if (ue_ip_dev[inst]) { @@ -425,7 +431,7 @@ void cleanup_module(void) } ue_ip_netlink_release(); - printk("nasmesh_cleanup_module: end\n"); + printk("[UE_IP_DRV][CLEANUP] end\n"); } #define DRV_NAME "ue_ip" diff --git a/openair2/NETWORK_DRIVER/UE_IP/local.h b/openair2/NETWORK_DRIVER/UE_IP/local.h index d4b1114258c..5dd428c4cf2 100755 --- a/openair2/NETWORK_DRIVER/UE_IP/local.h +++ b/openair2/NETWORK_DRIVER/UE_IP/local.h @@ -75,7 +75,7 @@ typedef struct ue_ip_priv_s { uint32_t timer_release; struct sock *nl_sk; uint8_t nlmsg[UE_IP_PRIMITIVE_MAX_LENGTH+sizeof(struct nlmsghdr)]; - uint8_t xbuffer[UE_IP_PRIMITIVE_MAX_LENGTH]; // transmition buffer + uint8_t xbuffer[UE_IP_PRIMITIVE_MAX_LENGTH]; // transmission buffer uint8_t rbuffer[UE_IP_PRIMITIVE_MAX_LENGTH]; // reception buffer } ue_ip_priv_t; diff --git a/openair2/NETWORK_DRIVER/UE_IP/netlink.c b/openair2/NETWORK_DRIVER/UE_IP/netlink.c index 27acf4573ca..a3efbb21404 100755 --- a/openair2/NETWORK_DRIVER/UE_IP/netlink.c +++ b/openair2/NETWORK_DRIVER/UE_IP/netlink.c @@ -47,7 +47,7 @@ #include "proto_extern.h" -#define NAS_NETLINK_ID 31 +#define OAI_IP_DRIVER_NETLINK_ID 31 #define NL_DEST_PID 1 /******************************************************************************* @@ -106,18 +106,27 @@ int ue_ip_netlink_init(void) printk("[UE_IP_DRV][NETLINK] Running init ...\n"); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) + cfg.groups = 0; + cfg.input = nas_nl_data_ready; + cfg.cb_mutex = &nasmesh_mutex; + cfg.bind = NULL; nas_nl_sk = netlink_kernel_create( &init_net, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) - NAS_NETLINK_ID, + OAI_IP_DRIVER_NETLINK_ID, +# if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) + THIS_MODULE, +# endif &cfg -#else - NAS_NETLINK_ID, +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ + nas_nl_sk = netlink_kernel_create( + &init_net, + OAI_IP_DRIVER_NETLINK_ID, 0, nas_nl_data_ready, &nasmesh_mutex, // NULL - THIS_MODULE -#endif + THIS_MODULE); +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ ); diff --git a/openair2/RRC/CELLULAR/Makefile b/openair2/RRC/CELLULAR/Makefile index ed2e73c874f..7639953c084 100755 --- a/openair2/RRC/CELLULAR/Makefile +++ b/openair2/RRC/CELLULAR/Makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc KERNEL_MAIN_TYPE=$(shell echo `uname -r | cut -d. -f-2 | tr "." "_"`) export KERNEL_MAIN_TYPE diff --git a/openair2/RRC/CELLULAR/rrc_constant.h b/openair2/RRC/CELLULAR/rrc_constant.h index b02c974a846..42c000359eb 100755 --- a/openair2/RRC/CELLULAR/rrc_constant.h +++ b/openair2/RRC/CELLULAR/rrc_constant.h @@ -52,8 +52,8 @@ /* **** */ // Case 1 : simulation = USER_MODE defined + RRC_NETLINK commented // Case 2 : netlink sockets = USER_MODE defined + -#define RRC_NETLINK NAS_NETLINK -// (TEMP: should be placed in Makefile, but currently, NAS_NETLINK is default in USER_MODE) +#define RRC_NETLINK PDCP_USE_NETLINK +// (TEMP: should be placed in Makefile, but currently, PDCP_USE_NETLINK is default in USER_MODE) // Case 3 : RT_FIFOS = USER_MODE undefined /* **** */ diff --git a/openair2/RRC/CELLULAR/rrc_nas_sap.h b/openair2/RRC/CELLULAR/rrc_nas_sap.h index e78e9601384..df3bb6e902a 100755 --- a/openair2/RRC/CELLULAR/rrc_nas_sap.h +++ b/openair2/RRC/CELLULAR/rrc_nas_sap.h @@ -72,7 +72,7 @@ #endif //NODE_RG #endif //USER_MODE -//#ifdef NAS_NETLINK +//#ifdef PDCP_USE_NETLINK // For netlink, all SAPs are on the same socket // GC-NT - OUT=UE, IN=RG // DCx - OUT/IN = UE + RG @@ -87,7 +87,7 @@ #define RRC_NAS_DC2_IN 8 #define RRC_NAS_DC2_OUT 9 // ToDo : continue with parameterization of the value (up to 250 MTs for 1 short int) -//#endif //NAS_NETLINK +//#endif //PDCP_USE_NETLINK #define NAS_RRCNL_ID 30 #define NL_DEST_RRC_PID 1 diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c index 352914f472c..785e446d6cb 100644 --- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c +++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c @@ -86,93 +86,200 @@ #include "COMMON/mac_rrc_primitives.h" #include "openair_rrc_L2_interface.h" -/********************************************************************************************************************/ -int8_t mac_rrc_data_req(module_id_t module_idP, frame_t frameP, rb_id_t srb_idP, uint8_t nb_tbP,uint8_t *buffer_pP, eNB_flag_t eNB_flagP, uint8_t eNB_indexP, uint8_t mbsfn_sync_areaP) +//------------------------------------------------------------------------------ +int8_t +mac_rrc_data_req( + const module_id_t module_idP, + const frame_t frameP, + const rb_id_t srb_idP, + const uint8_t nb_tbP, + const uint8_t *buffer_pP, + const eNB_flag_t eNB_flagP, + const uint8_t eNB_indexP, + const uint8_t mbsfn_sync_areaP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ - return(mac_rrc_lite_data_req(module_idP,frameP,srb_idP,nb_tbP,buffer_pP,eNB_flagP,eNB_indexP,mbsfn_sync_areaP)); + return(mac_rrc_lite_data_req( + module_idP, + frameP, + srb_idP, + nb_tbP, + buffer_pP, + eNB_flagP, + eNB_indexP, + mbsfn_sync_areaP) + ); } -/********************************************************************************************************************/ -int8_t mac_rrc_data_ind(module_id_t module_idP, frame_t frameP, rb_id_t srb_idP, uint8_t *sduP, sdu_size_t sdu_lenP, eNB_flag_t eNB_flagP, uint8_t eNB_indexP,uint8_t mbsfn_sync_area) +//------------------------------------------------------------------------------ +int8_t +mac_rrc_data_ind( + const module_id_t module_idP, + const frame_t frameP, + const rnti_t rntiP, + const rb_id_t srb_idP, + const uint8_t *sduP, + const sdu_size_t sdu_lenP, + const eNB_flag_t eNB_flagP, + const mac_enb_index_t eNB_indexP, + const uint8_t mbsfn_sync_area +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ - return(mac_rrc_lite_data_ind(module_idP,frameP,srb_idP,sduP,sdu_lenP,eNB_flagP,eNB_indexP,mbsfn_sync_area)); + return(mac_rrc_lite_data_ind( + module_idP, + frameP, + rntiP, + srb_idP, + sduP, + sdu_lenP, + eNB_flagP, + eNB_indexP, + mbsfn_sync_area) + ); } -/********************************************************************************************************************/ -void rlcrrc_data_ind(const protocol_ctxt_t* const ctxt_pP, rb_id_t srb_idP, sdu_size_t sdu_lenP,uint8_t *buffer_pP) +//------------------------------------------------------------------------------ +void +rlcrrc_data_ind( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t srb_idP, + const sdu_size_t sdu_lenP, + const uint8_t * const buffer_pP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ - rrc_lite_data_ind(ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - ctxt_pP->frame, - ctxt_pP->enb_flag, + rrc_lite_data_ind(ctxt_pP, srb_idP, sdu_lenP, buffer_pP); } -/********************************************************************************************************************/ -uint8_t pdcp_rrc_data_req(module_id_t enb_instP, module_id_t ue_instP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, boolean_t confirmP, - sdu_size_t sdu_buffer_sizeP, uint8_t* sdu_buffer_pP, uint8_t modeP) +//------------------------------------------------------------------------------ +uint8_t +pdcp_rrc_data_req( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t rb_idP, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_buffer_sizeP, + uint8_t* const sdu_buffer_pP, + const pdcp_transmission_mode_t modeP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ - return rrc_lite_data_req (enb_instP, ue_instP, frameP, eNB_flagP, rb_idP, muiP, confirmP, sdu_buffer_sizeP, sdu_buffer_pP, modeP); + return rrc_lite_data_req ( + ctxt_pP, + rb_idP, + muiP, + confirmP, + sdu_buffer_sizeP, + sdu_buffer_pP, + modeP); } -/********************************************************************************************************************/ -void pdcp_rrc_data_ind(module_id_t enb_instP, module_id_t ue_instP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t srb_idP, sdu_size_t sdu_sizeP,uint8_t *buffer_pP) +//------------------------------------------------------------------------------ +void +pdcp_rrc_data_ind( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t srb_idP, + const sdu_size_t sdu_sizeP, + uint8_t * const buffer_pP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ - rrc_lite_data_ind(enb_instP, ue_instP,frameP,eNB_flagP,srb_idP,sdu_sizeP,buffer_pP); + rrc_lite_data_ind( + ctxt_pP, + srb_idP, + sdu_sizeP, + buffer_pP); } -/********************************************************************************************************************/ -void mac_rrc_meas_ind(module_id_t module_idP,MAC_MEAS_REQ_ENTRY *Meas_entry_pP) +//------------------------------------------------------------------------------ +void +mac_rrc_meas_ind( + const module_id_t module_idP, + MAC_MEAS_REQ_ENTRY * const Meas_entry_pP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ // mac_rrc_meas_ind(module_idP,Meas_entry_pP); } -/********************************************************************************************************************/ -void mac_sync_ind(module_id_t module_idP,uint8_t Status) +//------------------------------------------------------------------------------ +void +mac_sync_ind( + const module_id_t module_idP, + const uint8_t Status +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ mac_lite_sync_ind(module_idP,Status); } -/********************************************************************************************************************/ -void mac_in_sync_ind(module_id_t module_idP,frame_t frameP, uint16_t eNB_indexP) +//------------------------------------------------------------------------------ +void +mac_in_sync_ind( + const module_id_t module_idP, + const frame_t frameP, + const uint16_t eNB_indexP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ rrc_lite_in_sync_ind(module_idP,frameP,eNB_indexP); } -/********************************************************************************************************************/ -void mac_out_of_sync_ind(module_id_t module_idP,frame_t frameP, uint16_t eNB_indexP) +//------------------------------------------------------------------------------ +void +mac_out_of_sync_ind( + const module_id_t module_idP, + const frame_t frameP, + const uint16_t eNB_indexP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ rrc_lite_out_of_sync_ind(module_idP,frameP,eNB_indexP); } -/********************************************************************************************************************/ -int mac_get_rrc_status(module_id_t module_idP,eNB_flag_t eNB_flagP,uint8_t indexP) +//------------------------------------------------------------------------------ +int +mac_eNB_get_rrc_status( + const module_id_t module_idP, + const rnti_t rntiP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ - return mac_get_rrc_lite_status(module_idP, eNB_flagP, indexP); + return mac_eNB_get_rrc_lite_status(module_idP, rntiP); +} +//------------------------------------------------------------------------------ +int +mac_UE_get_rrc_status( + const module_id_t module_idP, + const uint8_t sig_indexP +) +//------------------------------------------------------------------------------ +{ + return mac_UE_get_rrc_lite_status(module_idP, sig_indexP); } -/********************************************************************************************************************/ -char openair_rrc_ue_init(module_id_t module_idP, unsigned char eNB_indexP) +//------------------------------------------------------------------------------ +char +openair_rrc_ue_init( + const module_id_t module_idP, + const unsigned char eNB_indexP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ return openair_rrc_lite_ue_init(module_idP, eNB_indexP); } -/********************************************************************************************************************/ -char openair_rrc_eNB_init(module_id_t module_idP) +//------------------------------------------------------------------------------ +char +openair_rrc_eNB_init( + const module_id_t module_idP +) +//------------------------------------------------------------------------------ { - /********************************************************************************************************************/ return openair_rrc_lite_eNB_init(module_idP); } diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h index f13cf37f635..af2a49942e1 100644 --- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h +++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h @@ -41,31 +41,98 @@ #include "COMMON/mac_rrc_primitives.h" #include "COMMON/platform_types.h" -int8_t mac_rrc_data_req(module_id_t module_idP, frame_t frameP, rb_id_t srb_idP, uint8_t nb_tbP, uint8_t *buffer_pP, eNB_flag_t eNB_flagP, uint8_t eNB_indexP, - uint8_t mbsfn_sync_areaP); - -int8_t mac_rrc_data_ind(module_id_t module_idP, frame_t frameP, rb_id_t srb_idP, uint8_t *sduP, sdu_size_t sdu_lenP, eNB_flag_t eNB_flagP, uint8_t eNB_index, - uint8_t mbsfn_sync_areaP); - -void mac_lite_sync_ind(module_id_t module_idP, uint8_t statusP); - -void mac_rrc_meas_ind(module_id_t, MAC_MEAS_REQ_ENTRY*); - -void rlcrrc_data_ind(const protocol_ctxt_t* const ctxt_pP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, uint8_t *buffer_pP); - -uint8_t pdcp_rrc_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, boolean_t confirmP, - sdu_size_t sdu_buffer_size, uint8_t* sdu_buffer, uint8_t mode); - -void pdcp_rrc_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t srb_idP, sdu_size_t sdu_sizeP, uint8_t *buffer_pP); - -void mac_out_of_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t CH_index); - -char openair_rrc_eNB_init(module_id_t module_idP); - -char openair_rrc_ue_init(module_id_t module_idP, unsigned char eNB_indexP); - -int mac_get_rrc_status(module_id_t module_idP, eNB_flag_t eNB_flagP, uint8_t indexP); - -void mac_in_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t eNB_indexP); +int8_t +mac_rrc_data_req( + const module_id_t module_idP, + const frame_t frameP, + const rb_id_t srb_idP, + const uint8_t nb_tbP, + const uint8_t *buffer_pP, + const eNB_flag_t eNB_flagP, + const mac_enb_index_t eNB_indexP, + const uint8_t mbsfn_sync_areaP +); + +int8_t +mac_rrc_data_ind( + const module_id_t module_idP, + const frame_t frameP, + const rnti_t rntiP, + const rb_id_t srb_idP, + const uint8_t *sduP, + const sdu_size_t sdu_lenP, + const eNB_flag_t eNB_flagP, + const mac_enb_index_t eNB_indexP, + const uint8_t mbsfn_sync_area +); + +void mac_lite_sync_ind( + const module_id_t module_idP, + const uint8_t statusP); + +void mac_rrc_meas_ind( + const module_id_t, + MAC_MEAS_REQ_ENTRY*const ); + +void +rlcrrc_data_ind( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t rb_idP, + const sdu_size_t sdu_sizeP, + const uint8_t * const buffer_pP +); + +uint8_t +pdcp_rrc_data_req( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t rb_idP, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_buffer_sizeP, + uint8_t* const sdu_buffer_pP, + const pdcp_transmission_mode_t modeP +); + +void +pdcp_rrc_data_ind( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t srb_idP, + const sdu_size_t sdu_sizeP, + uint8_t * const buffer_pP +); + +void mac_out_of_sync_ind( + const module_id_t module_idP, + const frame_t frameP, + const uint16_t CH_index); + +char openair_rrc_eNB_init( + const module_id_t module_idP); + +char openair_rrc_ue_init( + const module_id_t module_idP, + const unsigned char eNB_indexP); + +int +mac_eNB_get_rrc_status( + const module_id_t module_idP, + const rnti_t indexP +); +int +mac_UE_get_rrc_status( + const module_id_t module_idP, + const uint8_t sig_indexP +); + +char +openair_rrc_ue_init( + const module_id_t module_idP, + const unsigned char eNB_indexP +); + +void mac_in_sync_ind( + const module_id_t module_idP, + const frame_t frameP, + const uint16_t eNB_indexP); #endif diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index 24d76f27c59..585563abb35 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -45,7 +45,11 @@ //#include "openair_rrc_utils.h" //#include "openair_rrc_main.h" #include "UTIL/LOG/log.h" +#include "rrc_eNB_UE_context.h" #include "pdcp.h" +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif #ifdef PHY_EMUL #include "SIMULATION/simulation_defs.h" @@ -63,23 +67,34 @@ extern UE_MAC_INST *UE_mac_inst; mui_t mui=0; -//-------------------------------------------------------------------------------------------// -int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_id, uint8_t Nb_tb, uint8_t *buffer_pP, eNB_flag_t enb_flagP, uint8_t eNB_index, - uint8_t mbsfn_sync_area) +//------------------------------------------------------------------------------ +int8_t +mac_rrc_lite_data_req( + const module_id_t Mod_idP, + const frame_t frameP, + const rb_id_t Srb_id, + const uint8_t Nb_tb, + uint8_t* const buffer_pP, + const eNB_flag_t enb_flagP, + const uint8_t eNB_index, + const uint8_t mbsfn_sync_area +) +//-------------------------------------------------------------------------- { - //-------------------------------------------------------------------------------------------// SRB_INFO *Srb_info; uint8_t Sdu_size=0; #ifdef DEBUG_RRC int i; - LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); + LOG_T(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); #endif if( enb_flagP == ENB_FLAG_YES) { if((Srb_id & RAB_OFFSET) == BCCH) { - if(eNB_rrc_inst[Mod_idP].SI.Active==0) return 0; + if(eNB_rrc_inst[Mod_idP].SI.Active==0) { + return 0; + } // All even frames transmit SIB in SF 5 if (eNB_rrc_inst[Mod_idP].sizeof_SIB1 == 255) { @@ -108,15 +123,16 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_idP].SIB1, sib1_size); RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_MAC_ENB, Mod_idP, message_p); + itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); } #endif #ifdef DEBUG_RRC - LOG_D(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP); + LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP); - for (i=0; i<eNB_rrc_inst[Mod_idP].sizeof_SIB1; i++) + for (i=0; i<eNB_rrc_inst[Mod_idP].sizeof_SIB1; i++) { LOG_T(RRC,"%x.",buffer_pP[i]); + } LOG_T(RRC,"\n"); #endif @@ -144,26 +160,27 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_idP].SIB23, sib23_size); RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_MAC_ENB, Mod_idP, message_p); + itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); } #endif #ifdef DEBUG_RRC - LOG_D(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP); + LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP); - for (i=0; i<eNB_rrc_inst[Mod_idP].sizeof_SIB23; i++) + for (i=0; i<eNB_rrc_inst[Mod_idP].sizeof_SIB23; i++) { LOG_T(RRC,"%x.",buffer_pP[i]); + } LOG_T(RRC,"\n"); #endif return(eNB_rrc_inst[Mod_idP].sizeof_SIB23); - } else + } else { return(0); + } } - if( (Srb_id & RAB_OFFSET ) == CCCH) { - LOG_D(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); + LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); if(eNB_rrc_inst[Mod_idP].Srb0.Active==0) { LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP); @@ -194,7 +211,7 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, Srb_info->Tx_buffer.Payload, ccch_size); RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_MAC_ENB, Mod_idP, message_p); + itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); } #endif @@ -209,7 +226,9 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i #ifdef Rel10 if((Srb_id & RAB_OFFSET) == MCCH) { - if(eNB_rrc_inst[Mod_idP].MCCH_MESS[mbsfn_sync_area].Active==0) return 0; // this parameter is set in function init_mcch in rrc_eNB.c + if(eNB_rrc_inst[Mod_idP].MCCH_MESS[mbsfn_sync_area].Active==0) { + return 0; // this parameter is set in function init_mcch in rrc_eNB.c + } // this part not needed as it is done in init_mcch /* if (eNB_rrc_inst[Mod_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area] == 255) { @@ -237,7 +256,7 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i RRC_MAC_MCCH_DATA_REQ (message_p).enb_index = eNB_index; RRC_MAC_MCCH_DATA_REQ (message_p).mbsfn_sync_area = mbsfn_sync_area; - itti_send_msg_to_task (TASK_MAC_ENB, Mod_idP, message_p); + itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); } #endif @@ -248,8 +267,9 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i #ifdef DEBUG_RRC LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP); - for (i=0; i<eNB_rrc_inst[Mod_idP].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) + for (i=0; i<eNB_rrc_inst[Mod_idP].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) { LOG_T(RRC,"%x.",buffer_pP[i]); + } LOG_T(RRC,"\n"); #endif @@ -261,9 +281,7 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i } #endif //Rel10 - } - - else { //This is an UE + } else { //This is an UE #ifdef DEBUG_RRC LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_id); LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); @@ -289,7 +307,7 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload, ccch_size); RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_MAC_UE, Mod_idP + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_MAC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); } #endif @@ -308,125 +326,100 @@ int8_t mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, uint16_t Srb_i return(0); } -//-------------------------------------------------------------------------------------------// -int8_t mac_rrc_lite_data_ind(module_id_t Mod_idP, frame_t frameP, rb_id_t Srb_id, uint8_t *Sdu, sdu_size_t sdu_size,eNB_flag_t enb_flagP,uint8_t eNB_index,uint8_t mbsfn_sync_area) +//------------------------------------------------------------------------------ +int8_t +mac_rrc_lite_data_ind( + const module_id_t module_idP, + const frame_t frameP, + const rnti_t rntiP, + const rb_id_t srb_idP, + const uint8_t* sduP, + const sdu_size_t sdu_lenP, + const eNB_flag_t eNB_flagP, + const mac_enb_index_t eNB_indexP, + const uint8_t mbsfn_sync_areaP +) +//-------------------------------------------------------------------------- { - //-------------------------------------------------------------------------------------------// SRB_INFO *Srb_info; + protocol_ctxt_t ctxt; + sdu_size_t sdu_size; /* int si_window; */ + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, eNB_flagP, rntiP, frameP, 0); - if(enb_flagP == ENB_FLAG_NO) { - - if(Srb_id == BCCH) { - - LOG_T(RRC,"[UE %d] Received SDU for BCCH on SRB %d from eNB %d\n",Mod_idP,Srb_id,eNB_index); + if(eNB_flagP == ENB_FLAG_NO) { + if(srb_idP == BCCH) { + LOG_T(RRC,"[UE %d] Received SDU for BCCH on SRB %d from eNB %d\n",module_idP,srb_idP,eNB_indexP); #if defined(ENABLE_ITTI) { MessageDef *message_p; int msg_sdu_size = sizeof(RRC_MAC_BCCH_DATA_IND (message_p).sdu); - if (sdu_size > msg_sdu_size) { - LOG_E(RRC, "SDU larger than BCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size); + if (sdu_lenP > msg_sdu_size) { + LOG_E(RRC, "SDU larger than BCCH SDU buffer size (%d, %d)", sdu_lenP, msg_sdu_size); sdu_size = msg_sdu_size; + } else { + sdu_size = sdu_lenP; } message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_BCCH_DATA_IND); + memset (RRC_MAC_BCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_BCCH_DATA_IND (message_p).sdu)); RRC_MAC_BCCH_DATA_IND (message_p).frame = frameP; RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size; - memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu)); - memcpy (RRC_MAC_BCCH_DATA_IND (message_p).sdu, Sdu, sdu_size); - RRC_MAC_BCCH_DATA_IND (message_p).enb_index = eNB_index; + memcpy (RRC_MAC_BCCH_DATA_IND (message_p).sdu, sduP, sdu_size); + RRC_MAC_BCCH_DATA_IND (message_p).enb_index = eNB_indexP; RRC_MAC_BCCH_DATA_IND (message_p).rsrq = 30 /* TODO change phy to report rspq */; RRC_MAC_BCCH_DATA_IND (message_p).rsrp = 45 /* TODO change phy to report rspp */; - itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); } #else - decode_BCCH_DLSCH_Message(Mod_idP,frameP,eNB_index,Sdu,sdu_size, 0, 0); - /* - if ((frameP %2) == 0) { - if (UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 0) { - LOG_D(RRC,"[UE %d] Frame %d : Received SIB1 from eNB %d (%d bytes)\n",Mod_id,frameP,eNB_index,sdu_size); - if (UE_rrc_inst[Mod_id].SIB1[eNB_index]) - memcpy(UE_rrc_inst[Mod_id].SIB1[eNB_index],&Sdu[0],sdu_size); - else { - LOG_E(RRC,"[FATAL ERROR] SIB1 buffer for eNB %d not allocated, exiting ...\n",eNB_index); - mac_xface->macphy_exit(""); - return(-1); - } - UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status = 1; - decode_SIB1(Mod_id,eNB_index); - } - } - else { - if ((UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 1) && - (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 0)) { - si_window = (frameP%UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod)/frameP%UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize; - LOG_D(RRC,"[UE %d] Frame %d : Received SI (%d bytes), in window %d (SIperiod %d, SIwindowsize %d)\n",Mod_id,frameP,sdu_size,si_window,UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod,UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize); - memcpy(UE_rrc_inst[Mod_id].SI[eNB_index],&Sdu[0],sdu_size); - if (decode_SI(Mod_id,frameP,eNB_index,si_window)==0) { - LOG_D(RRC,"[UE %d] Frame %d :Decoded SI successfully\n",Mod_id,frameP); - UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1; - } - } - - - - } - - - if ((UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 1) && - (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 1)) { - if (UE_rrc_inst[Mod_id].Info[eNB_index].State == RRC_IDLE) { - LOG_I(RRC,"[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n",Mod_id); - UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_SI_RECEIVED; - } - } - */ + decode_BCCH_DLSCH_Message(&ctxt,eNB_indexP,sduP,sdu_lenP, 0, 0); #endif } - if((Srb_id & RAB_OFFSET) == CCCH) { - if (sdu_size>0) { - LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",Mod_idP,Srb_id & RAB_OFFSET,eNB_index); + if((srb_idP & RAB_OFFSET) == CCCH) { + if (sdu_lenP>0) { + LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",module_idP,srb_idP & RAB_OFFSET,eNB_indexP); #if defined(ENABLE_ITTI) { MessageDef *message_p; - int msg_sdu_size = sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu); + int msg_sdu_size = CCCH_SDU_SIZE; - if (sdu_size > msg_sdu_size) { + if (sdu_lenP > msg_sdu_size) { LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size); sdu_size = msg_sdu_size; + } else { + sdu_size = sdu_lenP; } message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_CCCH_DATA_IND); + memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); + memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, sduP, sdu_size); RRC_MAC_CCCH_DATA_IND (message_p).frame = frameP; RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size; - memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu)); - memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, Sdu, sdu_size); - RRC_MAC_CCCH_DATA_IND (message_p).enb_index = eNB_index; - - itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); + RRC_MAC_CCCH_DATA_IND (message_p).enb_index = eNB_indexP; + RRC_MAC_CCCH_DATA_IND (message_p).rnti = rntiP; + itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); } #else - Srb_info = &UE_rrc_inst[Mod_idP].Srb0[eNB_index]; - - memcpy(Srb_info->Rx_buffer.Payload,Sdu,sdu_size); - Srb_info->Rx_buffer.payload_size = sdu_size; - rrc_ue_decode_ccch(Mod_idP, frameP, Srb_info, eNB_index); + Srb_info = &UE_rrc_inst[module_idP].Srb0[eNB_indexP]; + memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP); + Srb_info->Rx_buffer.payload_size = sdu_lenP; + rrc_ue_decode_ccch(&ctxt, Srb_info, eNB_indexP); #endif } } #ifdef Rel10 - if ((Srb_id & RAB_OFFSET) == MCCH) { + if ((srb_idP & RAB_OFFSET) == MCCH) { LOG_T(RRC,"[UE %d] Frame %d: Received SDU on MBSFN sync area %d for MCCH on SRB %d from eNB %d\n", - Mod_idP,frameP, mbsfn_sync_area, Srb_id & RAB_OFFSET,eNB_index); + module_idP,frameP, mbsfn_sync_areaP, srb_idP & RAB_OFFSET,eNB_indexP); #if defined(ENABLE_ITTI) { @@ -440,52 +433,49 @@ int8_t mac_rrc_lite_data_ind(module_id_t Mod_idP, frame_t frameP, rb_id_t Srb_id message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_MCCH_DATA_IND); RRC_MAC_MCCH_DATA_IND (message_p).frame = frameP; - RRC_MAC_MCCH_DATA_IND (message_p).sdu_size = sdu_size; + RRC_MAC_MCCH_DATA_IND (message_p).sdu_size = sdu_lenP; memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu)); - memcpy (RRC_MAC_MCCH_DATA_IND (message_p).sdu, Sdu, sdu_size); - RRC_MAC_MCCH_DATA_IND (message_p).enb_index = eNB_index; - RRC_MAC_MCCH_DATA_IND (message_p).mbsfn_sync_area = mbsfn_sync_area; - - itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); + memcpy (RRC_MAC_MCCH_DATA_IND (message_p).sdu, sduP, sdu_lenP); + RRC_MAC_MCCH_DATA_IND (message_p).enb_index = eNB_indexP; + RRC_MAC_MCCH_DATA_IND (message_p).mbsfn_sync_area = mbsfn_sync_areaP; + itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); } #else - decode_MCCH_Message(Mod_idP, frameP, eNB_index, Sdu, sdu_size, mbsfn_sync_area); + decode_MCCH_Message(&ctxt, eNB_indexP, sduP, sdu_lenP, mbsfn_sync_areaP); #endif } #endif // Rel10 - } - - else { // This is an eNB - Srb_info = &eNB_rrc_inst[Mod_idP].Srb0; - LOG_T(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",Mod_idP,Srb_info->Srb_id); + } else { // This is an eNB + Srb_info = &eNB_rrc_inst[module_idP].Srb0; + LOG_T(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",module_idP,Srb_info->Srb_id); #if defined(ENABLE_ITTI) { MessageDef *message_p; int msg_sdu_size = sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu); - if (sdu_size > msg_sdu_size) { - LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size); + if (sdu_lenP > msg_sdu_size) { + LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_lenP, msg_sdu_size); sdu_size = msg_sdu_size; } message_p = itti_alloc_new_message (TASK_MAC_ENB, RRC_MAC_CCCH_DATA_IND); RRC_MAC_CCCH_DATA_IND (message_p).frame = frameP; + RRC_MAC_CCCH_DATA_IND (message_p).rnti = rntiP; RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size; memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu)); - memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, Sdu, sdu_size); - - itti_send_msg_to_task (TASK_RRC_ENB, Mod_idP, message_p); + memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, sduP, sdu_lenP); + itti_send_msg_to_task (TASK_RRC_ENB, ctxt.instance, message_p); } #else // msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id); - if (sdu_size > 0) { - memcpy(Srb_info->Rx_buffer.Payload,Sdu,sdu_size); - Srb_info->Rx_buffer.payload_size = sdu_size; - rrc_eNB_decode_ccch(Mod_idP,frameP,Srb_info); + if (sdu_lenP > 0) { + memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP); + Srb_info->Rx_buffer.payload_size = sdu_lenP; + rrc_eNB_decode_ccch(&ctxt,Srb_info); } #endif @@ -502,68 +492,99 @@ void mac_lite_sync_ind(module_id_t Mod_idP,uint8_t Status) //-------------------------------------------------------------------------------------------// } -//-------------------------------------------------------------------------------------------// -uint8_t rrc_lite_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP, rb_id_t rb_idP, mui_t muiP, uint32_t confirmP, - sdu_size_t sdu_size, uint8_t* buffer_pP, pdcp_transmission_mode_t mode) +//------------------------------------------------------------------------------ +uint8_t +rrc_lite_data_req( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t rb_idP, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_sizeP, + uint8_t* const buffer_pP, + const pdcp_transmission_mode_t modeP +) +//------------------------------------------------------------------------------ { - //-------------------------------------------------------------------------------------------// +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + ctxt_pP->enb_flag ? MSC_RRC_ENB : MSC_RRC_UE, + ctxt_pP->enb_flag ? MSC_PDCP_ENB : MSC_PDCP_UE, + buffer_pP, + sdu_sizeP, + MSC_AS_TIME_FMT"RRC_DCCH_DATA_REQ UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt_pP->rnti, + muiP, + sdu_sizeP); +#endif #if defined(ENABLE_ITTI) { MessageDef *message_p; // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). uint8_t *message_buffer; - message_buffer = itti_malloc (enb_flagP ? TASK_RRC_ENB : TASK_RRC_UE, enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, sdu_size); - memcpy (message_buffer, buffer_pP, sdu_size); + message_buffer = itti_malloc ( + ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, + ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, + sdu_sizeP); + + memcpy (message_buffer, buffer_pP, sdu_sizeP); - message_p = itti_alloc_new_message (enb_flagP ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ); - RRC_DCCH_DATA_REQ (message_p).frame = frameP; - RRC_DCCH_DATA_REQ (message_p).enb_flag = enb_flagP; + message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ); + RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame; + RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag; RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP; RRC_DCCH_DATA_REQ (message_p).muip = muiP; RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP; - RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_size; + RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP; RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer; - RRC_DCCH_DATA_REQ (message_p).mode = mode; - RRC_DCCH_DATA_REQ (message_p).eNB_index = enb_mod_idP; - RRC_DCCH_DATA_REQ (message_p).ue_index = ue_mod_idP; - - itti_send_msg_to_task (enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, enb_flagP ? enb_mod_idP : NB_eNB_INST + ue_mod_idP, message_p); + RRC_DCCH_DATA_REQ (message_p).mode = modeP; + RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id; + RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti; + + itti_send_msg_to_task ( + ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, + ctxt_pP->instance, + message_p); return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. } #else - protocol_ctxt_t ctxt; - ctxt.enb_module_id = enb_mod_idP; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = enb_flagP; - - return pdcp_data_req (&ctxt, SRB_FLAG_YES, rb_idP, muiP, confirmP, sdu_size, buffer_pP, mode); + return pdcp_data_req ( + ctxt_pP, + SRB_FLAG_YES, + rb_idP, + muiP, + confirmP, + sdu_sizeP, + buffer_pP, + modeP); #endif } -//-------------------------------------------------------------------------------------------// -void rrc_lite_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP,rb_id_t Srb_id, sdu_size_t sdu_sizeP,uint8_t *buffer_pP) +//------------------------------------------------------------------------------ +void +rrc_lite_data_ind( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t Srb_id, + const sdu_size_t sdu_sizeP, + const uint8_t* const buffer_pP +) +//------------------------------------------------------------------------------ { - //-------------------------------------------------------------------------------------------// rb_id_t DCCH_index = Srb_id; -#if defined(ENABLE_ITTI) - instance_t instance; -#endif - if (enb_flagP == ENB_FLAG_NO) { -#if defined(ENABLE_ITTI) - instance = ue_mod_idP + NB_eNB_INST; -#endif - LOG_N(RRC, "[UE %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from eNB %d\n", - ue_mod_idP, frameP, DCCH_index,Srb_id-1,sdu_sizeP, enb_mod_idP); + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + LOG_N(RRC, "[UE %x] Frame %d: received a DCCH %d message on SRB %d with Size %d from eNB ???\n", + ctxt_pP->module_id, ctxt_pP->frame, DCCH_index,Srb_id-1,sdu_sizeP); } else { -#if defined(ENABLE_ITTI) - instance = enb_mod_idP; -#endif LOG_N(RRC, "[eNB %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from UE %d\n", - enb_mod_idP, frameP, DCCH_index,Srb_id-1,sdu_sizeP, ue_mod_idP); + ctxt_pP->module_id, + ctxt_pP->frame, + DCCH_index, + Srb_id-1, + sdu_sizeP, + ctxt_pP->rnti); } #if defined(ENABLE_ITTI) @@ -572,25 +593,33 @@ void rrc_lite_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). uint8_t *message_buffer; - message_buffer = itti_malloc (enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, enb_flagP ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP); + message_buffer = itti_malloc (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP); memcpy (message_buffer, buffer_pP, sdu_sizeP); - message_p = itti_alloc_new_message (enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND); - RRC_DCCH_DATA_IND (message_p).frame = frameP; + message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND); + RRC_DCCH_DATA_IND (message_p).frame = ctxt_pP->frame; RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index; RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_sizeP; RRC_DCCH_DATA_IND (message_p).sdu_p = message_buffer; - RRC_DCCH_DATA_IND (message_p).ue_index = ue_mod_idP; - RRC_DCCH_DATA_IND (message_p).eNB_index = enb_mod_idP; - - itti_send_msg_to_task (enb_flagP ? TASK_RRC_ENB : TASK_RRC_UE, instance, message_p); + RRC_DCCH_DATA_IND (message_p).rnti = ctxt_pP->rnti; + RRC_DCCH_DATA_IND (message_p).module_id = ctxt_pP->module_id; + itti_send_msg_to_task (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, ctxt_pP->instance, message_p); } #else - if (enb_flagP == ENB_FLAG_YES) { - rrc_eNB_decode_dcch(enb_mod_idP,frameP,DCCH_index,ue_mod_idP,buffer_pP,sdu_sizeP); + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { + rrc_eNB_decode_dcch( + ctxt_pP, + DCCH_index, + buffer_pP, + sdu_sizeP); } else { - rrc_ue_decode_dcch(ue_mod_idP,frameP,DCCH_index,buffer_pP,enb_mod_idP); +#warning "LG put 0 to arg4 that is eNB index" + rrc_ue_decode_dcch( + ctxt_pP, + DCCH_index, + buffer_pP, + 0); } #endif @@ -608,13 +637,14 @@ void rrc_lite_in_sync_ind(module_id_t Mod_idP, frame_t frameP, uint16_t eNB_inde RRC_MAC_IN_SYNC_IND (message_p).frame = frameP; RRC_MAC_IN_SYNC_IND (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); } #else UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt=0; - if (UE_rrc_inst[Mod_idP].Info[eNB_index].T310_active==1) + if (UE_rrc_inst[Mod_idP].Info[eNB_index].T310_active==1) { UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt++; + } #endif } @@ -637,28 +667,45 @@ void rrc_lite_out_of_sync_ind(module_id_t Mod_idP, frame_t frameP, uint16_t eNB_ RRC_MAC_OUT_OF_SYNC_IND (message_p).frame = frameP; RRC_MAC_OUT_OF_SYNC_IND (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); } #else UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt++; #endif } -//-------------------------------------------------------------------------------------------// -int mac_get_rrc_lite_status(module_id_t Mod_idP,eNB_flag_t enb_flagP,uint8_t index) +//------------------------------------------------------------------------------ +int +mac_eNB_get_rrc_lite_status( + const module_id_t Mod_idP, + const rnti_t rntiP +) +//------------------------------------------------------------------------------ { - //-------------------------------------------------------------------------------------------// - if (enb_flagP == ENB_FLAG_YES) { - DevAssert( Mod_idP < NB_eNB_INST ); - DevAssert( index < NUMBER_OF_UE_MAX ); - return(eNB_rrc_inst[Mod_idP].Info.UE[index].Status); + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + ue_context_p = rrc_eNB_get_ue_context( + &eNB_rrc_inst[Mod_idP], + rntiP); + + if (ue_context_p != NULL) { + return(ue_context_p->ue_context.Status); } else { - DevAssert( Mod_idP < NB_UE_INST ); - DevAssert( index < NB_SIG_CNX_UE ); - return(UE_rrc_inst[Mod_idP].Info[index].State); + return RRC_INACTIVE; } } + +//------------------------------------------------------------------------------ +int +mac_UE_get_rrc_lite_status( + const module_id_t Mod_idP, + const uint8_t indexP +) +//------------------------------------------------------------------------------ +{ + return(UE_rrc_inst[Mod_idP].Info[indexP].State); +} + //-------------------------------------------------------------------------------------------// int mac_ue_ccch_success_ind(module_id_t Mod_idP, uint8_t eNB_index) { @@ -670,7 +717,7 @@ int mac_ue_ccch_success_ind(module_id_t Mod_idP, uint8_t eNB_index) message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_CCCH_DATA_CNF); RRC_MAC_CCCH_DATA_CNF (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); } #else // reset the tx buffer to indicate RRC that ccch was successfully transmitted (for example if contention resolution succeeds) diff --git a/openair2/RRC/LITE/MESSAGES/Makefile b/openair2/RRC/LITE/MESSAGES/Makefile index 5317fd8b964..bd99081ad2e 100644 --- a/openair2/RRC/LITE/MESSAGES/Makefile +++ b/openair2/RRC/LITE/MESSAGES/Makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc OPENAIR2_TOP = ../../.. include $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index fb04b3cbebe..ad805368037 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -182,8 +182,9 @@ uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId) uint8_t i; for(i=0; i<7; i++) { - if(two_tier_hexagonal_cellIds[i] == phyCellId) + if(two_tier_hexagonal_cellIds[i] == phyCellId) { return i; + } } LOG_E(RRC,"\nCannot get adjacent cell mod id! Fatal error!\n"); @@ -389,8 +390,9 @@ uint8_t do_MIB(uint8_t Mod_id, LTE_DL_FRAME_PARMS *frame_parms, uint32_t frame, # endif #endif - if (enc_rval.encoded==-1) + if (enc_rval.encoded==-1) { return(-1); + } return((enc_rval.encoded+7)/8); /* @@ -602,8 +604,9 @@ uint8_t do_SIB1(uint8_t Mod_id, LTE_DL_FRAME_PARMS *frame_parms, uint8_t *buffer LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); #endif - if (enc_rval.encoded==-1) + if (enc_rval.encoded==-1) { return(-1); + } return((enc_rval.encoded+7)/8); } @@ -633,9 +636,9 @@ uint8_t do_SIB23(uint8_t Mod_id, #endif asn_enc_rval_t enc_rval; - if (bcch_message) + if (bcch_message) { memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t)); - else { + } else { LOG_E(RRC,"[eNB %d] BCCH_MESSAGE is null, exiting\n", Mod_id); exit(-1); } @@ -703,10 +706,12 @@ uint8_t do_SIB23(uint8_t Mod_id, } (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep = configuration->rach_powerRampingStep[0]; - (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower = configuration->rach_preambleInitialReceivedTargetPower[0]; + (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower = + configuration->rach_preambleInitialReceivedTargetPower[0]; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax = configuration->rach_preambleTransMax[0]; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize = configuration->rach_raResponseWindowSize[0]; - (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer = configuration->rach_macContentionResolutionTimer[0]; + (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer = + configuration->rach_macContentionResolutionTimer[0]; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = configuration->rach_maxHARQ_Msg3Tx[0]; // BCCH-Config @@ -833,10 +838,12 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles=RACH_ConfigCommon__preambleInfo__numberOfRA_Preambles_n64; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep=RACH_ConfigCommon__powerRampingParameters__powerRampingStep_dB2; - (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower=RACH_ConfigCommon__powerRampingParameters__preambleInitialReceivedTargetPower_dBm_100; + (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower= + RACH_ConfigCommon__powerRampingParameters__preambleInitialReceivedTargetPower_dBm_100; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax=RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize=RACH_ConfigCommon__ra_SupervisionInfo__ra_ResponseWindowSize_sf10; - (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer=RACH_ConfigCommon__ra_SupervisionInfo__mac_ContentionResolutionTimer_sf48; + (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer= + RACH_ConfigCommon__ra_SupervisionInfo__mac_ContentionResolutionTimer_sf48; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = 4; // BCCH-Config @@ -856,11 +863,12 @@ uint8_t do_SIB23(uint8_t Mod_id, // PDSCH-Config (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower=0; // corresponds to 24.7 dBm 5 MHz/ 27.7 10 MHz/ 30.7 20 MHz - if (frame_parms->mode1_flag==1) + if (frame_parms->mode1_flag==1) { (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=0; - else + } else { (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=1; + } // PUSCH-Config (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB=1; @@ -1109,14 +1117,6 @@ uint8_t do_SIB23(uint8_t Mod_id, AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); -#ifdef XER_PRINT - int i=0; - - for (i = 0; i < (enc_rval.encoded+7)/8; i++) - printf("%02x ", ((uint8_t*)buffer)[i]); - - printf("\n"); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) @@ -1314,7 +1314,14 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin } -uint8_t do_RRCConnectionReconfigurationComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id) +//------------------------------------------------------------------------------ +uint8_t +do_RRCConnectionReconfigurationComplete( + const protocol_ctxt_t* const ctxt_pP, + uint8_t* buffer, + const uint8_t Transaction_id +) +//------------------------------------------------------------------------------ { @@ -1331,7 +1338,8 @@ uint8_t do_RRCConnectionReconfigurationComplete(uint8_t Mod_id, uint8_t *buffer, rrcConnectionReconfigurationComplete = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionReconfigurationComplete; rrcConnectionReconfigurationComplete->rrc_TransactionIdentifier = Transaction_id; - rrcConnectionReconfigurationComplete->criticalExtensions.present = RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8; + rrcConnectionReconfigurationComplete->criticalExtensions.present = + RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8; rrcConnectionReconfigurationComplete->criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.nonCriticalExtension=NULL; enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, @@ -1354,7 +1362,7 @@ uint8_t do_RRCConnectionReconfigurationComplete(uint8_t Mod_id, uint8_t *buffer, msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif @@ -1368,12 +1376,15 @@ uint8_t do_RRCConnectionReconfigurationComplete(uint8_t Mod_id, uint8_t *buffer, } -uint8_t do_RRCConnectionSetup(uint8_t Mod_id, - uint8_t *buffer, - uint8_t transmission_mode, - uint8_t UE_id, - uint8_t Transaction_id, - LTE_DL_FRAME_PARMS *frame_parms, +//------------------------------------------------------------------------------ +uint8_t +do_RRCConnectionSetup( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + uint8_t* const buffer, + const uint8_t transmission_mode, + const uint8_t Transaction_id, + const LTE_DL_FRAME_PARMS* const frame_parms, SRB_ToAddModList_t **SRB_configList, struct PhysicalConfigDedicated **physicalConfigDedicated) { @@ -1381,23 +1392,22 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, asn_enc_rval_t enc_rval; uint8_t ecause=0; - long *logicalchannelgroup; - - struct SRB_ToAddMod *SRB1_config; - struct SRB_ToAddMod__rlc_Config *SRB1_rlc_config; - struct SRB_ToAddMod__logicalChannelConfig *SRB1_lchan_config; - struct LogicalChannelConfig__ul_SpecificParameters *SRB1_ul_SpecificParameters; + long* logicalchannelgroup = NULL; + struct SRB_ToAddMod* SRB1_config = NULL; + struct SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL; + struct SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL; + struct LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL; #ifdef CBA - struct PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola; - long * betaOffset_CBA_Index; - long * cShift_CBA; + struct PUSCH_CBAConfigDedicated_vlola* pusch_CBAConfigDedicated_vlola = NULL; + long* betaOffset_CBA_Index = NULL; + long* cShift_CBA = NULL; #endif - PhysicalConfigDedicated_t *physicalConfigDedicated2; + PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL; DL_CCCH_Message_t dl_ccch_msg; - RRCConnectionSetup_t *rrcConnectionSetup; + RRCConnectionSetup_t* rrcConnectionSetup = NULL; memset((void *)&dl_ccch_msg,0,sizeof(DL_CCCH_Message_t)); dl_ccch_msg.message.present = DL_CCCH_MessageType_PR_c1; @@ -1408,6 +1418,9 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, // Configure SRB1 // *SRB_configList = CALLOC(1,sizeof(*SRB_configList)); + if (*SRB_configList) { + free(*SRB_configList); + } *SRB_configList = CALLOC(1,sizeof(SRB_ToAddModList_t)); /// SRB1 @@ -1419,12 +1432,12 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, SRB1_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB1_rlc_config->choice.explicitValue.present=RLC_Config_PR_am; - SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit=T_PollRetransmit_ms15; - SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU=PollPDU_p8; - SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte=PollByte_kB1000; - SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold=UL_AM_RLC__maxRetxThreshold_t16; - SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering=T_Reordering_ms50; - SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit=T_StatusProhibit_ms10; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms80; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = PollPDU_p4; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = PollByte_kBinfinity; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8; + SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35; + SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms0; SRB1_lchan_config = CALLOC(1,sizeof(*SRB1_lchan_config)); SRB1_config->logicalChannelConfig = SRB1_lchan_config; @@ -1478,11 +1491,11 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.choice.release=0; if (frame_parms->frame_type == FDD) { - physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode=NULL;//PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing; } else { //TDD physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode= CALLOC(1,sizeof(long)); - *(physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode) = PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_bundling;//PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing; + *(physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode) = + PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_bundling;//PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing; } // Pusch_config_dedicated @@ -1498,7 +1511,8 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, physicalConfigDedicated2->uplinkPowerControlDedicated->accumulationEnabled = 1; // TRUE physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUCCH = 0; // 0 dB physicalConfigDedicated2->uplinkPowerControlDedicated->pSRS_Offset = 0; // 0 dB - physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient = CALLOC(1,sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient)); + physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient = CALLOC(1, + sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient)); // assign_enum(physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient,FilterCoefficient_fc4); // fc4 dB *physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient=FilterCoefficient_fc4; // fc4 dB @@ -1510,7 +1524,7 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf=CALLOC(1,2); physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.size=2; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[0]=0x12; - physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1]=0x34+UE_id; + physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.bits_unused=0; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->present=TPC_PDCCH_Config_PR_setup; @@ -1519,7 +1533,7 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf=CALLOC(1,2); physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.size=2; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0]=0x22; - physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1]=0x34+UE_id; + physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused=0; // CQI ReportConfig @@ -1577,8 +1591,10 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, case 3: physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm3; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction= CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction)); - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction= CALLOC(1, + sizeof(*physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction)); + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; @@ -1606,23 +1622,26 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, // SchedulingRequestConfig physicalConfigDedicated2->schedulingRequestConfig->present = SchedulingRequestConfig_PR_setup; - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = UE_id; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = ue_context_pP->local_uid; - if (frame_parms->frame_type == 0) // FDD - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5+(UE_id%10); // Isr = 5 (every 10 subframes, offset=2+UE_id mod3) + if (frame_parms->frame_type == 0) { // FDD + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5+(ue_context_pP->local_uid%10); // Isr = 5 (every 10 subframes, offset=2+UE_id mod3) + } else { switch (frame_parms->tdd_config) { case 1: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(UE_id&1)+((UE_id&3)>>1) - *5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(ue_context_pP->local_uid&1)+(( + ue_context_pP->local_uid&3)>>1)*5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) break; case 3: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(UE_id%3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ + (ue_context_pP->local_uid%3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) break; case 4: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(UE_id&1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ + (ue_context_pP->local_uid&1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) break; default: @@ -1679,14 +1698,15 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif #ifdef USER_MODE - LOG_D(RRC,"RRCConnectionSetup Encoded %d bits (%d bytes), ecause %d\n",enc_rval.encoded,(enc_rval.encoded+7)/8,ecause); + LOG_D(RRC,"RRCConnectionSetup Encoded %d bits (%d bytes), ecause %d\n", + enc_rval.encoded,(enc_rval.encoded+7)/8,ecause); #endif // FREEMEM(SRB_list); @@ -1698,12 +1718,16 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, return((enc_rval.encoded+7)/8); } -uint8_t do_SecurityModeCommand(uint8_t Mod_id, - uint8_t *buffer, - uint8_t UE_id, - uint8_t Transaction_id, - uint8_t cipheringAlgorithm, - uint8_t integrityProtAlgorithm) +//------------------------------------------------------------------------------ +uint8_t +do_SecurityModeCommand( + const protocol_ctxt_t* const ctxt_pP, + uint8_t* const buffer, + const uint8_t Transaction_id, + const uint8_t cipheringAlgorithm, + const uint8_t integrityProtAlgorithm +) +//------------------------------------------------------------------------------ { DL_DCCH_Message_t dl_dcch_msg; asn_enc_rval_t enc_rval; @@ -1716,7 +1740,8 @@ uint8_t do_SecurityModeCommand(uint8_t Mod_id, dl_dcch_msg.message.choice.c1.choice.securityModeCommand.rrc_TransactionIdentifier = Transaction_id; dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1; - dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.present = SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8; + dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.present = + SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8; // the two following information could be based on the mod_id dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm = (e_SecurityAlgorithmConfig__cipheringAlgorithm)cipheringAlgorithm; @@ -1746,18 +1771,24 @@ uint8_t do_SecurityModeCommand(uint8_t Mod_id, msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif #ifdef USER_MODE - LOG_D(RRC,"[eNB %d] securityModeCommand for UE %d Encoded %d bits (%d bytes)\n",Mod_id,UE_id,enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_D(RRC,"[eNB %d] securityModeCommand for UE %x Encoded %d bits (%d bytes)\n", + ctxt_pP->module_id, + ctxt_pP->rnti, + enc_rval.encoded, + (enc_rval.encoded+7)/8); #endif if (enc_rval.encoded==-1) { - LOG_E(RRC,"[eNB %d] ASN1 : securityModeCommand encoding failed for UE %d\n",Mod_id,UE_id); + LOG_E(RRC,"[eNB %d] ASN1 : securityModeCommand encoding failed for UE %x\n", + ctxt_pP->module_id, + ctxt_pP->rnti); return(-1); } @@ -1766,10 +1797,14 @@ uint8_t do_SecurityModeCommand(uint8_t Mod_id, return((enc_rval.encoded+7)/8); } -uint8_t do_UECapabilityEnquiry(uint8_t Mod_id, - uint8_t *buffer, - uint8_t UE_id, - uint8_t Transaction_id) +//------------------------------------------------------------------------------ +uint8_t +do_UECapabilityEnquiry( + const protocol_ctxt_t* const ctxt_pP, + uint8_t* const buffer, + const uint8_t Transaction_id +) +//------------------------------------------------------------------------------ { DL_DCCH_Message_t dl_dcch_msg; @@ -1785,7 +1820,8 @@ uint8_t do_UECapabilityEnquiry(uint8_t Mod_id, dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.rrc_TransactionIdentifier = Transaction_id; dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.present = UECapabilityEnquiry__criticalExtensions_PR_c1; - dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present = UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8; + dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present = + UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8; dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count=0; ASN_SEQUENCE_ADD(&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list, &rat); @@ -1813,29 +1849,35 @@ uint8_t do_UECapabilityEnquiry(uint8_t Mod_id, msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif #ifdef USER_MODE - LOG_D(RRC,"[eNB %d] UECapabilityRequest for UE %d Encoded %d bits (%d bytes)\n",Mod_id,UE_id,enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_D(RRC,"[eNB %d] UECapabilityRequest for UE %x Encoded %d bits (%d bytes)\n", + ctxt_pP->module_id, + ctxt_pP->rnti, + enc_rval.encoded, + (enc_rval.encoded+7)/8); #endif if (enc_rval.encoded==-1) { - LOG_E(RRC,"[eNB %d] ASN1 : UECapabilityRequest encoding failed for UE %d\n",Mod_id,UE_id); + LOG_E(RRC,"[eNB %d] ASN1 : UECapabilityRequest encoding failed for UE %x\n", + ctxt_pP->module_id, + ctxt_pP->rnti); return(-1); } - // rrc_ue_process_ueCapabilityEnquiry(0,1000,&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry,0); - // exit(-1); return((enc_rval.encoded+7)/8); } -uint16_t do_RRCConnectionReconfiguration(uint8_t Mod_id, +//------------------------------------------------------------------------------ +uint16_t +do_RRCConnectionReconfiguration( + const protocol_ctxt_t* const ctxt_pP, uint8_t *buffer, - uint8_t UE_id, uint8_t Transaction_id, SRB_ToAddModList_t *SRB_list, DRB_ToAddModList_t *DRB_list, @@ -1859,6 +1901,7 @@ uint16_t do_RRCConnectionReconfiguration(uint8_t Mod , SCellToAddMod_r10_t *SCell_config #endif ) +//------------------------------------------------------------------------------ { asn_enc_rval_t enc_rval; @@ -1917,16 +1960,18 @@ uint16_t do_RRCConnectionReconfiguration(uint8_t Mod memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig, (void *)quantityConfig, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig)); - } else + } else { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig = NULL; + } if(speedStatePars != NULL) { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars)); memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars, (void *)speedStatePars,sizeof(*speedStatePars)); - } else + } else { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars = NULL; + } rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->s_Measure= rsrp; } else { @@ -1936,9 +1981,12 @@ uint16_t do_RRCConnectionReconfiguration(uint8_t Mod if (mobilityInfo !=NULL) { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo)); - memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo, (void *)mobilityInfo,sizeof(MobilityControlInfo_t)); - } else + memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo, (void*)mobilityInfo, + sizeof(MobilityControlInfo_t)); + + } else { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo = NULL; + } rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.dedicatedInfoNASList = dedicatedInfoNASList; rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.securityConfigHO = NULL; @@ -1967,7 +2015,7 @@ uint16_t do_RRCConnectionReconfiguration(uint8_t Mod msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif @@ -1984,9 +2032,10 @@ uint16_t do_RRCConnectionReconfiguration(uint8_t Mod return((enc_rval.encoded+7)/8); } -uint8_t do_RRCConnectionRelease(uint8_t Mod_id, - uint8_t *buffer, - uint8_t Transaction_id) +uint8_t do_RRCConnectionRelease( + uint8_t Mod_id, + uint8_t *buffer, + uint8_t Transaction_id) { asn_enc_rval_t enc_rval; @@ -2472,9 +2521,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) // UE_EUTRA_Capability->measParameters.bandListEUTRA.list.count = 0; // no measurements on other bands // UE_EUTRA_Capability->featureGroupIndicators // null // UE_EUTRA_Capability->interRAT_Parameters // null - } - - else { + } else { FILE* f = fopen(UE_EUTRA_Capability_xer_fname, "r"); assert(f); @@ -2537,8 +2584,9 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) char *sdu; sdu = malloc (3 * UECapability.sdu_size + 1 /* For '\0' */); - for (i = 0; i < UECapability.sdu_size; i++) + for (i = 0; i < UECapability.sdu_size; i++) { sprintf (&sdu[3 * i], "%02x.", UECapability.sdu[i]); + } LOG_D(PHY, "[RRC]UE Capability encoded, %s\n", sdu); free(sdu); diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.h b/openair2/RRC/LITE/MESSAGES/asn1_msg.h index 4568bf6b531..3279a472fe7 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.h @@ -121,16 +121,24 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv); /** \brief Generate an RRCConnectionSetupComplete UL-DCCH-Message (UE) @param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS); +uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t* buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, + const char* dedicatedInfoNAS); /** \brief Generate an RRCConnectionReconfigurationComplete UL-DCCH-Message (UE) @param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionReconfigurationComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id); +uint8_t +do_RRCConnectionReconfigurationComplete( + const protocol_ctxt_t* const ctxt_pP, + uint8_t* buffer, + const uint8_t Transaction_id +); /** \brief Generate an RRCConnectionSetup DL-CCCH-Message (eNB). This routine configures SRB_ToAddMod (SRB1/SRB2) and PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting (PUCCH format 2/2a/2b) or SRS. +@param ctxt_pP Running context +@param ue_context_pP UE context @param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU @param transmission_mode Transmission mode for UE (1-9) @param UE_id UE index for this message @@ -138,21 +146,23 @@ PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting @param SRB_configList Pointer (returned) to SRB1_config/SRB2_config(later) IEs for this UE @param physicalConfigDedicated Pointer (returned) to PhysicalConfigDedicated IE for this UE @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionSetup(uint8_t Mod_id, - uint8_t *buffer, - uint8_t transmission_mode, - uint8_t UE_id, - uint8_t Transaction_id, - LTE_DL_FRAME_PARMS *frame_parms, - SRB_ToAddModList_t **SRB1_configList, - struct PhysicalConfigDedicated **physicalConfigDedicated); +uint8_t +do_RRCConnectionSetup( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + uint8_t* const buffer, + const uint8_t transmission_mode, + const uint8_t Transaction_id, + const LTE_DL_FRAME_PARMS* const frame_parms, + SRB_ToAddModList_t** SRB_configList, + struct PhysicalConfigDedicated** physicalConfigDedicated +); /** \brief Generate an RRCConnectionReconfiguration DL-DCCH-Message (eNB). This routine configures SRBToAddMod (SRB2) and one DRBToAddMod (DRB3). PhysicalConfigDedicated is not updated. -@param Mod_id Module ID of this eNB Instance +@param ctxt_pP Running context @param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU -@param UE_id UE index for this message @param Transaction_id Transaction_ID for this message @param SRB_list Pointer to SRB List to be added/modified (NULL if no additions/modifications) @param DRB_list Pointer to DRB List to be added/modified (NULL if no additions/modifications) @@ -170,9 +180,10 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id, @param cba_rnti RNTI for the cba transmission @returns Size of encoded bit stream in bytes*/ -uint16_t do_RRCConnectionReconfiguration(uint8_t Mod_id, +uint16_t +do_RRCConnectionReconfiguration( + const protocol_ctxt_t* const ctxt_pP, uint8_t *buffer, - uint8_t UE_id, uint8_t Transaction_id, SRB_ToAddModList_t *SRB_list, DRB_ToAddModList_t *DRB_list, @@ -189,8 +200,7 @@ uint16_t do_RRCConnectionReconfiguration(uint8_t Mod struct MeasConfig__speedStatePars *speedStatePars, RSRP_Range_t *rsrp, C_RNTI_t *cba_rnti, - struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList - *dedicatedInfoNASList + struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList* dedicatedInfoNASList #ifdef Rel10 , SCellToAddMod_r10_t *SCell_config #endif @@ -234,14 +244,16 @@ uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer); -uint8_t do_UECapabilityEnquiry(uint8_t Mod_id, - uint8_t *buffer, - uint8_t UE_id, - uint8_t Transaction_id); - -uint8_t do_SecurityModeCommand(uint8_t Mod_id, - uint8_t *buffer, - uint8_t UE_id, - uint8_t Transaction_id, - uint8_t cipheringAlgorithm, - uint8_t integrityProtAlgorithm); +uint8_t +do_UECapabilityEnquiry( + const protocol_ctxt_t* const ctxt_pP, + uint8_t* const buffer, + const uint8_t Transaction_id +); + +uint8_t do_SecurityModeCommand( + const protocol_ctxt_t* const ctxt_pP, + uint8_t* const buffer, + const uint8_t Transaction_id, + const uint8_t cipheringAlgorithm, + const uint8_t integrityProtAlgorithm); diff --git a/openair2/RRC/LITE/MESSAGES/bsearch.c b/openair2/RRC/LITE/MESSAGES/bsearch.c index 6519ca086cb..9f54633d6eb 100644 --- a/openair2/RRC/LITE/MESSAGES/bsearch.c +++ b/openair2/RRC/LITE/MESSAGES/bsearch.c @@ -35,19 +35,21 @@ void *bsearch(const void *key, const void *base, size_t num, size_t size, { int start = 0, end = num - 1, mid, result; - if (num == 0) + if (num == 0) { return NULL; + } while (start <= end) { mid = (start + end) / 2; result = cmp(key, base + mid * size); - if (result < 0) + if (result < 0) { end = mid - 1; - else if (result > 0) + } else if (result > 0) { start = mid + 1; - else + } else { return (void *)base + mid * size; + } } return NULL; diff --git a/openair2/RRC/LITE/MESSAGES/rtai_mem.c b/openair2/RRC/LITE/MESSAGES/rtai_mem.c index aa3c2b4b601..b54817eafa4 100644 --- a/openair2/RRC/LITE/MESSAGES/rtai_mem.c +++ b/openair2/RRC/LITE/MESSAGES/rtai_mem.c @@ -100,9 +100,9 @@ void* rt_realloc(void* oldptr, int size) printk("rt_mem.c: reallocating %p with %d bytes\n",oldptr,size); - if (oldptr==NULL) + if (oldptr==NULL) { newptr = rt_malloc(size); - else { + } else { newptr = rt_malloc(size); memcpy(newptr,oldptr,size); rt_free(oldptr); diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index 33edf567c2a..bc09e1107ee 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -46,9 +46,11 @@ #include <string.h> #endif +#include "collection/tree.h" #include "rrc_types.h" #include "PHY/defs.h" #include "COMMON/platform_constants.h" +#include "COMMON/platform_types.h" #include "COMMON/mac_rrc_primitives.h" #include "LAYER2/MAC/defs.h" @@ -117,6 +119,22 @@ # include "collection/hashtable/obj_hashtable.h" #endif +//-------- +typedef unsigned int uid_t; +#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((NUMBER_OF_UE_MAX/8)/sizeof(unsigned int)) + 1) +typedef struct uid_linear_allocator_s { + unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE]; +} uid_allocator_t; + +//-------- + + + +#define PROTOCOL_RRC_CTXT_UE_FMT PROTOCOL_CTXT_FMT +#define PROTOCOL_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp) + +#define PROTOCOL_RRC_CTXT_FMT PROTOCOL_CTXT_FMT +#define PROTOCOL_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp) /** @defgroup _rrc_impl_ RRC Layer Reference Implementation * @ingroup _ref_implementation_ * @{ @@ -190,6 +208,7 @@ typedef struct UE_RRC_INFO_s { uint32_t T310_cnt; uint32_t N310_cnt; uint32_t N311_cnt; + rnti_t rnti; } __attribute__ ((__packed__)) UE_RRC_INFO; typedef struct UE_S_TMSI_s { @@ -211,60 +230,10 @@ typedef struct e_rab_param_s { } __attribute__ ((__packed__)) e_rab_param_t; #endif -typedef struct eNB_RRC_UE_INFO_s { - uint8_t Status; - -#if defined(ENABLE_ITTI) - /* Information from UE RRC ConnectionRequest */ - UE_S_TMSI Initialue_identity_s_TMSI; - EstablishmentCause_t establishment_cause; - - /* Information from UE RRC ConnectionReestablishmentRequest */ - - ReestablishmentCause_t reestablishment_cause; - - - /* UE id for initial connection to S1AP */ - uint16_t ue_initial_id; - - /* Information from S1AP initial_context_setup_req */ - uint32_t eNB_ue_s1ap_id :24; - - security_capabilities_t security_capabilities; - - /* Number of e_rab to be setup in the list */ - uint8_t nb_of_e_rabs; - /* list of e_rab to be setup by RRC layers */ - e_rab_param_t e_rab[S1AP_MAX_E_RAB]; - - // LG: For GTPV1 TUNNELS - uint32_t enb_gtp_teid[S1AP_MAX_E_RAB]; - transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB]; - rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB]; - -#endif -} __attribute__ ((__packed__)) eNB_RRC_UE_INFO; - -typedef struct eNB_RRC_INFO_s { - /* Number of UE handle by the eNB */ - uint8_t Nb_ue; - /* UE list for UE index allocation */ - uint64_t UE_list[NUMBER_OF_UE_MAX]; - /* Information on UE */ - eNB_RRC_UE_INFO UE[NUMBER_OF_UE_MAX]; -} __attribute__ ((__packed__)) eNB_RRC_INFO; -typedef struct RRC_INFO_s { - int Status; - union { - UE_RRC_INFO UE_info; - eNB_RRC_INFO CH_info; - } Info; -} RRC_INFO; - -/* Intermediate structure for Hanodver management. Associated per-UE in eNB_RRC_INST */ +/* Intermediate structure for Handover management. Associated per-UE in eNB_RRC_INST */ typedef struct HANDOVER_INFO_s { uint8_t ho_prepare; uint8_t ho_complete; @@ -326,6 +295,87 @@ typedef struct HANDOVER_INFO_UE_s { PhysCellId_t targetCellId; uint8_t measFlag; } HANDOVER_INFO_UE; +typedef struct eNB_RRC_UE_s { +#ifdef Rel10 + SCellToAddMod_r10_t sCell_config[2]; +#endif + SRB_ToAddModList_t* SRB_configList; + DRB_ToAddModList_t* DRB_configList; + uint8_t DRB_active[8]; + struct PhysicalConfigDedicated* physicalConfigDedicated; + struct SPS_Config* sps_Config; + MeasObjectToAddMod_t* MeasObj[MAX_MEAS_OBJ]; + struct ReportConfigToAddMod* ReportConfig[MAX_MEAS_CONFIG]; + struct QuantityConfig* QuantityConfig; + struct MeasIdToAddMod* MeasId[MAX_MEAS_ID]; + MAC_MainConfig_t* mac_MainConfig; + MeasGapConfig_t* measGapConfig; + SRB_INFO SI; + SRB_INFO Srb0; + SRB_INFO_TABLE_ENTRY Srb1; + SRB_INFO_TABLE_ENTRY Srb2; + MeasConfig_t* measConfig; + HANDOVER_INFO* handover_info; + + +#if defined(ENABLE_SECURITY) + /* KeNB as derived from KASME received from EPC */ + uint8_t kenb[32]; +#endif + /* Used integrity/ciphering algorithms */ + e_SecurityAlgorithmConfig__cipheringAlgorithm ciphering_algorithm; + e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; + + + + uint8_t Status; + rnti_t rnti; + uint64_t random_ue_identity; + +#if defined(ENABLE_ITTI) + /* Information from UE RRC ConnectionRequest */ + UE_S_TMSI Initialue_identity_s_TMSI; + EstablishmentCause_t establishment_cause; + + /* Information from UE RRC ConnectionReestablishmentRequest */ + ReestablishmentCause_t reestablishment_cause; + + /* UE id for initial connection to S1AP */ + uint16_t ue_initial_id; + + /* Information from S1AP initial_context_setup_req */ + uint32_t eNB_ue_s1ap_id :24; + + security_capabilities_t security_capabilities; + + /* Number of e_rab to be setup in the list */ + uint8_t nb_of_e_rabs; + /* list of e_rab to be setup by RRC layers */ + e_rab_param_t e_rab[S1AP_MAX_E_RAB]; + + // LG: For GTPV1 TUNNELS + uint32_t enb_gtp_teid[S1AP_MAX_E_RAB]; + transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB]; + rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB]; +#endif +} eNB_RRC_UE_t; + +typedef uid_t ue_uid_t; +typedef struct rrc_eNB_ue_context_s { + /* Tree related data */ + RB_ENTRY(rrc_eNB_ue_context_s) entries; + + /* Uniquely identifies the UE between MME and eNB within the eNB. + * This id is encoded on 24bits. + */ + rnti_t ue_id_rnti; + + // an other key for protocol layers but should not be used as a key for RB tree + ue_uid_t local_uid; + + /* UE id for initial connection to S1AP */ + struct eNB_RRC_UE_s ue_context; +} rrc_eNB_ue_context_t; typedef struct eNB_RRC_INST_s { uint8_t *SIB1; @@ -333,9 +383,6 @@ typedef struct eNB_RRC_INST_s { uint8_t *SIB23; uint8_t sizeof_SIB23; uint16_t physCellId; -#ifdef Rel10 - SCellToAddMod_r10_t sCell_config[NUMBER_OF_UE_MAX][2]; -#endif BCCH_BCH_Message_t mib; BCCH_DL_SCH_Message_t siblock1; BCCH_DL_SCH_Message_t systemInformation; @@ -357,35 +404,16 @@ typedef struct eNB_RRC_INST_s { uint8_t num_active_cba_groups; uint16_t cba_rnti[NUM_MAX_CBA_GROUP]; #endif - SRB_ToAddModList_t *SRB_configList[NUMBER_OF_UE_MAX]; - DRB_ToAddModList_t *DRB_configList[NUMBER_OF_UE_MAX]; - uint8_t DRB_active[NUMBER_OF_UE_MAX][8]; - struct PhysicalConfigDedicated *physicalConfigDedicated[NUMBER_OF_UE_MAX]; - struct SPS_Config *sps_Config[NUMBER_OF_UE_MAX]; - MeasObjectToAddMod_t *MeasObj[NUMBER_OF_UE_MAX][MAX_MEAS_OBJ]; - struct ReportConfigToAddMod *ReportConfig[NUMBER_OF_UE_MAX][MAX_MEAS_CONFIG]; - struct QuantityConfig *QuantityConfig[NUMBER_OF_UE_MAX]; - struct MeasIdToAddMod *MeasId[NUMBER_OF_UE_MAX][MAX_MEAS_ID]; - MAC_MainConfig_t *mac_MainConfig[NUMBER_OF_UE_MAX]; - MeasGapConfig_t *measGapConfig[NUMBER_OF_UE_MAX]; - eNB_RRC_INFO Info; + uid_allocator_t uid_allocator; // for rrc_ue_head + RB_HEAD(rrc_ue_tree_s, rrc_eNB_ue_context_s) rrc_ue_head; // ue_context tree key search by rnti + RB_HEAD(rrc_rnti_tree_s, rrc_ue_s1ap_ids_s) rrc_rnti_head; // ue-rnti tree key search by S1AP ids SRB_INFO SI; SRB_INFO Srb0; - SRB_INFO_TABLE_ENTRY Srb1[NUMBER_OF_UE_MAX+1]; - SRB_INFO_TABLE_ENTRY Srb2[NUMBER_OF_UE_MAX+1]; - MeasConfig_t *measConfig[NUMBER_OF_UE_MAX]; - HANDOVER_INFO *handover_info[NUMBER_OF_UE_MAX]; uint8_t HO_flag; + uint8_t Nb_ue; #if defined(ENABLE_RAL) obj_hash_table_t *ral_meas_thresholds; #endif -#if defined(ENABLE_SECURITY) - /* KeNB as derived from KASME received from EPC */ - uint8_t kenb[NUMBER_OF_UE_MAX][32]; -#endif - /* Used integrity/ciphering algorithms */ - e_SecurityAlgorithmConfig__cipheringAlgorithm ciphering_algorithm[NUMBER_OF_UE_MAX]; - e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm[NUMBER_OF_UE_MAX]; #ifdef LOCALIZATION /// localization type, 0: power based, 1: time based uint8_t loc_type; diff --git a/openair2/RRC/LITE/mesh_top.c b/openair2/RRC/LITE/mesh_top.c index f099e79f1a6..7fd0edaf12d 100644 --- a/openair2/RRC/LITE/mesh_top.c +++ b/openair2/RRC/LITE/mesh_top.c @@ -86,8 +86,9 @@ int init_module( void ) if( Mac_rlc_xface == NULL ) { printk("[OPENAIR][RRC][INIT] Could not get RRC descriptor\n"); return -1; - } else + } else { printk("[OPENAIR][RRC][INIT] Got RRC descriptor , Rcc_xface %p,Mac_rlc_xface=%p \n",Rrc_xface,Mac_rlc_xface); + } if(rrc_init_global_param()==-1) { printk("[OPENAIR][RRC][INIT] FATAL ERROR: INIT_GLOBAL_PARAM_NOK\n"); diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h index 0a216b4dea4..b88d4b348c2 100644 --- a/openair2/RRC/LITE/proto.h +++ b/openair2/RRC/LITE/proto.h @@ -40,61 +40,104 @@ int rrc_init_global_param(void); int L3_xface_init(void); void openair_rrc_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active,uint8_t HO_enabled); -char openair_rrc_lite_eNB_init(module_id_t module_idP); -char openair_rrc_lite_ue_init(module_id_t module_idP,uint8_t CH_IDX); +#if defined(ENABLE_ITTI) +char +openair_rrc_lite_eNB_configuration( + const module_id_t enb_mod_idP, + RrcConfigurationReq* configuration +); +#endif +char openair_rrc_lite_eNB_init( + const module_id_t module_idP); + +char openair_rrc_lite_ue_init( + const module_id_t module_idP, + const uint8_t CH_IDX); void rrc_config_buffer(SRB_INFO *srb_info, uint8_t Lchan_type, uint8_t Role); -void openair_rrc_on(module_id_t module_idP, eNB_flag_t eNB_flagP); +void +openair_rrc_on( + const protocol_ctxt_t* const ctxt_pP); void rrc_top_cleanup(void); /** \brief Function to update timers every subframe. For UE it updates T300,T304 and T310. -@param module_idP Instance of UE/eNB -@param frame Frame index -@param eNB_flag Flag to indicate if this instance is and eNB or UE -@param index Index of corresponding eNB (for UE) +@param ctxt_pP running context +@param enb_index +@param CC_id */ -RRC_status_t rrc_rx_tx(module_id_t module_idP,frame_t frameP, eNB_flag_t eNB_flagP,uint8_t index,int CC_id); +RRC_status_t +rrc_rx_tx( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t enb_index, + const int CC_id +); // UE RRC Procedures /** \brief Decodes DL-CCCH message and invokes appropriate routine to handle the message - \param module_idP Instance ID of UE + \param ctxt_pP Running context \param Srb_info Pointer to SRB_INFO structure (SRB0) \param eNB_index Index of corresponding eNB/CH*/ -int rrc_ue_decode_ccch(module_id_t module_idP, frame_t frameP, SRB_INFO *Srb_info,uint8_t eNB_index); +int +rrc_ue_decode_ccch( + const protocol_ctxt_t* const ctxt_pP, + const SRB_INFO* const Srb_info, + const uint8_t eNB_index +); /** \brief Decodes a DL-DCCH message and invokes appropriate routine to handle the message - \param module_idP Instance ID of UE - \param frame Frame index + \param ctxt_pP Running context \param Srb_id Index of Srb (1,2) \param buffer_pP Pointer to received SDU - \param eNB_index Index of corresponding CH/eNB*/ -void rrc_ue_decode_dcch(module_id_t module_idP, frame_t frameP, uint8_t Srb_id, uint8_t* buffer_pP,uint8_t eNB_index); + \param eNB_index Index of corresponding eNB/CH*/ +void +rrc_ue_decode_dcch( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t Srb_id, + const uint8_t* const Buffer, + const uint8_t eNB_indexP +); /** \brief Generate/Encodes RRCConnnectionRequest message at UE - \param module_idP Instance ID of UE - \param frame Frame index - \param Srb_id Index of Srb (1,2) + \param ctxt_pP Running context \param eNB_index Index of corresponding eNB/CH*/ -void rrc_ue_generate_RRCConnectionRequest(module_id_t module_idP, frame_t frameP, uint8_t eNB_index); +void +rrc_ue_generate_RRCConnectionRequest( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index +); /** \brief Generates/Encodes RRCConnnectionSetupComplete message at UE - \param module_idP Instance ID of UE - \param frame Frame index - \param eNB_index Index of corresponding eNB/CH*/ -void rrc_ue_generate_RRCConnectionSetupComplete(module_id_t module_idP,frame_t frameP,uint8_t eNB_index, uint8_t Transaction_id); + \param ctxt_pP Running context + \param eNB_index Index of corresponding eNB/CH + \param Transaction_id Transaction identifier*/ +void +rrc_ue_generate_RRCConnectionSetupComplete( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t Transaction_id +); /** \brief process the received rrcConnectionReconfiguration message at UE - \param module_idP Instance ID of UE - \param frame Frame index + \param ctxt_pP Running context \param *rrcConnectionReconfiguration pointer to the sturcture \param eNB_index Index of corresponding eNB/CH*/ -void rrc_ue_process_rrcConnectionReconfiguration(module_id_t module_idP, frame_t frameP,RRCConnectionReconfiguration_t *rrcConnectionReconfiguration,uint8_t eNB_index); +void +rrc_ue_process_rrcConnectionReconfiguration( + const protocol_ctxt_t* const ctxt_pP, + RRCConnectionReconfiguration_t* rrcConnectionReconfiguration, + uint8_t eNB_index +); /** \brief Generates/Encodes RRCConnectionReconfigurationComplete message at UE - \param module_idP Instance ID of UE - \param frame Frame index - \param eNB_index Index of corresponding eNB/CH*/ -void rrc_ue_generate_RRCConnectionReconfigurationComplete(module_id_t module_idP, frame_t frameP, uint8_t eNB_index, uint8_t Transaction_id); + \param ctxt_pP Running context + \param eNB_index Index of corresponding eNB/CH + \param Transaction_id RRC transaction identifier */ +void +rrc_ue_generate_RRCConnectionReconfigurationComplete( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t Transaction_id +); /** \brief Establish SRB1 based on configuration in SRB_ToAddMod structure. Configures RLC/PDCP accordingly \param module_idP Instance ID of UE @@ -120,25 +163,35 @@ int32_t rrc_ue_establish_srb2(module_id_t module_idP,frame_t frameP, uint8_t eN int32_t rrc_ue_establish_drb(module_id_t module_idP,frame_t frameP,uint8_t eNB_index,struct DRB_ToAddMod *DRB_config); /** \brief Process MobilityControlInfo Message to proceed with handover and configure PHY/MAC - \param module_idP Instance of UE on which to act - \param frame frame time interval + \param ctxt_pP Running context \param eNB_index Index of corresponding CH/eNB \param mobilityControlInfo Pointer to mobilityControlInfo */ -void rrc_ue_process_mobilityControlInfo(module_id_t enb_module_idP, module_id_t ue_module_idP, frame_t frameP, struct MobilityControlInfo *mobilityControlInfo); +void +rrc_ue_process_mobilityControlInfo( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + struct MobilityControlInfo* const mobilityControlInfo +); /** \brief Process a measConfig Message and configure PHY/MAC - \param module_idP Instance of UE on which to act - \param frame frame time interval + \param ctxt_pP Running context \param eNB_index Index of corresponding CH/eNB \param measConfig Pointer to MeasConfig IE from configuration*/ -void rrc_ue_process_measConfig(module_id_t module_idP,frame_t frameP, uint8_t eNB_index,MeasConfig_t *measConfig); +void +rrc_ue_process_measConfig( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + MeasConfig_t* const measConfig +); /** \brief Process a RadioResourceConfigDedicated Message and configure PHY/MAC - \param module_idP Instance of UE on which to act + \param ctxt_pP Running context \param eNB_index Index of corresponding CH/eNB \param radioResourceConfigDedicated Pointer to RadioResourceConfigDedicated IE from configuration*/ -void rrc_ue_process_radioResourceConfigDedicated(module_id_t module_idP,frame_t frameP, uint8_t eNB_index, +void rrc_ue_process_radioResourceConfigDedicated( + const protocol_ctxt_t* const ctxt_pP, + uint8_t eNB_index, RadioResourceConfigDedicated_t *radioResourceConfigDedicated); // eNB/CH RRC Procedures @@ -149,45 +202,72 @@ void rrc_ue_process_radioResourceConfigDedicated(module_id_t module_idP,frame_t uint8_t rrc_eNB_get_next_transaction_identifier(module_id_t module_idP); /**\brief Entry routine to decode a UL-CCCH-Message. Invokes PER decoder and parses message. - \param module_idP Instance ID for CH/eNB - \param frame Frame index + \param ctxt_pP Running context \param Srb_info Pointer to SRB0 information structure (buffer, etc.)*/ -int rrc_eNB_decode_ccch(module_id_t module_idP, frame_t frameP, SRB_INFO *Srb_info); +int +rrc_eNB_decode_ccch( + protocol_ctxt_t* const ctxt_pP, + const SRB_INFO* const Srb_info +); /**\brief Entry routine to decode a UL-DCCH-Message. Invokes PER decoder and parses message. - \param module_idP Instance ID for CH/eNB - \param frame Frame index - \param ue_module_idP Index of UE sending the message + \param ctxt_pP Context \param Rx_sdu Pointer Received Message \param sdu_size Size of incoming SDU*/ -int rrc_eNB_decode_dcch(module_id_t module_idP, frame_t frameP, uint8_t Srb_id, module_id_t ue_module_idP, uint8_t *Rx_sdu, sdu_size_t sdu_size); +int +rrc_eNB_decode_dcch( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t Srb_id, + const uint8_t* const Rx_sdu, + const sdu_size_t sdu_sizeP +); /**\brief Generate the RRCConnectionSetup based on information coming from RRM - \param module_idP Instance ID for eNB/CH - \param frame Frame index - \param ue_module_idP Index of UE receiving the message*/ -void rrc_eNB_generate_RRCConnectionSetup(module_id_t module_idP,frame_t frameP, module_id_t ue_module_idP); + \param ctxt_pP Running context + \param ue_context_pP UE context*/ +void +rrc_eNB_generate_RRCConnectionSetup( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +); /**\brief Process the RRCConnectionSetupComplete based on information coming from UE - \param module_idP Instance ID for eNB/CH - \param frame Frame index - \param ue_module_idP Index of UE transmitting the message + \param ctxt_pP Running context + \param ue_context_pP RRC UE context \param rrcConnectionSetupComplete Pointer to RRCConnectionSetupComplete message*/ -void rrc_eNB_process_RRCConnectionSetupComplete(module_id_t module_idP, frame_t frameP, module_id_t ue_module_idP, - RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete); +void +rrc_eNB_process_RRCConnectionSetupComplete( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete +); /**\brief Process the RRCConnectionReconfigurationComplete based on information coming from UE - \param module_idP Instance ID for eNB/CH - \param ue_module_idP Index of UE transmitting the messages + \param ctxt_pP Running context + \param ue_context_pP RRC UE context \param rrcConnectionReconfigurationComplete Pointer to RRCConnectionReconfigurationComplete message*/ -void rrc_eNB_process_RRCConnectionReconfigurationComplete(module_id_t module_idP,frame_t frameP,module_id_t ue_module_idP, - RRCConnectionReconfigurationComplete_r8_IEs_t *rrcConnectionReconfigurationComplete); +void +rrc_eNB_process_RRCConnectionReconfigurationComplete( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + RRCConnectionReconfigurationComplete_r8_IEs_t* rrcConnectionReconfigurationComplete +); /**\brief Generate the RRCConnectionRelease - \param module_idP Instance ID for eNB - \param frame Frame index - \param ue_module_idP Index of UE receiving the message*/ -void rrc_eNB_generate_RRCConnectionRelease(module_id_t module_idP,frame_t frameP, ue_id_t ue_idP); + \param ctxt_pP Running context + \param ue_context_pP UE context of UE receiving the message*/ +void +rrc_eNB_generate_RRCConnectionRelease( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +); + +void +rrc_eNB_generate_defaultRRCConnectionReconfiguration( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + const uint8_t ho_state +); #if defined(ENABLE_ITTI) /**\brief RRC eNB task. @@ -203,68 +283,205 @@ void *rrc_ue_task(void *args_p); \param module_idP Instance ID for eNB/CH \param frame Frame index \param ue_module_idP Index of UE transmitting the messages*/ -void rrc_eNB_generate_RRCConnectionReconfiguration_handover(module_id_t module_idP, frame_t frameP, module_id_t ue_module_idP, uint8_t *nas_pdu, uint32_t nas_length); +void +rrc_eNB_generate_RRCConnectionReconfiguration_handover( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + uint8_t* const nas_pdu, + const uint32_t nas_length +); //L2_interface.c -int8_t mac_rrc_lite_data_req( module_id_t module_idP, frame_t frameP, rb_id_t Srb_id, uint8_t Nb_tb, uint8_t *buffer_pP,eNB_flag_t eNB_flagP, uint8_t eNB_index, uint8_t mbsfn_sync_area); - -int8_t mac_rrc_lite_data_ind( module_id_t module_idP, frame_t frameP, rb_id_t Srb_id, uint8_t *Sdu, sdu_size_t Sdu_len,eNB_flag_t eNB_flagP,uint8_t eNB_index, uint8_t mbsfn_sync_area); +int8_t +mac_rrc_lite_data_req( + const module_id_t Mod_idP, + const frame_t frameP, + const rb_id_t Srb_id, + const uint8_t Nb_tb, + uint8_t* const buffer_pP, + const eNB_flag_t enb_flagP, + const uint8_t eNB_index, + const uint8_t mbsfn_sync_area +); + +int8_t +mac_rrc_lite_data_ind( + const module_id_t module_idP, + const frame_t frameP, + const rnti_t rntiP, + const rb_id_t srb_idP, + const uint8_t* sduP, + const sdu_size_t sdu_lenP, + const eNB_flag_t eNB_flagP, + const mac_enb_index_t eNB_indexP, + const uint8_t mbsfn_sync_areaP +); void mac_sync_ind( module_id_t Mod_instP, uint8_t status); -uint8_t rrc_lite_data_req(module_id_t enb_mod_idP, - module_id_t ue_mod_idP, - frame_t frameP, - eNB_flag_t eNB_flagP, - rb_id_t rb_idP, - mui_t muiP, - confirm_t confirmP, - sdu_size_t sdu_sizeP, - uint8_t *Buffer_pP, - pdcp_transmission_mode_t modeP); - -void rrc_lite_data_ind(module_id_t eNB_id, module_id_t UE_id, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t Rb_id, sdu_size_t sdu_size,uint8_t *buffer_pP); +uint8_t +rrc_lite_data_req( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t rb_idP, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_size, + uint8_t* const buffer_pP, + const pdcp_transmission_mode_t modeP +); + +void +rrc_lite_data_ind( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t Srb_id, + const sdu_size_t sdu_sizeP, + const uint8_t* const buffer_pP +); void rrc_lite_in_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t eNB_index); void rrc_lite_out_of_sync_ind(module_id_t module_idP, frame_t frameP, unsigned short eNB_index); -int decode_MCCH_Message(module_id_t module_idP, frame_t frameP, uint8_t eNB_index, uint8_t *Sdu, uint8_t Sdu_len,uint8_t mbsfn_sync_area); +int +decode_MCCH_Message( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t* const Sdu, + const uint8_t Sdu_len, + const uint8_t mbsfn_sync_area +); void decode_MBSFNAreaConfiguration(module_id_t module_idP, uint8_t eNB_index, frame_t frameP,uint8_t mbsfn_sync_area); -int decode_BCCH_DLSCH_Message(module_id_t module_idP,frame_t frameP,uint8_t eNB_index,uint8_t *Sdu,uint8_t Sdu_len, uint8_t rsrq, uint8_t rsrp); - -int decode_SIB1(module_id_t module_idP,uint8_t eNB_index, uint8_t rsrq, uint8_t rsrp); - -int decode_SI(module_id_t module_idP,frame_t frameP,uint8_t eNB_index,uint8_t si_window); - -void ue_meas_filtering(module_id_t module_idP,frame_t frameP,uint8_t eNB_index); - -void ue_measurement_report_triggering(module_id_t module_idP, frame_t frameP,uint8_t eNB_index); - -int mac_get_rrc_lite_status(module_id_t module_idP,eNB_flag_t eNB_flagP,uint8_t index); - -void rrc_eNB_generate_UECapabilityEnquiry(module_id_t module_idP, frame_t frameP, module_id_t ue_module_idP); - -void rrc_eNB_generate_SecurityModeCommand(module_id_t module_idP, frame_t frameP, module_id_t ue_module_idP); - -void rrc_eNB_process_MeasurementReport(uint8_t module_idP,frame_t frameP, module_id_t ue_module_idP,MeasResults_t *measResults2) ; +int +decode_BCCH_DLSCH_Message( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + uint8_t* const Sdu, + const uint8_t Sdu_len, + const uint8_t rsrq, + const uint8_t rsrp +); + +int +decode_SIB1( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t rsrq, + const uint8_t rsrp +); + +int +decode_SI( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t si_window +); + +void +ue_meas_filtering( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index +); + +void +ue_measurement_report_triggering( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index +); + +int +mac_eNB_get_rrc_lite_status( + const module_id_t Mod_idP, + const rnti_t rntiP +); + +int +mac_UE_get_rrc_lite_status( + const module_id_t Mod_idP, + const uint8_t indexP +); + +void +rrc_eNB_generate_UECapabilityEnquiry( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +); + +void +rrc_eNB_generate_SecurityModeCommand( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +); + +void +rrc_eNB_process_MeasurementReport( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + const MeasResults_t* const measResults2 +); + +void +rrc_ue_generate_MeasurementReport( + const protocol_ctxt_t* const ctxt_pP, + uint8_t eNB_index +); + +void +rrc_eNB_generate_HandoverPreparationInformation( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + PhysCellId_t targetPhyId +); + +void +check_handovers( + protocol_ctxt_t* const ctxt_pP +); + +uint8_t check_trigger_meas_event( + uint8_t module_idP, + frame_t frameP, + uint8_t eNB_index, + uint8_t ue_cnx_index, + uint8_t meas_index, + Q_OffsetRange_t ofn, Q_OffsetRange_t ocn, Hysteresis_t hys, + Q_OffsetRange_t ofs, Q_OffsetRange_t ocs, long a3_offset, TimeToTrigger_t ttt); -void rrc_ue_generate_MeasurementReport(module_id_t eNB_id, module_id_t UE_id, frame_t frameP); +//void rrc_ue_process_ueCapabilityEnquiry(uint8_t module_idP,uint32_t frame,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index); +/*void +rrc_ue_process_securityModeCommand( + const protocol_ctxt_t* const ctxt_pP, + SecurityModeCommand_t *const securityModeCommand, + const uint8_t eNB_index + ); +*/ -void rrc_eNB_generate_HandoverPreparationInformation (uint8_t module_idP, frame_t frameP, module_id_t ue_module_idP, PhysCellId_t targetPhyId) ; +#if !defined(ENABLE_USE_MME) +void rrc_eNB_emulation_notify_ue_module_id( + const module_id_t ue_module_idP, + const rnti_t rntiP, + const uint8_t cell_identity_byte0P, + const uint8_t cell_identity_byte1P, + const uint8_t cell_identity_byte2P, + const uint8_t cell_identity_byte3P); +#endif -void check_handovers(uint8_t module_idP, frame_t frameP); -uint8_t check_trigger_meas_event(uint8_t module_idP,frame_t frameP, uint8_t eNB_index, uint8_t ue_cnx_index, uint8_t meas_index, - Q_OffsetRange_t ofn, Q_OffsetRange_t ocn, Hysteresis_t hys, - Q_OffsetRange_t ofs, Q_OffsetRange_t ocs, long a3_offset, TimeToTrigger_t ttt); +void +rrc_eNB_free_mem_UE_context( + const protocol_ctxt_t* const ctxt_pP, + struct rrc_eNB_ue_context_s* const ue_context_pP +); -//void rrc_ue_process_ueCapabilityEnquiry(uint8_t module_idP,uint32_t frame,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index); -//void rrc_ue_process_securityModeCommand(uint8_t module_idP,uint32_t frame,SecurityModeCommand_t *securityModeCommand,uint8_t eNB_index); -void rrc_eNB_free_UE_index (module_id_t enb_mod_idP, module_id_t ue_mod_idP,int frameP); +void +rrc_eNB_free_UE( + const module_id_t enb_mod_idP, + const rnti_t rntiP, + const frame_t frameP, + const sub_frame_t subframeP +); long binary_search_int(int elements[], long numElem, int value); diff --git a/openair2/RRC/LITE/rrc_2_rrm_msg.c b/openair2/RRC/LITE/rrc_2_rrm_msg.c index 5978d2e36b8..64318c8063e 100644 --- a/openair2/RRC/LITE/rrc_2_rrm_msg.c +++ b/openair2/RRC/LITE/rrc_2_rrm_msg.c @@ -277,10 +277,11 @@ msg_t * msg_rrc_cx_establish_ind( P_cx_est_ind.DTCH_id = DTCH_id ; P_cx_est_ind.L3_info_t = L3_info_t ; - if ( L3_info_t == IPv4_ADDR ) + if ( L3_info_t == IPv4_ADDR ) { memcpy( P_cx_est_ind.L3_info, L3_info, 4 ); - else if ( L3_info_t == IPv6_ADDR ) + } else if ( L3_info_t == IPv6_ADDR ) { memcpy( P_cx_est_ind.L3_info, L3_info, 16 ); + } mesg.data = (char *) &P_cx_est_ind ; return &mesg ; diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index 0a8eea8e8c0..502fad3e1a7 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -104,6 +104,12 @@ extern void *bigphys_malloc(int); extern inline unsigned int taus(void); extern int8_t dB_fixed2(uint32_t x,uint32_t y); +void +rrc_ue_process_securityModeCommand( + const protocol_ctxt_t* const ctxt_pP, + SecurityModeCommand_t* const securityModeCommand, + const uint8_t eNB_index +); /*------------------------------------------------------------------------------*/ static Rrc_State_t rrc_get_state (module_id_t ue_mod_idP) { @@ -131,7 +137,7 @@ static int rrc_set_state (module_id_t ue_mod_idP, Rrc_State_t state) RRC_STATE_IND(msg_p).state = UE_rrc_inst[ue_mod_idP].RrcState; RRC_STATE_IND(msg_p).sub_state = UE_rrc_inst[ue_mod_idP].RrcSubState; - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + ue_mod_idP, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, UE_MODULE_ID_TO_INSTANCE(ue_mod_idP), msg_p); } #endif return (1); @@ -140,7 +146,13 @@ static int rrc_set_state (module_id_t ue_mod_idP, Rrc_State_t state) return (0); } -static int rrc_set_sub_state (module_id_t ue_mod_idP, Rrc_Sub_State_t subState) +//----------------------------------------------------------------------------- +static int +rrc_set_sub_state ( + module_id_t ue_mod_idP, + Rrc_Sub_State_t subState +) +//----------------------------------------------------------------------------- { #if (defined(ENABLE_ITTI) && (defined(ENABLE_USE_MME) || defined(ENABLE_RAL))) @@ -174,7 +186,7 @@ static int rrc_set_sub_state (module_id_t ue_mod_idP, Rrc_Sub_State_t subState) RRC_STATE_IND(msg_p).state = UE_rrc_inst[ue_mod_idP].RrcState; RRC_STATE_IND(msg_p).sub_state = UE_rrc_inst[ue_mod_idP].RrcSubState; - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + ue_mod_idP, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, UE_MODULE_ID_TO_INSTANCE(ue_mod_idP), msg_p); } #endif return (1); @@ -183,26 +195,30 @@ static int rrc_set_sub_state (module_id_t ue_mod_idP, Rrc_Sub_State_t subState) return (0); } -/*------------------------------------------------------------------------------*/ -void init_SI_UE(module_id_t ue_mod_idP,uint8_t eNB_index) +//----------------------------------------------------------------------------- +void +init_SI_UE( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index +) +//----------------------------------------------------------------------------- { int i; - UE_rrc_inst[ue_mod_idP].sizeof_SIB1[eNB_index] = 0; - UE_rrc_inst[ue_mod_idP].sizeof_SI[eNB_index] = 0; - - UE_rrc_inst[ue_mod_idP].SIB1[eNB_index] = (uint8_t *)malloc16(32); - UE_rrc_inst[ue_mod_idP].sib1[eNB_index] = (SystemInformationBlockType1_t *)malloc16(sizeof(SystemInformationBlockType1_t)); - UE_rrc_inst[ue_mod_idP].SI[eNB_index] = (uint8_t *)malloc16(64); + UE_rrc_inst[ctxt_pP->module_id].sizeof_SIB1[eNB_index] = 0; + UE_rrc_inst[ctxt_pP->module_id].sizeof_SI[eNB_index] = 0; + UE_rrc_inst[ctxt_pP->module_id].SIB1[eNB_index] = (uint8_t*)malloc16(32); + UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index] = (SystemInformationBlockType1_t*)malloc16(sizeof(SystemInformationBlockType1_t)); + UE_rrc_inst[ctxt_pP->module_id].SI[eNB_index] = (uint8_t*)malloc16(64); for (i=0; i<NB_CNX_UE; i++) { - UE_rrc_inst[ue_mod_idP].si[eNB_index][i] = (SystemInformation_t *)malloc16(sizeof(SystemInformation_t)); + UE_rrc_inst[ctxt_pP->module_id].si[eNB_index][i] = (SystemInformation_t*)malloc16(sizeof(SystemInformation_t)); } - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIB1Status = 0; - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIStatus = 0; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1Status = 0; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 0; } #ifdef Rel10 @@ -213,14 +229,17 @@ void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index) UE_rrc_inst[ue_mod_idP].MCCH_MESSAGE[eNB_index] = (uint8_t *)malloc16(32); UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index] = (MBSFNAreaConfiguration_r9_t *)malloc16(sizeof(MBSFNAreaConfiguration_r9_t)); - for (i=0; i<8; i++) // MAX MBSFN Area + for (i=0; i<8; i++) { // MAX MBSFN Area UE_rrc_inst[ue_mod_idP].Info[eNB_index].MCCHStatus[i] = 0; + } } #endif static -void openair_rrc_lite_ue_init_security(module_id_t ue_mod_idP) +void openair_rrc_lite_ue_init_security( + const protocol_ctxt_t* const ctxt_pP +) { #if defined(ENABLE_SECURITY) // uint8_t *kRRCenc; @@ -228,61 +247,69 @@ void openair_rrc_lite_ue_init_security(module_id_t ue_mod_idP) char ascii_buffer[65]; uint8_t i; - memset(UE_rrc_inst[ue_mod_idP].kenb, ue_mod_idP, 32); + memset(UE_rrc_inst[ctxt_pP->module_id].kenb, ctxt_pP->module_id, 32); for (i = 0; i < 32; i++) { - sprintf(&ascii_buffer[2 * i], "%02X", UE_rrc_inst[ue_mod_idP].kenb[i]); + sprintf(&ascii_buffer[2 * i], "%02X", UE_rrc_inst[ctxt_pP->module_id].kenb[i]); } - LOG_T(RRC, "[OSA][UE %02d] kenb = %s\n", ue_mod_idP, ascii_buffer); + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT"[OSA] kenb = %s\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + ascii_buffer); #endif } -/*------------------------------------------------------------------------------*/ -char openair_rrc_lite_ue_init(module_id_t ue_mod_idP, unsigned char eNB_index) +//----------------------------------------------------------------------------- +char +openair_rrc_lite_ue_init( + const module_id_t ue_mod_idP, + const unsigned char eNB_index +) +//----------------------------------------------------------------------------- { - /*-----------------------------------------------------------------------------*/ + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_idP, ENB_FLAG_NO, NOT_A_RNTI, 0, 0); + LOG_I(RRC, + PROTOCOL_RRC_CTXT_FMT" Init...\n", + PROTOCOL_RRC_CTXT_ARGS(&ctxt)); rrc_set_state (ue_mod_idP, RRC_STATE_INACTIVE); rrc_set_sub_state (ue_mod_idP, RRC_SUB_STATE_INACTIVE); - LOG_D(RRC,"[UE %d] INIT State = RRC_IDLE (eNB %d)\n",ue_mod_idP,eNB_index); - LOG_D(RRC,"[MSC_NEW][FRAME 00000][RRC_UE][MOD %02d][]\n", ue_mod_idP+NB_eNB_INST); - LOG_D(RRC, "[MSC_NEW][FRAME 00000][IP][MOD %02d][]\n", ue_mod_idP+NB_eNB_INST); - - UE_rrc_inst[ue_mod_idP].Info[eNB_index].State=RRC_IDLE; - UE_rrc_inst[ue_mod_idP].Info[eNB_index].T300_active = 0; - UE_rrc_inst[ue_mod_idP].Info[eNB_index].T304_active = 0; - UE_rrc_inst[ue_mod_idP].Info[eNB_index].T310_active = 0; - UE_rrc_inst[ue_mod_idP].Info[eNB_index].UE_index=0xffff; - UE_rrc_inst[ue_mod_idP].Srb0[eNB_index].Active=0; - UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Active=0; - UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Active=0; - UE_rrc_inst[ue_mod_idP].HandoverInfoUe.measFlag=1; - - UE_rrc_inst[ue_mod_idP].ciphering_algorithm = SecurityAlgorithmConfig__cipheringAlgorithm_eea0; + LOG_D(RRC,"[UE %d] INIT State = RRC_IDLE (eNB %d)\n",ctxt.module_id,eNB_index); + UE_rrc_inst[ctxt.module_id].Info[eNB_index].State=RRC_IDLE; + UE_rrc_inst[ctxt.module_id].Info[eNB_index].T300_active = 0; + UE_rrc_inst[ctxt.module_id].Info[eNB_index].T304_active = 0; + UE_rrc_inst[ctxt.module_id].Info[eNB_index].T310_active = 0; + UE_rrc_inst[ctxt.module_id].Info[eNB_index].UE_index=0xffff; + UE_rrc_inst[ctxt.module_id].Srb0[eNB_index].Active=0; + UE_rrc_inst[ctxt.module_id].Srb1[eNB_index].Active=0; + UE_rrc_inst[ctxt.module_id].Srb2[eNB_index].Active=0; + UE_rrc_inst[ctxt.module_id].HandoverInfoUe.measFlag=1; + UE_rrc_inst[ctxt.module_id].ciphering_algorithm = SecurityAlgorithmConfig__cipheringAlgorithm_eea0; #ifdef Rel10 - UE_rrc_inst[ue_mod_idP].integrity_algorithm = SecurityAlgorithmConfig__integrityProtAlgorithm_eia0_v920; + UE_rrc_inst[ctxt.module_id].integrity_algorithm = SecurityAlgorithmConfig__integrityProtAlgorithm_eia0_v920; #else - UE_rrc_inst[ue_mod_idP].integrity_algorithm = SecurityAlgorithmConfig__integrityProtAlgorithm_reserved; + UE_rrc_inst[ctxt.module_id].integrity_algorithm = SecurityAlgorithmConfig__integrityProtAlgorithm_reserved; #endif - openair_rrc_lite_ue_init_security(ue_mod_idP); - - init_SI_UE(ue_mod_idP,eNB_index); - LOG_D(RRC,"[UE %d] INIT: phy_sync_2_ch_ind\n", ue_mod_idP); + openair_rrc_lite_ue_init_security(&ctxt); + init_SI_UE(&ctxt,eNB_index); + LOG_D(RRC,PROTOCOL_RRC_CTXT_FMT" INIT: phy_sync_2_ch_ind\n", + PROTOCOL_RRC_CTXT_ARGS(&ctxt)); #ifndef NO_RRM - send_msg(&S_rrc,msg_rrc_phy_synch_to_CH_ind(ue_mod_idP,eNB_index,UE_rrc_inst[ue_mod_idP].Mac_id)); + send_msg(&S_rrc,msg_rrc_phy_synch_to_CH_ind(ctxt.module_id,eNB_index,UE_rrc_inst[ctxt.module_id].Mac_id)); #endif #ifdef NO_RRM //init ch SRB0, SRB1 & BDTCH - openair_rrc_on(ue_mod_idP,0); + openair_rrc_on(&ctxt); #endif #ifdef CBA int j; - for(j=0; j<NUM_MAX_CBA_GROUP; j++) + for(j=0; j<NUM_MAX_CBA_GROUP; j++) { UE_rrc_inst[ue_mod_idP].cba_rnti[j] = 0x0000; + } UE_rrc_inst[ue_mod_idP].num_active_cba_groups = 0; #endif @@ -290,14 +317,18 @@ char openair_rrc_lite_ue_init(module_id_t ue_mod_idP, unsigned char eNB_index) return 0; } -/*------------------------------------------------------------------------------*/ -void rrc_ue_generate_RRCConnectionRequest(module_id_t ue_mod_idP, frame_t frameP, uint8_t eNB_index) +//----------------------------------------------------------------------------- +void +rrc_ue_generate_RRCConnectionRequest( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index +) +//----------------------------------------------------------------------------- { - /*------------------------------------------------------------------------------*/ uint8_t i=0,rv[6]; - if(UE_rrc_inst[ue_mod_idP].Srb0[eNB_index].Tx_buffer.payload_size ==0) { + if(UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size ==0) { // Get RRCConnectionRequest, fill random for now // Generate random byte stream for contention resolution @@ -312,21 +343,22 @@ void rrc_ue_generate_RRCConnectionRequest(module_id_t ue_mod_idP, frame_t frameP } LOG_T(RRC,"\n"); - UE_rrc_inst[ue_mod_idP].Srb0[eNB_index].Tx_buffer.payload_size = do_RRCConnectionRequest(ue_mod_idP, (uint8_t *)UE_rrc_inst[ue_mod_idP].Srb0[eNB_index].Tx_buffer.Payload,rv); + UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size = + do_RRCConnectionRequest( + ctxt_pP->module_id, + (uint8_t*)UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload, + rv); LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCConnectionRequest (bytes %d, eNB %d)\n", - ue_mod_idP, frameP, UE_rrc_inst[ue_mod_idP].Srb0[eNB_index].Tx_buffer.payload_size, eNB_index); + ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size, eNB_index); - for (i=0; i<UE_rrc_inst[ue_mod_idP].Srb0[eNB_index].Tx_buffer.payload_size; i++) { - LOG_T(RRC,"%x.",UE_rrc_inst[ue_mod_idP].Srb0[eNB_index].Tx_buffer.Payload[i]); + for (i=0; i<UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size; i++) { + LOG_T(RRC,"%x.",UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload[i]); } LOG_T(RRC,"\n"); - /* - UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.Payload[i] = taus()&0xff; - - UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.payload_size =i; - */ + /*UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.Payload[i] = taus()&0xff; + UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.payload_size =i; */ } } @@ -335,7 +367,7 @@ void rrc_ue_generate_RRCConnectionRequest(module_id_t ue_mod_idP, frame_t frameP mui_t rrc_mui=0; /* NAS Attach request with IMSI */ -static const char nas_attach_req_imsi[] = { +static const char const nas_attach_req_imsi[] = { 0x07, 0x41, /* EPS Mobile identity = IMSI */ 0x71, 0x08, 0x29, 0x80, 0x43, 0x21, 0x43, 0x65, 0x87, @@ -349,7 +381,7 @@ static const char nas_attach_req_imsi[] = { }; /* NAS Attach request with GUTI */ -static const char nas_attach_req_guti[] = { +static const char const nas_attach_req_guti[] = { 0x07, 0x41, /* EPS Mobile identity = GUTI */ 0x71, 0x0B, 0xF6, 0x12, 0xF2, 0x01, 0x80, 0x00, 0x01, 0xE0, 0x00, @@ -362,10 +394,15 @@ static const char nas_attach_req_guti[] = { 0x01, 0x27, 0x11, }; -/*------------------------------------------------------------------------------*/ -void rrc_ue_generate_RRCConnectionSetupComplete(module_id_t ue_mod_idP, frame_t frameP, uint8_t eNB_index, uint8_t Transaction_id) +//----------------------------------------------------------------------------- +void +rrc_ue_generate_RRCConnectionSetupComplete( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t Transaction_id +) +//----------------------------------------------------------------------------- { - /*------------------------------------------------------------------------------*/ uint8_t buffer[100]; uint8_t size; @@ -373,55 +410,79 @@ void rrc_ue_generate_RRCConnectionSetupComplete(module_id_t ue_mod_idP, frame_t int nas_msg_length; #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - nas_msg = (char *) UE_rrc_inst[ue_mod_idP].initialNasMsg.data; - nas_msg_length = UE_rrc_inst[ue_mod_idP].initialNasMsg.length; + nas_msg = (char*) UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; + nas_msg_length = UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; #else nas_msg = nas_attach_req_imsi; nas_msg_length = sizeof(nas_attach_req_imsi); #endif - size = do_RRCConnectionSetupComplete(ue_mod_idP, buffer, Transaction_id, nas_msg_length, nas_msg); + size = do_RRCConnectionSetupComplete(ctxt_pP->module_id, buffer, Transaction_id, nas_msg_length, nas_msg); LOG_I(RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCConnectionSetupComplete (bytes%d, eNB %d)\n", - ue_mod_idP,frameP, size, eNB_index); - - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionSetupComplete to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frameP, ue_mod_idP+NB_eNB_INST, size, eNB_index, rrc_mui, ue_mod_idP+NB_eNB_INST, DCCH); - - // rrc_rlc_data_req(ue_mod_idP+NB_eNB_INST,frameP, 0 ,DCCH,rrc_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req (eNB_index, ue_mod_idP, frameP, 0, DCCH, rrc_mui++, 0, size, buffer, 1); + ctxt_pP->module_id,ctxt_pP->frame, size, eNB_index); + LOG_D(RLC, + "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionSetupComplete to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", + ctxt_pP->frame, ctxt_pP->module_id+NB_eNB_INST, size, eNB_index, rrc_mui, ctxt_pP->module_id+NB_eNB_INST, DCCH); + pdcp_rrc_data_req ( + ctxt_pP, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } -void rrc_ue_generate_RRCConnectionReconfigurationComplete(module_id_t ue_mod_idP, frame_t frameP, uint8_t eNB_index, uint8_t Transaction_id) +//----------------------------------------------------------------------------- +void +rrc_ue_generate_RRCConnectionReconfigurationComplete( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t Transaction_id +) +//----------------------------------------------------------------------------- { uint8_t buffer[32], size; - - size = do_RRCConnectionReconfigurationComplete(ue_mod_idP, buffer, Transaction_id); - - LOG_I(RRC,"[UE %d] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCConnectionReconfigurationComplete (bytes %d, eNB_index %d)\n", - ue_mod_idP,frameP, size, eNB_index); - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionReconfigurationComplete to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frameP, ue_mod_idP+NB_eNB_INST, size, eNB_index, rrc_mui, ue_mod_idP+NB_eNB_INST, DCCH); - - //rrc_rlc_data_req(ue_mod_idP+NB_eNB_INST,frameP, 0 ,DCCH,rrc_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req (eNB_index, ue_mod_idP, frameP, 0, DCCH, rrc_mui++, 0, size, buffer, 1); + size = do_RRCConnectionReconfigurationComplete(ctxt_pP, buffer, Transaction_id); + LOG_I(RRC,PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel UL-DCCH (SRB1), Generating RRCConnectionReconfigurationComplete (bytes %d, eNB_index %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, eNB_index); + LOG_D(RLC, + "[MSC_MSG][FRAME %05d][RRC_UE][INST %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionReconfigurationComplete to eNB %d MUI %d) --->][PDCP][INST %02d][RB %02d]\n", + ctxt_pP->frame, + UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), + size, + eNB_index, + rrc_mui, + UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), + DCCH); + pdcp_rrc_data_req ( + ctxt_pP, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } -/*------------------------------------------------------------------------------*/ -int rrc_ue_decode_ccch(module_id_t ue_mod_idP, frame_t frameP, SRB_INFO *Srb_info, uint8_t eNB_index) -{ - /*------------------------------------------------------------------------------*/ - //DL_CCCH_Message_t dlccchmsg; - DL_CCCH_Message_t *dl_ccch_msg=NULL;//&dlccchmsg; +//----------------------------------------------------------------------------- +// Called by L2 interface (MAC) +int +rrc_ue_decode_ccch( + const protocol_ctxt_t* const ctxt_pP, + const SRB_INFO* const Srb_info, + const uint8_t eNB_index +) +//----------------------------------------------------------------------------- +{ + DL_CCCH_Message_t* dl_ccch_msg=NULL; asn_dec_rval_t dec_rval; int rval=0; vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_IN); - - //memset(dl_ccch_msg,0,sizeof(DL_CCCH_Message_t)); - // LOG_D(RRC,"[UE %d] Decoding DL-CCCH message (%d bytes), State %d\n",ue_mod_idP,Srb_info->Rx_buffer.payload_size, // UE_rrc_inst[ue_mod_idP].Info[eNB_index].State); @@ -443,7 +504,7 @@ int rrc_ue_decode_ccch(module_id_t ue_mod_idP, frame_t frameP, SRB_INFO *Srb_inf msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_DL_CCCH_MESSAGE); memcpy (&msg_p->ittiMsg, (void *) dl_ccch_msg, sizeof(RrcDlCcchMessage)); - itti_send_msg_to_task (TASK_UNKNOWN, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task (TASK_UNKNOWN, ctxt_pP->instance, msg_p); } # else { @@ -457,78 +518,85 @@ int rrc_ue_decode_ccch(module_id_t ue_mod_idP, frame_t frameP, SRB_INFO *Srb_inf msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { - LOG_E(RRC,"[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%d bytes)\n",ue_mod_idP,dec_rval.consumed); + LOG_E(RRC,"[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%d bytes)\n",ctxt_pP->module_id,dec_rval.consumed); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_OUT); return -1; } if (dl_ccch_msg->message.present == DL_CCCH_MessageType_PR_c1) { - if (UE_rrc_inst[ue_mod_idP].Info[eNB_index].State == RRC_SI_RECEIVED) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_SI_RECEIVED) { switch (dl_ccch_msg->message.choice.c1.present) { case DL_CCCH_MessageType__c1_PR_NOTHING: - LOG_I(RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n", ue_mod_idP, frameP); + LOG_I(RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n", + ctxt_pP->module_id, + ctxt_pP->frame); rval = 0; break; case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment: - LOG_D(RRC, - "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionReestablishment ENB %d) --->][RRC_UE][MOD %02d][]\n", frameP, ue_mod_idP+NB_eNB_INST, eNB_index, ue_mod_idP+NB_eNB_INST); - LOG_I(RRC, - "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishment\n", ue_mod_idP, frameP); + "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishment\n", + ctxt_pP->module_id, + ctxt_pP->frame); rval = 0; break; case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject: - LOG_D(RRC, - "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (RRCConnectionReestablishmentReject ENB %d) --->][RRC_UE][MOD %02d][]\n", frameP, ue_mod_idP+NB_eNB_INST, eNB_index, - ue_mod_idP+NB_eNB_INST); LOG_I(RRC, - "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishmentReject\n", ue_mod_idP, frameP); + "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishmentReject\n", + ctxt_pP->module_id, + ctxt_pP->frame); rval = 0; break; case DL_CCCH_MessageType__c1_PR_rrcConnectionReject: - LOG_D(RRC, - "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionReject ENB %d) --->][RRC_UE][MOD %02d][]\n", frameP, ue_mod_idP+NB_eNB_INST, eNB_index, ue_mod_idP+NB_eNB_INST); - LOG_I(RRC, - "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n", ue_mod_idP, frameP); + "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n", + ctxt_pP->module_id, + ctxt_pP->frame); rval = 0; break; case DL_CCCH_MessageType__c1_PR_rrcConnectionSetup: - LOG_D(RRC, - "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionSetup ENB %d) --->][RRC_UE][MOD %02d][]\n", frameP, ue_mod_idP+NB_eNB_INST, eNB_index, ue_mod_idP+NB_eNB_INST); - LOG_I(RRC, - "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup \n", ue_mod_idP, frameP); + "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup RNTI %x\n", + ctxt_pP->module_id, + ctxt_pP->frame, + ctxt_pP->rnti); // Get configuration // Release T300 timer - UE_rrc_inst[ue_mod_idP].Info[eNB_index].T300_active = 0; - rrc_ue_process_radioResourceConfigDedicated(ue_mod_idP, frameP, eNB_index, + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T300_active = 0; + rrc_ue_process_radioResourceConfigDedicated( + ctxt_pP, + eNB_index, &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated); - rrc_set_state (ue_mod_idP, RRC_STATE_CONNECTED); - rrc_set_sub_state (ue_mod_idP, RRC_SUB_STATE_CONNECTED); - rrc_ue_generate_RRCConnectionSetupComplete(ue_mod_idP, frameP, eNB_index, dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.rrc_TransactionIdentifier); + rrc_set_state (ctxt_pP->module_id, RRC_STATE_CONNECTED); + rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_CONNECTED); + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].rnti = ctxt_pP->rnti; + rrc_ue_generate_RRCConnectionSetupComplete( + ctxt_pP, + eNB_index, + dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.rrc_TransactionIdentifier); rval = 0; break; default: - LOG_E(RRC, "[UE%d] Frame %d : Unknown message\n", ue_mod_idP, frameP); + LOG_E(RRC, "[UE%d] Frame %d : Unknown message\n", + ctxt_pP->module_id, + ctxt_pP->frame); rval = -1; break; } @@ -539,7 +607,15 @@ int rrc_ue_decode_ccch(module_id_t ue_mod_idP, frame_t frameP, SRB_INFO *Srb_inf return rval; } -int32_t rrc_ue_establish_srb1(module_id_t ue_mod_idP, frame_t frameP,uint8_t eNB_index, struct SRB_ToAddMod *SRB_config) +//----------------------------------------------------------------------------- +int32_t +rrc_ue_establish_srb1( + module_id_t ue_mod_idP, + frame_t frameP, + uint8_t eNB_index, + struct SRB_ToAddMod* SRB_config +) +//----------------------------------------------------------------------------- { // add descriptor from RRC PDU @@ -565,7 +641,15 @@ int32_t rrc_ue_establish_srb1(module_id_t ue_mod_idP, frame_t frameP,uint8_t eNB return(0); } -int32_t rrc_ue_establish_srb2(module_id_t ue_mod_idP, frame_t frameP,uint8_t eNB_index, struct SRB_ToAddMod *SRB_config) +//----------------------------------------------------------------------------- +int32_t +rrc_ue_establish_srb2( + module_id_t ue_mod_idP, + frame_t frameP, + uint8_t eNB_index, + struct SRB_ToAddMod* SRB_config +) +//----------------------------------------------------------------------------- { // add descriptor from RRC PDU @@ -591,10 +675,18 @@ int32_t rrc_ue_establish_srb2(module_id_t ue_mod_idP, frame_t frameP,uint8_t eNB return(0); } -int32_t rrc_ue_establish_drb(module_id_t ue_mod_idP, frame_t frameP,uint8_t eNB_index, - struct DRB_ToAddMod *DRB_config) // add descriptor from RRC PDU +//----------------------------------------------------------------------------- +int32_t +rrc_ue_establish_drb( + module_id_t ue_mod_idP, + frame_t frameP, + uint8_t eNB_index, + struct DRB_ToAddMod* DRB_config +) +//----------------------------------------------------------------------------- { -#ifdef NAS_NETLINK + // add descriptor from RRC PDU +#ifdef PDCP_USE_NETLINK int oip_ifup=0,ip_addr_offset3=0,ip_addr_offset4=0; #endif @@ -608,7 +700,8 @@ int32_t rrc_ue_establish_drb(module_id_t ue_mod_idP, frame_t frameP,uint8_t eNB_ (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity, RADIO_ACCESS_BEARER,Rlc_info_um); */ -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK +# if !defined(OAI_NW_DRIVER_TYPE_ETHERNET) && !defined(EXMIMO) && !defined(LINK_ENB_PDCP_TO_GTPV1U) # ifdef OAI_EMU ip_addr_offset3 = oai_emulation.info.nb_enb_local; ip_addr_offset4 = NB_eNB_INST; @@ -616,7 +709,6 @@ int32_t rrc_ue_establish_drb(module_id_t ue_mod_idP, frame_t frameP,uint8_t eNB_ ip_addr_offset3 = 0; ip_addr_offset4 = 8; # endif -# if !defined(OAI_NW_DRIVER_TYPE_ETHERNET) && !defined(EXMIMO) LOG_I(OIP,"[UE %d] trying to bring up the OAI interface oai%d, IP 10.0.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1); oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP, // interface_id @@ -653,7 +745,14 @@ int32_t rrc_ue_establish_drb(module_id_t ue_mod_idP, frame_t frameP,uint8_t eNB_ } -void rrc_ue_process_measConfig(module_id_t ue_mod_idP, frame_t frameP, uint8_t eNB_index,MeasConfig_t *measConfig) +//----------------------------------------------------------------------------- +void +rrc_ue_process_measConfig( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + MeasConfig_t* const measConfig +) +//----------------------------------------------------------------------------- { // This is the procedure described in 36.331 Section 5.5.2.1 @@ -664,7 +763,7 @@ void rrc_ue_process_measConfig(module_id_t ue_mod_idP, frame_t frameP, uint8_t if (measConfig->measObjectToRemoveList != NULL) { for (i=0; i<measConfig->measObjectToRemoveList->list.count; i++) { ind = *measConfig->measObjectToRemoveList->list.array[i]; - free(UE_rrc_inst[ue_mod_idP].MeasObj[eNB_index][ind-1]); + free(UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1]); } } @@ -675,9 +774,9 @@ void rrc_ue_process_measConfig(module_id_t ue_mod_idP, frame_t frameP, uint8_t measObj = measConfig->measObjectToAddModList->list.array[i]; ind = measConfig->measObjectToAddModList->list.array[i]->measObjectId; - if (UE_rrc_inst[ue_mod_idP].MeasObj[eNB_index][ind-1]) { + if (UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1]) { LOG_D(RRC,"Modifying measurement object %d\n",ind); - memcpy((char*)UE_rrc_inst[ue_mod_idP].MeasObj[eNB_index][ind-1], + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1], (char*)measObj, sizeof(MeasObjectToAddMod_t)); } else { @@ -689,19 +788,19 @@ void rrc_ue_process_measConfig(module_id_t ue_mod_idP, frame_t frameP, uint8_t measObj->measObject.choice.measObjectEUTRA.allowedMeasBandwidth, measObj->measObject.choice.measObjectEUTRA.presenceAntennaPort1, measObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf[0]); - UE_rrc_inst[ue_mod_idP].MeasObj[eNB_index][ind-1]=measObj; + UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1]=measObj; } } } - rrc_mac_config_req(ue_mod_idP,ENB_FLAG_NO,0,eNB_index, + rrc_mac_config_req(ctxt_pP->module_id,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif - UE_rrc_inst[ue_mod_idP].MeasObj[eNB_index], + UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index], (MAC_MainConfig_t *)NULL, 0, (struct LogicalChannelConfig *)NULL, @@ -731,7 +830,7 @@ void rrc_ue_process_measConfig(module_id_t ue_mod_idP, frame_t frameP, uint8_t if (measConfig->reportConfigToRemoveList != NULL) { for (i=0; i<measConfig->reportConfigToRemoveList->list.count; i++) { ind = *measConfig->reportConfigToRemoveList->list.array[i]; - free(UE_rrc_inst[ue_mod_idP].ReportConfig[eNB_index][ind-1]); + free(UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1]); } } @@ -741,34 +840,34 @@ void rrc_ue_process_measConfig(module_id_t ue_mod_idP, frame_t frameP, uint8_t for (i=0; i<measConfig->reportConfigToAddModList->list.count; i++) { ind = measConfig->reportConfigToAddModList->list.array[i]->reportConfigId; - if (UE_rrc_inst[ue_mod_idP].ReportConfig[eNB_index][ind-1]) { + if (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1]) { LOG_I(RRC,"Modifying Report Configuration %d\n",ind-1); - memcpy((char*)UE_rrc_inst[ue_mod_idP].ReportConfig[eNB_index][ind-1], + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1], (char*)measConfig->reportConfigToAddModList->list.array[i], sizeof(ReportConfigToAddMod_t)); } else { LOG_D(RRC,"Adding Report Configuration %d %p \n",ind-1,measConfig->reportConfigToAddModList->list.array[i]); - UE_rrc_inst[ue_mod_idP].ReportConfig[eNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i]; + UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i]; } } } if (measConfig->quantityConfig != NULL) { - if (UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index]) { + if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]) { LOG_D(RRC,"Modifying Quantity Configuration \n"); - memcpy((char*)UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index], + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index], (char*)measConfig->quantityConfig, sizeof(QuantityConfig_t)); } else { LOG_D(RRC,"Adding Quantity configuration\n"); - UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index] = measConfig->quantityConfig; + UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index] = measConfig->quantityConfig; } } if (measConfig->measIdToRemoveList != NULL) { for (i=0; i<measConfig->measIdToRemoveList->list.count; i++) { ind = *measConfig->measIdToRemoveList->list.array[i]; - free(UE_rrc_inst[ue_mod_idP].MeasId[eNB_index][ind-1]); + free(UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1]); } } @@ -776,74 +875,83 @@ void rrc_ue_process_measConfig(module_id_t ue_mod_idP, frame_t frameP, uint8_t for (i=0; i<measConfig->measIdToAddModList->list.count; i++) { ind = measConfig->measIdToAddModList->list.array[i]->measId; - if (UE_rrc_inst[ue_mod_idP].MeasId[eNB_index][ind-1]) { + if (UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1]) { LOG_D(RRC,"Modifying Measurement ID %d\n",ind-1); - memcpy((char*)UE_rrc_inst[ue_mod_idP].MeasId[eNB_index][ind-1], + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1], (char*)measConfig->measIdToAddModList->list.array[i], sizeof(MeasIdToAddMod_t)); } else { LOG_D(RRC,"Adding Measurement ID %d %p\n",ind-1,measConfig->measIdToAddModList->list.array[i]); - UE_rrc_inst[ue_mod_idP].MeasId[eNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i]; + UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i]; } } } if (measConfig->measGapConfig !=NULL) { - if (UE_rrc_inst[ue_mod_idP].measGapConfig[eNB_index]) { - memcpy((char*)UE_rrc_inst[ue_mod_idP].measGapConfig[eNB_index], + if (UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index]) { + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index], (char*)measConfig->measGapConfig, sizeof(MeasGapConfig_t)); } else { - UE_rrc_inst[ue_mod_idP].measGapConfig[eNB_index] = measConfig->measGapConfig; + UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index] = measConfig->measGapConfig; } } if (measConfig->quantityConfig != NULL) { - if (UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index]) { + if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]) { LOG_I(RRC,"Modifying Quantity Configuration \n"); - memcpy((char*)UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index], + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index], (char*)measConfig->quantityConfig, sizeof(QuantityConfig_t)); } else { LOG_I(RRC,"Adding Quantity configuration\n"); - UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index] = measConfig->quantityConfig; + UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index] = measConfig->quantityConfig; } - UE_rrc_inst[ue_mod_idP].filter_coeff_rsrp = 1./pow(2,(*UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP)/4); - UE_rrc_inst[ue_mod_idP].filter_coeff_rsrq = 1./pow(2,(*UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ)/4); + UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrp = 1./pow(2, + (*UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP)/4); + UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrq = 1./pow(2, + (*UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ)/4); LOG_I(RRC,"[UE %d] set rsrp-coeff for eNB %d: %d rsrq-coeff: %d rsrp_factor: %f rsrq_factor: %f \n", - ue_mod_idP, eNB_index, // UE_rrc_inst[ue_mod_idP].Info[eNB_index].UE_index, - *UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP, - *UE_rrc_inst[ue_mod_idP].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ, - UE_rrc_inst[ue_mod_idP].filter_coeff_rsrp, UE_rrc_inst[ue_mod_idP].filter_coeff_rsrp, - UE_rrc_inst[ue_mod_idP].filter_coeff_rsrp, UE_rrc_inst[ue_mod_idP].filter_coeff_rsrq); + ctxt_pP->module_id, eNB_index, // UE_rrc_inst[ue_mod_idP].Info[eNB_index].UE_index, + *UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP, + *UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ, + UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrp, + UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrp, + UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrp, + UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrq); } if (measConfig->s_Measure != NULL) { - UE_rrc_inst[ue_mod_idP].s_measure = *measConfig->s_Measure; + UE_rrc_inst[ctxt_pP->module_id].s_measure = *measConfig->s_Measure; } if (measConfig->speedStatePars != NULL) { - if (UE_rrc_inst[ue_mod_idP].speedStatePars) - memcpy((char*)UE_rrc_inst[ue_mod_idP].speedStatePars,(char*)measConfig->speedStatePars,sizeof(struct MeasConfig__speedStatePars)); - else - UE_rrc_inst[ue_mod_idP].speedStatePars = measConfig->speedStatePars; + if (UE_rrc_inst[ctxt_pP->module_id].speedStatePars) { + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].speedStatePars,(char*)measConfig->speedStatePars,sizeof(struct MeasConfig__speedStatePars)); + } else { + UE_rrc_inst[ctxt_pP->module_id].speedStatePars = measConfig->speedStatePars; + } LOG_I(RRC,"[UE %d] Configuring mobility optimization params for UE %d \n", - ue_mod_idP,UE_rrc_inst[ue_mod_idP].Info[0].UE_index); + ctxt_pP->module_id,UE_rrc_inst[ctxt_pP->module_id].Info[0].UE_index); } } +//----------------------------------------------------------------------------- void -rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t frameP, uint8_t eNB_index, - RadioResourceConfigDedicated_t *radioResourceConfigDedicated) +rrc_ue_process_radioResourceConfigDedicated( + const protocol_ctxt_t* const ctxt_pP, + uint8_t eNB_index, + RadioResourceConfigDedicated_t* radioResourceConfigDedicated +) +//----------------------------------------------------------------------------- { long SRB_id,DRB_id; int i,cnt; LogicalChannelConfig_t *SRB1_logicalChannelConfig,*SRB2_logicalChannelConfig; - protocol_ctxt_t ctxt; #ifdef CBA uint8_t cba_found = 0; uint16_t cba_RNTI; @@ -851,33 +959,34 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram // Save physicalConfigDedicated if present if (radioResourceConfigDedicated->physicalConfigDedicated) { - if (UE_rrc_inst[ue_mod_idP].physicalConfigDedicated[eNB_index]) { - memcpy((char*)UE_rrc_inst[ue_mod_idP].physicalConfigDedicated[eNB_index],(char*)radioResourceConfigDedicated->physicalConfigDedicated, + if (UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]) { + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],(char*)radioResourceConfigDedicated->physicalConfigDedicated, sizeof(struct PhysicalConfigDedicated)); } else { - UE_rrc_inst[ue_mod_idP].physicalConfigDedicated[eNB_index] = radioResourceConfigDedicated->physicalConfigDedicated; + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index] = radioResourceConfigDedicated->physicalConfigDedicated; } } // Apply macMainConfig if present if (radioResourceConfigDedicated->mac_MainConfig) { if (radioResourceConfigDedicated->mac_MainConfig->present == RadioResourceConfigDedicated__mac_MainConfig_PR_explicitValue) { - if (UE_rrc_inst[ue_mod_idP].mac_MainConfig[eNB_index]) { - memcpy((char*)UE_rrc_inst[ue_mod_idP].mac_MainConfig[eNB_index],(char*)&radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue, + if (UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index]) { + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],(char*)&radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue, sizeof(MAC_MainConfig_t)); - } else - UE_rrc_inst[ue_mod_idP].mac_MainConfig[eNB_index] = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue; + } else { + UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index] = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue; + } } } // Apply spsConfig if present if (radioResourceConfigDedicated->sps_Config) { - if (UE_rrc_inst[ue_mod_idP].sps_Config[eNB_index]) { - memcpy(UE_rrc_inst[ue_mod_idP].sps_Config[eNB_index],radioResourceConfigDedicated->sps_Config, + if (UE_rrc_inst[ctxt_pP->module_id].sps_Config[eNB_index]) { + memcpy(UE_rrc_inst[ctxt_pP->module_id].sps_Config[eNB_index],radioResourceConfigDedicated->sps_Config, sizeof(struct SPS_Config)); } else { - UE_rrc_inst[ue_mod_idP].sps_Config[eNB_index] = radioResourceConfigDedicated->sps_Config; + UE_rrc_inst[ctxt_pP->module_id].sps_Config[eNB_index] = radioResourceConfigDedicated->sps_Config; } } @@ -888,18 +997,19 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram (radioResourceConfigDedicated->cba_RNTI_vlola->buf[0]&0xff)); for (i=0 ; i< NUM_MAX_CBA_GROUP; i++) { - if (UE_rrc_inst[ue_mod_idP].cba_rnti[i] == cba_RNTI ) { + if (UE_rrc_inst[ctxt_pP->module_id].cba_rnti[i] == cba_RNTI ) { cba_found=1; break; - } else if (UE_rrc_inst[ue_mod_idP].cba_rnti[i] == 0 ) + } else if (UE_rrc_inst[ctxt_pP->module_id].cba_rnti[i] == 0 ) { break; + } } if (cba_found==0) { - UE_rrc_inst[ue_mod_idP].num_active_cba_groups++; - UE_rrc_inst[ue_mod_idP].cba_rnti[i]=cba_RNTI; + UE_rrc_inst[ctxt_pP->module_id].num_active_cba_groups++; + UE_rrc_inst[ctxt_pP->module_id].cba_rnti[i]=cba_RNTI; LOG_D(RRC, "[UE %d] Frame %d: radioResourceConfigDedicated reveived CBA_RNTI = %x for group %d from eNB %d \n", - ue_mod_idP,frameP, UE_rrc_inst[ue_mod_idP].cba_rnti[i], i, eNB_index); + ctxt_pP->module_id,frameP, UE_rrc_inst[ctxt_pP->module_id].cba_rnti[i], i, eNB_index); } } @@ -912,23 +1022,18 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram uint8_t *kRRCint = NULL; #if defined(ENABLE_SECURITY) - derive_key_rrc_enc(UE_rrc_inst[ue_mod_idP].ciphering_algorithm, - UE_rrc_inst[ue_mod_idP].kenb, &kRRCenc); - derive_key_rrc_int(UE_rrc_inst[ue_mod_idP].integrity_algorithm, - UE_rrc_inst[ue_mod_idP].kenb, &kRRCint); + derive_key_rrc_enc(UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm, + UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCenc); + derive_key_rrc_int(UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm, + UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCint); #endif - - ctxt.enb_module_id = eNB_index; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_NO; // Refresh SRBs - rrc_pdcp_config_asn1_req(&ctxt, + rrc_pdcp_config_asn1_req(ctxt_pP, radioResourceConfigDedicated->srb_ToAddModList, (DRB_ToAddModList_t*)NULL, (DRB_ToReleaseList_t*)NULL, - UE_rrc_inst[ue_mod_idP].ciphering_algorithm | - (UE_rrc_inst[ue_mod_idP].integrity_algorithm << 4), + UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm | + (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4), kRRCenc, kRRCint, NULL @@ -938,7 +1043,7 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram ); // Refresh SRBs - rrc_rlc_config_asn1_req(&ctxt, + rrc_rlc_config_asn1_req(ctxt_pP, radioResourceConfigDedicated->srb_ToAddModList, (DRB_ToAddModList_t*)NULL, (DRB_ToReleaseList_t*)NULL @@ -949,26 +1054,26 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram #ifdef ENABLE_RAL // first msg that includes srb config - UE_rrc_inst[ue_mod_idP].num_srb=radioResourceConfigDedicated->srb_ToAddModList->list.count; + UE_rrc_inst[ctxt_pP->module_id].num_srb=radioResourceConfigDedicated->srb_ToAddModList->list.count; #endif for (cnt=0; cnt<radioResourceConfigDedicated->srb_ToAddModList->list.count; cnt++) { // connection_reestablishment_ind.num_srb+=1; SRB_id = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]->srb_Identity; - LOG_D(RRC,"[UE %d]: Frame %d SRB config cnt %d (SRB%ld)\n",ue_mod_idP,frameP,cnt,SRB_id); + LOG_D(RRC,"[UE %d]: Frame %d SRB config cnt %d (SRB%ld)\n",ctxt_pP->module_id,ctxt_pP->frame,cnt,SRB_id); if (SRB_id == 1) { - if (UE_rrc_inst[ue_mod_idP].SRB1_config[eNB_index]) { - memcpy(UE_rrc_inst[ue_mod_idP].SRB1_config[eNB_index],radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt], + if (UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]) { + memcpy(UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index],radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt], sizeof(struct SRB_ToAddMod)); } else { - UE_rrc_inst[ue_mod_idP].SRB1_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; + UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; + rrc_ue_establish_srb1(ctxt_pP->module_id,ctxt_pP->frame,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); - rrc_ue_establish_srb1(ue_mod_idP,frameP,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); + if (UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig) { + if (UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { + SRB1_logicalChannelConfig = &UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig->choice.explicitValue; - if (UE_rrc_inst[ue_mod_idP].SRB1_config[eNB_index]->logicalChannelConfig) { - if (UE_rrc_inst[ue_mod_idP].SRB1_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { - SRB1_logicalChannelConfig = &UE_rrc_inst[ue_mod_idP].SRB1_config[eNB_index]->logicalChannelConfig->choice.explicitValue; } else { SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; } @@ -977,16 +1082,16 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram } LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 eNB %d) --->][MAC_UE][MOD %02d][]\n", - frameP, ue_mod_idP, eNB_index, ue_mod_idP); - rrc_mac_config_req(ue_mod_idP,ENB_FLAG_NO,0,eNB_index, + ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); + rrc_mac_config_req(ctxt_pP->module_id,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, - UE_rrc_inst[ue_mod_idP].physicalConfigDedicated[eNB_index], + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index], #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif (MeasObjectToAddMod_t **)NULL, - UE_rrc_inst[ue_mod_idP].mac_MainConfig[eNB_index], + UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index], 1, SRB1_logicalChannelConfig, (MeasGapConfig_t *)NULL, @@ -1012,19 +1117,17 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram ); } } else { - if (UE_rrc_inst[ue_mod_idP].SRB2_config[eNB_index]) { - memcpy(UE_rrc_inst[ue_mod_idP].SRB2_config[eNB_index],radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt], + if (UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index]) { + memcpy(UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index],radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt], sizeof(struct SRB_ToAddMod)); } else { + UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; + rrc_ue_establish_srb2(ctxt_pP->module_id,ctxt_pP->frame,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); - UE_rrc_inst[ue_mod_idP].SRB2_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; - - rrc_ue_establish_srb2(ue_mod_idP,frameP,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); - - if (UE_rrc_inst[ue_mod_idP].SRB2_config[eNB_index]->logicalChannelConfig) { - if (UE_rrc_inst[ue_mod_idP].SRB2_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { + if (UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index]->logicalChannelConfig) { + if (UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { LOG_I(RRC,"Applying Explicit SRB2 logicalChannelConfig\n"); - SRB2_logicalChannelConfig = &UE_rrc_inst[ue_mod_idP].SRB2_config[eNB_index]->logicalChannelConfig->choice.explicitValue; + SRB2_logicalChannelConfig = &UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index]->logicalChannelConfig->choice.explicitValue; } else { LOG_I(RRC,"Applying default SRB2 logicalChannelConfig\n"); SRB2_logicalChannelConfig = &SRB2_logicalChannelConfig_defaultValue; @@ -1034,19 +1137,22 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram } LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", - frameP, ue_mod_idP, eNB_index, ue_mod_idP); - rrc_mac_config_req(ue_mod_idP,ENB_FLAG_NO,0,eNB_index, + ctxt_pP->frame, + ctxt_pP->module_id, + eNB_index, + ctxt_pP->module_id); + rrc_mac_config_req(ctxt_pP->module_id,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, - UE_rrc_inst[ue_mod_idP].physicalConfigDedicated[eNB_index], + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index], #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif (MeasObjectToAddMod_t **)NULL, - UE_rrc_inst[ue_mod_idP].mac_MainConfig[eNB_index], + UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index], 2, SRB2_logicalChannelConfig, - UE_rrc_inst[ue_mod_idP].measGapConfig[eNB_index], + UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index], (TDD_Config_t *)NULL, (MobilityControlInfo_t *)NULL, NULL, @@ -1077,21 +1183,17 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram uint8_t *kUPenc = NULL; #if defined(ENABLE_SECURITY) - derive_key_up_enc(UE_rrc_inst[ue_mod_idP].integrity_algorithm, - UE_rrc_inst[ue_mod_idP].kenb, &kUPenc); + derive_key_up_enc(UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm, + UE_rrc_inst[ctxt_pP->module_id].kenb, &kUPenc); #endif - ctxt.enb_module_id = eNB_index; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_NO; // Refresh DRBs - rrc_pdcp_config_asn1_req(&ctxt, + rrc_pdcp_config_asn1_req(ctxt_pP, (SRB_ToAddModList_t*)NULL, radioResourceConfigDedicated->drb_ToAddModList, (DRB_ToReleaseList_t*)NULL, - UE_rrc_inst[ue_mod_idP].ciphering_algorithm | - (UE_rrc_inst[ue_mod_idP].integrity_algorithm << 4), + UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm | + (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4), NULL, NULL, kUPenc @@ -1101,7 +1203,7 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram ); // Refresh DRBs - rrc_rlc_config_asn1_req(&ctxt, + rrc_rlc_config_asn1_req(ctxt_pP, (SRB_ToAddModList_t*)NULL, radioResourceConfigDedicated->drb_ToAddModList, (DRB_ToReleaseList_t*)NULL @@ -1113,28 +1215,31 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram for (i=0; i<radioResourceConfigDedicated->drb_ToAddModList->list.count; i++) { DRB_id = radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity-1; - if (UE_rrc_inst[ue_mod_idP].DRB_config[eNB_index][DRB_id]) { - memcpy(UE_rrc_inst[ue_mod_idP].DRB_config[eNB_index][DRB_id],radioResourceConfigDedicated->drb_ToAddModList->list.array[i], + if (UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]) { + memcpy(UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id], + radioResourceConfigDedicated->drb_ToAddModList->list.array[i], sizeof(struct DRB_ToAddMod)); } else { - UE_rrc_inst[ue_mod_idP].DRB_config[eNB_index][DRB_id] = radioResourceConfigDedicated->drb_ToAddModList->list.array[i]; - - rrc_ue_establish_drb(ue_mod_idP,frameP,eNB_index,radioResourceConfigDedicated->drb_ToAddModList->list.array[i]); + UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id] = radioResourceConfigDedicated->drb_ToAddModList->list.array[i]; + rrc_ue_establish_drb(ctxt_pP->module_id,ctxt_pP->frame,eNB_index,radioResourceConfigDedicated->drb_ToAddModList->list.array[i]); // MAC/PHY Configuration LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (DRB %d eNB %d) --->][MAC_UE][MOD %02d][]\n", - frameP, ue_mod_idP, radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity, eNB_index, ue_mod_idP); - rrc_mac_config_req(ue_mod_idP,ENB_FLAG_NO,0,eNB_index, + ctxt_pP->frame, ctxt_pP->module_id, + radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity, + eNB_index, + ctxt_pP->module_id); + rrc_mac_config_req(ctxt_pP->module_id,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, - UE_rrc_inst[ue_mod_idP].physicalConfigDedicated[eNB_index], + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index], #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif (MeasObjectToAddMod_t **)NULL, - UE_rrc_inst[ue_mod_idP].mac_MainConfig[eNB_index], - *UE_rrc_inst[ue_mod_idP].DRB_config[eNB_index][DRB_id]->logicalChannelIdentity, - UE_rrc_inst[ue_mod_idP].DRB_config[eNB_index][DRB_id]->logicalChannelConfig, - UE_rrc_inst[ue_mod_idP].measGapConfig[eNB_index], + UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index], + *UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelIdentity, + UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelConfig, + UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index], (TDD_Config_t*)NULL, (MobilityControlInfo_t *)NULL, NULL, @@ -1160,13 +1265,28 @@ rrc_ue_process_radioResourceConfigDedicated(module_id_t ue_mod_idP, frame_t fram } } - UE_rrc_inst[ue_mod_idP].Info[eNB_index].State = RRC_CONNECTED; - LOG_I(RRC,"[UE %d] State = RRC_CONNECTED (eNB %d)\n",ue_mod_idP,eNB_index); - - + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_CONNECTED; + LOG_I(RRC,"[UE %d] State = RRC_CONNECTED (eNB %d)\n",ctxt_pP->module_id,eNB_index); +#if !defined(ENABLE_USE_MME) + rrc_eNB_emulation_notify_ue_module_id( + ctxt_pP->module_id, + ctxt_pP->rnti, + UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[0], + UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[1], + UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[2], + UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[3]); +#endif } -void rrc_ue_process_securityModeCommand(uint8_t ue_mod_idP, frame_t frameP,SecurityModeCommand_t *securityModeCommand,uint8_t eNB_index) + +//----------------------------------------------------------------------------- +void +rrc_ue_process_securityModeCommand( + const protocol_ctxt_t* const ctxt_pP, + SecurityModeCommand_t* const securityModeCommand, + const uint8_t eNB_index +) +//----------------------------------------------------------------------------- { asn_enc_rval_t enc_rval; @@ -1177,72 +1297,77 @@ void rrc_ue_process_securityModeCommand(uint8_t ue_mod_idP, frame_t frameP,Secur int i, securityMode; LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (eNB %d)\n", - ue_mod_idP,frameP,eNB_index); + ctxt_pP->module_id,ctxt_pP->frame,eNB_index); switch (securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm) { case SecurityAlgorithmConfig__cipheringAlgorithm_eea0: - LOG_I(RRC,"[UE %d] Security algorithm is set to eea0\n",ue_mod_idP); + LOG_I(RRC,"[UE %d] Security algorithm is set to eea0\n", + ctxt_pP->module_id); securityMode= SecurityAlgorithmConfig__cipheringAlgorithm_eea0; break; case SecurityAlgorithmConfig__cipheringAlgorithm_eea1: - LOG_I(RRC,"[UE %d] Security algorithm is set to eea1\n",ue_mod_idP); + LOG_I(RRC,"[UE %d] Security algorithm is set to eea1\n",ctxt_pP->module_id); securityMode= SecurityAlgorithmConfig__cipheringAlgorithm_eea1; break; case SecurityAlgorithmConfig__cipheringAlgorithm_eea2: - LOG_I(RRC,"[UE %d] Security algorithm is set to eea2\n",ue_mod_idP); + LOG_I(RRC,"[UE %d] Security algorithm is set to eea2\n", + ctxt_pP->module_id); securityMode = SecurityAlgorithmConfig__cipheringAlgorithm_eea2; break; default: - LOG_I(RRC,"[UE %d] Security algorithm is set to none\n",ue_mod_idP); + LOG_I(RRC,"[UE %d] Security algorithm is set to none\n",ctxt_pP->module_id); securityMode = SecurityAlgorithmConfig__cipheringAlgorithm_spare1; break; } switch (securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm) { case SecurityAlgorithmConfig__integrityProtAlgorithm_eia1: - LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to eia1\n",ue_mod_idP); + LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to eia1\n",ctxt_pP->module_id); securityMode |= 1 << 5; break; case SecurityAlgorithmConfig__integrityProtAlgorithm_eia2: - LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to eia2\n",ue_mod_idP); + LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to eia2\n",ctxt_pP->module_id); securityMode |= 1 << 6; break; default: - LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to none\n",ue_mod_idP); + LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to none\n",ctxt_pP->module_id); securityMode |= 0x70 ; break; } - LOG_D(RRC,"[UE %d] security mode is %x \n",ue_mod_idP, securityMode); + LOG_D(RRC,"[UE %d] security mode is %x \n",ctxt_pP->module_id, securityMode); /* Store the parameters received */ - UE_rrc_inst[ue_mod_idP].ciphering_algorithm = securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm; - UE_rrc_inst[ue_mod_idP].integrity_algorithm = securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm; + UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm = + securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm; + UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm = + securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm; memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); //memset((void *)&SecurityModeCommand,0,sizeof(SecurityModeCommand_t)); ul_dcch_msg.message.present = UL_DCCH_MessageType_PR_c1; - if (securityMode >= NO_SECURITY_MODE) + if (securityMode >= NO_SECURITY_MODE) { ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_securityModeComplete; - else + } else { ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_securityModeFailure; + } if (securityModeCommand->criticalExtensions.present == SecurityModeCommand__criticalExtensions_PR_c1) { if (securityModeCommand->criticalExtensions.choice.c1.present == SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8) { ul_dcch_msg.message.choice.c1.choice.securityModeComplete.rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier; - ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1; // FIXME wrong enum types + ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1; ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.choice.securityModeComplete_r8.nonCriticalExtension =NULL; LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d)\n", - ue_mod_idP,frameP,eNB_index); + ctxt_pP->module_id,ctxt_pP->frame,eNB_index); enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg, @@ -1268,7 +1393,7 @@ void rrc_ue_process_securityModeCommand(uint8_t ue_mod_idP, frame_t frameP,Secur msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + ue_mod_idP, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif @@ -1278,16 +1403,31 @@ void rrc_ue_process_securityModeCommand(uint8_t ue_mod_idP, frame_t frameP,Secur LOG_D(RRC, "securityModeComplete Encoded %d bits (%d bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); #endif - for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) + for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) { LOG_T(RRC, "%02x.", buffer[i]); + } LOG_T(RRC, "\n"); - pdcp_rrc_data_req (eNB_index, ue_mod_idP, frameP, 0, DCCH, rrc_mui++, 0, (enc_rval.encoded + 7) / 8, buffer, 1); + pdcp_rrc_data_req ( + ctxt_pP, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + (enc_rval.encoded + 7) / 8, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + } } } -} -void rrc_ue_process_ueCapabilityEnquiry(uint8_t ue_mod_idP, frame_t frameP,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index) +//----------------------------------------------------------------------------- +void +rrc_ue_process_ueCapabilityEnquiry( + const protocol_ctxt_t* const ctxt_pP, + UECapabilityEnquiry_t* UECapabilityEnquiry, + uint8_t eNB_index +) +//----------------------------------------------------------------------------- { asn_enc_rval_t enc_rval; @@ -1301,7 +1441,9 @@ void rrc_ue_process_ueCapabilityEnquiry(uint8_t ue_mod_idP, frame_t frameP,UECap int i; LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing UECapabilityEnquiry (eNB %d)\n", - ue_mod_idP,frameP,eNB_index); + ctxt_pP->module_id, + ctxt_pP->frame, + eNB_index); memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); @@ -1313,8 +1455,8 @@ void rrc_ue_process_ueCapabilityEnquiry(uint8_t ue_mod_idP, frame_t frameP,UECap ue_CapabilityRAT_Container.rat_Type = RAT_Type_eutra; OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ueCapabilityRAT_Container, - (const char*)UE_rrc_inst[ue_mod_idP].UECapability, - UE_rrc_inst[ue_mod_idP].UECapability_size); + (const char*)UE_rrc_inst[ctxt_pP->module_id].UECapability, + UE_rrc_inst[ctxt_pP->module_id].UECapability_size); // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.buf = UE_rrc_inst[ue_mod_idP].UECapability; // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.size = UE_rrc_inst[ue_mod_idP].UECapability_size; @@ -1322,8 +1464,10 @@ void rrc_ue_process_ueCapabilityEnquiry(uint8_t ue_mod_idP, frame_t frameP,UECap if (UECapabilityEnquiry->criticalExtensions.present == UECapabilityEnquiry__criticalExtensions_PR_c1) { if (UECapabilityEnquiry->criticalExtensions.choice.c1.present == UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8) { ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.present = UECapabilityInformation__criticalExtensions_PR_c1; - ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.present = UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8; - ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count=0; + ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.present = + UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8; + ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count + =0; for (i=0; i<UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count; i++) { @@ -1354,7 +1498,7 @@ void rrc_ue_process_ueCapabilityEnquiry(uint8_t ue_mod_idP, frame_t frameP,UECap msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + ue_mod_idP, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif @@ -1364,11 +1508,19 @@ void rrc_ue_process_ueCapabilityEnquiry(uint8_t ue_mod_idP, frame_t frameP,UECap LOG_D(RRC,"UECapabilityInformation Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); #endif - for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) + for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) { LOG_T(RRC, "%02x.", buffer[i]); + } LOG_T(RRC, "\n"); - pdcp_rrc_data_req (eNB_index, ue_mod_idP, frameP, 0, DCCH, rrc_mui++, 0, (enc_rval.encoded + 7) / 8, buffer, 1); + pdcp_rrc_data_req ( + ctxt_pP, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + (enc_rval.encoded + 7) / 8, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } } } @@ -1376,33 +1528,43 @@ void rrc_ue_process_ueCapabilityEnquiry(uint8_t ue_mod_idP, frame_t frameP,UECap } -void rrc_ue_process_rrcConnectionReconfiguration(module_id_t ue_mod_idP, frame_t frameP, +//----------------------------------------------------------------------------- +void +rrc_ue_process_rrcConnectionReconfiguration( + const protocol_ctxt_t* const ctxt_pP, RRCConnectionReconfiguration_t *rrcConnectionReconfiguration, - uint8_t eNB_index) + uint8_t eNB_index +) +//----------------------------------------------------------------------------- { LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing RRCConnectionReconfiguration (eNB %d)\n", - ue_mod_idP,frameP,eNB_index); + ctxt_pP->module_id,ctxt_pP->frame,eNB_index); if (rrcConnectionReconfiguration->criticalExtensions.present == RRCConnectionReconfiguration__criticalExtensions_PR_c1) { if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present == RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) { - RRCConnectionReconfiguration_r8_IEs_t *rrcConnectionReconfiguration_r8 = &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8; + RRCConnectionReconfiguration_r8_IEs_t* rrcConnectionReconfiguration_r8 = + &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8; if (rrcConnectionReconfiguration_r8->mobilityControlInfo) { LOG_I(RRC,"Mobility Control Information is present\n"); - rrc_ue_process_mobilityControlInfo(ue_mod_idP, eNB_index, frameP, rrcConnectionReconfiguration_r8->mobilityControlInfo); + rrc_ue_process_mobilityControlInfo( + ctxt_pP, + eNB_index, + rrcConnectionReconfiguration_r8->mobilityControlInfo); } if (rrcConnectionReconfiguration_r8->measConfig != NULL) { LOG_I(RRC,"Measurement Configuration is present\n"); - rrc_ue_process_measConfig(ue_mod_idP,frameP, eNB_index, + rrc_ue_process_measConfig(ctxt_pP, + eNB_index, rrcConnectionReconfiguration_r8->measConfig); } if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated) { LOG_I(RRC,"Radio Resource Configuration is present\n"); - rrc_ue_process_radioResourceConfigDedicated(ue_mod_idP,frameP,eNB_index, rrcConnectionReconfiguration_r8->radioResourceConfigDedicated); + rrc_ue_process_radioResourceConfigDedicated(ctxt_pP,eNB_index, rrcConnectionReconfiguration_r8->radioResourceConfigDedicated); } #if defined(ENABLE_ITTI) @@ -1423,7 +1585,7 @@ void rrc_ue_process_rrcConnectionReconfiguration(module_id_t ue_mod_idP, frame_t NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length = pdu_length; NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data = pdu_buffer; - itti_send_msg_to_task(TASK_NAS_UE, ue_mod_idP, msg_p); + itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); } free (rrcConnectionReconfiguration_r8->dedicatedInfoNASList); @@ -1438,13 +1600,15 @@ void rrc_ue_process_rrcConnectionReconfiguration(module_id_t ue_mod_idP, frame_t message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_REESTABLISHMENT_IND); memset(&connection_reestablishment_ind, 0, sizeof(rrc_ral_connection_reestablishment_ind_t)); // TO DO ral_si_ind.plmn_id = 0; - connection_reestablishment_ind.ue_id = ue_mod_idP; + connection_reestablishment_ind.ue_id = ctxt_pP->rnti; if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { connection_reestablishment_ind.num_drb = rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; - for (i=0; (i<rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count) && (i < maxDRB); i++) { + for (i=0; ( + i<rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count) + && (i < maxDRB); i++) { // why minus 1 in RRC code for drb_identity ? connection_reestablishment_ind.drb_id[i] = rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity; @@ -1455,19 +1619,21 @@ void rrc_ue_process_rrcConnectionReconfiguration(module_id_t ue_mod_idP, frame_t if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { connection_reestablishment_ind.num_srb = - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count + UE_rrc_inst[ue_mod_idP].num_srb; + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count + + UE_rrc_inst[ctxt_pP->module_id].num_srb; } else { - connection_reestablishment_ind.num_srb += UE_rrc_inst[ue_mod_idP].num_srb; + connection_reestablishment_ind.num_srb += UE_rrc_inst[ctxt_pP->module_id].num_srb; } - if (connection_reestablishment_ind.num_srb > 2) // fixme: only 2 srbs can exist, adjust the value + if (connection_reestablishment_ind.num_srb > 2) { // fixme: only 2 srbs can exist, adjust the value connection_reestablishment_ind.num_srb =2; + } memcpy (&message_ral_p->ittiMsg, (void *) &connection_reestablishment_ind, sizeof(rrc_ral_connection_reestablishment_ind_t)); //#warning "ue_mod_idP ? for instance ? => YES" LOG_I(RRC, "Sending RRC_RAL_CONNECTION_REESTABLISHMENT_IND to mRAL\n"); - itti_send_msg_to_task (TASK_RAL_UE, ue_mod_idP + NB_eNB_INST, message_ral_p); + itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p); } #endif #endif @@ -1476,21 +1642,27 @@ void rrc_ue_process_rrcConnectionReconfiguration(module_id_t ue_mod_idP, frame_t } /* 36.331, 5.3.5.4 Reception of an RRCConnectionReconfiguration including the mobilityControlInfo by the UE (handover) */ -void rrc_ue_process_mobilityControlInfo(uint8_t eNB_index, uint8_t UE_id, frame_t frameP, struct MobilityControlInfo *mobilityControlInfo) +//----------------------------------------------------------------------------- +void +rrc_ue_process_mobilityControlInfo( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + struct MobilityControlInfo* const mobilityControlInfo +) +//----------------------------------------------------------------------------- { - module_id_t ue_mod_idP = UE_id; - protocol_ctxt_t ctxt; /* DRB_ToReleaseList_t* drb2release_list; DRB_Identity_t *lcid; */ LOG_N(RRC,"Note: This function needs some updates\n"); - if(UE_rrc_inst[UE_id].Info[eNB_index].T310_active == 1) - UE_rrc_inst[UE_id].Info[eNB_index].T310_active = 0; + if(UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T310_active == 1) { + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T310_active = 0; + } - UE_rrc_inst[UE_id].Info[eNB_index].T304_active = 1; - UE_rrc_inst[UE_id].Info[eNB_index].T304_cnt = T304[mobilityControlInfo->t304]; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T304_active = 1; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].T304_cnt = T304[mobilityControlInfo->t304]; /* drb2release_list = CALLOC (1, sizeof (*drb2release_list)); @@ -1500,21 +1672,14 @@ void rrc_ue_process_mobilityControlInfo(uint8_t eNB_index, uint8_t UE_id, frame_ ASN_SEQUENCE_ADD (&(drb2release_list)->list,lcid); } */ - - ctxt.enb_module_id = eNB_index; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_NO; //Removing SRB1 and SRB2 and DRB0 - LOG_N(RRC,"[UE %d] : Update needed for rrc_pdcp_config_req (deprecated) and rrc_rlc_config_req commands(deprecated)\n", UE_id); - rrc_pdcp_config_req (&ctxt, SRB_FLAG_YES, CONFIG_ACTION_REMOVE, DCCH,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(&ctxt, SRB_FLAG_YES, MBMS_FLAG_NO, CONFIG_ACTION_REMOVE,ue_mod_idP+DCCH,Rlc_info_am_config); - - rrc_pdcp_config_req (&ctxt, SRB_FLAG_YES, CONFIG_ACTION_REMOVE, DCCH1,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(&ctxt, SRB_FLAG_YES,CONFIG_ACTION_REMOVE, MBMS_FLAG_NO,ue_mod_idP+DCCH1,Rlc_info_am_config); - - rrc_pdcp_config_req (&ctxt, SRB_FLAG_NO, CONFIG_ACTION_REMOVE, DTCH,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(&ctxt, SRB_FLAG_NO,CONFIG_ACTION_REMOVE, MBMS_FLAG_NO,ue_mod_idP+DTCH,Rlc_info_um); + LOG_N(RRC,"[UE %d] : Update needed for rrc_pdcp_config_req (deprecated) and rrc_rlc_config_req commands(deprecated)\n", ctxt_pP->module_id); + rrc_pdcp_config_req (ctxt_pP, SRB_FLAG_YES, CONFIG_ACTION_REMOVE, DCCH,UNDEF_SECURITY_MODE); + rrc_rlc_config_req(ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, CONFIG_ACTION_REMOVE,ctxt_pP->module_id+DCCH,Rlc_info_am_config); + rrc_pdcp_config_req (ctxt_pP, SRB_FLAG_YES, CONFIG_ACTION_REMOVE, DCCH1,UNDEF_SECURITY_MODE); + rrc_rlc_config_req(ctxt_pP, SRB_FLAG_YES,CONFIG_ACTION_REMOVE, MBMS_FLAG_NO,ctxt_pP->module_id+DCCH1,Rlc_info_am_config); + rrc_pdcp_config_req (ctxt_pP, SRB_FLAG_NO, CONFIG_ACTION_REMOVE, DTCH,UNDEF_SECURITY_MODE); + rrc_rlc_config_req(ctxt_pP, SRB_FLAG_NO,CONFIG_ACTION_REMOVE, MBMS_FLAG_NO,ctxt_pP->module_id+DTCH,Rlc_info_um); /* rrc_pdcp_config_asn1_req(NB_eNB_INST+ue_mod_idP,frameP, 0,eNB_index, NULL, // SRB_ToAddModList @@ -1558,11 +1723,15 @@ void rrc_ue_process_mobilityControlInfo(uint8_t eNB_index, uint8_t UE_id, frame_ UE_rrc_inst[ue_mod_idP].DRB_config[eNB_index][0] = NULL; */ //Synchronisation to DL of target cell - LOG_D(RRC,"HO: Reset PDCP and RLC for configured RBs.. \n[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", - frameP, ue_mod_idP, eNB_index, ue_mod_idP); + LOG_D(RRC, + "HO: Reset PDCP and RLC for configured RBs.. \n[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", + ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); // Reset MAC and configure PHY - rrc_mac_config_req(ue_mod_idP,ENB_FLAG_NO,0,eNB_index, + rrc_mac_config_req(ctxt_pP->module_id, + ENB_FLAG_NO, + 0, + eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, #ifdef Rel10 @@ -1603,19 +1772,30 @@ void rrc_ue_process_mobilityControlInfo(uint8_t eNB_index, uint8_t UE_id, frame_ // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DCCH,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DCCH1,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DTCH,RADIO_ACCESS_BEARER,Rlc_info_um); - - UE_rrc_inst[ue_mod_idP].Info[eNB_index].State = RRC_SI_RECEIVED; - + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_SI_RECEIVED; } -void rrc_detach_from_eNB(module_id_t ue_mod_idP,uint8_t eNB_index) + +//----------------------------------------------------------------------------- +void +rrc_detach_from_eNB( + module_id_t ue_mod_idP, + uint8_t eNB_index +) +//----------------------------------------------------------------------------- { //UE_rrc_inst[ue_mod_idP].DRB_config[eNB_index] } -/*------------------------------------------------------------------------------------------*/ -void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, uint8_t *Buffer,uint8_t eNB_index) +//----------------------------------------------------------------------------- +void +rrc_ue_decode_dcch( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t Srb_id, + const uint8_t* const Buffer, + const uint8_t eNB_indexP +) +//----------------------------------------------------------------------------- { - /*------------------------------------------------------------------------------------------*/ //DL_DCCH_Message_t dldcchmsg; DL_DCCH_Message_t *dl_dcch_msg=NULL;//&dldcchmsg; @@ -1628,7 +1808,7 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, if (Srb_id != 1) { LOG_E(RRC,"[UE %d] Frame %d: Received message on DL-DCCH (SRB%d), should not have ...\n", - ue_mod_idP, frameP, Srb_id); + ctxt_pP->module_id, ctxt_pP->frame, Srb_id); return; } @@ -1657,7 +1837,7 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_DL_DCCH_MESSAGE); memcpy (&msg_p->ittiMsg, (void *) dl_dcch_msg, sizeof(RrcDlDcchMessage)); - itti_send_msg_to_task (TASK_UNKNOWN, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task (TASK_UNKNOWN, ctxt_pP->instance, msg_p); } # else { @@ -1669,7 +1849,7 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif @@ -1677,12 +1857,13 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, if (dl_dcch_msg->message.present == DL_DCCH_MessageType_PR_c1) { - if (UE_rrc_inst[ue_mod_idP].Info[eNB_index].State >= RRC_CONNECTED) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State >= RRC_CONNECTED) { switch (dl_dcch_msg->message.choice.c1.present) { case DL_DCCH_MessageType__c1_PR_NOTHING: - LOG_I(RRC, "[UE %d] Frame %d : Received PR_NOTHING on DL-DCCH-Message\n", ue_mod_idP, frameP); + LOG_I(RRC, "[UE %d] Frame %d : Received PR_NOTHING on DL-DCCH-Message\n", + ctxt_pP->module_id, ctxt_pP->frame); return; case DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000: @@ -1708,11 +1889,11 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf; msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_DOWNLINK_DATA_IND); - NAS_DOWNLINK_DATA_IND(msg_p).UEid = ue_mod_idP; // TODO set the UEid to something else ? + NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ? NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = pdu_length; NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = pdu_buffer; - itti_send_msg_to_task(TASK_NAS_UE, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); } #endif @@ -1731,34 +1912,45 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo != NULL) { /* 36.331, 5.3.5.4 Reception of an RRCConnectionReconfiguration including the mobilityControlInfo by the UE (handover)*/ - if (UE_rrc_inst[ue_mod_idP].HandoverInfoUe.targetCellId + if (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId != dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId) { LOG_W(RRC, - "[UE %d] Frame %d: Handover target (%d) is different from RSRP measured target (%d)..\n", ue_mod_idP, frameP, + "[UE %d] Frame %d: Handover target (%d) is different from RSRP measured target (%d)..\n", + ctxt_pP->module_id, + ctxt_pP->frame, dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId, - UE_rrc_inst[ue_mod_idP].HandoverInfoUe.targetCellId); + UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId); return; - } else if ((target_eNB_index = get_adjacent_cell_mod_id(UE_rrc_inst[ue_mod_idP].HandoverInfoUe.targetCellId)) + } else if ((target_eNB_index = get_adjacent_cell_mod_id(UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId)) == 0xFF) { LOG_W(RRC, - "[UE %d] Frame %d: ue_mod_idP of the target eNB not found, check the network topology\n", ue_mod_idP, frameP); + "[UE %d] Frame %d: ue_mod_idP of the target eNB not found, check the network topology\n", + ctxt_pP->module_id, + ctxt_pP->frame); return; } else { LOG_I(RRC, - "[UE% d] Frame %d: Received rrcConnectionReconfiguration with mobilityControlInfo \n", ue_mod_idP, frameP); - UE_rrc_inst[ue_mod_idP].HandoverInfoUe.measFlag = 1; // Ready to send more MeasReports if required + "[UE% d] Frame %d: Received rrcConnectionReconfiguration with mobilityControlInfo \n", + ctxt_pP->module_id, + ctxt_pP->frame); + UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; // Ready to send more MeasReports if required } } - rrc_ue_process_rrcConnectionReconfiguration(ue_mod_idP, frameP, - &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration, eNB_index); + rrc_ue_process_rrcConnectionReconfiguration( + ctxt_pP, + &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration, + eNB_indexP); if (target_eNB_index != 0xFF) { - rrc_ue_generate_RRCConnectionReconfigurationComplete(ue_mod_idP, frameP, target_eNB_index, + rrc_ue_generate_RRCConnectionReconfigurationComplete( + ctxt_pP, + target_eNB_index, dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier); - UE_rrc_inst[ue_mod_idP].Info[eNB_index].State = RRC_HO_EXECUTION; - UE_rrc_inst[ue_mod_idP].Info[target_eNB_index].State = RRC_RECONFIGURED; - LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED during HO (eNB %d)\n", ue_mod_idP, target_eNB_index); + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State = RRC_HO_EXECUTION; + UE_rrc_inst[ctxt_pP->module_id].Info[target_eNB_index].State = RRC_RECONFIGURED; + LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED during HO (eNB %d)\n", + ctxt_pP->module_id, target_eNB_index); #if defined(ENABLE_ITTI) #ifdef ENABLE_RAL { @@ -1768,9 +1960,10 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND); memset(&connection_reconfiguration_ho_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t)); - connection_reconfiguration_ho_ind.ue_id = ue_mod_idP; + connection_reconfiguration_ho_ind.ue_id = ctxt_pP->module_id; - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList + != NULL) { connection_reconfiguration_ho_ind.num_drb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; @@ -1785,29 +1978,36 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, connection_reconfiguration_ho_ind.num_drb = 0; } - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList + != NULL) { connection_reconfiguration_ho_ind.num_srb = - dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count + - UE_rrc_inst[ue_mod_idP].num_srb; + dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count + + + UE_rrc_inst[ctxt_pP->module_id].num_srb; } else { - connection_reconfiguration_ho_ind.num_srb += UE_rrc_inst[ue_mod_idP].num_srb; + connection_reconfiguration_ho_ind.num_srb += UE_rrc_inst[ctxt_pP->module_id].num_srb; } - if (connection_reconfiguration_ho_ind.num_srb > 2 ) + if (connection_reconfiguration_ho_ind.num_srb > 2 ) { connection_reconfiguration_ho_ind.num_srb =2; + } memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ho_ind, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t)); //#warning "ue_mod_idP ? for instance ? => YES" LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND to mRAL\n"); - itti_send_msg_to_task (TASK_RAL_UE, ue_mod_idP + NB_eNB_INST, message_ral_p); + itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p); } #endif #endif } else { - rrc_ue_generate_RRCConnectionReconfigurationComplete(ue_mod_idP, frameP, eNB_index, + rrc_ue_generate_RRCConnectionReconfigurationComplete( + ctxt_pP, + eNB_indexP, dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier); - UE_rrc_inst[ue_mod_idP].Info[eNB_index].State = RRC_RECONFIGURED; - LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED (eNB %d)\n", ue_mod_idP, eNB_index); + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State = RRC_RECONFIGURED; + LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED (eNB %d)\n", + ctxt_pP->module_id, + eNB_indexP); #if defined(ENABLE_ITTI) #ifdef ENABLE_RAL { @@ -1817,9 +2017,10 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_IND); memset(&connection_reconfiguration_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ind_t)); - connection_reconfiguration_ind.ue_id = ue_mod_idP; + connection_reconfiguration_ind.ue_id = ctxt_pP->module_id; - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList + != NULL) { connection_reconfiguration_ind.num_drb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; @@ -1834,21 +2035,24 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, connection_reconfiguration_ind.num_drb = 0; } - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList + != NULL) { connection_reconfiguration_ind.num_srb = - dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count + - UE_rrc_inst[ue_mod_idP].num_srb; + dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count + + + UE_rrc_inst[ctxt_pP->module_id].num_srb; } else { - connection_reconfiguration_ind.num_srb +=UE_rrc_inst[ue_mod_idP].num_srb; + connection_reconfiguration_ind.num_srb +=UE_rrc_inst[ctxt_pP->module_id].num_srb; } - if (connection_reconfiguration_ind.num_srb > 2 ) + if (connection_reconfiguration_ind.num_srb > 2 ) { connection_reconfiguration_ind.num_srb =2; + } memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ind, sizeof(rrc_ral_connection_reconfiguration_ind_t)); //#warning "ue_mod_idP ? for instance ? => YES" LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_IND to mRAL\n"); - itti_send_msg_to_task (TASK_RAL_UE, ue_mod_idP + NB_eNB_INST, message_ral_p); + itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p); } #endif #endif @@ -1869,25 +2073,32 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause; } - itti_send_msg_to_task(TASK_NAS_UE, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); #if defined(ENABLE_RAL) msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_CONNECTION_RELEASE_IND); - RRC_RAL_CONNECTION_RELEASE_IND(msg_p).ue_id = ue_mod_idP; - itti_send_msg_to_task(TASK_RAL_UE, ue_mod_idP + NB_eNB_INST, msg_p); + RRC_RAL_CONNECTION_RELEASE_IND(msg_p).ue_id = ctxt_pP->module_id; + itti_send_msg_to_task(TASK_RAL_UE, ctxt_pP->instance, msg_p); #endif #endif break; case DL_DCCH_MessageType__c1_PR_securityModeCommand: - LOG_I(RRC, "[UE %d] Received securityModeCommand (eNB %d)\n", ue_mod_idP, eNB_index); - rrc_ue_process_securityModeCommand(ue_mod_idP, frameP, &dl_dcch_msg->message.choice.c1.choice.securityModeCommand, - eNB_index); + LOG_I(RRC, "[UE %d] Received securityModeCommand (eNB %d)\n", + ctxt_pP->module_id, eNB_indexP); + rrc_ue_process_securityModeCommand( + ctxt_pP, + &dl_dcch_msg->message.choice.c1.choice.securityModeCommand, + eNB_indexP); break; case DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: - LOG_I(RRC, "[UE %d] Received Capability Enquiry (eNB %d)\n", ue_mod_idP, eNB_index); - rrc_ue_process_ueCapabilityEnquiry(ue_mod_idP, frameP, &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, - eNB_index); + LOG_I(RRC, "[UE %d] Received Capability Enquiry (eNB %d)\n", + ctxt_pP->module_id, + eNB_indexP); + rrc_ue_process_ueCapabilityEnquiry( + ctxt_pP, + &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, + eNB_indexP); break; case DL_DCCH_MessageType__c1_PR_counterCheck: @@ -1918,7 +2129,7 @@ void rrc_ue_decode_dcch(module_id_t ue_mod_idP, frame_t frameP,uint8_t Srb_id, } #ifndef NO_RRM - send_msg(&S_rrc,msg_rrc_end_scan_req(ue_mod_idP,eNB_index)); + send_msg(&S_rrc,msg_rrc_end_scan_req(ctxt_pP->module_id,eNB_indexP)); #endif } @@ -1929,41 +2140,42 @@ const char SIBType[16][6] = {"SIB3\0","SIB4\0","SIB5\0","SIB6\0","SIB7\0","SIB8\ const char SIBPeriod[7][7]= {"80ms\0","160ms\0","320ms\0","640ms\0","1280ms\0","2560ms\0","5120ms\0"}; int siPeriod_int[7] = {80,160,320,640,1280,2560,5120}; +//----------------------------------------------------------------------------- int decode_BCCH_DLSCH_Message( - module_id_t ue_mod_idP, - frame_t frameP, - uint8_t eNB_index, - uint8_t *Sdu, - uint8_t Sdu_len, - uint8_t rsrq, - uint8_t rsrp + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + uint8_t* const Sdu, + const uint8_t Sdu_len, + const uint8_t rsrq, + const uint8_t rsrp ) +//----------------------------------------------------------------------------- { //BCCH_DL_SCH_Message_t bcch_message; BCCH_DL_SCH_Message_t *bcch_message=NULL;//_ptr=&bcch_message; - SystemInformationBlockType1_t **sib1=&UE_rrc_inst[ue_mod_idP].sib1[eNB_index]; - SystemInformation_t **si=UE_rrc_inst[ue_mod_idP].si[eNB_index]; + SystemInformationBlockType1_t** sib1=&UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]; + SystemInformation_t** si=UE_rrc_inst[ctxt_pP->module_id].si[eNB_index]; asn_dec_rval_t dec_rval; uint32_t si_window;//, sib1_decoded=0, si_decoded=0; - int i; + // int i; vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_IN); - if ((UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIB1Status == 1) && - (UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIStatus == 1)) { + if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1Status == 1) && + (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus == 1)) { // Avoid decoding to prevent memory bloating vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT); return 0; } else { - rrc_set_sub_state (ue_mod_idP, RRC_SUB_STATE_IDLE_RECEIVING_SIB); + rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_IDLE_RECEIVING_SIB); //memset(&bcch_message,0,sizeof(BCCH_DL_SCH_Message_t)); - LOG_D(RRC,"[UE %d] Decoding DL_BCCH_DLSCH_Message\n",ue_mod_idP); + /*LOG_D(RRC,"[UE %d] Decoding DL_BCCH_DLSCH_Message\n",ue_mod_idP);*/ dec_rval = uper_decode_complete(NULL, &asn_DEF_BCCH_DL_SCH_Message, @@ -1972,10 +2184,9 @@ decode_BCCH_DLSCH_Message( Sdu_len);//,0,0); if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { - LOG_E(RRC,"[UE %d] Failed to decode BCCH_DLSCH_MESSAGE (%d bits)\n",ue_mod_idP,dec_rval.consumed); - /* for (i=0;i<Sdu_len;i++) - printf("%2x ",Sdu[i]); - printf("\n"); */ + LOG_E(RRC,"[UE %d] Failed to decode BCCH_DLSCH_MESSAGE (%d bits)\n", + ctxt_pP->module_id, + dec_rval.consumed); //free the memory SEQUENCE_free(&asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message, 1); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT); @@ -1992,7 +2203,7 @@ decode_BCCH_DLSCH_Message( msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_DL_BCCH_MESSAGE); memcpy (&msg_p->ittiMsg, (void *) bcch_message, sizeof(RrcDlBcchMessage)); - itti_send_msg_to_task (TASK_UNKNOWN, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task (TASK_UNKNOWN, ctxt_pP->instance, msg_p); } # else { @@ -2006,7 +2217,7 @@ decode_BCCH_DLSCH_Message( msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif @@ -2015,13 +2226,13 @@ decode_BCCH_DLSCH_Message( if (bcch_message->message.present == BCCH_DL_SCH_MessageType_PR_c1) { switch (bcch_message->message.choice.c1.present) { case BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1: - if ((frameP %2) == 0) { - if (UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIB1Status == 0) { + if ((ctxt_pP->frame %2) == 0) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1Status == 0) { memcpy((void*)*sib1, (void*)&bcch_message->message.choice.c1.choice.systemInformationBlockType1, sizeof(SystemInformationBlockType1_t)); - LOG_D(RRC,"[UE %d] Decoding First SIB1\n",ue_mod_idP); - decode_SIB1(ue_mod_idP, eNB_index, rsrq, rsrp); + LOG_D(RRC,"[UE %d] Decoding First SIB1\n",ctxt_pP->module_id); + decode_SIB1(ctxt_pP, eNB_index, rsrq, rsrp); //mac_xface->macphy_exit("after decode_SIB1"); } } @@ -2029,15 +2240,19 @@ decode_BCCH_DLSCH_Message( break; case BCCH_DL_SCH_MessageType__c1_PR_systemInformation: - if ((UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIB1Status == 1) && - (UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIStatus == 0)) { + if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1Status == 1) && + (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus == 0)) { // if ((frameP %8) == 1) { // check only in odd frames for SI - si_window = (frameP%(UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIperiod/10))/(UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIwindowsize/10); + si_window = (ctxt_pP->frame%(UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod/10))/ + (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize/10); memcpy((void*)si[si_window], (void*)&bcch_message->message.choice.c1.choice.systemInformation, sizeof(SystemInformation_t)); - LOG_D(RRC,"[UE %d] Decoding SI for frameP %d, si_window %d\n",ue_mod_idP,frameP,si_window); - decode_SI(ue_mod_idP,frameP,eNB_index,si_window); + LOG_D(RRC,"[UE %d] Decoding SI for frameP %d, si_window %d\n", + ctxt_pP->module_id, + ctxt_pP->frame, + si_window); + decode_SI(ctxt_pP,eNB_index,si_window); //mac_xface->macphy_exit("after decode_SI"); // } @@ -2052,15 +2267,14 @@ decode_BCCH_DLSCH_Message( } } - if ((rrc_get_sub_state(ue_mod_idP) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) + if ((rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) # if defined(ENABLE_USE_MME) - && (UE_rrc_inst[ue_mod_idP].initialNasMsg.data != NULL) + && (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) #endif ) { - rrc_ue_generate_RRCConnectionRequest(ue_mod_idP, frameP, 0); - // LOG_I(RRC, "not sending connection request\n"); - - rrc_set_sub_state (ue_mod_idP, RRC_SUB_STATE_IDLE_CONNECTING); + rrc_ue_generate_RRCConnectionRequest(ctxt_pP, 0); + LOG_I(RRC, "not sending connection request\n"); + rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_IDLE_CONNECTING); } /* if ((UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIB1Status == 1) && @@ -2072,15 +2286,17 @@ decode_BCCH_DLSCH_Message( } +//----------------------------------------------------------------------------- int decode_SIB1( - module_id_t ue_mod_idP, - uint8_t eNB_index, - uint8_t rsrq, - uint8_t rsrp + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t rsrq, + const uint8_t rsrp ) +//----------------------------------------------------------------------------- { - SystemInformationBlockType1_t **sib1=&UE_rrc_inst[ue_mod_idP].sib1[eNB_index]; + SystemInformationBlockType1_t** sib1=&UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]; int i; int mcc,mnc,mccdigits,mncdigits,tac=0; PLMN_Identity_t *PLMN_identity; @@ -2088,7 +2304,7 @@ decode_SIB1( vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SIB1, VCD_FUNCTION_IN); - LOG_I(RRC,"[UE %d] : Dumping SIB 1\n",ue_mod_idP); + LOG_I(RRC,"[UE %d] : Dumping SIB 1\n",ctxt_pP->module_id); // xer_fprint(stdout,&asn_DEF_SystemInformationBlockType1, (void*)*sib1); PLMN_identity = &(*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->plmn_Identity; @@ -2108,8 +2324,9 @@ decode_SIB1( mnc = *PLMN_identity->mnc.list.array[0]*100 + *PLMN_identity->mnc.list.array[1]*10 + *PLMN_identity->mnc.list.array[2]; } - if ((*sib1)->cellAccessRelatedInfo.trackingAreaCode.size == 2) + if ((*sib1)->cellAccessRelatedInfo.trackingAreaCode.size == 2) { tac = ((*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[0]<<8)+(*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[1]; + } LOG_I(RRC,"PLMN MCC %d, MNC %d, TAC %x\n",mcc,mnc,tac); plmn_ind = 0; @@ -2123,8 +2340,9 @@ decode_SIB1( plmn_ind++; } - if (plmn_data[plmn_ind].mcc<0) + if (plmn_data[plmn_ind].mcc<0) { LOG_I(RRC,"Found Unknown operator\n"); + } LOG_I(RRC,"cellAccessRelatedInfo.cellIdentity : %x.%x.%x.%x\n", (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[0], @@ -2140,9 +2358,9 @@ decode_SIB1( for (i=0; i<(*sib1)->schedulingInfoList.list.count; i++) { LOG_I(RRC,"siSchedulingInfoPeriod[%d] : %s\n",i,SIBPeriod[(int)(*sib1)->schedulingInfoList.list.array[i]->si_Periodicity]); - if ((*sib1)->schedulingInfoList.list.array[i]->sib_MappingInfo.list.count>0) + if ((*sib1)->schedulingInfoList.list.array[i]->sib_MappingInfo.list.count>0) { LOG_I(RRC,"siSchedulingInfoSIBType[%d] : %s\n",i,SIBType[(int)(*(*sib1)->schedulingInfoList.list.array[i]->sib_MappingInfo.list.array[0])]); - else { + } else { LOG_W(RRC,"mapping list %d is null\n",i); } } @@ -2156,12 +2374,11 @@ decode_SIB1( LOG_I(RRC,"S-Subframe Config : %d\n",(int)(*sib1)->tdd_Config->specialSubframePatterns); } - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIperiod = siPeriod_int[(*sib1)->schedulingInfoList.list.array[0]->si_Periodicity]; - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIwindowsize = siWindowLength_int[(*sib1)->si_WindowLength]; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod = siPeriod_int[(*sib1)->schedulingInfoList.list.array[0]->si_Periodicity]; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize = siWindowLength_int[(*sib1)->si_WindowLength]; LOG_D(RRC, "[MSC_MSG][FRAME unknown][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB1 params eNB %d) --->][MAC_UE][MOD %02d][]\n", - ue_mod_idP, eNB_index, ue_mod_idP); - - rrc_mac_config_req(ue_mod_idP,ENB_FLAG_NO,0,eNB_index, + ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); + rrc_mac_config_req(ctxt_pP->module_id,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, #ifdef Rel10 @@ -2173,10 +2390,10 @@ decode_SIB1( 0, (struct LogicalChannelConfig *)NULL, (MeasGapConfig_t *)NULL, - UE_rrc_inst[ue_mod_idP].sib1[eNB_index]->tdd_Config, + UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config, (MobilityControlInfo_t *) NULL, - &UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIwindowsize, - &UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIperiod, + &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize, + &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod, NULL, NULL, NULL, @@ -2193,8 +2410,8 @@ decode_SIB1( #endif ); - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIB1Status = 1; - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIB1systemInfoValueTag = (*sib1)->systemInfoValueTag; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1Status = 1; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1systemInfoValueTag = (*sib1)->systemInfoValueTag; #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) { @@ -2215,15 +2432,15 @@ decode_SIB1( if (((plmn_Identity->mcc == NULL) || - ((UE_rrc_inst[ue_mod_idP].plmnID.MCCdigit1 == *(plmn_Identity->mcc->list.array[0])) && - (UE_rrc_inst[ue_mod_idP].plmnID.MCCdigit2 == *(plmn_Identity->mcc->list.array[1])) && - (UE_rrc_inst[ue_mod_idP].plmnID.MCCdigit3 == *(plmn_Identity->mcc->list.array[2])))) + ((UE_rrc_inst[ctxt_pP->module_id].plmnID.MCCdigit1 == *(plmn_Identity->mcc->list.array[0])) && + (UE_rrc_inst[ctxt_pP->module_id].plmnID.MCCdigit2 == *(plmn_Identity->mcc->list.array[1])) && + (UE_rrc_inst[ctxt_pP->module_id].plmnID.MCCdigit3 == *(plmn_Identity->mcc->list.array[2])))) && - (UE_rrc_inst[ue_mod_idP].plmnID.MNCdigit1 == *(plmn_Identity->mnc.list.array[0])) && - (UE_rrc_inst[ue_mod_idP].plmnID.MNCdigit2 == *(plmn_Identity->mnc.list.array[1])) && - (((UE_rrc_inst[ue_mod_idP].plmnID.MNCdigit3 == 0xf) && (plmn_Identity->mnc.list.count == 2)) + (UE_rrc_inst[ctxt_pP->module_id].plmnID.MNCdigit1 == *(plmn_Identity->mnc.list.array[0])) && + (UE_rrc_inst[ctxt_pP->module_id].plmnID.MNCdigit2 == *(plmn_Identity->mnc.list.array[1])) && + (((UE_rrc_inst[ctxt_pP->module_id].plmnID.MNCdigit3 == 0xf) && (plmn_Identity->mnc.list.count == 2)) || - (UE_rrc_inst[ue_mod_idP].plmnID.MNCdigit3 == *(plmn_Identity->mnc.list.array[2])))) { + (UE_rrc_inst[ctxt_pP->module_id].plmnID.MNCdigit3 == *(plmn_Identity->mnc.list.array[2])))) { /* PLMN match, send a confirmation to NAS */ MessageDef *msg_p; @@ -2235,7 +2452,7 @@ decode_SIB1( NAS_CELL_SELECTION_CNF (msg_p).rsrq = rsrq; NAS_CELL_SELECTION_CNF (msg_p).rsrp = rsrp; - itti_send_msg_to_task(TASK_NAS_UE, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); cell_valid = 1; break; } @@ -2248,7 +2465,7 @@ decode_SIB1( msg_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_NEXT_CELL_REQ); - itti_send_msg_to_task(TASK_PHY_UE, ue_mod_idP + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_PHY_UE, ctxt_pP->instance, msg_p); } } #endif @@ -2259,10 +2476,12 @@ decode_SIB1( } +//----------------------------------------------------------------------------- void dump_sib2( SystemInformationBlockType2_t *sib2 ) +//----------------------------------------------------------------------------- { LOG_I(RRC,"radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles : %ld\n", @@ -2271,14 +2490,16 @@ dump_sib2( // if (radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig) //msg("radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig ",sib2->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL; - LOG_I(RRC,"[UE]radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep : %ld\n",sib2->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep); + LOG_I(RRC,"[UE]radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep : %ld\n", + sib2->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep); LOG_I(RRC,"[UE]radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower : %ld\n", sib2->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower); - LOG_I(RRC,"radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax : %ld\n",sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax); - - LOG_I(RRC,"radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize : %ld\n",sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize); + LOG_I(RRC,"radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax : %ld\n", + sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax); + LOG_I(RRC,"radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize : %ld\n", + sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize); LOG_I(RRC,"radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer : %ld\n", sib2->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer); @@ -2287,27 +2508,36 @@ dump_sib2( sib2->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx); LOG_I(RRC,"radioResourceConfigCommon.prach_Config.rootSequenceIndex : %ld\n",sib2->radioResourceConfigCommon.prach_Config.rootSequenceIndex); - LOG_I(RRC,"radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex : %ld\n",sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex); - LOG_I(RRC,"radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag : %d\n", (int)sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag); - LOG_I(RRC,"radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig : %ld\n", sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig); - LOG_I(RRC,"radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset %ld\n", sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset); + LOG_I(RRC,"radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex : %ld\n", + sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex); + LOG_I(RRC,"radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag : %d\n", + (int)sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag); + LOG_I(RRC,"radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig : %ld\n", + sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig); + LOG_I(RRC,"radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset %ld\n", + sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset); // PDSCH-Config LOG_I(RRC,"radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower : %ld\n",sib2->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower); LOG_I(RRC,"radioResourceConfigCommon.pdsch_ConfigCommon.p_b : %ld\n",sib2->radioResourceConfigCommon.pdsch_ConfigCommon.p_b); // PUSCH-Config - LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB : %ld\n",sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB); - LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode : %ld\n",sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); - LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset : %ld\n",sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset); - LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM : %d\n",(int)sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM); + LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB : %ld\n", + sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB); + LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode : %ld\n", + sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); + LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset : %ld\n", + sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset); + LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM : %d\n", + (int)sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM); LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled : %d\n", (int)sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled); LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH : %ld\n", sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled : %d\n", (int)sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); - LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift : %ld\n",sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); + LOG_I(RRC,"radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift : %ld\n", + sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); // PUCCH-Config @@ -2321,10 +2551,12 @@ dump_sib2( // uplinkPowerControlCommon - LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH : %ld\n",sib2->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH); + LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH : %ld\n", + sib2->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH); LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.alpha : %ld\n",sib2->radioResourceConfigCommon.uplinkPowerControlCommon.alpha); - LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH : %ld\n",sib2->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH); + LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH : %ld\n", + sib2->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH); LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1 : %ld\n", sib2->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1); LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b :%ld\n", @@ -2336,7 +2568,8 @@ dump_sib2( LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b :%ld\n", sib2->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b); - LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 : %ld\n",sib2->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3); + LOG_I(RRC,"radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 : %ld\n", + sib2->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3); LOG_I(RRC,"radioResourceConfigCommon.ul_CyclicPrefixLength : %ld\n", sib2->radioResourceConfigCommon.ul_CyclicPrefixLength); @@ -2354,19 +2587,23 @@ dump_sib2( LOG_I(RRC,"timeAlignmentTimerCommon : %ld\n", sib2->timeAlignmentTimerCommon); } +//----------------------------------------------------------------------------- void dump_sib3( SystemInformationBlockType3_t *sib3 ) +//----------------------------------------------------------------------------- { } #ifdef Rel10 +//----------------------------------------------------------------------------- void dump_sib13( SystemInformationBlockType13_r9_t *sib13 ) +//----------------------------------------------------------------------------- { LOG_D(RRC,"[RRC][UE] Dumping SIB13\n"); @@ -2380,16 +2617,17 @@ dump_sib13( //const char SIBPeriod[7][7]= {"80ms\0","160ms\0","320ms\0","640ms\0","1280ms\0","2560ms\0","5120ms\0"}; +//----------------------------------------------------------------------------- int decode_SI( - module_id_t ue_mod_idP, - frame_t frameP, - uint8_t eNB_index, - uint8_t si_window + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t si_window ) +//----------------------------------------------------------------------------- { - SystemInformation_t **si=&UE_rrc_inst[ue_mod_idP].si[eNB_index][si_window]; + SystemInformation_t** si=&UE_rrc_inst[ctxt_pP->module_id].si[eNB_index][si_window]; int i; struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *typeandinfo; @@ -2410,13 +2648,13 @@ decode_SI( switch(typeandinfo->present) { case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2: - UE_rrc_inst[ue_mod_idP].sib2[eNB_index] = &typeandinfo->choice.sib2; - LOG_D(RRC,"[UE %d] Frame %d Found SIB2 from eNB %d\n",ue_mod_idP,frameP,eNB_index); - dump_sib2(UE_rrc_inst[ue_mod_idP].sib2[eNB_index]); + UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index] = &typeandinfo->choice.sib2; + LOG_D(RRC,"[UE %d] Frame %d Found SIB2 from eNB %d\n",ctxt_pP->module_id,ctxt_pP->frame,eNB_index); + dump_sib2(UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]); LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB2 params eNB %d) --->][MAC_UE][MOD %02d][]\n", - frameP, ue_mod_idP, eNB_index, ue_mod_idP); - rrc_mac_config_req(ue_mod_idP,ENB_FLAG_NO,0,eNB_index, - &UE_rrc_inst[ue_mod_idP].sib2[eNB_index]->radioResourceConfigCommon, + ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); + rrc_mac_config_req(ctxt_pP->module_id,ENB_FLAG_NO,0,eNB_index, + &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->radioResourceConfigCommon, (struct PhysicalConfigDedicated *)NULL, #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, @@ -2431,10 +2669,10 @@ decode_SI( (MobilityControlInfo_t *)NULL, NULL, NULL, - UE_rrc_inst[ue_mod_idP].sib2[eNB_index]->freqInfo.ul_CarrierFreq, - UE_rrc_inst[ue_mod_idP].sib2[eNB_index]->freqInfo.ul_Bandwidth, - &UE_rrc_inst[ue_mod_idP].sib2[eNB_index]->freqInfo.additionalSpectrumEmission, - UE_rrc_inst[ue_mod_idP].sib2[eNB_index]->mbsfn_SubframeConfigList + UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_CarrierFreq, + UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth, + &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.additionalSpectrumEmission, + UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->mbsfn_SubframeConfigList #ifdef Rel10 ,0, (MBSFN_AreaInfoList_r9_t *)NULL, @@ -2445,21 +2683,21 @@ decode_SI( 0 #endif ); - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIStatus = 1; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1; // After SI is received, prepare RRCConnectionRequest #ifdef Rel10 - if (UE_rrc_inst[ue_mod_idP].MBMS_flag < 3) // see -Q option + if (UE_rrc_inst[ctxt_pP->module_id].MBMS_flag < 3) // see -Q option #endif #if !(defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)) - rrc_ue_generate_RRCConnectionRequest(ue_mod_idP,frameP,eNB_index); + rrc_ue_generate_RRCConnectionRequest(ctxt_pP,eNB_index); LOG_I(RRC, "not sending connection request\n"); #endif - if (UE_rrc_inst[ue_mod_idP].Info[eNB_index].State == RRC_IDLE) { - LOG_I(RRC,"[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n",ue_mod_idP); - UE_rrc_inst[ue_mod_idP].Info[eNB_index].State = RRC_SI_RECEIVED; + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_IDLE) { + LOG_I(RRC,"[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n",ctxt_pP->module_id); + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_SI_RECEIVED; #ifdef ENABLE_RAL { MessageDef *message_ral_p = NULL; @@ -2483,7 +2721,7 @@ decode_SI( ral_si_ind.link_data_rate = 0; memcpy (&message_ral_p->ittiMsg, (void *) &ral_si_ind, sizeof(rrc_ral_system_information_ind_t)); #warning "ue_mod_idP ? for instance ?" - itti_send_msg_to_task (TASK_RAL_UE, ue_mod_idP + NB_eNB_INST, message_ral_p); + itti_send_msg_to_task (TASK_RAL_UE, UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), message_ral_p); } #endif } @@ -2491,68 +2729,67 @@ decode_SI( break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3: - UE_rrc_inst[ue_mod_idP].sib3[eNB_index] = &typeandinfo->choice.sib3; - LOG_I(RRC,"[UE %d] Frame %d Found SIB3 from eNB %d\n",ue_mod_idP,frameP,eNB_index); - dump_sib3(UE_rrc_inst[ue_mod_idP].sib3[eNB_index]); - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIStatus = 1; - - rrc_set_sub_state (ue_mod_idP, RRC_SUB_STATE_IDLE_SIB_COMPLETE); + UE_rrc_inst[ctxt_pP->module_id].sib3[eNB_index] = &typeandinfo->choice.sib3; + LOG_I(RRC,"[UE %d] Frame %d Found SIB3 from eNB %d\n",ctxt_pP->module_id,ctxt_pP->frame,eNB_index); + dump_sib3(UE_rrc_inst[ctxt_pP->module_id].sib3[eNB_index]); + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1; + rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_IDLE_SIB_COMPLETE); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4: - UE_rrc_inst[ue_mod_idP].sib4[eNB_index] = &typeandinfo->choice.sib4; - LOG_I(RRC,"[UE %d] Frame %d Found SIB4 from eNB %d\n",ue_mod_idP,frameP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib4[eNB_index] = &typeandinfo->choice.sib4; + LOG_I(RRC,"[UE %d] Frame %d Found SIB4 from eNB %d\n",ctxt_pP->module_id,ctxt_pP->frame,eNB_index); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5: - UE_rrc_inst[ue_mod_idP].sib5[eNB_index] = &typeandinfo->choice.sib5; - LOG_I(RRC,"[UE %d] Found SIB5 from eNB %d\n",ue_mod_idP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index] = &typeandinfo->choice.sib5; + LOG_I(RRC,"[UE %d] Found SIB5 from eNB %d\n",ctxt_pP->module_id,eNB_index); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6: - UE_rrc_inst[ue_mod_idP].sib6[eNB_index] = &typeandinfo->choice.sib6; - LOG_I(RRC,"[UE %d] Found SIB6 from eNB %d\n",ue_mod_idP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib6[eNB_index] = &typeandinfo->choice.sib6; + LOG_I(RRC,"[UE %d] Found SIB6 from eNB %d\n",ctxt_pP->module_id,eNB_index); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7: - UE_rrc_inst[ue_mod_idP].sib7[eNB_index] = &typeandinfo->choice.sib7; - LOG_I(RRC,"[UE %d] Found SIB7 from eNB %d\n",ue_mod_idP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib7[eNB_index] = &typeandinfo->choice.sib7; + LOG_I(RRC,"[UE %d] Found SIB7 from eNB %d\n",ctxt_pP->module_id,eNB_index); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8: - UE_rrc_inst[ue_mod_idP].sib8[eNB_index] = &typeandinfo->choice.sib8; - LOG_I(RRC,"[UE %d] Found SIB8 from eNB %d\n",ue_mod_idP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib8[eNB_index] = &typeandinfo->choice.sib8; + LOG_I(RRC,"[UE %d] Found SIB8 from eNB %d\n",ctxt_pP->module_id,eNB_index); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9: - UE_rrc_inst[ue_mod_idP].sib9[eNB_index] = &typeandinfo->choice.sib9; - LOG_I(RRC,"[UE %d] Found SIB9 from eNB %d\n",ue_mod_idP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib9[eNB_index] = &typeandinfo->choice.sib9; + LOG_I(RRC,"[UE %d] Found SIB9 from eNB %d\n",ctxt_pP->module_id,eNB_index); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10: - UE_rrc_inst[ue_mod_idP].sib10[eNB_index] = &typeandinfo->choice.sib10; - LOG_I(RRC,"[UE %d] Found SIB10 from eNB %d\n",ue_mod_idP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib10[eNB_index] = &typeandinfo->choice.sib10; + LOG_I(RRC,"[UE %d] Found SIB10 from eNB %d\n",ctxt_pP->module_id,eNB_index); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11: - UE_rrc_inst[ue_mod_idP].sib11[eNB_index] = &typeandinfo->choice.sib11; - LOG_I(RRC,"[UE %d] Found SIB11 from eNB %d\n",ue_mod_idP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib11[eNB_index] = &typeandinfo->choice.sib11; + LOG_I(RRC,"[UE %d] Found SIB11 from eNB %d\n",ctxt_pP->module_id,eNB_index); break; #ifdef Rel10 case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920: - UE_rrc_inst[ue_mod_idP].sib12[eNB_index] = &typeandinfo->choice.sib12_v920; - LOG_I(RRC,"[RRC][UE %d] Found SIB12 from eNB %d\n",ue_mod_idP,eNB_index); + UE_rrc_inst[ctxt_pP->module_id].sib12[eNB_index] = &typeandinfo->choice.sib12_v920; + LOG_I(RRC,"[RRC][UE %d] Found SIB12 from eNB %d\n",ctxt_pP->module_id,eNB_index); break; case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920: - UE_rrc_inst[ue_mod_idP].sib13[eNB_index] = &typeandinfo->choice.sib13_v920; - LOG_I(RRC,"[RRC][UE %d] Found SIB13 from eNB %d\n",ue_mod_idP,eNB_index); - dump_sib13(UE_rrc_inst[ue_mod_idP].sib13[eNB_index]); + UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index] = &typeandinfo->choice.sib13_v920; + LOG_I(RRC,"[RRC][UE %d] Found SIB13 from eNB %d\n",ctxt_pP->module_id,eNB_index); + dump_sib13(UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index]); // adding here function to store necessary parameters for using in decode_MCCH_Message + maybe transfer to PHY layer LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB13 params eNB %d) --->][MAC_UE][MOD %02d][]\n", - frameP, ue_mod_idP, eNB_index, ue_mod_idP); - rrc_mac_config_req(ue_mod_idP,ENB_FLAG_NO,0,eNB_index, + ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); + rrc_mac_config_req(ctxt_pP->module_id,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, #ifdef Rel10 @@ -2573,14 +2810,14 @@ decode_SI( NULL, (MBSFN_SubframeConfigList_t *)NULL ,0, - &UE_rrc_inst[ue_mod_idP].sib13[eNB_index]->mbsfn_AreaInfoList_r9, + &UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index]->mbsfn_AreaInfoList_r9, (PMCH_InfoList_r9_t *)NULL #ifdef CBA ,0, 0 #endif ); - UE_rrc_inst[ue_mod_idP].Info[eNB_index].SIStatus = 1; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1; break; #endif @@ -2595,59 +2832,69 @@ decode_SI( } // layer 3 filtering of RSRP (EUTRA) measurements: 36.331, Sec. 5.5.3.2 +//----------------------------------------------------------------------------- void ue_meas_filtering( - module_id_t ue_mod_idP, - frame_t frameP, - uint8_t eNB_index + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index ) +//----------------------------------------------------------------------------- { - float a = UE_rrc_inst[ue_mod_idP].filter_coeff_rsrp; // 'a' in 36.331 Sec. 5.5.3.2 - float a1 = UE_rrc_inst[ue_mod_idP].filter_coeff_rsrq; + float a = UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrp; // 'a' in 36.331 Sec. 5.5.3.2 + float a1 = UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrq; //float rsrp_db, rsrq_db; uint8_t eNB_offset; - if(UE_rrc_inst[ue_mod_idP].QuantityConfig[0] != NULL) { // Only consider 1 serving cell (index: 0) - if (UE_rrc_inst[ue_mod_idP].QuantityConfig[0]->quantityConfigEUTRA != NULL) { - if(UE_rrc_inst[ue_mod_idP].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP != NULL) { - for (eNB_offset = 0; eNB_offset<1+mac_xface->get_n_adj_cells(ue_mod_idP,0); eNB_offset++) { + if(UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0] != NULL) { // Only consider 1 serving cell (index: 0) + if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0]->quantityConfigEUTRA != NULL) { + if(UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP != NULL) { + for (eNB_offset = 0; eNB_offset<1+mac_xface->get_n_adj_cells(ctxt_pP->module_id,0); eNB_offset++) { //filter_factor = 1/power(2,*UE_rrc_inst[ue_mod_idP].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP/4); // LOG_N(RRC,"[UE %d] Frame %d : check proper operation in abstraction mode rsrp (%d), rx gain (%d) N_RB_DL (%d)\n", // ue_mod_idP,frameP,mac_xface->get_RSRP(ue_mod_idP,0,eNB_offset),mac_xface->get_rx_total_gain_dB(ue_mod_idP,0),mac_xface->lte_frame_parms->N_RB_DL); - UE_rrc_inst[ue_mod_idP].rsrp_db[eNB_offset] = (dB_fixed_times10(mac_xface->get_RSRP(ue_mod_idP,0,eNB_offset))/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP, - 0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12); - UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset] = (1.0-a)*UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset] + a*UE_rrc_inst[ue_mod_idP].rsrp_db[eNB_offset]; + UE_rrc_inst[ctxt_pP->module_id].rsrp_db[eNB_offset] = + (dB_fixed_times10(mac_xface->get_RSRP(ctxt_pP->module_id,0,eNB_offset))/10.0) - + mac_xface->get_rx_total_gain_dB(ctxt_pP->module_id,0) - + dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12); + UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[eNB_offset] = + (1.0-a)*UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[eNB_offset] + + a*UE_rrc_inst[ctxt_pP->module_id].rsrp_db[eNB_offset]; //mac_xface->set_RSRP_filtered(ue_mod_idP,eNB_offset,UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset]); //LOG_D(RRC,"RSRP_total_dB: %3.2f \n",(dB_fixed_times10(mac_xface->get_RSRP(ue_mod_idP,0,eNB_offset))/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP,0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12)); - LOG_D(RRC,"RSRP_dBm: %3.2f \n",(dB_fixed_times10(mac_xface->get_RSRP(ue_mod_idP,0,eNB_offset))/10.0)); - LOG_D(RRC,"gain_loss_dB: %d \n",mac_xface->get_rx_total_gain_dB(ue_mod_idP,0)); + LOG_D(RRC,"RSRP_dBm: %3.2f \n",(dB_fixed_times10(mac_xface->get_RSRP(ctxt_pP->module_id,0,eNB_offset))/10.0)); + LOG_D(RRC,"gain_loss_dB: %d \n",mac_xface->get_rx_total_gain_dB(ctxt_pP->module_id,0)); LOG_D(RRC,"gain_fixed_dB: %d \n",dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12)); LOG_D(PHY,"[UE %d] Frame %d, RRC Measurements => rssi %3.1f dBm (digital: %3.1f dB)\n", - ue_mod_idP, frameP, 10*log10(mac_xface->get_RSSI(ue_mod_idP,0))-mac_xface->get_rx_total_gain_dB(ue_mod_idP,0),10*log10(mac_xface->get_RSSI(ue_mod_idP,0))); + ctxt_pP->module_id, + ctxt_pP->frame, + 10*log10(mac_xface->get_RSSI(ctxt_pP->module_id,0))-mac_xface->get_rx_total_gain_dB(ctxt_pP->module_id,0), + 10*log10(mac_xface->get_RSSI(ctxt_pP->module_id,0))); LOG_D(RRC,"[UE %d] Frame %d: Meas RSRP: eNB_offset: %d rsrp_coef: %3.1f filter_coef: %d before L3 filtering: rsrp: %3.1f after L3 filtering: rsrp: %3.1f \n ", - ue_mod_idP, frameP, eNB_offset,a, + ctxt_pP->module_id, + ctxt_pP->frame, eNB_offset,a, *UE_rrc_inst->QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP, - UE_rrc_inst[ue_mod_idP].rsrp_db[eNB_offset], - UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset]); + UE_rrc_inst[ctxt_pP->module_id].rsrp_db[eNB_offset], + UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[eNB_offset]); } } } else { - for (eNB_offset = 0; eNB_offset<1+mac_xface->get_n_adj_cells(ue_mod_idP,0); eNB_offset++) { - UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset]= mac_xface->get_RSRP(ue_mod_idP,0,eNB_offset); + for (eNB_offset = 0; eNB_offset<1+mac_xface->get_n_adj_cells(ctxt_pP->module_id,0); eNB_offset++) { + UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[eNB_offset]= mac_xface->get_RSRP(ctxt_pP->module_id,0,eNB_offset); // phy_vars_ue->PHY_measurements.rsrp_filtered[eNB_offset]=UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset]; //mac_xface->set_RSRP_filtered(ue_mod_idP,eNB_offset,UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset]); } } - if (UE_rrc_inst[ue_mod_idP].QuantityConfig[0]->quantityConfigEUTRA != NULL) { - if(UE_rrc_inst[ue_mod_idP].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRQ != NULL) { - for (eNB_offset = 0; eNB_offset<1+mac_xface->get_n_adj_cells(ue_mod_idP,0); eNB_offset++) { + if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0]->quantityConfigEUTRA != NULL) { + if(UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRQ != NULL) { + for (eNB_offset = 0; eNB_offset<1+mac_xface->get_n_adj_cells(ctxt_pP->module_id,0); eNB_offset++) { // LOG_N(RRC,"[UE %d] Frame %d : check if this operation workes properly in abstraction mode\n",ue_mod_idP,frameP); - UE_rrc_inst[ue_mod_idP].rsrq_db[eNB_offset] = (10*log10(mac_xface->get_RSRQ(ue_mod_idP,0,eNB_offset)))-20; - UE_rrc_inst[ue_mod_idP].rsrq_db_filtered[eNB_offset]=(1-a1)*UE_rrc_inst[ue_mod_idP].rsrq_db_filtered[eNB_offset] + a1 *UE_rrc_inst[ue_mod_idP].rsrq_db[eNB_offset]; + UE_rrc_inst[ctxt_pP->module_id].rsrq_db[eNB_offset] = (10*log10(mac_xface->get_RSRQ(ctxt_pP->module_id,0,eNB_offset)))-20; + UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[eNB_offset]=(1-a1)*UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[eNB_offset] + + a1 *UE_rrc_inst[ctxt_pP->module_id].rsrq_db[eNB_offset]; //mac_xface->set_RSRP_filtered(ue_mod_idP,eNB_offset,UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset]); /* LOG_D(RRC,"[UE %d] Frame %d: Meas RSRQ: eNB_offset: %d rsrq_coef: %3.2f filter_coef: %d before L3 filtering: rsrq: %3.1f after L3 filtering: rsrq: %3.1f \n ", @@ -2660,20 +2907,21 @@ ue_meas_filtering( } } } else { - for (eNB_offset = 0; eNB_offset<1+mac_xface->get_n_adj_cells(ue_mod_idP,0); eNB_offset++) { - UE_rrc_inst[ue_mod_idP].rsrq_db_filtered[eNB_offset]= mac_xface->get_RSRQ(ue_mod_idP,0,eNB_offset); + for (eNB_offset = 0; eNB_offset<1+mac_xface->get_n_adj_cells(ctxt_pP->module_id,0); eNB_offset++) { + UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[eNB_offset]= mac_xface->get_RSRQ(ctxt_pP->module_id,0,eNB_offset); } } } } //Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5 +//----------------------------------------------------------------------------- void rrc_ue_generate_MeasurementReport( - module_id_t eNB_id, - module_id_t UE_id, - frame_t frameP + const protocol_ctxt_t* const ctxt_pP, + uint8_t eNB_index ) +//----------------------------------------------------------------------------- { uint8_t buffer[32], size; @@ -2687,53 +2935,61 @@ rrc_ue_generate_MeasurementReport( float rsrp_filtered, rsrq_filtered; static frame_t pframe=0; int result; - protocol_ctxt_t ctxt; - - ctxt.enb_module_id = eNB_id; - ctxt.ue_module_id = UE_id; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_NO; - - nElem = 98; nElem1 = 35; - target_eNB_offset = UE_rrc_inst[UE_id].Info[0].handoverTarget; // eNB_offset of target eNB: used to obtain the mod_id of target eNB + target_eNB_offset = UE_rrc_inst[ctxt_pP->module_id].Info[0].handoverTarget; // eNB_offset of target eNB: used to obtain the mod_id of target eNB for (i=0; i<MAX_MEAS_ID; i++) { - if (UE_rrc_inst[UE_id].measReportList[0][i] != NULL) { - measId = UE_rrc_inst[UE_id].measReportList[0][i]->measId; + if (UE_rrc_inst[ctxt_pP->module_id].measReportList[0][i] != NULL) { + measId = UE_rrc_inst[ctxt_pP->module_id].measReportList[0][i]->measId; // Note: Values in the meas report have to be the mapped values...to implement binary search for LUT - rsrp_filtered = UE_rrc_inst[UE_id].rsrp_db_filtered[eNB_id];//nid_cell]; + rsrp_filtered = UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[eNB_index];//nid_cell]; rsrp_s = binary_search_float(RSRP_meas_mapping,nElem, rsrp_filtered); - rsrq_filtered = UE_rrc_inst[UE_id].rsrq_db_filtered[eNB_id];//nid_cell]; //RSRQ of serving cell + rsrq_filtered = UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[eNB_index];//nid_cell]; //RSRQ of serving cell rsrq_s = binary_search_float(RSRQ_meas_mapping,nElem1,rsrq_filtered);//mapped RSRQ of serving cell LOG_D(RRC,"[UE %d] Frame %d: source eNB %d :rsrp_s: %ld rsrq_s: %ld rsrp_filtered: %f rsrq_filtered: %f \n", - UE_id, frameP, eNB_id, rsrp_s,rsrq_s,rsrp_filtered,rsrq_filtered); - - rsrp_t = binary_search_float(RSRP_meas_mapping,nElem,UE_rrc_inst[UE_id].rsrp_db_filtered[target_eNB_offset]); //RSRP of target cell - rsrq_t = binary_search_float(RSRQ_meas_mapping,nElem1,UE_rrc_inst[UE_id].rsrq_db_filtered[target_eNB_offset]); //RSRQ of target cell + ctxt_pP->module_id, + ctxt_pP->frame, + eNB_index, + rsrp_s, + rsrq_s, + rsrp_filtered, + rsrq_filtered); + rsrp_t = binary_search_float(RSRP_meas_mapping,nElem,UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[target_eNB_offset]); //RSRP of target cell + rsrq_t = binary_search_float(RSRQ_meas_mapping,nElem1,UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[target_eNB_offset]); //RSRQ of target cell LOG_D(RRC,"[UE %d] Frame %d: target eNB %d :rsrp_t: %ld rsrq_t: %ld rsrp_filtered: %f rsrq_filtered: %f \n", - UE_id, frameP, target_eNB_offset, rsrp_t,rsrq_t,UE_rrc_inst[UE_id].rsrp_db_filtered[target_eNB_offset],UE_rrc_inst[UE_id].rsrq_db_filtered[target_eNB_offset]); + ctxt_pP->module_id, + ctxt_pP->frame, + target_eNB_offset, + rsrp_t, + rsrq_t, + UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[target_eNB_offset], + UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[target_eNB_offset]); // if (measFlag == 1) { - cellId = get_adjacent_cell_id(UE_id, eNB_id); //PhycellId of serving cell - targetCellId = UE_rrc_inst[UE_id].HandoverInfoUe.targetCellId ;//get_adjacent_cell_id(ue_mod_idP,target_eNB_offset); //PhycellId of target cell + cellId = get_adjacent_cell_id(ctxt_pP->module_id, eNB_index); //PhycellId of serving cell + targetCellId = UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId ;//get_adjacent_cell_id(ue_mod_idP,target_eNB_offset); //PhycellId of target cell - if (pframe!=frameP) { - pframe=frameP; + if (pframe!=ctxt_pP->frame) { + pframe=ctxt_pP->frame; LOG_D(RRC, "[UE %d] Frame %d: doing MeasReport: servingCell(%d) targetCell(%d) rsrp_s(%ld) rsrq_s(%ld) rsrp_t(%ld) rsrq_t(%ld) \n", - UE_id, frameP, cellId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); - size = do_MeasurementReport(UE_id, buffer,measId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); - - LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d\n", UE_id, frameP, eNB_id); - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][UE %02d][][--- PDCP_DATA_REQ/%d Bytes (MeasurementReport to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frameP, UE_id, size, eNB_id, rrc_mui, eNB_id, DCCH); - result = pdcp_data_req(&ctxt, SRB_FLAG_YES, DCCH, rrc_mui++, 0, size, buffer, PDCP_TRANSMISSION_MODE_DATA); + ctxt_pP->module_id, + ctxt_pP->frame, + cellId, + targetCellId, + rsrp_s, + rsrq_s, + rsrp_t, + rsrq_t); + size = do_MeasurementReport(ctxt_pP->module_id, buffer,measId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); + LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d\n", + ctxt_pP->module_id, ctxt_pP->frame, eNB_index); + result = pdcp_data_req(ctxt_pP, SRB_FLAG_YES, DCCH, rrc_mui++, 0, size, buffer, PDCP_TRANSMISSION_MODE_DATA); AssertFatal (result == TRUE, "PDCP data request failed!\n"); //LOG_D(RRC, "[UE %d] Frame %d Sending MeasReport (%d bytes) through DCCH%d to PDCP \n",ue_mod_idP,frameP, size, DCCH); } @@ -2745,12 +3001,13 @@ rrc_ue_generate_MeasurementReport( } // Measurement report triggering, described in 36.331 Section 5.5.4.1: called periodically +//----------------------------------------------------------------------------- void ue_measurement_report_triggering( - module_id_t ue_mod_idP, - frame_t frameP, - uint8_t eNB_index + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index ) +//----------------------------------------------------------------------------- { uint8_t i,j; Hysteresis_t hys; @@ -2765,76 +3022,91 @@ ue_measurement_report_triggering( for(i=0 ; i<NB_CNX_UE ; i++) { for(j=0 ; j<MAX_MEAS_ID ; j++) { - if(UE_rrc_inst[ue_mod_idP].MeasId[i][j] != NULL) { - measObjId = UE_rrc_inst[ue_mod_idP].MeasId[i][j]->measObjectId; - reportConfigId = UE_rrc_inst[ue_mod_idP].MeasId[i][j]->reportConfigId; + if(UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j] != NULL) { + measObjId = UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j]->measObjectId; + reportConfigId = UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j]->reportConfigId; - if( /*UE_rrc_inst[ue_mod_idP].MeasId[i][j] != NULL && */ UE_rrc_inst[ue_mod_idP].MeasObj[i][measObjId-1] != NULL) { - if(UE_rrc_inst[ue_mod_idP].MeasObj[i][measObjId-1]->measObject.present == MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { + if( /*UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j] != NULL && */ UE_rrc_inst[ctxt_pP->module_id].MeasObj[i][measObjId-1] != NULL) { + if(UE_rrc_inst[ctxt_pP->module_id].MeasObj[i][measObjId-1]->measObject.present == MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { /* consider any neighboring cell detected on the associated frequency to be * applicable when the concerned cell is not included in the blackCellsToAddModList * defined within the VarMeasConfig for this measId */ - // LOG_I(RRC,"event %d %d %p \n", measObjId,reportConfigId, UE_rrc_inst[ue_mod_idP].ReportConfig[i][reportConfigId-1]); - if((UE_rrc_inst[ue_mod_idP].ReportConfig[i][reportConfigId-1] != NULL) && - (UE_rrc_inst[ue_mod_idP].ReportConfig[i][reportConfigId-1]->reportConfig.present==ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA) && - (UE_rrc_inst[ue_mod_idP].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.present == ReportConfigEUTRA__triggerType_PR_event)) { - hys = UE_rrc_inst[ue_mod_idP].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis; - //LOG_N(RRC,"[UE%d] Frame %d Check below lines for segfault :), Fix me \n",ue_mod_idP, frameP); - ttt_ms = timeToTrigger_ms[UE_rrc_inst[ue_mod_idP].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger]; + // LOG_I(RRC,"event %d %d %p \n", measObjId,reportConfigId, UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]); + if((UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1] != NULL) && + (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.present==ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA) && + (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.present == + ReportConfigEUTRA__triggerType_PR_event)) { + hys = UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis; + //LOG_N(RRC,"[UE%d] Frame %d Check below lines for segfault :), Fix me \n",ctxt_pP->module_id, frameP); + ttt_ms = timeToTrigger_ms[UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId + -1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger]; // Freq specific offset of neighbor cell freq - ofn = 5;//((UE_rrc_inst[ue_mod_idP].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq != NULL) ? - // *UE_rrc_inst[ue_mod_idP].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq : 15); // /* 15 is the Default */ + ofn = 5;//((UE_rrc_inst[ctxt_pP->module_id].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq != NULL) ? + // *UE_rrc_inst[ctxt_pP->module_id].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq : 15); // /* 15 is the Default */ // cellIndividualOffset of neighbor cell - not defined yet ocn = 0; - a3_offset = UE_rrc_inst[ue_mod_idP].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset; + a3_offset = UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId + -1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset; - switch (UE_rrc_inst[ue_mod_idP].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present) { + switch (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present) { case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA1: - LOG_D(RRC,"[UE %d] Frame %d : A1 event: check if serving becomes better than threshold\n",ue_mod_idP, frameP); + LOG_D(RRC,"[UE %d] Frame %d : A1 event: check if serving becomes better than threshold\n", + ctxt_pP->module_id, ctxt_pP->frame); break; case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA2: - LOG_D(RRC,"[UE %d] Frame %d : A2 event, check if serving becomes worse than a threshold\n",ue_mod_idP, frameP); + LOG_D(RRC,"[UE %d] Frame %d : A2 event, check if serving becomes worse than a threshold\n", + ctxt_pP->module_id, ctxt_pP->frame); break; case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3: - LOG_D(RRC,"[UE %d] Frame %d : A3 event: check if a neighboring cell becomes offset better than serving to trigger a measurement event \n",ue_mod_idP, frameP); - - if ((check_trigger_meas_event(ue_mod_idP,frameP,eNB_index,i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)) && - (UE_rrc_inst[ue_mod_idP].Info[0].State >= RRC_CONNECTED) && - (UE_rrc_inst[ue_mod_idP].Info[0].T304_active == 0 ) && - (UE_rrc_inst[ue_mod_idP].HandoverInfoUe.measFlag == 1)) { + LOG_D(RRC,"[UE %d] Frame %d : A3 event: check if a neighboring cell becomes offset better than serving to trigger a measurement event \n", + ctxt_pP->module_id, ctxt_pP->frame); + + if ((check_trigger_meas_event( + ctxt_pP->module_id, + ctxt_pP->frame, + eNB_index, + i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)) && + (UE_rrc_inst[ctxt_pP->module_id].Info[0].State >= RRC_CONNECTED) && + (UE_rrc_inst[ctxt_pP->module_id].Info[0].T304_active == 0 ) && + (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag == 1)) { //trigger measurement reporting procedure (36.331, section 5.5.5) - if (UE_rrc_inst[ue_mod_idP].measReportList[i][j] == NULL) { - UE_rrc_inst[ue_mod_idP].measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); + if (UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] == NULL) { + UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); } - UE_rrc_inst[ue_mod_idP].measReportList[i][j]->measId = UE_rrc_inst[ue_mod_idP].MeasId[i][j]->measId; - UE_rrc_inst[ue_mod_idP].measReportList[i][j]->numberOfReportsSent = 0; - rrc_ue_generate_MeasurementReport(eNB_index, ue_mod_idP,frameP); - UE_rrc_inst[ue_mod_idP].HandoverInfoUe.measFlag = 1; - LOG_I(RRC,"[UE %d] Frame %d: A3 event detected, state: %d \n", ue_mod_idP, frameP, UE_rrc_inst[ue_mod_idP].Info[0].State); + UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]->measId = UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j]->measId; + UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]->numberOfReportsSent = 0; + rrc_ue_generate_MeasurementReport( + ctxt_pP, + eNB_index); + UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; + LOG_I(RRC,"[UE %d] Frame %d: A3 event detected, state: %d \n", + ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[0].State); } else { - if(UE_rrc_inst[ue_mod_idP].measReportList[i][j] != NULL) { - free(UE_rrc_inst[ue_mod_idP].measReportList[i][j]); + if(UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] != NULL) { + free(UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]); } - UE_rrc_inst[ue_mod_idP].measReportList[i][j] = NULL; + UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] = NULL; } break; case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA4: - LOG_D(RRC,"[UE %d] Frame %d : received an A4 event, neighbor becomes offset better than a threshold\n",ue_mod_idP, frameP); + LOG_D(RRC,"[UE %d] Frame %d : received an A4 event, neighbor becomes offset better than a threshold\n", + ctxt_pP->module_id, ctxt_pP->frame); break; case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA5: - LOG_D(RRC,"[UE %d] Frame %d: received an A5 event, serving becomes worse than threshold 1 and neighbor becomes better than threshold 2\n",ue_mod_idP, frameP); + LOG_D(RRC,"[UE %d] Frame %d: received an A5 event, serving becomes worse than threshold 1 and neighbor becomes better than threshold 2\n", + ctxt_pP->module_id, ctxt_pP->frame); break; default: LOG_D(RRC,"Invalid ReportConfigEUTRA__triggerType__event__eventId: %d", - UE_rrc_inst[ue_mod_idP].ReportConfig[i][j]->reportConfig.choice.reportConfigEUTRA.triggerType.present); + UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][j]->reportConfig.choice.reportConfigEUTRA.triggerType.present); break; } } @@ -2846,6 +3118,7 @@ ue_measurement_report_triggering( } //check_trigger_meas_event(ue_mod_idP, frameP, eNB_index, i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms) +//----------------------------------------------------------------------------- uint8_t check_trigger_meas_event( module_id_t ue_mod_idP, @@ -2861,6 +3134,7 @@ check_trigger_meas_event( long a3_offset, TimeToTrigger_t ttt ) +//----------------------------------------------------------------------------- { uint8_t eNB_offset; uint8_t currentCellIndex = mac_xface->lte_frame_parms->Nid_cell; @@ -2897,7 +3171,8 @@ check_trigger_meas_event( ue_mod_idP, frameP, eNB_index, UE_rrc_inst->HandoverInfoUe.targetCellId,ue_cnx_index,eNB_offset, (dB_fixed_times10(UE_rrc_inst[ue_mod_idP].rsrp_db[0])/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP,0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12), - (dB_fixed_times10(UE_rrc_inst[ue_mod_idP].rsrp_db[eNB_offset])/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP,0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12)); + (dB_fixed_times10(UE_rrc_inst[ue_mod_idP].rsrp_db[eNB_offset])/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP, + 0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12)); UE_rrc_inst->Info[0].handoverTarget = eNB_offset; //LOG_D(RRC,"PHY_ID: %d \n",UE_rrc_inst->HandoverInfoUe.targetCellId); return 1; @@ -2913,25 +3188,28 @@ check_trigger_meas_event( } #ifdef Rel10 +//----------------------------------------------------------------------------- int decode_MCCH_Message( - module_id_t ue_mod_idP, - frame_t frameP, - uint8_t eNB_index, - uint8_t *Sdu, - uint8_t Sdu_len, - uint8_t mbsfn_sync_area + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t* const Sdu, + const uint8_t Sdu_len, + const uint8_t mbsfn_sync_area ) +//----------------------------------------------------------------------------- { MCCH_Message_t *mcch=NULL; - MBSFNAreaConfiguration_r9_t **mcch_message=&UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]; + MBSFNAreaConfiguration_r9_t** mcch_message=&UE_rrc_inst[ctxt_pP->module_id].mcch_message[eNB_index]; asn_dec_rval_t dec_rval; - if (UE_rrc_inst[ue_mod_idP].Info[eNB_index].MCCHStatus[mbsfn_sync_area] == 1) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].MCCHStatus[mbsfn_sync_area] == 1) { LOG_D(RRC,"[UE %d] Frame %d: MCCH MESSAGE for MBSFN sync area %d has been already received!\n", - ue_mod_idP, frameP, mbsfn_sync_area); + ctxt_pP->module_id, + ctxt_pP->frame, + mbsfn_sync_area); return 0; // avoid decoding to prevent memory bloating } else { dec_rval = uper_decode_complete(NULL, @@ -2941,7 +3219,9 @@ decode_MCCH_Message( Sdu_len); if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { - LOG_E(RRC,"[UE %d] Failed to decode MCCH__MESSAGE (%d bits)\n",ue_mod_idP,dec_rval.consumed); + LOG_E(RRC,"[UE %d] Failed to decode MCCH__MESSAGE (%d bits)\n", + ctxt_pP->module_id, + dec_rval.consumed); //free the memory SEQUENCE_free(&asn_DEF_MCCH_Message, (void*)mcch, 1); return -1; @@ -2952,7 +3232,8 @@ decode_MCCH_Message( #endif if (mcch->message.present == MCCH_MessageType_PR_c1) { - LOG_D(RRC,"[UE %d] Found mcch message \n",ue_mod_idP); + LOG_D(RRC,"[UE %d] Found mcch message \n", + ctxt_pP->module_id); if(mcch->message.choice.c1.present == MCCH_MessageType__c1_PR_mbsfnAreaConfiguration_r9) { /* @@ -2960,8 +3241,15 @@ decode_MCCH_Message( (void*)&mcch->message.choice.c1.choice.mbsfnAreaConfiguration_r9, sizeof(MBSFNAreaConfiguration_r9_t)); */ *mcch_message = &mcch->message.choice.c1.choice.mbsfnAreaConfiguration_r9; - LOG_I(RRC,"[UE %d] Frame %d : Found MBSFNAreaConfiguration from eNB %d \n",ue_mod_idP, frameP, eNB_index); - decode_MBSFNAreaConfiguration(ue_mod_idP,eNB_index,frameP, mbsfn_sync_area); + LOG_I(RRC,"[UE %d] Frame %d : Found MBSFNAreaConfiguration from eNB %d \n", + ctxt_pP->module_id, + ctxt_pP->frame, + eNB_index); + decode_MBSFNAreaConfiguration( + ctxt_pP->module_id, + eNB_index, + ctxt_pP->frame, + mbsfn_sync_area); } } @@ -2970,6 +3258,7 @@ decode_MCCH_Message( return 0; } +//----------------------------------------------------------------------------- void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, @@ -2977,6 +3266,7 @@ decode_MBSFNAreaConfiguration( frame_t frameP, uint8_t mbsfn_sync_area ) +//----------------------------------------------------------------------------- { protocol_ctxt_t ctxt; @@ -3018,10 +3308,7 @@ decode_MBSFNAreaConfiguration( UE_rrc_inst[ue_mod_idP].Info[eNB_index].MCCHStatus[mbsfn_sync_area] = 1; - ctxt.enb_module_id = eNB_index; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_NO; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_idP, ENB_FLAG_NO, UE_rrc_inst[ue_mod_idP].Info[eNB_index].rnti, frameP, 0); // Config Radio Bearer for MBMS user data (similar way to configure for eNB side in init_MBMS function) rrc_pdcp_config_asn1_req(&ctxt, @@ -3056,10 +3343,12 @@ EXPORT_SYMBOL(Rlc_info_am_config); #endif #if defined(ENABLE_ITTI) +//----------------------------------------------------------------------------- void *rrc_ue_task( void *args_p ) +//----------------------------------------------------------------------------- { MessageDef *msg_p; const char *msg_name; @@ -3068,6 +3357,7 @@ void int result; SRB_INFO *srb_info_p; + protocol_ctxt_t ctxt; itti_mark_task_ready (TASK_RRC_UE); while(1) { @@ -3076,7 +3366,7 @@ void msg_name = ITTI_MSG_NAME (msg_p); instance = ITTI_MSG_INSTANCE (msg_p); - ue_mod_id = instance - NB_eNB_INST; + ue_mod_id = UE_INSTANCE_TO_MODULE_ID(instance); switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: @@ -3094,8 +3384,9 @@ void UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N310_cnt = 0; - if (UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].T310_active == 1) + if (UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].T310_active == 1) { UE_rrc_inst[ue_mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N311_cnt++; + } break; @@ -3110,10 +3401,13 @@ void LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name, RRC_MAC_BCCH_DATA_IND (msg_p).frame, RRC_MAC_BCCH_DATA_IND (msg_p).enb_index); - decode_BCCH_DLSCH_Message (ue_mod_id, RRC_MAC_BCCH_DATA_IND (msg_p).frame, - RRC_MAC_BCCH_DATA_IND (msg_p).enb_index, RRC_MAC_BCCH_DATA_IND (msg_p).sdu, + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, NOT_A_RNTI, RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0); + decode_BCCH_DLSCH_Message (&ctxt, + RRC_MAC_BCCH_DATA_IND (msg_p).enb_index, + RRC_MAC_BCCH_DATA_IND (msg_p).sdu, RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size, - RRC_MAC_BCCH_DATA_IND (msg_p).rsrq, RRC_MAC_BCCH_DATA_IND (msg_p).rsrp); + RRC_MAC_BCCH_DATA_IND (msg_p).rsrq, + RRC_MAC_BCCH_DATA_IND (msg_p).rsrp); break; case RRC_MAC_CCCH_DATA_CNF: @@ -3125,15 +3419,21 @@ void break; case RRC_MAC_CCCH_DATA_IND: - LOG_I(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name, - RRC_MAC_CCCH_DATA_IND (msg_p).frame, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index); + LOG_I(RRC, "[UE %d] RNTI %x Received %s: frameP %d, eNB %d\n", + ue_mod_id, + RRC_MAC_CCCH_DATA_IND (msg_p).rnti, + msg_name, + RRC_MAC_CCCH_DATA_IND (msg_p).frame, + RRC_MAC_CCCH_DATA_IND (msg_p).enb_index); srb_info_p = &UE_rrc_inst[ue_mod_id].Srb0[RRC_MAC_CCCH_DATA_IND (msg_p).enb_index]; memcpy (srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND (msg_p).sdu, RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size); srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size; - rrc_ue_decode_ccch (ue_mod_id, RRC_MAC_CCCH_DATA_IND (msg_p).frame, srb_info_p, + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, RRC_MAC_CCCH_DATA_IND (msg_p).rnti, RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0); + rrc_ue_decode_ccch (&ctxt, + srb_info_p, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index); break; @@ -3143,21 +3443,36 @@ void LOG_I(RRC, "[UE %d] Received %s: frameP %d, eNB %d, mbsfn SA %d\n", ue_mod_id, msg_name, RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area); - decode_MCCH_Message (ue_mod_id, RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, - RRC_MAC_MCCH_DATA_IND (msg_p).sdu, RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size, + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, M_RNTI, RRC_MAC_MCCH_DATA_IND (msg_p).frame, 0); + decode_MCCH_Message ( + &ctxt, + RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, + RRC_MAC_MCCH_DATA_IND (msg_p).sdu, + RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area); break; # endif /* PDCP messages */ case RRC_DCCH_DATA_IND: - LOG_I(RRC, "[UE %d] Received %s: frameP %d, DCCH %d, eNB %d\n", ue_mod_id, msg_name, - RRC_DCCH_DATA_IND (msg_p).frame, RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).eNB_index); - - rrc_ue_decode_dcch (ue_mod_id, RRC_DCCH_DATA_IND (msg_p).frame, - RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).sdu_p, + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, RRC_DCCH_DATA_IND (msg_p).module_id, ENB_FLAG_NO, RRC_DCCH_DATA_IND (msg_p).rnti, RRC_DCCH_DATA_IND (msg_p).frame, 0); + LOG_I(RRC, "[UE %d] Received %s: frameP %d, DCCH %d, eNB %d\n", + RRC_DCCH_DATA_IND (msg_p).module_id, + msg_name, + RRC_DCCH_DATA_IND (msg_p).frame, + RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).eNB_index); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"Received %s DCCH %d, eNB %d", + PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt), + msg_name, + RRC_DCCH_DATA_IND (msg_p).dcch_index, + RRC_DCCH_DATA_IND (msg_p).eNB_index); + rrc_ue_decode_dcch ( + &ctxt, + RRC_DCCH_DATA_IND (msg_p).dcch_index, + RRC_DCCH_DATA_IND (msg_p).sdu_p, + RRC_DCCH_DATA_IND (msg_p).eNB_index); // Message buffer has been processed, free it now. result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND (msg_p).sdu_p); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); @@ -3190,7 +3505,7 @@ void message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE); - itti_send_msg_to_task(TASK_L2L1, NB_eNB_INST + ue_mod_id, message_p); + itti_send_msg_to_task(TASK_L2L1, UE_MODULE_ID_TO_INSTANCE(ue_mod_id), message_p); rrc_set_state (ue_mod_id, RRC_STATE_IDLE); /* Fall through to next case */ @@ -3205,7 +3520,7 @@ void PHY_FIND_CELL_REQ (message_p).earfcn_start = 1; PHY_FIND_CELL_REQ (message_p).earfcn_end = 1; - itti_send_msg_to_task(TASK_PHY_UE, NB_eNB_INST + ue_mod_id, message_p); + itti_send_msg_to_task(TASK_PHY_UE, UE_MODULE_ID_TO_INSTANCE(ue_mod_id), message_p); rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_SEARCHING); break; @@ -3227,12 +3542,13 @@ void LOG_I(RRC, "[UE %d] Received %s: cause %d, type %d, s_tmsi %d, plmnID %d\n", ue_mod_id, msg_name, NAS_CONN_ESTABLI_REQ (msg_p).cause, NAS_CONN_ESTABLI_REQ (msg_p).type, NAS_CONN_ESTABLI_REQ (msg_p).s_tmsi, NAS_CONN_ESTABLI_REQ (msg_p).plmnID); + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, NOT_A_RNTI, 0, 0); UE_rrc_inst[ue_mod_id].initialNasMsg = NAS_CONN_ESTABLI_REQ (msg_p).initialNasMsg; switch (rrc_get_state(ue_mod_id)) { case RRC_STATE_IDLE: { if (rrc_get_sub_state(ue_mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) { - rrc_ue_generate_RRCConnectionRequest(ue_mod_id, 0 /* TODO put frameP number ! */, 0); + rrc_ue_generate_RRCConnectionRequest(&ctxt, 0); LOG_I(RRC, "not sending connection request\n"); rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_CONNECTING); @@ -3264,7 +3580,13 @@ void length = do_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data); /* Transfer data to PDCP */ - pdcp_rrc_data_req (0, ue_mod_id, 0 /* TODO put frameP number ! */, 0, DCCH, rrc_mui++, 0, length, buffer, 1); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0); + pdcp_rrc_data_req (&ctxt, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + length, buffer, + PDCP_TRANSMISSION_MODE_CONTROL); break; } @@ -3399,6 +3721,9 @@ void switch (rrc_get_state(ue_mod_id)) { case RRC_STATE_IDLE: { if (rrc_get_sub_state(ue_mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) { + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0); + rrc_ue_generate_RRCConnectionRequest(&ctxt, 0); + LOG_I(RRC, "not sending connection request\n"); rrc_set_sub_state (ue_mod_id, RRC_SUB_STATE_IDLE_CONNECTING); } diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index 182243094ce..1646e4f2426 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -47,6 +47,7 @@ #include "UTIL/LOG/log.h" #include "asn1_msg.h" #include "pdcp.h" +#include "UTIL/LOG/vcd_signal_dumper.h" #ifdef LOCALIZATION #include <sys/time.h> @@ -59,33 +60,45 @@ extern UE_MAC_INST *UE_mac_inst; extern mui_t rrc_eNB_mui; //configure BCCH & CCCH Logical Channels and associated rrc_buffers, configure associated SRBs -void openair_rrc_on(module_id_t Mod_id, const eNB_flag_t eNB_flag) +//----------------------------------------------------------------------------- +void +openair_rrc_on( + const protocol_ctxt_t* const ctxt_pP +) +//----------------------------------------------------------------------------- { unsigned short i; - if (eNB_flag == 1) { - LOG_I(RRC, "[eNB %d] OPENAIR RRC IN....\n", Mod_id); - - rrc_config_buffer (&eNB_rrc_inst[Mod_id].SI, BCCH, 1); - eNB_rrc_inst[Mod_id].SI.Active = 1; - rrc_config_buffer (&eNB_rrc_inst[Mod_id].Srb0, CCCH, 1); - eNB_rrc_inst[Mod_id].Srb0.Active = 1; + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" OPENAIR RRC IN....\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + rrc_config_buffer (&eNB_rrc_inst[ctxt_pP->module_id].SI, BCCH, 1); + eNB_rrc_inst[ctxt_pP->module_id].SI.Active = 1; + rrc_config_buffer (&eNB_rrc_inst[ctxt_pP->module_id].Srb0, CCCH, 1); + eNB_rrc_inst[ctxt_pP->module_id].Srb0.Active = 1; } else { - LOG_I(RRC, "[UE %d] OPENAIR RRC IN....\n", Mod_id); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" OPENAIR RRC IN....\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); for (i = 0; i < NB_eNB_INST; i++) { - LOG_D(RRC, "[RRC][UE %d] Activating CCCH (eNB %d)\n", Mod_id, i); - UE_rrc_inst[Mod_id].Srb0[i].Srb_id = CCCH; - memcpy (&UE_rrc_inst[Mod_id].Srb0[i].Lchan_desc[0], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - memcpy (&UE_rrc_inst[Mod_id].Srb0[i].Lchan_desc[1], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - rrc_config_buffer (&UE_rrc_inst[Mod_id].Srb0[i], CCCH, 1); - UE_rrc_inst[Mod_id].Srb0[i].Active = 1; + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" Activating CCCH (eNB %d)\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), i); + UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Srb_id = CCCH; + memcpy (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Lchan_desc[0], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE); + memcpy (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Lchan_desc[1], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE); + rrc_config_buffer (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i], CCCH, 1); + UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Active = 1; } } } -int rrc_init_global_param(void) +//----------------------------------------------------------------------------- +int +rrc_init_global_param( + void +) +//----------------------------------------------------------------------------- { //#ifdef USER_MODE @@ -144,8 +157,9 @@ int rrc_init_global_param(void) Rlc_info_am_config.rlc.rlc_am_info.t_status_prohibit = 10; #ifndef NO_RRM - if (L3_xface_init ()) + if (L3_xface_init ()) { return (-1); + } #endif @@ -153,10 +167,13 @@ int rrc_init_global_param(void) } #ifndef NO_RRM -/*------------------------------------------------------------------------------*/ -int L3_xface_init(void) +//----------------------------------------------------------------------------- +int +L3_xface_init( + void +) +//----------------------------------------------------------------------------- { - /*------------------------------------------------------------------------------*/ int ret = 0; @@ -165,8 +182,9 @@ int L3_xface_init(void) int sock; LOG_D(RRC, "[L3_XFACE] init de l'interface \n"); - if (open_socket (&S_rrc, RRC_RRM_SOCK_PATH, RRM_RRC_SOCK_PATH, 0) == -1) + if (open_socket (&S_rrc, RRC_RRM_SOCK_PATH, RRM_RRC_SOCK_PATH, 0) == -1) { return (-1); + } if (S_rrc.s == -1) { return (-1); @@ -182,7 +200,6 @@ int L3_xface_init(void) if (ret < 0) { msg("[openair][MAC][INIT] Cannot create RRC2RRM fifo %d (ERROR %d)\n",RRC2RRM_FIFO,ret); - return(-1); } else { msg("[openair][MAC][INIT] Created RRC2RRM fifo %d\n",RRC2RRM_FIFO); @@ -193,7 +210,6 @@ int L3_xface_init(void) if (ret < 0) { msg("[openair][MAC][INIT] Cannot create RRM2RRC fifo %d (ERROR %d)\n",RRM2RRC_FIFO,ret); - return(-1); } else { msg("[openair][MAC][INIT] Created RRC2RRM fifo %d\n",RRM2RRC_FIFO); @@ -206,7 +222,14 @@ int L3_xface_init(void) } #endif -void rrc_config_buffer(SRB_INFO *Srb_info, uint8_t Lchan_type, uint8_t Role) +//----------------------------------------------------------------------------- +void +rrc_config_buffer( + SRB_INFO* Srb_info, + uint8_t Lchan_type, + uint8_t Role +) +//----------------------------------------------------------------------------- { Srb_info->Rx_buffer.payload_size = 0; @@ -214,9 +237,15 @@ void rrc_config_buffer(SRB_INFO *Srb_info, uint8_t Lchan_type, uint8_t Role) } /*------------------------------------------------------------------------------*/ -void openair_rrc_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active,uint8_t HO_active) +void +openair_rrc_top_init( + int eMBMS_active, + char* uecap_xer, + uint8_t cba_group_active, + uint8_t HO_active +) +//----------------------------------------------------------------------------- { - /*-----------------------------------------------------------------------------*/ module_id_t module_id; OAI_UECapability_t *UECap = NULL; @@ -246,8 +275,9 @@ void openair_rrc_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_a } #endif - } else + } else { UE_rrc_inst = NULL; + } if (NB_eNB_INST > 0) { eNB_rrc_inst = (eNB_RRC_INST*) malloc16(NB_eNB_INST*sizeof(eNB_RRC_INST)); @@ -288,8 +318,9 @@ void openair_rrc_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_a #endif LOG_D(RRC, "ALLOCATE %d Bytes for eNB_RRC_INST @ %p\n", (unsigned int)(NB_eNB_INST*sizeof(eNB_RRC_INST)), eNB_rrc_inst); - } else + } else { eNB_rrc_inst = NULL; + } #ifndef NO_RRM #ifndef USER_MODE @@ -305,212 +336,252 @@ void openair_rrc_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_a #endif //USER_MODE } -void rrc_top_cleanup(void) +//----------------------------------------------------------------------------- +void +rrc_top_cleanup( + void +) +//----------------------------------------------------------------------------- { - if (NB_UE_INST > 0) + if (NB_UE_INST > 0) { free (UE_rrc_inst); + } - if (NB_eNB_INST > 0) + if (NB_eNB_INST > 0) { free (eNB_rrc_inst); + } } -void rrc_t310_expiration(const frame_t frameP, uint8_t Mod_id, uint8_t eNB_index) +//----------------------------------------------------------------------------- +void +rrc_t310_expiration( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index +) +//----------------------------------------------------------------------------- { - protocol_ctxt_t ctxt; - - ctxt.enb_module_id = eNB_index; - ctxt.ue_module_id = Mod_id; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_NO; - - if (UE_rrc_inst[Mod_id].Info[eNB_index].State != RRC_CONNECTED) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State != RRC_CONNECTED) { LOG_D(RRC, "Timer 310 expired, going to RRC_IDLE\n"); - UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_IDLE; - UE_rrc_inst[Mod_id].Info[eNB_index].UE_index = 0xffff; - - UE_rrc_inst[Mod_id].Srb0[eNB_index].Rx_buffer.payload_size = 0; - UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size = 0; - - UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Rx_buffer.payload_size = 0; - UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size = 0; - - if (UE_rrc_inst[Mod_id].Srb2[eNB_index].Active == 1) { - msg ("[RRC Inst %d] eNB_index %d, Remove RB %d\n ", Mod_id, eNB_index, - UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id); - rrc_pdcp_config_req (&ctxt, + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_IDLE; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].UE_index = 0xffff; + UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Rx_buffer.payload_size = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb1[eNB_index].Srb_info.Rx_buffer.payload_size = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size = 0; + + if (UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active == 1) { + msg ("[RRC Inst %d] eNB_index %d, Remove RB %d\n ", ctxt_pP->module_id, eNB_index, + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id); + rrc_pdcp_config_req (ctxt_pP, SRB_FLAG_YES, CONFIG_ACTION_REMOVE, - UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id, + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id, 0); - rrc_rlc_config_req (&ctxt, + rrc_rlc_config_req (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, CONFIG_ACTION_REMOVE, - UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id, + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id, Rlc_info_um); - UE_rrc_inst[Mod_id].Srb2[eNB_index].Active = 0; - UE_rrc_inst[Mod_id].Srb2[eNB_index].Status = IDLE; - UE_rrc_inst[Mod_id].Srb2[eNB_index].Next_check_frame = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Status = IDLE; + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Next_check_frame = 0; } } else { // Restablishment procedure LOG_D(RRC, "Timer 310 expired, trying RRCRestablishment ...\n"); } } -RRC_status_t rrc_rx_tx(uint8_t Mod_id, const frame_t frameP, const eNB_flag_t eNB_flagP,uint8_t index,int CC_id) +//----------------------------------------------------------------------------- +RRC_status_t +rrc_rx_tx( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t enb_indexP, + const int CC_id +) +//----------------------------------------------------------------------------- { + uint8_t UE_id; + int32_t current_timestamp_ms, ref_timestamp_ms; + struct timeval ts; +#ifdef LOCALIZATION + double estimated_distance; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + protocol_ctxt_t ctxt; +#endif + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN); - if(eNB_flagP == 0) { + if(ctxt_pP->enb_flag == ENB_FLAG_NO) { // check timers - if (UE_rrc_inst[Mod_id].Info[index].T300_active == 1) { - if ((UE_rrc_inst[Mod_id].Info[index].T300_cnt % 10) == 0) + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_active == 1) { + if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt % 10) == 0) LOG_D(RRC, - "[UE %d][RAPROC] Frame %d T300 Count %d ms\n", Mod_id, frameP, UE_rrc_inst[Mod_id].Info[index].T300_cnt); + "[UE %d][RAPROC] Frame %d T300 Count %d ms\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt); - if (UE_rrc_inst[Mod_id].Info[index].T300_cnt - == T300[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.t300]) { - UE_rrc_inst[Mod_id].Info[index].T300_active = 0; + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt + == T300[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.t300]) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_active = 0; // ALLOW CCCH to be used - UE_rrc_inst[Mod_id].Srb0[index].Tx_buffer.payload_size = 0; - rrc_ue_generate_RRCConnectionRequest (Mod_id, frameP, index); + UE_rrc_inst[ctxt_pP->module_id].Srb0[enb_indexP].Tx_buffer.payload_size = 0; + rrc_ue_generate_RRCConnectionRequest (ctxt_pP, enb_indexP); + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); return (RRC_ConnSetup_failed); } - UE_rrc_inst[Mod_id].Info[index].T300_cnt++; + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt++; } - if (UE_rrc_inst[Mod_id].sib2[index]) { - if (UE_rrc_inst[Mod_id].Info[index].N310_cnt - == N310[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.n310]) { - UE_rrc_inst[Mod_id].Info[index].T310_active = 1; + if (UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt + == N310[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.n310]) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 1; } } else { // in case we have not received SIB2 yet - if (UE_rrc_inst[Mod_id].Info[index].N310_cnt == 100) { - UE_rrc_inst[Mod_id].Info[index].N310_cnt = 0; + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt == 100) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt = 0; + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); return RRC_PHY_RESYNCH; } } - if (UE_rrc_inst[Mod_id].Info[index].T310_active == 1) { - if (UE_rrc_inst[Mod_id].Info[index].N311_cnt - == N311[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.n311]) { - UE_rrc_inst[Mod_id].Info[index].T310_active = 0; - UE_rrc_inst[Mod_id].Info[index].N311_cnt = 0; + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active == 1) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N311_cnt + == N311[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.n311]) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 0; + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N311_cnt = 0; } - if ((UE_rrc_inst[Mod_id].Info[index].T310_cnt % 10) == 0) - LOG_D(RRC, "[UE %d] Frame %d T310 Count %d ms\n", Mod_id, frameP, UE_rrc_inst[Mod_id].Info[index].T310_cnt); + if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt % 10) == 0) { + LOG_D(RRC, "[UE %d] Frame %d T310 Count %d ms\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt); + } - if (UE_rrc_inst[Mod_id].Info[index].T310_cnt == T310[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.t310]) { - UE_rrc_inst[Mod_id].Info[index].T310_active = 0; - rrc_t310_expiration (frameP, Mod_id, index); + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt == T310[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.t310]) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 0; + rrc_t310_expiration (ctxt_pP, enb_indexP); + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); return (RRC_PHY_RESYNCH); } - UE_rrc_inst[Mod_id].Info[index].T310_cnt++; + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt++; } + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_active==1) { + if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt % 10) == 0) + LOG_D(RRC,"[UE %d][RAPROC] Frame %d T304 Count %d ms\n",ctxt_pP->module_id,ctxt_pP->frame, + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt); - if (UE_rrc_inst[Mod_id].Info[index].T304_active==1) { - if ((UE_rrc_inst[Mod_id].Info[index].T304_cnt % 10) == 0) - LOG_D(RRC,"[UE %d][RAPROC] Frame %d T304 Count %d ms\n",Mod_id,frameP, - UE_rrc_inst[Mod_id].Info[index].T304_cnt); - - if (UE_rrc_inst[Mod_id].Info[index].T304_cnt == 0) { - UE_rrc_inst[Mod_id].Info[index].T304_active = 0; - UE_rrc_inst[Mod_id].HandoverInfoUe.measFlag = 1; + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt == 0) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_active = 0; + UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; LOG_E(RRC,"[UE %d] Handover failure..initiating connection re-establishment procedure... \n"); //Implement 36.331, section 5.3.5.6 here + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); return(RRC_Handover_failed); } - UE_rrc_inst[Mod_id].Info[index].T304_cnt--; + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt--; } // Layer 3 filtering of RRC measurements - if (UE_rrc_inst[Mod_id].QuantityConfig[0] != NULL) { - ue_meas_filtering(Mod_id,frameP,index); + if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0] != NULL) { + ue_meas_filtering(ctxt_pP,enb_indexP); } - ue_measurement_report_triggering(Mod_id,frameP,index); + ue_measurement_report_triggering(ctxt_pP,enb_indexP); - if (UE_rrc_inst[Mod_id].Info[0].handoverTarget > 0) - LOG_I(RRC,"[UE %d] Frame %d : RRC handover initiated\n", Mod_id, frameP); + if (UE_rrc_inst[ctxt_pP->module_id].Info[0].handoverTarget > 0) { + LOG_I(RRC,"[UE %d] Frame %d : RRC handover initiated\n", ctxt_pP->module_id, ctxt_pP->frame); + } - if((UE_rrc_inst[Mod_id].Info[index].State == RRC_HO_EXECUTION) && - (UE_rrc_inst[Mod_id].HandoverInfoUe.targetCellId != 0xFF)) { - UE_rrc_inst[Mod_id].Info[index].State= RRC_IDLE; + if((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].State == RRC_HO_EXECUTION) && + (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId != 0xFF)) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].State= RRC_IDLE; + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); return(RRC_HO_STARTED); } } else { // eNB - check_handovers(Mod_id,frameP); + check_handovers(ctxt_pP); // counetr, and get the value and aggregate #ifdef LOCALIZATION - int32_t current_timestamp_ms, ref_timestamp_ms; - struct timeval ts; /* for the localization, only primary CC_id might be relevant*/ gettimeofday(&ts, NULL); current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; - - ref_timestamp_ms = eNB_rrc_inst[Mod_id].reference_timestamp_ms; - - for (uint8_t UE_id=0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - - if ((current_timestamp_ms - ref_timestamp_ms > eNB_rrc_inst[Mod_id].aggregation_period_ms) && - rrc_get_estimated_ue_distance(Mod_id,frameP,UE_id, CC_id,eNB_rrc_inst[Mod_id].loc_type) != -1) { + ref_timestamp_ms = eNB_rrc_inst[ctxt_pP->module_id].reference_timestamp_ms; + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) { + ctxt = *ctxt_pP; + ctxt.rnti = ue_context_p->ue_context.rnti; + estimated_distance = rrc_get_estimated_ue_distance( + &ctxt, + CC_id, + eNB_rrc_inst[ctxt_pP->module_id].loc_type); + + if ((current_timestamp_ms - ref_timestamp_ms > eNB_rrc_inst[ctxt_pP->module_id].aggregation_period_ms) && + estimated_distance != -1) { LOG_D(LOCALIZE, " RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n", - UE_id, - Mod_id, + ctxt.rnti, + ctxt_pP->module_id, current_timestamp_ms, - frameP, - rrc_get_estimated_ue_distance(Mod_id,frameP,UE_id, CC_id,eNB_rrc_inst[Mod_id].loc_type)); - LOG_D(LOCALIZE, " RRC status %d\n", eNB_rrc_inst[Mod_id].Info.UE[UE_id].Status); - push_front(&eNB_rrc_inst[Mod_id].loc_list, - rrc_get_estimated_ue_distance(Mod_id,frameP,UE_id, CC_id,eNB_rrc_inst[Mod_id].loc_type)); - eNB_rrc_inst[Mod_id].reference_timestamp_ms = current_timestamp_ms; + ctxt_pP->frame, + estimated_distance); + LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.Status); + push_front(&eNB_rrc_inst[ctxt_pP->module_id].loc_list, + estimated_distance); + eNB_rrc_inst[ctxt_pP->module_id].reference_timestamp_ms = current_timestamp_ms; } } #endif } + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); return (RRC_OK); } -long binary_search_int(int elements[], long numElem, int value) +//----------------------------------------------------------------------------- +long +binary_search_int( + int elements[], + long numElem, + int value +) +//----------------------------------------------------------------------------- { long first, last, middle, search = -1; first = 0; last = numElem-1; middle = (first+last)/2; - if(value < elements[0]) + if(value < elements[0]) { return first; + } - if(value > elements[last]) + if(value > elements[last]) { return last; + } while (first <= last) { - if (elements[middle] < value) + if (elements[middle] < value) { first = middle+1; - else if (elements[middle] == value) { + } else if (elements[middle] == value) { search = middle+1; break; - } else + } else { last = middle -1; + } middle = (first+last)/2; } - if (first > last) + if (first > last) { LOG_E(RRC,"Error in binary search!"); + } return search; } @@ -519,30 +590,41 @@ long binary_search_int(int elements[], long numElem, int value) point numbers and returns the index of the range the value lies in Used for RSRP and RSRQ measurement mapping. Can potentially be used for other things */ -long binary_search_float(float elements[], long numElem, float value) +//----------------------------------------------------------------------------- +long +binary_search_float( + float elements[], + long numElem, + float value +) +//----------------------------------------------------------------------------- { long first, last, middle; first = 0; last = numElem-1; middle = (first+last)/2; - if(value <= elements[0]) + if(value <= elements[0]) { return first; + } - if(value >= elements[last]) + if(value >= elements[last]) { return last; + } while (last - first > 1) { - if (elements[middle] > value) + if (elements[middle] > value) { last = middle; - else + } else { first = middle; + } middle = (first+last)/2; } - if (first < 0 || first >= numElem) + if (first < 0 || first >= numElem) { LOG_E(RRC,"\n Error in binary search float!"); + } return first; } diff --git a/openair2/RRC/LITE/rrc_config.c b/openair2/RRC/LITE/rrc_config.c index 3da8bd55a84..e33c2a71b9b 100644 --- a/openair2/RRC/LITE/rrc_config.c +++ b/openair2/RRC/LITE/rrc_config.c @@ -292,18 +292,21 @@ void rrc_config_req(Instance_t Mod_id, void *smsg, unsigned char Action,Transact Mac_rlc_xface->rrc_rlc_config_req(Mod_id,CONFIG_ACTION_ADD,Idx,RADIO_ACCESS_BEARER,Rlc_info_um); CH_rrc_inst[Mod_id].IP_addr_type = p->L3_info_t; - if(CH_rrc_inst[Mod_id].IP_addr_type == IPv4_ADDR) + if(CH_rrc_inst[Mod_id].IP_addr_type == IPv4_ADDR) { memcpy(CH_rrc_inst[Mod_id].IP_addr,p->L3_info,4); - else + } else { memcpy(CH_rrc_inst[Mod_id].IP_addr,p->L3_info,16); - } else + } + } else { Mac_rlc_xface->rrc_rlc_config_req(Mod_id,CONFIG_ACTION_ADD,Idx,RADIO_ACCESS_BEARER,Rlc_info_am_config); + } } - if(p->Lchan_desc.Lchan_t==DTCH) + if(p->Lchan_desc.Lchan_t==DTCH) { send_msg(&S_rrc,msg_rrc_rb_establish_cfm(Mod_id,Idx,0,Trans_id)); - else + } else { send_msg(&S_rrc,msg_rrc_rb_establish_cfm(Mod_id,Idx,1,Trans_id)); + } } break; diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 7ce60573a0f..1a605e21266 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -59,6 +59,11 @@ #include "HandoverCommand.h" #include "rlc.h" #include "SIMULATION/ETH_TRANSPORT/extern.h" +#include "rrc_eNB_UE_context.h" +#include "platform_types.h" +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif //#ifdef Rel10 #include "MeasResults.h" @@ -102,27 +107,27 @@ extern EMULATION_VARS *Emul_vars; extern eNB_MAC_INST *eNB_mac_inst; extern UE_MAC_INST *UE_mac_inst; #ifdef BIGPHYSAREA -extern void *bigphys_malloc( - int); +extern void* bigphys_malloc(int); #endif extern uint16_t two_tier_hexagonal_cellIds[7]; -extern inline unsigned int taus( - void); +extern inline unsigned int taus(void); /* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */ static const uint8_t RRC_TRANSACTION_IDENTIFIER_NUMBER = 4; mui_t rrc_eNB_mui = 0; -/*------------------------------------------------------------------------------*/ -static void init_SI( - module_id_t enb_mod_idP +//----------------------------------------------------------------------------- +static void +init_SI( + const protocol_ctxt_t* const ctxt_pP #if defined(ENABLE_ITTI) , RrcConfigurationReq * configuration #endif ) +//----------------------------------------------------------------------------- { uint8_t SIwindowsize = 1; uint16_t SIperiod = 8; @@ -174,10 +179,9 @@ static void init_SI( exit(-1); */ - eNB_rrc_inst[enb_mod_idP].sizeof_SIB1 = 0; - eNB_rrc_inst[enb_mod_idP].sizeof_SIB23 = 0; - - eNB_rrc_inst[enb_mod_idP].SIB1 = (uint8_t *) malloc16(32); + eNB_rrc_inst[ctxt_pP->module_id].sizeof_SIB1 = 0; + eNB_rrc_inst[ctxt_pP->module_id].sizeof_SIB23 = 0; + eNB_rrc_inst[ctxt_pP->module_id].SIB1 = (uint8_t*) malloc16(32); /* printf ("before SIB1 init : Nid_cell %d\n", mac_xface->lte_frame_parms->Nid_cell); @@ -186,16 +190,20 @@ static void init_SI( mac_xface->lte_frame_parms->tdd_config); */ - if (eNB_rrc_inst[enb_mod_idP].SIB1) - eNB_rrc_inst[enb_mod_idP].sizeof_SIB1 = do_SIB1(enb_mod_idP, mac_xface->lte_frame_parms, (uint8_t *) - eNB_rrc_inst[enb_mod_idP].SIB1, - &eNB_rrc_inst[enb_mod_idP].siblock1, &eNB_rrc_inst[enb_mod_idP].sib1 + if (eNB_rrc_inst[ctxt_pP->module_id].SIB1) + eNB_rrc_inst[ctxt_pP->module_id].sizeof_SIB1 = do_SIB1( + ctxt_pP->module_id, + mac_xface->lte_frame_parms, + (uint8_t*)eNB_rrc_inst[ctxt_pP->module_id].SIB1, + &eNB_rrc_inst[ctxt_pP->module_id].siblock1, + &eNB_rrc_inst[ctxt_pP->module_id].sib1 #if defined(ENABLE_ITTI) , configuration #endif ); else { - LOG_E(RRC, "[eNB %d] init_SI: FATAL, no memory for SIB1 allocated\n", enb_mod_idP); + LOG_E(RRC, PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB1 allocated\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); mac_xface->macphy_exit("[RRC][init_SI] FATAL, no memory for SIB1 allocated"); } @@ -205,19 +213,23 @@ static void init_SI( mac_xface->lte_frame_parms->frame_type, mac_xface->lte_frame_parms->tdd_config); */ - if (eNB_rrc_inst[enb_mod_idP].sizeof_SIB1 == 255) + if (eNB_rrc_inst[ctxt_pP->module_id].sizeof_SIB1 == 255) { mac_xface->macphy_exit("[RRC][init_SI] FATAL, eNB_rrc_inst[enb_mod_idP].sizeof_SIB1 == 255"); + } - eNB_rrc_inst[enb_mod_idP].SIB23 = (uint8_t *) malloc16(64); + eNB_rrc_inst[ctxt_pP->module_id].SIB23 = (uint8_t*) malloc16(64); - if (eNB_rrc_inst[enb_mod_idP].SIB23) { - eNB_rrc_inst[enb_mod_idP].sizeof_SIB23 = do_SIB23(enb_mod_idP, + if (eNB_rrc_inst[ctxt_pP->module_id].SIB23) { + eNB_rrc_inst[ctxt_pP->module_id].sizeof_SIB23 = do_SIB23( + ctxt_pP->module_id, mac_xface->lte_frame_parms, - eNB_rrc_inst[enb_mod_idP].SIB23, - &eNB_rrc_inst[enb_mod_idP].systemInformation, - &eNB_rrc_inst[enb_mod_idP].sib2, &eNB_rrc_inst[enb_mod_idP].sib3 + eNB_rrc_inst[ctxt_pP->module_id].SIB23, + &eNB_rrc_inst[ctxt_pP->module_id].systemInformation, + &eNB_rrc_inst[ctxt_pP->module_id].sib2, + &eNB_rrc_inst[ctxt_pP->module_id].sib3 #ifdef Rel10 - , &eNB_rrc_inst[enb_mod_idP].sib13, eNB_rrc_inst[enb_mod_idP].MBMS_flag + , &eNB_rrc_inst[ctxt_pP->module_id].sib13, + eNB_rrc_inst[ctxt_pP->module_id].MBMS_flag #endif #if defined(ENABLE_ITTI) , configuration @@ -225,83 +237,93 @@ static void init_SI( ); /* - eNB_rrc_inst[enb_mod_idP].sizeof_SIB23 = do_SIB2_AT4(enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].SIB23, - &eNB_rrc_inst[enb_mod_idP].systemInformation, - &eNB_rrc_inst[enb_mod_idP].sib2, + eNB_rrc_inst[ctxt_pP->module_id].sizeof_SIB23 = do_SIB2_AT4(ctxt_pP->module_id, + eNB_rrc_inst[ctxt_pP->module_id].SIB23, + &eNB_rrc_inst[ctxt_pP->module_id].systemInformation, + &eNB_rrc_inst[ctxt_pP->module_id].sib2, #if defined(ENABLE_ITTI) , configuration #endif ); */ - if (eNB_rrc_inst[enb_mod_idP].sizeof_SIB23 == 255) - mac_xface->macphy_exit("[RRC][init_SI] FATAL, eNB_rrc_inst[enb_mod_idP].sizeof_SIB23 == 255"); - - LOG_T(RRC, "[eNB %d] SIB2/3 Contents (partial)\n", enb_mod_idP); - LOG_T(RRC, "[eNB %d] pusch_config_common.n_SB = %ld\n", enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB); - LOG_T(RRC, "[eNB %d] pusch_config_common.hoppingMode = %ld\n", enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); - LOG_T(RRC, "[eNB %d] pusch_config_common.pusch_HoppingOffset = %ld\n", - enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + if (eNB_rrc_inst[ctxt_pP->module_id].sizeof_SIB23 == 255) { + mac_xface->macphy_exit("[RRC][init_SI] FATAL, eNB_rrc_inst[mod].sizeof_SIB23 == 255"); + } + + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" SIB2/3 Contents (partial)\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.n_SB = %ld\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB); + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.hoppingMode = %ld\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.pusch_HoppingOffset = %ld\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. pusch_ConfigBasic.pusch_HoppingOffset); - LOG_T(RRC, "[eNB %d] pusch_config_common.enable64QAM = %d\n", enb_mod_idP, - (int)eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.enable64QAM = %d\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. pusch_ConfigBasic.enable64QAM); - LOG_T(RRC, "[eNB %d] pusch_config_common.groupHoppingEnabled = %d\n", enb_mod_idP, - (int)eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupHoppingEnabled = %d\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. ul_ReferenceSignalsPUSCH.groupHoppingEnabled); - LOG_T(RRC, "[eNB %d] pusch_config_common.groupAssignmentPUSCH = %ld\n", enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH. - groupAssignmentPUSCH); - LOG_T(RRC, "[eNB %d] pusch_config_common.sequenceHoppingEnabled = %d\n", enb_mod_idP, - (int)eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH. - sequenceHoppingEnabled); - LOG_T(RRC, "[eNB %d] pusch_config_common.cyclicShift = %ld\n", enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.cyclicShift); + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupAssignmentPUSCH = %ld\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.sequenceHoppingEnabled = %d\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); + LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.cyclicShift = %ld\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); #ifdef Rel10 - if (eNB_rrc_inst[enb_mod_idP].MBMS_flag > 0) { - for (i = 0; i < eNB_rrc_inst[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.count; i++) { + if (eNB_rrc_inst[ctxt_pP->module_id].MBMS_flag > 0) { + for (i = 0; i < eNB_rrc_inst[ctxt_pP->module_id].sib2->mbsfn_SubframeConfigList->list.count; i++) { // SIB 2 // LOG_D(RRC, "[eNB %d] mbsfn_SubframeConfigList.list.count = %ld\n", enb_mod_idP, eNB_rrc_inst[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.count); - LOG_D(RRC, "[eNB %d] SIB13 contents for MBSFN subframe allocation %d/%d(partial)\n", - enb_mod_idP, i, eNB_rrc_inst[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.count); - LOG_D(RRC, "[eNB %d] mbsfn_Subframe_pattern is = %x\n", enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation. - choice.oneFrame.buf[0] >> 0); - LOG_D(RRC, "[eNB %d] radioframe_allocation_period = %ld (just index number, not the real value)\n", enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod); // need to display the real value, using array of char (like in dumping SIB2) - LOG_D(RRC, "[eNB %d] radioframe_allocation_offset = %ld\n", - enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset); + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN subframe allocation %d/%d(partial)\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + i, + eNB_rrc_inst[ctxt_pP->module_id].sib2->mbsfn_SubframeConfigList->list.count); + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" mbsfn_Subframe_pattern is = %x\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0); + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_period = %ld (just index number, not the real value)\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod); // need to display the real value, using array of char (like in dumping SIB2) + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_offset = %ld\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset); } // SIB13 - for (i = 0; i < eNB_rrc_inst[enb_mod_idP].sib13->mbsfn_AreaInfoList_r9.list.count; i++) { - LOG_D(RRC, "[eNB %d] SIB13 contents for MBSFN sync area %d/2 (partial)\n", - enb_mod_idP, i, eNB_rrc_inst[enb_mod_idP].sib13->mbsfn_AreaInfoList_r9.list.count); - LOG_D(RRC, "[eNB %d] MCCH Repetition Period: %d (just index number, not real value)\n", - enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib13->mbsfn_AreaInfoList_r9.list.array[i]-> - mcch_Config_r9.mcch_RepetitionPeriod_r9); - LOG_D(RRC, "[eNB %d] MCCH Offset: %d\n", enb_mod_idP, - eNB_rrc_inst[enb_mod_idP].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); + for (i = 0; i < eNB_rrc_inst[ctxt_pP->module_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) { + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN sync area %d/2 (partial)\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + i, + eNB_rrc_inst[ctxt_pP->module_id].sib13->mbsfn_AreaInfoList_r9.list.count); + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Repetition Period: %d (just index number, not real value)\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Offset: %d\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); } } #endif LOG_D(RRC, - "[FRAME unknown][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) --->][MAC_UE][MOD %02d][]\n", - enb_mod_idP, enb_mod_idP); - - rrc_mac_config_req(enb_mod_idP, ENB_FLAG_YES, 0, 0, + PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + rrc_mac_config_req(ctxt_pP->module_id, ENB_FLAG_YES, 0, 0, (RadioResourceConfigCommonSIB_t *) & - eNB_rrc_inst[enb_mod_idP].sib2->radioResourceConfigCommon, + eNB_rrc_inst[ctxt_pP->module_id].sib2->radioResourceConfigCommon, (struct PhysicalConfigDedicated *)NULL, #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, @@ -311,34 +333,38 @@ static void init_SI( (MAC_MainConfig_t *) NULL, 0, (struct LogicalChannelConfig *)NULL, (MeasGapConfig_t *) NULL, - eNB_rrc_inst[enb_mod_idP].sib1->tdd_Config, + eNB_rrc_inst[ctxt_pP->module_id].sib1->tdd_Config, NULL, &SIwindowsize, &SIperiod, - eNB_rrc_inst[enb_mod_idP].sib2->freqInfo.ul_CarrierFreq, - eNB_rrc_inst[enb_mod_idP].sib2->freqInfo.ul_Bandwidth, - &eNB_rrc_inst[enb_mod_idP].sib2->freqInfo.additionalSpectrumEmission, - (MBSFN_SubframeConfigList_t *) eNB_rrc_inst[enb_mod_idP].sib2->mbsfn_SubframeConfigList + eNB_rrc_inst[ctxt_pP->module_id].sib2->freqInfo.ul_CarrierFreq, + eNB_rrc_inst[ctxt_pP->module_id].sib2->freqInfo.ul_Bandwidth, + &eNB_rrc_inst[ctxt_pP->module_id].sib2->freqInfo.additionalSpectrumEmission, + (MBSFN_SubframeConfigList_t*) eNB_rrc_inst[ctxt_pP->module_id].sib2->mbsfn_SubframeConfigList #ifdef Rel10 , - eNB_rrc_inst[enb_mod_idP].MBMS_flag, - (MBSFN_AreaInfoList_r9_t *) & eNB_rrc_inst[enb_mod_idP].sib13->mbsfn_AreaInfoList_r9, + eNB_rrc_inst[ctxt_pP->module_id].MBMS_flag, + (MBSFN_AreaInfoList_r9_t*) & eNB_rrc_inst[ctxt_pP->module_id].sib13->mbsfn_AreaInfoList_r9, (PMCH_InfoList_r9_t *) NULL #endif #ifdef CBA - , 0, //eNB_rrc_inst[enb_mod_idP].num_active_cba_groups, - 0 //eNB_rrc_inst[enb_mod_idP].cba_rnti[0] + , 0, //eNB_rrc_inst[ctxt_pP->module_id].num_active_cba_groups, + 0 //eNB_rrc_inst[ctxt_pP->module_id].cba_rnti[0] #endif ); } else { - LOG_E(RRC, "[eNB] init_SI: FATAL, no memory for SIB2/3 allocated\n"); + LOG_E(RRC, PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB2/3 allocated\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); mac_xface->macphy_exit("[RRC][init_SI] FATAL, no memory for SIB2/3 allocated"); } } #ifdef Rel10 /*------------------------------------------------------------------------------*/ -static void init_MCCH( - module_id_t enb_mod_idP) +static void +init_MCCH( + module_id_t enb_mod_idP +) +//----------------------------------------------------------------------------- { int sync_area = 0; @@ -376,10 +402,11 @@ static void init_MCCH( eNB_rrc_inst[enb_mod_idP].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation. choice.oneFrame.buf[0]); - if (eNB_rrc_inst[enb_mod_idP].sizeof_MCCH_MESSAGE[sync_area] == 255) + if (eNB_rrc_inst[enb_mod_idP].sizeof_MCCH_MESSAGE[sync_area] == 255) { mac_xface->macphy_exit("[RRC][init_MCCH] eNB_rrc_inst[enb_mod_idP].sizeof_MCCH_MESSAGE[sync_area] == 255"); - else + } else { eNB_rrc_inst[enb_mod_idP].MCCH_MESS[sync_area].Active = 1; + } } } @@ -419,19 +446,18 @@ static void init_MCCH( } -/*------------------------------------------------------------------------------*/ +//----------------------------------------------------------------------------- static void init_MBMS( module_id_t enb_mod_idP, - frame_t frameP) + frame_t frameP +) +//----------------------------------------------------------------------------- { // init the configuration for MTCH protocol_ctxt_t ctxt; if (eNB_rrc_inst[enb_mod_idP].MBMS_flag > 0) { - ctxt.enb_module_id = enb_mod_idP; - ctxt.ue_module_id = 0; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_YES; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0); LOG_D(RRC, "[eNB %d] Frame %d : Radio Bearer config request for MBMS\n", enb_mod_idP, frameP); //check the lcid // Configuring PDCP and RLC for MBMS Radio Bearer @@ -460,233 +486,457 @@ static void init_MBMS( } #endif -/*------------------------------------------------------------------------------*/ -static void rrc_lite_eNB_init_security( - module_id_t enb_mod_idP, - module_id_t ue_mod_idP) +//----------------------------------------------------------------------------- +uint8_t +rrc_eNB_get_next_transaction_identifier( + module_id_t enb_mod_idP +) +//----------------------------------------------------------------------------- { -#if defined(ENABLE_SECURITY) - char ascii_buffer[65]; - uint8_t i; + static uint8_t rrc_transaction_identifier[NUMBER_OF_eNB_MAX]; + rrc_transaction_identifier[enb_mod_idP] = (rrc_transaction_identifier[enb_mod_idP] + 1) % RRC_TRANSACTION_IDENTIFIER_NUMBER; + return rrc_transaction_identifier[enb_mod_idP]; +} +/*------------------------------------------------------------------------------*/ +/* Functions to handle UE index in eNB UE list */ + - memset(eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP], ue_mod_idP, 32); +////----------------------------------------------------------------------------- +//static module_id_t +//rrc_eNB_get_UE_index( +// module_id_t enb_mod_idP, +// uint64_t UE_identity +//) +////----------------------------------------------------------------------------- +//{ +// +// boolean_t reg = FALSE; +// module_id_t i; +// +// AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB index invalid (%d/%d)!", enb_mod_idP, NB_eNB_INST); +// +// for (i = 0; i < NUMBER_OF_UE_MAX; i++) { +// if (eNB_rrc_inst[enb_mod_idP].Info.UE_list[i] == UE_identity) { +// // UE_identity already registered +// reg = TRUE; +// break; +// } +// } +// +// if (reg == FALSE) { +// return (UE_MODULE_INVALID); +// } else +// return (i); +//} + + +//----------------------------------------------------------------------------- +// return a new ue context structure if ue_identityP, ctxt_pP->rnti not found in collection +static struct rrc_eNB_ue_context_s* +rrc_eNB_get_next_free_ue_context( + const protocol_ctxt_t* const ctxt_pP, + const uint64_t ue_identityP +) +//----------------------------------------------------------------------------- +{ + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + ue_context_p = rrc_eNB_get_ue_context( + &eNB_rrc_inst[ctxt_pP->module_id], + ctxt_pP->rnti); + + if (ue_context_p == NULL) { + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) { + if (ue_context_p->ue_context.random_ue_identity == ue_identityP) { + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist rand UE id 0x%x, uid %u\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_identityP, + ue_context_p->local_uid); + return NULL; + } + } + ue_context_p = rrc_eNB_allocate_new_UE_context(&eNB_rrc_inst[ctxt_pP->module_id]); - for (i = 0; i < 32; i++) { - sprintf(&ascii_buffer[2 * i], "%02X", eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP][i]); + if (ue_context_p == NULL) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, no memory\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + return NULL; } - ascii_buffer[2 * i] = '\0'; + ue_context_p->ue_id_rnti = ctxt_pP->rnti; // here ue_id_rnti is just a key, may be something else + ue_context_p->ue_context.rnti = ctxt_pP->rnti; // yes duplicate, 1 may be removed + ue_context_p->ue_context.random_ue_identity = ue_identityP; + RB_INSERT(rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head, ue_context_p); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" Created new UE context uid %u\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p->local_uid); + return ue_context_p; - LOG_T(RRC, "[OSA][eNB %d][UE %d] kenb = %s\n", enb_mod_idP, ue_mod_idP, ascii_buffer); -#endif + } else { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + return NULL; + } } -/*------------------------------------------------------------------------------*/ -uint8_t rrc_eNB_get_next_transaction_identifier( - module_id_t enb_mod_idP) +#if !defined(ENABLE_USE_MME) +void rrc_eNB_emulation_notify_ue_module_id( + const module_id_t ue_module_idP, + const rnti_t rntiP, + const uint8_t cell_identity_byte0P, + const uint8_t cell_identity_byte1P, + const uint8_t cell_identity_byte2P, + const uint8_t cell_identity_byte3P) { - static uint8_t rrc_transaction_identifier[NUMBER_OF_eNB_MAX]; - - rrc_transaction_identifier[enb_mod_idP] = (rrc_transaction_identifier[enb_mod_idP] + 1) % RRC_TRANSACTION_IDENTIFIER_NUMBER; - - return rrc_transaction_identifier[enb_mod_idP]; + module_id_t enb_module_id; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + + // find enb_module_id + for (enb_module_id = 0; enb_module_id < NUMBER_OF_eNB_MAX; enb_module_id++) { + if (eNB_rrc_inst[enb_module_id].sib1 != NULL) { + if ( + (eNB_rrc_inst[enb_module_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[0] == cell_identity_byte0P) && + (eNB_rrc_inst[enb_module_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[1] == cell_identity_byte1P) && + (eNB_rrc_inst[enb_module_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[2] == cell_identity_byte2P) && + (eNB_rrc_inst[enb_module_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[3] == cell_identity_byte3P) + ) { + oai_emulation.info.eNB_ue_module_id_to_rnti[enb_module_id][ue_module_idP] = rntiP; + ue_context_p = rrc_eNB_get_ue_context( + &eNB_rrc_inst[enb_module_id], + rntiP + ); + + if (NULL != ue_context_p) { + oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[enb_module_id][ue_context_p->local_uid] = ue_module_idP; } -/*------------------------------------------------------------------------------*/ -/* Functions to handle UE index in eNB UE list */ + return; + } + } + } + AssertFatal(enb_module_id == NUMBER_OF_eNB_MAX, + "Cell identity not found for ue module id %u rnti %x", + ue_module_idP, rntiP); +} +#endif -static module_id_t -rrc_eNB_get_UE_index( - module_id_t enb_mod_idP, - uint64_t UE_identity +//----------------------------------------------------------------------------- +void +rrc_eNB_free_mem_UE_context( + const protocol_ctxt_t* const ctxt_pP, + struct rrc_eNB_ue_context_s* const ue_context_pP ) +//----------------------------------------------------------------------------- { + int i; + LOG_T(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" Clearing UE context 0x%x (free internal structs)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_pP); +#ifdef Rel10 + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[0]); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[1]); +#endif + + if (ue_context_pP->ue_context.SRB_configList) { + ASN_STRUCT_FREE(asn_DEF_SRB_ToAddModList, ue_context_pP->ue_context.SRB_configList); + ue_context_pP->ue_context.SRB_configList = NULL; + } - boolean_t reg = FALSE; - module_id_t i; + if (ue_context_pP->ue_context.DRB_configList) { + ASN_STRUCT_FREE(asn_DEF_DRB_ToAddModList, ue_context_pP->ue_context.DRB_configList); + ue_context_pP->ue_context.DRB_configList = NULL; + } - AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB index invalid (%d/%d)!", enb_mod_idP, NB_eNB_INST); + memset(ue_context_pP->ue_context.DRB_active, 0, sizeof(ue_context_pP->ue_context.DRB_active)); - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (eNB_rrc_inst[enb_mod_idP].Info.UE_list[i] == UE_identity) { - // UE_identity already registered - reg = TRUE; - break; + if (ue_context_pP->ue_context.physicalConfigDedicated) { + ASN_STRUCT_FREE(asn_DEF_PhysicalConfigDedicated, ue_context_pP->ue_context.physicalConfigDedicated); + ue_context_pP->ue_context.physicalConfigDedicated = NULL; } + if (ue_context_pP->ue_context.sps_Config) { + ASN_STRUCT_FREE(asn_DEF_SPS_Config, ue_context_pP->ue_context.sps_Config); + ue_context_pP->ue_context.sps_Config = NULL; } - if (reg == FALSE) { - return (UE_MODULE_INVALID); - } else - return (i); + for (i=0; i < MAX_MEAS_OBJ; i++) { + if (ue_context_pP->ue_context.MeasObj[i] != NULL) { + ASN_STRUCT_FREE(asn_DEF_MeasObjectToAddMod, ue_context_pP->ue_context.MeasObj[i]); + ue_context_pP->ue_context.MeasObj[i] = NULL; + } } -static module_id_t -rrc_eNB_get_next_free_UE_index( - module_id_t enb_mod_idP, - uint64_t UE_identity -) -{ + for (i=0; i < MAX_MEAS_CONFIG; i++) { + if (ue_context_pP->ue_context.ReportConfig[i] != NULL) { + ASN_STRUCT_FREE(asn_DEF_ReportConfigToAddMod, ue_context_pP->ue_context.ReportConfig[i]); + ue_context_pP->ue_context.ReportConfig[i] = NULL; + } + } - boolean_t reg = FALSE; - module_id_t i, first_index = UE_MODULE_INVALID; + if (ue_context_pP->ue_context.QuantityConfig) { + ASN_STRUCT_FREE(asn_DEF_QuantityConfig, ue_context_pP->ue_context.QuantityConfig); + ue_context_pP->ue_context.QuantityConfig = NULL; + } - LOG_D(RRC,"ENB_ID= %d \n",enb_mod_idP); - LOG_D(RRC,"N_ID= %d \n",NB_eNB_INST); + if (ue_context_pP->ue_context.mac_MainConfig) { + ASN_STRUCT_FREE(asn_DEF_MAC_MainConfig, ue_context_pP->ue_context.mac_MainConfig); + ue_context_pP->ue_context.mac_MainConfig = NULL; + } - AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB index invalid (%d/%d)!", enb_mod_idP, NB_eNB_INST); + if (ue_context_pP->ue_context.measGapConfig) { + ASN_STRUCT_FREE(asn_DEF_MeasGapConfig, ue_context_pP->ue_context.measGapConfig); + ue_context_pP->ue_context.measGapConfig = NULL; + } - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if ((first_index == UE_MODULE_INVALID) && (eNB_rrc_inst[enb_mod_idP].Info.UE_list[i] == 0)) { - first_index = i; // save first free position + //SRB_INFO SI; + //SRB_INFO Srb0; + //SRB_INFO_TABLE_ENTRY Srb1; + //SRB_INFO_TABLE_ENTRY Srb2; + if (ue_context_pP->ue_context.measConfig) { + ASN_STRUCT_FREE(asn_DEF_MeasConfig, ue_context_pP->ue_context.measConfig); + ue_context_pP->ue_context.measConfig = NULL; } - if (eNB_rrc_inst[enb_mod_idP].Info.UE_list[i] == UE_identity) { - // UE_identity already registered - reg = TRUE; - } + if (ue_context_pP->ue_context.measConfig) { + ASN_STRUCT_FREE(asn_DEF_MeasConfig, ue_context_pP->ue_context.measConfig); + ue_context_pP->ue_context.measConfig = NULL; } - if (reg == 0) { - LOG_I(RRC, "[eNB %d] Adding UE %d with identity " PRIu64 "\n", enb_mod_idP, first_index, UE_identity); - return (first_index); - } else - return (UE_MODULE_INVALID); + //HANDOVER_INFO *handover_info; +#if defined(ENABLE_SECURITY) + //uint8_t kenb[32]; +#endif + //e_SecurityAlgorithmConfig__cipheringAlgorithm ciphering_algorithm; + //e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; + //uint8_t Status; + //rnti_t rnti; + //uint64_t random_ue_identity; +#if defined(ENABLE_ITTI) + //UE_S_TMSI Initialue_identity_s_TMSI; + //EstablishmentCause_t establishment_cause; + //ReestablishmentCause_t reestablishment_cause; + //uint16_t ue_initial_id; + //uint32_t eNB_ue_s1ap_id :24; + //security_capabilities_t security_capabilities; + //uint8_t nb_of_e_rabs; + //e_rab_param_t e_rab[S1AP_MAX_E_RAB]; + //uint32_t enb_gtp_teid[S1AP_MAX_E_RAB]; + //transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB]; + //rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB]; +#endif } +//----------------------------------------------------------------------------- +// called by MAC layer only void -rrc_eNB_free_UE_index( - module_id_t enb_mod_idP, - module_id_t ue_mod_idP, - int frameP +rrc_eNB_free_UE( + const module_id_t enb_mod_idP, + const rnti_t rntiP, + const frame_t frameP, + const sub_frame_t subframeP ) +//----------------------------------------------------------------------------- { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; protocol_ctxt_t ctxt; - DRB_ToAddModList_t *DRB_configList = eNB_rrc_inst[enb_mod_idP].DRB_configList[ue_mod_idP]; - SRB_ToAddModList_t *SRB_configList = eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_idP]; - - AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %d!", enb_mod_idP, NB_eNB_INST, ue_mod_idP); - AssertFatal(ue_mod_idP < NUMBER_OF_UE_MAX, "UE inst invalid (%d/%d) for eNB %d!", ue_mod_idP, NUMBER_OF_UE_MAX, - enb_mod_idP); +#if !defined(ENABLE_USE_MME) + module_id_t ue_module_id; +#endif + AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rntiP); + ue_context_p = rrc_eNB_get_ue_context( + &eNB_rrc_inst[enb_mod_idP], + rntiP + ); - LOG_W(RRC, "[eNB %d] Removing UE %d rv 0x%" PRIx64 "\n", enb_mod_idP, ue_mod_idP, - eNB_rrc_inst[enb_mod_idP].Info.UE_list[ue_mod_idP]); + if (NULL != ue_context_p) { + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rntiP, frameP, subframeP); + LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rntiP); #if defined(ENABLE_USE_MME) - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_mod_idP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_p, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before * triggering the S1 UE Context Release Request procedure * in order to allow the UE to perform the NAS recovery * procedure, see TS 23.401 [17]. */ +#else + AssertFatal(ue_context_p->local_uid < NUMBER_OF_UE_MAX, "local_uid invalid (%d<%d) for UE %x!", ue_context_p->local_uid, NUMBER_OF_UE_MAX, rntiP); + ue_module_id = oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[enb_mod_idP][ue_context_p->local_uid]; + AssertFatal(ue_module_id < NUMBER_OF_UE_MAX, "ue_module_id invalid (%d<%d) for UE %x!", ue_module_id, NUMBER_OF_UE_MAX, rntiP); + oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[enb_mod_idP][ue_context_p->local_uid] = -1; + oai_emulation.info.eNB_ue_module_id_to_rnti[enb_mod_idP][ue_module_id] = NOT_A_RNTI; #endif - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_idP].Status = RRC_IDLE; - eNB_rrc_inst[enb_mod_idP].Info.UE_list[ue_mod_idP] = 0; - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_idP].eNB_ue_s1ap_id = 0; - - ctxt.enb_module_id = enb_mod_idP; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_YES; + ue_context_p->ue_context.Status = RRC_IDLE; rrc_rlc_remove_ue(&ctxt); pdcp_remove_UE(&ctxt); - free(eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_idP]); + rrc_eNB_remove_ue_context( + &ctxt, + &eNB_rrc_inst[enb_mod_idP], + ue_context_p); + } } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_process_RRCConnectionSetupComplete( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP, +//----------------------------------------------------------------------------- +void +rrc_eNB_process_RRCConnectionSetupComplete( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, RRCConnectionSetupComplete_r8_IEs_t * rrcConnectionSetupComplete ) +//----------------------------------------------------------------------------- { LOG_I(RRC, - "[eNB %d][RAPROC] Frame %d : Logical Channel UL-DCCH, " "processing RRCConnectionSetupComplete from UE %d\n", - enb_mod_idP, frameP, ue_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing RRCConnectionSetupComplete from UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); #if defined(ENABLE_USE_MME) if (EPC_MODE_ENABLED == 1) { // Forward message to S1AP layer - rrc_eNB_send_S1AP_NAS_FIRST_REQ(enb_mod_idP, ue_mod_idP, rrcConnectionSetupComplete); + rrc_eNB_send_S1AP_NAS_FIRST_REQ( + ctxt_pP, + ue_context_pP, + rrcConnectionSetupComplete); } else #endif { // RRC loop back (no S1AP), send SecurityModeCommand to UE - rrc_eNB_generate_SecurityModeCommand(enb_mod_idP, frameP, ue_mod_idP); + rrc_eNB_generate_SecurityModeCommand( + ctxt_pP, + ue_context_pP); // rrc_eNB_generate_UECapabilityEnquiry(enb_mod_idP,frameP,ue_mod_idP); } } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_generate_SecurityModeCommand( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_SecurityModeCommand( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP ) +//----------------------------------------------------------------------------- { uint8_t buffer[100]; uint8_t size; - size = do_SecurityModeCommand(enb_mod_idP, buffer, ue_mod_idP, rrc_eNB_get_next_transaction_identifier(enb_mod_idP), - eNB_rrc_inst[enb_mod_idP].ciphering_algorithm[ue_mod_idP], - eNB_rrc_inst[enb_mod_idP].integrity_algorithm[ue_mod_idP]); + size = do_SecurityModeCommand( + ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), + ue_context_pP->ue_context.ciphering_algorithm, + ue_context_pP->ue_context.integrity_algorithm); #ifdef RRC_MSG_PRINT uint16_t i=0; LOG_F(RRC,"[MSG] RRC Security Mode Command\n"); - for (i = 0; i < size; i++) + for (i = 0; i < size; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]); + } LOG_F(RRC,"\n"); #endif LOG_I(RRC, - "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d, UE id %d)\n", - enb_mod_idP, frameP, size, ue_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size); LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (securityModeCommand to UE %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frameP, enb_mod_idP, size, ue_mod_idP, rrc_eNB_mui, enb_mod_idP, DCCH); - //rrc_rlc_data_req(enb_mod_idP,frameP, 1,(ue_mod_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req(enb_mod_idP, ue_mod_idP, frameP, 1, DCCH, rrc_eNB_mui++, 0, size, buffer, 1); + PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (securityModeCommand to UE MUI %d) --->[PDCP][RB %02d]\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size, + rrc_eNB_mui, + DCCH); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" securityModeCommand UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); +#endif + pdcp_rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_generate_UECapabilityEnquiry( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP) +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_UECapabilityEnquiry( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +) +//----------------------------------------------------------------------------- { uint8_t buffer[100]; uint8_t size; - size = do_UECapabilityEnquiry(enb_mod_idP, buffer, ue_mod_idP, rrc_eNB_get_next_transaction_identifier(enb_mod_idP)); + size = do_UECapabilityEnquiry( + ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); LOG_I(RRC, - "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate UECapabilityEnquiry (bytes %d, UE id %d)\n", - enb_mod_idP, frameP, size, ue_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate UECapabilityEnquiry (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size); LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (UECapabilityEnquiry to UE %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frameP, enb_mod_idP, size, ue_mod_idP, rrc_eNB_mui, enb_mod_idP, DCCH); - //rrc_rlc_data_req(enb_mod_idP,frameP, 1,(ue_mod_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req(enb_mod_idP, ue_mod_idP, frameP, 1, DCCH, rrc_eNB_mui++, 0, size, buffer, 1); + PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (UECapabilityEnquiry MUI %d) --->[PDCP][RB %02d]\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size, + rrc_eNB_mui, + DCCH); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" rrcUECapabilityEnquiry UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); +#endif + pdcp_rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } -void rrc_eNB_generate_RRCConnectionRelease(module_id_t enb_mod_idP, - frame_t frameP, - ue_id_t ue_idP) +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_RRCConnectionRelease( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +) +//----------------------------------------------------------------------------- { uint8_t buffer[RRC_BUF_SIZE]; @@ -694,44 +944,64 @@ void rrc_eNB_generate_RRCConnectionRelease(module_id_t enb_mod_idP, memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionRelease(enb_mod_idP, buffer,rrc_eNB_get_next_transaction_identifier(enb_mod_idP)); + size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); LOG_I(RRC, - "[eNB %d] Frame %d Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d, UE id %d)\n", - enb_mod_idP, frameP, size, ue_idP); + PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size); LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %u/%u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease to UE %d MUI %d) --->][PDCP][MOD %u/%u][RB %u]\n", - frameP, enb_mod_idP, ue_idP, size, ue_idP, rrc_eNB_mui, enb_mod_idP, ue_idP, DCCH); - //rrc_rlc_data_req(enb_mod_idP,frameP, 1,(ue_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req(enb_mod_idP, ue_idP, frameP, 1, DCCH, rrc_eNB_mui++, 0, size, buffer, 1); + PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size, + rrc_eNB_mui, + DCCH); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" rrcConnectionRelease UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); +#endif + pdcp_rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } -/*------------------------------------------------------------------------------*/ -static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP, - uint8_t ho_state) +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_defaultRRCConnectionReconfiguration( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + const uint8_t ho_state +) +//----------------------------------------------------------------------------- { -#if defined(ENABLE_ITTI) - eNB_RRC_UE_INFO *UE_info = &eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_idP]; -#endif uint8_t buffer[RRC_BUF_SIZE]; uint16_t size; int i; // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE - eNB_RRC_INST *rrc_inst = &eNB_rrc_inst[enb_mod_idP]; - - struct PhysicalConfigDedicated **physicalConfigDedicated = &rrc_inst->physicalConfigDedicated[ue_mod_idP]; + eNB_RRC_INST* rrc_inst = &eNB_rrc_inst[ctxt_pP->module_id]; + struct PhysicalConfigDedicated** physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; struct SRB_ToAddMod *SRB2_config = NULL; struct SRB_ToAddMod__rlc_Config *SRB2_rlc_config = NULL; struct SRB_ToAddMod__logicalChannelConfig *SRB2_lchan_config = NULL; struct LogicalChannelConfig__ul_SpecificParameters *SRB2_ul_SpecificParameters = NULL; - SRB_ToAddModList_t *SRB_configList = rrc_inst->SRB_configList[ue_mod_idP]; + SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; SRB_ToAddModList_t *SRB_configList2 = NULL; struct DRB_ToAddMod *DRB_config = NULL; @@ -742,7 +1012,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( struct LogicalChannelConfig *DRB_lchan_config = NULL; struct LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters = NULL; - DRB_ToAddModList_t **DRB_configList = &rrc_inst->DRB_configList[ue_mod_idP]; + DRB_ToAddModList_t** DRB_configList = &ue_context_pP->ue_context.DRB_configList; MAC_MainConfig_t *mac_MainConfig = NULL; MeasObjectToAddModList_t *MeasObj_list = NULL; @@ -854,7 +1124,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); DRB_config->rlc_Config = DRB_rlc_config; -#ifdef RRC_RLC_AM // EXMIMO_IOT +#ifdef RRC_DEFAULT_RAB_IS_AM DRB_rlc_config->present = RLC_Config_PR_am; DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms50; DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = PollPDU_p16; @@ -867,7 +1137,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10; DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10; #ifdef CBA - DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;//T_Reordering_ms25; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms5;//T_Reordering_ms25; #else DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; #endif @@ -880,7 +1150,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( DRB_pdcp_config->rlc_AM = NULL; DRB_pdcp_config->rlc_UM = NULL; -#ifdef RRC_RLC_AM // EXMIMO_IOT +#ifdef RRC_DEFAULT_RAB_IS_AM // EXMIMO_IOT PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; PDCP_rlc_AM->statusReportRequired = FALSE; @@ -910,7 +1180,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( ASN_SEQUENCE_ADD(&(*DRB_configList)->list, DRB_config); mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig)); - eNB_rrc_inst[enb_mod_idP].mac_MainConfig[ue_mod_idP] = mac_MainConfig; + ue_context_pP->ue_context.mac_MainConfig = mac_MainConfig; mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config)); @@ -1015,7 +1285,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( for (i = 0; i < 6; i++) { CellToAdd = (CellsToAddMod_t *) CALLOC(1, sizeof(*CellToAdd)); CellToAdd->cellIndex = i + 1; - CellToAdd->physCellId = get_adjacent_cell_id(enb_mod_idP, i); + CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); CellToAdd->cellIndividualOffset = Q_OffsetRange_dB0; ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); @@ -1073,7 +1343,8 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1); if (ho_state == 1 /*HO_MEASURMENT */ ) { - LOG_I(RRC, "[eNB %d] frame %d: requesting A2, A3, A4, A5, and A6 event reporting\n", enb_mod_idP, frameP); + LOG_I(RRC, "[eNB %d] frame %d: requesting A2, A3, A4, A5, and A6 event reporting\n", + ctxt_pP->module_id, ctxt_pP->frame); ReportConfig_A2->reportConfigId = 3; ReportConfig_A2->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1190,24 +1461,24 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( LOG_I(RRC, "[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n", - enb_mod_idP, frameP); + ctxt_pP->module_id, ctxt_pP->frame); // store the information in an intermediate structure for Hanodver management //rrc_inst->handover_info.as_config.sourceRadioResourceConfig.srb_ToAddModList = CALLOC(1,sizeof()); - rrc_inst->handover_info[ue_mod_idP] = CALLOC(1, sizeof(*(rrc_inst->handover_info[ue_mod_idP]))); + ue_context_pP->ue_context.handover_info = CALLOC(1, sizeof(*(ue_context_pP->ue_context.handover_info))); //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.srb_ToAddModList,(void *)SRB_list,sizeof(SRB_ToAddModList_t)); - rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.srb_ToAddModList = SRB_configList2; + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.srb_ToAddModList = SRB_configList2; //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.drb_ToAddModList,(void *)DRB_list,sizeof(DRB_ToAddModList_t)); - rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.drb_ToAddModList = *DRB_configList; - rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; - rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.mac_MainConfig = - CALLOC(1, sizeof(*rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.mac_MainConfig)); - memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.mac_MainConfig, + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToAddModList = *DRB_configList; + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig = + CALLOC(1, sizeof(*ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig)); + memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, (void *)mac_MainConfig, sizeof(MAC_MainConfig_t)); - rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.physicalConfigDedicated = + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated = CALLOC(1, sizeof(PhysicalConfigDedicated_t)); - memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.physicalConfigDedicated, - (void *)rrc_inst->physicalConfigDedicated[ue_mod_idP], sizeof(PhysicalConfigDedicated_t)); - rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config = NULL; + memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, + (void*)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(PhysicalConfigDedicated_t)); + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.sps_Config = NULL; //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config,(void *)rrc_inst->sps_Config[ue_mod_idP],sizeof(SPS_Config_t)); } @@ -1217,23 +1488,24 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); /* Add all NAS PDUs to the list */ - for (i = 0; i < UE_info->nb_of_e_rabs; i++) { - if (UE_info->e_rab[i].param.nas_pdu.buffer != NULL) { + for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { + if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t)); memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); - OCTET_STRING_fromBuf(dedicatedInfoNas, (char *)UE_info->e_rab[i].param.nas_pdu.buffer, - UE_info->e_rab[i].param.nas_pdu.length); + OCTET_STRING_fromBuf(dedicatedInfoNas, (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, + ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); } - /* TODO parameters yet to process ... - UE_info->e_rab[i].param.qos; - UE_info->e_rab[i].param.sgw_addr; - UE_info->e_rab[i].param.gtp_teid; - */ + /* TODO parameters yet to process ... */ + { + ue_context_pP->ue_context.e_rab[i].param.qos; + ue_context_pP->ue_context.e_rab[i].param.sgw_addr; + ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + } /* TODO should test if e RAB are Ok before! */ - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_idP].e_rab[i].status = E_RAB_STATUS_DONE; + ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; } /* If list is empty free the list and reset the address */ @@ -1246,27 +1518,40 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionReconfiguration(enb_mod_idP, buffer, ue_mod_idP, - rrc_eNB_get_next_transaction_identifier(enb_mod_idP), //Transaction_id, - NULL, /// NN: do not reconfig srb1: SRB_configList2, - *DRB_configList, NULL, // DRB2_list, - NULL, // *sps_Config, + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id, + (SRB_ToAddModList_t*)NULL, /// NN: do not reconfig srb1: SRB_configList2, + (DRB_ToAddModList_t*)*DRB_configList, + (DRB_ToReleaseList_t*)NULL, // DRB2_list, + (struct SPS_Config*)NULL, // *sps_Config, #ifdef EXMIMO_IOT NULL, NULL, NULL, NULL,NULL, #else - physicalConfigDedicated[ue_mod_idP], MeasObj_list, ReportConfig_list, quantityConfig, MeasId_list, + (struct PhysicalConfigDedicated*)*physicalConfigDedicated, + (MeasObjectToAddModList_t*)MeasObj_list, + (ReportConfigToAddModList_t*)ReportConfig_list, + (QuantityConfig_t*)quantityConfig, + (MeasIdToAddModList_t*)MeasId_list, #endif - mac_MainConfig, NULL, NULL, Sparams, rsrp, cba_RNTI, dedicatedInfoNASList + (MAC_MainConfig_t*)mac_MainConfig, + (MeasGapConfig_t*)NULL, + (MobilityControlInfo_t*)NULL, + (struct MeasConfig__speedStatePars*)Sparams, + (RSRP_Range_t*)rsrp, + (C_RNTI_t*)cba_RNTI, + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList #ifdef Rel10 - , NULL //SCellToAddMod_r10_t + , (SCellToAddMod_r10_t*)NULL #endif ); #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n"); - for (i = 0; i < size; i++) + for (i = 0; i < size; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]); + } LOG_F(RRC,"\n"); //////////////////////////////////////// @@ -1275,30 +1560,55 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration( #if defined(ENABLE_ITTI) /* Free all NAS PDUs */ - for (i = 0; i < UE_info->nb_of_e_rabs; i++) { - if (UE_info->e_rab[i].param.nas_pdu.buffer != NULL) { + for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { + if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { /* Free the NAS PDU buffer and invalidate it */ - free(UE_info->e_rab[i].param.nas_pdu.buffer); - UE_info->e_rab[i].param.nas_pdu.buffer = NULL; + free(ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer); + ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer = NULL; } } #endif LOG_I(RRC, - "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %d)\n", - enb_mod_idP, frameP, size, ue_mod_idP); + "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n", + ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %u/%u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %d MUI %d) --->][PDCP][MOD %u/%u][RB %u]\n", - frameP, enb_mod_idP, ue_mod_idP, size, ue_mod_idP, rrc_eNB_mui, enb_mod_idP, ue_mod_idP, DCCH); - //rrc_rlc_data_req(enb_mod_idP,frameP, 1,(ue_mod_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req(enb_mod_idP, ue_mod_idP, frameP, 1, DCCH, rrc_eNB_mui++, 0, size, buffer, 1); + "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", + ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" rrcConnectionReconfiguration UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); +#endif + pdcp_rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } -int rrc_eNB_generate_RRCConnectionReconfiguration_SCell(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frame, uint32_t dl_CarrierFreq_r10) +//----------------------------------------------------------------------------- +int +rrc_eNB_generate_RRCConnectionReconfiguration_SCell( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + uint32_t dl_CarrierFreq_r10 +) +//----------------------------------------------------------------------------- { uint8_t size; @@ -1310,18 +1620,17 @@ int rrc_eNB_generate_RRCConnectionReconfiguration_SCell(module_id_t enb_mod_idP, // uint8_t sCellIndexToAdd; // sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1); // if (eNB_rrc_inst[enb_mod_idP].sCell_config[ue_mod_idP][sCellIndexToAdd] ) { - if (eNB_rrc_inst[enb_mod_idP].sCell_config != NULL) { - eNB_rrc_inst[enb_mod_idP].sCell_config[ue_mod_idP][sCellIndexToAdd].cellIdentification_r10->dl_CarrierFreq_r10 = dl_CarrierFreq_r10; + if (ue_context_pP->ue_context.sCell_config != NULL) { + ue_context_pP->ue_context.sCell_config[sCellIndexToAdd].cellIdentification_r10->dl_CarrierFreq_r10 = dl_CarrierFreq_r10; } else { LOG_E(RRC,"Scell not configured!\n"); return(-1); } #endif - size = do_RRCConnectionReconfiguration(enb_mod_idP, + size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, - ue_mod_idP, - rrc_eNB_get_next_transaction_identifier(enb_mod_idP),//Transaction_id, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),//Transaction_id, (SRB_ToAddModList_t*)NULL, (DRB_ToAddModList_t*)NULL, (DRB_ToReleaseList_t*)NULL, @@ -1340,33 +1649,49 @@ int rrc_eNB_generate_RRCConnectionReconfiguration_SCell(module_id_t enb_mod_idP, (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL #ifdef Rel10 - , eNB_rrc_inst[enb_mod_idP].sCell_config + , ue_context_pP->ue_context.sCell_config #endif ); + LOG_I(RRC,"[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n", + ctxt_pP->module_id,ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); + +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" rrcConnectionReconfiguration UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); +#endif - LOG_I(RRC,"[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %d)\n", - enb_mod_idP,frame, size, ue_mod_idP); - - LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frame, enb_mod_idP, size, ue_mod_idP, rrc_eNB_mui, enb_mod_idP, /*(ue_mod_idP*MAX_NUM_RB)+*/DCCH); - //rrc_rlc_data_req(Mod_id,frame, 1,(UE_index*MAX_NUM_RB)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - // pdcp_data_req(enb_mod_idP, ue_mod_idP, frame, 1, /*(UE_index * MAX_NUM_RB) + */DCCH, rrc_eNB_mui++, 0, size, (char*)buffer, 1); - pdcp_rrc_data_req(enb_mod_idP, ue_mod_idP, frame, 1, DCCH, rrc_eNB_mui++, 0, size, buffer, 1); - + pdcp_rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); return(0); } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_process_MeasurementReport( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP, - MeasResults_t * measResults2) +//----------------------------------------------------------------------------- +void +rrc_eNB_process_MeasurementReport( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + const MeasResults_t* const measResults2 +) +//----------------------------------------------------------------------------- { - LOG_I(RRC, "[eNB %d] Frame %d: Process Measurement Report From UE %d (Measurement Id %d)\n", - enb_mod_idP, frameP, ue_mod_idP, (int)measResults2->measId); + LOG_I(RRC, "[eNB %d] Frame %d: Process Measurement Report From UE %x (Measurement Id %d)\n", + ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId); if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) { LOG_I(RRC, "Physical Cell Id %d\n", @@ -1387,15 +1712,14 @@ void rrc_eNB_process_MeasurementReport( LOG_I(RRC, "RSRQ of Source %d\n", measResults2->measResultServCell.rsrqResult); #endif - if (eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ho_prepare != 0xF0) { - rrc_eNB_generate_HandoverPreparationInformation(enb_mod_idP, - frameP, - ue_mod_idP, + if (ue_context_pP->ue_context.handover_info->ho_prepare != 0xF0) { + rrc_eNB_generate_HandoverPreparationInformation(ctxt_pP, + ue_context_pP, measResults2->measResultNeighCells->choice. measResultListEUTRA.list.array[0]->physCellId); } else { - LOG_D(RRC, "[eNB %d] Frame %d: Ignoring MeasReport from UE %d as Handover is in progress... \n", enb_mod_idP, frameP, - ue_mod_idP); + LOG_D(RRC, "[eNB %d] Frame %d: Ignoring MeasReport from UE %x as Handover is in progress... \n", ctxt_pP->module_id, ctxt_pP->frame, + ctxt_pP->rnti); } //Look for IP address of the target eNB @@ -1414,14 +1738,17 @@ void rrc_eNB_process_MeasurementReport( } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_generate_HandoverPreparationInformation( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP, - PhysCellId_t targetPhyId) +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_HandoverPreparationInformation( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + PhysCellId_t targetPhyId +) +//----------------------------------------------------------------------------- { - uint8_t UE_id_target; + struct rrc_eNB_ue_context_s* ue_context_target_p = NULL; + //uint8_t UE_id_target = -1; uint8_t mod_id_target = get_adjacent_cell_mod_id(targetPhyId); HANDOVER_INFO *handoverInfo = CALLOC(1, sizeof(*handoverInfo)); /* @@ -1435,136 +1762,166 @@ void rrc_eNB_generate_HandoverPreparationInformation( handoverInfo->as_config.sourceDl_CarrierFreq = 36090; //Verify! memcpy((void *)&handoverInfo->as_config.sourceMasterInformationBlock, - (void *)&eNB_rrc_inst[enb_mod_idP].mib, sizeof(MasterInformationBlock_t)); + (void*)&eNB_rrc_inst[ctxt_pP->module_id].mib, sizeof(MasterInformationBlock_t)); memcpy((void *)&handoverInfo->as_config.sourceMeasConfig, - (void *)&eNB_rrc_inst[enb_mod_idP].measConfig[ue_mod_idP], sizeof(MeasConfig_t)); + (void*)ue_context_pP->ue_context.measConfig, sizeof(MeasConfig_t)); // FIXME handoverInfo not used... free( handoverInfo ); handoverInfo = 0; //to be configured - memset((void *)&eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_config.sourceSecurityAlgorithmConfig, + memset((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSecurityAlgorithmConfig, 0, sizeof(SecurityAlgorithmConfig_t)); - memcpy((void *)&eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_config.sourceSystemInformationBlockType1, - (void *)&eNB_rrc_inst[enb_mod_idP].SIB1, sizeof(SystemInformationBlockType1_t)); - memcpy((void *)&eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_config.sourceSystemInformationBlockType2, - (void *)&eNB_rrc_inst[enb_mod_idP].SIB23, sizeof(SystemInformationBlockType2_t)); - - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_context.reestablishmentInfo = + memcpy((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType1, + (void*)&eNB_rrc_inst[ctxt_pP->module_id].SIB1, sizeof(SystemInformationBlockType1_t)); + memcpy((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType2, + (void*)&eNB_rrc_inst[ctxt_pP->module_id].SIB23, sizeof(SystemInformationBlockType2_t)); + ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo = CALLOC(1, sizeof(ReestablishmentInfo_t)); - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_context.reestablishmentInfo->sourcePhysCellId = - eNB_rrc_inst[enb_mod_idP].physCellId; - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_context.reestablishmentInfo->targetCellShortMAC_I.buf = NULL; // Check values later - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_context.reestablishmentInfo->targetCellShortMAC_I.size = 0; - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_context.reestablishmentInfo->targetCellShortMAC_I.bits_unused = 0; - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_context.reestablishmentInfo->additionalReestabInfoList = NULL; - - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ho_prepare = 0xFF; //0xF0; - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ho_complete = 0; + ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->sourcePhysCellId = + eNB_rrc_inst[ctxt_pP->module_id].physCellId; + ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->targetCellShortMAC_I.buf = NULL; // Check values later + ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->targetCellShortMAC_I.size = 0; + ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->targetCellShortMAC_I.bits_unused = 0; + ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->additionalReestabInfoList = NULL; + ue_context_pP->ue_context.handover_info->ho_prepare = 0xFF; //0xF0; + ue_context_pP->ue_context.handover_info->ho_complete = 0; if (mod_id_target != 0xFF) { //UE_id_target = rrc_find_free_ue_index(modid_target); - UE_id_target = rrc_eNB_get_next_free_UE_index(mod_id_target, eNB_rrc_inst[enb_mod_idP].Info.UE_list[ue_mod_idP]); //this should return a new index - - if (UE_id_target != 0xFF) { + ue_context_target_p = + rrc_eNB_get_ue_context( + &eNB_rrc_inst[mod_id_target], + ue_context_pP->ue_context.rnti); + + /*UE_id_target = rrc_eNB_get_next_free_UE_index( + mod_id_target, + eNB_rrc_inst[ctxt_pP->module_id].Info.UE_list[ue_mod_idP]); //this should return a new index*/ + + if (ue_context_target_p == NULL) { // if not already in target cell + ue_context_target_p = rrc_eNB_allocate_new_UE_context(&eNB_rrc_inst[ctxt_pP->module_id]); + ue_context_target_p->ue_id_rnti = ue_context_pP->ue_context.rnti; // LG: should not be the same + ue_context_target_p->ue_context.rnti = ue_context_target_p->ue_id_rnti; // idem LOG_N(RRC, - "[eNB %d] Frame %d : Emulate sending HandoverPreparationInformation msg from eNB source %d to eNB target %d: source UE_id %d target UE_id %d source_modId: %d target_modId: %d\n", - enb_mod_idP, frameP, eNB_rrc_inst[enb_mod_idP].physCellId, targetPhyId, ue_mod_idP, UE_id_target, enb_mod_idP, + "[eNB %d] Frame %d : Emulate sending HandoverPreparationInformation msg from eNB source %d to eNB target %d: source UE_id %x target UE_id %x source_modId: %d target_modId: %d\n", + ctxt_pP->module_id, + ctxt_pP->frame, + eNB_rrc_inst[ctxt_pP->module_id].physCellId, + targetPhyId, + ue_context_pP->ue_context.rnti, + ue_context_target_p->ue_id_rnti, + ctxt_pP->module_id, mod_id_target); - eNB_rrc_inst[mod_id_target].handover_info[UE_id_target] = - CALLOC(1, sizeof(*(eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]))); - memcpy((void *)&eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]->as_context, - (void *)&eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_context, sizeof(AS_Context_t)); - memcpy((void *)&eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]->as_config, - (void *)&eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_config, sizeof(AS_Config_t)); - - eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]->ho_prepare = 0x00;// 0xFF; - eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]->ho_complete = 0; - - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->modid_t = mod_id_target; - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ueid_s = ue_mod_idP; - eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->modid_s = enb_mod_idP; - eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]->modid_t = mod_id_target; - eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]->modid_s = enb_mod_idP; - eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]->ueid_t = UE_id_target; - } else + ue_context_target_p->ue_context.handover_info = + CALLOC(1, sizeof(*(ue_context_target_p->ue_context.handover_info))); + memcpy((void*)&ue_context_target_p->ue_context.handover_info->as_context, + (void*)&ue_context_pP->ue_context.handover_info->as_context, + sizeof(AS_Context_t)); + memcpy((void*)&ue_context_target_p->ue_context.handover_info->as_config, + (void*)&ue_context_pP->ue_context.handover_info->as_config, + sizeof(AS_Config_t)); + ue_context_target_p->ue_context.handover_info->ho_prepare = 0x00;// 0xFF; + ue_context_target_p->ue_context.handover_info->ho_complete = 0; + ue_context_pP->ue_context.handover_info->modid_t = mod_id_target; + ue_context_pP->ue_context.handover_info->ueid_s = ue_context_pP->ue_context.rnti; + ue_context_pP->ue_context.handover_info->modid_s = ctxt_pP->module_id; + ue_context_target_p->ue_context.handover_info->modid_t = mod_id_target; + ue_context_target_p->ue_context.handover_info->modid_s = ctxt_pP->module_id; + ue_context_target_p->ue_context.handover_info->ueid_t = ue_context_target_p->ue_context.rnti; + + } else { LOG_E(RRC, "\nError in obtaining free UE id in target eNB %l for handover \n", targetPhyId); - } else + } + + } else { LOG_E(RRC, "\nError in obtaining Module ID of target eNB for handover \n"); + } } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_process_handoverPreparationInformation( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP) +//----------------------------------------------------------------------------- +void +rrc_eNB_process_handoverPreparationInformation( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +) +//----------------------------------------------------------------------------- { LOG_I(RRC, "[eNB %d] Frame %d : Logical Channel UL-DCCH, processing RRCHandoverPreparationInformation, sending RRCConnectionReconfiguration to UE %d \n", - enb_mod_idP, frameP, ue_mod_idP); - - //eNB_rrc_inst[enb_mod_idP].Info.UE_list[ue_mod_idP] - rrc_eNB_generate_RRCConnectionReconfiguration_handover(enb_mod_idP, frameP, ue_mod_idP, NULL, 0); - + ctxt_pP->module_id, ctxt_pP->frame, ue_context_pP->ue_context.rnti); + rrc_eNB_generate_RRCConnectionReconfiguration_handover( + ctxt_pP, + ue_context_pP, + NULL, + 0); } -/*------------------------------------------------------------------------------*/ -void check_handovers( - module_id_t enb_mod_idP, - frame_t frameP + +//----------------------------------------------------------------------------- +void +check_handovers( + protocol_ctxt_t* const ctxt_pP ) +//----------------------------------------------------------------------------- { - uint8_t i; int result; - protocol_ctxt_t ctxt; - - ctxt.enb_module_id = enb_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_YES; + struct rrc_eNB_ue_context_s* ue_context_p; + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head) { + ctxt_pP->rnti = ue_context_p->ue_id_rnti; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - ctxt.ue_module_id = i; - - if (eNB_rrc_inst[enb_mod_idP].handover_info[i] != NULL) { - if (eNB_rrc_inst[enb_mod_idP].handover_info[i]->ho_prepare == 0xFF) { + if (ue_context_p->ue_context.handover_info != NULL) { + if (ue_context_p->ue_context.handover_info->ho_prepare == 0xFF) { LOG_D(RRC, "[eNB %d] Frame %d: Incoming handover detected for new UE_idx %d (source eNB %d->target eNB %d) \n", - enb_mod_idP, frameP, i, enb_mod_idP, eNB_rrc_inst[enb_mod_idP].handover_info[i]->modid_t); + ctxt_pP->module_id, + ctxt_pP->frame, + ctxt_pP->rnti, + ctxt_pP->module_id, + ue_context_p->ue_context.handover_info->modid_t); // source eNB generates rrcconnectionreconfiguration to prepare the HO - rrc_eNB_process_handoverPreparationInformation(enb_mod_idP, frameP, i); - eNB_rrc_inst[enb_mod_idP].handover_info[i]->ho_prepare = 0xF1; + rrc_eNB_process_handoverPreparationInformation( + ctxt_pP, + ue_context_p); + ue_context_p->ue_context.handover_info->ho_prepare = 0xF1; } - if (eNB_rrc_inst[enb_mod_idP].handover_info[i]->ho_complete == 0xF1) { + if (ue_context_p->ue_context.handover_info->ho_complete == 0xF1) { LOG_D(RRC, - "[eNB %d] Frame %d: handover Command received for new UE_idx %d current eNB %d target eNB: %d \n", - enb_mod_idP, frameP, i, enb_mod_idP, eNB_rrc_inst[enb_mod_idP].handover_info[i]->modid_t); + "[eNB %d] Frame %d: handover Command received for new UE_id %x current eNB %d target eNB: %d \n", + ctxt_pP->module_id, + ctxt_pP->frame, + ctxt_pP->rnti, + ctxt_pP->module_id, + ue_context_p->ue_context.handover_info->modid_t); //rrc_eNB_process_handoverPreparationInformation(enb_mod_idP,frameP,i); - result = pdcp_data_req(&ctxt, + result = pdcp_data_req(ctxt_pP, SRB_FLAG_YES, DCCH, rrc_eNB_mui++, - FALSE, - eNB_rrc_inst[enb_mod_idP].handover_info[i]->size, - eNB_rrc_inst[enb_mod_idP].handover_info[i]->buf, 1); + SDU_CONFIRM_NO, + ue_context_p->ue_context.handover_info->size, + ue_context_p->ue_context.handover_info->buf, + PDCP_TRANSMISSION_MODE_CONTROL); AssertFatal(result == TRUE, "PDCP data request failed!\n"); - eNB_rrc_inst[enb_mod_idP].handover_info[i]->ho_complete = 0xF2; + ue_context_p->ue_context.handover_info->ho_complete = 0xF2; } } } } -/*------------------------------------------------------------------------------*/ // 5.3.5.4 RRCConnectionReconfiguration including the mobilityControlInfo to prepare the UE handover -void rrc_eNB_generate_RRCConnectionReconfiguration_handover( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP, - uint8_t * nas_pdu, - uint32_t nas_length) +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_RRCConnectionReconfiguration_handover( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + uint8_t* const nas_pdu, + const uint32_t nas_length +) +//----------------------------------------------------------------------------- { uint8_t buffer[RRC_BUF_SIZE]; @@ -1573,16 +1930,15 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( uint8_t rv[2]; uint16_t Idx; // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE - eNB_RRC_INST *rrc_inst = &eNB_rrc_inst[enb_mod_idP]; - - struct PhysicalConfigDedicated **physicalConfigDedicated = &rrc_inst->physicalConfigDedicated[ue_mod_idP]; + eNB_RRC_INST* rrc_inst = &eNB_rrc_inst[ctxt_pP->module_id]; + struct PhysicalConfigDedicated** physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; struct SRB_ToAddMod *SRB2_config; struct SRB_ToAddMod__rlc_Config *SRB2_rlc_config; struct SRB_ToAddMod__logicalChannelConfig *SRB2_lchan_config; struct LogicalChannelConfig__ul_SpecificParameters *SRB2_ul_SpecificParameters; LogicalChannelConfig_t *SRB1_logicalChannelConfig = NULL; - SRB_ToAddModList_t *SRB_configList = rrc_inst->SRB_configList[ue_mod_idP]; // not used in this context: may be removed + SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; // not used in this context: may be removed SRB_ToAddModList_t *SRB_configList2; struct DRB_ToAddMod *DRB_config; @@ -1591,7 +1947,6 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( struct PDCP_Config__rlc_UM *PDCP_rlc_UM; struct LogicalChannelConfig *DRB_lchan_config; struct LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters; - // DRB_ToAddModList_t **DRB_configList = &rrc_inst->DRB_configList[ue_mod_idP]; DRB_ToAddModList_t *DRB_configList2; MAC_MainConfig_t *mac_MainConfig; @@ -1606,7 +1961,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( MobilityControlInfo_t *mobilityInfo; // HandoverCommand_t handoverCommand; uint8_t sourceModId = - get_adjacent_cell_mod_id(rrc_inst->handover_info[ue_mod_idP]->as_context.reestablishmentInfo->sourcePhysCellId); + get_adjacent_cell_mod_id(ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->sourcePhysCellId); #if Rel10 long *sr_ProhibitTimer_r9; #endif @@ -1628,12 +1983,8 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList; protocol_ctxt_t ctxt; - ctxt.enb_module_id = enb_mod_idP; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_YES; - - LOG_D(RRC, "[eNB %d] Frame %d: handover preparation: get the newSourceUEIdentity (C-RNTI): ", enb_mod_idP, frameP); + LOG_D(RRC, "[eNB %d] Frame %d: handover preparation: get the newSourceUEIdentity (C-RNTI): ", + ctxt_pP->module_id, ctxt_pP->frame); for (i = 0; i < 2; i++) { rv[i] = taus() & 0xff; @@ -1641,7 +1992,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( } LOG_D(RRC, "[eNB %d] Frame %d : handover reparation: add target eNB SRB1 and PHYConfigDedicated reconfiguration\n", - enb_mod_idP, frameP); + ctxt_pP->module_id, ctxt_pP->frame); // 1st: reconfigure SRB SRB_configList2 = CALLOC(1, sizeof(*SRB_configList)); SRB1_config = CALLOC(1, sizeof(*SRB1_config)); @@ -1740,7 +2091,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf = CALLOC(1, 2); physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.size = 2; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[0] = 0x12; - physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_mod_idP; + physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.bits_unused = 0; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->present = TPC_PDCCH_Config_PR_setup; @@ -1749,7 +2100,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf = CALLOC(1, 2); physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.size = 2; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0] = 0x22; - physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_mod_idP; + physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused = 0; // CQI ReportConfig @@ -1814,23 +2165,26 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( // SchedulingRequestConfig physicalConfigDedicated2->schedulingRequestConfig->present = SchedulingRequestConfig_PR_setup; - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = ue_mod_idP; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = ue_context_pP->local_uid; if (mac_xface->lte_frame_parms->frame_type == 0) { // FDD - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5 + (ue_mod_idP % 10); // Isr = 5 (every 10 subframes, offset=2+UE_id mod3) + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5 + (ue_context_pP->local_uid % + 10); // Isr = 5 (every 10 subframes, offset=2+UE_id mod3) } else { switch (mac_xface->lte_frame_parms->tdd_config) { case 1: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_mod_idP & 1) + ((ue_mod_idP & 3) >> 1) * - 5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid & 1) + (( + ue_context_pP->local_uid & 3) >> 1) * 5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) break; case 3: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_mod_idP % 3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid % + 3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) break; case 4: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_mod_idP & 1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid & + 1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) break; default: @@ -1846,24 +2200,37 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( SchedulingRequestConfig__setup__dsr_TransMax_n4; LOG_D(RRC, - "handover_config [FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 UE %d) --->][MAC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, ue_mod_idP, enb_mod_idP); - rrc_mac_config_req(enb_mod_idP, ENB_FLAG_YES, ue_mod_idP, 0, (RadioResourceConfigCommonSIB_t *) NULL, - eNB_rrc_inst[enb_mod_idP].physicalConfigDedicated[ue_mod_idP], + "handover_config [FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 UE %x) --->][MAC_eNB][MOD %02d][]\n", + ctxt_pP->frame, ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ctxt_pP->module_id); + rrc_mac_config_req( + ctxt_pP->module_id, + ENB_FLAG_YES, + ue_context_pP->ue_context.rnti, + 0, + (RadioResourceConfigCommonSIB_t*) NULL, + ue_context_pP->ue_context.physicalConfigDedicated, #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif (MeasObjectToAddMod_t **) NULL, - eNB_rrc_inst[enb_mod_idP].mac_MainConfig[ue_mod_idP], 1, SRB1_logicalChannelConfig, - eNB_rrc_inst[enb_mod_idP].measGapConfig[ue_mod_idP], (TDD_Config_t *) NULL, - (MobilityControlInfo_t *) NULL, (uint8_t *) NULL, (uint16_t *) NULL, NULL, NULL, NULL, + ue_context_pP->ue_context.mac_MainConfig, + 1, + SRB1_logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (TDD_Config_t*) NULL, + (MobilityControlInfo_t*) NULL, + (uint8_t*) NULL, + (uint16_t*) NULL, + NULL, + NULL, + NULL, (MBSFN_SubframeConfigList_t *) NULL #ifdef Rel10 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL #endif #ifdef CBA - , eNB_rrc_inst[enb_mod_idP].num_active_cba_groups, eNB_rrc_inst[enb_mod_idP].cba_rnti[0] + , eNB_rrc_inst[ctxt_pP->module_id].num_active_cba_groups, eNB_rrc_inst[ctxt_pP->module_id].cba_rnti[0] #endif ); @@ -1953,7 +2320,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( ASN_SEQUENCE_ADD(&DRB_configList2->list, DRB_config); mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig)); - eNB_rrc_inst[enb_mod_idP].mac_MainConfig[ue_mod_idP] = mac_MainConfig; + ue_context_pP->ue_context.mac_MainConfig = mac_MainConfig; mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config)); @@ -2056,7 +2423,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( for (i = 0; i < 6; i++) { CellToAdd = (CellsToAddMod_t *) CALLOC(1, sizeof(*CellToAdd)); CellToAdd->cellIndex = i + 1; - CellToAdd->physCellId = get_adjacent_cell_id(enb_mod_idP, i); + CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); CellToAdd->cellIndividualOffset = Q_OffsetRange_dB0; ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); @@ -2221,9 +2588,13 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( mobilityInfo = CALLOC(1, sizeof(*mobilityInfo)); memset((void *)mobilityInfo, 0, sizeof(*mobilityInfo)); mobilityInfo->targetPhysCellId = - (PhysCellId_t) two_tier_hexagonal_cellIds[rrc_inst->handover_info[ue_mod_idP]->modid_t]; - LOG_D(RRC, "[eNB %d] Frame %d: handover preparation: targetPhysCellId: %d mod_id: %d ue_mod_idP: %d \n", enb_mod_idP, - frameP, mobilityInfo->targetPhysCellId, enb_mod_idP, ue_mod_idP); + (PhysCellId_t) two_tier_hexagonal_cellIds[ue_context_pP->ue_context.handover_info->modid_t]; + LOG_D(RRC, "[eNB %d] Frame %d: handover preparation: targetPhysCellId: %d mod_id: %d ue: %x \n", + ctxt_pP->module_id, + ctxt_pP->frame, + mobilityInfo->targetPhysCellId, + ctxt_pP->module_id, + ue_context_pP->ue_context.rnti); mobilityInfo->additionalSpectrumEmission = CALLOC(1, sizeof(*mobilityInfo->additionalSpectrumEmission)); *mobilityInfo->additionalSpectrumEmission = 1; //Check this value! @@ -2287,22 +2658,27 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( mobilityInfo->carrierFreq->dl_CarrierFreq = 36090; mobilityInfo->carrierFreq->ul_CarrierFreq = NULL; - mobilityInfo->carrierBandwidth = CALLOC(1, sizeof(*mobilityInfo->carrierBandwidth)); //CALLOC(1,sizeof(struct CarrierBandwidthEUTRA)); AllowedMeasBandwidth_mbw25 + mobilityInfo->carrierBandwidth = CALLOC(1, sizeof( + *mobilityInfo->carrierBandwidth)); //CALLOC(1,sizeof(struct CarrierBandwidthEUTRA)); AllowedMeasBandwidth_mbw25 mobilityInfo->carrierBandwidth->dl_Bandwidth = CarrierBandwidthEUTRA__dl_Bandwidth_n25; mobilityInfo->carrierBandwidth->ul_Bandwidth = NULL; mobilityInfo->rach_ConfigDedicated = NULL; // store the srb and drb list for ho management, mainly in case of failure - memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.srb_ToAddModList, - (void *)SRB_configList2, sizeof(SRB_ToAddModList_t)); - memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.drb_ToAddModList, - (void *)DRB_configList2, sizeof(DRB_ToAddModList_t)); - rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; - memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.mac_MainConfig, - (void *)mac_MainConfig, sizeof(MAC_MainConfig_t)); - memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.physicalConfigDedicated, - (void *)rrc_inst->physicalConfigDedicated[ue_mod_idP], sizeof(PhysicalConfigDedicated_t)); + memcpy(ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.srb_ToAddModList, + (void*)SRB_configList2, + sizeof(SRB_ToAddModList_t)); + memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToAddModList, + (void*)DRB_configList2, + sizeof(DRB_ToAddModList_t)); + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; + memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, + (void*)mac_MainConfig, + sizeof(MAC_MainConfig_t)); + memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, + (void*)ue_context_pP->ue_context.physicalConfigDedicated, + sizeof(PhysicalConfigDedicated_t)); /* memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config, (void *)rrc_inst->sps_Config[ue_mod_idP], sizeof(SPS_Config_t)); @@ -2311,24 +2687,24 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( //Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; Idx = DCCH; // SRB1 - eNB_rrc_inst[enb_mod_idP].Srb1[ue_mod_idP].Active = 1; - eNB_rrc_inst[enb_mod_idP].Srb1[ue_mod_idP].Srb_info.Srb_id = Idx; - memcpy(&eNB_rrc_inst[enb_mod_idP].Srb1[ue_mod_idP].Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - memcpy(&eNB_rrc_inst[enb_mod_idP].Srb1[ue_mod_idP].Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); + ue_context_pP->ue_context.Srb1.Active = 1; + ue_context_pP->ue_context.Srb1.Srb_info.Srb_id = Idx; + memcpy(&ue_context_pP->ue_context.Srb1.Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); + memcpy(&ue_context_pP->ue_context.Srb1.Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); // SRB2 - eNB_rrc_inst[enb_mod_idP].Srb2[ue_mod_idP].Active = 1; - eNB_rrc_inst[enb_mod_idP].Srb2[ue_mod_idP].Srb_info.Srb_id = Idx; - memcpy(&eNB_rrc_inst[enb_mod_idP].Srb2[ue_mod_idP].Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - memcpy(&eNB_rrc_inst[enb_mod_idP].Srb2[ue_mod_idP].Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - - LOG_I(RRC, "[eNB %d] CALLING RLC CONFIG SRB1 (rbid %d) for UE %d\n", enb_mod_idP, Idx, ue_mod_idP); + ue_context_pP->ue_context.Srb2.Active = 1; + ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = Idx; + memcpy(&ue_context_pP->ue_context.Srb2.Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); + memcpy(&ue_context_pP->ue_context.Srb2.Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); + LOG_I(RRC, "[eNB %d] CALLING RLC CONFIG SRB1 (rbid %d) for UE %x\n", + ctxt_pP->module_id, Idx, ue_context_pP->ue_context.rnti); // rrc_pdcp_config_req (enb_mod_idP, frameP, 1, CONFIG_ACTION_ADD, idx, UNDEF_SECURITY_MODE); // rrc_rlc_config_req(enb_mod_idP,frameP,1,CONFIG_ACTION_ADD,Idx,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); rrc_pdcp_config_asn1_req(&ctxt, - eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_idP], + ue_context_pP->ue_context.SRB_configList, (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL, 0xff, NULL, NULL, NULL #ifdef Rel10 , (PMCH_InfoList_r9_t *) NULL @@ -2336,7 +2712,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( ); rrc_rlc_config_asn1_req(&ctxt, - eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_idP], + ue_context_pP->ue_context.SRB_configList, (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL #ifdef Rel10 , (PMCH_InfoList_r9_t *) NULL @@ -2349,24 +2725,38 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( // rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionReconfiguration(enb_mod_idP, buffer, ue_mod_idP, rrc_eNB_get_next_transaction_identifier(enb_mod_idP), //Transaction_id, - SRB_configList2, DRB_configList2, NULL, // DRB2_list, + size = do_RRCConnectionReconfiguration( + ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id, + SRB_configList2, + DRB_configList2, + NULL, // DRB2_list, NULL, //*sps_Config, - physicalConfigDedicated[ue_mod_idP], MeasObj_list, ReportConfig_list, NULL, //quantityConfig, - MeasId_list, mac_MainConfig, NULL, mobilityInfo, Sparams, - NULL, NULL, dedicatedInfoNASList + ue_context_pP->ue_context.physicalConfigDedicated, + MeasObj_list, + ReportConfig_list, + NULL, //quantityConfig, + MeasId_list, + mac_MainConfig, + NULL, + mobilityInfo, + Sparams, + NULL, + NULL, + dedicatedInfoNASList #ifdef Rel10 , NULL // SCellToAddMod_r10_t #endif ); LOG_I(RRC, - "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration for handover (bytes %d, UE id %d)\n", - enb_mod_idP, frameP, size, ue_mod_idP); + "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration for handover (bytes %d, UE rnti %x)\n", + ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); // to be updated if needed - /*if (eNB_rrc_inst[enb_mod_idP].SRB1_config[ue_mod_idP]->logicalChannelConfig) { - if (eNB_rrc_inst[enb_mod_idP].SRB1_config[ue_mod_idP]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { - SRB1_logicalChannelConfig = &eNB_rrc_inst[enb_mod_idP].SRB1_config[ue_mod_idP]->logicalChannelConfig->choice.explicitValue; + /*if (eNB_rrc_inst[ctxt_pP->module_id].SRB1_config[ue_mod_idP]->logicalChannelConfig) { + if (eNB_rrc_inst[ctxt_pP->module_id].SRB1_config[ue_mod_idP]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { + SRB1_logicalChannelConfig = &eNB_rrc_inst[ctxt_pP->module_id].SRB1_config[ue_mod_idP]->logicalChannelConfig->choice.explicitValue; } else { SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; @@ -2378,23 +2768,26 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( */ LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration_handover to UE %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frameP, enb_mod_idP, size, ue_mod_idP, rrc_eNB_mui, enb_mod_idP, DCCH); - - //rrc_rlc_data_req(enb_mod_idP,frameP, 1,(ue_mod_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - //pdcp_data_req (enb_mod_idP, frameP, 1, (ue_mod_idP * NB_RB_MAX) + DCCH,rrc_eNB_mui++, 0, size, (char *) buffer, 1); - rrc_mac_config_req(enb_mod_idP, ENB_FLAG_YES, ue_mod_idP, 0, + "[FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration_handover to UE %x MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", + ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); + //rrc_rlc_data_req(ctxt_pP->module_id,frameP, 1,(ue_mod_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); + //pdcp_data_req (ctxt_pP->module_id, frameP, 1, (ue_mod_idP * NB_RB_MAX) + DCCH,rrc_eNB_mui++, 0, size, (char *) buffer, 1); + rrc_mac_config_req( + ctxt_pP->module_id, + ENB_FLAG_YES, + ue_context_pP->ue_context.rnti, + 0, (RadioResourceConfigCommonSIB_t *) NULL, - eNB_rrc_inst[enb_mod_idP].physicalConfigDedicated[ue_mod_idP], + ue_context_pP->ue_context.physicalConfigDedicated, #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif (MeasObjectToAddMod_t **) NULL, - eNB_rrc_inst[enb_mod_idP].mac_MainConfig[ue_mod_idP], + ue_context_pP->ue_context.mac_MainConfig, 1, SRB1_logicalChannelConfig, - eNB_rrc_inst[enb_mod_idP].measGapConfig[ue_mod_idP], + ue_context_pP->ue_context.measGapConfig, (TDD_Config_t *) NULL, (MobilityControlInfo_t *) mobilityInfo, (uint8_t *) NULL, (uint16_t *) NULL, NULL, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL @@ -2412,21 +2805,29 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( handoverCommand.criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.buf = buffer; handoverCommand.criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.size = size; */ +#warning "COMPILATION PROBLEM" +#ifdef PROBLEM_COMPILATION_RESOLVED if (sourceModId != 0xFF) { - memcpy(eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ueid_s]->buf, + memcpy(eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ueid_s]->buf, (void *)buffer, size); - eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ueid_s]->size = size; - eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ueid_s]->ho_complete = + eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ueid_s]->size = size; + eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ueid_s]->ho_complete = 0xF1; - //eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ho_complete = 0xFF; + //eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ho_complete = 0xFF; LOG_D(RRC, "[eNB %d] Frame %d: setting handover complete to 0xF1 for (%d,%d) and to 0xFF for (%d,%d)\n", - enb_mod_idP, frameP, sourceModId, eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->ueid_s, enb_mod_idP, ue_mod_idP); + ctxt_pP->module_id, + ctxt_pP->frame, + sourceModId, + eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ueid_s, + ctxt_pP->module_id, + ue_mod_idP); } else LOG_W(RRC, "[eNB %d] Frame %d: rrc_eNB_generate_RRCConnectionReconfiguration_handover: Could not find source eNB mod_id.\n", - enb_mod_idP, frameP); + ctxt_pP->module_id, ctxt_pP->frame); +#endif } /* @@ -2448,44 +2849,41 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( } */ -/*------------------------------------------------------------------------------*/ -void rrc_eNB_process_RRCConnectionReconfigurationComplete( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP, - RRCConnectionReconfigurationComplete_r8_IEs_t * rrcConnectionReconfigurationComplete) +//----------------------------------------------------------------------------- +void +rrc_eNB_process_RRCConnectionReconfigurationComplete( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + RRCConnectionReconfigurationComplete_r8_IEs_t* rrcConnectionReconfigurationComplete +) +//----------------------------------------------------------------------------- { int i; -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK int oip_ifup = 0; int dest_ip_offset = 0; + module_id_t ue_module_id = -1; #endif uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; - DRB_ToAddModList_t *DRB_configList = eNB_rrc_inst[enb_mod_idP].DRB_configList[ue_mod_idP]; - SRB_ToAddModList_t *SRB_configList = eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_idP]; - protocol_ctxt_t ctxt; - - ctxt.enb_module_id = enb_mod_idP; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_YES; + DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList; + SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; #if defined(ENABLE_SECURITY) /* Derive the keys from kenb */ if (DRB_configList != NULL) { - derive_key_up_enc(eNB_rrc_inst[enb_mod_idP].ciphering_algorithm[ue_mod_idP], - eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP], &kUPenc); + derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm, + ue_context_pP->ue_context.kenb, &kUPenc); } - derive_key_rrc_enc(eNB_rrc_inst[enb_mod_idP].ciphering_algorithm[ue_mod_idP], - eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP], &kRRCenc); - derive_key_rrc_int(eNB_rrc_inst[enb_mod_idP].integrity_algorithm[ue_mod_idP], - eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP], &kRRCint); + derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm, + ue_context_pP->ue_context.kenb, &kRRCenc); + derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, + ue_context_pP->ue_context.kenb, &kRRCint); #endif #ifdef ENABLE_RAL @@ -2496,7 +2894,7 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete( message_ral_p = itti_alloc_new_message(TASK_RRC_ENB, RRC_RAL_CONNECTION_RECONFIGURATION_IND); memset(&connection_reconfiguration_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ind_t)); - connection_reconfiguration_ind.ue_id = ue_mod_idP; + connection_reconfiguration_ind.ue_id = ctxt_pP->rnti; if (DRB_configList != NULL) { connection_reconfiguration_ind.num_drb = DRB_configList->list.count; @@ -2517,16 +2915,16 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete( memcpy(&message_ral_p->ittiMsg, (void *)&connection_reconfiguration_ind, sizeof(rrc_ral_connection_reconfiguration_ind_t)); LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_IND to RAL\n"); - itti_send_msg_to_task(TASK_RAL_ENB, enb_mod_idP, message_ral_p); + itti_send_msg_to_task(TASK_RAL_ENB, ctxt_pP->instance, message_ral_p); } #endif // Refresh SRBs/DRBs rrc_pdcp_config_asn1_req( - &ctxt, + ctxt_pP, NULL, //LG-RK 14/05/2014 SRB_configList, DRB_configList, (DRB_ToReleaseList_t *) NULL, - /*eNB_rrc_inst[enb_mod_idP].ciphering_algorithm[ue_mod_idP] | - (eNB_rrc_inst[enb_mod_idP].integrity_algorithm[ue_mod_idP] << 4), + /*eNB_rrc_inst[ctxt_pP->module_id].ciphering_algorithm[ue_mod_idP] | + (eNB_rrc_inst[ctxt_pP->module_id].integrity_algorithm[ue_mod_idP] << 4), */ 0xff, // already configured during the securitymodecommand kRRCenc, @@ -2538,7 +2936,7 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete( ); // Refresh SRBs/DRBs rrc_rlc_config_asn1_req( - &ctxt, + ctxt_pP, NULL, //LG-RK 14/05/2014 SRB_configList, DRB_configList, (DRB_ToReleaseList_t *) NULL @@ -2553,86 +2951,99 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete( for (i = 0; i < DRB_configList->list.count; i++) { // num max DRB (11-3-8) if (DRB_configList->list.array[i]) { LOG_I(RRC, - "[eNB %d] Frame %d : Logical Channel UL-DCCH, Received RRCConnectionReconfigurationComplete from UE %d, reconfiguring DRB %d/LCID %d\n", - enb_mod_idP, frameP, ue_mod_idP, + "[eNB %d] Frame %d : Logical Channel UL-DCCH, Received RRCConnectionReconfigurationComplete from UE rnti %x, reconfiguring DRB %d/LCID %d\n", + ctxt_pP->module_id, + ctxt_pP->frame, + ctxt_pP->rnti, + (int)DRB_configList->list.array[i]->drb_Identity, + (int)*DRB_configList->list.array[i]->logicalChannelIdentity); + // for pre-ci tests + LOG_I(RRC, + "[eNB %d] Frame %d : Logical Channel UL-DCCH, Received RRCConnectionReconfigurationComplete from UE %u, reconfiguring DRB %d/LCID %d\n", + ctxt_pP->module_id, + ctxt_pP->frame, + oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[ctxt_pP->module_id][ue_context_pP->local_uid], (int)DRB_configList->list.array[i]->drb_Identity, - (ue_mod_idP * NB_RB_MAX) + (int)*DRB_configList->list.array[i]->logicalChannelIdentity); + (int)*DRB_configList->list.array[i]->logicalChannelIdentity); - if (eNB_rrc_inst[enb_mod_idP].DRB_active[ue_mod_idP][i] == 0) { + if (ue_context_pP->ue_context.DRB_active[i] == 0) { /* - rrc_pdcp_config_req (enb_mod_idP, frameP, 1, CONFIG_ACTION_ADD, + rrc_pdcp_config_req (ctxt_pP->module_id, frameP, 1, CONFIG_ACTION_ADD, (ue_mod_idP * NB_RB_MAX) + *DRB_configList->list.array[i]->logicalChannelIdentity,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(enb_mod_idP,frameP,1,CONFIG_ACTION_ADD, - (ue_mod_idP * NB_RB_MAX) + (int)*eNB_rrc_inst[enb_mod_idP].DRB_config[ue_mod_idP][i]->logicalChannelIdentity, + rrc_rlc_config_req(ctxt_pP->module_id,frameP,1,CONFIG_ACTION_ADD, + (ue_mod_idP * NB_RB_MAX) + (int)*eNB_rrc_inst[ctxt_pP->module_id].DRB_config[ue_mod_idP][i]->logicalChannelIdentity, RADIO_ACCESS_BEARER,Rlc_info_um); */ - eNB_rrc_inst[enb_mod_idP].DRB_active[ue_mod_idP][i] = 1; + ue_context_pP->ue_context.DRB_active[i] = 1; LOG_D(RRC, "[eNB %d] Frame %d: Establish RLC UM Bidirectional, DRB %d Active\n", - enb_mod_idP, frameP, (int)DRB_configList->list.array[i]->drb_Identity); - -#ifdef NAS_NETLINK + ctxt_pP->module_id, ctxt_pP->frame, (int)DRB_configList->list.array[i]->drb_Identity); +#if defined(PDCP_USE_NETLINK) && !defined(LINK_ENB_PDCP_TO_GTPV1U) // can mean also IPV6 since ether -> ipv6 autoconf # if !defined(OAI_NW_DRIVER_TYPE_ETHERNET) && !defined(EXMIMO) - LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n", enb_mod_idP, enb_mod_idP); + LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n", + ctxt_pP->module_id, + ctxt_pP->module_id); oip_ifup = nas_config( - enb_mod_idP, // interface index - enb_mod_idP + 1, // thrid octet - enb_mod_idP + 1); // fourth octet + ctxt_pP->module_id, // interface index + ctxt_pP->module_id + 1, // thrid octet + ctxt_pP->module_id + 1); // fourth octet if (oip_ifup == 0) { // interface is up --> send a config the DRB # ifdef OAI_EMU - oai_emulation.info.oai_ifup[enb_mod_idP] = 1; + oai_emulation.info.oai_ifup[ctxt_pP->module_id] = 1; dest_ip_offset = NB_eNB_INST; # else dest_ip_offset = 8; # endif LOG_I(OIP, "[eNB %d] Config the oai%d to send/receive pkt on DRB %d to/from the protocol stack\n", - enb_mod_idP, enb_mod_idP, - (ue_mod_idP * maxDRB) + DRB_configList->list.array[i]->drb_Identity); + ctxt_pP->module_id, ctxt_pP->module_id, + (ue_context_pP->local_uid * maxDRB) + DRB_configList->list.array[i]->drb_Identity); + ue_module_id = oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[ctxt_pP->module_id][ue_context_pP->local_uid]; rb_conf_ipv4(0, //add - ue_mod_idP, //cx - enb_mod_idP, //inst - (ue_mod_idP * maxDRB) + DRB_configList->list.array[i]->drb_Identity, // RB + ue_module_id, //cx + ctxt_pP->module_id, //inst + (ue_module_id * maxDRB) + DRB_configList->list.array[i]->drb_Identity, // RB 0, //dscp - ipv4_address(enb_mod_idP + 1, enb_mod_idP + 1), //saddr - ipv4_address(enb_mod_idP + 1, dest_ip_offset + ue_mod_idP + 1)); //daddr - - LOG_D(RRC, "[eNB %d] State = Attached (UE %d)\n", enb_mod_idP, ue_mod_idP); + ipv4_address(ctxt_pP->module_id + 1, ctxt_pP->module_id + 1), //saddr + ipv4_address(ctxt_pP->module_id + 1, dest_ip_offset + ue_module_id + 1)); //daddr + LOG_D(RRC, "[eNB %d] State = Attached (UE rnti %x module id %u)\n", + ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ue_module_id); } # else # ifdef OAI_EMU - oai_emulation.info.oai_ifup[enb_mod_idP] = 1; + oai_emulation.info.oai_ifup[ctxt_pP->module_id] = 1; # endif # endif #endif LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (DRB UE %d) --->][MAC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, ue_mod_idP, enb_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (DRB) ---> MAC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - if (DRB_configList->list.array[i]->logicalChannelIdentity) + if (DRB_configList->list.array[i]->logicalChannelIdentity) { DRB2LCHAN[i] = (uint8_t) * DRB_configList->list.array[i]->logicalChannelIdentity; + } rrc_mac_config_req( - enb_mod_idP, + ctxt_pP->module_id, ENB_FLAG_YES, - ue_mod_idP, + ue_context_pP->ue_context.rnti, 0, (RadioResourceConfigCommonSIB_t *) NULL, - eNB_rrc_inst[enb_mod_idP].physicalConfigDedicated[ue_mod_idP], + ue_context_pP->ue_context.physicalConfigDedicated, #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif (MeasObjectToAddMod_t **) NULL, - eNB_rrc_inst[enb_mod_idP].mac_MainConfig[ue_mod_idP], + ue_context_pP->ue_context.mac_MainConfig, DRB2LCHAN[i], DRB_configList->list.array[i]->logicalChannelConfig, - eNB_rrc_inst[enb_mod_idP].measGapConfig[ue_mod_idP], + ue_context_pP->ue_context.measGapConfig, (TDD_Config_t *) NULL, NULL, (uint8_t *) NULL, @@ -2641,19 +3052,19 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete( , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL #endif #ifdef CBA - , eNB_rrc_inst[enb_mod_idP].num_active_cba_groups, eNB_rrc_inst[enb_mod_idP].cba_rnti[0] + , eNB_rrc_inst[ctxt_pP->module_id].num_active_cba_groups, eNB_rrc_inst[ctxt_pP->module_id].cba_rnti[0] #endif ); } else { // remove LCHAN from MAC/PHY - if (eNB_rrc_inst[enb_mod_idP].DRB_active[ue_mod_idP][i] == 1) { + if (ue_context_pP->ue_context.DRB_active[i] == 1) { // DRB has just been removed so remove RLC + PDCP for DRB - /* rrc_pdcp_config_req (enb_mod_idP, frameP, 1, CONFIG_ACTION_REMOVE, + /* rrc_pdcp_config_req (ctxt_pP->module_id, frameP, 1, CONFIG_ACTION_REMOVE, (ue_mod_idP * NB_RB_MAX) + DRB2LCHAN[i],UNDEF_SECURITY_MODE); */ rrc_rlc_config_req( - &ctxt, + ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, CONFIG_ACTION_REMOVE, @@ -2661,23 +3072,22 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete( Rlc_info_um); } - eNB_rrc_inst[enb_mod_idP].DRB_active[ue_mod_idP][i] = 0; + ue_context_pP->ue_context.DRB_active[i] = 0; LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (DRB UE %d) --->][MAC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, ue_mod_idP, enb_mod_idP); - - rrc_mac_config_req(enb_mod_idP, + PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (DRB) ---> MAC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_mac_config_req(ctxt_pP->module_id, ENB_FLAG_YES, - ue_mod_idP, + ue_context_pP->ue_context.rnti, 0, (RadioResourceConfigCommonSIB_t *) NULL, - eNB_rrc_inst[enb_mod_idP].physicalConfigDedicated[ue_mod_idP], + ue_context_pP->ue_context.physicalConfigDedicated, #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif (MeasObjectToAddMod_t **) NULL, - eNB_rrc_inst[enb_mod_idP].mac_MainConfig[ue_mod_idP], + ue_context_pP->ue_context.mac_MainConfig, DRB2LCHAN[i], (LogicalChannelConfig_t *) NULL, (MeasGapConfig_t *) NULL, @@ -2696,11 +3106,13 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete( } } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_generate_RRCConnectionSetup( - module_id_t enb_mod_idP, - frame_t frameP, - module_id_t ue_mod_idP) +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_RRCConnectionSetup( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +) +//----------------------------------------------------------------------------- { LogicalChannelConfig_t *SRB1_logicalChannelConfig; //,*SRB2_logicalChannelConfig; @@ -2708,25 +3120,23 @@ void rrc_eNB_generate_RRCConnectionSetup( SRB_ToAddMod_t *SRB1_config; int cnt; - AssertFatal(ue_mod_idP < NUMBER_OF_UE_MAX, "UE index invalid (%d/%d) for eNB %d!", ue_mod_idP, NUMBER_OF_UE_MAX, - enb_mod_idP); - - SRB_configList = &eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_idP]; - - eNB_rrc_inst[enb_mod_idP].Srb0.Tx_buffer.payload_size = - do_RRCConnectionSetup(enb_mod_idP, - (uint8_t *) eNB_rrc_inst[enb_mod_idP].Srb0.Tx_buffer.Payload, + SRB_configList = &ue_context_pP->ue_context.SRB_configList; + eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.payload_size = + do_RRCConnectionSetup(ctxt_pP, + ue_context_pP, + (uint8_t*) eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.Payload, (mac_xface->lte_frame_parms->nb_antennas_tx==2)?2:1, - ue_mod_idP, - rrc_eNB_get_next_transaction_identifier(enb_mod_idP), + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), mac_xface->lte_frame_parms, - SRB_configList, &eNB_rrc_inst[enb_mod_idP].physicalConfigDedicated[ue_mod_idP]); + SRB_configList, + &ue_context_pP->ue_context.physicalConfigDedicated); #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Connection Setup\n"); - for (cnt = 0; cnt < eNB_rrc_inst[enb_mod_idP].Srb0.Tx_buffer.payload_size; cnt++) - LOG_F(RRC,"%02x ", ((uint8_t*)eNB_rrc_inst[enb_mod_idP].Srb0.Tx_buffer.Payload)[cnt]); + for (cnt = 0; cnt < eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.payload_size; cnt++) { + LOG_F(RRC,"%02x ", ((uint8_t*)eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.Payload)[cnt]); + } LOG_F(RRC,"\n"); ////////////////////////////////// @@ -2751,20 +3161,24 @@ void rrc_eNB_generate_RRCConnectionSetup( } LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 UE %d) --->][MAC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, ue_mod_idP, enb_mod_idP); - rrc_mac_config_req(enb_mod_idP, ENB_FLAG_YES, ue_mod_idP, 0, + PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_mac_config_req( + ctxt_pP->module_id, + ENB_FLAG_YES, + ue_context_pP->ue_context.rnti, + 0, (RadioResourceConfigCommonSIB_t *) NULL, - eNB_rrc_inst[enb_mod_idP].physicalConfigDedicated[ue_mod_idP], + ue_context_pP->ue_context.physicalConfigDedicated, #ifdef Rel10 (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif (MeasObjectToAddMod_t **) NULL, - eNB_rrc_inst[enb_mod_idP].mac_MainConfig[ue_mod_idP], + ue_context_pP->ue_context.mac_MainConfig, 1, SRB1_logicalChannelConfig, - eNB_rrc_inst[enb_mod_idP].measGapConfig[ue_mod_idP], + ue_context_pP->ue_context.measGapConfig, (TDD_Config_t *) NULL, NULL, (uint8_t *) NULL, @@ -2780,17 +3194,32 @@ void rrc_eNB_generate_RRCConnectionSetup( } } } +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.Header, // LG WARNING + eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.payload_size, + MSC_AS_TIME_FMT" RRCConnectionSetup UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.payload_size); +#endif LOG_I(RRC, - "[eNB %d][RAPROC] Frame %d : Logical Channel DL-CCCH, Generating RRCConnectionSetup (bytes %d, UE %d)\n", - enb_mod_idP, frameP, eNB_rrc_inst[enb_mod_idP].Srb0.Tx_buffer.payload_size, ue_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCConnectionSetup (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.payload_size); } -/*------------------------------------------------------------------------------*/ #if defined(ENABLE_ITTI) -char openair_rrc_lite_eNB_init( - module_id_t enb_mod_idP) +char +//----------------------------------------------------------------------------- +openair_rrc_lite_eNB_init( + const module_id_t enb_mod_idP +) +//----------------------------------------------------------------------------- { /* Dummy function, initialization will be done through ITTI messaging */ return 0; @@ -2798,72 +3227,86 @@ char openair_rrc_lite_eNB_init( #endif #if defined(ENABLE_ITTI) -char openair_rrc_lite_eNB_configuration( - uint8_t enb_mod_idP, - RrcConfigurationReq * configuration) +//----------------------------------------------------------------------------- +char +openair_rrc_lite_eNB_configuration( + const module_id_t enb_mod_idP, + RrcConfigurationReq* configuration +) #else -char openair_rrc_lite_eNB_init( - module_id_t enb_mod_idP) +char +openair_rrc_lite_eNB_init( + const module_id_t enb_mod_idP +) #endif +//----------------------------------------------------------------------------- { - /*-----------------------------------------------------------------------------*/ - module_id_t j; - LOG_I(RRC, "[eNB %d] Init (UE State = RRC_IDLE)...\n", enb_mod_idP); + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, NOT_A_RNTI, 0, 0); + LOG_I(RRC, + PROTOCOL_RRC_CTXT_FMT" Init...\n", + PROTOCOL_RRC_CTXT_ARGS(&ctxt)); AssertFatal(eNB_rrc_inst != NULL, "eNB_rrc_inst not initialized!"); AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); - for (j = 0; j < NUMBER_OF_UE_MAX; j++) - eNB_rrc_inst[enb_mod_idP].Info.UE[j].Status = RRC_IDLE; //CH_READY; - -#if defined(ENABLE_USE_MME) - - /* Connect eNB to MME */ - if (EPC_MODE_ENABLED <= 0) -#endif - { - /* Init security parameters */ - for (j = 0; j < NUMBER_OF_UE_MAX; j++) { - eNB_rrc_inst[enb_mod_idP].ciphering_algorithm[j] = SecurityAlgorithmConfig__cipheringAlgorithm_eea0; - eNB_rrc_inst[enb_mod_idP].integrity_algorithm[j] = SecurityAlgorithmConfig__integrityProtAlgorithm_eia2; - rrc_lite_eNB_init_security(enb_mod_idP, j); - } - } - - eNB_rrc_inst[enb_mod_idP].Info.Nb_ue = 0; - - eNB_rrc_inst[enb_mod_idP].Srb0.Active = 0; - - for (j = 0; j < (NUMBER_OF_UE_MAX + 1); j++) { - eNB_rrc_inst[enb_mod_idP].Srb2[j].Active = 0; - } + // for (j = 0; j < NUMBER_OF_UE_MAX; j++) + // eNB_rrc_inst[ctxt.module_id].Info.UE[j].Status = RRC_IDLE; //CH_READY; + // + //#if defined(ENABLE_USE_MME) + // // Connect eNB to MME + // if (EPC_MODE_ENABLED <= 0) + //#endif + // { + // /* Init security parameters */ + // for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + // eNB_rrc_inst[ctxt.module_id].ciphering_algorithm[j] = SecurityAlgorithmConfig__cipheringAlgorithm_eea0; + // eNB_rrc_inst[ctxt.module_id].integrity_algorithm[j] = SecurityAlgorithmConfig__integrityProtAlgorithm_eia2; + // rrc_lite_eNB_init_security(enb_mod_idP, j); + // } + // } + eNB_rrc_inst[ctxt.module_id].Nb_ue = 0; + eNB_rrc_inst[ctxt.module_id].Srb0.Active = 0; + uid_linear_allocator_init(&eNB_rrc_inst[ctxt.module_id].uid_allocator); + RB_INIT(&eNB_rrc_inst[ctxt.module_id].rrc_ue_head); + RB_INIT(&eNB_rrc_inst[ctxt.module_id].rrc_rnti_head); + // for (j = 0; j < (NUMBER_OF_UE_MAX + 1); j++) { + // eNB_rrc_inst[enb_mod_idP].Srb2[j].Active = 0; + // } /// System Information INIT - LOG_I(RRC, "[eNB %d] Checking release \n", enb_mod_idP); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Checking release \n", + PROTOCOL_RRC_CTXT_ARGS(&ctxt)); #ifdef Rel10 // This has to come from some top-level configuration - LOG_I(RRC, "[eNB %d] Rel10 RRC detected, MBMS flag %d\n", enb_mod_idP, eNB_rrc_inst[enb_mod_idP].MBMS_flag); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Rel10 RRC detected, MBMS flag %d\n", + PROTOCOL_RRC_CTXT_ARGS(&ctxt), + eNB_rrc_inst[ctxt.module_id].MBMS_flag); #else - LOG_I(RRC, "[eNB %d] Rel8 RRC\n", enb_mod_idP); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Rel8 RRC\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); #endif #ifdef CBA - for (j = 0; j < NUM_MAX_CBA_GROUP; j++) - eNB_rrc_inst[enb_mod_idP].cba_rnti[j] = CBA_OFFSET + j; + for (j = 0; j < NUM_MAX_CBA_GROUP; j++) { + eNB_rrc_inst[ctxt.module_id].cba_rnti[j] = CBA_OFFSET + j; + } - if (eNB_rrc_inst[enb_mod_idP].num_active_cba_groups > NUM_MAX_CBA_GROUP) - eNB_rrc_inst[enb_mod_idP].num_active_cba_groups = NUM_MAX_CBA_GROUP; + if (eNB_rrc_inst[ctxt.module_id].num_active_cba_groups > NUM_MAX_CBA_GROUP) { + eNB_rrc_inst[ctxt.module_id].num_active_cba_groups = NUM_MAX_CBA_GROUP; + } - LOG_D(RRC, "[eNB %d] Initialization of 4 cba_RNTI values (%x %x %x %x) num active groups %d\n", - enb_mod_idP, eNB_rrc_inst[enb_mod_idP].cba_rnti[0], - eNB_rrc_inst[enb_mod_idP].cba_rnti[1], eNB_rrc_inst[enb_mod_idP].cba_rnti[2], - eNB_rrc_inst[enb_mod_idP].cba_rnti[3], eNB_rrc_inst[enb_mod_idP].num_active_cba_groups); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_FMT" Initialization of 4 cba_RNTI values (%x %x %x %x) num active groups %d\n", + PROTOCOL_RRC_CTXT_ARGS(&ctxt), + enb_mod_idP, eNB_rrc_inst[ctxt.module_id].cba_rnti[0], + eNB_rrc_inst[ctxt.module_id].cba_rnti[1], eNB_rrc_inst[ctxt.module_id].cba_rnti[2], + eNB_rrc_inst[ctxt.module_id].cba_rnti[3], eNB_rrc_inst[ctxt.module_id].num_active_cba_groups); #endif - init_SI(enb_mod_idP + init_SI(&ctxt #if defined(ENABLE_ITTI) , configuration #endif @@ -2871,39 +3314,39 @@ char openair_rrc_lite_eNB_init( #ifdef Rel10 - switch (eNB_rrc_inst[enb_mod_idP].MBMS_flag) { + switch (eNB_rrc_inst[ctxt.module_id].MBMS_flag) { case 1: case 2: case 3: - LOG_I(RRC, "[eNB %d] Configuring 1 MBSFN sync area\n", enb_mod_idP); - eNB_rrc_inst[enb_mod_idP].num_mbsfn_sync_area = 1; + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 1 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); + eNB_rrc_inst[ctxt.module_id].num_mbsfn_sync_area = 1; break; case 4: - LOG_I(RRC, "[eNB %d] Configuring 2 MBSFN sync area\n", enb_mod_idP); - eNB_rrc_inst[enb_mod_idP].num_mbsfn_sync_area = 2; + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 2 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); + eNB_rrc_inst[ctxt.module_id].num_mbsfn_sync_area = 2; break; default: - eNB_rrc_inst[enb_mod_idP].num_mbsfn_sync_area = 0; + eNB_rrc_inst[ctxt.module_id].num_mbsfn_sync_area = 0; break; } // if we are here the eNB_rrc_inst[enb_mod_idP].MBMS_flag > 0, /// MCCH INIT - if (eNB_rrc_inst[enb_mod_idP].MBMS_flag > 0) { - init_MCCH(enb_mod_idP); + if (eNB_rrc_inst[ctxt.module_id].MBMS_flag > 0) { + init_MCCH(ctxt.module_id); /// MTCH data bearer init - init_MBMS(enb_mod_idP, 0); + init_MBMS(ctxt.module_id, 0); } #endif #ifdef NO_RRM //init ch SRB0, SRB1 & BDTCH - openair_rrc_on(enb_mod_idP, 1); + openair_rrc_on(&ctxt); #else - eNB_rrc_inst[enb_mod_idP].Last_scan_req = 0; - send_msg(&S_rrc, msg_rrc_phy_synch_to_MR_ind(enb_mod_idP, eNB_rrc_inst[enb_mod_idP].Mac_id)); + eNB_rrc_inst[ctxt.module_id].Last_scan_req = 0; + send_msg(&S_rrc, msg_rrc_phy_synch_to_MR_ind(ctxt.module_id, eNB_rrc_inst[ctxt.module_id].Mac_id)); #endif return 0; @@ -2911,37 +3354,40 @@ char openair_rrc_lite_eNB_init( } /*------------------------------------------------------------------------------*/ -int rrc_eNB_decode_ccch( - module_id_t enb_mod_idP, - frame_t frameP, - SRB_INFO * Srb_info) +int +rrc_eNB_decode_ccch( + protocol_ctxt_t* const ctxt_pP, + const SRB_INFO* const Srb_info +) +//----------------------------------------------------------------------------- { - /*------------------------------------------------------------------------------*/ - - module_id_t Idx, ue_mod_id = 0; + module_id_t Idx; asn_dec_rval_t dec_rval; UL_CCCH_Message_t *ul_ccch_msg = NULL; - RRCConnectionRequest_r8_IEs_t *rrcConnectionRequest; - RRCConnectionReestablishmentRequest_r8_IEs_t *rrcConnectionReestablishmentRequest; + RRCConnectionRequest_r8_IEs_t* rrcConnectionRequest = NULL; + RRCConnectionReestablishmentRequest_r8_IEs_t* rrcConnectionReestablishmentRequest = NULL; int i, rval; - protocol_ctxt_t ctxt; - - ctxt.enb_module_id = enb_mod_idP; - ctxt.frame = frameP; - ctxt.enb_flag = ENB_FLAG_YES; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint64_t random_value = 0; //memset(ul_ccch_msg,0,sizeof(UL_CCCH_Message_t)); - LOG_D(RRC, "[eNB %d] Frame %d: Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n", - enb_mod_idP, frameP, ((uint8_t *) Srb_info->Rx_buffer.Payload)[0], + LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ((uint8_t*) Srb_info->Rx_buffer.Payload)[0], ((uint8_t *) Srb_info->Rx_buffer.Payload)[1], ((uint8_t *) Srb_info->Rx_buffer.Payload)[2], ((uint8_t *) Srb_info->Rx_buffer.Payload)[3], ((uint8_t *) Srb_info->Rx_buffer.Payload)[4], ((uint8_t *) Srb_info->Rx_buffer.Payload)[5], (uint8_t *) Srb_info->Rx_buffer.Payload); - dec_rval = - uper_decode(NULL, &asn_DEF_UL_CCCH_Message, (void **)&ul_ccch_msg, - (uint8_t *) Srb_info->Rx_buffer.Payload, 100, 0, 0); + dec_rval = uper_decode( + NULL, + &asn_DEF_UL_CCCH_Message, + (void**)&ul_ccch_msg, + (uint8_t*) Srb_info->Rx_buffer.Payload, + 100, + 0, + 0); #if defined(ENABLE_ITTI) # if defined(DISABLE_ITTI_XER_PRINT) @@ -2951,7 +3397,7 @@ int rrc_eNB_decode_ccch( message_p = itti_alloc_new_message(TASK_RRC_ENB, RRC_UL_CCCH_MESSAGE); memcpy(&message_p->ittiMsg, (void *)ul_ccch_msg, sizeof(RrcUlCcchMessage)); - itti_send_msg_to_task(TASK_UNKNOWN, enb_mod_idP, message_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, message_p); } # else { @@ -2966,17 +3412,20 @@ int rrc_eNB_decode_ccch( msg_p->ittiMsg.rrc_ul_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ul_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, enb_mod_idP, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif - for (i = 0; i < 8; i++) + for (i = 0; i < 8; i++) { LOG_T(RRC, "%x.", ((uint8_t *) & ul_ccch_msg)[i]); + } if (dec_rval.consumed == 0) { - LOG_E(RRC, "[eNB %d] FATAL Error in receiving CCCH\n", enb_mod_idP); + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" FATAL Error in receiving CCCH\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); return -1; } @@ -2985,26 +3434,29 @@ int rrc_eNB_decode_ccch( switch (ul_ccch_msg->message.choice.c1.present) { case UL_CCCH_MessageType__c1_PR_NOTHING: - LOG_I(RRC, "[eNB %d] Frame %d : Received PR_NOTHING on UL-CCCH-Message\n", enb_mod_idP, frameP); + LOG_I(RRC, + PROTOCOL_RRC_CTXT_FMT" Received PR_NOTHING on UL-CCCH-Message\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); break; case UL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentRequest: #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Connection Reestablishement Request\n"); - for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) + for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Srb_info->Rx_buffer.Payload)[i]); + } LOG_F(RRC,"\n"); #endif LOG_D(RRC, - "[FRAME %05d][MAC_eNB][MOD %02d][][--- MAC_DATA_IND (rrcConnectionReestablishmentRequest on SRB0) -->][RRC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, enb_mod_idP); - - rrcConnectionReestablishmentRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionReestablishmentRequest.criticalExtensions.choice.rrcConnectionReestablishmentRequest_r8; - - LOG_I(RRC, "[eNB %d] Frame %d UE %d: RRCConnectionReestablishmentRequest cause %s\n", enb_mod_idP, - frameP, ue_mod_id, + PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB--- MAC_DATA_IND (rrcConnectionReestablishmentRequest on SRB0) --> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrcConnectionReestablishmentRequest = + &ul_ccch_msg->message.choice.c1.choice.rrcConnectionReestablishmentRequest.criticalExtensions.choice.rrcConnectionReestablishmentRequest_r8; + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest cause %s\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), ((rrcConnectionReestablishmentRequest->reestablishmentCause == ReestablishmentCause_otherFailure) ? "Other Failure" : (rrcConnectionReestablishmentRequest->reestablishmentCause == ReestablishmentCause_handoverFailure) ? "Handover Failure" : "reconfigurationFailure")); @@ -3029,166 +3481,224 @@ int rrc_eNB_decode_ccch( #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Connection Request\n"); - for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) + for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Srb_info->Rx_buffer.Payload)[i]); + } LOG_F(RRC,"\n"); #endif LOG_D(RRC, - "[FRAME %05d][MAC_eNB][MOD %02d][][--- MAC_DATA_IND (rrcConnectionRequest on SRB0) -->][RRC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, enb_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB --- MAC_DATA_IND (rrcConnectionRequest on SRB0) --> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + ue_context_p = rrc_eNB_get_ue_context( + &eNB_rrc_inst[ctxt_pP->module_id], + ctxt_pP->rnti); + + if (ue_context_p != NULL) { + // erase content + rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_p); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_discarded_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Srb_info->Rx_buffer.Payload, + dec_rval.consumed, + MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (UE already in context)", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + dec_rval.consumed); +#endif + } else { rrcConnectionRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionRequest.criticalExtensions.choice.rrcConnectionRequest_r8; { - uint64_t random_value = 0; - memcpy(((uint8_t *) & random_value) + 3, rrcConnectionRequest->ue_Identity.choice.randomValue.buf, + memcpy(((uint8_t*) & random_value) + 3, + rrcConnectionRequest->ue_Identity.choice.randomValue.buf, rrcConnectionRequest->ue_Identity.choice.randomValue.size); - ue_mod_id = rrc_eNB_get_next_free_UE_index(enb_mod_idP, random_value); + ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value); } + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE context: %X\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p); - if (ue_mod_id != UE_MODULE_INVALID) { - ctxt.ue_module_id = ue_mod_id; + if (ue_context_p != NULL) { #if defined(ENABLE_ITTI) /* Check s-TMSI presence in message */ - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_id].Initialue_identity_s_TMSI.presence = + ue_context_p->ue_context.Initialue_identity_s_TMSI.presence = (rrcConnectionRequest->ue_Identity.present == InitialUE_Identity_PR_s_TMSI); - if (eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_id].Initialue_identity_s_TMSI.presence) { + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence) { /* Save s-TMSI */ S_TMSI_t s_TMSI = rrcConnectionRequest->ue_Identity.choice.s_TMSI; - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_id].Initialue_identity_s_TMSI.mme_code = + ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = BIT_STRING_to_uint8(&s_TMSI.mmec); - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_id].Initialue_identity_s_TMSI.m_tmsi = + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = BIT_STRING_to_uint32(&s_TMSI.m_TMSI); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_discarded_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Srb_info->Rx_buffer.Payload, + dec_rval.consumed, + MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (s-TMSI mmec %u m_TMSI %u random UE id (0x%" PRIx64 ")", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + dec_rval.consumed, + s_TMSI.mmec, + s_TMSI.m_TMSI, + ue_context_p->ue_context.random_ue_identity); +#endif + } else { +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_discarded_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Srb_info->Rx_buffer.Payload, + dec_rval.consumed, + MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u random UE id (0x%" PRIx64 ")", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + dec_rval.consumed, + ue_context_p->ue_context.random_ue_identity); +#endif } - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_id].establishment_cause = + ue_context_p->ue_context.establishment_cause = rrcConnectionRequest->establishmentCause; + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE random UE identity (0x%" PRIx64 ") MME code %u TMSI %u cause %u\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p->ue_context.random_ue_identity, + ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code, + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.establishment_cause); +#else + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection for UE random UE identity (0x%" PRIx64 ")\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p->ue_context.random_ue_identity); #endif + eNB_rrc_inst[ctxt_pP->module_id].Nb_ue++; - // memcpy(&Rrc_xface->UE_id[enb_mod_idP][ue_mod_idP],(uint8_t *)rrcConnectionRequest->ue_Identity.choice.randomValue.buf,5); - memcpy(&eNB_rrc_inst[enb_mod_idP].Info.UE_list[ue_mod_id], - (uint8_t *) rrcConnectionRequest->ue_Identity.choice.randomValue.buf, 5); - - LOG_I(RRC, "[eNB %d] Frame %d : Accept new connection from UE %d (0x%" PRIx64 ")\n", - enb_mod_idP, frameP, ue_mod_id, eNB_rrc_inst[enb_mod_idP].Info.UE_list[ue_mod_id]); - - //CONFIG SRB2 (DCCHs, ONE per User) //meas && lchan Cfg - //eNB_rrc_inst[enb_mod_idP].Info.Dtch_bd_config[ue_mod_idP].Status=NEED_RADIO_CONFIG; - //eNB_rrc_inst[enb_mod_idP].Info.Dtch_bd_config[ue_mod_idP].Next_eNBeck_frame=Rrc_xface->Frame_index+1; - eNB_rrc_inst[enb_mod_idP].Info.Nb_ue++; + } else { + // no context available + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Can't create new context for UE random UE identity (0x%" PRIx64 ")\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p->ue_context.random_ue_identity); + return -1; + } + } #ifndef NO_RRM - send_msg(&S_rrc, msg_rrc_MR_attach_ind(enb_mod_idP, Mac_id)); + send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id)); #else //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; Idx = DCCH; // SRB1 - eNB_rrc_inst[enb_mod_idP].Srb1[ue_mod_id].Active = 1; - eNB_rrc_inst[enb_mod_idP].Srb1[ue_mod_id].Srb_info.Srb_id = Idx; - memcpy(&eNB_rrc_inst[enb_mod_idP].Srb1[ue_mod_id].Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, + ue_context_p->ue_context.Srb1.Active = 1; + ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx; + memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0], + &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - memcpy(&eNB_rrc_inst[enb_mod_idP].Srb1[ue_mod_id].Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, + memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1], + &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); // SRB2 - eNB_rrc_inst[enb_mod_idP].Srb2[ue_mod_id].Active = 1; - eNB_rrc_inst[enb_mod_idP].Srb2[ue_mod_id].Srb_info.Srb_id = Idx; - memcpy(&eNB_rrc_inst[enb_mod_idP].Srb2[ue_mod_id].Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, + ue_context_p->ue_context.Srb2.Active = 1; + ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx; + memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0], + &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - memcpy(&eNB_rrc_inst[enb_mod_idP].Srb2[ue_mod_id].Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, + memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1], + &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - rrc_eNB_generate_RRCConnectionSetup(enb_mod_idP, frameP, ue_mod_id); - //LOG_D(RRC, "[MSC_NBOX][FRAME %05d][RRC_eNB][MOD %02d][][Tx RRCConnectionSetup][RRC_eNB][MOD %02d][]\n", - // frameP, enb_mod_idP, enb_mod_idP); - - //LOG_D(RRC,"[eNB %d] RLC AM allocation index@0 is %d\n",enb_mod_idP,rlc[enb_mod_idP].m_rlc_am_array[0].allocation); - //LOG_D(RRC,"[eNB %d] RLC AM allocation index@1 is %d\n",enb_mod_idP,rlc[enb_mod_idP].m_rlc_am_array[1].allocation); - LOG_I(RRC, "[eNB %d] CALLING RLC CONFIG SRB1 (rbid %d) for UE %d\n", enb_mod_idP, Idx, ue_mod_id); - - // rrc_pdcp_config_req (enb_mod_idP, frameP, 1, CONFIG_ACTION_ADD, idx, UNDEF_SECURITY_MODE); - - // rrc_rlc_config_req(enb_mod_idP,frameP,1,CONFIG_ACTION_ADD,Idx,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - - rrc_pdcp_config_asn1_req(&ctxt, - eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_id], + rrc_eNB_generate_RRCConnectionSetup(ctxt_pP, ue_context_p); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + Idx); + rrc_pdcp_config_asn1_req(ctxt_pP, + ue_context_p->ue_context.SRB_configList, (DRB_ToAddModList_t *) NULL, - (DRB_ToReleaseList_t *) NULL, 0xff, NULL, NULL, NULL + (DRB_ToReleaseList_t*) NULL, + 0xff, + NULL, + NULL, + NULL # ifdef Rel10 , (PMCH_InfoList_r9_t *) NULL # endif ); - rrc_rlc_config_asn1_req(&ctxt, - eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_id], - (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL + rrc_rlc_config_asn1_req(ctxt_pP, + ue_context_p->ue_context.SRB_configList, + (DRB_ToAddModList_t*) NULL, + (DRB_ToReleaseList_t*) NULL # ifdef Rel10 , (PMCH_InfoList_r9_t *) NULL # endif ); - //LOG_D(RRC,"[eNB %d] RLC AM allocation index@0 is %d\n",enb_mod_idP,rlc[enb_mod_idP].m_rlc_am_array[0].allocation); - //LOG_D(RRC,"[eNB %d] RLC AM allocation index@1 is %d\n",enb_mod_idP,rlc[enb_mod_idP].m_rlc_am_array[1].allocation); - - /* - - LOG_D(RRC,"[eNB %d] CALLING RLC CONFIG SRB2 (rbid %d) for UE %d\n", - enb_mod_idP,Idx+1,ue_mod_idP); - Mac_rlc_xface->rrc_rlc_config_req(enb_mod_idP,CONFIG_ACTION_ADD,Idx+1,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - LOG_D(RRC,"[eNB %d] RLC AM allocation index@0 is %d\n",enb_mod_idP,rlc[enb_mod_idP].m_rlc_am_array[0].allocation); - LOG_D(RRC,"[eNB %d] RLC AM allocation index@1 is %d\n",rlc[enb_mod_idP].m_rlc_am_array[1].allocation); - */ #endif //NO_RRM - } else { - LOG_E(RRC, "can't add UE, max user count reached!\n"); - } break; default: - LOG_E(RRC, "[eNB %d] Frame %d : Unknown message\n", enb_mod_idP, frameP); + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); rval = -1; break; } rval = 0; } else { - LOG_E(RRC, "[eNB %d] Frame %d : Unknown error \n", enb_mod_idP, frameP); + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown error \n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); rval = -1; } return rval; } -/*------------------------------------------------------------------------------*/ -int rrc_eNB_decode_dcch( - module_id_t enb_mod_idP, - frame_t frameP, - uint8_t Srb_id, - module_id_t ue_mod_idP, - uint8_t *Rx_sdu, - sdu_size_t sdu_sizeP) +//----------------------------------------------------------------------------- +int +rrc_eNB_decode_dcch( + const protocol_ctxt_t* const ctxt_pP, + const rb_id_t Srb_id, + const uint8_t* const Rx_sdu, + const sdu_size_t sdu_sizeP +) +//----------------------------------------------------------------------------- { - /*------------------------------------------------------------------------------*/ asn_dec_rval_t dec_rval; //UL_DCCH_Message_t uldcchmsg; UL_DCCH_Message_t *ul_dcch_msg = NULL; //&uldcchmsg; UE_EUTRA_Capability_t *UE_EUTRA_Capability = NULL; int i; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; if ((Srb_id != 1) && (Srb_id != 2)) { - LOG_E(RRC, "[eNB %d] Frame %d: Received message on SRB%d, should not have ...\n", enb_mod_idP, frameP, Srb_id); + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received message on SRB%d, should not have ...\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + Srb_id); } //memset(ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); - LOG_D(RRC, "[eNB %d] Frame %d: Decoding UL-DCCH Message\n", enb_mod_idP, frameP); - dec_rval = uper_decode(NULL, &asn_DEF_UL_DCCH_Message, (void **)&ul_dcch_msg, Rx_sdu, sdu_sizeP, 0, 0); + LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL-DCCH Message\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + dec_rval = uper_decode( + NULL, + &asn_DEF_UL_DCCH_Message, + (void**)&ul_dcch_msg, + Rx_sdu, + sdu_sizeP, + 0, + 0); #if defined(ENABLE_ITTI) # if defined(DISABLE_ITTI_XER_PRINT) @@ -3198,7 +3708,7 @@ int rrc_eNB_decode_dcch( message_p = itti_alloc_new_message(TASK_RRC_ENB, RRC_UL_DCCH_MESSAGE); memcpy(&message_p->ittiMsg, (void *)ul_dcch_msg, sizeof(RrcUlDcchMessage)); - itti_send_msg_to_task(TASK_UNKNOWN, enb_mod_idP, message_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, message_p); } # else { @@ -3213,23 +3723,29 @@ int rrc_eNB_decode_dcch( msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, enb_mod_idP, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif { - for (i = 0; i < sdu_sizeP; i++) + for (i = 0; i < sdu_sizeP; i++) { LOG_T(RRC, "%x.", Rx_sdu[i]); + } LOG_T(RRC, "\n"); } if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(RRC, "[UE %d] Frame %d : Failed to decode UL-DCCH (%d bytes)\n", enb_mod_idP, frameP, dec_rval.consumed); + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Failed to decode UL-DCCH (%d bytes)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + dec_rval.consumed); return -1; } + ue_context_p = rrc_eNB_get_ue_context( + &eNB_rrc_inst[ctxt_pP->module_id], + ctxt_pP->rnti); if (ul_dcch_msg->message.present == UL_DCCH_MessageType_PR_c1) { @@ -3242,10 +3758,14 @@ int rrc_eNB_decode_dcch( case UL_DCCH_MessageType__c1_PR_measurementReport: LOG_D(RRC, - "[FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND " - "%d bytes (measurementReport) --->][RRC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, DCCH, sdu_sizeP, enb_mod_idP); - rrc_eNB_process_MeasurementReport(enb_mod_idP, frameP, ue_mod_idP, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND " + "%d bytes (measurementReport) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); + rrc_eNB_process_MeasurementReport( + ctxt_pP, + ue_context_p, &ul_dcch_msg->message.choice.c1.choice.measurementReport. criticalExtensions.choice.c1.choice.measurementReport_r8.measResults); break; @@ -3254,33 +3774,53 @@ int rrc_eNB_decode_dcch( #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Connection Reconfiguration Complete\n"); - for (i = 0; i < sdu_sizeP; i++) + for (i = 0; i < sdu_sizeP; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]); + } LOG_F(RRC,"\n"); +#endif +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" RRCConnectionReconfigurationComplete UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); #endif LOG_D(RRC, - "[FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " - "(RRCConnectionReconfigurationComplete) --->][RRC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, DCCH, sdu_sizeP, enb_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(RRCConnectionReconfigurationComplete) ---> RRC_eNB]\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions. present == RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8) { - rrc_eNB_process_RRCConnectionReconfigurationComplete(enb_mod_idP, frameP, ue_mod_idP, + rrc_eNB_process_RRCConnectionReconfigurationComplete( + ctxt_pP, + ue_context_p, &ul_dcch_msg->message.choice.c1.choice. rrcConnectionReconfigurationComplete. criticalExtensions.choice. rrcConnectionReconfigurationComplete_r8); - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_idP].Status = RRC_RECONFIGURED; - LOG_I(RRC, "[eNB %d] UE %d State = RRC_RECONFIGURED \n", enb_mod_idP, ue_mod_idP); + ue_context_p->ue_context.Status = RRC_RECONFIGURED; + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED \n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); } #if defined(ENABLE_USE_MME) # if defined(ENABLE_ITTI) if (EPC_MODE_ENABLED == 1) { - rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(enb_mod_idP, ue_mod_idP); + rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( + ctxt_pP, + ue_context_p); } # endif @@ -3291,45 +3831,71 @@ int rrc_eNB_decode_dcch( #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Connection Reestablishment Complete\n"); - for (i = 0; i < sdu_sizeP; i++) + for (i = 0; i < sdu_sizeP; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]); + } LOG_F(RRC,"\n"); +#endif +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" rrcConnectionReestablishmentComplete UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); #endif LOG_I(RRC, - "[FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " - "(rrcConnectionReestablishmentComplete) --->][RRC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, DCCH, sdu_sizeP, enb_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(rrcConnectionReestablishmentComplete) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); break; case UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete: #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Connection SetupComplete\n"); - for (i = 0; i < sdu_sizeP; i++) + for (i = 0; i < sdu_sizeP; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]); + } LOG_F(RRC,"\n"); +#endif +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" RRCConnectionSetupComplete UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); #endif LOG_D(RRC, - "[FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " - "(RRCConnectionSetupComplete) --->][RRC_eNB][MOD %02d][]\n", - frameP, enb_mod_idP, DCCH, sdu_sizeP, enb_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(RRCConnectionSetupComplete) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.present == RRCConnectionSetupComplete__criticalExtensions_PR_c1) { if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1. present == RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8) { - rrc_eNB_process_RRCConnectionSetupComplete(enb_mod_idP, frameP, ue_mod_idP, - &ul_dcch_msg->message.choice.c1.choice. - rrcConnectionSetupComplete.criticalExtensions.choice. - c1.choice.rrcConnectionSetupComplete_r8); - eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_idP].Status = RRC_CONNECTED; - LOG_I(RRC, "[eNB %d] UE %d State = RRC_CONNECTED \n", enb_mod_idP, ue_mod_idP); - LOG_D(RRC, - "[MSC_NBOX][FRAME %05d][RRC_eNB][MOD %02d][][Rx RRCConnectionSetupComplete\n" - "Now CONNECTED with UE %d][RRC_eNB][MOD %02d][]\n", frameP, enb_mod_idP, ue_mod_idP, enb_mod_idP); + rrc_eNB_process_RRCConnectionSetupComplete( + ctxt_pP, + ue_context_p, + &ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8); + ue_context_p->ue_context.Status = RRC_CONNECTED; + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); } } @@ -3339,62 +3905,112 @@ int rrc_eNB_decode_dcch( #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Security Mode Complete\n"); - for (i = 0; i < sdu_sizeP; i++) + for (i = 0; i < sdu_sizeP; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]); + } LOG_F(RRC,"\n"); +#endif +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" securityModeComplete UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); #endif LOG_I(RRC, - "[eNB %d] Frame %d received securityModeComplete on UL-DCCH %d from UE %d\n", - enb_mod_idP, frameP, DCCH, ue_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" received securityModeComplete on UL-DCCH %d from UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH); LOG_D(RRC, - "[FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " - "(securityModeComplete) --->][RRC_eNB][MOD %02d][]\n", frameP, enb_mod_idP, DCCH, sdu_sizeP, enb_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(securityModeComplete) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); #ifdef XER_PRINT xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg); #endif // confirm with PDCP about the security mode for DCCH //rrc_pdcp_config_req (enb_mod_idP, frameP, 1,CONFIG_ACTION_SET_SECURITY_MODE, (ue_mod_idP * NB_RB_MAX) + DCCH, 0x77); // continue the procedure - rrc_eNB_generate_UECapabilityEnquiry(enb_mod_idP, frameP, ue_mod_idP); + rrc_eNB_generate_UECapabilityEnquiry( + ctxt_pP, + ue_context_p); break; case UL_DCCH_MessageType__c1_PR_securityModeFailure: #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Security Mode Failure\n"); - for (i = 0; i < sdu_sizeP; i++) + for (i = 0; i < sdu_sizeP; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]); + } LOG_F(RRC,"\n"); #endif - LOG_D(RRC, - "[FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " - "(securityModeFailure) --->][RRC_eNB][MOD %02d][]\n", frameP, enb_mod_idP, DCCH, sdu_sizeP, enb_mod_idP); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" securityModeFailure UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); +#endif + LOG_W(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(securityModeFailure) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); #ifdef XER_PRINT xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg); #endif // cancel the security mode in PDCP // followup with the remaining procedure - rrc_eNB_generate_UECapabilityEnquiry(enb_mod_idP, frameP, ue_mod_idP); +#warning "LG Removed rrc_eNB_generate_UECapabilityEnquiry after receiving securityModeFailure" + // LG commented rrc_eNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); break; case UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC UECapablility Information \n"); - for (i = 0; i < sdu_sizeP; i++) + for (i = 0; i < sdu_sizeP; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]); + } LOG_F(RRC,"\n"); +#endif +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" ueCapabilityInformation UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); #endif LOG_I(RRC, - "[eNB %d] Frame %d received ueCapabilityInformation on UL-DCCH %d from UE %d\n", - enb_mod_idP, frameP, DCCH, ue_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" received ueCapabilityInformation on UL-DCCH %d from UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH); LOG_D(RRC, - "[FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " - "(UECapabilityInformation) --->][RRC_eNB][MOD %02d][]\n", frameP, enb_mod_idP, DCCH, sdu_sizeP, enb_mod_idP); + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(UECapabilityInformation) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); #ifdef XER_PRINT xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg); #endif @@ -3414,13 +4030,16 @@ int rrc_eNB_decode_dcch( #if defined(ENABLE_USE_MME) if (EPC_MODE_ENABLED == 1) { - rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(enb_mod_idP, ue_mod_idP, ul_dcch_msg); + rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(ctxt_pP, + ue_context_p, + ul_dcch_msg); } #endif - rrc_eNB_generate_defaultRRCConnectionReconfiguration(enb_mod_idP, frameP, - ue_mod_idP, eNB_rrc_inst[enb_mod_idP].HO_flag); + rrc_eNB_generate_defaultRRCConnectionReconfiguration(ctxt_pP, + ue_context_p, + eNB_rrc_inst[ctxt_pP->module_id].HO_flag); break; case UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer: @@ -3430,16 +4049,30 @@ int rrc_eNB_decode_dcch( #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC UL Information Transfer \n"); - for (i = 0; i < sdu_sizeP; i++) + for (i = 0; i < sdu_sizeP; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]); + } LOG_F(RRC,"\n"); #endif +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" ulInformationTransfer UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); +#endif #if defined(ENABLE_USE_MME) if (EPC_MODE_ENABLED == 1) { - rrc_eNB_send_S1AP_UPLINK_NAS(enb_mod_idP, ue_mod_idP, ul_dcch_msg); + rrc_eNB_send_S1AP_UPLINK_NAS(ctxt_pP, + ue_context_p, + ul_dcch_msg); } #endif @@ -3467,30 +4100,37 @@ int rrc_eNB_decode_dcch( #endif default: - LOG_E(RRC, "[UE %d] Frame %d : Unknown message\n", enb_mod_idP, frameP); + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message %s:%u\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + __FILE__, __LINE__); return -1; } return 0; } else { - LOG_E(RRC, "[UE %d] Frame %d : Unknown error\n", enb_mod_idP, frameP); + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown error %s:%u\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + __FILE__, __LINE__); return -1; } } #if defined(ENABLE_ITTI) -/*------------------------------------------------------------------------------*/ -void *rrc_enb_task( - void *args_p) +//----------------------------------------------------------------------------- +void* +rrc_enb_task( + void* args_p +) +//----------------------------------------------------------------------------- { MessageDef *msg_p; const char *msg_name_p; instance_t instance; - unsigned int ue_mod_id; int result; SRB_INFO *srb_info_p; + protocol_ctxt_t ctxt; itti_mark_task_ready(TASK_RRC_ENB); while (1) { @@ -3511,25 +4151,40 @@ void *rrc_enb_task( /* Messages from MAC */ case RRC_MAC_CCCH_DATA_IND: - LOG_I(RRC, "[eNB %d] Received %s: frameP %d,\n", instance, msg_name_p, - RRC_MAC_CCCH_DATA_IND(msg_p).frame); + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, + instance, + ENB_FLAG_YES, + RRC_MAC_CCCH_DATA_IND(msg_p).rnti, + msg_p->ittiMsgHeader.lte_time.frame, + msg_p->ittiMsgHeader.lte_time.slot); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received %s\n", + PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt), + msg_name_p); srb_info_p = &eNB_rrc_inst[instance].Srb0; - memcpy(srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND(msg_p).sdu, + memcpy(srb_info_p->Rx_buffer.Payload, + RRC_MAC_CCCH_DATA_IND(msg_p).sdu, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size; - rrc_eNB_decode_ccch(instance, RRC_MAC_CCCH_DATA_IND(msg_p).frame, srb_info_p); + rrc_eNB_decode_ccch(&ctxt, srb_info_p); break; /* Messages from PDCP */ case RRC_DCCH_DATA_IND: - LOG_I(RRC, "[eNB %d][UE %d] Received %s: frameP %d, DCCH %d\n", instance, - RRC_DCCH_DATA_IND(msg_p).ue_index, msg_name_p, RRC_DCCH_DATA_IND(msg_p).frame, - RRC_DCCH_DATA_IND(msg_p).dcch_index); - - rrc_eNB_decode_dcch(instance, RRC_DCCH_DATA_IND(msg_p).frame, RRC_DCCH_DATA_IND(msg_p).dcch_index, - RRC_DCCH_DATA_IND(msg_p).ue_index, RRC_DCCH_DATA_IND(msg_p).sdu_p, + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, + instance, + ENB_FLAG_YES, + RRC_DCCH_DATA_IND(msg_p).rnti, + msg_p->ittiMsgHeader.lte_time.frame, + msg_p->ittiMsgHeader.lte_time.slot); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received on DCCH %d %s\n", + PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt), + RRC_DCCH_DATA_IND(msg_p).dcch_index, + msg_name_p); + rrc_eNB_decode_dcch(&ctxt, + RRC_DCCH_DATA_IND(msg_p).dcch_index, + RRC_DCCH_DATA_IND(msg_p).sdu_p, RRC_DCCH_DATA_IND(msg_p).sdu_size); // Message buffer has been processed, free it now. @@ -3565,7 +4220,13 @@ void *rrc_enb_task( break; case GTPV1U_ENB_CREATE_TUNNEL_RESP: - rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(msg_p, msg_name_p, instance); + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, + instance, + ENB_FLAG_YES, + GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_p).rnti, + msg_p->ittiMsgHeader.lte_time.frame, + msg_p->ittiMsgHeader.lte_time.slot); + rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(&ctxt, msg_p, msg_name_p); break; case GTPV1U_ENB_DELETE_TUNNEL_RESP: @@ -3579,7 +4240,7 @@ void *rrc_enb_task( /* Messages from eNB app */ case RRC_CONFIGURATION_REQ: LOG_I(RRC, "[eNB %d] Received %s\n", instance, msg_name_p); - openair_rrc_lite_eNB_configuration(instance, &RRC_CONFIGURATION_REQ(msg_p)); + openair_rrc_lite_eNB_configuration(ENB_INSTANCE_TO_MODULE_ID(instance), &RRC_CONFIGURATION_REQ(msg_p)); break; # ifdef ENABLE_RAL @@ -3592,12 +4253,20 @@ void *rrc_enb_task( //SPECTRA: Add the RRC connection reconfiguration with Second cell configuration case RRC_RAL_CONNECTION_RECONFIGURATION_REQ: // ue_mod_id = 0; /* TODO force ue_mod_id to first UE, NAS UE not virtualized yet */ +#warning "TODO GET RIGHT RNTI" + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, + instance, + ENB_FLAG_YES, + NOT_A_RNTI, // TO DO GET RIGHT RNTI + msg_p->ittiMsgHeader.lte_time.frame, + msg_p->ittiMsgHeader.lte_time.slot); LOG_I(RRC, "[eNB %d] Send RRC_RAL_CONNECTION_RECONFIGURATION_REQ to UE %s\n", instance, msg_name_p); //Method RRC connection reconfiguration command with Second cell configuration # ifdef ENABLE_RAL - rrc_eNB_generate_RRCConnectionReconfiguration_SCell(instance, 0/* TODO put frameP number ! */, /*ue_mod_id force ue_mod_id to first UE*/0, 36126); + //rrc_eNB_generate_RRCConnectionReconfiguration_SCell(instance, 0/* TODO put frameP number ! */, /*ue_mod_id force ue_mod_id to first UE*/0, 36126); # else - rrc_eNB_generate_defaultRRCConnectionReconfiguration(instance, 0/* TODO put frameP number ! */, /*ue_mod_id force ue_mod_id to first UE*/0, eNB_rrc_inst[instance].HO_flag); + //rrc_eNB_generate_defaultRRCConnectionReconfiguration(instance, 0/* TODO put frameP number ! */, /*ue_mod_id force ue_mod_id to first UE*/0, + // eNB_rrc_inst[instance].HO_flag); # endif break; diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c b/openair2/RRC/LITE/rrc_eNB_GTPV1U.c index 1a2ac603186..4e1ef94c097 100755 --- a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c +++ b/openair2/RRC/LITE/rrc_eNB_GTPV1U.c @@ -39,40 +39,45 @@ # include "extern.h" # include "RRC/LITE/MESSAGES/asn1_msg.h" # include "rrc_eNB_GTPV1U.h" +# include "rrc_eNB_UE_context.h" # if defined(ENABLE_ITTI) # include "asn1_conversions.h" # include "intertask_interface.h" # endif -int rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(MessageDef *msg_pP, const char *msg_name_pP, instance_t instanceP) +int +rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( + const protocol_ctxt_t* const ctxt_pP, + MessageDef* msg_pP, + const char* msg_name_pP +) { - uint8_t ue_index; + rnti_t rnti; int i; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; if (msg_pP) { - LOG_D(RRC, "[eNB] RX %s num tunnels %u \n", + LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" RX %s num tunnels %u \n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), msg_name_pP, GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).num_tunnels); - ue_index = GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).ue_index; - - // !!! - instanceP = 0; + rnti = GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).rnti; + ue_context_p = rrc_eNB_get_ue_context( + &eNB_rrc_inst[ctxt_pP->module_id], + ctxt_pP->rnti); for (i = 0; i < GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).num_tunnels; i++) { - LOG_D(RRC, "[eNB] instance %u ue index %u rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel %u bearer index %u id %u\n", - instanceP, - ue_index, + LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel %u bearer index %u id %u\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).enb_S1u_teid[i], i, GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).eps_bearer_id[i]); - eNB_rrc_inst[instanceP].Info.UE[ue_index].enb_gtp_teid[i] = GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).enb_S1u_teid[i]; - eNB_rrc_inst[instanceP].Info.UE[ue_index].enb_gtp_addrs[i] = GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).enb_addr; - eNB_rrc_inst[instanceP].Info.UE[ue_index].enb_gtp_ebi[i] = GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).eps_bearer_id[i]; + ue_context_p->ue_context.enb_gtp_teid[i] = GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).enb_S1u_teid[i]; + ue_context_p->ue_context.enb_gtp_addrs[i] = GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).enb_addr; + ue_context_p->ue_context.enb_gtp_ebi[i] = GTPV1U_ENB_CREATE_TUNNEL_RESP(msg_pP).eps_bearer_id[i]; } - - LOG_D(RRC, "[eNB] RX %s END\n"); return 0; } else { return -1; diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.h b/openair2/RRC/LITE/rrc_eNB_GTPV1U.h index 924dc5b8d5d..99afe8c291e 100755 --- a/openair2/RRC/LITE/rrc_eNB_GTPV1U.h +++ b/openair2/RRC/LITE/rrc_eNB_GTPV1U.h @@ -42,13 +42,18 @@ # if defined(ENABLE_ITTI) -/*! \fn rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(MessageDef *msg_pP, const char *msg_name_pP, instance_t instanceP) +/*! \fn rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t* const ctxt_pP, MessageDef *msg_pP, const char *msg_name_pP) *\brief Process GTPV1U_ENB_CREATE_TUNNEL_RESP message received from GTPV1U, retrieve the enb teid created. - *\param msg_p Message received by RRC. - *\param msg_name Message name. - *\param instance Message instance. + *\param ctxt_pP Running context + *\param msg_pP Message received by RRC. + *\param msg_name_pP Message name. *\return 0 when successful, -1 if the UE index can not be retrieved. */ -int rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(MessageDef *msg_pP, const char *msg_name_pP, instance_t instanceP); +int +rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( + const protocol_ctxt_t* const ctxt_pP, + MessageDef* msg_pP, + const char* msg_name_pP +); # endif # endif /* defined(ENABLE_USE_MME) */ diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index 043804409bf..e12ca293b77 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -28,7 +28,7 @@ *******************************************************************************/ /*! \file rrc_eNB_S1AP.c * \brief rrc S1AP procedures for eNB - * \author Laurent Winckel and Navid Nikaein + * \author Laurent Winckel and Sebastien ROUX and Navid Nikaein and Lionel GAUTHIER * \date 2013-2014 * \version 1.0 * \company Eurecom @@ -40,6 +40,8 @@ # include "extern.h" # include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" # include "RRC/LITE/MESSAGES/asn1_msg.h" +# include "RRC/LITE/defs.h" +# include "rrc_eNB_UE_context.h" # include "rrc_eNB_S1AP.h" # if defined(ENABLE_ITTI) @@ -55,6 +57,9 @@ #if defined(ENABLE_SECURITY) # include "UTIL/OSA/osa_defs.h" #endif +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif /* Value to indicate an invalid UE initial id */ static const uint16_t UE_INITIAL_ID_INVALID = 0; @@ -78,86 +83,110 @@ static const uint16_t S1AP_INTEGRITY_EIA2_MASK = 0x4000; #endif # if defined(ENABLE_ITTI) -/*! \fn uint16_t get_next_ue_initial_id(uint8_t mod_id) - *\brief provide an UE initial ID for S1AP initial communication. - *\param mod_id Instance ID of eNB. - *\return the UE initial ID. - */ -static uint16_t get_next_ue_initial_id(uint8_t mod_id) +//------------------------------------------------------------------------------ +int +rrc_eNB_S1AP_compare_ue_ids( + struct rrc_ue_s1ap_ids_s* c1_pP, + struct rrc_ue_s1ap_ids_s* c2_pP +) +//------------------------------------------------------------------------------ { - static uint16_t ue_initial_id[NUMBER_OF_eNB_MAX]; - - ue_initial_id[mod_id]++; + LOG_T(RRC, "rrc_eNB_S1AP_compare_ue_ids() c1.ue_initial_id %x c2.ue_initial_id %x c1.eNB_ue_s1ap_id %x c2.eNB_ue_s1ap_id %x\n", + c1_pP->ue_initial_id, + c2_pP->ue_initial_id, + c1_pP->eNB_ue_s1ap_id, + c2_pP->eNB_ue_s1ap_id); + + if ((c1_pP->eNB_ue_s1ap_id == 0) || (c2_pP->eNB_ue_s1ap_id == 0)) { + if (c1_pP->ue_initial_id > c2_pP->ue_initial_id) { + return 1; + } - /* Never use UE_INITIAL_ID_INVALID this is the invalid id! */ - if (ue_initial_id[mod_id] == UE_INITIAL_ID_INVALID) { - ue_initial_id[mod_id]++; + if (c1_pP->ue_initial_id < c2_pP->ue_initial_id) { + return -1; } - return ue_initial_id[mod_id]; + return 0; } -/*! \fn uint8_t get_UE_index_from_initial_id (uint8_t mod_id, uint16_t ue_initial_id) - *\brief retrieve UE index in the eNB from the UE initial ID. - *\param mod_id Instance ID of eNB. - *\param ue_initial_id The UE initial ID sent to S1AP. - *\return the UE index or UE_INDEX_INVALID if not found. - */ -static uint8_t get_UE_index_from_initial_id(uint8_t mod_id, uint16_t ue_initial_id) -{ - uint8_t ue_index; + if (c1_pP->eNB_ue_s1ap_id > c2_pP->eNB_ue_s1ap_id) { + return 1; + } - AssertFatal(mod_id < NB_eNB_INST, "eNB index invalid (%d/%d)!", mod_id, NB_eNB_INST); - LOG_D(RRC, "[eNB %d] get_UE_index_from_initial_id: ue_initial_id %d\n", ue_initial_id); + if (c1_pP->eNB_ue_s1ap_id < c2_pP->eNB_ue_s1ap_id) { + return -1; + } - for (ue_index = 0; ue_index < NUMBER_OF_UE_MAX; ue_index++) { - /* Check if this UE is in use */ - LOG_D(RRC, "[eNB %d][UE %d] UE rv 0x%" PRIx64 " %d\n", mod_id, ue_index, - eNB_rrc_inst[mod_id].Info.UE_list[ue_index], eNB_rrc_inst[mod_id].Info.UE[ue_index].ue_initial_id); + return 0; +} - if (eNB_rrc_inst[mod_id].Info.UE_list[ue_index] != 0) { - /* Check if the initial id match */ - if (eNB_rrc_inst[mod_id].Info.UE[ue_index].ue_initial_id == ue_initial_id) { - return ue_index; +//------------------------------------------------------------------------------ +/* Generate the tree management functions */ +RB_GENERATE(rrc_rnti_tree_s, rrc_ue_s1ap_ids_s, entries, rrc_eNB_S1AP_compare_ue_ids); +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +struct rrc_ue_s1ap_ids_s* +rrc_eNB_S1AP_get_ue_ids( + eNB_RRC_INST* const rrc_instance_pP, + const uint16_t ue_initial_id, + const uint32_t eNB_ue_s1ap_id +) +//------------------------------------------------------------------------------ +{ + rrc_ue_s1ap_ids_t temp; + memset(&temp, 0, sizeof(struct rrc_ue_s1ap_ids_s)); + /* eNB ue rrc id = 24 bits wide */ + temp.ue_initial_id = ue_initial_id; + temp.eNB_ue_s1ap_id = eNB_ue_s1ap_id; + return RB_FIND(rrc_rnti_tree_s, &rrc_instance_pP->rrc_rnti_head, &temp); } +//------------------------------------------------------------------------------ +void +rrc_eNB_S1AP_remove_ue_ids( + eNB_RRC_INST* const rrc_instance_pP, + struct rrc_ue_s1ap_ids_s* const ue_ids_pP +) +//------------------------------------------------------------------------------ +{ + if (rrc_instance_pP == NULL) { + LOG_E(RRC, "Bad RRC instance\n"); + return; } + if (ue_ids_pP == NULL) { + LOG_E(RRC, "Trying to free a NULL S1AP UE IDs\n"); + return; } - return UE_INDEX_INVALID; + RB_REMOVE(rrc_rnti_tree_s, &rrc_instance_pP->rrc_rnti_head, ue_ids_pP); + free(ue_ids_pP); } -/*! \fn uint8_t get_UE_index_from_eNB_ue_s1ap_id(uint8_t mod_id, uint32_t eNB_ue_s1ap_id) - *\brief retrieve UE index in the eNB from the eNB_ue_s1ap_id previously transmitted by S1AP. +/*! \fn uint16_t get_next_ue_initial_id(uint8_t mod_id) + *\brief provide an UE initial ID for S1AP initial communication. *\param mod_id Instance ID of eNB. - *\param eNB_ue_s1ap_id The value sent by S1AP. - *\return the UE index or UE_INDEX_INVALID if not found. + *\return the UE initial ID. */ -static uint8_t get_UE_index_from_eNB_ue_s1ap_id(uint8_t mod_id, uint32_t eNB_ue_s1ap_id) +//------------------------------------------------------------------------------ +static uint16_t +get_next_ue_initial_id( + const module_id_t mod_id +) +//------------------------------------------------------------------------------ { - uint8_t ue_index; - - AssertFatal(mod_id < NB_eNB_INST, "eNB index invalid (%d/%d)!", mod_id, NB_eNB_INST); - LOG_D(RRC, "[eNB %d] get_UE_index_from_eNB_ue_s1ap_id: eNB_ue_s1ap_id %d\n", mod_id, eNB_ue_s1ap_id); + static uint16_t ue_initial_id[NUMBER_OF_eNB_MAX]; + ue_initial_id[mod_id]++; - for (ue_index = 0; ue_index < NUMBER_OF_UE_MAX; ue_index++) { - /* Check if this UE is in use */ - LOG_D(RRC, "[eNB %d][UE %d] UE rv 0x%" PRIx64 " %d\n", mod_id, ue_index, - eNB_rrc_inst[mod_id].Info.UE_list[ue_index], eNB_rrc_inst[mod_id].Info.UE[ue_index].eNB_ue_s1ap_id); + /* Never use UE_INITIAL_ID_INVALID this is the invalid id! */ + if (ue_initial_id[mod_id] == UE_INITIAL_ID_INVALID) { + ue_initial_id[mod_id]++; + } - if (eNB_rrc_inst[mod_id].Info.UE_list[ue_index] != 0) { - /* Check if the initial id match */ - if (eNB_rrc_inst[mod_id].Info.UE[ue_index].eNB_ue_s1ap_id == eNB_ue_s1ap_id) { - return ue_index; + return ue_initial_id[mod_id]; } - } - } - LOG_D(RRC, - "[eNB %d] return UE_INDEX_INVALID for eNB_ue_s1ap_id %u\n", - mod_id, - eNB_ue_s1ap_id); - return UE_INDEX_INVALID; -} + + /*! \fn uint8_t get_UE_index_from_s1ap_ids(uint8_t mod_id, uint16_t ue_initial_id, uint32_t eNB_ue_s1ap_id) *\brief retrieve UE index in the eNB from the UE initial ID if not equal to UE_INDEX_INVALID or @@ -167,19 +196,32 @@ static uint8_t get_UE_index_from_eNB_ue_s1ap_id(uint8_t mod_id, uint32_t eNB_ue_ *\param eNB_ue_s1ap_id The value sent by S1AP. *\return the UE index or UE_INDEX_INVALID if not found. */ -static uint8_t get_UE_index_from_s1ap_ids(uint8_t mod_id, uint16_t ue_initial_id, uint32_t eNB_ue_s1ap_id) +static struct rrc_eNB_ue_context_s* +rrc_eNB_get_ue_context_from_s1ap_ids( + const instance_t instanceP, + const uint16_t ue_initial_idP, + const uint32_t eNB_ue_s1ap_idP +) { - uint8_t ue_index; + rrc_ue_s1ap_ids_t* temp = NULL; + temp = + rrc_eNB_S1AP_get_ue_ids( + &eNB_rrc_inst[ENB_INSTANCE_TO_MODULE_ID(instanceP)], + ue_initial_idP, + eNB_ue_s1ap_idP); + + if (temp) { + // found by ue_initial_id, fill now eNB_ue_s1ap_idP + if (temp->eNB_ue_s1ap_id != eNB_ue_s1ap_idP) { + temp->eNB_ue_s1ap_id = eNB_ue_s1ap_idP; + } - if (ue_initial_id == UE_INITIAL_ID_INVALID) { - /* If "ue_initial_id" is not set search if "eNB_ue_s1ap_id" is know by RRC */ - ue_index = get_UE_index_from_eNB_ue_s1ap_id (mod_id, eNB_ue_s1ap_id); - } else { - /* If "ue_initial_id" is set there is probably not yet an associated "eNB_ue_s1ap_id" with S1AP */ - ue_index = get_UE_index_from_initial_id (mod_id, ue_initial_id); + return rrc_eNB_get_ue_context( + &eNB_rrc_inst[ENB_INSTANCE_TO_MODULE_ID(instanceP)], + temp->ue_rnti); } - return ue_index; + return NULL; } /*! \fn e_SecurityAlgorithmConfig__cipheringAlgorithm rrc_eNB_select_ciphering(uint16_t algorithms) @@ -230,94 +272,121 @@ static e_SecurityAlgorithmConfig__integrityProtAlgorithm rrc_eNB_select_integrit *\param security_capabilities The security capabilities received from S1AP. *\return TRUE if at least one algorithm has been changed else FALSE. */ -static int rrc_eNB_process_security (uint8_t mod_id, uint8_t ue_index, security_capabilities_t *security_capabilities) +static int +rrc_eNB_process_security( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + security_capabilities_t* security_capabilities_pP +) { - int changed = FALSE; + boolean_t changed = FALSE; e_SecurityAlgorithmConfig__cipheringAlgorithm cipheringAlgorithm; e_SecurityAlgorithmConfig__integrityProtAlgorithm integrityProtAlgorithm; /* Save security parameters */ - eNB_rrc_inst[mod_id].Info.UE[ue_index].security_capabilities = *security_capabilities; + ue_context_pP->ue_context.security_capabilities = *security_capabilities_pP; // translation LOG_D(RRC, "[eNB %d] NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %u NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n", - mod_id, - eNB_rrc_inst[mod_id].Info.UE[ue_index].security_capabilities.encryption_algorithms, - eNB_rrc_inst[mod_id].ciphering_algorithm[ue_index], - eNB_rrc_inst[mod_id].Info.UE[ue_index].security_capabilities.integrity_algorithms, - eNB_rrc_inst[mod_id].integrity_algorithm[ue_index]); + ctxt_pP->module_id, + ue_context_pP->ue_context.security_capabilities.encryption_algorithms, + ue_context_pP->ue_context.ciphering_algorithm, + ue_context_pP->ue_context.security_capabilities.integrity_algorithms, + ue_context_pP->ue_context.integrity_algorithm); /* Select relevant algorithms */ - cipheringAlgorithm = rrc_eNB_select_ciphering (eNB_rrc_inst[mod_id].Info.UE[ue_index].security_capabilities.encryption_algorithms); + cipheringAlgorithm = rrc_eNB_select_ciphering (ue_context_pP->ue_context.security_capabilities.encryption_algorithms); - if (eNB_rrc_inst[mod_id].ciphering_algorithm[ue_index] != cipheringAlgorithm) { - eNB_rrc_inst[mod_id].ciphering_algorithm[ue_index] = cipheringAlgorithm; + if (ue_context_pP->ue_context.ciphering_algorithm != cipheringAlgorithm) { + ue_context_pP->ue_context.ciphering_algorithm = cipheringAlgorithm; changed = TRUE; } - integrityProtAlgorithm = rrc_eNB_select_integrity (eNB_rrc_inst[mod_id].Info.UE[ue_index].security_capabilities.integrity_algorithms); + integrityProtAlgorithm = rrc_eNB_select_integrity (ue_context_pP->ue_context.security_capabilities.integrity_algorithms); - if (eNB_rrc_inst[mod_id].integrity_algorithm[ue_index] != integrityProtAlgorithm) { - eNB_rrc_inst[mod_id].integrity_algorithm[ue_index] = integrityProtAlgorithm; + if (ue_context_pP->ue_context.integrity_algorithm != integrityProtAlgorithm) { + ue_context_pP->ue_context.integrity_algorithm = integrityProtAlgorithm; changed = TRUE; } - LOG_I (RRC, "[eNB %d][UE %d] Selected security algorithms (%x): %x, %x, %s\n", - mod_id, ue_index, security_capabilities, cipheringAlgorithm, integrityProtAlgorithm, changed ? "changed" : "same"); + LOG_I (RRC, "[eNB %d][UE %x] Selected security algorithms (%x): %x, %x, %s\n", + ctxt_pP->module_id, + ue_context_pP->ue_context.rnti, + security_capabilities_pP, + cipheringAlgorithm, + integrityProtAlgorithm, + changed ? "changed" : "same"); return changed; } -/*! \fn void process_eNB_security_key (uint8_t mod_id, uint8_t ue_index, uint8_t *security_key) +/*! \fn void process_eNB_security_key (const protocol_ctxt_t* const ctxt_pP, eNB_RRC_UE_t * const ue_context_pP, uint8_t *security_key) *\brief save security key. - *\param mod_id Instance ID of eNB. - *\param ue_index Instance ID of UE in the eNB. - *\param security_key The security key received from S1AP. + *\param ctxt_pP Running context. + *\param ue_context_pP UE context. + *\param security_key_pP The security key received from S1AP. */ -static void process_eNB_security_key (uint8_t mod_id, uint8_t ue_index, uint8_t *security_key) +//------------------------------------------------------------------------------ +static void process_eNB_security_key ( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + uint8_t* security_key_pP +) +//------------------------------------------------------------------------------ { #if defined(ENABLE_SECURITY) char ascii_buffer[65]; uint8_t i; /* Saves the security key */ - memcpy (eNB_rrc_inst[mod_id].kenb[ue_index], security_key, SECURITY_KEY_LENGTH); + memcpy (ue_context_pP->ue_context.kenb, security_key_pP, SECURITY_KEY_LENGTH); for (i = 0; i < 32; i++) { - sprintf(&ascii_buffer[2 * i], "%02X", eNB_rrc_inst[mod_id].kenb[ue_index][i]); + sprintf(&ascii_buffer[2 * i], "%02X", ue_context_pP->ue_context.kenb[i]); } ascii_buffer[2 * i] = '\0'; - LOG_I (RRC, "[eNB %d][UE %d] Saved security key %s\n", mod_id, ue_index, ascii_buffer); + LOG_I (RRC, "[eNB %d][UE %x] Saved security key %s\n", ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ascii_buffer); #endif } -static void rrc_pdcp_config_security(uint8_t enb_mod_idP, uint8_t ue_mod_idP, uint8_t send_security_mode_command ) +//------------------------------------------------------------------------------ +static void +rrc_pdcp_config_security( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + const uint8_t send_security_mode_command +) +//------------------------------------------------------------------------------ { #if defined(ENABLE_SECURITY) - SRB_ToAddModList_t *SRB_configList = eNB_rrc_inst[enb_mod_idP].SRB_configList[ue_mod_idP]; + SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; pdcp_t *pdcp_p = NULL; static int print_keys= 1; - protocol_ctxt_t ctxt; + hashtable_rc_t h_rc; + hash_key_t key; /* Derive the keys from kenb */ if (SRB_configList != NULL) { - derive_key_up_enc(eNB_rrc_inst[enb_mod_idP].ciphering_algorithm[ue_mod_idP], - eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP], &kUPenc); + derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm, + ue_context_pP->ue_context.kenb, + &kUPenc); } - derive_key_rrc_enc(eNB_rrc_inst[enb_mod_idP].ciphering_algorithm[ue_mod_idP], - eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP], &kRRCenc); - derive_key_rrc_int(eNB_rrc_inst[enb_mod_idP].integrity_algorithm[ue_mod_idP], - eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP], &kRRCint); + derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm, + ue_context_pP->ue_context.kenb, + &kRRCenc); + derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, + ue_context_pP->ue_context.kenb, + &kRRCint); #define DEBUG_SECURITY 1 @@ -329,87 +398,115 @@ static void rrc_pdcp_config_security(uint8_t enb_mod_idP, uint8_t ue_mod_idP, ui int i; msg("\nKeNB:"); - for(i = 0; i < 32; i++) - msg("%02x", eNB_rrc_inst[enb_mod_idP].kenb[ue_mod_idP][i]); + for(i = 0; i < 32; i++) { + msg("%02x", ue_context_pP->ue_context.kenb[i]); + } msg("\n"); msg("\nKRRCenc:"); - for(i = 0; i < 32; i++) + for(i = 0; i < 32; i++) { msg("%02x", kRRCenc[i]); + } msg("\n"); msg("\nKRRCint:"); - for(i = 0; i < 32; i++) + for(i = 0; i < 32; i++) { msg("%02x", kRRCint[i]); + } msg("\n"); } #endif //DEBUG_SECURITY + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - pdcp_p = &pdcp_array_srb_eNB[enb_mod_idP][ue_mod_idP][DCCH-1]; - - ctxt.enb_module_id = enb_mod_idP; - ctxt.ue_module_id = ue_mod_idP; - ctxt.frame = 0; - ctxt.enb_flag = ENB_FLAG_YES; + if (h_rc == HASH_TABLE_OK) { pdcp_config_set_security( - &ctxt, + ctxt_pP, pdcp_p, DCCH, DCCH+2, (send_security_mode_command == TRUE) ? - 0 | (eNB_rrc_inst[enb_mod_idP].integrity_algorithm[ue_mod_idP] << 4) : - (eNB_rrc_inst[enb_mod_idP].ciphering_algorithm[ue_mod_idP] ) | - (eNB_rrc_inst[enb_mod_idP].integrity_algorithm[ue_mod_idP] << 4), + 0 | (ue_context_pP->ue_context.integrity_algorithm << 4) : + (ue_context_pP->ue_context.ciphering_algorithm ) | + (ue_context_pP->ue_context.integrity_algorithm << 4), kRRCenc, kRRCint, kUPenc); + } else { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT"Could not get PDCP instance for SRB DCCH %u\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH); + } #endif } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(uint8_t mod_id, uint8_t ue_index) +//------------------------------------------------------------------------------ +void +rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +) +//------------------------------------------------------------------------------ { - eNB_RRC_UE_INFO *UE_info = &eNB_rrc_inst[mod_id].Info.UE[ue_index]; MessageDef *msg_p = NULL; int e_rab; int e_rabs_done = 0; int e_rabs_failed = 0; msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_INITIAL_CONTEXT_SETUP_RESP); - S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id = UE_info->eNB_ue_s1ap_id; + S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; - for (e_rab = 0; e_rab < UE_info->nb_of_e_rabs; e_rab++) { - if (UE_info->e_rab[e_rab].status == E_RAB_STATUS_DONE) { + for (e_rab = 0; e_rab < ue_context_pP->ue_context.nb_of_e_rabs; e_rab++) { + if (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { e_rabs_done++; - S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].e_rab_id = UE_info->e_rab[e_rab].param.e_rab_id; + S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; // TODO add other information from S1-U when it will be integrated - S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].gtp_teid = UE_info->enb_gtp_teid[e_rab]; - S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr = UE_info->enb_gtp_addrs[e_rab]; + S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].gtp_teid = ue_context_pP->ue_context.enb_gtp_teid[e_rab]; + S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr = ue_context_pP->ue_context.enb_gtp_addrs[e_rab]; S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr.length = 4; } else { e_rabs_failed++; - S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs_failed[e_rab].e_rab_id = UE_info->e_rab[e_rab].param.e_rab_id; + S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs_failed[e_rab].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; // TODO add cause when it will be integrated } } +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_RRC_ENB, + MSC_S1AP_ENB, + (const char *)&S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p), + sizeof(s1ap_initial_context_setup_resp_t), + MSC_AS_TIME_FMT" INITIAL_CONTEXT_SETUP_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_id_rnti, + S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id, + e_rabs_done, e_rabs_failed); +#endif S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs = e_rabs_done; S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; - itti_send_msg_to_task (TASK_S1AP, mod_id, msg_p); + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } # endif -/*------------------------------------------------------------------------------*/ -void rrc_eNB_send_S1AP_UPLINK_NAS(uint8_t mod_id, uint8_t ue_index, UL_DCCH_Message_t *ul_dcch_msg) +//------------------------------------------------------------------------------ +void +rrc_eNB_send_S1AP_UPLINK_NAS( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + UL_DCCH_Message_t* const ul_dcch_msg +) +//------------------------------------------------------------------------------ { #if defined(ENABLE_ITTI) { @@ -431,11 +528,11 @@ void rrc_eNB_send_S1AP_UPLINK_NAS(uint8_t mod_id, uint8_t ue_index, UL_DCCH_Mess pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf; msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UPLINK_NAS); - S1AP_UPLINK_NAS (msg_p).eNB_ue_s1ap_id = eNB_rrc_inst[mod_id].Info.UE[ue_index].eNB_ue_s1ap_id; + S1AP_UPLINK_NAS (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; S1AP_UPLINK_NAS (msg_p).nas_pdu.length = pdu_length; S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer = pdu_buffer; - itti_send_msg_to_task (TASK_S1AP, mod_id, msg_p); + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } } #else @@ -472,8 +569,13 @@ void rrc_eNB_send_S1AP_UPLINK_NAS(uint8_t mod_id, uint8_t ue_index, UL_DCCH_Mess #endif } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(uint8_t mod_id, uint8_t ue_index, UL_DCCH_Message_t *ul_dcch_msg) +//------------------------------------------------------------------------------ +void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + UL_DCCH_Message_t* ul_dcch_msg +) +//------------------------------------------------------------------------------ { UECapabilityInformation_t *ueCapabilityInformation = &ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation; @@ -481,42 +583,59 @@ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(uint8_t mod_id, uint8_t ue_index, UL_ && (ueCapabilityInformation->criticalExtensions.choice.c1.present == UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8) && (ueCapabilityInformation->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count > 0)) { - UE_CapabilityRAT_ContainerList_t *ue_CapabilityRAT_ContainerList = &ueCapabilityInformation->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList; + UE_CapabilityRAT_ContainerList_t* ue_CapabilityRAT_ContainerList = + &ueCapabilityInformation->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList; MessageDef *msg_p; msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UE_CAPABILITIES_IND); - S1AP_UE_CAPABILITIES_IND (msg_p).eNB_ue_s1ap_id = eNB_rrc_inst[mod_id].Info.UE[ue_index].eNB_ue_s1ap_id; + S1AP_UE_CAPABILITIES_IND (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; S1AP_UE_CAPABILITIES_IND (msg_p).ue_radio_cap.length = ue_CapabilityRAT_ContainerList->list.array[0]->ueCapabilityRAT_Container.size; S1AP_UE_CAPABILITIES_IND (msg_p).ue_radio_cap.buffer = ue_CapabilityRAT_ContainerList->list.array[0]->ueCapabilityRAT_Container.buf; - itti_send_msg_to_task (TASK_S1AP, mod_id, msg_p); + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); if (ue_CapabilityRAT_ContainerList->list.count > 1) { - LOG_W (RRC,"[eNB %d][UE %d] can only handle 1 UE capability RAT item for now (%d)\n", mod_id, ue_index, + LOG_W (RRC,"[eNB %d][UE %x] can only handle 1 UE capability RAT item for now (%d)\n", + ctxt_pP->module_id, + ue_context_pP->ue_context.rnti, ue_CapabilityRAT_ContainerList->list.count); } } } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_send_S1AP_NAS_FIRST_REQ(uint8_t mod_id, uint8_t ue_index, - RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete) +//------------------------------------------------------------------------------ +void +rrc_eNB_send_S1AP_NAS_FIRST_REQ( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete +) +//------------------------------------------------------------------------------ { #if defined(ENABLE_ITTI) { - MessageDef *message_p; + MessageDef* message_p = NULL; + rrc_ue_s1ap_ids_t* rrc_ue_s1ap_ids_p = NULL; message_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_NAS_FIRST_REQ); memset(&message_p->ittiMsg.s1ap_nas_first_req, 0, sizeof(s1ap_nas_first_req_t)); - eNB_rrc_inst[mod_id].Info.UE[ue_index].ue_initial_id = get_next_ue_initial_id (mod_id); - S1AP_NAS_FIRST_REQ (message_p).ue_initial_id = eNB_rrc_inst[mod_id].Info.UE[ue_index].ue_initial_id; + ue_context_pP->ue_context.ue_initial_id = get_next_ue_initial_id (ctxt_pP->module_id); + S1AP_NAS_FIRST_REQ (message_p).ue_initial_id = ue_context_pP->ue_context.ue_initial_id; + + rrc_ue_s1ap_ids_p = malloc(sizeof(*rrc_ue_s1ap_ids_p)); + rrc_ue_s1ap_ids_p->ue_initial_id = ue_context_pP->ue_context.ue_initial_id; + rrc_ue_s1ap_ids_p->eNB_ue_s1ap_id = UE_INITIAL_ID_INVALID; + rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; + + RB_INSERT(rrc_rnti_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_rnti_head, rrc_ue_s1ap_ids_p); /* Assume that cause is coded in the same way in RRC and S1ap, just check that the value is in S1ap range */ - AssertFatal(eNB_rrc_inst[mod_id].Info.UE[ue_index].establishment_cause < RRC_CAUSE_LAST, + AssertFatal(ue_context_pP->ue_context.establishment_cause < RRC_CAUSE_LAST, "Establishment cause invalid (%jd/%d) for eNB %d!", - eNB_rrc_inst[mod_id].Info.UE[ue_index].establishment_cause, RRC_CAUSE_LAST, mod_id); - S1AP_NAS_FIRST_REQ (message_p).establishment_cause = eNB_rrc_inst[mod_id].Info.UE[ue_index].establishment_cause; + ue_context_pP->ue_context.establishment_cause, RRC_CAUSE_LAST, ctxt_pP->module_id); + + S1AP_NAS_FIRST_REQ (message_p).establishment_cause = ue_context_pP->ue_context.establishment_cause; /* Forward NAS message */S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer = rrcConnectionSetupComplete->dedicatedInfoNAS.buf; @@ -526,18 +645,18 @@ void rrc_eNB_send_S1AP_NAS_FIRST_REQ(uint8_t mod_id, uint8_t ue_index, { S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask = UE_IDENTITIES_NONE; - if (eNB_rrc_inst[mod_id].Info.UE[ue_index].Initialue_identity_s_TMSI.presence) { + if (ue_context_pP->ue_context.Initialue_identity_s_TMSI.presence) { /* Fill s-TMSI */ - UE_S_TMSI *s_TMSI = &eNB_rrc_inst[mod_id].Info.UE[ue_index].Initialue_identity_s_TMSI; + UE_S_TMSI* s_TMSI = &ue_context_pP->ue_context.Initialue_identity_s_TMSI; S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask |= UE_IDENTITIES_s_tmsi; S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code = s_TMSI->mme_code; S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi = s_TMSI->m_tmsi; - LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ with s_TMSI: MME code %u M-TMSI %u ue_index %d\n", - mod_id, + LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ with s_TMSI: MME code %u M-TMSI %u ue %x\n", + ctxt_pP->module_id, S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code, S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi, - ue_index); + ue_context_pP->ue_context.rnti); } if (rrcConnectionSetupComplete->registeredMME != NULL) { @@ -550,36 +669,49 @@ void rrc_eNB_send_S1AP_NAS_FIRST_REQ(uint8_t mod_id, uint8_t ue_index, if ((r_mme->plmn_Identity->mcc != NULL) && (r_mme->plmn_Identity->mcc->list.count > 0)) { /* Use first indicated PLMN MCC if it is defined */ S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc = *r_mme->plmn_Identity->mcc->list.array[0]; - LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI MCC %u ue_index %d\n", - mod_id, + LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI MCC %u ue %x\n", + ctxt_pP->module_id, S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc, - ue_index); + ue_context_pP->ue_context.rnti); } if (r_mme->plmn_Identity->mnc.list.count > 0) { /* Use first indicated PLMN MNC if it is defined */ S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc = *r_mme->plmn_Identity->mnc.list.array[0]; - LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI MNC %u ue_index %d\n", - mod_id, + LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI MNC %u ue %x\n", + ctxt_pP->module_id, S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc, - ue_index); + ue_context_pP->ue_context.rnti); } } S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code = BIT_STRING_to_uint8 (&r_mme->mmec); S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id = BIT_STRING_to_uint16 (&r_mme->mmegi); - LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI mme_code %u mme_group_id %u ue_index %d\n", - mod_id, +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_S1AP_ENB, + MSC_S1AP_MME, + (const char *)&message_p->ittiMsg.s1ap_nas_first_req, + sizeof(s1ap_nas_first_req_t), + MSC_AS_TIME_FMT" S1AP_NAS_FIRST_REQ eNB %u UE %x", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt_pP->module_id, + ctxt_pP->rnti); +#endif + LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI mme_code %u mme_group_id %u ue %x\n", + ctxt_pP->module_id, S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code, S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id, - ue_index); + ue_context_pP->ue_context.rnti); } } - itti_send_msg_to_task (TASK_S1AP, mod_id, message_p); + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, message_p); } #else { - s1ap_eNB_new_data_request (mod_id, ue_index, + s1ap_eNB_new_data_request ( + ctxt_pP->module_id, + ue_context_pP, rrcConnectionSetupComplete->dedicatedInfoNAS. buf, rrcConnectionSetupComplete->dedicatedInfoNAS. @@ -589,22 +721,44 @@ void rrc_eNB_send_S1AP_NAS_FIRST_REQ(uint8_t mod_id, uint8_t ue_index, } # if defined(ENABLE_ITTI) -/*------------------------------------------------------------------------------*/ -int rrc_eNB_process_S1AP_DOWNLINK_NAS(MessageDef *msg_p, const char *msg_name, instance_t instance, mui_t *rrc_eNB_mui) +//------------------------------------------------------------------------------ +int +rrc_eNB_process_S1AP_DOWNLINK_NAS( + MessageDef* msg_p, + const char* msg_name, + instance_t instance, + mui_t* rrc_eNB_mui +) +//------------------------------------------------------------------------------ { uint16_t ue_initial_id; uint32_t eNB_ue_s1ap_id; - uint8_t ue_index; uint32_t length; uint8_t *buffer; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + protocol_ctxt_t ctxt; ue_initial_id = S1AP_DOWNLINK_NAS (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; - ue_index = get_UE_index_from_s1ap_ids (instance, ue_initial_id, eNB_ue_s1ap_id); - - LOG_I(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d, ue_index %d\n", instance, msg_name, ue_initial_id, eNB_ue_s1ap_id, ue_index); + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); + LOG_I(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d\n", + instance, + msg_name, + ue_initial_id, + eNB_ue_s1ap_id); - if (ue_index == UE_INDEX_INVALID) { + if (ue_context_p == NULL) { +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_S1AP_ENB, + NULL, + 0, + MSC_AS_TIME_FMT" DOWNLINK-NAS UE initial id %u eNB_ue_s1ap_id %u", + 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), + ue_initial_id, + eNB_ue_s1ap_id); +#endif /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p; @@ -617,17 +771,42 @@ int rrc_eNB_process_S1AP_DOWNLINK_NAS(MessageDef *msg_p, const char *msg_name, i // TODO add failure cause when defined! +#ifdef MESSAGE_CHART_GENERATOR + msc_log_tx_message( + MSC_RRC_ENB, + MSC_S1AP_ENB, + (const char *)NULL, + 0, + MSC_AS_TIME_FMT" S1AP_NAS_NON_DELIVERY_IND UE initial id %u eNB_ue_s1ap_id %u (ue ctxt !found)", + 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), + ue_initial_id, + eNB_ue_s1ap_id); +#endif itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); - return (-1); } else { + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); /* Is it the first income from S1AP ? */ - if (eNB_rrc_inst[instance].Info.UE[ue_index].eNB_ue_s1ap_id == 0) { - eNB_rrc_inst[instance].Info.UE[ue_index].eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; + if (ue_context_p->ue_context.eNB_ue_s1ap_id == 0) { + ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; } +#ifdef MESSAGE_CHART_GENERATOR + msc_log_rx_message( + MSC_RRC_ENB, + MSC_S1AP_ENB, + (const char *)NULL, + 0, + MSC_AS_TIME_FMT" DOWNLINK-NAS UE initial id %u eNB_ue_s1ap_id %u", + 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), + ue_initial_id, + S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id); +#endif /* Create message for PDCP (DLInformationTransfer_t) */ - length = do_DLInformationTransfer (instance, &buffer, rrc_eNB_get_next_transaction_identifier (instance), + length = do_DLInformationTransfer ( + instance, + &buffer, + rrc_eNB_get_next_transaction_identifier (instance), S1AP_DOWNLINK_NAS (msg_p).nas_pdu.length, S1AP_DOWNLINK_NAS (msg_p).nas_pdu.buffer); @@ -635,14 +814,21 @@ int rrc_eNB_process_S1AP_DOWNLINK_NAS(MessageDef *msg_p, const char *msg_name, i int i=0; LOG_F(RRC,"[MSG] RRC DL Information Transfer\n"); - for (i = 0; i < length; i++) + for (i = 0; i < length; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]); + } LOG_F(RRC,"\n"); #endif /* Transfer data to PDCP */ - pdcp_rrc_data_req (instance, ue_index, 0 /* TODO put frame number ! */, 1, DCCH, *rrc_eNB_mui++, 0, - length, buffer, 1); + pdcp_rrc_data_req ( + &ctxt, + DCCH, + *rrc_eNB_mui++, + SDU_CONFIRM_NO, + length, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); return (0); } @@ -653,17 +839,17 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char { uint16_t ue_initial_id; uint32_t eNB_ue_s1ap_id; - uint8_t ue_index; MessageDef *message_gtpv1u_p = NULL; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + protocol_ctxt_t ctxt; ue_initial_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id; - ue_index = get_UE_index_from_s1ap_ids (instance, ue_initial_id, eNB_ue_s1ap_id); - - LOG_I(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d, nb_of_e_rabs %d, ue_index %d\n", - instance, msg_name, ue_initial_id, eNB_ue_s1ap_id, S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs, ue_index); + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); + LOG_I(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d, nb_of_e_rabs %d\n", + instance, msg_name, ue_initial_id, eNB_ue_s1ap_id, S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs); - if (ue_index == UE_INDEX_INVALID) { + if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p = NULL; @@ -675,11 +861,11 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char // TODO add failure cause when defined! itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); - return (-1); } else { - eNB_rrc_inst[instance].Info.UE[ue_index].eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id; + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id; /* Save e RAB information for later */ { @@ -687,12 +873,11 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char message_gtpv1u_p = itti_alloc_new_message(TASK_S1AP, GTPV1U_ENB_CREATE_TUNNEL_REQ); memset(&message_gtpv1u_p->ittiMsg.Gtpv1uCreateTunnelReq, 0 , sizeof(gtpv1u_enb_create_tunnel_req_t)); + ue_context_p->ue_context.nb_of_e_rabs = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs; - eNB_rrc_inst[instance].Info.UE[ue_index].nb_of_e_rabs = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs; - - for (i = 0; i < eNB_rrc_inst[instance].Info.UE[ue_index].nb_of_e_rabs; i++) { - eNB_rrc_inst[instance].Info.UE[ue_index].e_rab[i].status = E_RAB_STATUS_NEW; - eNB_rrc_inst[instance].Info.UE[ue_index].e_rab[i].param = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i]; + for (i = 0; i < ue_context_p->ue_context.nb_of_e_rabs; i++) { + ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW; + ue_context_p->ue_context.e_rab[i].param = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i]; GTPV1U_ENB_CREATE_TUNNEL_REQ(message_gtpv1u_p).eps_bearer_id[i] = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].e_rab_id; @@ -703,10 +888,10 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char sizeof(transport_layer_addr_t)); } - GTPV1U_ENB_CREATE_TUNNEL_REQ(message_gtpv1u_p).ue_index = ue_index; // warning put zero above + GTPV1U_ENB_CREATE_TUNNEL_REQ(message_gtpv1u_p).rnti = ue_context_p->ue_context.rnti; // warning put zero above GTPV1U_ENB_CREATE_TUNNEL_REQ(message_gtpv1u_p).num_tunnels = i; - itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_gtpv1u_p); + itti_send_msg_to_task(TASK_GTPV1_U, instance, message_gtpv1u_p); } /* TODO parameters yet to process ... */ @@ -714,31 +899,44 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr; } - rrc_eNB_process_security (instance, ue_index, &S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_capabilities); - - process_eNB_security_key (instance, ue_index, S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_key); + rrc_eNB_process_security ( + &ctxt, + ue_context_p, + &S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_capabilities); + process_eNB_security_key ( + &ctxt, + ue_context_p, + S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_key); { uint8_t send_security_mode_command = TRUE; #ifndef EXMIMO_IOT - if ((eNB_rrc_inst[instance].ciphering_algorithm[ue_index] == SecurityAlgorithmConfig__cipheringAlgorithm_eea0) - && (eNB_rrc_inst[instance].integrity_algorithm[ue_index] == INTEGRITY_ALGORITHM_NONE)) { + if ((ue_context_p->ue_context.ciphering_algorithm == SecurityAlgorithmConfig__cipheringAlgorithm_eea0) + && (ue_context_p->ue_context.integrity_algorithm == INTEGRITY_ALGORITHM_NONE)) { send_security_mode_command = FALSE; } #endif - rrc_pdcp_config_security(instance, ue_index,send_security_mode_command); + rrc_pdcp_config_security( + &ctxt, + ue_context_p, + send_security_mode_command); if (send_security_mode_command) { - rrc_eNB_generate_SecurityModeCommand (instance, 0 /* TODO put frame number ! */, ue_index); + rrc_eNB_generate_SecurityModeCommand ( + &ctxt, + ue_context_p); send_security_mode_command = FALSE; // apply ciphering after RRC security command mode - rrc_pdcp_config_security(instance, ue_index,send_security_mode_command); + rrc_pdcp_config_security( + &ctxt, + ue_context_p, + send_security_mode_command); } else { - rrc_eNB_generate_UECapabilityEnquiry (instance, 0 /* TODO put frame number ! */, ue_index); + rrc_eNB_generate_UECapabilityEnquiry (&ctxt, ue_context_p); } } return (0); @@ -749,12 +947,13 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) { uint32_t eNB_ue_s1ap_id; - uint8_t ue_index; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + protocol_ctxt_t ctxt; eNB_ue_s1ap_id = S1AP_UE_CTXT_MODIFICATION_REQ (msg_p).eNB_ue_s1ap_id; - ue_index = get_UE_index_from_eNB_ue_s1ap_id (instance, eNB_ue_s1ap_id); + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); - if (ue_index == UE_INDEX_INVALID) { + if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p; @@ -766,10 +965,10 @@ int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char // TODO add failure cause when defined! itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); - return (-1); } else { + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); /* TODO parameters yet to process ... */ { if (S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).present & S1AP_UE_CONTEXT_MODIFICATION_UE_AMBR) { @@ -778,14 +977,22 @@ int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char } if (S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).present & S1AP_UE_CONTEXT_MODIFICATION_UE_SECU_CAP) { - if (rrc_eNB_process_security (instance, ue_index, &S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_capabilities)) { + if (rrc_eNB_process_security ( + &ctxt, + ue_context_p, + &S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_capabilities)) { /* transmit the new security parameters to UE */ - rrc_eNB_generate_SecurityModeCommand (instance, 0 /* TODO put frame number ! */, ue_index); + rrc_eNB_generate_SecurityModeCommand ( + &ctxt, + ue_context_p); } } if (S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).present & S1AP_UE_CONTEXT_MODIFICATION_SECURITY_KEY) { - process_eNB_security_key (instance, ue_index, S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_key); + process_eNB_security_key ( + &ctxt, + ue_context_p, + S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_key); /* TODO reconfigure lower layers... */ } @@ -805,20 +1012,21 @@ int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char } /*------------------------------------------------------------------------------*/ -#warning "LG Note this message is only from eNB to MME, proc to be deleted" int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char *msg_name, instance_t instance) { uint32_t eNB_ue_s1ap_id; - uint8_t ue_index; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_REQ(msg_p).eNB_ue_s1ap_id; - ue_index = get_UE_index_from_eNB_ue_s1ap_id(instance, eNB_ue_s1ap_id); + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); - if (ue_index == UE_INDEX_INVALID) { + if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p; - LOG_W(RRC, "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_REQ: unknown UE from eNB_ue_s1ap_id (%d) for eNB %d\n", instance, eNB_ue_s1ap_id); + LOG_W(RRC, "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_REQ: unknown UE from eNB_ue_s1ap_id (%d) for eNB %d\n", + instance, + eNB_ue_s1ap_id); msg_fail_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_RESP); /* TODO change message ID. */ S1AP_UE_CONTEXT_RELEASE_RESP(msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; @@ -826,7 +1034,6 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char * // TODO add failure cause when defined! itti_send_msg_to_task(TASK_S1AP, instance, msg_fail_p); - return (-1); } else { /* TODO release context. */ @@ -845,27 +1052,25 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char * } } -/*------------------------------------------------------------------------------*/ -void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ (uint8_t mod_id, uint8_t ue_index, s1ap_Cause_t causeP, long cause_valueP) +//------------------------------------------------------------------------------ +void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( + const module_id_t enb_mod_idP, + const rrc_eNB_ue_context_t* const ue_context_pP, + const s1ap_Cause_t causeP, + const long cause_valueP +) +//------------------------------------------------------------------------------ { - uint32_t eNB_ue_s1ap_id; - - if (ue_index == UE_INDEX_INVALID) { + if (ue_context_pP == NULL) { LOG_W(RRC, "[eNB] In S1AP_UE_CONTEXT_RELEASE_COMMAND: invalid UE\n"); - return; } else { - int e_rab; - int mod_id = 0; - eNB_RRC_UE_INFO *UE_info = &eNB_rrc_inst[mod_id].Info.UE[ue_index]; - MessageDef *msg_context_release_req_p = NULL; msg_context_release_req_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_REQ); - S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).eNB_ue_s1ap_id = UE_info->eNB_ue_s1ap_id; + S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).cause = causeP; S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).cause_value = cause_valueP; - itti_send_msg_to_task(TASK_S1AP, mod_id, msg_context_release_req_p); - return; + itti_send_msg_to_task(TASK_S1AP, ENB_MODULE_ID_TO_INSTANCE(enb_mod_idP), msg_context_release_req_p); } } @@ -874,12 +1079,13 @@ void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ (uint8_t mod_id, uint8_t ue_index, int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const char *msg_name, instance_t instance) { uint32_t eNB_ue_s1ap_id; - uint8_t ue_index; + protocol_ctxt_t ctxt; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p).eNB_ue_s1ap_id; - ue_index = get_UE_index_from_eNB_ue_s1ap_id(instance, eNB_ue_s1ap_id); + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); - if (ue_index == UE_INDEX_INVALID) { + if (ue_context_p == NULL) { /* Can not associate this message to an UE index */ MessageDef *msg_complete_p; @@ -891,10 +1097,10 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; itti_send_msg_to_task(TASK_S1AP, instance, msg_complete_p); - return (-1); } else { - rrc_eNB_generate_RRCConnectionRelease(instance, 0 /*frame*/, ue_index); + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + rrc_eNB_generate_RRCConnectionRelease(&ctxt, ue_context_p); /* LOG_W(RRC, "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: TODO call rrc_eNB_connection_release for eNB %d\n", @@ -904,7 +1110,6 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch { int e_rab; int mod_id = 0; - eNB_RRC_UE_INFO *UE_info = &eNB_rrc_inst[mod_id].Info.UE[ue_index]; MessageDef *msg_delete_tunnels_p = NULL; msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); @@ -913,14 +1118,15 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); // do not wait response - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).ue_index = ue_index; + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - for (e_rab = 0; e_rab < UE_info->nb_of_e_rabs; e_rab++) { - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_p).num_erab++] = UE_info->enb_gtp_ebi[e_rab]; + for (e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_p).num_erab++] = + ue_context_p->ue_context.enb_gtp_ebi[e_rab]; // erase data - UE_info->enb_gtp_teid[e_rab] = 0; - memset(&UE_info->enb_gtp_addrs[e_rab], 0, sizeof(UE_info->enb_gtp_addrs[e_rab])); - UE_info->enb_gtp_ebi[e_rab] = 0; + ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; + memset(&ue_context_p->ue_context.enb_gtp_addrs[e_rab], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); + ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; } itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p); diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.h b/openair2/RRC/LITE/rrc_eNB_S1AP.h index a724c487bf5..0f6e01d5b60 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.h +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.h @@ -28,7 +28,7 @@ *******************************************************************************/ /*! \file rrc_eNB_S1AP.h * \brief rrc S1AP procedures for eNB - * \author Laurent Winckel and Navid Nikaein + * \author Laurent Winckel and Sebastien ROUX and Navid Nikaein and Lionel GAUTHIER * \date 2013 * \version 1.0 * \company Eurecom @@ -45,49 +45,103 @@ /* Up link procedures */ # if defined(ENABLE_ITTI) +typedef struct rrc_ue_s1ap_ids_s { + /* Tree related data */ + RB_ENTRY(rrc_ue_s1ap_ids_s) entries; + + // keys + uint16_t ue_initial_id; + uint32_t eNB_ue_s1ap_id; + + // value + rnti_t ue_rnti; +} rrc_ue_s1ap_ids_t; + +int +rrc_eNB_S1AP_compare_ue_ids( + struct rrc_ue_s1ap_ids_s* c1_pP, + struct rrc_ue_s1ap_ids_s* c2_pP +); + +RB_PROTOTYPE(rrc_rnti_tree_s, rrc_ue_s1ap_ids_s, entries, rrc_eNB_S1AP_compare_ue_ids); + +struct rrc_ue_s1ap_ids_s* +rrc_eNB_S1AP_get_ue_ids( + eNB_RRC_INST* const rrc_instance_pP, + const uint16_t ue_initial_id, + const uint32_t eNB_ue_s1ap_id +); + +void +rrc_eNB_S1AP_remove_ue_ids( + eNB_RRC_INST* const rrc_instance_pP, + struct rrc_ue_s1ap_ids_s* const ue_ids_pP +); /*! \fn void rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(uint8_t mod_id, uint8_t ue_index) *\brief create a S1AP_INITIAL_CONTEXT_SETUP_RESP for S1AP. - *\param mod_id Instance ID of eNB. - *\param ue_index Instance ID of UE in the eNB. + *\param ctxt_pP Running context. + *\param ue_context_pP RRC UE context. */ -void rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(uint8_t Mod_id, uint8_t UE_index); +void +rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +); -/*! \fn void rrc_eNB_send_S1AP_UPLINK_NAS(uint8_t Mod_id, uint8_t UE_index, UL_DCCH_Message_t *ul_dcch_msg) +/*! \fn void rrc_eNB_send_S1AP_UPLINK_NAS(const protocol_ctxt_t * const ctxt_pP, eNB_RRC_UE_t * const ue_context_pP, UL_DCCH_Message_t * const ul_dcch_msg) *\brief create a S1AP_UPLINK_NAS to transfer a NAS message to S1AP. - *\param mod_id Instance ID of eNB. - *\param ue_index Instance ID of UE in the eNB. + *\param ctxt_pP Running context. + *\param ue_context_pP UE context. *\param ul_dcch_msg The message receive by RRC holding the NAS message. */ -void rrc_eNB_send_S1AP_UPLINK_NAS(uint8_t Mod_id, uint8_t UE_index, UL_DCCH_Message_t *ul_dcch_msg); - -/*! \fn void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(uint8_t Mod_id, uint8_t UE_index, UL_DCCH_Message_t *ul_dcch_msg) +void +rrc_eNB_send_S1AP_UPLINK_NAS( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + UL_DCCH_Message_t* const ul_dcch_msg +); + +/*! \fn void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(const protocol_ctxt_t * const ctxt_pP, eNB_RRC_UE_t * const ue_context_pP, UL_DCCH_Message_t *ul_dcch_msg) *\brief create a S1AP_UE_CAPABILITIES_IND to transfer a NAS message to S1AP. - *\param mod_id Instance ID of eNB. - *\param ue_index Instance ID of UE in the eNB. + *\param ctxt_pP Running context. + *\param ue_context_pP UE context. *\param ul_dcch_msg The message receive by RRC holding the NAS message. */ -void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(uint8_t mod_id, uint8_t ue_index, UL_DCCH_Message_t *ul_dcch_msg); +void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + UL_DCCH_Message_t* ul_dcch_msg +); -/*! \fn rrc_eNB_send_S1AP_NAS_FIRST_REQ(uint8_t Mod_id, uint8_t UE_index, RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete) +/*! \fn rrc_eNB_send_S1AP_NAS_FIRST_REQ(const protocol_ctxt_t* const ctxt_pP,eNB_RRC_UE_t *const ue_context_pP, RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete) *\brief create a S1AP_NAS_FIRST_REQ to indicate that RRC has completed its first connection setup to S1AP. *\brief eventually forward a NAS message to S1AP. - *\param mod_id Instance ID of eNB. - *\param ue_index Instance ID of UE in the eNB. + *\param ctxt_pP Running context. + *\param ue_context_pP RRC UE context. *\param rrcConnectionSetupComplete The message receive by RRC that may hold the NAS message. */ -void rrc_eNB_send_S1AP_NAS_FIRST_REQ(uint8_t Mod_id, uint8_t UE_index, - RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete); +void +rrc_eNB_send_S1AP_NAS_FIRST_REQ( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete +); -/*! \fn rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(uint8_t Mod_id, uint8_t UE_index, s1ap_Cause_t causeP, long cause_valueP) +/*! \fn rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(const module_id_t enb_mod_idP, const struct rrc_eNB_ue_context_s *const ue_context_pP, const s1ap_Cause_t causeP, const long cause_valueP) *\brief create a S1AP_UE_CONTEXT_RELEASE_REQ message, the message is sent by the eNB to S1AP task to request the release of the UE-associated S1-logical connection over the S1 interface. . - *\param mod_id Instance ID of eNB. - *\param ue_index Instance ID of UE in the eNB. + *\param enb_mod_idP Instance ID of eNB. + *\param ue_context_pP UE context in the eNB. *\param causeP Origin of the cause for the UE removal. *\param cause_valueP Contextual value (in regard of the origin) of the cause. */ -void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ (uint8_t mod_id, uint8_t ue_index, s1ap_Cause_t causeP, long cause_valueP); +void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( + const module_id_t enb_mod_idP, + const rrc_eNB_ue_context_t* const ue_context_pP, + const s1ap_Cause_t causeP, + const long cause_valueP +); /* Down link procedures */ diff --git a/openair2/RRC/LITE/rrc_eNB_UE_context.c b/openair2/RRC/LITE/rrc_eNB_UE_context.c new file mode 100644 index 00000000000..8ac4657a9fc --- /dev/null +++ b/openair2/RRC/LITE/rrc_eNB_UE_context.c @@ -0,0 +1,202 @@ +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2014 Eurecom + + OpenAirInterface is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + + OpenAirInterface is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OpenAirInterface.The full GNU General Public License is + included in this distribution in the file called "COPYING". If not, + see <http://www.gnu.org/licenses/>. + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@eurecom.fr + + Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE + +*******************************************************************************/ + +/*! \file rrc_eNB_UE_context.h + * \brief rrc procedures for UE context + * \author Lionel GAUTHIER + * \date 2015 + * \version 1.0 + * \company Eurecom + * \email: lionel.gauthier@eurecom.fr + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> + +#include "UTIL/LOG/log.h" +#include "rrc_eNB_UE_context.h" +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif + + +//------------------------------------------------------------------------------ +void +uid_linear_allocator_init( + uid_allocator_t* const uid_pP +) +//------------------------------------------------------------------------------ +{ + memset(uid_pP, 0, sizeof(uid_allocator_t)); +} + +//------------------------------------------------------------------------------ +uid_t +uid_linear_allocator_new( + eNB_RRC_INST* const rrc_instance_pP +) +//------------------------------------------------------------------------------ +{ + unsigned int i; + unsigned int bit_index = 1; + uid_t uid = 0; + uid_allocator_t* uia_p = &rrc_instance_pP->uid_allocator; + + for (i=0; i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE; i++) { + if (uia_p->bitmap[i] != UINT_MAX) { + bit_index = 1; + uid = 0; + + while ((uia_p->bitmap[i] & bit_index) == bit_index) { + bit_index = bit_index << 1; + uid += 1; + } + + uia_p->bitmap[i] |= bit_index; + return uid + (i*sizeof(unsigned int)*8); + } + } + + return UINT_MAX; +} + + +//------------------------------------------------------------------------------ +void +uid_linear_allocator_free( + eNB_RRC_INST* rrc_instance_pP, + uid_t uidP +) +//------------------------------------------------------------------------------ +{ + unsigned int i = uidP/sizeof(unsigned int)/8; + unsigned int bit = uidP % (sizeof(unsigned int) * 8); + unsigned int value = ~(0x00000001 << bit); + + if (i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE) { + rrc_instance_pP->uid_allocator.bitmap[i] &= value; + } +} + + +//------------------------------------------------------------------------------ +int rrc_eNB_compare_ue_rnti_id( + struct rrc_eNB_ue_context_s* c1_pP, struct rrc_eNB_ue_context_s* c2_pP) +//------------------------------------------------------------------------------ +{ + if (c1_pP->ue_id_rnti > c2_pP->ue_id_rnti) { + return 1; + } + + if (c1_pP->ue_id_rnti < c2_pP->ue_id_rnti) { + return -1; + } + + return 0; +} + +/* Generate the tree management functions */ +RB_GENERATE(rrc_ue_tree_s, rrc_eNB_ue_context_s, entries, + rrc_eNB_compare_ue_rnti_id); + + + +//------------------------------------------------------------------------------ +struct rrc_eNB_ue_context_s* +rrc_eNB_allocate_new_UE_context( + eNB_RRC_INST* rrc_instance_pP +) +//------------------------------------------------------------------------------ +{ + struct rrc_eNB_ue_context_s* new_p; + new_p = malloc(sizeof(struct rrc_eNB_ue_context_s)); + + if (new_p == NULL) { + LOG_E(RRC, "Cannot allocate new ue context\n"); + return NULL; + } + + memset(new_p, 0, sizeof(struct rrc_eNB_ue_context_s)); + new_p->local_uid = uid_linear_allocator_new(rrc_instance_pP); + return new_p; +} + + +//------------------------------------------------------------------------------ +struct rrc_eNB_ue_context_s* +rrc_eNB_get_ue_context( + eNB_RRC_INST* rrc_instance_pP, + rnti_t rntiP) +//------------------------------------------------------------------------------ +{ + rrc_eNB_ue_context_t temp; + memset(&temp, 0, sizeof(struct rrc_eNB_ue_context_s)); + /* eNB ue rrc id = 24 bits wide */ + temp.ue_id_rnti = rntiP; + return RB_FIND(rrc_ue_tree_s, &rrc_instance_pP->rrc_ue_head, &temp); +} + + +//------------------------------------------------------------------------------ +void rrc_eNB_remove_ue_context( + const protocol_ctxt_t* const ctxt_pP, + eNB_RRC_INST* rrc_instance_pP, + struct rrc_eNB_ue_context_s* ue_context_pP) +//------------------------------------------------------------------------------ +{ + if (rrc_instance_pP == NULL) { + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Bad RRC instance\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + return; + } + + if (ue_context_pP == NULL) { + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Trying to free a NULL UE context\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + return; + } + + RB_REMOVE(rrc_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_pP); +#ifdef MESSAGE_CHART_GENERATOR + msc_log_event( + MSC_RRC_ENB, + "Removed UE %x", + ue_context_pP->ue_context.rnti); +#endif + rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_pP); + uid_linear_allocator_free(rrc_instance_pP, ue_context_pP->local_uid); + free(ue_context_pP); + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" Removed UE context\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); +} + + diff --git a/openair2/RRC/LITE/rrc_eNB_UE_context.h b/openair2/RRC/LITE/rrc_eNB_UE_context.h new file mode 100644 index 00000000000..6a575cd7004 --- /dev/null +++ b/openair2/RRC/LITE/rrc_eNB_UE_context.h @@ -0,0 +1,88 @@ +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2014 Eurecom + + OpenAirInterface is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + + OpenAirInterface is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OpenAirInterface.The full GNU General Public License is + included in this distribution in the file called "COPYING". If not, + see <http://www.gnu.org/licenses/>. + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@eurecom.fr + + Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE + +*******************************************************************************/ + +/*! \file rrc_eNB_UE_context.h + * \brief rrc procedures for UE context + * \author Lionel GAUTHIER + * \date 2015 + * \version 1.0 + * \company Eurecom + * \email: lionel.gauthier@eurecom.fr + */ +#ifndef __RRC_ENB_UE_CONTEXT_H__ +#include "collection/tree.h" +#include "COMMON/platform_types.h" +#include "defs.h" + + +void +uid_linear_allocator_init( + uid_allocator_t* const uid_pP +); + +uid_t +uid_linear_allocator_new( + eNB_RRC_INST* rrc_instance_pP +); + + +void +uid_linear_allocator_free( + eNB_RRC_INST* rrc_instance_pP, + uid_t uidP +); + + + + +int rrc_eNB_compare_ue_rnti_id( + struct rrc_eNB_ue_context_s* c1_pP, + struct rrc_eNB_ue_context_s* c2_pP +); + +RB_PROTOTYPE(rrc_ue_tree_s, rrc_eNB_ue_context_s, entries, rrc_eNB_compare_ue_rnti_id); + +struct rrc_eNB_ue_context_s* +rrc_eNB_allocate_new_UE_context( + eNB_RRC_INST* rrc_instance_pP +); + +struct rrc_eNB_ue_context_s* +rrc_eNB_get_ue_context( + eNB_RRC_INST* rrc_instance_pP, + rnti_t rntiP +); + +void rrc_eNB_remove_ue_context( + const protocol_ctxt_t* const ctxt_pP, + eNB_RRC_INST* rrc_instance_pP, + struct rrc_eNB_ue_context_s* ue_context_pP +); + +#endif diff --git a/openair2/RRC/LITE/rrc_eNB_ral.h b/openair2/RRC/LITE/rrc_eNB_ral.h index cd08e76185f..31c1d031cac 100755 --- a/openair2/RRC/LITE/rrc_eNB_ral.h +++ b/openair2/RRC/LITE/rrc_eNB_ral.h @@ -68,7 +68,8 @@ private_rrc_enb_ral( int rrc_enb_ral_delete_all_thresholds_type (unsigned int mod_idP, ral_link_param_type_t *param_type_pP);) -private_rrc_enb_ral( int rrc_enb_ral_delete_threshold (unsigned int mod_idP, ral_link_param_type_t *param_type_pP, ral_threshold_t *threshold_pP);) +private_rrc_enb_ral( int rrc_enb_ral_delete_threshold (unsigned int mod_idP, ral_link_param_type_t* param_type_pP, + ral_threshold_t* threshold_pP);) protected_rrc_enb_ral(int rrc_enb_ral_handle_configure_threshold_request(unsigned int mod_idP, MessageDef *msg_pP);) #endif diff --git a/openair2/RRC/LITE/rrc_rrm_interface.c b/openair2/RRC/LITE/rrc_rrm_interface.c index 662c2695e14..9e539bf4df4 100644 --- a/openair2/RRC/LITE/rrc_rrm_interface.c +++ b/openair2/RRC/LITE/rrc_rrm_interface.c @@ -152,11 +152,13 @@ int send_msg_sock( struct iovec iov; int taille = sizeof(msg_head_t) ; - if ( smsg == NULL ) + if ( smsg == NULL ) { return -1 ; + } - if ( smsg->data != NULL ) + if ( smsg->data != NULL ) { taille += smsg->head.size ; + } //buf = RRM_MALLOC(char, taille); //if (buf ==NULL) @@ -211,8 +213,9 @@ char *recv_msg( buf = RRM_CALLOC( char,taille); - if ( buf == NULL ) + if ( buf == NULL ) { return NULL ; + } iov.iov_base = (void *)buf; iov.iov_len = taille ; @@ -243,8 +246,9 @@ char *recv_msg( smsg = RRM_CALLOC(char , size_msg ) ; - if ( smsg != NULL ) + if ( smsg != NULL ) { memcpy( smsg , buf , size_msg ) ; + } RRM_FREE( buf ) ; @@ -259,8 +263,9 @@ int send_msg_fifo(int *s, msg_t *fmsg) int taille = sizeof(msg_head_t) ; msg("write on fifos %d, msg %p\n",*s,fmsg); - if ( fmsg == NULL ) + if ( fmsg == NULL ) { return -1 ; + } // envoi le header diff --git a/openair2/RRC/LITE/rrm_2_rrc_msg.c b/openair2/RRC/LITE/rrm_2_rrc_msg.c index 075159696b4..6cc08421dde 100644 --- a/openair2/RRC/LITE/rrm_2_rrc_msg.c +++ b/openair2/RRC/LITE/rrm_2_rrc_msg.c @@ -85,7 +85,9 @@ void fn_rrc (void) #ifdef USER_MODE Header = (msg_head_t *) recv_msg(&S_rrc) ; - if(Header==NULL) break; + if(Header==NULL) { + break; + } Data_to_read=Header->size; #else @@ -93,8 +95,9 @@ void fn_rrc (void) if(Header_read_idx < Header_size) { bytes_read = rtf_get (RRM2RRC_FIFO,&Header_buf[Header_read_idx],Header_size-Header_read_idx); - if(bytes_read >0) + if(bytes_read >0) { msg("RRC: GET FIFOS RETURNS %d bytes, header %d\n",bytes_read,Header_read_idx); + } Header_read_idx+=bytes_read; @@ -104,8 +107,9 @@ void fn_rrc (void) msg("RRC: Header read completed, data size %d\n",Data_to_read); } //msg("[fn_rrc]TTI %d: rcv_msg return Null\n",Rrc_xface->Frame_index); - else + else { break; + } } #endif @@ -116,13 +120,16 @@ void fn_rrc (void) #else bytes_read = rtf_get (RRM2RRC_FIFO,&Data[Data_read_idx],Data_to_read); - if(bytes_read >0) + if(bytes_read >0) { msg("RRC: GET FIFOS RETURNS %d bytes, Data_to_read %d\n",bytes_read,Data_to_read); + } Data_to_read-=bytes_read; Data_read_idx+=bytes_read; - if(Data_to_read > 0 ) break; + if(Data_to_read > 0 ) { + break; + } msg("RRC: DATA read completed, data size %d\n",Data_to_read); Header_read_idx=0; @@ -185,10 +192,13 @@ void fn_rrc (void) UE_rrc_inst[Header->inst-NB_CH_INST].Srb2[CH_index].Srb_info.IP_addr_type=p->L3_info_t; - if(p->L3_info_t == IPv4_ADDR) + if(p->L3_info_t == IPv4_ADDR) { memcpy(&UE_rrc_inst[Header->inst-NB_CH_INST].Srb2[CH_index].Srb_info.IP_addr,p->L3_info,4); - else + } + + else { memcpy(&UE_rrc_inst[Header->inst-NB_CH_INST].Srb2[CH_index].Srb_info.IP_addr,p->L3_info,16); + } } break ; diff --git a/openair2/RRC/LITE/utils.c b/openair2/RRC/LITE/utils.c index 691411e5446..cf1252c30a3 100644 --- a/openair2/RRC/LITE/utils.c +++ b/openair2/RRC/LITE/utils.c @@ -49,8 +49,9 @@ char bcmp(void *x, void *y,int Size ) unsigned char i; for(i=0; i<Size; i++) - if(*(char*)(x+i)!= *(char *)(y+i)) + if(*(char*)(x+i)!= *(char*)(y+i)) { return 1; + } return 0; } @@ -62,16 +63,18 @@ uint16_t find_free_dtch_position(uint8_t Mod_id, uint16_t UE_CH_index) { uint16_t i,j; - if(UE_CH_index==0) + if(UE_CH_index==0) { j=0; - else + } else { j=1; + } for(i=j; i<NB_RAB_MAX; i++) { //first RAB IS BROADCAST DTCH //msg("i=%d\n",i); - if(CH_rrc_inst[Mod_id].Rab[i][UE_CH_index].Active==0) + if(CH_rrc_inst[Mod_id].Rab[i][UE_CH_index].Active==0) { return( i); + } } msg("NO FREE DTCH LCHAN, exit... \n"); @@ -92,8 +95,9 @@ uint8_t rrc_find_free_ue_index(uint8_t Mod_id) (CH_rrc_inst[Mod_id].Info.UE_list[i][1] == 0) && (CH_rrc_inst[Mod_id].Info.UE_list[i][2] == 0) && (CH_rrc_inst[Mod_id].Info.UE_list[i][3] == 0) && - (CH_rrc_inst[Mod_id].Info.UE_list[i][4] == 0)) + (CH_rrc_inst[Mod_id].Info.UE_list[i][4] == 0)) { return i; + } return 0xff; } diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 8758b8717f0..d6c12a09e66 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -65,7 +65,7 @@ void setBaseNetAddress (char* baseAddr) strcpy(baseNetAddress,baseAddr); } -char* getBaseNetAddress () +char* getBaseNetAddress (void) { return baseNetAddress; } @@ -75,7 +75,7 @@ void setNetMask (char* baseAddr) strcpy(netMask,baseAddr); } -char* getNetMask () +char* getNetMask (void) { return netMask; } @@ -85,7 +85,7 @@ void setBroadcastAddress (char* baseAddr) strcpy(broadcastAddr, baseAddr); } -char* getBroadcastAddress () +char* getBroadcastAddress (void) { return broadcastAddr; } diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c index 39c34c0fdb9..2c0d5584212 100644 --- a/openair2/UTIL/MEM/mem_block.c +++ b/openair2/UTIL/MEM/mem_block.c @@ -57,7 +57,7 @@ uint32_t counters[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; * initialize all ures */ void * -pool_buffer_init () +pool_buffer_init (void) { //----------------------------------------------------------------------------- @@ -189,20 +189,19 @@ free_mem_block (mem_block_t * leP) //----------------------------------------------------------------------------- mem_block_t * -get_free_mem_block (uint16_t sizeP) +get_free_mem_block (uint32_t sizeP) { //----------------------------------------------------------------------------- mem_block_t *le = NULL; int pool_selected; int size; - // next block commented, because sizeP > MEM_MNGT_MB12_BLOCK_SIZE can never be true. - // if (sizeP > MEM_MNGT_MB12_BLOCK_SIZE) { - // msg ("[MEM_MNGT][ERROR][FATAL] size requested %d out of bounds\n", sizeP); - // display_mem_load (); - // mac_xface->macphy_exit("[MEM_MNGT][ERROR][FATAL] get_free_mem_block size requested out of bounds"); - // return NULL; - // } + if (sizeP > MEM_MNGT_MB12_BLOCK_SIZE) { + msg ("[MEM_MNGT][ERROR][FATAL] size requested %d out of bounds\n", sizeP); + display_mem_load (); + mac_xface->macphy_exit("[MEM_MNGT][ERROR][FATAL] get_free_mem_block size requested out of bounds"); + return NULL; + } size = sizeP >> 6; pool_selected = 0; @@ -332,7 +331,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL1 block index %d\n", index); } } @@ -340,7 +340,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL2 block index %d\n", index); } } @@ -348,7 +349,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL3 block index %d\n", index); } } @@ -356,7 +358,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL4 block index %d\n", index); } } @@ -364,7 +367,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL5 block index %d\n", index); } } @@ -372,7 +376,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL6 block index %d\n", index); } } @@ -380,7 +385,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL7 block index %d\n", index); } } @@ -388,7 +394,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL8 block index %d\n", index); } } @@ -396,7 +403,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL9 block index %d\n", index); } } @@ -404,7 +412,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL10 block index %d\n", index); } } @@ -412,7 +421,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL11 block index %d\n", index); } } @@ -420,7 +430,8 @@ check_mem_area (void) 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)) { + 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)) { msg ("[MEM] ERROR POOL12 block index %d\n", index); } } diff --git a/openair2/UTIL/MEM/mem_block.h b/openair2/UTIL/MEM/mem_block.h index 96c0bf1bc14..b38e9a2417e 100755 --- a/openair2/UTIL/MEM/mem_block.h +++ b/openair2/UTIL/MEM/mem_block.h @@ -39,6 +39,9 @@ #ifndef __MEM_BLOCK_H__ # define __MEM_BLOCK_H__ +#ifdef USER_MODE +#include <stdint.h> +#endif #ifdef MEM_BLOCK_C # define public_mem_block(x) x # define private_mem_block(x) x @@ -61,7 +64,7 @@ typedef struct mem_block_t { public_mem_block(void *pool_buffer_init (void);) public_mem_block(void *pool_buffer_clean (void *arg);) public_mem_block(void free_mem_block (mem_block_t * leP);) -public_mem_block(mem_block_t *get_free_mem_block (unsigned short sizeP);) +public_mem_block(mem_block_t* get_free_mem_block (uint32_t sizeP);) public_mem_block(mem_block_t *get_free_copy_mem_block (void);) public_mem_block(mem_block_t *get_free_copy_mem_block_up (void);) public_mem_block(mem_block_t *copy_mem_block (mem_block_t * leP, mem_block_t * destP);) diff --git a/openair2/UTIL/MEM/mem_mngt.c b/openair2/UTIL/MEM/mem_mngt.c index af1db439ed1..43f55d1a05a 100755 --- a/openair2/UTIL/MEM/mem_mngt.c +++ b/openair2/UTIL/MEM/mem_mngt.c @@ -450,29 +450,34 @@ check_free_mem_block (mem_block_t * leP) 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) { + } 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) { + 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_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_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_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"); diff --git a/openair2/UTIL/OCG/OCG.c b/openair2/UTIL/OCG/OCG.c index d8cd3b3f311..1170a6db7fd 100644 --- a/openair2/UTIL/OCG/OCG.c +++ b/openair2/UTIL/OCG/OCG.c @@ -232,9 +232,6 @@ int OCG_main(char is_local_server[FILENAME_LENGTH_MAX]) case STATE_GENERATE_REPORT : if (create_dir_OK != MODULE_OK) { // a temp folder is required when the output folder could not be correctly generated - //strcpy(output_dir, OPENAIR_TARGETS); - //strcat(output_dir, "SIMU/EXAMPLES/OSD/"); - //strcat(output_dir, TEMP_OUTPUT_DIR); strncpy(output_dir, OPENAIR_TARGETS, sizeof(output_dir)); output_dir[sizeof(output_dir) - 1] = 0; // terminate string strncat(output_dir, "SIMU/EXAMPLES/OSD/", sizeof(output_dir) - strlen(output_dir) - 1); diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h index c9e26aa1f41..a32bfb14eef 100644 --- a/openair2/UTIL/OCG/OCG.h +++ b/openair2/UTIL/OCG/OCG.h @@ -726,6 +726,11 @@ typedef struct { */ unsigned char slot_isr; int slot_sfd; + rnti_t eNB_ue_module_id_to_rnti[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX];/*!< \brief used by eNB, this array can be filled: + by local virtualization: set directly by UE, or by remote UEs: TODO add signalisation on ethernet emulation link from UE to eNB*/ + + module_id_t eNB_ue_local_uid_to_ue_module_id[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX];/*!< \brief used by eNB, this array can be filled: + by local virtualization: set directly by UE, or by remote UEs: TODO add signalisation on ethernet emulation link from UE to eNB*/ } Info; /* @}*/ diff --git a/openair2/UTIL/OCG/OCG_create_dir.c b/openair2/UTIL/OCG/OCG_create_dir.c index b2a82a0a5d5..357fce7b202 100644 --- a/openair2/UTIL/OCG/OCG_create_dir.c +++ b/openair2/UTIL/OCG/OCG_create_dir.c @@ -53,7 +53,6 @@ int create_dir(char output_dir[DIR_LENGTH_MAX], char user_name[FILENAME_LENGTH_M char directory[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX] = ""; mode_t process_mask = umask(0); - //strcpy(directory, output_dir); strncpy(directory, output_dir, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX); directory[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - 1] = 0; // terminate string @@ -64,13 +63,10 @@ int create_dir(char output_dir[DIR_LENGTH_MAX], char user_name[FILENAME_LENGTH_M LOG_I(OCG, "output_dir %s is created", directory); } - //strcat(directory, user_name); strncat(directory, user_name, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(directory) - 1); mkdir(directory, S_IRWXU | S_IRWXG | S_IRWXO); - // strcat(directory, "/"); - //strcat(directory, file_date); strncat(directory, "/", FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(directory) - 1); strncat(directory, file_date, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(directory) - 1); diff --git a/openair2/UTIL/OCG/OCG_detect_file.c b/openair2/UTIL/OCG/OCG_detect_file.c index 8707cd104b5..1ce230fb973 100644 --- a/openair2/UTIL/OCG/OCG_detect_file.c +++ b/openair2/UTIL/OCG/OCG_detect_file.c @@ -95,8 +95,6 @@ int detect_file(char src_dir[DIR_LENGTH_MAX], char is_local_server[FILENAME_LENG } char check_src_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX]; - //strcpy(check_src_file, src_dir); - //strcat(check_src_file, filename); strncpy(check_src_file, src_dir, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX); check_src_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - 1] = 0; // terminate string strncat(check_src_file, filename, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(check_src_file) - 1); diff --git a/openair2/UTIL/OCG/OCG_generate_report.c b/openair2/UTIL/OCG/OCG_generate_report.c index 456e3739299..36db0d2ccbc 100644 --- a/openair2/UTIL/OCG/OCG_generate_report.c +++ b/openair2/UTIL/OCG/OCG_generate_report.c @@ -55,8 +55,6 @@ int generate_report(char dst_dir[DIR_LENGTH_MAX], char filename[FILENAME_LENGTH_ // for the xml writer, refer to http://xmlsoft.org/html/libxml-xmlwriter.html char dst_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX] = ""; - //strcat(dst_file, dst_dir); - //strcat(dst_file, filename); strncat(dst_file, dst_dir, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(dst_file) - 1); strncat(dst_file, filename, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(dst_file) - 1); diff --git a/openair2/UTIL/OCG/OCG_parse_XML.c b/openair2/UTIL/OCG/OCG_parse_XML.c index cc0c525f28a..7d6cfad8aeb 100644 --- a/openair2/UTIL/OCG/OCG_parse_XML.c +++ b/openair2/UTIL/OCG/OCG_parse_XML.c @@ -1272,10 +1272,8 @@ void characters(void *user_data, const xmlChar *xmlch, int xmllen) // called o } else if (trace_file_) { oai_emulation.info.opt_enabled = 1; - // if (strcmp(strndup(ch, len), "wireshark") == 0) { if (strncmp(ch, "wireshark", len) == 0) { opt_type = OPT_WIRESHARK; - // } else if (strcmp(strndup(ch, len), "pcap") == 0) { } else if (strncmp(ch, "pcap", len) == 0) { opt_type = OPT_PCAP; } else { diff --git a/openair2/UTIL/OCG/OCG_parse_filename.c b/openair2/UTIL/OCG/OCG_parse_filename.c index fe70760710c..bb860728a78 100644 --- a/openair2/UTIL/OCG/OCG_parse_filename.c +++ b/openair2/UTIL/OCG/OCG_parse_filename.c @@ -50,14 +50,12 @@ int parse_filename(char filename[FILENAME_LENGTH_MAX]) { char *delim = "._"; - //char *result; char tmp_filename[FILENAME_LENGTH_MAX]; char *fd_tmp; char *un_tmp; char *ex_tmp; //delim = "._"; - // strcpy(tmp_filename, filename); strncpy(tmp_filename, filename, FILENAME_LENGTH_MAX); tmp_filename[FILENAME_LENGTH_MAX - 1] = 0; // terminate string @@ -70,8 +68,6 @@ int parse_filename(char filename[FILENAME_LENGTH_MAX]) "Please use .xml file for configuration with the format \"user_name.file_date.xml\"\nfile_date = \"year month day hour minute second\" without space, \ne.g. 20100201193045 represents in the year 2010, February 1st, 19:30:45\n"); return MODULE_ERROR; } else { - //strcpy(file_date, fd_tmp); - //strcpy(user_name, un_tmp); strncpy(file_date, fd_tmp, sizeof(file_date)); file_date[sizeof(file_date) - 1] = 0; // terminate string strncpy(user_name, un_tmp, sizeof(user_name)); diff --git a/openair2/UTIL/OCG/OCG_save_XML.c b/openair2/UTIL/OCG/OCG_save_XML.c index 1d47eed6357..5ad40815729 100644 --- a/openair2/UTIL/OCG/OCG_save_XML.c +++ b/openair2/UTIL/OCG/OCG_save_XML.c @@ -55,12 +55,9 @@ int save_XML(int copy_or_move, char *src_file, char *output_dir, char *filename) char dst_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX + 32] = ""; char XML_saving_dir[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX + 32] = ""; - //strcpy(dst_file, output_dir); strncpy(dst_file, output_dir, sizeof(dst_file)); dst_file[sizeof(dst_file) - 1] = 0; // terminate string //strcat(dst_file, "SCENARIO/XML/"); - //strcpy(XML_saving_dir, dst_file); - //strcat(dst_file, filename); strncpy(XML_saving_dir, dst_file, sizeof(XML_saving_dir)); XML_saving_dir[sizeof(XML_saving_dir) - 1] = 0; // terminate string strncat(dst_file, filename, sizeof(dst_file) - strlen(dst_file) - 1); diff --git a/openair2/UTIL/OCG/makefile b/openair2/UTIL/OCG/makefile index 5fcf45837f1..1e531f94941 100644 --- a/openair2/UTIL/OCG/makefile +++ b/openair2/UTIL/OCG/makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc LIB = -lxml2 TOP_DIR = ../.. @@ -18,8 +18,8 @@ ifdef DEBUG_PHY CFLAGS += -DDEBUG_PHY endif -ifdef NAS_NETLINK -CFLAGS += -DNAS_NETLINK -DLINUX -DDEBUG_CONTROL +ifdef PDCP_USE_NETLINK +CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif CFLAGS += -DPHY_ABSTRACTION diff --git a/openair2/UTIL/OMG/makefile b/openair2/UTIL/OMG/makefile index 84cfc3a3209..319b8296cd6 100644 --- a/openair2/UTIL/OMG/makefile +++ b/openair2/UTIL/OMG/makefile @@ -71,8 +71,8 @@ ifdef DEBUG_PHY CFLAGS += -DDEBUG_PHY endif -ifdef NAS_NETLINK -CFLAGS += -DNAS_NETLINK -DLINUX -DDEBUG_CONTROL +ifdef PDCP_USE_NETLINK +CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif CFLAGS += -DPHY_ABSTRACTION diff --git a/openair2/UTIL/OMG/makefile_old b/openair2/UTIL/OMG/makefile_old index 1f11fb518fa..acc89254fb1 100644 --- a/openair2/UTIL/OMG/makefile_old +++ b/openair2/UTIL/OMG/makefile_old @@ -73,8 +73,8 @@ ifdef DEBUG_PHY CFLAGS += -DDEBUG_PHY endif -ifdef NAS_NETLINK -CFLAGS += -DNAS_NETLINK -DLINUX -DDEBUG_CONTROL +ifdef PDCP_USE_NETLINK +CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif CFLAGS += -DPHY_ABSTRACTION diff --git a/openair2/UTIL/OMG/socket_traci_OMG.c b/openair2/UTIL/OMG/socket_traci_OMG.c index dff4f61f3b8..fed154aa083 100644 --- a/openair2/UTIL/OMG/socket_traci_OMG.c +++ b/openair2/UTIL/OMG/socket_traci_OMG.c @@ -196,8 +196,6 @@ storage * receiveExact() storage* temp = writePacket(buf, NN); free( buf ); return temp; - //return writePacket(buf, NN); - } diff --git a/openair2/UTIL/OTG/otg_defs.h b/openair2/UTIL/OTG/otg_defs.h index 54357ed7ec0..4f4cc4f6019 100644 --- a/openair2/UTIL/OTG/otg_defs.h +++ b/openair2/UTIL/OTG/otg_defs.h @@ -25,18 +25,18 @@ Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE -*******************************************************************************/ + *******************************************************************************/ /*! \file otg_defs.h main used structures -* \brief otg structure -* \author N. Nikaein and A. Hafsaoui -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr -* \note -* \warning -*/ + * \brief otg structure + * \author N. Nikaein and A. Hafsaoui + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: navid.nikaein@eurecom.fr + * \note + * \warning + */ #ifndef __OTG_DEFS_H__ # define __OTG_DEFS_H__ @@ -52,12 +52,12 @@ #include "otg_config.h" /** -* \enum Application -* \brief OTG applications type -* -* -* Application describes the class of traffic supported and can be pre-configured bu otg_tx -*/ + * \enum Application + * \brief OTG applications type + * + * + * Application describes the class of traffic supported and can be pre-configured bu otg_tx + */ typedef enum { NO_PREDEFINED_MULTICAST_TRAFFIC =0, MSCBR, @@ -70,12 +70,12 @@ typedef enum { } Multicast_Application; /** -* \enum Application -* \brief OTG applications type -* -* -* Application describes the class of traffic supported and can be pre-configured bu otg_tx -*/ + * \enum Application + * \brief OTG applications type + * + * + * Application describes the class of traffic supported and can be pre-configured bu otg_tx + */ typedef enum { NO_PREDEFINED_TRAFFIC =0, M2M, // 1 @@ -118,12 +118,12 @@ typedef enum { /** -* \enum dist_type -* \brief OTG implemented distribution for packet and inter departure time computation -* -* -* dist_type presents the used distribition to generate inter departure time and packet size -*/ + * \enum dist_type + * \brief OTG implemented distribution for packet and inter departure time computation + * + * + * dist_type presents the used distribition to generate inter departure time and packet size + */ typedef enum { NO_TRAFFIC=0, @@ -144,12 +144,12 @@ typedef enum { /** -* \enum trans_proto -* -* \brief trans_proto enmerates used transport protocol -* -* -*/ + * \enum trans_proto + * + * \brief trans_proto enmerates used transport protocol + * + * + */ typedef enum { NO_PROTO=0, @@ -159,11 +159,11 @@ typedef enum { /** -* \enum ip_v -* -*\brief ip_v presents the used IP version to generate the packet -* -*/ + * \enum ip_v + * + *\brief ip_v presents the used IP version to generate the packet + * + */ typedef enum { NO_IP=0, IPV4=1, @@ -171,11 +171,11 @@ typedef enum { } ip_v; /** -* \enum ip_v -* -*\brief ip_v presents the used IP version to generate the packet -* -*/ + * \enum ip_v + * + *\brief ip_v presents the used IP version to generate the packet + * + */ /* typedef enum { OFF_STATE=0, @@ -183,7 +183,7 @@ typedef enum { ACTIVE_STATE, MAX_NUM_STATE, }TRAFFIC_STATE; -*/ + */ typedef enum { OFF_STATE=0, @@ -198,11 +198,11 @@ typedef enum { } VOIP_STATE; /** -* \enum ALPHABET -* -*\brief ALPHABET Alphabet type to generate random string -* -*/ + * \enum ALPHABET + * + *\brief ALPHABET Alphabet type to generate random string + * + */ typedef enum { REPEAT_STRING=0, // repeat the same set of characters SUBSTRACT_STRING, // substract the string from the know character string @@ -217,11 +217,11 @@ typedef enum { /** -* \enum HEADER_TYPE -* -* \brief HEADER_TYPE alows to identify the transport protocol and IP version -* -*/ + * \enum HEADER_TYPE + * + * \brief HEADER_TYPE alows to identify the transport protocol and IP version + * + */ typedef enum { NO_HEADER=0, @@ -232,18 +232,18 @@ typedef enum { } HEADER_TYPE; /** -* \enum TRAFFIC_TYPE -* -* \brief HEADER_TYPE alows to identify the traffic type no specific type, m2m,etc. -* -*/ + * \enum TRAFFIC_TYPE + * + * \brief HEADER_TYPE alows to identify the traffic type no specific type, m2m,etc. + * + */ /* typedef enum { NO_TYPE=0, M2M_TYPE, }TRAFFIC_TYPE; -*/ + */ /* @@ -339,11 +339,11 @@ typedef struct { /** -* \struct otg_t -* -*\brief otg_t define the traffic generator global parameters, it include a matrix of nodes (source, destination and state) parameters -* -*/ + * \struct otg_t + * + *\brief otg_t define the traffic generator global parameters, it include a matrix of nodes (source, destination and state) parameters + * + */ typedef struct { int max_nb_frames; /*!< \brief Max Number of frames*/ int application_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/ @@ -425,14 +425,16 @@ typedef struct { typedef struct { - unsigned char flow_id; /*!< \brief It identify the flow ID (we can have source and destination with several flows) */ - unsigned int time; /*!< \brief simulation time at the tx, this is ctime */ - unsigned int seq_num; /*!< \brief Sequence Number, counter of data packets between tx and rx */ - unsigned char state; /*!< \brief state of node : on, off, or active */ - unsigned char hdr_type; /*!< \brief Header type: tcp/udp vs ipv4/ipv6 */ + unsigned char flow_id; /*!< \brief It identify the flow ID (we can have source and destination with several flows) */ + unsigned int time; /*!< \brief simulation time at the tx, this is ctime */ + unsigned int seq_num; /*!< \brief Sequence Number, counter of data packets between tx and rx */ + unsigned char state; /*!< \brief state of node : on, off, or active */ + unsigned char hdr_type; /*!< \brief Header type: tcp/udp vs ipv4/ipv6 */ + unsigned char src_instance; /*!< \brief traffic source instance */ + unsigned char dst_instance; /*!< \brief traffic destination instance */ unsigned short pkts_size; /*!< \brief the size of payload + header */ - unsigned short aggregation_level; /*!< \brief packet aggregation level */ - unsigned int traffic_type; /*!< \brief to specify if it corresponds to an m2m traffic */ + unsigned short aggregation_level;/*!< \brief packet aggregation level */ + unsigned int traffic_type; /*!< \brief to specify if it corresponds to an m2m traffic */ //int payload_size; /*!< \brief the size of the payload to transmit */ //int header_size; /*!< \brief Header type: tcp/udp vs ipv4/ipv6 */ } __attribute__((__packed__)) otg_hdr_t; @@ -444,12 +446,12 @@ typedef struct { /** -* \struct packet_t -* -* \brief packet_t corresponds to the global structure of the generated packet -* -* -*/ + * \struct packet_t + * + * \brief packet_t corresponds to the global structure of the generated packet + * + * + */ typedef struct { @@ -500,11 +502,11 @@ typedef struct { /** -* \struct packet_t -* -* \brief The OTG information and KPI of the simulation structure -* -*/ + * \struct packet_t + * + * \brief The OTG information and KPI of the simulation structure + * + */ typedef struct { /*!< \brief info part: */ @@ -536,9 +538,9 @@ typedef struct { float rx_owd_min_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ float rx_owd_max_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ float rx_pkt_owd_history[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ - float rx_pkt_owd_history_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ + float rx_pkt_owd_history_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ float rx_pkt_jitter[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime */ - float rx_jitter_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_jitter_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ float rx_jitter_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ float rx_jitter_avg[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ float rx_pkt_jitter_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime */ diff --git a/openair2/UTIL/OTG/otg_models.c b/openair2/UTIL/OTG/otg_models.c index b53722f43a5..b1327e8a087 100644 --- a/openair2/UTIL/OTG/otg_models.c +++ b/openair2/UTIL/OTG/otg_models.c @@ -43,6 +43,7 @@ #include "otg_models.h" #include "UTIL/LOG/log.h" +double backgroundRateRnd(void); /*all the TARMA stuff: diff --git a/openair2/UTIL/OTG/otg_rx.c b/openair2/UTIL/OTG/otg_rx.c index 6d27a32d39d..a97ecf80f97 100644 --- a/openair2/UTIL/OTG/otg_rx.c +++ b/openair2/UTIL/OTG/otg_rx.c @@ -25,18 +25,18 @@ Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE -*******************************************************************************/ + *******************************************************************************/ /*! \file otg_rx.c -* \brief function containing the OTG traffic generation functions -* \author Navid Nikaein and A. Hafsaoui -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr -* \note -* \warning -*/ + * \brief function containing the OTG traffic generation functions + * \author Navid Nikaein and A. Hafsaoui + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: navid.nikaein@eurecom.fr + * \note + * \warning + */ #include "otg_rx.h" #include "otg_externs.h" @@ -61,23 +61,28 @@ extern unsigned char NB_UE_INST; // Check if the packet is well received or not and extract data -int otg_rx_pkt( int src, int dst, int ctime, char *buffer_tx, unsigned int size) +int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buffer_tx, const unsigned int size) { - int bytes_read=0; + int bytes_read = 0; otg_hdr_info_t * otg_hdr_info_rx; - otg_hdr_t * otg_hdr_rx; - int is_size_ok=0; - unsigned int seq_num_rx; - unsigned int nb_loss_pkts; - unsigned int lost_packet=0; + otg_hdr_t * otg_hdr_rx; + int is_size_ok = 0; + unsigned int seq_num_rx; + unsigned int nb_loss_pkts; + unsigned int lost_packet = 0; + unsigned int src_instance; + unsigned int dst_instance; if (buffer_tx!=NULL) { otg_hdr_info_rx = (otg_hdr_info_t *) (&buffer_tx[bytes_read]); bytes_read += sizeof (otg_hdr_info_t); - LOG_D(OTG,"otg_rx_pkt functions: source %d, destination %d, size %d, otg_hdr_info_rx->flag %.4x, otg_hdr_info_rx->size %d \n", - src,dst,size,otg_hdr_info_rx->flag,otg_hdr_info_rx->size); + LOG_D(OTG,"otg_rx_pkt functions: destination %d, size %d, otg_hdr_info_rx->flag %.4x, otg_hdr_info_rx->size %d \n", + dst_instanceP, + size, + otg_hdr_info_rx->flag, + otg_hdr_info_rx->size); if (((otg_hdr_info_rx->flag == 0xffff) || @@ -91,55 +96,79 @@ int otg_rx_pkt( int src, int dst, int ctime, char *buffer_tx, unsigned int size) if (( otg_hdr_info_rx->size ) == size ) {*/ is_size_ok= 1; otg_hdr_rx = (otg_hdr_t *) (&buffer_tx[bytes_read]); - LOG_I(OTG,"[SRC %d][DST %d] [FLOW_idx %d][APP TYPE %d] RX INFO pkt at time %d: flag 0x %x, seq number %d, tx time %d, size (hdr %d, pdcp %d) \n", src, dst,otg_hdr_rx->flow_id, - otg_hdr_rx->traffic_type, ctime, otg_hdr_info_rx->flag, otg_hdr_rx->seq_num, otg_hdr_rx->time, otg_hdr_info_rx->size, size); + LOG_I(OTG,"[SRC %d][DST %d] [FLOW_idx %d][APP TYPE %d] RX INFO pkt at time %d: flag 0x %x, seq number %d, tx time %d, size (hdr %d, pdcp %d) \n", + otg_hdr_rx->src_instance, + otg_hdr_rx->dst_instance, + otg_hdr_rx->flow_id, + otg_hdr_rx->traffic_type, + ctime, + otg_hdr_info_rx->flag, + otg_hdr_rx->seq_num, + otg_hdr_rx->time, + otg_hdr_info_rx->size, size); + bytes_read += sizeof (otg_hdr_t); + src_instance = otg_hdr_rx->src_instance; + dst_instance = otg_hdr_rx->dst_instance; + + if (dst_instance != dst_instanceP) { +#warning "LG: TODO think about multicast traffic" + LOG_W(OTG,"[SRC %d][DST %d] [FLOW_idx %d][APP TYPE %d] RX INFO pkt at time %d: flag 0x %x, seq number %d, tx time %d, size (hdr %d, pdcp %d) not for dest instance %u\n", + dst_instanceP); + } + if(otg_hdr_rx->traffic_type > MAX_NUM_APPLICATION) { LOG_W(OTG,"RX packet: application type out of range %d for the pair of (src %d, dst %d) \n", - otg_hdr_rx->traffic_type, src, dst); + otg_hdr_rx->traffic_type, src_instance, dst_instance); otg_hdr_rx->traffic_type=0; } /** unicast traffic **/ if (otg_hdr_info_rx->flag == 0xffff) { - seq_num_rx=otg_info->seq_num_rx[src][dst][otg_hdr_rx->traffic_type]; + seq_num_rx=otg_info->seq_num_rx[src_instance][dst_instance][otg_hdr_rx->traffic_type]; - if (src<NB_eNB_INST) - nb_loss_pkts=otg_info->nb_loss_pkts_dl[src][dst][otg_hdr_rx->traffic_type]; + if (src_instance<NB_eNB_INST) + nb_loss_pkts=otg_info->nb_loss_pkts_dl[src_instance][dst_instance][otg_hdr_rx->traffic_type]; else - nb_loss_pkts=otg_info->nb_loss_pkts_ul[src][dst][otg_hdr_rx->traffic_type]; + nb_loss_pkts=otg_info->nb_loss_pkts_ul[src_instance][dst_instance][otg_hdr_rx->traffic_type]; } /** multicast traffic **/ else if (otg_hdr_info_rx->flag == 0x1000) { - seq_num_rx = otg_multicast_info->rx_sn[src][dst][otg_hdr_rx->traffic_type]; - nb_loss_pkts = otg_multicast_info->loss_pkts_dl[src][dst][otg_hdr_rx->traffic_type]; - // otg_multicast_info->ran_owd[src][dst][otg_hdr_rx->traffic_type] = ctime- otg_hdr_rx->time; - // rx_check_loss(src, dst, otg_hdr_info_rx->flag, otg_hdr_rx->seq_num, &seq_num_rx, &nb_loss_pkts); - // otg_multicast_info->loss_rate[src][dst][otg_hdr_rx->traffic_type]=nb_loss_pkts; - //otg_multicast_info->rx_sn[src][dst][otg_hdr_rx->traffic_type]=seq_num_rx; + seq_num_rx = otg_multicast_info->rx_sn[src_instance][dst_instance][otg_hdr_rx->traffic_type]; + nb_loss_pkts = otg_multicast_info->loss_pkts_dl[src_instance][dst_instance][otg_hdr_rx->traffic_type]; + // otg_multicast_info->ran_owd[src_instance][dst_instance][otg_hdr_rx->traffic_type] = ctime- otg_hdr_rx->time; + // rx_check_loss(src_instance, dst_instance, otg_hdr_info_rx->flag, otg_hdr_rx->seq_num, &seq_num_rx, &nb_loss_pkts); + // otg_multicast_info->loss_rate[src_instance][dst_instance][otg_hdr_rx->traffic_type]=nb_loss_pkts; + //otg_multicast_info->rx_sn[src_instance][dst_instance][otg_hdr_rx->traffic_type]=seq_num_rx; LOG_I(OTG,"received a multicast packet with size %d sn %d ran owd %d loss rate %d\n", otg_hdr_info_rx->size, seq_num_rx, ctime- otg_hdr_rx->time, nb_loss_pkts); //return 0; } /** background traffic **/ else { - seq_num_rx=otg_info->seq_num_rx_background[src][dst]; + seq_num_rx=otg_info->seq_num_rx_background[src_instance][dst_instance]; - if (src<NB_eNB_INST) - nb_loss_pkts=otg_info->nb_loss_pkts_background_dl[src][dst]; + if (src_instance<NB_eNB_INST) + nb_loss_pkts=otg_info->nb_loss_pkts_background_dl[src_instance][dst_instance]; else - nb_loss_pkts=otg_info->nb_loss_pkts_background_ul[src][dst]; + nb_loss_pkts=otg_info->nb_loss_pkts_background_ul[src_instance][dst_instance]; } - LOG_D(OTG,"[%d][%d] AGGREGATION LEVEL (RX) %d \n", src, dst, otg_hdr_rx->aggregation_level); - otg_info->aggregation_level[src][dst]=otg_hdr_rx->aggregation_level; + LOG_D(OTG,"[%d][%d] AGGREGATION LEVEL (RX) %d \n", src_instance, dst_instance, otg_hdr_rx->aggregation_level); + otg_info->aggregation_level[src_instance][dst_instance]=otg_hdr_rx->aggregation_level; /* Loss and out of sequence data management */ - lost_packet= rx_check_loss(src, dst, otg_hdr_info_rx->flag, otg_hdr_rx->seq_num, &seq_num_rx, &nb_loss_pkts); + lost_packet= rx_check_loss( + src_instance, + dst_instance, + otg_hdr_info_rx->flag, + otg_hdr_rx->seq_num, + &seq_num_rx, + &nb_loss_pkts); - if (otg_info->owd_const[src][dst][otg_hdr_rx->flow_id]==0) - owd_const_gen(src,dst,otg_hdr_rx->flow_id, otg_hdr_rx->traffic_type); + if (otg_info->owd_const[src_instance][dst_instance][otg_hdr_rx->flow_id]==0) + owd_const_gen(src_instance,dst_instance,otg_hdr_rx->flow_id, otg_hdr_rx->traffic_type); /******/ @@ -149,128 +178,185 @@ int otg_rx_pkt( int src, int dst, int ctime, char *buffer_tx, unsigned int size) float owd_const_IP_backbone_v=owd_const_IP_backbone()/2; float owd_const_application_v=owd_const_application()/2; - FILE *file; - file = fopen("/tmp/log_latency_m2m.txt", "a"); - fprintf(file," %d %d [%d] [%d] %.2f %.2f %.2f %.2f %.2f %.2f\n", otg_hdr_rx->time, otg_hdr_info_rx->size, src, dst, owd_const_capillary_v,otg_info->radio_access_delay[src][dst],owd_const_mobile_core_v, owd_const_IP_backbone_v, owd_const_application_v, owd_const_capillary_v + otg_info->radio_access_delay[src][dst]+owd_const_mobile_core_v + owd_const_IP_backbone_v+ owd_const_application_v); - fclose(file); - */ + FILE *file; + file = fopen("/tmp/log_latency_m2m.txt", "a"); + fprintf(file," %d %d [%d] [%d] %.2f %.2f %.2f %.2f %.2f %.2f\n", otg_hdr_rx->time, otg_hdr_info_rx->size, src, dst, owd_const_capillary_v,otg_info->radio_access_delay[src][dst],owd_const_mobile_core_v, owd_const_IP_backbone_v, owd_const_application_v, owd_const_capillary_v + otg_info->radio_access_delay[src][dst]+owd_const_mobile_core_v + owd_const_IP_backbone_v+ owd_const_application_v); + fclose(file); + */ /******/ // } if (otg_hdr_rx->time<=ctime) { - otg_info->radio_access_delay[src][dst]=(float) (ctime- otg_hdr_rx->time); - otg_multicast_info->radio_access_delay[src][dst]=(float) (ctime- otg_hdr_rx->time); + otg_info->radio_access_delay[src_instance][dst_instance]=(float) (ctime- otg_hdr_rx->time); + otg_multicast_info->radio_access_delay[src_instance][dst_instance]=(float) (ctime- otg_hdr_rx->time); } else { LOG_N(OTG,"received packet has tx time %d greater than the current time %d\n",otg_hdr_rx->time,ctime ); - otg_info->radio_access_delay[src][dst] = 0; - otg_multicast_info->radio_access_delay[src][dst]=0; + otg_info->radio_access_delay[src_instance][dst_instance] = 0; + otg_multicast_info->radio_access_delay[src_instance][dst_instance]=0; } /* actual radio OWD*/ - otg_info->rx_pkt_owd[src][dst]=otg_info->radio_access_delay[src][dst]; + otg_info->rx_pkt_owd[src_instance][dst_instance]=otg_info->radio_access_delay[src_instance][dst_instance]; /* estimated E2E OWD based on the emulated delays for the other part of the network */ - otg_info->rx_pkt_owd_e2e[src][dst]=otg_info->owd_const[src][dst][otg_hdr_rx->flow_id] + otg_info->radio_access_delay[src][dst]; - otg_multicast_info->rx_pkt_owd[src][dst]=otg_multicast_info->radio_access_delay[src][dst]; - - LOG_D(OTG, "[src %d][dst %d] ctime %d tx time %d: OWD %lf E2E OWD %lf \n", src, dst, ctime, otg_hdr_rx->time, otg_info->rx_pkt_owd[src][dst], otg_info->rx_pkt_owd_e2e[src][dst] ); + otg_info->rx_pkt_owd_e2e[src_instance][dst_instance]= + otg_info->owd_const[src_instance][dst_instance][otg_hdr_rx->flow_id] + otg_info->radio_access_delay[src_instance][dst_instance]; + otg_multicast_info->rx_pkt_owd[src_instance][dst_instance]=otg_multicast_info->radio_access_delay[src_instance][dst_instance]; + + LOG_D(OTG, "[src %d][dst %d] ctime %d tx time %d: OWD %lf E2E OWD %lf \n", + src_instance, + dst_instance, + ctime, + otg_hdr_rx->time, + otg_info->rx_pkt_owd[src_instance][dst_instance], + otg_info->rx_pkt_owd_e2e[src_instance][dst_instance] ); // compute the jitter by ignoring the packet loss if (lost_packet == 0) { // radio access - otg_info->rx_pkt_owd_history[src][dst][1] = otg_info->rx_pkt_owd_history[src][dst][0]; // the previous owd - otg_info->rx_pkt_owd_history[src][dst][0] = otg_info->rx_pkt_owd[src][dst]; // the current owd + otg_info->rx_pkt_owd_history[src_instance][dst_instance][1] = otg_info->rx_pkt_owd_history[src_instance][dst_instance][0]; // the previous owd + otg_info->rx_pkt_owd_history[src_instance][dst_instance][0] = otg_info->rx_pkt_owd[src_instance][dst_instance]; // the current owd - if (otg_info->rx_pkt_owd_history[src][dst][1] == 0) // first packet - otg_info->rx_pkt_jitter[src][dst]=0; + if (otg_info->rx_pkt_owd_history[src_instance][dst_instance][1] == 0) // first packet + otg_info->rx_pkt_jitter[src_instance][dst_instance]=0; else // for the consecutive packets - otg_info->rx_pkt_jitter[src][dst] = fabsf(otg_info->rx_pkt_owd_history[src][dst][0] - otg_info->rx_pkt_owd_history[src][dst][1]); + otg_info->rx_pkt_jitter[src_instance][dst_instance]= + abs(otg_info->rx_pkt_owd_history[src_instance][dst_instance][0] - otg_info->rx_pkt_owd_history[src_instance][dst_instance][1]); LOG_D(OTG,"The packet jitter for the pair (src %d, dst %d)) at %d is %lf (current %lf, previous %lf) \n", - src, dst, ctime, otg_info->rx_pkt_jitter[src][dst], - otg_info->rx_pkt_owd_history[src][dst][0], otg_info->rx_pkt_owd_history[src][dst][1]); + src_instance, dst_instance, ctime, otg_info->rx_pkt_jitter[src_instance][dst_instance], + otg_info->rx_pkt_owd_history[src_instance][dst_instance][0], otg_info->rx_pkt_owd_history[src_instance][dst_instance][1]); // e2e - otg_info->rx_pkt_owd_history_e2e[src][dst][1] = otg_info->rx_pkt_owd_history_e2e[src][dst][0]; // the previous owd - otg_info->rx_pkt_owd_history_e2e[src][dst][0] = otg_info->rx_pkt_owd_e2e[src][dst]; // the current owd + otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][1] = otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][0]; // the previous owd + otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][0] = otg_info->rx_pkt_owd_e2e[src_instance][dst_instance]; // the current owd - if (otg_info->rx_pkt_owd_history_e2e[src][dst][1] == 0) // first packet - otg_info->rx_pkt_jitter_e2e[src][dst]=0; + if (otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][1] == 0) // first packet + otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance]=0; else // for the consecutive packets - otg_info->rx_pkt_jitter_e2e[src][dst]= fabsf(otg_info->rx_pkt_owd_history_e2e[src][dst][0] - otg_info->rx_pkt_owd_history_e2e[src][dst][1]); + otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance]= + abs(otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][0] - otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][1]); LOG_D(OTG,"The packet jitter for the pair (src %d, dst %d)) at %d is %lf (current %lf, previous %lf) \n", - src, dst, ctime, otg_info->rx_pkt_jitter_e2e[src][dst], - otg_info->rx_pkt_owd_history_e2e[src][dst][0], otg_info->rx_pkt_owd_history_e2e[src][dst][1]); + src_instance, + dst_instance, + ctime, + otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance], + otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][0], + otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][1]); } if (otg_hdr_info_rx->flag == 0x1000) { LOG_I(OTG,"[SRC%d -> DST %d] Received a multicast packet at time %d with size %d, seq num %d, ran owd %d number loss packet %d\n", - dst, src, ctime,otg_hdr_info_rx->size, otg_hdr_rx->seq_num, ctime - otg_hdr_rx->time, nb_loss_pkts); + src_instance, + dst_instance, + ctime,otg_hdr_info_rx->size, + otg_hdr_rx->seq_num, + ctime - otg_hdr_rx->time, + nb_loss_pkts); LOG_I(OTG,"INFO LATENCY :: [SRC %d][DST %d] radio access %.2f (tx time %d, ctime %d), OWD:%.2f (ms):\n", - src, dst, otg_multicast_info->radio_access_delay[src][dst], otg_hdr_rx->time, ctime , otg_multicast_info->rx_pkt_owd[src][dst]); - - if (otg_multicast_info->rx_owd_max[src][dst][otg_hdr_rx->traffic_type]==0) { - otg_multicast_info->rx_owd_max[src][dst][otg_hdr_rx->traffic_type]=otg_multicast_info->rx_pkt_owd[src][dst]; - otg_multicast_info->rx_owd_min[src][dst][otg_hdr_rx->traffic_type]=otg_multicast_info->rx_pkt_owd[src][dst]; + src_instance, + dst_instance, + otg_multicast_info->radio_access_delay[src_instance][dst_instance], + otg_hdr_rx->time, ctime , + otg_multicast_info->rx_pkt_owd[src_instance][dst_instance]); + + if (otg_multicast_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]==0) { + otg_multicast_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_multicast_info->rx_pkt_owd[src_instance][dst_instance]; + otg_multicast_info->rx_owd_min[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_multicast_info->rx_pkt_owd[src_instance][dst_instance]; } else { - otg_multicast_info->rx_owd_max[src][dst][otg_hdr_rx->traffic_type]=MAX(otg_multicast_info->rx_owd_max[src][dst][otg_hdr_rx->traffic_type],otg_multicast_info->rx_pkt_owd[src][dst] ); - otg_multicast_info->rx_owd_min[src][dst][otg_hdr_rx->traffic_type]=MIN(otg_multicast_info->rx_owd_min[src][dst][otg_hdr_rx->traffic_type],otg_multicast_info->rx_pkt_owd[src][dst] ); + otg_multicast_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MAX( + otg_multicast_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_multicast_info->rx_pkt_owd[src_instance][dst_instance] ); + otg_multicast_info->rx_owd_min[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MIN( + otg_multicast_info->rx_owd_min[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_multicast_info->rx_pkt_owd[src_instance][dst_instance] ); } if (g_otg->curve==1) { if (g_otg->owd_radio_access==0) - add_tab_metric(src, dst, otg_multicast_info->rx_pkt_owd[src][dst], ((otg_hdr_info_rx->size*1000*8)/(otg_multicast_info->rx_pkt_owd[src][dst]*1024 )), otg_hdr_rx->time); + add_tab_metric( + src_instance, + dst_instance, + otg_multicast_info->rx_pkt_owd[src_instance][dst_instance], + ((otg_hdr_info_rx->size*1000*8)/(otg_multicast_info->rx_pkt_owd[src_instance][dst_instance]*1024 )), + otg_hdr_rx->time); else - add_tab_metric(src, dst, otg_multicast_info->radio_access_delay[src][dst], ((otg_hdr_info_rx->size*1000*8)/(otg_multicast_info->rx_pkt_owd[src][dst]*1024 )), otg_hdr_rx->time); + add_tab_metric(src_instance, + dst_instance, + otg_multicast_info->radio_access_delay[src_instance][dst_instance], + ((otg_hdr_info_rx->size*1000*8)/(otg_multicast_info->rx_pkt_owd[src_instance][dst_instance]*1024 )), + otg_hdr_rx->time); } otg_multicast_info->rx_total_bytes_dl+=otg_hdr_info_rx->size; } else { LOG_I(OTG,"[SRC %d][DST %d] Stats :: radio access latency %.2f (tx time %d, ctime %d) jitter %.2f, Estimated E2E OWD:%.2f (ms):\n", - src, dst, otg_info->radio_access_delay[src][dst], otg_hdr_rx->time, ctime , otg_info->rx_pkt_jitter[src][dst], otg_info->rx_pkt_owd_e2e[src][dst]); + src_instance, + dst_instance, + otg_info->radio_access_delay[src_instance][dst_instance], + otg_hdr_rx->time, ctime , + otg_info->rx_pkt_jitter[src_instance][dst_instance], + otg_info->rx_pkt_owd_e2e[src_instance][dst_instance]); if (otg_hdr_info_rx->flag == 0xffff) { - if (otg_info->rx_owd_max[src][dst][otg_hdr_rx->traffic_type]==0) { - otg_info->rx_owd_max[src][dst][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd[src][dst]; - otg_info->rx_owd_min[src][dst][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd[src][dst]; - otg_info->rx_owd_max_e2e[src][dst][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd_e2e[src][dst]; - otg_info->rx_owd_min_e2e[src][dst][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd_e2e[src][dst]; + if (otg_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]==0) { + otg_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd[src_instance][dst_instance]; + otg_info->rx_owd_min[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd[src_instance][dst_instance]; + otg_info->rx_owd_max_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd_e2e[src_instance][dst_instance]; + otg_info->rx_owd_min_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd_e2e[src_instance][dst_instance]; } else { - otg_info->rx_owd_max[src][dst][otg_hdr_rx->traffic_type]=MAX(otg_info->rx_owd_max[src][dst][otg_hdr_rx->traffic_type],otg_info->rx_pkt_owd[src][dst] ); - otg_info->rx_owd_min[src][dst][otg_hdr_rx->traffic_type]=MIN(otg_info->rx_owd_min[src][dst][otg_hdr_rx->traffic_type],otg_info->rx_pkt_owd[src][dst] ); - otg_info->rx_owd_max_e2e[src][dst][otg_hdr_rx->traffic_type]=MAX(otg_info->rx_owd_max_e2e[src][dst][otg_hdr_rx->traffic_type],otg_info->rx_pkt_owd_e2e[src][dst] ); - otg_info->rx_owd_min_e2e[src][dst][otg_hdr_rx->traffic_type]=MIN(otg_info->rx_owd_min_e2e[src][dst][otg_hdr_rx->traffic_type],otg_info->rx_pkt_owd_e2e[src][dst] ); + otg_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MAX(otg_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_info->rx_pkt_owd[src_instance][dst_instance] ); + otg_info->rx_owd_min[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MIN(otg_info->rx_owd_min[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_info->rx_pkt_owd[src_instance][dst_instance] ); + otg_info->rx_owd_max_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MAX(otg_info->rx_owd_max_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_info->rx_pkt_owd_e2e[src_instance][dst_instance] ); + otg_info->rx_owd_min_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MIN(otg_info->rx_owd_min_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_info->rx_pkt_owd_e2e[src_instance][dst_instance] ); } - if (otg_info->rx_jitter_max[src][dst][otg_hdr_rx->traffic_type]==0) { - otg_info->rx_jitter_max[src][dst][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_jitter[src][dst]; - otg_info->rx_jitter_min[src][dst][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_jitter[src][dst]; - otg_info->rx_jitter_max_e2e[src][dst][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_jitter_e2e[src][dst]; - otg_info->rx_jitter_min_e2e[src][dst][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_jitter_e2e[src][dst]; + if (otg_info->rx_jitter_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]==0) { + otg_info->rx_jitter_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_jitter[src_instance][dst_instance]; + otg_info->rx_jitter_min[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_jitter[src_instance][dst_instance]; + otg_info->rx_jitter_max_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance]; + otg_info->rx_jitter_min_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance]; } else if (lost_packet==0) { - otg_info->rx_jitter_max[src][dst][otg_hdr_rx->traffic_type]=MAX(otg_info->rx_jitter_max[src][dst][otg_hdr_rx->traffic_type],otg_info->rx_pkt_jitter[src][dst] ); - otg_info->rx_jitter_min[src][dst][otg_hdr_rx->traffic_type]=MIN(otg_info->rx_jitter_min[src][dst][otg_hdr_rx->traffic_type],otg_info->rx_pkt_jitter[src][dst] ); - otg_info->rx_jitter_max_e2e[src][dst][otg_hdr_rx->traffic_type]=MAX(otg_info->rx_jitter_max_e2e[src][dst][otg_hdr_rx->traffic_type],otg_info->rx_pkt_jitter_e2e[src][dst] ); - otg_info->rx_jitter_min_e2e[src][dst][otg_hdr_rx->traffic_type]=MIN(otg_info->rx_jitter_min_e2e[src][dst][otg_hdr_rx->traffic_type],otg_info->rx_pkt_jitter_e2e[src][dst] ); + otg_info->rx_jitter_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MAX(otg_info->rx_jitter_max[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_info->rx_pkt_jitter[src_instance][dst_instance] ); + otg_info->rx_jitter_min[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MIN(otg_info->rx_jitter_min[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_info->rx_pkt_jitter[src_instance][dst_instance] ); + otg_info->rx_jitter_max_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MAX(otg_info->rx_jitter_max_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance] ); + otg_info->rx_jitter_min_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type]=MIN(otg_info->rx_jitter_min_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type], + otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance] ); // avg jitter - otg_info->rx_jitter_avg[src][dst][otg_hdr_rx->traffic_type] += otg_info->rx_pkt_jitter[src][dst]; - otg_info->rx_jitter_avg_e2e[src][dst][otg_hdr_rx->traffic_type] += otg_info->rx_pkt_jitter_e2e[src][dst]; - otg_info->rx_jitter_sample[src][dst][otg_hdr_rx->traffic_type] +=1; + otg_info->rx_jitter_avg[src_instance][dst_instance][otg_hdr_rx->traffic_type] += otg_info->rx_pkt_jitter[src_instance][dst_instance]; + otg_info->rx_jitter_avg_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type] += otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance]; + otg_info->rx_jitter_sample[src_instance][dst_instance][otg_hdr_rx->traffic_type] +=1; } } if (g_otg->curve==1) { if (g_otg->owd_radio_access==0) - add_tab_metric(src, dst, otg_info->rx_pkt_owd[src][dst], ((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src][dst]*1024 )), otg_hdr_rx->time); + add_tab_metric( + src_instance, + dst_instance, + otg_info->rx_pkt_owd[src_instance][dst_instance], + ((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src_instance][dst_instance]*1024 )), + otg_hdr_rx->time); else - add_tab_metric(src, dst, otg_info->radio_access_delay[src][dst], ((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src][dst]*1024 )), otg_hdr_rx->time); + add_tab_metric( + src_instance, + dst_instance, otg_info->radio_access_delay[src_instance][dst_instance], + ((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src_instance][dst_instance]*1024 )), + otg_hdr_rx->time); } - if (src<NB_eNB_INST) + if (src_instance<NB_eNB_INST) otg_info->rx_total_bytes_dl+=otg_hdr_info_rx->size; else otg_info->rx_total_bytes_ul+=otg_hdr_info_rx->size; @@ -283,85 +369,97 @@ int otg_rx_pkt( int src, int dst, int ctime, char *buffer_tx, unsigned int size) //printf("payload_size %d, header_size %d \n", otg_hdr_rx->pkts_size, otg_hdr_rx->hdr_type); LOG_I(OTG,"[RX] OTG packet, PACKET SIZE [SRC %d][DST %d]: Flag (0x%x), Traffic %d, time(%d), Seq num (%d), Total size (%d)\n", - src, dst, otg_hdr_info_rx->flag, otg_hdr_rx->traffic_type, ctime, otg_hdr_rx->seq_num, size); + src_instance, + dst_instance, + otg_hdr_info_rx->flag, + otg_hdr_rx->traffic_type, + ctime, + otg_hdr_rx->seq_num, size); /*LOG_I(OTG,"details::RX [SRC %d][DST %d]: Flag (0x%x), time(%d), Seq num (%d), Total size (%d), header(%d), payload (%d) \n", src, dst, otg_hdr_info_rx->flag, ctime, otg_hdr_rx->seq_num, size, strlen(packet_rx->header), strlen(packet_rx->payload));*/ if (otg_hdr_info_rx->flag == 0xffff) { - otg_info->rx_num_pkt[src][dst][otg_hdr_rx->traffic_type]+=1; - otg_info->rx_num_bytes[src][dst][otg_hdr_rx->traffic_type]+=otg_hdr_info_rx->size; - otg_info->seq_num_rx[src][dst][otg_hdr_rx->traffic_type]=seq_num_rx; + otg_info->rx_num_pkt[src_instance][dst_instance][otg_hdr_rx->traffic_type]+=1; + otg_info->rx_num_bytes[src_instance][dst_instance][otg_hdr_rx->traffic_type]+=otg_hdr_info_rx->size; + otg_info->seq_num_rx[src_instance][dst_instance][otg_hdr_rx->traffic_type]=seq_num_rx; - if (src<NB_eNB_INST) - otg_info->nb_loss_pkts_dl[src][dst][otg_hdr_rx->traffic_type]=nb_loss_pkts; + if (src_instance<NB_eNB_INST) + otg_info->nb_loss_pkts_dl[src_instance][dst_instance][otg_hdr_rx->traffic_type]=nb_loss_pkts; else - otg_info->nb_loss_pkts_ul[src][dst][otg_hdr_rx->traffic_type]=nb_loss_pkts; + otg_info->nb_loss_pkts_ul[src_instance][dst_instance][otg_hdr_rx->traffic_type]=nb_loss_pkts; /*Plots of latency and goodput are only plotted for the data traffic*/ /*measurements are done for the data and background traffic */ if (g_otg->latency_metric) { if (g_otg->owd_radio_access==0) { - add_log_metric(src, dst, otg_hdr_rx->time, otg_info->rx_pkt_owd[src][dst], OTG_LATENCY); - add_log_metric(src, dst, otg_hdr_rx->time, otg_info->rx_pkt_jitter_e2e[src][dst], OTG_JITTER); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, otg_info->rx_pkt_owd[src_instance][dst_instance], OTG_LATENCY); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance], OTG_JITTER); } else { - add_log_metric(src, dst, otg_hdr_rx->time, otg_info->radio_access_delay[src][dst], OTG_LATENCY); - add_log_metric(src, dst, otg_hdr_rx->time, otg_info->rx_pkt_jitter[src][dst], OTG_JITTER); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, otg_info->radio_access_delay[src_instance][dst_instance], OTG_LATENCY); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, otg_info->rx_pkt_jitter[src_instance][dst_instance], OTG_JITTER); } } if (g_otg->throughput_metric) - add_log_metric(src, dst, otg_hdr_rx->time, ((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src][dst]*1024 )), OTG_GP); /* compute the throughput in Kbit/s */ + add_log_metric(src_instance, + dst_instance, + otg_hdr_rx->time, + ((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src_instance][dst_instance]*1024 )), + OTG_GP); /* compute the throughput in Kbit/s */ } else if (otg_hdr_info_rx->flag == 0x1000) { - otg_multicast_info->rx_num_pkt[src][dst][otg_hdr_rx->traffic_type]+=1; - otg_multicast_info->rx_num_bytes[src][dst][otg_hdr_rx->traffic_type]+=otg_hdr_info_rx->size; + otg_multicast_info->rx_num_pkt[src_instance][dst_instance][otg_hdr_rx->traffic_type]+=1; + otg_multicast_info->rx_num_bytes[src_instance][dst_instance][otg_hdr_rx->traffic_type]+=otg_hdr_info_rx->size; // LOG_D(OTG,"DUY: otg_multicast_info->rx_num_bytes[%d][%d][%d] is %d \nn",src,dst,otg_hdr_rx->traffic_type,otg_multicast_info->rx_num_bytes[src][dst][otg_hdr_rx->traffic_type]); - otg_multicast_info->rx_sn[src][dst][otg_hdr_rx->traffic_type]=seq_num_rx; - otg_multicast_info->loss_pkts_dl[src][dst][otg_hdr_rx->traffic_type]=nb_loss_pkts; + otg_multicast_info->rx_sn[src_instance][dst_instance][otg_hdr_rx->traffic_type]=seq_num_rx; + otg_multicast_info->loss_pkts_dl[src_instance][dst_instance][otg_hdr_rx->traffic_type]=nb_loss_pkts; /*Plots of latency and goodput are only plotted for the data traffic*/ /*measurements are done for the data and background traffic */ if (g_otg->latency_metric) { if (g_otg->owd_radio_access==0) - add_log_metric(src, dst, otg_hdr_rx->time, otg_multicast_info->rx_pkt_owd[src][dst], OTG_LATENCY); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, otg_multicast_info->rx_pkt_owd[src_instance][dst_instance], OTG_LATENCY); else - add_log_metric(src, dst, otg_hdr_rx->time, otg_multicast_info->radio_access_delay[src][dst], OTG_LATENCY); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, otg_multicast_info->radio_access_delay[src_instance][dst_instance], OTG_LATENCY); } if (g_otg->throughput_metric) - add_log_metric(src, dst, otg_hdr_rx->time, ((otg_hdr_info_rx->size*1000*8)/(otg_multicast_info->rx_pkt_owd[src][dst]*1024 )), OTG_GP); /* compute the throughput in Kbit/s */ + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, ((otg_hdr_info_rx->size*1000*8)/(otg_multicast_info->rx_pkt_owd[src_instance][dst_instance]*1024 )), + OTG_GP); /* compute the throughput in Kbit/s */ } else { - otg_info->rx_num_pkt_background[src][dst]+=1; - otg_info->rx_num_bytes_background[src][dst]+=otg_hdr_info_rx->size; - otg_info->seq_num_rx_background[src][dst]=seq_num_rx; + otg_info->rx_num_pkt_background[src_instance][dst_instance]+=1; + otg_info->rx_num_bytes_background[src_instance][dst_instance]+=otg_hdr_info_rx->size; + otg_info->seq_num_rx_background[src_instance][dst_instance]=seq_num_rx; - if (src<NB_eNB_INST) - otg_info->nb_loss_pkts_background_dl[src][dst]=nb_loss_pkts; + if (src_instance<NB_eNB_INST) + otg_info->nb_loss_pkts_background_dl[src_instance][dst_instance]=nb_loss_pkts; else - otg_info->nb_loss_pkts_background_ul[src][dst]=nb_loss_pkts; + otg_info->nb_loss_pkts_background_ul[src_instance][dst_instance]=nb_loss_pkts; if (g_otg->latency_metric) { if (g_otg->owd_radio_access==0) - add_log_metric(src, dst, otg_hdr_rx->time, otg_info->rx_pkt_owd[src][dst], OTG_LATENCY_BG); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, otg_info->rx_pkt_owd[src_instance][dst_instance], OTG_LATENCY_BG); else - add_log_metric(src, dst, otg_hdr_rx->time, otg_info->radio_access_delay[src][dst], OTG_LATENCY_BG); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, otg_info->radio_access_delay[src_instance][dst_instance], OTG_LATENCY_BG); } if (g_otg->throughput_metric) - add_log_metric(src, dst, otg_hdr_rx->time, ((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src][dst]*1024 )), OTG_GP_BG); + add_log_metric(src_instance, dst_instance, otg_hdr_rx->time, ((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src_instance][dst_instance]*1024 )), OTG_GP_BG); } if (is_size_ok == 0) { otg_hdr_rx = (otg_hdr_t *) (&buffer_tx[bytes_read]); - LOG_W(OTG,"[SRC %d][DST %d] RX pkt: seq number %d size mis-matche (hdr %d, pdcp %d) \n", src, dst, otg_hdr_rx->seq_num, otg_hdr_info_rx->size, size); - otg_info->nb_loss_pkts_otg[src][dst]++; + LOG_W(OTG,"[SRC %d][DST %d] RX pkt: seq number %d size mis-matche (hdr %d, pdcp %d) \n", + src_instance, dst_instance, otg_hdr_rx->seq_num, otg_hdr_info_rx->size, size); + otg_info->nb_loss_pkts_otg[src_instance][dst_instance]++; } return(0); } else { - LOG_W(OTG,"RX: Not an OTG pkt, forward to upper layer (flag %x, size %d, pdcp_size %d) FIX ME \n", otg_hdr_info_rx->flag, otg_hdr_info_rx->size, size); + LOG_W(OTG,"RX: Not an OTG pkt, forward to upper layer (flag %x, size %d, pdcp_size %d) FIX ME \n", + otg_hdr_info_rx->flag, otg_hdr_info_rx->size, size); return(0); //to be fixed on the real case to one } @@ -373,7 +471,13 @@ int otg_rx_pkt( int src, int dst, int ctime, char *buffer_tx, unsigned int size) -int rx_check_loss(int src, int dst, unsigned int flag, int seq_num, unsigned int *seq_num_rx, unsigned int *nb_loss_pkts) +int rx_check_loss( + const int src, + const int dst, + const unsigned int flag, + const int seq_num, + unsigned int * const seq_num_rx, + unsigned int * const nb_loss_pkts) { /* Loss and out of sequence data management, we have 3 case : */ @@ -406,7 +510,11 @@ int rx_check_loss(int src, int dst, unsigned int flag, int seq_num, unsigned int -void owd_const_gen(int src, int dst, int flow_id, unsigned int flag) +void owd_const_gen( + const int src, + const int dst, + const int flow_id, + const unsigned int flag) { otg_info->owd_const[src][dst][flow_id]=(owd_const_mobile_core()+owd_const_IP_backbone()+owd_const_application())/2; @@ -423,9 +531,9 @@ void owd_const_gen(int src, int dst, int flow_id, unsigned int flag) float owd_const_capillary(void) { /*return (uniform_dist(MIN_APPLICATION_PROCESSING_GATEWAY_DELAY, MAX_APPLICATION_PROCESSING_GATEWAY_DELAY) + - uniform_dist(MIN_FORMATING_TRANSFERRING_DELAY, MAX_FORMATING_TRANSFERRING_DELAY) + - uniform_dist(MIN_ACCESS_DELAY, MAX_ACCESS_DELAY) + - TERMINAL_ACCESS_DELAY);*/ + uniform_dist(MIN_FORMATING_TRANSFERRING_DELAY, MAX_FORMATING_TRANSFERRING_DELAY) + + uniform_dist(MIN_ACCESS_DELAY, MAX_ACCESS_DELAY) + + TERMINAL_ACCESS_DELAY);*/ return ((double)MIN_APPLICATION_PROCESSING_GATEWAY_DELAY+ (double)MAX_APPLICATION_PROCESSING_GATEWAY_DELAY + (double)MIN_FORMATING_TRANSFERRING_DELAY+ (double)MAX_FORMATING_TRANSFERRING_DELAY+ (double)MIN_ACCESS_DELAY+(double)MAX_ACCESS_DELAY) /2 + (double)TERMINAL_ACCESS_DELAY; } @@ -442,7 +550,7 @@ float owd_const_mobile_core(void) // in this case, according to the fit in the paper, // the delay is generalized pareto: GP(k=0.75,s=0.55,t=1.2) // using inverse cdf method we have CDF(x)=1-(k(x-t)/s+1)^(-1/k), - // x=CDF^(-1)(u)=t+s/k*((1-u)^(-k)-1) , hence when u~uniform, than x~GP(k,s,t) + // x=CDF^(-1)(u)=t+s/k*((1-u)^(-k)-1) , hence when u~uniform, than x~GP(k,s,t) double k,s,t,u; k=0.75; diff --git a/openair2/UTIL/OTG/otg_rx.h b/openair2/UTIL/OTG/otg_rx.h index 45ee245b9f9..6b3536a9c09 100644 --- a/openair2/UTIL/OTG/otg_rx.h +++ b/openair2/UTIL/OTG/otg_rx.h @@ -53,16 +53,17 @@ -/*! \fn char *check_packet(int src, int dst, int ctime); +/*! \fn int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buffer_tx, const unsigned int size); * \brief check if the packet is well received and do measurements: one way delay, throughput,etc. -* \param[in] the source * \param[in] the destination * \param[in] time of the emulation +* \param[in] The packet +* \param[in] Size of the packet * \param[out] return NULL is the packet is well received, else the packet to forward * \note * @ingroup _otg */ -int otg_rx_pkt(int src, int dst, int ctime, char *packet, unsigned int size); +int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buffer_tx, const unsigned int size); /*! \fn void owd_const_gen(int src,int dst); @@ -73,7 +74,7 @@ int otg_rx_pkt(int src, int dst, int ctime, char *packet, unsigned int size); *\note *@ingroup _otg */ -void owd_const_gen(int src,int dst, int flow_id, unsigned int flag); +void owd_const_gen(const int src, const int dst, const int flow_id, const unsigned int flag); /*! \fn float owd_const_capillary(); *\brief compute the one way delay introduced in LTE/LTE-A network REF PAPER: "Latency for Real-Time Machine-to-Machine Communication in LTE-Based System Architecture" @@ -108,7 +109,7 @@ float owd_const_IP_backbone(void); float owd_const_application(void); -/*! \fn void rx_check_loss(int src, int dst, unsigned int flag, int seq_num, unsigned int *seq_num_rx, unsigned int *nb_loss_pkts); +/*! \fn void rx_check_loss(const int src, const int dst, const unsigned int flag, const int seq_num, unsigned int * const seq_num_rx, unsigned int * const nb_loss_pkts); *\brief check the number of loss packet/out of sequence *\param[in] src *\param[in] dst @@ -120,6 +121,12 @@ float owd_const_application(void); *\note *@ingroup _otg */ -int rx_check_loss(int src, int dst, unsigned int flag, int seq_num, unsigned int *seq_num_rx, unsigned int *nb_loss_pkts); +int rx_check_loss( + const int src, + const int dst, + const unsigned int flag, + const int seq_num, + unsigned int * const seq_num_rx, + unsigned int * const nb_loss_pkts); #endif diff --git a/openair2/UTIL/OTG/otg_tx.c b/openair2/UTIL/OTG/otg_tx.c index c40dc223bb5..52b30ea44bc 100644 --- a/openair2/UTIL/OTG/otg_tx.c +++ b/openair2/UTIL/OTG/otg_tx.c @@ -25,24 +25,23 @@ Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE -*******************************************************************************/ + *******************************************************************************/ /*! \file otg_tx.c -* \brief function containing the OTG TX traffic generation functions -* \author N. Nikaein and A. Hafsaoui -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr -* \note -* \warning -*/ + * \brief function containing the OTG TX traffic generation functions + * \author N. Nikaein and A. Hafsaoui + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: navid.nikaein@eurecom.fr + * \note + * \warning + */ #include "UTIL/MATH/oml.h" #include "otg_tx.h" #include "otg_externs.h" -#include "assertions.h" extern unsigned char NB_eNB_INST; extern unsigned char NB_UE_INST; @@ -65,72 +64,78 @@ int ptime=0; // Time Distribution function to distribute the inter-departure time using the required distribution -int time_dist(int src, int dst,int application, int state) +int time_dist( + const int src_instance, + const int dst_instance, + const int application, + const int state) { int idt=0; - switch (g_otg->idt_dist[src][dst][application][state]) { + switch (g_otg->idt_dist[src_instance][dst_instance][application][state]) { case UNIFORM: - idt = ceil((uniform_dist(g_otg->idt_min[src][dst][application][state], g_otg->idt_max[src][dst][application][state]))); + idt = ceil((uniform_dist(g_otg->idt_min[src_instance][dst_instance][application][state], g_otg->idt_max[src_instance][dst_instance][application][state]))); break; case GAUSSIAN: - idt = ceil((gaussian_dist((g_otg->idt_max[src][dst][application][state] + g_otg->idt_min[src][dst][application][state])/2 , g_otg->idt_std_dev[src][dst][application][state]))); + idt = ceil((gaussian_dist((g_otg->idt_max[src_instance][dst_instance][application][state] + g_otg->idt_min[src_instance][dst_instance][application][state])/2 , + g_otg->idt_std_dev[src_instance][dst_instance][application][state]))); break; case EXPONENTIAL : - idt= ceil((exponential_dist(g_otg->idt_lambda[src][dst][application][state]))); + idt= ceil((exponential_dist(g_otg->idt_lambda[src_instance][dst_instance][application][state]))); break; case POISSON: - idt = ceil((poisson_dist(g_otg->idt_lambda[src][dst][application][state]))); + idt = ceil((poisson_dist(g_otg->idt_lambda[src_instance][dst_instance][application][state]))); break; case FIXED : - idt = ceil((g_otg->idt_min[src][dst][application][state])); //IDT_TH * + idt = ceil((g_otg->idt_min[src_instance][dst_instance][application][state])); //IDT_TH * break; case WEIBULL : - idt =ceil(weibull_dist(g_otg->idt_scale[src][dst][application][state],g_otg->idt_shape[src][dst][application][state] )); + idt =ceil(weibull_dist(g_otg->idt_scale[src_instance][dst_instance][application][state],g_otg->idt_shape[src_instance][dst_instance][application][state] )); break; case PARETO : - idt =ceil(pareto_dist(g_otg->idt_scale[src][dst][application][state],g_otg->idt_shape[src][dst][application][state] )); + idt =ceil(pareto_dist(g_otg->idt_scale[src_instance][dst_instance][application][state],g_otg->idt_shape[src_instance][dst_instance][application][state] )); break; case GAMMA : - idt =ceil(gamma_dist(g_otg->idt_scale[src][dst][application][state],g_otg->idt_shape[src][dst][application][state] )); + idt =ceil(gamma_dist(g_otg->idt_scale[src_instance][dst_instance][application][state],g_otg->idt_shape[src_instance][dst_instance][application][state] )); break; case CAUCHY : - idt =ceil(cauchy_dist(g_otg->idt_scale[src][dst][application][state],g_otg->idt_shape[src][dst][application][state] )); + idt =ceil(cauchy_dist(g_otg->idt_scale[src_instance][dst_instance][application][state],g_otg->idt_shape[src_instance][dst_instance][application][state] )); break; case LOG_NORMAL : - idt =ceil((lognormal_dist((g_otg->idt_max[src][dst][application][state] + g_otg->idt_min[src][dst][application][state])/2 , g_otg->idt_std_dev[src][dst][application][state]))); + idt =ceil((lognormal_dist((g_otg->idt_max[src_instance][dst_instance][application][state] + g_otg->idt_min[src_instance][dst_instance][application][state])/2 , + g_otg->idt_std_dev[src_instance][dst_instance][application][state]))); break; case TARMA : - idt=ceil(tarmaCalculateSample(otg_info->tarma_stream[src][dst][application]->tarma_input_samples, - &(otg_info->tarma_stream[src][dst][application]->tarma_idt))); + idt=ceil(tarmaCalculateSample(otg_info->tarma_stream[src_instance][dst_instance][application]->tarma_input_samples, + &(otg_info->tarma_stream[src_instance][dst_instance][application]->tarma_idt))); break; case VIDEO : - idt = ceil((g_otg->idt_min[src][dst][application][state])); //IDT_TH * + idt = ceil((g_otg->idt_min[src_instance][dst_instance][application][state])); //IDT_TH * break; case BACKGROUND_DIST : - idt = ceil((g_otg->idt_min[src][dst][application][state])); //IDT_TH * + idt = ceil((g_otg->idt_min[src_instance][dst_instance][application][state])); //IDT_TH * break; default : idt =0; LOG_W(OTG, "IDT distribution unknown, set to 0 for (src %d, dst %d, app %d, state %d)\n", - src, dst, application, state ); + src_instance, dst_instance, application, state ); } - LOG_D(OTG,"IDT :: Inter Departure Time Distribution= %d , val= %d\n", g_otg->idt_dist[src][dst][application][state],idt); + LOG_D(OTG,"IDT :: Inter Departure Time Distribution= %d , val= %d\n", g_otg->idt_dist[src_instance][dst_instance][application][state],idt); return idt; } @@ -138,84 +143,91 @@ int time_dist(int src, int dst,int application, int state) // otg_params.size Distribution Function to distribute the packet otg_params.size using the required distribution -int size_dist(int src, int dst, int application, int state) +int size_dist( + const int src_instance, + const int dst_instance, + const int application, + const int state) { int size_data=0; if (state==PU_STATE) - size_data=g_otg->pu_size_pkts[src][dst][application]; + size_data=g_otg->pu_size_pkts[src_instance][dst_instance][application]; else if (state==ED_STATE) - size_data=g_otg->ed_size_pkts[src][dst][application]; + size_data=g_otg->ed_size_pkts[src_instance][dst_instance][application]; else { - LOG_D(OTG,"Size Distribution idx= %d \n", g_otg->size_dist[src][dst][application][state]); + LOG_D(OTG,"Size Distribution idx= %d \n", g_otg->size_dist[src_instance][dst_instance][application][state]); - switch (g_otg->size_dist[src][dst][application][state]) { + switch (g_otg->size_dist[src_instance][dst_instance][application][state]) { case UNIFORM : - size_data = ceil(uniform_dist(g_otg->size_min[src][dst][application][state], g_otg->size_max[src][dst][application][state])); + size_data = ceil(uniform_dist(g_otg->size_min[src_instance][dst_instance][application][state], g_otg->size_max[src_instance][dst_instance][application][state])); break; case GAUSSIAN : - size_data = ceil(gaussian_dist((g_otg->size_max[src][dst][application][state] + g_otg->size_min[src][dst][application][state])/2 , g_otg->size_std_dev[src][dst][application][state])); + size_data = ceil(gaussian_dist((g_otg->size_max[src_instance][dst_instance][application][state] + g_otg->size_min[src_instance][dst_instance][application][state])/2 , + g_otg->size_std_dev[src_instance][dst_instance][application][state])); break; case EXPONENTIAL : - size_data= ceil(exponential_dist(g_otg->size_lambda[src][dst][application][state])); //SIZE_COEF * + size_data= ceil(exponential_dist(g_otg->size_lambda[src_instance][dst_instance][application][state])); //SIZE_COEF * break; case POISSON : - size_data =ceil(poisson_dist(g_otg->size_lambda[src][dst][application][state])); + size_data =ceil(poisson_dist(g_otg->size_lambda[src_instance][dst_instance][application][state])); break; case FIXED : - size_data=ceil(g_otg->size_min[src][dst][application][state]); + size_data=ceil(g_otg->size_min[src_instance][dst_instance][application][state]); break; case WEIBULL : - size_data =ceil(weibull_dist(g_otg->size_scale[src][dst][application][state],g_otg->size_shape[src][dst][application][state] )); + size_data =ceil(weibull_dist(g_otg->size_scale[src_instance][dst_instance][application][state],g_otg->size_shape[src_instance][dst_instance][application][state] )); break; case PARETO : - size_data =ceil(pareto_dist(g_otg->size_scale[src][dst][application][state],g_otg->size_shape[src][dst][application][state] )); + size_data =ceil(pareto_dist(g_otg->size_scale[src_instance][dst_instance][application][state],g_otg->size_shape[src_instance][dst_instance][application][state] )); break; case GAMMA : - size_data =ceil(gamma_dist(g_otg->size_scale[src][dst][application][state],g_otg->size_shape[src][dst][application][state] )); + size_data =ceil(gamma_dist(g_otg->size_scale[src_instance][dst_instance][application][state],g_otg->size_shape[src_instance][dst_instance][application][state] )); break; case CAUCHY : - size_data =ceil(cauchy_dist(g_otg->size_scale[src][dst][application][state],g_otg->size_shape[src][dst][application][state] )); + size_data =ceil(cauchy_dist(g_otg->size_scale[src_instance][dst_instance][application][state],g_otg->size_shape[src_instance][dst_instance][application][state] )); break; case LOG_NORMAL : - size_data =ceil((lognormal_dist((g_otg->size_max[src][dst][application][state] + g_otg->size_min[src][dst][application][state])/2 , g_otg->size_std_dev[src][dst][application][state]))); + size_data =ceil((lognormal_dist((g_otg->size_max[src_instance][dst_instance][application][state] + g_otg->size_min[src_instance][dst_instance][application][state])/2 , + g_otg->size_std_dev[src_instance][dst_instance][application][state]))); break; case TARMA : - size_data=ceil(tarmaCalculateSample(otg_info->tarma_stream[src][dst][application]->tarma_input_samples, - &(otg_info->tarma_stream[src][dst][application]->tarma_size))); + size_data=ceil(tarmaCalculateSample(otg_info->tarma_stream[src_instance][dst_instance][application]->tarma_input_samples, + &(otg_info->tarma_stream[src_instance][dst_instance][application]->tarma_size))); break; case VIDEO : - size_data=ceil(tarmaCalculateVideoSample (otg_info->tarma_video[src][dst][application])); + size_data=ceil(tarmaCalculateVideoSample (otg_info->tarma_video[src_instance][dst_instance][application])); break; case BACKGROUND_DIST : - size_data = ceil(backgroundCalculateSize(otg_info->background_stream[src][dst][application], - otg_info->ctime, otg_info->idt[src][dst][application])); + size_data = ceil(backgroundCalculateSize(otg_info->background_stream[src_instance][dst_instance][application], + otg_info->ctime, otg_info->idt[src_instance][dst_instance][application])); break; default: LOG_E(OTG, "PKT Size Distribution unknown (src %d, dst %d, app %d, state %d)\n", - src, dst, application, state ); + src_instance, dst_instance, application, state ); } } //Case when size overfill min and max values size_data=adjust_size(size_data); - LOG_D(OTG,"[src %d] [dst %d] [application %d] [state %d]Packet :: Size=%d Distribution= %d \n", src, dst, application, state, size_data, g_otg->size_dist[src][dst][application][state]); + LOG_D(OTG,"[src %d] [dst %d] [application %d] [state %d]Packet :: Size=%d Distribution= %d \n", src_instance, dst_instance, application, state, size_data, + g_otg->size_dist[src_instance][dst_instance][application][state]); return size_data; } @@ -238,8 +250,14 @@ int adjust_size(int size) -unsigned char *packet_gen(int src, int dst, int app, int ctime, unsigned int * pkt_size) // when pdcp, ctime = frame cnt +unsigned char *packet_gen( + const int src_instance, + const int dst_instance, + const int app, + const int ctime, + unsigned int * const pkt_size) { + // when pdcp, ctime = frame cnt //unsigned char *packet=NULL; unsigned int size=0; @@ -254,105 +272,138 @@ unsigned char *packet_gen(int src, int dst, int app, int ctime, unsigned int * p // check if the app is configured - if (app >= g_otg->application_idx[src][dst]) { + if (app >= g_otg->application_idx[src_instance][dst_instance]) { return NULL; } - LOG_T(OTG,"[src %d] [dst %d ][APP %d] current time %d\n",src, dst, app, ctime); + LOG_T(OTG,"[src %d] [dst %d ][APP %d] current time %d\n",src_instance, dst_instance, app, ctime); *pkt_size=0; - init_packet_gen(src, dst,ctime); - size=check_data_transmit(src,dst,app,ctime); + init_packet_gen(src_instance, dst_instance,ctime); + size=check_data_transmit(src_instance,dst_instance,app,ctime); /* Send Packets when: - there is data to send - time to transmit background traffic - when (emutime- ctime)>20m ==> to avoid the fact that TX transmit and RX - can't received due to the end of the emulation - */ - if (((size>0) || (otg_info->traffic_type_background[src][dst]==1)) && + can't received due to the end of the emulation + */ + if (((size>0) || (otg_info->traffic_type_background[src_instance][dst_instance]==1)) && (((g_otg->max_nb_frames*10)-ctime)>20)) { /* No aggregation for background traffic */ - if (otg_info->traffic_type_background[src][dst]==0) { - if (otg_info->header_size[src][dst] <= 0) - otg_info->header_size[src][dst]=1; + if (otg_info->traffic_type_background[src_instance][dst_instance]==0) { + if (otg_info->header_size[src_instance][dst_instance] <= 0) + otg_info->header_size[src_instance][dst_instance]=1; - header = random_string(otg_info->header_size[src][dst], g_otg->packet_gen_type, HEADER_ALPHABET); + header = random_string(otg_info->header_size[src_instance][dst_instance], g_otg->packet_gen_type, HEADER_ALPHABET); header_size = (header != NULL)? strlen(header) : 0; payload = random_string(size, RANDOM_STRING, PAYLOAD_ALPHABET); if (payload == NULL) return NULL; flag=0xffff; - flow=otg_info->flow_id[src][dst]; - seq_num=otg_info->seq_num[src][dst][otg_info->traffic_type[src][dst]]; - otg_info->header_type[src][dst]=type_header; - otg_info->seq_num[src][dst][otg_info->traffic_type[src][dst]]+=1; - otg_info->tx_num_bytes[src][dst][otg_info->traffic_type[src][dst]]+= otg_hdr_size(src,dst) + header_size + strlen(payload) ; - otg_info->tx_num_pkt[src][dst][otg_info->traffic_type[src][dst]]+=1; + flow=otg_info->flow_id[src_instance][dst_instance]; + seq_num=otg_info->seq_num[src_instance][dst_instance][otg_info->traffic_type[src_instance][dst_instance]]; + otg_info->header_type[src_instance][dst_instance]=type_header; + otg_info->seq_num[src_instance][dst_instance][otg_info->traffic_type[src_instance][dst_instance]]+=1; + otg_info->tx_num_bytes[src_instance][dst_instance][otg_info->traffic_type[src_instance][dst_instance]]+= otg_hdr_size(src_instance,dst_instance) + header_size + strlen(payload) ; + otg_info->tx_num_pkt[src_instance][dst_instance][otg_info->traffic_type[src_instance][dst_instance]]+=1; if (size!=strlen(payload)) - LOG_E(OTG,"[%d][%d] [0x %x] The expected packet size does not match the payload size : size %d, strlen %d, seq_num %d packet: |%s|%s| \n", src, dst, flag, size, strlen(payload), seq_num, header, - payload); + LOG_E(OTG,"[%d][%d] [0x %x] The expected packet size does not match the payload size : size %d, strlen %d, seq_num %d packet: |%s|%s| \n", + src_instance, dst_instance, flag, size, strlen(payload), seq_num, header, payload); else - LOG_D(OTG,"[%d][%d] 0x %x][m2m Aggre %d][Flow %d][Type %d/%s] TX INFO pkt at time %d Size= [payload %d] [Total %d] with seq num %d, state=%d : |%s|%s| \n", src, dst, flag, - otg_info->m2m_aggregation[src][dst],otg_info->flow_id[src][dst], - otg_info->traffic_type[src][dst], map_int_to_str(otg_app_type_names,otg_info->traffic_type[src][dst]), + LOG_D(OTG,"[%d][%d] 0x %x][m2m Aggre %d][Flow %d][Type %d/%s] TX INFO pkt at time %d Size= [payload %d] [Total %d] with seq num %d, state=%d : |%s|%s| \n", + src_instance, dst_instance, flag, + otg_info->m2m_aggregation[src_instance][dst_instance], + otg_info->flow_id[src_instance][dst_instance], + otg_info->traffic_type[src_instance][dst_instance], + map_int_to_str(otg_app_type_names,otg_info->traffic_type[src_instance][dst_instance]), ctime, size, header_size+strlen(payload), seq_num,state, header, payload); - LOG_D(OTG, "[%d]MY_SEQ %d \n", otg_info->traffic_type[src][dst], otg_info->seq_num[src][dst][otg_info->traffic_type[src][dst]] ); + LOG_D(OTG, "[%d]MY_SEQ %d \n", otg_info->traffic_type[src_instance][dst_instance], otg_info->seq_num[src_instance][dst_instance][otg_info->traffic_type[src_instance][dst_instance]] ); } else { - if ((g_otg->aggregation_level[src][dst][application]*otg_info->size_background[src][dst])<=PAYLOAD_MAX) - otg_info->size_background[src][dst]=g_otg->aggregation_level[src][dst][application]*otg_info->size_background[src][dst]; + if ((g_otg->aggregation_level[src_instance][dst_instance][application]*otg_info->size_background[src_instance][dst_instance])<=PAYLOAD_MAX) + otg_info->size_background[src_instance][dst_instance]=g_otg->aggregation_level[src_instance][dst_instance][application]*otg_info->size_background[src_instance][dst_instance]; else { - //otg_info->size_background[src][dst]=PAYLOAD_MAX; + //otg_info->size_background[src][dst_instance]=PAYLOAD_MAX; LOG_E(OTG,"[BACKGROUND] Aggregated packet larger than PAYLOAD_MAX, payload is limited to %d\n", PAYLOAD_MAX); } - header =random_string(header_size_gen_background(src,dst), g_otg->packet_gen_type, HEADER_ALPHABET); - payload = random_string(otg_info->size_background[src][dst], RANDOM_STRING, PAYLOAD_ALPHABET); + header =random_string(header_size_gen_background(src_instance,dst_instance), g_otg->packet_gen_type, HEADER_ALPHABET); + payload = random_string(otg_info->size_background[src_instance][dst_instance], RANDOM_STRING, PAYLOAD_ALPHABET); flag=0xbbbb; flow=flow_id_background; - seq_num=otg_info->seq_num_background[src][dst]; - otg_info->tx_num_bytes_background[src][dst]+= otg_hdr_size(src,dst) + header_size + strlen(payload) ; - otg_info->tx_num_pkt_background[src][dst]+=1; - otg_info->seq_num_background[src][dst]+=1; - - if (otg_info->size_background[src][dst]!=strlen(payload)) - LOG_E(OTG,"[%d][%d] [0x %x] The expected packet size does not match the payload size : size %d, strlen %d, seq num %d, packet |%s|%s| \n", src, dst, flag, otg_info->size_background[src][dst], - strlen(payload), seq_num, header, payload); + seq_num=otg_info->seq_num_background[src_instance][dst_instance]; + otg_info->tx_num_bytes_background[src_instance][dst_instance]+= otg_hdr_size(src_instance,dst_instance) + header_size + strlen(payload) ; + otg_info->tx_num_pkt_background[src_instance][dst_instance]+=1; + otg_info->seq_num_background[src_instance][dst_instance]+=1; + + if (otg_info->size_background[src_instance][dst_instance]!=strlen(payload)) + LOG_E(OTG,"[%d][%d] [0x %x] The expected packet size does not match the payload size : size %d, strlen %d, seq num %d, packet |%s|%s| \n", + src_instance, + dst_instance, + flag, + otg_info->size_background[src_instance][dst_instance], + strlen(payload), + seq_num, + header, + payload); else - LOG_D(OTG,"[%d][%d][%s][0x %x] TX INFO pkt at time %d size is %d with seq num %d, state=%d : |%s|%s| \n", src, dst, flag,ctime, - map_int_to_str(otg_app_type_names,otg_info->traffic_type[src][dst]), - otg_info->size_background[src][dst], seq_num, state, header, payload); + LOG_D(OTG,"[%d][%d][%s][0x %x] TX INFO pkt at time %d size is %d with seq num %d, state=%d : |%s|%s| \n", + src_instance, + dst_instance, + flag, + ctime, + map_int_to_str(otg_app_type_names,otg_info->traffic_type[src_instance][dst_instance]), + otg_info->size_background[src_instance][dst_instance], + seq_num, + state, + header, + payload); } - buffer_size = otg_hdr_size(src,dst) + header_size + strlen(payload); + buffer_size = otg_hdr_size(src_instance,dst_instance) + header_size + strlen(payload); *pkt_size = buffer_size; - if (src<NB_eNB_INST) + if (src_instance<NB_eNB_INST) otg_info->tx_total_bytes_dl+=buffer_size; else otg_info->tx_total_bytes_ul+=buffer_size; - if (otg_info->traffic_type[src][dst] > MAX_NUM_APPLICATION) { + if (otg_info->traffic_type[src_instance][dst_instance] > MAX_NUM_APPLICATION) { LOG_W(OTG,"application type out of range %d for the pair of (src %d, dst %d) \n", - otg_info->traffic_type[src][dst], src, dst); - otg_info->traffic_type[src][dst]=0; + otg_info->traffic_type[src_instance][dst_instance], src_instance, dst_instance); + otg_info->traffic_type[src_instance][dst_instance]=0; } - return serialize_buffer(header, payload, buffer_size, otg_info->traffic_type[src][dst], flag, flow, ctime, seq_num, otg_info->header_type_app[src][dst][flow], state, - otg_info->m2m_aggregation[src][dst]); + return serialize_buffer(header, + payload, + buffer_size, + otg_info->traffic_type[src_instance][dst_instance], + flag, + flow, + ctime, + seq_num, + otg_info->header_type_app[src_instance][dst_instance][flow], + state, + otg_info->m2m_aggregation[src_instance][dst_instance], + src_instance, + dst_instance); + } else { + return NULL; } +} - else - return NULL; -} -unsigned char *packet_gen_multicast(int src, int dst, int ctime, unsigned int * pkt_size) +unsigned char *packet_gen_multicast( + const int src_instance, + const int dst_instance, + const int ctime, + unsigned int * const pkt_size) { *pkt_size =0; @@ -369,46 +420,64 @@ unsigned char *packet_gen_multicast(int src, int dst, int ctime, unsigned int * //for (app=0; app<MAX_NUM_APPLICATION; app++){ for (app=0; app<1; app++) { - if ( (g_otg_multicast->idt_dist[src][dst][app]> 0) && - ((ctime - otg_multicast_info->ptime[src][dst][app]) >= otg_multicast_info->idt[src][dst][app]) ) { + if ( (g_otg_multicast->idt_dist[src_instance][dst_instance][app]> 0) && + ((ctime - otg_multicast_info->ptime[src_instance][dst_instance][app]) >= otg_multicast_info->idt[src_instance][dst_instance][app]) ) { //Duy add LOG_I(OTG,"multicast gen: entering generating\n"); //end Duy add - //otg_info->idt[src][dst][app]= time_dist(src, dst, app, -1); - otg_multicast_info->idt[src][dst][app]=ceil(uniform_dist(g_otg_multicast->idt_min[src][dst][app], - g_otg_multicast->idt_max[src][dst][app])); - size = ceil(uniform_dist(g_otg_multicast->size_min[src][dst][app], - g_otg_multicast->size_max[src][dst][app])); - LOG_D(OTG, "ptime %d, ctime %d idt %d (min %d, max %d) size %d (min %d, max %d)\n", otg_multicast_info->ptime[src][dst][application], ctime, - otg_multicast_info->idt[src][dst][app], g_otg_multicast->idt_min[src][dst][app], g_otg_multicast->idt_max[src][dst][app], - size,g_otg_multicast->size_min[src][dst][app],g_otg_multicast->size_max[src][dst][app]); - otg_multicast_info->ptime[src][dst][application]=ctime; + //otg_info->idt[src_instance][dst_instance][app]= time_dist(src_instance, dst_instance, app, -1); + otg_multicast_info->idt[src_instance][dst_instance][app]=ceil(uniform_dist(g_otg_multicast->idt_min[src_instance][dst_instance][app], + g_otg_multicast->idt_max[src_instance][dst_instance][app])); + size = ceil(uniform_dist(g_otg_multicast->size_min[src_instance][dst_instance][app], + g_otg_multicast->size_max[src_instance][dst_instance][app])); + LOG_D(OTG, "ptime %d, ctime %d idt %d (min %d, max %d) size %d (min %d, max %d)\n", + otg_multicast_info->ptime[src_instance][dst_instance][application], + ctime, + otg_multicast_info->idt[src_instance][dst_instance][app], + g_otg_multicast->idt_min[src_instance][dst_instance][app], + g_otg_multicast->idt_max[src_instance][dst_instance][app], + size,g_otg_multicast->size_min[src_instance][dst_instance][app], + g_otg_multicast->size_max[src_instance][dst_instance][app]); + + otg_multicast_info->ptime[src_instance][dst_instance][application]=ctime; if (size == 0) size = 1; - if (otg_multicast_info->header_size_app[src][dst][app]==0) { - otg_multicast_info->header_size_app[src][dst][app]=1; + if (otg_multicast_info->header_size_app[src_instance][dst_instance][app]==0) { + otg_multicast_info->header_size_app[src_instance][dst_instance][app]=1; LOG_W(OTG,"header type not defined, set to 1\n"); } - header = random_string(otg_multicast_info->header_size_app[src][dst][app], + header = random_string(otg_multicast_info->header_size_app[src_instance][dst_instance][app], g_otg->packet_gen_type, HEADER_ALPHABET); payload = random_string(size, RANDOM_STRING, PAYLOAD_ALPHABET); flag = 0x1000; - seq_num=otg_multicast_info->tx_sn[src][dst][app]++; - otg_multicast_info->tx_num_pkt[src][dst][app]+=1; - otg_multicast_info->tx_num_bytes[src][dst][app]+= strlen(header) + strlen(payload) + otg_hdr_size; - LOG_D(OTG,"otg_multicast_info->tx_num_bytes[%d][%d][%d] = %d \n",src,dst,app, otg_multicast_info->tx_num_bytes[src][dst][app]); + seq_num=otg_multicast_info->tx_sn[src_instance][dst_instance][app]++; + otg_multicast_info->tx_num_pkt[src_instance][dst_instance][app]+=1; + otg_multicast_info->tx_num_bytes[src_instance][dst_instance][app]+= strlen(header) + strlen(payload) + otg_hdr_size; + LOG_D(OTG,"otg_multicast_info->tx_num_bytes[%d][%d][%d] = %d \n", + src_instance, + dst_instance, + app, + otg_multicast_info->tx_num_bytes[src_instance][dst_instance][app]); if (size!=strlen(payload)) - LOG_E(OTG,"[src %d][dst %d] The expected packet size does not match the payload size : size %d, strlen %d \n", src, dst, size, strlen(payload)); + LOG_E(OTG,"[src %d][dst %d] The expected packet size does not match the payload size : size %d, strlen %d \n", + src_instance, dst_instance, size, strlen(payload)); else { LOG_I(OTG,"[src %d][dst %d]TX INFO pkt at time %d Size= [payload %d] [Total %d] with seq num %d: |%s|%s| \n", - src, dst, ctime, size, strlen(header)+strlen(payload)+otg_hdr_size, seq_num, header, payload); + src_instance, + dst_instance, + ctime, + size, + strlen(header)+strlen(payload)+otg_hdr_size, + seq_num, + header, + payload); LOG_D(OTG,"\n"); } @@ -420,36 +489,59 @@ unsigned char *packet_gen_multicast(int src, int dst, int ctime, unsigned int * } } - if (buffer_size) - return serialize_buffer(header, payload, buffer_size,0/*g_otg_multicast->application_type[src][dst][app]*/, flag, 0, ctime, seq_num, 0, HDR_IP_v4_MIN+HDR_UDP, 1); + if (buffer_size) { + return serialize_buffer( + header, + payload, + buffer_size, + 0/*g_otg_multicast->application_type[src_instance][dst][app]*/, + flag, 0, ctime, + seq_num, + 0, + HDR_IP_v4_MIN+HDR_UDP, + 1, + src_instance, + dst_instance); + } + // application_types is MSCBR = 1 is set in g_otg_multicast init, but 0 is need in otg_rx for coherence with index of otg_multicast_info - else - return NULL; + return NULL; } -int otg_hdr_size(int src, int dst) + + +int otg_hdr_size( + const int src_instance, + const int dst_instance) { - if (otg_info->hdr_size[src][dst]==0) - otg_info->hdr_size[src][dst]=sizeof(otg_hdr_info_t) + sizeof(otg_hdr_t); + if (otg_info->hdr_size[src_instance][dst_instance]==0) + otg_info->hdr_size[src_instance][dst_instance]=sizeof(otg_hdr_info_t) + sizeof(otg_hdr_t); - return otg_info->hdr_size[src][dst]; + return otg_info->hdr_size[src_instance][dst_instance]; } -void init_packet_gen(int src, int dst,int ctime) + + +void init_packet_gen( + const int src_instance, + const int dst_instance, + const int ctime) { check_ctime(ctime); set_ctime(ctime); - otg_info->m2m_aggregation[src][dst]=0; - otg_info->flow_id[src][dst]=0; - otg_info->traffic_type[src][dst]=0; - otg_info->traffic_type_background[src][dst]=0; + otg_info->m2m_aggregation[src_instance][dst_instance]=0; + otg_info->flow_id[src_instance][dst_instance]=0; + otg_info->traffic_type[src_instance][dst_instance]=0; + otg_info->traffic_type_background[src_instance][dst_instance]=0; /* init background traffic*/ - /* if (otg_info->idt_background[src][dst]==0){ - otg_info->idt_background[src][dst]= exponential_dist(0.025); - otg_info->background_stream[src][dst][0]=backgroundStreamInit(0,1); - } */ + /*if (otg_info->idt_background[src_instance][dst_instance]==0){ + otg_info->idt_background[src_instance][dst_instance]= exponential_dist(0.025); + otg_info->background_stream[src_instance][dst_instance][0]=backgroundStreamInit(0,1); + } */ } + + void check_ctime(int ctime) { if (ptime>ctime) @@ -458,43 +550,59 @@ void check_ctime(int ctime) ptime=ctime; } -int check_data_transmit(int src,int dst, int app, int ctime) + + +int check_data_transmit( + const int src_instance, + const int dst_instance, + const int app, + const int ctime) { unsigned int size=0; - // for (application=0; application<g_otg->application_idx[src][dst]; application++){ + // for (application=0; application<g_otg->application_idx[src_instance][dst_instance]; application++){ otg_info->gen_pkts=0; - LOG_T(OTG,"FLOW_INFO [src %d][dst %d] [IDX %d] [APPLICATION TYPE %d] MAX %d [M2M %d ]\n", src, dst, app, g_otg->application_type[src][dst][app],g_otg->application_idx[src][dst], - g_otg->m2m[src][dst][app]); + LOG_T(OTG,"FLOW_INFO [src %d][dst %d] [IDX %d] [APPLICATION TYPE %d] MAX %d [M2M %d ]\n", + src_instance, dst_instance, app, + g_otg->application_type[src_instance][dst_instance][app], + g_otg->application_idx[src_instance][dst_instance], + g_otg->m2m[src_instance][dst_instance][app]); - // do not generate packet for this pair of src, dst : no app type and/or no idt are defined - if (g_otg->flow_start[src][dst][app] > ctime ) { - //g_ otg->flow_start_flag[src][dst][app]=1; + // do not generate packet for this pair of src_instance, dst_instance : no app type and/or no idt are defined + if (g_otg->flow_start[src_instance][dst_instance][app] > ctime ) { + //g_ otg->flow_start_flag[src_instance][dst_instance][app]=1; LOG_T(OTG,"Flow start time not reached : do not generate packet for this pair of src=%d, dst =%d, start %d < ctime %d \n", - src, dst,g_otg->flow_start[src][dst][app], ctime); + src_instance, + dst_instance,g_otg->flow_start[src_instance][dst_instance][app], + ctime); size=0; - } else if (g_otg->flow_duration[src][dst][app] + g_otg->flow_start[src][dst][app] < ctime ) { + } else if (g_otg->flow_duration[src_instance][dst_instance][app] + g_otg->flow_start[src_instance][dst_instance][app] < ctime ) { LOG_T(OTG,"Flow duration reached: do not generate packet for this pair of src=%d, dst =%d, duration %d < ctime %d + start %d\n", - src, dst,g_otg->flow_duration[src][dst][app], ctime, g_otg->flow_start[src][dst][app]); + src_instance, dst_instance, + g_otg->flow_duration[src_instance][dst_instance][app], + ctime, + g_otg->flow_start[src_instance][dst_instance][app]); size=0; - } else if ((g_otg->application_type[src][dst][app]==0)&&(g_otg->idt_dist[src][dst][app][PE_STATE]==0)) { - LOG_T(OTG,"Do not generate packet for this pair of src=%d, dst =%d, IDT zero and app %d not specificed\n", src, dst, app); + } else if ((g_otg->application_type[src_instance][dst_instance][app]==0)&&(g_otg->idt_dist[src_instance][dst_instance][app][PE_STATE]==0)) { + LOG_T(OTG,"Do not generate packet for this pair of src=%d, dst =%d, IDT zero and app %d not specificed\n", + src_instance, + dst_instance, app); size=0; } - else if ((g_otg->application_type[src][dst][app] >0) || (g_otg->idt_dist[src][dst][app][PE_STATE] > 0)) { - state = get_application_state(src, dst, app, ctime); + else if ((g_otg->application_type[src_instance][dst_instance][app] >0) || (g_otg->idt_dist[src_instance][dst_instance][app][PE_STATE] > 0)) { + state = get_application_state(src_instance, dst_instance, app, ctime); #ifdef STANDALONE //pre-config for the standalone - if (ctime<otg_info->ptime[src][dst][app]) //it happends when the emulation was finished - otg_info->ptime[src][dst][app]=ctime; + if (ctime<otg_info->ptime[src_instance][dst_instance][app]) //it happends when the emulation was finished + otg_info->ptime[src_instance][dst_instance][app]=ctime; if (ctime==0) - otg_info->idt[src][dst][app]=0; //for the standalone mode: the emulation is run several times, we need to initialise the idt to 0 when ctime=0 + otg_info->idt[src_instance][dst_instance][app]=0; //for the standalone mode: the emulation is run several times, we need to initialise the idt to 0 when ctime=0 //end pre-config #endif @@ -502,50 +610,58 @@ int check_data_transmit(int src,int dst, int app, int ctime) if (state!=OFF_STATE) { - if (((state==PU_STATE)||(state==ED_STATE))|| (otg_info->idt[src][dst][app]==0) || (( (ctime-otg_info->ptime[src][dst][app]) >= otg_info->idt[src][dst][app] ) )) { + if (((state==PU_STATE)||(state==ED_STATE))|| (otg_info->idt[src_instance][dst_instance][app]==0) + || (( (ctime-otg_info->ptime[src_instance][dst_instance][app]) >= otg_info->idt[src_instance][dst_instance][app] ) )) { LOG_D(OTG,"[TX] OTG packet: Time To Transmit::OK (Source= %d, Destination= %d, Application %d, State= %d) , (IDT= %d ,ctime= %d, ptime= %d) \n", - src, dst ,app, state, otg_info->idt[src][dst][app], ctime, otg_info->ptime[src][dst][app]); - otg_info->ptime[src][dst][app]=ctime; + src_instance, + dst_instance , + app, + state, + otg_info->idt[src_instance][dst_instance][app], + ctime, + otg_info->ptime[src_instance][dst_instance][app]); + + otg_info->ptime[src_instance][dst_instance][app]=ctime; if (state==PE_STATE) //compute the IDT only for PE STATE - tarmaUpdateInputSample(otg_info->tarma_stream[src][dst][app]); + tarmaUpdateInputSample(otg_info->tarma_stream[src_instance][dst_instance][app]); - otg_info->idt[src][dst][app]=time_dist(src, dst, app,state); + otg_info->idt[src_instance][dst_instance][app]=time_dist(src_instance, dst_instance, app,state); otg_info->gen_pkts=1; - header_size_gen(src,dst, app); - //for(i=1;i<=g_otg->aggregation_level[src][dst][application];i++) - /* if (g_otg->m2m[src][dst][application]==M2M){ //TO FIX FOR M2M - size+=size_dist(src, dst, application,state); - if (otg_info->header_size_app[src][dst][application] > otg_info->header_size[src][dst]) //adapt the header to the application (increment the header if the the new header size is largest that the already computed) - otg_info->header_size[src][dst]+=otg_info->header_size_app[src][dst][application]; - otg_info->m2m_aggregation[src][dst]++; - otg_info->flow_id[src][dst]=application; - otg_info->traffic_type[src][dst]=g_otg->application_type[src][dst][application] //M2M; - } - else{ */ + header_size_gen(src_instance,dst_instance, app); + //for(i=1;i<=g_otg->aggregation_level[src_instance][dst_instance][application];i++) + /* if (g_otg->m2m[src_instance][dst_instance][application]==M2M){ //TO FIX FOR M2M + size+=size_dist(src_instance, dst_instance, application,state); + if (otg_info->header_size_app[src_instance][dst_instance][application] > otg_info->header_size[src_instance][dst_instance]) //adapt the header to the application (increment the header if the the new header size is largest that the already computed) + otg_info->header_size[src_instance][dst_instance]+=otg_info->header_size_app[src_instance][dst_instance][application]; + otg_info->m2m_aggregation[src_instance][dst_instance]++; + otg_info->flow_id[src_instance][dst_instance]=application; + otg_info->traffic_type[src_instance][dst_instance]=g_otg->application_type[src_instance][dst_instance][application] //M2M; + } + else{ */ /* For the case of non M2M traffic: when more than one flows transmit data in the same time - --> the second flow transmit (because of non data aggragation) */ - size=size_dist(src, dst, app,state); - otg_info->header_size[src][dst]=otg_info->header_size_app[src][dst][app]; - otg_info->flow_id[src][dst]=app; - otg_info->traffic_type[src][dst]=app;//g_otg->application_type[src][dst][app]; + --> the second flow transmit (because of non data aggragation) */ + size=size_dist(src_instance, dst_instance, app,state); + otg_info->header_size[src_instance][dst_instance]=otg_info->header_size_app[src_instance][dst_instance][app]; + otg_info->flow_id[src_instance][dst_instance]=app; + otg_info->traffic_type[src_instance][dst_instance]=app;//g_otg->application_type[src_instance][dst_instance][app]; /*} */ /* if the aggregated size is less than PAYLOAD_MAX the traffic is aggregated, otherwise size=PAYLOAD_MAX */ - if (size>=(PAYLOAD_MAX-(sizeof(otg_hdr_info_t) + sizeof(otg_hdr_t) + otg_info->header_size[src][dst]))) { - //size=PAYLOAD_MAX- (sizeof(otg_hdr_info_t) + sizeof(otg_hdr_t) + otg_info->header_size[src][dst]); + if (size>=(PAYLOAD_MAX-(sizeof(otg_hdr_info_t) + sizeof(otg_hdr_t) + otg_info->header_size[src_instance][dst_instance]))) { + //size=PAYLOAD_MAX- (sizeof(otg_hdr_info_t) + sizeof(otg_hdr_t) + otg_info->header_size[src_instance][dst_instance]); LOG_E(OTG,"Aggregated packet larger than PAYLOAD_MAX, payload is limited to %d \n", PAYLOAD_MAX ); } } //check if there is background traffic to generate - else if ((otg_info->gen_pkts==0) && (g_otg->background[src][dst][app]==1)&&(background_gen(src, dst, ctime)!=0)) { // the gen_pkts condition could be relaxed here - otg_info->traffic_type_background[src][dst]=1; + else if ((otg_info->gen_pkts==0) && (g_otg->background[src_instance][dst_instance][app]==1)&&(background_gen(src_instance, dst_instance, ctime)!=0)) { // the gen_pkts condition could be relaxed here + otg_info->traffic_type_background[src_instance][dst_instance]=1; - if (g_otg->m2m[src][dst][app]==M2M) - otg_info->traffic_type[src][dst]=app;//g_otg->application_idx[src][dst];//M2M; + if (g_otg->m2m[src_instance][dst_instance][app]==M2M) + otg_info->traffic_type[src_instance][dst_instance]=app;//g_otg->application_idx[src_instance][dst_instance];//M2M; - LOG_D(OTG,"[BACKGROUND=%d] Time To Transmit [SRC %d][DST %d][APPLI %d] \n", otg_info->traffic_type_background[src][dst], src, dst, app); + LOG_D(OTG,"[BACKGROUND=%d] Time To Transmit [SRC %d][DST %d][APPLI %d] \n", otg_info->traffic_type_background[src_instance][dst_instance], src_instance, dst_instance, app); } } @@ -558,88 +674,107 @@ int check_data_transmit(int src,int dst, int app, int ctime) } -unsigned int get_application_state(int src, int dst, int application, int ctime) + +unsigned int get_application_state( + const int src_instance, + const int dst_instance, + const int application, + const int ctime) { - switch (g_otg->application_type[src][dst][application]) { + switch (g_otg->application_type[src_instance][dst_instance][application]) { case VOIP_G711: case VOIP_G729: - voip_traffic(src, dst, application, ctime); - return otg_info->voip_state[src][dst][application]; + voip_traffic(src_instance, dst_instance, application, ctime); + return otg_info->voip_state[src_instance][dst_instance][application]; break; default: - state_management(src,dst,application, ctime); - return otg_info->state[src][dst][application]; + state_management(src_instance,dst_instance,application, ctime); + return otg_info->state[src_instance][dst_instance][application]; break; } } -void header_size_gen(int src, int dst, int application) + + +void header_size_gen( + const int src_instance, + const int dst_instance, + const int application) { unsigned int size_header=0; - if (otg_info->header_size_app[src][dst][application]==0) { - if (g_otg->ip_v[src][dst][application]==1) { + if (otg_info->header_size_app[src_instance][dst_instance][application]==0) { + if (g_otg->ip_v[src_instance][dst_instance][application]==1) { size_header+=HDR_IP_v4_MIN; - otg_info->header_type_app[src][dst][application]+=0; - } else if (g_otg->ip_v[src][dst][application]==2) { + otg_info->header_type_app[src_instance][dst_instance][application]+=0; + } else if (g_otg->ip_v[src_instance][dst_instance][application]==2) { size_header+=HDR_IP_v6; - otg_info->header_type_app[src][dst][application]+=2; + otg_info->header_type_app[src_instance][dst_instance][application]+=2; } - if (g_otg->trans_proto[src][dst][application]==1) { + if (g_otg->trans_proto[src_instance][dst_instance][application]==1) { size_header+= HDR_UDP ; - otg_info->header_type_app[src][dst][application]+=1; - } else if (g_otg->trans_proto[src][dst][application]==2) { + otg_info->header_type_app[src_instance][dst_instance][application]+=1; + } else if (g_otg->trans_proto[src_instance][dst_instance][application]==2) { size_header+= HDR_TCP; - otg_info->header_type_app[src][dst][application]+=2; + otg_info->header_type_app[src_instance][dst_instance][application]+=2; } - if ((g_otg->application_type[src][dst][application]==VOIP_G711)||(g_otg->application_type[src][dst][application]==VOIP_G729)) + if ((g_otg->application_type[src_instance][dst_instance][application]==VOIP_G711)||(g_otg->application_type[src_instance][dst_instance][application]==VOIP_G729)) size_header+=RTP_HEADER; - LOG_D(OTG,"Header size is %d [IP V=%d][PROTO=%d]\n", size_header, g_otg->ip_v[src][dst][application],g_otg->trans_proto[src][dst][application]); - otg_info->header_size_app[src][dst][application]=size_header; + LOG_D(OTG,"Header size is %d [IP V=%d][PROTO=%d]\n", size_header, g_otg->ip_v[src_instance][dst_instance][application],g_otg->trans_proto[src_instance][dst_instance][application]); + otg_info->header_size_app[src_instance][dst_instance][application]=size_header; } } -void header_size_gen_multicast(int src, int dst, int application) + + +void header_size_gen_multicast( + const int src_instance, + const int dst_instance, + const int application) { unsigned int size_header=0; - if (otg_multicast_info->header_size_app[src][dst][application]==0) { + if (otg_multicast_info->header_size_app[src_instance][dst_instance][application]==0) { - if (g_otg_multicast->ip_v[src][dst][application]==1) { + if (g_otg_multicast->ip_v[src_instance][dst_instance][application]==1) { size_header+=HDR_IP_v4_MIN; - } else if (g_otg_multicast->ip_v[src][dst][application]==2) { + } else if (g_otg_multicast->ip_v[src_instance][dst_instance][application]==2) { size_header+=HDR_IP_v6; } - if (g_otg_multicast->trans_proto[src][dst][application]==1) { + if (g_otg_multicast->trans_proto[src_instance][dst_instance][application]==1) { size_header+= HDR_UDP ; - } else if (g_otg_multicast->trans_proto[src][dst][application]==2) { + } else if (g_otg_multicast->trans_proto[src_instance][dst_instance][application]==2) { size_header+= HDR_TCP; } // LOG_I(OTG,"multicast header is set to %d\n", size_header); - otg_multicast_info->header_size_app[src][dst][application]=size_header; + otg_multicast_info->header_size_app[src_instance][dst_instance][application]=size_header; } } + + + // Generate a random string[size] -char *random_string(int size, ALPHABET_GEN mode, ALPHABET_TYPE data_type) +char *random_string( + const int size, + const ALPHABET_GEN mode, + const ALPHABET_TYPE data_type) { char *data=NULL; int i=0,start=0; - DevAssert( size < strlen(FIXED_STRING) ); - switch (mode) { case REPEAT_STRING: - start = uniform_dist (0, strlen(FIXED_STRING) - size - 1); + start = uniform_dist (0, abs(strlen(FIXED_STRING)- size - 1)); return str_sub (FIXED_STRING, start, start + size -1); break; @@ -648,10 +783,10 @@ char *random_string(int size, ALPHABET_GEN mode, ALPHABET_TYPE data_type) //data=strndup(data_string + (strlen(data_string) - size), strlen(data_string)); //data=strndup(data_string + (strlen(data_string) - size), size); if (data_type == HEADER_ALPHABET) { - start = uniform_dist (0, strlen(HEADER_STRING) - size - 1); + start = uniform_dist (0, abs(strlen(HEADER_STRING)- size - 1)); return str_sub (HEADER_STRING, start, start + size -1); } else if (data_type == PAYLOAD_ALPHABET) { - start = uniform_dist (0, strlen(PAYLOAD_STRING) - size - 1); + start = uniform_dist (0, abs(strlen(PAYLOAD_STRING)- size - 1)); return str_sub (PAYLOAD_STRING, start, start+size - 1 ); } else LOG_E(OTG, "unsupported alphabet data type \n"); @@ -700,7 +835,9 @@ char *random_string(int size, ALPHABET_GEN mode, ALPHABET_TYPE data_type) return data; } -unsigned int header_size(int hdr_size) + + +unsigned int header_size(const int hdr_size) { int size = hdr_size; @@ -715,8 +852,21 @@ unsigned int header_size(int hdr_size) } -unsigned char * serialize_buffer(char* header, char* payload, unsigned int buffer_size, unsigned int traffic_type, int flag, int flow_id, int ctime, int seq_num, int hdr_type, int state, - unsigned int aggregation_level) + +unsigned char * serialize_buffer( + char* const header, + char* const payload, + const unsigned int buffer_size, + const unsigned int traffic_type, + const int flag, + const int flow_id, + const int ctime, + const int seq_num, + const int hdr_type, + const int state, + const unsigned int aggregation_level, + const int src_instance, + const int dst_instance) { unsigned char *tx_buffer=NULL; @@ -739,6 +889,8 @@ unsigned char * serialize_buffer(char* header, char* payload, unsigned int buffe otg_hdr_p->time =ctime; otg_hdr_p->seq_num =seq_num; otg_hdr_p->hdr_type=hdr_type; + otg_hdr_p->src_instance = src_instance; + otg_hdr_p->dst_instance = dst_instance; otg_hdr_p->state = state; otg_hdr_p->aggregation_level=aggregation_level; otg_hdr_p->traffic_type=traffic_type; @@ -757,7 +909,7 @@ unsigned char * serialize_buffer(char* header, char* payload, unsigned int buffe return tx_buffer; } -void init_predef_multicast_traffic() +void init_predef_multicast_traffic(void) { int i, j, k; @@ -902,7 +1054,11 @@ void init_predef_multicast_traffic() } } -void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) + + +void init_predef_traffic( + const unsigned char nb_ue_local, + const unsigned char nb_enb_local) { int i,j, k; @@ -1021,25 +1177,25 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) break; /* case OPENARENA : - g_otg->trans_proto[i][j][k] = 2; - g_otg->ip_v[i][j][k] = 1; - g_otg->idt_dist[i][j][k][PE_STATE] = UNIFORM; - LOG_I(OTG,"OTG_CONFIG OPENARENA, src = %d, dst = %d, dist IDT = %d\n", i, j, g_otg->idt_dist[i][j][k][PE_STATE]); - g_otg->idt_min[i][j][k][PE_STATE] = 69; - g_otg->idt_max[i][j][k][PE_STATE] = 103; - g_otg->idt_std_dev[i][j][k][PE_STATE] = 0; - g_otg->idt_lambda[i][j][k][PE_STATE] = 0; - g_otg->size_dist[i][j][k][PE_STATE] = GAUSSIAN; - g_otg->size_min[i][j][k][PE_STATE] = 5; - g_otg->size_max[i][j][k][PE_STATE] = 43; - g_otg->size_std_dev[i][j][k][PE_STATE] = 5; - g_otg->size_lambda[i][j][k][PE_STATE] = 0; + g_otg->trans_proto[i][j][k] = 2; + g_otg->ip_v[i][j][k] = 1; + g_otg->idt_dist[i][j][k][PE_STATE] = UNIFORM; + LOG_I(OTG,"OTG_CONFIG OPENARENA, src = %d, dst = %d, dist IDT = %d\n", i, j, g_otg->idt_dist[i][j][k][PE_STATE]); + g_otg->idt_min[i][j][k][PE_STATE] = 69; + g_otg->idt_max[i][j][k][PE_STATE] = 103; + g_otg->idt_std_dev[i][j][k][PE_STATE] = 0; + g_otg->idt_lambda[i][j][k][PE_STATE] = 0; + g_otg->size_dist[i][j][k][PE_STATE] = GAUSSIAN; + g_otg->size_min[i][j][k][PE_STATE] = 5; + g_otg->size_max[i][j][k][PE_STATE] = 43; + g_otg->size_std_dev[i][j][k][PE_STATE] = 5; + g_otg->size_lambda[i][j][k][PE_STATE] = 0; #ifdef STANDALONE - g_otg->dst_port[i][j] = 302; - g_otg->flow_duration[i][j] = 1000; + g_otg->dst_port[i][j] = 302; + g_otg->flow_duration[i][j] = 1000; #endif - break; */ + break; */ case TEAM_FORTRESS : g_otg->trans_proto[i][j][k] = 2; g_otg->ip_v[i][j][k] = 1; @@ -1093,7 +1249,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case AUTO_PILOT_L : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ g_otg->trans_proto[i][j][k] = TCP; g_otg->ip_v[i][j][k] = IPV4; @@ -1135,7 +1291,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case AUTO_PILOT_M : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ g_otg->trans_proto[i][j][k] = TCP; g_otg->ip_v[i][j][k] = IPV4; @@ -1177,7 +1333,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case AUTO_PILOT_H : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ g_otg->trans_proto[i][j][k] = TCP; g_otg->ip_v[i][j][k] = IPV4; @@ -1219,7 +1375,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case AUTO_PILOT_E : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ /* DL SCENARIO*/ g_otg->trans_proto[i][j][k] = TCP; @@ -1262,7 +1418,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case VIRTUAL_GAME_L : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ LOG_I(OTG,"VIRTUAL GAME LOW SPEEDS, src = %d, dst = %d, application type = %d\n", i, j, g_otg->application_type[i][j][k]); g_otg->trans_proto[i][j][k] = TCP; g_otg->ip_v[i][j][k] = IPV4; @@ -1284,7 +1440,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case VIRTUAL_GAME_M : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ LOG_I(OTG,"VIRTUAL GAME MEDIUM SPEEDS, src = %d, dst = %d, application type = %d\n", i, j, g_otg->application_type[i][j][k]); /* DL SCENARIO*/ g_otg->trans_proto[i][j][k] = TCP; @@ -1307,7 +1463,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case VIRTUAL_GAME_H : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ LOG_I(OTG,"VIRTUAL GAME HIGH SPEEDS, src = %d, dst = %d, application type = %d\n", i, j, g_otg->application_type[i][j][k]); g_otg->trans_proto[i][j][k] = TCP; g_otg->ip_v[i][j][k] = IPV4; @@ -1328,7 +1484,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case VIRTUAL_GAME_F : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ LOG_I(OTG,"VIRTUAL GAME FINISH, src = %d, dst = %d, application type = %d\n", i, j, g_otg->application_type[i][j][k]); /* DL SCENARIO*/ g_otg->trans_proto[i][j][k] = TCP; @@ -1350,8 +1506,8 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case ALARM_HUMIDITY : /* Measurements from: - * Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + * Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) + */ LOG_I(OTG,"ALARM HUMIDITY, src = %d, dst = %d, application type = %d\n", i, j, g_otg->application_type[i][j][k]); g_otg->trans_proto[i][j][k] = TCP; g_otg->ip_v[i][j][k] = IPV4; @@ -1360,8 +1516,8 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) g_otg->prob_off_pu[i][j][k]=0.5; g_otg->prob_off_ed[i][j][k]=0.5; g_otg->prob_pu_ed[i][j][k]=0.5; - g_otg->holding_time_off_pu[i][j][k]=1680000; /* 28 minutes*/ - g_otg->holding_time_off_ed[i][j][k]=32400000; /* 9 hours*/ + g_otg->holding_time_off_pu[i][j][k]=1680000; /* 28 minutes*/ + g_otg->holding_time_off_ed[i][j][k]=32400000; /* 9 hours*/ g_otg->m2m[i][j][k]=1; #ifdef STANDALONE g_otg->dst_port[i][j] = 303; @@ -1372,7 +1528,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case ALARM_SMOKE : /* Measurements from: Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + */ LOG_I(OTG,"ALARM SMOKE, src = %d, dst = %d, application type = %d\n", i, j, g_otg->application_type[i][j][k]); g_otg->trans_proto[i][j][k] = TCP; g_otg->ip_v[i][j][k] = IPV4; @@ -1381,8 +1537,8 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) g_otg->prob_off_pu[i][j][k]=0.5; g_otg->prob_off_ed[i][j][k]=0.5; g_otg->prob_pu_ed[i][j][k]=0.5; - g_otg->holding_time_off_pu[i][j][k]=60000; /* 1 minute*/ - g_otg->holding_time_off_ed[i][j][k]=43200000; /* 12 hours*/ + g_otg->holding_time_off_pu[i][j][k]=60000; /* 1 minute*/ + g_otg->holding_time_off_ed[i][j][k]=43200000; /* 12 hours*/ g_otg->m2m[i][j][k]=1; #ifdef STANDALONE g_otg->dst_port[i][j] = 303; @@ -1392,8 +1548,8 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) case ALARM_TEMPERATURE : /* Measurements from: - * Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) - */ + * Traffic Modeling Framework for Machine Type Communincation (Navid NiKaein, Markus Laner, Kajie Zhou, Philippe Svoboda, Dejan Drajic, Serjan Krco and Milica Popovic) + */ LOG_I(OTG,"ALARM TEMPERATURE, src = %d, dst = %d, application type = %d\n", i, j, g_otg->application_type[i][j][k]); g_otg->trans_proto[i][j][k] = TCP; g_otg->ip_v[i][j][k] = IPV4; @@ -1402,8 +1558,8 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) g_otg->prob_off_pu[i][j][k]=0.5; g_otg->prob_off_ed[i][j][k]=0.5; g_otg->prob_pu_ed[i][j][k]=0.5; - g_otg->holding_time_off_pu[i][j][k]=1680000; /* 28 minute*/ - g_otg->holding_time_off_ed[i][j][k]=18000000; /* 5 hours*/ + g_otg->holding_time_off_pu[i][j][k]=1680000; /* 28 minute*/ + g_otg->holding_time_off_ed[i][j][k]=18000000; /* 5 hours*/ g_otg->m2m[i][j][k]=1; #ifdef STANDALONE g_otg->dst_port[i][j]= 303; @@ -1583,7 +1739,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) break; case VOIP_G711 : /*http://www.computerweekly.com/feature/VoIP-bandwidth-fundamentals */ - /* Voice bit rate= 64 Kbps | Sample time= 20 msec | Voice payload=160 bytes */ + /* Voice bit rate= 64 Kbps | Sample time= 20 msec | Voice payload=160 bytes */ g_otg->trans_proto[i][j][k] = UDP; g_otg->ip_v[i][j][k] = IPV4; g_otg->idt_dist[i][j][k][SIMPLE_TALK] = FIXED; @@ -1601,7 +1757,7 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) break; case VOIP_G729 : /*http://www.computerweekly.com/feature/VoIP-bandwidth-fundamentals */ - /* Voice bit rate= 8 Kbps | Sample time= 30 msec | Voice payload=30 bytes */ + /* Voice bit rate= 8 Kbps | Sample time= 30 msec | Voice payload=30 bytes */ g_otg->trans_proto[i][j][k] = UDP; g_otg->ip_v[i][j][k] = IPV4; g_otg->idt_dist[i][j][k][SIMPLE_TALK] = FIXED; @@ -1684,62 +1840,81 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local) } -int background_gen(int src, int dst, int ctime) + +int background_gen( + const int src_instance, + const int dst_instance, + const int ctime) { int ptime_background; - if (src<NB_eNB_INST) // DL case + if (src_instance<NB_eNB_INST) // DL case ptime_background=otg_info->ptime_background_dl; else //UL case ptime_background=otg_info->ptime_background_ul; /*check if it is time to transmit the background traffic - - we have different distributions for packet size and idt for the UL and DL */ - if ((((ctime-ptime_background) >= otg_info->idt_background[src][dst])) || - (otg_info->idt_background[src][dst]==0)) { - - LOG_D(OTG,"[SRC %d][DST %d] BACKGROUND :: OK (idt=%d, ctime=%d,ptime=%d ) !!\n", src, dst, otg_info->idt_background[src][dst], ctime, ptime_background); - otg_info->size_background[src][dst]=adjust_size(ceil(backgroundCalculateSize(otg_info->background_stream[src][dst][0], ctime, otg_info->idt_background[src][dst]))); - - if (src<NB_eNB_INST) { // DL case - otg_info->idt_background[src][dst]= exponential_dist(0.025); + - we have different distributions for packet size and idt for the UL and DL */ + if ((((ctime-ptime_background) >= otg_info->idt_background[src_instance][dst_instance])) || + (otg_info->idt_background[src_instance][dst_instance]==0)) { + + LOG_D(OTG,"[SRC %d][DST %d] BACKGROUND :: OK (idt=%d, ctime=%d,ptime=%d ) !!\n", + src_instance, + dst_instance, + otg_info->idt_background[src_instance][dst_instance], + ctime, ptime_background); + otg_info->size_background[src_instance][dst_instance]=adjust_size( + ceil(backgroundCalculateSize(otg_info->background_stream[src_instance][dst_instance][0], + ctime, + otg_info->idt_background[src_instance][dst_instance]))); + + if (src_instance<NB_eNB_INST) { // DL case + otg_info->idt_background[src_instance][dst_instance]= exponential_dist(0.025); otg_info->ptime_background_dl=ctime; } else { //UL case - otg_info->idt_background[src][dst]= uniform_dist(500,1000); + otg_info->idt_background[src_instance][dst_instance]= uniform_dist(500,1000); otg_info->ptime_background_ul=ctime; } /* - // Distinguish between the UL and DL case - if (src<NB_eNB_INST) // DL case - otg_info->size_background[src][dst]=ceil(lognormal_dist(5.46,0.85)); //lognormal distribution for DL background packet - else //UL case - otg_info->size_background[src][dst]=ceil(lognormal_dist(3.03,0.5)); //lognormal distribution for DL background packet - - // adjust the packet size if needed - if (otg_info->size_background[src][dst]>1400) - otg_info->size_background[src][dst]=1400; - if (otg_info->size_background[src][dst]<=10) - otg_info->size_background[src][dst]=10; - - - // Compute the corresponding IDT - - // Eq. (7) from "Users in Cells: a Data Traffic Analysis (Markus Laner, Philipp Svoboda, Stefan Schwarz, and Markus Rupp)" - Measured traffic consists of a mixture of many different types (e.g., web, video streaming, file download), gives an intuition for the encountered heavy-tails of. Most sessions are short with low data-volume, consisting of small downloads (e.g., e-mail, TCP-acknowledges), whereas some few sessions last very long and require high throughput (e.g., VoIP, video streaming, file-download). - - otg_info->idt_background[src][dst]=ceil(((otg_info->size_background[src][dst])*8000)/pow(10, lognormal_dist(1.3525, 0.1954))); - //if(otg_info->idt_background[src][dst]==0) - //otg_info->idt_background[src][dst]=10; - otg_info->ptime_background=ctime; - */ - LOG_D(OTG,"[BACKGROUND] TRAFFIC:: (src=%d, dst=%d) pkts size=%d idt=%d \n", src, dst, otg_info->size_background[src][dst],otg_info->idt_background[src][dst]); + // Distinguish between the UL and DL case + if (src_instance<NB_eNB_INST) // DL case + otg_info->size_background[src_instance][dst_instance]=ceil(lognormal_dist(5.46,0.85)); //lognormal distribution for DL background packet + else //UL case + otg_info->size_background[src_instance][dst_instance]=ceil(lognormal_dist(3.03,0.5)); //lognormal distribution for DL background packet + + // adjust the packet size if needed + if (otg_info->size_background[src_instance][dst_instance]>1400) + otg_info->size_background[src_instance][dst_instance]=1400; + if (otg_info->size_background[src_instance][dst_instance]<=10) + otg_info->size_background[src_instance][dst_instance]=10; + + + // Compute the corresponding IDT + + // Eq. (7) from "Users in Cells: a Data Traffic Analysis (Markus Laner, Philipp Svoboda, Stefan Schwarz, and Markus Rupp)" - Measured traffic consists of a mixture of many different types (e.g., web, video streaming, file download), gives an intuition for the encountered heavy-tails of. Most sessions are short with low data-volume, consisting of small downloads (e.g., e-mail, TCP-acknowledges), whereas some few sessions last very long and require high throughput (e.g., VoIP, video streaming, file-download). + + otg_info->idt_background[src_instance][dst_instance]=ceil(((otg_info->size_background[src_instance][dst_instance])*8000)/pow(10, lognormal_dist(1.3525, 0.1954))); + //if(otg_info->idt_background[src_instance][dst_instance]==0) + //otg_info->idt_background[src_instance][dst_instance]=10; + otg_info->ptime_background=ctime; + */ + LOG_D(OTG,"[BACKGROUND] TRAFFIC:: (src=%d, dst=%d) pkts size=%d idt=%d \n", + src_instance, + dst_instance, + otg_info->size_background[src_instance][dst_instance], + otg_info->idt_background[src_instance][dst_instance]); return 1; } else { - LOG_D(OTG,"[SRC %d][DST %d] [BACKGROUND] TRAFFIC:: not the time to transmit= (idt=%d, ctime=%d,ptime=%d ) size= %d \n", src, dst, otg_info->idt_background[src][dst], ctime, ptime_background, - otg_info->size_background[src][dst]); + LOG_D(OTG,"[SRC %d][DST %d] [BACKGROUND] TRAFFIC:: not the time to transmit= (idt=%d, ctime=%d,ptime=%d ) size= %d \n", + src_instance, + dst_instance, + otg_info->idt_background[src_instance][dst_instance], + ctime, ptime_background, + otg_info->size_background[src_instance][dst_instance]); return 0; } @@ -1747,16 +1922,18 @@ int background_gen(int src, int dst, int ctime) -int header_size_gen_background(int src, int dst) +int header_size_gen_background( + const int src_instance, + const int dst_instance) { int size_header=0; - if (otg_info->header_size_background[src][dst]==0) { + if (otg_info->header_size_background[src_instance][dst_instance]==0) { - if(g_otg->trans_proto_background[src][dst]==0) - g_otg->trans_proto_background[src][dst]= rand() % (TCP_IPV6 - UDP_IPV4 + 1) + UDP_IPV4; + if(g_otg->trans_proto_background[src_instance][dst_instance]==0) + g_otg->trans_proto_background[src_instance][dst_instance]= rand() % (TCP_IPV6 - UDP_IPV4 + 1) + UDP_IPV4; - switch (g_otg->trans_proto_background[src][dst]) { + switch (g_otg->trans_proto_background[src_instance][dst_instance]) { case UDP_IPV4: size_header=HDR_IP_v4_MIN + HDR_UDP; break; @@ -1778,143 +1955,155 @@ int header_size_gen_background(int src, int dst) break; } - otg_info->header_size_background[src][dst]=size_header; + otg_info->header_size_background[src_instance][dst_instance]=size_header; } - LOG_D(OTG," [SRC %d][DST %d] BACKGROUND TRAFFIC:: size header %d \n", src, dst, otg_info->header_size_background[src][dst]); - return otg_info->header_size_background[src][dst]; + LOG_D(OTG," [SRC %d][DST %d] BACKGROUND TRAFFIC:: size header %d \n", src_instance, dst_instance, otg_info->header_size_background[src_instance][dst_instance]); + return otg_info->header_size_background[src_instance][dst_instance]; } -void state_management(int src, int dst, int application, int ctime) +void state_management( + const int src_instance, + const int dst_instance, + const int application, + const int ctime) { - - if ((g_otg->holding_time_off_pu[src][dst][application]==0) && - (g_otg->holding_time_off_ed[src][dst][application]==0) && - (g_otg->holding_time_off_pe[src][dst][application]==0)) - otg_info->state[src][dst][application]=PE_STATE; + if ((g_otg->holding_time_off_pu[src_instance][dst_instance][application]==0) && + (g_otg->holding_time_off_ed[src_instance][dst_instance][application]==0) && + (g_otg->holding_time_off_pe[src_instance][dst_instance][application]==0)) + otg_info->state[src_instance][dst_instance][application]=PE_STATE; else { - if (otg_info->state_transition_prob[src][dst][application]==0) { - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); - otg_info->state[src][dst][application]=OFF_STATE; - LOG_D(OTG,"[%d][%d][Appli id %d] STATE:: OFF INIT \n", src, dst, application); - otg_info->start_holding_time_off[src][dst][application]=0/*ctime*/; + if (otg_info->state_transition_prob[src_instance][dst_instance][application]==0) { + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + otg_info->state[src_instance][dst_instance][application]=OFF_STATE; + LOG_D(OTG,"[%d][%d][Appli id %d] STATE:: OFF INIT \n", src_instance, dst_instance, application); + otg_info->start_holding_time_off[src_instance][dst_instance][application]=0/*ctime*/; } - //LOG_D(OTG,"[%d][[%d] HOLDING_TIMES OFF_PE: %d, OFF_PU: %d, OFF_ED %d, PE_OFF: %d \n", src, dst, g_otg->holding_time_off_pe[src][dst], g_otg->holding_time_off_pu[src][dst],g_otg->holding_time_off_ed[src][dst], g_otg->holding_time_pe_off[src][dst] ); + //LOG_D(OTG,"[%d][[%d] HOLDING_TIMES OFF_PE: %d, OFF_PU: %d, OFF_ED %d, PE_OFF: %d \n", src_instance, dst_instance, g_otg->holding_time_off_pe[src_instance][dst_instance], g_otg->holding_time_off_pu[src_instance][dst_instance],g_otg->holding_time_off_ed[src_instance][dst_instance], g_otg->holding_time_pe_off[src_instance][dst_instance] ); - switch (otg_info->state[src][dst][application]) { + switch (otg_info->state[src_instance][dst_instance][application]) { case OFF_STATE: - if (ctime>otg_info->start_holding_time_off[src][dst][application]) { - otg_info->c_holding_time_off[src][dst][application]= ctime - otg_info->start_holding_time_off[src][dst][application]; - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] STATE:: OFF Holding Time %d (%d, %d)\n", src, dst,application , g_otg->aggregation_level[src][dst][application], - otg_info->c_holding_time_off[src][dst][application], ctime, otg_info->start_holding_time_off[src][dst][application]); + if (ctime>otg_info->start_holding_time_off[src_instance][dst_instance][application]) { + otg_info->c_holding_time_off[src_instance][dst_instance][application]= ctime - otg_info->start_holding_time_off[src_instance][dst_instance][application]; + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] STATE:: OFF Holding Time %d (%d, %d)\n", src_instance, dst_instance,application , g_otg->aggregation_level[src_instance][dst_instance][application], + otg_info->c_holding_time_off[src_instance][dst_instance][application], ctime, otg_info->start_holding_time_off[src_instance][dst_instance][application]); } - if ( ((otg_info->state_transition_prob[src][dst][application]>= 1-(g_otg->prob_off_pu[src][dst][application]+g_otg->prob_off_ed[src][dst][application]+g_otg->prob_off_pe[src][dst][application])) - && (otg_info->state_transition_prob[src][dst][application]<1-(g_otg->prob_off_ed[src][dst][application]+g_otg->prob_off_pe[src][dst][application]))) - && (otg_info->c_holding_time_off[src][dst][application]>=g_otg->holding_time_off_pu[src][dst][application])) { - otg_info->state[src][dst][application]=PU_STATE; - LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->PU %d (ctime %d, start %d )\n", src, dst,application, g_otg->aggregation_level[src][dst][application], - otg_info->c_holding_time_off[src][dst][application], ctime, otg_info->start_holding_time_off[src][dst][application]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); - - } else if ( ((otg_info->state_transition_prob[src][dst][application]>= 1-(g_otg->prob_off_ed[src][dst][application]+g_otg->prob_off_pe[src][dst][application])) - && (otg_info->state_transition_prob[src][dst][application]< 1-g_otg->prob_off_pe[src][dst][application])) - && (otg_info->c_holding_time_off[src][dst][application]>=g_otg->holding_time_off_ed[src][dst][application])) { - otg_info->state[src][dst][application]=ED_STATE; - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->ED \n", src, dst,application, g_otg->aggregation_level[src][dst][application]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); + if ( ((otg_info->state_transition_prob[src_instance][dst_instance][application]>= 1-(g_otg->prob_off_pu[src_instance][dst_instance][application] + +g_otg->prob_off_ed[src_instance][dst_instance][application]+g_otg->prob_off_pe[src_instance][dst_instance][application])) + && (otg_info->state_transition_prob[src_instance][dst_instance][application]<1-(g_otg->prob_off_ed[src_instance][dst_instance][application] + +g_otg->prob_off_pe[src_instance][dst_instance][application]))) + && (otg_info->c_holding_time_off[src_instance][dst_instance][application]>=g_otg->holding_time_off_pu[src_instance][dst_instance][application])) { + otg_info->state[src_instance][dst_instance][application]=PU_STATE; + LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->PU %d (ctime %d, start %d )\n", src_instance, dst_instance,application, + g_otg->aggregation_level[src_instance][dst_instance][application], otg_info->c_holding_time_off[src_instance][dst_instance][application], ctime, + otg_info->start_holding_time_off[src_instance][dst_instance][application]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + + } else if ( ((otg_info->state_transition_prob[src_instance][dst_instance][application]>= 1-(g_otg->prob_off_ed[src_instance][dst_instance][application] + +g_otg->prob_off_pe[src_instance][dst_instance][application])) + && (otg_info->state_transition_prob[src_instance][dst_instance][application]< 1-g_otg->prob_off_pe[src_instance][dst_instance][application])) + && (otg_info->c_holding_time_off[src_instance][dst_instance][application]>=g_otg->holding_time_off_ed[src_instance][dst_instance][application])) { + otg_info->state[src_instance][dst_instance][application]=ED_STATE; + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->ED \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); } - else if (((otg_info->state_transition_prob[src][dst][application]>=1-g_otg->prob_off_pe[src][dst][application]) && (otg_info->state_transition_prob[src][dst][application]<=1)) - && (otg_info->c_holding_time_off[src][dst]>=g_otg->holding_time_off_pe[src][dst])) { - otg_info->state[src][dst][application]=PE_STATE; - LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->PE \n", src, dst,application, g_otg->aggregation_level[src][dst]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); + else if (((otg_info->state_transition_prob[src_instance][dst_instance][application]>=1-g_otg->prob_off_pe[src_instance][dst_instance][application]) + && (otg_info->state_transition_prob[src_instance][dst_instance][application]<=1)) + && (otg_info->c_holding_time_off[src_instance][dst_instance]>=g_otg->holding_time_off_pe[src_instance][dst_instance])) { + otg_info->state[src_instance][dst_instance][application]=PE_STATE; + LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); } else { - otg_info->c_holding_time_off[src][dst][application]= ctime - otg_info->start_holding_time_off[src][dst][application]; - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] STATE:: OFF\n", src, dst,application, g_otg->aggregation_level[src][dst][application]); + otg_info->c_holding_time_off[src_instance][dst_instance][application]= ctime - otg_info->start_holding_time_off[src_instance][dst_instance][application]; + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] STATE:: OFF\n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); } break; case PU_STATE: - if (otg_info->state_transition_prob[src][dst][application]<=1-(g_otg->prob_pu_ed[src][dst][application]+g_otg->prob_pu_pe[src][dst][application])) { - //otg_info->state[src][dst]=OFF_STATE; - otg_info->state[src][dst][application]=OFF_STATE; - otg_info->start_holding_time_off[src][dst][application]=ctime; - otg_info->c_holding_time_off[src][dst][application]=0; - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->OFF \n", src, dst,application, g_otg->aggregation_level[src][dst][application]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); - } else if ((otg_info->state_transition_prob[src][dst][application]<=1-g_otg->prob_pu_pe[src][dst][application]) - && (otg_info->state_transition_prob[src][dst][application]>1-(g_otg->prob_pu_ed[src][dst][application]+g_otg->prob_pu_pe[src][dst][application]))) { - //otg_info->state[src][dst]=ON_STATE; - otg_info->state[src][dst][application]=ED_STATE; - LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->ED \n", src, dst,application, g_otg->aggregation_level[src][dst][application]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); - } else { /*if (otg_info->state_transition_prob[src][dst]>=g_otg->prob_pu_ed)*/ - //otg_info->state[src][dst]=ON_STATE; - otg_info->state[src][dst][application]=PE_STATE; - otg_info->start_holding_time_pe_off[src][dst][application]=ctime; - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->PE \n", src, dst,application, g_otg->aggregation_level[src][dst][application]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); + if (otg_info->state_transition_prob[src_instance][dst_instance][application]<=1-(g_otg->prob_pu_ed[src_instance][dst_instance][application] + +g_otg->prob_pu_pe[src_instance][dst_instance][application])) { + //otg_info->state[src_instance][dst_instance]=OFF_STATE; + otg_info->state[src_instance][dst_instance][application]=OFF_STATE; + otg_info->start_holding_time_off[src_instance][dst_instance][application]=ctime; + otg_info->c_holding_time_off[src_instance][dst_instance][application]=0; + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->OFF \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + } else if ((otg_info->state_transition_prob[src_instance][dst_instance][application]<=1-g_otg->prob_pu_pe[src_instance][dst_instance][application]) + && (otg_info->state_transition_prob[src_instance][dst_instance][application]>1-(g_otg->prob_pu_ed[src_instance][dst_instance][application] + +g_otg->prob_pu_pe[src_instance][dst_instance][application]))) { + //otg_info->state[src_instance][dst_instance]=ON_STATE; + otg_info->state[src_instance][dst_instance][application]=ED_STATE; + LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->ED \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + } else { /*if (otg_info->state_transition_prob[src_instance][dst_instance]>=g_otg->prob_pu_ed)*/ + //otg_info->state[src_instance][dst_instance]=ON_STATE; + otg_info->state[src_instance][dst_instance][application]=PE_STATE; + otg_info->start_holding_time_pe_off[src_instance][dst_instance][application]=ctime; + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); } break; case ED_STATE: - if (otg_info->state_transition_prob[src][dst][application]<1-(g_otg->prob_ed_pu[src][dst][application] + g_otg->prob_ed_pe[src][dst][application])) { - //otg_info->state[src][dst]=OFF_STATE; - otg_info->state[src][dst][application]=OFF_STATE; - otg_info->start_holding_time_off[src][dst][application]=ctime; - otg_info->c_holding_time_off[src][dst][application]=0; - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->OFF \n", src, dst,application, g_otg->aggregation_level[src][dst][application]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); - } else if ((otg_info->state_transition_prob[src][dst][application]>=1-(g_otg->prob_ed_pu[src][dst][application] + g_otg->prob_ed_pe[src][dst][application] )) - && (otg_info->state_transition_prob[src][dst][application]<1-g_otg->prob_ed_pe[src][dst][application])) { - //otg_info->state[src][dst]=ON_STATE; - otg_info->state[src][dst][application]=PE_STATE; - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->PU \n", src, dst,application, g_otg->aggregation_level[src][dst][application]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); - } else { /*if ((otg_info->state_transition_prob[src][dst]>=1-g_otg->prob_ed_pe)&&(otg_info->state_transition_prob[src][dst]<=1)) */ - //otg_info->state[src][dst]=ON_STATE; - otg_info->state[src][dst][application]=PE_STATE; - otg_info->start_holding_time_pe_off[src][dst][application]=ctime; - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->PE \n", src, dst,application, g_otg->aggregation_level[src][dst][application]); - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); + if (otg_info->state_transition_prob[src_instance][dst_instance][application]<1-(g_otg->prob_ed_pu[src_instance][dst_instance][application] + + g_otg->prob_ed_pe[src_instance][dst_instance][application])) { + //otg_info->state[src_instance][dst_instance]=OFF_STATE; + otg_info->state[src_instance][dst_instance][application]=OFF_STATE; + otg_info->start_holding_time_off[src_instance][dst_instance][application]=ctime; + otg_info->c_holding_time_off[src_instance][dst_instance][application]=0; + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->OFF \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + } else if ((otg_info->state_transition_prob[src_instance][dst_instance][application]>=1-(g_otg->prob_ed_pu[src_instance][dst_instance][application] + + g_otg->prob_ed_pe[src_instance][dst_instance][application] )) + && (otg_info->state_transition_prob[src_instance][dst_instance][application]<1-g_otg->prob_ed_pe[src_instance][dst_instance][application])) { + //otg_info->state[src_instance][dst_instance]=ON_STATE; + otg_info->state[src_instance][dst_instance][application]=PE_STATE; + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->PU \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + } else { /*if ((otg_info->state_transition_prob[src_instance][dst_instance]>=1-g_otg->prob_ed_pe)&&(otg_info->state_transition_prob[src_instance][dst_instance]<=1)) */ + //otg_info->state[src_instance][dst_instance]=ON_STATE; + otg_info->state[src_instance][dst_instance][application]=PE_STATE; + otg_info->start_holding_time_pe_off[src_instance][dst_instance][application]=ctime; + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); } break; case PE_STATE: - if (g_otg->holding_time_pe_off[src][dst][application]<=otg_info->c_holding_time_pe_off[src][dst][application]) { - //otg_info->state[src][dst]=OFF_STATE; - otg_info->state[src][dst][application]=OFF_STATE; - LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PE->OFF\n", src, dst,application, g_otg->aggregation_level[src][dst][application]); - otg_info->c_holding_time_pe_off[src][dst][application]=0; - otg_info->state_transition_prob[src][dst][application]=uniform_dist(0,1); - otg_info->start_holding_time_off[src][dst][application]=ctime; - otg_info->c_holding_time_off[src][dst][application]=0; - } else { /* if (g_otg->holding_time_pe_off>otg_info->c_holding_time_pe_off[src][dst])*/ - if (ctime>otg_info->start_holding_time_pe_off[src][dst][application]) - otg_info->c_holding_time_pe_off[src][dst][application]=ctime-otg_info->start_holding_time_pe_off[src][dst][application]; - - LOG_D(OTG,"[%d][%d][Appli id %d] STATE:: PE \n", src, dst,application); + if (g_otg->holding_time_pe_off[src_instance][dst_instance][application]<=otg_info->c_holding_time_pe_off[src_instance][dst_instance][application]) { + //otg_info->state[src_instance][dst_instance]=OFF_STATE; + otg_info->state[src_instance][dst_instance][application]=OFF_STATE; + LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PE->OFF\n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]); + otg_info->c_holding_time_pe_off[src_instance][dst_instance][application]=0; + otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + otg_info->start_holding_time_off[src_instance][dst_instance][application]=ctime; + otg_info->c_holding_time_off[src_instance][dst_instance][application]=0; + } else { /* if (g_otg->holding_time_pe_off>otg_info->c_holding_time_pe_off[src_instance][dst_instance])*/ + if (ctime>otg_info->start_holding_time_pe_off[src_instance][dst_instance][application]) + otg_info->c_holding_time_pe_off[src_instance][dst_instance][application]=ctime-otg_info->start_holding_time_pe_off[src_instance][dst_instance][application]; + + LOG_D(OTG,"[%d][%d][Appli id %d] STATE:: PE \n", src_instance, dst_instance,application); } break; default: - LOG_W(OTG,"Unknown state(%d) \n", otg_info->state[src][dst][application]); - otg_info->state[src][dst][application]= OFF_STATE; // switch to default state + LOG_W(OTG,"Unknown state(%d) \n", otg_info->state[src_instance][dst_instance][application]); + otg_info->state[src_instance][dst_instance][application]= OFF_STATE; // switch to default state break; } @@ -1924,7 +2113,11 @@ void state_management(int src, int dst, int application, int ctime) -void voip_traffic(int src, int dst, int application, int ctime) +void voip_traffic( + const int src_instance, + const int dst_instance, + const int application, + const int ctime) { /***************************************************************************************************** @@ -1934,70 +2127,71 @@ void voip_traffic(int src, int dst, int application, int ctime) Tms = − 0, 456 ln (1 − x3 ) //Tms (length of mutual silence) 0 < x1, x2, x3 < 1: Random variables with uniform distribution - *****************************************************************************************************/ - - if (otg_info->silence_time[src][dst][application]==0) { - //otg_info->voip_transition_prob[src][dst][application]=uniform_dist(0,1); - otg_info->voip_state[src][dst][application]=SILENCE; - LOG_I(OTG,"[%d][%d][Appli id %d] STATE:: SILENCE INIT \n", src, dst, application); - otg_info->start_voip_silence[src][dst][application]=ctime /*ctime*/; - otg_info->c_holding_time_talk[src][dst][application]=0; - otg_info->c_holding_time_silence[src][dst][application]=0; - otg_info->silence_time[src][dst][application]=ceil((-0.854*log(1-(uniform_dist(0,1))))*1000) + ceil((-0.226*log(1-(uniform_dist(0,1))))*1000); - otg_info->simple_talk_time[src][dst][application]=ceil((-0.356*log(1-(uniform_dist(0,1))))*1000) ; + *****************************************************************************************************/ + + if (otg_info->silence_time[src_instance][dst_instance][application]==0) { + //otg_info->voip_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1); + otg_info->voip_state[src_instance][dst_instance][application]=SILENCE; + LOG_I(OTG,"[%d][%d][Appli id %d] STATE:: SILENCE INIT \n", src_instance, dst_instance, application); + otg_info->start_voip_silence[src_instance][dst_instance][application]=ctime /*ctime*/; + otg_info->c_holding_time_talk[src_instance][dst_instance][application]=0; + otg_info->c_holding_time_silence[src_instance][dst_instance][application]=0; + otg_info->silence_time[src_instance][dst_instance][application]=ceil((-0.854*log(1-(uniform_dist(0,1))))*1000) + ceil((-0.226*log(1-(uniform_dist(0,1))))*1000); + otg_info->simple_talk_time[src_instance][dst_instance][application]=ceil((-0.356*log(1-(uniform_dist(0,1))))*1000) ; } - switch (otg_info->voip_state[src][dst][application]) { + switch (otg_info->voip_state[src_instance][dst_instance][application]) { case SILENCE: - if (ctime>otg_info->start_voip_silence[src][dst][application]) { - if (ctime>otg_info->start_voip_silence[src][dst][application]) - otg_info->c_holding_time_silence[src][dst][application]= ctime - otg_info->start_voip_silence[src][dst][application]; + if (ctime>otg_info->start_voip_silence[src_instance][dst_instance][application]) { + if (ctime>otg_info->start_voip_silence[src_instance][dst_instance][application]) + otg_info->c_holding_time_silence[src_instance][dst_instance][application]= ctime - otg_info->start_voip_silence[src_instance][dst_instance][application]; - LOG_D(OTG,"[%d][%d][Appli id %d] VOIP STATE:: SILENCE %d (ctime=%d, start=%d)\n", src, dst,application, - otg_info->c_holding_time_silence[src][dst][application], ctime, otg_info->start_voip_silence[src][dst][application]); + LOG_D(OTG,"[%d][%d][Appli id %d] VOIP STATE:: SILENCE %d (ctime=%d, start=%d)\n", src_instance, dst_instance,application, + otg_info->c_holding_time_silence[src_instance][dst_instance][application], ctime, otg_info->start_voip_silence[src_instance][dst_instance][application]); } - if (otg_info->c_holding_time_silence[src][dst][application]>=otg_info->silence_time[src][dst][application]) { - otg_info->voip_state[src][dst][application]=SIMPLE_TALK; - LOG_I(OTG,"[%d][%d][Appli id %d] NEW VOIP STATE :: SILENCE-->TALK %d (ctime=%d, start=%d )\n", src, dst,application , - otg_info->c_holding_time_silence[src][dst][application], ctime, otg_info->start_voip_silence[src][dst][application]); - otg_info->start_voip_talk[src][dst][application]=ctime; - otg_info->c_holding_time_talk[src][dst][application]=0; - otg_info->simple_talk_time[src][dst][application]=ceil((-0.854*log(1-(uniform_dist(0,1))))*1000); + if (otg_info->c_holding_time_silence[src_instance][dst_instance][application]>=otg_info->silence_time[src_instance][dst_instance][application]) { + otg_info->voip_state[src_instance][dst_instance][application]=SIMPLE_TALK; + LOG_I(OTG,"[%d][%d][Appli id %d] NEW VOIP STATE :: SILENCE-->TALK %d (ctime=%d, start=%d )\n", src_instance, dst_instance,application , + otg_info->c_holding_time_silence[src_instance][dst_instance][application], ctime, otg_info->start_voip_silence[src_instance][dst_instance][application]); + otg_info->start_voip_talk[src_instance][dst_instance][application]=ctime; + otg_info->c_holding_time_talk[src_instance][dst_instance][application]=0; + otg_info->simple_talk_time[src_instance][dst_instance][application]=ceil((-0.854*log(1-(uniform_dist(0,1))))*1000); } else { - if (ctime>otg_info->start_voip_silence[src][dst][application]) - otg_info->c_holding_time_silence[src][dst][application]= ctime - otg_info->start_voip_silence[src][dst][application]; + if (ctime>otg_info->start_voip_silence[src_instance][dst_instance][application]) + otg_info->c_holding_time_silence[src_instance][dst_instance][application]= ctime - otg_info->start_voip_silence[src_instance][dst_instance][application]; - LOG_I(OTG,"[%d][%d][Appli id %d] STATE:: SILENCE [timer:%d] \n", src, dst,application, otg_info->c_holding_time_silence[src][dst][application]); + LOG_I(OTG,"[%d][%d][Appli id %d] STATE:: SILENCE [timer:%d] \n", src_instance, dst_instance,application, otg_info->c_holding_time_silence[src_instance][dst_instance][application]); } break; case SIMPLE_TALK: - if (otg_info->c_holding_time_talk[src][dst][application]>=otg_info->simple_talk_time[src][dst][application]) { - otg_info->voip_state[src][dst][application]=SILENCE; - LOG_I(OTG,"[%d][%d][Appli id %d] NEW VOIP STATE:: TALK-->SILENCE %d (ctime=%d, start=%d )\n", src, dst,application , - otg_info->c_holding_time_talk[src][dst][application], ctime, otg_info->start_voip_talk[src][dst][application]); - otg_info->start_voip_silence[src][dst][application]=ctime; - otg_info->c_holding_time_silence[src][dst][application]=0; - otg_info->silence_time[src][dst][application]=ceil((-0.456*log(1-(uniform_dist(0,1))))*1000)+ceil((-0.226*log(1-(uniform_dist(0,1))))*1000); + if (otg_info->c_holding_time_talk[src_instance][dst_instance][application]>=otg_info->simple_talk_time[src_instance][dst_instance][application]) { + otg_info->voip_state[src_instance][dst_instance][application]=SILENCE; + LOG_I(OTG,"[%d][%d][Appli id %d] NEW VOIP STATE:: TALK-->SILENCE %d (ctime=%d, start=%d )\n", src_instance, dst_instance,application , + otg_info->c_holding_time_talk[src_instance][dst_instance][application], ctime, otg_info->start_voip_talk[src_instance][dst_instance][application]); + otg_info->start_voip_silence[src_instance][dst_instance][application]=ctime; + otg_info->c_holding_time_silence[src_instance][dst_instance][application]=0; + otg_info->silence_time[src_instance][dst_instance][application]=ceil((-0.456*log(1-(uniform_dist(0,1))))*1000)+ceil((-0.226*log(1-(uniform_dist(0,1))))*1000); } else { - if (ctime>otg_info->start_voip_talk[src][dst][application]) - otg_info->c_holding_time_talk[src][dst][application]= ctime - otg_info->start_voip_talk[src][dst][application]; + if (ctime>otg_info->start_voip_talk[src_instance][dst_instance][application]) + otg_info->c_holding_time_talk[src_instance][dst_instance][application]= ctime - otg_info->start_voip_talk[src_instance][dst_instance][application]; - LOG_I(OTG,"[%d][%d][Appli id %d] VOIP STATE:: TALK [timer:%d]\n", src, dst,application, otg_info->c_holding_time_talk[src][dst][application]); - LOG_I(OTG, "test_talk [ctime %d] [start talk %d] [%d] \n",ctime, otg_info->start_voip_talk[src][dst][application], otg_info->c_holding_time_talk[src][dst][application] ); + LOG_I(OTG,"[%d][%d][Appli id %d] VOIP STATE:: TALK [timer:%d]\n", src_instance, dst_instance,application, otg_info->c_holding_time_talk[src_instance][dst_instance][application]); + LOG_I(OTG, "test_talk [ctime %d] [start talk %d] [%d] \n",ctime, otg_info->start_voip_talk[src_instance][dst_instance][application], + otg_info->c_holding_time_talk[src_instance][dst_instance][application] ); } break; default: - LOG_W(OTG,"Unknown VOIP state(%d) \n", otg_info->voip_state[src][dst][application]); - otg_info->voip_state[src][dst][application]= SILENCE; // switch to default state + LOG_W(OTG,"Unknown VOIP state(%d) \n", otg_info->voip_state[src_instance][dst_instance][application]); + otg_info->voip_state[src_instance][dst_instance][application]= SILENCE; // switch to default state break; } diff --git a/openair2/UTIL/OTG/otg_tx.h b/openair2/UTIL/OTG/otg_tx.h index da019e30985..b5cd7741a4c 100644 --- a/openair2/UTIL/OTG/otg_tx.h +++ b/openair2/UTIL/OTG/otg_tx.h @@ -54,25 +54,33 @@ //#include "COMMON/platform_constants.h" -/*! \fn int time_dist(int src, int dst, int state) +/*! \fn int time_dist(const int src, const int dst, const int state) * \brief compute Inter Departure Time, in ms * \param[in] Source, destination, state * \param[out] Inter Departure Time * \note * @ingroup _otg */ -int time_dist(int src, int dst, int application, int state); +int time_dist( + const int src_instance, + const int dst_instance, + const int application, + const int state); -/*! \fn int size_dist(int src, int dst, int state) +/*! \fn int size_dist(const int src, const int dst, const int state) * \brief compute the payload size, in bytes * \param[in] Source, node_dst, state * \param[out] size of the payload, in bytes * \note * @ingroup _otg */ -int size_dist(int src, int dst, int application, int state); +int size_dist( + const int src_instance, + const int dst_instance, + const int application, + const int state); -/*! \fn char *random_string(int size, ALPHABET_GEN mode, ALPHABET_TYPE data_type); +/*! \fn char *random_string(const int size, const ALPHABET_GEN mode, const ALPHABET_TYPE data_type); * \brief return a random string[size] * \param[in] size of the string to generate, * \param[in] ALPHABET_GEN : static or random string @@ -81,10 +89,9 @@ int size_dist(int src, int dst, int application, int state); * \note * @ingroup _otg */ -char * random_string(int size, ALPHABET_GEN mode, ALPHABET_TYPE data_type); -//char *random_string(int size, ALPHABET data_type, char *data_string); +char * random_string(const int size, const ALPHABET_GEN mode, const ALPHABET_TYPE data_type); -/*! \fn int packet_gen(int src, int dst, int state, int ctime) +/*! \fn int packet_gen(const int src, const int dst, const int state, const int ctime) * \brief return int= 1 if the packet is generated: OTG header + header + payload, else 0 * \param[in] src source identity * \param[in] dst destination id @@ -94,41 +101,49 @@ char * random_string(int size, ALPHABET_GEN mode, ALPHABET_TYPE data_type); * \note * @ingroup _otg */ -unsigned char *packet_gen(int src, int dst, int app, int ctime, unsigned int *pkt_size); - -/*! \fn int packet_gen(int src, int dst, int state, int ctime) +unsigned char *packet_gen( + const int src_instance, + const int dst_instance, + const int app, + const int ctime, + unsigned int * const pkt_size); + +/*! \fn unsigned char * packet_gen_multicast(const int src, const int dst, const int ctime, unsigned int * const pkt_size) * \brief return int= 1 if the packet is generated: OTG header + header + payload, else 0 * \param[in] src source identity * \param[in] dst destination id -* \param[in] application id that might generate the packet +* \param[in] ctime * \param[out] final packet size -* \param[out] packet_t: the generated packet: otg_header + header + payload * \note * @ingroup _otg */ -unsigned char *packet_gen_multicast(int src, int dst, int ctime, unsigned int * pkt_size); +unsigned char *packet_gen_multicast( + const int src_instance, + const int dst_instance, + const int ctime, + unsigned int * const pkt_size); -/*! \fn char *header_gen(int hdr_size); +/*! \fn char *header_gen(const int hdr_size); * \brief generate IP (v4/v6) + transport header(TCP/UDP) * \param[in] int : size * \param[out] the payload corresponding to ip version and transport protocol * \note * @ingroup _otg */ -unsigned char *header_gen(int hdr_size); +unsigned char *header_gen(const int hdr_size); -/*! \fn char *payload_pkts(int payload_size); +/*! \fn char *payload_pkts(const int payload_size); * \brief generate the payload * \param[in] int : payload size * \param[out] char * payload * \note * @ingroup _otg */ -unsigned char *payload_pkts(int payload_size); +unsigned char *payload_pkts(const int payload_size); /*! \fn -char * serialize_buffer(char* header, char* payload, unsigned int buffer_size, int flag, int flow_id, int ctime, int seq_num, int hdr_type, int state) +char * serialize_buffer(char* const header, char* const payload, const unsigned int buffer_size, const int flag, const int flow_id, const int ctime, const int seq_num, const int hdr_type, const int state) * \brief serilize the packet and add otg control information * \param[in] char* header pointer to the header * \param[in] char* payload pointer to the payload @@ -144,8 +159,20 @@ flow id, simulation time, , sequence number, header type (to know the transport/ * @ingroup _otg */ -unsigned char * serialize_buffer(char* header, char* payload, unsigned int buffer_size, unsigned int traffic_type, int flag, int flow_id, int ctime, int seq_num, int hdr_type, int state, - unsigned int aggregation_level); +unsigned char * serialize_buffer( + char* const header, + char* const payload, + const unsigned int buffer_size, + const unsigned int traffic_type, + const int flag, + const int flow_id, + const int ctime, + const int seq_num, + const int hdr_type, + const int state, + const unsigned int aggregation_level, + const int src_instance, + const int dst_instance); /*! \fn int adjust_size(int size); @@ -165,7 +192,7 @@ int adjust_size(int size); * \note * @ingroup _otg */ -void header_size_gen(int src, int dst, int application); +void header_size_gen(const int src, const int dst, const int application); void init_predef_multicast_traffic(void); @@ -176,9 +203,9 @@ void init_predef_multicast_traffic(void); * \note * @ingroup _otg */ -void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local); +void init_predef_traffic(const unsigned char nb_ue_local, const unsigned char nb_enb_local); -/*! \fn int background_gen(int src, int dst, int ctime); +/*! \fn int background_gen(const int src, const int dst, const int ctime); * \brief manage idt and packet size for the backgrounf traffic. * \param[in] src * \param[in] dst @@ -187,22 +214,24 @@ void init_predef_traffic(unsigned char nb_ue_local, unsigned char nb_enb_local); * \note * @ingroup _otg */ -int background_gen(int src, int dst, int ctime); +int background_gen(const int src, const int dst, const int ctime); -int header_size_gen_background(int src, int dst); +int header_size_gen_background(const int src, const int dst); -void state_management(int src, int dst,int application, int ctime); +void state_management(const int src, const int dst,const int application, const int ctime); -void voip_traffic(int src, int dst, int application, int ctime); +void voip_traffic(const int src, const int dst, const int application, const int ctime); -int otg_hdr_size(int src, int dst); +int otg_hdr_size( + const int src_instance, + const int dst_instance); -void init_packet_gen(int src, int dst, int ctime); +void init_packet_gen(const int src_instance, const int dst_instance, const int ctime); -int check_data_transmit(int src,int dst, int app, int ctime); +int check_data_transmit(const int src,const int dst, const int app, const int ctime); -unsigned int get_application_state(int src, int dst, int application, int ctime); +unsigned int get_application_state(const int src, const int dst, const int application, const int ctime); -void check_ctime(int ctime); +void check_ctime(const int ctime); #endif diff --git a/openair3/MESH/RRM/Makefile b/openair3/MESH/RRM/Makefile index ce6946cd2cf..fb095f2f0bb 100644 --- a/openair3/MESH/RRM/Makefile +++ b/openair3/MESH/RRM/Makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc OSTYPE = $(shell uname -o ) #AAA: if rrc emulated remove comment from next line diff --git a/targets/ARCH/EXMIMO/DRIVER/eurecom/Makefile b/targets/ARCH/EXMIMO/DRIVER/eurecom/Makefile index 5cd129f84e1..bb35fee87f8 100755 --- a/targets/ARCH/EXMIMO/DRIVER/eurecom/Makefile +++ b/targets/ARCH/EXMIMO/DRIVER/eurecom/Makefile @@ -1,5 +1,5 @@ CCC = gcc -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc KERNEL_MAIN_TYPE:=$(shell echo `uname -r | cut -d. -f-2 | tr "." "_"`) export KERNEL_MAIN_TYPE diff --git a/targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c b/targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c index bafc62993bf..988238bea97 100755 --- a/targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c +++ b/targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c @@ -63,18 +63,13 @@ module_param(irq,int,S_IRUSR|S_IWUSR); static struct file_operations openair_fops = { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) -unlocked_ioctl: - openair_device_ioctl, + unlocked_ioctl:openair_device_ioctl, #else -ioctl: - openair_device_ioctl, + ioctl: openair_device_ioctl, #endif -open: - openair_device_open, -release: - openair_device_release, -mmap: - openair_device_mmap + open: openair_device_open, + release:openair_device_release, + mmap: openair_device_mmap }; static int __init openair_init_module( void ) diff --git a/targets/ARCH/EXMIMO/DRIVER/exmimo3/Makefile b/targets/ARCH/EXMIMO/DRIVER/exmimo3/Makefile index 57bf8de41c4..dc9991e109b 100755 --- a/targets/ARCH/EXMIMO/DRIVER/exmimo3/Makefile +++ b/targets/ARCH/EXMIMO/DRIVER/exmimo3/Makefile @@ -1,5 +1,5 @@ CCC = gcc -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc KERNEL_MAIN_TYPE=$(shell echo `uname -r | cut -d. -f-2 | tr "." "_"`) export KERNEL_MAIN_TYPE diff --git a/targets/ARCH/EXMIMO/DRIVER/exmimo3/module_main.c b/targets/ARCH/EXMIMO/DRIVER/exmimo3/module_main.c index 48cdf057275..679f83d4268 100755 --- a/targets/ARCH/EXMIMO/DRIVER/exmimo3/module_main.c +++ b/targets/ARCH/EXMIMO/DRIVER/exmimo3/module_main.c @@ -63,18 +63,13 @@ module_param(irq,int,S_IRUSR|S_IWUSR); static struct file_operations openair_fops = { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) -unlocked_ioctl: - openair_device_ioctl, + unlocked_ioctl:openair_device_ioctl, #else -ioctl: - openair_device_ioctl, + ioctl: openair_device_ioctl, #endif -open: - openair_device_open, -release: - openair_device_release, -mmap: - openair_device_mmap + open: openair_device_open, + release:openair_device_release, + mmap: openair_device_mmap }; static int __init openair_init_module( void ) diff --git a/targets/ARCH/EXMIMO/USERSPACE/LIB/gain_control.c b/targets/ARCH/EXMIMO/USERSPACE/LIB/gain_control.c index 478762f26e3..9413295d46b 100644 --- a/targets/ARCH/EXMIMO/USERSPACE/LIB/gain_control.c +++ b/targets/ARCH/EXMIMO/USERSPACE/LIB/gain_control.c @@ -34,16 +34,14 @@ #include "UTIL/LOG/log_extern.h" #endif -void gain_control_all (unsigned int rx_power_fil_dB, unsigned int card) -{ +void gain_control_all (unsigned int rx_power_fil_dB, unsigned int card) { unsigned int ant; for (ant=0; ant<4; ant++) gain_control (rx_power_fil_dB,ant,card); } -void gain_control (unsigned int rx_power_fil_dB, unsigned int ant, unsigned int card) -{ +void gain_control (unsigned int rx_power_fil_dB, unsigned int ant, unsigned int card) { exmimo_config_t *p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr; unsigned int rf_mode, rx_gain, LNA; diff --git a/targets/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.c b/targets/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.c index ae75c2b01a1..b30cc89e8bc 100644 --- a/targets/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.c +++ b/targets/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.c @@ -247,8 +247,7 @@ int openair0_stop_without_reset(int card) #define MY_RF_MODE (RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX + DMAMODE_TX) #define RF_MODE_BASE (LNA1ON + RFBBNORM) -int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) -{ +int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) { // Initialize card exmimo_config_t *p_exmimo_config; @@ -470,8 +469,7 @@ int openair0_reconfig(openair0_config_t *openair0_cfg) } -unsigned int *openair0_daq_cnt() -{ +unsigned int *openair0_daq_cnt(void) { return((unsigned int *)openair0_exmimo_pci[0].rxcnt_ptr[0]); diff --git a/targets/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw.c b/targets/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw.c index caa3e400138..17cca70a8aa 100644 --- a/targets/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw.c +++ b/targets/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw.c @@ -86,8 +86,7 @@ struct option updatefw_longopts[LONGOPTIONS_NB+1] = { #define TRUE 1 #define FALSE 0 -void show_usage(char* pgname) -{ +void show_usage(char* pgname) { unsigned int i; fprintf(stderr, " %s : Tool to update firmware of Cardbus-MIMO-1/Leon3 card through the PCI interface,\n", pgname); fprintf(stderr, " "); @@ -152,8 +151,7 @@ void show_usage(char* pgname) fprintf(stderr, " [-h|--help] Displays this help.\n"); } -int get_elf_header(Elf32_Ehdr* p_Elf32_hdr, FILE* p_file) -{ +int get_elf_header(Elf32_Ehdr* p_Elf32_hdr, FILE* p_file) { int nbread; nbread = fread(p_Elf32_hdr, sizeof(elf_Ehdr), 1, p_file); @@ -183,8 +181,7 @@ int get_elf_header(Elf32_Ehdr* p_Elf32_hdr, FILE* p_file) && (p_Elf32_hdr->e_ident[EI_VERSION] == EV_CURRENT); } -int get_elf_section_header(Elf32_Shdr* p_Elf32_Shdr, FILE* p_file, unsigned int section_ndx) -{ +int get_elf_section_header(Elf32_Shdr* p_Elf32_Shdr, FILE* p_file, unsigned int section_ndx) { int nbread; /* retrieve the position of the section header table */ fseek(p_file, Shdr_pos + (section_ndx * elf_Ehdr.e_shentsize), 0); @@ -213,8 +210,7 @@ int get_elf_section_header(Elf32_Shdr* p_Elf32_Shdr, FILE* p_file, unsigned int return nbread; } -void find_and_transfer_section(char* section_name, unsigned int verboselevel) -{ +void find_and_transfer_section(char* section_name, unsigned int verboselevel) { /* Interface with driver */ int ioctlretval; int ifile; @@ -310,8 +306,7 @@ void find_and_transfer_section(char* section_name, unsigned int verboselevel) } /* for secnb */ } -void find_and_clear_section_bss(unsigned int verboselevel) -{ +void find_and_clear_section_bss(unsigned int verboselevel) { /* Interface with driver */ int ioctlretval; int ifile; @@ -361,8 +356,7 @@ void find_and_clear_section_bss(unsigned int verboselevel) } /* for secnb */ } -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { /* Interface with driver */ int ioctlretval; int ifile; diff --git a/targets/Makefile.common b/targets/Makefile.common index e7b1b02402c..7c7698edaac 100644 --- a/targets/Makefile.common +++ b/targets/Makefile.common @@ -1,20 +1,20 @@ # This file gathers compilation directive shared between lte-softmodem and oaisim -export COMMON_UTILS_DIR = $(OPENAIR_HOME)/common/utils -export UE_NAS_DIR = $(OPENAIR_HOME)/openair-cn/NAS -export S1AP_DIR = $(OPENAIR_HOME)/openair-cn/S1AP -export X2AP_DIR = $(OPENAIR_HOME)/openair2/X2AP -export SCTP_DIR = $(OPENAIR_HOME)/openair-cn/SCTP -export UDP_DIR = $(OPENAIR_HOME)/openair-cn/UDP -export GTPV1U_DIR = $(OPENAIR_HOME)/openair-cn/GTPV1-U -export SECU_DIR = $(OPENAIR_HOME)/openair-cn/SECU - -UE_NAS_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(UE_NAS_DIR)) -SECU_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(SECU_DIR)) -S1AP_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(S1AP_DIR)) -X2AP_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(X2AP_DIR)) -SCTP_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(SCTP_DIR)) -UDP_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(UDP_DIR)) -GTPV1U_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(GTPV1U_DIR)) +export COMMON_UTILS_DIR = $(OPENAIR_DIR)/common/utils +export UE_NAS_DIR = $(OPENAIR_DIR)/openair-cn/NAS +export S1AP_DIR = $(OPENAIR_DIR)/openair-cn/S1AP +export X2AP_DIR = $(OPENAIR_DIR)/openair2/X2AP +export SCTP_DIR = $(OPENAIR_DIR)/openair-cn/SCTP +export UDP_DIR = $(OPENAIR_DIR)/openair-cn/UDP +export GTPV1U_DIR = $(OPENAIR_DIR)/openair-cn/GTPV1-U +export SECU_DIR = $(OPENAIR_DIR)/openair-cn/SECU + +UE_NAS_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(UE_NAS_DIR)) +SECU_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(SECU_DIR)) +S1AP_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(S1AP_DIR)) +X2AP_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(X2AP_DIR)) +SCTP_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(SCTP_DIR)) +UDP_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(UDP_DIR)) +GTPV1U_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(GTPV1U_DIR)) #Export common cflags (between softmodem and oaisim) COMMON_CFLAGS = \ @@ -65,6 +65,9 @@ ifeq ($(ENABLE_RAL), 1) CFLAGS += -DENABLE_RAL endif +ifeq ($(PDCP_USE_NETLINK),1) +CFLAGS += -DPDCP_USE_NETLINK +endif ifeq ($(LIBCONFIG_LONG),1) CFLAGS += -DLIBCONFIG_LONG endif @@ -73,8 +76,8 @@ endif ifeq ($(USE_MME), R10) COMMON_CFLAGS += -DENABLE_USE_MME ENABLE_ITTI = 1 -ifeq ($(LINK_PDCP_TO_GTPV1U), 1) - COMMON_CFLAGS += -DLINK_PDCP_TO_GTPV1U +ifeq ($(LINK_ENB_PDCP_TO_GTPV1U), 1) + COMMON_CFLAGS += -DLINK_ENB_PDCP_TO_GTPV1U # COMMON_CFLAGS += -I$(UDP_DIR) # COMMON_CFLAGS += -I$(GTPV1U_DIR) # COMMON_CFLAGS += -I$(GTPV1U_DIR)/nw-gtpv1u/shared @@ -109,12 +112,12 @@ COMMON_CFLAGS += -DLOG_NO_THREAD openair_cn_available := $(shell if [ -d "$(UE_NAS_DIR)" ]; then echo "0" ; else echo "1" ; fi ) ifeq ($(openair_cn_available), 0) COMMON_CFLAGS += -DENABLE_NAS_UE_LOGGING -COMMON_CFLAGS += -I$(OPENAIR_HOME)/openair-cn/NAS/EURECOM-NAS/src/api/network -COMMON_CFLAGS += -I$(OPENAIR_HOME)/openair-cn/NAS/EURECOM-NAS/src/include -COMMON_CFLAGS += -I$(OPENAIR_HOME)/openair-cn/NAS/EURECOM-NAS/src/ies -COMMON_CFLAGS += -I$(OPENAIR_HOME)/openair-cn/NAS/EURECOM-NAS/src/emm/msg -COMMON_CFLAGS += -I$(OPENAIR_HOME)/openair-cn/NAS/EURECOM-NAS/src/esm/msg -COMMON_CFLAGS += -I$(OPENAIR_HOME)/openair-cn/NAS/EURECOM-NAS/src/util +COMMON_CFLAGS += -I$(OPENAIR_DIR)/openair-cn/NAS/EURECOM-NAS/src/api/network +COMMON_CFLAGS += -I$(OPENAIR_DIR)/openair-cn/NAS/EURECOM-NAS/src/include +COMMON_CFLAGS += -I$(OPENAIR_DIR)/openair-cn/NAS/EURECOM-NAS/src/ies +COMMON_CFLAGS += -I$(OPENAIR_DIR)/openair-cn/NAS/EURECOM-NAS/src/emm/msg +COMMON_CFLAGS += -I$(OPENAIR_DIR)/openair-cn/NAS/EURECOM-NAS/src/esm/msg +COMMON_CFLAGS += -I$(OPENAIR_DIR)/openair-cn/NAS/EURECOM-NAS/src/util endif UENAS_CFLAGS = $(COMMON_CFLAGS) @@ -122,8 +125,8 @@ UENAS_CFLAGS += -I$(SECU_DIR) export UENAS_CFLAGS SECU_CFLAGS = $(COMMON_CFLAGS) -SECU_CFLAGS += -I$(OPENAIR_HOME)/openair-cn/COMMON -SECU_CFLAGS += -I$(OPENAIR_HOME)/openair-cn/UTILS +SECU_CFLAGS += -I$(OPENAIR_DIR)/openair-cn/COMMON +SECU_CFLAGS += -I$(OPENAIR_DIR)/openair-cn/UTILS SECU_CFLAGS += -I$(SECU_DIR) export SECU_CFLAGS @@ -150,7 +153,7 @@ UDP_CFLAGS = $(COMMON_CFLAGS) $(COMMON_MME_CFLAGS) UDP_CFLAGS += -DENB_MODE UDP_CFLAGS += -I$(TOP_DIR) UDP_CFLAGS += $(UTIL_incl) -UDP_CFLAGS += -I$(OPENAIR_HOME)/openair2/ENB_APP +UDP_CFLAGS += -I$(OPENAIR_DIR)/openair2/ENB_APP export UDP_CFLAGS GTPV1U_CFLAGS = $(COMMON_CFLAGS) $(COMMON_MME_CFLAGS) @@ -158,12 +161,12 @@ GTPV1U_CFLAGS += -DENB_MODE GTPV1U_CFLAGS += -I$(TOP_DIR) GTPV1U_CFLAGS += -I$(GTPV1U_DIR)/nw-gtpv1u/include GTPV1U_CFLAGS += -I$(GTPV1U_DIR)/nw-gtpv1u/shared -GTPV1U_CFLAGS += -I$(OPENAIR_HOME)/openair2/ENB_APP +GTPV1U_CFLAGS += -I$(OPENAIR_DIR)/openair2/ENB_APP GTPV1U_CFLAGS += $(UTIL_incl) -I$(OPENAIRCN_DIR)/UTILS export GTPV1U_CFLAGS GTPV1U_ENB_CFLAGS = $(COMMON_CFLAGS) -GTPV1U_ENB_CFLAGS += $(OPENAIR_HOME)/openair2/COMMON +GTPV1U_ENB_CFLAGS += $(OPENAIR_DIR)/openair2/COMMON GTPV1U_ENB_CFLAGS += -I$(X2AP_DIR) GTPV1U_ENB_CFLAGS += -I$(S1AP_DIR) GTPV1U_ENB_CFLAGS += -I$(UDP_DIR) @@ -172,7 +175,7 @@ GTPV1U_ENB_CFLAGS += -DENB_MODE GTPV1U_ENB_CFLAGS += -I$(TOP_DIR) GTPV1U_ENB_CFLAGS += -I$(GTPV1U_DIR)/nw-gtpv1u/include GTPV1U_ENB_CFLAGS += -I$(GTPV1U_DIR)/nw-gtpv1u/shared -GTPV1U_ENB_CFLAGS += -I$(OPENAIR_HOME)/openair2/ENB_APP +GTPV1U_ENB_CFLAGS += -I$(OPENAIR_DIR)/openair2/ENB_APP GTPV1U_ENB_CFLAGS += $(UTIL_incl) -I$(OPENAIRCN_DIR)/UTILS export GTPV1U_ENB_CFLAGS diff --git a/targets/PROJECTS/E-MBMS/build_all.bash b/targets/PROJECTS/E-MBMS/build_all.bash index f639adf899a..270c0c9d479 100755 --- a/targets/PROJECTS/E-MBMS/build_all.bash +++ b/targets/PROJECTS/E-MBMS/build_all.bash @@ -90,8 +90,8 @@ make echo_success "\n###############################" echo_success "# COMPILE ITTI ANALYSER" echo_success "###############################" -#cd $OPENAIR_HOME/common/utils/itti_analyzer -#if [ ! -f $OPENAIR_HOME/common/utils/itti_analyzer/Makefile ] +#cd $OPENAIR_DIR/common/utils/itti_analyzer +#if [ ! -f $OPENAIR_DIR/common/utils/itti_analyzer/Makefile ] # then # ./autogen.sh # ./configure diff --git a/targets/PROJECTS/E-MBMS/utils.bash b/targets/PROJECTS/E-MBMS/utils.bash index c4342434944..5410fc5818b 100755 --- a/targets/PROJECTS/E-MBMS/utils.bash +++ b/targets/PROJECTS/E-MBMS/utils.bash @@ -189,7 +189,7 @@ set_openair() { openair_path=`echo $path | cut -c1-$index` #openair_path=`echo ${path:0:$index}` export OPENAIR_DIR=$openair_path - export OPENAIR_HOME=$openair_path + export OPENAIR_DIR=$openair_path export OPENAIR1_DIR=$openair_path/openair1 export OPENAIR2_DIR=$openair_path/openair2 export OPENAIR3_DIR=$openair_path/openair3 @@ -363,7 +363,7 @@ check_for_root_rights() { ########################################################### declare -x OPENAIR_DIR="" -declare -x OPENAIR_HOME="" +declare -x OPENAIR_DIR="" declare -x OPENAIR1_DIR="" declare -x OPENAIR2_DIR="" declare -x OPENAIR3_DIR="" @@ -373,7 +373,7 @@ declare -x OPENAIR_TARGETS="" set_openair cecho "OPENAIR_DIR = $OPENAIR_DIR" $green -cecho "OPENAIR_HOME = $OPENAIR_HOME" $green +cecho "OPENAIR_DIR = $OPENAIR_DIR" $green cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/start_enb_and_ue_virt.bash b/targets/PROJECTS/GENERIC-LTE-EPC/start_enb_and_ue_virt.bash index 7ef5989c7c7..e0e97d81459 100755 --- a/targets/PROJECTS/GENERIC-LTE-EPC/start_enb_and_ue_virt.bash +++ b/targets/PROJECTS/GENERIC-LTE-EPC/start_enb_and_ue_virt.bash @@ -44,7 +44,7 @@ ########################################################### # Parameters ########################################################### -declare MAKE_LTE_ACCESS_STRATUM_TARGET="oaisim LIBCONFIG_LONG=1 DEBUG=1 ENABLE_ITTI=1 USE_MME=R10 LINK_PDCP_TO_GTPV1U=1 NAS=1 SECU=1 Rel10=1 TRACE_RLC_AM_PDU=1 TRACE_RLC_UM_PDU=1" +declare MAKE_LTE_ACCESS_STRATUM_TARGET="oaisim LIBCONFIG_LONG=1 DEBUG=1 ENABLE_ITTI=1 USE_MME=R10 LINK_ENB_PDCP_TO_GTPV1U=1 NAS=1 SECU=1 Rel10=1 TRACE_RLC_AM_PDU=1 TRACE_RLC_UM_PDU=1" declare MAKE_IP_DRIVER_TARGET="ue_ip.ko" declare IP_DRIVER_NAME="ue_ip" declare LTEIF="oip1" diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/utils.bash b/targets/PROJECTS/GENERIC-LTE-EPC/utils.bash index 47ce0c5b498..76646782900 100755 --- a/targets/PROJECTS/GENERIC-LTE-EPC/utils.bash +++ b/targets/PROJECTS/GENERIC-LTE-EPC/utils.bash @@ -182,7 +182,7 @@ set_openair() { openair_path=${fullpath%/targets/*} export OPENAIR_DIR=$openair_path - export OPENAIR_HOME=$openair_path + export OPENAIR_DIR=$openair_path export OPENAIR1_DIR=$openair_path/openair1 export OPENAIR2_DIR=$openair_path/openair2 export OPENAIR3_DIR=$openair_path/openair3 @@ -701,7 +701,7 @@ declare -x OPENAIR_TARGETS="" set_openair cecho "OPENAIR_DIR = $OPENAIR_DIR" $green -cecho "OPENAIR_HOME = $OPENAIR_HOME" $green +cecho "OPENAIR_DIR = $OPENAIR_DIR" $green cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/virtual_box.bash b/targets/PROJECTS/GENERIC-LTE-EPC/virtual_box.bash index 2b66d0f88de..57b935c0db1 100755 --- a/targets/PROJECTS/GENERIC-LTE-EPC/virtual_box.bash +++ b/targets/PROJECTS/GENERIC-LTE-EPC/virtual_box.bash @@ -176,7 +176,7 @@ build_vbox_vm_mme() { VBoxManage storagectl $UUID --name "SATA Controller" --add sata --controller IntelAhci --sataportcount 4 --hostiocache off --bootable on VBoxManage storageattach $UUID --storagectl "SATA Controller" --type hdd --port 0 --device 0 --medium "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/"$MME_VM_NAME".vdi - bash_exec "VBoxManage sharedfolder add $MME_VM_NAME --name $TRUNK_SHARED_FOLDER_NAME --hostpath $OPENAIR_HOME" + bash_exec "VBoxManage sharedfolder add $MME_VM_NAME --name $TRUNK_SHARED_FOLDER_NAME --hostpath $OPENAIR_DIR" } build_vbox_vm_hss() { diff --git a/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/clientSensing/client/spectra_client.c b/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/clientSensing/client/spectra_client.c index 485b5a13818..68f93fd6e34 100644 --- a/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/clientSensing/client/spectra_client.c +++ b/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/clientSensing/client/spectra_client.c @@ -33,8 +33,7 @@ * @param id messsage identificatior * @return example message */ -SpectraMessage createTestMessageClient(int id, int type, int nSamples) -{ +SpectraMessage createTestMessageClient(int id, int type, int nSamples) { SpectraMessage msg; msg.type = type; @@ -53,8 +52,7 @@ SpectraMessage createTestMessageClient(int id, int type, int nSamples) * * @return - the socket descriptor */ -int createsSocket(int argc, char *argv[]) -{ +int createsSocket(int argc, char *argv[]) { int sock; struct sockaddr_in server; //Create socket @@ -101,8 +99,7 @@ int createsSocket(int argc, char *argv[]) * @param argv * @return */ -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { char server_reply[MAX_PACKET_SIZE]; int nSamples = 10; diff --git a/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/common/openair_scripts/build_all.bash b/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/common/openair_scripts/build_all.bash index f9bc814e621..688342049a6 100644 --- a/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/common/openair_scripts/build_all.bash +++ b/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/common/openair_scripts/build_all.bash @@ -108,8 +108,8 @@ b2 --boost-root=$BOOST_ROOT linkflags=-lrt linkflags=-lpthread echo_success "\n###############################" echo_success "# COMPILE ITTI ANALYSER" echo_success "###############################" -cd $OPENAIR_HOME/common/utils/itti_analyzer -if [ ! -f $OPENAIR_HOME/common/utils/itti_analyzer/Makefile ] +cd $OPENAIR_DIR/common/utils/itti_analyzer +if [ ! -f $OPENAIR_DIR/common/utils/itti_analyzer/Makefile ] then autoreconf -i mkdir -m 777 objs diff --git a/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/common/openair_scripts/utils.bash b/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/common/openair_scripts/utils.bash index 9322aa4a619..9ce016d1d23 100644 --- a/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/common/openair_scripts/utils.bash +++ b/targets/PROJECTS/SPECTRA/DEMO_SPECTRA/spectra_demo_src/common/openair_scripts/utils.bash @@ -177,7 +177,6 @@ set_openair() { openair_path=`echo $path | cut -c1-$index` #openair_path=`echo ${path:0:$index}` export OPENAIR_DIR=$openair_path - export OPENAIR_HOME=$openair_path export OPENAIR1_DIR=$openair_path/openair1 export OPENAIR2_DIR=$openair_path/openair2 export OPENAIR3_DIR=$openair_path/openair3 @@ -362,7 +361,6 @@ rotate_log_file () { ########################################################### declare -x OPENAIR_DIR="" -declare -x OPENAIR_HOME="" declare -x OPENAIR1_DIR="" declare -x OPENAIR2_DIR="" declare -x OPENAIR3_DIR="" @@ -372,7 +370,6 @@ declare -x OPENAIR_TARGETS="" set_openair cecho "OPENAIR_DIR = $OPENAIR_DIR" $green -cecho "OPENAIR_HOME = $OPENAIR_HOME" $green cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green diff --git a/targets/PROJECTS/SPECTRA/build_all.bash b/targets/PROJECTS/SPECTRA/build_all.bash index f9bc814e621..688342049a6 100755 --- a/targets/PROJECTS/SPECTRA/build_all.bash +++ b/targets/PROJECTS/SPECTRA/build_all.bash @@ -108,8 +108,8 @@ b2 --boost-root=$BOOST_ROOT linkflags=-lrt linkflags=-lpthread echo_success "\n###############################" echo_success "# COMPILE ITTI ANALYSER" echo_success "###############################" -cd $OPENAIR_HOME/common/utils/itti_analyzer -if [ ! -f $OPENAIR_HOME/common/utils/itti_analyzer/Makefile ] +cd $OPENAIR_DIR/common/utils/itti_analyzer +if [ ! -f $OPENAIR_DIR/common/utils/itti_analyzer/Makefile ] then autoreconf -i mkdir -m 777 objs diff --git a/targets/PROJECTS/SPECTRA/utils.bash b/targets/PROJECTS/SPECTRA/utils.bash index b5844efa1fa..821bbfee643 100755 --- a/targets/PROJECTS/SPECTRA/utils.bash +++ b/targets/PROJECTS/SPECTRA/utils.bash @@ -177,7 +177,6 @@ set_openair() { openair_path=`echo $path | cut -c1-$index` #openair_path=`echo ${path:0:$index}` export OPENAIR_DIR=$openair_path - export OPENAIR_HOME=$openair_path export OPENAIR1_DIR=$openair_path/openair1 export OPENAIR2_DIR=$openair_path/openair2 export OPENAIR3_DIR=$openair_path/openair3 @@ -362,7 +361,6 @@ rotate_log_file () { ########################################################### declare -x OPENAIR_DIR="" -declare -x OPENAIR_HOME="" declare -x OPENAIR1_DIR="" declare -x OPENAIR2_DIR="" declare -x OPENAIR3_DIR="" @@ -372,7 +370,6 @@ declare -x OPENAIR_TARGETS="" set_openair cecho "OPENAIR_DIR = $OPENAIR_DIR" $green -cecho "OPENAIR_HOME = $OPENAIR_HOME" $green cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green diff --git a/targets/README.txt b/targets/README.txt index 0a9b2021c1f..8b8463e7ef9 100644 --- a/targets/README.txt +++ b/targets/README.txt @@ -44,12 +44,12 @@ The 3 folders have the following structures 3. Now, please check the following: - the env variables in .bashrc the following lines, and source them if necessary : - set OPENAIR_HOME variable and export the following: - export OPENAIR1_DIR=$OPENAIR_HOME/openair4G/openair1 - export OPENAIR2_DIR=$OPENAIR_HOME/openair4G/openair2 - export OPENAIR3_DIR=$OPENAIR_HOME/openair4G/openair3 - export OPENAIRITS_DIR=$OPENAIR_HOME/openair4G/openairITS - export OPENAIR_TARGETS=$OPENAIR_HOME/openair4G/targets/ + set OPENAIR_DIR variable and export the following: + export OPENAIR1_DIR=$OPENAIR_DIR/openair4G/openair1 + export OPENAIR2_DIR=$OPENAIR_DIR/openair4G/openair2 + export OPENAIR3_DIR=$OPENAIR_DIR/openair4G/openair3 + export OPENAIRITS_DIR=$OPENAIR_DIR/openair4G/openairITS + export OPENAIR_TARGETS=$OPENAIR_DIR/openair4G/targets/ - checkout and compile the asn1 messages follow the README.txt in OPENAIR2_DIR/RRC/LITE/MESSAGES to checkout the ASN.1 RRC messages diff --git a/targets/RT/Makefile b/targets/RT/Makefile index ae696ffb908..1be49d2db80 100644 --- a/targets/RT/Makefile +++ b/targets/RT/Makefile @@ -3,7 +3,7 @@ # these flags have to be explicitely exported so that the sub-make is aware of them -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc ifndef OPENAIR_LTE export OPENAIR_LTE=1 export OPENAIR_EMU=0 diff --git a/targets/RT/USER/Makefile b/targets/RT/USER/Makefile index 6f0f716e4f7..531907d6afb 100644 --- a/targets/RT/USER/Makefile +++ b/targets/RT/USER/Makefile @@ -116,7 +116,7 @@ ifeq ($(USRP),1) include $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/Makefile.inc #CFLAGS += -I/opt/include/uhd -L/opt/lib -luhd -lpthread -lstdc++ CFLAGS += -I/usr/include/uhd -L/usr/lib -luhd -lpthread -lstdc++ -CFLAGS += -DUSRP +CFLAGS += -DOAI_USRP #LDFLAGS += -L/opt/lib -luhd -lpthread -lstdc++ LDFLAGS += -L/usr/lib/ -luhd -lpthread -lstdc++ endif @@ -198,9 +198,15 @@ CFLAGS += -D_FILE_OFFSET_BITS=64 -DEMOS #-DEMOS_CHANNEL LDFLAGS += -lgps endif -ifeq ($(NAS),1) -CFLAGS += -DNAS_NETLINK -DLINUX + +ifeq ($(LINK_ENB_PDCP_TO_GTPV1U), 1) +CFLAGS += -DLINK_ENB_PDCP_TO_GTPV1U +endif + +ifeq ($(LINK_ENB_PDCP_TO_IP_DRIVER), 1) +CFLAGS += -DPDCP_USE_NETLINK -DLINUX OBJ += $(NAS_OBJS) +NAS_FLAG=1 endif LDFLAGS += -lpthread -lm -lforms -lconfig -lrt @@ -211,11 +217,11 @@ endif #ifeq ($(USRP),1) #CFLAGS += -I/opt/uhd/include -L/opt/uhd/lib -luhd -lpthread -lstdc++ -#CFLAGS += -DUSRP +#CFLAGS += -DOAI_USRP #endif #CFLAGS += -I/usr/include/c++/4.6 -I/usr/include/c++/4.6/x86_64-linux-gnu -I/usr/include/rtai/ -LFDS_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(LFDS_DIR)) +LFDS_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(LFDS_DIR)) LFDS_LIB = $(LFDS_OBJ_DIR)/bin/liblfds611.a LIBS += $(LFDS_LIB) SHARED_DEPENDENCIES += $(LFDS_LIB) diff --git a/targets/RT/USER/Makefile.agilent b/targets/RT/USER/Makefile.agilent index f31a3a4c222..061c15a31cc 100644 --- a/targets/RT/USER/Makefile.agilent +++ b/targets/RT/USER/Makefile.agilent @@ -121,7 +121,7 @@ NAS=1 endif ifeq ($(NAS),1) -CFLAGS += -DNAS_NETLINK -DLINUX +CFLAGS += -DPDCP_USE_NETLINK -DLINUX OBJ += $(NAS_OBJS) endif diff --git a/targets/RT/USER/emos-raw.c b/targets/RT/USER/emos-raw.c index 2423a635dcb..86fc3708db6 100644 --- a/targets/RT/USER/emos-raw.c +++ b/targets/RT/USER/emos-raw.c @@ -1076,7 +1076,7 @@ int main(int argc, char **argv) vcd_signal_dumper_init("/tmp/openair_dump_eNB.vcd"); } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK netlink_init(); #endif diff --git a/targets/RT/USER/init_exmimo2.sh b/targets/RT/USER/init_exmimo2.sh index e47f7c7098d..c30a037c350 100644 --- a/targets/RT/USER/init_exmimo2.sh +++ b/targets/RT/USER/init_exmimo2.sh @@ -24,7 +24,7 @@ load_module() { sudo insmod $1 } -load_module $OPENAIR_TARGETS/ARCH/EXMIMO/DRIVER/eurecom/openair_rf.ko +load_module $OPENAIR_TARGETS/bin/openair_rf.ko sleep 1 if [ ! -e /dev/openair0 ]; then @@ -36,17 +36,17 @@ DEVICE=`echo $PCI | awk -F\" '{print $(NF-1)}' | awk '{print $2}'` DEVICE_SWID=${DEVICE:2:2} if [ $DEVICE_SWID == '08' ]; then echo "Using firmware version 8" - $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw -s 0x43fffff0 -b -f $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/sdr_expressmimo2 + $OPENAIR_TARGETS/bin/updatefw -s 0x43fffff0 -b -f $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/sdr_expressmimo2 else if [ $DEVICE_SWID == '09' ]; then echo "Using firmware version 9" - $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw -s 0x43fffff0 -b -f $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/sdr_expressmimo2_v9 + $OPENAIR_TARGETS/bin/updatefw -s 0x43fffff0 -b -f $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/sdr_expressmimo2_v9 else if [ $DEVICE_SWID == '0a' ]; then echo "Using firware version 10" #$OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw -s 0x43fffff0 -b -f $OPENAIR0_DIR/express-mimo/software/sdr/exmimo2/sdr_expressmimo2 #$OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw -s 0x43fffff0 -b -f $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/sdr_expressmimo2_v10_spectra - $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw -s 0x43fffff0 -b -f $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/sdr_expressmimo2_v10 + $OPENAIR_TARGETS/bin/updatefw -s 0x43fffff0 -b -f $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/sdr_expressmimo2_v10 else echo 'No corresponding firmware found' return @@ -54,16 +54,16 @@ else fi fi -load_module $OPENAIR2_DIR/NAS/DRIVER/MESH/nasmesh.ko +#load_module $OPENAIR2_DIR/NAS/DRIVER/MESH/nasmesh.ko -if [ "$1" = "eNB" ]; then - echo "bring up oai0 interface for enb" - sudo ifconfig oai0 10.0.1.1 netmask 255.255.255.0 broadcast 10.0.1.255 - $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL/rb_tool -a -c0 -i0 -z0 -s 10.0.1.1 -t 10.0.1.9 -r 1 -else - if [ "$1" = "UE" ]; then - echo "bring up oai0 interface for UE" - sudo ifconfig oai0 10.0.1.9 netmask 255.255.255.0 broadcast 10.0.1.255 - $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL/rb_tool -a -c0 -i0 -z0 -s 10.0.1.9 -t 10.0.1.1 -r 1 - fi -fi +#if [ "$1" = "eNB" ]; then +# echo "bring up oai0 interface for enb" +# sudo ifconfig oai0 10.0.1.1 netmask 255.255.255.0 broadcast 10.0.1.255 +# $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL/rb_tool -a -c0 -i0 -z0 -s 10.0.1.1 -t 10.0.1.9 -r 1 +#else +# if [ "$1" = "UE" ]; then +# echo "bring up oai0 interface for UE" +# sudo ifconfig oai0 10.0.1.9 netmask 255.255.255.0 broadcast 10.0.1.255 +# $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL/rb_tool -a -c0 -i0 -z0 -s 10.0.1.9 -t 10.0.1.1 -r 1 +# fi +#fi diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 9b7e4667e18..57835f30565 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -58,6 +58,9 @@ #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all #include "assertions.h" +#ifdef MESSAGE_CHART_GENERATOR +#include "msc.h" +#endif #ifdef EMOS #include <gps.h> @@ -120,7 +123,7 @@ unsigned short config_frames[4] = {2,9,11,13}; # include "create_tasks.h" # if defined(ENABLE_USE_MME) # include "s1ap_eNB.h" -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK # include "SIMULATION/ETH_TRANSPORT/proto.h" #endif # endif @@ -139,10 +142,10 @@ unsigned short config_frames[4] = {2,9,11,13}; //#define USRP_DEBUG 1 struct timing_info_t { - //unsigned int frame, hw_slot, last_slot, next_slot; - RTIME time_min, time_max, time_avg, time_last, time_now; - //unsigned int mbox0, mbox1, mbox2, mbox_target; - unsigned int n_samples; + //unsigned int frame, hw_slot, last_slot, next_slot; + RTIME time_min, time_max, time_avg, time_last, time_now; + //unsigned int mbox0, mbox1, mbox2, mbox_target; + unsigned int n_samples; } timing_info; @@ -157,7 +160,7 @@ int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_c void fill_ue_band_info(void); #ifdef XFORMS // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) -// at eNB 0, an UL scope for every UE +// at eNB 0, an UL scope for every UE FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; FD_lte_phy_scope_enb *form_enb[NUMBER_OF_UE_MAX]; FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; @@ -249,14 +252,19 @@ runmode_t mode = normal_txrx; #ifdef EXMIMO +#if MAX_NUM_CCs == 1 +double tx_gain[MAX_NUM_CCs][4] = {{20,20,0,0}}; +double rx_gain[MAX_NUM_CCs][4] = {{20,20,0,0}}; +#else double tx_gain[MAX_NUM_CCs][4] = {{20,20,0,0},{20,20,0,0}}; double rx_gain[MAX_NUM_CCs][4] = {{20,20,0,0},{20,20,0,0}}; +#endif // these are for EXMIMO2 target only /* static unsigned int rxg_max[4] = {133,133,133,133}; static unsigned int rxg_med[4] = {127,127,127,127}; static unsigned int rxg_byp[4] = {120,120,120,120}; -*/ + */ // these are for EXMIMO2 card 39 unsigned int rxg_max[4] = {128,128,128,126}; unsigned int rxg_med[4] = {122,123,123,120}; @@ -264,7 +272,11 @@ unsigned int rxg_byp[4] = {116,117,116,116}; unsigned int nf_max[4] = {7,9,16,12}; unsigned int nf_med[4] = {12,13,22,17}; unsigned int nf_byp[4] = {15,20,29,23}; +#if MAX_NUM_CCs == 1 +rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}}; +#else rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain},{max_gain,max_gain,max_gain,max_gain}}; +#endif #else double tx_gain[MAX_NUM_CCs][4] = {{20,0,0,0}}; double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0}}; diff --git a/targets/RT/USER/synctest.c b/targets/RT/USER/synctest.c index f73cf7836e6..71cfbd88f81 100644 --- a/targets/RT/USER/synctest.c +++ b/targets/RT/USER/synctest.c @@ -841,7 +841,7 @@ int main(int argc, char **argv) vcd_signal_dumper_init("/tmp/openair_dump_eNB.vcd"); } -#ifdef NAS_NETLINK +#ifdef PDCP_USE_NETLINK netlink_init(); #endif diff --git a/targets/SCRIPTS/msc_gen.py b/targets/SCRIPTS/msc_gen.py index 4d45677cff0..fbd216d2db2 100755 --- a/targets/SCRIPTS/msc_gen.py +++ b/targets/SCRIPTS/msc_gen.py @@ -40,7 +40,15 @@ g_display_color = ['\"teal\"', '\"indigo\"', '\"indigo\"', '\"indigo\"', - '\"purple\"'] + '\"black\"', + '\"black\"', + '\"black\"', + '\"black\"', + '\"black\"', + '\"black\"', + '\"black\"', + '\"black\"', + '\"black\"'] @@ -61,19 +69,23 @@ def parse_oai_log_files(): global g_final_display_order_list #open TXT file that contain OAI filtered traces for mscgen filenames = [ - '/tmp/openair.msc.gtpu_enb.log', - '/tmp/openair.msc.mac_enb.log', - '/tmp/openair.msc.mac_ue.log', '/tmp/openair.msc.nas_ue.log', - '/tmp/openair.msc.pdcp_enb.log', '/tmp/openair.msc.pdcp_ue.log', - '/tmp/openair.msc.phy_enb.log', + '/tmp/openair.msc.rrc_ue.log', + '/tmp/openair.msc.rlc_ue.log', + '/tmp/openair.msc.mac_ue.log', '/tmp/openair.msc.phy_ue.log', + '/tmp/openair.msc.phy_enb.log', + '/tmp/openair.msc.mac_enb.log', '/tmp/openair.msc.rlc_enb.log', - '/tmp/openair.msc.rlc_ue.log', + '/tmp/openair.msc.pdcp_enb.log', '/tmp/openair.msc.rrc_enb.log', - '/tmp/openair.msc.rrc_ue.log', - '/tmp/openair.msc.s1ap_enb.log'] + '/tmp/openair.msc.s1ap_enb.log', + '/tmp/openair.msc.gtpu_enb.log', + '/tmp/openair.msc.nas_mme.log', + '/tmp/openair.msc.gtpu_sgw.log', + '/tmp/openair.msc.s1ap_mme.log'] + for filename in filenames: fhandle = open(filename, 'r') fcontent = fhandle.read() @@ -82,71 +94,72 @@ def parse_oai_log_files(): # split file content in lines lines = fcontent.splitlines() for line in lines: - print ("INPUT LINE: %s " % line) - partition = line.split(' ',3) - event_id = int(partition[0]) - event_type = partition[1] - entity_id = int(partition[2]) - if MSC_NEW_STR == event_type: - entity_name = partition[3] - if len(g_proto_names) < (entity_id +1): - for i in range(len(g_proto_names),(entity_id +1)): - g_proto_names.append(None) - g_proto_names[entity_id] = entity_name - - # if line is a trace of a message between 2 protocol entities or layers - elif MSC_MSG_STR == event_type: - print ("partition[3]:%s" % partition[3]) - sub_partition = partition[3].split(' ',4) - arrow = sub_partition[0] - entity2_id = int(sub_partition[1]) - mac = int(sub_partition[2]) - time = sub_partition[3] - message = sub_partition[4] - Message = {} - Message['mac'] = mac - Message['time'] = time - Message['message'] = message - Message['line_color'] = g_display_color[entity_id] - Message['text_color'] = g_display_color[entity_id] - if arrow == '<-': - Message['type'] = "rx" - Message['tx'] = entity2_id - Message['rx'] = entity_id - Message['discarded'] = False - g_messages[event_id] = Message - elif arrow == '->': - Message['type'] = "tx" - Message['tx'] = entity_id - Message['rx'] = entity2_id - Message['discarded'] = False - g_messages[event_id] = Message - elif arrow == 'x-': - Message['type'] = "rx" - Message['tx'] = entity2_id - Message['rx'] = entity_id - Message['discarded'] = True - g_messages[event_id] = Message - elif arrow == '-x': - Message['type'] = "tx" - Message['tx'] = entity_id - Message['rx'] = entity2_id - Message['discarded'] = True - g_messages[event_id] = Message - - elif MSC_BOX_STR == event_type: - message = partition[3] - Message = {} - Message['type'] = "box" - Message['tx'] = entity_id - Message['rx'] = entity_id - Message['discarded'] = False - Message['mac'] = mac - Message['time'] = time - Message['message'] = message - Message['line_color'] = g_display_color[entity_id] - Message['text_color'] = g_display_color[entity_id] - g_messages[event_id] = Message + if line.strip() != "": + print ("INPUT LINE: %s " % line) + partition = line.split(' ',3) + event_id = int(partition[0]) + event_type = partition[1] + entity_id = int(partition[2]) + if MSC_NEW_STR == event_type: + entity_name = partition[3] + if len(g_proto_names) <= entity_id: + for i in range(len(g_proto_names),(entity_id +1)): + g_proto_names.append("NotDeclared") + g_proto_names[entity_id] = entity_name + + # if line is a trace of a message between 2 protocol entities or layers + elif MSC_MSG_STR == event_type: + print ("partition[3]:%s" % partition[3]) + sub_partition = partition[3].split(' ',4) + arrow = sub_partition[0] + entity2_id = int(sub_partition[1]) + mac = int(sub_partition[2]) + time = sub_partition[3] + message = sub_partition[4] + Message = {} + Message['mac'] = mac + Message['time'] = time + Message['message'] = message + Message['line_color'] = g_display_color[entity_id] + Message['text_color'] = g_display_color[entity_id] + if arrow == '<-': + Message['type'] = "rx" + Message['tx'] = entity2_id + Message['rx'] = entity_id + Message['discarded'] = False + g_messages[event_id] = Message + elif arrow == '->': + Message['type'] = "tx" + Message['tx'] = entity_id + Message['rx'] = entity2_id + Message['discarded'] = False + g_messages[event_id] = Message + elif arrow == 'x-': + Message['type'] = "rx" + Message['tx'] = entity2_id + Message['rx'] = entity_id + Message['discarded'] = True + g_messages[event_id] = Message + elif arrow == '-x': + Message['type'] = "tx" + Message['tx'] = entity_id + Message['rx'] = entity2_id + Message['discarded'] = True + g_messages[event_id] = Message + + elif MSC_BOX_STR == event_type: + message = partition[3] + Message = {} + Message['type'] = "box" + Message['tx'] = entity_id + Message['rx'] = entity_id + Message['discarded'] = False + Message['mac'] = mac + Message['time'] = time + Message['message'] = message + Message['line_color'] = g_display_color[entity_id] + Message['text_color'] = g_display_color[entity_id] + g_messages[event_id] = Message #print("------------------------------------") @@ -162,6 +175,7 @@ def msc_chart_write_header(fileP): fileP.write("width = \"2048\";\n") entity_line_list_str = '' + print (" %s " % ( g_proto_names ) ) for entity in g_proto_names: entity_line_list_str = entity_line_list_str + ' ' + entity + ',' @@ -170,7 +184,7 @@ def msc_chart_write_header(fileP): def msc_chart_write_footer(fileP): - fileP.write("}\n") + fileP.write("\n}\n") def msc_chart_generate(file_nameP): global MSCGEN_OUTPUT_TYPE @@ -206,7 +220,6 @@ g_file = get_new_file_descriptor() msc_chart_write_header(g_file) for event_id_int in sorted(g_messages.iterkeys()): -#for message in g_messages: message = g_messages[event_id_int] if 'tx' in message['type']: g_file.write(" %s=>%s [ label = \"(%d|%s) %s\", linecolour=%s , textcolour=%s ] ;\n" % (g_proto_names[message['tx']], g_proto_names[message['rx']], event_id_int, message['time'], message['message'], message['line_color'], message['text_color'])) diff --git a/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE/Makefile b/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE/Makefile index 6c05991a2fb..c8ea4ea5c30 100644 --- a/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE/Makefile +++ b/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE/Makefile @@ -1,7 +1,7 @@ all: oaisim nasmesh oaisim: - (cd $(OPENAIR_TARGETS)/SIMU/USER && make NAS=1 -j2 ) + (cd $(OPENAIR_TARGETS)/SIMU/USER && make LINK_ENB_PDCP_TO_IP_DRIVER=1 -j2 ) nasmesh: (cd $(OPENAIR2_DIR) && make nasmesh_netlink.ko) (cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL/ && make) diff --git a/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE_OAI_DRIVER_ETHERNET/Makefile b/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE_OAI_DRIVER_ETHERNET/Makefile index ce862432442..c89992e7e47 100755 --- a/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE_OAI_DRIVER_ETHERNET/Makefile +++ b/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_1UE_OAI_DRIVER_ETHERNET/Makefile @@ -1,7 +1,7 @@ all: oaisim naslite_netlink_ether oaisim: - (cd $(OPENAIR_TARGETS)/SIMU/USER && make oaisim OAI_NW_DRIVER_TYPE_ETHERNET=1 NAS_NETLINK=1) + (cd $(OPENAIR_TARGETS)/SIMU/USER && make oaisim OAI_NW_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1) naslite_netlink_ether: (cd $(OPENAIR2_DIR) && make naslite_netlink_ether.ko) (cd $(OPENAIR2_DIR)/NAS/DRIVER/LITE/RB_TOOL/ && make) diff --git a/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_2UE/Makefile b/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_2UE/Makefile index 87159768ff9..7e14cfa8de2 100644 --- a/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_2UE/Makefile +++ b/targets/SIMU/EXAMPLES/ETH_EMUL_1eNB_2UE/Makefile @@ -3,7 +3,7 @@ all: oaisim nasmesh userclean: clean oaisim nasmesh oaisim: - (cd $(OPENAIR_TARGETS)/SIMU/USER && make NAS=1 -j2) + (cd $(OPENAIR_TARGETS)/SIMU/USER && make LINK_ENB_PDCP_TO_IP_DRIVER=1 -j2) nasmesh: (cd $(OPENAIR2_DIR) && make nasmesh_netlink.ko) (cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL/ && make) diff --git a/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/Makefile b/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/Makefile index 0c6a6b8adcd..6fdf92b93ea 100644 --- a/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/Makefile +++ b/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/Makefile @@ -11,9 +11,9 @@ help: all: help oaisim: - (cd $(OPENAIR_TARGETS)/SIMU/USER && $(MAKE) oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ) + (cd $(OPENAIR_TARGETS)/SIMU/USER && $(MAKE) oaisim LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 DEBUG=1) oaisim_nas: - (cd $(OPENAIR_TARGETS)/SIMU/USER && $(MAKE) oaisim OAI_NW_DRIVER_TYPE_ETHERNET=1 NAS=1) + (cd $(OPENAIR_TARGETS)/SIMU/USER && $(MAKE) oaisim OAI_NW_DRIVER_TYPE_ETHERNET=1 LINK_ENB_PDCP_TO_IP_DRIVER=1) nasmesh: (cd $(OPENAIR2_DIR) && make nasmesh_netlink_address_fix.ko) (cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL && make) diff --git a/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/start_one_eNB_multi_UE_nas b/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/start_one_eNB_multi_UE_nas index 0ccda137e76..df8357c610d 100755 --- a/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/start_one_eNB_multi_UE_nas +++ b/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB/start_one_eNB_multi_UE_nas @@ -46,8 +46,8 @@ if [ $1 -ge 4 ]; then fi echo "start the emulation with 1eNB and" $1 "UE" -echo "$OPENAIR_TARGETS/SIMU/USER/oaisim -a -u" $1 ">/dev/null" -$OPENAIR_TARGETS/SIMU/USER/oaisim -a -u $1 > /dev/null +echo "$OPENAIR_TARGETS/SIMU/USER/oaisim -a -V -u" $1 ">/dev/null" +$OPENAIR_TARGETS/SIMU/USER/oaisim -a -V -u $1 > /dev/null echo "End" diff --git a/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB_OAI_LITE/Makefile b/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB_OAI_LITE/Makefile index 5213a37eada..7cff6e66e6d 100755 --- a/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB_OAI_LITE/Makefile +++ b/targets/SIMU/EXAMPLES/VIRT_EMUL_1eNB_OAI_LITE/Makefile @@ -2,7 +2,7 @@ all: oaisim naslite_netlink_ether oaisim: - (cd $(OPENAIR_TARGETS)/SIMU/USER && $(MAKE) oaisim OAI_NW_DRIVER_TYPE_ETHERNET=1 NAS=1) + (cd $(OPENAIR_TARGETS)/SIMU/USER && $(MAKE) oaisim OAI_NW_DRIVER_TYPE_ETHERNET=1 LINK_ENB_PDCP_TO_IP_DRIVER=1) naslite_netlink_ether: (cd $(OPENAIR2_DIR) && $(MAKE) naslite_netlink_ether.ko) diff --git a/targets/SIMU/USER/Makefile b/targets/SIMU/USER/Makefile index 1a9b65634a0..8aaea0c5999 100644 --- a/targets/SIMU/USER/Makefile +++ b/targets/SIMU/USER/Makefile @@ -15,8 +15,11 @@ ifeq ($(DEBUG),1) CFLAGS += -g -ggdb -DDEBUG_PHY -DDEBUG_MEAS CFLAGS += -DRRC_MSG_PRINT CFLAGS += -DPDCP_MSG_PRINT -#CFLAGS += -DTRACE_RLC_UM_PDU -#CFLAGS += -DTRACE_RLC_AM_PDU +CFLAGS += -DTRACE_RLC_UM_PDU +CFLAGS += -DTRACE_RLC_AM_PDU +else +CFLAGS += -DTRACE_RLC_UM_PDU +CFLAGS += -DTRACE_RLC_AM_PDU endif ifeq ($(MSG_PRINT),1) @@ -24,6 +27,7 @@ CFLAGS += -DRRC_MSG_PRINT CFLAGS += -DPDCP_MSG_PRINT endif + CFLAGS += -Wpointer-sign CFLAGS += -DUSER_MODE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 $(CPUFLAGS) -I/usr/include/X11 #-Wno-packed-bitfield-compat @@ -146,11 +150,15 @@ endif -ifeq ($(NAS), 1) -CFLAGS += -DNAS_NETLINK -DLINUX +ifeq ($(LINK_ENB_PDCP_TO_IP_DRIVER), 1) +CFLAGS += -DPDCP_USE_NETLINK -DLINUX NAS_FLAG=1 endif +ifeq ($(LINK_ENB_PDCP_TO_GTPV1U), 1) +CFLAGS += -DLINK_ENB_PDCP_TO_GTPV1U +endif + ifdef TEST_OMG CFLAGS += -DTEST_OMG #CFLAGS += -DDEBUG_OMG @@ -257,7 +265,7 @@ endif CFLAGS += -DENABLE_VCD_FIFO CFLAGS += -DENABLE_NEW_MULTICAST ifdef NAS -CFLAGS += -DENABLE_PDCP_NETLINK_FIFO +CFLAGS += -DUSE_PDCP_NETLINK_QUEUES endif # CFLAGS += -DENABLE_LOG_FIFO @@ -274,7 +282,7 @@ ifeq ($(OPENAIR2),1) OBJ += $(L2_OBJS) endif -LFDS_OBJ_DIR = $(subst $(OPENAIR_HOME),$(OBJS_DIR),$(LFDS_DIR)) +LFDS_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(LFDS_DIR)) LFDS_LIB = $(LFDS_OBJ_DIR)/bin/liblfds611.a LIBS += $(LFDS_LIB) SHARED_DEPENDENCIES += $(LFDS_LIB) @@ -303,10 +311,10 @@ printvars: @echo Enable PGM: $(PGM_FOUND) ##UTIL_YAC_C = $(OPENAIR2_TOP)/UTIL/enb_parser.o -##$(UTIL_LEX_C) = $(subst $(OPENAIR_HOME), $(OBJS_DIR), $(OBJ) $(OAISIM_OBJS) $(ASN1_RRC_MSG_OBJS1)) +##$(UTIL_LEX_C) = $(subst $(OPENAIR_DIR), $(OBJS_DIR), $(OBJ) $(OAISIM_OBJS) $(ASN1_RRC_MSG_OBJS1)) -OAISIM_COMPILED_OBJECTS = $(subst $(OPENAIR_HOME), $(OBJS_DIR), $(OBJ) $(OAISIM_OBJS) $(ASN1_RRC_MSG_OBJS1)) +OAISIM_COMPILED_OBJECTS = $(subst $(OPENAIR_DIR), $(OBJS_DIR), $(OBJ) $(OAISIM_OBJS) $(ASN1_RRC_MSG_OBJS1)) -include $(ITTI_MESSAGES_XML:.xml=.d) -include $(OAISIM_PAD_OBJS:.o=.d) @@ -321,7 +329,7 @@ endif $(OAISIM_COMPILED_OBJECTS): | objsdir .SECONDEXPANSION: -$(OAISIM_COMPILED_OBJECTS) $(OAISIM_PAD_OBJS): %.o : $$(subst $(OBJS_DIR), $(OPENAIR_HOME), $$*.c) +$(OAISIM_COMPILED_OBJECTS) $(OAISIM_PAD_OBJS): %.o : $$(subst $(OBJS_DIR), $(OPENAIR_DIR), $$*.c) @echo Compiling $< @if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi; @$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DPHY_CONTEXT=1 $(INCLUDES) -o $@ $< diff --git a/targets/SIMU/USER/event_handler.c b/targets/SIMU/USER/event_handler.c index 63815ae5d1b..956f3455505 100644 --- a/targets/SIMU/USER/event_handler.c +++ b/targets/SIMU/USER/event_handler.c @@ -102,7 +102,6 @@ void schedule_delayed(Operation_Type_t op, Event_Type_t type, char * key, void* intps=time(NULL); pdh = localtime(&intps); char *date_cpy = malloc (sizeof (char) * 256); - //strcpy(date_cpy,date); strncpy( date_cpy, date, 256 ); date_cpy[255] = 0; // terminate string // second count the frame to reach the time @@ -435,7 +434,7 @@ void update_mac(Event_t event) if((Mac_config *) event.value !=NULL && validate_mac(event)) { - Mac_config* mac_config;// = malloc(sizeof(Mac_config)*16); + Mac_config* mac_config; mac_config = (Mac_config *) event.value; LOG_I(EMU,"update complete mac params \n"); @@ -462,7 +461,6 @@ void update_mac(Event_t event) if(mac_config[i].priority !=NULL) { LOG_I(EMU,"update priority \n"); int j; - for(j=0; j<MAX_NUM_LCID; j++) { if(&mac_config[i].priority[j]!=NULL) { @@ -674,7 +672,6 @@ void update_mac(Event_t event) mac_config = (Mac_config *) event.value; int j=0; LOG_I(EMU,"priority update \n"); - if(event.ue == -1) { for(i=0; i<MAX_NUM_LCID; i++) { for(j=0; j<MAX_NUM_LCID; j++) { diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index e0121fa5f52..6741013cd8c 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -163,25 +163,16 @@ time_stats_t dl_chan_stats; time_stats_t ul_chan_stats; // this should reflect the channel models in openair1/SIMULATION/TOOLS/defs.h -mapping small_scale_names[] = { { "custom", custom }, { "SCM_A", SCM_A }, { - "SCM_B", SCM_B - }, { "SCM_C", SCM_C }, { "SCM_D", SCM_D }, { - "EPA", EPA - }, { "EVA", EVA }, { "ETU", ETU }, - { "MBSFN", MBSFN }, { "Rayleigh8", Rayleigh8 }, { - "Rayleigh1", - Rayleigh1 - }, { "Rayleigh1_800", Rayleigh1_800 }, - { "Rayleigh1_corr", Rayleigh1_corr }, { - "Rayleigh1_anticorr", - Rayleigh1_anticorr - }, { "Rice8", Rice8 }, { - "Rice1", Rice1 - }, { "Rice1_corr", Rice1_corr }, - { "Rice1_anticorr", Rice1_anticorr }, { "AWGN", AWGN }, { - NULL, - -1 - } +mapping small_scale_names[] = { + { "custom", custom }, { "SCM_A", SCM_A }, + { "SCM_B", SCM_B }, { "SCM_C", SCM_C }, + { "SCM_D", SCM_D }, { "EPA", EPA }, + { "EVA", EVA }, { "ETU", ETU }, + { "MBSFN", MBSFN }, { "Rayleigh8", Rayleigh8 }, + { "Rayleigh1", Rayleigh1 }, { "Rayleigh1_800", Rayleigh1_800 }, + { "Rayleigh1_corr", Rayleigh1_corr }, { "Rayleigh1_anticorr", Rayleigh1_anticorr }, + { "Rice8", Rice8 }, { "Rice1", Rice1 }, { "Rice1_corr", Rice1_corr }, + { "Rice1_anticorr", Rice1_anticorr }, { "AWGN", AWGN }, { NULL,-1 } }; #if !defined(ENABLE_ITTI) static void * @@ -747,7 +738,7 @@ l2l1_task (void *args_p) PHY_vars_eNB_g[eNB_inst][0]->lte_frame_parms.Nid_cell); #ifdef OPENAIR2 - //Appliation: traffic gen + //Application: traffic gen update_otg_eNB (eNB_inst, oai_emulation.info.time_ms); //IP/OTG to PDCP and PDCP to IP operation @@ -837,10 +828,7 @@ l2l1_task (void *args_p) update_otg_UE (UE_inst, oai_emulation.info.time_ms); //Access layer - ctxt.enb_module_id = 0; - ctxt.ue_module_id = UE_inst; - ctxt.frame = frame; - ctxt.enb_flag = ENB_FLAG_NO; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE_inst, ENB_FLAG_NO, NOT_A_RNTI, frame, next_slot); pdcp_run (&ctxt); #endif diff --git a/targets/TEST/AT_COMMANDS/Makefile b/targets/TEST/AT_COMMANDS/Makefile index e75d5291b85..2939b30c017 100755 --- a/targets/TEST/AT_COMMANDS/Makefile +++ b/targets/TEST/AT_COMMANDS/Makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc TOP_DIR = $(OPENAIR1_DIR) OPENAIR1_TOP = $(OPENAIR1_DIR) @@ -19,8 +19,8 @@ ifdef DEBUG_PHY CFLAGS += -DDEBUG_PHY endif -ifdef NAS_NETLINK -CFLAGS += -DNAS_NETLINK -DLINUX -DDEBUG_CONTROL +ifdef PDCP_USE_NETLINK +CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif CFLAGS += -DPHY_ABSTRACTION #-DEMIT_ASN_DEBUG=1 diff --git a/targets/TEST/OAI/case01.py b/targets/TEST/OAI/case01.py index cd0468d442f..4a9594fdcaa 100644 --- a/targets/TEST/OAI/case01.py +++ b/targets/TEST/OAI/case01.py @@ -92,7 +92,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): log.start() test = '02' name = 'Compile oai.rel8.nas.make' - conf = 'make nasmesh_fix; make NAS=1' + conf = 'make nasmesh_fix; make LINK_ENB_PDCP_TO_IP_DRIVER=1' diag = 'check the compilation errors for oai and nas driver' oai.send('make cleanall;') oai.send('rm -f ./oaisim.rel8.nas'+host) @@ -104,7 +104,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): oai.send('cp $OPENAIR2_DIR/NAS/DRIVER/MESH/nasmesh.ko .') trace = logdir + '/log_' + case + test + '_2.txt;' tee = ' 2>&1 | tee ' + trace - oai.send_expect_false('make NAS=1 JF=1 -j4' + tee, makerr1, timeout) + oai.send_expect_false('make LINK_ENB_PDCP_TO_IP_DRIVER=1 JF=1 -j4' + tee, makerr1, timeout) oai.send('cp ./oaisim ./oaisim.rel8.nas.'+host) except log.err, e: @@ -255,7 +255,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): log.start() test = '14' name = 'Compile oai.rel8.itti.ral.make' - conf = 'make DISABLE_XER_PRINT=1 NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel8=1' + conf = 'make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel8=1' trace = logdir + '/log_' + case + test + '.txt;' tee = ' 2>&1 | tee ' + trace diag = 'check the compilation errors for ITTI Rel8' @@ -263,7 +263,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): oai.send('make cleanall;') oai.send('make cleanasn1;') oai.send('rm -f ./oaisim.rel8.itti.ral.'+host) - oai.send_expect_false('make DISABLE_XER_PRINT=1 NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel8=1 -j4' + tee, makerr1, timeout) + oai.send_expect_false('make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel8=1 -j4' + tee, makerr1, timeout) oai.send('cp ./oaisim ./oaisim.rel8.itti.ral.'+host) except log.err, e: log.fail(case, test, name, conf, e.value, diag, logfile,trace) @@ -274,7 +274,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): log.start() test = '15' name = 'Compile oai.rel10.itti.ral.make' - conf = 'make DISABLE_XER_PRINT=1 NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel10=1' + conf = 'make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel10=1' trace = logdir + '/log_' + case + test + '.txt;' tee = ' 2>&1 | tee ' + trace diag = 'check the compilation errors for ITTI Rel10' @@ -282,7 +282,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): oai.send('make cleanall;') oai.send('make cleanasn1;') oai.send('rm -f ./oaisim.rel10.itti.ral.'+host) - oai.send_expect_false('make DISABLE_XER_PRINT=1 NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel10=1 -j4' + tee, makerr1, timeout) + oai.send_expect_false('make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel10=1 -j4' + tee, makerr1, timeout) oai.send('cp ./oaisim ./oaisim.rel10.itti.ral.'+host) except log.err, e: log.fail(case, test, name, conf, e.value, diag, logfile,trace) diff --git a/targets/TEST/PACKET_TRACER/Makefile b/targets/TEST/PACKET_TRACER/Makefile index c6678ed3b9a..46fa86037ce 100755 --- a/targets/TEST/PACKET_TRACER/Makefile +++ b/targets/TEST/PACKET_TRACER/Makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc TOP_DIR = $(OPENAIR1_DIR) OPENAIR1_TOP = $(OPENAIR1_DIR) @@ -48,7 +48,7 @@ ifdef DEBUG_PHY CFLAGS += -DDEBUG_PHY endif -#CFLAGS += -DNAS_NETLINK -DLINUX +#CFLAGS += -DPDCP_USE_NETLINK -DLINUX #NAS_FLAG=1 #require kernel patch for oai driver to enable address autoconfiguration (IPv6 only) diff --git a/targets/TEST/PDCP/Makefile b/targets/TEST/PDCP/Makefile index f11b044f1ac..66af847af5e 100755 --- a/targets/TEST/PDCP/Makefile +++ b/targets/TEST/PDCP/Makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc TOP_DIR = $(OPENAIR1_DIR) OPENAIR1_TOP = $(OPENAIR1_DIR) @@ -21,8 +21,8 @@ ifdef DEBUG_PHY CFLAGS += -DDEBUG_PHY endif -ifdef NAS_NETLINK -CFLAGS += -DNAS_NETLINK -DLINUX -DDEBUG_CONTROL +ifdef PDCP_USE_NETLINK +CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif CFLAGS += -DPHY_ABSTRACTION #-DEMIT_ASN_DEBUG=1 diff --git a/targets/TEST/PDCP/test_pdcp.c b/targets/TEST/PDCP/test_pdcp.c index d9dc33b8b74..bce5cd31a9d 100755 --- a/targets/TEST/PDCP/test_pdcp.c +++ b/targets/TEST/PDCP/test_pdcp.c @@ -153,7 +153,7 @@ BOOL init_pdcp_entity(pdcp_t *pdcp_entity) return TRUE; } -BOOL test_tx_window() +BOOL test_tx_window(void) { unsigned long index = 0; @@ -171,7 +171,7 @@ BOOL test_tx_window() return TRUE; } -BOOL test_rx_window() +BOOL test_rx_window(void) { unsigned long index = 0; @@ -190,7 +190,7 @@ BOOL test_rx_window() return TRUE; } -BOOL test_pdcp_data_req() +BOOL test_pdcp_data_req(void) { unsigned char* pdcp_test_pdu_buffer = NULL; unsigned char pdcp_test_pdu_buffer_size = DUMMY_BUFFER_SIZE + PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; @@ -288,7 +288,7 @@ BOOL test_pdcp_data_req() return TRUE; } -BOOL test_pdcp_data_ind() +BOOL test_pdcp_data_ind(void) { /* * This is the list that pdcp_data_ind() takes to put pdcp_data_ind_header_t diff --git a/targets/TEST/PDCP/test_pdcp.h b/targets/TEST/PDCP/test_pdcp.h index 3c986f823e6..ce3004a8a39 100644 --- a/targets/TEST/PDCP/test_pdcp.h +++ b/targets/TEST/PDCP/test_pdcp.h @@ -17,24 +17,15 @@ * /homes/demiray/workspace/openair4G/trunk/openair2/LAYER2/PDCP_v10.1.0/pdcp.c:270: undefined reference to `pdcp_fifo_read_input_sdus' * /homes/demiray/workspace/openair4G/trunk/openair2/LAYER2/PDCP_v10.1.0/pdcp.c:273: undefined reference to `pdcp_fifo_flush_sdus' */ -int pdcp_fifo_flush_sdus () -{ - return 0; -} -int pdcp_fifo_read_input_sdus_remaining_bytes () -{ - return 0; -} -int pdcp_fifo_read_input_sdus () -{ - return 0; -} +int pdcp_fifo_flush_sdus (void) { return 0; } +int pdcp_fifo_read_input_sdus_remaining_bytes (void) { return 0; } +int pdcp_fifo_read_input_sdus (void) { return 0; } BOOL init_pdcp_entity(pdcp_t *pdcp_entity); -BOOL test_tx_window(); -BOOL test_rx_window(); -BOOL test_pdcp_data_req(); -BOOL test_pdcp_data_ind(); +BOOL test_tx_window(void); +BOOL test_rx_window(void); +BOOL test_pdcp_data_req(void); +BOOL test_pdcp_data_ind(void); /* * PDCP methods that are going to be utilised throughout the test diff --git a/targets/TEST/PDCP/with_rlc/Makefile.data_bearer b/targets/TEST/PDCP/with_rlc/Makefile.data_bearer index 41d99dbb005..00f07c1b928 100755 --- a/targets/TEST/PDCP/with_rlc/Makefile.data_bearer +++ b/targets/TEST/PDCP/with_rlc/Makefile.data_bearer @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc TOP_DIR = $(OPENAIR1_DIR) OPENAIR1_TOP = $(OPENAIR1_DIR) @@ -21,8 +21,8 @@ ifdef DEBUG_PHY CFLAGS += -DDEBUG_PHY endif -ifdef NAS_NETLINK -CFLAGS += -DNAS_NETLINK -DLINUX -DDEBUG_CONTROL +ifdef PDCP_USE_NETLINK +CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif CFLAGS += -DPHY_ABSTRACTION #-DEMIT_ASN_DEBUG=1 diff --git a/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c b/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c index 3a4fbd60419..b894d7f11c8 100755 --- a/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c +++ b/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c @@ -91,8 +91,7 @@ int pdcp_fifo_read_input_sdus () {} BOOL init_pdcp_entity(pdcp_t *pdcp_entity); //----------------------------------------------------------------------------- -void pdcp_rlc_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_data_req *data_requestP, int* drop_countP, int *tx_packetsP, - int* dropped_tx_packetsP) //----------------------------------------------------------------------------- +void pdcp_rlc_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_data_req *data_requestP, int* drop_countP, int *tx_packetsP, int* dropped_tx_packetsP) //----------------------------------------------------------------------------- { mem_block_t* tb_src; mem_block_t* tb_dst; diff --git a/targets/TEST/RLC_AM_V9.3.0/Makefile b/targets/TEST/RLC_AM_V9.3.0/Makefile index 7b8e8e867cc..9c807cd8265 100755 --- a/targets/TEST/RLC_AM_V9.3.0/Makefile +++ b/targets/TEST/RLC_AM_V9.3.0/Makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc NUM_CORES=$(shell cat /proc/cpuinfo | grep processor | wc -l) @@ -88,7 +88,7 @@ endif endif ifeq ($(NAS), 1) -CFLAGS += -DNAS_NETLINK -DLINUX +CFLAGS += -DPDCP_USE_NETLINK -DLINUX NAS_FLAG=1 endif diff --git a/targets/TEST/RLC_UM_V9.3.0/Makefile b/targets/TEST/RLC_UM_V9.3.0/Makefile index f466a55ba93..b01ea156f4f 100755 --- a/targets/TEST/RLC_UM_V9.3.0/Makefile +++ b/targets/TEST/RLC_UM_V9.3.0/Makefile @@ -1,4 +1,4 @@ -include $(OPENAIR_HOME)/common/utils/Makefile.inc +include $(OPENAIR_DIR)/common/utils/Makefile.inc NUM_CORES=$(shell cat /proc/cpuinfo | grep processor | wc -l) @@ -85,7 +85,7 @@ endif endif ifeq ($(NAS), 1) -CFLAGS += -DNAS_NETLINK -DLINUX +CFLAGS += -DPDCP_USE_NETLINK -DLINUX NAS_FLAG=1 endif -- GitLab