From 0b83862fc29012effdba3147a4b3eb6d1b40984c Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Tue, 28 Mar 2017 18:28:30 +0200 Subject: [PATCH 001/141] uplink proto --- .../MESSAGES/V2/controller_commands.proto | 11 +++++-- openair2/ENB_APP/MESSAGES/V2/flexran.proto | 13 ++++++-- .../ENB_APP/MESSAGES/V2/mac_primitives.proto | 31 +++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto b/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto index cbec332b30..98ca6b8bee 100644 --- a/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto +++ b/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto @@ -3,7 +3,7 @@ package protocol; import "mac_primitives.proto"; // -// Body of UE DL MAC scheduling configuration info +// Body of UE DL/UL MAC scheduling configuration info // message flex_dl_data { @@ -15,6 +15,13 @@ message flex_dl_data { optional uint32 act_deact_ce = 6; //Hex content of MAC CE for Activation/Deactivation in CA } + +message flex_ul_data { + optional uint32 rnti = 1; + optional flex_ul_dci dl_dci = 2; + +} + // // Body of the RAR scheduler configuration // @@ -55,4 +62,4 @@ message flex_pdcch_ofdm_sym_count { enum flex_broadcast_type { FLBT_BCCH = 0; FLBT_PCCH = 1; -} \ No newline at end of file +} diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index 3a1d40bca6..ffd58daaae 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -25,9 +25,10 @@ message flexran_message { flex_lc_config_request lc_config_request_msg = 12; flex_lc_config_reply lc_config_reply_msg = 13; flex_dl_mac_config dl_mac_config_msg = 14; - flex_ue_state_change ue_state_change_msg = 15; - flex_control_delegation control_delegation_msg = 16; - flex_agent_reconfiguration agent_reconfiguration_msg = 17; + flex_ul_mac_config ul_mac_config_msg = 15 + flex_ue_state_change ue_state_change_msg = 16; + flex_control_delegation control_delegation_msg = 17; + flex_agent_reconfiguration agent_reconfiguration_msg = 18; } } @@ -163,6 +164,12 @@ message flex_dl_mac_config { repeated flex_pdcch_ofdm_sym_count ofdm_sym = 6; // OFDM symbol count for each CC } +message flex_ul_mac_config { + optional flex_header header = 1; + optional uint32 sfn_sf = 2; + repeated flex_ul_data ul_ue_data = 3; +} + // // UE state change message // diff --git a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto index be7c72ab7b..3b3bc4e912 100644 --- a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto +++ b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto @@ -35,6 +35,37 @@ message flex_dl_dci { optional uint32 cif = 27; // CIF for cross-carrier scheduling } +message flex_ul_dci { + optional uint32 rnti = 1; + optional uint32 res_alloc = 2; // Type of resource allocation + optional uint32 rb_bitmap = 3; // Bitmap for RB allocation + optional uint32 rb_shift = 4; // See TS 36.214, section 7.1.6.2 + repeated uint32 tbs_size = 5; // The size of each TBS + repeated uint32 mcs = 6; // The MCS of each TB + repeated uint32 ndi = 7; // New data indicator of each TB + //repeated uint32 rv = 8; // Redundancy version of each TB + //optional uint32 cce_index = 9; // CCE index used to send the DCI + //optional uint32 aggr_level = 10; + //optional uint32 precoding_info = 11; // 2 antenna ports:0..6, + // 4 antenna ports:0..50 + optional uint32 format = 12; // DCI format. A FLDCIF_* value + optional uint32 tpc = 13; // TS 36.213, sec 5.1.1.1 + optional uint32 harq_process = 14; // HARQ process ID + optional uint32 dai = 15; // TDD only + //optional uint32 vrb_format = 16; // One of the FLVRBF_* values + optional uint32 tb_swap = 17; // Boolean. TB to codeword swap flag + //optional uint32 sps_release = 18; // Flag value + optional uint32 pdcch_order = 19; +// optional uint32 preamble_index = 20; // Only valid if pdcch_order = 1 + optional uint32 prach_mask_index = 21; // Only valid if pdcch_order = 1 + optional uint32 n_gap = 22; // One of the FLNGV_* values + optional uint32 tbs_idx = 23; // The TBS index for Format 1A + optional uint32 dl_power_offset = 24; // For format 1D +// optional uint32 pdcch_power_offset = 25; // DL PDCCH power boosting in dB +// optional uint32 cif_present = 26; // Boolean. Indication of CIF field +// optional uint32 cif = 27; // CIF for cross-carrier scheduling +} + // // Messages related to the creation of RLC PDUs // From 1a516df2db06892732fd6663e84abcbf6e18b195 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Fri, 31 Mar 2017 16:40:26 +0200 Subject: [PATCH 002/141] proto uplink mac --- .../ENB_APP/MESSAGES/V2/mac_primitives.proto | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto index 3b3bc4e912..ecc82f116c 100644 --- a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto +++ b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto @@ -36,34 +36,39 @@ message flex_dl_dci { } message flex_ul_dci { + optional uint32 handle = 1; + optional uint32 size = 2; // Size of the ULSCH PDU in bytes for UL Grant. optional uint32 rnti = 1; - optional uint32 res_alloc = 2; // Type of resource allocation + optional uint32 res_block_start = 2; // match DCI format 0 PDU optional uint32 rb_bitmap = 3; // Bitmap for RB allocation - optional uint32 rb_shift = 4; // See TS 36.214, section 7.1.6.2 - repeated uint32 tbs_size = 5; // The size of each TBS - repeated uint32 mcs = 6; // The MCS of each TB - repeated uint32 ndi = 7; // New data indicator of each TB - //repeated uint32 rv = 8; // Redundancy version of each TB - //optional uint32 cce_index = 9; // CCE index used to send the DCI - //optional uint32 aggr_level = 10; - //optional uint32 precoding_info = 11; // 2 antenna ports:0..6, - // 4 antenna ports:0..50 + optional uint32 modulation_t = 4; // A FLMOD_* Value + optional uint32 cyclic_shift2 = 5; // match DCI format 0/4 PDU + optional uint32 freq_hop_flag = 6; // 0 no hopping, 1 hoppping + optional uint32 freq_hop_map = 8; // match DCI format 0 PDU + optional uint32 ndi = 7; // New data indicator of each TB + optional uint32 rv = 8; // Redundancy version of each TB + optional uint32 harq_process_number = 14; // A FLHARQ_* value + optional uint32 ultx_mode = 14; // A FLULM_* value + repeated uint32 tbs_size = 5; // The size of each TBS + repeated uint32 current_harq = 9; // CCE index used to send the DCI + optional uint32 n_srs = 10; // Over lap indication with srs + optional uint32 res_alloc = 2; // Type of resource allocation optional uint32 format = 12; // DCI format. A FLDCIF_* value - optional uint32 tpc = 13; // TS 36.213, sec 5.1.1.1 - optional uint32 harq_process = 14; // HARQ process ID - optional uint32 dai = 15; // TDD only - //optional uint32 vrb_format = 16; // One of the FLVRBF_* values - optional uint32 tb_swap = 17; // Boolean. TB to codeword swap flag - //optional uint32 sps_release = 18; // Flag value - optional uint32 pdcch_order = 19; + + +// optional uint32 dai = 15; // TDD only + +// optional uint32 tb_swap = 17; // Boolean. TB to codeword swap flag + +// optional uint32 pdcch_order = 19; // optional uint32 preamble_index = 20; // Only valid if pdcch_order = 1 - optional uint32 prach_mask_index = 21; // Only valid if pdcch_order = 1 - optional uint32 n_gap = 22; // One of the FLNGV_* values - optional uint32 tbs_idx = 23; // The TBS index for Format 1A - optional uint32 dl_power_offset = 24; // For format 1D -// optional uint32 pdcch_power_offset = 25; // DL PDCCH power boosting in dB -// optional uint32 cif_present = 26; // Boolean. Indication of CIF field -// optional uint32 cif = 27; // CIF for cross-carrier scheduling +// optional uint32 prach_mask_index = 21; // Only valid if pdcch_order = 1 + +// optional uint32 tbs_idx = 23; // The TBS index for Format 1A + + + + } // @@ -104,4 +109,10 @@ enum flex_vrb_format { enum flex_ngap_val { FLNGV_1 = 0; FLNGV_2 = 1; -} \ No newline at end of file +} + +enum flex_mod_type { + FLMOD_QPSK = 2; + FLMOD_16QAM = 4; + FLMOD_64QAM = 6; +} From a08178fa0e53f45dc2002ee8036c81192555e5ce Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Tue, 4 Apr 2017 21:11:16 +0000 Subject: [PATCH 003/141] Made modifications to UL scheduling messages --- .../MESSAGES/V2/controller_commands.proto | 3 +- openair2/ENB_APP/MESSAGES/V2/flexran.proto | 12 +++---- .../ENB_APP/MESSAGES/V2/mac_primitives.proto | 34 ++++++++----------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto b/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto index 98ca6b8bee..252efc6aef 100644 --- a/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto +++ b/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto @@ -18,8 +18,7 @@ message flex_dl_data { message flex_ul_data { optional uint32 rnti = 1; - optional flex_ul_dci dl_dci = 2; - + optional flex_ul_dci ul_dci = 2; } // diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index ffd58daaae..f49b69f4ad 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -25,10 +25,10 @@ message flexran_message { flex_lc_config_request lc_config_request_msg = 12; flex_lc_config_reply lc_config_reply_msg = 13; flex_dl_mac_config dl_mac_config_msg = 14; - flex_ul_mac_config ul_mac_config_msg = 15 - flex_ue_state_change ue_state_change_msg = 16; - flex_control_delegation control_delegation_msg = 17; - flex_agent_reconfiguration agent_reconfiguration_msg = 18; + flex_ul_mac_config ul_mac_config_msg = 18; + flex_ue_state_change ue_state_change_msg = 15; + flex_control_delegation control_delegation_msg = 16; + flex_agent_reconfiguration agent_reconfiguration_msg = 17; } } @@ -166,8 +166,8 @@ message flex_dl_mac_config { message flex_ul_mac_config { optional flex_header header = 1; - optional uint32 sfn_sf = 2; - repeated flex_ul_data ul_ue_data = 3; + optional uint32 sfn_sf = 2; + repeated flex_ul_data ul_ue_data = 3; } // diff --git a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto index ecc82f116c..01f8799a17 100644 --- a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto +++ b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto @@ -36,27 +36,23 @@ message flex_dl_dci { } message flex_ul_dci { - optional uint32 handle = 1; - optional uint32 size = 2; // Size of the ULSCH PDU in bytes for UL Grant. optional uint32 rnti = 1; - optional uint32 res_block_start = 2; // match DCI format 0 PDU - optional uint32 rb_bitmap = 3; // Bitmap for RB allocation - optional uint32 modulation_t = 4; // A FLMOD_* Value - optional uint32 cyclic_shift2 = 5; // match DCI format 0/4 PDU - optional uint32 freq_hop_flag = 6; // 0 no hopping, 1 hoppping - optional uint32 freq_hop_map = 8; // match DCI format 0 PDU - optional uint32 ndi = 7; // New data indicator of each TB - optional uint32 rv = 8; // Redundancy version of each TB - optional uint32 harq_process_number = 14; // A FLHARQ_* value - optional uint32 ultx_mode = 14; // A FLULM_* value - repeated uint32 tbs_size = 5; // The size of each TBS - repeated uint32 current_harq = 9; // CCE index used to send the DCI - optional uint32 n_srs = 10; // Over lap indication with srs - optional uint32 res_alloc = 2; // Type of resource allocation - optional uint32 format = 12; // DCI format. A FLDCIF_* value + optional uint32 rb_start = 2; // The start RB allocated to the UE + optional uint32 rb_len = 3; // The number of RBs allocated to the UE + optional uint32 mcs = 4; // Modulation and coding scheme + optional uint32 cyclic_shift2 = 5; // match DCI format 0/4 PDU + optional uint32 freq_hop_flag = 6; // 0 no hopping, 1 hoppping + optional uint32 freq_hop_map = 7; // Frequency hopping bits (0..4) + optional uint32 ndi = 8; // New data indicator + optional uint32 rv = 9; // Redundancy version + optional uint32 harq_pid = 10; // The harq process id + optional uint32 ultx_mode = 11; // A FLULM_* value + optional uint32 tbs_size = 12; // The size of each TBS + optional uint32 n_srs = 13; // Overlap indication with srs + optional uint32 res_alloc = 14; // Type of resource allocation + optional uint32 size = 15; // Size of the ULSCH PDU in bytes for UL Grant. - -// optional uint32 dai = 15; // TDD only + optional uint32 dai = 16; // TDD only // optional uint32 tb_swap = 17; // Boolean. TB to codeword swap flag From 4cfa87b6b3854285359f4155f60b04d41ee20a07 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Wed, 5 Apr 2017 10:38:36 +0200 Subject: [PATCH 004/141] downlink throughput enhancement --- cmake_targets/CMakeLists.txt | 4 + .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 1233 ++++++---------- .../CONTROL_MODULES/MAC/flexran_agent_mac.h | 44 +- .../MAC/flexran_agent_mac_internal.c | 10 +- .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 662 +++++++++ .../CONTROL_MODULES/RRC/flexran_agent_rrc.h | 74 + .../RRC/flexran_agent_rrc_defs.h | 62 + openair2/ENB_APP/MESSAGES/V2/flexran.proto | 8 + openair2/ENB_APP/MESSAGES/V2/header.proto | 2 + .../ENB_APP/MESSAGES/V2/stats_common.proto | 60 + .../ENB_APP/MESSAGES/V2/stats_messages.proto | 6 +- openair2/ENB_APP/enb_config.c | 81 +- openair2/ENB_APP/enb_config.h | 4 + openair2/ENB_APP/flexran_agent.c | 24 +- openair2/ENB_APP/flexran_agent.h | 12 +- openair2/ENB_APP/flexran_agent_common.c | 1296 +---------------- openair2/ENB_APP/flexran_agent_common.h | 395 +---- openair2/ENB_APP/flexran_agent_defs.h | 83 +- openair2/ENB_APP/flexran_agent_extern.h | 16 +- openair2/ENB_APP/flexran_agent_handler.c | 580 +++++++- openair2/ENB_APP/flexran_agent_ran_api.c | 929 ++++++++++++ openair2/ENB_APP/flexran_agent_ran_api.h | 290 ++++ openair2/ENB_APP/flexran_agent_timer.c | 217 +++ openair2/ENB_APP/flexran_agent_timer.h | 133 ++ openair2/LAYER2/MAC/eNB_scheduler.c | 20 +- .../LAYER2/MAC/eNB_scheduler_primitives.c | 10 + openair2/RRC/LITE/rrc_eNB.c | 665 ++++++++- 27 files changed, 4388 insertions(+), 2532 deletions(-) create mode 100644 openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c create mode 100644 openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h create mode 100644 openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h create mode 100644 openair2/ENB_APP/flexran_agent_ran_api.c create mode 100644 openair2/ENB_APP/flexran_agent_ran_api.h create mode 100644 openair2/ENB_APP/flexran_agent_timer.c create mode 100644 openair2/ENB_APP/flexran_agent_timer.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 94a88c095b..5413014fbf 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -820,6 +820,7 @@ include_directories("${OPENAIR_DIR}/targets/ARCH/EXMIMO/USERSPACE/LIB/") include_directories("${OPENAIR_DIR}/targets/ARCH/EXMIMO/DEFS") include_directories("${OPENAIR2_DIR}/ENB_APP") include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC") +include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC") include_directories("${OPENAIR2_DIR}/UTIL/OSA") include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds6.1.1/liblfds611/inc") include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/inc") @@ -905,8 +906,11 @@ if (FLEXRAN_AGENT_SB_IF) add_library(FLEXRAN_AGENT ${OPENAIR2_DIR}/ENB_APP/flexran_agent_handler.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent_common.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_ran_api.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_timer.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent_common_internal.c ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c + ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent_task_manager.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent_net_comm.c diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 1a43f203df..01df6248f1 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -31,6 +31,7 @@ #include "flexran_agent_common.h" #include "flexran_agent_mac_internal.h" #include "flexran_agent_net_comm.h" +#include "flexran_agent_timer.h" #include "LAYER2/MAC/proto.h" #include "LAYER2/MAC/flexran_agent_mac_proto.h" @@ -54,683 +55,497 @@ struct lfds700_ringbuffer_element *dl_mac_config_array[NUM_MAX_ENB]; struct lfds700_ringbuffer_state ringbuffer_state[NUM_MAX_ENB]; -int flexran_agent_mac_handle_stats(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg){ +int flexran_agent_mac_stats_reply(mid_t mod_id, + const report_config_t *report_config, + Protocol__FlexUeStatsReport **ue_report, + Protocol__FlexCellStatsReport **cell_report) { - // TODO: Must deal with sanitization of input - // TODO: Must check if RNTIs and cell ids of the request actually exist - // TODO: Must resolve conflicts among stats requests - int i; - err_code_t err_code; - xid_t xid; - uint32_t usec_interval, sec_interval; - - //TODO: We do not deal with multiple CCs at the moment and eNB id is 0 - int enb_id = mod_id; - - //eNB_MAC_INST *eNB = &eNB_mac_inst[enb_id]; - //UE_list_t *eNB_UE_list= &eNB->UE_list; - - report_config_t report_config; - - uint32_t ue_flags = 0; - uint32_t c_flags = 0; - - Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params; - - Protocol__FlexStatsRequest *stats_req = input->stats_request_msg; - xid = (stats_req->header)->xid; - - // Check the type of request that is made - switch(stats_req->body_case) { - case PROTOCOL__FLEX_STATS_REQUEST__BODY_COMPLETE_STATS_REQUEST: ; - Protocol__FlexCompleteStatsRequest *comp_req = stats_req->complete_stats_request; - if (comp_req->report_frequency == PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_OFF) { - /*Disable both periodic and continuous updates*/ - flexran_agent_disable_cont_mac_stats_update(mod_id); - flexran_agent_destroy_timer_by_task_id(xid); - *msg = NULL; - return 0; - } else { //One-off, periodical or continuous reporting - //Set the proper flags - ue_flags = comp_req->ue_report_flags; - c_flags = comp_req->cell_report_flags; - //Create a list of all eNB RNTIs and cells - - //Set the number of UEs and create list with their RNTIs stats configs - report_config.nr_ue = flexran_get_num_ues(mod_id); //eNB_UE_list->num_UEs - report_config.ue_report_type = (ue_report_type_t *) malloc(sizeof(ue_report_type_t) * report_config.nr_ue); - if (report_config.ue_report_type == NULL) { - // TODO: Add appropriate error code - err_code = -100; - goto error; - } - for (i = 0; i < report_config.nr_ue; i++) { - report_config.ue_report_type[i].ue_rnti = flexran_get_ue_crnti(enb_id, i); //eNB_UE_list->eNB_UE_stats[UE_PCCID(enb_id,i)][i].crnti; - report_config.ue_report_type[i].ue_report_flags = ue_flags; - } - //Set the number of CCs and create a list with the cell stats configs - report_config.nr_cc = MAX_NUM_CCs; - report_config.cc_report_type = (cc_report_type_t *) malloc(sizeof(cc_report_type_t) * report_config.nr_cc); - if (report_config.cc_report_type == NULL) { - // TODO: Add appropriate error code - err_code = -100; - goto error; - } - for (i = 0; i < report_config.nr_cc; i++) { - //TODO: Must fill in the proper cell ids - report_config.cc_report_type[i].cc_id = i; - report_config.cc_report_type[i].cc_report_flags = c_flags; - } - /* Check if request was periodical */ - if (comp_req->report_frequency == PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_PERIODICAL) { - /* Create a one off flexran message as an argument for the periodical task */ - Protocol__FlexranMessage *timer_msg; - stats_request_config_t request_config; - request_config.report_type = PROTOCOL__FLEX_STATS_TYPE__FLST_COMPLETE_STATS; - request_config.report_frequency = PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_ONCE; - request_config.period = 0; - /* Need to make sure that the ue flags are saved (Bug) */ - if (report_config.nr_ue == 0) { - report_config.nr_ue = 1; - report_config.ue_report_type = (ue_report_type_t *) malloc(sizeof(ue_report_type_t)); - if (report_config.ue_report_type == NULL) { - // TODO: Add appropriate error code - err_code = -100; - goto error; - } - report_config.ue_report_type[0].ue_rnti = 0; // Dummy value - report_config.ue_report_type[0].ue_report_flags = ue_flags; - } - request_config.config = &report_config; - flexran_agent_mac_stats_request(enb_id, xid, &request_config, &timer_msg); - /* Create a timer */ - long timer_id = 0; - flexran_agent_timer_args_t *timer_args; - timer_args = malloc(sizeof(flexran_agent_timer_args_t)); - memset (timer_args, 0, sizeof(flexran_agent_timer_args_t)); - timer_args->mod_id = enb_id; - timer_args->msg = timer_msg; - /*Convert subframes to usec time*/ - usec_interval = 1000*comp_req->sf; - sec_interval = 0; - /*add seconds if required*/ - if (usec_interval >= 1000*1000) { - sec_interval = usec_interval/(1000*1000); - usec_interval = usec_interval%(1000*1000); - } - flexran_agent_create_timer(sec_interval, usec_interval, FLEXRAN_AGENT_DEFAULT, enb_id, FLEXRAN_AGENT_TIMER_TYPE_PERIODIC, xid, flexran_agent_handle_timed_task,(void*) timer_args, &timer_id); - } else if (comp_req->report_frequency == PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_CONTINUOUS) { - /*If request was for continuous updates, disable the previous configuration and - set up a new one*/ - flexran_agent_disable_cont_mac_stats_update(mod_id); - stats_request_config_t request_config; - request_config.report_type = PROTOCOL__FLEX_STATS_TYPE__FLST_COMPLETE_STATS; - request_config.report_frequency = PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_ONCE; - request_config.period = 0; - /* Need to make sure that the ue flags are saved (Bug) */ - if (report_config.nr_ue == 0) { - report_config.nr_ue = 1; - report_config.ue_report_type = (ue_report_type_t *) malloc(sizeof(ue_report_type_t)); - if (report_config.ue_report_type == NULL) { - // TODO: Add appropriate error code - err_code = -100; - goto error; - } - report_config.ue_report_type[0].ue_rnti = 0; // Dummy value - report_config.ue_report_type[0].ue_report_flags = ue_flags; - } - request_config.config = &report_config; - flexran_agent_enable_cont_mac_stats_update(enb_id, xid, &request_config); - } - } - break; - case PROTOCOL__FLEX_STATS_REQUEST__BODY_CELL_STATS_REQUEST:; - Protocol__FlexCellStatsRequest *cell_req = stats_req->cell_stats_request; - // UE report config will be blank - report_config.nr_ue = 0; - report_config.ue_report_type = NULL; - report_config.nr_cc = cell_req->n_cell; - report_config.cc_report_type = (cc_report_type_t *) malloc(sizeof(cc_report_type_t) * report_config.nr_cc); - if (report_config.cc_report_type == NULL) { - // TODO: Add appropriate error code - err_code = -100; - goto error; - } - for (i = 0; i < report_config.nr_cc; i++) { - //TODO: Must fill in the proper cell ids - report_config.cc_report_type[i].cc_id = cell_req->cell[i]; - report_config.cc_report_type[i].cc_report_flags = cell_req->flags; - } - break; - case PROTOCOL__FLEX_STATS_REQUEST__BODY_UE_STATS_REQUEST:; - Protocol__FlexUeStatsRequest *ue_req = stats_req->ue_stats_request; - // Cell report config will be blank - report_config.nr_cc = 0; - report_config.cc_report_type = NULL; - report_config.nr_ue = ue_req->n_rnti; - report_config.ue_report_type = (ue_report_type_t *) malloc(sizeof(ue_report_type_t) * report_config.nr_ue); - if (report_config.ue_report_type == NULL) { - // TODO: Add appropriate error code - err_code = -100; - goto error; - } - for (i = 0; i < report_config.nr_ue; i++) { - report_config.ue_report_type[i].ue_rnti = ue_req->rnti[i]; - report_config.ue_report_type[i].ue_report_flags = ue_req->flags; - } - break; - default: - //TODO: Add appropriate error code - err_code = -100; - goto error; - } - - if (flexran_agent_mac_stats_reply(enb_id, xid, &report_config, msg) < 0 ){ - err_code = PROTOCOL__FLEXRAN_ERR__MSG_BUILD; - goto error; - } - - free(report_config.ue_report_type); - free(report_config.cc_report_type); - - return 0; - - error : - LOG_E(FLEXRAN_AGENT, "errno %d occured\n", err_code); - return err_code; -} - -int flexran_agent_mac_stats_request(mid_t mod_id, - xid_t xid, - const stats_request_config_t *report_config, - Protocol__FlexranMessage **msg) { - Protocol__FlexHeader *header; - int i; - - Protocol__FlexStatsRequest *stats_request_msg; - stats_request_msg = malloc(sizeof(Protocol__FlexStatsRequest)); - if(stats_request_msg == NULL) - goto error; - protocol__flex_stats_request__init(stats_request_msg); - - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REQUEST, &header) != 0) - goto error; - - stats_request_msg->header = header; - - stats_request_msg->type = report_config->report_type; - stats_request_msg->has_type = 1; - - switch (report_config->report_type) { - case PROTOCOL__FLEX_STATS_TYPE__FLST_COMPLETE_STATS: - stats_request_msg->body_case = PROTOCOL__FLEX_STATS_REQUEST__BODY_COMPLETE_STATS_REQUEST; - Protocol__FlexCompleteStatsRequest *complete_stats; - complete_stats = malloc(sizeof(Protocol__FlexCompleteStatsRequest)); - if(complete_stats == NULL) - goto error; - protocol__flex_complete_stats_request__init(complete_stats); - complete_stats->report_frequency = report_config->report_frequency; - complete_stats->has_report_frequency = 1; - complete_stats->sf = report_config->period; - complete_stats->has_sf = 1; - complete_stats->has_cell_report_flags = 1; - complete_stats->has_ue_report_flags = 1; - if (report_config->config->nr_cc > 0) { - complete_stats->cell_report_flags = report_config->config->cc_report_type[0].cc_report_flags; - } - if (report_config->config->nr_ue > 0) { - complete_stats->ue_report_flags = report_config->config->ue_report_type[0].ue_report_flags; - } - stats_request_msg->complete_stats_request = complete_stats; - break; - case PROTOCOL__FLEX_STATS_TYPE__FLST_CELL_STATS: - stats_request_msg->body_case = PROTOCOL__FLEX_STATS_REQUEST__BODY_CELL_STATS_REQUEST; - Protocol__FlexCellStatsRequest *cell_stats; - cell_stats = malloc(sizeof(Protocol__FlexCellStatsRequest)); - if(cell_stats == NULL) - goto error; - protocol__flex_cell_stats_request__init(cell_stats); - cell_stats->n_cell = report_config->config->nr_cc; - cell_stats->has_flags = 1; - if (cell_stats->n_cell > 0) { - uint32_t *cells; - cells = (uint32_t *) malloc(sizeof(uint32_t)*cell_stats->n_cell); - for (i = 0; i < cell_stats->n_cell; i++) { - cells[i] = report_config->config->cc_report_type[i].cc_id; - } - cell_stats->cell = cells; - cell_stats->flags = report_config->config->cc_report_type[i].cc_report_flags; - } - stats_request_msg->cell_stats_request = cell_stats; - break; - case PROTOCOL__FLEX_STATS_TYPE__FLST_UE_STATS: - stats_request_msg->body_case = PROTOCOL__FLEX_STATS_REQUEST__BODY_UE_STATS_REQUEST; - Protocol__FlexUeStatsRequest *ue_stats; - ue_stats = malloc(sizeof(Protocol__FlexUeStatsRequest)); - if(ue_stats == NULL) - goto error; - protocol__flex_ue_stats_request__init(ue_stats); - ue_stats->n_rnti = report_config->config->nr_ue; - ue_stats->has_flags = 1; - if (ue_stats->n_rnti > 0) { - uint32_t *ues; - ues = (uint32_t *) malloc(sizeof(uint32_t)*ue_stats->n_rnti); - for (i = 0; i < ue_stats->n_rnti; i++) { - ues[i] = report_config->config->ue_report_type[i].ue_rnti; - } - ue_stats->rnti = ues; - ue_stats->flags = report_config->config->ue_report_type[i].ue_report_flags; - } - stats_request_msg->ue_stats_request = ue_stats; - break; - default: - goto error; - } - *msg = malloc(sizeof(Protocol__FlexranMessage)); - if(*msg == NULL) - goto error; - protocol__flexran_message__init(*msg); - (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REQUEST_MSG; - (*msg)->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__INITIATING_MESSAGE; - (*msg)->stats_request_msg = stats_request_msg; - return 0; - - error: - // TODO: Need to make proper error handling - if (header != NULL) - free(header); - if (stats_request_msg != NULL) - free(stats_request_msg); - if(*msg != NULL) - free(*msg); - //LOG_E(MAC, "%s: an error occured\n", __FUNCTION__); - return -1; -} - -int flexran_agent_mac_destroy_stats_request(Protocol__FlexranMessage *msg) { - if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REQUEST_MSG) - goto error; - free(msg->stats_request_msg->header); - if (msg->stats_request_msg->body_case == PROTOCOL__FLEX_STATS_REQUEST__BODY_CELL_STATS_REQUEST) { - free(msg->stats_request_msg->cell_stats_request->cell); - } - if (msg->stats_request_msg->body_case == PROTOCOL__FLEX_STATS_REQUEST__BODY_UE_STATS_REQUEST) { - free(msg->stats_request_msg->ue_stats_request->rnti); - } - free(msg->stats_request_msg); - free(msg); - return 0; - - error: - //LOG_E(MAC, "%s: an error occured\n", __FUNCTION__); - return -1; -} - -int flexran_agent_mac_stats_reply(mid_t mod_id, - xid_t xid, - const report_config_t *report_config, - Protocol__FlexranMessage **msg) { - Protocol__FlexHeader *header; + // Protocol__FlexHeader *header; int i, j, k; + int cc_id = 0; int enb_id = mod_id; - //eNB_MAC_INST *eNB = &eNB_mac_inst[enb_id]; - //UE_list_t *eNB_UE_list= &eNB->UE_list; - - Protocol__FlexStatsReply *stats_reply_msg; - stats_reply_msg = malloc(sizeof(Protocol__FlexStatsReply)); - if (stats_reply_msg == NULL) - goto error; - protocol__flex_stats_reply__init(stats_reply_msg); - - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) - goto error; - - stats_reply_msg->header = header; - - stats_reply_msg->n_ue_report = report_config->nr_ue; - stats_reply_msg->n_cell_report = report_config->nr_cc; - - Protocol__FlexUeStatsReport **ue_report; - Protocol__FlexCellStatsReport **cell_report; - /* Allocate memory for list of UE reports */ if (report_config->nr_ue > 0) { - ue_report = malloc(sizeof(Protocol__FlexUeStatsReport *) * report_config->nr_ue); - if (ue_report == NULL) - goto error; - for (i = 0; i < report_config->nr_ue; i++) { - ue_report[i] = malloc(sizeof(Protocol__FlexUeStatsReport)); - protocol__flex_ue_stats_report__init(ue_report[i]); - ue_report[i]->rnti = report_config->ue_report_type[i].ue_rnti; - ue_report[i]->has_rnti = 1; - ue_report[i]->flags = report_config->ue_report_type[i].ue_report_flags; - ue_report[i]->has_flags = 1; - /* Check the types of reports that need to be constructed based on flag values */ - /* Check flag for creation of buffer status report */ - if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_BSR) { - ue_report[i]->n_bsr = 4; - uint32_t *elem; - elem = (uint32_t *) malloc(sizeof(uint32_t)*ue_report[i]->n_bsr); - if (elem == NULL) - goto error; - for (j = 0; j < ue_report[i]->n_bsr; j++) { - // NN: we need to know the cc_id here, consider the first one - elem[j] = flexran_get_ue_bsr (enb_id, i, j); - } - ue_report[i]->bsr = elem; - } + + for (i = 0; i < report_config->nr_ue; i++) { - /* Check flag for creation of PRH report */ - if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PRH) { - ue_report[i]->phr = flexran_get_ue_phr (enb_id, i); // eNB_UE_list->UE_template[UE_PCCID(enb_id,i)][i].phr_info; - ue_report[i]->has_phr = 1; - } - /* Check flag for creation of RLC buffer status report */ - if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_RLC_BS) { - ue_report[i]->n_rlc_report = 3; // Set this to the number of LCs for this UE. This needs to be generalized for for LCs - Protocol__FlexRlcBsr ** rlc_reports; - rlc_reports = malloc(sizeof(Protocol__FlexRlcBsr *) * ue_report[i]->n_rlc_report); - if (rlc_reports == NULL) - goto error; - // NN: see LAYER2/openair2_proc.c for rlc status - for (j = 0; j < ue_report[i]->n_rlc_report; j++) { - rlc_reports[j] = malloc(sizeof(Protocol__FlexRlcBsr)); - if (rlc_reports[j] == NULL) - goto error; - protocol__flex_rlc_bsr__init(rlc_reports[j]); - rlc_reports[j]->lc_id = j + 1; - rlc_reports[j]->has_lc_id = 1; - rlc_reports[j]->tx_queue_size = flexran_get_tx_queue_size(enb_id,i,j + 1); - rlc_reports[j]->has_tx_queue_size = 1; - - //TODO:Set tx queue head of line delay in ms - rlc_reports[j]->tx_queue_hol_delay = flexran_get_hol_delay(enb_id, i, j+1); - rlc_reports[j]->has_tx_queue_hol_delay = 1; - //TODO:Set retransmission queue size in bytes - rlc_reports[j]->retransmission_queue_size = 10; - rlc_reports[j]->has_retransmission_queue_size = 0; - //TODO:Set retransmission queue head of line delay in ms - rlc_reports[j]->retransmission_queue_hol_delay = 100; - rlc_reports[j]->has_retransmission_queue_hol_delay = 0; - //TODO:Set current size of the pending message in bytes - rlc_reports[j]->status_pdu_size = 100; - rlc_reports[j]->has_status_pdu_size = 0; - } - // Add RLC buffer status reports to the full report - if (ue_report[i]->n_rlc_report > 0) - ue_report[i]->rlc_report = rlc_reports; - } + /* Check flag for creation of buffer status report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_BSR) { + //TODO should be automated + ue_report[i]->n_bsr = 4; + uint32_t *elem; + elem = (uint32_t *) malloc(sizeof(uint32_t)*ue_report[i]->n_bsr); + if (elem == NULL) + goto error; + for (j = 0; j < ue_report[i]->n_bsr; j++) { + // NN: we need to know the cc_id here, consider the first one + elem[j] = flexran_get_ue_bsr (enb_id, i, j); + } + + ue_report[i]->bsr = elem; + } + + /* Check flag for creation of PHR report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PHR) { + ue_report[i]->phr = flexran_get_ue_phr (enb_id, i); // eNB_UE_list->UE_template[UE_PCCID(enb_id,i)][i].phr_info; + ue_report[i]->has_phr = 1; + + } - /* Check flag for creation of MAC CE buffer status report */ - if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_MAC_CE_BS) { - // TODO: Fill in the actual MAC CE buffer status report - ue_report[i]->pending_mac_ces = (flexran_get_MAC_CE_bitmap_TA(enb_id,i,0) | (0 << 1) | (0 << 2) | (0 << 3)) & 15; /* Use as bitmap. Set one or more of the - PROTOCOL__FLEX_CE_TYPE__FLPCET_ values - found in stats_common.pb-c.h. See - flex_ce_type in FlexRAN specification */ - ue_report[i]->has_pending_mac_ces = 1; - } + /* Check flag for creation of RLC buffer status report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_RLC_BS) { + ue_report[i]->n_rlc_report = 3; // Set this to the number of LCs for this UE. This needs to be generalized for for LCs + Protocol__FlexRlcBsr ** rlc_reports; + rlc_reports = malloc(sizeof(Protocol__FlexRlcBsr *) * ue_report[i]->n_rlc_report); + if (rlc_reports == NULL) + goto error; - /* Check flag for creation of DL CQI report */ - if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_DL_CQI) { - // TODO: Fill in the actual DL CQI report for the UE based on its configuration - Protocol__FlexDlCqiReport * dl_report; - dl_report = malloc(sizeof(Protocol__FlexDlCqiReport)); - if (dl_report == NULL) - goto error; - protocol__flex_dl_cqi_report__init(dl_report); + // NN: see LAYER2/openair2_proc.c for rlc status + for (j = 0; j < ue_report[i]->n_rlc_report; j++) { - dl_report->sfn_sn = flexran_get_sfn_sf(enb_id); - dl_report->has_sfn_sn = 1; - //Set the number of DL CQI reports for this UE. One for each CC - dl_report->n_csi_report = flexran_get_active_CC(enb_id,i); + rlc_reports[j] = malloc(sizeof(Protocol__FlexRlcBsr)); + if (rlc_reports[j] == NULL) + goto error; + protocol__flex_rlc_bsr__init(rlc_reports[j]); + rlc_reports[j]->lc_id = j+1; + rlc_reports[j]->has_lc_id = 1; + rlc_reports[j]->tx_queue_size = flexran_get_tx_queue_size(enb_id, i, j + 1, "bytes_buffer"); + rlc_reports[j]->has_tx_queue_size = 1; - //Create the actual CSI reports. - Protocol__FlexDlCsi **csi_reports; - csi_reports = malloc(sizeof(Protocol__FlexDlCsi *)*dl_report->n_csi_report); - if (csi_reports == NULL) - goto error; - for (j = 0; j < dl_report->n_csi_report; j++) { - csi_reports[j] = malloc(sizeof(Protocol__FlexDlCsi)); - if (csi_reports[j] == NULL) - goto error; - protocol__flex_dl_csi__init(csi_reports[j]); - //The servCellIndex for this report - csi_reports[j]->serv_cell_index = j; - csi_reports[j]->has_serv_cell_index = 1; - //The rank indicator value for this cc - csi_reports[j]->ri = flexran_get_current_RI(enb_id,i,j); - csi_reports[j]->has_ri = 1; - //TODO: the type of CSI report based on the configuration of the UE - //For now we only support type P10, which only needs a wideband value - //The full set of types can be found in stats_common.pb-c.h and - //in the FlexRAN specifications - csi_reports[j]->type = PROTOCOL__FLEX_CSI_TYPE__FLCSIT_P10; - csi_reports[j]->has_type = 1; - csi_reports[j]->report_case = PROTOCOL__FLEX_DL_CSI__REPORT_P10CSI; - if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_P10CSI){ - Protocol__FlexCsiP10 *csi10; - csi10 = malloc(sizeof(Protocol__FlexCsiP10)); - if (csi10 == NULL) - goto error; - protocol__flex_csi_p10__init(csi10); - //TODO: set the wideband value - // NN: this is also depends on cc_id - csi10->wb_cqi = flexran_get_ue_wcqi (enb_id, i); //eNB_UE_list->eNB_UE_stats[UE_PCCID(enb_id,i)][i].dl_cqi; - csi10->has_wb_cqi = 1; - //Add the type of measurements to the csi report in the proper union type - csi_reports[j]->p10csi = csi10; - } - else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_P11CSI){ + //TODO:Set tx queue head of line delay in ms + rlc_reports[j]->tx_queue_hol_delay = flexran_get_tx_queue_size(enb_id, i, j + 1, "head_line"); + rlc_reports[j]->has_tx_queue_hol_delay = 1; + //TODO:Set retransmission queue size in bytes + rlc_reports[j]->retransmission_queue_size = 10; + rlc_reports[j]->has_retransmission_queue_size = 0; + //TODO:Set retransmission queue head of line delay in ms + rlc_reports[j]->retransmission_queue_hol_delay = 100; + rlc_reports[j]->has_retransmission_queue_hol_delay = 0; + //TODO DONE:Set current size of the pending message in bytes + rlc_reports[j]->status_pdu_size = flexran_get_hol_delay(enb_id, i, j + 1); + rlc_reports[j]->has_status_pdu_size = 1; - } - else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_P20CSI){ + } + // Add RLC buffer status reports to the full report + if (ue_report[i]->n_rlc_report > 0) + ue_report[i]->rlc_report = rlc_reports; - } - else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_P21CSI){ + + } - } - else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A12CSI){ + /* Check flag for creation of MAC CE buffer status report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_MAC_CE_BS) { + // TODO: Fill in the actual MAC CE buffer status report + ue_report[i]->pending_mac_ces = (flexran_get_MAC_CE_bitmap_TA(enb_id,i,0) | (0 << 1) | (0 << 2) + | (0 << 3)) & 15; /* Use as bitmap. Set one or more of the; /* Use as bitmap. Set one or more of the + PROTOCOL__FLEX_CE_TYPE__FLPCET_ values + found in stats_common.pb-c.h. See + flex_ce_type in FlexRAN specification */ + ue_report[i]->has_pending_mac_ces = 1; + + } - } - else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A22CSI){ + /* Check flag for creation of DL CQI report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_DL_CQI) { + // TODO: Fill in the actual DL CQI report for the UE based on its configuration + Protocol__FlexDlCqiReport * dl_report; + dl_report = malloc(sizeof(Protocol__FlexDlCqiReport)); + if (dl_report == NULL) + goto error; + protocol__flex_dl_cqi_report__init(dl_report); - } - else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A20CSI){ + dl_report->sfn_sn = flexran_get_sfn_sf(enb_id); + dl_report->has_sfn_sn = 1; + //Set the number of DL CQI reports for this UE. One for each CC + dl_report->n_csi_report = flexran_get_active_CC(enb_id,i); + dl_report->n_csi_report = 1 ; + //Create the actual CSI reports. + Protocol__FlexDlCsi **csi_reports; + csi_reports = malloc(sizeof(Protocol__FlexDlCsi *)*dl_report->n_csi_report); + if (csi_reports == NULL) + goto error; + for (j = 0; j < dl_report->n_csi_report; j++) { - } - else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A30CSI){ + csi_reports[j] = malloc(sizeof(Protocol__FlexDlCsi)); + if (csi_reports[j] == NULL) + goto error; + protocol__flex_dl_csi__init(csi_reports[j]); + //The servCellIndex for this report + csi_reports[j]->serv_cell_index = j; + csi_reports[j]->has_serv_cell_index = 1; + //The rank indicator value for this cc + csi_reports[j]->ri = flexran_get_current_RI(enb_id,i,j); + csi_reports[j]->has_ri = 1; + //TODO: the type of CSI report based on the configuration of the UE + //For now we only support type P10, which only needs a wideband value + //The full set of types can be found in stats_common.pb-c.h and + //in the FlexRAN specifications + csi_reports[j]->type = PROTOCOL__FLEX_CSI_TYPE__FLCSIT_P10; + csi_reports[j]->has_type = 1; + csi_reports[j]->report_case = PROTOCOL__FLEX_DL_CSI__REPORT_P10CSI; - } - else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A31CSI){ + if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_P10CSI){ - } - } - //Add the csi reports to the full DL CQI report - dl_report->csi_report = csi_reports; - //Add the DL CQI report to the stats report - ue_report[i]->dl_cqi_report = dl_report; - } + Protocol__FlexCsiP10 *csi10; + csi10 = malloc(sizeof(Protocol__FlexCsiP10)); + if (csi10 == NULL) + goto error; + protocol__flex_csi_p10__init(csi10); + //TODO: set the wideband value + // NN: this is also depends on cc_id + csi10->wb_cqi = flexran_get_ue_wcqi (enb_id, i); //eNB_UE_list->eNB_UE_stats[UE_PCCID(enb_id,i)][i].dl_cqi; + csi10->has_wb_cqi = 1; + //Add the type of measurements to the csi report in the proper union type + csi_reports[j]->p10csi = csi10; + } - /* Check flag for creation of paging buffer status report */ - if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PBS) { - //TODO: Fill in the actual paging buffer status report. For this field to be valid, the RNTI - //set in the report must be a P-RNTI - Protocol__FlexPagingBufferReport *paging_report; - paging_report = malloc(sizeof(Protocol__FlexPagingBufferReport)); - if (paging_report == NULL) - goto error; - protocol__flex_paging_buffer_report__init(paging_report); - //Set the number of pending paging messages - paging_report->n_paging_info = 1; - //Provide a report for each pending paging message - Protocol__FlexPagingInfo **p_info; - p_info = malloc(sizeof(Protocol__FlexPagingInfo *) * paging_report->n_paging_info); - if (p_info == NULL) - goto error; - for (j = 0; j < paging_report->n_paging_info; j++) { - p_info[j] = malloc(sizeof(Protocol__FlexPagingInfo)); - if(p_info[j] == NULL) - goto error; - protocol__flex_paging_info__init(p_info[j]); - //TODO: Set paging index. This index is the same that will be used for the scheduling of the - //paging message by the controller - p_info[j]->paging_index = 10; - p_info[j]->has_paging_index = 0; - //TODO:Set the paging message size - p_info[j]->paging_message_size = 100; - p_info[j]->has_paging_message_size = 0; - //TODO: Set the paging subframe - p_info[j]->paging_subframe = 10; - p_info[j]->has_paging_subframe = 0; - //TODO: Set the carrier index for the pending paging message - p_info[j]->carrier_index = 0; - p_info[j]->has_carrier_index = 0; - } - //Add all paging info to the paging buffer rerport - paging_report->paging_info = p_info; - //Add the paging report to the UE report - ue_report[i]->pbr = paging_report; - } + else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_P11CSI){ - /* Check flag for creation of UL CQI report */ - if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_UL_CQI) { - //Fill in the full UL CQI report of the UE - Protocol__FlexUlCqiReport *full_ul_report; - full_ul_report = malloc(sizeof(Protocol__FlexUlCqiReport)); - if(full_ul_report == NULL) - goto error; - protocol__flex_ul_cqi_report__init(full_ul_report); - //TODO:Set the SFN and SF of the generated report - full_ul_report->sfn_sn = flexran_get_sfn_sf(enb_id); - full_ul_report->has_sfn_sn = 1; - //TODO:Set the number of UL measurement reports based on the types of measurements - //configured for this UE and on the servCellIndex - full_ul_report->n_cqi_meas = 1; - Protocol__FlexUlCqi **ul_report; - ul_report = malloc(sizeof(Protocol__FlexUlCqi *) * full_ul_report->n_cqi_meas); - if(ul_report == NULL) - goto error; - //Fill each UL report of the UE for each of the configured report types - for(j = 0; j < full_ul_report->n_cqi_meas; j++) { - ul_report[j] = malloc(sizeof(Protocol__FlexUlCqi)); - if(ul_report[j] == NULL) - goto error; - protocol__flex_ul_cqi__init(ul_report[j]); - //TODO: Set the type of the UL report. As an example set it to SRS UL report - // See enum flex_ul_cqi_type in FlexRAN specification for more details - ul_report[j]->type = PROTOCOL__FLEX_UL_CQI_TYPE__FLUCT_SRS; - ul_report[j]->has_type = 1; - //TODO:Set the number of SINR measurements based on the report type - //See struct flex_ul_cqi in FlexRAN specification for more details - ul_report[j]->n_sinr = 0; - uint32_t *sinr_meas; - sinr_meas = (uint32_t *) malloc(sizeof(uint32_t) * ul_report[j]->n_sinr); - if (sinr_meas == NULL) - goto error; - //TODO:Set the SINR measurements for the specified type - for (k = 0; k < ul_report[j]->n_sinr; k++) { - sinr_meas[k] = 10; - } - ul_report[j]->sinr = sinr_meas; - //TODO: Set the servCellIndex for this report - ul_report[j]->serv_cell_index = 0; - ul_report[j]->has_serv_cell_index = 1; - - //Set the list of UL reports of this UE to the full UL report - full_ul_report->cqi_meas = ul_report; - full_ul_report->n_pucch_dbm = MAX_NUM_CCs; - full_ul_report->pucch_dbm = malloc(sizeof(Protocol__FlexPucchDbm *) * full_ul_report->n_pucch_dbm); + Protocol__FlexCsiP11 *csi11; + csi11 = malloc(sizeof(Protocol__FlexCsiP11)); + if (csi11 == NULL) + goto error; + protocol__flex_csi_p11__init(csi11); + + csi11->wb_cqi = flexran_get_ue_wcqi (enb_id, i); + // According To spec 36.213 + + if (flexran_get_antenna_ports(enb_id, j) == 2 && csi_reports[j]->ri == 1) { + // TODO PMI + csi11->wb_pmi = flexran_get_ue_pmi(enb_id); + csi11->has_wb_pmi = 1; - for (j = 0; j < MAX_NUM_CCs; j++) { - full_ul_report->pucch_dbm[j] = malloc(sizeof(Protocol__FlexPucchDbm)); - protocol__flex_pucch_dbm__init(full_ul_report->pucch_dbm[j]); - full_ul_report->pucch_dbm[j]->has_serv_cell_index = 1; - full_ul_report->pucch_dbm[j]->serv_cell_index = j; - if(flexran_get_p0_pucch_dbm(enb_id,i, j) != -1){ - full_ul_report->pucch_dbm[j]->p0_pucch_dbm = flexran_get_p0_pucch_dbm(enb_id,i,j); - full_ul_report->pucch_dbm[j]->has_p0_pucch_dbm = 1; - } - full_ul_report->pucch_dbm[j]->has_p0_pucch_updated = 1; - full_ul_report->pucch_dbm[j]->p0_pucch_updated = flexran_get_p0_pucch_status(enb_id, i, j); - } + } - //Add full UL CQI report to the UE report - ue_report[i]->ul_cqi_report = full_ul_report; - } - } - } - /* Add list of all UE reports to the message */ - stats_reply_msg->ue_report = ue_report; - } + else if (flexran_get_antenna_ports(enb_id, j) == 2 && csi_reports[j]->ri == 2){ + // TODO PMI + csi11->wb_pmi = flexran_get_ue_pmi(enb_id); + csi11->has_wb_pmi = 1; + + } + + else if (flexran_get_antenna_ports(enb_id, j) == 4 && csi_reports[j]->ri == 2){ + // TODO PMI + csi11->wb_pmi = flexran_get_ue_pmi(enb_id); + csi11->has_wb_pmi = 1; + + + } + + csi11->has_wb_pmi = 0; + + csi_reports[j]->p11csi = csi11; + + } + + + + + + else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_P20CSI){ + + Protocol__FlexCsiP20 *csi20; + csi20 = malloc(sizeof(Protocol__FlexCsiP20)); + if (csi20 == NULL) + goto error; + protocol__flex_csi_p20__init(csi20); + + csi20->wb_cqi = flexran_get_ue_wcqi (enb_id, i); + csi20->has_wb_cqi = 1; + + + csi20->bandwidth_part_index = 1 ;//TODO + csi20->has_bandwidth_part_index = 1; + + csi20->sb_index = 1 ;//TODO + csi20->has_sb_index = 1 ; + + + csi_reports[j]->p20csi = csi20; + + + } + + else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_P21CSI){ + + // Protocol__FlexCsiP21 *csi21; + // csi21 = malloc(sizeof(Protocol__FlexCsiP21)); + // if (csi21 == NULL) + // goto error; + // protocol__flex_csi_p21__init(csi21); + + // csi21->wb_cqi = flexran_get_ue_wcqi (enb_id, i); + + + // csi21->wb_pmi = flexran_get_ue_pmi(enb_id); //TDO inside + // csi21->has_wb_pmi = 1; + + // csi21->sb_cqi = 1; // TODO + + // csi21->bandwidth_part_index = 1 ; //TDO inside + // csi21->has_bandwidth_part_index = 1 ; + + // csi21->sb_index = 1 ;//TODO + // csi21->has_sb_index = 1 ; + + + // csi_reports[j]->p20csi = csi21; + + } + + else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A12CSI){ + + + // Protocol__FlexCsiA12 *csi12; + // csi12 = malloc(sizeof(Protocol__FlexCsiA12)); + // if (csi12 == NULL) + // goto error; + // protocol__flex_csi_a12__init(csi12); + + // csi12->wb_cqi = flexran_get_ue_wcqi (enb_id, i); + + // csi12->sb_pmi = 1 ; //TODO inside + + // TODO continou + } + + else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A22CSI){ + + // Protocol__FlexCsiA22 *csi22; + // csi22 = malloc(sizeof(Protocol__FlexCsiA22)); + // if (csi22 == NULL) + // goto error; + // protocol__flex_csi_a22__init(csi22); + + // csi22->wb_cqi = flexran_get_ue_wcqi (enb_id, i); + + // csi22->sb_cqi = 1 ; //TODO inside + + // csi22->wb_pmi = flexran_get_ue_wcqi (enb_id, i); + // csi22->has_wb_pmi = 1; + + // csi22->sb_pmi = 1 ; //TODO inside + // csi22->has_wb_pmi = 1; + + // csi22->sb_list = flexran_get_ue_wcqi (enb_id, i); + + + } + + else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A20CSI){ + + // Protocol__FlexCsiA20 *csi20; + // csi20 = malloc(sizeof(Protocol__FlexCsiA20)); + // if (csi20 == NULL) + // goto error; + // protocol__flex_csi_a20__init(csi20); + + // csi20->wb_cqi = flexran_get_ue_wcqi (enb_id, i); + // csi20->has_wb_cqi = 1; + + // csi20>sb_cqi = 1 ; //TODO inside + // csi20>has_sb_cqi = 1 ; + + // csi20->sb_list = 1; // TODO inside + + + } + + else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A30CSI){ + + } + + else if(csi_reports[j]->report_case == PROTOCOL__FLEX_DL_CSI__REPORT_A31CSI){ + + } + + } + //Add the csi reports to the full DL CQI report + dl_report->csi_report = csi_reports; + //Add the DL CQI report to the stats report + ue_report[i]->dl_cqi_report = dl_report; + + } + + /* Check flag for creation of paging buffer status report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PBS) { + //TODO: Fill in the actual paging buffer status report. For this field to be valid, the RNTI + //set in the report must be a P-RNTI + Protocol__FlexPagingBufferReport *paging_report; + paging_report = malloc(sizeof(Protocol__FlexPagingBufferReport)); + if (paging_report == NULL) + goto error; + protocol__flex_paging_buffer_report__init(paging_report); + //Set the number of pending paging messages + paging_report->n_paging_info = 1; + //Provide a report for each pending paging message + Protocol__FlexPagingInfo **p_info; + p_info = malloc(sizeof(Protocol__FlexPagingInfo *) * paging_report->n_paging_info); + if (p_info == NULL) + goto error; + + for (j = 0; j < paging_report->n_paging_info; j++) { + + p_info[j] = malloc(sizeof(Protocol__FlexPagingInfo)); + if(p_info[j] == NULL) + goto error; + protocol__flex_paging_info__init(p_info[j]); + //TODO: Set paging index. This index is the same that will be used for the scheduling of the + //paging message by the controller + p_info[j]->paging_index = 10; + p_info[j]->has_paging_index = 1; + //TODO:Set the paging message size + p_info[j]->paging_message_size = 100; + p_info[j]->has_paging_message_size = 1; + //TODO: Set the paging subframe + p_info[j]->paging_subframe = 10; + p_info[j]->has_paging_subframe = 1; + //TODO: Set the carrier index for the pending paging message + p_info[j]->carrier_index = 0; + p_info[j]->has_carrier_index = 1; + + } + //Add all paging info to the paging buffer rerport + paging_report->paging_info = p_info; + //Add the paging report to the UE report + ue_report[i]->pbr = paging_report; + } + + /* Check flag for creation of UL CQI report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_UL_CQI) { + + //Fill in the full UL CQI report of the UE + Protocol__FlexUlCqiReport *full_ul_report; + full_ul_report = malloc(sizeof(Protocol__FlexUlCqiReport)); + if(full_ul_report == NULL) + goto error; + protocol__flex_ul_cqi_report__init(full_ul_report); + //TODO:Set the SFN and SF of the generated report + full_ul_report->sfn_sn = flexran_get_sfn_sf(enb_id); + full_ul_report->has_sfn_sn = 1; + //TODO:Set the number of UL measurement reports based on the types of measurements + //configured for this UE and on the servCellIndex + full_ul_report->n_cqi_meas = 1; + Protocol__FlexUlCqi **ul_report; + ul_report = malloc(sizeof(Protocol__FlexUlCqi *) * full_ul_report->n_cqi_meas); + if(ul_report == NULL) + goto error; + //Fill each UL report of the UE for each of the configured report types + for(j = 0; j < full_ul_report->n_cqi_meas; j++) { + + ul_report[j] = malloc(sizeof(Protocol__FlexUlCqi)); + if(ul_report[j] == NULL) + goto error; + protocol__flex_ul_cqi__init(ul_report[j]); + //TODO: Set the type of the UL report. As an example set it to SRS UL report + // See enum flex_ul_cqi_type in FlexRAN specification for more details + ul_report[j]->type = PROTOCOL__FLEX_UL_CQI_TYPE__FLUCT_SRS; + ul_report[j]->has_type = 1; + //TODO:Set the number of SINR measurements based on the report type + //See struct flex_ul_cqi in FlexRAN specification for more details + ul_report[j]->n_sinr = 0; + uint32_t *sinr_meas; + sinr_meas = (uint32_t *) malloc(sizeof(uint32_t) * ul_report[j]->n_sinr); + if (sinr_meas == NULL) + goto error; + //TODO:Set the SINR measurements for the specified type + for (k = 0; k < ul_report[j]->n_sinr; k++) { + sinr_meas[k] = 10; + } + ul_report[j]->sinr = sinr_meas; + //TODO: Set the servCellIndex for this report + ul_report[j]->serv_cell_index = 0; + ul_report[j]->has_serv_cell_index = 1; + + //Set the list of UL reports of this UE to the full UL report + full_ul_report->cqi_meas = ul_report; + + full_ul_report->n_pucch_dbm = MAX_NUM_CCs; + full_ul_report->pucch_dbm = malloc(sizeof(Protocol__FlexPucchDbm *) * full_ul_report->n_pucch_dbm); + + for (j = 0; j < MAX_NUM_CCs; j++) { + + full_ul_report->pucch_dbm[j] = malloc(sizeof(Protocol__FlexPucchDbm)); + protocol__flex_pucch_dbm__init(full_ul_report->pucch_dbm[j]); + full_ul_report->pucch_dbm[j]->has_serv_cell_index = 1; + full_ul_report->pucch_dbm[j]->serv_cell_index = j; + + if(flexran_get_p0_pucch_dbm(enb_id,i, j) != -1){ + full_ul_report->pucch_dbm[j]->p0_pucch_dbm = flexran_get_p0_pucch_dbm(enb_id,i,j); + full_ul_report->pucch_dbm[j]->has_p0_pucch_dbm = 1; + } + } + + + } + // Add full UL CQI report to the UE report + ue_report[i]->ul_cqi_report = full_ul_report; + + + } + + + + + } + + + + + } /* Allocate memory for list of cell reports */ if (report_config->nr_cc > 0) { - cell_report = malloc(sizeof(Protocol__FlexCellStatsReport *) * report_config->nr_cc); - if (cell_report == NULL) - goto error; - // Fill in the Cell reports - for (i = 0; i < report_config->nr_cc; i++) { - cell_report[i] = malloc(sizeof(Protocol__FlexCellStatsReport)); - if(cell_report[i] == NULL) - goto error; - protocol__flex_cell_stats_report__init(cell_report[i]); - cell_report[i]->carrier_index = report_config->cc_report_type[i].cc_id; - cell_report[i]->has_carrier_index = 1; - cell_report[i]->flags = report_config->cc_report_type[i].cc_report_flags; - cell_report[i]->has_flags = 1; + + + // Fill in the Cell reports + for (i = 0; i < report_config->nr_cc; i++) { - /* Check flag for creation of noise and interference report */ - if(report_config->cc_report_type[i].cc_report_flags & PROTOCOL__FLEX_CELL_STATS_TYPE__FLCST_NOISE_INTERFERENCE) { - // TODO: Fill in the actual noise and interference report for this cell - Protocol__FlexNoiseInterferenceReport *ni_report; - ni_report = malloc(sizeof(Protocol__FlexNoiseInterferenceReport)); - if(ni_report == NULL) - goto error; - protocol__flex_noise_interference_report__init(ni_report); - // Current frame and subframe number - ni_report->sfn_sf = flexran_get_sfn_sf(enb_id); - ni_report->has_sfn_sf = 1; - //TODO:Received interference power in dbm - ni_report->rip = 0; - ni_report->has_rip = 0; - //TODO:Thermal noise power in dbm - ni_report->tnp = 0; - ni_report->has_tnp = 0; - ni_report->p0_nominal_pucch = flexran_get_p0_nominal_pucch(enb_id, 0); - ni_report->has_p0_nominal_pucch = 1; - cell_report[i]->noise_inter_report = ni_report; - } - } - /* Add list of all cell reports to the message */ - stats_reply_msg->cell_report = cell_report; + /* Check flag for creation of noise and interference report */ + if(report_config->cc_report_type[i].cc_report_flags & PROTOCOL__FLEX_CELL_STATS_TYPE__FLCST_NOISE_INTERFERENCE) { + // TODO: Fill in the actual noise and interference report for this cell + Protocol__FlexNoiseInterferenceReport *ni_report; + ni_report = malloc(sizeof(Protocol__FlexNoiseInterferenceReport)); + if(ni_report == NULL) + goto error; + protocol__flex_noise_interference_report__init(ni_report); + // Current frame and subframe number + ni_report->sfn_sf = flexran_get_sfn_sf(enb_id); + ni_report->has_sfn_sf = 1; + //TODO:Received interference power in dbm + ni_report->rip = 0; + ni_report->has_rip = 1; + //TODO:Thermal noise power in dbm + ni_report->tnp = 0; + ni_report->has_tnp = 1; + + ni_report->p0_nominal_pucch = flexran_get_p0_nominal_pucch(enb_id, 0); + ni_report->has_p0_nominal_pucch = 1; + cell_report[i]->noise_inter_report = ni_report; + } + } + + + + } - *msg = malloc(sizeof(Protocol__FlexranMessage)); - if(*msg == NULL) - goto error; - protocol__flexran_message__init(*msg); - (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG; - (*msg)->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__SUCCESSFUL_OUTCOME; - (*msg)->stats_reply_msg = stats_reply_msg; return 0; error: - // TODO: Need to make proper error handling - if (header != NULL) - free(header); - if (stats_reply_msg != NULL) - free(stats_reply_msg); - if(*msg != NULL) - free(*msg); - //LOG_E(MAC, "%s: an error occured\n", __FUNCTION__); + + if (cell_report != NULL) + free(cell_report); + if (ue_report != NULL) + free(ue_report); + return -1; } @@ -1346,58 +1161,7 @@ void flexran_agent_send_sf_trigger(mid_t mod_id) { LOG_D(FLEXRAN_AGENT, "Could not send sf trigger message\n"); } -void flexran_agent_send_update_mac_stats(mid_t mod_id) { - Protocol__FlexranMessage *current_report = NULL; - void *data; - int size; - err_code_t err_code; - int priority = 0; - - if (pthread_mutex_lock(mac_stats_context[mod_id].mutex)) { - goto error; - } - - if (mac_stats_context[mod_id].cont_update == 1) { - - /*Create a fresh report with the required flags*/ - err_code = flexran_agent_mac_handle_stats(mod_id, (void *) mac_stats_context[mod_id].stats_req, ¤t_report); - if (err_code < 0) { - goto error; - } - } - /* /\*TODO:Check if a previous reports exists and if yes, generate a report */ - /* *that is the diff between the old and the new report, */ - /* *respecting the thresholds. Otherwise send the new report*\/ */ - /* if (mac_stats_context[mod_id].prev_stats_reply != NULL) { */ - - /* msg = flexran_agent_generate_diff_mac_stats_report(current_report, mac_stats_context[mod_id].prev_stats_reply); */ - - /* /\*Destroy the old stats*\/ */ - /* flexran_agent_destroy_flexran_message(mac_stats_context[mod_id].prev_stats_reply); */ - /* } */ - /* /\*Use the current report for future comparissons*\/ */ - /* mac_stats_context[mod_id].prev_stats_reply = current_report; */ - - - if (pthread_mutex_unlock(mac_stats_context[mod_id].mutex)) { - goto error; - } - - if (current_report != NULL){ - data=flexran_agent_pack_message(current_report, &size); - /*Send any stats updates using the MAC channel of the eNB*/ - if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_MAC, data, size, priority)) { - err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; - goto error; - } - - LOG_D(FLEXRAN_AGENT,"sent message with size %d\n", size); - return; - } - error: - LOG_D(FLEXRAN_AGENT, "Could not send sf trigger message\n"); -} int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { if (mac_agent_registered[mod_id]) { @@ -1408,11 +1172,10 @@ int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { //xface->agent_ctxt = &shared_ctxt[mod_id]; xface->flexran_agent_send_sr_info = flexran_agent_send_sr_info; xface->flexran_agent_send_sf_trigger = flexran_agent_send_sf_trigger; - xface->flexran_agent_send_update_mac_stats = flexran_agent_send_update_mac_stats; + //xface->flexran_agent_send_update_mac_stats = flexran_agent_send_update_mac_stats; xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_default; //xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_remote; xface->flexran_agent_get_pending_dl_mac_config = flexran_agent_get_pending_dl_mac_config; - xface->flexran_agent_notify_ue_state_change = flexran_agent_ue_state_change; xface->dl_scheduler_loaded_lib = NULL; @@ -1427,10 +1190,10 @@ int flexran_agent_unregister_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { //xface->agent_ctxt = NULL; xface->flexran_agent_send_sr_info = NULL; xface->flexran_agent_send_sf_trigger = NULL; - xface->flexran_agent_send_update_mac_stats = NULL; + //xface->flexran_agent_send_update_mac_stats = NULL; xface->flexran_agent_schedule_ue_spec = NULL; xface->flexran_agent_get_pending_dl_mac_config = NULL; - xface->flexran_agent_notify_ue_state_change = NULL; + xface->dl_scheduler_loaded_lib = NULL; @@ -1441,89 +1204,7 @@ int flexran_agent_unregister_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { } -/****************************************************** - *Implementations of flexran_agent_mac_internal.h functions - ******************************************************/ - -err_code_t flexran_agent_init_cont_mac_stats_update(mid_t mod_id) { - - /*Initialize the Mac stats update structure*/ - /*Initially the continuous update is set to false*/ - mac_stats_context[mod_id].cont_update = 0; - mac_stats_context[mod_id].is_initialized = 1; - mac_stats_context[mod_id].stats_req = NULL; - mac_stats_context[mod_id].prev_stats_reply = NULL; - mac_stats_context[mod_id].mutex = calloc(1, sizeof(pthread_mutex_t)); - if (mac_stats_context[mod_id].mutex == NULL) - goto error; - if (pthread_mutex_init(mac_stats_context[mod_id].mutex, NULL)) - goto error;; - - return 0; - - error: - return -1; -} - -err_code_t flexran_agent_destroy_cont_mac_stats_update(mid_t mod_id) { - /*Disable the continuous updates for the MAC*/ - mac_stats_context[mod_id].cont_update = 0; - mac_stats_context[mod_id].is_initialized = 0; - flexran_agent_destroy_flexran_message(mac_stats_context[mod_id].stats_req); - flexran_agent_destroy_flexran_message(mac_stats_context[mod_id].prev_stats_reply); - free(mac_stats_context[mod_id].mutex); - - mac_agent_registered[mod_id] = 0; - return 1; -} -err_code_t flexran_agent_enable_cont_mac_stats_update(mid_t mod_id, - xid_t xid, stats_request_config_t *stats_req) { - /*Enable the continuous updates for the MAC*/ - if (pthread_mutex_lock(mac_stats_context[mod_id].mutex)) { - goto error; - } - Protocol__FlexranMessage *req_msg; - flexran_agent_mac_stats_request(mod_id, xid, stats_req, &req_msg); - mac_stats_context[mod_id].stats_req = req_msg; - mac_stats_context[mod_id].prev_stats_reply = NULL; - - mac_stats_context[mod_id].cont_update = 1; - mac_stats_context[mod_id].xid = xid; - - if (pthread_mutex_unlock(mac_stats_context[mod_id].mutex)) { - goto error; - } - return 0; - - error: - LOG_E(FLEXRAN_AGENT, "mac_stats_context for eNB %d is not initialized\n", mod_id); - return -1; -} - -err_code_t flexran_agent_disable_cont_mac_stats_update(mid_t mod_id) { - /*Disable the continuous updates for the MAC*/ - if (pthread_mutex_lock(mac_stats_context[mod_id].mutex)) { - goto error; - } - mac_stats_context[mod_id].cont_update = 0; - mac_stats_context[mod_id].xid = 0; - if (mac_stats_context[mod_id].stats_req != NULL) { - flexran_agent_destroy_flexran_message(mac_stats_context[mod_id].stats_req); - } - if (mac_stats_context[mod_id].prev_stats_reply != NULL) { - flexran_agent_destroy_flexran_message(mac_stats_context[mod_id].prev_stats_reply); - } - if (pthread_mutex_unlock(mac_stats_context[mod_id].mutex)) { - goto error; - } - return 0; - - error: - LOG_E(FLEXRAN_AGENT, "mac_stats_context for eNB %d is not initialized\n", mod_id); - return -1; - -} diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.h index e2378e9311..d2db860ce4 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.h @@ -37,50 +37,10 @@ #include "flexran_agent_common.h" #include "flexran_agent_extern.h" -/* These types will be used to give - instructions for the type of stats reports - we need to create */ -typedef struct { - uint16_t ue_rnti; - uint32_t ue_report_flags; /* Indicates the report elements - required for this UE id. See - FlexRAN specification 1.2.4.2 */ -} ue_report_type_t; - -typedef struct { - uint16_t cc_id; - uint32_t cc_report_flags; /* Indicates the report elements - required for this CC index. See - FlexRAN specification 1.2.4.3 */ -} cc_report_type_t; - -typedef struct { - int nr_ue; - ue_report_type_t *ue_report_type; - int nr_cc; - cc_report_type_t *cc_report_type; -} report_config_t; - -typedef struct stats_request_config_s{ - uint8_t report_type; - uint8_t report_frequency; - uint16_t period; /*In number of subframes*/ - report_config_t *config; -} stats_request_config_t; /* Initialization function for the agent structures etc */ void flexran_agent_init_mac_agent(mid_t mod_id); -int flexran_agent_mac_handle_stats(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg); - -/* Statistics request protocol message constructor and destructor */ -int flexran_agent_mac_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg); -int flexran_agent_mac_destroy_stats_request(Protocol__FlexranMessage *msg); - -/* Statistics reply protocol message constructor and destructor */ -int flexran_agent_mac_stats_reply(mid_t mod_id, xid_t xid, const report_config_t *report_config, Protocol__FlexranMessage **msg); -int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg); - /* Scheduling request information protocol message constructor and estructor */ int flexran_agent_mac_sr_info(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg); int flexran_agent_mac_destroy_sr_info(Protocol__FlexranMessage *msg); @@ -89,6 +49,10 @@ int flexran_agent_mac_destroy_sr_info(Protocol__FlexranMessage *msg); int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg); int flexran_agent_mac_destroy_sf_trigger(Protocol__FlexranMessage *msg); +/* Statistics reply protocol message constructor and destructor */ +int flexran_agent_mac_stats_reply(mid_t mod_id, const report_config_t *report_config, Protocol__FlexUeStatsReport **ue_report, Protocol__FlexCellStatsReport **cell_report); +int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg); + /* DL MAC scheduling decision protocol message constructor (empty command) and destructor */ int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMessage **msg); int flexran_agent_mac_destroy_dl_config(Protocol__FlexranMessage *msg); diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index 1fa9852487..66efafae55 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -180,10 +180,12 @@ Protocol__FlexUeStatsReport * copy_ue_stats_report(Protocol__FlexUeStatsReport * } } - if (copy->flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PRH) { - copy->has_phr = original->has_phr; - copy->phr = original->phr; - } + + + if (copy->flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PHR) { + copy->has_phr = original->has_phr; + copy->phr = original->phr; + } if (copy->flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_RLC_BS) { copy->n_rlc_report = original->n_rlc_report; diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c new file mode 100644 index 0000000000..9475b06643 --- /dev/null +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -0,0 +1,662 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file flexran_agent_mac.c + * \brief FlexRAN agent Control Module RRC + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + */ + +#include "flexran_agent_rrc.h" + + +#include "liblfds700.h" + +#include "log.h" + + +/*Flags showing if a rrc agent has already been registered*/ +unsigned int rrc_agent_registered[NUM_MAX_ENB]; + +/*Array containing the Agent-RRC interfaces*/ +AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]; + +/* Ringbuffer related structs used for maintaining the dl rrc config messages */ +//message_queue_t *rrc_dl_config_queue; +struct lfds700_misc_prng_state rrc_ps[NUM_MAX_ENB]; +struct lfds700_ringbuffer_element *rrc_dl_config_array[NUM_MAX_ENB]; +struct lfds700_ringbuffer_state rrc_ringbuffer_state[NUM_MAX_ENB]; + + + +void flexran_agent_init_rrc_agent(mid_t mod_id) { + lfds700_misc_library_init_valid_on_current_logical_core(); + lfds700_misc_prng_init(&rrc_ps[mod_id]); + int num_elements = RINGBUFFER_SIZE + 1; + //Allow RINGBUFFER_SIZE messages to be stored in the ringbuffer at any time + rrc_dl_config_array[mod_id] = malloc( sizeof(struct lfds700_ringbuffer_element) * num_elements); + lfds700_ringbuffer_init_valid_on_current_logical_core( &rrc_ringbuffer_state[mod_id], rrc_dl_config_array[mod_id], num_elements, &rrc_ps[mod_id], NULL ); +} + + + + + +int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) { + int size; + Protocol__FlexranMessage *msg; + Protocol__FlexHeader *header; + void *data; + int priority; + err_code_t err_code; + + int xid = 0; + + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_UE_STATE_CHANGE, &header) != 0) + goto error; + + Protocol__FlexUeStateChange *ue_state_change_msg; + ue_state_change_msg = malloc(sizeof(Protocol__FlexUeStateChange)); + if(ue_state_change_msg == NULL) { + goto error; + } + protocol__flex_ue_state_change__init(ue_state_change_msg); + ue_state_change_msg->has_type = 1; + ue_state_change_msg->type = state_change; + + Protocol__FlexUeConfig *config; + config = malloc(sizeof(Protocol__FlexUeConfig)); + if (config == NULL) { + goto error; + } + protocol__flex_ue_config__init(config); + if (state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED) { + // Simply set the rnti of the UE + config->has_rnti = 1; + config->rnti = rnti; + } else if (state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED + || state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED) { + int i = find_UE_id(mod_id, rnti); + config->has_rnti = 1; + config->rnti = rnti; + if(flexran_get_time_alignment_timer(mod_id,i) != -1) { + config->time_alignment_timer = flexran_get_time_alignment_timer(mod_id,i); + config->has_time_alignment_timer = 1; + } + if(flexran_get_meas_gap_config(mod_id,i) != -1){ + config->meas_gap_config_pattern = flexran_get_meas_gap_config(mod_id,i); + config->has_meas_gap_config_pattern = 1; + } + if(config->has_meas_gap_config_pattern == 1 && + config->meas_gap_config_pattern != PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF) { + config->meas_gap_config_sf_offset = flexran_get_meas_gap_config_offset(mod_id,i); + config->has_meas_gap_config_sf_offset = 1; + } + //TODO: Set the SPS configuration (Optional) + //Not supported for now, so we do not set it + + //TODO: Set the SR configuration (Optional) + //We do not set it for now + + //TODO: Set the CQI configuration (Optional) + //We do not set it for now + + if(flexran_get_ue_transmission_mode(mod_id,i) != -1) { + config->transmission_mode = flexran_get_ue_transmission_mode(mod_id,i); + config->has_transmission_mode = 1; + } + + config->ue_aggregated_max_bitrate_ul = flexran_get_ue_aggregated_max_bitrate_ul(mod_id,i); + config->has_ue_aggregated_max_bitrate_ul = 1; + + config->ue_aggregated_max_bitrate_dl = flexran_get_ue_aggregated_max_bitrate_dl(mod_id,i); + config->has_ue_aggregated_max_bitrate_dl = 1; + + //TODO: Set the UE capabilities + Protocol__FlexUeCapabilities *c_capabilities; + c_capabilities = malloc(sizeof(Protocol__FlexUeCapabilities)); + protocol__flex_ue_capabilities__init(c_capabilities); + //TODO: Set half duplex (FDD operation) + c_capabilities->has_half_duplex = 0; + c_capabilities->half_duplex = 1;//flexran_get_half_duplex(i); + //TODO: Set intra-frame hopping flag + c_capabilities->has_intra_sf_hopping = 0; + c_capabilities->intra_sf_hopping = 1;//flexran_get_intra_sf_hopping(i); + //TODO: Set support for type 2 hopping with n_sb > 1 + c_capabilities->has_type2_sb_1 = 0; + c_capabilities->type2_sb_1 = 1;//flexran_get_type2_sb_1(i); + //TODO: Set ue category + c_capabilities->has_ue_category = 0; + c_capabilities->ue_category = 1;//flexran_get_ue_category(i); + //TODO: Set UE support for resource allocation type 1 + c_capabilities->has_res_alloc_type1 = 0; + c_capabilities->res_alloc_type1 = 1;//flexran_get_res_alloc_type1(i); + //Set the capabilites to the message + config->capabilities = c_capabilities; + + if(flexran_get_ue_transmission_antenna(mod_id,i) != -1) { + config->has_ue_transmission_antenna = 1; + config->ue_transmission_antenna = flexran_get_ue_transmission_antenna(mod_id,i); + } + + if(flexran_get_tti_bundling(mod_id,i) != -1) { + config->has_tti_bundling = 1; + config->tti_bundling = flexran_get_tti_bundling(mod_id,i); + } + + if(flexran_get_maxHARQ_TX(mod_id,i) != -1){ + config->has_max_harq_tx = 1; + config->max_harq_tx = flexran_get_maxHARQ_TX(mod_id,i); + } + + if(flexran_get_beta_offset_ack_index(mod_id,i) != -1) { + config->has_beta_offset_ack_index = 1; + config->beta_offset_ack_index = flexran_get_beta_offset_ack_index(mod_id,i); + } + + if(flexran_get_beta_offset_ri_index(mod_id,i) != -1) { + config->has_beta_offset_ri_index = 1; + config->beta_offset_ri_index = flexran_get_beta_offset_ri_index(mod_id,i); + } + + if(flexran_get_beta_offset_cqi_index(mod_id,i) != -1) { + config->has_beta_offset_cqi_index = 1; + config->beta_offset_cqi_index = flexran_get_beta_offset_cqi_index(mod_id,i); + } + + if(flexran_get_ack_nack_simultaneous_trans(mod_id,i) != -1) { + config->has_ack_nack_simultaneous_trans = 1; + config->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id,i); + } + + if(flexran_get_simultaneous_ack_nack_cqi(mod_id,i) != -1) { + config->has_simultaneous_ack_nack_cqi = 1; + config->simultaneous_ack_nack_cqi = flexran_get_simultaneous_ack_nack_cqi(mod_id,i); + } + + if(flexran_get_aperiodic_cqi_rep_mode(mod_id,i) != -1) { + config->has_aperiodic_cqi_rep_mode = 1; + int mode = flexran_get_aperiodic_cqi_rep_mode(mod_id,i); + if (mode > 4) { + config->aperiodic_cqi_rep_mode = PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_NONE; + } else { + config->aperiodic_cqi_rep_mode = mode; + } + } + + if(flexran_get_tdd_ack_nack_feedback(mod_id, i) != -1) { + config->has_tdd_ack_nack_feedback = 1; + config->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback(mod_id,i); + } + + if(flexran_get_ack_nack_repetition_factor(mod_id, i) != -1) { + config->has_ack_nack_repetition_factor = 1; + config->ack_nack_repetition_factor = flexran_get_ack_nack_repetition_factor(mod_id,i); + } + + if(flexran_get_extended_bsr_size(mod_id, i) != -1) { + config->has_extended_bsr_size = 1; + config->extended_bsr_size = flexran_get_extended_bsr_size(mod_id,i); + } + + config->has_pcell_carrier_index = 1; + config->pcell_carrier_index = UE_PCCID(mod_id, i); + //TODO: Set carrier aggregation support (boolean) + config->has_ca_support = 0; + config->ca_support = 0; + if(config->has_ca_support){ + //TODO: Set cross carrier scheduling support (boolean) + config->has_cross_carrier_sched_support = 1; + config->cross_carrier_sched_support = 0; + //TODO: Set secondary cells configuration + // We do not set it for now. No carrier aggregation support + + //TODO: Set deactivation timer for secondary cell + config->has_scell_deactivation_timer = 0; + config->scell_deactivation_timer = 0; + } + } else if (state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_MOVED) { + // TODO: Not supported for now. Leave blank + } + + ue_state_change_msg->config = config; + msg = malloc(sizeof(Protocol__FlexranMessage)); + if (msg == NULL) { + goto error; + } + protocol__flexran_message__init(msg); + msg->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_STATE_CHANGE_MSG; + msg->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__INITIATING_MESSAGE; + msg->ue_state_change_msg = ue_state_change_msg; + + data = flexran_agent_pack_message(msg, &size); + /*Send sr info using the MAC channel of the eNB*/ + if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { + err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; + goto error; + } + + LOG_D(FLEXRAN_AGENT,"sent message with size %d\n", size); + return; + error: + LOG_D(FLEXRAN_AGENT, "Could not send UE state message\n"); +} + + + +int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg) { + if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_STATE_CHANGE_MSG) + goto error; + free(msg->ue_state_change_msg->header); + //TODO: Free the contents of the UE config structure + free(msg->ue_state_change_msg); + free(msg); + return 0; + + error: + //LOG_E(MAC, "%s: an error occured\n", __FUNCTION__); + return -1; +} + +/* this is called by RRC as a part of rrc xface . The controller previously requested this*/ +int flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults) { + + // int i, m, k; + int priority; + void *data; + int size; + err_code_t err_code; + Protocol__FlexUeStatsReport **ue_report; + Protocol__FlexCellStatsReport **cell_report; + Protocol__FlexStatsReply *stats_reply_msg; + Protocol__FlexranMessage *msg; + + Protocol__FlexHeader *header; + int xid = 0; + int i; + + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) + goto error; + + + + stats_reply_msg = malloc(sizeof(Protocol__FlexStatsReply)); + + if (stats_reply_msg == NULL) + goto error; + + protocol__flex_stats_reply__init(stats_reply_msg); + stats_reply_msg->header = header; + stats_reply_msg->n_ue_report = 1; + stats_reply_msg->n_cell_report = 1; + +/****** LOCK ******************************************************************/ + // pthread_spin_lock(&rrc_meas_t_lock); + + // struct rrc_meas_trigg *ctxt; + // ctxt = rrc_meas_get_trigg(p->rnti, p->meas->measId); + + // pthread_spin_unlock(&rrc_meas_t_lock); +/****** UNLOCK ****************************************************************/ + + // if (ctxt == NULL) { + + // flexran_RRC_meas_reconf(p->rnti, -1, p->meas->measId, NULL, NULL); + // Free the measurement report received from UE. + // ASN_STRUCT_FREE(asn_DEF_MeasResults, p->meas); + // /* Free the params. */ + // free(p); + // return 0; + // } + + + /* Check here whether trigger is registered in agent and then proceed. + */ + // if (em_has_trigger(mod_id, ctxt->t_id, RRC_MEAS_TRIGGER) == 0) { + + // flexran_RRC_meas_reconf(p->rnti, -1, p->meas->measId, NULL, NULL); + // /* Trigger does not exist in agent so remove from wrapper as well. */ + // if (rrc_meas_rem_trigg(ctxt) < 0) { + // goto error; + // } + // } + + + + + /* Set the RNTI of the UE. */ + // repl->rnti = p->rnti; + /* Set the request status. */ + // if (p->reconfig_success == 0) { + // repl->status = STATS_REQ_STATUS__SREQS_FAILURE; + // goto error; + // } + /* Successful outcome. */ + // repl->status = STATS_REQ_STATUS__SREQS_SUCCESS; + /* Set the measurement ID of measurement. */ + // repl->has_measid = 1; + // repl->measid = measResults->measId; + /* Fill the Primary Cell RSRP and RSRQ. */ + // repl->has_pcell_rsrp = 1; + // repl->has_pcell_rsrq = 1; + // #ifdef Rel10 + // repl->has_pcell_rsrp = 1; + // repl->has_pcell_rsrq = 1; + // repl->pcell_rsrp = measResults2->measResultPCell.rsrpResult - 140; + // repl->pcell_rsrq = (measResults2->measResultPCell.rsrqResult)/2 - 20; + + ue_report = malloc(sizeof(Protocol__FlexUeStatsReport *) * 1); + if (ue_report == NULL) + goto error; + + for (i = 0; i < 1; i++) { + + ue_report[i] = malloc(sizeof(Protocol__FlexUeStatsReport)); + if(ue_report[i] == NULL) + goto error; + protocol__flex_ue_stats_report__init(ue_report[i]); + ue_report[i]->rnti = flexran_get_ue_crnti(mod_id, 0); + ue_report[i]->has_rnti = 1; + ue_report[i]->flags = 65536; + ue_report[i]->has_flags = 1; + + } + + cell_report = malloc(sizeof(Protocol__FlexCellStatsReport *) * 1); + if (cell_report == NULL) + goto error; + + for (i = 0; i < 1; i++) { + + cell_report[i] = malloc(sizeof(Protocol__FlexCellStatsReport)); + if(cell_report[i] == NULL) + goto error; + + protocol__flex_cell_stats_report__init(cell_report[i]); + cell_report[i]->carrier_index = 0; //report_config->cc_report_type[i].cc_id; + cell_report[i]->has_carrier_index = 1; + cell_report[i]->flags = 0; // report_config->cc_report_type[i].cc_report_flags; + cell_report[i]->has_flags = 1; + } + + + Protocol__FlexRrcMeasurements *rrc_measurements; + rrc_measurements = malloc(sizeof(Protocol__FlexRrcMeasurements)); + if (rrc_measurements == NULL) + goto error; + protocol__flex_rrc_measurements__init(rrc_measurements); + + rrc_measurements->measid = measResults->measId; + rrc_measurements->has_measid = 1; + + rrc_measurements->pcell_rsrp = measResults->measResultPCell.rsrpResult - 140; + rrc_measurements->has_pcell_rsrp = 1; + + rrc_measurements->pcell_rsrq = (measResults->measResultPCell.rsrqResult)/2 - 20; + rrc_measurements->has_pcell_rsrq = 1 ; + + ue_report[0]->rrc_measurements = rrc_measurements; + + + + + + // #else + // repl->has_pcell_rsrp = 1; + // repl->has_pcell_rsrq = 1; + // repl->pcell_rsrp = RSRP_meas_mapping[meas-> + // measResultServCell.rsrpResult]; + // repl->pcell_rsrq = RSRQ_meas_mapping[meas-> + // measResultServCell.rsrqResult]; + // #endif + + // repl->neigh_meas = NULL; + + // if (meas->measResultNeighCells != NULL) { + // /* + // * Neighboring cells measurements performed by UE. + // */ + // NeighCellsMeasurements *neigh_meas; + // neigh_meas = malloc(sizeof(NeighCellsMeasurements)); + // if (neigh_meas == NULL) + // goto error; + // neigh_cells_measurements__init(neigh_meas); + + // /* EUTRAN RRC Measurements. */ + // if (meas->measResultNeighCells->present == + // MeasResults__measResultNeighCells_PR_measResultListEUTRA) { + + // MeasResultListEUTRA_t meas_list = meas->measResultNeighCells-> + // choice.measResultListEUTRA; + // /* Set the number of EUTRAN measurements present in report. */ + // neigh_meas->n_eutra_meas = meas_list.list.count; + // if (neigh_meas->n_eutra_meas > 0) { + // /* Initialize EUTRAN measurements. */ + // EUTRAMeasurements **eutra_meas; + // eutra_meas = malloc(sizeof(EUTRAMeasurements *) * + // neigh_meas->n_eutra_meas); + // for (i = 0; i < neigh_meas->n_eutra_meas; i++) { + // eutra_meas[i] = malloc(sizeof(EUTRAMeasurements)); + // eutra_measurements__init(eutra_meas[i]); + // /* Fill in the physical cell identifier. */ + // eutra_meas[i]->has_phys_cell_id = 1; + // eutra_meas[i]->phys_cell_id = meas_list.list.array[i]-> + // physCellId; + // // log_i(agent,"PCI of Target %d", eutra_meas[i]->phys_cell_id); + // /* Check for Reference signal measurements. */ + // if (&(meas_list.list.array[i]->measResult)) { + // /* Initialize Ref. signal measurements. */ + // EUTRARefSignalMeas *meas_result; + // meas_result = malloc(sizeof(EUTRARefSignalMeas)); + // eutra_ref_signal_meas__init(meas_result); + + // if (meas_list.list.array[i]->measResult.rsrpResult) { + // meas_result->has_rsrp = 1; + // meas_result->rsrp = RSRP_meas_mapping[*(meas_list. + // list.array[i]->measResult.rsrpResult)]; + // // log_i(agent,"RSRP of Target %d", meas_result->rsrp); + // } + + // if (meas_list.list.array[i]->measResult.rsrqResult) { + // meas_result->has_rsrq = 1; + // meas_result->rsrq = RSRQ_meas_mapping[*(meas_list. + // list.array[i]->measResult.rsrqResult)]; + // // log_i(agent,"RSRQ of Target %d", meas_result->rsrq); + // } + // eutra_meas[i]->meas_result = meas_result; + // } + // /* Check for CGI measurements. */ + // if (meas_list.list.array[i]->cgi_Info) { + // /* Initialize CGI measurements. */ + // EUTRACgiMeasurements *cgi_meas; + // cgi_meas = malloc(sizeof(EUTRACgiMeasurements)); + // eutra_cgi_measurements__init(cgi_meas); + + // /* EUTRA Cell Global Identity (CGI). */ + // CellGlobalIdEUTRA *cgi; + // cgi = malloc(sizeof(CellGlobalIdEUTRA)); + // cell_global_id__eutra__init(cgi); + + // cgi->has_cell_id = 1; + // CellIdentity_t cId = meas_list.list.array[i]-> + // cgi_Info->cellGlobalId.cellIdentity; + // cgi->cell_id = (cId.buf[0] << 20) + (cId.buf[1] << 12) + + // (cId.buf[2] << 4) + (cId.buf[3] >> 4); + + // /* Public land mobile network identifier of neighbor + // * cell. + // */ + // PlmnIdentity *plmn_id; + // plmn_id = malloc(sizeof(PlmnIdentity)); + // plmn_identity__init(plmn_id); + + // MNC_t mnc = meas_list.list.array[i]-> + // cgi_Info->cellGlobalId.plmn_Identity.mnc; + + // plmn_id->has_mnc = 1; + // plmn_id->mnc = 0; + // for (m = 0; m < mnc.list.count; m++) { + // plmn_id->mnc += *mnc.list.array[m] * + // ((uint32_t) pow(10, mnc.list.count - m - 1)); + // } + + // MCC_t *mcc = meas_list.list.array[i]-> + // cgi_Info->cellGlobalId.plmn_Identity.mcc; + + // plmn_id->has_mcc = 1; + // plmn_id->mcc = 0; + // for (m = 0; m < mcc->list.count; m++) { + // plmn_id->mcc += *mcc->list.array[m] * + // ((uint32_t) pow(10, mcc->list.count - m - 1)); + // } + + // TrackingAreaCode_t tac = meas_list.list.array[i]-> + // cgi_Info->trackingAreaCode; + + // cgi_meas->has_tracking_area_code = 1; + // cgi_meas->tracking_area_code = (tac.buf[0] << 8) + + // (tac.buf[1]); + + // PLMN_IdentityList2_t *plmn_l = meas_list.list.array[i]-> + // cgi_Info->plmn_IdentityList; + + // cgi_meas->n_plmn_id = plmn_l->list.count; + // /* Set the PLMN ID list in CGI measurements. */ + // PlmnIdentity **plmn_id_l; + // plmn_id_l = malloc(sizeof(PlmnIdentity *) * + // cgi_meas->n_plmn_id); + + // MNC_t mnc2; + // MCC_t *mcc2; + // for (m = 0; m < cgi_meas->n_plmn_id; m++) { + // plmn_id_l[m] = malloc(sizeof(PlmnIdentity)); + // plmn_identity__init(plmn_id_l[m]); + + // mnc2 = plmn_l->list.array[m]->mnc; + // plmn_id_l[m]->has_mnc = 1; + // plmn_id_l[m]->mnc = 0; + // for (k = 0; k < mnc2.list.count; k++) { + // plmn_id_l[m]->mnc += *mnc2.list.array[k] * + // ((uint32_t) pow(10, mnc2.list.count - k - 1)); + // } + + // mcc2 = plmn_l->list.array[m]->mcc; + // plmn_id_l[m]->has_mcc = 1; + // plmn_id_l[m]->mcc = 0; + // for (k = 0; k < mcc2->list.count; k++) { + // plmn_id_l[m]->mcc += *mcc2->list.array[k] * + // ((uint32_t) pow(10, mcc2->list.count - k - 1)); + // } + // } + // cgi_meas->plmn_id = plmn_id_l; + // eutra_meas[i]->cgi_meas = cgi_meas; + // } + // } + // neigh_meas->eutra_meas = eutra_meas; + // } + // } + // repl->neigh_meas = neigh_meas; + // } + /* Attach the RRC measurement reply message to RRC measurements message. */ + // mrrc_meas->repl = repl; + /* Attach RRC measurement message to triggered event message. */ + // te->mrrc_meas = mrrc_meas; + // te->has_action = 0; + /* Attach the triggered event message to main message. */ + // reply->te = te; + + /* Send the report to controller. */ + // if (flexran_agent_msg_send(b_id, reply) < 0) { + // goto error; + // } + + /* Free the measurement report received from UE. */ + // ASN_STRUCT_FREE(asn_DEF_MeasResults, p->meas); + /* Free the params. */ + // free(p); + + + stats_reply_msg->cell_report = cell_report; + + stats_reply_msg->ue_report = ue_report; + + msg = malloc(sizeof(Protocol__FlexranMessage)); + if(msg == NULL) + goto error; + protocol__flexran_message__init(msg); + msg->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG; + msg->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__SUCCESSFUL_OUTCOME; + msg->stats_reply_msg = stats_reply_msg; + + data = flexran_agent_pack_message(msg, &size); + + + if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { + + err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; + goto error; + } + + LOG_I(FLEXRAN_AGENT,"RRC Trigger is done \n"); + + return 0; + + error: + + LOG_E(RRC, "Error triggering RRC measurements message!"); + /* Free the measurement report received from UE. */ + // ASN_STRUCT_FREE(asn_DEF_MeasResults, p->meas); + /* Free the params. */ + // free(p); + return -1; +} + + +int flexran_agent_register_rrc_xface(mid_t mod_id, AGENT_RRC_xface *xface) { + if (rrc_agent_registered[mod_id]) { + LOG_E(RRC, "RRC agent for eNB %d is already registered\n", mod_id); + return -1; + } + +// xface->flexran_agent_send_update_rrc_stats = flexran_agent_send_update_rrc_stats; + + xface->flexran_agent_notify_ue_state_change = flexran_agent_ue_state_change; + xface->flexran_trigger_rrc_measurements = flexran_trigger_rrc_measurements; + + rrc_agent_registered[mod_id] = 1; + agent_rrc_xface[mod_id] = xface; + + return 0; +} + +int flexran_agent_unregister_rrc_xface(mid_t mod_id, AGENT_RRC_xface *xface) { + + //xface->agent_ctxt = NULL; +// xface->flexran_agent_send_update_rrc_stats = NULL; + + xface->flexran_agent_notify_ue_state_change = NULL; + xface->flexran_trigger_rrc_measurements = NULL; + rrc_agent_registered[mod_id] = 0; + agent_rrc_xface[mod_id] = NULL; + + return 0; +} diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h new file mode 100644 index 0000000000..17b58dac93 --- /dev/null +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h @@ -0,0 +1,74 @@ +/******************************************************************************* + 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 . + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr + + Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France. + + *******************************************************************************/ + +/*! \file flexran_agent_rrc.h + * \brief FlexRAN agent Control Module RRC header + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + */ + +#ifndef FLEXRAN_AGENT_RRC_H_ +#define FLEXRAN_AGENT_RRC_H_ + +#include "header.pb-c.h" +#include "flexran.pb-c.h" +#include "stats_messages.pb-c.h" +#include "stats_common.pb-c.h" +#include "MeasResults.h" + +#include "flexran_agent_common.h" +#include "flexran_agent_rrc_defs.h" + + +/* Initialization function for the agent structures etc */ +void flexran_agent_init_rrc_agent(mid_t mod_id); + +/* UE state change message constructor and destructor */ +int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change); +int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg); + + +/********************************** + * FlexRAN agent - technology RRC API + **********************************/ + +/* Send to the controller all the rrc stat updates that occured during this subframe*/ +// void flexran_agent_send_update_rrc_stats(mid_t mod_id); + +/* this is called by RRC as a part of rrc xface . The controller previously requested this*/ +int flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t *); + +/*Register technology specific interface callbacks*/ +int flexran_agent_register_rrc_xface(mid_t mod_id, AGENT_RRC_xface *xface); + +/*Unregister technology specific callbacks*/ +int flexran_agent_unregister_rrc_xface(mid_t mod_id, AGENT_RRC_xface*xface); + +#endif diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h new file mode 100644 index 0000000000..10fc4ba254 --- /dev/null +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h @@ -0,0 +1,62 @@ +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2016 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 . + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr + + Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France. + + *******************************************************************************/ + +/*! \file flexran_agent_rrc_defs.h + * \brief FlexRAN agent - RRC interface primitives + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + * \mail + */ + +#ifndef __FLEXRAN_AGENT_RRC_PRIMITIVES_H__ +#define __FLEXRAN_AGENT_RRC_PRIMITIVES_H__ + +#include "flexran_agent_defs.h" +#include "flexran.pb-c.h" +#include "header.pb-c.h" + +#define RINGBUFFER_SIZE 100 + +/* FLEXRAN AGENT-RRC Interface */ +typedef struct { + + /// Inform the controller about the scheduling requests received during the subframe + //void (*flexran_agent_send_update_rrc_stats)(mid_t mod_id); + + /// Notify the controller for a state change of a particular UE, by sending the proper + /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) + void (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, + uint32_t state_change); + + void (*flexran_trigger_rrc_measurements)(mid_t mod_id, MeasResults_t* measResults) + +} AGENT_RRC_xface; + +#endif diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index 3a1d40bca6..7fb3a22df8 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -28,6 +28,7 @@ message flexran_message { flex_ue_state_change ue_state_change_msg = 15; flex_control_delegation control_delegation_msg = 16; flex_agent_reconfiguration agent_reconfiguration_msg = 17; + flex_rrc_triggering rrc_triggering = 18; } } @@ -163,6 +164,13 @@ message flex_dl_mac_config { repeated flex_pdcch_ofdm_sym_count ofdm_sym = 6; // OFDM symbol count for each CC } +message flex_rrc_triggering { + + optional flex_header header = 1; + optional string rrc_trigger = 2; +} + + // // UE state change message // diff --git a/openair2/ENB_APP/MESSAGES/V2/header.proto b/openair2/ENB_APP/MESSAGES/V2/header.proto index dfd5ea6c99..468dcd201e 100644 --- a/openair2/ENB_APP/MESSAGES/V2/header.proto +++ b/openair2/ENB_APP/MESSAGES/V2/header.proto @@ -39,5 +39,7 @@ enum flex_type { // Control delegation messages FLPT_DELEGATE_CONTROL = 15; FLPT_RECONFIGURE_AGENT = 16; + FLPT_RRC_TRIGGERING = 17; + } diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto index 080883ea97..cce36df00a 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto @@ -181,3 +181,63 @@ message flex_noise_interference_report { optional int32 p0_nominal_pucch = 4; } +// +// RRC Primitives +// +message flex_rrc_measurements { + // Measurement identifier. + optional int32 measid = 1; + // Primary Cell Reference Signal Received Power (RSRP). + optional int32 pcell_rsrp = 2; + // Primary Cell Reference Signal Received Quality (RSRQ). + optional int32 pcell_rsrq = 3; + // Neighboring cells measurements performed by UE. + optional flex_neigh_cells_measurements neigh_meas = 4; +} + +message flex_neigh_cells_measurements { + // Neighboring EUTRA cells measurements. + repeated flex_eutra_measurements eutra_meas = 1; +} + +message flex_eutra_measurements { + // Physical Cell identifier. + optional int32 phys_cell_id = 1; + // EUTRA Cell Global Identity (CGI) measurement. + optional flex_eutra_cgi_measurements cgi_meas = 2; + // EUTRA nearby cell reference signal measurement. + optional flex_eutra_ref_signal_meas meas_result = 3; +} + +message flex_eutra_cgi_measurements { + // EUTRA Cell Global Identity (CGI). + optional flex_cell_global_eutra_id cgi = 1; + // Tracking area code of the neighbor cell. + optional uint32 tracking_area_code = 2; + // Public land mobile network identifiers of neighbor cell. + repeated flex_plmn_identity plmn_id = 3; +} + +message flex_cell_global_eutra_id { + // Public land mobile network identifier of neighbor cell. + optional flex_plmn_identity plmn_id = 1; + // Cell identifier of neighbor cell. + optional uint32 cell_id = 2; +} + +message flex_plmn_identity { + // Mobile Network Code (MNC). + repeated uint32 mnc = 1; + // Mobile Country Code (MCC). + repeated uint32 mcc = 2; + // tracking area code + repeated uint32 tac = 3; +} + +message flex_eutra_ref_signal_meas { + // Neighboring Cell Reference Signal Received Power (RSRP). + optional int32 rsrp = 1; + // Neighboring Cell Reference Signal Received Quality (RSRQ). + optional int32 rsrq = 2; + +} diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto b/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto index 1b1567dda1..48360f6f68 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto @@ -46,6 +46,7 @@ message flex_ue_stats_report { optional flex_dl_cqi_report dl_cqi_report = 7; optional flex_paging_buffer_report pbr = 8; optional flex_ul_cqi_report ul_cqi_report = 9; + optional flex_rrc_measurements rrc_measurements = 10; } // @@ -76,11 +77,12 @@ enum flex_cell_stats_type { // Flags for UE-related statistics enum flex_ue_stats_type { FLUST_BSR = 1; - FLUST_PRH = 2; + FLUST_PHR = 2; FLUST_RLC_BS = 4; FLUST_MAC_CE_BS = 8; FLUST_DL_CQI = 16; FLUST_PBS = 32; FLUST_UL_CQI = 64; // To be extended with more types of stats -} \ No newline at end of file + FLUST_RRC_MEASUREMENTS = 65536; +} diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 153c89b3e2..09d7495a69 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -98,6 +98,8 @@ #define ENB_CONFIG_STRING_EUTRA_BAND "eutra_band" #define ENB_CONFIG_STRING_DOWNLINK_FREQUENCY "downlink_frequency" #define ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET "uplink_frequency_offset" +#define ENB_CONFIG_STRING_RRC_REPORT_CONFIG_AMOUNT "report_amount" +#define ENB_CONFIG_STRING_RRC_REPORT_CONFIG_INTERVAL "report_interval" #define ENB_CONFIG_STRING_NID_CELL "Nid_cell" #define ENB_CONFIG_STRING_N_RB_DL "N_RB_DL" @@ -165,7 +167,7 @@ #define ENB_CONFIG_STRING_UETIMERS_N310 "ue_TimersAndConstants_n310" #define ENB_CONFIG_STRING_UETIMERS_N311 "ue_TimersAndConstants_n311" #define ENB_CONFIG_STRING_UE_TRANSMISSION_MODE "ue_TransmissionMode" - +#define ENB_CONFIG_STRING_RRC_CONFIG "rrc_config" #define ENB_CONFIG_STRING_SRB1 "srb1_parameters" #define ENB_CONFIG_STRING_SRB1_TIMER_POLL_RETRANSMIT "timer_poll_retransmit" #define ENB_CONFIG_STRING_SRB1_TIMER_REORDERING "timer_reordering" @@ -456,6 +458,10 @@ void enb_config_display(void) printf( "\tue_TransmissionMode for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ue_TransmissionMode[j]); + printf( "\n\tRRC Report Config: \n"); + printf( "\n\t Report interval \t%ld: ", enb_properties.properties[i]->rrc_report_interval); + printf( "\n\t Report amount \t%ld: \n", enb_properties.properties[i]->rrc_report_amount); + } for (j=0; j < enb_properties.properties[i]->num_otg_elements; j++) { @@ -545,6 +551,7 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) config_setting_t *setting_enb = NULL; config_setting_t *setting_otg = NULL; config_setting_t *subsetting_otg = NULL; + config_setting_t *setting_rrc = NULL; int parse_errors = 0; int num_enb_properties = 0; int enb_properties_index = 0; @@ -651,7 +658,8 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) libconfig_int srb1_max_retx_threshold = 0; libconfig_int my_int; - + const char* rrc_report_amount = NULL; + const char* rrc_report_interval = NULL; char* if_name = NULL; char* ipv4 = NULL; @@ -1968,6 +1976,75 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } } + + setting_rrc = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_RRC_CONFIG); + if (setting_rrc != NULL) { + + if (!(config_setting_lookup_string(setting_rrc, ENB_CONFIG_STRING_RRC_REPORT_CONFIG_AMOUNT, &rrc_report_amount) + && config_setting_lookup_string(setting_rrc, ENB_CONFIG_STRING_RRC_REPORT_CONFIG_INTERVAL, &rrc_report_interval))) + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d, rrc_report_amount and rrc_reporyt_interval !\n", + lib_config_file_name_pP, i); + + if (strcmp(rrc_report_amount, "r1") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_r1; + } else if (strcmp(rrc_report_amount, "r2") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_r2; + }else if (strcmp(rrc_report_amount, "r4") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_r4; + }else if (strcmp(rrc_report_amount, "r8") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_r8; + }else if (strcmp(rrc_report_amount, "r16") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_r16; + }else if (strcmp(rrc_report_amount, "r32") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_r32; + }else if (strcmp(rrc_report_amount, "r64") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_r64; + }else if (strcmp(rrc_report_amount, "infinity") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_infinity; + }else{ + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for report_amount choice: r1, r2, r4, r8, r16, r32, r64, infinity !\n", + lib_config_file_name_pP, i,rrc_report_amount); + } + + if (strcmp(rrc_report_interval, "120ms") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms120; + } else if (strcmp(rrc_report_interval, "240ms") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms240; + }else if (strcmp(rrc_report_interval, "480ms") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms480; + }else if (strcmp(rrc_report_interval, "640ms") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms640; + }else if (strcmp(rrc_report_interval, "1024ms") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms1024; + }else if (strcmp(rrc_report_interval, "2048ms") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms2048; + }else if (strcmp(rrc_report_interval, "5120ms") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms5120; + }else if (strcmp(rrc_report_interval, "10240ms") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms10240; + }else if (strcmp(rrc_report_interval, "1min") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_min1; + }else if (strcmp(rrc_report_interval, "6min") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_min6; + }else if (strcmp(rrc_report_interval, "12min") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_min12; + }else if (strcmp(rrc_report_interval, "30min") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_min30; + } else if (strcmp(rrc_report_interval, "60min") == 0) { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_min60; + } else { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for report_interval choice: 120ms, 240ms, 480ms, 640ms, 1024ms, 2048ms, 5120ms, 10240ms, 1min, 6min, 12", + lib_config_file_name_pP, i,rrc_report_interval); + } + + } else { + enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_ms120; + enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_r1; + } + setting_srb1 = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_SRB1); if (setting_srb1 != NULL) { diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h index a508a82e1f..094360749b 100644 --- a/openair2/ENB_APP/enb_config.h +++ b/openair2/ENB_APP/enb_config.h @@ -214,6 +214,10 @@ typedef struct Enb_properties_s { long srb1_poll_pdu; long srb1_poll_byte; long srb1_max_retx_threshold; + + long rrc_report_amount; + long rrc_report_interval; + /* Nb of MME to connect to */ uint8_t nb_mme; /* List of MME to connect to */ diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index 0dcacd4b81..d96076df83 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -21,27 +21,16 @@ /*! \file flexran_agent.h * \brief top level flexran agent receive thread and itti task - * \author Xenofon Foukas and Navid Nikaein - * \date 2016 + * \author Xenofon Foukas and Navid Nikaein and shahab SHARIAT BAGHERI + * \date 2017 * \version 0.1 */ -#include "flexran_agent_common.h" -#include "log.h" #include "flexran_agent.h" -#include "flexran_agent_mac_defs.h" -#include "flexran_agent_mac.h" -#include "flexran_agent_mac_internal.h" - -#include "flexran_agent_extern.h" - -#include "assertions.h" - -#include "flexran_agent_net_comm.h" -#include "flexran_agent_async.h" #include + //#define TEST_TIMER flexran_agent_instance_t flexran_agent[NUM_MAX_ENB]; @@ -264,8 +253,8 @@ int flexran_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properti *flexran_agent_register_channel(mod_id, channel, FLEXRAN_AGENT_MAC); */ - /*Initialize the continuous MAC stats update mechanism*/ - flexran_agent_init_cont_mac_stats_update(mod_id); + /*Initialize the continuous stats update mechanism*/ + flexran_agent_init_cont_stats_update(mod_id); new_thread(receive_thread, &flexran_agent[mod_id]); @@ -275,6 +264,9 @@ int flexran_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properti AGENT_MAC_xface *mac_agent_xface = (AGENT_MAC_xface *) malloc(sizeof(AGENT_MAC_xface)); flexran_agent_register_mac_xface(mod_id, mac_agent_xface); + AGENT_RRC_xface *rrc_agent_xface = (AGENT_MAC_xface *) malloc(sizeof(AGENT_MAC_xface)); + flexran_agent_register_rrc_xface(mod_id, rrc_agent_xface); + /* * initilize a timer */ diff --git a/openair2/ENB_APP/flexran_agent.h b/openair2/ENB_APP/flexran_agent.h index 21ea21aafc..aec4f004a8 100644 --- a/openair2/ENB_APP/flexran_agent.h +++ b/openair2/ENB_APP/flexran_agent.h @@ -22,15 +22,23 @@ /*! \file flexran_agent.h * \brief top level flexran agent * \author Navid Nikaein and Xenofon Foukas - * \date 2016 + * \date 2017 * \version 0.1 */ #ifndef FLEXRAN_AGENT_H_ #define FLEXRAN_AGENT_H_ -#include "enb_config.h" // for enb properties #include "flexran_agent_common.h" +#include "flexran_agent_async.h" +#include "flexran_agent_extern.h" +#include "flexran_agent_timer.h" +#include "flexran_agent_defs.h" + +#include "log.h" +#include "assertions.h" + +#include "enb_config.h" // for enb properties /* Initiation and termination of the eNodeB agent */ diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index f2d00145a0..7d9cfe685c 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -21,8 +21,8 @@ /*! \file flexran_agent_common.c * \brief common primitives for all agents - * \author Xenofon Foukas, Mohamed Kassem and Navid Nikaein - * \date 2016 + * \author Xenofon Foukas, Mohamed Kassem and Navid Nikaein, shahab SHARIAT BAGHERI + * \date 2017 * \version 0.1 */ @@ -41,10 +41,6 @@ #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "rrc_eNB_UE_context.h" -void * enb[NUM_MAX_ENB]; -void * enb_ue[NUM_MAX_ENB]; -void * enb_rrc[NUM_MAX_ENB]; - /* * message primitives */ @@ -344,19 +340,6 @@ int flexran_agent_destroy_lc_config_reply(Protocol__FlexranMessage *msg) { return -1; } -int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg) { - if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_STATE_CHANGE_MSG) - goto error; - free(msg->ue_state_change_msg->header); - //TODO: Free the contents of the UE config structure - free(msg->ue_state_change_msg); - free(msg); - return 0; - - error: - //LOG_E(MAC, "%s: an error occured\n", __FUNCTION__); - return -1; -} int flexran_agent_destroy_enb_config_request(Protocol__FlexranMessage *msg) { if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_ENB_CONFIG_REQUEST_MSG) @@ -442,1082 +425,6 @@ int flexran_agent_destroy_agent_reconfiguration(Protocol__FlexranMessage *msg) { } -/* - * get generic info from RAN - */ - -void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ - - switch (ran){ - case RAN_LTE_OAI : - enb[mod_id] = (void *)&eNB_mac_inst[mod_id]; - enb_ue[mod_id] = (void *)&eNB_mac_inst[mod_id].UE_list; - enb_rrc[mod_id] = (void *)&eNB_rrc_inst[mod_id]; - break; - default : - goto error; - } - - return; - - error: - LOG_E(FLEXRAN_AGENT, "unknown RAN name %d\n", ran); -} - -int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag){ - - if (subframe_flag == 1){ - return ((eNB_MAC_INST *)enb[mod_id])->frame*10 + ((eNB_MAC_INST *)enb[mod_id])->subframe; - }else { - return ((eNB_MAC_INST *)enb[mod_id])->frame*10; - } - -} - -unsigned int flexran_get_current_frame (mid_t mod_id) { - - // #warning "SFN will not be in [0-1023] when oaisim is used" - return ((eNB_MAC_INST *)enb[mod_id])->frame; - -} - -unsigned int flexran_get_current_system_frame_num(mid_t mod_id) { - return (flexran_get_current_frame(mod_id) %1024); -} - -unsigned int flexran_get_current_subframe (mid_t mod_id) { - - return ((eNB_MAC_INST *)enb[mod_id])->subframe; - -} - -uint16_t flexran_get_sfn_sf (mid_t mod_id) { - - frame_t frame; - sub_frame_t subframe; - uint16_t sfn_sf, frame_mask, sf_mask; - - frame = (frame_t) flexran_get_current_system_frame_num(mod_id); - subframe = (sub_frame_t) flexran_get_current_subframe(mod_id); - frame_mask = ((1<<12) - 1); - sf_mask = ((1<<4) - 1); - sfn_sf = (subframe & sf_mask) | ((frame & frame_mask) << 4); - - return sfn_sf; -} - -uint16_t flexran_get_future_sfn_sf (mid_t mod_id, int ahead_of_time) { - - frame_t frame; - sub_frame_t subframe; - uint16_t sfn_sf, frame_mask, sf_mask; - - frame = (frame_t) flexran_get_current_system_frame_num(mod_id); - subframe = (sub_frame_t) flexran_get_current_subframe(mod_id); - - subframe = ((subframe + ahead_of_time) % 10); - - if (subframe < flexran_get_current_subframe(mod_id)) { - frame = (frame + 1) % 1024; - } - - int additional_frames = ahead_of_time / 10; - frame = (frame + additional_frames) % 1024; - - frame_mask = ((1<<12) - 1); - sf_mask = ((1<<4) - 1); - sfn_sf = (subframe & sf_mask) | ((frame & frame_mask) << 4); - - return sfn_sf; -} - -int flexran_get_num_ues (mid_t mod_id){ - - return ((UE_list_t *)enb_ue[mod_id])->num_UEs; -} - -int flexran_get_ue_crnti (mid_t mod_id, mid_t ue_id) { - - return UE_RNTI(mod_id, ue_id); -} - -int flexran_get_ue_bsr (mid_t mod_id, mid_t ue_id, lcid_t lcid) { - - return ((UE_list_t *)enb_ue[mod_id])->UE_template[UE_PCCID(mod_id,ue_id)][ue_id].bsr_info[lcid]; -} - -int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id) { - - return ((UE_list_t *)enb_ue[mod_id])->UE_template[UE_PCCID(mod_id,ue_id)][ue_id].phr_info; -} - -int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, 0, UE_RNTI(mod_id, ue_id)); - return eNB_UE_stats->DL_cqi[0]; - - // return ((UE_list_t *)enb_ue[mod_id])->eNB_UE_stats[UE_PCCID(mod_id,ue_id)][ue_id].dl_cqi; -} - -int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); - mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id,frame,ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); - return rlc_status.bytes_in_buffer; -} - -int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); - mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, ENB_FLAG_YES, MBMS_FLAG_NO, channel_id, 0); - return rlc_status.head_sdu_creation_time; -} - -short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id) { - - UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; - int rnti; - - rnti = flexran_get_ue_crnti(mod_id, ue_id); - - LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - //ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY - switch (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.N_RB_DL) { - case 6: - return eNB_UE_stats->timing_advance_update; - case 15: - return eNB_UE_stats->timing_advance_update/2; - case 25: - return eNB_UE_stats->timing_advance_update/4; - case 50: - return eNB_UE_stats->timing_advance_update/8; - case 75: - return eNB_UE_stats->timing_advance_update/12; - case 100: - if (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.threequarter_fs == 0) { - return eNB_UE_stats->timing_advance_update/16; - } else { - return eNB_UE_stats->timing_advance_update/12; - } - default: - return 0; - } -} - -void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id) { - - UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[ue_id]; - - if (ue_sched_ctl->ta_timer == 0) { - - // WE SHOULD PROTECT the eNB_UE_stats with a mutex here ... - // LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - //ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY - ue_sched_ctl->ta_update = flexran_get_TA(mod_id, ue_id, CC_id); - - // clear the update in case PHY does not have a new measurement after timer expiry - // eNB_UE_stats->timing_advance_update = 0; - } else { - ue_sched_ctl->ta_timer--; - ue_sched_ctl->ta_update = 0; // don't trigger a timing advance command - } -} - -int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id,int CC_id) { - - UE_list_t *UE_list = &eNB_mac_inst[mod_id].UE_list; - - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); - - if (eNB_UE_stats == NULL) { - return 0; - } - - if (flexran_get_TA(mod_id, ue_id, CC_id) != 0) { - return PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; - } else { - return 0; - } - -} - -int flexran_get_active_CC(mid_t mod_id, mid_t ue_id) { - return ((UE_list_t *)enb_ue[mod_id])->numactiveCCs[ue_id]; -} - -int flexran_get_current_RI(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); - - if (eNB_UE_stats == NULL) { - return 0; - } - - return eNB_UE_stats[CC_id].rank; -} - -int flexran_get_tpc(mid_t mod_id, mid_t ue_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - int32_t normalized_rx_power, target_rx_power; - int tpc = 1; - - int pCCid = UE_PCCID(mod_id,ue_id); - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, pCCid, rnti); - - target_rx_power = mac_xface->get_target_pusch_rx_power(mod_id,pCCid); - - if (eNB_UE_stats == NULL) { - normalized_rx_power = target_rx_power; - } else if (eNB_UE_stats->UL_rssi != NULL) { - normalized_rx_power = eNB_UE_stats->UL_rssi[0]; - } else { - normalized_rx_power = target_rx_power; - } - - if (normalized_rx_power>(target_rx_power+1)) { - tpc = 0; //-1 - } else if (normalized_rx_power<(target_rx_power-1)) { - tpc = 2; //+1 - } else { - tpc = 1; //0 - } - return tpc; -} - -int flexran_get_harq(const mid_t mod_id, - const uint8_t CC_id, - const mid_t ue_id, - const int frame, - const uint8_t subframe, - uint8_t *id, - uint8_t *round) { //flag_id_status = 0 then id, else status - /*TODO: Add int TB in function parameters to get the status of the second TB. This can be done to by editing in - * get_ue_active_harq_pid function in line 272 file: phy_procedures_lte_eNB.c to add - * DLSCH_ptr = PHY_vars_eNB_g[Mod_id][CC_id]->dlsch_eNB[(uint32_t)UE_id][1];*/ - - uint8_t harq_pid; - uint8_t harq_round; - - - uint16_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - mac_xface->get_ue_active_harq_pid(mod_id,CC_id,rnti,frame,subframe,&harq_pid,&harq_round,openair_harq_DL); - - *id = harq_pid; - *round = harq_round; - /* if (round > 0) { */ - /* *status = 1; */ - /* } else { */ - /* *status = 0; */ - /* } */ - - /* return 0; */ - return *round; -} - -int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - - if (eNB_UE_stats == NULL) { - return -1; - } - - // if(eNB_UE_stats->Po_PUCCH_update == 1) { - return eNB_UE_stats->Po_PUCCH_dBm; - //} - //else - // return -1; -} - -int flexran_get_p0_nominal_pucch(mid_t mod_id, int CC_id) { - int32_t pucch_rx_received = mac_xface->get_target_pucch_rx_power(mod_id, CC_id); - return pucch_rx_received; -} - -int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - return eNB_UE_stats->Po_PUCCH_update; -} - -int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - eNB_UE_stats->Po_PUCCH_update = 0; - - return 0; -} - - -/* - * ************************************ - * Get Messages for eNB Configuration Reply - * ************************************ - */ - -int flexran_get_hopping_offset(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pusch_config_common.pusch_HoppingOffset; -} - -int flexran_get_hopping_mode(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pusch_config_common.hoppingMode; -} - -int flexran_get_n_SB(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pusch_config_common.n_SB; -} - -int flexran_get_enable64QAM(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pusch_config_common.enable64QAM; -} - -int flexran_get_phich_duration(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->phich_config_common.phich_duration; -} - -int flexran_get_phich_resource(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - if(frame_parms->phich_config_common.phich_resource == oneSixth) - return 0; - else if(frame_parms->phich_config_common.phich_resource == half) - return 1; - else if(frame_parms->phich_config_common.phich_resource == one) - return 2; - else if(frame_parms->phich_config_common.phich_resource == two) - return 3; - - return -1; -} - -int flexran_get_n1pucch_an(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pucch_config_common.n1PUCCH_AN; -} - -int flexran_get_nRB_CQI(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pucch_config_common.nRB_CQI; -} - -int flexran_get_deltaPUCCH_Shift(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pucch_config_common.deltaPUCCH_Shift; -} - -int flexran_get_prach_ConfigIndex(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; -} - -int flexran_get_prach_FreqOffset(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset; -} - -int flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->maxHARQ_Msg3Tx; -} - -int flexran_get_ul_cyclic_prefix_length(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->Ncp_UL; -} - -int flexran_get_dl_cyclic_prefix_length(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->Ncp; -} - -int flexran_get_cell_id(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->Nid_cell; -} - -int flexran_get_srs_BandwidthConfig(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->soundingrs_ul_config_common.srs_BandwidthConfig; -} - -int flexran_get_srs_SubframeConfig(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->soundingrs_ul_config_common.srs_SubframeConfig; -} - -int flexran_get_srs_MaxUpPts(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->soundingrs_ul_config_common.srs_MaxUpPts; -} - -int flexran_get_N_RB_DL(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->N_RB_DL; -} - -int flexran_get_N_RB_UL(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->N_RB_UL; -} - -int flexran_get_N_RBG(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->N_RBG; -} - -int flexran_get_subframe_assignment(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->tdd_config; -} - -int flexran_get_special_subframe_assignment(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->tdd_config_S; -} - -int flexran_get_ra_ResponseWindowSize(mid_t mod_id, int CC_id) { - return enb_config_get()->properties[mod_id]->rach_raResponseWindowSize[CC_id]; -} - -int flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, int CC_id) { - return enb_config_get()->properties[mod_id]->rach_macContentionResolutionTimer[CC_id]; -} - -int flexran_get_duplex_mode(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - if(frame_parms->frame_type == TDD) - return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD; - else if (frame_parms->frame_type == FDD) - return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_FDD; - - return -1; -} - -long flexran_get_si_window_length(mid_t mod_id, int CC_id) { - return ((eNB_RRC_INST *)enb_rrc[mod_id])->carrier[CC_id].sib1->si_WindowLength; -} - -int flexran_get_sib1_length(mid_t mod_id, int CC_id) { - return ((eNB_RRC_INST *)enb_rrc[mod_id])->carrier[CC_id].sizeof_SIB1; -} - -int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id) { - /* TODO: This should return the number of PDCCH symbols initially used by the cell CC_id */ - return 0; - //(PHY_vars_UE_g[mod_id][CC_id]->lte_ue_pdcch_vars[mod_id]->num_pdcch_symbols); -} - - - -/* - * ************************************ - * Get Messages for UE Configuration Reply - * ************************************ - */ - - -int flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL) { - return ue_context_p->ue_context.mac_MainConfig->timeAlignmentTimerDedicated; - } else { - return -1; - } - } else { - return -1; - } -} - -int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measGapConfig != NULL) { - if(ue_context_p->ue_context.measGapConfig->present == MeasGapConfig_PR_setup) { - if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0) { - return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_GP1; - } else if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1) { - return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_GP2; - } else { - return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF; - } - } - } - } - return -1; -} - - -int flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measGapConfig != NULL){ - if(ue_context_p->ue_context.measGapConfig->present == MeasGapConfig_PR_setup) { - if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0) { - return ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.choice.gp0; - } else if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1) { - return ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.choice.gp0; - } - } - } - } - return -1; -} - -int flexran_get_ue_aggregated_max_bitrate_dl (mid_t mod_id, mid_t ue_id) { - return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateDL; -} - -int flexran_get_ue_aggregated_max_bitrate_ul (mid_t mod_id, mid_t ue_id) { - return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL; -} - -int flexran_get_half_duplex(mid_t ue_id) { - // TODO - //int halfduplex = 0; - //int bands_to_scan = ((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count; - //for (int i =0; i < bands_to_scan; i++){ - //if(((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->halfDuplex > 0) - // halfduplex = 1; - //} - //return halfduplex; - return 0; -} - -int flexran_get_intra_sf_hopping(mid_t ue_id) { - //TODO:Get proper value - //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); - //return (0 & ( 1 << (31))); - return 0; -} - -int flexran_get_type2_sb_1(mid_t ue_id) { - //TODO:Get proper value - //uint8_t temp = 0; - //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); - //return (temp & ( 1 << (11))); - return 0; -} - -int flexran_get_ue_category(mid_t ue_id) { - //TODO:Get proper value - //return (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->ue_Category); - return 0; -} - -int flexran_get_res_alloc_type1(mid_t ue_id) { - //TODO:Get proper value - //uint8_t temp = 0; - //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); - //return (temp & ( 1 << (30))); - return 0; -} - -int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode; - } else { - return -1; - } - } else { - return -1; - } -} - -int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL){ - return ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->ttiBundling; - } else { - return -1; - } - } - else { - return -1; - } -} - -int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL){ - return *ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; - } - } - return -1; -} - -int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; - } else { - return -1; - } - } else { - return -1; - } -} - -int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; - } else { - return -1; - } - } else { - return -1; - } -} - -int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; - } else { - return -1; - } - } - else { - return -1; - } -} - -int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - if (ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic != NULL) { - return ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI; - } - } - } - return -1; -} - -int flexran_get_ack_nack_simultaneous_trans(mid_t mod_id,mid_t ue_id) { - return (&eNB_rrc_inst[mod_id])->carrier[0].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; -} - -int flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return *ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; - } - } - return -1; -} - -int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id) { - // TODO: This needs fixing - return -1; - - /* struct rrc_eNB_ue_context_s* ue_context_p = NULL; */ - /* uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); */ - - /* ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); */ - - /* if(ue_context_p != NULL) { */ - /* if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ */ - /* return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode; */ - /* } else { */ - /* return -1; */ - /* } */ - /* } else { */ - /* return -1; */ - /* } */ -} - -int flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.choice.setup.repetitionFactor; - } else { - return -1; - } - } else { - return -1; - } -} - -int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) { - //TODO: need to double check - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL){ - if(ue_context_p->ue_context.mac_MainConfig->ext2 != NULL){ - long val = (*(ue_context_p->ue_context.mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10)); - if (val > 0) { - return 1; - } - } - } - } - return -1; -} - -int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_closedLoop) { - return 2; - } else if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_openLoop) { - return 1; - } else { - return 0; - } - } else { - return -1; - } - } else { - return -1; - } -} - -int flexran_get_lcg(mid_t ue_id, mid_t lc_id) { - if (UE_mac_inst == NULL) { - return -1; - } - if(UE_mac_inst[ue_id].logicalChannelConfig[lc_id] != NULL) { - return *UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters->logicalChannelGroup; - } else { - return -1; - } -} - -int flexran_get_direction(mid_t ue_id, mid_t lc_id) { - /*TODO: fill with the value for the rest of LCID*/ - if(lc_id == DCCH || lc_id == DCCH1) { - return 2; - } else if(lc_id == DTCH) { - return 1; - } else { - return -1; - } -} - -int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) { - int size; - Protocol__FlexranMessage *msg; - Protocol__FlexHeader *header; - void *data; - int priority = 0; - - int xid = 0; - - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_UE_STATE_CHANGE, &header) != 0) - goto error; - - Protocol__FlexUeStateChange *ue_state_change_msg; - ue_state_change_msg = malloc(sizeof(Protocol__FlexUeStateChange)); - if(ue_state_change_msg == NULL) { - goto error; - } - protocol__flex_ue_state_change__init(ue_state_change_msg); - ue_state_change_msg->has_type = 1; - ue_state_change_msg->type = state_change; - - Protocol__FlexUeConfig *config; - config = malloc(sizeof(Protocol__FlexUeConfig)); - if (config == NULL) { - goto error; - } - protocol__flex_ue_config__init(config); - if (state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED) { - // Simply set the rnti of the UE - config->has_rnti = 1; - config->rnti = rnti; - } else if (state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED - || state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED) { - int i = find_UE_id(mod_id, rnti); - config->has_rnti = 1; - config->rnti = rnti; - if(flexran_get_time_alignment_timer(mod_id,i) != -1) { - config->time_alignment_timer = flexran_get_time_alignment_timer(mod_id,i); - config->has_time_alignment_timer = 1; - } - if(flexran_get_meas_gap_config(mod_id,i) != -1){ - config->meas_gap_config_pattern = flexran_get_meas_gap_config(mod_id,i); - config->has_meas_gap_config_pattern = 1; - } - if(config->has_meas_gap_config_pattern == 1 && - config->meas_gap_config_pattern != PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF) { - config->meas_gap_config_sf_offset = flexran_get_meas_gap_config_offset(mod_id,i); - config->has_meas_gap_config_sf_offset = 1; - } - //TODO: Set the SPS configuration (Optional) - //Not supported for now, so we do not set it - - //TODO: Set the SR configuration (Optional) - //We do not set it for now - - //TODO: Set the CQI configuration (Optional) - //We do not set it for now - - if(flexran_get_ue_transmission_mode(mod_id,i) != -1) { - config->transmission_mode = flexran_get_ue_transmission_mode(mod_id,i); - config->has_transmission_mode = 1; - } - - config->ue_aggregated_max_bitrate_ul = flexran_get_ue_aggregated_max_bitrate_ul(mod_id,i); - config->has_ue_aggregated_max_bitrate_ul = 1; - - config->ue_aggregated_max_bitrate_dl = flexran_get_ue_aggregated_max_bitrate_dl(mod_id,i); - config->has_ue_aggregated_max_bitrate_dl = 1; - - //TODO: Set the UE capabilities - Protocol__FlexUeCapabilities *c_capabilities; - c_capabilities = malloc(sizeof(Protocol__FlexUeCapabilities)); - protocol__flex_ue_capabilities__init(c_capabilities); - //TODO: Set half duplex (FDD operation) - c_capabilities->has_half_duplex = 0; - c_capabilities->half_duplex = 1;//flexran_get_half_duplex(i); - //TODO: Set intra-frame hopping flag - c_capabilities->has_intra_sf_hopping = 0; - c_capabilities->intra_sf_hopping = 1;//flexran_get_intra_sf_hopping(i); - //TODO: Set support for type 2 hopping with n_sb > 1 - c_capabilities->has_type2_sb_1 = 0; - c_capabilities->type2_sb_1 = 1;//flexran_get_type2_sb_1(i); - //TODO: Set ue category - c_capabilities->has_ue_category = 0; - c_capabilities->ue_category = 1;//flexran_get_ue_category(i); - //TODO: Set UE support for resource allocation type 1 - c_capabilities->has_res_alloc_type1 = 0; - c_capabilities->res_alloc_type1 = 1;//flexran_get_res_alloc_type1(i); - //Set the capabilites to the message - config->capabilities = c_capabilities; - - if(flexran_get_ue_transmission_antenna(mod_id,i) != -1) { - config->has_ue_transmission_antenna = 1; - config->ue_transmission_antenna = flexran_get_ue_transmission_antenna(mod_id,i); - } - - if(flexran_get_tti_bundling(mod_id,i) != -1) { - config->has_tti_bundling = 1; - config->tti_bundling = flexran_get_tti_bundling(mod_id,i); - } - - if(flexran_get_maxHARQ_TX(mod_id,i) != -1){ - config->has_max_harq_tx = 1; - config->max_harq_tx = flexran_get_maxHARQ_TX(mod_id,i); - } - - if(flexran_get_beta_offset_ack_index(mod_id,i) != -1) { - config->has_beta_offset_ack_index = 1; - config->beta_offset_ack_index = flexran_get_beta_offset_ack_index(mod_id,i); - } - - if(flexran_get_beta_offset_ri_index(mod_id,i) != -1) { - config->has_beta_offset_ri_index = 1; - config->beta_offset_ri_index = flexran_get_beta_offset_ri_index(mod_id,i); - } - - if(flexran_get_beta_offset_cqi_index(mod_id,i) != -1) { - config->has_beta_offset_cqi_index = 1; - config->beta_offset_cqi_index = flexran_get_beta_offset_cqi_index(mod_id,i); - } - - if(flexran_get_ack_nack_simultaneous_trans(mod_id,i) != -1) { - config->has_ack_nack_simultaneous_trans = 1; - config->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id,i); - } - - if(flexran_get_simultaneous_ack_nack_cqi(mod_id,i) != -1) { - config->has_simultaneous_ack_nack_cqi = 1; - config->simultaneous_ack_nack_cqi = flexran_get_simultaneous_ack_nack_cqi(mod_id,i); - } - - if(flexran_get_aperiodic_cqi_rep_mode(mod_id,i) != -1) { - config->has_aperiodic_cqi_rep_mode = 1; - int mode = flexran_get_aperiodic_cqi_rep_mode(mod_id,i); - if (mode > 4) { - config->aperiodic_cqi_rep_mode = PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_NONE; - } else { - config->aperiodic_cqi_rep_mode = mode; - } - } - - if(flexran_get_tdd_ack_nack_feedback(mod_id, i) != -1) { - config->has_tdd_ack_nack_feedback = 1; - config->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback(mod_id,i); - } - - if(flexran_get_ack_nack_repetition_factor(mod_id, i) != -1) { - config->has_ack_nack_repetition_factor = 1; - config->ack_nack_repetition_factor = flexran_get_ack_nack_repetition_factor(mod_id,i); - } - - if(flexran_get_extended_bsr_size(mod_id, i) != -1) { - config->has_extended_bsr_size = 1; - config->extended_bsr_size = flexran_get_extended_bsr_size(mod_id,i); - } - - config->has_pcell_carrier_index = 1; - config->pcell_carrier_index = UE_PCCID(mod_id, i); - //TODO: Set carrier aggregation support (boolean) - config->has_ca_support = 0; - config->ca_support = 0; - if(config->has_ca_support){ - //TODO: Set cross carrier scheduling support (boolean) - config->has_cross_carrier_sched_support = 1; - config->cross_carrier_sched_support = 0; - //TODO: Set secondary cells configuration - // We do not set it for now. No carrier aggregation support - - //TODO: Set deactivation timer for secondary cell - config->has_scell_deactivation_timer = 0; - config->scell_deactivation_timer = 0; - } - } else if (state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_MOVED) { - // TODO: Not supported for now. Leave blank - } - - ue_state_change_msg->config = config; - msg = malloc(sizeof(Protocol__FlexranMessage)); - if (msg == NULL) { - goto error; - } - protocol__flexran_message__init(msg); - msg->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_STATE_CHANGE_MSG; - msg->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__INITIATING_MESSAGE; - msg->ue_state_change_msg = ue_state_change_msg; - - data = flexran_agent_pack_message(msg, &size); - /*Send sr info using the MAC channel of the eNB*/ - if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { - goto error; - } - - LOG_D(FLEXRAN_AGENT,"sent message with size %d\n", size); - return 0; - error: - LOG_D(FLEXRAN_AGENT, "Could not send UE state message\n"); - return -1; -} - - int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { @@ -2138,191 +1045,38 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F } +int flexran_agent_rrc_measurement(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { -/* - * timer primitives - */ + protocol_ctxt_t ctxt; -//struct flexran_agent_map agent_map; -flexran_agent_timer_instance_t timer_instance; -int agent_timer_init = 0; -err_code_t flexran_agent_init_timer(void){ + Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params; + Protocol__FlexRrcTriggering *triggering = input->rrc_triggering; + + agent_reconf_rrc *reconf_param = malloc(sizeof(agent_reconf_rrc)); - LOG_I(FLEXRAN_AGENT, "init RB tree\n"); - if (!agent_timer_init) { - RB_INIT(&timer_instance.flexran_agent_head); - agent_timer_init = 1; + + reconf_param->trigger_policy = triggering->rrc_trigger; + + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[mod_id].rrc_ue_head)){ + + + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, ue_context_p->ue_context.rnti, flexran_get_current_frame(mod_id), flexran_get_current_subframe (mod_id), mod_id); + + flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(&ctxt, ue_context_p, 0, reconf_param); + } - - return PROTOCOL__FLEXRAN_ERR__NO_ERR; -} - -RB_GENERATE(flexran_agent_map, flexran_agent_timer_element_s, entry, flexran_agent_compare_timer); - -/* The timer_id might not be the best choice for the comparison */ -int flexran_agent_compare_timer(struct flexran_agent_timer_element_s *a, struct flexran_agent_timer_element_s *b){ - - if (a->timer_id < b->timer_id) return -1; - if (a->timer_id > b->timer_id) return 1; - - // equal timers + + + *msg = NULL; return 0; } -err_code_t flexran_agent_create_timer(uint32_t interval_sec, - uint32_t interval_usec, - agent_id_t agent_id, - instance_t instance, - uint32_t timer_type, - xid_t xid, - flexran_agent_timer_callback_t cb, - void* timer_args, - long *timer_id){ - - struct flexran_agent_timer_element_s *e = calloc(1, sizeof(*e)); - DevAssert(e != NULL); - -//uint32_t timer_id; - int ret=-1; - - if ((interval_sec == 0) && (interval_usec == 0 )) - return TIMER_NULL; - - if (timer_type >= FLEXRAN_AGENT_TIMER_TYPE_MAX) - return TIMER_TYPE_INVALIDE; - - if (timer_type == FLEXRAN_AGENT_TIMER_TYPE_ONESHOT){ - ret = timer_setup(interval_sec, - interval_usec, - TASK_FLEXRAN_AGENT, - instance, - TIMER_ONE_SHOT, - timer_args, - timer_id); + +int flexran_agent_destroy_rrc_measurement(Protocol__FlexranMessage *msg){ - e->type = TIMER_ONE_SHOT; - } - else if (timer_type == FLEXRAN_AGENT_TIMER_TYPE_PERIODIC ){ - ret = timer_setup(interval_sec, - interval_usec, - TASK_FLEXRAN_AGENT, - instance, - TIMER_PERIODIC, - timer_args, - timer_id); - - e->type = TIMER_PERIODIC; - } - - if (ret < 0 ) { - return TIMER_SETUP_FAILED; - } - - e->agent_id = agent_id; - e->instance = instance; - e->state = FLEXRAN_AGENT_TIMER_STATE_ACTIVE; - e->timer_id = *timer_id; - e->xid = xid; - e->timer_args = timer_args; - e->cb = cb; - /*element should be a real pointer*/ - RB_INSERT(flexran_agent_map, &timer_instance.flexran_agent_head, e); - - LOG_I(FLEXRAN_AGENT,"Created a new timer with id 0x%lx for agent %d, instance %d \n", - e->timer_id, e->agent_id, e->instance); - - return 0; -} - -err_code_t flexran_agent_destroy_timer(long timer_id){ - - struct flexran_agent_timer_element_s *e = get_timer_entry(timer_id); - - if (e != NULL ) { - RB_REMOVE(flexran_agent_map, &timer_instance.flexran_agent_head, e); - flexran_agent_destroy_flexran_message(e->timer_args->msg); - free(e); - } - - if (timer_remove(timer_id) < 0 ) - goto error; - - return 0; - - error: - LOG_E(FLEXRAN_AGENT, "timer can't be removed\n"); - return TIMER_REMOVED_FAILED ; -} - -err_code_t flexran_agent_destroy_timer_by_task_id(xid_t xid) { - struct flexran_agent_timer_element_s *e = NULL; - long timer_id; - RB_FOREACH(e, flexran_agent_map, &timer_instance.flexran_agent_head) { - if (e->xid == xid) { - timer_id = e->timer_id; - RB_REMOVE(flexran_agent_map, &timer_instance.flexran_agent_head, e); - flexran_agent_destroy_flexran_message(e->timer_args->msg); - free(e); - if (timer_remove(timer_id) < 0 ) { - goto error; - } - } - } - return 0; - - error: - LOG_E(FLEXRAN_AGENT, "timer can't be removed\n"); - return TIMER_REMOVED_FAILED ; -} - -err_code_t flexran_agent_destroy_timers(void){ - - struct flexran_agent_timer_element_s *e = NULL; - - RB_FOREACH(e, flexran_agent_map, &timer_instance.flexran_agent_head) { - RB_REMOVE(flexran_agent_map, &timer_instance.flexran_agent_head, e); - timer_remove(e->timer_id); - flexran_agent_destroy_flexran_message(e->timer_args->msg); - free(e); - } - - return 0; - -} - -void flexran_agent_sleep_until(struct timespec *ts, int delay) { - ts->tv_nsec += delay; - if(ts->tv_nsec >= 1000*1000*1000){ - ts->tv_nsec -= 1000*1000*1000; - ts->tv_sec++; - } - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, ts, NULL); } -err_code_t flexran_agent_stop_timer(long timer_id){ - - struct flexran_agent_timer_element_s *e=NULL; - struct flexran_agent_timer_element_s search; - memset(&search, 0, sizeof(struct flexran_agent_timer_element_s)); - search.timer_id = timer_id; - e = RB_FIND(flexran_agent_map, &timer_instance.flexran_agent_head, &search); - - if (e != NULL ) { - e->state = FLEXRAN_AGENT_TIMER_STATE_STOPPED; - } - - timer_remove(timer_id); - - return 0; -} - -struct flexran_agent_timer_element_s * get_timer_entry(long timer_id) { - - struct flexran_agent_timer_element_s search; - memset(&search, 0, sizeof(struct flexran_agent_timer_element_s)); - search.timer_id = timer_id; - - return RB_FIND(flexran_agent_map, &timer_instance.flexran_agent_head, &search); -} diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h index abe5a05b44..4f2b9c71bb 100644 --- a/openair2/ENB_APP/flexran_agent_common.h +++ b/openair2/ENB_APP/flexran_agent_common.h @@ -21,8 +21,8 @@ /*! \file flexran_agent_common.h * \brief common message primitves and utilities - * \author Xenofon Foukas, Mohamed Kassem and Navid Nikaein - * \date 2016 + * \author Xenofon Foukas, Mohamed Kassem and Navid Nikaein and shahab SHARIAT BAGHERI + * \date 2017 * \version 0.1 */ @@ -60,6 +60,19 @@ typedef int (*flexran_agent_message_destruction_callback)( Protocol__FlexranMessage *msg ); +typedef struct { + + uint8_t is_initialized; + volatile uint8_t cont_update; + xid_t xid; + Protocol__FlexranMessage *stats_req; + Protocol__FlexranMessage *prev_stats_reply; + + pthread_mutex_t *mutex; +} stats_updates_context_t; + +stats_updates_context_t stats_context[NUM_MAX_ENB]; + /********************************** * FlexRAN protocol messages helper * functions and generic handlers @@ -116,10 +129,6 @@ int flexran_agent_destroy_ue_config_request(Protocol__FlexranMessage *msg); /* TODO: Need to define and implement destructor */ int flexran_agent_destroy_lc_config_request(Protocol__FlexranMessage *msg); -/* UE state change message constructor and destructor */ -int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change); -int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg); - /* Control delegation message constructor and destructor */ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg); int flexran_agent_destroy_control_delegation(Protocol__FlexranMessage *msg); @@ -128,6 +137,11 @@ int flexran_agent_destroy_control_delegation(Protocol__FlexranMessage *msg); int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg); int flexran_agent_destroy_agent_reconfiguration(Protocol__FlexranMessage *msg); +/* rrc triggering measurement message constructor and destructor */ +int flexran_agent_rrc_measurement(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg); +int flexran_agent_destroy_rrc_measurement(Protocol__FlexranMessage *msg); + + /* FlexRAN protocol message dispatcher function */ Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id, uint8_t *data, @@ -136,367 +150,22 @@ Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id, /* Function to be used to send a message to a dispatcher once the appropriate event is triggered. */ Protocol__FlexranMessage *flexran_agent_handle_timed_task(void *args); +/*Top level Statistics hanlder*/ +int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg); +/* Function to be used to handle reply message . */ +int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *report_config, Protocol__FlexranMessage **msg); +/* Statistics request protocol message constructor and destructor */ +int flexran_agent_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg); +int flexran_agent_destroy_stats_request(Protocol__FlexranMessage *msg); -/**************************** - * get generic info from RAN - ****************************/ +int flexran_agent_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg); +int flexran_agent_destroy_stats_request(Protocol__FlexranMessage *msg); + +err_code_t flexran_agent_enable_cont_stats_update(mid_t mod_id, xid_t xid, stats_request_config_t *stats_req) ; -void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran); - -int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag); - -/*Return the current frame number - *Could be using implementation specific numbering of frames - */ -unsigned int flexran_get_current_frame(mid_t mod_id); - -/*Return the current SFN (0-1023)*/ -unsigned int flexran_get_current_system_frame_num(mid_t mod_id); - -unsigned int flexran_get_current_subframe(mid_t mod_id); - -/*Return the frame and subframe number in compact 16-bit format. - Bits 0-3 subframe, rest for frame. Required by FlexRAN protocol*/ -uint16_t flexran_get_sfn_sf (mid_t mod_id); - -/* Return a future frame and subframe number that is ahead_of_time - subframes later in compact 16-bit format. Bits 0-3 subframe, - rest for frame */ -uint16_t flexran_get_future_sfn_sf(mid_t mod_id, int ahead_of_time); - -/* Return the number of attached UEs */ -int flexran_get_num_ues(mid_t mod_id); - -/* Get the rnti of a UE with id ue_id */ -int flexran_get_ue_crnti (mid_t mod_id, mid_t ue_id); - -/* Get the RLC buffer status report of a ue for a designated - logical channel id */ -int flexran_get_ue_bsr (mid_t mod_id, mid_t ue_id, lcid_t lcid); - -/* Get power headroom of UE with id ue_id */ -int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id); - -/* Get the UE wideband CQI */ -int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id); - -/* Get the transmission queue size for a UE with a channel_id logical channel id */ -int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); - -/* Get the head of line delay for a UE with a channel_id logical channel id */ -int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); - -/* Check the status of the timing advance for a UE */ -short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id); - -/* Update the timing advance status (find out whether a timing advance command is required) */ -void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id); - -/* Return timing advance MAC control element for a designated cell and UE */ -int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id, int CC_id); - -/* Get the number of active component carriers for a specific UE */ -int flexran_get_active_CC(mid_t mod_id, mid_t ue_id); - -/* Get the rank indicator for a designated cell and UE */ -int flexran_get_current_RI(mid_t mod_id, mid_t ue_id, int CC_id); - -/* See TS 36.213, section 10.1 */ -int flexran_get_n1pucch_an(mid_t mod_id, int CC_id); - -/* See TS 36.211, section 5.4 */ -int flexran_get_nRB_CQI(mid_t mod_id, int CC_id); - -/* See TS 36.211, section 5.4 */ -int flexran_get_deltaPUCCH_Shift(mid_t mod_id, int CC_id); - -/* See TS 36.211, section 5.7.1 */ -int flexran_get_prach_ConfigIndex(mid_t mod_id, int CC_id); - -/* See TS 36.211, section 5.7.1 */ -int flexran_get_prach_FreqOffset(mid_t mod_id, int CC_id); - -/* See TS 36.321 */ -int flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, int CC_id); - -/* Get the length of the UL cyclic prefix */ -int flexran_get_ul_cyclic_prefix_length(mid_t mod_id, int CC_id); - -/* Get the length of the DL cyclic prefix */ -int flexran_get_dl_cyclic_prefix_length(mid_t mod_id, int CC_id); - -/* Get the physical cell id of a cell */ -int flexran_get_cell_id(mid_t mod_id, int CC_id); - -/* See TS 36.211, section 5.5.3.2 */ -int flexran_get_srs_BandwidthConfig(mid_t mod_id, int CC_id); - -/* See TS 36.211, table 5.5.3.3-1 and 2 */ -int flexran_get_srs_SubframeConfig(mid_t mod_id, int CC_id); - -/* Boolean value. See TS 36.211, - section 5.5.3.2. TDD only */ -int flexran_get_srs_MaxUpPts(mid_t mod_id, int CC_id); - -/* Get number of DL resource blocks */ -int flexran_get_N_RB_DL(mid_t mod_id, int CC_id); - -/* Get number of UL resource blocks */ -int flexran_get_N_RB_UL(mid_t mod_id, int CC_id); - -/* Get number of resource block groups */ -int flexran_get_N_RBG(mid_t mod_id, int CC_id); - -/* Get DL/UL subframe assignment. TDD only */ -int flexran_get_subframe_assignment(mid_t mod_id, int CC_id); - -/* TDD only. See TS 36.211, table 4.2.1 */ -int flexran_get_special_subframe_assignment(mid_t mod_id, int CC_id); - -/* Get the duration of the random access response window in subframes */ -int flexran_get_ra_ResponseWindowSize(mid_t mod_id, int CC_id); - -/* Get timer used for random access */ -int flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, int CC_id); - -/* Get type of duplex mode (FDD/TDD) */ -int flexran_get_duplex_mode(mid_t mod_id, int CC_id); - -/* Get the SI window length */ -long flexran_get_si_window_length(mid_t mod_id, int CC_id); - -/* Get the number of PDCCH symbols configured for the cell */ -int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id); - -/* See TS 36.213, sec 5.1.1.1 */ -int flexran_get_tpc(mid_t mod_id, mid_t ue_id); - -/* Get the first available HARQ process for a specific cell and UE during - a designated frame and subframe. Returns 0 for success. The id and the - status of the HARQ process are stored in id and status respectively */ -int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, - const int frame, const uint8_t subframe, unsigned char *id, unsigned char *round); - -/* Uplink power control management*/ -int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id); - -int flexran_get_p0_nominal_pucch(mid_t mod_id, int CC_id); - -int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id); - -int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id); - - -/* - * ************************************ - * Get Messages for UE Configuration Reply - * ************************************ - */ - -/* Get timer in subframes. Controls the synchronization - status of the UE, not the actual timing - advance procedure. See TS 36.321 */ -int flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id); - -/* Get measurement gap configuration. See TS 36.133 */ -int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id); - -/* Get measurement gap configuration offset if applicable */ -int flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id); - -/* DL aggregated bit-rate of non-gbr bearer - per UE. See TS 36.413 */ -int flexran_get_ue_aggregated_max_bitrate_dl (mid_t mod_id, mid_t ue_id); - -/* UL aggregated bit-rate of non-gbr bearer - per UE. See TS 36.413 */ -int flexran_get_ue_aggregated_max_bitrate_ul (mid_t mod_id, mid_t ue_id); - -/* Only half-duplex support. FDD - operation. Boolean value */ -int flexran_get_half_duplex(mid_t ue_id); - -/* Support of intra-subframe hopping. - Boolean value */ -int flexran_get_intra_sf_hopping(mid_t ue_id); - -/* UE support for type 2 hopping with - n_sb>1 */ -int flexran_get_type2_sb_1(mid_t ue_id); - -/* Get the UE category */ -int flexran_get_ue_category(mid_t ue_id); - -/* UE support for resource allocation - type 1 */ -int flexran_get_res_alloc_type1(mid_t ue_id); - -/* Get UE transmission mode */ -int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id); - -/* Boolean value. See TS 36.321 */ -int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id); - -/* The max HARQ retransmission for UL. - See TS 36.321 */ -int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id); - -/* See TS 36.213 */ -int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id); - -/* See TS 36.213 */ -int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id); - -/* See TS 36.213 */ -int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id); - -/* Boolean. See TS36.213, Section 10.1 */ -int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id); - -/* Boolean. See TS 36.213, Section 8.2 */ -int flexran_get_ack_nack_simultaneous_trans(mid_t mod_id,mid_t ue_id); - -/* Get aperiodic CQI report mode */ -int flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id); - -/* Get ACK/NACK feedback mode. TDD only */ -int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id); - -/* See TS36.213, section 10.1 */ -int flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id); - -/* Boolean. Extended buffer status report size */ -int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id); - -/* Get number of UE transmission antennas */ -int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id); - -/* Get logical channel group of a channel with id lc_id */ -int flexran_get_lcg(mid_t ue_id, mid_t lc_id); - -/* Get direction of logical channel with id lc_id */ -int flexran_get_direction(mid_t ue_id, mid_t lc_id); - -/******************* - * timer primitves - *******************/ - -#define TIMER_NULL -1 -#define TIMER_TYPE_INVALIDE -2 -#define TIMER_SETUP_FAILED -3 -#define TIMER_REMOVED_FAILED -4 -#define TIMER_ELEMENT_NOT_FOUND -5 - - -/* Type of the callback executed when the timer expired */ -typedef Protocol__FlexranMessage *(*flexran_agent_timer_callback_t)(void*); - -typedef enum { - /* oneshot timer: */ - FLEXRAN_AGENT_TIMER_TYPE_ONESHOT = 0x0, - - /* periodic timer */ - FLEXRAN_AGENT_TIMER_TYPE_PERIODIC = 0x1, - - /* Inactive state: initial state for any timer. */ - FLEXRAN_AGENT_TIMER_TYPE_EVENT_DRIVEN = 0x2, - - /* Max number of states available */ - FLEXRAN_AGENT_TIMER_TYPE_MAX, -} flexran_agent_timer_type_t; - -typedef enum { - /* Inactive state: initial state for any timer. */ - FLEXRAN_AGENT_TIMER_STATE_INACTIVE = 0x0, - - /* Inactive state: initial state for any timer. */ - FLEXRAN_AGENT_TIMER_STATE_ACTIVE = 0x1, - - /* Inactive state: initial state for any timer. */ - FLEXRAN_AGENT_TIMER_STATE_STOPPED = 0x2, - - /* Max number of states available */ - FLEXRAN_AGENT_TIMER_STATE_MAX, -} flexran_agent_timer_state_t; - -typedef struct flexran_agent_timer_args_s{ - mid_t mod_id; - Protocol__FlexranMessage *msg; -} flexran_agent_timer_args_t; - - - -typedef struct flexran_agent_timer_element_s{ - RB_ENTRY(flexran_agent_timer_element_s) entry; - - agent_id_t agent_id; - instance_t instance; - - flexran_agent_timer_type_t type; - flexran_agent_timer_state_t state; - - uint32_t interval_sec; - uint32_t interval_usec; - - long timer_id; /* Timer id returned by the timer API*/ - xid_t xid; /*The id of the task as received by the controller - message*/ - - flexran_agent_timer_callback_t cb; - flexran_agent_timer_args_t *timer_args; - -} flexran_agent_timer_element_t; - -typedef struct flexran_agent_timer_instance_s{ - RB_HEAD(flexran_agent_map, flexran_agent_timer_element_s) flexran_agent_head; -}flexran_agent_timer_instance_t; - - -err_code_t flexran_agent_init_timer(void); - -/* Create a timer for some agent related event with id xid. Will store the id - of the generated timer in timer_id */ -err_code_t flexran_agent_create_timer(uint32_t interval_sec, - uint32_t interval_usec, - agent_id_t agent_id, - instance_t instance, - uint32_t timer_type, - xid_t xid, - flexran_agent_timer_callback_t cb, - void* timer_args, - long *timer_id); - -/* Destroy all existing timers */ -err_code_t flexran_agent_destroy_timers(void); - -/* Destroy the timer with the given timer_id */ -err_code_t flexran_agent_destroy_timer(long timer_id); - -/* Destroy the timer for task with id xid */ -err_code_t flexran_agent_destroy_timer_by_task_id(xid_t xid); - -/* Stop a timer */ -err_code_t flexran_agent_stop_timer(long timer_id); - -/* Restart the given timer */ -err_code_t flexran_agent_restart_timer(long *timer_id); - -/* Find the timer with the given timer_id */ -struct flexran_agent_timer_element_s * get_timer_entry(long timer_id); - -/* Obtain the protocol message stored in the given expired timer */ -Protocol__FlexranMessage * flexran_agent_process_timeout(long timer_id, void* timer_args); - -/* Comparator function comparing two timers. Decides the ordering of the timers */ -int flexran_agent_compare_timer(struct flexran_agent_timer_element_s *a, struct flexran_agent_timer_element_s *b); - -/*Specify a delay in nanoseconds to timespec and sleep until then*/ -void flexran_agent_sleep_until(struct timespec *ts, int delay); - -/* RB_PROTOTYPE is for .h files */ -RB_PROTOTYPE(flexran_agent_map, flexran_agent_timer_element_s, entry, flexran_agent_compare_timer); +int flexran_agent_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg); #endif diff --git a/openair2/ENB_APP/flexran_agent_defs.h b/openair2/ENB_APP/flexran_agent_defs.h index d60510b0c7..0b8822a949 100644 --- a/openair2/ENB_APP/flexran_agent_defs.h +++ b/openair2/ENB_APP/flexran_agent_defs.h @@ -21,8 +21,8 @@ /*! \file flexran_agent_defs.h * \brief FlexRAN agent common definitions - * \author Navid Nikaein and Xenofon Foukas - * \date 2016 + * \author Navid Nikaein and Xenofon Foukas and shahab SHARIAT BAGHERI + * \date 2017 * \version 0.1 */ #ifndef FLEXRAN_AGENT_DEFS_H_ @@ -102,6 +102,38 @@ typedef uint8_t lcid_t; typedef int32_t err_code_t; +/*---------Timer Enums --------- */ + +typedef enum { + /* oneshot timer: */ + FLEXRAN_AGENT_TIMER_TYPE_ONESHOT = 0, + + /* periodic timer */ + FLEXRAN_AGENT_TIMER_TYPE_PERIODIC = 1, + + /* Inactive state: initial state for any timer. */ + FLEXRAN_AGENT_TIMER_TYPE_EVENT_DRIVEN = 2, + + /* Max number of states available */ + FLEXRAN_AGENT_TIMER_TYPE_MAX, +} flexran_agent_timer_type_t; + + +typedef enum { + /* Inactive state: initial state for any timer. */ + FLEXRAN_AGENT_TIMER_STATE_INACTIVE = 0x0, + + /* Inactive state: initial state for any timer. */ + FLEXRAN_AGENT_TIMER_STATE_ACTIVE = 0x1, + + /* Inactive state: initial state for any timer. */ + FLEXRAN_AGENT_TIMER_STATE_STOPPED = 0x2, + + /* Max number of states available */ + FLEXRAN_AGENT_TIMER_STATE_MAX, +} flexran_agent_timer_state_t; + + typedef struct { /* general info */ @@ -116,6 +148,53 @@ typedef struct { } flexran_agent_info_t; + +/* +rrc triggering + */ + + +typedef struct { + char * trigger_policy; + uint32_t report_interval; + uint32_t report_amount; + +} agent_reconf_rrc; + + +/* These structs will be used to give + instructions for the type of stats reports + we need to create */ + + +typedef struct { + uint16_t ue_rnti; + uint32_t ue_report_flags; /* Indicates the report elements + required for this UE id. See + FlexRAN specification 1.2.4.2 */ +} ue_report_type_t; + +typedef struct { + uint16_t cc_id; + uint32_t cc_report_flags; /* Indicates the report elements + required for this CC index. See + FlexRAN specification 1.2.4.3 */ +} cc_report_type_t; + +typedef struct { + int nr_ue; + ue_report_type_t *ue_report_type; + int nr_cc; + cc_report_type_t *cc_report_type; +} report_config_t; + +typedef struct stats_request_config_s{ + uint8_t report_type; + uint8_t report_frequency; + uint16_t period; /*In number of subframes*/ + report_config_t *config; +} stats_request_config_t; + typedef struct { mid_t enb_id; flexran_agent_info_t agent_info; diff --git a/openair2/ENB_APP/flexran_agent_extern.h b/openair2/ENB_APP/flexran_agent_extern.h index 4a04d5d3a6..4df984e1a0 100644 --- a/openair2/ENB_APP/flexran_agent_extern.h +++ b/openair2/ENB_APP/flexran_agent_extern.h @@ -20,9 +20,9 @@ */ /*! \file ENB_APP/extern.h - * \brief FlexRAN agent - mac interface primitives - * \author Xenofon Foukas - * \date 2016 + * \brief FlexRAN agent - Extern VSF xfaces + * \author Xenofon Foukas and shahab SHARIAT BAGHERI + * \date 2017 * \version 0.1 * \mail x.foukas@sms.ed.ac.uk */ @@ -30,9 +30,9 @@ #ifndef __FLEXRAN_AGENT_EXTERN_H__ #define __FLEXRAN_AGENT_EXTERN_H__ -#include "flexran_agent_defs.h" +// #include "flexran_agent_defs.h" #include "flexran_agent_mac_defs.h" - +#include "flexran_agent_rrc_defs.h" //extern msg_context_t shared_ctxt[NUM_MAX_ENB][FLEXRAN_AGENT_MAX]; @@ -45,6 +45,12 @@ extern AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]; /* Flag indicating whether the VSFs for the MAC control module have been registered */ extern unsigned int mac_agent_registered[NUM_MAX_ENB]; +/* Control module interface for the communication of the RRC Control Module with the agent */ +extern AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]; + +/* Flag indicating whether the VSFs for the RRC control module have been registered */ +extern unsigned int rrc_agent_registered[NUM_MAX_ENB]; + /* Requried to know which UEs had a harq updated over some subframe */ extern int harq_pid_updated[NUMBER_OF_UE_MAX][8]; extern int harq_pid_round[NUMBER_OF_UE_MAX][8]; diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index 29a1c1000c..b57039bec5 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -21,14 +21,16 @@ /*! \file flexran_agent_handler.c * \brief FlexRAN agent tx and rx message handler - * \author Xenofon Foukas and Navid Nikaein - * \date 2016 + * \author Xenofon Foukas and Navid Nikaein and shahab SHARIAT BAGHERI + * \date 2017 * \version 0.1 */ - +#include "flexran_agent_defs.h" #include "flexran_agent_common.h" #include "flexran_agent_mac.h" +#include "flexran_agent_rrc.h" +#include "flexran_agent_timer.h" #include "log.h" #include "assertions.h" @@ -37,7 +39,7 @@ flexran_agent_message_decoded_callback agent_messages_callback[][3] = { {flexran_agent_hello, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_HELLO_MSG*/ {flexran_agent_echo_reply, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_ECHO_REQUEST_MSG*/ {0, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_ECHO_REPLY_MSG*/ //Must add handler when receiving echo reply - {flexran_agent_mac_handle_stats, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REQUEST_MSG*/ + {flexran_agent_handle_stats, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REQUEST_MSG*/ {0, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG*/ {0, 0, 0}, /*PROTOCOK__FLEXRAN_MESSAGE__MSG_SF_TRIGGER_MSG*/ {0, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_UL_SR_INFO_MSG*/ @@ -51,13 +53,14 @@ flexran_agent_message_decoded_callback agent_messages_callback[][3] = { {0, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_STATE_CHANGE_MSG*/ {flexran_agent_control_delegation, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_CONTROL_DELEGATION_MSG*/ {flexran_agent_reconfiguration, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_AGENT_RECONFIGURATION_MSG*/ + {flexran_agent_rrc_measurement, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_RRC_TRIGGERING_MSG*/ }; flexran_agent_message_destruction_callback message_destruction_callback[] = { flexran_agent_destroy_hello, flexran_agent_destroy_echo_request, flexran_agent_destroy_echo_reply, - flexran_agent_mac_destroy_stats_request, + flexran_agent_destroy_stats_request, flexran_agent_mac_destroy_stats_reply, flexran_agent_mac_destroy_sf_trigger, flexran_agent_mac_destroy_sr_info, @@ -93,7 +96,7 @@ Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id, err_code= PROTOCOL__FLEXRAN_ERR__MSG_DECODING; goto error; } - + printf("==================> %d %d \n", decoded_message->msg_case, decoded_message->msg_dir); if ((decoded_message->msg_case > sizeof(agent_messages_callback) / (3 * sizeof(flexran_agent_message_decoded_callback))) || (decoded_message->msg_dir > PROTOCOL__FLEXRAN_DIRECTION__UNSUCCESSFUL_OUTCOME)){ err_code= PROTOCOL__FLEXRAN_ERR__MSG_NOT_HANDLED; @@ -187,3 +190,568 @@ Protocol__FlexranMessage* flexran_agent_process_timeout(long timer_id, void* tim err_code_t flexran_agent_destroy_flexran_message(Protocol__FlexranMessage *msg) { return ((*message_destruction_callback[msg->msg_case-1])(msg)); } + + +/* + Top Level Statistics Report + + */ + + + +int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg){ + + // TODO: Must deal with sanitization of input + // TODO: Must check if RNTIs and cell ids of the request actually exist + // TODO: Must resolve conflicts among stats requests + + int i; + err_code_t err_code; + xid_t xid; + uint32_t usec_interval, sec_interval; + + //TODO: We do not deal with multiple CCs at the moment and eNB id is 0 + int enb_id = mod_id; + + //eNB_MAC_INST *eNB = &eNB_mac_inst[enb_id]; + //UE_list_t *eNB_UE_list= &eNB->UE_list; + + report_config_t report_config; + + uint32_t ue_flags = 0; + uint32_t c_flags = 0; + + Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params; + + Protocol__FlexStatsRequest *stats_req = input->stats_request_msg; + xid = (stats_req->header)->xid; + + // Check the type of request that is made + switch(stats_req->body_case) { + case PROTOCOL__FLEX_STATS_REQUEST__BODY_COMPLETE_STATS_REQUEST: ; + Protocol__FlexCompleteStatsRequest *comp_req = stats_req->complete_stats_request; + if (comp_req->report_frequency == PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_OFF) { + /*Disable both periodic and continuous updates*/ + // flexran_agent_disable_cont_stats_update(mod_id); + flexran_agent_destroy_timer_by_task_id(xid); + *msg = NULL; + return 0; + } else { //One-off, periodical or continuous reporting + //Set the proper flags + ue_flags = comp_req->ue_report_flags; + c_flags = comp_req->cell_report_flags; + //Create a list of all eNB RNTIs and cells + + //Set the number of UEs and create list with their RNTIs stats configs + report_config.nr_ue = flexran_get_num_ues(mod_id); //eNB_UE_list->num_UEs + report_config.ue_report_type = (ue_report_type_t *) malloc(sizeof(ue_report_type_t) * report_config.nr_ue); + if (report_config.ue_report_type == NULL) { + // TODO: Add appropriate error code + err_code = -100; + goto error; + } + for (i = 0; i < report_config.nr_ue; i++) { + report_config.ue_report_type[i].ue_rnti = flexran_get_ue_crnti(enb_id, i); //eNB_UE_list->eNB_UE_stats[UE_PCCID(enb_id,i)][i].crnti; + report_config.ue_report_type[i].ue_report_flags = ue_flags; + } + //Set the number of CCs and create a list with the cell stats configs + report_config.nr_cc = MAX_NUM_CCs; + report_config.cc_report_type = (cc_report_type_t *) malloc(sizeof(cc_report_type_t) * report_config.nr_cc); + if (report_config.cc_report_type == NULL) { + // TODO: Add appropriate error code + err_code = -100; + goto error; + } + for (i = 0; i < report_config.nr_cc; i++) { + //TODO: Must fill in the proper cell ids + report_config.cc_report_type[i].cc_id = i; + report_config.cc_report_type[i].cc_report_flags = c_flags; + } + /* Check if request was periodical */ + if (comp_req->report_frequency == PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_PERIODICAL) { + /* Create a one off flexran message as an argument for the periodical task */ + Protocol__FlexranMessage *timer_msg; + stats_request_config_t request_config; + request_config.report_type = PROTOCOL__FLEX_STATS_TYPE__FLST_COMPLETE_STATS; + request_config.report_frequency = PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_ONCE; + request_config.period = 0; + /* Need to make sure that the ue flags are saved (Bug) */ + if (report_config.nr_ue == 0) { + report_config.nr_ue = 1; + report_config.ue_report_type = (ue_report_type_t *) malloc(sizeof(ue_report_type_t)); + if (report_config.ue_report_type == NULL) { + // TODO: Add appropriate error code + err_code = -100; + goto error; + } + report_config.ue_report_type[0].ue_rnti = 0; // Dummy value + report_config.ue_report_type[0].ue_report_flags = ue_flags; + } + request_config.config = &report_config; + flexran_agent_stats_request(enb_id, xid, &request_config, &timer_msg); + /* Create a timer */ + long timer_id = 0; + flexran_agent_timer_args_t *timer_args; + timer_args = malloc(sizeof(flexran_agent_timer_args_t)); + memset (timer_args, 0, sizeof(flexran_agent_timer_args_t)); + timer_args->mod_id = enb_id; + timer_args->msg = timer_msg; + /*Convert subframes to usec time*/ + usec_interval = 1000*comp_req->sf; + sec_interval = 0; + /*add seconds if required*/ + if (usec_interval >= 1000*1000) { + sec_interval = usec_interval/(1000*1000); + usec_interval = usec_interval%(1000*1000); + } + flexran_agent_create_timer(sec_interval, usec_interval, FLEXRAN_AGENT_DEFAULT, enb_id, FLEXRAN_AGENT_TIMER_TYPE_PERIODIC, xid, flexran_agent_handle_timed_task,(void*) timer_args, &timer_id); + } else if (comp_req->report_frequency == PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_CONTINUOUS) { + /*If request was for continuous updates, disable the previous configuration and + set up a new one*/ + // flexran_agent_disable_cont_stats_update(mod_id); + stats_request_config_t request_config; + request_config.report_type = PROTOCOL__FLEX_STATS_TYPE__FLST_COMPLETE_STATS; + request_config.report_frequency = PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_ONCE; + request_config.period = 0; + /* Need to make sure that the ue flags are saved (Bug) */ + if (report_config.nr_ue == 0) { + report_config.nr_ue = 1; + report_config.ue_report_type = (ue_report_type_t *) malloc(sizeof(ue_report_type_t)); + if (report_config.ue_report_type == NULL) { + // TODO: Add appropriate error code + err_code = -100; + goto error; + } + report_config.ue_report_type[0].ue_rnti = 0; // Dummy value + report_config.ue_report_type[0].ue_report_flags = ue_flags; + } + request_config.config = &report_config; + flexran_agent_enable_cont_stats_update(enb_id, xid, &request_config); + } + } + break; + case PROTOCOL__FLEX_STATS_REQUEST__BODY_CELL_STATS_REQUEST:; + Protocol__FlexCellStatsRequest *cell_req = stats_req->cell_stats_request; + // UE report config will be blank + report_config.nr_ue = 0; + report_config.ue_report_type = NULL; + report_config.nr_cc = cell_req->n_cell; + report_config.cc_report_type = (cc_report_type_t *) malloc(sizeof(cc_report_type_t) * report_config.nr_cc); + if (report_config.cc_report_type == NULL) { + // TODO: Add appropriate error code + err_code = -100; + goto error; + } + for (i = 0; i < report_config.nr_cc; i++) { + //TODO: Must fill in the proper cell ids + report_config.cc_report_type[i].cc_id = cell_req->cell[i]; + report_config.cc_report_type[i].cc_report_flags = cell_req->flags; + } + break; + case PROTOCOL__FLEX_STATS_REQUEST__BODY_UE_STATS_REQUEST:; + Protocol__FlexUeStatsRequest *ue_req = stats_req->ue_stats_request; + // Cell report config will be blank + report_config.nr_cc = 0; + report_config.cc_report_type = NULL; + report_config.nr_ue = ue_req->n_rnti; + report_config.ue_report_type = (ue_report_type_t *) malloc(sizeof(ue_report_type_t) * report_config.nr_ue); + if (report_config.ue_report_type == NULL) { + // TODO: Add appropriate error code + err_code = -100; + goto error; + } + for (i = 0; i < report_config.nr_ue; i++) { + report_config.ue_report_type[i].ue_rnti = ue_req->rnti[i]; + report_config.ue_report_type[i].ue_report_flags = ue_req->flags; + } + break; + default: + //TODO: Add appropriate error code + err_code = -100; + goto error; + } + + if (flexran_agent_stats_reply(enb_id, xid, &report_config, msg )){ + err_code = PROTOCOL__FLEXRAN_ERR__MSG_BUILD; + goto error; + } + + free(report_config.ue_report_type); + free(report_config.cc_report_type); + + return 0; + + error : + LOG_E(FLEXRAN_AGENT, "errno %d occured\n", err_code); + return err_code; +} + +/* + Top level reply + */ + +int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *report_config, Protocol__FlexranMessage **msg){ + + Protocol__FlexHeader *header; + err_code_t err_code; + int i; + + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) + goto error; + + + Protocol__FlexStatsReply *stats_reply_msg; + + stats_reply_msg = malloc(sizeof(Protocol__FlexStatsReply)); + + if (stats_reply_msg == NULL) + goto error; + + protocol__flex_stats_reply__init(stats_reply_msg); + stats_reply_msg->header = header; + + stats_reply_msg->n_ue_report = report_config->nr_ue; + stats_reply_msg->n_cell_report = report_config->nr_cc; + + // UE report + + Protocol__FlexUeStatsReport **ue_report; + + + ue_report = malloc(sizeof(Protocol__FlexUeStatsReport *) * report_config->nr_ue); + if (ue_report == NULL) + goto error; + + for (i = 0; i < report_config->nr_ue; i++) { + + ue_report[i] = malloc(sizeof(Protocol__FlexUeStatsReport)); + protocol__flex_ue_stats_report__init(ue_report[i]); + ue_report[i]->rnti = report_config->ue_report_type[i].ue_rnti; + ue_report[i]->has_rnti = 1; + ue_report[i]->flags = report_config->ue_report_type[i].ue_report_flags; + ue_report[i]->has_flags = 1; + + } + + // cell rpoert + + Protocol__FlexCellStatsReport **cell_report; + + + cell_report = malloc(sizeof(Protocol__FlexCellStatsReport *) * report_config->nr_cc); + if (cell_report == NULL) + goto error; + + for (i = 0; i < report_config->nr_cc; i++) { + + cell_report[i] = malloc(sizeof(Protocol__FlexCellStatsReport)); + if(cell_report[i] == NULL) + goto error; + + protocol__flex_cell_stats_report__init(cell_report[i]); + cell_report[i]->carrier_index = report_config->cc_report_type[i].cc_id; + cell_report[i]->has_carrier_index = 1; + cell_report[i]->flags = report_config->cc_report_type[i].cc_report_flags; + cell_report[i]->has_flags = 1; + + } + + /* + MAC reply split + */ + + + if (flexran_agent_mac_stats_reply(enb_id, report_config, ue_report, cell_report) < 0 ) { + err_code = PROTOCOL__FLEXRAN_ERR__MSG_BUILD; + goto error; + } + + + stats_reply_msg->cell_report = cell_report; + stats_reply_msg->ue_report = ue_report; + + *msg = malloc(sizeof(Protocol__FlexranMessage)); + if(*msg == NULL) + goto error; + protocol__flexran_message__init(*msg); + (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG; + (*msg)->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__SUCCESSFUL_OUTCOME; + (*msg)->stats_reply_msg = stats_reply_msg; + + return 0; + +error : + LOG_E(FLEXRAN_AGENT, "errno %d occured\n", err_code); + return err_code; + +} + +/* + Top Level Request + */ + +int flexran_agent_stats_request(mid_t mod_id, + xid_t xid, + const stats_request_config_t *report_config, + Protocol__FlexranMessage **msg) { + Protocol__FlexHeader *header; + int i; + + Protocol__FlexStatsRequest *stats_request_msg; + stats_request_msg = malloc(sizeof(Protocol__FlexStatsRequest)); + if(stats_request_msg == NULL) + goto error; + protocol__flex_stats_request__init(stats_request_msg); + + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REQUEST, &header) != 0) + goto error; + + stats_request_msg->header = header; + + stats_request_msg->type = report_config->report_type; + stats_request_msg->has_type = 1; + + switch (report_config->report_type) { + case PROTOCOL__FLEX_STATS_TYPE__FLST_COMPLETE_STATS: + stats_request_msg->body_case = PROTOCOL__FLEX_STATS_REQUEST__BODY_COMPLETE_STATS_REQUEST; + Protocol__FlexCompleteStatsRequest *complete_stats; + complete_stats = malloc(sizeof(Protocol__FlexCompleteStatsRequest)); + if(complete_stats == NULL) + goto error; + protocol__flex_complete_stats_request__init(complete_stats); + complete_stats->report_frequency = report_config->report_frequency; + complete_stats->has_report_frequency = 1; + complete_stats->sf = report_config->period; + complete_stats->has_sf = 1; + complete_stats->has_cell_report_flags = 1; + complete_stats->has_ue_report_flags = 1; + if (report_config->config->nr_cc > 0) { + complete_stats->cell_report_flags = report_config->config->cc_report_type[0].cc_report_flags; + } + if (report_config->config->nr_ue > 0) { + complete_stats->ue_report_flags = report_config->config->ue_report_type[0].ue_report_flags; + } + stats_request_msg->complete_stats_request = complete_stats; + break; + case PROTOCOL__FLEX_STATS_TYPE__FLST_CELL_STATS: + stats_request_msg->body_case = PROTOCOL__FLEX_STATS_REQUEST__BODY_CELL_STATS_REQUEST; + Protocol__FlexCellStatsRequest *cell_stats; + cell_stats = malloc(sizeof(Protocol__FlexCellStatsRequest)); + if(cell_stats == NULL) + goto error; + protocol__flex_cell_stats_request__init(cell_stats); + cell_stats->n_cell = report_config->config->nr_cc; + cell_stats->has_flags = 1; + if (cell_stats->n_cell > 0) { + uint32_t *cells; + cells = (uint32_t *) malloc(sizeof(uint32_t)*cell_stats->n_cell); + for (i = 0; i < cell_stats->n_cell; i++) { + cells[i] = report_config->config->cc_report_type[i].cc_id; + } + cell_stats->cell = cells; + cell_stats->flags = report_config->config->cc_report_type[i].cc_report_flags; + } + stats_request_msg->cell_stats_request = cell_stats; + break; + case PROTOCOL__FLEX_STATS_TYPE__FLST_UE_STATS: + stats_request_msg->body_case = PROTOCOL__FLEX_STATS_REQUEST__BODY_UE_STATS_REQUEST; + Protocol__FlexUeStatsRequest *ue_stats; + ue_stats = malloc(sizeof(Protocol__FlexUeStatsRequest)); + if(ue_stats == NULL) + goto error; + protocol__flex_ue_stats_request__init(ue_stats); + ue_stats->n_rnti = report_config->config->nr_ue; + ue_stats->has_flags = 1; + if (ue_stats->n_rnti > 0) { + uint32_t *ues; + ues = (uint32_t *) malloc(sizeof(uint32_t)*ue_stats->n_rnti); + for (i = 0; i < ue_stats->n_rnti; i++) { + ues[i] = report_config->config->ue_report_type[i].ue_rnti; + } + ue_stats->rnti = ues; + ue_stats->flags = report_config->config->ue_report_type[i].ue_report_flags; + } + stats_request_msg->ue_stats_request = ue_stats; + break; + default: + goto error; + } + *msg = malloc(sizeof(Protocol__FlexranMessage)); + if(*msg == NULL) + goto error; + protocol__flexran_message__init(*msg); + (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REQUEST_MSG; + (*msg)->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__INITIATING_MESSAGE; + (*msg)->stats_request_msg = stats_request_msg; + return 0; + + error: + // TODO: Need to make proper error handling + if (header != NULL) + free(header); + if (stats_request_msg != NULL) + free(stats_request_msg); + if(*msg != NULL) + free(*msg); + //LOG_E(MAC, "%s: an error occured\n", __FUNCTION__); + return -1; +} + +int flexran_agent_destroy_stats_request(Protocol__FlexranMessage *msg) { + if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REQUEST_MSG) + goto error; + free(msg->stats_request_msg->header); + if (msg->stats_request_msg->body_case == PROTOCOL__FLEX_STATS_REQUEST__BODY_CELL_STATS_REQUEST) { + free(msg->stats_request_msg->cell_stats_request->cell); + } + if (msg->stats_request_msg->body_case == PROTOCOL__FLEX_STATS_REQUEST__BODY_UE_STATS_REQUEST) { + free(msg->stats_request_msg->ue_stats_request->rnti); + } + free(msg->stats_request_msg); + free(msg); + return 0; + + error: + //LOG_E(MAC, "%s: an error occured\n", __FUNCTION__); + return -1; +} + +/* + Top Level Update + */ + +void flexran_agent_send_update_stats(mid_t mod_id) { + + Protocol__FlexranMessage *current_report = NULL; + void *data; + int size; + err_code_t err_code; + int priority = 0; + + if (pthread_mutex_lock(stats_context[mod_id].mutex)) { + goto error; + } + + if (stats_context[mod_id].cont_update == 1) { + + /*Create a fresh report with the required flags*/ + err_code = flexran_agent_handle_stats(mod_id, (void *) stats_context[mod_id].stats_req, ¤t_report); + if (err_code < 0) { + goto error; + } + } + /* /\*TODO:Check if a previous reports exists and if yes, generate a report */ + /* *that is the diff between the old and the new report, */ + /* *respecting the thresholds. Otherwise send the new report*\/ */ + /* if (stats_context[mod_id].prev_stats_reply != NULL) { */ + + /* msg = flexran_agent_generate_diff_mac_stats_report(current_report, stats_context[mod_id].prev_stats_reply); */ + + /* /\*Destroy the old stats*\/ */ + /* flexran_agent_destroy_flexran_message(stats_context[mod_id].prev_stats_reply); */ + /* } */ + /* /\*Use the current report for future comparissons*\/ */ + /* stats_context[mod_id].prev_stats_reply = current_report; */ + + + if (pthread_mutex_unlock(stats_context[mod_id].mutex)) { + goto error; + } + + if (current_report != NULL){ + data=flexran_agent_pack_message(current_report, &size); + /*Send any stats updates using the MAC channel of the eNB*/ + if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_MAC, data, size, priority)) { + err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; + goto error; + } + + LOG_D(FLEXRAN_AGENT,"sent message with size %d\n", size); + return; + } + error: + LOG_D(FLEXRAN_AGENT, "Could not send sf trigger message\n"); +} + +err_code_t flexran_agent_disable_cont_stats_update(mid_t mod_id) { + /*Disable the continuous updates for the MAC*/ + if (pthread_mutex_lock(stats_context[mod_id].mutex)) { + goto error; + } + stats_context[mod_id].cont_update = 0; + stats_context[mod_id].xid = 0; + if (stats_context[mod_id].stats_req != NULL) { + flexran_agent_destroy_flexran_message(stats_context[mod_id].stats_req); + } + if (stats_context[mod_id].prev_stats_reply != NULL) { + flexran_agent_destroy_flexran_message(stats_context[mod_id].prev_stats_reply); + } + if (pthread_mutex_unlock(stats_context[mod_id].mutex)) { + goto error; + } + return 0; + + error: + LOG_E(FLEXRAN_AGENT, "stats_context for eNB %d is not initialized\n", mod_id); + return -1; + +} + +err_code_t flexran_agent_enable_cont_stats_update(mid_t mod_id, + xid_t xid, stats_request_config_t *stats_req) { + + if (pthread_mutex_lock(stats_context[mod_id].mutex)) { + goto error; + } + + Protocol__FlexranMessage *req_msg; + + flexran_agent_stats_request(mod_id, xid, stats_req, &req_msg); + stats_context[mod_id].stats_req = req_msg; + stats_context[mod_id].prev_stats_reply = NULL; + + stats_context[mod_id].cont_update = 1; + stats_context[mod_id].xid = xid; + + if (pthread_mutex_unlock(stats_context[mod_id].mutex)) { + goto error; + } + return 0; + + error: + LOG_E(FLEXRAN_AGENT, "stats_context for eNB %d is not initialized\n", mod_id); + return -1; +} + + +err_code_t flexran_agent_init_cont_stats_update(mid_t mod_id) { + + + /*Initially the continuous update is set to false*/ + stats_context[mod_id].cont_update = 0; + stats_context[mod_id].is_initialized = 1; + stats_context[mod_id].stats_req = NULL; + stats_context[mod_id].prev_stats_reply = NULL; + stats_context[mod_id].mutex = calloc(1, sizeof(pthread_mutex_t)); + if (stats_context[mod_id].mutex == NULL) + goto error; + if (pthread_mutex_init(stats_context[mod_id].mutex, NULL)) + goto error;; + + return 0; + + error: + return -1; +} + +err_code_t flexran_agent_destroy_cont_stats_update(mid_t mod_id) { + + stats_context[mod_id].cont_update = 0; + stats_context[mod_id].is_initialized = 0; + flexran_agent_destroy_flexran_message(stats_context[mod_id].stats_req); + flexran_agent_destroy_flexran_message(stats_context[mod_id].prev_stats_reply); + free(stats_context[mod_id].mutex); + + // mac_agent_registered[mod_id] = 0; + return 1; +} \ No newline at end of file diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c new file mode 100644 index 0000000000..17a53c7eb0 --- /dev/null +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -0,0 +1,929 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file flexran_agent_ran_api.c + * \brief FlexRAN RAN API abstraction + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + */ + +#include "flexran_agent_ran_api.h" + + +/* + * get generic info from RAN + */ + + + +void * enb[NUM_MAX_ENB]; +void * enb_ue[NUM_MAX_ENB]; +void * enb_rrc[NUM_MAX_ENB]; + +void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ + + switch (ran){ + case RAN_LTE_OAI : + enb[mod_id] = (void *)&eNB_mac_inst[mod_id]; + enb_ue[mod_id] = (void *)&eNB_mac_inst[mod_id].UE_list; + enb_rrc[mod_id] = (void *)&eNB_rrc_inst[mod_id]; + break; + default : + goto error; + } + + return; + + error: + LOG_E(FLEXRAN_AGENT, "unknown RAN name %d\n", ran); +} + +int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag){ + + if (subframe_flag == 1){ + return ((eNB_MAC_INST *)enb[mod_id])->frame*10 + ((eNB_MAC_INST *)enb[mod_id])->subframe; + }else { + return ((eNB_MAC_INST *)enb[mod_id])->frame*10; + } + +} + +unsigned int flexran_get_current_frame (mid_t mod_id) { + + // #warning "SFN will not be in [0-1023] when oaisim is used" + return ((eNB_MAC_INST *)enb[mod_id])->frame; + +} + +unsigned int flexran_get_current_system_frame_num(mid_t mod_id) { + return (flexran_get_current_frame(mod_id) %1024); +} + +unsigned int flexran_get_current_subframe (mid_t mod_id) { + + return ((eNB_MAC_INST *)enb[mod_id])->subframe; + +} + +uint16_t flexran_get_sfn_sf (mid_t mod_id) { + + frame_t frame; + sub_frame_t subframe; + uint16_t sfn_sf, frame_mask, sf_mask; + + frame = (frame_t) flexran_get_current_system_frame_num(mod_id); + subframe = (sub_frame_t) flexran_get_current_subframe(mod_id); + frame_mask = ((1<<12) - 1); + sf_mask = ((1<<4) - 1); + sfn_sf = (subframe & sf_mask) | ((frame & frame_mask) << 4); + + return sfn_sf; +} + +uint16_t flexran_get_future_sfn_sf (mid_t mod_id, int ahead_of_time) { + + frame_t frame; + sub_frame_t subframe; + uint16_t sfn_sf, frame_mask, sf_mask; + + frame = (frame_t) flexran_get_current_system_frame_num(mod_id); + subframe = (sub_frame_t) flexran_get_current_subframe(mod_id); + + subframe = ((subframe + ahead_of_time) % 10); + + if (subframe < flexran_get_current_subframe(mod_id)) { + frame = (frame + 1) % 1024; + } + + int additional_frames = ahead_of_time / 10; + frame = (frame + additional_frames) % 1024; + + frame_mask = ((1<<12) - 1); + sf_mask = ((1<<4) - 1); + sfn_sf = (subframe & sf_mask) | ((frame & frame_mask) << 4); + + return sfn_sf; +} + +int flexran_get_num_ues (mid_t mod_id){ + + return ((UE_list_t *)enb_ue[mod_id])->num_UEs; +} + +int flexran_get_ue_crnti (mid_t mod_id, mid_t ue_id) { + + return UE_RNTI(mod_id, ue_id); +} + +int flexran_get_ue_bsr (mid_t mod_id, mid_t ue_id, lcid_t lcid) { + + return ((UE_list_t *)enb_ue[mod_id])->UE_template[UE_PCCID(mod_id,ue_id)][ue_id].bsr_info[lcid]; +} + +int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id) { + + return ((UE_list_t *)enb_ue[mod_id])->UE_template[UE_PCCID(mod_id,ue_id)][ue_id].phr_info; +} + +int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id) { + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, 0, UE_RNTI(mod_id, ue_id)); + return eNB_UE_stats->DL_cqi[0]; + + // return ((UE_list_t *)enb_ue[mod_id])->eNB_UE_stats[UE_PCCID(mod_id,ue_id)][ue_id].dl_cqi; +} + +int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id,frame,ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); + return rlc_status.bytes_in_buffer; +} + +int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, ENB_FLAG_YES, MBMS_FLAG_NO, channel_id, 0); + return rlc_status.head_sdu_creation_time; +} + +short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id) { + + UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; + int rnti; + + rnti = flexran_get_ue_crnti(mod_id, ue_id); + + LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + //ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY + switch (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.N_RB_DL) { + case 6: + return eNB_UE_stats->timing_advance_update; + case 15: + return eNB_UE_stats->timing_advance_update/2; + case 25: + return eNB_UE_stats->timing_advance_update/4; + case 50: + return eNB_UE_stats->timing_advance_update/8; + case 75: + return eNB_UE_stats->timing_advance_update/12; + case 100: + if (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.threequarter_fs == 0) { + return eNB_UE_stats->timing_advance_update/16; + } else { + return eNB_UE_stats->timing_advance_update/12; + } + default: + return 0; + } +} + +int flexran_get_ue_pmi(mid_t mod_id){ + + /*Xenofon to check this*/ + + return 0; +} + + +void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id) { + + UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; + UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[ue_id]; + + if (ue_sched_ctl->ta_timer == 0) { + + // WE SHOULD PROTECT the eNB_UE_stats with a mutex here ... + // LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + //ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY + ue_sched_ctl->ta_update = flexran_get_TA(mod_id, ue_id, CC_id); + + // clear the update in case PHY does not have a new measurement after timer expiry + // eNB_UE_stats->timing_advance_update = 0; + } else { + ue_sched_ctl->ta_timer--; + ue_sched_ctl->ta_update = 0; // don't trigger a timing advance command + } +} + +int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id,int CC_id) { + + UE_list_t *UE_list = &eNB_mac_inst[mod_id].UE_list; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); + + if (eNB_UE_stats == NULL) { + return 0; + } + + if (flexran_get_TA(mod_id, ue_id, CC_id) != 0) { + return PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; + } else { + return 0; + } + +} + +int flexran_get_active_CC(mid_t mod_id, mid_t ue_id) { + return ((UE_list_t *)enb_ue[mod_id])->numactiveCCs[ue_id]; +} + +int flexran_get_current_RI(mid_t mod_id, mid_t ue_id, int CC_id) { + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); + + if (eNB_UE_stats == NULL) { + return 0; + } + + return eNB_UE_stats[CC_id].rank; +} + +int flexran_get_tpc(mid_t mod_id, mid_t ue_id) { + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + int32_t normalized_rx_power, target_rx_power; + int tpc = 1; + + int pCCid = UE_PCCID(mod_id,ue_id); + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, pCCid, rnti); + + target_rx_power = mac_xface->get_target_pusch_rx_power(mod_id,pCCid); + + if (eNB_UE_stats == NULL) { + normalized_rx_power = target_rx_power; + } else if (eNB_UE_stats->UL_rssi != NULL) { + normalized_rx_power = eNB_UE_stats->UL_rssi[0]; + } else { + normalized_rx_power = target_rx_power; + } + + if (normalized_rx_power>(target_rx_power+1)) { + tpc = 0; //-1 + } else if (normalized_rx_power<(target_rx_power-1)) { + tpc = 2; //+1 + } else { + tpc = 1; //0 + } + return tpc; +} + +int flexran_get_harq(const mid_t mod_id, + const uint8_t CC_id, + const mid_t ue_id, + const int frame, + const uint8_t subframe, + uint8_t *id, + uint8_t *round) { //flag_id_status = 0 then id, else status + /*TODO: Add int TB in function parameters to get the status of the second TB. This can be done to by editing in + * get_ue_active_harq_pid function in line 272 file: phy_procedures_lte_eNB.c to add + * DLSCH_ptr = PHY_vars_eNB_g[Mod_id][CC_id]->dlsch_eNB[(uint32_t)UE_id][1];*/ + + uint8_t harq_pid; + uint8_t harq_round; + + + uint16_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + mac_xface->get_ue_active_harq_pid(mod_id,CC_id,rnti,frame,subframe,&harq_pid,&harq_round,openair_harq_DL); + + *id = harq_pid; + *round = harq_round; + /* if (round > 0) { */ + /* *status = 1; */ + /* } else { */ + /* *status = 0; */ + /* } */ + + /* return 0; */ + return *round; +} + +int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id) { + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + + if (eNB_UE_stats == NULL) { + return -1; + } + + // if(eNB_UE_stats->Po_PUCCH_update == 1) { + return eNB_UE_stats->Po_PUCCH_dBm; + //} + //else + // return -1; +} + +int flexran_get_p0_nominal_pucch(mid_t mod_id, int CC_id) { + int32_t pucch_rx_received = mac_xface->get_target_pucch_rx_power(mod_id, CC_id); + return pucch_rx_received; +} + +int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id) { + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + return eNB_UE_stats->Po_PUCCH_update; +} + +int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id) { + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + eNB_UE_stats->Po_PUCCH_update = 0; + + return 0; +} + + +/* + * ************************************ + * Get Messages for eNB Configuration Reply + * ************************************ + */ + +int flexran_get_hopping_offset(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->pusch_config_common.pusch_HoppingOffset; +} + +int flexran_get_hopping_mode(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->pusch_config_common.hoppingMode; +} + +int flexran_get_n_SB(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->pusch_config_common.n_SB; +} + +int flexran_get_enable64QAM(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->pusch_config_common.enable64QAM; +} + +int flexran_get_phich_duration(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->phich_config_common.phich_duration; +} + +int flexran_get_phich_resource(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + if(frame_parms->phich_config_common.phich_resource == oneSixth) + return 0; + else if(frame_parms->phich_config_common.phich_resource == half) + return 1; + else if(frame_parms->phich_config_common.phich_resource == one) + return 2; + else if(frame_parms->phich_config_common.phich_resource == two) + return 3; + + return -1; +} + +int flexran_get_n1pucch_an(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->pucch_config_common.n1PUCCH_AN; +} + +int flexran_get_nRB_CQI(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->pucch_config_common.nRB_CQI; +} + +int flexran_get_deltaPUCCH_Shift(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->pucch_config_common.deltaPUCCH_Shift; +} + +int flexran_get_prach_ConfigIndex(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; +} + +int flexran_get_prach_FreqOffset(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset; +} + +int flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->maxHARQ_Msg3Tx; +} + +int flexran_get_ul_cyclic_prefix_length(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->Ncp_UL; +} + +int flexran_get_dl_cyclic_prefix_length(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->Ncp; +} + +int flexran_get_cell_id(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->Nid_cell; +} + +int flexran_get_srs_BandwidthConfig(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->soundingrs_ul_config_common.srs_BandwidthConfig; +} + +int flexran_get_srs_SubframeConfig(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->soundingrs_ul_config_common.srs_SubframeConfig; +} + +int flexran_get_srs_MaxUpPts(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->soundingrs_ul_config_common.srs_MaxUpPts; +} + +int flexran_get_N_RB_DL(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->N_RB_DL; +} + +int flexran_get_N_RB_UL(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->N_RB_UL; +} + +int flexran_get_N_RBG(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->N_RBG; +} + +int flexran_get_subframe_assignment(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->tdd_config; +} + +int flexran_get_special_subframe_assignment(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->tdd_config_S; +} + +int flexran_get_ra_ResponseWindowSize(mid_t mod_id, int CC_id) { + return enb_config_get()->properties[mod_id]->rach_raResponseWindowSize[CC_id]; +} + +int flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, int CC_id) { + return enb_config_get()->properties[mod_id]->rach_macContentionResolutionTimer[CC_id]; +} + +int flexran_get_duplex_mode(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + if(frame_parms->frame_type == TDD) + return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD; + else if (frame_parms->frame_type == FDD) + return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_FDD; + + return -1; +} + +long flexran_get_si_window_length(mid_t mod_id, int CC_id) { + return ((eNB_RRC_INST *)enb_rrc[mod_id])->carrier[CC_id].sib1->si_WindowLength; +} + +int flexran_get_sib1_length(mid_t mod_id, int CC_id) { + return ((eNB_RRC_INST *)enb_rrc[mod_id])->carrier[CC_id].sizeof_SIB1; +} + +int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id) { + /* TODO: This should return the number of PDCCH symbols initially used by the cell CC_id */ + return 0; + //(PHY_vars_UE_g[mod_id][CC_id]->lte_ue_pdcch_vars[mod_id]->num_pdcch_symbols); +} + + + +/* + * ************************************ + * Get Messages for UE Configuration Reply + * ************************************ + */ + + +int flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.mac_MainConfig != NULL) { + return ue_context_p->ue_context.mac_MainConfig->timeAlignmentTimerDedicated; + } else { + return -1; + } + } else { + return -1; + } +} + +int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.measGapConfig != NULL) { + if(ue_context_p->ue_context.measGapConfig->present == MeasGapConfig_PR_setup) { + if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0) { + return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_GP1; + } else if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1) { + return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_GP2; + } else { + return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF; + } + } + } + } + return -1; +} + + +int flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.measGapConfig != NULL){ + if(ue_context_p->ue_context.measGapConfig->present == MeasGapConfig_PR_setup) { + if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0) { + return ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.choice.gp0; + } else if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1) { + return ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.choice.gp0; + } + } + } + } + return -1; +} + +int flexran_get_ue_aggregated_max_bitrate_dl (mid_t mod_id, mid_t ue_id) { + return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateDL; +} + +int flexran_get_ue_aggregated_max_bitrate_ul (mid_t mod_id, mid_t ue_id) { + return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL; +} + +int flexran_get_half_duplex(mid_t ue_id) { + // TODO + //int halfduplex = 0; + //int bands_to_scan = ((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count; + //for (int i =0; i < bands_to_scan; i++){ + //if(((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->halfDuplex > 0) + // halfduplex = 1; + //} + //return halfduplex; + return 0; +} + +int flexran_get_intra_sf_hopping(mid_t ue_id) { + //TODO:Get proper value + //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); + //return (0 & ( 1 << (31))); + return 0; +} + +int flexran_get_type2_sb_1(mid_t ue_id) { + //TODO:Get proper value + //uint8_t temp = 0; + //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); + //return (temp & ( 1 << (11))); + return 0; +} + +int flexran_get_ue_category(mid_t ue_id) { + //TODO:Get proper value + //return (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->ue_Category); + return 0; +} + +int flexran_get_res_alloc_type1(mid_t ue_id) { + //TODO:Get proper value + //uint8_t temp = 0; + //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); + //return (temp & ( 1 << (30))); + return 0; +} + +int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode; + } else { + return -1; + } + } else { + return -1; + } +} + +int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.mac_MainConfig != NULL){ + return ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->ttiBundling; + } else { + return -1; + } + } + else { + return -1; + } +} + +int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.mac_MainConfig != NULL){ + return *ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; + } + } + return -1; +} + +int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; + } else { + return -1; + } + } else { + return -1; + } +} + +int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; + } else { + return -1; + } + } else { + return -1; + } +} + +int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; + } else { + return -1; + } + } + else { + return -1; + } +} + +int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + if (ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic != NULL) { + return ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI; + } + } + } + return -1; +} + +int flexran_get_ack_nack_simultaneous_trans(mid_t mod_id,mid_t ue_id) { + return (&eNB_rrc_inst[mod_id])->carrier[0].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; +} + +int flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return *ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; + } + } + return -1; +} + +int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id) { + // TODO: This needs fixing + return -1; + + /* struct rrc_eNB_ue_context_s* ue_context_p = NULL; */ + /* uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); */ + + /* ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); */ + + /* if(ue_context_p != NULL) { */ + /* if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ */ + /* return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode; */ + /* } else { */ + /* return -1; */ + /* } */ + /* } else { */ + /* return -1; */ + /* } */ +} + +int flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.choice.setup.repetitionFactor; + } else { + return -1; + } + } else { + return -1; + } +} + +int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) { + //TODO: need to double check + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.mac_MainConfig != NULL){ + if(ue_context_p->ue_context.mac_MainConfig->ext2 != NULL){ + long val = (*(ue_context_p->ue_context.mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10)); + if (val > 0) { + return 1; + } + } + } + } + return -1; +} + +int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ + if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_closedLoop) { + return 2; + } else if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_openLoop) { + return 1; + } else { + return 0; + } + } else { + return -1; + } + } else { + return -1; + } +} + +int flexran_get_lcg(mid_t ue_id, mid_t lc_id) { + if (UE_mac_inst == NULL) { + return -1; + } + if(UE_mac_inst[ue_id].logicalChannelConfig[lc_id] != NULL) { + return *UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters->logicalChannelGroup; + } else { + return -1; + } +} + +int flexran_get_direction(mid_t ue_id, mid_t lc_id) { + /*TODO: fill with the value for the rest of LCID*/ + if(lc_id == DCCH || lc_id == DCCH1) { + return 2; + } else if(lc_id == DTCH) { + return 1; + } else { + return -1; + } +} + +int flexran_get_antenna_ports(mid_t mod_id, int CC_id){ + + LTE_DL_FRAME_PARMS *frame_parms; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->nb_antenna_ports_eNB; + +} \ No newline at end of file diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h new file mode 100644 index 0000000000..12962a1f9d --- /dev/null +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -0,0 +1,290 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file flexran_agent_ran_api.h + * \brief FlexRAN RAN API abstraction header + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + */ + +#include +#include + +#include "flexran_agent_common.h" +#include "flexran_agent_common_internal.h" +#include "flexran_agent_extern.h" +#include "flexran_agent_defs.h" + + +#include "enb_config.h" +#include "LAYER2/MAC/extern.h" +#include "LAYER2/RLC/rlc.h" +#include "SCHED/defs.h" +#include "RRC/LITE/extern.h" +#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +#include "RRC/LITE/rrc_eNB_UE_context.h" +#include "PHY/extern.h" +#include "log.h" + +/**************************** + * get generic info from RAN + ****************************/ + +void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran); + +int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag); + +/*Return the current frame number + *Could be using implementation specific numbering of frames + */ +unsigned int flexran_get_current_frame(mid_t mod_id); + +/*Return the current SFN (0-1023)*/ +unsigned int flexran_get_current_system_frame_num(mid_t mod_id); + +unsigned int flexran_get_current_subframe(mid_t mod_id); + +/*Return the frame and subframe number in compact 16-bit format. + Bits 0-3 subframe, rest for frame. Required by FlexRAN protocol*/ +uint16_t flexran_get_sfn_sf (mid_t mod_id); + +/* Return a future frame and subframe number that is ahead_of_time + subframes later in compact 16-bit format. Bits 0-3 subframe, + rest for frame */ +uint16_t flexran_get_future_sfn_sf(mid_t mod_id, int ahead_of_time); + +/* Return the number of attached UEs */ +int flexran_get_num_ues(mid_t mod_id); + +/* Get the rnti of a UE with id ue_id */ +int flexran_get_ue_crnti (mid_t mod_id, mid_t ue_id); + +/* Get the RLC buffer status report of a ue for a designated + logical channel id */ +int flexran_get_ue_bsr (mid_t mod_id, mid_t ue_id, lcid_t lcid); + +/* Get power headroom of UE with id ue_id */ +int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id); + +/* Get the UE wideband CQI */ +int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id); + +/* Get the transmission queue size for a UE with a channel_id logical channel id */ +int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); + +/* Get the head of line delay for a UE with a channel_id logical channel id */ +int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); + +/* Check the status of the timing advance for a UE */ +short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id); + +/* Update the timing advance status (find out whether a timing advance command is required) */ +void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id); + +/* Return timing advance MAC control element for a designated cell and UE */ +int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id, int CC_id); + +/* Get the number of active component carriers for a specific UE */ +int flexran_get_active_CC(mid_t mod_id, mid_t ue_id); + +/* Get the rank indicator for a designated cell and UE */ +int flexran_get_current_RI(mid_t mod_id, mid_t ue_id, int CC_id); + +/* See TS 36.213, section 10.1 */ +int flexran_get_n1pucch_an(mid_t mod_id, int CC_id); + +/* See TS 36.211, section 5.4 */ +int flexran_get_nRB_CQI(mid_t mod_id, int CC_id); + +/* See TS 36.211, section 5.4 */ +int flexran_get_deltaPUCCH_Shift(mid_t mod_id, int CC_id); + +/* See TS 36.211, section 5.7.1 */ +int flexran_get_prach_ConfigIndex(mid_t mod_id, int CC_id); + +/* See TS 36.211, section 5.7.1 */ +int flexran_get_prach_FreqOffset(mid_t mod_id, int CC_id); + +/* See TS 36.321 */ +int flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, int CC_id); + +/* Get the length of the UL cyclic prefix */ +int flexran_get_ul_cyclic_prefix_length(mid_t mod_id, int CC_id); + +/* Get the length of the DL cyclic prefix */ +int flexran_get_dl_cyclic_prefix_length(mid_t mod_id, int CC_id); + +/* Get the physical cell id of a cell */ +int flexran_get_cell_id(mid_t mod_id, int CC_id); + +/* See TS 36.211, section 5.5.3.2 */ +int flexran_get_srs_BandwidthConfig(mid_t mod_id, int CC_id); + +/* See TS 36.211, table 5.5.3.3-1 and 2 */ +int flexran_get_srs_SubframeConfig(mid_t mod_id, int CC_id); + +/* Boolean value. See TS 36.211, + section 5.5.3.2. TDD only */ +int flexran_get_srs_MaxUpPts(mid_t mod_id, int CC_id); + +/* Get number of DL resource blocks */ +int flexran_get_N_RB_DL(mid_t mod_id, int CC_id); + +/* Get number of UL resource blocks */ +int flexran_get_N_RB_UL(mid_t mod_id, int CC_id); + +/* Get number of resource block groups */ +int flexran_get_N_RBG(mid_t mod_id, int CC_id); + +/* Get DL/UL subframe assignment. TDD only */ +int flexran_get_subframe_assignment(mid_t mod_id, int CC_id); + +/* TDD only. See TS 36.211, table 4.2.1 */ +int flexran_get_special_subframe_assignment(mid_t mod_id, int CC_id); + +/* Get the duration of the random access response window in subframes */ +int flexran_get_ra_ResponseWindowSize(mid_t mod_id, int CC_id); + +/* Get timer used for random access */ +int flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, int CC_id); + +/* Get type of duplex mode (FDD/TDD) */ +int flexran_get_duplex_mode(mid_t mod_id, int CC_id); + +/* Get the SI window length */ +long flexran_get_si_window_length(mid_t mod_id, int CC_id); + +/* Get the number of PDCCH symbols configured for the cell */ +int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id); + +int flexran_get_antenna_ports(mid_t mod_id, int CC_id); + +/* See TS 36.213, sec 5.1.1.1 */ +int flexran_get_tpc(mid_t mod_id, mid_t ue_id); + +int flexran_get_ue_pmi(mid_t mod_id); + +/* Get the first available HARQ process for a specific cell and UE during + a designated frame and subframe. Returns 0 for success. The id and the + status of the HARQ process are stored in id and status respectively */ +int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, + const int frame, const uint8_t subframe, unsigned char *id, unsigned char *round); + +/* Uplink power control management*/ +int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id); + +int flexran_get_p0_nominal_pucch(mid_t mod_id, int CC_id); + +int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id); + +int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id); + + +/* + * ************************************ + * Get Messages for UE Configuration Reply + * ************************************ + */ + +/* Get timer in subframes. Controls the synchronization + status of the UE, not the actual timing + advance procedure. See TS 36.321 */ +int flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id); + +/* Get measurement gap configuration. See TS 36.133 */ +int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id); + +/* Get measurement gap configuration offset if applicable */ +int flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id); + +/* DL aggregated bit-rate of non-gbr bearer + per UE. See TS 36.413 */ +int flexran_get_ue_aggregated_max_bitrate_dl (mid_t mod_id, mid_t ue_id); + +/* UL aggregated bit-rate of non-gbr bearer + per UE. See TS 36.413 */ +int flexran_get_ue_aggregated_max_bitrate_ul (mid_t mod_id, mid_t ue_id); + +/* Only half-duplex support. FDD + operation. Boolean value */ +int flexran_get_half_duplex(mid_t ue_id); + +/* Support of intra-subframe hopping. + Boolean value */ +int flexran_get_intra_sf_hopping(mid_t ue_id); + +/* UE support for type 2 hopping with + n_sb>1 */ +int flexran_get_type2_sb_1(mid_t ue_id); + +/* Get the UE category */ +int flexran_get_ue_category(mid_t ue_id); + +/* UE support for resource allocation + type 1 */ +int flexran_get_res_alloc_type1(mid_t ue_id); + +/* Get UE transmission mode */ +int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id); + +/* Boolean value. See TS 36.321 */ +int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id); + +/* The max HARQ retransmission for UL. + See TS 36.321 */ +int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id); + +/* See TS 36.213 */ +int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id); + +/* See TS 36.213 */ +int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id); + +/* See TS 36.213 */ +int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id); + +/* Boolean. See TS36.213, Section 10.1 */ +int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id); + +/* Boolean. See TS 36.213, Section 8.2 */ +int flexran_get_ack_nack_simultaneous_trans(mid_t mod_id,mid_t ue_id); + +/* Get aperiodic CQI report mode */ +int flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id); + +/* Get ACK/NACK feedback mode. TDD only */ +int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id); + +/* See TS36.213, section 10.1 */ +int flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id); + +/* Boolean. Extended buffer status report size */ +int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id); + +/* Get number of UE transmission antennas */ +int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id); + +/* Get logical channel group of a channel with id lc_id */ +int flexran_get_lcg(mid_t ue_id, mid_t lc_id); + +/* Get direction of logical channel with id lc_id */ +int flexran_get_direction(mid_t ue_id, mid_t lc_id); \ No newline at end of file diff --git a/openair2/ENB_APP/flexran_agent_timer.c b/openair2/ENB_APP/flexran_agent_timer.c new file mode 100644 index 0000000000..f5436e4d01 --- /dev/null +++ b/openair2/ENB_APP/flexran_agent_timer.c @@ -0,0 +1,217 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file flexran_agent_timer.c + * \brief FlexRAN Timer + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + */ + +/* + * timer primitives + */ + +#include "flexran_agent_timer.h" + +//struct flexran_agent_map agent_map; +flexran_agent_timer_instance_t timer_instance; +int agent_timer_init = 0; +err_code_t flexran_agent_init_timer(void){ + + LOG_I(FLEXRAN_AGENT, "init RB tree\n"); + if (!agent_timer_init) { + RB_INIT(&timer_instance.flexran_agent_head); + agent_timer_init = 1; + } + + return PROTOCOL__FLEXRAN_ERR__NO_ERR; +} + +RB_GENERATE(flexran_agent_map, flexran_agent_timer_element_s, entry, flexran_agent_compare_timer); + +/* The timer_id might not be the best choice for the comparison */ +int flexran_agent_compare_timer(struct flexran_agent_timer_element_s *a, struct flexran_agent_timer_element_s *b){ + + if (a->timer_id < b->timer_id) return -1; + if (a->timer_id > b->timer_id) return 1; + + // equal timers + return 0; +} + +err_code_t flexran_agent_create_timer(uint32_t interval_sec, + uint32_t interval_usec, + agent_id_t agent_id, + instance_t instance, + uint32_t timer_type, + xid_t xid, + flexran_agent_timer_callback_t cb, + void* timer_args, + long *timer_id){ + + struct flexran_agent_timer_element_s *e = calloc(1, sizeof(*e)); + DevAssert(e != NULL); + +//uint32_t timer_id; + int ret=-1; + + if ((interval_sec == 0) && (interval_usec == 0 )) + return TIMER_NULL; + + if (timer_type >= FLEXRAN_AGENT_TIMER_TYPE_MAX) + return TIMER_TYPE_INVALIDE; + + if (timer_type == FLEXRAN_AGENT_TIMER_TYPE_ONESHOT){ + ret = timer_setup(interval_sec, + interval_usec, + TASK_FLEXRAN_AGENT, + instance, + TIMER_ONE_SHOT, + timer_args, + timer_id); + + e->type = TIMER_ONE_SHOT; + } + else if (timer_type == FLEXRAN_AGENT_TIMER_TYPE_PERIODIC ){ + ret = timer_setup(interval_sec, + interval_usec, + TASK_FLEXRAN_AGENT, + instance, + TIMER_PERIODIC, + timer_args, + timer_id); + + e->type = TIMER_PERIODIC; + } + + if (ret < 0 ) { + return TIMER_SETUP_FAILED; + } + + e->agent_id = agent_id; + e->instance = instance; + e->state = FLEXRAN_AGENT_TIMER_STATE_ACTIVE; + e->timer_id = *timer_id; + e->xid = xid; + e->timer_args = timer_args; + e->cb = cb; + /*element should be a real pointer*/ + RB_INSERT(flexran_agent_map, &timer_instance.flexran_agent_head, e); + + LOG_I(FLEXRAN_AGENT,"Created a new timer with id 0x%lx for agent %d, instance %d \n", + e->timer_id, e->agent_id, e->instance); + + return 0; +} + +err_code_t flexran_agent_destroy_timer(long timer_id){ + + struct flexran_agent_timer_element_s *e = get_timer_entry(timer_id); + + if (e != NULL ) { + RB_REMOVE(flexran_agent_map, &timer_instance.flexran_agent_head, e); + flexran_agent_destroy_flexran_message(e->timer_args->msg); + free(e); + } + + if (timer_remove(timer_id) < 0 ) + goto error; + + return 0; + + error: + LOG_E(FLEXRAN_AGENT, "timer can't be removed\n"); + return TIMER_REMOVED_FAILED ; +} + +err_code_t flexran_agent_destroy_timer_by_task_id(xid_t xid) { + struct flexran_agent_timer_element_s *e = NULL; + long timer_id; + RB_FOREACH(e, flexran_agent_map, &timer_instance.flexran_agent_head) { + if (e->xid == xid) { + timer_id = e->timer_id; + RB_REMOVE(flexran_agent_map, &timer_instance.flexran_agent_head, e); + flexran_agent_destroy_flexran_message(e->timer_args->msg); + free(e); + if (timer_remove(timer_id) < 0 ) { + goto error; + } + } + } + return 0; + + error: + LOG_E(FLEXRAN_AGENT, "timer can't be removed\n"); + return TIMER_REMOVED_FAILED ; +} + +err_code_t flexran_agent_destroy_timers(void){ + + struct flexran_agent_timer_element_s *e = NULL; + + RB_FOREACH(e, flexran_agent_map, &timer_instance.flexran_agent_head) { + RB_REMOVE(flexran_agent_map, &timer_instance.flexran_agent_head, e); + timer_remove(e->timer_id); + flexran_agent_destroy_flexran_message(e->timer_args->msg); + free(e); + } + + return 0; + +} + +void flexran_agent_sleep_until(struct timespec *ts, int delay) { + ts->tv_nsec += delay; + if(ts->tv_nsec >= 1000*1000*1000){ + ts->tv_nsec -= 1000*1000*1000; + ts->tv_sec++; + } + clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, ts, NULL); +} + + +err_code_t flexran_agent_stop_timer(long timer_id){ + + struct flexran_agent_timer_element_s *e=NULL; + struct flexran_agent_timer_element_s search; + memset(&search, 0, sizeof(struct flexran_agent_timer_element_s)); + search.timer_id = timer_id; + + e = RB_FIND(flexran_agent_map, &timer_instance.flexran_agent_head, &search); + + if (e != NULL ) { + e->state = FLEXRAN_AGENT_TIMER_STATE_STOPPED; + } + + timer_remove(timer_id); + + return 0; +} + +struct flexran_agent_timer_element_s * get_timer_entry(long timer_id) { + + struct flexran_agent_timer_element_s search; + memset(&search, 0, sizeof(struct flexran_agent_timer_element_s)); + search.timer_id = timer_id; + + return RB_FIND(flexran_agent_map, &timer_instance.flexran_agent_head, &search); +} diff --git a/openair2/ENB_APP/flexran_agent_timer.h b/openair2/ENB_APP/flexran_agent_timer.h new file mode 100644 index 0000000000..86e0d07825 --- /dev/null +++ b/openair2/ENB_APP/flexran_agent_timer.h @@ -0,0 +1,133 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file flexran_agent_timer.h + * \brief FlexRAN Timer header + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + */ + +#include +#include + +#include "flexran_agent_common.h" +#include "flexran_agent_common_internal.h" +#include "flexran_agent_extern.h" +#include "flexran_agent_defs.h" + + +# include "tree.h" +# include "intertask_interface.h" +# include "timer.h" + + + +/******************* + * timer primitves + *******************/ + +#define TIMER_NULL -1 +#define TIMER_TYPE_INVALIDE -2 +#define TIMER_SETUP_FAILED -3 +#define TIMER_REMOVED_FAILED -4 +#define TIMER_ELEMENT_NOT_FOUND -5 + + +/* Type of the callback executed when the timer expired */ +typedef Protocol__FlexranMessage *(*flexran_agent_timer_callback_t)(void*); + + +typedef struct flexran_agent_timer_args_s{ + mid_t mod_id; + Protocol__FlexranMessage *msg; +} flexran_agent_timer_args_t; + + +typedef struct flexran_agent_timer_element_s{ + RB_ENTRY(flexran_agent_timer_element_s) entry; + + agent_id_t agent_id; + instance_t instance; + + flexran_agent_timer_type_t type; + flexran_agent_timer_state_t state; + + uint32_t interval_sec; + uint32_t interval_usec; + + long timer_id; /* Timer id returned by the timer API*/ + xid_t xid; /*The id of the task as received by the controller + message*/ + + flexran_agent_timer_callback_t cb; + flexran_agent_timer_args_t *timer_args; + +} flexran_agent_timer_element_t; + +typedef struct flexran_agent_timer_instance_s{ + RB_HEAD(flexran_agent_map, flexran_agent_timer_element_s) flexran_agent_head; +}flexran_agent_timer_instance_t; + + +err_code_t flexran_agent_init_timer(void); + +/* Create a timer for some agent related event with id xid. Will store the id + of the generated timer in timer_id */ +err_code_t flexran_agent_create_timer(uint32_t interval_sec, + uint32_t interval_usec, + agent_id_t agent_id, + instance_t instance, + uint32_t timer_type, + xid_t xid, + flexran_agent_timer_callback_t cb, + void* timer_args, + long *timer_id); + +/* Destroy all existing timers */ +err_code_t flexran_agent_destroy_timers(void); + +/* Destroy the timer with the given timer_id */ +err_code_t flexran_agent_destroy_timer(long timer_id); + +/* Destroy the timer for task with id xid */ +err_code_t flexran_agent_destroy_timer_by_task_id(xid_t xid); + +/* Stop a timer */ +err_code_t flexran_agent_stop_timer(long timer_id); + +/* Restart the given timer */ +err_code_t flexran_agent_restart_timer(long *timer_id); + +/* Find the timer with the given timer_id */ +struct flexran_agent_timer_element_s * get_timer_entry(long timer_id); + +/* Obtain the protocol message stored in the given expired timer */ +Protocol__FlexranMessage * flexran_agent_process_timeout(long timer_id, void* timer_args); + +/* Comparator function comparing two timers. Decides the ordering of the timers */ +int flexran_agent_compare_timer(struct flexran_agent_timer_element_s *a, struct flexran_agent_timer_element_s *b); + +/*Specify a delay in nanoseconds to timespec and sleep until then*/ +void flexran_agent_sleep_until(struct timespec *ts, int delay); + +/* RB_PROTOTYPE is for .h files */ +RB_PROTOTYPE(flexran_agent_map, flexran_agent_timer_element_s, entry, flexran_agent_compare_timer); diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 6509471124..b75a3e7e8e 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -158,8 +158,8 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, //mac_remove_ue(module_idP, i, frameP, subframeP); //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future #if defined(FLEXRAN_AGENT_SB_IF) - if (mac_agent_registered[module_idP]) { - agent_mac_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP, + if (rrc_agent_registered[module_idP]) { + agent_rrc_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP, rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); } @@ -1082,15 +1082,15 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, for (CC_id=0;CC_idflexran_agent_send_update_mac_stats(module_idP); - } -#endif -#endif - + // if (mac_agent_registered[module_idP]) { + // agent_mac_xface[module_idP]->flexran_agent_send_update_mac_stats(module_idP); + // } +// #endif +// #endif +flexran_agent_send_update_stats(module_idP); /* int dummy=0; for (i=0; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 56ede260e8..01edbb87cf 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -180,6 +180,10 @@ uint8_t find_active_UEs(module_id_t module_idP,int CC_id){ } */ +int UE_BSR (uint8_t mod_id, uint8_t ue_id, uint8_t lcid) { + + return eNB_mac_inst[mod_id].UE_list.UE_template[UE_PCCID(mod_id,ue_id)][ue_id].bsr_info[lcid]; +} // get aggregation (L) form phy for a give UE unsigned char get_aggregation (uint8_t bw_index, uint8_t cqi, uint8_t dci_fmt) @@ -304,6 +308,12 @@ printf("MAC: cannot add new UE for rnti %x\n", rntiP); return(-1); } +int CC_id_rnti_downlink (uint8_t mod_id, int CC_index, uint16_t ue_rnti) { + + return eNB_mac_inst[mod_id].UE_list.ordered_CCids[CC_index][ue_rnti]; +} + + //------------------------------------------------------------------------------ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) //------------------------------------------------------------------------------ diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index da9d93c19a..6247548bcc 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -1899,7 +1899,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity; 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", ctxt_pP->module_id, ctxt_pP->frame); @@ -2159,6 +2159,598 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons } +//----------------------------------------------------------------------------- +void +flexran_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, + agent_reconf_rrc * trig_param + ) +//----------------------------------------------------------------------------- +{ + 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[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 = ue_context_pP->ue_context.SRB_configList; + SRB_ToAddModList_t **SRB_configList2 = NULL; + + struct DRB_ToAddMod *DRB_config = NULL; + struct RLC_Config *DRB_rlc_config = NULL; + struct PDCP_Config *DRB_pdcp_config = NULL; + struct PDCP_Config__rlc_AM *PDCP_rlc_AM = NULL; + struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; + struct LogicalChannelConfig *DRB_lchan_config = NULL; + struct LogicalChannelConfig__ul_SpecificParameters + *DRB_ul_SpecificParameters = NULL; + DRB_ToAddModList_t** DRB_configList = &ue_context_pP->ue_context.DRB_configList; + DRB_ToAddModList_t** DRB_configList2 = NULL; + MAC_MainConfig_t *mac_MainConfig = NULL; + MeasObjectToAddModList_t *MeasObj_list = NULL; + MeasObjectToAddMod_t *MeasObj = NULL; + ReportConfigToAddModList_t *ReportConfig_list = NULL; + ReportConfigToAddMod_t *ReportConfig_per, *ReportConfig_A1, + *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; + MeasIdToAddModList_t *MeasId_list = NULL; + MeasIdToAddMod_t *MeasId0, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5; +#if Rel10 + long *sr_ProhibitTimer_r9 = NULL; + // uint8_t sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1); + //uint8_t sCellIndexToAdd = 0; +#endif + + long *logicalchannelgroup, *logicalchannelgroup_drb; + long *maxHARQ_Tx, *periodicBSR_Timer; + + RSRP_Range_t *rsrp = NULL; + struct MeasConfig__speedStatePars *Sparams = NULL; + QuantityConfig_t *quantityConfig = NULL; + CellsToAddMod_t *CellToAdd = NULL; + CellsToAddModList_t *CellsToAddModList = NULL; + struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; + DedicatedInfoNAS_t *dedicatedInfoNas = NULL; + /* for no gcc warnings */ + (void)dedicatedInfoNas; + + C_RNTI_t *cba_RNTI = NULL; + + uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); //Transaction_id, + +#ifdef CBA + //struct PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola; + uint8_t *cba_RNTI_buf; + cba_RNTI = CALLOC(1, sizeof(C_RNTI_t)); + cba_RNTI_buf = CALLOC(1, 2 * sizeof(uint8_t)); + cba_RNTI->buf = cba_RNTI_buf; + cba_RNTI->size = 2; + cba_RNTI->bits_unused = 0; + + // associate UEs to the CBa groups as a function of their UE id + if (rrc_inst->num_active_cba_groups) { + cba_RNTI->buf[0] = rrc_inst->cba_rnti[ue_mod_idP % rrc_inst->num_active_cba_groups] & 0xff; + cba_RNTI->buf[1] = 0xff; + LOG_D(RRC, + "[eNB %d] Frame %d: cba_RNTI = %x in group %d is attribued to UE %d\n", + enb_mod_idP, frameP, + rrc_inst->cba_rnti[ue_mod_idP % rrc_inst->num_active_cba_groups], + ue_mod_idP % rrc_inst->num_active_cba_groups, ue_mod_idP); + } else { + cba_RNTI->buf[0] = 0x0; + cba_RNTI->buf[1] = 0x0; + LOG_D(RRC, "[eNB %d] Frame %d: no cba_RNTI is configured for UE %d\n", enb_mod_idP, frameP, ue_mod_idP); + } + +#endif + + T(T_ENB_RRC_CONNECTION_RECONFIGURATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + + // Configure SRB2 + /// SRB2 + SRB_configList2=&ue_context_pP->ue_context.SRB_configList2[xid]; + if (*SRB_configList2) { + free(*SRB_configList2); + } + *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2)); + memset(*SRB_configList2, 0, sizeof(**SRB_configList2)); + SRB2_config = CALLOC(1, sizeof(*SRB2_config)); + + SRB2_config->srb_Identity = 2; + SRB2_rlc_config = CALLOC(1, sizeof(*SRB2_rlc_config)); + SRB2_config->rlc_Config = SRB2_rlc_config; + + SRB2_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue; + SRB2_rlc_config->choice.explicitValue.present = RLC_Config_PR_am; + SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms15; + SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = PollPDU_p8; + SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = PollByte_kB1000; + SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t32; + SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35; + SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms10; + + SRB2_lchan_config = CALLOC(1, sizeof(*SRB2_lchan_config)); + SRB2_config->logicalChannelConfig = SRB2_lchan_config; + + SRB2_lchan_config->present = SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; + + SRB2_ul_SpecificParameters = CALLOC(1, sizeof(*SRB2_ul_SpecificParameters)); + + SRB2_ul_SpecificParameters->priority = 3; // let some priority for SRB1 and dedicated DRBs + SRB2_ul_SpecificParameters->prioritisedBitRate = + LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + SRB2_ul_SpecificParameters->bucketSizeDuration = + LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + // LCG for CCCH and DCCH is 0 as defined in 36331 + logicalchannelgroup = CALLOC(1, sizeof(long)); + *logicalchannelgroup = 0; + + SRB2_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; + + SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB2_ul_SpecificParameters; + // this list has the configuration for SRB1 and SRB2 + ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); + // this list has only the configuration for SRB2 + ASN_SEQUENCE_ADD(&(*SRB_configList2)->list, SRB2_config); + + // Configure DRB + //*DRB_configList = CALLOC(1, sizeof(*DRB_configList)); + // list for all the configured DRB + if (*DRB_configList) { + free(*DRB_configList); + } + *DRB_configList = CALLOC(1, sizeof(**DRB_configList)); + memset(*DRB_configList, 0, sizeof(**DRB_configList)); + + // list for the configured DRB for a this xid + DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid]; + if (*DRB_configList2) { + free(*DRB_configList2); + } + *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); + memset(*DRB_configList2, 0, sizeof(**DRB_configList2)); + + + /// DRB + DRB_config = CALLOC(1, sizeof(*DRB_config)); + + DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long)); + *(DRB_config->eps_BearerIdentity) = 5L; // LW set to first value, allowed value 5..15, value : x+4 + // DRB_config->drb_Identity = (DRB_Identity_t) 1; //allowed values 1..32 + // NN: this is the 1st DRB for this ue, so set it to 1 + DRB_config->drb_Identity = (DRB_Identity_t) 1; // (ue_mod_idP+1); //allowed values 1..32, value: x + DRB_config->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(DRB_config->logicalChannelIdentity) = (long)3; // value : x+2 + DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); + DRB_config->rlc_Config = DRB_rlc_config; + +#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; + DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = PollByte_kBinfinity; + DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8; + DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35; + DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms25; +#else + DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional; + 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_ms5;//T_Reordering_ms25; +#else + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; +#endif +#endif + + DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); + DRB_config->pdcp_Config = DRB_pdcp_config; + DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); + *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; + DRB_pdcp_config->rlc_AM = NULL; + DRB_pdcp_config->rlc_UM = NULL; + + /* avoid gcc warnings */ + (void)PDCP_rlc_AM; + (void)PDCP_rlc_UM; + +#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; +#else + PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM)); + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; +#endif + DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed; + + DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config)); + DRB_config->logicalChannelConfig = DRB_lchan_config; + DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); + DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; + + DRB_ul_SpecificParameters->priority = 12; // lower priority than srb1, srb2 and other dedicated bearer + DRB_ul_SpecificParameters->prioritisedBitRate =LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + DRB_ul_SpecificParameters->bucketSizeDuration = + LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM) + logicalchannelgroup_drb = CALLOC(1, sizeof(long)); + *logicalchannelgroup_drb = 1; + DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; + + ASN_SEQUENCE_ADD(&(*DRB_configList)->list, DRB_config); + ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); + + //ue_context_pP->ue_context.DRB_configList2[0] = &(*DRB_configList); + + mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig)); + // ue_context_pP->ue_context.mac_MainConfig = mac_MainConfig; + + mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config)); + + maxHARQ_Tx = CALLOC(1, sizeof(long)); + *maxHARQ_Tx = MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + mac_MainConfig->ul_SCH_Config->maxHARQ_Tx = maxHARQ_Tx; + periodicBSR_Timer = CALLOC(1, sizeof(long)); + *periodicBSR_Timer = PeriodicBSR_Timer_r12_sf64; + mac_MainConfig->ul_SCH_Config->periodicBSR_Timer = periodicBSR_Timer; + mac_MainConfig->ul_SCH_Config->retxBSR_Timer = RetxBSR_Timer_r12_sf320; + mac_MainConfig->ul_SCH_Config->ttiBundling = 0; // FALSE + + mac_MainConfig->timeAlignmentTimerDedicated = TimeAlignmentTimer_infinity; + + mac_MainConfig->drx_Config = NULL; + + mac_MainConfig->phr_Config = CALLOC(1, sizeof(*mac_MainConfig->phr_Config)); + + mac_MainConfig->phr_Config->present = MAC_MainConfig__phr_Config_PR_setup; + mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; // sf20 = 20 subframes + + mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; // sf20 = 20 subframes + + mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; // Value dB1 =1 dB, dB3 = 3 dB + +#ifdef Rel10 + sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long)); + *sr_ProhibitTimer_r9 = 0; // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR + mac_MainConfig->ext1 = CALLOC(1, sizeof(struct MAC_MainConfig__ext1)); + mac_MainConfig->ext1->sr_ProhibitTimer_r9 = sr_ProhibitTimer_r9; + //sps_RA_ConfigList_rlola = NULL; +#endif + + //change the transmission mode for the primary component carrier + //TODO: add codebook subset restriction here + //TODO: change TM for secondary CC in SCelltoaddmodlist + if (*physicalConfigDedicated) { + if ((*physicalConfigDedicated)->antennaInfo) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.ue_TransmissionMode[0]; + LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.ue_TransmissionMode[0]); + if (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm3) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; + } + else if (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm4) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; + + } + else if (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm5) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; + } + else if (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm6) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; + } + } + else { + LOG_E(RRC,"antenna_info not present in physical_config_dedicated. Not reconfiguring!\n"); + } + if ((*physicalConfigDedicated)->cqi_ReportConfig) { + if ((rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm4) || + (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm5) || + (rrc_inst->configuration.ue_TransmissionMode[0]==AntennaInfoDedicated__transmissionMode_tm6)) { + //feedback mode needs to be set as well + //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable + printf("setting cqi reporting mode to rm31\n"); +#if defined(Rel10) || defined(Rel14) + *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportModeAperiodic_rm31; +#else + *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI +#endif + } + } + else { + LOG_E(RRC,"cqi_ReportConfig not present in physical_config_dedicated. Not reconfiguring!\n"); + } + } + else { + LOG_E(RRC,"physical_config_dedicated not present in RRCConnectionReconfiguration. Not reconfiguring!\n"); + } + + // Measurement ID list + MeasId_list = CALLOC(1, sizeof(*MeasId_list)); + memset((void *)MeasId_list, 0, sizeof(*MeasId_list)); + + MeasId0 = CALLOC(1, sizeof(*MeasId0)); + MeasId0->measId = 1; + MeasId0->measObjectId = 1; + MeasId0->reportConfigId = 1; + ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0); + + /* + * Add one EUTRA Measurement Object + */ + + MeasObj_list = CALLOC(1, sizeof(*MeasObj_list)); + memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list)); + + // Configure MeasObject + + MeasObj = CALLOC(1, sizeof(*MeasObj)); + memset((void *)MeasObj, 0, sizeof(*MeasObj)); + + MeasObj->measObjectId = 1; + MeasObj->measObject.present = MeasObjectToAddMod__measObject_PR_measObjectEUTRA; + MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz + //MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 36090; //band 33, 1.909GHz + MeasObj->measObject.choice.measObjectEUTRA.allowedMeasBandwidth = AllowedMeasBandwidth_mbw25; + MeasObj->measObject.choice.measObjectEUTRA.presenceAntennaPort1 = 1; + MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf = CALLOC(1, sizeof(uint8_t)); + MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf[0] = 0; + MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1; + MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6; + MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL; // Default is 15 or 0dB + + MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList = + (CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList)); + + CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList; + + // Add adjacent cell lists (6 per eNB) + for (i = 0; i < 6; i++) { + CellToAdd = (CellsToAddMod_t *) CALLOC(1, sizeof(*CellToAdd)); + CellToAdd->cellIndex = i + 1; + CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); + CellToAdd->cellIndividualOffset = Q_OffsetRange_dB0; + + ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); + } + + ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj); + // rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; + + // Report Configurations for periodical, A1-A5 events + + /* RRC Strategy Measurement */ + + + if (strcmp("one_shot", trig_param->trigger_policy) == 0){ + + trig_param->report_interval = 0; + trig_param->report_amount = 0; + + } + + else if (strcmp("event_driven", trig_param->trigger_policy) == 0){ + + trig_param->report_interval = 6; + trig_param->report_amount = 2; + + } + + else if (strcmp("periodical", trig_param->trigger_policy) == 0){ + + trig_param->report_interval = 1; + trig_param->report_amount = 7; + + } + + else { + + LOG_E(FLEXRAN_AGENT, "There is something wrong on RRC agent!"); + } + + + + ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list)); + + ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per)); + + // Periodical Measurement Report + + ReportConfig_per->reportConfigId = 1; + ReportConfig_per->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; + + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present = + ReportConfigEUTRA__triggerType_PR_periodical; + + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.periodical.purpose = + ReportConfigEUTRA__triggerType__periodical__purpose_reportStrongestCells; + + // ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = TimeToTrigger_ms40; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = trig_param->report_interval ;//ReportInterval_ms2048; // RRC counter frame- ms1024 is 1ms + + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = trig_param->report_amount; //ReportConfigEUTRA__reportAmount_r2; // put r1 to see once, r2 for 2 times and ... + + + ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per); + + + + quantityConfig = CALLOC(1, sizeof(*quantityConfig)); + memset((void *)quantityConfig, 0, sizeof(*quantityConfig)); + quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct QuantityConfigEUTRA)); + memset((void *)quantityConfig->quantityConfigEUTRA, 0, sizeof(*quantityConfig->quantityConfigEUTRA)); + quantityConfig->quantityConfigCDMA2000 = NULL; + quantityConfig->quantityConfigGERAN = NULL; + quantityConfig->quantityConfigUTRA = NULL; + quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = + CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP))); + quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = + CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ))); + *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = FilterCoefficient_fc4; + *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = FilterCoefficient_fc4; + + +#if defined(ENABLE_ITTI) + /* Initialize NAS list */ + dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); + + /* Add all NAS PDUs to the list */ + 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_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_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! */ + ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; + LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", + i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE"); + } + + /* If list is empty free the list and reset the address */ + if (dedicatedInfoNASList->list.count == 0) { + free(dedicatedInfoNASList); + dedicatedInfoNASList = NULL; + } + +#endif + + memset(buffer, 0, RRC_BUF_SIZE); + + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + xid, //Transaction_id, + (SRB_ToAddModList_t*)NULL, // SRB_configList + (DRB_ToAddModList_t*)NULL, + (DRB_ToReleaseList_t*)NULL, // DRB2_list, + (struct SPS_Config*)NULL, // *sps_Config, + (struct PhysicalConfigDedicated*)*physicalConfigDedicated, +// #ifdef EXMIMO_IOT +// NULL, NULL, NULL,NULL, +// #else + (MeasObjectToAddModList_t*)MeasObj_list, + (ReportConfigToAddModList_t*)ReportConfig_list, + (QuantityConfig_t*)quantityConfig, + (MeasIdToAddModList_t*)MeasId_list, +// #endif + (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 +#if defined(Rel10) || defined(Rel14) + , (SCellToAddMod_r10_t*)NULL +#endif + ); + +#ifdef RRC_MSG_PRINT + LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n"); + for (i = 0; i < size; i++) { + LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]); + } + LOG_F(RRC,"\n"); + //////////////////////////////////////// +#endif + +#if defined(ENABLE_ITTI) + + /* Free all NAS PDUs */ + 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_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 %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][][--- 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); + + 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); + + rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); +} + + + //----------------------------------------------------------------------------- int @@ -2246,41 +2838,41 @@ rrc_eNB_process_MeasurementReport( ) //----------------------------------------------------------------------------- { - T(T_ENB_RRC_MEASUREMENT_REPORT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + // T(T_ENB_RRC_MEASUREMENT_REPORT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + // T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - 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); + // 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", - (int)measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId); - LOG_I(RRC, "RSRP of Target %d\n", - (int)*(measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]-> - measResult.rsrpResult)); - LOG_I(RRC, "RSRQ of Target %d\n", - (int)*(measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]-> - measResult.rsrqResult)); - } + // if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) { + // LOG_I(RRC, "Physical Cell Id %d\n", + // (int)measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId); + // LOG_I(RRC, "RSRP of Target %d\n", + // (int)*(measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]-> + // measResult.rsrpResult)); + // LOG_I(RRC, "RSRQ of Target %d\n", + // (int)*(measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]-> + // measResult.rsrqResult)); + // } -#if defined(Rel10) || defined(Rel14) +// #if defined(Rel10) || defined(Rel14) LOG_I(RRC, "RSRP of Source %ld\n", measResults2->measResultPCell.rsrpResult); LOG_I(RRC, "RSRQ of Source %ld\n", measResults2->measResultPCell.rsrqResult); -#else - LOG_I(RRC, "RSRP of Source %d\n", measResults2->measResultServCell.rsrpResult); - LOG_I(RRC, "RSRQ of Source %d\n", measResults2->measResultServCell.rsrqResult); -#endif +// #else + // LOG_I(RRC, "RSRP of Source %d\n", measResults2->measResultServCell.rsrpResult); + // LOG_I(RRC, "RSRQ of Source %d\n", measResults2->measResultServCell.rsrqResult); +// #endif - 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 %x as Handover is in progress... \n", ctxt_pP->module_id, ctxt_pP->frame, - ctxt_pP->rnti); - } + // 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 %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 //Send Handover Request -> target eNB @@ -4501,6 +5093,13 @@ rrc_eNB_decode_dcch( ue_context_p, &ul_dcch_msg->message.choice.c1.choice.measurementReport. criticalExtensions.choice.c1.choice.measurementReport_r8.measResults); + #if defined(FLEXRAN_AGENT_SB_IF) + + if (rrc_agent_registered[ctxt_pP->module_id]) { + agent_rrc_xface[ctxt_pP->eNB_index]->flexran_trigger_rrc_measurements (ctxt_pP->module_id, &ul_dcch_msg->message.choice.c1.choice.measurementReport.criticalExtensions.choice.c1.choice.measurementReport_r8.measResults); + } +#endif + break; case UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete: @@ -4553,8 +5152,8 @@ rrc_eNB_decode_dcch( #if defined(FLEXRAN_AGENT_SB_IF) //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future - if (mac_agent_registered[ctxt_pP->module_id]) { - agent_mac_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + if (rrc_agent_registered[ctxt_pP->module_id]) { + agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, ue_context_p->ue_id_rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED); } @@ -4657,8 +5256,8 @@ rrc_eNB_decode_dcch( #if defined(FLEXRAN_AGENT_SB_IF) //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future - if (mac_agent_registered[ctxt_pP->module_id]) { - agent_mac_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + if (rrc_agent_registered[ctxt_pP->module_id]) { + agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, ue_context_p->ue_id_rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); } From 714ad4d774a665bc288425d47dcf2ba2f9e2d7cc Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Wed, 5 Apr 2017 16:48:21 +0200 Subject: [PATCH 005/141] Warning Decreasing --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 15 +++++++------- .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 16 +++++++-------- .../CONTROL_MODULES/RRC/flexran_agent_rrc.h | 6 +++--- .../RRC/flexran_agent_rrc_defs.h | 4 +++- openair2/ENB_APP/flexran_agent.c | 2 +- openair2/ENB_APP/flexran_agent.h | 5 ++++- openair2/ENB_APP/flexran_agent_common.c | 1 + openair2/ENB_APP/flexran_agent_common.h | 14 ++++++------- openair2/ENB_APP/flexran_agent_handler.c | 5 +++-- openair2/ENB_APP/flexran_agent_ran_api.c | 20 ++++++++++++++----- openair2/ENB_APP/flexran_agent_ran_api.h | 13 +++++++++++- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 2 +- .../flexran_agent_scheduler_dlsch_ue_remote.c | 2 +- openair2/RRC/LITE/rrc_eNB.c | 6 +++--- 14 files changed, 70 insertions(+), 41 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 01df6248f1..ba69308553 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -32,6 +32,7 @@ #include "flexran_agent_mac_internal.h" #include "flexran_agent_net_comm.h" #include "flexran_agent_timer.h" +#include "flexran_agent_ran_api.h" #include "LAYER2/MAC/proto.h" #include "LAYER2/MAC/flexran_agent_mac_proto.h" @@ -63,7 +64,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, // Protocol__FlexHeader *header; int i, j, k; - int cc_id = 0; + // int cc_id = 0; int enb_id = mod_id; /* Allocate memory for list of UE reports */ @@ -141,11 +142,11 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, /* Check flag for creation of MAC CE buffer status report */ if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_MAC_CE_BS) { // TODO: Fill in the actual MAC CE buffer status report - ue_report[i]->pending_mac_ces = (flexran_get_MAC_CE_bitmap_TA(enb_id,i,0) | (0 << 1) | (0 << 2) - | (0 << 3)) & 15; /* Use as bitmap. Set one or more of the; /* Use as bitmap. Set one or more of the - PROTOCOL__FLEX_CE_TYPE__FLPCET_ values - found in stats_common.pb-c.h. See - flex_ce_type in FlexRAN specification */ + ue_report[i]->pending_mac_ces = (flexran_get_MAC_CE_bitmap_TA(enb_id,i,0) | (0 << 1) | (0 << 2) | (0 << 3)) & 15; + // Use as bitmap. Set one or more of the; /* Use as bitmap. Set one or more of the + // PROTOCOL__FLEX_CE_TYPE__FLPCET_ values + // found in stats_common.pb-c.h. See + // flex_ce_type in FlexRAN specification ue_report[i]->has_pending_mac_ces = 1; } @@ -213,7 +214,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, goto error; protocol__flex_csi_p11__init(csi11); - csi11->wb_cqi = flexran_get_ue_wcqi (enb_id, i); + csi11->wb_cqi = flexran_get_ue_wcqi (enb_id, i); // According To spec 36.213 if (flexran_get_antenna_ports(enb_id, j) == 2 && csi_reports[j]->ri == 1) { diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index 9475b06643..d48d12d670 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -61,12 +61,12 @@ void flexran_agent_init_rrc_agent(mid_t mod_id) { -int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) { +void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) { int size; Protocol__FlexranMessage *msg; Protocol__FlexHeader *header; void *data; - int priority; + int priority = 0; err_code_t err_code; int xid = 0; @@ -258,7 +258,7 @@ int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_cha LOG_D(FLEXRAN_AGENT,"sent message with size %d\n", size); return; error: - LOG_D(FLEXRAN_AGENT, "Could not send UE state message\n"); + LOG_E(FLEXRAN_AGENT, "Could not send UE state message becasue of %d \n",err_code); } @@ -278,10 +278,10 @@ int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg) { } /* this is called by RRC as a part of rrc xface . The controller previously requested this*/ -int flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults) { +void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults) { // int i, m, k; - int priority; + int priority = 0; // Warning Preventing void *data; int size; err_code_t err_code; @@ -618,16 +618,16 @@ int flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults) LOG_I(FLEXRAN_AGENT,"RRC Trigger is done \n"); - return 0; + return; error: - LOG_E(RRC, "Error triggering RRC measurements message!"); + LOG_E(FLEXRAN_AGENT, "Could not send UE state message becasue of %d \n",err_code); /* Free the measurement report received from UE. */ // ASN_STRUCT_FREE(asn_DEF_MeasResults, p->meas); /* Free the params. */ // free(p); - return -1; + // return -1; } diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h index 17b58dac93..aa210f9d41 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h @@ -41,7 +41,7 @@ #include "flexran.pb-c.h" #include "stats_messages.pb-c.h" #include "stats_common.pb-c.h" -#include "MeasResults.h" + #include "flexran_agent_common.h" #include "flexran_agent_rrc_defs.h" @@ -51,7 +51,7 @@ void flexran_agent_init_rrc_agent(mid_t mod_id); /* UE state change message constructor and destructor */ -int flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change); +void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change); int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg); @@ -63,7 +63,7 @@ int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg); // void flexran_agent_send_update_rrc_stats(mid_t mod_id); /* this is called by RRC as a part of rrc xface . The controller previously requested this*/ -int flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t *); +void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t *); /*Register technology specific interface callbacks*/ int flexran_agent_register_rrc_xface(mid_t mod_id, AGENT_RRC_xface *xface); diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h index 10fc4ba254..679bc4d623 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h @@ -38,9 +38,11 @@ #ifndef __FLEXRAN_AGENT_RRC_PRIMITIVES_H__ #define __FLEXRAN_AGENT_RRC_PRIMITIVES_H__ +#include "PHY/extern.h" #include "flexran_agent_defs.h" #include "flexran.pb-c.h" #include "header.pb-c.h" +#include "MeasResults.h" #define RINGBUFFER_SIZE 100 @@ -55,7 +57,7 @@ typedef struct { void (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, uint32_t state_change); - void (*flexran_trigger_rrc_measurements)(mid_t mod_id, MeasResults_t* measResults) + void (*flexran_trigger_rrc_measurements)(mid_t mod_id, MeasResults_t* measResults); } AGENT_RRC_xface; diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index d96076df83..ec984cfa8b 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -264,7 +264,7 @@ int flexran_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properti AGENT_MAC_xface *mac_agent_xface = (AGENT_MAC_xface *) malloc(sizeof(AGENT_MAC_xface)); flexran_agent_register_mac_xface(mod_id, mac_agent_xface); - AGENT_RRC_xface *rrc_agent_xface = (AGENT_MAC_xface *) malloc(sizeof(AGENT_MAC_xface)); + AGENT_RRC_xface *rrc_agent_xface = (AGENT_RRC_xface *) malloc(sizeof(AGENT_RRC_xface)); flexran_agent_register_rrc_xface(mod_id, rrc_agent_xface); /* diff --git a/openair2/ENB_APP/flexran_agent.h b/openair2/ENB_APP/flexran_agent.h index aec4f004a8..0ef48e2105 100644 --- a/openair2/ENB_APP/flexran_agent.h +++ b/openair2/ENB_APP/flexran_agent.h @@ -34,7 +34,10 @@ #include "flexran_agent_extern.h" #include "flexran_agent_timer.h" #include "flexran_agent_defs.h" - +#include "flexran_agent_net_comm.h" +#include "flexran_agent_ran_api.h" +#include "flexran_agent_mac.h" +#include "flexran_agent_rrc.h" #include "log.h" #include "assertions.h" diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 7d9cfe685c..27364a7eaa 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -33,6 +33,7 @@ #include "flexran_agent_common_internal.h" #include "flexran_agent_extern.h" #include "flexran_agent_net_comm.h" +#include "flexran_agent_ran_api.h" #include "PHY/extern.h" #include "log.h" diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h index 4f2b9c71bb..d96712622f 100644 --- a/openair2/ENB_APP/flexran_agent_common.h +++ b/openair2/ENB_APP/flexran_agent_common.h @@ -37,7 +37,8 @@ #include "flexran.pb-c.h" #include "stats_messages.pb-c.h" #include "stats_common.pb-c.h" - +#include "flexran_agent_ran_api.h" +#include "flexran_agent_net_comm.h" #include "flexran_agent_defs.h" #include "enb_config.h" @@ -156,16 +157,15 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr /* Function to be used to handle reply message . */ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *report_config, Protocol__FlexranMessage **msg); -/* Statistics request protocol message constructor and destructor */ +/* Top level Statistics request protocol message constructor and destructor */ int flexran_agent_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg); int flexran_agent_destroy_stats_request(Protocol__FlexranMessage *msg); -int flexran_agent_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg); -int flexran_agent_destroy_stats_request(Protocol__FlexranMessage *msg); - +err_code_t flexran_agent_init_cont_stats_update(mid_t mod_id); + +void flexran_agent_send_update_stats(mid_t mod_id); + err_code_t flexran_agent_enable_cont_stats_update(mid_t mod_id, xid_t xid, stats_request_config_t *stats_req) ; -int flexran_agent_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg); - #endif diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index b57039bec5..84948d1eee 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -31,6 +31,7 @@ #include "flexran_agent_mac.h" #include "flexran_agent_rrc.h" #include "flexran_agent_timer.h" +#include "flexran_agent_ran_api.h" #include "log.h" #include "assertions.h" @@ -96,7 +97,7 @@ Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id, err_code= PROTOCOL__FLEXRAN_ERR__MSG_DECODING; goto error; } - printf("==================> %d %d \n", decoded_message->msg_case, decoded_message->msg_dir); + //printf("==================> %d %d \n", decoded_message->msg_case, decoded_message->msg_dir); if ((decoded_message->msg_case > sizeof(agent_messages_callback) / (3 * sizeof(flexran_agent_message_decoded_callback))) || (decoded_message->msg_dir > PROTOCOL__FLEXRAN_DIRECTION__UNSUCCESSFUL_OUTCOME)){ err_code= PROTOCOL__FLEXRAN_ERR__MSG_NOT_HANDLED; @@ -754,4 +755,4 @@ err_code_t flexran_agent_destroy_cont_stats_update(mid_t mod_id) { // mac_agent_registered[mod_id] = 0; return 1; -} \ No newline at end of file +} diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 17a53c7eb0..dd3e8a4bcb 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -152,11 +152,21 @@ int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id) { // return ((UE_list_t *)enb_ue[mod_id])->eNB_UE_stats[UE_PCCID(mod_id,ue_id)][ue_id].dl_cqi; } -int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { +int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id, char * buffer_status) { rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); - mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id,frame,ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); - return rlc_status.bytes_in_buffer; + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id,frame,ENB_FLAG_YES,MBMS_FLAG_NO,channel_id,0); + + if (strcmp(buffer_status, "bytes_buffer")){ + return rlc_status.bytes_in_buffer; + } else if(strcmp(buffer_status, "pdu_buffer")) { + return rlc_status.pdus_in_buffer; + } + /* else if (strcmp(buffer_status, "head_line")){ */ + + /* return rlc_status.head_sdu_remaining_size_to_send; */ + + /* } */ } int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { @@ -168,7 +178,7 @@ int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_i short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id) { - UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; + // UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; int rnti; rnti = flexran_get_ue_crnti(mod_id, ue_id); @@ -227,7 +237,7 @@ void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id) { int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id,int CC_id) { - UE_list_t *UE_list = &eNB_mac_inst[mod_id].UE_list; + // UE_list_t *UE_list = &eNB_mac_inst[mod_id].UE_list; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 12962a1f9d..4a893a4c96 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -89,7 +89,7 @@ int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id); int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id); /* Get the transmission queue size for a UE with a channel_id logical channel id */ -int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); +int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id, char * buffer_status); /* Get the head of line delay for a UE with a channel_id logical channel id */ int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); @@ -198,6 +198,17 @@ int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id); int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id); +int flexran_get_hopping_mode(mid_t mod_id, int CC_id); + +int flexran_get_hopping_offset(mid_t mod_id, int CC_id); + +int flexran_get_n_SB(mid_t mod_id, int CC_id); + +int flexran_get_phich_resource(mid_t mod_id, int CC_id); + +int flexran_get_enable64QAM(mid_t mod_id, int CC_id); + +int flexran_get_phich_duration(mid_t mod_id, int CC_id); /* * ************************************ diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 00027f04ce..953de903c4 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -50,7 +50,7 @@ #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "ENB_APP/flexran_agent_defs.h" - +#include "flexran_agent_ran_api.h" #include "pdcp.h" #include "header.pb-c.h" diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c index 7dec8d0c56..bff461acc7 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c @@ -30,7 +30,7 @@ */ #include "flexran_agent_common_internal.h" - +#include "flexran_agent_ran_api.h" #include "flexran_agent_scheduler_dlsch_ue_remote.h" #include "LAYER2/MAC/defs.h" diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 6247548bcc..1f2bf2d262 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2198,10 +2198,10 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt MeasObjectToAddModList_t *MeasObj_list = NULL; MeasObjectToAddMod_t *MeasObj = NULL; ReportConfigToAddModList_t *ReportConfig_list = NULL; - ReportConfigToAddMod_t *ReportConfig_per, *ReportConfig_A1, - *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; + ReportConfigToAddMod_t *ReportConfig_per;//, *ReportConfig_A1, + // *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; MeasIdToAddModList_t *MeasId_list = NULL; - MeasIdToAddMod_t *MeasId0, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5; + MeasIdToAddMod_t *MeasId0; //, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5; #if Rel10 long *sr_ProhibitTimer_r9 = NULL; // uint8_t sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1); From 77c4d3742f884039d7d228b05cf36e5fc2ca269d Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Fri, 7 Apr 2017 11:28:51 +0200 Subject: [PATCH 006/141] Wanring Preventing remote-sch --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 10 +++++----- .../CONTROL_MODULES/MAC/flexran_agent_mac_defs.h | 6 +++--- .../CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h | 2 +- openair2/ENB_APP/flexran_agent_common.h | 2 +- openair2/ENB_APP/flexran_agent_handler.c | 4 ++-- openair2/ENB_APP/flexran_agent_ran_api.c | 16 +++------------- openair2/ENB_APP/flexran_agent_ran_api.h | 2 +- 7 files changed, 16 insertions(+), 26 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index ba69308553..d22633a818 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -115,11 +115,11 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, protocol__flex_rlc_bsr__init(rlc_reports[j]); rlc_reports[j]->lc_id = j+1; rlc_reports[j]->has_lc_id = 1; - rlc_reports[j]->tx_queue_size = flexran_get_tx_queue_size(enb_id, i, j + 1, "bytes_buffer"); + rlc_reports[j]->tx_queue_size = flexran_get_tx_queue_size(enb_id, i, j + 1); rlc_reports[j]->has_tx_queue_size = 1; //TODO:Set tx queue head of line delay in ms - rlc_reports[j]->tx_queue_hol_delay = flexran_get_tx_queue_size(enb_id, i, j + 1, "head_line"); + rlc_reports[j]->tx_queue_hol_delay = flexran_get_hol_delay(enb_id, i, j + 1); rlc_reports[j]->has_tx_queue_hol_delay = 1; //TODO:Set retransmission queue size in bytes rlc_reports[j]->retransmission_queue_size = 10; @@ -128,7 +128,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, rlc_reports[j]->retransmission_queue_hol_delay = 100; rlc_reports[j]->has_retransmission_queue_hol_delay = 0; //TODO DONE:Set current size of the pending message in bytes - rlc_reports[j]->status_pdu_size = flexran_get_hol_delay(enb_id, i, j + 1); + rlc_reports[j]->status_pdu_size = flexran_get_tx_queue_size(enb_id, i, j + 1); rlc_reports[j]->has_status_pdu_size = 1; } @@ -1174,8 +1174,8 @@ int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->flexran_agent_send_sr_info = flexran_agent_send_sr_info; xface->flexran_agent_send_sf_trigger = flexran_agent_send_sf_trigger; //xface->flexran_agent_send_update_mac_stats = flexran_agent_send_update_mac_stats; - xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_default; - //xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_remote; + // xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_default; + xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_remote; xface->flexran_agent_get_pending_dl_mac_config = flexran_agent_get_pending_dl_mac_config; xface->dl_scheduler_loaded_lib = NULL; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h index 9ec8594f88..8354223123 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h @@ -48,7 +48,7 @@ typedef struct { /// Send to the controller all the mac stat updates that occured during this subframe /// based on the stats request configuration - void (*flexran_agent_send_update_mac_stats)(mid_t mod_id); + // void (*flexran_agent_send_update_mac_stats)(mid_t mod_id); /// Provide to the scheduler a pending dl_mac_config message void (*flexran_agent_get_pending_dl_mac_config)(mid_t mod_id, @@ -63,8 +63,8 @@ typedef struct { /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) - int (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, - uint8_t state_change); + // int (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, + // uint8_t state_change); void *dl_scheduler_loaded_lib; diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h index 679bc4d623..95fbf3bed0 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h @@ -54,7 +54,7 @@ typedef struct { /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) - void (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, + int (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, uint32_t state_change); void (*flexran_trigger_rrc_measurements)(mid_t mod_id, MeasResults_t* measResults); diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h index d96712622f..8fd62a0524 100644 --- a/openair2/ENB_APP/flexran_agent_common.h +++ b/openair2/ENB_APP/flexran_agent_common.h @@ -166,6 +166,6 @@ err_code_t flexran_agent_init_cont_stats_update(mid_t mod_id); void flexran_agent_send_update_stats(mid_t mod_id); err_code_t flexran_agent_enable_cont_stats_update(mid_t mod_id, xid_t xid, stats_request_config_t *stats_req) ; - +err_code_t flexran_agent_disable_cont_stats_update(mid_t mod_id); #endif diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index 84948d1eee..fc2ed135c8 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -97,7 +97,7 @@ Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id, err_code= PROTOCOL__FLEXRAN_ERR__MSG_DECODING; goto error; } - //printf("==================> %d %d \n", decoded_message->msg_case, decoded_message->msg_dir); + // printf("==================> %d %d \n", decoded_message->msg_case, decoded_message->msg_dir); if ((decoded_message->msg_case > sizeof(agent_messages_callback) / (3 * sizeof(flexran_agent_message_decoded_callback))) || (decoded_message->msg_dir > PROTOCOL__FLEXRAN_DIRECTION__UNSUCCESSFUL_OUTCOME)){ err_code= PROTOCOL__FLEXRAN_ERR__MSG_NOT_HANDLED; @@ -309,7 +309,7 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr } else if (comp_req->report_frequency == PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_CONTINUOUS) { /*If request was for continuous updates, disable the previous configuration and set up a new one*/ - // flexran_agent_disable_cont_stats_update(mod_id); + flexran_agent_disable_cont_stats_update(mod_id); stats_request_config_t request_config; request_config.report_type = PROTOCOL__FLEX_STATS_TYPE__FLST_COMPLETE_STATS; request_config.report_frequency = PROTOCOL__FLEX_STATS_REPORT_FREQ__FLSRF_ONCE; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index dd3e8a4bcb..59ccb67293 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -152,21 +152,11 @@ int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id) { // return ((UE_list_t *)enb_ue[mod_id])->eNB_UE_stats[UE_PCCID(mod_id,ue_id)][ue_id].dl_cqi; } -int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id, char * buffer_status) { +int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); - mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id,frame,ENB_FLAG_YES,MBMS_FLAG_NO,channel_id,0); - - if (strcmp(buffer_status, "bytes_buffer")){ - return rlc_status.bytes_in_buffer; - } else if(strcmp(buffer_status, "pdu_buffer")) { - return rlc_status.pdus_in_buffer; - } - /* else if (strcmp(buffer_status, "head_line")){ */ - - /* return rlc_status.head_sdu_remaining_size_to_send; */ - - /* } */ + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id,frame,ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); + return rlc_status.bytes_in_buffer; } int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 4a893a4c96..8a7d6dbaf7 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -89,7 +89,7 @@ int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id); int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id); /* Get the transmission queue size for a UE with a channel_id logical channel id */ -int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id, char * buffer_status); +int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); /* Get the head of line delay for a UE with a channel_id logical channel id */ int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); From 14fb9e2ba201790e3c741501594e930248e66e09 Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Tue, 11 Apr 2017 08:58:20 +0000 Subject: [PATCH 007/141] Changed default scheduler to local --- openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index d22633a818..63dba00d7c 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1174,8 +1174,8 @@ int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->flexran_agent_send_sr_info = flexran_agent_send_sr_info; xface->flexran_agent_send_sf_trigger = flexran_agent_send_sf_trigger; //xface->flexran_agent_send_update_mac_stats = flexran_agent_send_update_mac_stats; - // xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_default; - xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_remote; + xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_default; + //xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_remote; xface->flexran_agent_get_pending_dl_mac_config = flexran_agent_get_pending_dl_mac_config; xface->dl_scheduler_loaded_lib = NULL; From e36c5b6024d02e497c2196978a03025104db1a1e Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Tue, 11 Apr 2017 09:28:22 +0000 Subject: [PATCH 008/141] Fixed compilation errors when compiling without agent enabled --- openair2/LAYER2/MAC/eNB_scheduler.c | 11 ++++++----- openair2/RRC/LITE/rrc_eNB.c | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index b75a3e7e8e..2bea6e1f1f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -1082,15 +1082,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, for (CC_id=0;CC_idflexran_agent_send_update_mac_stats(module_idP); // } -// #endif -// #endif -flexran_agent_send_update_stats(module_idP); +#endif +#endif + /* int dummy=0; for (i=0; diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 1f2bf2d262..53616d334d 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2158,6 +2158,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons PDCP_TRANSMISSION_MODE_CONTROL); } +#if defined(FLEXRAN_AGENT_SB_IF) //----------------------------------------------------------------------------- void @@ -2749,7 +2750,7 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt PDCP_TRANSMISSION_MODE_CONTROL); } - +#endif //----------------------------------------------------------------------------- From e3df5d3de55f8966c7eba3c9c24e3438b228ea86 Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Tue, 11 Apr 2017 11:46:34 +0000 Subject: [PATCH 009/141] Fixed warnings and bugs --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 4 +++- .../RRC/flexran_agent_rrc_defs.h | 4 ++-- openair2/ENB_APP/flexran_agent_common.c | 3 ++- openair2/LAYER2/MAC/proto.h | 1 + openair2/RRC/LITE/proto.h | 17 +++++++++++++++++ openair2/RRC/LITE/rrc_eNB.c | 3 --- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 63dba00d7c..73ae74a32f 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -214,7 +214,9 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, goto error; protocol__flex_csi_p11__init(csi11); - csi11->wb_cqi = flexran_get_ue_wcqi (enb_id, i); + csi11->wb_cqi = malloc(sizeof(csi11->wb_cqi)); + csi11->n_wb_cqi = 1; + csi11->wb_cqi[0] = flexran_get_ue_wcqi (enb_id, i); // According To spec 36.213 if (flexran_get_antenna_ports(enb_id, j) == 2 && csi_reports[j]->ri == 1) { diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h index 95fbf3bed0..ad1375171e 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h @@ -54,8 +54,8 @@ typedef struct { /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) - int (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, - uint32_t state_change); + void (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, + uint8_t state_change); void (*flexran_trigger_rrc_measurements)(mid_t mod_id, MeasResults_t* measResults); diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index d67eb8b6a7..78d3a75ec7 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -1075,7 +1075,8 @@ int flexran_agent_rrc_measurement(mid_t mod_id, const void *params, Protocol__Fl int flexran_agent_destroy_rrc_measurement(Protocol__FlexranMessage *msg){ - + // TODO + return 0; } diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index ea264f1bfd..16f2d186ea 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -539,6 +539,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); int phy_stats_exist(module_id_t Mod_id, int rnti); +void sort_UEs (module_id_t Mod_idP, int frameP, sub_frame_t subframeP); /*! \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. diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h index 8433980be4..20bc99ab79 100644 --- a/openair2/RRC/LITE/proto.h +++ b/openair2/RRC/LITE/proto.h @@ -33,6 +33,10 @@ #include "RRC/LITE/defs.h" +#if defined(FLEXRAN_AGENT_SB_IF) +#include "flexran_agent_extern.h" +#endif + //main.c int rrc_init_global_param(void); int L3_xface_init(void); @@ -254,6 +258,19 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( const uint8_t ho_state ); + +#if defined(FLEXRAN_AGENT_SB_IF) + +void +flexran_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, + agent_reconf_rrc * trig_param + ); + +#endif + void rrc_eNB_generate_dedeicatedRRCConnectionReconfiguration( const protocol_ctxt_t* const ctxt_pP, diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 53616d334d..11628a80b6 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -93,9 +93,6 @@ #include "SIMULATION/TOOLS/defs.h" // for taus -#if defined(FLEXRAN_AGENT_SB_IF) -#include "flexran_agent_extern.h" -#endif //#define XER_PRINT #ifdef PHY_EMUL From 3bd3bedcd2d60bad25f79970bfc6f56b9f18f698 Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Tue, 11 Apr 2017 13:25:08 +0000 Subject: [PATCH 010/141] Fixed ue state change notification functionality for deactivation of UEs --- openair2/RRC/LITE/L2_interface.c | 11 +++++++++++ openair2/RRC/LITE/rrc_eNB.c | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index 64734cac9a..6a64d7811e 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -52,6 +52,10 @@ extern UE_MAC_INST *UE_mac_inst; # include "intertask_interface.h" #endif +#if defined(FLEXRAN_AGENT_SB_IF) +#include "flexran_agent_extern.h" +#endif + //#define RRC_DATA_REQ_DEBUG #define DEBUG_RRC 1 @@ -734,6 +738,13 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, else { LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP); } +#if defined(FLEXRAN_AGENT_SB_IF) + if (rrc_agent_registered[Mod_instP]) { + agent_rrc_xface[Mod_instP]->flexran_agent_notify_ue_state_change(Mod_instP, + rntiP, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + } +#endif rrc_mac_remove_ue(Mod_instP,rntiP); } diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 11628a80b6..6fbdd645ed 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -829,6 +829,15 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* #endif #endif +#if defined(FLEXRAN_AGENT_SB_IF) + if (rrc_agent_registered[enb_mod_idP]) { + agent_rrc_xface[enb_mod_idP]->flexran_agent_notify_ue_state_change(enb_mod_idP, + rnti, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + } +#endif + + rrc_mac_remove_ue(enb_mod_idP,rnti); rrc_rlc_remove_ue(&ctxt); pdcp_remove_UE(&ctxt); @@ -4885,6 +4894,13 @@ rrc_eNB_decode_ccch( } else { // no context available +#if defined(FLEXRAN_AGENT_SB_IF) + if (rrc_agent_registered[ctxt_pP->module_id]) { + agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + ctxt_pP->rnti, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + } +#endif 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), random_value); From 169f33464e91d43410447b34dc21f5fbd31ec241 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Tue, 18 Apr 2017 18:13:42 +0200 Subject: [PATCH 011/141] Uplink Agent Mac function --- cmake_targets/CMakeLists.txt | 1 + .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 1 + .../MAC/flexran_agent_mac_defs.h | 4 + openair2/LAYER2/MAC/eNB_scheduler.c | 183 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 8 + .../MAC/flexran_agent_scheduler_ulsch_ue.c | 1673 +++++++++++++++++ 7 files changed, 1868 insertions(+), 4 deletions(-) create mode 100644 openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 5413014fbf..192590e20f 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1207,6 +1207,7 @@ if (FLEXRAN_AGENT_SB_IF) set (MAC_SRC ${MAC_SRC} ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue.c + ${MAC_DIR}/flexran_agent_scheduler_ulsch_ue.c ${MAC_DIR}/flexran_agent_scheduler_dataplane.c ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue_remote.c ) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 73ae74a32f..405837061a 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1177,6 +1177,7 @@ int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->flexran_agent_send_sf_trigger = flexran_agent_send_sf_trigger; //xface->flexran_agent_send_update_mac_stats = flexran_agent_send_update_mac_stats; xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_default; + xface->flexran_agent_schedule_ul_spec = flexran_agent_schedule_ulsch_ue_spec; //xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_remote; xface->flexran_agent_get_pending_dl_mac_config = flexran_agent_get_pending_dl_mac_config; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h index 8354223123..ab6bf57417 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h @@ -61,6 +61,10 @@ typedef struct { int *mbsfn_flag, Protocol__FlexranMessage **dl_info); + void (*flexran_agent_schedule_ul_spec)(mid_t module_idP, uint32_t frameP, unsigned char cooperation_flag, + uint32_t subframeP, + unsigned char sched_subframe); + /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) // int (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 2bea6e1f1f..7250d66f07 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -382,11 +382,26 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, if (mac_xface->frame_parms->frame_type == FDD) { //FDD +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag); +#else + if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + } else if ((mac_xface->frame_parms->tdd_config == 0) || //TDD (mac_xface->frame_parms->tdd_config == 3) || (mac_xface->frame_parms->tdd_config == 6)) { +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag); +#else + if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif } #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); @@ -418,14 +433,31 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, switch (mac_xface->frame_parms->tdd_config) { case 0: case 1: - schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7); +#ifndef FLEXRAN_AGENT_SB_IF + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);//,calibration_flag); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif #ifndef FLEXRAN_AGENT_SB_IF fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); #endif break; case 6: +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8); +#else + + if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); #endif @@ -435,7 +467,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; } } else { //FDD +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,1,5); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -465,7 +506,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, // TDD, nothing // FDD, normal UL/DLSCH if (mac_xface->frame_parms->frame_type == FDD) { //FDD +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,2,6); +#else + + if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -498,7 +548,15 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, if (mac_xface->frame_parms->frame_type == TDD) { switch (mac_xface->frame_parms->tdd_config) { case 2: +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif // no break here! case 5: @@ -528,8 +586,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; } } else { //FDD - +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,3,7); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -563,7 +629,15 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, switch (mac_xface->frame_parms->tdd_config) { case 1: // schedule_RA(module_idP,frameP,subframeP); +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif // no break here! case 2: @@ -600,8 +674,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } } else { if (mac_xface->frame_parms->frame_type == FDD) { //FDD - +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP, frameP, subframeP, mbsfn_status); fill_DLSCH_dci(module_idP, frameP, subframeP, mbsfn_status); @@ -637,7 +719,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, //schedule_RA(module_idP,frameP,subframeP,5); if (mac_xface->frame_parms->frame_type == FDD) { schedule_RA(module_idP,frameP,subframeP,1); +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,5,9); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP, frameP, subframeP, mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -700,7 +791,15 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; case 1: +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif // schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); #ifndef FLEXRAN_AGENT_SB_IF fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -708,7 +807,15 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; case 6: +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif // schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); #ifndef FLEXRAN_AGENT_SB_IF fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -767,7 +874,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; } } else { //FDD +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,6,0); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -850,7 +966,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; } } else { //FDD +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,7,1); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -888,7 +1013,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, case 5: // schedule_RA(module_idP,subframeP); +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -915,7 +1049,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; } } else { //FDD +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,8,2); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -946,7 +1089,15 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, if (mac_xface->frame_parms->frame_type == TDD) { switch (mac_xface->frame_parms->tdd_config) { case 1: +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif schedule_RA(module_idP,frameP,subframeP,7); // 7 = Msg3 subframeP, not #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); @@ -972,7 +1123,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, case 3: case 4: +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -996,7 +1156,15 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; case 6: +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif //schedule_RA(module_idP,frameP,subframeP); #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); @@ -1049,7 +1217,16 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; } } else { //FDD +#ifndef FLEXRAN_AGENT_SB_IF schedule_ulsch(module_idP,frameP,cooperation_flag,9,3); +#else + +if (mac_agent_registered[module_idP]){ + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + } + +#endif + #ifndef FLEXRAN_AGENT_SB_IF schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 6d0044b346..585d9c2c1c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -885,7 +885,7 @@ abort(); rb_table_index=UE_template->pre_allocated_rb_table_index_ul; } else { mcs=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); - rb_table_index=5; // for PHR + rb_table_index=13; // for PHR } UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index a3ff3b6a4a..8a9d5971e3 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -168,6 +168,14 @@ void _dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, void flexran_schedule_ue_spec_default(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, Protocol__FlexranMessage **dl_info); +/* + Uplink scheduler used by MAC agent +*/ + +void flexran_agent_schedule_ulsch_ue_spec(module_id_t module_idP, frame_t frameP, unsigned char cooperation_flag, + sub_frame_t subframeP, + unsigned char sched_subframe); + /* * Data plane function for applying the DL decisions of the scheduler */ diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c new file mode 100644 index 0000000000..2abd09024b --- /dev/null +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -0,0 +1,1673 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file eNB_scheduler_ulsch.c + * \brief FlexRAN eNB procedures for the ULSCH transport channel + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 1.0 + * @ingroup _mac + + */ + +#include "assertions.h" +#include "PHY/defs.h" +#include "PHY/extern.h" + +#include "SCHED/defs.h" +#include "SCHED/extern.h" + +#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/extern.h" +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "UTIL/OPT/opt.h" +#include "OCG.h" +#include "OCG_extern.h" + +#include "RRC/LITE/extern.h" +#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" + +//#include "LAYER2/MAC/pre_processor.c" +#include "pdcp.h" + +#if defined(ENABLE_ITTI) +# include "intertask_interface.h" +#endif + +#include "T.h" + +// #define ENABLE_MAC_PAYLOAD_DEBUG +// #define DEBUG_eNB_SCHEDULER 1 + +// // This table holds the allowable PRB sizes for ULSCH transmissions +// uint8_t rb_table[33] = {1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60,72,75,80,81,90,96,100}; + +// void rx_sdu(const module_id_t enb_mod_idP, +// const int CC_idP, +// const frame_t frameP, +// const sub_frame_t subframeP, +// const rnti_t rntiP, +// uint8_t *sduP, +// const uint16_t sdu_lenP, +// const int harq_pidP, +// uint8_t *msg3_flagP) +// { + +// unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; +// unsigned char rx_lcids[NB_RB_MAX]; +// unsigned short rx_lengths[NB_RB_MAX]; +// int UE_id = find_UE_id(enb_mod_idP,rntiP); +// int ii,j; +// eNB_MAC_INST *eNB = &eNB_mac_inst[enb_mod_idP]; +// UE_list_t *UE_list= &eNB->UE_list; +// int crnti_rx=0; +// int old_buffer_info; + +// start_meas(&eNB->rx_ulsch_sdu); + +// if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1) ) +// for(ii=0; iiUE_sched_ctrl[UE_id].ul_scheduled &= (~(1<UE_sched_ctrl[UE_id].ul_inactivity_timer=0; +// UE_list->UE_sched_ctrl[UE_id].ul_failure_timer =0; +// UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { +// UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0; +// mac_eNB_rrc_ul_in_sync(enb_mod_idP,CC_idP,frameP,subframeP,UE_RNTI(enb_mod_idP,UE_id)); +// } +// } + + +// payload_ptr = parse_ulsch_header(sduP,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_lenP); + +// T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP), +// T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu)); +// T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP), +// T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP)); + +// eNB->eNB_stats[CC_idP].ulsch_bytes_rx=sdu_lenP; +// eNB->eNB_stats[CC_idP].total_ulsch_bytes_rx+=sdu_lenP; +// eNB->eNB_stats[CC_idP].total_ulsch_pdus_rx+=1; +// // control element +// for (i=0; iUE_template[CC_idP][UE_id].phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET; +// LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n", +// enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].phr_info); +// UE_list->UE_template[CC_idP][UE_id].phr_info_configured=1; +// UE_list->UE_sched_ctrl[UE_id].phr_received = 1; +// } +// payload_ptr+=sizeof(POWER_HEADROOM_CMD); +// break; + +// case CRNTI: +// UE_id = find_UE_id(enb_mod_idP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]); +// LOG_I(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n", +// frameP,subframeP,enb_mod_idP, CC_idP, rx_ces[i], i,num_ce,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1],UE_id); +// if (UE_id!=-1) { +// UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer=0; +// UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0; +// if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { +// UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0; +// mac_eNB_rrc_ul_in_sync(enb_mod_idP,CC_idP,frameP,subframeP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]); +// } +// } +// crnti_rx=1; +// payload_ptr+=2; + +// if (msg3_flagP != NULL) { +// *msg3_flagP = 0; +// } +// break; + +// case TRUNCATED_BSR: +// case SHORT_BSR: { +// uint8_t lcgid; +// lcgid = (payload_ptr[0] >> 6); + +// LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", +// enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f); + +// if (crnti_rx==1) +// LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", +// enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f); +// if (UE_id != -1) { + +// UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid] = (payload_ptr[0] & 0x3f); + +// // update buffer info + +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid]]; + +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]; + +// PHY_vars_eNB_g[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP] = (payload_ptr[0] & 0x3f); +// if (UE_id == UE_list->head) +// VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,PHY_vars_eNB_g[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP]); +// 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; +// } +// if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP,UE_id)) < RRC_CONNECTED) +// LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : ul_total_buffer = %d (lcg increment %d)\n", +// enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].ul_total_buffer, +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]); +// } +// else { + +// } +// payload_ptr += 1;//sizeof(SHORT_BSR); // fixme +// } +// break; + +// case LONG_BSR: +// if (UE_id != -1) { +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0] = ((payload_ptr[0] & 0xFC) >> 2); +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1] = +// ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2] = +// ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] = (payload_ptr[2] & 0x3F); + +// // update buffer info +// old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]; +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0]]; + +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]; +// if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; +// else +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; + +// old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]; +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1]]; +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]; +// if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; +// else +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; + +// old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]; +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2]]; +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]; +// if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; +// else +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; + +// old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]]; +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; +// if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; +// else +// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; + +// LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " +// "%u LCGID2 = %u LCGID3 = %u\n", +// enb_mod_idP, CC_idP, +// rx_ces[i], +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0], +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1], +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2], +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]); +// if (crnti_rx==1) +// LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " +// "%u LCGID2 = %u LCGID3 = %u\n", +// enb_mod_idP, CC_idP, +// rx_ces[i], +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0], +// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1], +// 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 ) { +// 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 ) { +// 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 ) { +// 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 ) { +// 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); +// break; + +// default: +// LOG_E(MAC, "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n", enb_mod_idP, CC_idP, rx_ces[i]); +// break; +// } +// } + +// for (i=0; i CCCH_PAYLOAD_SIZE_MAX) { +// LOG_E(MAC, "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d), dropping packet\n", +// enb_mod_idP, CC_idP, frameP, rx_lengths[i], CCCH_PAYLOAD_SIZE_MAX); +// break; +// } +// LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n", +// enb_mod_idP,CC_idP,frameP, +// payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4], payload_ptr[5], rntiP); +// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,1); +// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,0); +// for (ii=0; iicommon_channels[CC_idP].RA_template[ii].rnti, rntiP, +// eNB->common_channels[CC_idP].RA_template[ii].RA_active); + +// if ((eNB->common_channels[CC_idP].RA_template[ii].rnti==rntiP) && +// (eNB->common_channels[CC_idP].RA_template[ii].RA_active==TRUE)) { + +// //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); + +// if (UE_id < 0) { +// memcpy(&eNB->common_channels[CC_idP].RA_template[ii].cont_res_id[0],payload_ptr,6); +// LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n", +// enb_mod_idP,CC_idP,frameP,rx_lengths[i],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 ) { +// mac_xface->macphy_exit("[MAC][eNB] Max user count reached\n"); +// // kill RA procedure +// } else +// LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n", +// enb_mod_idP,CC_idP,frameP,eNB->common_channels[CC_idP].RA_template[ii].rnti,UE_id); +// } else { +// LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n", +// enb_mod_idP,CC_idP,frameP,UE_id,rx_lengths[i],payload_ptr-sduP); +// // kill RA procedure +// } + +// if (Is_rrc_registered == 1) +// mac_rrc_data_ind( +// enb_mod_idP, +// CC_idP, +// frameP,subframeP, +// rntiP, +// CCCH, +// (uint8_t*)payload_ptr, +// rx_lengths[i], +// ENB_FLAG_YES, +// enb_mod_idP, +// 0); + + +// if (num_ce >0) { // handle msg3 which is not RRCConnectionRequest +// // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); +// } + +// eNB->common_channels[CC_idP].RA_template[ii].generate_Msg4 = 1; +// eNB->common_channels[CC_idP].RA_template[ii].wait_ack_Msg4 = 0; + +// } // if process is active +// } // loop on RA processes + +// break ; + +// case DCCH : +// case DCCH1 : +// // if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){ + + +// #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++) { +// LOG_T(MAC,"%x ",payload_ptr[j]); +// } +// LOG_T(MAC,"\n"); +// #endif + +// if (UE_id != -1) { +// // adjust buffer occupancy of the correponding logical channel group +// if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; +// else +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; + +// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n", +// enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]); + +// mac_rlc_data_ind( +// enb_mod_idP, +// rntiP, +// enb_mod_idP, +// frameP, +// ENB_FLAG_YES, +// MBMS_FLAG_NO, +// rx_lcids[i], +// (char *)payload_ptr, +// rx_lengths[i], +// 1, +// NULL);//(unsigned int*)crc_status); +// UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1; +// UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; +// } /* UE_id != -1 */ + +// // } +// break; + +// // all the DRBS +// case DTCH: +// default : + +// #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++) { +// LOG_T(MAC,"%x ",payload_ptr[j]); +// } +// LOG_T(MAC,"\n"); +// #endif +// if (rx_lcids[i] < NB_RB_MAX ) { +// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n", +// enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]); + +// if (UE_id != -1) { +// // adjust buffer occupancy of the correponding logical channel group +// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d, removing from LCGID %ld, %d\n", +// enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i], +// UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]], +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]]); + +// if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; +// else +// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; +// if ((rx_lengths[i] 0) ) { // MAX SIZE OF transport block +// mac_rlc_data_ind( +// enb_mod_idP, +// rntiP, +// enb_mod_idP, +// frameP, +// ENB_FLAG_YES, +// MBMS_FLAG_NO, +// rx_lcids[i], +// (char *)payload_ptr, +// rx_lengths[i], +// 1, +// NULL);//(unsigned int*)crc_status); + +// UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1; +// UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; +// } +// else { /* rx_length[i] */ +// UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx+=1; +// LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ", +// enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id); +// } +// } +// else {/*(UE_id != -1*/ +// LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ", +// enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id); +// } +// } + +// break; +// } + +// payload_ptr+=rx_lengths[i]; +// } + +// /* NN--> FK: we could either check the payload, or use a phy helper to detect a false msg3 */ +// if ((num_sdu == 0) && (num_ce==0)) { +// if (UE_id != -1) +// UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_errors_rx+=1; + +// if (msg3_flagP != NULL) { +// if( *msg3_flagP == 1 ) { +// LOG_N(MAC,"[eNB %d] CC_id %d frame %d : false msg3 detection: signal phy to canceling RA and remove the UE\n", enb_mod_idP, CC_idP, frameP); +// *msg3_flagP=0; +// } +// } +// } else { +// if (UE_id != -1) { +// UE_list->eNB_UE_stats[CC_idP][UE_id].pdu_bytes_rx=sdu_lenP; +// UE_list->eNB_UE_stats[CC_idP][UE_id].total_pdu_bytes_rx+=sdu_lenP; +// UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_pdus_rx+=1; +// } +// } + +// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,0); +// stop_meas(&eNB->rx_ulsch_sdu); +// } + +void _ulsch_scheduler_pre_processor(module_id_t module_idP, + int frameP, + sub_frame_t subframeP, + uint16_t *first_rb) +{ + + int16_t i; + uint16_t UE_id,n,r; + uint8_t CC_id, round, harq_pid; + uint16_t nb_allocated_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX],total_allocated_rbs[MAX_NUM_CCs],average_rbs_per_user[MAX_NUM_CCs]; + int16_t total_remaining_rbs[MAX_NUM_CCs]; + uint16_t max_num_ue_to_be_scheduled=0,total_ue_count=0; + rnti_t rnti= -1; + UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; + UE_TEMPLATE *UE_template = 0; + LTE_DL_FRAME_PARMS *frame_parms = 0; + + + //LOG_I(MAC,"assign max mcs min rb\n"); + // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB + assign_max_mcs_min_rb(module_idP,frameP, subframeP, first_rb); + + //LOG_I(MAC,"sort ue \n"); + // sort ues + sort_ue_ul (module_idP,frameP, subframeP); + + + // we need to distribute RBs among UEs + // step1: reset the vars + for (CC_id=0; CC_idhead_ul; i>=0; i=UE_list->next_ul[i]) { + nb_allocated_rbs[CC_id][i]=0; + } + } + + //LOG_I(MAC,"step2 \n"); + // step 2: calculate the average rb per UE + total_ue_count =0; + max_num_ue_to_be_scheduled=0; + + for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { + + rnti = UE_RNTI(module_idP,i); + + if (rnti==NOT_A_RNTI) + continue; + + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + + if (!phy_stats_exist(module_idP, rnti)) + continue; + + UE_id = i; + + for (n=0; nnumactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + UE_template = &UE_list->UE_template[CC_id][UE_id]; + average_rbs_per_user[CC_id]=0; + frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); + + if (UE_template->pre_allocated_nb_rb_ul > 0) { + total_ue_count+=1; + } + /* + if((mac_xface->get_nCCE_max(module_idP,CC_id,3,subframeP) - nCCE_to_be_used[CC_id]) > (1<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)) { + 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 ) { + 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", + module_idP,frameP,subframeP,UE_id,CC_id); + } + } + } + if (total_ue_count > 0) + LOG_D(MAC,"[eNB %d] Frame %d subframe %d: total ue to be scheduled %d/%d\n", + module_idP, frameP, subframeP,total_ue_count, max_num_ue_to_be_scheduled); + + //LOG_D(MAC,"step3\n"); + + // step 3: assigne RBS + for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { + rnti = UE_RNTI(module_idP,i); + + if (rnti==NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (!phy_stats_exist(module_idP, rnti)) + continue; + + UE_id = i; + + for (n=0; nnumactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + + mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); + + if(round>0) { + nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; + } 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]; + + } + } + + // step 4: assigne the remaining RBs and set the pre_allocated rbs accordingly + for(r=0; r<2; r++) { + + for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { + rnti = UE_RNTI(module_idP,i); + + if (rnti==NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (!phy_stats_exist(module_idP, rnti)) + continue; + + UE_id = i; + + for (n=0; nnumactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + UE_template = &UE_list->UE_template[CC_id][UE_id]; + 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 ) { + total_remaining_rbs[CC_id]+=1; + } + + if ( r == 0 ) { + while ( (UE_template->pre_allocated_nb_rb_ul > 0 ) && + (nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul) && + (total_remaining_rbs[CC_id] > 0)) { + nb_allocated_rbs[CC_id][UE_id] = cmin(nb_allocated_rbs[CC_id][UE_id]+1,UE_template->pre_allocated_nb_rb_ul); + total_remaining_rbs[CC_id]--; + total_allocated_rbs[CC_id]++; + } + } else { + UE_template->pre_allocated_nb_rb_ul= nb_allocated_rbs[CC_id][UE_id]; + LOG_D(MAC,"******************UL Scheduling Information for UE%d CC_id %d ************************\n",UE_id, CC_id); + LOG_D(MAC,"[eNB %d] total RB allocated for UE%d CC_id %d = %d\n", module_idP, UE_id, CC_id, UE_template->pre_allocated_nb_rb_ul); + } + } + } + } + + for (CC_id=0; CC_idget_lte_frame_parms(module_idP,CC_id); + + 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]); + } + } +} + + + +// uint32_t bytes_to_bsr_index(int32_t nbytes) +// { + +// uint32_t i=0; + +// if (nbytes<0) { +// return(0); +// } + +// while ((iE == 0) { +// not_done = 0; +// } + +// lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; + +// if (lcid < EXTENDED_POWER_HEADROOM) { +// if (not_done==0) { // last MAC SDU, length is implicit +// 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++) { +// length -= rx_lengths[num_sdu_cnt]; +// } +// } else { +// if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { +// length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; +// mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT); +// } else { // F = 1 +// length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); +// mac_header_ptr += 3;//sizeof(SCH_SUBHEADER_LONG); +// } +// } + +// LOG_D(MAC,"[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n", +// num_sdus,lcid,tb_length, length,mac_header_ptr-mac_header); +// rx_lcids[num_sdus] = lcid; +// rx_lengths[num_sdus] = length; +// num_sdus++; +// } else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI +// if (lcid == SHORT_PADDING) { +// mac_header_ptr++; +// } else { +// rx_ces[num_ces] = lcid; +// num_ces++; +// mac_header_ptr++; + +// if (lcid==LONG_BSR) { +// ce_len+=3; +// } else if (lcid==CRNTI) { +// ce_len+=2; +// } else if ((lcid==POWER_HEADROOM) || (lcid==TRUNCATED_BSR)|| (lcid== SHORT_BSR)) { +// ce_len++; +// } else { +// LOG_E(MAC,"unknown CE %d \n", lcid); +// mac_xface->macphy_exit("unknown CE"); +// } +// } +// } +// } + +// *num_ce = num_ces; +// *num_sdu = num_sdus; + +// return(mac_header_ptr); +// } + + +void flexran_agent_schedule_ulsch_ue_spec(module_id_t module_idP, + frame_t frameP, + unsigned char cooperation_flag, + sub_frame_t subframeP, + unsigned char sched_subframe) { + + + + uint16_t first_rb[MAX_NUM_CCs],i; + int CC_id; + eNB_MAC_INST *eNB=&eNB_mac_inst[module_idP]; + + start_meas(&eNB->schedule_ulsch); + + + for (CC_id=0; CC_idcommon_channels[CC_id].RA_template[i].RA_active == TRUE) && + (eNB->common_channels[CC_id].RA_template[i].generate_rar == 0) && + (eNB->common_channels[CC_id].RA_template[i].generate_Msg4 == 0) && + (eNB->common_channels[CC_id].RA_template[i].wait_ack_Msg4 == 0) && + (eNB->common_channels[CC_id].RA_template[i].Msg3_subframe == sched_subframe)) { + first_rb[CC_id]++; + eNB->common_channels[CC_id].RA_template[i].Msg3_subframe = -1; + break; + } + } + + /* + if (mac_xface->is_prach_subframe(&(mac_xface->lte_frame_parms),frameP,subframeP)) { + first_rb[CC_id] = (mac_xface->get_prach_prb_offset(&(mac_xface->lte_frame_parms), + */ + + } + + flexran_agent_schedule_ulsch_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe,first_rb); + +// #ifdef CBA + // schedule_ulsch_cba_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe, first_rb); +// #endif + + + stop_meas(&eNB->schedule_ulsch); + +} + + + +void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, + unsigned char cooperation_flag, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframe, + uint16_t *first_rb) +{ + + int UE_id; + uint8_t aggregation = 2; + rnti_t rnti = -1; + uint8_t round = 0; + uint8_t harq_pid = 0; + void *ULSCH_dci = NULL; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + DCI_PDU *DCI_pdu; + uint8_t status = 0; + uint8_t rb_table_index = -1; + uint16_t TBS = 0; + // int32_t buffer_occupancy=0; + uint32_t cqi_req,cshift,ndi,mcs=0,rballoc,tpc; + int32_t normalized_rx_power, target_rx_power=-90; + static int32_t tpc_accumulated=0; + + int n,CC_id = 0; + eNB_MAC_INST *eNB=&eNB_mac_inst[module_idP]; + UE_list_t *UE_list=&eNB->UE_list; + UE_TEMPLATE *UE_template; + UE_sched_ctrl *UE_sched_ctrl; + + // int rvidx_tab[4] = {0,2,3,1}; + LTE_DL_FRAME_PARMS *frame_parms; + int drop_ue=0; + + // LOG_I(MAC,"entering ulsch preprocesor\n"); + + _ulsch_scheduler_pre_processor(module_idP, + frameP, + subframeP, + first_rb); + + // LOG_I(MAC,"exiting ulsch preprocesor\n"); + + // loop over all active UEs + 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) { + LOG_I(MAC,"[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n", + module_idP,frameP,subframeP,UE_id); + continue; + } + + rnti = UE_RNTI(module_idP,UE_id); + + if (rnti==NOT_A_RNTI) { + LOG_W(MAC,"[eNB %d] frame %d subfarme %d, UE %d: no RNTI \n", module_idP,frameP,subframeP,UE_id); + continue; + } + + /* let's drop the UE if get_eNB_UE_stats returns NULL when calling it with any of the UE's active UL CCs */ + /* TODO: refine? */ + drop_ue = 0; + for (n=0; nnumactiveULCCs[UE_id]; n++) { + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + if (mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti) == NULL) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: no PHY context\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); + drop_ue = 1; + break; + } + } + if (drop_ue == 1) { +/* we can't come here, ulsch_scheduler_pre_processor won't put in the list a UE with no PHY context */ +abort(); + /* TODO: this is a hack. Sometimes the UE has no PHY context but + * is still present in the MAC with 'ul_failure_timer' = 0 and + * 'ul_out_of_sync' = 0. It seems wrong and the UE stays there forever. Let's + * start an UL out of sync procedure in this case. + * The root cause of this problem has to be found and corrected. + * In the meantime, this hack... + */ + if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 0 && + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: UE in weird state, let's put it 'out of sync'\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + // inform RRC of failure and clear timer + mac_eNB_rrc_ul_failure(module_idP,CC_id,frameP,subframeP,rnti); + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0; + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=1; + } + continue; + } + + // loop over all active UL CC_ids for this UE + for (n=0; nnumactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); + eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); + + aggregation=get_aggregation(get_bw_index(module_idP,CC_id), + eNB_UE_stats->DL_cqi[0], + format0); + + if (CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,aggregation,rnti)) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); + continue; // break; + } else{ + LOG_D(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d mode %s: aggregation level %d\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, mode_string[eNB_UE_stats->mode], 1<mode == PUSCH) { // ue has a ulsch channel + + DCI_pdu = &eNB->common_channels[CC_id].DCI_pdu; + UE_template = &UE_list->UE_template[CC_id][UE_id]; + UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + + if (mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL) == -1 ) { + LOG_W(MAC,"[eNB %d] Scheduler Frame %d, subframeP %d: candidate harq_pid from PHY for UE %d CC %d RNTI %x\n", + module_idP,frameP,subframeP, UE_id, CC_id, rnti); + continue; + } else + LOG_T(MAC,"[eNB %d] Frame %d, subframeP %d, UE %d CC %d : got harq pid %d round %d (rnti %x,mode %s)\n", + module_idP,frameP,subframeP,UE_id,CC_id, harq_pid, round,rnti,mode_string[eNB_UE_stats->mode]); + + PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]); + if (((UE_is_to_be_scheduled(module_idP,CC_id,UE_id)>0)) || (round>0))// || ((frameP%10)==0)) + // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames + { + LOG_D(MAC,"[eNB %d][PUSCH] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d)\n", + module_idP,frameP,subframeP,UE_id,rnti,round,UE_template->ul_SR, + UE_sched_ctrl->ul_inactivity_timer, + UE_sched_ctrl->ul_failure_timer); + // reset the scheduling request + UE_template->ul_SR = 0; + status = mac_eNB_get_rrc_status(module_idP,rnti); + if (status < RRC_CONNECTED) + cqi_req = 0; + else if (UE_sched_ctrl->cqi_req_timer>30) { + cqi_req = 1; + UE_sched_ctrl->cqi_req_timer=0; + } + else + cqi_req = 0; + + //power control + //compute the expected ULSCH RX power (for the stats) + + // this is the normalized RX power and this should be constant (regardless of mcs + normalized_rx_power = eNB_UE_stats->UL_rssi[0]; + target_rx_power = mac_xface->get_target_pusch_rx_power(module_idP,CC_id); + + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe; + if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case + ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around + { + UE_template->pusch_tpc_tx_frame=frameP; + UE_template->pusch_tpc_tx_subframe=subframeP; + if (normalized_rx_power>(target_rx_power+1)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power<(target_rx_power-1)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + } else { + tpc = 1; //0 + } + + if (tpc!=1) { + LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + module_idP,frameP,subframeP,harq_pid,tpc, + tpc_accumulated,normalized_rx_power,target_rx_power); + } + + // new transmission + if (round==0) { + + ndi = 1-UE_template->oldNDI_UL[harq_pid]; + UE_template->oldNDI_UL[harq_pid]=ndi; + UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; + mcs = UE_template->pre_assigned_mcs_ul;//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) { + rb_table_index=UE_template->pre_allocated_rb_table_index_ul; + } else { + mcs=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); + rb_table_index=5; // for PHR + } + + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; + // buffer_occupancy = UE_template->ul_total_buffer; + + while (((rb_table[rb_table_index]>(frame_parms->N_RB_UL-1-first_rb[CC_id])) || + (rb_table[rb_table_index]>45)) && + (rb_table_index>0)) { + rb_table_index--; + } + + TBS = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=TBS; + // buffer_occupancy -= TBS; + rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, + first_rb[CC_id], + rb_table[rb_table_index]); + + T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(mcs), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), + T_INT(TBS), T_INT(ndi)); + + if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) + LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", + module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs, + first_rb[CC_id],rb_table[rb_table_index], + rb_table_index,TBS,harq_pid); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + // increment for next UE allocation + first_rb[CC_id]+=rb_table[rb_table_index]; + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; + UE_sched_ctrl->ul_scheduled |= (1<head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled); + + // adjust total UL buffer status by TBS, wait for UL sdus to do final update + LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,TBS); + if (UE_template->ul_total_buffer > TBS) + UE_template->ul_total_buffer -= TBS; + else + UE_template->ul_total_buffer = 0; + LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer); + // Cyclic shift for DM RS + 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) { + case 6: + ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; + + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = tpc; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_template->DAI_ul[sched_subframe]; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_1_5MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_1_5MHz_TDD_1_6_t, + format0, + 0); + break; + + default: + case 25: + ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; + + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = tpc; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_template->DAI_ul[sched_subframe]; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_5MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_5MHz_TDD_1_6_t, + format0, + 0); + break; + + case 50: + ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; + + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->TPC = tpc; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_template->DAI_ul[sched_subframe]; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_10MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_10MHz_TDD_1_6_t, + format0, + 0); + break; + + case 100: + ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; + + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->TPC = tpc; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_template->DAI_ul[sched_subframe]; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_20MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_20MHz_TDD_1_6_t, + format0, + 0); + break; + } + } // TDD + else { //FDD + switch (frame_parms->N_RB_UL) { + case 25: + default: + + ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; + + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->type = 0; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->TPC = tpc; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->padding = 0; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_5MHz_FDD_t), + aggregation, + sizeof_DCI0_5MHz_FDD_t, + format0, + 0); + break; + + case 6: + ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; + + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->type = 0; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->TPC = tpc; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->padding = 0; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_1_5MHz_FDD_t), + aggregation, + sizeof_DCI0_1_5MHz_FDD_t, + format0, + 0); + break; + + case 50: + ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; + + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->type = 0; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->hopping = 0; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->TPC = tpc; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->padding = 0; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_10MHz_FDD_t), + aggregation, + sizeof_DCI0_10MHz_FDD_t, + format0, + 0); + break; + + case 100: + ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; + + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->type = 0; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->hopping = 0; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->TPC = tpc; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->padding = 0; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_20MHz_FDD_t), + aggregation, + sizeof_DCI0_20MHz_FDD_t, + format0, + 0); + break; + + } + } + + + add_ue_ulsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_UL_SCHEDULED); + + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id); +#ifdef DEBUG + dump_dci(frame_parms, &DCI_pdu->dci_alloc[DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci-1]); +#endif + + } + else { + T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(mcs), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), + T_INT(round)); + + LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d,round %d)\n", + module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs, + first_rb[CC_id],rb_table[rb_table_index], + rb_table_index,TBS,harq_pid,round); + }/* + else if (round > 0) { //we schedule a retransmission + + ndi = UE_template->oldNDI_UL[harq_pid]; + + if ((round&3)==0) { + mcs = openair_daq_vars.target_ue_ul_mcs; + } else { + mcs = rvidx_tab[round&3] + 28; //not correct for round==4! + + } + + LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, harq_pid %d, round %d)\n", + module_idP,UE_id,rnti,CC_id,frameP,subframeP,mcs, + first_rb[CC_id],UE_template->nb_rb_ul[harq_pid], + harq_pid, round); + + rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, + first_rb[CC_id], + UE_template->nb_rb_ul[harq_pid]); + first_rb[CC_id]+=UE_template->nb_rb_ul[harq_pid]; // increment for next UE allocation + + UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission_rx+=1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_rx=UE_template->nb_rb_ul[harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=UE_template->nb_rb_ul[harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=mcs; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; + } + */ + + } // UE_is_to_be_scheduled + } // UE is in PUSCH + } // loop over UE_id + } // loop of CC_id +} + +// #ifdef CBA +// void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframeP, unsigned char sched_subframe, uint16_t *first_rb) +// { + +// eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP]; +// UE_list_t *UE_list=&eNB->UE_list; +// //UE_TEMPLATE *UE_template; +// void *ULSCH_dci = NULL; +// DCI_PDU *DCI_pdu; +// uint8_t CC_id=0; +// uint8_t rb_table_index=0, aggregation=2; +// uint32_t rballoc; +// uint8_t cba_group, cba_resources; +// uint8_t required_rbs[NUM_MAX_CBA_GROUP]; +// int8_t num_cba_resources[NUM_MAX_CBA_GROUP];// , weight[NUM_MAX_CBA_GROUP] +// // the following vars should become a vector [MAX_NUM_CCs] +// LTE_DL_FRAME_PARMS *frame_parms; +// int8_t available_rbs=0; +// uint8_t remaining_rbs=0; +// uint8_t allocated_rbs=0; +// uint8_t total_UEs=UE_list->num_UEs; +// uint8_t active_UEs[NUM_MAX_CBA_GROUP]; +// uint8_t total_groups=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups; +// int min_rb_unit=2; +// uint8_t cba_policy=CBA_ES; +// int UE_id; +// uint8_t mcs[NUM_MAX_CBA_GROUP]; +// uint32_t total_cba_resources=0; +// uint32_t total_rbs=0; +// // We compute the weight of each group and initialize some variables + +// // loop over all active UEs +// // for (UE_id=UE_list->head_ul;UE_id>=0;UE_id=UE_list->next_ul[UE_id]) { + +// for (cba_group=0; cba_groupget_lte_frame_parms(module_idP,CC_id); +// available_rbs=frame_parms->N_RB_DL-1-first_rb[CC_id]; +// remaining_rbs=available_rbs; +// total_groups=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups; +// min_rb_unit=get_min_rb_unit(module_idP,CC_id); + +// if (available_rbs < min_rb_unit ) +// continue; + +// // remove this condition later +// // cba group template uses the exisitng UE template, and thus if a UE +// // is scheduled, the correspodning group can't be used for CBA +// // this can be fixed later +// if (total_groups > 0) { +// DCI_pdu = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu; + +// for (cba_group=0; +// (cba_group (1<head_ul; UE_id>=0; UE_id=UE_list->next_ul[UE_id]) { +// 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_eNB_get_rrc_status(module_idP,rnti) > RRC_CONNECTED) && +// (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) { +// mcs[cba_group]= 8; // apply fixed scheduling +// } 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]= mcs[cba_group];//cmin(mcs[cba_group],openair_daq_vars.target_ue_ul_mcs); + +// if (available_rbs < min_rb_unit ) +// break; + +// // If the group needs some resource +// // determine the total number of allocations (one or multiple DCIs): to be refined +// if ((active_UEs[cba_group] > 0) && (eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group] != 0)) { +// // to be refined in case of : total_UEs >> weight[cba_group]*available_rbs + +// switch(cba_policy) { +// case CBA_ES: +// required_rbs[cba_group] = (uint8_t)floor(available_rbs/total_groups); // allocate equally among groups +// num_cba_resources[cba_group]=1; +// break; + +// // can't have more than one allocation for the same group/UE +// /* case CBA_ES_S: +// required_rbs[cba_group] = (uint8_t)floor(available_rbs/total_groups); // allocate equally among groups +// if (required_rbs[cba_group] > min_rb_unit) +// num_cba_resources[cba_group]=(uint8_t)(required_rbs[cba_group]/ min_rb_unit); +// break;*/ +// case CBA_PF: +// required_rbs[cba_group] = (uint8_t)floor((active_UEs[cba_group]*available_rbs)/total_UEs); +// num_cba_resources[cba_group]=1; +// break; +// /* case CBA_PF_S: +// required_rbs[cba_group] = (uint8_t)ceil((active_UEs[cba_group]*available_rbs)/total_UEs); +// if (required_rbs[cba_group] > min_rb_unit) +// num_cba_resources[cba_group]=(uint8_t) floor(required_rbs[cba_group] / min_rb_unit); +// break;*/ + +// default: +// LOG_W(MAC,"unknown CBA policy\n"); +// break; +// } + +// total_cba_resources+=num_cba_resources[cba_group]; +// total_rbs+=required_rbs[cba_group]; + +// /* while ((remaining_rbs < required_rbs[cba_group]) && +// (required_rbs[cba_group] > 0) && +// (required_rbs[cba_group] < min_rb_unit )) +// required_rbs[cba_group]--; +// */ + +// /* +// while (rb_table[rb_table_index] < required_rbs[cba_group]) +// rb_table_index++; + +// while (rb_table[rb_table_index] > remaining_rbs ) +// rb_table_index--; + +// remaining_rbs-=rb_table[rb_table_index]; +// required_rbs[cba_group]=rb_table[rb_table_index]; +// */ +// // num_cba_resources[cba_group]=1; + +// } +// } + +// // phase 2 reduce the number of cba allocations among the groups +// cba_group=0; + +// if (total_cba_resources <= 0) { +// return; +// } + +// // increase rb if any left: to be done +// cba_group=0; + +// while (total_rbs < available_rbs - 1 ) { +// required_rbs[cba_group%total_groups]++; +// total_rbs++; +// cba_group++; +// } + +// // phase 3: +// for (cba_group=0; cba_group remaining_rbs ) { +// rb_table_index--; +// } + +// remaining_rbs-=rb_table[rb_table_index]; +// allocated_rbs=rb_table[rb_table_index]; + +// rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, +// first_rb[CC_id], +// rb_table[rb_table_index]); + +// first_rb[CC_id]+=rb_table[rb_table_index]; +// LOG_N(MAC, +// "[eNB %d] CC_id %d Frame %d, subframeP %d: schedule CBA access %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), mcs %d, rballoc %d\n", +// module_idP, CC_id, 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); + +// switch (frame_parms->N_RB_UL) { +// case 6: +// mac_xface->macphy_exit("[MAC][eNB] CBA RB=6 not supported \n"); +// break; + +// case 25: +// if (frame_parms->frame_type == TDD) { +// ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0]; + +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs[cba_group]; +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = 1; +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1;//tpc; +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cba_group; +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_list->UE_template[CC_id][cba_group].DAI_ul[sched_subframe]; +// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = 1; + +// //add_ue_spec_dci +// add_common_dci(DCI_pdu, +// ULSCH_dci, +// eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], +// sizeof(DCI0_5MHz_TDD_1_6_t), +// aggregation, +// sizeof_DCI0_5MHz_TDD_1_6_t, +// format0, +// 0); +// } else { +// ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0]; + +// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->type = 0; +// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; +// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; +// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs[cba_group]; +// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->ndi = 1; +// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->TPC = 1;//tpc; +// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cshift = cba_group; +// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cqi_req = 1; + +// //add_ue_spec_dci +// add_common_dci(DCI_pdu, +// ULSCH_dci, +// eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], +// sizeof(DCI0_5MHz_FDD_t), +// aggregation, +// sizeof_DCI0_5MHz_FDD_t, +// format0, +// 0); +// } + +// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for CBA group %d, RB 25 format 0\n", module_idP,CC_id,frameP,subframeP,cba_group); +// break; + +// case 50: +// if (frame_parms->frame_type == TDD) { +// ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0]; + +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs[cba_group]; +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->ndi = 1; +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1;//tpc; +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cba_group; +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_list->UE_template[CC_id][cba_group].DAI_ul[sched_subframe]; +// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = 1; + +// //add_ue_spec_dci +// add_common_dci(DCI_pdu, +// ULSCH_dci, +// eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], +// sizeof(DCI0_10MHz_TDD_1_6_t), +// aggregation, +// sizeof_DCI0_10MHz_TDD_1_6_t, +// format0, +// 0); +// } else { +// ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0]; + +// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->type = 0; +// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->hopping = 0; +// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; +// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->mcs = mcs[cba_group]; +// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->ndi = 1; +// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->TPC = 1;//tpc; +// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cshift = cba_group; +// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cqi_req = 1; + +// //add_ue_spec_dci +// add_common_dci(DCI_pdu, +// ULSCH_dci, +// eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], +// sizeof(DCI0_10MHz_FDD_t), +// aggregation, +// sizeof_DCI0_10MHz_FDD_t, +// format0, +// 0); +// } + +// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for CBA group %d, RB 50 format 0\n", module_idP,CC_id,frameP,subframeP,cba_group); +// break; + +// case 100: +// mac_xface->macphy_exit("[MAC][eNB] CBA RB=100 not supported \n"); +// break; + +// default: +// break; +// } + +// // break;// for the moment only schedule one +// } +// } +// } +// } +// } +// #endif From 5ce9858d63bf3c0f210816dd999b607aa37e57b3 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Fri, 21 Apr 2017 13:22:20 +0200 Subject: [PATCH 012/141] uplink scheduling --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 33 +++++++++++++++ openair2/ENB_APP/MESSAGES/V2/flexran.proto | 4 +- openair2/ENB_APP/MESSAGES/V2/header.proto | 11 ++--- openair2/LAYER2/MAC/eNB_scheduler.c | 40 +++++++++---------- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 6 +++ 5 files changed, 67 insertions(+), 27 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 405837061a..cd81abca3f 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1044,6 +1044,39 @@ int flexran_agent_mac_destroy_dl_config(Protocol__FlexranMessage *msg) { return -1; } +int flexran_agent_mac_create_empty_ul_config(mid_t mod_id, Protocol__FlexranMessage **msg) { + + int xid = 0; + Protocol__FlexHeader *header; + if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_UL_MAC_CONFIG, &header) != 0) + goto error; + + Protocol__FlexUlMacConfig *ul_mac_config_msg; + ul_mac_config_msg = malloc(sizeof(Protocol__FlexUlMacConfig)); + if (ul_mac_config_msg == NULL) { + goto error; + } + protocol__flex_ul_mac_config__init(ul_mac_config_msg); + + ul_mac_config_msg->header = header; + ul_mac_config_msg->has_sfn_sf = 1; + ul_mac_config_msg->sfn_sf = flexran_get_sfn_sf(mod_id); + + *msg = malloc(sizeof(Protocol__FlexranMessage)); + if(*msg == NULL) + goto error; + protocol__flexran_message__init(*msg); + (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_UL_MAC_CONFIG_MSG; + (*msg)->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__INITIATING_MESSAGE; + (*msg)->ul_mac_config_msg = ul_mac_config_msg; + + return 0; + + error: + return -1; +} + + void flexran_agent_get_pending_dl_mac_config(mid_t mod_id, Protocol__FlexranMessage **msg) { struct lfds700_misc_prng_state ls; diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index caee626a73..01728bb268 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -24,12 +24,12 @@ message flexran_message { flex_ue_config_reply ue_config_reply_msg = 11; flex_lc_config_request lc_config_request_msg = 12; flex_lc_config_reply lc_config_reply_msg = 13; - flex_dl_mac_config dl_mac_config_msg = 14; - flex_ul_mac_config ul_mac_config_msg = 19; + flex_dl_mac_config dl_mac_config_msg = 14; flex_ue_state_change ue_state_change_msg = 15; flex_control_delegation control_delegation_msg = 16; flex_agent_reconfiguration agent_reconfiguration_msg = 17; flex_rrc_triggering rrc_triggering = 18; + flex_ul_mac_config ul_mac_config_msg = 19; } } diff --git a/openair2/ENB_APP/MESSAGES/V2/header.proto b/openair2/ENB_APP/MESSAGES/V2/header.proto index 468dcd201e..1650030e32 100644 --- a/openair2/ENB_APP/MESSAGES/V2/header.proto +++ b/openair2/ENB_APP/MESSAGES/V2/header.proto @@ -32,14 +32,15 @@ enum flex_type { //Controller command messages FLPT_DL_MAC_CONFIG = 13; - + FLPT_UL_MAC_CONFIG = 14 + ; // UE state change messages - FLPT_UE_STATE_CHANGE = 14; + FLPT_UE_STATE_CHANGE = 15; // Control delegation messages - FLPT_DELEGATE_CONTROL = 15; - FLPT_RECONFIGURE_AGENT = 16; - FLPT_RRC_TRIGGERING = 17; + FLPT_DELEGATE_CONTROL = 16; + FLPT_RECONFIGURE_AGENT = 17; + FLPT_RRC_TRIGGERING = 18; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 7250d66f07..56052b050a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -398,7 +398,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag); #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,4); } #endif @@ -438,7 +438,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,7); } #endif @@ -453,7 +453,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,8); } #endif @@ -472,7 +472,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,1,5); } #endif @@ -511,7 +511,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,2,6); } #endif @@ -553,7 +553,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,7); } #endif @@ -591,7 +591,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,3,7); } #endif @@ -634,7 +634,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,8); } #endif @@ -679,7 +679,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,4,8); } #endif @@ -724,7 +724,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,5,9); } #endif @@ -796,7 +796,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,2); } #endif @@ -812,7 +812,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3); } #endif @@ -879,7 +879,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,6,0); } #endif @@ -971,7 +971,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,7,1); } #endif @@ -1018,7 +1018,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,2); } #endif @@ -1054,7 +1054,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,8,2); } #endif @@ -1094,7 +1094,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3); } #endif @@ -1128,7 +1128,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3); } #endif @@ -1161,7 +1161,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,4); } #endif @@ -1222,7 +1222,7 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,9,3); } #endif diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 2abd09024b..a45f81fdaa 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -790,6 +790,7 @@ void flexran_agent_schedule_ulsch_ue_spec(module_id_t module_idP, unsigned char sched_subframe) { +// flexran_agent_mac_create_empty_ul_config(module_idP, ul_info); uint16_t first_rb[MAX_NUM_CCs],i; int CC_id; @@ -884,6 +885,11 @@ void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, // LOG_I(MAC,"entering ulsch preprocesor\n"); + + + + + _ulsch_scheduler_pre_processor(module_idP, frameP, subframeP, From fdac4d178be4b250787a5779d2da700128627aa2 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Sat, 22 Apr 2017 12:43:04 +0200 Subject: [PATCH 013/141] uplink harq api --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 39 +++++ .../CONTROL_MODULES/MAC/flexran_agent_mac.h | 4 + .../MAC/flexran_agent_mac_defs.h | 2 +- openair2/ENB_APP/MESSAGES/V2/flexran.proto | 4 +- openair2/ENB_APP/MESSAGES/V2/header.proto | 13 +- openair2/ENB_APP/flexran_agent_ran_api.c | 20 ++- openair2/ENB_APP/flexran_agent_ran_api.h | 2 +- openair2/LAYER2/MAC/eNB_scheduler.c | 147 +++++++++++++----- openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 4 +- .../MAC/flexran_agent_scheduler_dataplane.c | 12 +- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 6 +- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 13 +- 12 files changed, 191 insertions(+), 75 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index cd81abca3f..db9af62eac 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1077,6 +1077,45 @@ int flexran_agent_mac_create_empty_ul_config(mid_t mod_id, Protocol__FlexranMess } +int flexran_agent_mac_destroy_ul_config(Protocol__FlexranMessage *msg) { + int i,j, k; + if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_UL_MAC_CONFIG_MSG) + goto error; + + Protocol__FlexUlDci *ul_dci; + + free(msg->ul_mac_config_msg->header); + for (i = 0; i < msg->ul_mac_config_msg->n_ul_ue_data; i++) { + // TODO uplink rlc ... + // free(msg->ul_mac_config_msg->dl_ue_data[i]->ce_bitmap); + // for (j = 0; j < msg->ul_mac_config_msg->ul_ue_data[i]->n_rlc_pdu; j++) { + // for (k = 0; k < msg->ul_mac_config_msg->ul_ue_data[i]->rlc_pdu[j]->n_rlc_pdu_tb; k++) { + // free(msg->ul_mac_config_msg->dl_ue_data[i]->rlc_pdu[j]->rlc_pdu_tb[k]); + // } + // free(msg->ul_mac_config_msg->ul_ue_data[i]->rlc_pdu[j]->rlc_pdu_tb); + // free(msg->ul_mac_config_msg->ul_ue_data[i]->rlc_pdu[j]); + // } + // free(msg->ul_mac_config_msg->ul_ue_data[i]->rlc_pdu); + ul_dci = msg->ul_mac_config_msg->ul_ue_data[i]->ul_dci; + // free(dl_dci->tbs_size); + // free(ul_dci->mcs); + // free(ul_dci->ndi); + // free(ul_dci->rv); + // free(ul_dci); + free(msg->ul_mac_config_msg->ul_ue_data[i]); + } + free(msg->ul_mac_config_msg->ul_ue_data); + + free(msg->ul_mac_config_msg); + free(msg); + + return 0; + + error: + return -1; +} + + void flexran_agent_get_pending_dl_mac_config(mid_t mod_id, Protocol__FlexranMessage **msg) { struct lfds700_misc_prng_state ls; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.h index d2db860ce4..0dcee577f5 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.h @@ -57,6 +57,10 @@ int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg); int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMessage **msg); int flexran_agent_mac_destroy_dl_config(Protocol__FlexranMessage *msg); +/* UL MAC scheduling decision protocol message constructor (empty command) and destructor */ +int flexran_agent_mac_create_empty_ul_config(mid_t mod_id, Protocol__FlexranMessage **msg); +int flexran_agent_mac_destroy_ul_config(Protocol__FlexranMessage *msg); + int flexran_agent_mac_handle_dl_mac_config(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg); diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h index ab6bf57417..49ef7f0fb7 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h @@ -63,7 +63,7 @@ typedef struct { void (*flexran_agent_schedule_ul_spec)(mid_t module_idP, uint32_t frameP, unsigned char cooperation_flag, uint32_t subframeP, - unsigned char sched_subframe); + unsigned char sched_subframe, Protocol__FlexranMessage **ul_info); /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index 01728bb268..8ebfc7df8b 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -168,8 +168,8 @@ message flex_dl_mac_config { message flex_ul_mac_config { optional flex_header header = 1; - optional uint32 sfn_sf = 2; - repeated flex_ul_data ul_ue_data = 3; + optional uint32 sfn_sf = 2; + repeated flex_ul_data ul_ue_data = 3; } diff --git a/openair2/ENB_APP/MESSAGES/V2/header.proto b/openair2/ENB_APP/MESSAGES/V2/header.proto index 1650030e32..79d541200c 100644 --- a/openair2/ENB_APP/MESSAGES/V2/header.proto +++ b/openair2/ENB_APP/MESSAGES/V2/header.proto @@ -32,15 +32,14 @@ enum flex_type { //Controller command messages FLPT_DL_MAC_CONFIG = 13; - FLPT_UL_MAC_CONFIG = 14 - ; + // UE state change messages - FLPT_UE_STATE_CHANGE = 15; + FLPT_UE_STATE_CHANGE = 14; // Control delegation messages - FLPT_DELEGATE_CONTROL = 16; - FLPT_RECONFIGURE_AGENT = 17; - FLPT_RRC_TRIGGERING = 18; - + FLPT_DELEGATE_CONTROL = 15; + FLPT_RECONFIGURE_AGENT = 16; + FLPT_RRC_TRIGGERING = 17; + FLPT_UL_MAC_CONFIG = 18; } diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 9602b041c3..334dd3cb9a 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -299,8 +299,9 @@ int flexran_get_harq(const mid_t mod_id, const mid_t ue_id, const int frame, const uint8_t subframe, - uint8_t *id, - uint8_t *round) { //flag_id_status = 0 then id, else status + uint8_t *pid, + uint8_t *round, + const uint8_t harq_flag) { //flag_id_status = 0 then id, else status /*TODO: Add int TB in function parameters to get the status of the second TB. This can be done to by editing in * get_ue_active_harq_pid function in line 272 file: phy_procedures_lte_eNB.c to add * DLSCH_ptr = PHY_vars_eNB_g[Mod_id][CC_id]->dlsch_eNB[(uint32_t)UE_id][1];*/ @@ -310,10 +311,21 @@ int flexran_get_harq(const mid_t mod_id, uint16_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + if (harq_flag == openair_harq_DL){ - mac_xface->get_ue_active_harq_pid(mod_id,CC_id,rnti,frame,subframe,&harq_pid,&harq_round,openair_harq_DL); + mac_xface->get_ue_active_harq_pid(mod_id,CC_id,rnti,frame,subframe,&harq_pid,&harq_round,openair_harq_DL); - *id = harq_pid; + } else if (harq_flag == openair_harq_UL){ + + mac_xface->get_ue_active_harq_pid(mod_id,CC_id,rnti,frame,subframe,&harq_pid,&round,openair_harq_UL); + } + else { + + LOG_W(FLEXRAN_AGENT,"harq_flag is not recongnized"); + } + + + *pid = harq_pid; *round = harq_round; /* if (round > 0) { */ /* *status = 1; */ diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 8a7d6dbaf7..e80ed44ce9 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -187,7 +187,7 @@ int flexran_get_ue_pmi(mid_t mod_id); a designated frame and subframe. Returns 0 for success. The id and the status of the HARQ process are stored in id and status respectively */ int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, - const int frame, const uint8_t subframe, unsigned char *id, unsigned char *round); + const int frame, const uint8_t subframe, unsigned char *id, unsigned char *round,const uint8_t harq_flag); /* Uplink power control management*/ int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id); diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 56052b050a..bf69d7c8ef 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -386,8 +386,10 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag); #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); #endif @@ -398,8 +400,10 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag); #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,4, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); #endif } @@ -415,7 +419,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -438,9 +442,12 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,7); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,7, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status); @@ -453,9 +460,11 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,8); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,8, &msg); } + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -472,9 +481,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,1,5); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,1,5, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -489,7 +501,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -511,9 +523,13 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,2,6); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,2,6, &msg); } + + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -528,7 +544,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -553,9 +569,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,7); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,7, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif // no break here! @@ -572,7 +591,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -591,9 +610,13 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,3,7); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,3,7, &msg); } + + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -608,7 +631,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -634,9 +657,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,8); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,8, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif // no break here! @@ -659,7 +685,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -679,9 +705,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,4,8); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,4,8, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -696,7 +725,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -724,9 +753,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,5,9); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,5,9, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -741,7 +773,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -768,7 +800,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -796,9 +828,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,2); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,2, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif // schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); #ifndef FLEXRAN_AGENT_SB_IF @@ -812,9 +847,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif // schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); #ifndef FLEXRAN_AGENT_SB_IF @@ -836,7 +874,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -860,7 +898,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -879,9 +917,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,6,0); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,6,0, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -896,7 +937,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -929,7 +970,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -952,7 +993,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -971,9 +1012,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,7,1); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,7,1, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -988,7 +1032,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -1018,9 +1062,11 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,2); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,2, &msg); } + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -1035,7 +1081,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -1054,9 +1100,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,8,2); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,8,2, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -1071,7 +1120,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -1094,9 +1143,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif schedule_RA(module_idP,frameP,subframeP,7); // 7 = Msg3 subframeP, not #ifndef FLEXRAN_AGENT_SB_IF @@ -1111,7 +1163,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -1128,9 +1180,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,3, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -1145,7 +1200,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -1161,9 +1216,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,4); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,subframeP,4, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif //schedule_RA(module_idP,frameP,subframeP); #ifndef FLEXRAN_AGENT_SB_IF @@ -1178,7 +1236,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -1203,7 +1261,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, @@ -1222,9 +1280,12 @@ if (mac_agent_registered[module_idP]){ #else if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,9,3); + agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,9,3, &msg); } + + flexran_agent_mac_destroy_ul_config(msg); + #endif #ifndef FLEXRAN_AGENT_SB_IF @@ -1239,7 +1300,7 @@ if (mac_agent_registered[module_idP]){ mbsfn_status, &msg); - flexran_apply_dl_scheduling_decisions(module_idP, + flexran_apply_scheduling_decisions(module_idP, frameP, subframeP, mbsfn_status, diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index 8a9d5971e3..7b5c402b61 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -174,12 +174,12 @@ void flexran_schedule_ue_spec_default(mid_t mod_id, uint32_t frame, uint32_t sub void flexran_agent_schedule_ulsch_ue_spec(module_id_t module_idP, frame_t frameP, unsigned char cooperation_flag, sub_frame_t subframeP, - unsigned char sched_subframe); + unsigned char sched_subframe, Protocol__FlexranMessage **ul_info); /* * Data plane function for applying the DL decisions of the scheduler */ -void flexran_apply_dl_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, +void flexran_apply_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, Protocol__FlexranMessage *dl_scheduling_info); /* diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c index 38f39e50e1..ba5aadcb5b 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c @@ -59,28 +59,28 @@ #include "SIMULATION/TOOLS/defs.h" // for taus -void flexran_apply_dl_scheduling_decisions(mid_t mod_id, +void flexran_apply_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, Protocol__FlexranMessage *dl_scheduling_info) { - Protocol__FlexDlMacConfig *mac_config = dl_scheduling_info->dl_mac_config_msg; + Protocol__FlexDlMacConfig *mac_dl_config = dl_scheduling_info->dl_mac_config_msg; // Check if there is anything to schedule for random access - if (mac_config->n_dl_rar > 0) { + if (mac_dl_config->n_dl_rar > 0) { /*TODO: call the random access data plane function*/ } // Check if there is anything to schedule for paging/broadcast - if (mac_config->n_dl_broadcast > 0) { + if (mac_dl_config->n_dl_broadcast > 0) { /*TODO: call the broadcast/paging data plane function*/ } // Check if there is anything to schedule for the UEs - if (mac_config->n_dl_ue_data > 0) { + if (mac_dl_config->n_dl_ue_data > 0) { flexran_apply_ue_spec_scheduling_decisions(mod_id, frame, subframe, mbsfn_flag, - mac_config->n_dl_ue_data, mac_config->dl_ue_data); + mac_dl_config->n_dl_ue_data, mac_dl_config->dl_ue_data); } } diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 81c18a26c0..fc3906ab6f 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -526,7 +526,7 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, CC_id = UE_list->ordered_CCids[ii][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][slice_id]; - flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round); + flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_DL); // if there is no available harq_process, skip the UE if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id]<0) @@ -640,7 +640,7 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, for (ii=0; iiordered_CCids[ii][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round); + flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_DL); rnti = UE_RNTI(Mod_id,UE_id); // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); @@ -1096,7 +1096,7 @@ flexran_schedule_ue_spec_common(mid_t mod_id, dl_data[num_ues_added]->serv_cell_index = CC_id; nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round); + flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round, openair_harq_DL); sdu_length_total=0; mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; // LOG_I(FLEXRAN_AGENT, "The MCS is %d\n", mcs); diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index a45f81fdaa..604a428d9c 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -615,8 +615,8 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; - mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); - + // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); + flexran_get_harq(module_idP, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_UL); if(round>0) { nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; } else { @@ -787,10 +787,11 @@ void flexran_agent_schedule_ulsch_ue_spec(module_id_t module_idP, frame_t frameP, unsigned char cooperation_flag, sub_frame_t subframeP, - unsigned char sched_subframe) { + unsigned char sched_subframe, + Protocol__FlexranMessage **ul_info) { -// flexran_agent_mac_create_empty_ul_config(module_idP, ul_info); +flexran_agent_mac_create_empty_ul_config(module_idP, ul_info); uint16_t first_rb[MAX_NUM_CCs],i; int CC_id; @@ -907,7 +908,7 @@ void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, continue; } - rnti = UE_RNTI(module_idP,UE_id); + rnti = flexran_get_ue_crnti(module_idP, UE_id); if (rnti==NOT_A_RNTI) { LOG_W(MAC,"[eNB %d] frame %d subfarme %d, UE %d: no RNTI \n", module_idP,frameP,subframeP,UE_id); @@ -973,7 +974,7 @@ abort(); UE_template = &UE_list->UE_template[CC_id][UE_id]; UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - if (mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL) == -1 ) { + if (flexran_get_harq(module_idP, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_UL) == -1 ) { LOG_W(MAC,"[eNB %d] Scheduler Frame %d, subframeP %d: candidate harq_pid from PHY for UE %d CC %d RNTI %x\n", module_idP,frameP,subframeP, UE_id, CC_id, rnti); continue; From 57129bc0af65ac764741ca1042d916a74f56600a Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Tue, 25 Apr 2017 18:19:47 +0200 Subject: [PATCH 014/141] Uplink Slicing --- openair2/ENB_APP/flexran_agent_ran_api.c | 15 +++++++++ .../MAC/flexran_agent_scheduler_dlsch_ue.c | 12 +++++++ .../MAC/flexran_agent_scheduler_ulsch_ue.c | 31 +++++++++++++------ 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 334dd3cb9a..ae304d1e26 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -655,6 +655,21 @@ int flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) { return -1; } + +int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP){ + + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + + if (ue_context_p != NULL) { + return(ue_context_p->ue_context.Status); + } else { + return RRC_INACTIVE; + } + +} + int flexran_get_ue_aggregated_max_bitrate_dl (mid_t mod_id, mid_t ue_id) { return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateDL; } diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index fc3906ab6f..aec093e88a 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -742,7 +742,9 @@ flexran_schedule_ue_spec_default(mid_t mod_id, if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active slices has changed: %d-->%d\n", mod_id, frame, subframe, n_active_slices_current, n_active_slices); + n_active_slices_current = n_active_slices; + } else { LOG_W(MAC,"invalid number of slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); n_active_slices = n_active_slices_current; @@ -756,18 +758,22 @@ flexran_schedule_ue_spec_default(mid_t mod_id, total_slice_percentage=total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]; LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", mod_id, i, frame, subframe, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); + slice_percentage_current[i] = slice_percentage[i]; + } else { LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", mod_id,i, total_slice_percentage, total_slice_percentage - slice_percentage_current[i] + slice_percentage[i], slice_percentage[i],slice_percentage_current[i]); + slice_percentage[i]= slice_percentage_current[i]; } } else { LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage[i],slice_percentage_current[i]); + slice_percentage[i]= slice_percentage_current[i]; } @@ -778,10 +784,14 @@ flexran_schedule_ue_spec_default(mid_t mod_id, if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)){ LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", mod_id, i, frame, subframe, slice_maxmcs_current[i], slice_maxmcs[i]); + slice_maxmcs_current[i] = slice_maxmcs[i]; + } else { LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_percentage[i],slice_percentage[i]); + slice_maxmcs[i]= slice_maxmcs_current[i]; + } } @@ -789,7 +799,9 @@ flexran_schedule_ue_spec_default(mid_t mod_id, if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", mod_id, i, frame, subframe, dl_scheduler_type[i]); + update_dl_scheduler_current[i] = update_dl_scheduler[i]; + } // Run each enabled slice-specific schedulers one by one diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 604a428d9c..001f284938 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -59,6 +59,12 @@ // #define ENABLE_MAC_PAYLOAD_DEBUG // #define DEBUG_eNB_SCHEDULER 1 + +// RB share for each slice for past and current time +float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; + + // // This table holds the allowable PRB sizes for ULSCH transmissions // uint8_t rb_table[33] = {1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60,72,75,80,81,90,96,100}; @@ -500,6 +506,7 @@ // } void _ulsch_scheduler_pre_processor(module_id_t module_idP, + int slice_id, int frameP, sub_frame_t subframeP, uint16_t *first_rb) @@ -515,7 +522,8 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; UE_TEMPLATE *UE_template = 0; LTE_DL_FRAME_PARMS *frame_parms = 0; - + + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; //LOG_I(MAC,"assign max mcs min rb\n"); // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB @@ -576,15 +584,17 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, max_num_ue_to_be_scheduled+=1; + nb_rbs_allowed_slice[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage_uplink[slice_id], flexran_get_N_RB_UL(module_idP, CC_id)); + if (total_ue_count == 0) { average_rbs_per_user[CC_id] = 0; } 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])) && + average_rbs_per_user[CC_id] = nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id]+1; + } else if( (total_ue_count <= (nb_rbs_allowed_slice[CC_id][slice_id]-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); + average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id])/total_ue_count); } 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); + average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice[CC_id][slice_id]-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", @@ -648,7 +658,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, CC_id = UE_list->ordered_ULCCids[n][UE_id]; UE_template = &UE_list->UE_template[CC_id][UE_id]; 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]; + total_remaining_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][slice_id] - first_rb[CC_id] - total_allocated_rbs[CC_id]; if (total_ue_count == 1 ) { total_remaining_rbs[CC_id]+=1; @@ -675,7 +685,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, frame_parms= mac_xface->get_lte_frame_parms(module_idP,CC_id); 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]); + LOG_D(MAC,"[eNB %d] total RB allocated for all UEs = %d/%d\n", module_idP, total_allocated_rbs[CC_id], nb_rbs_allowed_slice[CC_id][slice_id] - first_rb[CC_id]); } } } @@ -888,10 +898,11 @@ void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, - + int slice_id = 0; _ulsch_scheduler_pre_processor(module_idP, + slice_id, frameP, subframeP, first_rb); @@ -993,7 +1004,9 @@ abort(); UE_sched_ctrl->ul_failure_timer); // reset the scheduling request UE_template->ul_SR = 0; - status = mac_eNB_get_rrc_status(module_idP,rnti); + // status = mac_eNB_get_rrc_status(module_idP,rnti); + status = flexran_get_rrc_status(module_idP, rnti); + if (status < RRC_CONNECTED) cqi_req = 0; else if (UE_sched_ctrl->cqi_req_timer>30) { From 897c8da299615016c7e9ac6320883423465a0de0 Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Wed, 26 Apr 2017 07:50:04 +0000 Subject: [PATCH 015/141] Fixed size of arrays for RSRP and RSRQ measurements --- openair2/RRC/LITE/extern.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/LITE/extern.h b/openair2/RRC/LITE/extern.h index d4c8192a95..7934690563 100644 --- a/openair2/RRC/LITE/extern.h +++ b/openair2/RRC/LITE/extern.h @@ -93,8 +93,8 @@ extern uint16_t N310[8]; extern uint16_t N311[8]; extern uint32_t T304[8]; extern uint32_t timeToTrigger_ms[16]; -extern float RSRP_meas_mapping[100]; -extern float RSRQ_meas_mapping[33]; +extern float RSRP_meas_mapping[98]; +extern float RSRQ_meas_mapping[35]; #endif From b9b45c4ac030ef54f210aa37c066e7ccb5ffac86 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Wed, 26 Apr 2017 19:15:39 +0200 Subject: [PATCH 016/141] uplink primitives --- openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 18 ++ .../MAC/flexran_agent_scheduler_ulsch_ue.c | 160 +++++++++++++++++- 2 files changed, 176 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index 7b5c402b61..fbb8a11950 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -117,6 +117,8 @@ int flexran_slice_member(int UE_id, int flexran_slice_maxmcs(int slice_id) ; +/* Downlink Primitivies */ + void _store_dlsch_buffer (module_id_t Mod_id, int slice_id, frame_t frameP, @@ -131,6 +133,22 @@ void _assign_rbs_required (module_id_t Mod_id, uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], int min_rb_unit[MAX_NUM_CCs]); + +/* Uplink Primitivies */ + +// 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 _ulsch_scheduler_pre_processor(module_id_t module_idP, + int slice_id, + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], + int frameP, + sub_frame_t subframeP, + uint16_t *first_rb); + + void _dlsch_scheduler_pre_processor (module_id_t Mod_id, int slice_id, frame_t frameP, diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 001f284938..849dc30869 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -65,6 +65,10 @@ float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +uint16_t flexran_nb_rbs_allowed_slice_uplink(float rb_percentage, int total_rbs){ + return (uint16_t) floor(rb_percentage * total_rbs); +} + // // This table holds the allowable PRB sizes for ULSCH transmissions // uint8_t rb_table[33] = {1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60,72,75,80,81,90,96,100}; @@ -505,6 +509,158 @@ float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; // stop_meas(&eNB->rx_ulsch_sdu); // } + + +// void _sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) +// { +// int i; +// int list[NUMBER_OF_UE_MAX]; +// int list_size = 0; +// int rnti; +// struct sort_ue_ul_params params = { module_idP, frameP, subframeP }; + +// UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; + +// for (i = 0; i < NUMBER_OF_UE_MAX; i++) { +// rnti = UE_RNTI(module_idP, i); +// if (rnti == NOT_A_RNTI) +// continue; +// if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) +// continue; +// if (!phy_stats_exist(module_idP, rnti)) +// continue; +// list[list_size] = i; +// list_size++; +// } + +// qsort_r(list, list_size, sizeof(int), ue_ul_compare, ¶ms); + +// if (list_size) { +// for (i = 0; i < list_size-1; i++) +// UE_list->next_ul[list[i]] = list[i+1]; +// UE_list->next_ul[list[list_size-1]] = -1; +// UE_list->head_ul = list[0]; +// } else { +// UE_list->head_ul = -1; +// } + +// } + + + +void _assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subframeP, uint16_t *first_rb) +{ + + int i; + uint16_t n,UE_id; + uint8_t CC_id; + rnti_t rnti = -1; + int mcs; + int rb_table_index=0,tbs,tx_power; + eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; + + UE_TEMPLATE *UE_template; + LTE_DL_FRAME_PARMS *frame_parms; + + + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) continue; + + rnti = UE_RNTI(module_idP,i); + + if (rnti==NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (!phy_stats_exist(module_idP, rnti)) + continue; + + if (UE_list->UE_sched_ctrl[i].phr_received == 1) + mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs + else + mcs = 10; // otherwise, limit to QPSK PUSCH + + UE_id = i; + + for (n=0; nnumactiveULCCs[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]; + + // if this UE has UL traffic + if (UE_template->ul_total_buffer > 0 ) { + + tbs = mac_xface->get_TBS_UL(mcs,3); // 1 or 2 PRB with cqi enabled does not work well! + // fixme: set use_srs flag + tx_power= mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); + + while ((((UE_template->phr_info - tx_power) < 0 ) || (tbs > UE_template->ul_total_buffer))&& + (mcs > 3)) { + // LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); + mcs--; + tbs = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); + tx_power = mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); // fixme: set use_srs + } + + while ((tbs < UE_template->ul_total_buffer) && + (rb_table[rb_table_index]<(frame_parms->N_RB_UL-first_rb[CC_id])) && + ((UE_template->phr_info - tx_power) > 0) && + (rb_table_index < 32 )) { + // LOG_I(MAC,"tbs %d ul buffer %d rb table %d max ul rb %d\n", tbs, UE_template->ul_total_buffer, rb_table[rb_table_index], frame_parms->N_RB_UL-first_rb[CC_id]); + rb_table_index++; + tbs = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); + tx_power = mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); + } + + UE_template->ue_tx_power = tx_power; + + if (rb_table[rb_table_index]>(frame_parms->N_RB_UL-first_rb[CC_id]-1)) { + rb_table_index--; + } + + // 1 or 2 PRB with cqi enabled does not work well! + 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; + UE_template->pre_allocated_nb_rb_ul= rb_table[rb_table_index]; + LOG_D(MAC,"[eNB %d] frame %d subframe %d: for UE %d CC %d: pre-assigned mcs %d, pre-allocated rb_table[%d]=%d RBs (phr %d, tx power %d)\n", + module_idP, frameP, subframeP, UE_id, CC_id, + UE_template->pre_assigned_mcs_ul, + UE_template->pre_allocated_rb_table_index_ul, + UE_template->pre_allocated_nb_rb_ul, + UE_template->phr_info,tx_power); + } else { + UE_template->pre_allocated_rb_table_index_ul=-1; + UE_template->pre_allocated_nb_rb_ul=0; + } + } + } +} + + + + void _ulsch_scheduler_pre_processor(module_id_t module_idP, int slice_id, int frameP, @@ -527,7 +683,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, //LOG_I(MAC,"assign max mcs min rb\n"); // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB - assign_max_mcs_min_rb(module_idP,frameP, subframeP, first_rb); + _assign_max_mcs_min_rb(module_idP,frameP, subframeP, first_rb); //LOG_I(MAC,"sort ue \n"); // sort ues @@ -584,7 +740,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, max_num_ue_to_be_scheduled+=1; - nb_rbs_allowed_slice[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage_uplink[slice_id], flexran_get_N_RB_UL(module_idP, CC_id)); + nb_rbs_allowed_slice[CC_id][slice_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[slice_id], flexran_get_N_RB_UL(module_idP, CC_id)); if (total_ue_count == 0) { average_rbs_per_user[CC_id] = 0; From eee0c1b84b896a6085211a01927f13e4c1a4f1d9 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Thu, 27 Apr 2017 09:29:00 +0200 Subject: [PATCH 017/141] uplink percentage --- openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 5 ++--- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 22 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index fbb8a11950..186ccf1287 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -138,12 +138,11 @@ void _assign_rbs_required (module_id_t Mod_id, // 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 _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, sub_frame_t subframeP, uint16_t *first_rb); void _ulsch_scheduler_pre_processor(module_id_t module_idP, - int slice_id, - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], + int slice_id, int frameP, sub_frame_t subframeP, uint16_t *first_rb); diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 849dc30869..333cc275c2 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -65,6 +65,8 @@ float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; + uint16_t flexran_nb_rbs_allowed_slice_uplink(float rb_percentage, int total_rbs){ return (uint16_t) floor(rb_percentage * total_rbs); } @@ -548,7 +550,7 @@ uint16_t flexran_nb_rbs_allowed_slice_uplink(float rb_percentage, int total_rbs) -void _assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subframeP, uint16_t *first_rb) +void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, sub_frame_t subframeP, uint16_t *first_rb) { int i; @@ -621,7 +623,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfr } while ((tbs < UE_template->ul_total_buffer) && - (rb_table[rb_table_index]<(frame_parms->N_RB_UL-first_rb[CC_id])) && + (rb_table[rb_table_index]<(nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id])) && ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { // LOG_I(MAC,"tbs %d ul buffer %d rb table %d max ul rb %d\n", tbs, UE_template->ul_total_buffer, rb_table[rb_table_index], frame_parms->N_RB_UL-first_rb[CC_id]); @@ -632,7 +634,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfr UE_template->ue_tx_power = tx_power; - if (rb_table[rb_table_index]>(frame_parms->N_RB_UL-first_rb[CC_id]-1)) { + if (rb_table[rb_table_index]>(nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id]-1)) { rb_table_index--; } @@ -662,7 +664,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfr void _ulsch_scheduler_pre_processor(module_id_t module_idP, - int slice_id, + int slice_id, int frameP, sub_frame_t subframeP, uint16_t *first_rb) @@ -679,11 +681,11 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, UE_TEMPLATE *UE_template = 0; LTE_DL_FRAME_PARMS *frame_parms = 0; - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; + //LOG_I(MAC,"assign max mcs min rb\n"); // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB - _assign_max_mcs_min_rb(module_idP,frameP, subframeP, first_rb); + _assign_max_mcs_min_rb(module_idP, slice_id, frameP, subframeP, first_rb); //LOG_I(MAC,"sort ue \n"); // sort ues @@ -1056,9 +1058,9 @@ void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, int slice_id = 0; - + _ulsch_scheduler_pre_processor(module_idP, - slice_id, + slice_id, frameP, subframeP, first_rb); @@ -1225,7 +1227,7 @@ abort(); UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; // buffer_occupancy = UE_template->ul_total_buffer; - while (((rb_table[rb_table_index]>(frame_parms->N_RB_UL-1-first_rb[CC_id])) || + while (((rb_table[rb_table_index]>(nb_rbs_allowed_slice[CC_id][slice_id]-1-first_rb[CC_id])) || (rb_table[rb_table_index]>45)) && (rb_table_index>0)) { rb_table_index--; @@ -1235,7 +1237,7 @@ abort(); UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=TBS; // buffer_occupancy -= TBS; - rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, + rballoc = mac_xface->computeRIV(nb_rbs_allowed_slice[CC_id][slice_id], first_rb[CC_id], rb_table[rb_table_index]); From 689eae92ee2f83d88f33d4f8393c8197f9e6fc63 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Wed, 10 May 2017 13:11:09 +0200 Subject: [PATCH 018/141] Fix Bug dl scheduler --- openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 81c18a26c0..0bde8c965b 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -284,7 +284,7 @@ void _assign_rbs_required (module_id_t Mod_id, nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; if (nb_rbs_required[CC_id][UE_id] > nb_rbs_allowed_slice[CC_id][slice_id]) { - TBS = mac_xface->get_TBS_DL(flexran_get_ue_wcqi(Mod_id, UE_id), nb_rbs_allowed_slice[CC_id][slice_id]); + TBS = mac_xface->get_TBS_DL(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_allowed_slice[CC_id][slice_id]); nb_rbs_required[CC_id][UE_id] = nb_rbs_allowed_slice[CC_id][slice_id]; break; } From 5de045b8027c6ac4f027bc8c6ad6f4ff2c8f7270 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Thu, 18 May 2017 15:25:10 +0200 Subject: [PATCH 019/141] Uplink slices --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 4 +- openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 6 +- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 14 +- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 1052 ++--------------- 4 files changed, 141 insertions(+), 935 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index db9af62eac..f17fb9a1ba 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1248,8 +1248,8 @@ int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->flexran_agent_send_sr_info = flexran_agent_send_sr_info; xface->flexran_agent_send_sf_trigger = flexran_agent_send_sf_trigger; //xface->flexran_agent_send_update_mac_stats = flexran_agent_send_update_mac_stats; - xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_default; - xface->flexran_agent_schedule_ul_spec = flexran_agent_schedule_ulsch_ue_spec; + xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_dl_spec_default; + xface->flexran_agent_schedule_ul_spec = flexran_schedule_ue_ul_spec_default; //xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_remote; xface->flexran_agent_get_pending_dl_mac_config = flexran_agent_get_pending_dl_mac_config; diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index 186ccf1287..c2d28b33f7 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -51,7 +51,7 @@ typedef void (*slice_scheduler)(module_id_t mod_id, /* * top level flexran scheduler used by the eNB scheduler */ -void flexran_schedule_ue_spec_default(mid_t mod_id, +void flexran_schedule_ue_dl_spec_default(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, @@ -102,7 +102,7 @@ flexran_schedule_ue_spec_be(mid_t mod_id, * common flexran scheduler function */ void -flexran_schedule_ue_spec_common(mid_t mod_id, +flexran_schedule_ue_dl_spec_common(mid_t mod_id, int slice_id, uint32_t frame, uint32_t subframe, @@ -182,7 +182,7 @@ void _dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, /* * Default scheduler used by the eNB agent */ -void flexran_schedule_ue_spec_default(mid_t mod_id, uint32_t frame, uint32_t subframe, +void flexran_schedule_ue_dl_spec_default(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, Protocol__FlexranMessage **dl_info); /* diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index aec093e88a..cfb14af641 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -709,12 +709,12 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, #define SF05_LIMIT 1 /* - * Main scheduling functions to support slicing + * Main Downlink Slicing * */ void -flexran_schedule_ue_spec_default(mid_t mod_id, +flexran_schedule_ue_dl_spec_default(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, @@ -876,7 +876,7 @@ flexran_schedule_ue_spec_embb(mid_t mod_id, Protocol__FlexranMessage **dl_info) { - flexran_schedule_ue_spec_common(mod_id, + flexran_schedule_ue_dl_spec_common(mod_id, slice_id, frame, subframe, @@ -894,7 +894,7 @@ flexran_schedule_ue_spec_urllc(mid_t mod_id, Protocol__FlexranMessage **dl_info) { - flexran_schedule_ue_spec_common(mod_id, + flexran_schedule_ue_spec_dl_common(mod_id, slice_id, frame, subframe, @@ -913,7 +913,7 @@ flexran_schedule_ue_spec_mmtc(mid_t mod_id, { - flexran_schedule_ue_spec_common(mod_id, + flexran_schedule_ue_dl_spec_common(mod_id, slice_id, frame, subframe, @@ -932,7 +932,7 @@ flexran_schedule_ue_spec_be(mid_t mod_id, { - flexran_schedule_ue_spec_common(mod_id, + flexran_schedule_ue_dl_spec_common(mod_id, slice_id, frame, subframe, @@ -943,7 +943,7 @@ flexran_schedule_ue_spec_be(mid_t mod_id, //------------------------------------------------------------------------------ void -flexran_schedule_ue_spec_common(mid_t mod_id, +flexran_schedule_ue_dl_spec_common(mid_t mod_id, int slice_id, uint32_t frame, uint32_t subframe, diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 333cc275c2..20e1c67366 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -67,488 +67,17 @@ float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; +int update_ul_scheduler[MAX_NUM_SLICES] = {1, 1, 1, 1}; +int update_ul_scheduler_current[MAX_NUM_SLICES] = {1, 1, 1, 1}; + +// name of available scheduler +char *ul_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_ul_spec_embb"}; + + uint16_t flexran_nb_rbs_allowed_slice_uplink(float rb_percentage, int total_rbs){ return (uint16_t) floor(rb_percentage * total_rbs); } -// // This table holds the allowable PRB sizes for ULSCH transmissions -// uint8_t rb_table[33] = {1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60,72,75,80,81,90,96,100}; - -// void rx_sdu(const module_id_t enb_mod_idP, -// const int CC_idP, -// const frame_t frameP, -// const sub_frame_t subframeP, -// const rnti_t rntiP, -// uint8_t *sduP, -// const uint16_t sdu_lenP, -// const int harq_pidP, -// uint8_t *msg3_flagP) -// { - -// unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; -// unsigned char rx_lcids[NB_RB_MAX]; -// unsigned short rx_lengths[NB_RB_MAX]; -// int UE_id = find_UE_id(enb_mod_idP,rntiP); -// int ii,j; -// eNB_MAC_INST *eNB = &eNB_mac_inst[enb_mod_idP]; -// UE_list_t *UE_list= &eNB->UE_list; -// int crnti_rx=0; -// int old_buffer_info; - -// start_meas(&eNB->rx_ulsch_sdu); - -// if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1) ) -// for(ii=0; iiUE_sched_ctrl[UE_id].ul_scheduled &= (~(1<UE_sched_ctrl[UE_id].ul_inactivity_timer=0; -// UE_list->UE_sched_ctrl[UE_id].ul_failure_timer =0; -// UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { -// UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0; -// mac_eNB_rrc_ul_in_sync(enb_mod_idP,CC_idP,frameP,subframeP,UE_RNTI(enb_mod_idP,UE_id)); -// } -// } - - -// payload_ptr = parse_ulsch_header(sduP,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_lenP); - -// T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP), -// T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu)); -// T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP), -// T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP)); - -// eNB->eNB_stats[CC_idP].ulsch_bytes_rx=sdu_lenP; -// eNB->eNB_stats[CC_idP].total_ulsch_bytes_rx+=sdu_lenP; -// eNB->eNB_stats[CC_idP].total_ulsch_pdus_rx+=1; -// // control element -// for (i=0; iUE_template[CC_idP][UE_id].phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET; -// LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n", -// enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].phr_info); -// UE_list->UE_template[CC_idP][UE_id].phr_info_configured=1; -// UE_list->UE_sched_ctrl[UE_id].phr_received = 1; -// } -// payload_ptr+=sizeof(POWER_HEADROOM_CMD); -// break; - -// case CRNTI: -// UE_id = find_UE_id(enb_mod_idP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]); -// LOG_I(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n", -// frameP,subframeP,enb_mod_idP, CC_idP, rx_ces[i], i,num_ce,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1],UE_id); -// if (UE_id!=-1) { -// UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer=0; -// UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0; -// if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { -// UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0; -// mac_eNB_rrc_ul_in_sync(enb_mod_idP,CC_idP,frameP,subframeP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]); -// } -// } -// crnti_rx=1; -// payload_ptr+=2; - -// if (msg3_flagP != NULL) { -// *msg3_flagP = 0; -// } -// break; - -// case TRUNCATED_BSR: -// case SHORT_BSR: { -// uint8_t lcgid; -// lcgid = (payload_ptr[0] >> 6); - -// LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", -// enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f); - -// if (crnti_rx==1) -// LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", -// enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f); -// if (UE_id != -1) { - -// UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid] = (payload_ptr[0] & 0x3f); - -// // update buffer info - -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid]]; - -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]; - -// PHY_vars_eNB_g[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP] = (payload_ptr[0] & 0x3f); -// if (UE_id == UE_list->head) -// VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,PHY_vars_eNB_g[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP]); -// 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; -// } -// if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP,UE_id)) < RRC_CONNECTED) -// LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : ul_total_buffer = %d (lcg increment %d)\n", -// enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].ul_total_buffer, -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]); -// } -// else { - -// } -// payload_ptr += 1;//sizeof(SHORT_BSR); // fixme -// } -// break; - -// case LONG_BSR: -// if (UE_id != -1) { -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0] = ((payload_ptr[0] & 0xFC) >> 2); -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1] = -// ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2] = -// ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] = (payload_ptr[2] & 0x3F); - -// // update buffer info -// old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]; -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0]]; - -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]; -// if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; -// else -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; - -// old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]; -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1]]; -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]; -// if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; -// else -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; - -// old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]; -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2]]; -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]; -// if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; -// else -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; - -// old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]]; -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; -// if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; -// else -// UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; - -// LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " -// "%u LCGID2 = %u LCGID3 = %u\n", -// enb_mod_idP, CC_idP, -// rx_ces[i], -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0], -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1], -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2], -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]); -// if (crnti_rx==1) -// LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " -// "%u LCGID2 = %u LCGID3 = %u\n", -// enb_mod_idP, CC_idP, -// rx_ces[i], -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0], -// UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1], -// 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 ) { -// 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 ) { -// 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 ) { -// 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 ) { -// 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); -// break; - -// default: -// LOG_E(MAC, "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n", enb_mod_idP, CC_idP, rx_ces[i]); -// break; -// } -// } - -// for (i=0; i CCCH_PAYLOAD_SIZE_MAX) { -// LOG_E(MAC, "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d), dropping packet\n", -// enb_mod_idP, CC_idP, frameP, rx_lengths[i], CCCH_PAYLOAD_SIZE_MAX); -// break; -// } -// LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n", -// enb_mod_idP,CC_idP,frameP, -// payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4], payload_ptr[5], rntiP); -// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,1); -// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,0); -// for (ii=0; iicommon_channels[CC_idP].RA_template[ii].rnti, rntiP, -// eNB->common_channels[CC_idP].RA_template[ii].RA_active); - -// if ((eNB->common_channels[CC_idP].RA_template[ii].rnti==rntiP) && -// (eNB->common_channels[CC_idP].RA_template[ii].RA_active==TRUE)) { - -// //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); - -// if (UE_id < 0) { -// memcpy(&eNB->common_channels[CC_idP].RA_template[ii].cont_res_id[0],payload_ptr,6); -// LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n", -// enb_mod_idP,CC_idP,frameP,rx_lengths[i],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 ) { -// mac_xface->macphy_exit("[MAC][eNB] Max user count reached\n"); -// // kill RA procedure -// } else -// LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n", -// enb_mod_idP,CC_idP,frameP,eNB->common_channels[CC_idP].RA_template[ii].rnti,UE_id); -// } else { -// LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n", -// enb_mod_idP,CC_idP,frameP,UE_id,rx_lengths[i],payload_ptr-sduP); -// // kill RA procedure -// } - -// if (Is_rrc_registered == 1) -// mac_rrc_data_ind( -// enb_mod_idP, -// CC_idP, -// frameP,subframeP, -// rntiP, -// CCCH, -// (uint8_t*)payload_ptr, -// rx_lengths[i], -// ENB_FLAG_YES, -// enb_mod_idP, -// 0); - - -// if (num_ce >0) { // handle msg3 which is not RRCConnectionRequest -// // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); -// } - -// eNB->common_channels[CC_idP].RA_template[ii].generate_Msg4 = 1; -// eNB->common_channels[CC_idP].RA_template[ii].wait_ack_Msg4 = 0; - -// } // if process is active -// } // loop on RA processes - -// break ; - -// case DCCH : -// case DCCH1 : -// // if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){ - - -// #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++) { -// LOG_T(MAC,"%x ",payload_ptr[j]); -// } -// LOG_T(MAC,"\n"); -// #endif - -// if (UE_id != -1) { -// // adjust buffer occupancy of the correponding logical channel group -// if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; -// else -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; - -// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n", -// enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]); - -// mac_rlc_data_ind( -// enb_mod_idP, -// rntiP, -// enb_mod_idP, -// frameP, -// ENB_FLAG_YES, -// MBMS_FLAG_NO, -// rx_lcids[i], -// (char *)payload_ptr, -// rx_lengths[i], -// 1, -// NULL);//(unsigned int*)crc_status); -// UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1; -// UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; -// } /* UE_id != -1 */ - -// // } -// break; - -// // all the DRBS -// case DTCH: -// default : - -// #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++) { -// LOG_T(MAC,"%x ",payload_ptr[j]); -// } -// LOG_T(MAC,"\n"); -// #endif -// if (rx_lcids[i] < NB_RB_MAX ) { -// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n", -// enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]); - -// if (UE_id != -1) { -// // adjust buffer occupancy of the correponding logical channel group -// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d, removing from LCGID %ld, %d\n", -// enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i], -// UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]], -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]]); - -// if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; -// else -// UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; -// if ((rx_lengths[i] 0) ) { // MAX SIZE OF transport block -// mac_rlc_data_ind( -// enb_mod_idP, -// rntiP, -// enb_mod_idP, -// frameP, -// ENB_FLAG_YES, -// MBMS_FLAG_NO, -// rx_lcids[i], -// (char *)payload_ptr, -// rx_lengths[i], -// 1, -// NULL);//(unsigned int*)crc_status); - -// UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1; -// UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; -// } -// else { /* rx_length[i] */ -// UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx+=1; -// LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ", -// enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id); -// } -// } -// else {/*(UE_id != -1*/ -// LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ", -// enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id); -// } -// } - -// break; -// } - -// payload_ptr+=rx_lengths[i]; -// } - -// /* NN--> FK: we could either check the payload, or use a phy helper to detect a false msg3 */ -// if ((num_sdu == 0) && (num_ce==0)) { -// if (UE_id != -1) -// UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_errors_rx+=1; - -// if (msg3_flagP != NULL) { -// if( *msg3_flagP == 1 ) { -// LOG_N(MAC,"[eNB %d] CC_id %d frame %d : false msg3 detection: signal phy to canceling RA and remove the UE\n", enb_mod_idP, CC_idP, frameP); -// *msg3_flagP=0; -// } -// } -// } else { -// if (UE_id != -1) { -// UE_list->eNB_UE_stats[CC_idP][UE_id].pdu_bytes_rx=sdu_lenP; -// UE_list->eNB_UE_stats[CC_idP][UE_id].total_pdu_bytes_rx+=sdu_lenP; -// UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_pdus_rx+=1; -// } -// } - -// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,0); -// stop_meas(&eNB->rx_ulsch_sdu); -// } - - - -// void _sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) -// { -// int i; -// int list[NUMBER_OF_UE_MAX]; -// int list_size = 0; -// int rnti; -// struct sort_ue_ul_params params = { module_idP, frameP, subframeP }; - -// UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; - -// for (i = 0; i < NUMBER_OF_UE_MAX; i++) { -// rnti = UE_RNTI(module_idP, i); -// if (rnti == NOT_A_RNTI) -// continue; -// if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) -// continue; -// if (!phy_stats_exist(module_idP, rnti)) -// continue; -// list[list_size] = i; -// list_size++; -// } - -// qsort_r(list, list_size, sizeof(int), ue_ul_compare, ¶ms); - -// if (list_size) { -// for (i = 0; i < list_size-1; i++) -// UE_list->next_ul[list[i]] = list[i+1]; -// UE_list->next_ul[list[list_size-1]] = -1; -// UE_list->head_ul = list[0]; -// } else { -// UE_list->head_ul = -1; -// } - -// } - - void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, sub_frame_t subframeP, uint16_t *first_rb) { @@ -565,7 +94,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, su UE_TEMPLATE *UE_template; LTE_DL_FRAME_PARMS *frame_parms; - + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { if (UE_list->active[i] != TRUE) continue; @@ -606,7 +135,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, su 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]; - + nb_rbs_allowed_slice[CC_id][UE_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[UE_id], flexran_get_N_RB_UL(module_idP, CC_id)); // if this UE has UL traffic if (UE_template->ul_total_buffer > 0 ) { @@ -623,7 +152,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, su } while ((tbs < UE_template->ul_total_buffer) && - (rb_table[rb_table_index]<(nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id])) && + (rb_table[rb_table_index]<(nb_rbs_allowed_slice[CC_id][UE_id]-first_rb[CC_id])) && ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { // LOG_I(MAC,"tbs %d ul buffer %d rb table %d max ul rb %d\n", tbs, UE_template->ul_total_buffer, rb_table[rb_table_index], frame_parms->N_RB_UL-first_rb[CC_id]); @@ -634,7 +163,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, su UE_template->ue_tx_power = tx_power; - if (rb_table[rb_table_index]>(nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id]-1)) { + if (rb_table[rb_table_index]>(nb_rbs_allowed_slice[CC_id][UE_id]-first_rb[CC_id]-1)) { rb_table_index--; } @@ -674,13 +203,14 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, uint16_t UE_id,n,r; uint8_t CC_id, round, harq_pid; uint16_t nb_allocated_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX],total_allocated_rbs[MAX_NUM_CCs],average_rbs_per_user[MAX_NUM_CCs]; + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; int16_t total_remaining_rbs[MAX_NUM_CCs]; uint16_t max_num_ue_to_be_scheduled=0,total_ue_count=0; rnti_t rnti= -1; UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; UE_TEMPLATE *UE_template = 0; LTE_DL_FRAME_PARMS *frame_parms = 0; - + UE_sched_ctrl *ue_sched_ctl; //LOG_I(MAC,"assign max mcs min rb\n"); @@ -742,15 +272,15 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, max_num_ue_to_be_scheduled+=1; - nb_rbs_allowed_slice[CC_id][slice_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[slice_id], flexran_get_N_RB_UL(module_idP, CC_id)); + nb_rbs_allowed_slice[CC_id][UE_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[UE_id], flexran_get_N_RB_UL(module_idP, CC_id)); if (total_ue_count == 0) { average_rbs_per_user[CC_id] = 0; } else if (total_ue_count == 1 ) { // increase the available RBs, special case, - average_rbs_per_user[CC_id] = nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id]+1; - } else if( (total_ue_count <= (nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id])) && + average_rbs_per_user[CC_id] = nb_rbs_allowed_slice[CC_id][i]-first_rb[CC_id]+1; + } else if( (total_ue_count <= (nb_rbs_allowed_slice[CC_id][i]-first_rb[CC_id])) && (total_ue_count <= max_num_ue_to_be_scheduled)) { - average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id])/total_ue_count); + average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice[CC_id][i]-first_rb[CC_id])/total_ue_count); } else if (max_num_ue_to_be_scheduled > 0 ) { average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id])/max_num_ue_to_be_scheduled); } else { @@ -782,7 +312,8 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, for (n=0; nnumactiveULCCs[UE_id]; n++) { // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; - + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][UE_id]; // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); flexran_get_harq(module_idP, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_UL); if(round>0) { @@ -814,9 +345,9 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, for (n=0; nnumactiveULCCs[UE_id]; n++) { // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; - UE_template = &UE_list->UE_template[CC_id][UE_id]; + UE_template = &UE_list->UE_template[CC_id][UE_id]; frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); - total_remaining_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][slice_id] - first_rb[CC_id] - total_allocated_rbs[CC_id]; + total_remaining_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][UE_id] - first_rb[CC_id] - total_allocated_rbs[CC_id]; if (total_ue_count == 1 ) { total_remaining_rbs[CC_id]+=1; @@ -848,110 +379,114 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, } } +/* + * Main Uplink Slicing + * + */ + +void +flexran_schedule_ue_ul_spec_default(mid_t mod_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage **dl_info) +//------------------------------------------------------------------------------ +{ + int i=0; + + flexran_agent_mac_create_empty_ul_config(module_idP, ul_info); + + for (i = 0; i < n_active_slices; i++) { + + // Load any updated functions + if (update_dl_scheduler[i] > 0 ) { + slice_sched[i] = dlsym(NULL, dl_scheduler_type[i]); + update_dl_scheduler[i] = 0; + update_dl_scheduler_current[i] = 0; + slice_percentage_current[i]= slice_percentage[i]; + total_slice_percentage+=slice_percentage[i]; + LOG_N(MAC,"update dl scheduler slice %d\n", i); + } + + // check if the number of slices has changed, and log + if (n_active_slices_current != n_active_slices ){ + if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { + LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active slices has changed: %d-->%d\n", + mod_id, frame, subframe, n_active_slices_current, n_active_slices); + + n_active_slices_current = n_active_slices; + + } else { + LOG_W(MAC,"invalid number of slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); + n_active_slices = n_active_slices_current; + } + } + + // check if the slice rb share has changed, and log the console + if (slice_percentage_current[i] != slice_percentage[i]){ + if ((slice_percentage[i] >= 0.0) && (slice_percentage[i] <= 1.0)){ + if ((total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]) <= 1.0) { + total_slice_percentage=total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]; + LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", + mod_id, i, frame, subframe, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); + + slice_percentage_current[i] = slice_percentage[i]; + + } else { + LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", + mod_id,i, + total_slice_percentage, + total_slice_percentage - slice_percentage_current[i] + slice_percentage[i], + slice_percentage[i],slice_percentage_current[i]); + + slice_percentage[i]= slice_percentage_current[i]; + + } + } else { + LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage[i],slice_percentage_current[i]); + + slice_percentage[i]= slice_percentage_current[i]; + + } + } + + // check if a new scheduler, and log the console + if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ + LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", + mod_id, i, frame, subframe, dl_scheduler_type[i]); + + update_dl_scheduler_current[i] = update_dl_scheduler[i]; + + } + + // Run each enabled slice-specific schedulers one by one + //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); + slice_sched[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); + + } + +} + +void +flexran_schedule_ue_ul_spec_embb(mid_t mod_id, + frame_t frameP, + unsigned char cooperation_flag, + uint32_t subframe, + unsigned char sched_subframe, + Protocol__FlexranMessage **ul_info) + +{ + flexran_agent_schedule_ulsch_ue_spec(mod_id, + frame, + cooperation_flag, + subframe, + sched_subframe, + ul_info); + +} -// uint32_t bytes_to_bsr_index(int32_t nbytes) -// { - -// uint32_t i=0; - -// if (nbytes<0) { -// return(0); -// } - -// while ((iE == 0) { -// not_done = 0; -// } - -// lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; - -// if (lcid < EXTENDED_POWER_HEADROOM) { -// if (not_done==0) { // last MAC SDU, length is implicit -// 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++) { -// length -= rx_lengths[num_sdu_cnt]; -// } -// } else { -// if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { -// length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; -// mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT); -// } else { // F = 1 -// length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); -// mac_header_ptr += 3;//sizeof(SCH_SUBHEADER_LONG); -// } -// } - -// LOG_D(MAC,"[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n", -// num_sdus,lcid,tb_length, length,mac_header_ptr-mac_header); -// rx_lcids[num_sdus] = lcid; -// rx_lengths[num_sdus] = length; -// num_sdus++; -// } else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI -// if (lcid == SHORT_PADDING) { -// mac_header_ptr++; -// } else { -// rx_ces[num_ces] = lcid; -// num_ces++; -// mac_header_ptr++; - -// if (lcid==LONG_BSR) { -// ce_len+=3; -// } else if (lcid==CRNTI) { -// ce_len+=2; -// } else if ((lcid==POWER_HEADROOM) || (lcid==TRUNCATED_BSR)|| (lcid== SHORT_BSR)) { -// ce_len++; -// } else { -// LOG_E(MAC,"unknown CE %d \n", lcid); -// mac_xface->macphy_exit("unknown CE"); -// } -// } -// } -// } - -// *num_ce = num_ces; -// *num_sdu = num_sdus; - -// return(mac_header_ptr); -// } - - -void flexran_agent_schedule_ulsch_ue_spec(module_id_t module_idP, +void flexran_agent_schedule_ulsch_ue_spec(mid_t module_idP, frame_t frameP, unsigned char cooperation_flag, sub_frame_t subframeP, @@ -959,8 +494,6 @@ void flexran_agent_schedule_ulsch_ue_spec(module_id_t module_idP, Protocol__FlexranMessage **ul_info) { -flexran_agent_mac_create_empty_ul_config(module_idP, ul_info); - uint16_t first_rb[MAX_NUM_CCs],i; int CC_id; eNB_MAC_INST *eNB=&eNB_mac_inst[module_idP]; @@ -1007,11 +540,6 @@ flexran_agent_mac_create_empty_ul_config(module_idP, ul_info); flexran_agent_schedule_ulsch_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe,first_rb); -// #ifdef CBA - // schedule_ulsch_cba_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe, first_rb); -// #endif - - stop_meas(&eNB->schedule_ulsch); } @@ -1227,7 +755,7 @@ abort(); UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; // buffer_occupancy = UE_template->ul_total_buffer; - while (((rb_table[rb_table_index]>(nb_rbs_allowed_slice[CC_id][slice_id]-1-first_rb[CC_id])) || + while (((rb_table[rb_table_index]>(nb_rbs_allowed_slice[CC_id][UE_id]-1-first_rb[CC_id])) || (rb_table[rb_table_index]>45)) && (rb_table_index>0)) { rb_table_index--; @@ -1237,7 +765,7 @@ abort(); UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=TBS; // buffer_occupancy -= TBS; - rballoc = mac_xface->computeRIV(nb_rbs_allowed_slice[CC_id][slice_id], + rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, first_rb[CC_id], rb_table[rb_table_index]); @@ -1527,325 +1055,3 @@ abort(); } // loop of CC_id } -// #ifdef CBA -// void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframeP, unsigned char sched_subframe, uint16_t *first_rb) -// { - -// eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP]; -// UE_list_t *UE_list=&eNB->UE_list; -// //UE_TEMPLATE *UE_template; -// void *ULSCH_dci = NULL; -// DCI_PDU *DCI_pdu; -// uint8_t CC_id=0; -// uint8_t rb_table_index=0, aggregation=2; -// uint32_t rballoc; -// uint8_t cba_group, cba_resources; -// uint8_t required_rbs[NUM_MAX_CBA_GROUP]; -// int8_t num_cba_resources[NUM_MAX_CBA_GROUP];// , weight[NUM_MAX_CBA_GROUP] -// // the following vars should become a vector [MAX_NUM_CCs] -// LTE_DL_FRAME_PARMS *frame_parms; -// int8_t available_rbs=0; -// uint8_t remaining_rbs=0; -// uint8_t allocated_rbs=0; -// uint8_t total_UEs=UE_list->num_UEs; -// uint8_t active_UEs[NUM_MAX_CBA_GROUP]; -// uint8_t total_groups=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups; -// int min_rb_unit=2; -// uint8_t cba_policy=CBA_ES; -// int UE_id; -// uint8_t mcs[NUM_MAX_CBA_GROUP]; -// uint32_t total_cba_resources=0; -// uint32_t total_rbs=0; -// // We compute the weight of each group and initialize some variables - -// // loop over all active UEs -// // for (UE_id=UE_list->head_ul;UE_id>=0;UE_id=UE_list->next_ul[UE_id]) { - -// for (cba_group=0; cba_groupget_lte_frame_parms(module_idP,CC_id); -// available_rbs=frame_parms->N_RB_DL-1-first_rb[CC_id]; -// remaining_rbs=available_rbs; -// total_groups=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups; -// min_rb_unit=get_min_rb_unit(module_idP,CC_id); - -// if (available_rbs < min_rb_unit ) -// continue; - -// // remove this condition later -// // cba group template uses the exisitng UE template, and thus if a UE -// // is scheduled, the correspodning group can't be used for CBA -// // this can be fixed later -// if (total_groups > 0) { -// DCI_pdu = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu; - -// for (cba_group=0; -// (cba_group (1<head_ul; UE_id>=0; UE_id=UE_list->next_ul[UE_id]) { -// 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_eNB_get_rrc_status(module_idP,rnti) > RRC_CONNECTED) && -// (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) { -// mcs[cba_group]= 8; // apply fixed scheduling -// } 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]= mcs[cba_group];//cmin(mcs[cba_group],openair_daq_vars.target_ue_ul_mcs); - -// if (available_rbs < min_rb_unit ) -// break; - -// // If the group needs some resource -// // determine the total number of allocations (one or multiple DCIs): to be refined -// if ((active_UEs[cba_group] > 0) && (eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group] != 0)) { -// // to be refined in case of : total_UEs >> weight[cba_group]*available_rbs - -// switch(cba_policy) { -// case CBA_ES: -// required_rbs[cba_group] = (uint8_t)floor(available_rbs/total_groups); // allocate equally among groups -// num_cba_resources[cba_group]=1; -// break; - -// // can't have more than one allocation for the same group/UE -// /* case CBA_ES_S: -// required_rbs[cba_group] = (uint8_t)floor(available_rbs/total_groups); // allocate equally among groups -// if (required_rbs[cba_group] > min_rb_unit) -// num_cba_resources[cba_group]=(uint8_t)(required_rbs[cba_group]/ min_rb_unit); -// break;*/ -// case CBA_PF: -// required_rbs[cba_group] = (uint8_t)floor((active_UEs[cba_group]*available_rbs)/total_UEs); -// num_cba_resources[cba_group]=1; -// break; -// /* case CBA_PF_S: -// required_rbs[cba_group] = (uint8_t)ceil((active_UEs[cba_group]*available_rbs)/total_UEs); -// if (required_rbs[cba_group] > min_rb_unit) -// num_cba_resources[cba_group]=(uint8_t) floor(required_rbs[cba_group] / min_rb_unit); -// break;*/ - -// default: -// LOG_W(MAC,"unknown CBA policy\n"); -// break; -// } - -// total_cba_resources+=num_cba_resources[cba_group]; -// total_rbs+=required_rbs[cba_group]; - -// /* while ((remaining_rbs < required_rbs[cba_group]) && -// (required_rbs[cba_group] > 0) && -// (required_rbs[cba_group] < min_rb_unit )) -// required_rbs[cba_group]--; -// */ - -// /* -// while (rb_table[rb_table_index] < required_rbs[cba_group]) -// rb_table_index++; - -// while (rb_table[rb_table_index] > remaining_rbs ) -// rb_table_index--; - -// remaining_rbs-=rb_table[rb_table_index]; -// required_rbs[cba_group]=rb_table[rb_table_index]; -// */ -// // num_cba_resources[cba_group]=1; - -// } -// } - -// // phase 2 reduce the number of cba allocations among the groups -// cba_group=0; - -// if (total_cba_resources <= 0) { -// return; -// } - -// // increase rb if any left: to be done -// cba_group=0; - -// while (total_rbs < available_rbs - 1 ) { -// required_rbs[cba_group%total_groups]++; -// total_rbs++; -// cba_group++; -// } - -// // phase 3: -// for (cba_group=0; cba_group remaining_rbs ) { -// rb_table_index--; -// } - -// remaining_rbs-=rb_table[rb_table_index]; -// allocated_rbs=rb_table[rb_table_index]; - -// rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, -// first_rb[CC_id], -// rb_table[rb_table_index]); - -// first_rb[CC_id]+=rb_table[rb_table_index]; -// LOG_N(MAC, -// "[eNB %d] CC_id %d Frame %d, subframeP %d: schedule CBA access %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), mcs %d, rballoc %d\n", -// module_idP, CC_id, 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); - -// switch (frame_parms->N_RB_UL) { -// case 6: -// mac_xface->macphy_exit("[MAC][eNB] CBA RB=6 not supported \n"); -// break; - -// case 25: -// if (frame_parms->frame_type == TDD) { -// ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0]; - -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs[cba_group]; -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = 1; -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1;//tpc; -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cba_group; -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_list->UE_template[CC_id][cba_group].DAI_ul[sched_subframe]; -// ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = 1; - -// //add_ue_spec_dci -// add_common_dci(DCI_pdu, -// ULSCH_dci, -// eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], -// sizeof(DCI0_5MHz_TDD_1_6_t), -// aggregation, -// sizeof_DCI0_5MHz_TDD_1_6_t, -// format0, -// 0); -// } else { -// ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0]; - -// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->type = 0; -// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; -// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; -// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs[cba_group]; -// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->ndi = 1; -// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->TPC = 1;//tpc; -// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cshift = cba_group; -// ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cqi_req = 1; - -// //add_ue_spec_dci -// add_common_dci(DCI_pdu, -// ULSCH_dci, -// eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], -// sizeof(DCI0_5MHz_FDD_t), -// aggregation, -// sizeof_DCI0_5MHz_FDD_t, -// format0, -// 0); -// } - -// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for CBA group %d, RB 25 format 0\n", module_idP,CC_id,frameP,subframeP,cba_group); -// break; - -// case 50: -// if (frame_parms->frame_type == TDD) { -// ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0]; - -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs[cba_group]; -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->ndi = 1; -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1;//tpc; -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cba_group; -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_list->UE_template[CC_id][cba_group].DAI_ul[sched_subframe]; -// ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = 1; - -// //add_ue_spec_dci -// add_common_dci(DCI_pdu, -// ULSCH_dci, -// eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], -// sizeof(DCI0_10MHz_TDD_1_6_t), -// aggregation, -// sizeof_DCI0_10MHz_TDD_1_6_t, -// format0, -// 0); -// } else { -// ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0]; - -// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->type = 0; -// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->hopping = 0; -// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; -// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->mcs = mcs[cba_group]; -// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->ndi = 1; -// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->TPC = 1;//tpc; -// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cshift = cba_group; -// ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cqi_req = 1; - -// //add_ue_spec_dci -// add_common_dci(DCI_pdu, -// ULSCH_dci, -// eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group], -// sizeof(DCI0_10MHz_FDD_t), -// aggregation, -// sizeof_DCI0_10MHz_FDD_t, -// format0, -// 0); -// } - -// LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for CBA group %d, RB 50 format 0\n", module_idP,CC_id,frameP,subframeP,cba_group); -// break; - -// case 100: -// mac_xface->macphy_exit("[MAC][eNB] CBA RB=100 not supported \n"); -// break; - -// default: -// break; -// } - -// // break;// for the moment only schedule one -// } -// } -// } -// } -// } -// #endif From 5c7377e1c090bd0e51cf53efde597e98f2c1008c Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Thu, 18 May 2017 17:21:07 +0200 Subject: [PATCH 020/141] Fix bug header --- openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 17 +++- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 12 +-- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 88 +++++++++++-------- 3 files changed, 71 insertions(+), 46 deletions(-) diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index c2d28b33f7..5fc53fece6 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -39,13 +39,19 @@ /* * slice specific scheduler */ -typedef void (*slice_scheduler)(module_id_t mod_id, +typedef void (*slice_scheduler_dl)(module_id_t mod_id, int slice_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, Protocol__FlexranMessage **dl_info); +typedef void (*slice_scheduler_ul)(module_id_t mod_id, + frame_t frame, + unsigned char cooperation_flag, + uint32_t subframe, + unsigned char sched_subframe, + Protocol__FlexranMessage **ul_info); /* @@ -109,6 +115,15 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, int *mbsfn_flag, Protocol__FlexranMessage **dl_info); +void +flexran_schedule_ue_ul_spec_default(mid_t mod_id, + uint32_t frame, + uint32_t cooperation_flag, + int subframe, + unsigned char sched_subframe, + Protocol__FlexranMessage **ul_info); + + uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs); diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index cfb14af641..b30cb5f491 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -88,8 +88,8 @@ typedef enum { // number of active slices for past and current time -int n_active_slices = 1; -int n_active_slices_current = 1; +static int n_active_slices = 1; +static int n_active_slices_current = 1; // ue to slice mapping int slicing_strategy = UEID_TO_SLICEID; @@ -115,7 +115,7 @@ char *dl_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_spec_embb", }; // pointer to the slice specific scheduler -slice_scheduler slice_sched[MAX_NUM_SLICES] = {0}; +slice_scheduler_dl slice_sched_dl[MAX_NUM_SLICES] = {0}; /** @@ -729,7 +729,7 @@ flexran_schedule_ue_dl_spec_default(mid_t mod_id, // Load any updated functions if (update_dl_scheduler[i] > 0 ) { - slice_sched[i] = dlsym(NULL, dl_scheduler_type[i]); + slice_sched_dl[i] = dlsym(NULL, dl_scheduler_type[i]); update_dl_scheduler[i] = 0; update_dl_scheduler_current[i] = 0; slice_percentage_current[i]= slice_percentage[i]; @@ -806,7 +806,7 @@ flexran_schedule_ue_dl_spec_default(mid_t mod_id, // Run each enabled slice-specific schedulers one by one //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); - slice_sched[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); + slice_sched_dl[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); } @@ -894,7 +894,7 @@ flexran_schedule_ue_spec_urllc(mid_t mod_id, Protocol__FlexranMessage **dl_info) { - flexran_schedule_ue_spec_dl_common(mod_id, + flexran_schedule_ue_dl_spec_common(mod_id, slice_id, frame, subframe, diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 20e1c67366..9a9ecbb1e5 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -35,6 +35,7 @@ #include "SCHED/defs.h" #include "SCHED/extern.h" +#include "LAYER2/MAC/flexran_agent_mac_proto.h" #include "LAYER2/MAC/defs.h" #include "LAYER2/MAC/proto.h" #include "LAYER2/MAC/extern.h" @@ -56,22 +57,30 @@ #include "T.h" -// #define ENABLE_MAC_PAYLOAD_DEBUG -// #define DEBUG_eNB_SCHEDULER 1 +/* number of active slices for past and current time*/ +static int n_active_slices = 1; +static int n_active_slices_current = 1; - -// RB share for each slice for past and current time -float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +/* RB share for each slice for past and current time*/ +float slice_percentage_uplink[MAX_NUM_SLICES] = {0.8, 0.2, 0.0, 0.0}; float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float total_slice_percentage_uplink = 0; - - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; - +/*resource blocks allowed*/ +static uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; +/*Slice Update */ int update_ul_scheduler[MAX_NUM_SLICES] = {1, 1, 1, 1}; int update_ul_scheduler_current[MAX_NUM_SLICES] = {1, 1, 1, 1}; -// name of available scheduler -char *ul_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_ul_spec_embb"}; + /* Slice Function Pointer */ +slice_scheduler_ul slice_sched_ul[MAX_NUM_SLICES] = {0}; + +/* name of available scheduler*/ +char *ul_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_ul_spec_embb", + "flexran_schedule_ue_ul_spec_urllc", + "flexran_schedule_ue_ul_spec_mmtc", + "flexran_schedule_ue_ul_spec_be" // best effort +}; uint16_t flexran_nb_rbs_allowed_slice_uplink(float rb_percentage, int total_rbs){ @@ -387,25 +396,26 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, void flexran_schedule_ue_ul_spec_default(mid_t mod_id, uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) + uint32_t cooperation_flag, + int subframe, + unsigned char sched_subframe, + Protocol__FlexranMessage **ul_info) //------------------------------------------------------------------------------ { int i=0; - flexran_agent_mac_create_empty_ul_config(module_idP, ul_info); + flexran_agent_mac_create_empty_ul_config(mod_id, ul_info); for (i = 0; i < n_active_slices; i++) { // Load any updated functions - if (update_dl_scheduler[i] > 0 ) { - slice_sched[i] = dlsym(NULL, dl_scheduler_type[i]); - update_dl_scheduler[i] = 0; - update_dl_scheduler_current[i] = 0; - slice_percentage_current[i]= slice_percentage[i]; - total_slice_percentage+=slice_percentage[i]; - LOG_N(MAC,"update dl scheduler slice %d\n", i); + if (update_ul_scheduler[i] > 0 ) { + slice_sched_ul[i] = dlsym(NULL, ul_scheduler_type[i]); + update_ul_scheduler[i] = 0; + update_ul_scheduler_current[i] = 0; + slice_percentage_current_uplink[i]= slice_percentage_uplink[i]; + total_slice_percentage_uplink+=slice_percentage_uplink[i]; + LOG_N(MAC,"update ul scheduler slice %d\n", i); } // check if the number of slices has changed, and log @@ -423,45 +433,45 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, } // check if the slice rb share has changed, and log the console - if (slice_percentage_current[i] != slice_percentage[i]){ - if ((slice_percentage[i] >= 0.0) && (slice_percentage[i] <= 1.0)){ - if ((total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]) <= 1.0) { - total_slice_percentage=total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]; + if (slice_percentage_current_uplink[i] != slice_percentage_uplink[i]){ + if ((slice_percentage_uplink[i] >= 0.0) && (slice_percentage_uplink[i] <= 1.0)){ + if ((total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i]) <= 1.0) { + total_slice_percentage_uplink=total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i]; LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", - mod_id, i, frame, subframe, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); + mod_id, i, frame, subframe, total_slice_percentage_uplink, slice_percentage_current_uplink[i], slice_percentage_uplink[i]); - slice_percentage_current[i] = slice_percentage[i]; + slice_percentage_current_uplink[i] = slice_percentage_uplink[i]; } else { LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", mod_id,i, - total_slice_percentage, - total_slice_percentage - slice_percentage_current[i] + slice_percentage[i], - slice_percentage[i],slice_percentage_current[i]); + total_slice_percentage_uplink, + total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i], + slice_percentage_uplink[i],slice_percentage_current_uplink[i]); - slice_percentage[i]= slice_percentage_current[i]; + slice_percentage_uplink[i]= slice_percentage_current_uplink[i]; } } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage[i],slice_percentage_current[i]); + LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage_uplink[i],slice_percentage_current_uplink[i]); - slice_percentage[i]= slice_percentage_current[i]; + slice_percentage_uplink[i]= slice_percentage_current_uplink[i]; } } // check if a new scheduler, and log the console - if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ + if (update_ul_scheduler_current[i] != update_ul_scheduler[i]){ LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", - mod_id, i, frame, subframe, dl_scheduler_type[i]); + mod_id, i, frame, subframe, ul_scheduler_type[i]); - update_dl_scheduler_current[i] = update_dl_scheduler[i]; + update_ul_scheduler_current[i] = update_ul_scheduler[i]; } // Run each enabled slice-specific schedulers one by one //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); - slice_sched[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); + slice_sched_ul[i](mod_id, frame, cooperation_flag, subframe, sched_subframe,ul_info); } @@ -469,7 +479,7 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, void flexran_schedule_ue_ul_spec_embb(mid_t mod_id, - frame_t frameP, + frame_t frame, unsigned char cooperation_flag, uint32_t subframe, unsigned char sched_subframe, @@ -583,7 +593,7 @@ void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, // LOG_I(MAC,"entering ulsch preprocesor\n"); - + /*TODO*/ int slice_id = 0; From 042a16d1f60c18487990a1f8ade9f48a76f2bb9d Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Thu, 18 May 2017 17:26:08 +0200 Subject: [PATCH 021/141] Fix percentage --- openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 9a9ecbb1e5..2abc6438c1 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -62,7 +62,7 @@ static int n_active_slices = 1; static int n_active_slices_current = 1; /* RB share for each slice for past and current time*/ -float slice_percentage_uplink[MAX_NUM_SLICES] = {0.8, 0.2, 0.0, 0.0}; +float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; float total_slice_percentage_uplink = 0; From 2e2b07ef9e4a4517f32153d1e47a876ad6d26d97 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Mon, 22 May 2017 19:19:28 +0200 Subject: [PATCH 022/141] push update load --- openair2/ENB_APP/flexran_agent_common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 78d3a75ec7..fe70a62ec8 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -26,8 +26,9 @@ * \version 0.1 */ -#include +#include #include +#include #include "flexran_agent_common.h" #include "flexran_agent_common_internal.h" @@ -386,13 +387,15 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_ Protocol__FlexControlDelegation *control_delegation_msg = input->control_delegation_msg; // struct timespec vartime = timer_start(); - + int status; //Write the payload lib into a file in the cache and load the lib char lib_name[120]; char target[512]; snprintf(lib_name, sizeof(lib_name), "/%s.so", control_delegation_msg->name); strcpy(target, local_cache); strcat(target, lib_name); + + status = mkdir(local_cache, S_IRWXU | S_IRWXG | S_IRWXO); FILE *f; f = fopen(target, "wb"); From 8458c8fcf82a401ceba3c9d58f8000d09f6cd8a0 Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Tue, 23 May 2017 23:46:31 +0200 Subject: [PATCH 023/141] uplink mac parser --- .../MAC/flexran_agent_mac_internal.c | 5 ++++- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 4 ++-- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 18 +++++++++--------- openair2/RRC/LITE/extern.h | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index 66efafae55..13b63b1494 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -607,7 +607,10 @@ int parse_mac_config(mid_t mod_id, yaml_parser_t *parser) { } else if (strcmp((char *) event.data.scalar.value, "ul_scheduler") == 0) { // Call the proper handler LOG_D(ENB_APP, "This is for the ul_scheduler subsystem\n"); - goto error; + if (parse_dl_scheduler_config(mod_id, parser) == -1) { + LOG_D(ENB_APP, "An error occured\n"); + goto error; + } // TODO } else if (strcmp((char *) event.data.scalar.value, "ra_scheduler") == 0) { // Call the proper handler diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index b30cb5f491..fce24223b5 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -88,8 +88,8 @@ typedef enum { // number of active slices for past and current time -static int n_active_slices = 1; -static int n_active_slices_current = 1; +int n_active_slices = 1; +int n_active_slices_current = 1; // ue to slice mapping int slicing_strategy = UEID_TO_SLICEID; diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 2abc6438c1..d8f9fe8e63 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -58,8 +58,8 @@ #include "T.h" /* number of active slices for past and current time*/ -static int n_active_slices = 1; -static int n_active_slices_current = 1; +int n_active_slices_uplink = 1; +int n_active_slices_uplink_current = 1; /* RB share for each slice for past and current time*/ float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; @@ -406,7 +406,7 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, flexran_agent_mac_create_empty_ul_config(mod_id, ul_info); - for (i = 0; i < n_active_slices; i++) { + for (i = 0; i < n_active_slices_uplink; i++) { // Load any updated functions if (update_ul_scheduler[i] > 0 ) { @@ -419,16 +419,16 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, } // check if the number of slices has changed, and log - if (n_active_slices_current != n_active_slices ){ - if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { + if (n_active_slices_uplink_current != n_active_slices_uplink ){ + if ((n_active_slices_uplink > 0) && (n_active_slices_uplink <= MAX_NUM_SLICES)) { LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active slices has changed: %d-->%d\n", - mod_id, frame, subframe, n_active_slices_current, n_active_slices); + mod_id, frame, subframe, n_active_slices_uplink_current, n_active_slices_uplink); - n_active_slices_current = n_active_slices; + n_active_slices_uplink_current = n_active_slices_uplink; } else { - LOG_W(MAC,"invalid number of slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); - n_active_slices = n_active_slices_current; + LOG_W(MAC,"invalid number of slices %d, revert to the previous value %d\n",n_active_slices_uplink, n_active_slices_uplink_current); + n_active_slices_uplink = n_active_slices_uplink_current; } } diff --git a/openair2/RRC/LITE/extern.h b/openair2/RRC/LITE/extern.h index d4c8192a95..7934690563 100644 --- a/openair2/RRC/LITE/extern.h +++ b/openair2/RRC/LITE/extern.h @@ -93,8 +93,8 @@ extern uint16_t N310[8]; extern uint16_t N311[8]; extern uint32_t T304[8]; extern uint32_t timeToTrigger_ms[16]; -extern float RSRP_meas_mapping[100]; -extern float RSRQ_meas_mapping[33]; +extern float RSRP_meas_mapping[98]; +extern float RSRQ_meas_mapping[35]; #endif From 1ecdcba33a88c56f9eceb62621f094a93daac80d Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Thu, 8 Jun 2017 18:36:25 +0200 Subject: [PATCH 024/141] uplink VSF --- cmake_targets/CMakeLists.txt | 3 + .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 4 +- .../MAC/flexran_agent_mac_defs.h | 4 +- .../MAC/flexran_agent_mac_internal.c | 107 +++++++++++++++++- .../MAC/flexran_agent_mac_internal.h | 4 + .../MAC/flexran_agent_scheduler_dlsch_ue.c | 38 +++---- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 72 ++++++------ 7 files changed, 174 insertions(+), 58 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 192590e20f..a04915bb53 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1231,6 +1231,9 @@ if (FLEXRAN_AGENT_SB_IF) add_library(default_sched SHARED ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue.c) add_library(remote_sched SHARED ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue_remote.c) +add_library(default_ul_sched SHARED ${MAC_DIR}/flexran_agent_scheduler_ulsch_ue.c) + + endif() # L3 Libs diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index f17fb9a1ba..512be68669 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1254,7 +1254,7 @@ int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->flexran_agent_get_pending_dl_mac_config = flexran_agent_get_pending_dl_mac_config; xface->dl_scheduler_loaded_lib = NULL; - + xface->ul_scheduler_loaded_lib = NULL; mac_agent_registered[mod_id] = 1; agent_mac_xface[mod_id] = xface; @@ -1272,7 +1272,7 @@ int flexran_agent_unregister_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->dl_scheduler_loaded_lib = NULL; - + xface->ul_scheduler_loaded_lib = NULL; mac_agent_registered[mod_id] = 0; agent_mac_xface[mod_id] = NULL; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h index 49ef7f0fb7..362c50f13c 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h @@ -62,8 +62,7 @@ typedef struct { void (*flexran_agent_schedule_ul_spec)(mid_t module_idP, uint32_t frameP, unsigned char cooperation_flag, - uint32_t subframeP, - unsigned char sched_subframe, Protocol__FlexranMessage **ul_info); + uint32_t subframeP, unsigned char sched_subframe, Protocol__FlexranMessage **ul_info); /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) @@ -72,6 +71,7 @@ typedef struct { void *dl_scheduler_loaded_lib; + void *ul_scheduler_loaded_lib; /*TODO: Fill in with the rest of the MAC layer technology specific callbacks (UL/DL scheduling, RACH info etc)*/ } AGENT_MAC_xface; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index 13b63b1494..68b82713e6 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -607,7 +607,7 @@ int parse_mac_config(mid_t mod_id, yaml_parser_t *parser) { } else if (strcmp((char *) event.data.scalar.value, "ul_scheduler") == 0) { // Call the proper handler LOG_D(ENB_APP, "This is for the ul_scheduler subsystem\n"); - if (parse_dl_scheduler_config(mod_id, parser) == -1) { + if (parse_ul_scheduler_config(mod_id, parser) == -1) { LOG_D(ENB_APP, "An error occured\n"); goto error; } @@ -703,6 +703,56 @@ int parse_dl_scheduler_config(mid_t mod_id, yaml_parser_t *parser) { return -1; } +int parse_ul_scheduler_config(mid_t mod_id, yaml_parser_t *parser) { + + yaml_event_t event; + + int done = 0; + int mapping_started = 0; + + while (!done) { + + if (!yaml_parser_parse(parser, &event)) + goto error; + + switch (event.type) { + // We are expecting a mapping (behavior and parameters) + case YAML_MAPPING_START_EVENT: + LOG_D(ENB_APP, "The mapping of the subsystem started\n"); + mapping_started = 1; + break; + case YAML_MAPPING_END_EVENT: + LOG_D(ENB_APP, "The mapping of the subsystem ended\n"); + mapping_started = 0; + break; + case YAML_SCALAR_EVENT: + if (!mapping_started) { + goto error; + } + // Check what key needs to be set + if (strcmp((char *) event.data.scalar.value, "parameters") == 0) { + LOG_D(ENB_APP, "Now it is time to set the parameters for this subsystem\n"); + if (parse_ul_scheduler_parameters(mod_id, parser) == -1) { + goto error; + } + } + break; + default: + goto error; + } + + done = (event.type == YAML_MAPPING_END_EVENT); + yaml_event_delete(&event); + } + + return 0; + + error: + yaml_event_delete(&event); + return -1; +} + + int parse_dl_scheduler_parameters(mid_t mod_id, yaml_parser_t *parser) { yaml_event_t event; @@ -758,6 +808,61 @@ int parse_dl_scheduler_parameters(mid_t mod_id, yaml_parser_t *parser) { return -1; } +int parse_ul_scheduler_parameters(mid_t mod_id, yaml_parser_t *parser) { + yaml_event_t event; + + void *param; + + int done = 0; + int mapping_started = 0; + + while (!done) { + + if (!yaml_parser_parse(parser, &event)) + goto error; + + switch (event.type) { + // We are expecting a mapping of parameters + case YAML_MAPPING_START_EVENT: + LOG_D(ENB_APP, "The mapping of the parameters started\n"); + mapping_started = 1; + break; + case YAML_MAPPING_END_EVENT: + LOG_D(ENB_APP, "The mapping of the parameters ended\n"); + mapping_started = 0; + break; + case YAML_SCALAR_EVENT: + if (!mapping_started) { + goto error; + } + // Check what key needs to be set + if (mac_agent_registered[mod_id]) { + LOG_D(ENB_APP, "Setting parameter %s\n", event.data.scalar.value); + param = dlsym(agent_mac_xface[mod_id]->ul_scheduler_loaded_lib, + (char *) event.data.scalar.value); + if (param == NULL) { + goto error; + } + apply_parameter_modification(param, parser); + } else { + goto error; + } + break; + default: + goto error; + } + + done = (event.type == YAML_MAPPING_END_EVENT); + yaml_event_delete(&event); + } + + return 0; + + error: + yaml_event_delete(&event); + return -1; +} + int load_dl_scheduler_function(mid_t mod_id, const char *function_name) { void *lib; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.h index 9a7d4a8555..95f6934e56 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.h @@ -101,6 +101,10 @@ int parse_dl_scheduler_config(mid_t mod_id, yaml_parser_t *parser); int parse_dl_scheduler_parameters(mid_t mod_id, yaml_parser_t *parser); +int parse_ul_scheduler_config(mid_t mod_id, yaml_parser_t *parser); + +int parse_ul_scheduler_parameters(mid_t mod_id, yaml_parser_t *parser); + int load_dl_scheduler_function(mid_t mod_id, const char *function_name); #endif /*FLEXRAN_AGENT_MAC_INTERNAL_H_*/ diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index fce24223b5..ade4b77c14 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -88,16 +88,16 @@ typedef enum { // number of active slices for past and current time -int n_active_slices = 1; -int n_active_slices_current = 1; +int n_active_slices = 2; +int n_active_slices_current = 2; // ue to slice mapping int slicing_strategy = UEID_TO_SLICEID; int slicing_strategy_current = UEID_TO_SLICEID; // RB share for each slice for past and current time -float slice_percentage[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; -float slice_percentage_current[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; +float slice_percentage_current[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; float total_slice_percentage = 0; // MAX MCS for each slice for past and current time @@ -753,30 +753,30 @@ flexran_schedule_ue_dl_spec_default(mid_t mod_id, // check if the slice rb share has changed, and log the console if (slice_percentage_current[i] != slice_percentage[i]){ - if ((slice_percentage[i] >= 0.0) && (slice_percentage[i] <= 1.0)){ - if ((total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]) <= 1.0) { - total_slice_percentage=total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]; + // if ((slice_percentage[i] >= 0.0) && (slice_percentage[i] <= 1.0)){ + // if ((total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]) <= 1.0) { + // total_slice_percentage=total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]; LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", mod_id, i, frame, subframe, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); slice_percentage_current[i] = slice_percentage[i]; - } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", - mod_id,i, - total_slice_percentage, - total_slice_percentage - slice_percentage_current[i] + slice_percentage[i], - slice_percentage[i],slice_percentage_current[i]); + // } else { + // LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", + // mod_id,i, + // total_slice_percentage, + // total_slice_percentage - slice_percentage_current[i] + slice_percentage[i], + // slice_percentage[i],slice_percentage_current[i]); - slice_percentage[i]= slice_percentage_current[i]; + // slice_percentage[i]= slice_percentage_current[i]; - } - } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage[i],slice_percentage_current[i]); + // } + // } else { + // LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage[i],slice_percentage_current[i]); - slice_percentage[i]= slice_percentage_current[i]; + // slice_percentage[i]= slice_percentage_current[i]; - } + // } } // check if the slice max MCS, and log the console diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index d8f9fe8e63..b0e7272e9d 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -58,16 +58,16 @@ #include "T.h" /* number of active slices for past and current time*/ -int n_active_slices_uplink = 1; -int n_active_slices_uplink_current = 1; +int n_active_slices_uplink = 2; +int n_active_slices_uplink_current = 2; /* RB share for each slice for past and current time*/ -float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; -float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage_uplink[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; +float slice_percentage_current_uplink[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; float total_slice_percentage_uplink = 0; /*resource blocks allowed*/ -static uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; +uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; /*Slice Update */ int update_ul_scheduler[MAX_NUM_SLICES] = {1, 1, 1, 1}; int update_ul_scheduler_current[MAX_NUM_SLICES] = {1, 1, 1, 1}; @@ -144,7 +144,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, su 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]; - nb_rbs_allowed_slice[CC_id][UE_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[UE_id], flexran_get_N_RB_UL(module_idP, CC_id)); + nb_rbs_allowed_slice_uplink[CC_id][UE_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[UE_id], flexran_get_N_RB_UL(module_idP, CC_id)); // if this UE has UL traffic if (UE_template->ul_total_buffer > 0 ) { @@ -161,7 +161,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, su } while ((tbs < UE_template->ul_total_buffer) && - (rb_table[rb_table_index]<(nb_rbs_allowed_slice[CC_id][UE_id]-first_rb[CC_id])) && + (rb_table[rb_table_index]<(nb_rbs_allowed_slice_uplink[CC_id][UE_id]-first_rb[CC_id])) && ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { // LOG_I(MAC,"tbs %d ul buffer %d rb table %d max ul rb %d\n", tbs, UE_template->ul_total_buffer, rb_table[rb_table_index], frame_parms->N_RB_UL-first_rb[CC_id]); @@ -172,7 +172,7 @@ void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, su UE_template->ue_tx_power = tx_power; - if (rb_table[rb_table_index]>(nb_rbs_allowed_slice[CC_id][UE_id]-first_rb[CC_id]-1)) { + if (rb_table[rb_table_index]>(nb_rbs_allowed_slice_uplink[CC_id][UE_id]-first_rb[CC_id]-1)) { rb_table_index--; } @@ -212,7 +212,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, uint16_t UE_id,n,r; uint8_t CC_id, round, harq_pid; uint16_t nb_allocated_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX],total_allocated_rbs[MAX_NUM_CCs],average_rbs_per_user[MAX_NUM_CCs]; - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; + uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; int16_t total_remaining_rbs[MAX_NUM_CCs]; uint16_t max_num_ue_to_be_scheduled=0,total_ue_count=0; rnti_t rnti= -1; @@ -281,17 +281,17 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, max_num_ue_to_be_scheduled+=1; - nb_rbs_allowed_slice[CC_id][UE_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[UE_id], flexran_get_N_RB_UL(module_idP, CC_id)); + nb_rbs_allowed_slice_uplink[CC_id][UE_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[UE_id], flexran_get_N_RB_UL(module_idP, CC_id)); if (total_ue_count == 0) { average_rbs_per_user[CC_id] = 0; } else if (total_ue_count == 1 ) { // increase the available RBs, special case, - average_rbs_per_user[CC_id] = nb_rbs_allowed_slice[CC_id][i]-first_rb[CC_id]+1; - } else if( (total_ue_count <= (nb_rbs_allowed_slice[CC_id][i]-first_rb[CC_id])) && + average_rbs_per_user[CC_id] = nb_rbs_allowed_slice_uplink[CC_id][i]-first_rb[CC_id]+1; + } else if( (total_ue_count <= (nb_rbs_allowed_slice_uplink[CC_id][i]-first_rb[CC_id])) && (total_ue_count <= max_num_ue_to_be_scheduled)) { - average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice[CC_id][i]-first_rb[CC_id])/total_ue_count); + average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice_uplink[CC_id][i]-first_rb[CC_id])/total_ue_count); } else if (max_num_ue_to_be_scheduled > 0 ) { - average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice[CC_id][slice_id]-first_rb[CC_id])/max_num_ue_to_be_scheduled); + average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice_uplink[CC_id][i]-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", @@ -322,7 +322,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][UE_id]; + ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice_uplink[CC_id][UE_id]; // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); flexran_get_harq(module_idP, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_UL); if(round>0) { @@ -356,7 +356,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, CC_id = UE_list->ordered_ULCCids[n][UE_id]; UE_template = &UE_list->UE_template[CC_id][UE_id]; frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); - total_remaining_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][UE_id] - first_rb[CC_id] - total_allocated_rbs[CC_id]; + total_remaining_rbs[CC_id]=nb_rbs_allowed_slice_uplink[CC_id][UE_id] - first_rb[CC_id] - total_allocated_rbs[CC_id]; if (total_ue_count == 1 ) { total_remaining_rbs[CC_id]+=1; @@ -383,7 +383,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, frame_parms= mac_xface->get_lte_frame_parms(module_idP,CC_id); 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], nb_rbs_allowed_slice[CC_id][slice_id] - first_rb[CC_id]); + LOG_D(MAC,"[eNB %d] total RB allocated for all UEs = %d/%d\n", module_idP, total_allocated_rbs[CC_id], nb_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id]); } } } @@ -434,30 +434,30 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, // check if the slice rb share has changed, and log the console if (slice_percentage_current_uplink[i] != slice_percentage_uplink[i]){ - if ((slice_percentage_uplink[i] >= 0.0) && (slice_percentage_uplink[i] <= 1.0)){ - if ((total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i]) <= 1.0) { - total_slice_percentage_uplink=total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i]; + // if ((slice_percentage_uplink[i] >= 0.0) && (slice_percentage_uplink[i] <= 1.0)){ + // if ((total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i]) <= 1.0) { + // total_slice_percentage_uplink=total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i]; LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", mod_id, i, frame, subframe, total_slice_percentage_uplink, slice_percentage_current_uplink[i], slice_percentage_uplink[i]); slice_percentage_current_uplink[i] = slice_percentage_uplink[i]; - } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", - mod_id,i, - total_slice_percentage_uplink, - total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i], - slice_percentage_uplink[i],slice_percentage_current_uplink[i]); + // } else { + // LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", + // mod_id,i, + // total_slice_percentage_uplink, + // total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i], + // slice_percentage_uplink[i],slice_percentage_current_uplink[i]); - slice_percentage_uplink[i]= slice_percentage_current_uplink[i]; + // slice_percentage_uplink[i]= slice_percentage_current_uplink[i]; - } - } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage_uplink[i],slice_percentage_current_uplink[i]); + // } + // } else { + // LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage_uplink[i],slice_percentage_current_uplink[i]); - slice_percentage_uplink[i]= slice_percentage_current_uplink[i]; + // slice_percentage_uplink[i]= slice_percentage_current_uplink[i]; - } + // } } // check if a new scheduler, and log the console @@ -471,9 +471,13 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, // Run each enabled slice-specific schedulers one by one //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); - slice_sched_ul[i](mod_id, frame, cooperation_flag, subframe, sched_subframe,ul_info); + + + } + + slice_sched_ul[0](mod_id, frame, cooperation_flag, subframe, sched_subframe,ul_info); } @@ -765,7 +769,7 @@ abort(); UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; // buffer_occupancy = UE_template->ul_total_buffer; - while (((rb_table[rb_table_index]>(nb_rbs_allowed_slice[CC_id][UE_id]-1-first_rb[CC_id])) || + while (((rb_table[rb_table_index]>(nb_rbs_allowed_slice_uplink[CC_id][UE_id]-1-first_rb[CC_id])) || (rb_table[rb_table_index]>45)) && (rb_table_index>0)) { rb_table_index--; From f7e376ed5f5e05c6f3e4f678520cee1982dc5a5b Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Fri, 14 Jul 2017 12:52:51 +0300 Subject: [PATCH 025/141] Added support of FlexRAN agent compilation for oaisim with S1 enabled --- cmake_targets/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 8f90141618..7c9855b29a 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1846,12 +1846,12 @@ add_executable(oaisim target_include_directories(oaisim PUBLIC ${OPENAIR_TARGETS}/SIMU/USER) target_link_libraries (oaisim -Wl,-ldl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} LIB_NAS_UE SIMU SIMU_ETH SECU_OSA ${ITTI_LIB} ${MIH_LIB} + RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} LIB_NAS_UE SIMU SIMU_ETH SECU_OSA ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 -Wl,--end-group ) target_link_libraries (oaisim ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES}) target_link_libraries (oaisim pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp - ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${OPENPGM_LIBRARIES}) + ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${OPENPGM_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) #Force link with forms, regardless XFORMS option target_link_libraries (oaisim forms) target_link_libraries (oaisim ${T_LIB}) From e51d8d3fd73d35fff38fd5306c011d2a68b4f001 Mon Sep 17 00:00:00 2001 From: Anta Huang Date: Thu, 20 Jul 2017 13:24:16 +0200 Subject: [PATCH 026/141] Add the slice_maxmcs_uplink to flexran agent ulsch --- openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index b0e7272e9d..86bb2407b6 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -66,6 +66,10 @@ float slice_percentage_uplink[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; float slice_percentage_current_uplink[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; float total_slice_percentage_uplink = 0; +// MAX MCS for each slice for past and current time +int slice_maxmcs_uplink[MAX_NUM_SLICES] = {16, 16, 16, 16}; +int slice_maxmcs_current_uplink[MAX_NUM_SLICES] = {28, 28, 28, 28}; + /*resource blocks allowed*/ uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; /*Slice Update */ From 9e7e57de74fd06ac02023a4097435cd9c1be05a8 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Tue, 25 Jul 2017 19:12:42 +0200 Subject: [PATCH 027/141] DL Fixed Bug get TBS --- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 550 +++++++++--------- 1 file changed, 280 insertions(+), 270 deletions(-) diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index ade4b77c14..e47adc4fdb 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -284,7 +284,7 @@ void _assign_rbs_required (module_id_t Mod_id, nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; if (nb_rbs_required[CC_id][UE_id] > nb_rbs_allowed_slice[CC_id][slice_id]) { - TBS = mac_xface->get_TBS_DL(flexran_get_ue_wcqi(Mod_id, UE_id), nb_rbs_allowed_slice[CC_id][slice_id]); + TBS = mac_xface->get_TBS_DL(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_allowed_slice[CC_id][slice_id]); nb_rbs_required[CC_id][UE_id] = nb_rbs_allowed_slice[CC_id][slice_id]; break; } @@ -495,7 +495,7 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, } } - // Store the DLSCH buffer for each logical channel + /* Store the DLSCH buffer for each logical channel for each UE */ _store_dlsch_buffer (Mod_id,slice_id,frameP,subframeP); // Calculate the number of RBs required by each UE on the basis of logical channel's buffer @@ -1044,9 +1044,10 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; if (eNB_UE_stats==NULL) { - LOG_D(MAC,"[eNB] Cannot find eNB_UE_stats\n"); - // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - continue; + + LOG_D(MAC,"[eNB] Cannot find eNB_UE_stats\n"); + // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); + continue; } if (flexran_slice_member(UE_id, slice_id) == 0) @@ -1062,28 +1063,29 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, case 1: case 2: case 7: - aggregation = get_aggregation(get_bw_index(mod_id,CC_id), + aggregation = get_aggregation(get_bw_index(mod_id,CC_id), eNB_UE_stats->DL_cqi[0], format1); - break; + break; case 3: - aggregation = get_aggregation(get_bw_index(mod_id,CC_id), + aggregation = get_aggregation(get_bw_index(mod_id,CC_id), eNB_UE_stats->DL_cqi[0], format2A); - break; + break; default: - LOG_W(MAC,"Unsupported transmission mode %d\n", mac_xface->get_transmission_mode(mod_id,CC_id,rnti)); - aggregation = 2; + LOG_W(MAC,"Unsupported transmission mode %d\n", mac_xface->get_transmission_mode(mod_id,CC_id,rnti)); + aggregation = 2; } if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated CCE_allocation_infeasible(mod_id, CC_id, 0, subframe, aggregation, rnti)) { - LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", - mod_id, frame, UE_id, CC_id); - //if(mac_xface->get_transmission_mode(module_idP,rnti)==5) - continue; //to next user (there might be rbs availiable for other UEs in TM5 - // else - // break; + + LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", + mod_id, frame, UE_id, CC_id); + //if(mac_xface->get_transmission_mode(module_idP,rnti)==5) + continue; //to next user (there might be rbs availiable for other UEs in TM5 + // else + // break; } if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { @@ -1106,26 +1108,28 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, dl_data[num_ues_added]->n_rlc_pdu = 0; dl_data[num_ues_added]->has_serv_cell_index = 1; dl_data[num_ues_added]->serv_cell_index = CC_id; - - nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; + flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round, openair_harq_DL); sdu_length_total=0; mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; // LOG_I(FLEXRAN_AGENT, "The MCS is %d\n", mcs); mcs = cmin(mcs,flexran_slice_maxmcs(slice_id)); -#ifdef EXMIMO +// #ifdef EXMIMO - if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti) == 5) { - mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; - mcs = cmin(mcs,16); - } +// if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti) == 5) { +// mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; +// mcs = cmin(mcs,16); +// } -#endif +// #endif + /*Get pre available resource blocks based on buffers*/ + nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; // initializing the rb allocation indicator for each UE for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0; - rballoc_sub[j] = 0; + + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0; + rballoc_sub[j] = 0; } /* LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", */ @@ -1146,72 +1150,74 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, /* process retransmission */ if (round > 0) { - LOG_D(FLEXRAN_AGENT, "There was a retransmission just now and the round was %d\n", round); + LOG_D(FLEXRAN_AGENT, "There was a retransmission just now and the round was %d\n", round); - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); - LOG_D(MAC,"DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", - CC_id, subframe,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); - } + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); + LOG_D(MAC,"DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframe,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); + } - mcs = UE_list->UE_template[CC_id][UE_id].mcs[harq_pid]; + mcs = UE_list->UE_template[CC_id][UE_id].mcs[harq_pid]; - // get freq_allocation - nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - - /*TODO: Must add this to FlexRAN agent API */ - dci_tbs = mac_xface->get_TBS_DL(mcs, nb_rb); + // get freq_allocation + nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + + /*TODO: Must add this to FlexRAN agent API */ + dci_tbs = mac_xface->get_TBS_DL(mcs, nb_rb); - if (nb_rb <= nb_available_rb) { - - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; + if (nb_rb <= nb_available_rb) { + + if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; - while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && - ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| - (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; - } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; - } - } - j = j + 1; - } - } + while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { + if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && + ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| + (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { + nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; + } else { + nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; + } + } + j = j + 1; + } + } - nb_available_rb -= nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j=0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } + nb_available_rb -= nb_rb; + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; + + for(j=0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { + PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } - // Keep the old NDI, do not toggle - ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - tpc = UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid]; - UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; + // Keep the old NDI, do not toggle + ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + tpc = UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid]; + UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; - ue_has_transmission = 1; - num_ues_added++; - } else { - LOG_D(MAC,"[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", - mod_id, frame, CC_id, UE_id); - ue_has_transmission = 0; - } - //End of retransmission - } else { /* This is a potentially new SDU opportunity */ + ue_has_transmission = 1; + num_ues_added++; + } else { + LOG_D(MAC,"[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", + mod_id, frame, CC_id, UE_id); + ue_has_transmission = 0; + } + //End of retransmission + } + + else { /* This is a potentially new SDU opportunity */ rlc_status.bytes_in_buffer = 0; // Now check RLC information to compute number of required RBs // get maximum TBS size for RLC request @@ -1265,11 +1271,14 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, //Fill in as much as possible data_to_request = cmin(dci_tbs - ta_len - header_len - sdu_length_total, rlc_status.bytes_in_buffer); LOG_D(FLEXRAN_AGENT, "Will request %d bytes from channel %d\n", data_to_request, j); + if (data_to_request < 128) { //The header will be one byte less - header_len--; - header_len_last = 2; - } else { - header_len_last = 3; + header_len--; + header_len_last = 2; + } + else { + + header_len_last = 3; } /* if (j == 1 || j == 2) { data_to_request+=0; @@ -1364,7 +1373,8 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; } - } else { + } + else { nb_rb_temp = nb_rb; j = 0; LOG_D(MAC, "[TEST]Will only partially fill the bitmap\n"); @@ -1412,12 +1422,12 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - UE_list->UE_template[CC_id][UE_id].DAI++; - // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); + // if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + // UE_list->UE_template[CC_id][UE_id].DAI++; + // // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); //#warning only for 5MHz channel - update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); - } + // update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); + // } // do PUCCH power control // this is the normalized RX power @@ -1475,189 +1485,189 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, ue_has_transmission = 0; } } // End of new scheduling - + // If we has transmission or retransmission if (ue_has_transmission) { - switch (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)) { - case 1: - case 2: - default: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->n_tbs_size = 1; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 3: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 2; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->ndi[1] = ndi; - dl_dci->n_rv = 2; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->rv[1] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 2; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->mcs[1] = mcs; - dl_dci->n_tbs_size = 2; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - dl_dci->tbs_size[1] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 4: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 2; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->ndi[1] = ndi; - dl_dci->n_rv = 2; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->rv[1] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 2; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->mcs[1] = mcs; - dl_dci->n_tbs_size = 2; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - dl_dci->tbs_size[1] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 5: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->n_tbs_size = 1; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - - if(ue_sched_ctl->dl_pow_off[CC_id] == 2) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - - dl_dci->has_dl_power_offset = 1; - dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; - dl_dci->has_precoding_info = 1; - dl_dci->precoding_info = 5; // Is this right?? - - break; - case 6: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } + switch (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)) { + case 1: + case 2: + default: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->n_tbs_size = 1; + dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + break; + case 3: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 2; + dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->ndi[1] = ndi; + dl_dci->n_rv = 2; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->rv[1] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 2; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->mcs[1] = mcs; + dl_dci->n_tbs_size = 2; + dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + dl_dci->tbs_size[1] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + break; + case 4: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 2; + dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->ndi[1] = ndi; + dl_dci->n_rv = 2; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->rv[1] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 2; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->mcs[1] = mcs; + dl_dci->n_tbs_size = 2; + dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + dl_dci->tbs_size[1] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + break; + case 5: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->n_tbs_size = 1; + dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } + + if(ue_sched_ctl->dl_pow_off[CC_id] == 2) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + + dl_dci->has_dl_power_offset = 1; + dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; + dl_dci->has_precoding_info = 1; + dl_dci->precoding_info = 5; // Is this right?? + + break; + case 6: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + } - dl_dci->has_dl_power_offset = 1; - dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; - dl_dci->has_precoding_info = 1; - dl_dci->precoding_info = 5; // Is this right?? - break; - } + dl_dci->has_dl_power_offset = 1; + dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; + dl_dci->has_precoding_info = 1; + dl_dci->precoding_info = 5; // Is this right?? + break; + } } - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + // if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { /* TODO */ //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe, frame_parms); - } + // } } // UE_id loop } // CC_id loop From 8e5b17404787e09decc13d2d649993610a394c7f Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Fri, 4 Aug 2017 16:02:17 +0200 Subject: [PATCH 028/141] merge to 68 --- .../LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c | 8 ++++---- .../LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index e47adc4fdb..02fe873144 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -88,16 +88,16 @@ typedef enum { // number of active slices for past and current time -int n_active_slices = 2; -int n_active_slices_current = 2; +int n_active_slices = 1; +int n_active_slices_current = 1; // ue to slice mapping int slicing_strategy = UEID_TO_SLICEID; int slicing_strategy_current = UEID_TO_SLICEID; // RB share for each slice for past and current time -float slice_percentage[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; -float slice_percentage_current[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; +float slice_percentage[MAX_NUM_SLICES] = {1.0, 1.0, 0.0, 0.0}; +float slice_percentage_current[MAX_NUM_SLICES] = {1.0, 1.0, 0.0, 0.0}; float total_slice_percentage = 0; // MAX MCS for each slice for past and current time diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 86bb2407b6..4038ae518b 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -58,12 +58,12 @@ #include "T.h" /* number of active slices for past and current time*/ -int n_active_slices_uplink = 2; -int n_active_slices_uplink_current = 2; +int n_active_slices_uplink = 1; +int n_active_slices_uplink_current = 1; /* RB share for each slice for past and current time*/ -float slice_percentage_uplink[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; -float slice_percentage_current_uplink[MAX_NUM_SLICES] = {0.5, 0.5, 0.0, 0.0}; +float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 1.0, 0.0, 0.0}; +float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 1.0, 0.0, 0.0}; float total_slice_percentage_uplink = 0; // MAX MCS for each slice for past and current time @@ -477,11 +477,11 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); - + slice_sched_ul[i](mod_id, frame, cooperation_flag, subframe, sched_subframe,ul_info); } - slice_sched_ul[0](mod_id, frame, cooperation_flag, subframe, sched_subframe,ul_info); + } From d12f55d2ed2c3b55d5dd140c130708fd5854a482 Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Fri, 4 Aug 2017 16:22:57 +0200 Subject: [PATCH 029/141] add operating downlink frequency --- openair2/ENB_APP/MESSAGES/V2/config_messages.proto | 1 + openair2/ENB_APP/flexran_agent_common.c | 4 ++++ openair2/ENB_APP/flexran_agent_ran_api.c | 8 ++++++++ openair2/ENB_APP/flexran_agent_ran_api.h | 5 ++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto index 441e193569..c21fee213b 100644 --- a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto +++ b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto @@ -38,6 +38,7 @@ message flex_cell_config { optional uint32 srs_mac_up_pts = 32; // Boolean value. See TS 36.211, section 5.5.3.2. TDD only optional uint32 enable_64QAM = 33; // One of the FLEQ_* enum values optional uint32 carrier_index = 34; // Carrier component index + optional uint32 op_dl_freq = 35; // operating downlink frequency } message flex_ue_config { diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index fe70a62ec8..4067145dfd 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -1013,6 +1013,10 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F cell_conf[i]->srs_mac_up_pts = flexran_get_srs_MaxUpPts(enb_id,i); cell_conf[i]->has_srs_mac_up_pts = 1; + + cell_conf[i]->op_dl_freq = flexran_agent_get_operating_dl_freq (0); + cell_conf[i]->has_op_dl_freq = 1; + if (flexran_get_enable64QAM(enb_id,i) == 0) { cell_conf[i]->enable_64qam = PROTOCOL__FLEX_QAM__FLEQ_MOD_16QAM; } else if(flexran_get_enable64QAM(enb_id,i) == 1) { diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index ae304d1e26..685a3bf57e 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -956,3 +956,11 @@ int flexran_get_antenna_ports(mid_t mod_id, int CC_id){ return frame_parms->nb_antenna_ports_eNB; } + + +float flexran_agent_get_operating_dl_freq (mid_t cc_id) { + const Enb_properties_array_t* enb_properties = enb_config_get(); + return (enb_properties->properties[0]->downlink_frequency[cc_id] / 1000000); +} + + diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index e80ed44ce9..ed2a2a1fd5 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -298,4 +298,7 @@ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id); int flexran_get_lcg(mid_t ue_id, mid_t lc_id); /* Get direction of logical channel with id lc_id */ -int flexran_get_direction(mid_t ue_id, mid_t lc_id); \ No newline at end of file +int flexran_get_direction(mid_t ue_id, mid_t lc_id); + +/*Gety downlink frequency*/ +float flexran_agent_get_operating_dl_freq (mid_t cc_id); \ No newline at end of file From 3cc3762ed9d63b6e5bec5c0ea3c29d1c852992be Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Fri, 4 Aug 2017 16:27:15 +0200 Subject: [PATCH 030/141] carrier index --- openair2/ENB_APP/flexran_agent_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 4067145dfd..df350e5d69 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -1014,7 +1014,7 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F cell_conf[i]->has_srs_mac_up_pts = 1; - cell_conf[i]->op_dl_freq = flexran_agent_get_operating_dl_freq (0); + cell_conf[i]->op_dl_freq = flexran_agent_get_operating_dl_freq (i); cell_conf[i]->has_op_dl_freq = 1; if (flexran_get_enable64QAM(enb_id,i) == 0) { From 863e9404fcbe4610e53f6539ca444cf90320c51f Mon Sep 17 00:00:00 2001 From: Anta Huang Date: Fri, 4 Aug 2017 17:42:32 +0200 Subject: [PATCH 031/141] Add additional cell config info to flexran API and message --- .../ENB_APP/MESSAGES/V2/config_messages.proto | 4 ++++ openair2/ENB_APP/flexran_agent_common.c | 16 +++++++++++-- openair2/ENB_APP/flexran_agent_ran_api.c | 23 +++++++++++++++++-- openair2/ENB_APP/flexran_agent_ran_api.h | 16 +++++++++++-- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto index c21fee213b..f19de4923f 100644 --- a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto +++ b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto @@ -39,6 +39,10 @@ message flex_cell_config { optional uint32 enable_64QAM = 33; // One of the FLEQ_* enum values optional uint32 carrier_index = 34; // Carrier component index optional uint32 op_dl_freq = 35; // operating downlink frequency + optional uint32 op_ul_freq = 36; // operating uplink frequency + optional uint32 op_eutra_band= 37; // operating band + optional int32 op_dl_pdsch_power = 38; // operating downlink power + optional int32 op_ul_pusch_power = 39; // operating uplink power } message flex_ue_config { diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index df350e5d69..d71e9496c8 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -1013,10 +1013,22 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F cell_conf[i]->srs_mac_up_pts = flexran_get_srs_MaxUpPts(enb_id,i); cell_conf[i]->has_srs_mac_up_pts = 1; - - cell_conf[i]->op_dl_freq = flexran_agent_get_operating_dl_freq (i); + cell_conf[i]->op_dl_freq = flexran_agent_get_operating_dl_freq (enb_id,i); cell_conf[i]->has_op_dl_freq = 1; + cell_conf[i]->op_ul_freq = flexran_agent_get_operating_ul_freq (enb_id, i); + cell_conf[i]->has_op_ul_freq = 1; + + cell_conf[i]->op_eutra_band = flexran_agent_get_operating_eutra_band (enb_id,i); + cell_conf[i]->has_op_eutra_band = 1; + + cell_conf[i]->op_dl_pdsch_power = flexran_agent_get_operating_pdsch_refpower(enb_id, i); + cell_conf[i]->has_op_dl_pdsch_power = 1; + + cell_conf[i]->op_ul_pusch_power = flexran_agent_get_operating_pusch_p0 (enb_id,i); + cell_conf[i]->has_op_ul_pusch_power = 1; + + if (flexran_get_enable64QAM(enb_id,i) == 0) { cell_conf[i]->enable_64qam = PROTOCOL__FLEX_QAM__FLEQ_MOD_16QAM; } else if(flexran_get_enable64QAM(enb_id,i) == 1) { diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 685a3bf57e..10b667e916 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -958,9 +958,28 @@ int flexran_get_antenna_ports(mid_t mod_id, int CC_id){ } -float flexran_agent_get_operating_dl_freq (mid_t cc_id) { +float flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id) { const Enb_properties_array_t* enb_properties = enb_config_get(); - return (enb_properties->properties[0]->downlink_frequency[cc_id] / 1000000); + return (enb_properties->properties[mod_id]->downlink_frequency[cc_id] / 1000000); +} + +float flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id) { + const Enb_properties_array_t* enb_properties = enb_config_get(); + return ((enb_properties->properties[mod_id] ->downlink_frequency[cc_id] + enb_properties->properties[0]->uplink_frequency_offset[cc_id]) / 1000000); +} + +int flexran_agent_get_operating_eutra_band (mid_t mod_id, int cc_id) { + const Enb_properties_array_t* enb_properties = enb_config_get(); + return enb_properties->properties[mod_id]->eutra_band[cc_id]; +} +int flexran_agent_get_operating_pdsch_refpower (mid_t mod_id, int cc_id) { + const Enb_properties_array_t* enb_properties = enb_config_get(); + return enb_properties->properties[mod_id]->pdsch_referenceSignalPower[cc_id]; +} +int flexran_agent_get_operating_pusch_p0 (mid_t mod_id, int cc_id) { + const Enb_properties_array_t* enb_properties = enb_config_get(); + return enb_properties->properties[mod_id]->pusch_p0_Nominal[cc_id]; } + diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index ed2a2a1fd5..668c0e6ba0 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -300,5 +300,17 @@ int flexran_get_lcg(mid_t ue_id, mid_t lc_id); /* Get direction of logical channel with id lc_id */ int flexran_get_direction(mid_t ue_id, mid_t lc_id); -/*Gety downlink frequency*/ -float flexran_agent_get_operating_dl_freq (mid_t cc_id); \ No newline at end of file +/*Get downlink frequency*/ +float flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id); + +/*Get uplink frequency*/ +float flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id); + +/*Get eutra band*/ +int flexran_agent_get_operating_eutra_band (mid_t mod_id, int cc_id); + +/*Get downlink ref signal power*/ +int flexran_agent_get_operating_pdsch_refpower (mid_t mod_id, int cc_id); + +/*Get uplink power*/ +int flexran_agent_get_operating_pusch_p0 (mid_t mod_id, int cc_id); From 1e857d5ba5a22789a9e302487905dc908ffe5a71 Mon Sep 17 00:00:00 2001 From: Anta Huang Date: Fri, 4 Aug 2017 18:19:38 +0200 Subject: [PATCH 032/141] Update the naming of cell config parameters --- .../ENB_APP/MESSAGES/V2/config_messages.proto | 10 +++++----- openair2/ENB_APP/flexran_agent_common.c | 20 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto index f19de4923f..1be6f7f43a 100644 --- a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto +++ b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto @@ -38,11 +38,11 @@ message flex_cell_config { optional uint32 srs_mac_up_pts = 32; // Boolean value. See TS 36.211, section 5.5.3.2. TDD only optional uint32 enable_64QAM = 33; // One of the FLEQ_* enum values optional uint32 carrier_index = 34; // Carrier component index - optional uint32 op_dl_freq = 35; // operating downlink frequency - optional uint32 op_ul_freq = 36; // operating uplink frequency - optional uint32 op_eutra_band= 37; // operating band - optional int32 op_dl_pdsch_power = 38; // operating downlink power - optional int32 op_ul_pusch_power = 39; // operating uplink power + optional uint32 dl_freq = 35; // operating downlink frequency + optional uint32 ul_freq = 36; // operating uplink frequency + optional uint32 eutra_band= 37; // operating band + optional int32 dl_pdsch_power = 38; // operating downlink power + optional int32 ul_pusch_power = 39; // operating uplink power } message flex_ue_config { diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index d71e9496c8..e3f96c05dc 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -1013,20 +1013,20 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F cell_conf[i]->srs_mac_up_pts = flexran_get_srs_MaxUpPts(enb_id,i); cell_conf[i]->has_srs_mac_up_pts = 1; - cell_conf[i]->op_dl_freq = flexran_agent_get_operating_dl_freq (enb_id,i); - cell_conf[i]->has_op_dl_freq = 1; + cell_conf[i]->dl_freq = flexran_agent_get_operating_dl_freq (enb_id,i); + cell_conf[i]->has_dl_freq = 1; - cell_conf[i]->op_ul_freq = flexran_agent_get_operating_ul_freq (enb_id, i); - cell_conf[i]->has_op_ul_freq = 1; + cell_conf[i]->ul_freq = flexran_agent_get_operating_ul_freq (enb_id, i); + cell_conf[i]->has_ul_freq = 1; - cell_conf[i]->op_eutra_band = flexran_agent_get_operating_eutra_band (enb_id,i); - cell_conf[i]->has_op_eutra_band = 1; + cell_conf[i]->eutra_band = flexran_agent_get_operating_eutra_band (enb_id,i); + cell_conf[i]->has_eutra_band = 1; - cell_conf[i]->op_dl_pdsch_power = flexran_agent_get_operating_pdsch_refpower(enb_id, i); - cell_conf[i]->has_op_dl_pdsch_power = 1; + cell_conf[i]->dl_pdsch_power = flexran_agent_get_operating_pdsch_refpower(enb_id, i); + cell_conf[i]->has_dl_pdsch_power = 1; - cell_conf[i]->op_ul_pusch_power = flexran_agent_get_operating_pusch_p0 (enb_id,i); - cell_conf[i]->has_op_ul_pusch_power = 1; + cell_conf[i]->ul_pusch_power = flexran_agent_get_operating_pusch_p0 (enb_id,i); + cell_conf[i]->has_ul_pusch_power = 1; if (flexran_get_enable64QAM(enb_id,i) == 0) { From 4d3689a56c0184d4f4697d443bbbca89172c3099 Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Wed, 9 Aug 2017 13:42:50 +0200 Subject: [PATCH 033/141] warning reducing --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 10 +++++----- .../CONTROL_MODULES/MAC/flexran_agent_mac_defs.h | 7 ++++--- openair2/ENB_APP/flexran_agent_common.c | 5 +++++ openair2/ENB_APP/flexran_agent_ran_api.c | 2 +- openair2/ENB_APP/flexran_agent_ran_api.h | 3 +++ openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 9 +++++++++ .../MAC/flexran_agent_scheduler_dlsch_ue.c | 4 ++-- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 16 ++++++++++++---- 8 files changed, 41 insertions(+), 15 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 512be68669..60cdba76aa 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1078,11 +1078,11 @@ int flexran_agent_mac_create_empty_ul_config(mid_t mod_id, Protocol__FlexranMess int flexran_agent_mac_destroy_ul_config(Protocol__FlexranMessage *msg) { - int i,j, k; + int i; //,j, k; if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_UL_MAC_CONFIG_MSG) goto error; - Protocol__FlexUlDci *ul_dci; + // Protocol__FlexUlDci *ul_dci; free(msg->ul_mac_config_msg->header); for (i = 0; i < msg->ul_mac_config_msg->n_ul_ue_data; i++) { @@ -1096,13 +1096,13 @@ int flexran_agent_mac_destroy_ul_config(Protocol__FlexranMessage *msg) { // free(msg->ul_mac_config_msg->ul_ue_data[i]->rlc_pdu[j]); // } // free(msg->ul_mac_config_msg->ul_ue_data[i]->rlc_pdu); - ul_dci = msg->ul_mac_config_msg->ul_ue_data[i]->ul_dci; + // ul_dci = msg->ul_mac_config_msg->ul_ue_data[i]->ul_dci; // free(dl_dci->tbs_size); // free(ul_dci->mcs); // free(ul_dci->ndi); // free(ul_dci->rv); // free(ul_dci); - free(msg->ul_mac_config_msg->ul_ue_data[i]); + // free(msg->ul_mac_config_msg->ul_ue_data[i]); } free(msg->ul_mac_config_msg->ul_ue_data); @@ -1269,7 +1269,7 @@ int flexran_agent_unregister_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { //xface->flexran_agent_send_update_mac_stats = NULL; xface->flexran_agent_schedule_ue_spec = NULL; xface->flexran_agent_get_pending_dl_mac_config = NULL; - + xface->flexran_agent_schedule_ul_spec = NULL; xface->dl_scheduler_loaded_lib = NULL; xface->ul_scheduler_loaded_lib = NULL; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h index 362c50f13c..10347f5587 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h @@ -60,9 +60,10 @@ typedef struct { void (*flexran_agent_schedule_ue_spec)(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, Protocol__FlexranMessage **dl_info); - - void (*flexran_agent_schedule_ul_spec)(mid_t module_idP, uint32_t frameP, unsigned char cooperation_flag, - uint32_t subframeP, unsigned char sched_subframe, Protocol__FlexranMessage **ul_info); + /// Run the UE UL scheduler and fill the Protocol__FlexranMessage. Assumes that + + void (*flexran_agent_schedule_ul_spec)(mid_t module_idP, uint32_t frameP, uint32_t cooperation_flag, + int subframeP, unsigned char sched_subframe, Protocol__FlexranMessage **ul_info); /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index e3f96c05dc..e56ebdfd22 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -397,6 +397,11 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_ status = mkdir(local_cache, S_IRWXU | S_IRWXG | S_IRWXO); + if (status < 0){ + + LOG_W(ENB_APP, "Couldn't create local cache!"); + } + FILE *f; f = fopen(target, "wb"); fwrite(control_delegation_msg->payload.data, control_delegation_msg->payload.len, 1, f); diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 10b667e916..a22b6cb061 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -317,7 +317,7 @@ int flexran_get_harq(const mid_t mod_id, } else if (harq_flag == openair_harq_UL){ - mac_xface->get_ue_active_harq_pid(mod_id,CC_id,rnti,frame,subframe,&harq_pid,&round,openair_harq_UL); + mac_xface->get_ue_active_harq_pid(mod_id,CC_id,rnti,frame,subframe,&harq_pid,round,openair_harq_UL); } else { diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 668c0e6ba0..33def5e09a 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -314,3 +314,6 @@ int flexran_agent_get_operating_pdsch_refpower (mid_t mod_id, int cc_id); /*Get uplink power*/ int flexran_agent_get_operating_pusch_p0 (mid_t mod_id, int cc_id); + +/*RRC status flexRAN*/ +int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); \ No newline at end of file diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index 5fc53fece6..59bef52dba 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -163,6 +163,15 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, uint16_t *first_rb); +void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, + unsigned char cooperation_flag, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframe, + uint16_t *first_rb); + +/* Downlink Primitives */ + void _dlsch_scheduler_pre_processor (module_id_t Mod_id, int slice_id, frame_t frameP, diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 02fe873144..601310d67a 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -788,7 +788,7 @@ flexran_schedule_ue_dl_spec_default(mid_t mod_id, slice_maxmcs_current[i] = slice_maxmcs[i]; } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_percentage[i],slice_percentage[i]); + // LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs[i],slice_percentage[i]); slice_maxmcs[i]= slice_maxmcs_current[i]; @@ -1253,7 +1253,7 @@ flexran_schedule_ue_dl_spec_common(mid_t mod_id, header_len += 3; // Need to see if we have space for data from this channel if (dci_tbs - ta_len - header_len - sdu_length_total > 0) { - LOG_D(MAC, "[TEST]Requested %d bytes from RLC buffer on channel %d during first call\n", dci_tbs-ta_len-header_len); + LOG_D(MAC, "[TEST]Requested %d bytes from RLC buffer on channel %d during first call\n", dci_tbs-ta_len-header_len, j); //If we have space, we need to see how much data we can request at most (if any available) rlc_status = mac_rlc_status_ind(mod_id, rnti, diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 4038ae518b..5b31c11681 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -49,14 +49,22 @@ #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" +#include "ENB_APP/flexran_agent_defs.h" +#include "flexran_agent_ran_api.h" #include "pdcp.h" +#include "header.pb-c.h" +#include "flexran.pb-c.h" +#include "flexran_agent_mac.h" + #if defined(ENABLE_ITTI) # include "intertask_interface.h" #endif #include "T.h" +#include + /* number of active slices for past and current time*/ int n_active_slices_uplink = 1; int n_active_slices_uplink_current = 1; @@ -222,7 +230,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, rnti_t rnti= -1; UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; UE_TEMPLATE *UE_template = 0; - LTE_DL_FRAME_PARMS *frame_parms = 0; + // LTE_DL_FRAME_PARMS *frame_parms; //Not used yet UE_sched_ctrl *ue_sched_ctl; @@ -272,7 +280,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, CC_id = UE_list->ordered_ULCCids[n][UE_id]; UE_template = &UE_list->UE_template[CC_id][UE_id]; average_rbs_per_user[CC_id]=0; - frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); + // frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); if (UE_template->pre_allocated_nb_rb_ul > 0) { total_ue_count+=1; @@ -359,7 +367,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; UE_template = &UE_list->UE_template[CC_id][UE_id]; - frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); + // frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); total_remaining_rbs[CC_id]=nb_rbs_allowed_slice_uplink[CC_id][UE_id] - first_rb[CC_id] - total_allocated_rbs[CC_id]; if (total_ue_count == 1 ) { @@ -384,7 +392,7 @@ void _ulsch_scheduler_pre_processor(module_id_t module_idP, } for (CC_id=0; CC_idget_lte_frame_parms(module_idP,CC_id); + // frame_parms= mac_xface->get_lte_frame_parms(module_idP,CC_id); 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], nb_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id]); From c3adbb954510cb0b9eb22e5c58ba4ab7558b6a1c Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Wed, 9 Aug 2017 22:46:42 +0200 Subject: [PATCH 034/141] warnings --- openair2/ENB_APP/flexran_agent_net_comm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/ENB_APP/flexran_agent_net_comm.c b/openair2/ENB_APP/flexran_agent_net_comm.c index 6e39d6089f..f8e350d6a9 100644 --- a/openair2/ENB_APP/flexran_agent_net_comm.c +++ b/openair2/ENB_APP/flexran_agent_net_comm.c @@ -118,7 +118,7 @@ int flexran_agent_create_channel(void *channel_info, /*element should be a real pointer*/ RB_INSERT(flexran_agent_channel_map, &channel_instance.flexran_agent_head, channel); - LOG_I(FLEXRAN_AGENT,"Created a new channel with id 0x%lx\n", channel->channel_id); + LOG_I(FLEXRAN_AGENT,"Created a new channel with id %d \n", channel->channel_id); return channel_id; } From e996f5d0f5a83255e3741866dfb991098154ba9b Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Fri, 17 Nov 2017 16:53:58 +0100 Subject: [PATCH 035/141] Add new RAN APIs form SMA app based on the initial eNb config file --- .../ENB_APP/flexran_agent_common_internal.c | 163 +++++++++++++++++- .../ENB_APP/flexran_agent_common_internal.h | 8 +- openair2/ENB_APP/flexran_agent_ran_api.c | 139 ++++++++++++--- openair2/ENB_APP/flexran_agent_ran_api.h | 25 ++- 4 files changed, 303 insertions(+), 32 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index e735b2748b..fca73894c5 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -21,8 +21,8 @@ /*! \file flexran_agent_common_internal.c * \brief internal functions for common message primitves and utilities - * \author Xenofon Foukas - * \date 2016 + * \author Xenofon Foukas and N. Nikaein + * \date 2017 * \version 0.1 */ @@ -31,6 +31,7 @@ #include "flexran_agent_common_internal.h" #include "flexran_agent_mac_internal.h" +extern volatile int reconfigure_enb; int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy_length) { @@ -64,7 +65,17 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy break; case YAML_SCALAR_EVENT: // Check the system name and call the proper handler - if (strcmp((char *) event.data.scalar.value, "mac") == 0) { + // Check the system name and call the proper handler + if (strcmp((char *) event.data.scalar.value, "enb") == 0) { + LOG_I(ENB_APP, "This is intended for the enb system\n"); + // Call the enb handler + if (parse_enb_id(mod_id, &parser) == -1) { + goto error; + } else { // succeful parse and setting + LOG_I(ENB_APP, "Successful parsed config for enb system\n"); + //reconfigure_enb=RECONF_FREQ; + } + } else if (strcmp((char *) event.data.scalar.value, "mac") == 0) { LOG_D(ENB_APP, "This is intended for the mac system\n"); // Call the mac handler if (parse_mac_config(mod_id, &parser) == -1) { @@ -90,8 +101,8 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy // TODO : Just skip it for now if (skip_system_section(&parser) == -1) { goto error; - } - } else { + } + } else { goto error; } break; @@ -115,6 +126,148 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy } +int parse_enb_id(mid_t mod_id, yaml_parser_t *parser) { + yaml_event_t event; + + void *param; + char *endptr; + int is_array = 0; + int i = 0; + + int done = 0; + int mapping_started = 0; + + while (!done) { + + if (!yaml_parser_parse(parser, &event)) + goto error; + + switch (event.type) { + // We are expecting a mapping of parameters + case YAML_SEQUENCE_START_EVENT: + is_array = 1; + break; + case YAML_MAPPING_START_EVENT: + LOG_D(ENB_APP, "The mapping of the parameters started\n"); + mapping_started = 1; + break; + case YAML_MAPPING_END_EVENT: + LOG_D(ENB_APP, "The mapping of the parameters ended\n"); + mapping_started = 0; + break; + case YAML_SCALAR_EVENT: + if (!mapping_started) { + goto error; + } + // Check what key needs to be set + // use eNB egistered + if (mac_agent_registered[mod_id]) { + LOG_I(ENB_APP, "Setting parameter for eNB %s\n", event.data.scalar.value); + if (strcmp((char *) event.data.scalar.tag, YAML_INT_TAG) == 0) { // if int + if ((strtol((char *) event.data.scalar.value, &endptr, 10))== mod_id ) { // enb_id == mod_id: right enb instance to be configured + if (parse_enb_config_parameters(mod_id, parser) == -1) { + goto error; + } + } + else{ + goto error; // not the expected type + } + } + } + break; + default: + goto error; + } + + done = (event.type == YAML_MAPPING_END_EVENT); + yaml_event_delete(&event); + } + + return 0; + + error: + yaml_event_delete(&event); + return -1; +} + +int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) { + yaml_event_t event; + + void *param; + char *endptr; + + int done = 0; + int mapping_started = 0; + + while (!done) { + + if (!yaml_parser_parse(parser, &event)) + goto error; + + switch (event.type) { + // We are expecting a mapping of parameters + case YAML_MAPPING_START_EVENT: + LOG_D(ENB_APP, "The mapping of the parameters started\n"); + mapping_started = 1; + break; + case YAML_MAPPING_END_EVENT: + LOG_D(ENB_APP, "The mapping of the parameters ended\n"); + mapping_started = 0; + break; + case YAML_SCALAR_EVENT: + if (!mapping_started) { + goto error; + } + // Check what key needs to be set + LOG_I(ENB_APP, "Setting parameter %s\n", event.data.scalar.value); + if (strcmp((char *) event.data.scalar.value, "dl_freq") == 0) { + if (!yaml_parser_parse(parser, &event)) + goto error; + flexran_agent_set_operating_dl_freq(mod_id, + 0, + strtol((char *) event.data.scalar.value, &endptr, 10)); + LOG_I(ENB_APP, "Setting parameter value %s\n", event.data.scalar.value); + } else if (strcmp((char *) event.data.scalar.value, "ul_freq_offset") == 0) { + if (!yaml_parser_parse(parser, &event)) + goto error; + flexran_agent_set_operating_ul_freq(mod_id, + 0, + strtol((char *) event.data.scalar.value, &endptr, 10)); + LOG_I(ENB_APP, "Setting parameter value %s\n", event.data.scalar.value); + } else if (strcmp((char *) event.data.scalar.value, "bandwidth") == 0) { + if (!yaml_parser_parse(parser, &event)) + goto error; + flexran_agent_set_operating_bandwidth(mod_id, + 0, + strtol((char *) event.data.scalar.value, &endptr, 10)); + LOG_I(ENB_APP, "Setting parameter value %s\n", event.data.scalar.value); + } else if (strcmp((char *) event.data.scalar.value, "frame_type") == 0) { + if (!yaml_parser_parse(parser, &event)) + goto error; + flexran_agent_set_operating_frame_type (mod_id, + 0, + strtol((char *) event.data.scalar.value, &endptr, 10)); + LOG_I(ENB_APP, "Setting parameter value %s\n", event.data.scalar.value); + }else { // not supported tag + goto error; + } + + break; + default: + goto error; + } + + done = (event.type == YAML_MAPPING_END_EVENT); + yaml_event_delete(&event); + } + + return 0; + + error: + yaml_event_delete(&event); + return -1; +} + int skip_system_section(yaml_parser_t *parser) { yaml_event_t event; diff --git a/openair2/ENB_APP/flexran_agent_common_internal.h b/openair2/ENB_APP/flexran_agent_common_internal.h index c8f78aafe9..2b39025489 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.h +++ b/openair2/ENB_APP/flexran_agent_common_internal.h @@ -21,8 +21,8 @@ /*! \file flexran_agent_common_internal.h * \brief internal agent functions for common message primitves and utilities - * \author Xenofon Foukas - * \date 2016 + * \author Xenofon Foukas and N. Nikaein + * \date 2017 * \version 0.1 */ @@ -37,6 +37,10 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy int apply_parameter_modification(void *parameter, yaml_parser_t *parser); +int parse_enb_id(mid_t mod_id, yaml_parser_t *parser); +int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) ; + + // This can be used when parsing for a specific system that is not yet implmeneted // in order to skip its configuration, without affecting the rest int skip_system_section(yaml_parser_t *parser); diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index a22b6cb061..0d3145e1d2 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -21,7 +21,7 @@ /*! \file flexran_agent_ran_api.c * \brief FlexRAN RAN API abstraction - * \author shahab SHARIAT BAGHERI + * \author N. Nikaein, X. Foukas and S. SHARIAT BAGHERI * \date 2017 * \version 0.1 */ @@ -30,7 +30,7 @@ /* - * get generic info from RAN + * generic info from RAN */ @@ -43,9 +43,15 @@ void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ switch (ran){ case RAN_LTE_OAI : - enb[mod_id] = (void *)&eNB_mac_inst[mod_id]; - enb_ue[mod_id] = (void *)&eNB_mac_inst[mod_id].UE_list; - enb_rrc[mod_id] = (void *)&eNB_rrc_inst[mod_id]; + if(eNB_mac_inst == NULL){ + enb[mod_id] = NULL; + enb_ue[mod_id] = NULL; + enb_rrc[mod_id] = NULL; + }else{ + enb[mod_id] = (void *)&eNB_mac_inst[mod_id]; + enb_ue[mod_id] = (void *)&eNB_mac_inst[mod_id].UE_list; + enb_rrc[mod_id] = (void *)&eNB_rrc_inst[mod_id]; + } break; default : goto error; @@ -56,9 +62,20 @@ void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ error: LOG_E(FLEXRAN_AGENT, "unknown RAN name %d\n", ran); } +static int mac_xface_not_ready(void); + +static int mac_xface_not_ready(void){ + if (mac_xface == NULL) + return 1; + else { + //printf("max_xface %p %d \n", mac_xface, mac_xface->active); + return 0;// !mac_xface->active; + } +} + int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag){ - + if (enb[mod_id] == NULL) return 0; if (subframe_flag == 1){ return ((eNB_MAC_INST *)enb[mod_id])->frame*10 + ((eNB_MAC_INST *)enb[mod_id])->subframe; }else { @@ -68,7 +85,7 @@ int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag){ } unsigned int flexran_get_current_frame (mid_t mod_id) { - + if (enb[mod_id] == NULL) return 0; // #warning "SFN will not be in [0-1023] when oaisim is used" return ((eNB_MAC_INST *)enb[mod_id])->frame; @@ -79,7 +96,7 @@ unsigned int flexran_get_current_system_frame_num(mid_t mod_id) { } unsigned int flexran_get_current_subframe (mid_t mod_id) { - + if (enb[mod_id] == NULL) return 0; return ((eNB_MAC_INST *)enb[mod_id])->subframe; } @@ -125,7 +142,7 @@ uint16_t flexran_get_future_sfn_sf (mid_t mod_id, int ahead_of_time) { } int flexran_get_num_ues (mid_t mod_id){ - + if (enb_ue[mod_id] == NULL) return 0; return ((UE_list_t *)enb_ue[mod_id])->num_UEs; } @@ -135,17 +152,19 @@ int flexran_get_ue_crnti (mid_t mod_id, mid_t ue_id) { } int flexran_get_ue_bsr (mid_t mod_id, mid_t ue_id, lcid_t lcid) { - + if (enb_ue[mod_id] == NULL) return 0; return ((UE_list_t *)enb_ue[mod_id])->UE_template[UE_PCCID(mod_id,ue_id)][ue_id].bsr_info[lcid]; } int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id) { - + if (enb_ue[mod_id] == NULL) return 0; return ((UE_list_t *)enb_ue[mod_id])->UE_template[UE_PCCID(mod_id,ue_id)][ue_id].phr_info; } int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id) { LTE_eNB_UE_stats *eNB_UE_stats = NULL; + if (mac_xface_not_ready()) return 0 ; + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, 0, UE_RNTI(mod_id, ue_id)); return eNB_UE_stats->DL_cqi[0]; @@ -174,10 +193,11 @@ short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id) { int rnti; rnti = flexran_get_ue_crnti(mod_id, ue_id); + if (mac_xface_not_ready()) return 0 ; LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); //ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY - switch (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.N_RB_DL) { + switch (flexran_get_N_RB_DL(mod_id, CC_id)) { case 6: return eNB_UE_stats->timing_advance_update; case 15: @@ -189,7 +209,7 @@ short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id) { case 75: return eNB_UE_stats->timing_advance_update/12; case 100: - if (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.threequarter_fs == 0) { + if (flexran_get_threequarter_fs(mod_id, CC_id) == 0) { return eNB_UE_stats->timing_advance_update/16; } else { return eNB_UE_stats->timing_advance_update/12; @@ -232,6 +252,8 @@ int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id,int CC_id) { // UE_list_t *UE_list = &eNB_mac_inst[mod_id].UE_list; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + if (mac_xface_not_ready()) return 0 ; + LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); if (eNB_UE_stats == NULL) { @@ -247,11 +269,13 @@ int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id,int CC_id) { } int flexran_get_active_CC(mid_t mod_id, mid_t ue_id) { + if (enb_ue[mod_id] == NULL) return 0; return ((UE_list_t *)enb_ue[mod_id])->numactiveCCs[ue_id]; } int flexran_get_current_RI(mid_t mod_id, mid_t ue_id, int CC_id) { LTE_eNB_UE_stats *eNB_UE_stats = NULL; + if (mac_xface_not_ready()) return 0 ; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); @@ -271,6 +295,7 @@ int flexran_get_tpc(mid_t mod_id, mid_t ue_id) { int pCCid = UE_PCCID(mod_id,ue_id); rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + if (mac_xface_not_ready()) return 0 ; eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, pCCid, rnti); @@ -309,6 +334,7 @@ int flexran_get_harq(const mid_t mod_id, uint8_t harq_pid; uint8_t harq_round; + if (mac_xface_not_ready()) return 0 ; uint16_t rnti = flexran_get_ue_crnti(mod_id,ue_id); if (harq_flag == openair_harq_DL){ @@ -340,7 +366,8 @@ int flexran_get_harq(const mid_t mod_id, int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id) { LTE_eNB_UE_stats *eNB_UE_stats = NULL; uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - + if (mac_xface_not_ready()) return 0 ; + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); if (eNB_UE_stats == NULL) { @@ -355,11 +382,15 @@ int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id) { } int flexran_get_p0_nominal_pucch(mid_t mod_id, int CC_id) { + if (mac_xface_not_ready()) return 0 ; + int32_t pucch_rx_received = mac_xface->get_target_pucch_rx_power(mod_id, CC_id); return pucch_rx_received; } int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id) { + if (mac_xface_not_ready()) return 0 ; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); @@ -368,6 +399,8 @@ int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id) { } int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id) { + if (mac_xface_not_ready()) return 0 ; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); @@ -383,9 +416,18 @@ int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id) { * Get Messages for eNB Configuration Reply * ************************************ */ +int flexran_get_threequarter_fs(mid_t mod_id, int CC_id) { + LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; + + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + return frame_parms->threequarter_fs; +} + int flexran_get_hopping_offset(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->pusch_config_common.pusch_HoppingOffset; @@ -393,6 +435,7 @@ int flexran_get_hopping_offset(mid_t mod_id, int CC_id) { int flexran_get_hopping_mode(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->pusch_config_common.hoppingMode; @@ -400,6 +443,7 @@ int flexran_get_hopping_mode(mid_t mod_id, int CC_id) { int flexran_get_n_SB(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->pusch_config_common.n_SB; @@ -407,6 +451,7 @@ int flexran_get_n_SB(mid_t mod_id, int CC_id) { int flexran_get_enable64QAM(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->pusch_config_common.enable64QAM; @@ -414,6 +459,7 @@ int flexran_get_enable64QAM(mid_t mod_id, int CC_id) { int flexran_get_phich_duration(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->phich_config_common.phich_duration; @@ -421,6 +467,7 @@ int flexran_get_phich_duration(mid_t mod_id, int CC_id) { int flexran_get_phich_resource(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); if(frame_parms->phich_config_common.phich_resource == oneSixth) @@ -437,6 +484,7 @@ int flexran_get_phich_resource(mid_t mod_id, int CC_id) { int flexran_get_n1pucch_an(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->pucch_config_common.n1PUCCH_AN; @@ -444,6 +492,7 @@ int flexran_get_n1pucch_an(mid_t mod_id, int CC_id) { int flexran_get_nRB_CQI(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->pucch_config_common.nRB_CQI; @@ -451,6 +500,7 @@ int flexran_get_nRB_CQI(mid_t mod_id, int CC_id) { int flexran_get_deltaPUCCH_Shift(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->pucch_config_common.deltaPUCCH_Shift; @@ -458,6 +508,7 @@ int flexran_get_deltaPUCCH_Shift(mid_t mod_id, int CC_id) { int flexran_get_prach_ConfigIndex(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; @@ -465,6 +516,7 @@ int flexran_get_prach_ConfigIndex(mid_t mod_id, int CC_id) { int flexran_get_prach_FreqOffset(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset; @@ -472,6 +524,7 @@ int flexran_get_prach_FreqOffset(mid_t mod_id, int CC_id) { int flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->maxHARQ_Msg3Tx; @@ -479,6 +532,7 @@ int flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, int CC_id) { int flexran_get_ul_cyclic_prefix_length(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->Ncp_UL; @@ -486,7 +540,8 @@ int flexran_get_ul_cyclic_prefix_length(mid_t mod_id, int CC_id) { int flexran_get_dl_cyclic_prefix_length(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; - + if (mac_xface_not_ready()) return 0 ; + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->Ncp; } @@ -494,19 +549,23 @@ int flexran_get_dl_cyclic_prefix_length(mid_t mod_id, int CC_id) { int flexran_get_cell_id(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0; + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->Nid_cell; } int flexran_get_srs_BandwidthConfig(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; - + if (mac_xface_not_ready()) return 0 ; + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->soundingrs_ul_config_common.srs_BandwidthConfig; } int flexran_get_srs_SubframeConfig(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->soundingrs_ul_config_common.srs_SubframeConfig; @@ -514,6 +573,7 @@ int flexran_get_srs_SubframeConfig(mid_t mod_id, int CC_id) { int flexran_get_srs_MaxUpPts(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->soundingrs_ul_config_common.srs_MaxUpPts; @@ -521,6 +581,7 @@ int flexran_get_srs_MaxUpPts(mid_t mod_id, int CC_id) { int flexran_get_N_RB_DL(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->N_RB_DL; @@ -528,6 +589,7 @@ int flexran_get_N_RB_DL(mid_t mod_id, int CC_id) { int flexran_get_N_RB_UL(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->N_RB_UL; @@ -535,6 +597,7 @@ int flexran_get_N_RB_UL(mid_t mod_id, int CC_id) { int flexran_get_N_RBG(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->N_RBG; @@ -542,6 +605,7 @@ int flexran_get_N_RBG(mid_t mod_id, int CC_id) { int flexran_get_subframe_assignment(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return frame_parms->tdd_config; @@ -549,9 +613,10 @@ int flexran_get_subframe_assignment(mid_t mod_id, int CC_id) { int flexran_get_special_subframe_assignment(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->tdd_config_S; + return (frame_parms == NULL)? 0:frame_parms->tdd_config_S; } int flexran_get_ra_ResponseWindowSize(mid_t mod_id, int CC_id) { @@ -564,8 +629,10 @@ int flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, int CC_id) { int flexran_get_duplex_mode(mid_t mod_id, int CC_id) { LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0 ; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); + if (frame_parms == NULL) return -1; if(frame_parms->frame_type == TDD) return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD; else if (frame_parms->frame_type == FDD) @@ -671,10 +738,12 @@ int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP){ } int flexran_get_ue_aggregated_max_bitrate_dl (mid_t mod_id, mid_t ue_id) { + if (enb_ue[mod_id] == NULL) return 0; return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateDL; } int flexran_get_ue_aggregated_max_bitrate_ul (mid_t mod_id, mid_t ue_id) { + if (enb_ue[mod_id] == NULL) return 0; return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL; } @@ -953,19 +1022,19 @@ int flexran_get_antenna_ports(mid_t mod_id, int CC_id){ LTE_DL_FRAME_PARMS *frame_parms; frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->nb_antenna_ports_eNB; + return (frame_parms == NULL)? 0:frame_parms->nb_antenna_ports_eNB; } -float flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id) { +uint32_t flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id) { const Enb_properties_array_t* enb_properties = enb_config_get(); return (enb_properties->properties[mod_id]->downlink_frequency[cc_id] / 1000000); } -float flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id) { +uint32_t flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id) { const Enb_properties_array_t* enb_properties = enb_config_get(); - return ((enb_properties->properties[mod_id] ->downlink_frequency[cc_id] + enb_properties->properties[0]->uplink_frequency_offset[cc_id]) / 1000000); + return ((enb_properties->properties[mod_id]->downlink_frequency[cc_id] + enb_properties->properties[0]->uplink_frequency_offset[cc_id]) / 1000000); } int flexran_agent_get_operating_eutra_band (mid_t mod_id, int cc_id) { @@ -981,5 +1050,33 @@ int flexran_agent_get_operating_pusch_p0 (mid_t mod_id, int cc_id) { return enb_properties->properties[mod_id]->pusch_p0_Nominal[cc_id]; } +void flexran_agent_set_operating_dl_freq (mid_t mod_id, int cc_id, uint32_t dl_freq_mhz) { + + Enb_properties_array_t* enb_properties = enb_config_get(); + enb_properties->properties[mod_id]->downlink_frequency[cc_id]=dl_freq_mhz * 1000000; + /*printf("[ENB_APP] mod id %d ccid %d dl freq %d/%d\n", mod_id, cc_id, dl_freq_mhz, enb_properties->properties[mod_id]->downlink_frequency[cc_id]); */ +} + +void flexran_agent_set_operating_ul_freq (mid_t mod_id, int cc_id, int32_t ul_freq_offset_mhz) { + Enb_properties_array_t* enb_properties = enb_config_get(); + enb_properties->properties[mod_id]->uplink_frequency_offset[cc_id]=ul_freq_offset_mhz * 1000000; +} +//TBD +void flexran_agent_set_operating_eutra_band (mid_t mod_id, int cc_id) { + Enb_properties_array_t* enb_properties = enb_config_get(); + enb_properties->properties[mod_id]->eutra_band[cc_id]=7; +} + +void flexran_agent_set_operating_bandwidth (mid_t mod_id, int cc_id, int bandwidth) { + Enb_properties_array_t* enb_properties = enb_config_get(); + enb_properties->properties[mod_id]->N_RB_DL[cc_id]=bandwidth; +} + +void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_type) { + Enb_properties_array_t* enb_properties = enb_config_get(); + enb_properties->properties[mod_id]->frame_type[cc_id]=frame_type; +} + + diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 33def5e09a..9f0313c1ca 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -21,7 +21,7 @@ /*! \file flexran_agent_ran_api.h * \brief FlexRAN RAN API abstraction header - * \author shahab SHARIAT BAGHERI + * \author N. Nikaein, X. Foukas and S. SHARIAT BAGHERI * \date 2017 * \version 0.1 */ @@ -198,6 +198,8 @@ int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id); int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id); +int flexran_get_threequarter_fs(mid_t mod_id, int CC_id); + int flexran_get_hopping_mode(mid_t mod_id, int CC_id); int flexran_get_hopping_offset(mid_t mod_id, int CC_id); @@ -301,10 +303,10 @@ int flexran_get_lcg(mid_t ue_id, mid_t lc_id); int flexran_get_direction(mid_t ue_id, mid_t lc_id); /*Get downlink frequency*/ -float flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id); +uint32_t flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id); /*Get uplink frequency*/ -float flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id); +uint32_t flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id); /*Get eutra band*/ int flexran_agent_get_operating_eutra_band (mid_t mod_id, int cc_id); @@ -315,5 +317,20 @@ int flexran_agent_get_operating_pdsch_refpower (mid_t mod_id, int cc_id); /*Get uplink power*/ int flexran_agent_get_operating_pusch_p0 (mid_t mod_id, int cc_id); +/*set the dl freq */ +void flexran_agent_set_operating_dl_freq (mid_t mod_id, int cc_id, uint32_t dl_freq_mhz); + +/* set the ul freq */ +void flexran_agent_set_operating_ul_freq (mid_t mod_id, int cc_id, int32_t ul_freq_offset_mhz); + +/*set the the band */ +void flexran_agent_set_operating_eutra_band (mid_t mod_id, int cc_id); + +/* set the bandwidth */ +void flexran_agent_set_operating_bandwidth (mid_t mod_id, int cc_id, int bandwidth); + +/*set frame type*/ +void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_type); + /*RRC status flexRAN*/ -int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); \ No newline at end of file +int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); From dc9cada6c2f3841677ce00801f3ec7c3c95fe3b2 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Fri, 8 Dec 2017 18:05:42 +0100 Subject: [PATCH 036/141] Add PDCP stats and update agent and RAN APIs --- cmake_targets/CMakeLists.txt | 2 + .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 2 +- .../CONTROL_MODULES/PDCP/flexran_agent_pdcp.c | 168 ++++++++++ .../CONTROL_MODULES/PDCP/flexran_agent_pdcp.h | 64 ++++ .../PDCP/flexran_agent_pdcp_defs.h | 63 ++++ .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 314 +++++++----------- .../CONTROL_MODULES/RRC/flexran_agent_rrc.h | 52 ++- .../RRC/flexran_agent_rrc_defs.h | 64 ++-- openair2/ENB_APP/MESSAGES/V2/flexran.proto | 1 + .../ENB_APP/MESSAGES/V2/stats_common.proto | 21 ++ .../ENB_APP/MESSAGES/V2/stats_messages.proto | 6 +- .../ENB_APP/MESSAGES/V2/time_common.proto | 1 + openair2/ENB_APP/flexran_agent.c | 3 + openair2/ENB_APP/flexran_agent.h | 1 + openair2/ENB_APP/flexran_agent_defs.h | 5 + openair2/ENB_APP/flexran_agent_extern.h | 7 + openair2/ENB_APP/flexran_agent_handler.c | 25 +- openair2/ENB_APP/flexran_agent_ran_api.c | 90 +++++ openair2/ENB_APP/flexran_agent_ran_api.h | 55 +++ openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 187 ++++++++--- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 46 ++- 21 files changed, 880 insertions(+), 297 deletions(-) create mode 100644 openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c create mode 100644 openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.h create mode 100644 openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp_defs.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 734bfccf2d..6399f02ef0 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -762,6 +762,7 @@ include_directories("${OPENAIR_DIR}/targets/ARCH/EXMIMO/DEFS") include_directories("${OPENAIR2_DIR}/ENB_APP") include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC") include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC") +include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/PDCP") include_directories("${OPENAIR2_DIR}/UTIL/OSA") include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds6.1.1/liblfds611/inc") include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/inc") @@ -852,6 +853,7 @@ if (FLEXRAN_AGENT_SB_IF) ${OPENAIR2_DIR}/ENB_APP/flexran_agent_common_internal.c ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c + ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent_task_manager.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent_net_comm.c diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 60cdba76aa..736cdb67e0 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -128,7 +128,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, rlc_reports[j]->retransmission_queue_hol_delay = 100; rlc_reports[j]->has_retransmission_queue_hol_delay = 0; //TODO DONE:Set current size of the pending message in bytes - rlc_reports[j]->status_pdu_size = flexran_get_tx_queue_size(enb_id, i, j + 1); + rlc_reports[j]->status_pdu_size = flexran_get_num_pdus_buffer(enb_id , i, j + 1); rlc_reports[j]->has_status_pdu_size = 1; } diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c new file mode 100644 index 0000000000..ecc40cd89a --- /dev/null +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c @@ -0,0 +1,168 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file flexran_agent_pdcp.c + * \brief FlexRAN agent Control Module PDCP + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + */ + +#include "flexran_agent_pdcp.h" + + +/*Trigger boolean for PDCP measurement*/ +bool triggered_pdcp = false; +/*Flags showing if a pdcp agent has already been registered*/ +unsigned int pdcp_agent_registered[NUM_MAX_ENB]; + +/*Array containing the Agent-PDCP interfaces*/ +AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB]; + +// NUMBER_OF_UE_MAX + +void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id, + const mid_t ue_id, + Protocol__FlexPdcpStats *pdcp_aggr_stats){ + + int lcid=0; + /* only calculate the DRBs */ + //LOG_I(FLEXRAN_AGENT, "enb %d ue %d \n", mod_id, ue_id); + + for (lcid=NUM_MAX_SRB ; lcid < NUM_MAX_SRB + NUM_MAX_DRB; lcid++){ + + pdcp_aggr_stats->pkt_tx += flexran_get_pdcp_tx(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_tx_bytes += flexran_get_pdcp_tx_bytes(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_tx_rate_s += flexran_get_pdcp_tx_rate_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_tx_throughput_s += flexran_get_pdcp_tx_throughput_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_tx_aiat += flexran_get_pdcp_tx_aiat(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_tx_aiat_s += flexran_get_pdcp_tx_aiat_s(mod_id,ue_id,lcid); + + + pdcp_aggr_stats->pkt_rx += flexran_get_pdcp_rx(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_bytes += flexran_get_pdcp_rx_bytes(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_rate_s += flexran_get_pdcp_rx_rate_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_goodput_s += flexran_get_pdcp_rx_goodput_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_aiat += flexran_get_pdcp_rx_aiat(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_aiat_s += flexran_get_pdcp_rx_aiat_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_oo += flexran_get_pdcp_rx_oo(mod_id,ue_id,lcid); + + } + +} + + +int flexran_agent_pdcp_stats_reply(mid_t mod_id, + const report_config_t *report_config, + Protocol__FlexUeStatsReport **ue_report, + Protocol__FlexCellStatsReport **cell_report) { + + + // Protocol__FlexHeader *header; + int i, j, k; + // int cc_id = 0; + + + /* Allocate memory for list of UE reports */ + if (report_config->nr_ue > 0) { + + for (i = 0; i < report_config->nr_ue; i++) { + + /* Check flag for creation of buffer status report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PDCP_STATS) { + + Protocol__FlexPdcpStats *pdcp_aggr_stats; + pdcp_aggr_stats = malloc(sizeof(Protocol__FlexPdcpStats)); + if (pdcp_aggr_stats == NULL) + goto error; + protocol__flex_pdcp_stats__init(pdcp_aggr_stats); + + flexran_agent_pdcp_aggregate_stats(mod_id, i, pdcp_aggr_stats); + + pdcp_aggr_stats->has_pkt_tx=1; + pdcp_aggr_stats->has_pkt_tx_bytes =1; + pdcp_aggr_stats->has_pkt_tx_rate_s=1; + pdcp_aggr_stats->has_pkt_tx_throughput_s =1; + pdcp_aggr_stats->has_pkt_tx_aiat =1; + pdcp_aggr_stats->has_pkt_tx_aiat_s =1; + + pdcp_aggr_stats->pkt_tx_sn = flexran_get_pdcp_tx_sn(mod_id, i, DEFAULT_DRB); + pdcp_aggr_stats->has_pkt_tx_sn =1; + + pdcp_aggr_stats->has_pkt_rx =1; + pdcp_aggr_stats->has_pkt_rx_bytes =1; + pdcp_aggr_stats->has_pkt_rx_rate_s =1; + pdcp_aggr_stats->has_pkt_rx_goodput_s =1; + pdcp_aggr_stats->has_pkt_rx_aiat =1; + pdcp_aggr_stats->has_pkt_rx_aiat_s =1; + pdcp_aggr_stats->has_pkt_rx_oo =1; + + pdcp_aggr_stats->pkt_rx_sn = flexran_get_pdcp_rx_sn(mod_id, i, DEFAULT_DRB); + pdcp_aggr_stats->has_pkt_rx_sn =1; + + ue_report[i]->pdcp_stats = pdcp_aggr_stats; + + } + } + } else { + LOG_D(FLEXRAN_AGENT, "no UE\n"); + } + + return 0; + + error: + LOG_W(FLEXRAN_AGENT, "Can't allocate PDCP stats\n"); + + /* if (cell_report != NULL) + free(cell_report); + if (ue_report != NULL) + free(ue_report); + */ + return -1; +} + + + +int flexran_agent_register_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface) { + if (pdcp_agent_registered[mod_id]) { + LOG_E(PDCP, "PDCP agent for eNB %d is already registered\n", mod_id); + return -1; + } + + //xface->flexran_pdcp_stats_measurement = NULL; + + pdcp_agent_registered[mod_id] = 1; + agent_pdcp_xface[mod_id] = xface; + + return 0; +} + +int flexran_agent_unregister_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface) { + + //xface->agent_ctxt = NULL; + //xface->flexran_pdcp_stats_measurement = NULL; + + + pdcp_agent_registered[mod_id] = 0; + agent_pdcp_xface[mod_id] = NULL; + + return 0; +} diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.h b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.h new file mode 100644 index 0000000000..a962390c00 --- /dev/null +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.h @@ -0,0 +1,64 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file flexran_agent_pdcp.h + * \brief FlexRAN agent Control Module PDCP header + * \author shahab SHARIAT BAGHERI + * \date 2017 + * \version 0.1 + */ + +#ifndef FLEXRAN_AGENT_PDCP_H_ +#define FLEXRAN_AGENT_PDCP_H_ + +#include "header.pb-c.h" +#include "flexran.pb-c.h" +#include "stats_messages.pb-c.h" +#include "stats_common.pb-c.h" + + +#include "flexran_agent_common.h" +#include "flexran_agent_defs.h" +#include "flexran_agent_pdcp_defs.h" +#include "flexran_agent_ran_api.h" + +/********************************** + * FlexRAN agent - technology PDCP API + **********************************/ + +/* Send to the controller all the pdcp stat updates that occured during this subframe*/ +int flexran_agent_pdcp_stats_reply(mid_t mod_id, + const report_config_t *report_config, + Protocol__FlexUeStatsReport **ue_report, + Protocol__FlexCellStatsReport **cell_report); + +/* Get the stats from RAN API and aggregate them per USER*/ +void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id, + const mid_t ue_id, + Protocol__FlexPdcpStats *pdcp_aggr_stats); + +/*Register technology specific interface callbacks*/ +int flexran_agent_register_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface); + +/*Unregister technology specific callbacks*/ +int flexran_agent_unregister_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface*xface); + +#endif diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp_defs.h b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp_defs.h new file mode 100644 index 0000000000..46bdf744de --- /dev/null +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp_defs.h @@ -0,0 +1,63 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ +#ifndef __FLEXRAN_AGENT_PDCP_PRIMITIVES_H__ +#define __FLEXRAN_AGENT_PDCP_PRIMITIVES_H__ + +#include "flexran_agent_defs.h" +#include "flexran.pb-c.h" +#include "header.pb-c.h" + + /*PDCP aggregated Packet stats */ +/* +typedef struct pdcp_aggr_stats_s { + int32_t rnti; + + int32_t pkt_tx; + int32_t pkt_tx_bytes; + int32_t pkt_tx_sn; + int32_t pkt_tx_rate_s; + int32_t pkt_tx_throughput_s; + int32_t pkt_tx_aiat; + int32_t pkt_tx_aiat_s; + + int32_t pkt_rx; + int32_t pkt_rx_bytes; + int32_t pkt_rx_sn; + int32_t pkt_rx_rate_s; + int32_t pkt_rx_goodput_s; + int32_t pkt_rx_aiat; + int32_t pkt_rx_aiat_s; + int32_t pkt_rx_oo; + + +} pdcp_aggr_stats_t; +*/ + +/* FLEXRAN AGENT-PDCP Interface */ +typedef struct { + + + // PDCP statistics + void (*flexran_pdcp_stats_measurement)(mid_t mod_id, uint16_t rnti, uint16_t seq_num, uint32_t size); + +} AGENT_PDCP_xface; + +#endif diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index d48d12d670..e70d2a3d97 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -33,33 +33,15 @@ #include "log.h" +/*Trigger boolean for RRC measurement*/ +bool triggered_rrc = false; -/*Flags showing if a rrc agent has already been registered*/ +/*Flags showing if an rrc agent has already been registered*/ unsigned int rrc_agent_registered[NUM_MAX_ENB]; /*Array containing the Agent-RRC interfaces*/ AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]; -/* Ringbuffer related structs used for maintaining the dl rrc config messages */ -//message_queue_t *rrc_dl_config_queue; -struct lfds700_misc_prng_state rrc_ps[NUM_MAX_ENB]; -struct lfds700_ringbuffer_element *rrc_dl_config_array[NUM_MAX_ENB]; -struct lfds700_ringbuffer_state rrc_ringbuffer_state[NUM_MAX_ENB]; - - - -void flexran_agent_init_rrc_agent(mid_t mod_id) { - lfds700_misc_library_init_valid_on_current_logical_core(); - lfds700_misc_prng_init(&rrc_ps[mod_id]); - int num_elements = RINGBUFFER_SIZE + 1; - //Allow RINGBUFFER_SIZE messages to be stored in the ringbuffer at any time - rrc_dl_config_array[mod_id] = malloc( sizeof(struct lfds700_ringbuffer_element) * num_elements); - lfds700_ringbuffer_init_valid_on_current_logical_core( &rrc_ringbuffer_state[mod_id], rrc_dl_config_array[mod_id], num_elements, &rrc_ps[mod_id], NULL ); -} - - - - void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) { int size; @@ -280,156 +262,26 @@ int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg) { /* this is called by RRC as a part of rrc xface . The controller previously requested this*/ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults) { - // int i, m, k; - int priority = 0; // Warning Preventing - void *data; - int size; - err_code_t err_code; - Protocol__FlexUeStatsReport **ue_report; - Protocol__FlexCellStatsReport **cell_report; - Protocol__FlexStatsReply *stats_reply_msg; - Protocol__FlexranMessage *msg; + int i, m, k; + // int priority = 0; // Warning Preventing + // void *data; + // int size; + err_code_t err_code = -100; + triggered_rrc = true; + int num; - Protocol__FlexHeader *header; - int xid = 0; - int i; + num = flexran_get_num_ues (mod_id); - if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) - goto error; + meas_stats = malloc(sizeof(rrc_meas_stats) * num); - - - stats_reply_msg = malloc(sizeof(Protocol__FlexStatsReply)); - - if (stats_reply_msg == NULL) - goto error; - - protocol__flex_stats_reply__init(stats_reply_msg); - stats_reply_msg->header = header; - stats_reply_msg->n_ue_report = 1; - stats_reply_msg->n_cell_report = 1; - -/****** LOCK ******************************************************************/ - // pthread_spin_lock(&rrc_meas_t_lock); - - // struct rrc_meas_trigg *ctxt; - // ctxt = rrc_meas_get_trigg(p->rnti, p->meas->measId); - - // pthread_spin_unlock(&rrc_meas_t_lock); -/****** UNLOCK ****************************************************************/ - - // if (ctxt == NULL) { - - // flexran_RRC_meas_reconf(p->rnti, -1, p->meas->measId, NULL, NULL); - // Free the measurement report received from UE. - // ASN_STRUCT_FREE(asn_DEF_MeasResults, p->meas); - // /* Free the params. */ - // free(p); - // return 0; - // } - - - /* Check here whether trigger is registered in agent and then proceed. - */ - // if (em_has_trigger(mod_id, ctxt->t_id, RRC_MEAS_TRIGGER) == 0) { - - // flexran_RRC_meas_reconf(p->rnti, -1, p->meas->measId, NULL, NULL); - // /* Trigger does not exist in agent so remove from wrapper as well. */ - // if (rrc_meas_rem_trigg(ctxt) < 0) { - // goto error; - // } - // } - - - - - /* Set the RNTI of the UE. */ - // repl->rnti = p->rnti; - /* Set the request status. */ - // if (p->reconfig_success == 0) { - // repl->status = STATS_REQ_STATUS__SREQS_FAILURE; - // goto error; - // } - /* Successful outcome. */ - // repl->status = STATS_REQ_STATUS__SREQS_SUCCESS; - /* Set the measurement ID of measurement. */ - // repl->has_measid = 1; - // repl->measid = measResults->measId; - /* Fill the Primary Cell RSRP and RSRQ. */ - // repl->has_pcell_rsrp = 1; - // repl->has_pcell_rsrq = 1; - // #ifdef Rel10 - // repl->has_pcell_rsrp = 1; - // repl->has_pcell_rsrq = 1; - // repl->pcell_rsrp = measResults2->measResultPCell.rsrpResult - 140; - // repl->pcell_rsrq = (measResults2->measResultPCell.rsrqResult)/2 - 20; - - ue_report = malloc(sizeof(Protocol__FlexUeStatsReport *) * 1); - if (ue_report == NULL) - goto error; - - for (i = 0; i < 1; i++) { - - ue_report[i] = malloc(sizeof(Protocol__FlexUeStatsReport)); - if(ue_report[i] == NULL) - goto error; - protocol__flex_ue_stats_report__init(ue_report[i]); - ue_report[i]->rnti = flexran_get_ue_crnti(mod_id, 0); - ue_report[i]->has_rnti = 1; - ue_report[i]->flags = 65536; - ue_report[i]->has_flags = 1; - - } - - cell_report = malloc(sizeof(Protocol__FlexCellStatsReport *) * 1); - if (cell_report == NULL) - goto error; - - for (i = 0; i < 1; i++) { - - cell_report[i] = malloc(sizeof(Protocol__FlexCellStatsReport)); - if(cell_report[i] == NULL) - goto error; - - protocol__flex_cell_stats_report__init(cell_report[i]); - cell_report[i]->carrier_index = 0; //report_config->cc_report_type[i].cc_id; - cell_report[i]->has_carrier_index = 1; - cell_report[i]->flags = 0; // report_config->cc_report_type[i].cc_report_flags; - cell_report[i]->has_flags = 1; - } - - - Protocol__FlexRrcMeasurements *rrc_measurements; - rrc_measurements = malloc(sizeof(Protocol__FlexRrcMeasurements)); - if (rrc_measurements == NULL) - goto error; - protocol__flex_rrc_measurements__init(rrc_measurements); - - rrc_measurements->measid = measResults->measId; - rrc_measurements->has_measid = 1; - - rrc_measurements->pcell_rsrp = measResults->measResultPCell.rsrpResult - 140; - rrc_measurements->has_pcell_rsrp = 1; - - rrc_measurements->pcell_rsrq = (measResults->measResultPCell.rsrqResult)/2 - 20; - rrc_measurements->has_pcell_rsrq = 1 ; - - ue_report[0]->rrc_measurements = rrc_measurements; - - - - - - // #else - // repl->has_pcell_rsrp = 1; - // repl->has_pcell_rsrq = 1; - // repl->pcell_rsrp = RSRP_meas_mapping[meas-> - // measResultServCell.rsrpResult]; - // repl->pcell_rsrq = RSRQ_meas_mapping[meas-> - // measResultServCell.rsrqResult]; - // #endif - - // repl->neigh_meas = NULL; + for (i = 0; i < num; i++){ + meas_stats[i].rnti = flexran_get_ue_crnti(mod_id, i); + meas_stats[i].meas_id = measResults->measId; + meas_stats[i].rsrp = measResults->measResultPCell.rsrpResult - 140; + meas_stats[i].rsrq = (measResults->measResultPCell.rsrqResult)/2 - 20; + + } + // repl->neigh_meas = NULL; // if (meas->measResultNeighCells != NULL) { // /* @@ -595,34 +447,34 @@ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults // free(p); - stats_reply_msg->cell_report = cell_report; + // stats_reply_msg->cell_report = cell_report; - stats_reply_msg->ue_report = ue_report; + // stats_reply_msg->ue_report = ue_report; - msg = malloc(sizeof(Protocol__FlexranMessage)); - if(msg == NULL) - goto error; - protocol__flexran_message__init(msg); - msg->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG; - msg->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__SUCCESSFUL_OUTCOME; - msg->stats_reply_msg = stats_reply_msg; + // msg = malloc(sizeof(Protocol__FlexranMessage)); + // if(msg == NULL) + // goto error; + // protocol__flexran_message__init(msg); + // msg->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG; + // msg->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__SUCCESSFUL_OUTCOME; + // msg->stats_reply_msg = stats_reply_msg; - data = flexran_agent_pack_message(msg, &size); + // data = flexran_agent_pack_message(msg, &size); - if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { + // if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { - err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; - goto error; - } + // err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; + // goto error; + // } - LOG_I(FLEXRAN_AGENT,"RRC Trigger is done \n"); + // LOG_I(FLEXRAN_AGENT,"RRC Trigger is done \n"); return; - error: + // error: - LOG_E(FLEXRAN_AGENT, "Could not send UE state message becasue of %d \n",err_code); + // LOG_E(FLEXRAN_AGENT, "Could not send UE state message becasue of %d \n",err_code); /* Free the measurement report received from UE. */ // ASN_STRUCT_FREE(asn_DEF_MeasResults, p->meas); /* Free the params. */ @@ -631,6 +483,98 @@ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults } +int flexran_agent_rrc_stats_reply(mid_t mod_id, + const report_config_t *report_config, + Protocol__FlexUeStatsReport **ue_report, + Protocol__FlexCellStatsReport **cell_report) { + + + // Protocol__FlexHeader *header; + int i, j, k; + // int cc_id = 0; + int enb_id = mod_id; + + /* Allocate memory for list of UE reports */ + if (report_config->nr_ue > 0) { + + for (i = 0; i < report_config->nr_ue; i++) { + + /* Check flag for creation of buffer status report */ + if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_RRC_MEASUREMENTS) { + + Protocol__FlexRrcMeasurements *rrc_measurements; + rrc_measurements = malloc(sizeof(Protocol__FlexRrcMeasurements)); + if (rrc_measurements == NULL) + goto error; + protocol__flex_rrc_measurements__init(rrc_measurements); + + if (triggered_rrc){ + rrc_measurements->measid = meas_stats[i].meas_id; + rrc_measurements->has_measid = 1; + + rrc_measurements->pcell_rsrp = meas_stats[i].rsrp; + rrc_measurements->has_pcell_rsrp = 1; + + rrc_measurements->pcell_rsrq = meas_stats[i].rsrq; + rrc_measurements->has_pcell_rsrq = 1 ; + + ue_report[i]->rrc_measurements = rrc_measurements; + // triggered_rrc = false; // To be decided later + } + } + } + } + + /* To be extended for RRC layer */ + // if (report_config->nr_cc > 0) { + + + // // Fill in the Cell reports + // for (i = 0; i < report_config->nr_cc; i++) { + + + // /* Check flag for creation of noise and interference report */ + // if(report_config->cc_report_type[i].cc_report_flags & PROTOCOL__FLEX_CELL_STATS_TYPE__FLCST_NOISE_INTERFERENCE) { + // // TODO: Fill in the actual noise and interference report for this cell + // Protocol__FlexNoiseInterferenceReport *ni_report; + // ni_report = malloc(sizeof(Protocol__FlexNoiseInterferenceReport)); + // if(ni_report == NULL) + // goto error; + // protocol__flex_noise_interference_report__init(ni_report); + // // Current frame and subframe number + // ni_report->sfn_sf = flexran_get_sfn_sf(enb_id); + // ni_report->has_sfn_sf = 1; + // //TODO:Received interference power in dbm + // ni_report->rip = 0; + // ni_report->has_rip = 1; + // //TODO:Thermal noise power in dbm + // ni_report->tnp = 0; + // ni_report->has_tnp = 1; + + // ni_report->p0_nominal_pucch = flexran_get_p0_nominal_pucch(enb_id, 0); + // ni_report->has_p0_nominal_pucch = 1; + // cell_report[i]->noise_inter_report = ni_report; + // } + // } + + + + + // } + + return 0; + + error: + + if (cell_report != NULL) + free(cell_report); + if (ue_report != NULL) + free(ue_report); + + return -1; +} + + int flexran_agent_register_rrc_xface(mid_t mod_id, AGENT_RRC_xface *xface) { if (rrc_agent_registered[mod_id]) { LOG_E(RRC, "RRC agent for eNB %d is already registered\n", mod_id); diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h index aa210f9d41..ae26b41621 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.h @@ -1,31 +1,23 @@ -/******************************************************************************* - 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 . - - Contact Information - OpenAirInterface Admin: openair_admin@eurecom.fr - OpenAirInterface Tech : openair_tech@eurecom.fr - OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr - - Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France. - - *******************************************************************************/ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ /*! \file flexran_agent_rrc.h * \brief FlexRAN agent Control Module RRC header @@ -65,6 +57,10 @@ int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg); /* this is called by RRC as a part of rrc xface . The controller previously requested this*/ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t *); +/* Statistics reply protocol message constructor and destructor */ +int flexran_agent_rrc_stats_reply(mid_t mod_id, const report_config_t *report_config, Protocol__FlexUeStatsReport **ue_report, Protocol__FlexCellStatsReport **cell_report); +int flexran_agent_rrc_destroy_stats_reply(Protocol__FlexranMessage *msg); + /*Register technology specific interface callbacks*/ int flexran_agent_register_rrc_xface(mid_t mod_id, AGENT_RRC_xface *xface); diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h index ad1375171e..a101bab242 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h @@ -1,31 +1,24 @@ -/******************************************************************************* - OpenAirInterface - Copyright(c) 1999 - 2016 Eurecom +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ - 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 . - - Contact Information - OpenAirInterface Admin: openair_admin@eurecom.fr - OpenAirInterface Tech : openair_tech@eurecom.fr - OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr - - Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France. - - *******************************************************************************/ /*! \file flexran_agent_rrc_defs.h * \brief FlexRAN agent - RRC interface primitives @@ -46,11 +39,24 @@ #define RINGBUFFER_SIZE 100 + +typedef struct +{ + int32_t rnti; + int32_t meas_id; + int32_t rsrp; + int32_t rsrq; + + /*To Be Extended*/ +}rrc_meas_stats; + +/* RRC CMI statistics */ +rrc_meas_stats * meas_stats; + + /* FLEXRAN AGENT-RRC Interface */ typedef struct { - /// Inform the controller about the scheduling requests received during the subframe - //void (*flexran_agent_send_update_rrc_stats)(mid_t mod_id); /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index d79051d201..18eb760cc3 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -132,6 +132,7 @@ message flex_enb_config_reply { optional flex_header header = 1; optional uint32 eNB_id = 2; // Unique id to distinguish the eNB repeated flex_cell_config cell_config = 3; + optional uint32 device_spec = 4; } message flex_ue_config_request { diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto index 0d8a565c06..a7d78841a3 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto @@ -242,3 +242,24 @@ message flex_eutra_ref_signal_meas { optional int32 rsrq = 2; } + +message flex_pdcp_stats { + + optional uint32 pkt_tx = 1; + optional uint32 pkt_tx_bytes = 2; + optional uint32 pkt_tx_sn = 3; + optional uint32 pkt_tx_rate_s = 4; + optional uint32 pkt_tx_throughput_s = 5; + optional uint32 pkt_tx_aiat = 7; + optional uint32 pkt_tx_aiat_s = 8; + + optional uint32 pkt_rx = 9; + optional uint32 pkt_rx_bytes = 10; + optional uint32 pkt_rx_sn = 11; + optional uint32 pkt_rx_rate_s = 12; + optional uint32 pkt_rx_goodput_s = 13; + optional uint32 pkt_rx_aiat = 14; + optional uint32 pkt_rx_aiat_s = 15; + optional uint32 pkt_rx_oo = 16; + } + diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto b/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto index 1ddb19722b..8cad6f4fbe 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto @@ -47,7 +47,8 @@ message flex_ue_stats_report { optional flex_dl_cqi_report dl_cqi_report = 7; optional flex_paging_buffer_report pbr = 8; optional flex_ul_cqi_report ul_cqi_report = 9; - optional flex_rrc_measurements rrc_measurements = 10; + optional flex_rrc_measurements rrc_measurements = 10; + optional flex_pdcp_stats pdcp_stats = 11; } // @@ -84,6 +85,9 @@ enum flex_ue_stats_type { FLUST_DL_CQI = 16; FLUST_PBS = 32; FLUST_UL_CQI = 64; + + FLUST_PDCP_STATS = 1024; // To be changed // To be extended with more types of stats FLUST_RRC_MEASUREMENTS = 65536; + } diff --git a/openair2/ENB_APP/MESSAGES/V2/time_common.proto b/openair2/ENB_APP/MESSAGES/V2/time_common.proto index 8bd2497443..baf0c0e9ae 100644 --- a/openair2/ENB_APP/MESSAGES/V2/time_common.proto +++ b/openair2/ENB_APP/MESSAGES/V2/time_common.proto @@ -26,5 +26,6 @@ message flex_ul_info { optional uint32 reception_status = 3; optional uint32 tpc = 4; optional uint32 serv_cell_index = 5; + optional uint32 rssi = 6; } diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index ec984cfa8b..23ac8f02ac 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -267,6 +267,9 @@ int flexran_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properti AGENT_RRC_xface *rrc_agent_xface = (AGENT_RRC_xface *) malloc(sizeof(AGENT_RRC_xface)); flexran_agent_register_rrc_xface(mod_id, rrc_agent_xface); + AGENT_PDCP_xface *pdcp_agent_xface = (AGENT_PDCP_xface *) malloc(sizeof(AGENT_PDCP_xface)); + flexran_agent_register_pdcp_xface(mod_id, pdcp_agent_xface); + /* * initilize a timer */ diff --git a/openair2/ENB_APP/flexran_agent.h b/openair2/ENB_APP/flexran_agent.h index 0ef48e2105..f9205c071f 100644 --- a/openair2/ENB_APP/flexran_agent.h +++ b/openair2/ENB_APP/flexran_agent.h @@ -38,6 +38,7 @@ #include "flexran_agent_ran_api.h" #include "flexran_agent_mac.h" #include "flexran_agent_rrc.h" +#include "flexran_agent_pdcp.h" #include "log.h" #include "assertions.h" diff --git a/openair2/ENB_APP/flexran_agent_defs.h b/openair2/ENB_APP/flexran_agent_defs.h index 0b8822a949..040a8192f6 100644 --- a/openair2/ENB_APP/flexran_agent_defs.h +++ b/openair2/ENB_APP/flexran_agent_defs.h @@ -32,11 +32,16 @@ #include #include #include +#include +#include #include "link_manager.h" #define NUM_MAX_ENB 2 +#define NUM_MAX_DRB 8 +#define NUM_MAX_SRB 3 #define NUM_MAX_UE 2048 +#define DEFAULT_DRB 3 #define DEFAULT_FLEXRAN_AGENT_IPv4_ADDRESS "127.0.0.1" #define DEFAULT_FLEXRAN_AGENT_PORT 2210 #define DEFAULT_FLEXRAN_AGENT_CACHE "/mnt/oai_agent_cache" diff --git a/openair2/ENB_APP/flexran_agent_extern.h b/openair2/ENB_APP/flexran_agent_extern.h index 4df984e1a0..a9af552856 100644 --- a/openair2/ENB_APP/flexran_agent_extern.h +++ b/openair2/ENB_APP/flexran_agent_extern.h @@ -33,6 +33,7 @@ // #include "flexran_agent_defs.h" #include "flexran_agent_mac_defs.h" #include "flexran_agent_rrc_defs.h" +#include "flexran_agent_pdcp_defs.h" //extern msg_context_t shared_ctxt[NUM_MAX_ENB][FLEXRAN_AGENT_MAX]; @@ -51,6 +52,12 @@ extern AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]; /* Flag indicating whether the VSFs for the RRC control module have been registered */ extern unsigned int rrc_agent_registered[NUM_MAX_ENB]; +/* Control module interface for the communication of the RRC Control Module with the agent */ +extern AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB]; + +/* Flag indicating whether the VSFs for the RRC control module have been registered */ +extern unsigned int pdcp_agent_registered[NUM_MAX_ENB]; + /* Requried to know which UEs had a harq updated over some subframe */ extern int harq_pid_updated[NUMBER_OF_UE_MAX][8]; extern int harq_pid_round[NUMBER_OF_UE_MAX][8]; diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index fc2ed135c8..6ad0b88975 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -143,7 +143,7 @@ void * flexran_agent_pack_message(Protocol__FlexranMessage *msg, DevAssert(buffer !=NULL); - LOG_D(FLEXRAN_AGENT,"Serilized the enb mac stats reply (size %d)\n", *size); + LOG_D(FLEXRAN_AGENT,"Serilized the eNB-UE stats reply (size %d)\n", *size); return buffer; @@ -457,7 +457,7 @@ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *re } - /* + /* MAC reply split */ @@ -467,7 +467,26 @@ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *re goto error; } - + /* + RRC reply split + */ + + if (flexran_agent_rrc_stats_reply(enb_id, report_config, ue_report, cell_report) < 0 ) { + err_code = PROTOCOL__FLEXRAN_ERR__MSG_BUILD; + goto error; + } + + + /* + PDCP reply split + */ + + if (flexran_agent_pdcp_stats_reply(enb_id, report_config, ue_report, cell_report) < 0 ) { + err_code = PROTOCOL__FLEXRAN_ERR__MSG_BUILD; + goto error; + } + + stats_reply_msg->cell_report = cell_report; stats_reply_msg->ue_report = ue_report; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 0d3145e1d2..01f05b1ba5 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -179,6 +179,17 @@ int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t chann return rlc_status.bytes_in_buffer; } + +int flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); + uint16_t subframe = (uint16_t) flexran_get_current_subframe(mod_id); + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); + return rlc_status.pdus_in_buffer; +} + + + int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); @@ -1077,6 +1088,85 @@ void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_ enb_properties->properties[mod_id]->frame_type[cc_id]=frame_type; } +/*********** PDCP *************/ + +/*PDCP num tx pdu status flexRAN*/ +uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + if (mod_id <0 || mod_id> MAX_NUM_CCs || ue_id<0 || ue_id> NUMBER_OF_UE_MAX || lcid<0 || lcid>NB_RB_MAX) + return -1; + return Pdcp_stats_tx[mod_id][ue_id][lcid]; +} + +/*PDCP num tx bytes status flexRAN*/ +uint32_t flexran_get_pdcp_tx_bytes(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_bytes[mod_id][ue_id][lcid]; +} + +/*PDCP number of transmit packet / second status flexRAN*/ +uint32_t flexran_get_pdcp_tx_rate_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_rate_s[mod_id][ue_id][lcid]; +} + +/*PDCP throughput (bit/s) status flexRAN*/ +uint32_t flexran_get_pdcp_tx_throughput_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_throughput_s[mod_id][ue_id][lcid]; +} + +/*PDCP tx sequence number flexRAN*/ +uint32_t flexran_get_pdcp_tx_sn(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_sn[mod_id][ue_id][lcid]; +} + +/*PDCP tx aggregated packet arrival flexRAN*/ +uint32_t flexran_get_pdcp_tx_aiat(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_aiat[mod_id][ue_id][lcid]; +} + +/*PDCP tx aggregated packet arrival flexRAN*/ +uint32_t flexran_get_pdcp_tx_aiat_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_aiat_s[mod_id][ue_id][lcid]; +} + + +/*PDCP num rx pdu status flexRAN*/ +uint32_t flexran_get_pdcp_rx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx[mod_id][ue_id][lcid]; +} + +/*PDCP num rx bytes status flexRAN*/ +uint32_t flexran_get_pdcp_rx_bytes(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_bytes[mod_id][ue_id][lcid]; +} + +/*PDCP number of received packet / second flexRAN*/ +uint32_t flexran_get_pdcp_rx_rate_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_rate_s[mod_id][ue_id][lcid]; +} + +/*PDCP gootput (bit/s) status flexRAN*/ +uint32_t flexran_get_pdcp_rx_goodput_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_goodput_s[mod_id][ue_id][lcid]; +} + +/*PDCP rx sequence number flexRAN*/ +uint32_t flexran_get_pdcp_rx_sn(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_sn[mod_id][ue_id][lcid]; +} + +/*PDCP rx aggregated packet arrival flexRAN*/ +uint32_t flexran_get_pdcp_rx_aiat(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_aiat[mod_id][ue_id][lcid]; +} + +/*PDCP rx aggregated packet arrival flexRAN*/ +uint32_t flexran_get_pdcp_rx_aiat_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_aiat_s[mod_id][ue_id][lcid]; +} + +/*PDCP num of received outoforder pdu status flexRAN*/ +uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_outoforder[mod_id][ue_id][lcid]; +} diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 9f0313c1ca..4d84251608 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -39,6 +39,7 @@ #include "LAYER2/MAC/extern.h" #include "LAYER2/RLC/rlc.h" #include "SCHED/defs.h" +#include "pdcp.h" #include "RRC/LITE/extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "RRC/LITE/rrc_eNB_UE_context.h" @@ -91,6 +92,9 @@ int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id); /* Get the transmission queue size for a UE with a channel_id logical channel id */ int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); +/*Get number of pdus in RLC buffer*/ +int flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); + /* Get the head of line delay for a UE with a channel_id logical channel id */ int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); @@ -334,3 +338,54 @@ void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_ /*RRC status flexRAN*/ int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); + + +/***************************** PDCP ***********************/ + +/*PDCP num tx pdu status flexRAN*/ +uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP num tx bytes status flexRAN*/ +uint32_t flexran_get_pdcp_tx_bytes(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP number of transmit packet / second status flexRAN*/ +uint32_t flexran_get_pdcp_tx_rate_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP throughput (bit/s) status flexRAN*/ +uint32_t flexran_get_pdcp_tx_throughput_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP tx sequence number flexRAN*/ +uint32_t flexran_get_pdcp_tx_sn(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP tx aggregated packet arrival flexRAN*/ +uint32_t flexran_get_pdcp_tx_aiat(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP tx aggregated packet arrival per second flexRAN*/ +uint32_t flexran_get_pdcp_tx_aiat_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + + +/*PDCP num rx pdu status flexRAN*/ +uint32_t flexran_get_pdcp_rx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP num rx bytes status flexRAN*/ +uint32_t flexran_get_pdcp_rx_bytes(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP number of received packet / second flexRAN*/ +uint32_t flexran_get_pdcp_rx_rate_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP gootput (bit/s) status flexRAN*/ +uint32_t flexran_get_pdcp_rx_goodput_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP rx sequence number flexRAN*/ +uint32_t flexran_get_pdcp_rx_sn(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP rx aggregated packet arrival flexRAN*/ +uint32_t flexran_get_pdcp_rx_aiat(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP rx aggregated packet arrival per second flexRAN*/ +uint32_t flexran_get_pdcp_rx_aiat_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + +/*PDCP num of received outoforder pdu status flexRAN*/ +uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); + + diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 8dad83a90a..397a194edf 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -69,6 +69,7 @@ extern int otg_enabled; #endif + //----------------------------------------------------------------------------- /* * If PDCP_UNIT_TEST is set here then data flow between PDCP and RLC is broken @@ -102,6 +103,8 @@ boolean_t pdcp_data_req( hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; + uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 : 0; + uint16_t pdcp_uid=0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_IN); CHECK_CTXT_ARGS(ctxt_pP); @@ -152,7 +155,7 @@ boolean_t pdcp_data_req( ctxt_pP->configured=TRUE; } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); } else { start_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); @@ -223,7 +226,7 @@ boolean_t pdcp_data_req( 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) { + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); } else { stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); @@ -241,8 +244,9 @@ boolean_t pdcp_data_req( if (pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer((unsigned char*)pdcp_pdu_p->data, &pdu_header) == FALSE) { 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_YES) { - 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); @@ -264,7 +268,7 @@ boolean_t pdcp_data_req( free_mem_block(pdcp_pdu_p, __func__); - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); } else { stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); @@ -292,7 +296,7 @@ boolean_t pdcp_data_req( (((pdcp_p->cipheringAlgorithm) != 0) || ((pdcp_p->integrityProtAlgorithm) != 0))) { - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].apply_security); } else { start_meas(&UE_pdcp_stats[ctxt_pP->module_id].apply_security); @@ -387,7 +391,7 @@ boolean_t pdcp_data_req( break; } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); } else { stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); @@ -397,16 +401,45 @@ boolean_t pdcp_data_req( * Control arrives here only if rlc_data_req() returns RLC_OP_STATUS_OK * so we return TRUE afterwards */ - /* - if (rb_id>=DTCH) { - if (ctxt_pP->enb_flag == 1) { - Pdcp_stats_tx[module_id][(rb_id & RAB_OFFSET2 )>> RAB_SHIFT2][(rb_id & RAB_OFFSET)-DTCH]++; - Pdcp_stats_tx_bytes[module_id][(rb_id & RAB_OFFSET2 )>> RAB_SHIFT2][(rb_id & RAB_OFFSET)-DTCH] += sdu_buffer_size; - } else { - Pdcp_stats_tx[module_id][(rb_id & RAB_OFFSET2 )>> RAB_SHIFT2][(rb_id & RAB_OFFSET)-DTCH]++; - Pdcp_stats_tx_bytes[module_id][(rb_id & RAB_OFFSET2 )>> RAB_SHIFT2][(rb_id & RAB_OFFSET)-DTCH] += sdu_buffer_size; - } - }*/ + + for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + if (pdcp_p->rnti[pdcp_uid] == ctxt_pP->rnti ) + break; + } + + //LOG_I(PDCP,"ueid %d lcid %d tx seq num %d\n", pdcp_uid, rb_idP+rb_offset, current_sn); + Pdcp_stats_tx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; + Pdcp_stats_tx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=current_sn; + + if (Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset] < pdcp_frame *10 + pdcp_subframe) { + Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + } + else { + Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 + pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 + pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + } + + + Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=ctxt_pP->frame*10+ctxt_pP->subframe; + + if (pdcp_frame % 100 == 0 ) { + Pdcp_stats_tx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]= Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]; + Pdcp_stats_tx_throughput_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]*8/1000; + Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]; + + Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; + Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; + Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; + }else { + Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; + + } + + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); return ret; @@ -436,6 +469,9 @@ pdcp_data_ind( boolean_t packet_forwarded = FALSE; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; + uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 :0; + uint16_t pdcp_uid=0; + uint8_t oo_flag=0; #if defined(LINK_ENB_PDCP_TO_GTPV1U) MessageDef *message_p = NULL; uint8_t *gtpu_buffer_p = NULL; @@ -590,6 +626,7 @@ pdcp_data_ind( else LOG_D(PDCP, "Passing piggybacked SDU to RRC ...\n");*/ } else { + oo_flag=1; 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), @@ -789,6 +826,53 @@ pdcp_data_ind( 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; + + /* Print octets of incoming data in hexadecimal form */ + LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", + sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t), + sdu_buffer_sizeP - payload_offset); + //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); + //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); + + /* + * Update PDCP statistics + * XXX Following two actions are identical, is there a merge error? + */ + + for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + if (pdcp_p->rnti[pdcp_uid] == ctxt_pP->rnti ) + break; + } + + Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP - payload_offset; + + Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; + + if (oo_flag == 1 ) + Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + + if (Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset] < pdcp_frame * 10 + pdcp_subframe) { + Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_frame *10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_frame *10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + } else { + Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 +pdcp_frame * 10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(1024 +pdcp_frame * 10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + } + Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_frame * 10 +pdcp_subframe; + + if (pdcp_frame % 102 == 0) { + Pdcp_stats_rx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]; + Pdcp_stats_rx_goodput_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]*8/1023; + Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]= Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]; + + Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; + Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; + Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; + }else { + Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); + } } #else @@ -842,25 +926,8 @@ pdcp_data_ind( sdu_buffer_sizeP - payload_offset); list_add_tail_eurecom (new_sdu_p, sdu_list_p); - /* Print octets of incoming data in hexadecimal form */ - LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", - sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t), - sdu_buffer_sizeP - payload_offset); - //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); - //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); - - /* - * Update PDCP statistics - * XXX Following two actions are identical, is there a merge error? - */ - - /*if (ctxt_pP->enb_flag == 1) { - Pdcp_stats_rx[module_id][(rb_idP & RAB_OFFSET2) >> RAB_SHIFT2][(rb_idP & RAB_OFFSET) - DTCH]++; - Pdcp_stats_rx_bytes[module_id][(rb_idP & RAB_OFFSET2) >> RAB_SHIFT2][(rb_idP & RAB_OFFSET) - DTCH] += sdu_buffer_sizeP; - } else { - Pdcp_stats_rx[module_id][(rb_idP & RAB_OFFSET2) >> RAB_SHIFT2][(rb_idP & RAB_OFFSET) - DTCH]++; - Pdcp_stats_rx_bytes[module_id][(rb_idP & RAB_OFFSET2) >> RAB_SHIFT2][(rb_idP & RAB_OFFSET) - DTCH] += sdu_buffer_sizeP; - }*/ + + } } @@ -891,6 +958,9 @@ pdcp_run ( ) //----------------------------------------------------------------------------- { + + pdcp_frame =ctxt_pP->frame; + pdcp_subframe= ctxt_pP->subframe; #if defined(ENABLE_ITTI) MessageDef *msg_p; const char *msg_name; @@ -1139,7 +1209,7 @@ rrc_pdcp_config_asn1_req ( return TRUE; } else { - LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64"\n", + LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64"\n", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), key); } @@ -1470,12 +1540,19 @@ pdcp_config_req_asn1 ( uint8_t *const kUPenc_pP) //----------------------------------------------------------------------------- { - + int i; switch (actionP) { case CONFIG_ACTION_ADD: DevAssert(pdcp_pP != NULL); if (ctxt_pP->enb_flag == ENB_FLAG_YES) { pdcp_pP->is_ue = FALSE; + for (i=0; i < NUMBER_OF_UE_MAX; i++) { + if (pdcp_pP->rnti[i] != 0 ) continue ; // skip active ues + pdcp_pP->rnti[i]=ctxt_pP->rnti; + pdcp_pP->uid[i]=i; + pdcp_num_ues++; + break; + } //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti; pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; @@ -1575,6 +1652,18 @@ pdcp_config_req_asn1 ( lc_idP, rb_idP); + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { + + for (i=0; i < NUMBER_OF_UE_MAX; i++) { + if (pdcp_pP->rnti[i] == ctxt_pP->rnti ) { + pdcp_pP->rnti[i]=0; + pdcp_pP->uid[i]=0; + pdcp_num_ues--; + break; + } + } + } + /* Security keys */ if (pdcp_pP->kUPenc != NULL) { free(pdcp_pP->kUPenc); @@ -1826,13 +1915,14 @@ rrc_pdcp_config_req ( //----------------------------------------------------------------------------- -// TODO PDCP module initialization code might be removed + int pdcp_module_init ( void ) //----------------------------------------------------------------------------- { + #ifdef PDCP_USE_RT_FIFO int ret; @@ -1952,14 +2042,27 @@ void pdcp_layer_init(void) pdcp_input_sdu_remaining_size_to_read=0; memset(Pdcp_stats_tx, 0, sizeof(Pdcp_stats_tx)); + memset(Pdcp_stats_tx_s, 0, sizeof(Pdcp_stats_tx_s)); memset(Pdcp_stats_tx_bytes, 0, sizeof(Pdcp_stats_tx_bytes)); - memset(Pdcp_stats_tx_bytes_last, 0, sizeof(Pdcp_stats_tx_bytes_last)); - memset(Pdcp_stats_tx_rate, 0, sizeof(Pdcp_stats_tx_rate)); + memset(Pdcp_stats_tx_bytes_s, 0, sizeof(Pdcp_stats_tx_bytes_s)); + memset(Pdcp_stats_tx_rate_s, 0, sizeof(Pdcp_stats_tx_rate_s)); + memset(Pdcp_stats_tx_sn, 0, sizeof(Pdcp_stats_tx_sn)); + memset(Pdcp_stats_tx_throughput_s, 0, sizeof(Pdcp_stats_tx_throughput_s)); + memset(Pdcp_stats_tx_aiat, 0, sizeof(Pdcp_stats_tx_aiat)); + memset(Pdcp_stats_tx_iat, 0, sizeof(Pdcp_stats_tx_iat)); + memset(Pdcp_stats_rx, 0, sizeof(Pdcp_stats_rx)); + memset(Pdcp_stats_rx_s, 0, sizeof(Pdcp_stats_rx_s)); memset(Pdcp_stats_rx_bytes, 0, sizeof(Pdcp_stats_rx_bytes)); - memset(Pdcp_stats_rx_bytes_last, 0, sizeof(Pdcp_stats_rx_bytes_last)); - memset(Pdcp_stats_rx_rate, 0, sizeof(Pdcp_stats_rx_rate)); + memset(Pdcp_stats_rx_bytes_s, 0, sizeof(Pdcp_stats_rx_bytes_s)); + memset(Pdcp_stats_rx_rate_s, 0, sizeof(Pdcp_stats_rx_rate_s)); + memset(Pdcp_stats_rx_sn, 0, sizeof(Pdcp_stats_rx_sn)); + memset(Pdcp_stats_rx_goodput_s, 0, sizeof(Pdcp_stats_rx_goodput_s)); + memset(Pdcp_stats_rx_aiat, 0, sizeof(Pdcp_stats_rx_aiat)); + memset(Pdcp_stats_rx_iat, 0, sizeof(Pdcp_stats_rx_iat)); + memset(Pdcp_stats_rx_outoforder, 0, sizeof(Pdcp_stats_rx_outoforder)); + } //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 94084273d1..fb3e02b299 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -94,15 +94,41 @@ extern int pdcp_instance_cnt; int init_pdcp_thread(void); void cleanup_pdcp_thread(void); +public_pdcp(frame_t pdcp_frame); +public_pdcp(sub_frame_t pdcp_subframe); +public_pdcp(uint16_t pdcp_num_ues); + + +public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_rate_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_throughput_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); + +public_pdcp(uint32_t Pdcp_stats_rx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_rate_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_goodput_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); + + +/*Packet Probing for agent PDCP*/ +//public_pdcp(uint64_t *pdcp_packet_counter); +//public_pdcp(uint64_t *pdcp_size_packet); -public_pdcp(unsigned int Pdcp_stats_tx[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_MAX]); -public_pdcp(unsigned int Pdcp_stats_tx_bytes[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_MAX]); -public_pdcp(unsigned int Pdcp_stats_tx_bytes_last[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_MAX]); -public_pdcp(unsigned int Pdcp_stats_tx_rate[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_MAX]); -public_pdcp(unsigned int Pdcp_stats_rx[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_MAX]); -public_pdcp(unsigned int Pdcp_stats_rx_bytes[NB_MODULES_MAX][NB_CNX_CH][NB_RAB_MAX]); -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_s { time_stats_t pdcp_run; @@ -125,6 +151,10 @@ typedef struct pdcp_s { boolean_t is_ue; boolean_t is_srb; + // used for eNB stats generation + uint16_t uid[NUMBER_OF_UE_MAX]; // local to pdcp + rnti_t rnti[NUMBER_OF_UE_MAX]; + /* Configured security algorithms */ uint8_t cipheringAlgorithm; uint8_t integrityProtAlgorithm; From 5e20c970e991ca0854bbf0c0754f4b135c0a8ed9 Mon Sep 17 00:00:00 2001 From: shahab Date: Sat, 9 Dec 2017 17:41:06 +0100 Subject: [PATCH 037/141] warning decreasing --- .../CONTROL_MODULES/PDCP/flexran_agent_pdcp.c | 2 +- .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 8 +++----- openair2/ENB_APP/flexran_agent_async.c | 4 ++-- openair2/ENB_APP/flexran_agent_common_internal.c | 7 ++----- openair2/ENB_APP/flexran_agent_handler.c | 2 +- openair2/ENB_APP/flexran_agent_net_comm.c | 8 ++++---- openair2/ENB_APP/flexran_agent_ran_api.c | 14 ++++---------- openair2/UTIL/ASYNC_IF/ringbuffer_queue.c | 2 +- openair2/UTIL/ASYNC_IF/ringbuffer_queue.h | 2 +- 9 files changed, 19 insertions(+), 30 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c index ecc40cd89a..4aa2e691b9 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c @@ -77,7 +77,7 @@ int flexran_agent_pdcp_stats_reply(mid_t mod_id, // Protocol__FlexHeader *header; - int i, j, k; + int i; // int cc_id = 0; diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index e70d2a3d97..587ac8c263 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -262,11 +262,11 @@ int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg) { /* this is called by RRC as a part of rrc xface . The controller previously requested this*/ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults) { - int i, m, k; + int i; // int priority = 0; // Warning Preventing // void *data; // int size; - err_code_t err_code = -100; + // err_code_t err_code = -100; triggered_rrc = true; int num; @@ -490,9 +490,7 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id, // Protocol__FlexHeader *header; - int i, j, k; - // int cc_id = 0; - int enb_id = mod_id; + int i; /* Allocate memory for list of UE reports */ if (report_config->nr_ue > 0) { diff --git a/openair2/ENB_APP/flexran_agent_async.c b/openair2/ENB_APP/flexran_agent_async.c index 978b44929d..7b7bb89d6c 100644 --- a/openair2/ENB_APP/flexran_agent_async.c +++ b/openair2/ENB_APP/flexran_agent_async.c @@ -68,12 +68,12 @@ flexran_agent_async_channel_t * flexran_agent_async_channel_info(mid_t mod_id, c error: LOG_I(FLEXRAN_AGENT,"there was an error\n"); - return 1; + return NULL; } int flexran_agent_async_msg_send(void *data, int size, int priority, void *channel_info) { flexran_agent_async_channel_t *channel; - channel = (flexran_agent_channel_t *)channel_info; + channel = (flexran_agent_async_channel_t *)channel_info; return message_put(channel->send_queue, data, size, priority); } diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index fca73894c5..839fb4c784 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -129,10 +129,8 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy int parse_enb_id(mid_t mod_id, yaml_parser_t *parser) { yaml_event_t event; - void *param; char *endptr; - int is_array = 0; - int i = 0; + // int is_array; int done = 0; int mapping_started = 0; @@ -145,7 +143,7 @@ int parse_enb_id(mid_t mod_id, yaml_parser_t *parser) { switch (event.type) { // We are expecting a mapping of parameters case YAML_SEQUENCE_START_EVENT: - is_array = 1; + // is_array = 1; break; case YAML_MAPPING_START_EVENT: LOG_D(ENB_APP, "The mapping of the parameters started\n"); @@ -193,7 +191,6 @@ int parse_enb_id(mid_t mod_id, yaml_parser_t *parser) { int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) { yaml_event_t event; - void *param; char *endptr; int done = 0; diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index 6ad0b88975..2a36b3e5c8 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -30,6 +30,7 @@ #include "flexran_agent_common.h" #include "flexran_agent_mac.h" #include "flexran_agent_rrc.h" +#include "flexran_agent_pdcp.h" #include "flexran_agent_timer.h" #include "flexran_agent_ran_api.h" #include "log.h" @@ -97,7 +98,6 @@ Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id, err_code= PROTOCOL__FLEXRAN_ERR__MSG_DECODING; goto error; } - // printf("==================> %d %d \n", decoded_message->msg_case, decoded_message->msg_dir); if ((decoded_message->msg_case > sizeof(agent_messages_callback) / (3 * sizeof(flexran_agent_message_decoded_callback))) || (decoded_message->msg_dir > PROTOCOL__FLEXRAN_DIRECTION__UNSUCCESSFUL_OUTCOME)){ err_code= PROTOCOL__FLEXRAN_ERR__MSG_NOT_HANDLED; diff --git a/openair2/ENB_APP/flexran_agent_net_comm.c b/openair2/ENB_APP/flexran_agent_net_comm.c index f8e350d6a9..d801bbdda5 100644 --- a/openair2/ENB_APP/flexran_agent_net_comm.c +++ b/openair2/ENB_APP/flexran_agent_net_comm.c @@ -141,9 +141,9 @@ int flexran_agent_destroy_channel(int channel_id) { for (i = 0; i < NUM_MAX_ENB; i++) { for (j = 0; j < FLEXRAN_AGENT_MAX; j++) { if (agent_channel[i][j] != NULL) { - if (agent_channel[i][j]->channel_id == e->channel_id) { - agent_channel[i][j] == NULL; - } + if (agent_channel[i][j]->channel_id == e->channel_id) { + free(agent_channel[i][j]); + } } } } @@ -164,7 +164,7 @@ err_code_t flexran_agent_init_channel_container(void) { for (i = 0; i < NUM_MAX_ENB; i++) { for (j = 0; j < FLEXRAN_AGENT_MAX; j++) { - agent_channel[i][j] == NULL; + agent_channel[i][j] = malloc(sizeof(flexran_agent_channel_t)); } } diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 01f05b1ba5..280b9807fd 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -38,6 +38,7 @@ void * enb[NUM_MAX_ENB]; void * enb_ue[NUM_MAX_ENB]; void * enb_rrc[NUM_MAX_ENB]; +Enb_properties_array_t* enb_properties; void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ @@ -47,10 +48,12 @@ void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ enb[mod_id] = NULL; enb_ue[mod_id] = NULL; enb_rrc[mod_id] = NULL; + enb_properties = NULL; }else{ enb[mod_id] = (void *)&eNB_mac_inst[mod_id]; enb_ue[mod_id] = (void *)&eNB_mac_inst[mod_id].UE_list; enb_rrc[mod_id] = (void *)&eNB_rrc_inst[mod_id]; + enb_properties = (Enb_properties_array_t *) enb_config_get(); } break; default : @@ -1039,52 +1042,43 @@ int flexran_get_antenna_ports(mid_t mod_id, int CC_id){ uint32_t flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id) { - const Enb_properties_array_t* enb_properties = enb_config_get(); + return (enb_properties->properties[mod_id]->downlink_frequency[cc_id] / 1000000); } uint32_t flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id) { - const Enb_properties_array_t* enb_properties = enb_config_get(); return ((enb_properties->properties[mod_id]->downlink_frequency[cc_id] + enb_properties->properties[0]->uplink_frequency_offset[cc_id]) / 1000000); } int flexran_agent_get_operating_eutra_band (mid_t mod_id, int cc_id) { - const Enb_properties_array_t* enb_properties = enb_config_get(); return enb_properties->properties[mod_id]->eutra_band[cc_id]; } int flexran_agent_get_operating_pdsch_refpower (mid_t mod_id, int cc_id) { - const Enb_properties_array_t* enb_properties = enb_config_get(); return enb_properties->properties[mod_id]->pdsch_referenceSignalPower[cc_id]; } int flexran_agent_get_operating_pusch_p0 (mid_t mod_id, int cc_id) { - const Enb_properties_array_t* enb_properties = enb_config_get(); return enb_properties->properties[mod_id]->pusch_p0_Nominal[cc_id]; } void flexran_agent_set_operating_dl_freq (mid_t mod_id, int cc_id, uint32_t dl_freq_mhz) { - Enb_properties_array_t* enb_properties = enb_config_get(); enb_properties->properties[mod_id]->downlink_frequency[cc_id]=dl_freq_mhz * 1000000; /*printf("[ENB_APP] mod id %d ccid %d dl freq %d/%d\n", mod_id, cc_id, dl_freq_mhz, enb_properties->properties[mod_id]->downlink_frequency[cc_id]); */ } void flexran_agent_set_operating_ul_freq (mid_t mod_id, int cc_id, int32_t ul_freq_offset_mhz) { - Enb_properties_array_t* enb_properties = enb_config_get(); enb_properties->properties[mod_id]->uplink_frequency_offset[cc_id]=ul_freq_offset_mhz * 1000000; } //TBD void flexran_agent_set_operating_eutra_band (mid_t mod_id, int cc_id) { - Enb_properties_array_t* enb_properties = enb_config_get(); enb_properties->properties[mod_id]->eutra_band[cc_id]=7; } void flexran_agent_set_operating_bandwidth (mid_t mod_id, int cc_id, int bandwidth) { - Enb_properties_array_t* enb_properties = enb_config_get(); enb_properties->properties[mod_id]->N_RB_DL[cc_id]=bandwidth; } void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_type) { - Enb_properties_array_t* enb_properties = enb_config_get(); enb_properties->properties[mod_id]->frame_type[cc_id]=frame_type; } diff --git a/openair2/UTIL/ASYNC_IF/ringbuffer_queue.c b/openair2/UTIL/ASYNC_IF/ringbuffer_queue.c index 047e3f716c..0c4bb1dfbb 100644 --- a/openair2/UTIL/ASYNC_IF/ringbuffer_queue.c +++ b/openair2/UTIL/ASYNC_IF/ringbuffer_queue.c @@ -117,7 +117,7 @@ int message_get(message_queue_t *queue, void **data, int *size, int *priority) { return 0; } -message_queue_t destroy_message_queue(message_queue_t *queue) { +void destroy_message_queue(message_queue_t *queue) { struct lfds700_misc_prng_state ls; message_t *m; diff --git a/openair2/UTIL/ASYNC_IF/ringbuffer_queue.h b/openair2/UTIL/ASYNC_IF/ringbuffer_queue.h index 7dc4637404..bdc5adce99 100644 --- a/openair2/UTIL/ASYNC_IF/ringbuffer_queue.h +++ b/openair2/UTIL/ASYNC_IF/ringbuffer_queue.h @@ -48,6 +48,6 @@ typedef struct { message_queue_t * new_message_queue(int size); int message_put(message_queue_t *queue, void *data, int size, int priority); int message_get(message_queue_t *queue, void **data, int *size, int *priority); -message_queue_t destroy_message_queue(message_queue_t *queue); +void destroy_message_queue(message_queue_t *queue); #endif /* RINGBUFFER_QUEUE_H */ From cd74f4d61b20cfacb71a10cea80ba24f6ad85626 Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Sun, 10 Dec 2017 16:19:27 +0100 Subject: [PATCH 038/141] Message balance --- .../ENB_APP/MESSAGES/V2/config_messages.proto | 2 +- .../MESSAGES/V2/control_delegation.proto | 2 +- .../MESSAGES/V2/controller_commands.proto | 8 +- openair2/ENB_APP/MESSAGES/V2/flexran.proto | 22 +--- openair2/ENB_APP/MESSAGES/V2/header.proto | 3 +- .../ENB_APP/MESSAGES/V2/mac_primitives.proto | 37 ------ .../ENB_APP/MESSAGES/V2/stats_common.proto | 106 +++++++++--------- .../ENB_APP/MESSAGES/V2/stats_messages.proto | 12 +- .../ENB_APP/MESSAGES/V2/time_common.proto | 4 +- openair2/ENB_APP/flexran_agent_common.c | 8 -- 10 files changed, 70 insertions(+), 134 deletions(-) diff --git a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto index 657f362873..995865f1ab 100644 --- a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto +++ b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto @@ -38,7 +38,7 @@ message flex_cell_config { optional uint32 srs_mac_up_pts = 32; // Boolean value. See TS 36.211, section 5.5.3.2. TDD only optional uint32 enable_64QAM = 33; // One of the FLEQ_* enum values optional uint32 carrier_index = 34; // Carrier component index - optional uint32 dl_freq = 35; // operating downlink frequency + optional uint32 dl_freq = 35; // operating downlink frequency optional uint32 ul_freq = 36; // operating uplink frequency optional uint32 eutra_band= 37; // operating band optional int32 dl_pdsch_power = 38; // operating downlink power diff --git a/openair2/ENB_APP/MESSAGES/V2/control_delegation.proto b/openair2/ENB_APP/MESSAGES/V2/control_delegation.proto index 0f7e34de15..ef0eea3bd2 100644 --- a/openair2/ENB_APP/MESSAGES/V2/control_delegation.proto +++ b/openair2/ENB_APP/MESSAGES/V2/control_delegation.proto @@ -3,4 +3,4 @@ package protocol; enum flex_control_delegation_type { FLCDT_MAC_DL_UE_SCHEDULER = 1; // DL UE scheduler delegation -} \ No newline at end of file +} diff --git a/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto b/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto index eeda90b8cb..6f30ea4755 100644 --- a/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto +++ b/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto @@ -4,7 +4,7 @@ package protocol; import "mac_primitives.proto"; // -// Body of UE DL/UL MAC scheduling configuration info +// Body of UE DL MAC scheduling configuration info // message flex_dl_data { @@ -16,12 +16,6 @@ message flex_dl_data { optional uint32 act_deact_ce = 6; //Hex content of MAC CE for Activation/Deactivation in CA } - -message flex_ul_data { - optional uint32 rnti = 1; - optional flex_ul_dci ul_dci = 2; -} - // // Body of the RAR scheduler configuration // diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index 18eb760cc3..45a139b73a 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -8,6 +8,7 @@ import "config_messages.proto"; import "controller_commands.proto"; import "control_delegation.proto"; + message flexran_message { optional flexran_direction msg_dir = 100; oneof msg { @@ -24,12 +25,11 @@ message flexran_message { flex_ue_config_reply ue_config_reply_msg = 11; flex_lc_config_request lc_config_request_msg = 12; flex_lc_config_reply lc_config_reply_msg = 13; - flex_dl_mac_config dl_mac_config_msg = 14; + flex_dl_mac_config dl_mac_config_msg = 14; flex_ue_state_change ue_state_change_msg = 15; flex_control_delegation control_delegation_msg = 16; flex_agent_reconfiguration agent_reconfiguration_msg = 17; flex_rrc_triggering rrc_triggering = 18; - flex_ul_mac_config ul_mac_config_msg = 19; } } @@ -166,22 +166,6 @@ message flex_dl_mac_config { repeated flex_pdcch_ofdm_sym_count ofdm_sym = 6; // OFDM symbol count for each CC } - -message flex_ul_mac_config { - optional flex_header header = 1; - optional uint32 sfn_sf = 2; - repeated flex_ul_data ul_ue_data = 3; -} - - -message flex_rrc_triggering { - - optional flex_header header = 1; - optional string rrc_trigger = 2; -} - - - // // UE state change message // @@ -209,7 +193,7 @@ message flex_control_delegation { message flex_agent_reconfiguration { optional flex_header header = 1; - optional string policy = 2; // The policy changes using YAML syntax in string format + optional string policy = 2; // The policy changes using YAML syntax in string format } // Extensions of the echo request and reply diff --git a/openair2/ENB_APP/MESSAGES/V2/header.proto b/openair2/ENB_APP/MESSAGES/V2/header.proto index 4f03e0755e..12110de24e 100644 --- a/openair2/ENB_APP/MESSAGES/V2/header.proto +++ b/openair2/ENB_APP/MESSAGES/V2/header.proto @@ -33,7 +33,7 @@ enum flex_type { //Controller command messages FLPT_DL_MAC_CONFIG = 13; - + // UE state change messages FLPT_UE_STATE_CHANGE = 14; @@ -41,6 +41,5 @@ enum flex_type { FLPT_DELEGATE_CONTROL = 15; FLPT_RECONFIGURE_AGENT = 16; FLPT_RRC_TRIGGERING = 17; - FLPT_UL_MAC_CONFIG = 18; } diff --git a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto index a34e9b6eaf..d3acb51318 100644 --- a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto +++ b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto @@ -36,37 +36,6 @@ message flex_dl_dci { optional uint32 cif = 27; // CIF for cross-carrier scheduling } -message flex_ul_dci { - optional uint32 rnti = 1; - optional uint32 rb_start = 2; // The start RB allocated to the UE - optional uint32 rb_len = 3; // The number of RBs allocated to the UE - optional uint32 mcs = 4; // Modulation and coding scheme - optional uint32 cyclic_shift2 = 5; // match DCI format 0/4 PDU - optional uint32 freq_hop_flag = 6; // 0 no hopping, 1 hoppping - optional uint32 freq_hop_map = 7; // Frequency hopping bits (0..4) - optional uint32 ndi = 8; // New data indicator - optional uint32 rv = 9; // Redundancy version - optional uint32 harq_pid = 10; // The harq process id - optional uint32 ultx_mode = 11; // A FLULM_* value - optional uint32 tbs_size = 12; // The size of each TBS - optional uint32 n_srs = 13; // Overlap indication with srs - optional uint32 res_alloc = 14; // Type of resource allocation - optional uint32 size = 15; // Size of the ULSCH PDU in bytes for UL Grant. - - optional uint32 dai = 16; // TDD only - -// optional uint32 tb_swap = 17; // Boolean. TB to codeword swap flag - -// optional uint32 pdcch_order = 19; -// optional uint32 preamble_index = 20; // Only valid if pdcch_order = 1 -// optional uint32 prach_mask_index = 21; // Only valid if pdcch_order = 1 - -// optional uint32 tbs_idx = 23; // The TBS index for Format 1A - - - - -} // // Messages related to the creation of RLC PDUs @@ -107,9 +76,3 @@ enum flex_ngap_val { FLNGV_1 = 0; FLNGV_2 = 1; } - -enum flex_mod_type { - FLMOD_QPSK = 2; - FLMOD_16QAM = 4; - FLMOD_64QAM = 6; -} diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto index a7d78841a3..35550c3733 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto @@ -183,83 +183,87 @@ message flex_noise_interference_report { } // -// RRC Primitives +// RRC Measurements Primitives // + + message flex_rrc_measurements { - // Measurement identifier. - optional int32 measid = 1; - // Primary Cell Reference Signal Received Power (RSRP). - optional int32 pcell_rsrp = 2; - // Primary Cell Reference Signal Received Quality (RSRQ). - optional int32 pcell_rsrq = 3; - // Neighboring cells measurements performed by UE. - optional flex_neigh_cells_measurements neigh_meas = 4; + // Measurement identifier. + optional int32 measid = 1; + // Primary Cell Reference Signal Received Power (RSRP). + optional int32 pcell_rsrp = 2; + // Primary Cell Reference Signal Received Quality (RSRQ). + optional int32 pcell_rsrq = 3; + // Neighboring cells measurements performed by UE. + optional flex_neigh_cells_measurements neigh_meas = 4; } message flex_neigh_cells_measurements { - // Neighboring EUTRA cells measurements. - repeated flex_eutra_measurements eutra_meas = 1; + // Neighboring EUTRA cells measurements. + repeated flex_eutra_measurements eutra_meas = 1; } message flex_eutra_measurements { - // Physical Cell identifier. - optional int32 phys_cell_id = 1; - // EUTRA Cell Global Identity (CGI) measurement. - optional flex_eutra_cgi_measurements cgi_meas = 2; - // EUTRA nearby cell reference signal measurement. - optional flex_eutra_ref_signal_meas meas_result = 3; + // Physical Cell identifier. + optional int32 phys_cell_id = 1; + // EUTRA Cell Global Identity (CGI) measurement. + optional flex_eutra_cgi_measurements cgi_meas = 2; + // EUTRA nearby cell reference signal measurement. + optional flex_eutra_ref_signal_meas meas_result = 3; } message flex_eutra_cgi_measurements { - // EUTRA Cell Global Identity (CGI). - optional flex_cell_global_eutra_id cgi = 1; - // Tracking area code of the neighbor cell. - optional uint32 tracking_area_code = 2; - // Public land mobile network identifiers of neighbor cell. - repeated flex_plmn_identity plmn_id = 3; + // EUTRA Cell Global Identity (CGI). + optional flex_cell_global_eutra_id cgi = 1; + // Tracking area code of the neighbor cell. + optional uint32 tracking_area_code = 2; + // Public land mobile network identifiers of neighbor cell. + repeated flex_plmn_identity plmn_id = 3; } message flex_cell_global_eutra_id { - // Public land mobile network identifier of neighbor cell. - optional flex_plmn_identity plmn_id = 1; - // Cell identifier of neighbor cell. - optional uint32 cell_id = 2; + // Public land mobile network identifier of neighbor cell. + optional flex_plmn_identity plmn_id = 1; + // Cell identifier of neighbor cell. + optional uint32 cell_id = 2; } message flex_plmn_identity { - // Mobile Network Code (MNC). - repeated uint32 mnc = 1; - // Mobile Country Code (MCC). - repeated uint32 mcc = 2; - // tracking area code - repeated uint32 tac = 3; -} + // Mobile Network Code (MNC). + repeated uint32 mnc = 1; + // Mobile Country Code (MCC). + repeated uint32 mcc = 2; + // tracking area code + repeated uint32 tac = 3; +} message flex_eutra_ref_signal_meas { - // Neighboring Cell Reference Signal Received Power (RSRP). - optional int32 rsrp = 1; - // Neighboring Cell Reference Signal Received Quality (RSRQ). - optional int32 rsrq = 2; - + // Neighboring Cell RSRP + optional int32 rsrp = 1; + // Neighboring Cell RSRQ + optional int32 rsrq = 2; } +// +// PDCP Statistics +// + message flex_pdcp_stats { - optional uint32 pkt_tx = 1; - optional uint32 pkt_tx_bytes = 2; - optional uint32 pkt_tx_sn = 3; - optional uint32 pkt_tx_rate_s = 4; + optional uint32 pkt_tx = 1; + optional uint32 pkt_tx_bytes = 2; + optional uint32 pkt_tx_sn = 3; + optional uint32 pkt_tx_rate_s = 4; optional uint32 pkt_tx_throughput_s = 5; - optional uint32 pkt_tx_aiat = 7; + optional uint32 pkt_tx_aiat = 7; optional uint32 pkt_tx_aiat_s = 8; optional uint32 pkt_rx = 9; - optional uint32 pkt_rx_bytes = 10; - optional uint32 pkt_rx_sn = 11; - optional uint32 pkt_rx_rate_s = 12; + optional uint32 pkt_rx_bytes = 10; + optional uint32 pkt_rx_sn = 11; + optional uint32 pkt_rx_rate_s = 12; optional uint32 pkt_rx_goodput_s = 13; - optional uint32 pkt_rx_aiat = 14; + optional uint32 pkt_rx_aiat = 14; optional uint32 pkt_rx_aiat_s = 15; - optional uint32 pkt_rx_oo = 16; - } - + optional uint32 pkt_rx_oo = 16; +} diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto b/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto index 8cad6f4fbe..b8126c55f2 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_messages.proto @@ -47,8 +47,8 @@ message flex_ue_stats_report { optional flex_dl_cqi_report dl_cqi_report = 7; optional flex_paging_buffer_report pbr = 8; optional flex_ul_cqi_report ul_cqi_report = 9; - optional flex_rrc_measurements rrc_measurements = 10; - optional flex_pdcp_stats pdcp_stats = 11; + optional flex_rrc_measurements rrc_measurements = 10; + optional flex_pdcp_stats pdcp_stats = 11; } // @@ -85,9 +85,9 @@ enum flex_ue_stats_type { FLUST_DL_CQI = 16; FLUST_PBS = 32; FLUST_UL_CQI = 64; - - FLUST_PDCP_STATS = 1024; // To be changed - // To be extended with more types of stats + + FLUST_PDCP_STATS = 1024; FLUST_RRC_MEASUREMENTS = 65536; - + // To be extended with more types of stats + } diff --git a/openair2/ENB_APP/MESSAGES/V2/time_common.proto b/openair2/ENB_APP/MESSAGES/V2/time_common.proto index baf0c0e9ae..6c0affbe51 100644 --- a/openair2/ENB_APP/MESSAGES/V2/time_common.proto +++ b/openair2/ENB_APP/MESSAGES/V2/time_common.proto @@ -25,7 +25,7 @@ message flex_ul_info { repeated uint32 ul_reception = 2; optional uint32 reception_status = 3; optional uint32 tpc = 4; - optional uint32 serv_cell_index = 5; - optional uint32 rssi = 6; + optional uint32 serv_cell_index = 5; + optional uint32 rssi = 6; } diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index e56ebdfd22..386dd18f1e 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -387,7 +387,6 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_ Protocol__FlexControlDelegation *control_delegation_msg = input->control_delegation_msg; // struct timespec vartime = timer_start(); - int status; //Write the payload lib into a file in the cache and load the lib char lib_name[120]; char target[512]; @@ -395,13 +394,6 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_ strcpy(target, local_cache); strcat(target, lib_name); - status = mkdir(local_cache, S_IRWXU | S_IRWXG | S_IRWXO); - - if (status < 0){ - - LOG_W(ENB_APP, "Couldn't create local cache!"); - } - FILE *f; f = fopen(target, "wb"); fwrite(control_delegation_msg->payload.data, control_delegation_msg->payload.len, 1, f); From acd996d2eb555248afefe5cd17fbb0c931e0b3e6 Mon Sep 17 00:00:00 2001 From: shahab Date: Sun, 10 Dec 2017 18:23:21 +0100 Subject: [PATCH 039/141] ul proto msg --- .../MESSAGES/V2/controller_commands.proto | 6 ++++ openair2/ENB_APP/MESSAGES/V2/flexran.proto | 13 ++++++++ openair2/ENB_APP/MESSAGES/V2/header.proto | 1 + .../ENB_APP/MESSAGES/V2/mac_primitives.proto | 32 +++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto b/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto index 6f30ea4755..29e0723835 100644 --- a/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto +++ b/openair2/ENB_APP/MESSAGES/V2/controller_commands.proto @@ -16,6 +16,12 @@ message flex_dl_data { optional uint32 act_deact_ce = 6; //Hex content of MAC CE for Activation/Deactivation in CA } + +message flex_ul_data { + optional uint32 rnti = 1; + optional flex_ul_dci ul_dci = 2; +} + // // Body of the RAR scheduler configuration // diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index 45a139b73a..b54fc171c6 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -30,6 +30,7 @@ message flexran_message { flex_control_delegation control_delegation_msg = 16; flex_agent_reconfiguration agent_reconfiguration_msg = 17; flex_rrc_triggering rrc_triggering = 18; + flex_ul_mac_config ul_mac_config_msg = 19; } } @@ -166,6 +167,18 @@ message flex_dl_mac_config { repeated flex_pdcch_ofdm_sym_count ofdm_sym = 6; // OFDM symbol count for each CC } +message flex_ul_mac_config { + optional flex_header header = 1; + optional uint32 sfn_sf = 2; + repeated flex_ul_data ul_ue_data = 3; +} + +message flex_rrc_triggering { + + optional flex_header header = 1; + optional string rrc_trigger = 2; +} + // // UE state change message // diff --git a/openair2/ENB_APP/MESSAGES/V2/header.proto b/openair2/ENB_APP/MESSAGES/V2/header.proto index 12110de24e..8900b93492 100644 --- a/openair2/ENB_APP/MESSAGES/V2/header.proto +++ b/openair2/ENB_APP/MESSAGES/V2/header.proto @@ -41,5 +41,6 @@ enum flex_type { FLPT_DELEGATE_CONTROL = 15; FLPT_RECONFIGURE_AGENT = 16; FLPT_RRC_TRIGGERING = 17; + FLPT_UL_MAC_CONFIG = 18; } diff --git a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto index d3acb51318..bd2b9cbe50 100644 --- a/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto +++ b/openair2/ENB_APP/MESSAGES/V2/mac_primitives.proto @@ -34,6 +34,38 @@ message flex_dl_dci { optional uint32 pdcch_power_offset = 25; // DL PDCCH power boosting in dB optional uint32 cif_present = 26; // Boolean. Indication of CIF field optional uint32 cif = 27; // CIF for cross-carrier scheduling +} + +message flex_ul_dci { + optional uint32 rnti = 1; + optional uint32 rb_start = 2; // The start RB allocated to the UE + optional uint32 rb_len = 3; // The number of RBs allocated to the UE + optional uint32 mcs = 4; // Modulation and coding scheme + optional uint32 cyclic_shift2 = 5; // match DCI format 0/4 PDU + optional uint32 freq_hop_flag = 6; // 0 no hopping, 1 hoppping + optional uint32 freq_hop_map = 7; // Frequency hopping bits (0..4) + optional uint32 ndi = 8; // New data indicator + optional uint32 rv = 9; // Redundancy version + optional uint32 harq_pid = 10; // The harq process id + optional uint32 ultx_mode = 11; // A FLULM_* value + optional uint32 tbs_size = 12; // The size of each TBS + optional uint32 n_srs = 13; // Overlap indication with srs + optional uint32 res_alloc = 14; // Type of resource allocation + optional uint32 size = 15; // Size of the ULSCH PDU in bytes for UL Grant. + + optional uint32 dai = 16; // TDD only + +// optional uint32 tb_swap = 17; // Boolean. TB to codeword swap flag + +// optional uint32 pdcch_order = 19; +// optional uint32 preamble_index = 20; // Only valid if pdcch_order = 1 +// optional uint32 prach_mask_index = 21; // Only valid if pdcch_order = 1 + +// optional uint32 tbs_idx = 23; // The TBS index for Format 1A + + + + } From 9601ea66c5f1aa709cccbe4da4627458932a1a66 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Mon, 11 Dec 2017 16:46:22 +0100 Subject: [PATCH 040/141] Update PDCP stats --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 139 +++++++++++++++------------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 2 + 2 files changed, 78 insertions(+), 63 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 397a194edf..fb4cc0c526 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -409,7 +409,9 @@ boolean_t pdcp_data_req( //LOG_I(PDCP,"ueid %d lcid %d tx seq num %d\n", pdcp_uid, rb_idP+rb_offset, current_sn); Pdcp_stats_tx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; + Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; Pdcp_stats_tx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=current_sn; if (Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset] < pdcp_frame *10 + pdcp_subframe) { @@ -421,22 +423,8 @@ boolean_t pdcp_data_req( Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 + pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); } - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=ctxt_pP->frame*10+ctxt_pP->subframe; - if (pdcp_frame % 100 == 0 ) { - Pdcp_stats_tx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]= Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]; - Pdcp_stats_tx_throughput_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]*8/1000; - Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]; - - Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; - Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; - Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; - }else { - Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; - - } @@ -828,53 +816,43 @@ pdcp_data_ind( packet_forwarded = TRUE; /* Print octets of incoming data in hexadecimal form */ - LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", - sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t), - sdu_buffer_sizeP - payload_offset); - //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); - //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); - - /* - * Update PDCP statistics - * XXX Following two actions are identical, is there a merge error? - */ - - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ - if (pdcp_p->rnti[pdcp_uid] == ctxt_pP->rnti ) - break; - } - - Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP - payload_offset; - - Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; - - if (oo_flag == 1 ) - Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - - if (Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset] < pdcp_frame * 10 + pdcp_subframe) { - Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_frame *10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_frame *10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - } else { - Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 +pdcp_frame * 10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(1024 +pdcp_frame * 10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - } - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_frame * 10 +pdcp_subframe; - - if (pdcp_frame % 102 == 0) { - Pdcp_stats_rx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]; - Pdcp_stats_rx_goodput_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]*8/1023; - Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]= Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]; - - Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; - Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; - Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=0; - }else { - Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); - } + LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", + sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t), + sdu_buffer_sizeP - payload_offset); + //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); + //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); + + /* + * Update PDCP statistics + * XXX Following two actions are identical, is there a merge error? + */ + + for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + if (pdcp_p->rnti[pdcp_uid] == ctxt_pP->rnti ) + break; + } + + Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); + Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); + + Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; + + if (oo_flag == 1 ) + Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + + if (Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset] < pdcp_frame * 10 + pdcp_subframe) { + Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_frame *10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_frame *10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + } else { + Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 +pdcp_frame * 10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(1024 +pdcp_frame * 10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + } + Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_frame * 10 +pdcp_subframe; + } - + #else packet_forwarded = FALSE; #endif @@ -951,6 +929,38 @@ pdcp_data_ind( return TRUE; } +void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ + + uint8_t pdcp_uid = 0; + uint8_t rb_id = 0; + + // these stats can be measured for both eNB and UE + if ((pdcp_frame % 102 == 0) && (pdcp_subframe ==0)) { + for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ + for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + //printf("frame %d and subframe %d \n", pdcp_frame, pdcp_subframe); + // tx stats + Pdcp_stats_tx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; + Pdcp_stats_tx_throughput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_id]*8/1024; + Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]; + + Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + + // rx stats + Pdcp_stats_rx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; + Pdcp_stats_rx_goodput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8/1024; + Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]; + + Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + + } + } + } +} //----------------------------------------------------------------------------- void pdcp_run ( @@ -958,9 +968,7 @@ pdcp_run ( ) //----------------------------------------------------------------------------- { - - pdcp_frame =ctxt_pP->frame; - pdcp_subframe= ctxt_pP->subframe; + #if defined(ENABLE_ITTI) MessageDef *msg_p; const char *msg_name; @@ -969,12 +977,17 @@ pdcp_run ( protocol_ctxt_t ctxt; #endif + 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); } + pdcp_frame =ctxt_pP->frame; // 1023 + pdcp_subframe= ctxt_pP->subframe; + pdcp_update_stats(ctxt_pP); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN); #if defined(ENABLE_ITTI) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index fb3e02b299..2f1d15ad5e 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -124,6 +124,8 @@ public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_ public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(void pdcp_update_perioidical_stats(const protocol_ctxt_t* const ctxt_pP)); + /*Packet Probing for agent PDCP*/ //public_pdcp(uint64_t *pdcp_packet_counter); From 38627c85d063073ae6e88a56d2ec6690a1e5f8c1 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Tue, 12 Dec 2017 10:14:30 +0100 Subject: [PATCH 041/141] Minor fix in the PDCP stats update --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index fb4cc0c526..7262d6b8d2 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -941,7 +941,8 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ //printf("frame %d and subframe %d \n", pdcp_frame, pdcp_subframe); // tx stats Pdcp_stats_tx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; - Pdcp_stats_tx_throughput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_id]*8/1024; + // unit: bit/s + Pdcp_stats_tx_throughput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; @@ -950,7 +951,7 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ // rx stats Pdcp_stats_rx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; - Pdcp_stats_rx_goodput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8/1024; + Pdcp_stats_rx_goodput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; From b7a1661855f440ac624a9bf78a544dbba2f573b4 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Tue, 12 Dec 2017 11:57:24 +0100 Subject: [PATCH 042/141] Better management of frame counter and stats in PDCP --- .../CONTROL_MODULES/PDCP/flexran_agent_pdcp.c | 5 +- .../ENB_APP/MESSAGES/V2/stats_common.proto | 2 + openair2/ENB_APP/flexran_agent_ran_api.c | 4 + openair2/ENB_APP/flexran_agent_ran_api.h | 3 + openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 127 ++++++++---------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 7 +- 6 files changed, 76 insertions(+), 72 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c index 4aa2e691b9..e4cc520070 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c @@ -21,7 +21,7 @@ /*! \file flexran_agent_pdcp.c * \brief FlexRAN agent Control Module PDCP - * \author shahab SHARIAT BAGHERI + * \author Navid Nikaein and shahab SHARIAT BAGHERI * \date 2017 * \version 0.1 */ @@ -118,6 +118,9 @@ int flexran_agent_pdcp_stats_reply(mid_t mod_id, pdcp_aggr_stats->pkt_rx_sn = flexran_get_pdcp_rx_sn(mod_id, i, DEFAULT_DRB); pdcp_aggr_stats->has_pkt_rx_sn =1; + pdcp_aggr_stats->sfn = flexran_get_pdcp_sfn(mod_id); + pdcp_aggr_stats->has_sfn =1; + ue_report[i]->pdcp_stats = pdcp_aggr_stats; } diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto index 35550c3733..94da9fbd04 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto @@ -266,4 +266,6 @@ message flex_pdcp_stats { optional uint32 pkt_rx_aiat = 14; optional uint32 pkt_rx_aiat_s = 15; optional uint32 pkt_rx_oo = 16; + + optional uint64 sfn=17; } diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 280b9807fd..7a4522e870 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -1083,6 +1083,10 @@ void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_ } /*********** PDCP *************/ +/*PDCP num tx pdu status flexRAN*/ +uint32_t flexran_get_pdcp_sfn(const mid_t mod_id){ + return Pdcp_sfn[mod_id]; +} /*PDCP num tx pdu status flexRAN*/ uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 4d84251608..bb9592399e 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -342,6 +342,9 @@ int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); /***************************** PDCP ***********************/ +/*PDCP superframe numberflexRAN*/ +uint32_t flexran_get_pdcp_sfn(const mid_t mod_id); + /*PDCP num tx pdu status flexRAN*/ uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 7262d6b8d2..c561043f4a 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -414,20 +414,10 @@ boolean_t pdcp_data_req( Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; Pdcp_stats_tx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=current_sn; - if (Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset] < pdcp_frame *10 + pdcp_subframe) { - Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - } - else { - Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 + pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 + pdcp_frame *10 + pdcp_subframe - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - } - - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=ctxt_pP->frame*10+ctxt_pP->subframe; - - - - + Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (Pdcp_sfn[ctxt_pP->module_id] - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (Pdcp_sfn[ctxt_pP->module_id] - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_sfn[ctxt_pP->module_id]; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); return ret; @@ -813,44 +803,7 @@ pdcp_data_ind( 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; - - /* Print octets of incoming data in hexadecimal form */ - LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", - sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t), - sdu_buffer_sizeP - payload_offset); - //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); - //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); - - /* - * Update PDCP statistics - * XXX Following two actions are identical, is there a merge error? - */ - - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ - if (pdcp_p->rnti[pdcp_uid] == ctxt_pP->rnti ) - break; - } - - Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); - Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); - - Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; - - if (oo_flag == 1 ) - Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - - if (Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset] < pdcp_frame * 10 + pdcp_subframe) { - Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_frame *10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_frame *10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - } else { - Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (1024 +pdcp_frame * 10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(1024 +pdcp_frame * 10 + pdcp_subframe - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - } - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_frame * 10 +pdcp_subframe; - + packet_forwarded = TRUE; } #else @@ -909,6 +862,38 @@ pdcp_data_ind( } } + /* Print octets of incoming data in hexadecimal form */ + LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", + sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t), + sdu_buffer_sizeP - payload_offset); + //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); + //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); + + /* + * Update PDCP statistics + * XXX Following two actions are identical, is there a merge error? + */ + + for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + if (pdcp_p->rnti[pdcp_uid] == ctxt_pP->rnti ) + break; + } + + Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); + Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); + + Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; + + if (oo_flag == 1 ) + Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + + Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (Pdcp_sfn[ctxt_pP->module_id] - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(Pdcp_sfn[ctxt_pP->module_id] - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_sfn[ctxt_pP->module_id]; + + #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) else { AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n", @@ -934,16 +919,16 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ uint8_t pdcp_uid = 0; uint8_t rb_id = 0; - // these stats can be measured for both eNB and UE - if ((pdcp_frame % 102 == 0) && (pdcp_subframe ==0)) { + // these stats are measured for both eNB and UE on per seond basis + if (Pdcp_sfn[ctxt_pP->module_id] % 1000 == 0){ for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ - //printf("frame %d and subframe %d \n", pdcp_frame, pdcp_subframe); + //printf("frame %d and subframe %d \n", Pdcp_frame[ctxt_pP->module_id], Pdcp_subframe[ctxt_pP->module_id]); // tx stats Pdcp_stats_tx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; // unit: bit/s Pdcp_stats_tx_throughput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8; - Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]; + Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]=(uint32_t)(Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]); Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; @@ -952,7 +937,7 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ // rx stats Pdcp_stats_rx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_rx_goodput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8; - Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]; + Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]= (uint32_t)(Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]); Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; @@ -985,8 +970,9 @@ pdcp_run ( start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_run); } - pdcp_frame =ctxt_pP->frame; // 1023 - pdcp_subframe= ctxt_pP->subframe; + Pdcp_sfn[ctxt_pP->module_id]++; // range: 0 to 18,446,744,073,709,551,615 + Pdcp_frame[ctxt_pP->module_id]=ctxt_pP->frame; // 1023 + Pdcp_subframe[ctxt_pP->module_id]= ctxt_pP->subframe; pdcp_update_stats(ctxt_pP); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN); @@ -1564,9 +1550,9 @@ pdcp_config_req_asn1 ( if (pdcp_pP->rnti[i] != 0 ) continue ; // skip active ues pdcp_pP->rnti[i]=ctxt_pP->rnti; pdcp_pP->uid[i]=i; - pdcp_num_ues++; + Pdcp_num_ues[ctxt_pP->module_id]++; break; - } + } //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti; pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; @@ -1669,14 +1655,14 @@ pdcp_config_req_asn1 ( if (ctxt_pP->enb_flag == ENB_FLAG_YES) { for (i=0; i < NUMBER_OF_UE_MAX; i++) { - if (pdcp_pP->rnti[i] == ctxt_pP->rnti ) { - pdcp_pP->rnti[i]=0; - pdcp_pP->uid[i]=0; - pdcp_num_ues--; - break; - } - } + if (pdcp_pP->rnti[i] == ctxt_pP->rnti ) { + pdcp_pP->rnti[i]=0; + pdcp_pP->uid[i]=0; + Pdcp_num_ues[ctxt_pP->module_id]--; + break; + } } + } /* Security keys */ if (pdcp_pP->kUPenc != NULL) { @@ -2055,6 +2041,11 @@ void pdcp_layer_init(void) pdcp_output_header_bytes_to_write=0; pdcp_input_sdu_remaining_size_to_read=0; + memset(Pdcp_sfn, 0, sizeof(Pdcp_sfn)); + memset(Pdcp_frame, 0, sizeof(Pdcp_frame)); + memset(Pdcp_subframe, 0, sizeof(Pdcp_subframe)); + memset(Pdcp_num_ues, 0, sizeof(Pdcp_num_ues)); + memset(Pdcp_stats_tx, 0, sizeof(Pdcp_stats_tx)); memset(Pdcp_stats_tx_s, 0, sizeof(Pdcp_stats_tx_s)); memset(Pdcp_stats_tx_bytes, 0, sizeof(Pdcp_stats_tx_bytes)); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 2f1d15ad5e..e9f20e0a94 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -94,9 +94,10 @@ extern int pdcp_instance_cnt; int init_pdcp_thread(void); void cleanup_pdcp_thread(void); -public_pdcp(frame_t pdcp_frame); -public_pdcp(sub_frame_t pdcp_subframe); -public_pdcp(uint16_t pdcp_num_ues); +public_pdcp(uint64_t Pdcp_sfn[MAX_NUM_CCs]); +public_pdcp(frame_t Pdcp_frame[MAX_NUM_CCs]); +public_pdcp(sub_frame_t Pdcp_subframe[MAX_NUM_CCs]); +public_pdcp(uint16_t Pdcp_num_ues[MAX_NUM_CCs]); public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); From b74c668ddb032f8148b56ce538efcc2555393a03 Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Tue, 12 Dec 2017 15:57:24 +0100 Subject: [PATCH 043/141] bug zero division for pdcp stats --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index c561043f4a..6118ddc745 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -928,7 +928,9 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ Pdcp_stats_tx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; // unit: bit/s Pdcp_stats_tx_throughput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8; - Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]=(uint32_t)(Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]); + if (Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){ + Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]=(Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]); + } Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; @@ -937,7 +939,10 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ // rx stats Pdcp_stats_rx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_rx_goodput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8; - Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]= (uint32_t)(Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]); + + if(Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){ + Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]= (Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]); + } Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; From 33696a4e93115d8ee366fb9b9b1164d75cf441a3 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Tue, 12 Dec 2017 20:24:29 +0100 Subject: [PATCH 044/141] *Update RRC RSRP/RSRQ measurement reports for multiple UEs, and add the corresponding RAN APIs *Fix the issue with the PDCP UE ID/RNTI management --- .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 36 +++---- openair2/ENB_APP/flexran_agent_ran_api.c | 68 +++++++++++++- openair2/ENB_APP/flexran_agent_ran_api.h | 8 ++ openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 93 +++++++++++-------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 31 +++++-- openair2/RRC/LITE/L2_interface.c | 4 +- openair2/RRC/LITE/defs.h | 3 +- openair2/RRC/LITE/proto.h | 2 +- openair2/RRC/LITE/rrc_eNB.c | 67 ++++++++----- 9 files changed, 217 insertions(+), 95 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index 587ac8c263..7a251be78b 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -276,9 +276,11 @@ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults for (i = 0; i < num; i++){ meas_stats[i].rnti = flexran_get_ue_crnti(mod_id, i); - meas_stats[i].meas_id = measResults->measId; - meas_stats[i].rsrp = measResults->measResultPCell.rsrpResult - 140; - meas_stats[i].rsrq = (measResults->measResultPCell.rsrqResult)/2 - 20; + meas_stats[i].meas_id = flexran_get_rrc_pcell_measid(mod_id,i); + meas_stats[i].rsrp = flexran_get_rrc_pcell_rsrp(mod_id,i) - 140; + // measResults->measResultPCell.rsrpResult - 140; + meas_stats[i].rsrq = flexran_get_rrc_pcell_rsrq(mod_id,i)/2 - 20; + // (measResults->measResultPCell.rsrqResult)/2 - 20; } // repl->neigh_meas = NULL; @@ -505,23 +507,21 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id, if (rrc_measurements == NULL) goto error; protocol__flex_rrc_measurements__init(rrc_measurements); - - if (triggered_rrc){ - rrc_measurements->measid = meas_stats[i].meas_id; - rrc_measurements->has_measid = 1; - - rrc_measurements->pcell_rsrp = meas_stats[i].rsrp; - rrc_measurements->has_pcell_rsrp = 1; - - rrc_measurements->pcell_rsrq = meas_stats[i].rsrq; - rrc_measurements->has_pcell_rsrq = 1 ; - - ue_report[i]->rrc_measurements = rrc_measurements; - // triggered_rrc = false; // To be decided later - } + + rrc_measurements->measid = flexran_get_rrc_pcell_measid(mod_id,i); + rrc_measurements->has_measid = 1; + + rrc_measurements->pcell_rsrp = flexran_get_rrc_pcell_rsrp(mod_id,i) - 140; + rrc_measurements->has_pcell_rsrp = 1; + + rrc_measurements->pcell_rsrq = flexran_get_rrc_pcell_rsrq(mod_id,i)/2 - 20; + rrc_measurements->has_pcell_rsrq = 1 ; + + ue_report[i]->rrc_measurements = rrc_measurements; + } } - } + } /* To be extended for RRC layer */ // if (report_config->nr_cc > 0) { diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 7a4522e870..17d62ced86 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -1083,9 +1083,9 @@ void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_ } /*********** PDCP *************/ -/*PDCP num tx pdu status flexRAN*/ +/*PDCP super frame counter flexRAN*/ uint32_t flexran_get_pdcp_sfn(const mid_t mod_id){ - return Pdcp_sfn[mod_id]; + return pdcp_enb[mod_id].sfn; } /*PDCP num tx pdu status flexRAN*/ @@ -1166,5 +1166,67 @@ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lc return Pdcp_stats_rx_outoforder[mod_id][ue_id][lcid]; } +/******************** RRC *****************************/ - +int flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.measResults != NULL) { + return ue_context_p->ue_context.measResults->measId; + } else { + return -1; + } + } else { + return -1; + } +} +int flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.measResults != NULL) { + return ue_context_p->ue_context.measResults->measResultPCell.rsrpResult; + } else { + return -1; + } + } else { + return -1; + } +} +int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.measResults != NULL) { + return ue_context_p->ue_context.measResults->measResultPCell.rsrqResult; + } else { + return -1; + } + } else { + return -1; + } +} +/* +void* flexran_get_rrc_ncell_measresult_eutra(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.measResults != NULL) { + return &ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA; + } else { + return -1; + } + } else { + return -1; + } +} +*/ diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index bb9592399e..84723be005 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -391,4 +391,12 @@ uint32_t flexran_get_pdcp_rx_aiat_s(const mid_t mod_id, const mid_t ue_id, cons /*PDCP num of received outoforder pdu status flexRAN*/ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); +/*********************RRC**********************/ +/*Get primary cell measuremeant id flexRAN*/ +int flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id); +/*Get primary cell RSRP measurement flexRAN*/ +int flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id); + +/*Get primary cell RSRQ measurement flexRAN*/ +int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 6118ddc745..baba5fa39e 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -69,7 +69,6 @@ extern int otg_enabled; #endif - //----------------------------------------------------------------------------- /* * If PDCP_UNIT_TEST is set here then data flow between PDCP and RLC is broken @@ -403,7 +402,7 @@ boolean_t pdcp_data_req( */ for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ - if (pdcp_p->rnti[pdcp_uid] == ctxt_pP->rnti ) + if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ) break; } @@ -414,9 +413,9 @@ boolean_t pdcp_data_req( Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; Pdcp_stats_tx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=current_sn; - Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (Pdcp_sfn[ctxt_pP->module_id] - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (Pdcp_sfn[ctxt_pP->module_id] - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_sfn[ctxt_pP->module_id]; + Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); return ret; @@ -875,8 +874,9 @@ pdcp_data_ind( */ for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ - if (pdcp_p->rnti[pdcp_uid] == ctxt_pP->rnti ) + if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ){ break; + } } Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; @@ -889,9 +889,9 @@ pdcp_data_ind( if (oo_flag == 1 ) Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (Pdcp_sfn[ctxt_pP->module_id] - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(Pdcp_sfn[ctxt_pP->module_id] - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=Pdcp_sfn[ctxt_pP->module_id]; + Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) @@ -920,10 +920,10 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ uint8_t rb_id = 0; // these stats are measured for both eNB and UE on per seond basis - if (Pdcp_sfn[ctxt_pP->module_id] % 1000 == 0){ + if (pdcp_enb[ctxt_pP->module_id].sfn % 1000 == 0){ for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ - //printf("frame %d and subframe %d \n", Pdcp_frame[ctxt_pP->module_id], Pdcp_subframe[ctxt_pP->module_id]); + //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe); // tx stats Pdcp_stats_tx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; // unit: bit/s @@ -975,9 +975,9 @@ pdcp_run ( start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_run); } - Pdcp_sfn[ctxt_pP->module_id]++; // range: 0 to 18,446,744,073,709,551,615 - Pdcp_frame[ctxt_pP->module_id]=ctxt_pP->frame; // 1023 - Pdcp_subframe[ctxt_pP->module_id]= ctxt_pP->subframe; + pdcp_enb[ctxt_pP->module_id].sfn++; // range: 0 to 18,446,744,073,709,551,615 + pdcp_enb[ctxt_pP->module_id].frame=ctxt_pP->frame; // 1023 + pdcp_enb[ctxt_pP->module_id].subframe= ctxt_pP->subframe; pdcp_update_stats(ctxt_pP); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN); @@ -1102,6 +1102,28 @@ pdcp_run ( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT); } +void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){ + int i, ue_flag=1, ret=-1;; + for (i=0; i < NUMBER_OF_UE_MAX; i++){ + if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti) { + ue_flag=-1; + break; + } + } + if (ue_flag == 1 ){ + for (i=0; i < NUMBER_OF_UE_MAX ; i++){ + if (pdcp_enb[ctxt_pP->module_id].rnti[i] == 0 ){ + pdcp_enb[ctxt_pP->module_id].rnti[i]=ctxt_pP->rnti; + pdcp_enb[ctxt_pP->module_id].uid[i]=i; + pdcp_enb[ctxt_pP->module_id].num_ues++; + printf("add new uid is %d %x\n\n", i, ctxt_pP->rnti); + ret=1; + break; + } + } + } + //return ret; +} //----------------------------------------------------------------------------- boolean_t @@ -1115,7 +1137,7 @@ pdcp_remove_UE( hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; - // check and remove SRBs first + // check and remove SRBs first for (srb_id=0; srb_id<2; srb_id++) { key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_YES); @@ -1130,6 +1152,19 @@ pdcp_remove_UE( (void)h_rc; /* remove gcc warning "set but not used" */ + // remove ue for pdcp enb inst + for (i=0; i < NUMBER_OF_UE_MAX; i++) { + if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti ) { + LOG_I(PDCP, "remove uid is %d/%d %x\n", i, + pdcp_enb[ctxt_pP->module_id].uid[i], + pdcp_enb[ctxt_pP->module_id].rnti[i]); + pdcp_enb[ctxt_pP->module_id].uid[i]=0; + pdcp_enb[ctxt_pP->module_id].rnti[i]=0; + pdcp_enb[ctxt_pP->module_id].num_ues--; + break; + } + } + return 1; } @@ -1524,7 +1559,6 @@ rrc_pdcp_config_asn1_req ( return 0; } - //----------------------------------------------------------------------------- boolean_t pdcp_config_req_asn1 ( @@ -1545,19 +1579,14 @@ pdcp_config_req_asn1 ( uint8_t *const kUPenc_pP) //----------------------------------------------------------------------------- { - int i; + switch (actionP) { case CONFIG_ACTION_ADD: DevAssert(pdcp_pP != NULL); if (ctxt_pP->enb_flag == ENB_FLAG_YES) { pdcp_pP->is_ue = FALSE; - for (i=0; i < NUMBER_OF_UE_MAX; i++) { - if (pdcp_pP->rnti[i] != 0 ) continue ; // skip active ues - pdcp_pP->rnti[i]=ctxt_pP->rnti; - pdcp_pP->uid[i]=i; - Pdcp_num_ues[ctxt_pP->module_id]++; - break; - } + pdcp_add_ue(ctxt_pP); + //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti; pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; @@ -1658,15 +1687,7 @@ pdcp_config_req_asn1 ( rb_idP); if (ctxt_pP->enb_flag == ENB_FLAG_YES) { - - for (i=0; i < NUMBER_OF_UE_MAX; i++) { - if (pdcp_pP->rnti[i] == ctxt_pP->rnti ) { - pdcp_pP->rnti[i]=0; - pdcp_pP->uid[i]=0; - Pdcp_num_ues[ctxt_pP->module_id]--; - break; - } - } + // pdcp_remove_UE(ctxt_pP); } /* Security keys */ @@ -2046,10 +2067,8 @@ void pdcp_layer_init(void) pdcp_output_header_bytes_to_write=0; pdcp_input_sdu_remaining_size_to_read=0; - memset(Pdcp_sfn, 0, sizeof(Pdcp_sfn)); - memset(Pdcp_frame, 0, sizeof(Pdcp_frame)); - memset(Pdcp_subframe, 0, sizeof(Pdcp_subframe)); - memset(Pdcp_num_ues, 0, sizeof(Pdcp_num_ues)); + memset(pdcp_enb, 0, sizeof(pdcp_enb_t)); + memset(Pdcp_stats_tx, 0, sizeof(Pdcp_stats_tx)); memset(Pdcp_stats_tx_s, 0, sizeof(Pdcp_stats_tx_s)); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index e9f20e0a94..cf3d927051 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -94,11 +94,12 @@ extern int pdcp_instance_cnt; int init_pdcp_thread(void); void cleanup_pdcp_thread(void); +/* public_pdcp(uint64_t Pdcp_sfn[MAX_NUM_CCs]); public_pdcp(frame_t Pdcp_frame[MAX_NUM_CCs]); public_pdcp(sub_frame_t Pdcp_subframe[MAX_NUM_CCs]); public_pdcp(uint16_t Pdcp_num_ues[MAX_NUM_CCs]); - +*/ public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_tx_bytes_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); @@ -131,7 +132,19 @@ public_pdcp(void pdcp_update_perioidical_stats(const protocol_ctxt_t* const ctx /*Packet Probing for agent PDCP*/ //public_pdcp(uint64_t *pdcp_packet_counter); //public_pdcp(uint64_t *pdcp_size_packet); +typedef struct pdcp_enb_s { + // used for eNB stats generation + uint16_t uid[NUMBER_OF_UE_MAX]; + rnti_t rnti[NUMBER_OF_UE_MAX]; + uint16_t num_ues; + + uint64_t sfn; + frame_t frame; + sub_frame_t subframe; + +} pdcp_enb_t; +public_pdcp(pdcp_enb_t pdcp_enb[MAX_NUM_CCs]); typedef struct pdcp_stats_s { time_stats_t pdcp_run; @@ -154,11 +167,7 @@ typedef struct pdcp_s { boolean_t is_ue; boolean_t is_srb; - // used for eNB stats generation - uint16_t uid[NUMBER_OF_UE_MAX]; // local to pdcp - rnti_t rnti[NUMBER_OF_UE_MAX]; - - /* Configured security algorithms */ + /* Configured security algorithms */ uint8_t cipheringAlgorithm; uint8_t integrityProtAlgorithm; @@ -360,9 +369,15 @@ public_pdcp(boolean_t pdcp_config_req_asn1 ( uint8_t *const kRRCint, uint8_t *const kUPenc)); - +/*! \fn void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP) +* \brief Function (for RRC) to add a new UE in PDCP module +* \param[in] ctxt_pP Running context. +* \return A status about the processing, OK or error code. +*/ +public_pdcp(void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP)); + /*! \fn boolean_t pdcp_remove_UE(const protocol_ctxt_t* const ctxt_pP) -* \brief Function for RRC to configure a Radio Bearer clear all PDCP resources for a particular UE +* \brief Function for RRC to remove UE from PDCP module hashtable * \param[in] ctxt_pP Running context. * \return A status about the processing, OK or error code. */ diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index 6a64d7811e..71616ffd91 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -597,10 +597,10 @@ rrc_data_ind( rb_id_t DCCH_index = Srb_id; 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 %d\n", + LOG_D(RRC, "[UE %x] Frame %d: received a DCCH %d message on SRB %d with Size %d from eNB %d\n", ctxt_pP->module_id, ctxt_pP->frame, DCCH_index,Srb_id,sdu_sizeP, ctxt_pP->eNB_index); } else { - LOG_N(RRC, "[eNB %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from UE %x\n", + LOG_D(RRC, "[eNB %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from UE %x\n", ctxt_pP->module_id, ctxt_pP->frame, DCCH_index, diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index 0a2043fd4e..29bc3e3997 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -374,7 +374,8 @@ typedef struct eNB_RRC_UE_s { SRB_INFO_TABLE_ENTRY Srb2; MeasConfig_t* measConfig; HANDOVER_INFO* handover_info; - + MeasResults_t* measResults; + #if defined(ENABLE_SECURITY) /* KeNB as derived from KASME received from EPC */ uint8_t kenb[32]; diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h index 20bc99ab79..3b64d2a45c 100644 --- a/openair2/RRC/LITE/proto.h +++ b/openair2/RRC/LITE/proto.h @@ -425,7 +425,7 @@ rrc_eNB_generate_SecurityModeCommand( void rrc_eNB_process_MeasurementReport( const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + rrc_eNB_ue_context_t* ue_context_pP, const MeasResults_t* const measResults2 ); diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 05e59755c2..aaf12da175 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2840,32 +2840,56 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell( void rrc_eNB_process_MeasurementReport( const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + rrc_eNB_ue_context_t* ue_context_pP, const MeasResults_t* const measResults2 ) //----------------------------------------------------------------------------- { - // T(T_ENB_RRC_MEASUREMENT_REPORT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - // T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + int i=0; + int neighboring_cells=-1; + + T(T_ENB_RRC_MEASUREMENT_REPORT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + if (measResults2 == NULL ) + return; + + if (measResults2->measId > 0 ){ + if (ue_context_pP->ue_context.measResults == NULL) { + ue_context_pP->ue_context.measResults = CALLOC(1, sizeof(MeasResults_t)); + } + ue_context_pP->ue_context.measResults->measId=measResults2->measId; + ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult=measResults2->measResultPCell.rsrpResult; + ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult=measResults2->measResultPCell.rsrqResult; + LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRP of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult-140); + LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRQ of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult/2 - 20); + } + if (measResults2->measResultNeighCells == NULL) + return; - // 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", - // (int)measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId); - // LOG_I(RRC, "RSRP of Target %d\n", - // (int)*(measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]-> - // measResult.rsrpResult)); - // LOG_I(RRC, "RSRQ of Target %d\n", - // (int)*(measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]-> - // measResult.rsrqResult)); - // } + if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) { + neighboring_cells=measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count; + + if (ue_context_pP->ue_context.measResults->measResultNeighCells == NULL) { + + ue_context_pP->ue_context.measResults->measResultNeighCells = CALLOC(1, sizeof(*measResults2->measResultNeighCells)*neighboring_cells); + } + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count=neighboring_cells; + for (i=0; i < neighboring_cells; i++){ + memcpy (ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i], + measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[i], + sizeof(MeasResultListEUTRA_t)); + + LOG_D(RRC, "Physical Cell Id %d\n", + (int)ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->physCellId); + LOG_D(RRC, "RSRP of Target %d\n", + (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult)); + LOG_D(RRC, "RSRQ of Target %d\n", + (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult)); + } + } // #if defined(Rel10) || defined(Rel14) - LOG_I(RRC, "RSRP of Source %ld\n", measResults2->measResultPCell.rsrpResult); - LOG_I(RRC, "RSRQ of Source %ld\n", measResults2->measResultPCell.rsrqResult); // #else @@ -5109,13 +5133,6 @@ rrc_eNB_decode_dcch( ue_context_p, &ul_dcch_msg->message.choice.c1.choice.measurementReport. criticalExtensions.choice.c1.choice.measurementReport_r8.measResults); - #if defined(FLEXRAN_AGENT_SB_IF) - - if (rrc_agent_registered[ctxt_pP->module_id]) { - agent_rrc_xface[ctxt_pP->eNB_index]->flexran_trigger_rrc_measurements (ctxt_pP->module_id, &ul_dcch_msg->message.choice.c1.choice.measurementReport.criticalExtensions.choice.c1.choice.measurementReport_r8.measResults); - } -#endif - break; case UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete: From 49ea4748072f50107d47bf9260003861fb42a896 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Wed, 13 Dec 2017 17:00:33 +0100 Subject: [PATCH 045/141] Fix the compilation issues --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index baba5fa39e..df85b06d06 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1136,7 +1136,7 @@ pdcp_remove_UE( DRB_Identity_t drb_id = 0; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; - + int i; // check and remove SRBs first for (srb_id=0; srb_id<2; srb_id++) { @@ -1585,7 +1585,7 @@ pdcp_config_req_asn1 ( DevAssert(pdcp_pP != NULL); if (ctxt_pP->enb_flag == ENB_FLAG_YES) { pdcp_pP->is_ue = FALSE; - pdcp_add_ue(ctxt_pP); + pdcp_add_UE(ctxt_pP); //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti; pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; From 6e6a462dc420def86472dc4e0530c5592437b5ee Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Dec 2017 12:46:38 +0100 Subject: [PATCH 046/141] check whether RRC instance is present in RAN API --- openair2/ENB_APP/flexran_agent_ran_api.c | 73 +++++++++++++++++++++--- 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 17d62ced86..3ecbf77e11 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -65,17 +65,27 @@ void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ error: LOG_E(FLEXRAN_AGENT, "unknown RAN name %d\n", ran); } -static int mac_xface_not_ready(void); -static int mac_xface_not_ready(void){ - if (mac_xface == NULL) +static int mac_xface_not_ready(void) +{ + if (mac_xface == NULL) { return 1; + } else { //printf("max_xface %p %d \n", mac_xface, mac_xface->active); return 0;// !mac_xface->active; } } - + +static int eNB_rrc_inst_not_ready(void) +{ + if (NULL == eNB_rrc_inst) { + return 1; + } + else { + return 0; + } +} int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag){ if (enb[mod_id] == NULL) return 0; @@ -681,6 +691,8 @@ int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id) { int flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -698,6 +710,8 @@ int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + if (eNB_rrc_inst_not_ready()) return -1; + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { if(ue_context_p->ue_context.measGapConfig != NULL) { @@ -719,6 +733,8 @@ int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id) { int flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); @@ -741,6 +757,8 @@ int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP){ struct rrc_eNB_ue_context_s* ue_context_p = NULL; + if (eNB_rrc_inst_not_ready()) return -1; + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if (ue_context_p != NULL) { @@ -805,6 +823,8 @@ int flexran_get_res_alloc_type1(mid_t ue_id) { int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); @@ -822,6 +842,8 @@ int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) { int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -839,6 +861,8 @@ int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) { int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -852,6 +876,8 @@ int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) { int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -868,6 +894,8 @@ int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) { int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -884,6 +912,8 @@ int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) { int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -901,6 +931,8 @@ int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) { int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -914,13 +946,18 @@ int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) { } int flexran_get_ack_nack_simultaneous_trans(mid_t mod_id,mid_t ue_id) { - return (&eNB_rrc_inst[mod_id])->carrier[0].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; + + if (eNB_rrc_inst_not_ready()) return -1; + + return (&eNB_rrc_inst[mod_id])->carrier[0].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; } int flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - + + if (eNB_rrc_inst_not_ready()) return -1; + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -935,6 +972,8 @@ int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id) { // TODO: This needs fixing return -1; + /* if (eNB_rrc_inst_not_ready()) return -1; */ + /* struct rrc_eNB_ue_context_s* ue_context_p = NULL; */ /* uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); */ @@ -954,6 +993,8 @@ int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id) { int flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -972,6 +1013,8 @@ int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + if (eNB_rrc_inst_not_ready()) return -1; + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { if(ue_context_p->ue_context.mac_MainConfig != NULL){ @@ -989,7 +1032,9 @@ int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) { int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - + + if (eNB_rrc_inst_not_ready()) return -1; + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -1035,6 +1080,8 @@ int flexran_get_antenna_ports(mid_t mod_id, int CC_id){ LTE_DL_FRAME_PARMS *frame_parms; + if (mac_xface_not_ready()) return 0; + frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); return (frame_parms == NULL)? 0:frame_parms->nb_antenna_ports_eNB; @@ -1171,6 +1218,8 @@ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lc int flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { @@ -1186,7 +1235,9 @@ int flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id) { int flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - + + if (eNB_rrc_inst_not_ready()) return -1; + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { if(ue_context_p->ue_context.measResults != NULL) { @@ -1201,7 +1252,9 @@ int flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id) { int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - + + if (eNB_rrc_inst_not_ready()) return -1; + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { if(ue_context_p->ue_context.measResults != NULL) { @@ -1217,6 +1270,8 @@ int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) { void* flexran_get_rrc_ncell_measresult_eutra(mid_t mod_id, mid_t ue_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { From 612ab055d7b97e02503f2f1143ba2092c3a1cd9b Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Wed, 6 Dec 2017 12:23:16 +0100 Subject: [PATCH 047/141] Add control logic to reconfigure and start eNB --- openair2/ENB_APP/enb_app.c | 36 ++++- openair2/ENB_APP/enb_config.c | 22 ++- openair2/ENB_APP/enb_config.h | 11 +- .../ENB_APP/flexran_agent_common_internal.c | 9 +- .../LAYER2/MAC/eNB_scheduler_primitives.c | 4 + targets/COMMON/create_tasks.c | 19 ++- targets/COMMON/create_tasks.h | 1 + .../CONF/enb.band7.flexran.usrpb210.conf | 6 +- targets/RT/USER/lte-softmodem.c | 143 ++++++++++++------ 9 files changed, 175 insertions(+), 76 deletions(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index de0d0490aa..4a5981f509 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -55,6 +55,17 @@ extern unsigned char NB_eNB_INST; #endif +extern volatile int node_control_state; + +static void enb_app_wait_reconfig_cmd (void) +{ + LOG_I(ENB_APP, "ENB APP await reconfiguration command\n"); + + while (node_control_state == ENB_WAIT_RECONFIGURATION_CMD) { + usleep(200000); + } + sleep(2); // wait for createing other tasks +} #if defined(ENABLE_ITTI) @@ -270,7 +281,7 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, con /*------------------------------------------------------------------------------*/ void *eNB_app_task(void *args_p) { - const Enb_properties_array_t *enb_properties_p = NULL; + Enb_properties_array_t *enb_properties_p = NULL; #if defined(ENABLE_ITTI) uint32_t enb_nb = 1; /* Default number of eNB is 1 */ uint32_t enb_id_start = 0; @@ -309,19 +320,28 @@ void *eNB_app_task(void *args_p) "Number of eNB is greater than eNB defined in configuration file (%d/%d)!", enb_nb, enb_properties_p->number); +#if defined (FLEXRAN_AGENT_SB_IF) + + for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { + flexran_agent_start(enb_id, enb_properties_p); + } + // wait for config comd from the controller/network app + enb_app_wait_reconfig_cmd(); + + // set again the ran api vars + for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { + printf("\n set again enb vars %d\n", enb_id); + flexran_set_enb_vars(enb_id, RAN_LTE_OAI); + } + +#endif + for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { configure_phy(enb_id, enb_properties_p); configure_rrc(enb_id, enb_properties_p); } -#if defined (FLEXRAN_AGENT_SB_IF) - for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - printf("\n start enb agent %d\n", enb_id); - flexran_agent_start(enb_id, enb_properties_p); - } -#endif - # if defined(ENABLE_USE_MME) /* Try to register each eNB */ registered_enb = 0; diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 09d7495a69..6282523b55 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -197,6 +197,7 @@ #define ENB_CONFIG_STRING_FLEXRAN_AGENT_IPV4_ADDRESS "FLEXRAN_AGENT_IPV4_ADDRESS" #define ENB_CONFIG_STRING_FLEXRAN_AGENT_PORT "FLEXRAN_AGENT_PORT" #define ENB_CONFIG_STRING_FLEXRAN_AGENT_CACHE "FLEXRAN_AGENT_CACHE" +#define ENB_CONFIG_STRING_FLEXRAN_AGENT_AWAIT_RECONF "FLEXRAN_AGENT_AWAIT_RECONF" #define ENB_CONFIG_STRING_RRH_GW_CONFIG "rrh_gw_config" #define ENB_CONFIG_STRING_RRH_GW_LOCAL_IF_NAME "local_if_name" @@ -351,6 +352,8 @@ void enb_config_display(void) // printf( "\tInterface IP Address: \t%s:\n",enb_properties.properties[i]->flexran_agent_ipv4_address); printf( "\tInterface PORT: \t%d:\n\n",enb_properties.properties[i]->flexran_agent_port); printf( "\tCache directory: \t%s:\n",enb_properties.properties[i]->flexran_agent_cache); + printf( "\teNB Control State: \t%s:\n",(enb_properties.properties[i]->flexran_agent_reconf==0)? "ENB_NORMAL_OPERATION":"ENB_WAIT_RECONFIGURATION_CMD"); + #endif @@ -536,7 +539,7 @@ extern int asn1_xer_print; #else #define libconfig_int int #endif -const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) +Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) { config_t cfg; config_setting_t *setting = NULL; @@ -689,6 +692,8 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) char* flexran_agent_ipv4_address = NULL; libconfig_int flexran_agent_port = 0; char* flexran_agent_cache = NULL; + char* flexran_agent_reconf = NULL; + libconfig_int otg_ue_id = 0; char* otg_app_type = NULL; char* otg_bg_traffic = NULL; @@ -2580,6 +2585,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) &flexran_agent_port) && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_CACHE, (const char **)&flexran_agent_cache) + && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_AWAIT_RECONF, + (const char **)&flexran_agent_reconf) + ) ) { enb_properties.properties[enb_properties_index]->flexran_agent_interface_name = strdup(flexran_agent_interface_name); @@ -2590,8 +2598,14 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) IPV4_STR_ADDR_TO_INT_NWBO (address, enb_properties.properties[enb_properties_index]->flexran_agent_ipv4_address, "BAD IP ADDRESS FORMAT FOR eNB Agent !\n" ); } - enb_properties.properties[enb_properties_index]->flexran_agent_port = flexran_agent_port; - enb_properties.properties[enb_properties_index]->flexran_agent_cache = strdup(flexran_agent_cache); + enb_properties.properties[enb_properties_index]->flexran_agent_port = flexran_agent_port; + enb_properties.properties[enb_properties_index]->flexran_agent_cache = strdup(flexran_agent_cache); + if ((strcmp(flexran_agent_reconf, "yes") == 0) || (strcmp(flexran_agent_reconf, "YES") == 0)){ + enb_properties.properties[enb_properties_index]->flexran_agent_reconf = 1; + } else { + enb_properties.properties[enb_properties_index]->flexran_agent_reconf = 0; + } + } } @@ -2885,7 +2899,7 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) } -const Enb_properties_array_t *enb_config_get(void) +Enb_properties_array_t *enb_config_get(void) { return &enb_properties; } diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h index 094360749b..8e914458bf 100644 --- a/openair2/ENB_APP/enb_config.h +++ b/openair2/ENB_APP/enb_config.h @@ -237,6 +237,8 @@ typedef struct Enb_properties_s { in_addr_t flexran_agent_ipv4_address; tcp_udp_port_t flexran_agent_port; char *flexran_agent_cache; + int flexran_agent_reconf; + /* Nb of RRH to connect to */ uint8_t nb_rrh_gw; @@ -276,15 +278,20 @@ typedef struct Enb_properties_s { #endif } Enb_properties_t; +typedef enum { + ENB_NORMAL_OPERATION=0x0, + ENB_WAIT_RECONFIGURATION_CMD=0x1 +} ENB_MODULE_STATE; + typedef struct Enb_properties_array_s { int number; Enb_properties_t *properties[MAX_ENB]; } Enb_properties_array_t; void enb_config_display(void); -const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP); +Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP); -const Enb_properties_array_t *enb_config_get(void); +Enb_properties_array_t *enb_config_get(void); #endif /* ENB_CONFIG_H_ */ /** @} */ diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index 839fb4c784..c883523855 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -31,7 +31,7 @@ #include "flexran_agent_common_internal.h" #include "flexran_agent_mac_internal.h" -extern volatile int reconfigure_enb; +extern volatile int node_control_state; int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy_length) { @@ -72,8 +72,8 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy if (parse_enb_id(mod_id, &parser) == -1) { goto error; } else { // succeful parse and setting - LOG_I(ENB_APP, "Successful parsed config for enb system\n"); - //reconfigure_enb=RECONF_FREQ; + node_control_state= ENB_NORMAL_OPERATION; + LOG_I(ENB_APP, "Successful parsed config for enb system, entering normal state\n"); } } else if (strcmp((char *) event.data.scalar.value, "mac") == 0) { LOG_D(ENB_APP, "This is intended for the mac system\n"); @@ -258,6 +258,9 @@ int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) { yaml_event_delete(&event); } + /* reflect in RAN API */ + flexran_set_enb_vars(mod_id, RAN_LTE_OAI); + return 0; error: diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 610700f3e8..a678178435 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -131,6 +131,7 @@ int UE_num_active_CC(UE_list_t *listP,int ue_idP) int UE_PCCID(module_id_t mod_idP,int ue_idP) //------------------------------------------------------------------------------ { + if (eNB_mac_inst == NULL) return 0; return(eNB_mac_inst[mod_idP].UE_list.pCC_id[ue_idP]); } @@ -139,6 +140,7 @@ rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP) //------------------------------------------------------------------------------ { + if (eNB_mac_inst == NULL) return 0; rnti_t rnti = eNB_mac_inst[mod_idP].UE_list.UE_template[UE_PCCID(mod_idP,ue_idP)][ue_idP].rnti; if (rnti>0) { @@ -154,6 +156,7 @@ rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP) boolean_t is_UE_active(module_id_t mod_idP, int ue_idP) //------------------------------------------------------------------------------ { + if (eNB_mac_inst == NULL) return 0; return(eNB_mac_inst[mod_idP].UE_list.active[ue_idP]); } @@ -182,6 +185,7 @@ uint8_t find_active_UEs(module_id_t module_idP,int CC_id){ int UE_BSR (uint8_t mod_id, uint8_t ue_id, uint8_t lcid) { + if (eNB_mac_inst == NULL) return 0; return eNB_mac_inst[mod_id].UE_list.UE_template[UE_PCCID(mod_id,ue_id)][ue_id].bsr_info[lcid]; } diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index c28b9e839c..1ca55b5926 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -40,6 +40,17 @@ # endif # include "enb_app.h" +int create_enb_app_task(uint32_t enb_nb) +{ + if (enb_nb > 0) { + if (itti_create_task (TASK_ENB_APP, eNB_app_task, NULL) < 0) { + LOG_E(ENB_APP, "Create task for eNB APP failed\n"); + return -1; + } + } + return 0; +} + int create_tasks(uint32_t enb_nb, uint32_t ue_nb) { itti_wait_ready(1); @@ -48,14 +59,6 @@ int create_tasks(uint32_t enb_nb, uint32_t ue_nb) return -1; } - if (enb_nb > 0) { - /* Last task to create, others task must be ready before its start */ - if (itti_create_task (TASK_ENB_APP, eNB_app_task, NULL) < 0) { - LOG_E(ENB_APP, "Create task for eNB APP failed\n"); - return -1; - } - } - # ifdef OPENAIR2 { diff --git a/targets/COMMON/create_tasks.h b/targets/COMMON/create_tasks.h index 6545f4b9d9..3455b283b5 100644 --- a/targets/COMMON/create_tasks.h +++ b/targets/COMMON/create_tasks.h @@ -27,6 +27,7 @@ extern void *l2l1_task(void *arg); int create_tasks(uint32_t enb_nb, uint32_t ue_nb); +int create_enb_app_task(uint32_t enb_nb); #endif #endif /* CREATE_TASKS_H_ */ diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.flexran.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.flexran.usrpb210.conf index 4ee429f45e..378d932f57 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.flexran.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.flexran.usrpb210.conf @@ -155,10 +155,11 @@ eNBs = NETWORK_CONTROLLER : { - FLEXRAN_AGENT_INTERFACE_NAME = "eth1"; - FLEXRAN_AGENT_IPV4_ADDRESS = "10.0.2.5/30"; + FLEXRAN_AGENT_INTERFACE_NAME = "lo"; + FLEXRAN_AGENT_IPV4_ADDRESS = "127.0.0.1/30"; FLEXRAN_AGENT_PORT = 2210; FLEXRAN_AGENT_CACHE = "/mnt/oai_agent_cache"; + FLEXRAN_AGENT_AWAIT_RECONF = "no"; }; log_config : @@ -177,6 +178,7 @@ eNBs = pdcp_log_verbosity ="medium"; rrc_log_level ="info"; rrc_log_verbosity ="medium"; + }; } ); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index a1f3bcb57b..042f77eea7 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -174,6 +174,8 @@ eNB_func_t node_function[MAX_NUM_CCs]; eNB_timing_t node_timing[MAX_NUM_CCs]; int16_t node_synch_ref[MAX_NUM_CCs]; +volatile int16_t node_control_state; + uint32_t target_dl_mcs = 28; //maximum allowed mcs uint32_t target_ul_mcs = 20; uint32_t timing_advance = 0; @@ -232,6 +234,12 @@ threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; */ uint8_t abstraction_flag=0; +/* */ + +/* overrid the enb configuration params*/ +static void reconfigure_enb_params(int enb_id); + + /*---------------------BMC: timespec helpers -----------------------------*/ struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; @@ -1080,11 +1088,20 @@ static void get_options (int argc, char **argv) { "Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!", conf_config_file_name, NB_eNB_INST, enb_properties->number); + NB_eNB_INST=enb_properties->number; + /* Update some simulation parameters */ for (i=0; i < enb_properties->number; i++) { AssertFatal (MAX_NUM_CCs == enb_properties->properties[i]->nb_cc, "lte-softmodem compiled with MAX_NUM_CCs=%d, but only %d CCs configured for eNB %d!", MAX_NUM_CCs, enb_properties->properties[i]->nb_cc, i); + + if (enb_properties->properties[i]->flexran_agent_reconf == 1) { + node_control_state = ENB_WAIT_RECONFIGURATION_CMD; + } else { + node_control_state = ENB_NORMAL_OPERATION; + } + eth_params = (eth_params_t*)malloc(enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t)); memset(eth_params, 0, enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t)); @@ -1133,37 +1150,9 @@ static void get_options (int argc, char **argv) { } - for (CC_id=0; CC_idproperties[i]->cc_node_function[CC_id]; - node_timing[CC_id] = enb_properties->properties[i]->cc_node_timing[CC_id]; - node_synch_ref[CC_id] = enb_properties->properties[i]->cc_node_synch_ref[CC_id]; - - frame_parms[CC_id]->frame_type = enb_properties->properties[i]->frame_type[CC_id]; - frame_parms[CC_id]->tdd_config = enb_properties->properties[i]->tdd_config[CC_id]; - frame_parms[CC_id]->tdd_config_S = enb_properties->properties[i]->tdd_config_s[CC_id]; - frame_parms[CC_id]->Ncp = enb_properties->properties[i]->prefix_type[CC_id]; - - //for (j=0; j < enb_properties->properties[i]->nb_cc; j++ ){ - frame_parms[CC_id]->Nid_cell = enb_properties->properties[i]->Nid_cell[CC_id]; - frame_parms[CC_id]->N_RB_DL = enb_properties->properties[i]->N_RB_DL[CC_id]; - frame_parms[CC_id]->N_RB_UL = enb_properties->properties[i]->N_RB_DL[CC_id]; - frame_parms[CC_id]->nb_antennas_tx = enb_properties->properties[i]->nb_antennas_tx[CC_id]; - frame_parms[CC_id]->nb_antenna_ports_eNB = enb_properties->properties[i]->nb_antenna_ports[CC_id]; - frame_parms[CC_id]->nb_antennas_rx = enb_properties->properties[i]->nb_antennas_rx[CC_id]; - - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex = enb_properties->properties[i]->prach_config_index[CC_id]; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset = enb_properties->properties[i]->prach_freq_offset[CC_id]; - - frame_parms[CC_id]->mode1_flag = (frame_parms[CC_id]->nb_antenna_ports_eNB == 1) ? 1 : 0; - frame_parms[CC_id]->threequarter_fs = threequarter_fs; - - //} // j - } - - - init_all_otg(0); + init_all_otg(0); g_otg->seed = 0; init_seeds(g_otg->seed); @@ -1206,20 +1195,7 @@ static void get_options (int argc, char **argv) { osa_log_verbosity = enb_properties->properties[i]->osa_log_verbosity; #endif - // adjust the log - for (CC_id=0; CC_idproperties[i]->downlink_frequency[CC_id]; - uplink_frequency_offset[CC_id][k] = enb_properties->properties[i]->uplink_frequency_offset[CC_id]; - rx_gain[CC_id][k] = (double)enb_properties->properties[i]->rx_gain[CC_id]; - tx_gain[CC_id][k] = (double)enb_properties->properties[i]->tx_gain[CC_id]; - } - - printf("Downlink frequency/ uplink offset of CC_id %d set to %ju/%d\n", CC_id, - enb_properties->properties[i]->downlink_frequency[CC_id], - enb_properties->properties[i]->uplink_frequency_offset[CC_id]); - - } // CC_id + }// i //this is needed for phy-test option @@ -1236,6 +1212,57 @@ static void get_options (int argc, char **argv) { } } + +static void reconfigure_enb_params(int enb_id) +{ + int CC_id, k; + const Enb_properties_array_t *enb_properties=enb_config_get(); + + + for (CC_id=0; CC_idproperties[enb_id]->cc_node_function[CC_id]; + node_timing[CC_id] = enb_properties->properties[enb_id]->cc_node_timing[CC_id]; + node_synch_ref[CC_id] = enb_properties->properties[enb_id]->cc_node_synch_ref[CC_id]; + + frame_parms[CC_id]->frame_type = enb_properties->properties[enb_id]->frame_type[CC_id]; + frame_parms[CC_id]->tdd_config = enb_properties->properties[enb_id]->tdd_config[CC_id]; + frame_parms[CC_id]->tdd_config_S = enb_properties->properties[enb_id]->tdd_config_s[CC_id]; + frame_parms[CC_id]->Ncp = enb_properties->properties[enb_id]->prefix_type[CC_id]; + + //for (j=0; j < enb_properties->properties[i]->nb_cc; j++ ){ + frame_parms[CC_id]->Nid_cell = enb_properties->properties[enb_id]->Nid_cell[CC_id]; + frame_parms[CC_id]->N_RB_DL = enb_properties->properties[enb_id]->N_RB_DL[CC_id]; + frame_parms[CC_id]->N_RB_UL = enb_properties->properties[enb_id]->N_RB_DL[CC_id]; + frame_parms[CC_id]->nb_antennas_tx = enb_properties->properties[enb_id]->nb_antennas_tx[CC_id]; + frame_parms[CC_id]->nb_antenna_ports_eNB = enb_properties->properties[enb_id]->nb_antenna_ports[CC_id]; + frame_parms[CC_id]->nb_antennas_rx = enb_properties->properties[enb_id]->nb_antennas_rx[CC_id]; + + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex = enb_properties->properties[enb_id]->prach_config_index[CC_id]; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset = enb_properties->properties[enb_id]->prach_freq_offset[CC_id]; + + frame_parms[CC_id]->mode1_flag = (frame_parms[CC_id]->nb_antenna_ports_eNB == 1) ? 1 : 0; + frame_parms[CC_id]->threequarter_fs = threequarter_fs; + + + for (k = 0 ; k < 4; k++) { + downlink_frequency[CC_id][k] = enb_properties->properties[enb_id]->downlink_frequency[CC_id]; + uplink_frequency_offset[CC_id][k] = enb_properties->properties[enb_id]->uplink_frequency_offset[CC_id]; + rx_gain[CC_id][k] = (double)enb_properties->properties[enb_id]->rx_gain[CC_id]; + tx_gain[CC_id][k] = (double)enb_properties->properties[enb_id]->tx_gain[CC_id]; + } + + printf("Downlink frequency/ uplink offset of CC_id %d set to %ju/%d\n", CC_id, + enb_properties->properties[enb_id]->downlink_frequency[CC_id], + enb_properties->properties[enb_id]->uplink_frequency_offset[CC_id]); + + init_ul_hopping(frame_parms[CC_id]); + init_frame_parms(frame_parms[CC_id],1); + // phy_init_top(frame_parms[CC_id]); + phy_init_lte_top(frame_parms[CC_id]); + } // CC_id +} + #if T_TRACER int T_wait = 1; /* by default we wait for the tracer */ int T_port = 2021; /* default port to listen to to wait for the tracer */ @@ -1395,6 +1422,19 @@ void init_openair0() { } } +/* check the state : either continue or wait for a command to start/stop the eNB + * if needed override the current configuration parameters, such as + * frequencies, bands, power, bandwidth + */ +static void ltesm_wait_reconfig_cmd(void) +{ + LOG_I(ENB_APP, "LTE Softmodem wait reconfiguration command\n"); + + while (node_control_state == ENB_WAIT_RECONFIGURATION_CMD) { + usleep(200000); + } +} + int main( int argc, char **argv ) { int i,j,k,aa,re; #if defined (XFORMS) @@ -1405,6 +1445,8 @@ int main( int argc, char **argv ) { uint8_t abstraction_flag=0; uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; + PHY_vars_eNB_g=NULL; + #if defined (XFORMS) int ret; #endif @@ -1570,11 +1612,6 @@ int main( int argc, char **argv ) { LOG_I(PHY,"Set nb_rx_antenna %d , nb_tx_antenna %d \n",frame_parms[CC_id]->nb_antennas_rx, frame_parms[CC_id]->nb_antennas_tx); } - - init_ul_hopping(frame_parms[CC_id]); - init_frame_parms(frame_parms[CC_id],1); - // phy_init_top(frame_parms[CC_id]); - phy_init_lte_top(frame_parms[CC_id]); } @@ -1586,6 +1623,14 @@ int main( int argc, char **argv ) { // N_ZC = (prach_fmt <4)?839:139; } + create_enb_app_task(UE_flag ? 0 : 1); + ltesm_wait_reconfig_cmd (); + // reconfigure_enb: 0 for wait, 1 for skip, and other values to reconfigure + for (i=0; (i < NB_eNB_INST && node_control_state == ENB_NORMAL_OPERATION ) ; i++){ + reconfigure_enb_params(i); + printf("[ENB_APP] Reconfigured eNB module %d - continue\n", i); + } + if (UE_flag==1) { NB_UE_INST=1; NB_INST=1; From c62be7a101ce487b329e889e2746c8c94afd880b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 8 Dec 2017 15:28:28 +0100 Subject: [PATCH 048/141] Uniform messages of exiting threads --- common/utils/msc/msc.c | 1 + openair2/ENB_APP/enb_app.c | 1 + openair2/ENB_APP/flexran_agent.c | 1 + openair2/RRC/LITE/rrc_UE.c | 1 + openair2/RRC/LITE/rrc_eNB.c | 1 + openair2/X2AP/x2ap.c | 1 + openair3/GTPV1-U/gtpv1u_eNB.c | 1 + openair3/GTPV1-U/gtpv1u_task.c | 1 + openair3/S1AP/s1ap_eNB.c | 1 + openair3/SCTP/sctp_eNB_task.c | 1 + openair3/TEST/EPC_TEST/play_scenario_s1ap.c | 1 + openair3/UDP/udp_eNB_task.c | 2 +- targets/RT/USER/lte-enb.c | 24 +++++++++++++++++---- targets/RT/USER/lte-softmodem.c | 3 ++- 14 files changed, 34 insertions(+), 6 deletions(-) diff --git a/common/utils/msc/msc.c b/common/utils/msc/msc.c index 7de2a47f98..83f3beb512 100644 --- a/common/utils/msc/msc.c +++ b/common/utils/msc/msc.c @@ -99,6 +99,7 @@ void *msc_task(void *args_p) break; case TERMINATE_MESSAGE: { + fprintf(stderr, " *** Exiting MSC thread\n"); timer_remove(timer_id); msc_end(); itti_exit_task(); diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 4a5981f509..bada59ffec 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -361,6 +361,7 @@ void *eNB_app_task(void *args_p) switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: + LOG_W(TASK_ENB_APP, " *** Exiting ENB_APP thread\n"); itti_exit_task (); break; diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index 23ac8f02ac..8af071527f 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -74,6 +74,7 @@ void *flexran_agent_task(void *args){ switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: + LOG_W(FLEXRAN_AGENT, " *** Exiting FLEXRAN thread\n"); itti_exit_task (); break; diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index 6798212fb2..7f0c3a8800 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -4286,6 +4286,7 @@ void *rrc_ue_task( void *args_p ) switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: + LOG_W(RRC, " *** Exiting RRC thread\n"); itti_exit_task (); break; diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index aaf12da175..c441c102e3 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -5621,6 +5621,7 @@ rrc_enb_task( switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: + LOG_W(RRC, " *** Exiting RRC thread\n"); itti_exit_task(); break; diff --git a/openair2/X2AP/x2ap.c b/openair2/X2AP/x2ap.c index 699ad5ddbf..6af71e5ca5 100644 --- a/openair2/X2AP/x2ap.c +++ b/openair2/X2AP/x2ap.c @@ -49,6 +49,7 @@ void *x2ap_task(void *arg) switch (ITTI_MSG_ID(received_msg)) { case TERMINATE_MESSAGE: + X2AP_WARN(" *** Exiting X2AP thread\n"); itti_exit_task(); break; diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index e273ac0712..d0a3bbd342 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -1132,6 +1132,7 @@ void *gtpv1u_eNB_task(void *args) hashtable_destroy (gtpv1u_data_g.teid_mapping); } + LOG_W(GTPU, " *** Exiting GTPU thread\n"); itti_exit_task(); } break; diff --git a/openair3/GTPV1-U/gtpv1u_task.c b/openair3/GTPV1-U/gtpv1u_task.c index f9397f21ca..bea003a655 100644 --- a/openair3/GTPV1-U/gtpv1u_task.c +++ b/openair3/GTPV1-U/gtpv1u_task.c @@ -423,6 +423,7 @@ static void *gtpv1u_thread(void *args) switch (ITTI_MSG_ID(received_message_p)) { case TERMINATE_MESSAGE: { + GTPU_WARN(" *** Exiting GTPU thread\n"); itti_exit_task(); } break; diff --git a/openair3/S1AP/s1ap_eNB.c b/openair3/S1AP/s1ap_eNB.c index 65b82055a3..b96d9103f4 100644 --- a/openair3/S1AP/s1ap_eNB.c +++ b/openair3/S1AP/s1ap_eNB.c @@ -310,6 +310,7 @@ void *s1ap_eNB_task(void *arg) switch (ITTI_MSG_ID(received_msg)) { case TERMINATE_MESSAGE: + S1AP_WARN(" *** Exiting S1AP thread\n"); itti_exit_task(); break; diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index 1f166af74c..758cbd5aa5 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -841,6 +841,7 @@ void *sctp_eNB_task(void *arg) break; case TERMINATE_MESSAGE: + SCTP_WARN("*** Exiting SCTP thread\n"); itti_exit_task(); break; diff --git a/openair3/TEST/EPC_TEST/play_scenario_s1ap.c b/openair3/TEST/EPC_TEST/play_scenario_s1ap.c index f1bbe393be..d2247f70a8 100644 --- a/openair3/TEST/EPC_TEST/play_scenario_s1ap.c +++ b/openair3/TEST/EPC_TEST/play_scenario_s1ap.c @@ -1089,6 +1089,7 @@ void *et_s1ap_eNB_task(void *arg) switch (ITTI_MSG_ID(received_msg)) { case TERMINATE_MESSAGE: + S1AP_WARN("*** Exiting S1AP thread\n"); itti_exit_task(); break; diff --git a/openair3/UDP/udp_eNB_task.c b/openair3/UDP/udp_eNB_task.c index b8b6b897a7..94c5612ec6 100644 --- a/openair3/UDP/udp_eNB_task.c +++ b/openair3/UDP/udp_eNB_task.c @@ -389,7 +389,7 @@ void *udp_eNB_task(void *args_p) break; case TERMINATE_MESSAGE: { - LOG_W(UDP_, "Received TERMINATE_MESSAGE\n"); + LOG_W(UDP_, " *** Exiting UDP thread\n"); itti_exit_task(); } break; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 5cbe0fe1d4..2223855419 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -643,7 +643,9 @@ static void* eNB_thread_rxtx( void* param ) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); - printf( "Exiting eNB thread RXn_TXnp4\n"); +#ifdef DEBUG_THREADS + printf(" *** Exiting eNB thread RXn_TXnp4\n"); +#endif eNB_thread_rxtx_status = 0; return &eNB_thread_rxtx_status; @@ -907,6 +909,10 @@ static void* eNB_thread_asynch_rxtx( void* param ) { } +#ifdef DEBUG_THREADS + printf(" *** Exiting eNB asynch rxtx thread\n"); +#endif + eNB_thread_asynch_rxtx_status=0; return(&eNB_thread_asynch_rxtx_status); } @@ -1372,6 +1378,10 @@ void *eNB_thread_synch(void *arg) { lte_sync_time_free(); +#ifdef DEBUG_THREADS + printf(" *** Exiting eNB synch thread\n"); +#endif + return NULL; } @@ -1484,7 +1494,9 @@ static void* eNB_thread_FH( void* param ) { rt_sleep_ns(800000LL); } - printf( "Exiting FH thread \n"); +#ifdef DEBUG_THREADS + printf(" *** Exiting FH thread \n"); +#endif eNB_thread_FH_status = 0; return &eNB_thread_FH_status; @@ -1518,7 +1530,9 @@ static void* eNB_thread_prach( void* param ) { if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; } - printf( "Exiting eNB thread PRACH\n"); +#ifdef DEBUG_THREADS + printf(" *** Exiting eNB thread PRACH\n"); +#endif eNB_thread_prach_status = 0; return &eNB_thread_prach_status; @@ -1688,7 +1702,9 @@ static void* eNB_thread_single( void* param ) { } - printf( "Exiting eNB_single thread \n"); +#ifdef DEBUG_THREADS + printf(" *** Exiting eNB_single thread\n"); +#endif eNB_thread_single_status = 0; return &eNB_thread_single_status; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 042f77eea7..ed0dd20360 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -558,7 +558,7 @@ void *l2l1_task(void *arg) { break; case TERMINATE_MESSAGE: - printf("received terminate message\n"); + LOG_W(TASK_L2L1, " *** Exiting L2L1 thread\n"); oai_exit=1; itti_exit_task (); break; @@ -579,6 +579,7 @@ void *l2l1_task(void *arg) { switch (ITTI_MSG_ID(message_p)) { case TERMINATE_MESSAGE: + LOG_W(TASK_L2L1, " *** Exiting L2L1 thread\n"); oai_exit=1; itti_exit_task (); break; From c313dff2ad9b37a23458d63f1431197c01d7e842 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 11 Dec 2017 11:32:06 +0100 Subject: [PATCH 049/141] better logging, remove warnings --- openair2/ENB_APP/enb_app.c | 2 +- .../ENB_APP/flexran_agent_common_internal.c | 25 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index bada59ffec..89e20889cb 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -330,7 +330,7 @@ void *eNB_app_task(void *args_p) // set again the ran api vars for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - printf("\n set again enb vars %d\n", enb_id); + LOG_I(ENB_APP, "set again enb vars %d\n", enb_id); flexran_set_enb_vars(enb_id, RAN_LTE_OAI); } diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index c883523855..e2ee656b23 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -216,35 +216,34 @@ int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) { goto error; } // Check what key needs to be set - LOG_I(ENB_APP, "Setting parameter %s\n", event.data.scalar.value); if (strcmp((char *) event.data.scalar.value, "dl_freq") == 0) { - if (!yaml_parser_parse(parser, &event)) - goto error; + if (!yaml_parser_parse(parser, &event)) + goto error; flexran_agent_set_operating_dl_freq(mod_id, 0, strtol((char *) event.data.scalar.value, &endptr, 10)); - LOG_I(ENB_APP, "Setting parameter value %s\n", event.data.scalar.value); + LOG_I(ENB_APP, "Setting dl_freq to %s\n", event.data.scalar.value); } else if (strcmp((char *) event.data.scalar.value, "ul_freq_offset") == 0) { - if (!yaml_parser_parse(parser, &event)) - goto error; + if (!yaml_parser_parse(parser, &event)) + goto error; flexran_agent_set_operating_ul_freq(mod_id, 0, strtol((char *) event.data.scalar.value, &endptr, 10)); - LOG_I(ENB_APP, "Setting parameter value %s\n", event.data.scalar.value); + LOG_I(ENB_APP, "Setting ul_freq_offset to %s\n", event.data.scalar.value); } else if (strcmp((char *) event.data.scalar.value, "bandwidth") == 0) { - if (!yaml_parser_parse(parser, &event)) - goto error; + if (!yaml_parser_parse(parser, &event)) + goto error; flexran_agent_set_operating_bandwidth(mod_id, 0, strtol((char *) event.data.scalar.value, &endptr, 10)); - LOG_I(ENB_APP, "Setting parameter value %s\n", event.data.scalar.value); + LOG_I(ENB_APP, "Setting bandwidth to %s\n", event.data.scalar.value); } else if (strcmp((char *) event.data.scalar.value, "frame_type") == 0) { - if (!yaml_parser_parse(parser, &event)) - goto error; + if (!yaml_parser_parse(parser, &event)) + goto error; flexran_agent_set_operating_frame_type (mod_id, 0, strtol((char *) event.data.scalar.value, &endptr, 10)); - LOG_I(ENB_APP, "Setting parameter value %s\n", event.data.scalar.value); + LOG_I(ENB_APP, "Setting frame_type to %s\n", event.data.scalar.value); }else { // not supported tag goto error; } From 1aa5d2930a61fc499b0233758ce7c27950667cdc Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 11 Dec 2017 11:37:10 +0100 Subject: [PATCH 050/141] Handle TERMINATE_MESSAGE in TASK_MAC --- openair2/LAYER2/MAC/eNB_scheduler.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index f46b9deb8d..60a6e22125 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -323,6 +323,11 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, break; #endif + case TERMINATE_MESSAGE: + LOG_W(MAC, "+++ Exiting MAC thread\n"); + itti_exit_task (); + break; + default: LOG_E(MAC, "Received unexpected message %s\n", msg_name); break; From ea65ddad2cb2fa33a6c4eb935a47d20b32bd0274 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 11 Dec 2017 15:31:21 +0100 Subject: [PATCH 051/141] fill PHY_vars_eNB_g in own function --- targets/RT/USER/lte-softmodem.c | 120 ++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index ed0dd20360..d36907bba7 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1423,6 +1423,70 @@ void init_openair0() { } } +void fill_PHY_vars_eNB_g(uint8_t abstraction_flag, uint8_t beta_ACK, uint8_t beta_RI, uint8_t beta_CQI) +{ + int CC_id, i, j, k, re; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id], + 0, + frame_parms[CC_id]->Nid_cell, + node_function[CC_id], + abstraction_flag); + PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc = 0x1fff; + PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs = target_dl_mcs; + PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb = 6; + PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs = target_ul_mcs; + // initialization for phy-test + for (k = 0; k < NUMBER_OF_UE_MAX; k++) { + PHY_vars_eNB_g[0][CC_id]->transmission_mode[k] = transmission_mode; + if (transmission_mode == 7) + lte_gold_ue_spec_port5(PHY_vars_eNB_g[0][CC_id]->lte_gold_uespec_port5_table[k], + frame_parms[CC_id]->Nid_cell, + 0x1235+k); + } + if ((transmission_mode == 1) || (transmission_mode == 7)) { + for (j = 0; j < frame_parms[CC_id]->nb_antennas_tx; j++) + for (re = 0; re < frame_parms[CC_id]->ofdm_symbol_size; re++) + PHY_vars_eNB_g[0][CC_id]->common_vars.beam_weights[0][0][j][re] = 0x00007fff / frame_parms[CC_id]->nb_antennas_tx; + } + + if (phy_test==1) + PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0; + else + PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1; + + if (PHY_vars_eNB_g[0][CC_id]->mac_enabled == 0) { //set default parameters for testing mode + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; + + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i; + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3); + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; + } + } + + compute_prach_seq(&PHY_vars_eNB_g[0][CC_id]->frame_parms.prach_config_common, + PHY_vars_eNB_g[0][CC_id]->frame_parms.frame_type, + PHY_vars_eNB_g[0][CC_id]->X_u); + + + PHY_vars_eNB_g[0][CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0]; + + if (frame_parms[CC_id]->frame_type == FDD) { + PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 0; + } else { + if (frame_parms[CC_id]->N_RB_DL == 100) + PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624; + else if (frame_parms[CC_id]->N_RB_DL == 50) + PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/2; + else if (frame_parms[CC_id]->N_RB_DL == 25) + PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/4; + } + } +} + /* check the state : either continue or wait for a command to start/stop the eNB * if needed override the current configuration parameters, such as * frequencies, bands, power, bandwidth @@ -1437,7 +1501,7 @@ static void ltesm_wait_reconfig_cmd(void) } int main( int argc, char **argv ) { - int i,j,k,aa,re; + int i,aa; #if defined (XFORMS) void *status; #endif @@ -1710,59 +1774,7 @@ int main( int argc, char **argv ) { PHY_vars_eNB_g = malloc(sizeof(PHY_VARS_eNB**)); PHY_vars_eNB_g[0] = malloc(sizeof(PHY_VARS_eNB*)); - for (CC_id=0; CC_idNid_cell,node_function[CC_id],abstraction_flag); - PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc=0x1fff; - PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs=target_dl_mcs; - PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb=6; - PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs=target_ul_mcs; - // initialization for phy-test - for (k=0; ktransmission_mode[k] = transmission_mode; - if (transmission_mode==7) - lte_gold_ue_spec_port5(PHY_vars_eNB_g[0][CC_id]->lte_gold_uespec_port5_table[k],frame_parms[CC_id]->Nid_cell,0x1235+k); - } - if ((transmission_mode==1) || (transmission_mode==7)) { - for (j=0; jnb_antennas_tx; j++) - for (re=0; reofdm_symbol_size; re++) - PHY_vars_eNB_g[0][CC_id]->common_vars.beam_weights[0][0][j][re] = 0x00007fff/frame_parms[CC_id]->nb_antennas_tx; - } - - if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0; - else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1; - - if (PHY_vars_eNB_g[0][CC_id]->mac_enabled == 0) { //set default parameters for testing mode - for (i=0; ipusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; - - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i; - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3); - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; - } - } - - compute_prach_seq(&PHY_vars_eNB_g[0][CC_id]->frame_parms.prach_config_common, - PHY_vars_eNB_g[0][CC_id]->frame_parms.frame_type, - PHY_vars_eNB_g[0][CC_id]->X_u); - - - PHY_vars_eNB_g[0][CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0]; - - if (frame_parms[CC_id]->frame_type==FDD) { - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 0; - } else { - if (frame_parms[CC_id]->N_RB_DL == 100) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624; - else if (frame_parms[CC_id]->N_RB_DL == 50) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/2; - else if (frame_parms[CC_id]->N_RB_DL == 25) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/4; - } - - } - + fill_PHY_vars_eNB_g(abstraction_flag, beta_ACK, beta_RI, beta_CQI); NB_eNB_INST=1; NB_INST=1; From e88a3cdf469f04b67158625e5a663dc29fad299e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 12 Dec 2017 10:56:40 +0100 Subject: [PATCH 052/141] bugfix ITTI: clean up in itti_exit_task() - when exiting task, the task is set as "not configured" - this permits to start a task again --- common/utils/itti/intertask_interface.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index 28267900af..59209994b6 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -775,15 +775,19 @@ void itti_mark_task_ready(task_id_t task_id) void itti_exit_task(void) { -#if defined(OAI_EMU) || defined(RTAI) task_id_t task_id = itti_get_current_task_id(); + thread_id_t thread_id = TASK_GET_THREAD_ID(task_id); +#if defined(OAI_EMU) || defined(RTAI) if (task_id > TASK_UNKNOWN) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_RECV_MSG, __sync_and_and_fetch (&itti_desc.vcd_receive_msg, ~(1L << task_id))); } - #endif + + itti_desc.threads[thread_id].task_state = TASK_STATE_NOT_CONFIGURED; + itti_desc.created_tasks--; + ITTI_DEBUG(ITTI_DEBUG_EXIT, "Thread for task %s (%d) exits\n", itti_get_task_name(task_id), task_id); pthread_exit (NULL); } From c619f6eff76234d2efd14d29e99d8132dd768946 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 12 Dec 2017 10:03:06 +0100 Subject: [PATCH 053/141] Feature: Provide restart for lte-softmodem - {restart,stop}_L1L2() in lte-softmodem.c - add function start_phy_rrc() in enb_app.{c,h}, accessible from outside - will be used to restart PHY and RRC when lte-softmodem is restarted use only one FlexRAN wait function --- openair2/ENB_APP/enb_app.c | 30 ++-- openair2/ENB_APP/enb_app.h | 7 + .../ENB_APP/flexran_agent_common_internal.c | 28 +++- targets/RT/USER/lte-softmodem.c | 133 ++++++++++++++++-- targets/RT/USER/lte-softmodem.h | 3 + 5 files changed, 178 insertions(+), 23 deletions(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 89e20889cb..be0b88acff 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -57,14 +57,13 @@ extern unsigned char NB_eNB_INST; #endif extern volatile int node_control_state; -static void enb_app_wait_reconfig_cmd (void) +void ltesm_wait_reconfig_cmd(void) { - LOG_I(ENB_APP, "ENB APP await reconfiguration command\n"); - - while (node_control_state == ENB_WAIT_RECONFIGURATION_CMD) { + LOG_I(ENB_APP, "LTE Softmodem wait reconfiguration command\n"); + + while (node_control_state == ENB_WAIT_RECONFIGURATION_CMD) { usleep(200000); } - sleep(2); // wait for createing other tasks } #if defined(ENABLE_ITTI) @@ -202,6 +201,15 @@ static void configure_rrc(uint32_t enb_id, const Enb_properties_array_t *enb_pro itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); } +void enb_app_start_phy_rrc(uint32_t enb_id_start, uint32_t enb_id_end) +{ + Enb_properties_array_t *enb_properties_p = enb_config_get(); + for (uint32_t enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { + configure_phy(enb_id, enb_properties_p); + configure_rrc(enb_id, enb_properties_p); + } +} + /*------------------------------------------------------------------------------*/ # if defined(ENABLE_USE_MME) static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, const Enb_properties_array_t *enb_properties) @@ -325,8 +333,10 @@ void *eNB_app_task(void *args_p) for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { flexran_agent_start(enb_id, enb_properties_p); } - // wait for config comd from the controller/network app - enb_app_wait_reconfig_cmd(); + // wait for config comd from the controller/network app plus some time so + // that the other Tasks are in place + ltesm_wait_reconfig_cmd(); + sleep(2); // set again the ran api vars for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { @@ -336,11 +346,7 @@ void *eNB_app_task(void *args_p) #endif - for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - configure_phy(enb_id, enb_properties_p); - configure_rrc(enb_id, enb_properties_p); - } - + enb_app_start_phy_rrc(enb_id_start, enb_id_end); # if defined(ENABLE_USE_MME) /* Try to register each eNB */ diff --git a/openair2/ENB_APP/enb_app.h b/openair2/ENB_APP/enb_app.h index 8e3c28760b..be5adfbb34 100644 --- a/openair2/ENB_APP/enb_app.h +++ b/openair2/ENB_APP/enb_app.h @@ -30,8 +30,15 @@ #ifndef ENB_APP_H_ #define ENB_APP_H_ +#include void *eNB_app_task(void *args_p); +/* needed for flexran: start PHY and RRC when restarting */ +void enb_app_start_phy_rrc(uint32_t enb_id_start, uint32_t enb_id_end); + +/* wait that FlexRAN left state ENB_WAIT_RECONFIGURATION_CMD */ +void ltesm_wait_reconfig_cmd(void); + #endif /* ENB_APP_H_ */ diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index e2ee656b23..e77557e9ee 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -31,8 +31,33 @@ #include "flexran_agent_common_internal.h" #include "flexran_agent_mac_internal.h" + +/* the following is needed to soft-restart the lte-softmodem */ +#include "targets/RT/USER/lte-softmodem.h" +#include "assertions.h" +#include "enb_app.h" extern volatile int node_control_state; +void handle_reconfiguration(mid_t mod_id) +{ + /* NOTE: this function might be extended by using stop_modem() + * to halt the modem so that it can later be resumed */ + + if (ENB_NORMAL_OPERATION != node_control_state) { + node_control_state = ENB_NORMAL_OPERATION; + } else { + if (stop_L1L2(mod_id) < 0 || restart_L1L2(mod_id) < 0) { + LOG_E(ENB_APP, "could not restart, killing lte-softmodem\n"); + /* shutdown the whole lte-softmodem */ + itti_terminate_tasks(TASK_PHY_ENB); + return; + } + + enb_app_start_phy_rrc(mod_id, mod_id+1); + LOG_I(ENB_APP, "lte-softmodem restart succeeded\n"); + } +} + int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy_length) { yaml_parser_t parser; @@ -72,8 +97,7 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy if (parse_enb_id(mod_id, &parser) == -1) { goto error; } else { // succeful parse and setting - node_control_state= ENB_NORMAL_OPERATION; - LOG_I(ENB_APP, "Successful parsed config for enb system, entering normal state\n"); + handle_reconfiguration(mod_id); } } else if (strcmp((char *) event.data.scalar.value, "mac") == 0) { LOG_D(ENB_APP, "This is intended for the mac system\n"); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index d36907bba7..b89c82aff4 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1487,19 +1487,129 @@ void fill_PHY_vars_eNB_g(uint8_t abstraction_flag, uint8_t beta_ACK, uint8_t bet } } -/* check the state : either continue or wait for a command to start/stop the eNB - * if needed override the current configuration parameters, such as - * frequencies, bands, power, bandwidth +#if defined(ENABLE_ITTI) && defined(FLEXRAN_AGENT_SB_IF) +/* + * helper function to terminate a certain ITTI task */ -static void ltesm_wait_reconfig_cmd(void) +void terminate_task(task_id_t task_id, mid_t mod_id) { - LOG_I(ENB_APP, "LTE Softmodem wait reconfiguration command\n"); - - while (node_control_state == ENB_WAIT_RECONFIGURATION_CMD) { - usleep(200000); - } + LOG_I(ENB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id); + MessageDef *msg; + msg = itti_alloc_new_message (ENB_APP, TERMINATE_MESSAGE); + itti_send_msg_to_task (task_id, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg); } +int stop_L1L2(int enb_id) +{ + int CC_id; + + LOG_W(ENB_APP, "stopping lte-softmodem\n"); + + /* stop trx devices */ + for(CC_id=0; CC_idrfdevice.trx_stop_func) { + LOG_I(ENB_APP, "stopping PHY_vars_eNB_g[0][%d]->rfdevice (via trx_stop_func())\n", CC_id); + PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_stop_func(&PHY_vars_eNB_g[0][CC_id]->rfdevice); + } + if (PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_stop_func) { + LOG_I(ENB_APP, "stopping PHY_vars_eNB_g[0][%d]->ifdevice (via trx_stop_func())\n", CC_id); + PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_stop_func(&PHY_vars_eNB_g[0][CC_id]->ifdevice); + } + } + + /* these tasks need to pick up new configuration */ + terminate_task(TASK_RRC_ENB, enb_id); + terminate_task(TASK_L2L1, enb_id); + oai_exit = 1; + LOG_W(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id); + kill_eNB_proc(enb_id); + /* give some time for all threads */ + sleep(1); + return 0; +} + +/* + * Restart the lte-softmodem. + * This function checks whether we are in ENB_NORMAL_OPERATION (defined by + * FlexRAN). If yes, first stop L1/L2/L3, then resume. + */ +int restart_L1L2(int enb_id) +{ + int i, aa, CC_id; + /* needed for fill_PHY_vars_eNB_g(), defined locally in main(); + * abstraction flag is needed too, but defined both globally and in main () */ + uint8_t beta_ACK = 0, beta_RI = 0, beta_CQI = 2; + /* needed for macphy_init() */ + int eMBMS_active = 0; + + LOG_W(ENB_APP, "restarting lte-softmodem\n"); + + /* block threads */ + sync_var = -1; + oai_exit = 0; + + reconfigure_enb_params(enb_id); /* set frame parameters from configuration */ + + /* PHY_vars_eNB_g will be filled by init_lte_eNB(), so free and + * let the data structure be filled again */ + for (CC_id=0; CC_idframe_parms = frame_parms[0]; + mac_xface->macphy_init(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,0,0); + + LOG_I(ENB_APP, "attempting to create ITTI tasks\n"); + if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) { + LOG_E(RRC, "Create task for RRC eNB failed\n"); + return -1; + } else { + LOG_I(RRC, "Re-created task for RRC eNB successfully\n"); + } + if (itti_create_task (TASK_L2L1, l2l1_task, NULL) < 0) { + LOG_E(PDCP, "Create task for L2L1 failed\n"); + return -1; + } else { + LOG_I(PDCP, "Re-created task for L2L1 successfully\n"); + } + + /* TODO XForms here */ + + printf("Initializing eNB threads\n"); + init_eNB(node_function, node_timing, 1, eth_params, single_thread_flag, wait_for_sync); + for(CC_id=0; CC_idrf_map.card=0; + PHY_vars_eNB_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; + } + + mlockall(MCL_CURRENT | MCL_FUTURE); + + printf("Setting eNB buffer to all-RX\n"); + // Set LSBs for antenna switch (ExpressMIMO) + for (CC_id=0; CC_idhw_timing_advance = 0; + for (i=0; isamples_per_tti*10; i++) + for (aa=0; aanb_antennas_tx; aa++) + PHY_vars_eNB_g[0][CC_id]->common_vars.txdata[0][aa][i] = 0x00010001; + } + + printf("Sending sync to all threads\n"); + + pthread_mutex_lock(&sync_mutex); + sync_var=0; + pthread_cond_broadcast(&sync_cond); + pthread_mutex_unlock(&sync_mutex); + + return 0; +} +#endif + int main( int argc, char **argv ) { int i,aa; #if defined (XFORMS) @@ -1689,7 +1799,12 @@ int main( int argc, char **argv ) { } create_enb_app_task(UE_flag ? 0 : 1); + +#ifdef FLEXRAN_AGENT_SB_IF + /* wait command for flexran agent: only start when configuration received */ ltesm_wait_reconfig_cmd (); +#endif + // reconfigure_enb: 0 for wait, 1 for skip, and other values to reconfigure for (i=0; (i < NB_eNB_INST && node_control_state == ENB_NORMAL_OPERATION ) ; i++){ reconfigure_enb_params(i); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 4d9d145c68..a0883c3d59 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -89,4 +89,7 @@ extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); +extern int stop_L1L2(int enb_id); +extern int restart_L1L2(int enb_id); + #endif From eb2dfa1b70db81fa77df72f2474982af973b0c9f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 12 Dec 2017 16:59:46 +0100 Subject: [PATCH 054/141] kill_eNB_proc(): join all PHY threads --- targets/RT/USER/lte-enb.c | 43 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 2223855419..9bde18df40 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -1754,6 +1754,7 @@ void init_eNB_proc(int inst) { pthread_mutex_init( &proc->mutex_prach, NULL); pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_synch,NULL); + pthread_mutex_init( &proc->mutex_FH, NULL); pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_FH, NULL); @@ -1862,30 +1863,68 @@ void kill_eNB_proc(int inst) { printf( "Killing TX CC_id %d thread %d\n", CC_id, i ); #endif - proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race! - proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race! + pthread_mutex_lock(&proc_rxtx[0].mutex_rxtx); + proc_rxtx[0].instance_cnt_rxtx = 0; + pthread_mutex_unlock(&proc_rxtx[0].mutex_rxtx); + pthread_mutex_lock(&proc_rxtx[1].mutex_rxtx); + proc_rxtx[1].instance_cnt_rxtx = 0; + pthread_mutex_unlock(&proc_rxtx[1].mutex_rxtx); + pthread_mutex_lock(&PHY_vars_eNB_g[0][CC_id]->proc.mutex_synch); + PHY_vars_eNB_g[0][CC_id]->proc.instance_cnt_synch = 1; + pthread_mutex_unlock(&PHY_vars_eNB_g[0][CC_id]->proc.mutex_synch); proc->instance_cnt_prach = 0; proc->instance_cnt_FH = 0; pthread_cond_signal( &proc_rxtx[0].cond_rxtx ); pthread_cond_signal( &proc_rxtx[1].cond_rxtx ); pthread_cond_signal( &proc->cond_prach ); pthread_cond_signal( &proc->cond_FH ); + pthread_cond_signal( &proc->cond_asynch_rxtx ); + pthread_cond_signal( &proc->cond_synch ); pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); +#ifdef DEBUG_THREADS + printf("joining pthread_FH\n"); +#endif pthread_join( proc->pthread_FH, (void**)&status ); pthread_mutex_destroy( &proc->mutex_FH ); pthread_cond_destroy( &proc->cond_FH ); +#ifdef DEBUG_THREADS + printf("joining pthread_prach\n"); +#endif pthread_join( proc->pthread_prach, (void**)&status ); pthread_mutex_destroy( &proc->mutex_prach ); pthread_cond_destroy( &proc->cond_prach ); int i; for (i=0;i<2;i++) { +#ifdef DEBUG_THREADS + printf("joining pthread_rxtx\n"); +#endif pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); } + +#ifdef DEBUG_THREADS + printf("joining pthread_asynch_rxtx\n"); +#endif + pthread_join(proc->pthread_asynch_rxtx, (void**)&status ); + pthread_mutex_destroy(&proc->mutex_asynch_rxtx); + pthread_cond_destroy(&proc->cond_asynch_rxtx); + +#ifdef DEBUG_THREADS + printf("joining pthread_single\n"); +#endif + pthread_join(proc->pthread_single, (void**)&status ); + +#ifdef DEBUG_THREADS + printf("joining pthread_synch\n"); +#endif + pthread_join(proc->pthread_synch, (void**)&status ); + pthread_mutex_destroy(&proc->mutex_synch); + pthread_cond_destroy(&proc->cond_synch); + printf("joined all threads\n"); } } From 730ffc76f4009b8164e17e959ccdf639e3b5631c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 12 Dec 2017 17:00:43 +0100 Subject: [PATCH 055/141] stop_L1L2(): no sleep, better oai_exit handling --- targets/RT/USER/lte-softmodem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index b89c82aff4..f881441cdb 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1504,6 +1504,7 @@ int stop_L1L2(int enb_id) int CC_id; LOG_W(ENB_APP, "stopping lte-softmodem\n"); + oai_exit = 1; /* stop trx devices */ for(CC_id=0; CC_id Date: Tue, 12 Dec 2017 18:04:25 +0100 Subject: [PATCH 056/141] Fix multiple compilation warnings --- openair2/ENB_APP/enb_config.c | 4 ++-- openair2/ENB_APP/flexran_agent_net_comm.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 6282523b55..08de05c144 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -2009,7 +2009,7 @@ Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) enb_properties.properties[enb_properties_index]->rrc_report_amount = ReportConfigEUTRA__reportAmount_infinity; }else{ AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for report_amount choice: r1, r2, r4, r8, r16, r32, r64, infinity !\n", + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for report_amount choice: r1, r2, r4, r8, r16, r32, r64, infinity !\n", lib_config_file_name_pP, i,rrc_report_amount); } @@ -2041,7 +2041,7 @@ Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) enb_properties.properties[enb_properties_index]->rrc_report_interval = ReportInterval_min60; } else { AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for report_interval choice: 120ms, 240ms, 480ms, 640ms, 1024ms, 2048ms, 5120ms, 10240ms, 1min, 6min, 12", + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for report_interval choice: 120ms, 240ms, 480ms, 640ms, 1024ms, 2048ms, 5120ms, 10240ms, 1min, 6min, 12", lib_config_file_name_pP, i,rrc_report_interval); } diff --git a/openair2/ENB_APP/flexran_agent_net_comm.c b/openair2/ENB_APP/flexran_agent_net_comm.c index d801bbdda5..e5f9109871 100644 --- a/openair2/ENB_APP/flexran_agent_net_comm.c +++ b/openair2/ENB_APP/flexran_agent_net_comm.c @@ -141,9 +141,9 @@ int flexran_agent_destroy_channel(int channel_id) { for (i = 0; i < NUM_MAX_ENB; i++) { for (j = 0; j < FLEXRAN_AGENT_MAX; j++) { if (agent_channel[i][j] != NULL) { - if (agent_channel[i][j]->channel_id == e->channel_id) { - free(agent_channel[i][j]); - } + if (agent_channel[i][j]->channel_id == e->channel_id) { + free(agent_channel[i][j]); + } } } } @@ -164,7 +164,9 @@ err_code_t flexran_agent_init_channel_container(void) { for (i = 0; i < NUM_MAX_ENB; i++) { for (j = 0; j < FLEXRAN_AGENT_MAX; j++) { - agent_channel[i][j] = malloc(sizeof(flexran_agent_channel_t)); + agent_channel[i][j] = malloc(sizeof(flexran_agent_channel_t)); + if (!agent_channel[i][j]) + return -1; } } From fea641220b7ca7b76715dc933b95fd0a639d8d48 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 12 Dec 2017 16:54:30 +0100 Subject: [PATCH 057/141] Start FlexRAN agent directly, lock with mutex&condition - lock with mutexes - don't start ENB_APP task, but Agent directly and wait in case of reconfiguration --- openair2/ENB_APP/enb_app.c | 31 +------------- openair2/ENB_APP/enb_app.h | 3 -- .../ENB_APP/flexran_agent_common_internal.c | 15 +++++-- targets/COMMON/create_tasks.c | 19 ++++----- targets/COMMON/create_tasks.h | 1 - targets/RT/USER/lte-softmodem.c | 42 ++++++++++++------- targets/RT/USER/lte-softmodem.h | 7 ++++ 7 files changed, 55 insertions(+), 63 deletions(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index be0b88acff..5fe0f741bf 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -50,21 +50,11 @@ # endif #if defined(FLEXRAN_AGENT_SB_IF) -# include "flexran_agent.h" +# include "targets/RT/USER/lte-softmodem.h" #endif extern unsigned char NB_eNB_INST; #endif -extern volatile int node_control_state; - -void ltesm_wait_reconfig_cmd(void) -{ - LOG_I(ENB_APP, "LTE Softmodem wait reconfiguration command\n"); - - while (node_control_state == ENB_WAIT_RECONFIGURATION_CMD) { - usleep(200000); - } -} #if defined(ENABLE_ITTI) @@ -299,7 +289,6 @@ void *eNB_app_task(void *args_p) uint32_t registered_enb; long enb_register_retry_timer_id; # endif - uint32_t enb_id; MessageDef *msg_p = NULL; const char *msg_name = NULL; instance_t instance; @@ -328,24 +317,6 @@ void *eNB_app_task(void *args_p) "Number of eNB is greater than eNB defined in configuration file (%d/%d)!", enb_nb, enb_properties_p->number); -#if defined (FLEXRAN_AGENT_SB_IF) - - for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - flexran_agent_start(enb_id, enb_properties_p); - } - // wait for config comd from the controller/network app plus some time so - // that the other Tasks are in place - ltesm_wait_reconfig_cmd(); - sleep(2); - - // set again the ran api vars - for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - LOG_I(ENB_APP, "set again enb vars %d\n", enb_id); - flexran_set_enb_vars(enb_id, RAN_LTE_OAI); - } - -#endif - enb_app_start_phy_rrc(enb_id_start, enb_id_end); # if defined(ENABLE_USE_MME) diff --git a/openair2/ENB_APP/enb_app.h b/openair2/ENB_APP/enb_app.h index be5adfbb34..441693ab31 100644 --- a/openair2/ENB_APP/enb_app.h +++ b/openair2/ENB_APP/enb_app.h @@ -38,7 +38,4 @@ void *eNB_app_task(void *args_p); /* needed for flexran: start PHY and RRC when restarting */ void enb_app_start_phy_rrc(uint32_t enb_id_start, uint32_t enb_id_end); -/* wait that FlexRAN left state ENB_WAIT_RECONFIGURATION_CMD */ -void ltesm_wait_reconfig_cmd(void); - #endif /* ENB_APP_H_ */ diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index e77557e9ee..c2bd396e36 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -36,25 +36,34 @@ #include "targets/RT/USER/lte-softmodem.h" #include "assertions.h" #include "enb_app.h" -extern volatile int node_control_state; void handle_reconfiguration(mid_t mod_id) { /* NOTE: this function might be extended by using stop_modem() * to halt the modem so that it can later be resumed */ + int do_restart = 0; + pthread_mutex_lock(&mutex_node_ctrl); if (ENB_NORMAL_OPERATION != node_control_state) { node_control_state = ENB_NORMAL_OPERATION; + pthread_cond_broadcast(&cond_node_ctrl); } else { + do_restart = 1; + } + pthread_mutex_unlock(&mutex_node_ctrl); + + if (do_restart) { + clock_t start_ms = 1000 * clock(); + /* operator || enforces sequence points */ if (stop_L1L2(mod_id) < 0 || restart_L1L2(mod_id) < 0) { LOG_E(ENB_APP, "could not restart, killing lte-softmodem\n"); /* shutdown the whole lte-softmodem */ itti_terminate_tasks(TASK_PHY_ENB); return; } - enb_app_start_phy_rrc(mod_id, mod_id+1); - LOG_I(ENB_APP, "lte-softmodem restart succeeded\n"); + int diff_ms = (1000 * clock() - start_ms) / CLOCKS_PER_SEC; + LOG_I(ENB_APP, "lte-softmodem restart succeeded in %d ms\n", diff_ms); } } diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index 1ca55b5926..c28b9e839c 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -40,17 +40,6 @@ # endif # include "enb_app.h" -int create_enb_app_task(uint32_t enb_nb) -{ - if (enb_nb > 0) { - if (itti_create_task (TASK_ENB_APP, eNB_app_task, NULL) < 0) { - LOG_E(ENB_APP, "Create task for eNB APP failed\n"); - return -1; - } - } - return 0; -} - int create_tasks(uint32_t enb_nb, uint32_t ue_nb) { itti_wait_ready(1); @@ -59,6 +48,14 @@ int create_tasks(uint32_t enb_nb, uint32_t ue_nb) return -1; } + if (enb_nb > 0) { + /* Last task to create, others task must be ready before its start */ + if (itti_create_task (TASK_ENB_APP, eNB_app_task, NULL) < 0) { + LOG_E(ENB_APP, "Create task for eNB APP failed\n"); + return -1; + } + } + # ifdef OPENAIR2 { diff --git a/targets/COMMON/create_tasks.h b/targets/COMMON/create_tasks.h index 3455b283b5..6545f4b9d9 100644 --- a/targets/COMMON/create_tasks.h +++ b/targets/COMMON/create_tasks.h @@ -27,7 +27,6 @@ extern void *l2l1_task(void *arg); int create_tasks(uint32_t enb_nb, uint32_t ue_nb); -int create_enb_app_task(uint32_t enb_nb); #endif #endif /* CREATE_TASKS_H_ */ diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index f881441cdb..39f40733f2 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -174,8 +174,6 @@ eNB_func_t node_function[MAX_NUM_CCs]; eNB_timing_t node_timing[MAX_NUM_CCs]; int16_t node_synch_ref[MAX_NUM_CCs]; -volatile int16_t node_control_state; - uint32_t target_dl_mcs = 28; //maximum allowed mcs uint32_t target_ul_mcs = 20; uint32_t timing_advance = 0; @@ -234,9 +232,7 @@ threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; */ uint8_t abstraction_flag=0; -/* */ - -/* overrid the enb configuration params*/ +/* override the enb configuration parameters */ static void reconfigure_enb_params(int enb_id); @@ -1097,11 +1093,13 @@ static void get_options (int argc, char **argv) { "lte-softmodem compiled with MAX_NUM_CCs=%d, but only %d CCs configured for eNB %d!", MAX_NUM_CCs, enb_properties->properties[i]->nb_cc, i); +#ifdef FLEXRAN_AGENT_SB_IF if (enb_properties->properties[i]->flexran_agent_reconf == 1) { node_control_state = ENB_WAIT_RECONFIGURATION_CMD; } else { node_control_state = ENB_NORMAL_OPERATION; } +#endif eth_params = (eth_params_t*)malloc(enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t)); memset(eth_params, 0, enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t)); @@ -1796,19 +1794,28 @@ int main( int argc, char **argv ) { // N_ZC = (prach_fmt <4)?839:139; } - create_enb_app_task(UE_flag ? 0 : 1); - #ifdef FLEXRAN_AGENT_SB_IF - /* wait command for flexran agent: only start when configuration received */ - ltesm_wait_reconfig_cmd (); + pthread_mutex_init(&mutex_node_ctrl, NULL); + pthread_cond_init(&cond_node_ctrl, NULL); + + for (i = 0; i < NB_eNB_INST; i++) { + flexran_agent_start(i, enb_config_get()); + } + + LOG_I(ENB_APP, " * Waiting for FlexRAN RTController command *\n"); + pthread_mutex_lock(&mutex_node_ctrl); + while (ENB_NORMAL_OPERATION != node_control_state) + pthread_cond_wait(&cond_node_ctrl, &mutex_node_ctrl); + pthread_mutex_unlock(&mutex_node_ctrl); + + /* reconfigure eNB in case FlexRAN controller applied changes */ + for (i=0; i < NB_eNB_INST; i++){ + LOG_I(ENB_APP, "Reconfigure eNB module %d and FlexRAN eNB variables\n", i); + reconfigure_enb_params(i); + flexran_set_enb_vars(i, RAN_LTE_OAI); + } #endif - // reconfigure_enb: 0 for wait, 1 for skip, and other values to reconfigure - for (i=0; (i < NB_eNB_INST && node_control_state == ENB_NORMAL_OPERATION ) ; i++){ - reconfigure_enb_params(i); - printf("[ENB_APP] Reconfigured eNB module %d - continue\n", i); - } - if (UE_flag==1) { NB_UE_INST=1; NB_INST=1; @@ -2175,6 +2182,10 @@ int main( int argc, char **argv ) { stop_eNB(1); } +#ifdef FLEXRAN_AGENT_SB_IF + pthread_cond_destroy(&cond_node_ctrl); + pthread_mutex_destroy(&mutex_node_ctrl); +#endif pthread_cond_destroy(&sync_cond); pthread_mutex_destroy(&sync_mutex); @@ -2200,5 +2211,6 @@ int main( int argc, char **argv ) { logClean(); + printf("Bye.\n"); return 0; } diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index a0883c3d59..4dbdd2a40a 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -92,4 +92,11 @@ extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); extern int stop_L1L2(int enb_id); extern int restart_L1L2(int enb_id); +#ifdef FLEXRAN_AGENT_SB_IF +#include "flexran_agent.h" // for locking +volatile ENB_MODULE_STATE node_control_state; +pthread_cond_t cond_node_ctrl; +pthread_mutex_t mutex_node_ctrl; +#endif + #endif From f39dd5df1887519ee23257e5347840dc0ba32175 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 13 Dec 2017 14:43:33 +0100 Subject: [PATCH 058/141] bugfix: handle variable start_eNB in restart --- openair2/ENB_APP/flexran_agent_common_internal.c | 3 +++ targets/RT/USER/lte-softmodem.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index c2bd396e36..67f4b7371c 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -62,6 +62,9 @@ void handle_reconfiguration(mid_t mod_id) return; } enb_app_start_phy_rrc(mod_id, mod_id+1); + MessageDef *msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE); + itti_send_msg_to_task(TASK_L2L1, INSTANCE_DEFAULT, msg_p); + int diff_ms = (1000 * clock() - start_ms) / CLOCKS_PER_SEC; LOG_I(ENB_APP, "lte-softmodem restart succeeded in %d ms\n", diff_ms); } diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 39f40733f2..04113ef3ae 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -555,7 +555,8 @@ void *l2l1_task(void *arg) { case TERMINATE_MESSAGE: LOG_W(TASK_L2L1, " *** Exiting L2L1 thread\n"); - oai_exit=1; + oai_exit = 1; + start_eNB = 0; itti_exit_task (); break; From 359e1528dd2c0e20232aac7fad67b6ee14b0c71f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Dec 2017 12:44:16 +0100 Subject: [PATCH 059/141] refactor: FlexRAN reads eNB configuration automatically --- openair2/ENB_APP/flexran_agent.c | 5 +++-- openair2/ENB_APP/flexran_agent.h | 2 +- openair2/ENB_APP/flexran_agent_ran_api.c | 3 +-- targets/RT/USER/lte-softmodem.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index 8af071527f..5a399541f5 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -187,9 +187,10 @@ pthread_t new_thread(void *(*f)(void *), void *b) { } int channel_container_init = 0; -int flexran_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properties){ - +int flexran_agent_start(mid_t mod_id) +{ int channel_id; + Enb_properties_array_t *enb_properties = enb_config_get(); flexran_set_enb_vars(mod_id, RAN_LTE_OAI); flexran_agent[mod_id].enb_id = mod_id; diff --git a/openair2/ENB_APP/flexran_agent.h b/openair2/ENB_APP/flexran_agent.h index f9205c071f..c1eb997e57 100644 --- a/openair2/ENB_APP/flexran_agent.h +++ b/openair2/ENB_APP/flexran_agent.h @@ -46,7 +46,7 @@ /* Initiation and termination of the eNodeB agent */ -int flexran_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properties); +int flexran_agent_start(mid_t mod_id); int flexran_agent_stop(mid_t mod_id); /* diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 3ecbf77e11..01c5c472bd 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -44,16 +44,15 @@ void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ switch (ran){ case RAN_LTE_OAI : + enb_properties = enb_config_get(); if(eNB_mac_inst == NULL){ enb[mod_id] = NULL; enb_ue[mod_id] = NULL; enb_rrc[mod_id] = NULL; - enb_properties = NULL; }else{ enb[mod_id] = (void *)&eNB_mac_inst[mod_id]; enb_ue[mod_id] = (void *)&eNB_mac_inst[mod_id].UE_list; enb_rrc[mod_id] = (void *)&eNB_rrc_inst[mod_id]; - enb_properties = (Enb_properties_array_t *) enb_config_get(); } break; default : diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 04113ef3ae..cbcf26145b 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1800,7 +1800,7 @@ int main( int argc, char **argv ) { pthread_cond_init(&cond_node_ctrl, NULL); for (i = 0; i < NB_eNB_INST; i++) { - flexran_agent_start(i, enb_config_get()); + flexran_agent_start(i); } LOG_I(ENB_APP, " * Waiting for FlexRAN RTController command *\n"); From d35f52a22847404ffa328091d160f4f1d94e5c37 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Thu, 14 Dec 2017 15:15:00 +0100 Subject: [PATCH 060/141] Add observation window to the PDCP stats --- .../CONTROL_MODULES/PDCP/flexran_agent_pdcp.c | 24 ++--- .../ENB_APP/MESSAGES/V2/stats_common.proto | 12 +-- openair2/ENB_APP/flexran_agent_ran_api.c | 40 +++++--- openair2/ENB_APP/flexran_agent_ran_api.h | 20 ++-- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 95 +++++++++++-------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 35 ++++--- 6 files changed, 133 insertions(+), 93 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c index e4cc520070..25ec919127 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c @@ -51,18 +51,18 @@ void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id, pdcp_aggr_stats->pkt_tx += flexran_get_pdcp_tx(mod_id,ue_id,lcid); pdcp_aggr_stats->pkt_tx_bytes += flexran_get_pdcp_tx_bytes(mod_id,ue_id,lcid); - pdcp_aggr_stats->pkt_tx_rate_s += flexran_get_pdcp_tx_rate_s(mod_id,ue_id,lcid); - pdcp_aggr_stats->pkt_tx_throughput_s += flexran_get_pdcp_tx_throughput_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_tx_w += flexran_get_pdcp_tx_w(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_tx_bytes_w += flexran_get_pdcp_tx_bytes_w(mod_id,ue_id,lcid); pdcp_aggr_stats->pkt_tx_aiat += flexran_get_pdcp_tx_aiat(mod_id,ue_id,lcid); - pdcp_aggr_stats->pkt_tx_aiat_s += flexran_get_pdcp_tx_aiat_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_tx_aiat_w += flexran_get_pdcp_tx_aiat_w(mod_id,ue_id,lcid); pdcp_aggr_stats->pkt_rx += flexran_get_pdcp_rx(mod_id,ue_id,lcid); pdcp_aggr_stats->pkt_rx_bytes += flexran_get_pdcp_rx_bytes(mod_id,ue_id,lcid); - pdcp_aggr_stats->pkt_rx_rate_s += flexran_get_pdcp_rx_rate_s(mod_id,ue_id,lcid); - pdcp_aggr_stats->pkt_rx_goodput_s += flexran_get_pdcp_rx_goodput_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_w += flexran_get_pdcp_rx_w(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_bytes_w += flexran_get_pdcp_rx_bytes_w(mod_id,ue_id,lcid); pdcp_aggr_stats->pkt_rx_aiat += flexran_get_pdcp_rx_aiat(mod_id,ue_id,lcid); - pdcp_aggr_stats->pkt_rx_aiat_s += flexran_get_pdcp_rx_aiat_s(mod_id,ue_id,lcid); + pdcp_aggr_stats->pkt_rx_aiat_w += flexran_get_pdcp_rx_aiat_w(mod_id,ue_id,lcid); pdcp_aggr_stats->pkt_rx_oo += flexran_get_pdcp_rx_oo(mod_id,ue_id,lcid); } @@ -99,20 +99,20 @@ int flexran_agent_pdcp_stats_reply(mid_t mod_id, pdcp_aggr_stats->has_pkt_tx=1; pdcp_aggr_stats->has_pkt_tx_bytes =1; - pdcp_aggr_stats->has_pkt_tx_rate_s=1; - pdcp_aggr_stats->has_pkt_tx_throughput_s =1; + pdcp_aggr_stats->has_pkt_tx_w=1; + pdcp_aggr_stats->has_pkt_tx_bytes_w =1; pdcp_aggr_stats->has_pkt_tx_aiat =1; - pdcp_aggr_stats->has_pkt_tx_aiat_s =1; + pdcp_aggr_stats->has_pkt_tx_aiat_w =1; pdcp_aggr_stats->pkt_tx_sn = flexran_get_pdcp_tx_sn(mod_id, i, DEFAULT_DRB); pdcp_aggr_stats->has_pkt_tx_sn =1; pdcp_aggr_stats->has_pkt_rx =1; pdcp_aggr_stats->has_pkt_rx_bytes =1; - pdcp_aggr_stats->has_pkt_rx_rate_s =1; - pdcp_aggr_stats->has_pkt_rx_goodput_s =1; + pdcp_aggr_stats->has_pkt_rx_w =1; + pdcp_aggr_stats->has_pkt_rx_bytes_w =1; pdcp_aggr_stats->has_pkt_rx_aiat =1; - pdcp_aggr_stats->has_pkt_rx_aiat_s =1; + pdcp_aggr_stats->has_pkt_rx_aiat_w =1; pdcp_aggr_stats->has_pkt_rx_oo =1; pdcp_aggr_stats->pkt_rx_sn = flexran_get_pdcp_rx_sn(mod_id, i, DEFAULT_DRB); diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto index 94da9fbd04..f651195ab1 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto @@ -253,18 +253,18 @@ message flex_pdcp_stats { optional uint32 pkt_tx = 1; optional uint32 pkt_tx_bytes = 2; optional uint32 pkt_tx_sn = 3; - optional uint32 pkt_tx_rate_s = 4; - optional uint32 pkt_tx_throughput_s = 5; + optional uint32 pkt_tx_w = 4; + optional uint32 pkt_tx_bytes_w = 5; optional uint32 pkt_tx_aiat = 7; - optional uint32 pkt_tx_aiat_s = 8; + optional uint32 pkt_tx_aiat_w = 8; optional uint32 pkt_rx = 9; optional uint32 pkt_rx_bytes = 10; optional uint32 pkt_rx_sn = 11; - optional uint32 pkt_rx_rate_s = 12; - optional uint32 pkt_rx_goodput_s = 13; + optional uint32 pkt_rx_w = 12; + optional uint32 pkt_rx_bytes_w = 13; optional uint32 pkt_rx_aiat = 14; - optional uint32 pkt_rx_aiat_s = 15; + optional uint32 pkt_rx_aiat_w = 15; optional uint32 pkt_rx_oo = 16; optional uint64 sfn=17; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 01c5c472bd..556f018f7c 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -1134,6 +1134,22 @@ uint32_t flexran_get_pdcp_sfn(const mid_t mod_id){ return pdcp_enb[mod_id].sfn; } +/*PDCP super frame counter flexRAN*/ +uint32_t flexran_set_pdcp_tx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window){ + if (obs_window > 0 ) + Pdcp_stats_tx_window_ms[mod_id][ue_id]=obs_window; + else + Pdcp_stats_tx_window_ms[mod_id][ue_id]=1000; +} + +/*PDCP super frame counter flexRAN*/ +uint32_t flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window){ + if (obs_window > 0 ) + Pdcp_stats_rx_window_ms[mod_id][ue_id]=obs_window; + else + Pdcp_stats_rx_window_ms[mod_id][ue_id]=1000; +} + /*PDCP num tx pdu status flexRAN*/ uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ if (mod_id <0 || mod_id> MAX_NUM_CCs || ue_id<0 || ue_id> NUMBER_OF_UE_MAX || lcid<0 || lcid>NB_RB_MAX) @@ -1147,13 +1163,13 @@ uint32_t flexran_get_pdcp_tx_bytes(const mid_t mod_id, const mid_t ue_id, const } /*PDCP number of transmit packet / second status flexRAN*/ -uint32_t flexran_get_pdcp_tx_rate_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ - return Pdcp_stats_tx_rate_s[mod_id][ue_id][lcid]; +uint32_t flexran_get_pdcp_tx_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_w[mod_id][ue_id][lcid]; } /*PDCP throughput (bit/s) status flexRAN*/ -uint32_t flexran_get_pdcp_tx_throughput_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ - return Pdcp_stats_tx_throughput_s[mod_id][ue_id][lcid]; +uint32_t flexran_get_pdcp_tx_bytes_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_bytes_w[mod_id][ue_id][lcid]; } /*PDCP tx sequence number flexRAN*/ @@ -1167,8 +1183,8 @@ uint32_t flexran_get_pdcp_tx_aiat(const mid_t mod_id, const mid_t ue_id, const } /*PDCP tx aggregated packet arrival flexRAN*/ -uint32_t flexran_get_pdcp_tx_aiat_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ - return Pdcp_stats_tx_aiat_s[mod_id][ue_id][lcid]; +uint32_t flexran_get_pdcp_tx_aiat_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_tx_aiat_w[mod_id][ue_id][lcid]; } @@ -1183,13 +1199,13 @@ uint32_t flexran_get_pdcp_rx_bytes(const mid_t mod_id, const mid_t ue_id, const } /*PDCP number of received packet / second flexRAN*/ -uint32_t flexran_get_pdcp_rx_rate_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ - return Pdcp_stats_rx_rate_s[mod_id][ue_id][lcid]; +uint32_t flexran_get_pdcp_rx_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_w[mod_id][ue_id][lcid]; } /*PDCP gootput (bit/s) status flexRAN*/ -uint32_t flexran_get_pdcp_rx_goodput_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ - return Pdcp_stats_rx_goodput_s[mod_id][ue_id][lcid]; +uint32_t flexran_get_pdcp_rx_bytes_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_bytes_w[mod_id][ue_id][lcid]; } /*PDCP rx sequence number flexRAN*/ @@ -1203,8 +1219,8 @@ uint32_t flexran_get_pdcp_rx_aiat(const mid_t mod_id, const mid_t ue_id, const } /*PDCP rx aggregated packet arrival flexRAN*/ -uint32_t flexran_get_pdcp_rx_aiat_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ - return Pdcp_stats_rx_aiat_s[mod_id][ue_id][lcid]; +uint32_t flexran_get_pdcp_rx_aiat_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ + return Pdcp_stats_rx_aiat_w[mod_id][ue_id][lcid]; } /*PDCP num of received outoforder pdu status flexRAN*/ diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 84723be005..12ca5febea 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -345,6 +345,12 @@ int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); /*PDCP superframe numberflexRAN*/ uint32_t flexran_get_pdcp_sfn(const mid_t mod_id); +/*PDCP pdcp tx stats window*/ +uint32_t flexran_set_pdcp_tx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window); + +/*PDCP pdcp rx stats window*/ +uint32_t flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window); + /*PDCP num tx pdu status flexRAN*/ uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); @@ -352,10 +358,10 @@ uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_ uint32_t flexran_get_pdcp_tx_bytes(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP number of transmit packet / second status flexRAN*/ -uint32_t flexran_get_pdcp_tx_rate_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); +uint32_t flexran_get_pdcp_tx_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); -/*PDCP throughput (bit/s) status flexRAN*/ -uint32_t flexran_get_pdcp_tx_throughput_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); +/*PDCP pdcp tx bytes in a given window flexRAN*/ +uint32_t flexran_get_pdcp_tx_bytes_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP tx sequence number flexRAN*/ uint32_t flexran_get_pdcp_tx_sn(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); @@ -364,7 +370,7 @@ uint32_t flexran_get_pdcp_tx_sn(const mid_t mod_id, const mid_t ue_id, const lc uint32_t flexran_get_pdcp_tx_aiat(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP tx aggregated packet arrival per second flexRAN*/ -uint32_t flexran_get_pdcp_tx_aiat_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); +uint32_t flexran_get_pdcp_tx_aiat_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP num rx pdu status flexRAN*/ @@ -374,10 +380,10 @@ uint32_t flexran_get_pdcp_rx(const mid_t mod_id, const mid_t ue_id, const lcid_ uint32_t flexran_get_pdcp_rx_bytes(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP number of received packet / second flexRAN*/ -uint32_t flexran_get_pdcp_rx_rate_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); +uint32_t flexran_get_pdcp_rx_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP gootput (bit/s) status flexRAN*/ -uint32_t flexran_get_pdcp_rx_goodput_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); +uint32_t flexran_get_pdcp_rx_bytes_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP rx sequence number flexRAN*/ uint32_t flexran_get_pdcp_rx_sn(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); @@ -386,7 +392,7 @@ uint32_t flexran_get_pdcp_rx_sn(const mid_t mod_id, const mid_t ue_id, const lc uint32_t flexran_get_pdcp_rx_aiat(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP rx aggregated packet arrival per second flexRAN*/ -uint32_t flexran_get_pdcp_rx_aiat_s(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); +uint32_t flexran_get_pdcp_rx_aiat_w(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); /*PDCP num of received outoforder pdu status flexRAN*/ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index df85b06d06..d74e8552d6 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -408,13 +408,13 @@ boolean_t pdcp_data_req( //LOG_I(PDCP,"ueid %d lcid %d tx seq num %d\n", pdcp_uid, rb_idP+rb_offset, current_sn); Pdcp_stats_tx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; - Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; + Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; Pdcp_stats_tx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=current_sn; Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); @@ -880,9 +880,9 @@ pdcp_data_ind( } Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); - Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); + Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; @@ -890,7 +890,7 @@ pdcp_data_ind( Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; @@ -920,36 +920,45 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ uint8_t rb_id = 0; // these stats are measured for both eNB and UE on per seond basis - if (pdcp_enb[ctxt_pP->module_id].sfn % 1000 == 0){ - for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ - //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe); - // tx stats - Pdcp_stats_tx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; + for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ + for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe); + // tx stats + if (pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ // unit: bit/s - Pdcp_stats_tx_throughput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8; - if (Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){ - Pdcp_stats_tx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]=(Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]); - } - - Pdcp_stats_tx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; - Pdcp_stats_tx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; - Pdcp_stats_tx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_tx_throughput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; + Pdcp_stats_tx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; + Pdcp_stats_tx_bytes_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; + if (Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){ + Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=(Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]); + }else { + Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + } + // reset the tmp vars + Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + } + if (pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ // rx stats - Pdcp_stats_rx_rate_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]; - Pdcp_stats_rx_goodput_s[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]*8; - - if(Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){ - Pdcp_stats_rx_aiat_s[ctxt_pP->module_id][pdcp_uid][rb_id]= (Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]); - } + Pdcp_stats_rx_goodput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; + Pdcp_stats_rx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; + Pdcp_stats_rx_bytes_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; - Pdcp_stats_rx_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; - Pdcp_stats_rx_bytes_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; - Pdcp_stats_rx_aiat_tmp_s[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + if(Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){ + Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]= (Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]); + } else { + Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + } + // reset the tmp vars + Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; + Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; } } + } } //----------------------------------------------------------------------------- @@ -2024,6 +2033,7 @@ void pdcp_layer_init(void) { module_id_t instance; + int i,j; #if defined(Rel10) || defined(Rel14) mbms_session_id_t session_id; mbms_service_id_t service_id; @@ -2070,24 +2080,35 @@ void pdcp_layer_init(void) memset(pdcp_enb, 0, sizeof(pdcp_enb_t)); + memset(Pdcp_stats_tx_window_ms, 0, sizeof(Pdcp_stats_tx_window_ms)); + memset(Pdcp_stats_rx_window_ms, 0, sizeof(Pdcp_stats_rx_window_ms)); + for (i =0; i< MAX_NUM_CCs ; i ++){ + for (j=0; j< NUMBER_OF_UE_MAX;j++){ + Pdcp_stats_tx_window_ms[i][j]=100; + Pdcp_stats_rx_window_ms[i][j]=100; + } + } + memset(Pdcp_stats_tx, 0, sizeof(Pdcp_stats_tx)); - memset(Pdcp_stats_tx_s, 0, sizeof(Pdcp_stats_tx_s)); + memset(Pdcp_stats_tx_w, 0, sizeof(Pdcp_stats_tx_w)); + memset(Pdcp_stats_tx_tmp_w, 0, sizeof(Pdcp_stats_tx_tmp_w)); memset(Pdcp_stats_tx_bytes, 0, sizeof(Pdcp_stats_tx_bytes)); - memset(Pdcp_stats_tx_bytes_s, 0, sizeof(Pdcp_stats_tx_bytes_s)); - memset(Pdcp_stats_tx_rate_s, 0, sizeof(Pdcp_stats_tx_rate_s)); + memset(Pdcp_stats_tx_bytes_w, 0, sizeof(Pdcp_stats_tx_bytes_w)); + memset(Pdcp_stats_tx_bytes_tmp_w, 0, sizeof(Pdcp_stats_tx_bytes_tmp_w)); memset(Pdcp_stats_tx_sn, 0, sizeof(Pdcp_stats_tx_sn)); - memset(Pdcp_stats_tx_throughput_s, 0, sizeof(Pdcp_stats_tx_throughput_s)); + memset(Pdcp_stats_tx_throughput_w, 0, sizeof(Pdcp_stats_tx_throughput_w)); memset(Pdcp_stats_tx_aiat, 0, sizeof(Pdcp_stats_tx_aiat)); memset(Pdcp_stats_tx_iat, 0, sizeof(Pdcp_stats_tx_iat)); memset(Pdcp_stats_rx, 0, sizeof(Pdcp_stats_rx)); - memset(Pdcp_stats_rx_s, 0, sizeof(Pdcp_stats_rx_s)); + memset(Pdcp_stats_rx_w, 0, sizeof(Pdcp_stats_rx_w)); + memset(Pdcp_stats_rx_tmp_w, 0, sizeof(Pdcp_stats_rx_tmp_w)); memset(Pdcp_stats_rx_bytes, 0, sizeof(Pdcp_stats_rx_bytes)); - memset(Pdcp_stats_rx_bytes_s, 0, sizeof(Pdcp_stats_rx_bytes_s)); - memset(Pdcp_stats_rx_rate_s, 0, sizeof(Pdcp_stats_rx_rate_s)); + memset(Pdcp_stats_rx_bytes_w, 0, sizeof(Pdcp_stats_rx_bytes_w)); + memset(Pdcp_stats_rx_bytes_tmp_w, 0, sizeof(Pdcp_stats_rx_bytes_tmp_w)); memset(Pdcp_stats_rx_sn, 0, sizeof(Pdcp_stats_rx_sn)); - memset(Pdcp_stats_rx_goodput_s, 0, sizeof(Pdcp_stats_rx_goodput_s)); + memset(Pdcp_stats_rx_goodput_w, 0, sizeof(Pdcp_stats_rx_goodput_w)); memset(Pdcp_stats_rx_aiat, 0, sizeof(Pdcp_stats_rx_aiat)); memset(Pdcp_stats_rx_iat, 0, sizeof(Pdcp_stats_rx_iat)); memset(Pdcp_stats_rx_outoforder, 0, sizeof(Pdcp_stats_rx_outoforder)); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index cf3d927051..cdd69a8659 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -94,35 +94,32 @@ extern int pdcp_instance_cnt; int init_pdcp_thread(void); void cleanup_pdcp_thread(void); -/* -public_pdcp(uint64_t Pdcp_sfn[MAX_NUM_CCs]); -public_pdcp(frame_t Pdcp_frame[MAX_NUM_CCs]); -public_pdcp(sub_frame_t Pdcp_subframe[MAX_NUM_CCs]); -public_pdcp(uint16_t Pdcp_num_ues[MAX_NUM_CCs]); -*/ - +public_pdcp(uint32_t Pdcp_stats_tx_window_ms[MAX_NUM_CCs][NUMBER_OF_UE_MAX]); public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_bytes_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_tx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_tx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_rate_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_throughput_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_throughput_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_tx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_aiat_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_tx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_window_ms[MAX_NUM_CCs][NUMBER_OF_UE_MAX]); public_pdcp(uint32_t Pdcp_stats_rx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_rx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_bytes_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_rx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_rate_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_goodput_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_goodput_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_rx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_aiat_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_s[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); From ccac021050d2754aa4f5591a42c04f95b6223096 Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Thu, 14 Dec 2017 18:34:41 +0100 Subject: [PATCH 061/141] Ue stats bugfix for dynamic reconfiguration --- openair2/ENB_APP/enb_app.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 5fe0f741bf..98f9ee3682 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -283,6 +283,7 @@ void *eNB_app_task(void *args_p) #if defined(ENABLE_ITTI) uint32_t enb_nb = 1; /* Default number of eNB is 1 */ uint32_t enb_id_start = 0; + uint32_t enb_i; uint32_t enb_id_end = enb_id_start + enb_nb; # if defined(ENABLE_USE_MME) uint32_t register_enb_pending; @@ -318,7 +319,13 @@ void *eNB_app_task(void *args_p) enb_nb, enb_properties_p->number); enb_app_start_phy_rrc(enb_id_start, enb_id_end); - + +#ifdef FLEXRAN_AGENT_SB_IF + for (enb_i = 0; enb_i <1; enb_i ++){ // To be handled for all of current eNB + flexran_set_enb_vars(enb_i, RAN_LTE_OAI); + +} +#endif # if defined(ENABLE_USE_MME) /* Try to register each eNB */ registered_enb = 0; From b049f0c820ad7f09e763ff3e1dc602e3f7cdc663 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Thu, 14 Dec 2017 18:34:41 +0100 Subject: [PATCH 062/141] Ue stats bugfix for dynamic reconfiguration --- openair2/ENB_APP/enb_app.c | 8 +- openair2/ENB_APP/flexran_agent.c | 24 ++- openair2/ENB_APP/flexran_agent.h | 1 + .../MAC/flexran_agent_scheduler_dlsch_ue.c | 153 ++++++++------- .../MAC/flexran_agent_scheduler_ulsch_ue.c | 179 ++++++++++-------- 5 files changed, 209 insertions(+), 156 deletions(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 5fe0f741bf..d51b0efcd7 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -283,6 +283,7 @@ void *eNB_app_task(void *args_p) #if defined(ENABLE_ITTI) uint32_t enb_nb = 1; /* Default number of eNB is 1 */ uint32_t enb_id_start = 0; + uint32_t enb_i; uint32_t enb_id_end = enb_id_start + enb_nb; # if defined(ENABLE_USE_MME) uint32_t register_enb_pending; @@ -318,7 +319,12 @@ void *eNB_app_task(void *args_p) enb_nb, enb_properties_p->number); enb_app_start_phy_rrc(enb_id_start, enb_id_end); - + +#ifdef FLEXRAN_AGENT_SB_IF + for (enb_i = 0; enb_i <1; enb_i ++){ // To be handled for all of current eNB + flexran_set_enb_vars(enb_i, RAN_LTE_OAI); + } +#endif # if defined(ENABLE_USE_MME) /* Try to register each eNB */ registered_enb = 0; diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index 5a399541f5..7cb910ae1a 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -186,15 +186,9 @@ pthread_t new_thread(void *(*f)(void *), void *b) { return t; } -int channel_container_init = 0; -int flexran_agent_start(mid_t mod_id) -{ - int channel_id; +void flexran_agent_reconfigure(mid_t mod_id){ Enb_properties_array_t *enb_properties = enb_config_get(); - - flexran_set_enb_vars(mod_id, RAN_LTE_OAI); - flexran_agent[mod_id].enb_id = mod_id; - + /* * check the configuration */ @@ -204,7 +198,7 @@ int flexran_agent_start(mid_t mod_id) } else { strcpy(local_cache, DEFAULT_FLEXRAN_AGENT_CACHE); } - + if (enb_properties->properties[mod_id]->flexran_agent_ipv4_address != 0) { inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN); } else { @@ -220,6 +214,18 @@ int flexran_agent_start(mid_t mod_id) flexran_agent[mod_id].enb_id, in_ip, in_port); + +} + +int channel_container_init = 0; +int flexran_agent_start(mid_t mod_id) +{ + int channel_id; + + flexran_set_enb_vars(mod_id, RAN_LTE_OAI); + flexran_agent[mod_id].enb_id = mod_id; + + flexran_agent_reconfigure(mod_id); /* * Initialize the channel container diff --git a/openair2/ENB_APP/flexran_agent.h b/openair2/ENB_APP/flexran_agent.h index c1eb997e57..b092e26d53 100644 --- a/openair2/ENB_APP/flexran_agent.h +++ b/openair2/ENB_APP/flexran_agent.h @@ -48,6 +48,7 @@ /* Initiation and termination of the eNodeB agent */ int flexran_agent_start(mid_t mod_id); int flexran_agent_stop(mid_t mod_id); +void flexran_agent_reconfigure(mid_t mod_id); /* * enb agent task mainly wakes up the tx thread for periodic and oneshot messages to the controller diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 601310d67a..a04987f07c 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -96,9 +96,11 @@ int slicing_strategy = UEID_TO_SLICEID; int slicing_strategy_current = UEID_TO_SLICEID; // RB share for each slice for past and current time -float slice_percentage[MAX_NUM_SLICES] = {1.0, 1.0, 0.0, 0.0}; -float slice_percentage_current[MAX_NUM_SLICES] = {1.0, 1.0, 0.0, 0.0}; +float avg_slice_percentage=0.25; +float slice_percentage[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage_current[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; float total_slice_percentage = 0; +float total_slice_percentage_current = 0; // MAX MCS for each slice for past and current time int slice_maxmcs[MAX_NUM_SLICES] = {28, 28, 28, 28}; @@ -724,7 +726,23 @@ flexran_schedule_ue_dl_spec_default(mid_t mod_id, int i=0; flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); - + + total_slice_percentage=0; + avg_slice_percentage=1.0/n_active_slices; + + // reset the slice percentage for inactive slices + for (i = n_active_slices; i< MAX_NUM_SLICES; i++) { + slice_percentage[i]=0; + } + for (i = 0; i < n_active_slices; i++) { + if (slice_percentage[i] < 0 ){ + LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %d. resetting to zero", + mod_id, frame, subframe, i, slice_percentage[i]); + slice_percentage[i]=0; + } + total_slice_percentage+=slice_percentage[i]; + } + for (i = 0; i < n_active_slices; i++) { // Load any updated functions @@ -732,84 +750,77 @@ flexran_schedule_ue_dl_spec_default(mid_t mod_id, slice_sched_dl[i] = dlsym(NULL, dl_scheduler_type[i]); update_dl_scheduler[i] = 0; update_dl_scheduler_current[i] = 0; - slice_percentage_current[i]= slice_percentage[i]; - total_slice_percentage+=slice_percentage[i]; LOG_N(MAC,"update dl scheduler slice %d\n", i); } - - // check if the number of slices has changed, and log - if (n_active_slices_current != n_active_slices ){ - if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { - LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active slices has changed: %d-->%d\n", - mod_id, frame, subframe, n_active_slices_current, n_active_slices); - n_active_slices_current = n_active_slices; + if (total_slice_percentage <= 1.0){ // the new total RB share is within the range - } else { - LOG_W(MAC,"invalid number of slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); - n_active_slices = n_active_slices_current; + // check if the number of slices has changed, and log + if (n_active_slices_current != n_active_slices ){ + if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { + LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active DL slices has changed: %d-->%d\n", + mod_id, frame, subframe, n_active_slices_current, n_active_slices); + + n_active_slices_current = n_active_slices; + + } else { + LOG_W(MAC,"invalid number of DL slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); + n_active_slices = n_active_slices_current; + } } - } - - // check if the slice rb share has changed, and log the console - if (slice_percentage_current[i] != slice_percentage[i]){ - // if ((slice_percentage[i] >= 0.0) && (slice_percentage[i] <= 1.0)){ - // if ((total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]) <= 1.0) { - // total_slice_percentage=total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]; - LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", - mod_id, i, frame, subframe, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); - - slice_percentage_current[i] = slice_percentage[i]; - - // } else { - // LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", - // mod_id,i, - // total_slice_percentage, - // total_slice_percentage - slice_percentage_current[i] + slice_percentage[i], - // slice_percentage[i],slice_percentage_current[i]); - - // slice_percentage[i]= slice_percentage_current[i]; - - // } - // } else { - // LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage[i],slice_percentage_current[i]); - - // slice_percentage[i]= slice_percentage_current[i]; - - // } - } - - // check if the slice max MCS, and log the console - if (slice_maxmcs_current[i] != slice_maxmcs[i]){ - if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)){ - LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", - mod_id, i, frame, subframe, slice_maxmcs_current[i], slice_maxmcs[i]); - - slice_maxmcs_current[i] = slice_maxmcs[i]; - - } else { - // LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs[i],slice_percentage[i]); - - slice_maxmcs[i]= slice_maxmcs_current[i]; - - } - } - - // check if a new scheduler, and log the console - if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ - LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", - mod_id, i, frame, subframe, dl_scheduler_type[i]); - - update_dl_scheduler_current[i] = update_dl_scheduler[i]; + // check if the slice rb share has changed, and log the console + if (slice_percentage_current[i] != slice_percentage[i]){ // new slice percentage + LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: total percentage %f-->%f, slice RB percentage has changed: %f-->%f\n", + mod_id, i, frame, subframe, total_slice_percentage_current, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); + total_slice_percentage_current= total_slice_percentage; + slice_percentage_current[i] = slice_percentage[i]; + + } + + // check if the slice max MCS, and log the console + if (slice_maxmcs_current[i] != slice_maxmcs[i]){ + if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)){ + LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", + mod_id, i, frame, subframe, slice_maxmcs_current[i], slice_maxmcs[i]); + slice_maxmcs_current[i] = slice_maxmcs[i]; + } else { + LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs[i],slice_maxmcs_current[i]); + slice_maxmcs[i]= slice_maxmcs_current[i]; + } + } + + // check if a new scheduler, and log the console + if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ + LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", + mod_id, i, frame, subframe, dl_scheduler_type[i]); + update_dl_scheduler_current[i] = update_dl_scheduler[i]; + } + + } else { + // here we can correct the values, e.g. reduce proportionally + + if (n_active_slices == n_active_slices_current){ + LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid total RB share (%f->%f), reduce proportionally the RB share by 0.1\n", + mod_id,i, + total_slice_percentage_current, total_slice_percentage); + if (slice_percentage[i] >= avg_slice_percentage){ + slice_percentage[i]-=0.1; + total_slice_percentage-=0.1; + } + } else { + LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid total RB share (%f->%f), revert the number of slice to its previous value (%d->%d)\n", + mod_id,i, + total_slice_percentage_current, total_slice_percentage, + n_active_slices, n_active_slices_current ); + n_active_slices = n_active_slices_current; + slice_percentage[i] = slice_percentage_current[i]; + } } - + // Run each enabled slice-specific schedulers one by one - //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); slice_sched_dl[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); - } - } uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs){ diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 5b31c11681..64f21482fb 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -21,7 +21,7 @@ /*! \file eNB_scheduler_ulsch.c * \brief FlexRAN eNB procedures for the ULSCH transport channel - * \author shahab SHARIAT BAGHERI + * \author Navid Nikaein and shahab SHARIAT BAGHERI * \date 2017 * \version 1.0 * @ingroup _mac @@ -67,19 +67,21 @@ /* number of active slices for past and current time*/ int n_active_slices_uplink = 1; -int n_active_slices_uplink_current = 1; +int n_active_slices_current_uplink = 1; /* RB share for each slice for past and current time*/ -float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 1.0, 0.0, 0.0}; -float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 1.0, 0.0, 0.0}; +float avg_slice_percentage_uplink=0.25; +float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; float total_slice_percentage_uplink = 0; +float total_slice_percentage_current_uplink = 0; // MAX MCS for each slice for past and current time int slice_maxmcs_uplink[MAX_NUM_SLICES] = {16, 16, 16, 16}; -int slice_maxmcs_current_uplink[MAX_NUM_SLICES] = {28, 28, 28, 28}; +int slice_maxmcs_current_uplink[MAX_NUM_SLICES] = {16,16,16,16}; /*resource blocks allowed*/ -uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; +uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; /*Slice Update */ int update_ul_scheduler[MAX_NUM_SLICES] = {1, 1, 1, 1}; int update_ul_scheduler_current[MAX_NUM_SLICES] = {1, 1, 1, 1}; @@ -89,9 +91,9 @@ slice_scheduler_ul slice_sched_ul[MAX_NUM_SLICES] = {0}; /* name of available scheduler*/ char *ul_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_ul_spec_embb", - "flexran_schedule_ue_ul_spec_urllc", - "flexran_schedule_ue_ul_spec_mmtc", - "flexran_schedule_ue_ul_spec_be" // best effort + "flexran_schedule_ue_ul_spec_embb", + "flexran_schedule_ue_ul_spec_embb", + "flexran_schedule_ue_ul_spec_embb" // best effort }; @@ -418,6 +420,22 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, flexran_agent_mac_create_empty_ul_config(mod_id, ul_info); + total_slice_percentage_uplink=0; + avg_slice_percentage_uplink=1.0/n_active_slices_uplink; + + // reset the slice percentage for inactive slices + for (i = n_active_slices_uplink; i< MAX_NUM_SLICES; i++) { + slice_percentage_uplink[i]=0; + } + for (i = 0; i < n_active_slices_uplink; i++) { + if (slice_percentage_uplink[i] < 0 ){ + LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %d. resetting to zero", + mod_id, frame, subframe, i, slice_percentage_uplink[i]); + slice_percentage_uplink[i]=0; + } + total_slice_percentage_uplink+=slice_percentage_uplink[i]; + } + for (i = 0; i < n_active_slices_uplink; i++) { // Load any updated functions @@ -425,89 +443,100 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, slice_sched_ul[i] = dlsym(NULL, ul_scheduler_type[i]); update_ul_scheduler[i] = 0; update_ul_scheduler_current[i] = 0; - slice_percentage_current_uplink[i]= slice_percentage_uplink[i]; - total_slice_percentage_uplink+=slice_percentage_uplink[i]; + //slice_percentage_current_uplink[i]= slice_percentage_uplink[i]; + //total_slice_percentage_current_uplink+=slice_percentage_uplink[i]; + //if (total_slice_percentage_current_uplink> 1) + // total_slice_percentage_current_uplink=1; LOG_N(MAC,"update ul scheduler slice %d\n", i); } - - // check if the number of slices has changed, and log - if (n_active_slices_uplink_current != n_active_slices_uplink ){ - if ((n_active_slices_uplink > 0) && (n_active_slices_uplink <= MAX_NUM_SLICES)) { - LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active slices has changed: %d-->%d\n", - mod_id, frame, subframe, n_active_slices_uplink_current, n_active_slices_uplink); + // the new total RB share is within the range + if (total_slice_percentage_uplink <= 1.0){ - n_active_slices_uplink_current = n_active_slices_uplink; - - } else { - LOG_W(MAC,"invalid number of slices %d, revert to the previous value %d\n",n_active_slices_uplink, n_active_slices_uplink_current); - n_active_slices_uplink = n_active_slices_uplink_current; + // check if the number of slices has changed, and log + if (n_active_slices_current_uplink != n_active_slices_uplink ){ + if ((n_active_slices_uplink > 0) && (n_active_slices_uplink <= MAX_NUM_SLICES)) { + LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active UL slices has changed: %d-->%d\n", + mod_id, frame, subframe, n_active_slices_current_uplink, n_active_slices_uplink); + + n_active_slices_current_uplink = n_active_slices_uplink; + + } else { + LOG_W(MAC,"invalid number of UL slices %d, revert to the previous value %d\n",n_active_slices_uplink, n_active_slices_current_uplink); + n_active_slices_uplink = n_active_slices_current_uplink; + } } - } // check if the slice rb share has changed, and log the console - if (slice_percentage_current_uplink[i] != slice_percentage_uplink[i]){ - // if ((slice_percentage_uplink[i] >= 0.0) && (slice_percentage_uplink[i] <= 1.0)){ - // if ((total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i]) <= 1.0) { - // total_slice_percentage_uplink=total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i]; - LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", - mod_id, i, frame, subframe, total_slice_percentage_uplink, slice_percentage_current_uplink[i], slice_percentage_uplink[i]); - - slice_percentage_current_uplink[i] = slice_percentage_uplink[i]; - - // } else { - // LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", - // mod_id,i, - // total_slice_percentage_uplink, - // total_slice_percentage_uplink - slice_percentage_current_uplink[i] + slice_percentage_uplink[i], - // slice_percentage_uplink[i],slice_percentage_current_uplink[i]); - - // slice_percentage_uplink[i]= slice_percentage_current_uplink[i]; - - // } - // } else { - // LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage_uplink[i],slice_percentage_current_uplink[i]); - - // slice_percentage_uplink[i]= slice_percentage_current_uplink[i]; - - // } - } - - // check if a new scheduler, and log the console - if (update_ul_scheduler_current[i] != update_ul_scheduler[i]){ - LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", - mod_id, i, frame, subframe, ul_scheduler_type[i]); - - update_ul_scheduler_current[i] = update_ul_scheduler[i]; + if (slice_percentage_current_uplink[i] != slice_percentage_uplink[i]){ + LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: total percentage %f-->%f, slice RB percentage has changed: %f-->%f\n", + mod_id, i, frame, subframe, total_slice_percentage_current_uplink, total_slice_percentage_uplink, slice_percentage_current_uplink[i], slice_percentage_uplink[i]); + total_slice_percentage_current_uplink= total_slice_percentage_uplink; + slice_percentage_current_uplink[i] = slice_percentage_uplink[i]; + + } + // check if the slice max MCS, and log the console + if (slice_maxmcs_current_uplink[i] != slice_maxmcs_uplink[i]){ + if ((slice_maxmcs_uplink[i] >= 0) && (slice_maxmcs_uplink[i] <= 16)){ + LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", + mod_id, i, frame, subframe, slice_maxmcs_current_uplink[i], slice_maxmcs_uplink[i]); + slice_maxmcs_current_uplink[i] = slice_maxmcs_uplink[i]; + } else { + LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs_uplink[i],slice_maxmcs_current_uplink[i]); + slice_maxmcs_uplink[i]= slice_maxmcs_current_uplink[i]; + + } + } + + // check if a new scheduler, and log the console + if (update_ul_scheduler_current[i] != update_ul_scheduler[i]){ + LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: UL scheduler for this slice is updated: %s \n", + mod_id, i, frame, subframe, ul_scheduler_type[i]); + + update_ul_scheduler_current[i] = update_ul_scheduler[i]; + } } - + else { + + if (n_active_slices_uplink == n_active_slices_current_uplink){ + LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid total RB share (%f->%f), reduce proportionally the RB share by 0.1\n", + mod_id,i, + total_slice_percentage_current_uplink, total_slice_percentage_uplink); + if (slice_percentage_uplink[i] > avg_slice_percentage_uplink){ + slice_percentage_uplink[i]-=0.1; + total_slice_percentage_uplink-=0.1; + } + } else { + // here we can correct the values, e.g. reduce proportionally + LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid total RB share (%f->%f), revert the number of slice to its previous value (%d->%d)\n", + mod_id,i, + total_slice_percentage_current_uplink, total_slice_percentage_uplink, + n_active_slices_uplink, n_active_slices_current_uplink); + n_active_slices_uplink = n_active_slices_current_uplink; + slice_percentage_uplink[i] = slice_percentage_current_uplink[i]; + } + } + // Run each enabled slice-specific schedulers one by one - //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); - - slice_sched_ul[i](mod_id, frame, cooperation_flag, subframe, sched_subframe,ul_info); - } - - - } void flexran_schedule_ue_ul_spec_embb(mid_t mod_id, - frame_t frame, - unsigned char cooperation_flag, - uint32_t subframe, - unsigned char sched_subframe, - Protocol__FlexranMessage **ul_info) - + frame_t frame, + unsigned char cooperation_flag, + uint32_t subframe, + unsigned char sched_subframe, + Protocol__FlexranMessage **ul_info) + { flexran_agent_schedule_ulsch_ue_spec(mod_id, - frame, - cooperation_flag, - subframe, - sched_subframe, - ul_info); + frame, + cooperation_flag, + subframe, + sched_subframe, + ul_info); } From b1acde2007a04995373e4bea44e6d8565cf49a9e Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Thu, 21 Dec 2017 13:55:37 +0100 Subject: [PATCH 063/141] Neighbouring cell RRC measurement + decrease warning --- .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 110 ++++++++++--- openair2/ENB_APP/flexran_agent_handler.c | 2 +- openair2/ENB_APP/flexran_agent_ran_api.c | 149 ++++++++++++++++-- openair2/ENB_APP/flexran_agent_ran_api.h | 22 ++- openair2/RRC/LITE/rrc_eNB.c | 4 +- 5 files changed, 248 insertions(+), 39 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index 7a251be78b..6f42d1da97 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -492,7 +492,7 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id, // Protocol__FlexHeader *header; - int i; + int i,j; /* Allocate memory for list of UE reports */ if (report_config->nr_ue > 0) { @@ -501,29 +501,86 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id, /* Check flag for creation of buffer status report */ if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_RRC_MEASUREMENTS) { - - Protocol__FlexRrcMeasurements *rrc_measurements; - rrc_measurements = malloc(sizeof(Protocol__FlexRrcMeasurements)); - if (rrc_measurements == NULL) - goto error; - protocol__flex_rrc_measurements__init(rrc_measurements); - - rrc_measurements->measid = flexran_get_rrc_pcell_measid(mod_id,i); - rrc_measurements->has_measid = 1; - - rrc_measurements->pcell_rsrp = flexran_get_rrc_pcell_rsrp(mod_id,i) - 140; - rrc_measurements->has_pcell_rsrp = 1; - - rrc_measurements->pcell_rsrq = flexran_get_rrc_pcell_rsrq(mod_id,i)/2 - 20; - rrc_measurements->has_pcell_rsrq = 1 ; - - ue_report[i]->rrc_measurements = rrc_measurements; - + + /*Source Cell*/ + Protocol__FlexRrcMeasurements *rrc_measurements; + rrc_measurements = malloc(sizeof(Protocol__FlexRrcMeasurements)); + if (rrc_measurements == NULL) + goto error; + protocol__flex_rrc_measurements__init(rrc_measurements); + + rrc_measurements->measid = flexran_get_rrc_pcell_measid(mod_id,i); + rrc_measurements->has_measid = 1; + + rrc_measurements->pcell_rsrp = flexran_get_rrc_pcell_rsrp(mod_id,i); + rrc_measurements->has_pcell_rsrp = 1; + + rrc_measurements->pcell_rsrq = flexran_get_rrc_pcell_rsrq(mod_id,i); + rrc_measurements->has_pcell_rsrq = 1 ; + + + /* Target Cell, Neghibouring*/ + Protocol__FlexNeighCellsMeasurements *neigh_meas; + neigh_meas = malloc(sizeof(Protocol__FlexNeighCellsMeasurements)); + if (neigh_meas == NULL) + goto error; + protocol__flex_neigh_cells_measurements__init(neigh_meas); + + + neigh_meas->n_eutra_meas = flexran_get_rrc_num_ncell(mod_id, i); + + Protocol__FlexEutraMeasurements **eutra_meas = NULL; + + if (neigh_meas->n_eutra_meas > 0){ + + eutra_meas = malloc(sizeof(Protocol__FlexEutraMeasurements) * neigh_meas->n_eutra_meas); + if (eutra_meas == NULL) + goto error; + + for (j = 0; j < neigh_meas->n_eutra_meas; j++ ){ + + eutra_meas[j] = malloc(sizeof(Protocol__FlexEutraMeasurements)); + if (eutra_meas[j] == NULL) + goto error; + + protocol__flex_eutra_measurements__init(eutra_meas[j]); + + eutra_meas[j]->phys_cell_id = flexran_get_rrc_neigh_phy_cell_id(mod_id, i, j); + eutra_meas[j]->has_phys_cell_id = 1; + + + /*TODO: Extend for CGI and PLMNID*/ + + Protocol__FlexEutraRefSignalMeas *meas_result; + meas_result = malloc(sizeof(Protocol__FlexEutraRefSignalMeas)); + + protocol__flex_eutra_ref_signal_meas__init(meas_result); + + meas_result->rsrp = flexran_get_rrc_neigh_rsrp(mod_id, i, eutra_meas[j]->phys_cell_id); + meas_result->has_rsrp = 1; + + meas_result->rsrq = flexran_get_rrc_neigh_rsrq(mod_id, i, eutra_meas[j]->phys_cell_id); + meas_result->has_rsrq = 1; + + eutra_meas[j]->meas_result = meas_result; + + } + + neigh_meas->eutra_meas = eutra_meas; + + rrc_measurements->neigh_meas = neigh_meas; + + } + + ue_report[i]->rrc_measurements = rrc_measurements; + } - } + + } + } - /* To be extended for RRC layer */ + /* To be considered for RRC signaling of cell*/ // if (report_config->nr_cc > 0) { @@ -564,6 +621,17 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id, error: + for (i = 0; i < report_config->nr_ue; i++){ + + if (ue_report[i]->rrc_measurements->neigh_meas != NULL){ + for (j = 0; j < flexran_get_rrc_num_ncell(mod_id, i); j++){ + + free(ue_report[i]->rrc_measurements->neigh_meas->eutra_meas[j]); + } + free(ue_report[i]->rrc_measurements->neigh_meas); + } + } + if (cell_report != NULL) free(cell_report); if (ue_report != NULL) diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index 2a36b3e5c8..02df1d41dc 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -756,7 +756,7 @@ err_code_t flexran_agent_init_cont_stats_update(mid_t mod_id) { if (stats_context[mod_id].mutex == NULL) goto error; if (pthread_mutex_init(stats_context[mod_id].mutex, NULL)) - goto error;; + goto error; return 0; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 556f018f7c..16462b4d40 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -1135,19 +1135,23 @@ uint32_t flexran_get_pdcp_sfn(const mid_t mod_id){ } /*PDCP super frame counter flexRAN*/ -uint32_t flexran_set_pdcp_tx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window){ - if (obs_window > 0 ) +void flexran_set_pdcp_tx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window){ + if (obs_window > 0 ){ Pdcp_stats_tx_window_ms[mod_id][ue_id]=obs_window; - else + } + else{ Pdcp_stats_tx_window_ms[mod_id][ue_id]=1000; + } } /*PDCP super frame counter flexRAN*/ -uint32_t flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window){ - if (obs_window > 0 ) +void flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window){ + if (obs_window > 0 ){ Pdcp_stats_rx_window_ms[mod_id][ue_id]=obs_window; - else + } + else{ Pdcp_stats_rx_window_ms[mod_id][ue_id]=1000; + } } /*PDCP num tx pdu status flexRAN*/ @@ -1256,7 +1260,7 @@ int flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id) { ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { if(ue_context_p->ue_context.measResults != NULL) { - return ue_context_p->ue_context.measResults->measResultPCell.rsrpResult; + return RSRP_meas_mapping[ue_context_p->ue_context.measResults->measResultPCell.rsrpResult]; } else { return -1; } @@ -1273,7 +1277,7 @@ int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) { ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { if(ue_context_p->ue_context.measResults != NULL) { - return ue_context_p->ue_context.measResults->measResultPCell.rsrqResult; + return RSRQ_meas_mapping[ue_context_p->ue_context.measResults->measResultPCell.rsrqResult]; } else { return -1; } @@ -1281,8 +1285,48 @@ int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) { return -1; } } -/* -void* flexran_get_rrc_ncell_measresult_eutra(mid_t mod_id, mid_t ue_id) { + +/*Number of neighbouring cells for specific UE*/ +int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return 0; + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + + if (ue_context_p->ue_context.measResults != NULL){ + + if(ue_context_p->ue_context.measResults->measResultNeighCells != NULL) { + + if (ue_context_p->ue_context.measResults->measResultNeighCells->present == MeasResults__measResultNeighCells_PR_measResultListEUTRA) { + + return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count; + } + else{ + + return 0; + } + + } else { + + return 0; + } + + } else { + + return 0; + + } + + } else { + return 0; + } + +} + +int flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id) { struct rrc_eNB_ue_context_s* ue_context_p = NULL; uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); @@ -1290,8 +1334,88 @@ void* flexran_get_rrc_ncell_measresult_eutra(mid_t mod_id, mid_t ue_id) { ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measResults != NULL) { - return &ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA; + if(ue_context_p->ue_context.measResults->measResultNeighCells != NULL) { + + if (ue_context_p->ue_context.measResults->measResultNeighCells->present == MeasResults__measResultNeighCells_PR_measResultListEUTRA) { + + return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->physCellId; + + } + else { + + return -1; + } + } else { + return -1; + } + } else { + return -1; + } +} + +int flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + + if(ue_context_p->ue_context.measResults->measResultNeighCells != NULL) { + + if (ue_context_p->ue_context.measResults->measResultNeighCells->present == MeasResults__measResultNeighCells_PR_measResultListEUTRA) { + + if (ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult){ + return RSRP_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult)]; + + } + else { + + return 0; + } + + } + else { + + return -1; + } + + } + else { + return -1; + } + + } + else { + return -1; + } +} + +int flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id) { + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); + + if (eNB_rrc_inst_not_ready()) return -1; + + ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); + if(ue_context_p != NULL) { + if(ue_context_p->ue_context.measResults->measResultNeighCells != NULL) { + if (ue_context_p->ue_context.measResults->measResultNeighCells->present == MeasResults__measResultNeighCells_PR_measResultListEUTRA) { + + if (ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult){ + return RSRQ_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult)]; + + } + else { + + return 0; + } + } + else { + + return -1; + } } else { return -1; } @@ -1299,4 +1423,3 @@ void* flexran_get_rrc_ncell_measresult_eutra(mid_t mod_id, mid_t ue_id) { return -1; } } -*/ diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 12ca5febea..05c6817136 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -346,10 +346,10 @@ int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); uint32_t flexran_get_pdcp_sfn(const mid_t mod_id); /*PDCP pdcp tx stats window*/ -uint32_t flexran_set_pdcp_tx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window); +void flexran_set_pdcp_tx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window); /*PDCP pdcp rx stats window*/ -uint32_t flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window); +void flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint16_t obs_window); /*PDCP num tx pdu status flexRAN*/ uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid); @@ -406,3 +406,21 @@ int flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id); /*Get primary cell RSRQ measurement flexRAN*/ int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id); + +/* Get RRC neighbouring measurement */ +int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id); + +/*Get physical cell id*/ +int flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id); + +/*Get RSRP of neighbouring Cell*/ +int flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id); + +/*Get RSRQ of neighbouring Cell*/ +int flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id); + +/*Get MCC PLMN identity neighbouring Cell*/ +int flexran_get_rrc_neigh_plmn_mcc(mid_t mod_id, mid_t ue_id, int cell_id); + +/*Get MNC PLMN identity neighbouring Cell*/ +int flexran_get_rrc_neigh_plmn_mnc(mid_t mod_id, mid_t ue_id, int cell_id); \ No newline at end of file diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index c441c102e3..c3c1421533 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2868,13 +2868,13 @@ rrc_eNB_process_MeasurementReport( return; if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) { - neighboring_cells=measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count; + neighboring_cells = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count; if (ue_context_pP->ue_context.measResults->measResultNeighCells == NULL) { ue_context_pP->ue_context.measResults->measResultNeighCells = CALLOC(1, sizeof(*measResults2->measResultNeighCells)*neighboring_cells); } - ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count=neighboring_cells; + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count = neighboring_cells; for (i=0; i < neighboring_cells; i++){ memcpy (ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i], measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[i], From a09728addba81262300e475a87cacdcf88f21b9b Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Sun, 24 Dec 2017 10:17:18 +0100 Subject: [PATCH 064/141] Warning decreasing --- openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c | 2 +- openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index a04987f07c..e5b0dc61d8 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -736,7 +736,7 @@ flexran_schedule_ue_dl_spec_default(mid_t mod_id, } for (i = 0; i < n_active_slices; i++) { if (slice_percentage[i] < 0 ){ - LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %d. resetting to zero", + LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %f. resetting to zero", mod_id, frame, subframe, i, slice_percentage[i]); slice_percentage[i]=0; } diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c index 64f21482fb..86ea61d943 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c @@ -429,7 +429,7 @@ flexran_schedule_ue_ul_spec_default(mid_t mod_id, } for (i = 0; i < n_active_slices_uplink; i++) { if (slice_percentage_uplink[i] < 0 ){ - LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %d. resetting to zero", + LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %f. resetting to zero", mod_id, frame, subframe, i, slice_percentage_uplink[i]); slice_percentage_uplink[i]=0; } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index d74e8552d6..08bf37fb94 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1112,7 +1112,7 @@ pdcp_run ( } void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){ - int i, ue_flag=1, ret=-1;; + int i, ue_flag=1; //, ret=-1; to be decied later for (i=0; i < NUMBER_OF_UE_MAX; i++){ if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti) { ue_flag=-1; @@ -1126,7 +1126,7 @@ void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){ pdcp_enb[ctxt_pP->module_id].uid[i]=i; pdcp_enb[ctxt_pP->module_id].num_ues++; printf("add new uid is %d %x\n\n", i, ctxt_pP->rnti); - ret=1; + // ret=1; break; } } From 0937339a5385e8771f1a73f698f9e1b51acb0b0e Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Fri, 12 Jan 2018 12:01:44 +0100 Subject: [PATCH 065/141] Update MAC scheduler for slicing (not tested) --- openair2/COMMON/platform_types.h | 1 + openair2/LAYER2/MAC/defs.h | 2 +- openair2/LAYER2/MAC/eNB_scheduler.c | 28 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 156 ++++++++++- .../LAYER2/MAC/eNB_scheduler_primitives.c | 25 ++ openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 256 ++++++++++-------- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 2 +- openair2/LAYER2/MAC/pre_processor.c | 177 +++++++----- openair2/LAYER2/MAC/proto.h | 18 +- 9 files changed, 453 insertions(+), 212 deletions(-) diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 3997d579bd..e5379d532d 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -69,6 +69,7 @@ typedef uint32_t frame_t; typedef int32_t sframe_t; typedef uint32_t sub_frame_t; typedef uint8_t module_id_t; +typedef uint8_t slice_id_t; typedef uint8_t eNB_index_t; typedef uint16_t ue_id_t; typedef int16_t smodule_id_t; diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 43d8167fe6..e27ef3648a 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -800,7 +800,7 @@ typedef struct { ///Contention resolution timer used during random access uint8_t mac_ContentionResolutionTimer; - uint16_t max_allowed_rbs[MAX_NUM_LCID]; + uint16_t max_rbs_allowed_slice[MAX_NUM_LCID][MAX_NUM_SLICES]; uint8_t max_mcs[MAX_NUM_LCID]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 14715aff5a..432915eb8c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -744,40 +744,14 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, copy_ulreq(module_idP, frameP, subframeP); // This schedules SRS in subframeP schedule_SRS(module_idP, frameP, subframeP); -#if defined(FLEXRAN_AGENT_SB_IF) - if (mac_agent_registered[module_idP]){ - agent_mac_xface[module_idP]->flexran_agent_schedule_ul_spec(module_idP,frameP,cooperation_flag,0,4, &msg); - } - flexran_agent_mac_destroy_ul_config(msg); -#else // This schedules ULSCH in subframeP (dci0) schedule_ulsch(module_idP, frameP, subframeP); -#endif // This schedules UCI_SR in subframeP schedule_SR(module_idP, frameP, subframeP); // This schedules UCI_CSI in subframeP schedule_CSI(module_idP, frameP, subframeP); - -#if defined(FLEXRAN_AGENT_SB_IF) - if (mac_agent_registered[module_idP]) { - agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec( - module_idP, - frameP, - subframeP, - mbsfn_status, - &msg); - - flexran_apply_scheduling_decisions(module_idP, - frameP, - subframeP, - mbsfn_status, - msg); - flexran_agent_mac_destroy_dl_config(msg); - } -#else // This schedules DLSCH in subframeP - schedule_ue_spec(module_idP, frameP, subframeP, mbsfn_status); -#endif + schedule_dlsch(module_idP, frameP, subframeP, mbsfn_status); // Allocate CCEs for good after scheduling is done for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 9dbbb39d03..0d9f129fa6 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -57,6 +57,15 @@ #include "intertask_interface.h" #endif +#if defined FLEXRAN_AGENT_SB_IF +#include "ENB_APP/flexran_agent_defs.h" +#include "flexran_agent_ran_api.h" +#include "header.pb-c.h" +#include "flexran.pb-c.h" +#include "flexran_agent_mac.h" +#include +#endif + #include "T.h" #define ENABLE_MAC_PAYLOAD_DEBUG @@ -64,6 +73,36 @@ extern RAN_CONTEXT_t RC; + +// number of active slices for past and current time +int n_active_slices = 1; +int n_active_slices_current = 1; + +// RB share for each slice for past and current time +float avg_slice_percentage=0.25; +float slice_percentage[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage_current[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float total_slice_percentage = 0; +float total_slice_percentage_current = 0; + +// MAX MCS for each slice for past and current time +int slice_maxmcs[MAX_NUM_SLICES] = { 28, 28, 28, 28 }; +int slice_maxmcs_current[MAX_NUM_SLICES] = { 28, 28, 28, 28 }; + +int update_dl_scheduler[MAX_NUM_SLICES] = { 1, 1, 1, 1 }; +int update_dl_scheduler_current[MAX_NUM_SLICES] = { 1, 1, 1, 1 }; + +// name of available scheduler +char *dl_scheduler_type[MAX_NUM_SLICES] = + { "schedule_ue_spec", + "schedule_ue_spec", + "schedule_ue_spec", + "schedule_ue_spec" + }; + +// pointer to the slice specific scheduler +slice_scheduler_dl slice_sched_dl[MAX_NUM_SLICES] = {0}; + //------------------------------------------------------------------------------ void add_ue_dlsch_info(module_id_t module_idP, @@ -408,12 +447,117 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, } } +//------------------------------------------------------------------------------ +void +schedule_dlsch(module_id_ module_idP, + frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) +//------------------------------------------------------------------------------{ +{ + + int i=0; + + total_slice_percentage=0; + avg_slice_percentage=1.0/n_active_slices; + + // reset the slice percentage for inactive slices + for (i = n_active_slices; i< MAX_NUM_SLICES; i++) { + slice_percentage[i]=0; + } + for (i = 0; i < n_active_slices; i++) { + if (slice_percentage[i] < 0 ){ + LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %f. resetting to zero", + mod_id, frame, subframe, i, slice_percentage[i]); + slice_percentage[i]=0; + } + total_slice_percentage+=slice_percentage[i]; + } + + for (i = 0; i < n_active_slices; i++) { + + // Load any updated functions + if (update_dl_scheduler[i] > 0 ) { + slice_sched_dl[i] = dlsym(NULL, dl_scheduler_type[i]); + update_dl_scheduler[i] = 0; + update_dl_scheduler_current[i] = 0; + LOG_N(MAC,"update dl scheduler slice %d\n", i); + } + + if (total_slice_percentage <= 1.0){ // the new total RB share is within the range + + // check if the number of slices has changed, and log + if (n_active_slices_current != n_active_slices ){ + if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { + LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active DL slices has changed: %d-->%d\n", + mod_id, frame, subframe, n_active_slices_current, n_active_slices); + + n_active_slices_current = n_active_slices; + + } else { + LOG_W(MAC,"invalid number of DL slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); + n_active_slices = n_active_slices_current; + } + } + + // check if the slice rb share has changed, and log the console + if (slice_percentage_current[i] != slice_percentage[i]){ // new slice percentage + LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: total percentage %f-->%f, slice RB percentage has changed: %f-->%f\n", + mod_id, i, frame, subframe, total_slice_percentage_current, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); + total_slice_percentage_current= total_slice_percentage; + slice_percentage_current[i] = slice_percentage[i]; + + } + + // check if the slice max MCS, and log the console + if (slice_maxmcs_current[i] != slice_maxmcs[i]){ + if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)){ + LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", + mod_id, i, frame, subframe, slice_maxmcs_current[i], slice_maxmcs[i]); + slice_maxmcs_current[i] = slice_maxmcs[i]; + } else { + LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs[i],slice_maxmcs_current[i]); + slice_maxmcs[i]= slice_maxmcs_current[i]; + } + } + + // check if a new scheduler, and log the console + if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ + LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", + mod_id, i, frame, subframe, dl_scheduler_type[i]); + update_dl_scheduler_current[i] = update_dl_scheduler[i]; + } + + } else { + // here we can correct the values, e.g. reduce proportionally + + if (n_active_slices == n_active_slices_current){ + LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid total RB share (%f->%f), reduce proportionally the RB share by 0.1\n", + mod_id,i, + total_slice_percentage_current, total_slice_percentage); + if (slice_percentage[i] >= avg_slice_percentage){ + slice_percentage[i]-=0.1; + total_slice_percentage-=0.1; + } + } else { + LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid total RB share (%f->%f), revert the number of slice to its previous value (%d->%d)\n", + mod_id,i, + total_slice_percentage_current, total_slice_percentage, + n_active_slices, n_active_slices_current ); + n_active_slices = n_active_slices_current; + slice_percentage[i] = slice_percentage_current[i]; + } + } + + // Run each enabled slice-specific schedulers one by one + slice_sched_dl[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); + } + +} // changes to pre-processor for eMTC //------------------------------------------------------------------------------ void -schedule_ue_spec(module_id_t module_idP, +schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) //------------------------------------------------------------------------------ { @@ -539,7 +683,11 @@ schedule_ue_spec(module_id_t module_idP, (VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_IN); start_meas(&eNB->schedule_dlsch_preprocessor); dlsch_scheduler_pre_processor(module_idP, - frameP, subframeP, N_RBG, mbsfn_flag); + slice_idP, + frameP, + subframeP, + N_RBG, + mbsfn_flag); stop_meas(&eNB->schedule_dlsch_preprocessor); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_OUT); @@ -570,6 +718,8 @@ schedule_ue_spec(module_id_t module_idP, LOG_D(MAC, "[eNB] Cannot find eNB_UE_stats\n"); continue_flag = 1; } + if (flexran_slice_member(UE_id, slice_idP) == 0) + continue; if (continue_flag != 1) { switch (get_tmode(module_idP, CC_id, UE_id)) { @@ -656,7 +806,7 @@ schedule_ue_spec(module_id_t module_idP, */ eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; - eNB_UE_stats->dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); + eNB_UE_stats->dlsch_mcs1 =cmin(eNB_UE_stats->dlsch_mcs1, flexran_slice_maxmcs(slice_idP));//openair_daq_vars.target_ue_dl_mcs); // store stats diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index e5f608d74c..4a316cf92c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -4472,3 +4472,28 @@ harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sched_ctl->pucch1_cqi_update[CC_idP] = 1; } } + +// Flexran Slicing functions + +uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs) +{ + return (uint16_t) floor(rb_percentage * total_rbs); +} + +int flexran_slice_maxmcs(int slice_id) +{ + return slice_maxmcs[slice_id]; +} + +int flexran_slice_member(int UE_id, int slice_id) +{ + + if ((slice_id < 0) || (slice_id > n_active_slices)) + LOG_W(MAC, "out of range slice id %d\n", slice_id); + + + if ((UE_id % n_active_slices) == slice_id) { + return 1; // this ue is a member of this slice + } + return 0; +} diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 035e4c5fa3..b5256820bb 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -57,6 +57,15 @@ #include "intertask_interface.h" #endif +#if defined FLEXRAN_AGENT_SB_IF +#include "ENB_APP/flexran_agent_defs.h" +#include "flexran_agent_ran_api.h" +#include "header.pb-c.h" +#include "flexran.pb-c.h" +#include "flexran_agent_mac.h" +#include +#endif + #include "T.h" #define ENABLE_MAC_PAYLOAD_DEBUG @@ -68,6 +77,37 @@ uint8_t rb_table[34] = 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100 }; +/* number of active slices for past and current time*/ +int n_active_slices_uplink = 1; +int n_active_slices_current_uplink = 1; + +/* RB share for each slice for past and current time*/ +float avg_slice_percentage_uplink=0.25; +float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float total_slice_percentage_uplink = 0; +float total_slice_percentage_current_uplink = 0; + +// MAX MCS for each slice for past and current time +int slice_maxmcs_uplink[MAX_NUM_SLICES] = {16, 16, 16, 16}; +int slice_maxmcs_current_uplink[MAX_NUM_SLICES] = {16,16,16,16}; + +/*resource blocks allowed*/ +uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; +/*Slice Update */ +int update_ul_scheduler[MAX_NUM_SLICES] = {1, 1, 1, 1}; +int update_ul_scheduler_current[MAX_NUM_SLICES] = {1, 1, 1, 1}; + +/* name of available scheduler*/ +char *ul_scheduler_type[MAX_NUM_SLICES] = {"schedule_ulsch_rnti", + "schedule_ulsch_rnti", + "schedule_ulsch_rnti", + "schedule_ulsch_rnti" +}; + +/* Slice Function Pointer */ +slice_scheduler_ul slice_sched_ul[MAX_NUM_SLICES] = {0}; + void rx_sdu(const module_id_t enb_mod_idP, const int CC_idP, @@ -921,7 +961,6 @@ set_msg3_subframe(module_id_t Mod_id, } } - void schedule_ulsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) @@ -1035,14 +1074,117 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, } } - schedule_ulsch_rnti(module_idP, frameP, subframeP, sched_subframe, - first_rb); + // perform slice-specifc operations + + total_slice_percentage_uplink=0; + avg_slice_percentage_uplink=1.0/n_active_slices_uplink; + + // reset the slice percentage for inactive slices + for (i = n_active_slices_uplink; i< MAX_NUM_SLICES; i++) { + slice_percentage_uplink[i]=0; + } + for (i = 0; i < n_active_slices_uplink; i++) { + if (slice_percentage_uplink[i] < 0 ){ + LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %f. resetting to zero", + mod_id, frame, subframe, i, slice_percentage_uplink[i]); + slice_percentage_uplink[i]=0; + } + total_slice_percentage_uplink+=slice_percentage_uplink[i]; + } + + for (i = 0; i < n_active_slices_uplink; i++) { + + // Load any updated functions + if (update_ul_scheduler[i] > 0 ) { + slice_sched_ul[i] = dlsym(NULL, ul_scheduler_type[i]); + update_ul_scheduler[i] = 0; + update_ul_scheduler_current[i] = 0; + //slice_percentage_current_uplink[i]= slice_percentage_uplink[i]; + //total_slice_percentage_current_uplink+=slice_percentage_uplink[i]; + //if (total_slice_percentage_current_uplink> 1) + // total_slice_percentage_current_uplink=1; + LOG_N(MAC,"update ul scheduler slice %d\n", i); + } + // the new total RB share is within the range + if (total_slice_percentage_uplink <= 1.0){ + + // check if the number of slices has changed, and log + if (n_active_slices_current_uplink != n_active_slices_uplink ){ + if ((n_active_slices_uplink > 0) && (n_active_slices_uplink <= MAX_NUM_SLICES)) { + LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active UL slices has changed: %d-->%d\n", + mod_id, frame, subframe, n_active_slices_current_uplink, n_active_slices_uplink); + + n_active_slices_current_uplink = n_active_slices_uplink; + + } else { + LOG_W(MAC,"invalid number of UL slices %d, revert to the previous value %d\n",n_active_slices_uplink, n_active_slices_current_uplink); + n_active_slices_uplink = n_active_slices_current_uplink; + } + } + + // check if the slice rb share has changed, and log the console + if (slice_percentage_current_uplink[i] != slice_percentage_uplink[i]){ + LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: total percentage %f-->%f, slice RB percentage has changed: %f-->%f\n", + mod_id, i, frame, subframe, total_slice_percentage_current_uplink, total_slice_percentage_uplink, slice_percentage_current_uplink[i], slice_percentage_uplink[i]); + total_slice_percentage_current_uplink= total_slice_percentage_uplink; + slice_percentage_current_uplink[i] = slice_percentage_uplink[i]; + + } + + // check if the slice max MCS, and log the console + if (slice_maxmcs_current_uplink[i] != slice_maxmcs_uplink[i]){ + if ((slice_maxmcs_uplink[i] >= 0) && (slice_maxmcs_uplink[i] <= 16)){ + LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", + mod_id, i, frame, subframe, slice_maxmcs_current_uplink[i], slice_maxmcs_uplink[i]); + slice_maxmcs_current_uplink[i] = slice_maxmcs_uplink[i]; + } else { + LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs_uplink[i],slice_maxmcs_current_uplink[i]); + slice_maxmcs_uplink[i]= slice_maxmcs_current_uplink[i]; + + } + } + + // check if a new scheduler, and log the console + if (update_ul_scheduler_current[i] != update_ul_scheduler[i]){ + LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: UL scheduler for this slice is updated: %s \n", + mod_id, i, frame, subframe, ul_scheduler_type[i]); + + update_ul_scheduler_current[i] = update_ul_scheduler[i]; + } + } + else { + + if (n_active_slices_uplink == n_active_slices_current_uplink){ + LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid total RB share (%f->%f), reduce proportionally the RB share by 0.1\n", + mod_id,i, + total_slice_percentage_current_uplink, total_slice_percentage_uplink); + if (slice_percentage_uplink[i] > avg_slice_percentage_uplink){ + slice_percentage_uplink[i]-=0.1; + total_slice_percentage_uplink-=0.1; + } + } else { + // here we can correct the values, e.g. reduce proportionally + LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid total RB share (%f->%f), revert the number of slice to its previous value (%d->%d)\n", + mod_id,i, + total_slice_percentage_current_uplink, total_slice_percentage_uplink, + n_active_slices_uplink, n_active_slices_current_uplink); + n_active_slices_uplink = n_active_slices_current_uplink; + slice_percentage_uplink[i] = slice_percentage_current_uplink[i]; + } + } + + // Run each enabled slice-specific schedulers one by one + slice_sched_ul[i](module_idP, i,frameP, subframeP, sched_subframe, + first_rb); + } + stop_meas(&mac->schedule_ulsch); } void schedule_ulsch_rnti(module_id_t module_idP, + slice_id_t slice_id, frame_t frameP, sub_frame_t subframeP, unsigned char sched_subframeP, uint16_t * first_rb) @@ -1081,7 +1223,7 @@ schedule_ulsch_rnti(module_id_t module_idP, &mac->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body; LOG_D(MAC, "entering ulsch preprocesor\n"); - ulsch_scheduler_pre_processor(module_idP, frameP, subframeP, first_rb); + ulsch_scheduler_pre_processor(module_idP, slice_id, frameP, subframeP, first_rb); LOG_D(MAC, "exiting ulsch preprocesor\n"); @@ -1115,7 +1257,6 @@ schedule_ulsch_rnti(module_id_t module_idP, for (n=0; nnumactiveULCCs[UE_id]; n++) { CC_id = UE_list->ordered_ULCCids[n][UE_id]; -<<<<<<< HEAD if (mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti) == NULL) { LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: no PHY context\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); drop_ue = 1; @@ -1142,111 +1283,6 @@ schedule_ulsch_rnti(module_id_t module_idP, subframeP, rnti); UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; -======= - // loop over all active UL CC_ids for this UE - for (n=0; nnumactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); - eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); - - aggregation=get_aggregation(get_bw_index(module_idP,CC_id), - eNB_UE_stats->DL_cqi[0], - format0); - - if (CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,aggregation,rnti)) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); - continue; // break; - } else{ - LOG_D(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d mode %s: aggregation level %d\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id, mode_string[eNB_UE_stats->mode], 1<mode == PUSCH) { // ue has a ulsch channel - - DCI_pdu = &eNB->common_channels[CC_id].DCI_pdu; - UE_template = &UE_list->UE_template[CC_id][UE_id]; - UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - - if (mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL) == -1 ) { - LOG_W(MAC,"[eNB %d] Scheduler Frame %d, subframeP %d: candidate harq_pid from PHY for UE %d CC %d RNTI %x\n", - module_idP,frameP,subframeP, UE_id, CC_id, rnti); - continue; - } else - LOG_T(MAC,"[eNB %d] Frame %d, subframeP %d, UE %d CC %d : got harq pid %d round %d (rnti %x,mode %s)\n", - module_idP,frameP,subframeP,UE_id,CC_id, harq_pid, round,rnti,mode_string[eNB_UE_stats->mode]); - - PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]); - if (((UE_is_to_be_scheduled(module_idP,CC_id,UE_id)>0)) || (round>0))// || ((frameP%10)==0)) - // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames - { - LOG_D(MAC,"[eNB %d][PUSCH] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d)\n", - module_idP,frameP,subframeP,UE_id,rnti,round,UE_template->ul_SR, - UE_sched_ctrl->ul_inactivity_timer, - UE_sched_ctrl->ul_failure_timer); - // reset the scheduling request - UE_template->ul_SR = 0; - status = mac_eNB_get_rrc_status(module_idP,rnti); - if (status < RRC_CONNECTED) - cqi_req = 0; - else if (UE_sched_ctrl->cqi_req_timer>30) { - cqi_req = 1; - UE_sched_ctrl->cqi_req_timer=0; - } - else - cqi_req = 0; - - //power control - //compute the expected ULSCH RX power (for the stats) - - // this is the normalized RX power and this should be constant (regardless of mcs - normalized_rx_power = eNB_UE_stats->UL_rssi[0]; - target_rx_power = mac_xface->get_target_pusch_rx_power(module_idP,CC_id); - - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe; - if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case - ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - { - UE_template->pusch_tpc_tx_frame=frameP; - UE_template->pusch_tpc_tx_subframe=subframeP; - if (normalized_rx_power>(target_rx_power+1)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-1)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - } else { - tpc = 1; //0 - } - - if (tpc!=1) { - LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - module_idP,frameP,subframeP,harq_pid,tpc, - tpc_accumulated,normalized_rx_power,target_rx_power); - } - - // new transmission - if (round==0) { - - ndi = 1-UE_template->oldNDI_UL[harq_pid]; - UE_template->oldNDI_UL[harq_pid]=ndi; - UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; - mcs = UE_template->pre_assigned_mcs_ul;//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) { - rb_table_index=UE_template->pre_allocated_rb_table_index_ul; - } else { - mcs=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); - rb_table_index=13; // for PHR ->>>>>>> feature-68-enb-agent } continue; } diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index a988862542..6445fa0845 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -578,7 +578,7 @@ _dlsch_scheduler_pre_processor(module_id_t Mod_id, if (!phy_stats_exist(Mod_id, rnti)) continue; - for (ii=0; ii < UE_num_active_CC(UE_list,UE_id); ii++) { + for (ii=0; ii < UE_num_active_CC(UE_list,UE_id); ii++) { CC_id = UE_list->ordered_CCids[ii][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][slice_id]; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 23d3f3bd60..a0cc0dd412 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -96,7 +96,7 @@ int phy_stats_exist(module_id_t Mod_id, int rnti) // This function stores the downlink buffer for all the logical channels void -store_dlsch_buffer(module_id_t Mod_id, frame_t frameP, +store_dlsch_buffer(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, sub_frame_t subframeP) { @@ -110,6 +110,9 @@ store_dlsch_buffer(module_id_t Mod_id, frame_t frameP, if (UE_list->active[UE_id] != TRUE) continue; + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + UE_template = &UE_list->UE_template[UE_PCCID(Mod_id, UE_id)][UE_id]; @@ -153,8 +156,8 @@ store_dlsch_buffer(module_id_t Mod_id, frame_t frameP, */ 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", - Mod_id, frameP, subframeP, UE_id, + "[eNB %d][SLICE %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, slice_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], @@ -182,6 +185,7 @@ store_dlsch_buffer(module_id_t Mod_id, frame_t frameP, // This function returns the estimated number of RBs required by each UE for downlink scheduling void assign_rbs_required(module_id_t Mod_id, + slice_id_t slice_id, frame_t frameP, sub_frame_t subframe, uint16_t @@ -200,7 +204,8 @@ assign_rbs_required(module_id_t Mod_id, for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { if (UE_list->active[UE_id] != TRUE) continue; - + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; pCCid = UE_PCCID(Mod_id, UE_id); //update CQI information across component carriers @@ -262,16 +267,18 @@ assign_rbs_required(module_id_t Mod_id, to_prb(RC.mac[Mod_id]->common_channels[CC_id]. mib->message.dl_Bandwidth); + UE_list->ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]= flexran_nb_rbs_allowed_slice(slice_percentage[slice_id],N_RB_DL); + /* calculating required number of RBs for each UE */ while (TBS < UE_list->UE_template[pCCid][UE_id]. dl_buffer_total) { nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; - if (nb_rbs_required[CC_id][UE_id] > N_RB_DL) { + if (nb_rbs_required[CC_id][UE_id] > UE_list->ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]) { TBS = - get_TBS_DL(eNB_UE_stats->dlsch_mcs1, N_RB_DL); - nb_rbs_required[CC_id][UE_id] = N_RB_DL; + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, UE_list->ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]); + nb_rbs_required[CC_id][UE_id] = UE_list->ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]; break; } @@ -556,13 +563,14 @@ void sort_UEs(module_id_t Mod_idP, int frameP, sub_frame_t subframeP) // This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done void dlsch_scheduler_pre_processor(module_id_t Mod_id, + slice_id_t slice_id, frame_t frameP, sub_frame_t subframeP, int N_RBG[MAX_NUM_CCs], int *mbsfn_flag) { unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], harq_pid = - 0, round = 0, total_ue_count; + 0, round = 0, total_ue_count[MAX_NUM_CCs], total_rbs_used[MAX_NUM_CCs]; unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; int UE_id, i; uint16_t ii, j; @@ -619,6 +627,8 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, N_RBG[CC_id], nb_rbs_required, nb_rbs_required_remaining, + total_ue_count, + total_rbs_used, rballoc_sub, MIMO_mode_indicator); @@ -627,12 +637,12 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, // Store the DLSCH buffer for each logical channel - store_dlsch_buffer(Mod_id, frameP, subframeP); + store_dlsch_buffer(Mod_id, slice_id,frameP, subframeP); // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - assign_rbs_required(Mod_id, frameP, subframeP, nb_rbs_required, + assign_rbs_required(Mod_id, slice_id, frameP, subframeP, nb_rbs_required, min_rb_unit); @@ -641,65 +651,89 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, sort_UEs(Mod_id, frameP, subframeP); - - total_ue_count = 0; - // loop over all active UEs for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { - rnti = UE_RNTI(Mod_id, i); + rnti = UE_RNTI(Mod_id, i); - if (rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - UE_id = i; + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + UE_id = i; + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; - for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - cc = &RC.mac[Mod_id]->common_channels[ii]; - if (cc->tdd_Config) - harq_pid = ((frameP * 10) + subframeP) % 10; - else - harq_pid = ((frameP * 10) + subframeP) & 7; - round = ue_sched_ctl->round[CC_id][harq_pid]; + for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + CC_id = UE_list->ordered_CCids[ii][UE_id]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + cc = &RC.mac[Mod_id]->common_channels[ii]; + if (cc->tdd_Config) + harq_pid = ((frameP * 10) + subframeP) % 10; + else + harq_pid = ((frameP * 10) + subframeP) & 7; + round = ue_sched_ctl->round[CC_id][harq_pid]; - average_rbs_per_user[CC_id] = 0; + average_rbs_per_user[CC_id] = 0; - if (round != 8) { - 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) { - total_ue_count = total_ue_count + 1; - } - // hypothetical assignment - /* - * If schedule is enabled and if the priority of the UEs is modified - * The average rbs per logical channel per user will depend on the level of - * priority. Concerning the hypothetical assignement, we should assign more - * rbs to prioritized users. Maybe, we can do a mapping between the - * average rbs per user and the level of priority or multiply the average rbs - * per user by a coefficient which represents the degree of priority. - */ + if (round != 8) { + nb_rbs_required[CC_id][UE_id] = + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + total_rbs_used[CC_id]+=nb_rbs_required[CC_id][UE_id]; + } - N_RB_DL = - to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib-> - message.dl_Bandwidth); + //nb_rbs_required_remaining[UE_id] = nb_rbs_required[UE_id]; + if (nb_rbs_required[CC_id][UE_id] > 0) { + total_ue_count[CC_id] = total_ue_count[CC_id] + 1; + } - if (total_ue_count == 0) { - average_rbs_per_user[CC_id] = 0; - } else if ((min_rb_unit[CC_id] * total_ue_count) <= (N_RB_DL)) { - average_rbs_per_user[CC_id] = - (uint16_t) floor(N_RB_DL / total_ue_count); - } else { - average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; // consider the total number of use that can be scheduled UE - } - } + } } + // loop over all active UEs and calculate avg rb per user based on total active UEs + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + rnti = UE_RNTI(Mod_id, i); + + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + UE_id = i; + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + + for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + CC_id = UE_list->ordered_CCids[ii][UE_id]; + + // hypothetical assignment + /* + * If schedule is enabled and if the priority of the UEs is modified + * The average rbs per logical channel per user will depend on the level of + * priority. Concerning the hypothetical assignement, we should assign more + * rbs to prioritized users. Maybe, we can do a mapping between the + * average rbs per user and the level of priority or multiply the average rbs + * per user by a coefficient which represents the degree of priority. + */ + + + N_RB_DL = + to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib-> + message.dl_Bandwidth) - total_rbs_used[CC_id]; + + //recalcualte based on the what is left after retransmission + ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]= flexran_nb_rbs_allowed_slice(slice_percentage[slice_id],N_RB_DL); + + if (total_ue_count[CC_id] == 0) { + average_rbs_per_user[CC_id] = 0; + } else if ((min_rb_unit[CC_id] * total_ue_count[CC_id]) <= (ue_sched_ctl.max_allowed_rbs[CC_id][slice_id])) { + average_rbs_per_user[CC_id] = + (uint16_t) floor(ue_sched_ctl.max_allowed_rbs[CC_id][slice_id] / total_ue_count[CC_id]); + } 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]) { @@ -709,6 +743,8 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + if (flexran_slice_member(i, slice_id) == 0) + continue; for (ii = 0; ii < UE_num_active_CC(UE_list, i); ii++) { CC_id = UE_list->ordered_CCids[ii][i]; @@ -765,11 +801,14 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, } } - if (total_ue_count > 0) { - for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { UE_id = i; for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + + // if there are UEs with traffic + if (total_ue_count [CC_id] > 0) { CC_id = UE_list->ordered_CCids[ii][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; round = ue_sched_ctl->round[CC_id][harq_pid]; @@ -969,9 +1008,9 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, } } #endif - } + } // total_ue_count } - } // total_ue_count + } } // end of for for r1 and r2 #ifdef TM5 @@ -1044,7 +1083,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, } //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; - LOG_D(MAC, "Total RBs allocated for UE%d = %d\n", UE_id, + LOG_D(MAC, "[eNB %d][SLICE %d]Total RBs allocated for UE%d = %d\n", Mod_id, slice_id, UE_id, ue_sched_ctl->pre_nb_available_rbs[CC_id]); } } @@ -1065,9 +1104,12 @@ dlsch_scheduler_pre_processor_reset(int module_idP, uint16_t nb_rbs_required_remaining [MAX_NUM_CCs][NUMBER_OF_UE_MAX], + unsigned char total_ue_count[MAX_NUM_CCs], + unsigned char total_rbs_used[MAX_NUM_CCs], unsigned char rballoc_sub[MAX_NUM_CCs] - [N_RBG_MAX], unsigned char + [N_RBG_MAX], + unsigned char MIMO_mode_indicator[MAX_NUM_CCs] [N_RBG_MAX]) { @@ -1154,7 +1196,8 @@ dlsch_scheduler_pre_processor_reset(int module_idP, ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; ue_sched_ctl->dl_pow_off[CC_id] = 2; nb_rbs_required_remaining[CC_id][UE_id] = 0; - + total_ue_count[CC_id]=0; + total_rbs_used[CC_id]=0; switch (N_RB_DL) { case 6: RBGsize = 1; @@ -1322,7 +1365,7 @@ dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, void ulsch_scheduler_pre_processor(module_id_t module_idP, - int frameP, + slice_id_t slice_id, int frameP, sub_frame_t subframeP, uint16_t * first_rb) { @@ -1538,7 +1581,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, void -assign_max_mcs_min_rb(module_id_t module_idP, int frameP, +assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, sub_frame_t subframeP, uint16_t * first_rb) { diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 9f3af1b053..a83aabef27 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -102,11 +102,12 @@ void schedule_ulsch(module_id_t module_idP, frame_t frameP, /** \brief ULSCH Scheduling per RNTI @param Mod_id Instance ID of eNB +@param slice_id Instance slice for this eNB @param frame Frame index @param subframe Subframe number on which to act @param sched_subframe Subframe number where PUSCH is transmitted (for DAI lookup) */ -void schedule_ulsch_rnti(module_id_t module_idP, frame_t frameP, +void schedule_ulsch_rnti(module_id_t module_idP, slice_id_t slice_idP, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, uint16_t * first_rb); @@ -127,9 +128,12 @@ void fill_DLSCH_dci(module_id_t module_idP, frame_t frameP, @param mbsfn_flag Indicates that MCH/MCCH is in this subframe */ -void schedule_ue_spec(module_id_t module_idP, frame_t frameP, +void schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframe, int *mbsfn_flag); +void schedule_ue_spec(module_id_t module_idP, slice_id_t slice_idP, + frame_t frameP,sub_frame_t subframe, int *mbsfn_flag); + /** \brief Function for UE/PHY to compute PUSCH transmit power in power-control procedure. @param Mod_id Module id of UE @@ -209,6 +213,7 @@ void dlsch_scheduler_pre_processor_reset(int module_idP, int UE_id, void dlsch_scheduler_pre_processor(module_id_t module_idP, + slice_id_t slice_idP, frame_t frameP, sub_frame_t subframe, int N_RBG[MAX_NUM_CCs], @@ -633,7 +638,7 @@ int UE_PCCID(module_id_t mod_idP, int ue_idP); rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP); -void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, +void ulsch_scheduler_pre_processor(module_id_t module_idP, slice_id_t slice_id, int frameP, sub_frame_t subframeP, uint16_t * first_rb); void store_ulsch_buffer(module_id_t module_idP, int frameP, @@ -1158,5 +1163,12 @@ int32_t get_uldl_offset(int eutra_bandP); int l2_init_ue(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); +/*Slice related functions */ +uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs); + +int flexran_slice_member(int UE_id, int slice_id); + +int flexran_slice_maxmcs(int slice_id;) + #endif /** @}*/ From 765d6370f640c23703bfe1d77e56ddd278b25c16 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 10 Jan 2018 14:22:14 +0100 Subject: [PATCH 066/141] update FlexRAN configuration definition (paramdef) --- openair2/ENB_APP/enb_paramdef.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 6a03687fab..36a1f2c0a7 100755 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -611,18 +611,26 @@ static int DEFENBS[] = {0}; /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define ENB_CONFIG_STRING_NETWORK_CONTROLLER_CONFIG "NETWORK_CONTROLLER" +#define CONFIG_STRING_NETWORK_CONTROLLER_CONFIG "NETWORK_CONTROLLER" -#define ENB_CONFIG_STRING_FLEXRAN_AGENT_INTERFACE_NAME "FLEXRAN_AGENT_INTERFACE_NAME" -#define ENB_CONFIG_STRING_FLEXRAN_AGENT_IPV4_ADDRESS "FLEXRAN_AGENT_IPV4_ADDRESS" -#define ENB_CONFIG_STRING_FLEXRAN_AGENT_PORT "FLEXRAN_AGENT_PORT" -#define ENB_CONFIG_STRING_FLEXRAN_AGENT_CACHE "FLEXRAN_AGENT_CACHE" +#define CONFIG_STRING_FLEXRAN_INTERFACE_NAME "FLEXRAN_INTERFACE_NAME" +#define CONFIG_STRING_FLEXRAN_IPV4_ADDRESS "FLEXRAN_IPV4_ADDRESS" +#define CONFIG_STRING_FLEXRAN_PORT "FLEXRAN_PORT" +#define CONFIG_STRING_FLEXRAN_CACHE "FLEXRAN_CACHE" +#define CONFIG_STRING_FLEXRAN_AWAIT_RECONF "FLEXRAN_AWAIT_RECONF" + +#define FLEXRAN_INTERFACE_NAME_IDX 0 +#define FLEXRAN_IPV4_ADDRESS_IDX 1 +#define FLEXRAN_PORT_IDX 2 +#define FLEXRAN_CACHE_IDX 3 +#define FLEXRAN_AWAIT_RECONF_IDX 4 #define FLEXRANPARAMS_DESC { \ -{ENB_CONFIG_STRING_FLEXRAN_AGENT_INTERFACE_NAME, NULL, 0, uptr:NULL, defstrval:ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE, TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_FLEXRAN_AGENT_IPV4_ADDRESS, NULL, 0, uptr:NULL, defstrval:ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE, TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_FLEXRAN_AGENT_PORT, NULL, 0, uptr:NULL, defstrval:ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE, TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_FLEXRAN_AGENT_CACHE, NULL, 0, uptr:NULL, defstrval:ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE, TYPE_STRING, 0} \ +{CONFIG_STRING_FLEXRAN_INTERFACE_NAME, NULL, 0, strptr:NULL, defstrval:"lo", TYPE_STRING, 0}, \ +{CONFIG_STRING_FLEXRAN_IPV4_ADDRESS, NULL, 0, strptr:NULL, defstrval:"127.0.0.1/30", TYPE_STRING, 0}, \ +{CONFIG_STRING_FLEXRAN_PORT, NULL, 0, uptr:NULL, defintval:2210, TYPE_UINT, 0}, \ +{CONFIG_STRING_FLEXRAN_CACHE, NULL, 0, strptr:NULL, defstrval:"/mnt/oai_agent_cache", TYPE_STRING, 0}, \ +{CONFIG_STRING_FLEXRAN_AWAIT_RECONF, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0} \ } /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ From fac968246dd4ac9806545df257e394e504a29a80 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 10 Jan 2018 17:49:39 +0100 Subject: [PATCH 067/141] define FlexRAN data in RAN context and use it - defines RCconfig data structures - adds method to read data - use it in source files --- common/ran_context.h | 7 ++ .../MAC/flexran_agent_mac_internal.c | 2 +- openair2/ENB_APP/enb_app.c | 4 +- openair2/ENB_APP/enb_config.c | 71 ++++++++++--------- openair2/ENB_APP/enb_config.h | 3 + openair2/ENB_APP/enb_paramdef.h | 2 +- openair2/ENB_APP/flexran_agent.c | 60 ++++------------ openair2/ENB_APP/flexran_agent.h | 1 - openair2/ENB_APP/flexran_agent_common.c | 4 +- openair2/ENB_APP/flexran_agent_defs.h | 23 +++--- openair2/ENB_APP/flexran_agent_extern.h | 6 +- 11 files changed, 82 insertions(+), 101 deletions(-) diff --git a/common/ran_context.h b/common/ran_context.h index 4e25729c86..d5e2a1f172 100644 --- a/common/ran_context.h +++ b/common/ran_context.h @@ -40,6 +40,9 @@ #include "PHY/impl_defs_top.h" #include "PHY/impl_defs_lte.h" #include "RRC/LITE/defs.h" +#ifdef FLEXRAN_AGENT_SB_IF +#include "flexran_agent_defs.h" +#endif #include "gtpv1u.h" #include "NwGtpv1u.h" @@ -64,6 +67,10 @@ typedef struct { int *nb_L1_CC; /// Number of RU instances in this node int nb_RU; +#ifdef FLEXRAN_AGENT_SB_IF + /// FlexRAN context variables + flexran_agent_info_t **flexran; +#endif /// eNB context variables struct PHY_VARS_eNB_s ***eNB; /// RRC context variables diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index 7239ca8233..2af6514ef6 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -869,7 +869,7 @@ int load_dl_scheduler_function(mid_t mod_id, const char *function_name) { char lib_name[120]; char target[512]; snprintf(lib_name, sizeof(lib_name), "/%s.so", function_name); - strcpy(target, local_cache); + strcpy(target, RC.flexran[mod_id]->cache_name); strcat(target, lib_name); LOG_I(FLEXRAN_AGENT, "Opening pushed code: %s\n", target); diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index bd9be082c2..636df458ae 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -343,8 +343,8 @@ void *eNB_app_task(void *args_p) enb_app_start_phy_rrc(enb_id_start, enb_id_end); #ifdef FLEXRAN_AGENT_SB_IF - for (enb_i = 0; enb_i <1; enb_i ++){ // To be handled for all of current eNB - flexran_set_enb_vars(enb_i, RAN_LTE_OAI); + for (uint32_t enb_i = 0; enb_i <1; enb_i ++){ // To be handled for all of current eNB + flexran_set_RC_vars(enb_i, RAN_LTE_OAI); } #endif diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index f2f89ad1ca..d2a35c3bd7 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -237,6 +237,44 @@ void RCconfig_RU(void) { } +#ifdef FLEXRAN_AGENT_SB_IF +void RCconfig_flexran() +{ + int i; + + paramdef_t flexranParams[] = FLEXRANPARAMS_DESC; + config_get(flexranParams, sizeof(flexranParams)/sizeof(paramdef_t), CONFIG_STRING_NETWORK_CONTROLLER_CONFIG); + + if (!RC.flexran) { + RC.flexran = calloc(RC.nb_L1_inst, sizeof(flexran_agent_info_t*)); + AssertFatal(RC.flexran != NULL, + "can't ALLOCATE %zu Bytes for %d flexran agent info with size %zu\n", + RC.nb_L1_inst * sizeof(flexran_agent_info_t*), + RC.nb_L1_inst, sizeof(flexran_agent_info_t*)); + } + + /* For all agent instance, fill in the same controller configuration. */ + for (i = 0; i < RC.nb_L1_inst; i++) { + RC.flexran[i] = calloc(1, sizeof(flexran_agent_info_t)); + AssertFatal(RC.flexran[i] != NULL, + "can't ALLOCATE %zu Bytes for flexran agent info (iteration %d/%d)\n", + sizeof(flexran_agent_info_t), i + 1, RC.nb_L1_inst); + RC.flexran[i]->interface_name = strdup(*(flexranParams[FLEXRAN_INTERFACE_NAME_IDX].strptr)); + //inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN); + //strcpy(in_ip, DEFAULT_FLEXRAN_AGENT_IPv4_ADDRESS ); + RC.flexran[i]->remote_ipv4_addr = strdup(*(flexranParams[FLEXRAN_IPV4_ADDRESS_IDX].strptr)); + // DEFAULT_FLEXRAN_AGENT_PORT + RC.flexran[i]->remote_port = *(flexranParams[FLEXRAN_PORT_IDX].uptr); + // DEFAULT_FLEXRAN_AGENT_CACHE + RC.flexran[i]->cache_name = strdup(*(flexranParams[FLEXRAN_CACHE_IDX].strptr)); + RC.flexran[i]->await_reconf = strcmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0; + RC.flexran[i]->enb_id = i; + } + + /* TODO: show FlexRAN config now? */ +} +#endif + void RCconfig_L1() { int i,j; paramdef_t L1_Params[] = L1PARAMS_DESC; @@ -451,10 +489,6 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { /* - char* flexran_agent_interface_name = NULL; - char* flexran_agent_ipv4_address = NULL; - int32_t flexran_agent_port = 0; - char* flexran_agent_cache = NULL; int32_t otg_ue_id = 0; char* otg_app_type = NULL; char* otg_bg_traffic = NULL; @@ -2028,35 +2062,6 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { rrc->srb1_poll_byte = PollByte_kBinfinity; rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t8; } - /* - // Network Controller - subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_NETWORK_CONTROLLER_CONFIG); - - if (subsetting != NULL) { - if ( ( - config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_INTERFACE_NAME, - (const char **)&flexran_agent_interface_name) - && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_IPV4_ADDRESS, - (const char **)&flexran_agent_ipv4_address) - && config_setting_lookup_int(subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_PORT, - &flexran_agent_port) - && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_CACHE, - (const char **)&flexran_agent_cache) - ) - ) { - enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_interface_name = strdup(flexran_agent_interface_name); - cidr = flexran_agent_ipv4_address; - address = strtok(cidr, "/"); - //enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_ipv4_address = strdup(address); - if (address) { - IPV4_STR_ADDR_TO_INT_NWBO (address, enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_ipv4_address, "BAD IP ADDRESS FORMAT FOR eNB Agent !\n" ); - } - - enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_port = flexran_agent_port; - enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_cache = strdup(flexran_agent_cache); - } - } - */ /* // OTG _CONFIG diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h index 0406e11e4c..4e4434ad70 100644 --- a/openair2/ENB_APP/enb_config.h +++ b/openair2/ENB_APP/enb_config.h @@ -94,6 +94,9 @@ typedef struct ru_config_s { } ru_config_t; extern void RCconfig_RU(void); +#ifdef FLEXRAN_AGENT_SB_IF +extern void RCconfig_flexran(void); +#endif extern void RCconfig_L1(void); extern void RCconfig_macrlc(void); extern int RCconfig_gtpu(void ); diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 36a1f2c0a7..0203380314 100755 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -627,7 +627,7 @@ static int DEFENBS[] = {0}; #define FLEXRANPARAMS_DESC { \ {CONFIG_STRING_FLEXRAN_INTERFACE_NAME, NULL, 0, strptr:NULL, defstrval:"lo", TYPE_STRING, 0}, \ -{CONFIG_STRING_FLEXRAN_IPV4_ADDRESS, NULL, 0, strptr:NULL, defstrval:"127.0.0.1/30", TYPE_STRING, 0}, \ +{CONFIG_STRING_FLEXRAN_IPV4_ADDRESS, NULL, 0, strptr:NULL, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ {CONFIG_STRING_FLEXRAN_PORT, NULL, 0, uptr:NULL, defintval:2210, TYPE_UINT, 0}, \ {CONFIG_STRING_FLEXRAN_CACHE, NULL, 0, strptr:NULL, defstrval:"/mnt/oai_agent_cache", TYPE_STRING, 0}, \ {CONFIG_STRING_FLEXRAN_AWAIT_RECONF, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0} \ diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index 530cb81042..60239cbbbd 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -30,15 +30,6 @@ #include - -//#define TEST_TIMER - -flexran_agent_instance_t flexran_agent[NUM_MAX_ENB]; - -char in_ip[40]; -static uint16_t in_port; -char local_cache[40]; - void *send_thread(void *args); void *receive_thread(void *args); pthread_t new_thread(void *(*f)(void *), void *b); @@ -52,7 +43,7 @@ int agent_task_created = 0; */ void *flexran_agent_task(void *args){ - //flexran_agent_instance_t *d = (flexran_agent_instance_t *) args; + //flexran_agent_info_t *d = (flexran_agent_info_t *) args; Protocol__FlexranMessage *msg; void *data; int size; @@ -113,7 +104,7 @@ void *flexran_agent_task(void *args){ void *receive_thread(void *args) { - flexran_agent_instance_t *d = args; + flexran_agent_info_t *d = args; void *data; int size; int priority; @@ -186,46 +177,19 @@ pthread_t new_thread(void *(*f)(void *), void *b) { return t; } -void flexran_agent_reconfigure(mid_t mod_id){ - Enb_properties_array_t *enb_properties = enb_config_get(); - - /* - * check the configuration - */ - if (enb_properties->properties[mod_id]->flexran_agent_cache != NULL) { - strncpy(local_cache, enb_properties->properties[mod_id]->flexran_agent_cache, sizeof(local_cache)); - local_cache[sizeof(local_cache) - 1] = 0; - } else { - strcpy(local_cache, DEFAULT_FLEXRAN_AGENT_CACHE); - } - - if (enb_properties->properties[mod_id]->flexran_agent_ipv4_address != 0) { - inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN); - } else { - strcpy(in_ip, DEFAULT_FLEXRAN_AGENT_IPv4_ADDRESS ); - } - - if (enb_properties->properties[mod_id]->flexran_agent_port != 0 ) { - in_port = enb_properties->properties[mod_id]->flexran_agent_port; - } else { - in_port = DEFAULT_FLEXRAN_AGENT_PORT ; - } - LOG_I(FLEXRAN_AGENT,"starting enb agent client for module id %d on ipv4 %s, port %d\n", - flexran_agent[mod_id].enb_id, - in_ip, - in_port); - -} - int channel_container_init = 0; int flexran_agent_start(mid_t mod_id) { int channel_id; + char *in_ip = RC.flexran[mod_id]->remote_ipv4_addr; + uint16_t in_port = RC.flexran[mod_id]->remote_port; - flexran_set_enb_vars(mod_id, RAN_LTE_OAI); - flexran_agent[mod_id].enb_id = mod_id; - - flexran_agent_reconfigure(mod_id); + RC.flexran[mod_id]->enb_id = mod_id; + /* assume for the moment the monolithic case, i.e. agent can provide + * information for all layers */ + RC.flexran[mod_id]->capability_mask = FLEXRAN_CAP_LOL1 | FLEXRAN_CAP_HIL1 + | FLEXRAN_CAP_LOL2 | FLEXRAN_CAP_HIL2 + | FLEXRAN_CAP_PDCP | FLEXRAN_CAP_RRC; /* * Initialize the channel container @@ -264,7 +228,7 @@ int flexran_agent_start(mid_t mod_id) /*Initialize the continuous stats update mechanism*/ flexran_agent_init_cont_stats_update(mod_id); - new_thread(receive_thread, &flexran_agent[mod_id]); + new_thread(receive_thread, RC.flexran[mod_id]); /*Initialize and register the mac xface. Must be modified later *for more flexibility in agent management */ @@ -293,7 +257,7 @@ int flexran_agent_start(mid_t mod_id) * start the enb agent task for tx and interaction with the underlying network function */ if (!agent_task_created) { - if (itti_create_task (TASK_FLEXRAN_AGENT, flexran_agent_task, (void *) &flexran_agent[mod_id]) < 0) { + if (itti_create_task (TASK_FLEXRAN_AGENT, flexran_agent_task, (void *) RC.flexran[mod_id]) < 0) { LOG_E(FLEXRAN_AGENT, "Create task for FlexRAN Agent failed\n"); return -1; } diff --git a/openair2/ENB_APP/flexran_agent.h b/openair2/ENB_APP/flexran_agent.h index f3f71c0631..ed9ee444c3 100644 --- a/openair2/ENB_APP/flexran_agent.h +++ b/openair2/ENB_APP/flexran_agent.h @@ -48,7 +48,6 @@ /* Initiation and termination of the eNodeB agent */ int flexran_agent_start(mid_t mod_id); int flexran_agent_stop(mid_t mod_id); -void flexran_agent_reconfigure(mid_t mod_id); /* * enb agent task mainly wakes up the tx thread for periodic and oneshot messages to the controller diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index b69ddf35cd..00aa7e9263 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -391,7 +391,7 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_ char lib_name[120]; char target[512]; snprintf(lib_name, sizeof(lib_name), "/%s.so", control_delegation_msg->name); - strcpy(target, local_cache); + strcpy(target, RC.flexran[mod_id]->cache_name); strcat(target, lib_name); FILE *f; @@ -1075,7 +1075,7 @@ int flexran_agent_rrc_measurement(mid_t mod_id, const void *params, Protocol__Fl struct rrc_eNB_ue_context_s *ue_context_p = NULL; - RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[mod_id].rrc_ue_head)){ + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[mod_id]->rrc_ue_head)){ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, ue_context_p->ue_context.rnti, flexran_get_current_frame(mod_id), flexran_get_current_subframe (mod_id), mod_id); diff --git a/openair2/ENB_APP/flexran_agent_defs.h b/openair2/ENB_APP/flexran_agent_defs.h index 2de19e59aa..dc86a422c4 100644 --- a/openair2/ENB_APP/flexran_agent_defs.h +++ b/openair2/ENB_APP/flexran_agent_defs.h @@ -138,11 +138,24 @@ typedef enum { FLEXRAN_AGENT_TIMER_STATE_MAX, } flexran_agent_timer_state_t; - +#define FLEXRAN_CAP_LOL1 0x1 +#define FLEXRAN_CAP_HIL1 0x2 +#define FLEXRAN_CAP_LOL2 0x4 // is: MAC +#define FLEXRAN_CAP_HIL2 0x8 // is: RLC +#define FLEXRAN_CAP_PDCP 0x16 +#define FLEXRAN_CAP_RRC 0x32 typedef struct { /* general info */ - + char *interface_name; + char *remote_ipv4_addr; + uint16_t remote_port; + char *cache_name; + uint8_t await_reconf; + + int enb_id; + uint8_t capability_mask; + /* stats */ uint32_t total_rx_msg; @@ -200,10 +213,4 @@ typedef struct stats_request_config_s{ report_config_t *config; } stats_request_config_t; -typedef struct { - mid_t enb_id; - flexran_agent_info_t agent_info; - -} flexran_agent_instance_t; - #endif diff --git a/openair2/ENB_APP/flexran_agent_extern.h b/openair2/ENB_APP/flexran_agent_extern.h index 8e9fef383d..589975b310 100644 --- a/openair2/ENB_APP/flexran_agent_extern.h +++ b/openair2/ENB_APP/flexran_agent_extern.h @@ -34,11 +34,7 @@ #include "flexran_agent_mac_defs.h" #include "flexran_agent_rrc_defs.h" #include "flexran_agent_pdcp_defs.h" - -//extern msg_context_t shared_ctxt[NUM_MAX_ENB][FLEXRAN_AGENT_MAX]; - -/* full path of the local cache for storing VSFs */ -extern char local_cache[40]; +#include "common/ran_context.h" /* Control module interface for the communication of the MAC Control Module with the agent */ extern AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]; From ab3f9dad492e11c9730e911e7876984b86a76c26 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 10 Jan 2018 15:52:02 +0100 Subject: [PATCH 068/141] add flexran sample config --- .../CONF/enb.band7.tm1.50PRB.usrpb210.conf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf index ff302811e9..b35b6147cd 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf @@ -189,6 +189,15 @@ RUs = ( } ); +NETWORK_CONTROLLER : +{ + FLEXRAN_INTERFACE_NAME = "lo"; + FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; + FLEXRAN_PORT = 2210; + FLEXRAN_CACHE = "/mnt/oai_agent_cache"; + FLEXRAN_AWAIT_RECONF = "no"; +}; + log_config : { global_log_level ="info"; From 6198a673f040e4c5f19005786a61942793ecbc8f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 11 Jan 2018 15:14:40 +0100 Subject: [PATCH 069/141] correctly instantiate flexran agent --- targets/RT/USER/lte-softmodem.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index ed1e708689..315eee23cd 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1268,7 +1268,9 @@ int main( int argc, char **argv ) pthread_mutex_init(&mutex_node_ctrl, NULL); pthread_cond_init(&cond_node_ctrl, NULL); - for (i = 0; i < NB_eNB_INST; i++) { + /* create RC.flexran data structure */ + RCconfig_flexran(); + for (i = 0; i < RC.nb_L1_inst; i++) { flexran_agent_start(i); } @@ -1279,11 +1281,12 @@ int main( int argc, char **argv ) pthread_mutex_unlock(&mutex_node_ctrl); /* reconfigure eNB in case FlexRAN controller applied changes */ - for (i=0; i < NB_eNB_INST; i++){ - LOG_I(ENB_APP, "Reconfigure eNB module %d and FlexRAN eNB variables\n", i); - reconfigure_enb_params(i); - flexran_set_enb_vars(i, RAN_LTE_OAI); - } + /* TODO needs to be done? */ + //for (i=0; i < NB_eNB_INST; i++){ + // LOG_I(ENB_APP, "Reconfigure eNB module %d and FlexRAN eNB variables\n", i); + // reconfigure_enb_params(i); + // flexran_set_enb_vars(i, RAN_LTE_OAI); + //} #endif if (UE_flag==1) { From cdbf65f5afdb69d26105635c047e76a902475d48 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 12 Jan 2018 09:43:33 +0100 Subject: [PATCH 070/141] revise RAN API - when changing values RC.rrc[i]->configuration should be changed too - then, RRC_RECONFIGURATION_REQ will pass the changed conf down until PHY - give warnings at functions that are not implemented - rename functions flexran_get_tdd_ack_nack_feedback() -> flexran_get_tdd_ack_nack_feedback_mode() flexran_get_ue_pmi() -> flexran_get_ue_wpmi() --- openair2/ENB_APP/flexran_agent_ran_api.c | 1626 ++++++++++------------ openair2/ENB_APP/flexran_agent_ran_api.h | 214 +-- 2 files changed, 811 insertions(+), 1029 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 16462b4d40..af1d1be63d 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -21,237 +21,196 @@ /*! \file flexran_agent_ran_api.c * \brief FlexRAN RAN API abstraction - * \author N. Nikaein, X. Foukas and S. SHARIAT BAGHERI + * \author N. Nikaein, X. Foukas, S. SHARIAT BAGHERI and R. Schmidt * \date 2017 * \version 0.1 */ #include "flexran_agent_ran_api.h" - /* * generic info from RAN */ +PHY_VARS_eNB *phy[NUM_MAX_ENB][MAX_NUM_CCs] = { NULL }; +eNB_MAC_INST *mac[NUM_MAX_ENB] = { NULL }; +eNB_RRC_INST *rrc[NUM_MAX_ENB] = { NULL }; +UE_list_t *UE_list[NUM_MAX_ENB] = { NULL }; - -void * enb[NUM_MAX_ENB]; -void * enb_ue[NUM_MAX_ENB]; -void * enb_rrc[NUM_MAX_ENB]; -Enb_properties_array_t* enb_properties; - -void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran){ - - switch (ran){ - case RAN_LTE_OAI : - enb_properties = enb_config_get(); - if(eNB_mac_inst == NULL){ - enb[mod_id] = NULL; - enb_ue[mod_id] = NULL; - enb_rrc[mod_id] = NULL; - }else{ - enb[mod_id] = (void *)&eNB_mac_inst[mod_id]; - enb_ue[mod_id] = (void *)&eNB_mac_inst[mod_id].UE_list; - enb_rrc[mod_id] = (void *)&eNB_rrc_inst[mod_id]; +void flexran_set_RC_vars(mid_t mod_id, ran_name_t ran) +{ + int i; + if (ran == RAN_LTE_OAI) { + if (RC.eNB && mod_id < RC.nb_RU && RC.eNB[mod_id] && RC.nb_CC) + for (i = 0; i < *RC.nb_CC; i++) + phy[mod_id][i] = RC.eNB[mod_id][i]; + if (RC.mac && mod_id < RC.nb_macrlc_inst && RC.mac[mod_id]) { + mac[mod_id] = RC.mac[mod_id]; + UE_list[mod_id] = &RC.mac[mod_id]->UE_list; } - break; - default : - goto error; - } - - return; - - error: - LOG_E(FLEXRAN_AGENT, "unknown RAN name %d\n", ran); -} - -static int mac_xface_not_ready(void) -{ - if (mac_xface == NULL) { - return 1; + if (RC.rrc && mod_id < RC.nb_macrlc_inst && RC.rrc[mod_id]) + rrc[mod_id] = RC.rrc[mod_id]; } else { - //printf("max_xface %p %d \n", mac_xface, mac_xface->active); - return 0;// !mac_xface->active; + LOG_E(FLEXRAN_AGENT, "unknown RAN name %d when setting RAN API variables\n", ran); } } -static int eNB_rrc_inst_not_ready(void) +uint32_t flexran_get_current_time_ms(mid_t mod_id, int subframe_flag) { - if (NULL == eNB_rrc_inst) { - return 1; - } - else { - return 0; - } + if (!mac[mod_id]) return 0; + if (subframe_flag == 1) + return mac[mod_id]->frame*10 + mac[mod_id]->subframe; + else + return mac[mod_id]->frame*10; } -int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag){ - if (enb[mod_id] == NULL) return 0; - if (subframe_flag == 1){ - return ((eNB_MAC_INST *)enb[mod_id])->frame*10 + ((eNB_MAC_INST *)enb[mod_id])->subframe; - }else { - return ((eNB_MAC_INST *)enb[mod_id])->frame*10; - } - -} - -unsigned int flexran_get_current_frame (mid_t mod_id) { - if (enb[mod_id] == NULL) return 0; +frame_t flexran_get_current_frame(mid_t mod_id) +{ + if (!mac[mod_id]) return 0; // #warning "SFN will not be in [0-1023] when oaisim is used" - return ((eNB_MAC_INST *)enb[mod_id])->frame; - + return mac[mod_id]->frame; } -unsigned int flexran_get_current_system_frame_num(mid_t mod_id) { - return (flexran_get_current_frame(mod_id) %1024); +frame_t flexran_get_current_system_frame_num(mid_t mod_id) +{ + return flexran_get_current_frame(mod_id) % 1024; } -unsigned int flexran_get_current_subframe (mid_t mod_id) { - if (enb[mod_id] == NULL) return 0; - return ((eNB_MAC_INST *)enb[mod_id])->subframe; - +sub_frame_t flexran_get_current_subframe(mid_t mod_id) +{ + if (!mac[mod_id]) return 0; + return mac[mod_id]->subframe; } -uint16_t flexran_get_sfn_sf (mid_t mod_id) { - - frame_t frame; - sub_frame_t subframe; +/* Why uint16_t, frame_t and sub_frame_t are defined as uint32_t? */ +uint16_t flexran_get_sfn_sf(mid_t mod_id) +{ + frame_t frame = flexran_get_current_system_frame_num(mod_id); + sub_frame_t subframe = flexran_get_current_subframe(mod_id); uint16_t sfn_sf, frame_mask, sf_mask; - - frame = (frame_t) flexran_get_current_system_frame_num(mod_id); - subframe = (sub_frame_t) flexran_get_current_subframe(mod_id); - frame_mask = ((1<<12) - 1); - sf_mask = ((1<<4) - 1); + + frame_mask = (1 << 12) - 1; + sf_mask = (1 << 4) - 1; sfn_sf = (subframe & sf_mask) | ((frame & frame_mask) << 4); - + return sfn_sf; } -uint16_t flexran_get_future_sfn_sf (mid_t mod_id, int ahead_of_time) { - - frame_t frame; - sub_frame_t subframe; +uint16_t flexran_get_future_sfn_sf(mid_t mod_id, int ahead_of_time) +{ + frame_t frame = flexran_get_current_system_frame_num(mod_id); + sub_frame_t subframe = flexran_get_current_subframe(mod_id); uint16_t sfn_sf, frame_mask, sf_mask; - - frame = (frame_t) flexran_get_current_system_frame_num(mod_id); - subframe = (sub_frame_t) flexran_get_current_subframe(mod_id); + int additional_frames; - subframe = ((subframe + ahead_of_time) % 10); - - if (subframe < flexran_get_current_subframe(mod_id)) { + subframe = (subframe + ahead_of_time) % 10; + + if (subframe < flexran_get_current_subframe(mod_id)) frame = (frame + 1) % 1024; - } - - int additional_frames = ahead_of_time / 10; + + additional_frames = ahead_of_time / 10; frame = (frame + additional_frames) % 1024; - - frame_mask = ((1<<12) - 1); - sf_mask = ((1<<4) - 1); + + frame_mask = (1 << 12) - 1; + sf_mask = (1 << 4) - 1; sfn_sf = (subframe & sf_mask) | ((frame & frame_mask) << 4); - + return sfn_sf; } -int flexran_get_num_ues (mid_t mod_id){ - if (enb_ue[mod_id] == NULL) return 0; - return ((UE_list_t *)enb_ue[mod_id])->num_UEs; +int flexran_get_num_ues(mid_t mod_id) +{ + if (!UE_list[mod_id]) return 0; + return UE_list[mod_id]->num_UEs; } -int flexran_get_ue_crnti (mid_t mod_id, mid_t ue_id) { - - return UE_RNTI(mod_id, ue_id); +rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id) +{ + return UE_RNTI(mod_id, ue_id); } -int flexran_get_ue_bsr (mid_t mod_id, mid_t ue_id, lcid_t lcid) { - if (enb_ue[mod_id] == NULL) return 0; - return ((UE_list_t *)enb_ue[mod_id])->UE_template[UE_PCCID(mod_id,ue_id)][ue_id].bsr_info[lcid]; +uint8_t flexran_get_ue_bsr(mid_t mod_id, mid_t ue_id, lcid_t lcid) +{ + if (!UE_list[mod_id]) return 0; + return UE_list[mod_id]->UE_template[UE_PCCID(mod_id, ue_id)][ue_id].bsr_info[lcid]; } -int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id) { - if (enb_ue[mod_id] == NULL) return 0; - return ((UE_list_t *)enb_ue[mod_id])->UE_template[UE_PCCID(mod_id,ue_id)][ue_id].phr_info; +int8_t flexran_get_ue_phr(mid_t mod_id, mid_t ue_id) +{ + if (!UE_list[mod_id]) return 0; + return UE_list[mod_id]->UE_template[UE_PCCID(mod_id, ue_id)][ue_id].phr_info; } -int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - if (mac_xface_not_ready()) return 0 ; - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, 0, UE_RNTI(mod_id, ue_id)); - return eNB_UE_stats->DL_cqi[0]; - - // return ((UE_list_t *)enb_ue[mod_id])->eNB_UE_stats[UE_PCCID(mod_id,ue_id)][ue_id].dl_cqi; +uint8_t flexran_get_ue_wcqi(mid_t mod_id, mid_t ue_id) +{ + if (!phy[mod_id][0]) return 0; + return phy[mod_id][0]->UE_stats[ue_id].DL_cqi[0]; } -int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); - uint16_t subframe = (uint16_t) flexran_get_current_subframe(mod_id); +rlc_buffer_occupancy_t flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) +{ + rnti_t rnti = flexran_get_ue_crnti(mod_id, ue_id); + frame_t frame = flexran_get_current_frame(mod_id); + sub_frame_t subframe = flexran_get_current_subframe(mod_id); mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); return rlc_status.bytes_in_buffer; } - -int flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { +rlc_buffer_occupancy_t flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) +{ rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); - uint16_t subframe = (uint16_t) flexran_get_current_subframe(mod_id); + frame_t frame = flexran_get_current_frame(mod_id); + sub_frame_t subframe = flexran_get_current_subframe(mod_id); mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); return rlc_status.pdus_in_buffer; } - - -int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { +frame_t flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) +{ rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); - uint16_t subframe = (uint16_t) flexran_get_current_subframe(mod_id); + frame_t frame = flexran_get_current_frame(mod_id); + sub_frame_t subframe = flexran_get_current_subframe(mod_id); mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, subframe, ENB_FLAG_YES, MBMS_FLAG_NO, channel_id, 0); return rlc_status.head_sdu_creation_time; } -short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id) { - - // UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; - int rnti; +int32_t flexran_get_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; - rnti = flexran_get_ue_crnti(mod_id, ue_id); - if (mac_xface_not_ready()) return 0 ; - - LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - //ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY - switch (flexran_get_N_RB_DL(mod_id, CC_id)) { + int32_t tau = phy[mod_id][cc_id]->UE_stats[ue_id].timing_advance_update; + switch (flexran_get_N_RB_DL(mod_id, cc_id)) { case 6: - return eNB_UE_stats->timing_advance_update; + return tau; case 15: - return eNB_UE_stats->timing_advance_update/2; + return tau / 2; case 25: - return eNB_UE_stats->timing_advance_update/4; + return tau / 4; case 50: - return eNB_UE_stats->timing_advance_update/8; + return tau / 8; case 75: - return eNB_UE_stats->timing_advance_update/12; + return tau / 12; case 100: - if (flexran_get_threequarter_fs(mod_id, CC_id) == 0) { - return eNB_UE_stats->timing_advance_update/16; - } else { - return eNB_UE_stats->timing_advance_update/12; - } + if (flexran_get_threequarter_fs(mod_id, cc_id) == 0) + return tau / 16; + else + return tau / 12; default: return 0; } } -int flexran_get_ue_pmi(mid_t mod_id){ - - /*Xenofon to check this*/ - - return 0; +uint8_t flexran_get_ue_wpmi(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ + if (!UE_list[mod_id]) return 0; + return UE_list[mod_id]->UE_sched_ctrl[ue_id].periodic_wideband_pmi[cc_id]; } - -void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id) { - +/* TODO needs to be revised */ +void flexran_update_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ +/* UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[ue_id]; @@ -268,92 +227,79 @@ void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id) { ue_sched_ctl->ta_timer--; ue_sched_ctl->ta_update = 0; // don't trigger a timing advance command } +*/ +#warning "Implement flexran_update_TA() in RAN API" } -int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id,int CC_id) { - - // UE_list_t *UE_list = &eNB_mac_inst[mod_id].UE_list; - - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - if (mac_xface_not_ready()) return 0 ; +/* TODO needs to be revised, looks suspicious: why do we need UE stats? */ +int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ +#warning "Implement flexran_get_MAC_CE_bitmap_TA() in RAN API" + if (!phy[mod_id][cc_id]) return 0; + /* UE_stats can not be null, they are an array in RC LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); if (eNB_UE_stats == NULL) { return 0; } + */ - if (flexran_get_TA(mod_id, ue_id, CC_id) != 0) { + if (flexran_get_TA(mod_id, ue_id, cc_id) != 0) { return PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; } else { return 0; } - } -int flexran_get_active_CC(mid_t mod_id, mid_t ue_id) { - if (enb_ue[mod_id] == NULL) return 0; - return ((UE_list_t *)enb_ue[mod_id])->numactiveCCs[ue_id]; +int flexran_get_active_CC(mid_t mod_id, mid_t ue_id) +{ + if (!UE_list[mod_id]) return 0; + return UE_list[mod_id]->numactiveCCs[ue_id]; } -int flexran_get_current_RI(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - if (mac_xface_not_ready()) return 0 ; - - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); - - if (eNB_UE_stats == NULL) { - return 0; - } - - return eNB_UE_stats[CC_id].rank; +uint8_t flexran_get_current_RI(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->UE_stats[ue_id].rank; } -int flexran_get_tpc(mid_t mod_id, mid_t ue_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - int32_t normalized_rx_power, target_rx_power; - int tpc = 1; +int flexran_get_tpc(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; - int pCCid = UE_PCCID(mod_id,ue_id); - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - if (mac_xface_not_ready()) return 0 ; + /* before: tested that UL_rssi != NULL and set parameter ([0]), but it is a + * static array -> target_rx_power is useless in old ifs?! */ + int pCCid = UE_PCCID(mod_id,ue_id); + int32_t target_rx_power = phy[mod_id][pCCid]->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; + int32_t normalized_rx_power = phy[mod_id][cc_id]->UE_stats[ue_id].UL_rssi[0]; - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, pCCid, rnti); - - target_rx_power = mac_xface->get_target_pusch_rx_power(mod_id,pCCid); - - if (eNB_UE_stats == NULL) { - normalized_rx_power = target_rx_power; - } else if (eNB_UE_stats->UL_rssi != NULL) { - normalized_rx_power = eNB_UE_stats->UL_rssi[0]; - } else { - normalized_rx_power = target_rx_power; - } - - if (normalized_rx_power>(target_rx_power+1)) { - tpc = 0; //-1 - } else if (normalized_rx_power<(target_rx_power-1)) { - tpc = 2; //+1 - } else { - tpc = 1; //0 - } - return tpc; + int tpc; + if (normalized_rx_power > target_rx_power + 1) + tpc = 0; //-1 + else if (normalized_rx_power < target_rx_power - 1) + tpc = 2; //+1 + else + tpc = 1; //0 + return tpc; } -int flexran_get_harq(const mid_t mod_id, - const uint8_t CC_id, - const mid_t ue_id, - const int frame, - const uint8_t subframe, - uint8_t *pid, - uint8_t *round, - const uint8_t harq_flag) { //flag_id_status = 0 then id, else status - /*TODO: Add int TB in function parameters to get the status of the second TB. This can be done to by editing in - * get_ue_active_harq_pid function in line 272 file: phy_procedures_lte_eNB.c to add - * DLSCH_ptr = PHY_vars_eNB_g[Mod_id][CC_id]->dlsch_eNB[(uint32_t)UE_id][1];*/ +int flexran_get_harq(mid_t mod_id, + uint8_t cc_id, + mid_t ue_id, + frame_t frame, + sub_frame_t subframe, + uint8_t *pid, + uint8_t *round, + uint8_t harq_flag) +{ + /* TODO: Add int TB in function parameters to get the status of the second + * TB. This can be done to by editing in get_ue_active_harq_pid function in + * line 272 file: phy_procedures_lte_eNB.c to add DLSCH_ptr = + * PHY_vars_eNB_g[Mod_id][CC_id]->dlsch_eNB[(uint32_t)UE_id][1];*/ + /* TODO IMPLEMENT */ + /* uint8_t harq_pid; uint8_t harq_round; @@ -375,61 +321,39 @@ int flexran_get_harq(const mid_t mod_id, *pid = harq_pid; - *round = harq_round; + *round = harq_round;*/ /* if (round > 0) { */ /* *status = 1; */ /* } else { */ /* *status = 0; */ /* } */ - - /* return 0; */ - return *round; + /*return *round;*/ +#warning "Implement flexran_get_harq() in RAN API" + return 0; } -int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - if (mac_xface_not_ready()) return 0 ; - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - - if (eNB_UE_stats == NULL) { - return -1; - } - - // if(eNB_UE_stats->Po_PUCCH_update == 1) { - return eNB_UE_stats->Po_PUCCH_dBm; - //} - //else - // return -1; +int32_t flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_dBm; } -int flexran_get_p0_nominal_pucch(mid_t mod_id, int CC_id) { - if (mac_xface_not_ready()) return 0 ; - - int32_t pucch_rx_received = mac_xface->get_target_pucch_rx_power(mod_id, CC_id); - return pucch_rx_received; +int8_t flexran_get_p0_nominal_pucch(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.ul_power_control_config_common.p0_NominalPUCCH; } -int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id) { - if (mac_xface_not_ready()) return 0 ; - - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - return eNB_UE_stats->Po_PUCCH_update; +int32_t flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_update; } -int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id) { - if (mac_xface_not_ready()) return 0 ; - - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - eNB_UE_stats->Po_PUCCH_update = 0; - +int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + phy[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_update = 0; return 0; } @@ -439,243 +363,206 @@ int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id) { * Get Messages for eNB Configuration Reply * ************************************ */ -int flexran_get_threequarter_fs(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->threequarter_fs; +uint8_t flexran_get_threequarter_fs(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.threequarter_fs; } -int flexran_get_hopping_offset(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pusch_config_common.pusch_HoppingOffset; +uint8_t flexran_get_hopping_offset(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.pusch_config_common.pusch_HoppingOffset; } -int flexran_get_hopping_mode(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pusch_config_common.hoppingMode; +PUSCH_HOPPING_t flexran_get_hopping_mode(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.pusch_config_common.hoppingMode; } -int flexran_get_n_SB(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pusch_config_common.n_SB; +uint8_t flexran_get_n_SB(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.pusch_config_common.n_SB; } -int flexran_get_enable64QAM(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pusch_config_common.enable64QAM; +uint8_t flexran_get_enable64QAM(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.pusch_config_common.enable64QAM; } -int flexran_get_phich_duration(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->phich_config_common.phich_duration; +PHICH_DURATION_t flexran_get_phich_duration(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.phich_config_common.phich_duration; } -int flexran_get_phich_resource(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - if(frame_parms->phich_config_common.phich_resource == oneSixth) - return 0; - else if(frame_parms->phich_config_common.phich_resource == half) - return 1; - else if(frame_parms->phich_config_common.phich_resource == one) - return 2; - else if(frame_parms->phich_config_common.phich_resource == two) - return 3; - - return -1; +int flexran_get_phich_resource(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + /* TODO why don't we return phich_resource? */ + switch (phy[mod_id][cc_id]->frame_parms.phich_config_common.phich_resource) { + case oneSixth: + return 0; + case half: + return 1; + case one: + return 2; + case two: + return 3; + default: + return -1; + } } -int flexran_get_n1pucch_an(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pucch_config_common.n1PUCCH_AN; +uint16_t flexran_get_n1pucch_an(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.pucch_config_common.n1PUCCH_AN; } -int flexran_get_nRB_CQI(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pucch_config_common.nRB_CQI; +uint8_t flexran_get_nRB_CQI(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.pucch_config_common.nRB_CQI; } -int flexran_get_deltaPUCCH_Shift(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->pucch_config_common.deltaPUCCH_Shift; +uint8_t flexran_get_deltaPUCCH_Shift(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.pucch_config_common.deltaPUCCH_Shift; } -int flexran_get_prach_ConfigIndex(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; +uint8_t flexran_get_prach_ConfigIndex(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex; } -int flexran_get_prach_FreqOffset(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset; +uint8_t flexran_get_prach_FreqOffset(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; } -int flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->maxHARQ_Msg3Tx; +uint8_t flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.maxHARQ_Msg3Tx; } -int flexran_get_ul_cyclic_prefix_length(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->Ncp_UL; +lte_prefix_type_t flexran_get_ul_cyclic_prefix_length(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.Ncp_UL; } -int flexran_get_dl_cyclic_prefix_length(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->Ncp; +lte_prefix_type_t flexran_get_dl_cyclic_prefix_length(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.Ncp; } -int flexran_get_cell_id(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - - if (mac_xface_not_ready()) return 0; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->Nid_cell; +uint16_t flexran_get_cell_id(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.Nid_cell; } -int flexran_get_srs_BandwidthConfig(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->soundingrs_ul_config_common.srs_BandwidthConfig; +uint8_t flexran_get_srs_BandwidthConfig(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_BandwidthConfig; } -int flexran_get_srs_SubframeConfig(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->soundingrs_ul_config_common.srs_SubframeConfig; +uint8_t flexran_get_srs_SubframeConfig(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_SubframeConfig; } -int flexran_get_srs_MaxUpPts(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->soundingrs_ul_config_common.srs_MaxUpPts; +uint8_t flexran_get_srs_MaxUpPts(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_MaxUpPts; } -int flexran_get_N_RB_DL(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->N_RB_DL; +uint8_t flexran_get_N_RB_DL(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.N_RB_DL; } -int flexran_get_N_RB_UL(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->N_RB_UL; +uint8_t flexran_get_N_RB_UL(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.N_RB_UL; } -int flexran_get_N_RBG(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->N_RBG; +uint8_t flexran_get_N_RBG(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.N_RBG; } -int flexran_get_subframe_assignment(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return frame_parms->tdd_config; +uint8_t flexran_get_subframe_assignment(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.tdd_config; } -int flexran_get_special_subframe_assignment(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return (frame_parms == NULL)? 0:frame_parms->tdd_config_S; +uint8_t flexran_get_special_subframe_assignment(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.tdd_config_S; } -int flexran_get_ra_ResponseWindowSize(mid_t mod_id, int CC_id) { - return enb_config_get()->properties[mod_id]->rach_raResponseWindowSize[CC_id]; +long flexran_get_ra_ResponseWindowSize(mid_t mod_id, uint8_t cc_id) +{ + if (!rrc[mod_id]) return 0; + return rrc[mod_id]->configuration.rach_raResponseWindowSize[cc_id]; } -int flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, int CC_id) { - return enb_config_get()->properties[mod_id]->rach_macContentionResolutionTimer[CC_id]; +long flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, uint8_t cc_id) +{ + if (!rrc[mod_id]) return 0; + return rrc[mod_id]->configuration.rach_macContentionResolutionTimer[cc_id]; } -int flexran_get_duplex_mode(mid_t mod_id, int CC_id) { - LTE_DL_FRAME_PARMS *frame_parms; - if (mac_xface_not_ready()) return 0 ; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - if (frame_parms == NULL) return -1; - if(frame_parms->frame_type == TDD) - return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD; - else if (frame_parms->frame_type == FDD) - return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_FDD; - - return -1; +Protocol__FlexDuplexMode flexran_get_duplex_mode(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + switch (phy[mod_id][cc_id]->frame_parms.frame_type) { + case TDD: + return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD; + case FDD: + return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_FDD; + default: + return -1; + } } -long flexran_get_si_window_length(mid_t mod_id, int CC_id) { - return ((eNB_RRC_INST *)enb_rrc[mod_id])->carrier[CC_id].sib1->si_WindowLength; +long flexran_get_si_window_length(mid_t mod_id, uint8_t cc_id) +{ + if (!rrc[mod_id] || !rrc[mod_id]->carrier[cc_id].sib1) return 0; + return rrc[mod_id]->carrier[cc_id].sib1->si_WindowLength; } -int flexran_get_sib1_length(mid_t mod_id, int CC_id) { - return ((eNB_RRC_INST *)enb_rrc[mod_id])->carrier[CC_id].sizeof_SIB1; +uint8_t flexran_get_sib1_length(mid_t mod_id, uint8_t cc_id) +{ + if (!rrc[mod_id]) return 0; + return rrc[mod_id]->carrier[cc_id].sizeof_SIB1; } -int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id) { - /* TODO: This should return the number of PDCCH symbols initially used by the cell CC_id */ - return 0; - //(PHY_vars_UE_g[mod_id][CC_id]->lte_ue_pdcch_vars[mod_id]->num_pdcch_symbols); +uint8_t flexran_get_num_pdcch_symb(mid_t mod_id, uint8_t cc_id) { + /* TODO: This should return the number of PDCCH symbols initially used by the + * cell cc_id -> is the correction right? */ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->pdcch_vars[0].num_pdcch_symbols; + //(PHY_vars_UE_g[mod_id][cc_id]->lte_ue_pdcch_vars[mod_id]->num_pdcch_symbols); } @@ -687,98 +574,86 @@ int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id) { */ -int flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +TimeAlignmentTimer_t flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL) { - return ue_context_p->ue_context.mac_MainConfig->timeAlignmentTimerDedicated; - } else { - return -1; - } - } else { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.mac_MainConfig) return -1; + return ue_context_p->ue_context.mac_MainConfig->timeAlignmentTimerDedicated; +} + +Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.measGapConfig) return -1; + if (ue_context_p->ue_context.measGapConfig->present != MeasGapConfig_PR_setup) return -1; + switch (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present) { + case MeasGapConfig__setup__gapOffset_PR_gp0: + return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_GP1; + case MeasGapConfig__setup__gapOffset_PR_gp1: + return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_GP2; + default: + return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF; + } +} + + +long flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.measGapConfig) return -1; + if (ue_context_p->ue_context.measGapConfig->present != MeasGapConfig_PR_setup) return -1; + switch (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present) { + case MeasGapConfig__setup__gapOffset_PR_gp0: + return ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.choice.gp0; + case MeasGapConfig__setup__gapOffset_PR_gp1: + return ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.choice.gp1; + default: return -1; } } -int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +/* TODO is there a reason we take the RNTI and not the UE ID? */ +/* TODO return type is unsigned, so we cannot return -1 in case of error! */ +uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti) +{ + if (!rrc[mod_id]) return 0; - if (eNB_rrc_inst_not_ready()) return -1; + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measGapConfig != NULL) { - if(ue_context_p->ue_context.measGapConfig->present == MeasGapConfig_PR_setup) { - if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0) { - return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_GP1; - } else if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1) { - return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_GP2; - } else { - return PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF; - } - } - } - } - return -1; + if (!ue_context_p) return RRC_INACTIVE; + return ue_context_p->ue_context.Status; } - -int flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measGapConfig != NULL){ - if(ue_context_p->ue_context.measGapConfig->present == MeasGapConfig_PR_setup) { - if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0) { - return ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.choice.gp0; - } else if (ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1) { - return ue_context_p->ue_context.measGapConfig->choice.setup.gapOffset.choice.gp0; - } - } - } - } - return -1; +uint64_t flexran_get_ue_aggregated_max_bitrate_dl(mid_t mod_id, mid_t ue_id) +{ + if (!UE_list[mod_id]) return 0; + return UE_list[mod_id]->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateDL; } - -int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP){ - - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if (ue_context_p != NULL) { - return(ue_context_p->ue_context.Status); - } else { - return RRC_INACTIVE; - } - +uint64_t flexran_get_ue_aggregated_max_bitrate_ul(mid_t mod_id, mid_t ue_id) +{ + if (!UE_list[mod_id]) return 0; + return UE_list[mod_id]->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL; } -int flexran_get_ue_aggregated_max_bitrate_dl (mid_t mod_id, mid_t ue_id) { - if (enb_ue[mod_id] == NULL) return 0; - return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateDL; -} - -int flexran_get_ue_aggregated_max_bitrate_ul (mid_t mod_id, mid_t ue_id) { - if (enb_ue[mod_id] == NULL) return 0; - return ((UE_list_t *)enb_ue[mod_id])->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL; -} - -int flexran_get_half_duplex(mid_t ue_id) { +int flexran_get_half_duplex(mid_t ue_id) +{ +#warning "Implement flexran_get_half_duplex() in RAN API" // TODO //int halfduplex = 0; //int bands_to_scan = ((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count; @@ -790,14 +665,18 @@ int flexran_get_half_duplex(mid_t ue_id) { return 0; } -int flexran_get_intra_sf_hopping(mid_t ue_id) { +int flexran_get_intra_sf_hopping(mid_t ue_id) +{ +#warning "Implement flexran_get_intra_sf_hopping() in RAN API" //TODO:Get proper value //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); //return (0 & ( 1 << (31))); return 0; } -int flexran_get_type2_sb_1(mid_t ue_id) { +int flexran_get_type2_sb_1(mid_t ue_id) +{ +#warning "Implement flexran_get_type2_sb_1() in RAN API" //TODO:Get proper value //uint8_t temp = 0; //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); @@ -805,13 +684,17 @@ int flexran_get_type2_sb_1(mid_t ue_id) { return 0; } -int flexran_get_ue_category(mid_t ue_id) { +int flexran_get_ue_category(mid_t ue_id) +{ +#warning "Implement flexran_get_ue_category() in RAN API" //TODO:Get proper value //return (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->ue_Category); return 0; } -int flexran_get_res_alloc_type1(mid_t ue_id) { +int flexran_get_res_alloc_type1(mid_t ue_id) +{ +#warning "Implement flexran_get_res_alloc_type1() in RAN API" //TODO:Get proper value //uint8_t temp = 0; //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); @@ -819,313 +702,291 @@ int flexran_get_res_alloc_type1(mid_t ue_id) { return 0; } -int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +long flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode; - } else { - return -1; - } - } else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->antennaInfo) return -1; + return ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode; } -int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL){ - return ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->ttiBundling; - } else { - return -1; - } - } - else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.mac_MainConfig) return -1; + if (!ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config) return -1; + return ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->ttiBundling; } -int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +long flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL){ - return *ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; - } - } - return -1; + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.mac_MainConfig) return -1; + if (!ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config) return -1; + return *(ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->maxHARQ_Tx); } -int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +long flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; - } else { - return -1; - } - } else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated) return -1; + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; } -int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +long flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; - } else { - return -1; - } - } else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated) return -1; + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; } -int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +long flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; - } else { - return -1; - } - } - else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated) return -1; + return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; } -int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - if (ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic != NULL) { - return ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI; - } - } - } - return -1; + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic) return -1; + return ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI; } -int flexran_get_ack_nack_simultaneous_trans(mid_t mod_id,mid_t ue_id) { - - if (eNB_rrc_inst_not_ready()) return -1; - - return (&eNB_rrc_inst[mod_id])->carrier[0].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; +BOOLEAN_t flexran_get_ack_nack_simultaneous_trans(mid_t mod_id, mid_t ue_id, uint8_t cc_id) +{ + if (!rrc[mod_id]) return -1; + if (!rrc[mod_id]->carrier[cc_id].sib2) return -1; + return rrc[mod_id]->carrier[cc_id].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; } -int flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +CQI_ReportModeAperiodic_t flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return *ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; - } - } - return -1; + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig) return -1; + return *ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; } -int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id) { - // TODO: This needs fixing - return -1; +long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - /* if (eNB_rrc_inst_not_ready()) return -1; */ + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - /* struct rrc_eNB_ue_context_s* ue_context_p = NULL; */ - /* uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); */ - - /* ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); */ - - /* if(ue_context_p != NULL) { */ - /* if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ */ - /* return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode; */ - /* } else { */ - /* return -1; */ - /* } */ - /* } else { */ - /* return -1; */ - /* } */ + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode) return -1; + return *(ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode); } -int flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +long flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.choice.setup.repetitionFactor; - } else { - return -1; - } - } else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated) return -1; + return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.choice.setup.repetitionFactor; } -int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) { - //TODO: need to double check - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.mac_MainConfig != NULL){ - if(ue_context_p->ue_context.mac_MainConfig->ext2 != NULL){ - long val = (*(ue_context_p->ue_context.mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10)); - if (val > 0) { - return 1; - } - } - } - } - return -1; + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.mac_MainConfig) return -1; + if (!ue_context_p->ue_context.mac_MainConfig->ext2) return -1; + if (!ue_context_p->ue_context.mac_MainConfig->ext2->mac_MainConfig_v1020) return -1; + return *(ue_context_p->ue_context.mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10); } -int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.physicalConfigDedicated != NULL){ - if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_closedLoop) { - return 2; - } else if(ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup == AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_openLoop) { - return 1; - } else { - return 0; - } - } else { - return -1; - } - } else { - return -1; - } -} - -int flexran_get_lcg(mid_t ue_id, mid_t lc_id) { - if (UE_mac_inst == NULL) { - return -1; - } - if(UE_mac_inst[ue_id].logicalChannelConfig[lc_id] != NULL) { - return *UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters->logicalChannelGroup; - } else { - return -1; - } -} - -int flexran_get_direction(mid_t ue_id, mid_t lc_id) { - /*TODO: fill with the value for the rest of LCID*/ - if(lc_id == DCCH || lc_id == DCCH1) { + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; + if (!ue_context_p->ue_context.physicalConfigDedicated->antennaInfo) return -1; + switch (ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.setup) { + case AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_closedLoop: return 2; - } else if(lc_id == DTCH) { + case AntennaInfoDedicated__ue_TransmitAntennaSelection__setup_openLoop: return 1; - } else { + default: + return 0; + } +} + +long flexran_get_lcg(mid_t ue_id, mid_t lc_id) +{ + if (!UE_mac_inst) return -1; + if (!UE_mac_inst[ue_id].logicalChannelConfig[lc_id]) return -1; + if (!UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters) return -1; + if (!UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters->logicalChannelGroup) return -1; + return *(UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters->logicalChannelGroup); +} + +int flexran_get_direction(mid_t ue_id, mid_t lc_id) +{ + /* TODO: fill with the value for the rest of LCID -> Robert: What does that + * mean? */ + switch (lc_id) { + case DCCH: + case DCCH1: + return 2; + case DTCH: + return 1; + default: return -1; } } -int flexran_get_antenna_ports(mid_t mod_id, int CC_id){ - - LTE_DL_FRAME_PARMS *frame_parms; - - if (mac_xface_not_ready()) return 0; - - frame_parms = mac_xface->get_lte_frame_parms(mod_id, CC_id); - return (frame_parms == NULL)? 0:frame_parms->nb_antenna_ports_eNB; - +uint8_t flexran_get_antenna_ports(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.nb_antenna_ports_eNB; } - -uint32_t flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id) { - - return (enb_properties->properties[mod_id]->downlink_frequency[cc_id] / 1000000); +/* TODO better give real value (without division)? */ +uint32_t flexran_agent_get_operating_dl_freq(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.dl_CarrierFreq / 1000000; } -uint32_t flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id) { - return ((enb_properties->properties[mod_id]->downlink_frequency[cc_id] + enb_properties->properties[0]->uplink_frequency_offset[cc_id]) / 1000000); +/* TODO better give real value (without division)? */ +uint32_t flexran_agent_get_operating_ul_freq(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.ul_CarrierFreq / 1000000; } -int flexran_agent_get_operating_eutra_band (mid_t mod_id, int cc_id) { - return enb_properties->properties[mod_id]->eutra_band[cc_id]; -} -int flexran_agent_get_operating_pdsch_refpower (mid_t mod_id, int cc_id) { - return enb_properties->properties[mod_id]->pdsch_referenceSignalPower[cc_id]; -} -int flexran_agent_get_operating_pusch_p0 (mid_t mod_id, int cc_id) { - return enb_properties->properties[mod_id]->pusch_p0_Nominal[cc_id]; +uint8_t flexran_agent_get_operating_eutra_band(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.eutra_band; } -void flexran_agent_set_operating_dl_freq (mid_t mod_id, int cc_id, uint32_t dl_freq_mhz) { - - enb_properties->properties[mod_id]->downlink_frequency[cc_id]=dl_freq_mhz * 1000000; - /*printf("[ENB_APP] mod id %d ccid %d dl freq %d/%d\n", mod_id, cc_id, dl_freq_mhz, enb_properties->properties[mod_id]->downlink_frequency[cc_id]); */ +int8_t flexran_agent_get_operating_pdsch_refpower(mid_t mod_id, uint8_t cc_id) +{ + if (!phy[mod_id][cc_id]) return 0; + return phy[mod_id][cc_id]->frame_parms.pdsch_config_common.referenceSignalPower; } -void flexran_agent_set_operating_ul_freq (mid_t mod_id, int cc_id, int32_t ul_freq_offset_mhz) { - enb_properties->properties[mod_id]->uplink_frequency_offset[cc_id]=ul_freq_offset_mhz * 1000000; -} -//TBD -void flexran_agent_set_operating_eutra_band (mid_t mod_id, int cc_id) { - enb_properties->properties[mod_id]->eutra_band[cc_id]=7; +long flexran_agent_get_operating_pusch_p0(mid_t mod_id, uint8_t cc_id) +{ + if (!rrc[mod_id]) return 0; + return rrc[mod_id]->configuration.pusch_p0_Nominal[cc_id]; } -void flexran_agent_set_operating_bandwidth (mid_t mod_id, int cc_id, int bandwidth) { - enb_properties->properties[mod_id]->N_RB_DL[cc_id]=bandwidth; +void flexran_agent_set_operating_dl_freq(mid_t mod_id, uint8_t cc_id, uint32_t dl_freq_mhz) +{ + if (phy[mod_id][cc_id]) { + phy[mod_id][cc_id]->frame_parms.dl_CarrierFreq = dl_freq_mhz * 1000000; + } + if (rrc[mod_id]) { + rrc[mod_id]->configuration.downlink_frequency[cc_id] = dl_freq_mhz * 1000000; + } } -void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_type) { - enb_properties->properties[mod_id]->frame_type[cc_id]=frame_type; +void flexran_agent_set_operating_ul_freq(mid_t mod_id, uint8_t cc_id, int32_t ul_freq_mhz_offset) +{ + if (phy[mod_id][cc_id]) { + uint32_t new_ul_freq_mhz = flexran_agent_get_operating_dl_freq(mod_id, cc_id) + ul_freq_mhz_offset; + phy[mod_id][cc_id]->frame_parms.ul_CarrierFreq = new_ul_freq_mhz * 1000000; + } + if (rrc[mod_id]) { + rrc[mod_id]->configuration.uplink_frequency_offset[cc_id] = ul_freq_mhz_offset; + } +} + +void flexran_agent_set_operating_eutra_band(mid_t mod_id, uint8_t cc_id, uint8_t eutra_band) +{ + if (phy[mod_id][cc_id]) { + phy[mod_id][cc_id]->frame_parms.eutra_band = eutra_band; + } + if (rrc[mod_id]) { + rrc[mod_id]->configuration.eutra_band[cc_id] = eutra_band; + } +} + +/* Sets both DL/UL */ +void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t N_RB) +{ + if (phy[mod_id][cc_id]) { + phy[mod_id][cc_id]->frame_parms.N_RB_DL = N_RB; + phy[mod_id][cc_id]->frame_parms.N_RB_UL = N_RB; + } + if (rrc[mod_id]) { + rrc[mod_id]->configuration.N_RB_DL[cc_id] = N_RB; + } +} + +void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type) +{ + if (phy[mod_id][cc_id]) { + phy[mod_id][cc_id]->frame_parms.frame_type = frame_type; + } + if (rrc[mod_id]) { + rrc[mod_id]->configuration.frame_type[cc_id] = frame_type; + } } /*********** PDCP *************/ @@ -1234,192 +1095,99 @@ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lc /******************** RRC *****************************/ -int flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +MeasId_t flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measResults != NULL) { - return ue_context_p->ue_context.measResults->measId; - } else { - return -1; - } - } else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.measResults) return -1; + return ue_context_p->ue_context.measResults->measId; } -int flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - if (eNB_rrc_inst_not_ready()) return -1; +float flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measResults != NULL) { - return RSRP_meas_mapping[ue_context_p->ue_context.measResults->measResultPCell.rsrpResult]; - } else { - return -1; - } - } else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.measResults) return -1; + return RSRP_meas_mapping[ue_context_p->ue_context.measResults->measResultPCell.rsrpResult]; } -int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); - if (eNB_rrc_inst_not_ready()) return -1; +float flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return -1; - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measResults != NULL) { - return RSRQ_meas_mapping[ue_context_p->ue_context.measResults->measResultPCell.rsrqResult]; - } else { - return -1; - } - } else { - return -1; - } + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.measResults) return -1; + return RSRQ_meas_mapping[ue_context_p->ue_context.measResults->measResultPCell.rsrqResult]; } /*Number of neighbouring cells for specific UE*/ -int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id) +{ + if (!rrc[mod_id]) return 0; - if (eNB_rrc_inst_not_ready()) return 0; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - if (ue_context_p->ue_context.measResults != NULL){ - - if(ue_context_p->ue_context.measResults->measResultNeighCells != NULL) { - - if (ue_context_p->ue_context.measResults->measResultNeighCells->present == MeasResults__measResultNeighCells_PR_measResultListEUTRA) { - - return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count; - } - else{ - - return 0; - } - - } else { - - return 0; - } - - } else { - - return 0; - - } - - } else { - return 0; - } - + if (!ue_context_p) return 0; + if (!ue_context_p->ue_context.measResults) return 0; + if (!ue_context_p->ue_context.measResults->measResultNeighCells) return 0; + if (ue_context_p->ue_context.measResults->measResultNeighCells->present != MeasResults__measResultNeighCells_PR_measResultListEUTRA) return 0; + return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count; } -int flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +PhysCellId_t flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measResults->measResultNeighCells != NULL) { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - if (ue_context_p->ue_context.measResults->measResultNeighCells->present == MeasResults__measResultNeighCells_PR_measResultListEUTRA) { - - return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->physCellId; - - } - else { - - return -1; - } - } else { - return -1; - } - } else { - return -1; - } + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.measResults) return -1; + if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1; + if (ue_context_p->ue_context.measResults->measResultNeighCells->present != MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1; + if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1; + return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->physCellId; } -int flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +float flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - if(ue_context_p->ue_context.measResults->measResultNeighCells != NULL) { - - if (ue_context_p->ue_context.measResults->measResultNeighCells->present == MeasResults__measResultNeighCells_PR_measResultListEUTRA) { - - if (ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult){ - return RSRP_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult)]; - - } - else { - - return 0; - } - - } - else { - - return -1; - } - - } - else { - return -1; - } - - } - else { - return -1; - } + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.measResults) return -1; + if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1; + if (ue_context_p->ue_context.measResults->measResultNeighCells->present != MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1; + if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]) return -1; + if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult) return 0; + return RSRP_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult)]; } -int flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - uint32_t rntiP = flexran_get_ue_crnti(mod_id,ue_id); +float flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id) +{ + if (!rrc[mod_id]) return -1; - if (eNB_rrc_inst_not_ready()) return -1; - - ue_context_p = rrc_eNB_get_ue_context(&eNB_rrc_inst[mod_id],rntiP); - if(ue_context_p != NULL) { - if(ue_context_p->ue_context.measResults->measResultNeighCells != NULL) { - if (ue_context_p->ue_context.measResults->measResultNeighCells->present == MeasResults__measResultNeighCells_PR_measResultListEUTRA) { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); - if (ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult){ - return RSRQ_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult)]; - - } - else { - - return 0; - } - } - else { - - return -1; - } - } else { - return -1; - } - } else { - return -1; - } + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.measResults) return -1; + if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1; + if (ue_context_p->ue_context.measResults->measResultNeighCells->present != MeasResults__measResultNeighCells_PR_measResultListEUTRA) return -1; + if (!ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult) return 0; + return RSRQ_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrqResult)]; } diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 05c6817136..6dc6fba377 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -50,23 +50,23 @@ * get generic info from RAN ****************************/ -void flexran_set_enb_vars(mid_t mod_id, ran_name_t ran); +void flexran_set_RC_vars(mid_t mod_id, ran_name_t ran); -int flexran_get_current_time_ms (mid_t mod_id, int subframe_flag); +uint32_t flexran_get_current_time_ms(mid_t mod_id, int subframe_flag); /*Return the current frame number *Could be using implementation specific numbering of frames */ -unsigned int flexran_get_current_frame(mid_t mod_id); +frame_t flexran_get_current_frame(mid_t mod_id); /*Return the current SFN (0-1023)*/ -unsigned int flexran_get_current_system_frame_num(mid_t mod_id); +frame_t flexran_get_current_system_frame_num(mid_t mod_id); -unsigned int flexran_get_current_subframe(mid_t mod_id); +sub_frame_t flexran_get_current_subframe(mid_t mod_id); /*Return the frame and subframe number in compact 16-bit format. Bits 0-3 subframe, rest for frame. Required by FlexRAN protocol*/ -uint16_t flexran_get_sfn_sf (mid_t mod_id); +uint16_t flexran_get_sfn_sf(mid_t mod_id); /* Return a future frame and subframe number that is ahead_of_time subframes later in compact 16-bit format. Bits 0-3 subframe, @@ -77,144 +77,151 @@ uint16_t flexran_get_future_sfn_sf(mid_t mod_id, int ahead_of_time); int flexran_get_num_ues(mid_t mod_id); /* Get the rnti of a UE with id ue_id */ -int flexran_get_ue_crnti (mid_t mod_id, mid_t ue_id); +rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id); /* Get the RLC buffer status report of a ue for a designated logical channel id */ -int flexran_get_ue_bsr (mid_t mod_id, mid_t ue_id, lcid_t lcid); +uint8_t flexran_get_ue_bsr(mid_t mod_id, mid_t ue_id, lcid_t lcid); /* Get power headroom of UE with id ue_id */ -int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id); +int8_t flexran_get_ue_phr(mid_t mod_id, mid_t ue_id); /* Get the UE wideband CQI */ -int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id); +uint8_t flexran_get_ue_wcqi(mid_t mod_id, mid_t ue_id); /* Get the transmission queue size for a UE with a channel_id logical channel id */ -int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); +rlc_buffer_occupancy_t flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); /*Get number of pdus in RLC buffer*/ -int flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); +rlc_buffer_occupancy_t flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); /* Get the head of line delay for a UE with a channel_id logical channel id */ -int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); +frame_t flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); /* Check the status of the timing advance for a UE */ -short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id); +int32_t flexran_get_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id); -/* Update the timing advance status (find out whether a timing advance command is required) */ -void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id); +/* Update the timing advance status(find out whether a timing advance command is required) */ +/* currently broken +void flexran_update_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id); */ /* Return timing advance MAC control element for a designated cell and UE */ -int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id, int CC_id); +/* this function is broken */ +int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id); /* Get the number of active component carriers for a specific UE */ int flexran_get_active_CC(mid_t mod_id, mid_t ue_id); /* Get the rank indicator for a designated cell and UE */ -int flexran_get_current_RI(mid_t mod_id, mid_t ue_id, int CC_id); +uint8_t flexran_get_current_RI(mid_t mod_id, mid_t ue_id, uint8_t cc_id); /* See TS 36.213, section 10.1 */ -int flexran_get_n1pucch_an(mid_t mod_id, int CC_id); +uint16_t flexran_get_n1pucch_an(mid_t mod_id, uint8_t cc_id); /* See TS 36.211, section 5.4 */ -int flexran_get_nRB_CQI(mid_t mod_id, int CC_id); +uint8_t flexran_get_nRB_CQI(mid_t mod_id, uint8_t cc_id); /* See TS 36.211, section 5.4 */ -int flexran_get_deltaPUCCH_Shift(mid_t mod_id, int CC_id); +uint8_t flexran_get_deltaPUCCH_Shift(mid_t mod_id, uint8_t cc_id); /* See TS 36.211, section 5.7.1 */ -int flexran_get_prach_ConfigIndex(mid_t mod_id, int CC_id); +uint8_t flexran_get_prach_ConfigIndex(mid_t mod_id, uint8_t cc_id); /* See TS 36.211, section 5.7.1 */ -int flexran_get_prach_FreqOffset(mid_t mod_id, int CC_id); +uint8_t flexran_get_prach_FreqOffset(mid_t mod_id, uint8_t cc_id); /* See TS 36.321 */ -int flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, int CC_id); +uint8_t flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, uint8_t cc_id); /* Get the length of the UL cyclic prefix */ -int flexran_get_ul_cyclic_prefix_length(mid_t mod_id, int CC_id); +lte_prefix_type_t flexran_get_ul_cyclic_prefix_length(mid_t mod_id, uint8_t cc_id); /* Get the length of the DL cyclic prefix */ -int flexran_get_dl_cyclic_prefix_length(mid_t mod_id, int CC_id); +lte_prefix_type_t flexran_get_dl_cyclic_prefix_length(mid_t mod_id, uint8_t cc_id); /* Get the physical cell id of a cell */ -int flexran_get_cell_id(mid_t mod_id, int CC_id); +uint16_t flexran_get_cell_id(mid_t mod_id, uint8_t cc_id); /* See TS 36.211, section 5.5.3.2 */ -int flexran_get_srs_BandwidthConfig(mid_t mod_id, int CC_id); +uint8_t flexran_get_srs_BandwidthConfig(mid_t mod_id, uint8_t cc_id); /* See TS 36.211, table 5.5.3.3-1 and 2 */ -int flexran_get_srs_SubframeConfig(mid_t mod_id, int CC_id); +uint8_t flexran_get_srs_SubframeConfig(mid_t mod_id, uint8_t cc_id); /* Boolean value. See TS 36.211, section 5.5.3.2. TDD only */ -int flexran_get_srs_MaxUpPts(mid_t mod_id, int CC_id); +uint8_t flexran_get_srs_MaxUpPts(mid_t mod_id, uint8_t cc_id); /* Get number of DL resource blocks */ -int flexran_get_N_RB_DL(mid_t mod_id, int CC_id); +uint8_t flexran_get_N_RB_DL(mid_t mod_id, uint8_t cc_id); /* Get number of UL resource blocks */ -int flexran_get_N_RB_UL(mid_t mod_id, int CC_id); +uint8_t flexran_get_N_RB_UL(mid_t mod_id, uint8_t cc_id); /* Get number of resource block groups */ -int flexran_get_N_RBG(mid_t mod_id, int CC_id); +uint8_t flexran_get_N_RBG(mid_t mod_id, uint8_t cc_id); /* Get DL/UL subframe assignment. TDD only */ -int flexran_get_subframe_assignment(mid_t mod_id, int CC_id); +uint8_t flexran_get_subframe_assignment(mid_t mod_id, uint8_t cc_id); /* TDD only. See TS 36.211, table 4.2.1 */ -int flexran_get_special_subframe_assignment(mid_t mod_id, int CC_id); +uint8_t flexran_get_special_subframe_assignment(mid_t mod_id, uint8_t cc_id); /* Get the duration of the random access response window in subframes */ -int flexran_get_ra_ResponseWindowSize(mid_t mod_id, int CC_id); +long flexran_get_ra_ResponseWindowSize(mid_t mod_id, uint8_t cc_id); /* Get timer used for random access */ -int flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, int CC_id); +long flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, uint8_t cc_id); -/* Get type of duplex mode (FDD/TDD) */ -int flexran_get_duplex_mode(mid_t mod_id, int CC_id); +/* Get type of duplex mode(FDD/TDD) */ +Protocol__FlexDuplexMode flexran_get_duplex_mode(mid_t mod_id, uint8_t cc_id); /* Get the SI window length */ -long flexran_get_si_window_length(mid_t mod_id, int CC_id); +long flexran_get_si_window_length(mid_t mod_id, uint8_t cc_id); + +/* Get length of SystemInformationBlock1 */ +uint8_t flexran_get_sib1_length(mid_t mod_id, uint8_t cc_id); /* Get the number of PDCCH symbols configured for the cell */ -int flexran_get_num_pdcch_symb(mid_t mod_id, int CC_id); +uint8_t flexran_get_num_pdcch_symb(mid_t mod_id, uint8_t cc_id); -int flexran_get_antenna_ports(mid_t mod_id, int CC_id); +uint8_t flexran_get_antenna_ports(mid_t mod_id, uint8_t cc_id); /* See TS 36.213, sec 5.1.1.1 */ -int flexran_get_tpc(mid_t mod_id, mid_t ue_id); +int flexran_get_tpc(mid_t mod_id, mid_t ue_id, uint8_t cc_id); -int flexran_get_ue_pmi(mid_t mod_id); +uint8_t flexran_get_ue_wpmi(mid_t mod_id, mid_t ue_id, uint8_t cc_id); /* Get the first available HARQ process for a specific cell and UE during a designated frame and subframe. Returns 0 for success. The id and the status of the HARQ process are stored in id and status respectively */ -int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, - const int frame, const uint8_t subframe, unsigned char *id, unsigned char *round,const uint8_t harq_flag); +/* currently broken +int flexran_get_harq(mid_t mod_id, uint8_t cc_id, mid_t ue_id, frame_t frame, + sub_frame_t subframe, unsigned char *id, unsigned char *round, + uint8_t harq_flag); */ /* Uplink power control management*/ -int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id); +int32_t flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, uint8_t cc_id); -int flexran_get_p0_nominal_pucch(mid_t mod_id, int CC_id); +int8_t flexran_get_p0_nominal_pucch(mid_t mod_id, uint8_t cc_id); -int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id); +int32_t flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, uint8_t cc_id); -int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id); +int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, uint8_t cc_id); -int flexran_get_threequarter_fs(mid_t mod_id, int CC_id); +uint8_t flexran_get_threequarter_fs(mid_t mod_id, uint8_t cc_id); -int flexran_get_hopping_mode(mid_t mod_id, int CC_id); +PUSCH_HOPPING_t flexran_get_hopping_mode(mid_t mod_id, uint8_t cc_id); -int flexran_get_hopping_offset(mid_t mod_id, int CC_id); +uint8_t flexran_get_hopping_offset(mid_t mod_id, uint8_t cc_id); -int flexran_get_n_SB(mid_t mod_id, int CC_id); +uint8_t flexran_get_n_SB(mid_t mod_id, uint8_t cc_id); -int flexran_get_phich_resource(mid_t mod_id, int CC_id); +int flexran_get_phich_resource(mid_t mod_id, uint8_t cc_id); -int flexran_get_enable64QAM(mid_t mod_id, int CC_id); +uint8_t flexran_get_enable64QAM(mid_t mod_id, uint8_t cc_id); -int flexran_get_phich_duration(mid_t mod_id, int CC_id); +PHICH_DURATION_t flexran_get_phich_duration(mid_t mod_id, uint8_t cc_id); /* * ************************************ @@ -225,119 +232,124 @@ int flexran_get_phich_duration(mid_t mod_id, int CC_id); /* Get timer in subframes. Controls the synchronization status of the UE, not the actual timing advance procedure. See TS 36.321 */ -int flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id); +TimeAlignmentTimer_t flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id); /* Get measurement gap configuration. See TS 36.133 */ -int flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id); +Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id); /* Get measurement gap configuration offset if applicable */ -int flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id); +long flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id); /* DL aggregated bit-rate of non-gbr bearer per UE. See TS 36.413 */ -int flexran_get_ue_aggregated_max_bitrate_dl (mid_t mod_id, mid_t ue_id); +uint64_t flexran_get_ue_aggregated_max_bitrate_dl(mid_t mod_id, mid_t ue_id); /* UL aggregated bit-rate of non-gbr bearer per UE. See TS 36.413 */ -int flexran_get_ue_aggregated_max_bitrate_ul (mid_t mod_id, mid_t ue_id); +uint64_t flexran_get_ue_aggregated_max_bitrate_ul(mid_t mod_id, mid_t ue_id); /* Only half-duplex support. FDD operation. Boolean value */ -int flexran_get_half_duplex(mid_t ue_id); +/* currently broken +int flexran_get_half_duplex(mid_t ue_id); */ /* Support of intra-subframe hopping. Boolean value */ -int flexran_get_intra_sf_hopping(mid_t ue_id); +/* currently broken +int flexran_get_intra_sf_hopping(mid_t ue_id); */ /* UE support for type 2 hopping with n_sb>1 */ -int flexran_get_type2_sb_1(mid_t ue_id); +/* currently broken +int flexran_get_type2_sb_1(mid_t ue_id); */ /* Get the UE category */ -int flexran_get_ue_category(mid_t ue_id); +/* currently broken +int flexran_get_ue_category(mid_t ue_id); */ /* UE support for resource allocation type 1 */ -int flexran_get_res_alloc_type1(mid_t ue_id); +/* currently broken +int flexran_get_res_alloc_type1(mid_t ue_id); */ /* Get UE transmission mode */ -int flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id); +long flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id); /* Boolean value. See TS 36.321 */ -int flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id); +BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id); /* The max HARQ retransmission for UL. See TS 36.321 */ -int flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id); +long flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id); /* See TS 36.213 */ -int flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id); +long flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id); /* See TS 36.213 */ -int flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id); +long flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id); /* See TS 36.213 */ -int flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id); +long flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id); /* Boolean. See TS36.213, Section 10.1 */ -int flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id); +BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id); /* Boolean. See TS 36.213, Section 8.2 */ -int flexran_get_ack_nack_simultaneous_trans(mid_t mod_id,mid_t ue_id); +BOOLEAN_t flexran_get_ack_nack_simultaneous_trans(mid_t mod_id, mid_t ue_id, uint8_t cc_id); /* Get aperiodic CQI report mode */ -int flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id); +CQI_ReportModeAperiodic_t flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id); /* Get ACK/NACK feedback mode. TDD only */ -int flexran_get_tdd_ack_nack_feedback(mid_t mod_id, mid_t ue_id); +long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, mid_t ue_id); /* See TS36.213, section 10.1 */ -int flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id); +long flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id); /* Boolean. Extended buffer status report size */ -int flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id); +long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id); /* Get number of UE transmission antennas */ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id); /* Get logical channel group of a channel with id lc_id */ -int flexran_get_lcg(mid_t ue_id, mid_t lc_id); +long flexran_get_lcg(mid_t ue_id, mid_t lc_id); /* Get direction of logical channel with id lc_id */ int flexran_get_direction(mid_t ue_id, mid_t lc_id); /*Get downlink frequency*/ -uint32_t flexran_agent_get_operating_dl_freq (mid_t mod_id, int cc_id); +uint32_t flexran_agent_get_operating_dl_freq(mid_t mod_id, uint8_t cc_id); /*Get uplink frequency*/ -uint32_t flexran_agent_get_operating_ul_freq (mid_t mod_id, int cc_id); +uint32_t flexran_agent_get_operating_ul_freq(mid_t mod_id, uint8_t cc_id); /*Get eutra band*/ -int flexran_agent_get_operating_eutra_band (mid_t mod_id, int cc_id); +uint8_t flexran_agent_get_operating_eutra_band(mid_t mod_id, uint8_t cc_id); /*Get downlink ref signal power*/ -int flexran_agent_get_operating_pdsch_refpower (mid_t mod_id, int cc_id); +int8_t flexran_agent_get_operating_pdsch_refpower(mid_t mod_id, uint8_t cc_id); /*Get uplink power*/ -int flexran_agent_get_operating_pusch_p0 (mid_t mod_id, int cc_id); +long flexran_agent_get_operating_pusch_p0(mid_t mod_id, uint8_t cc_id); /*set the dl freq */ -void flexran_agent_set_operating_dl_freq (mid_t mod_id, int cc_id, uint32_t dl_freq_mhz); +void flexran_agent_set_operating_dl_freq(mid_t mod_id, uint8_t cc_id, uint32_t dl_freq_mhz); /* set the ul freq */ -void flexran_agent_set_operating_ul_freq (mid_t mod_id, int cc_id, int32_t ul_freq_offset_mhz); +void flexran_agent_set_operating_ul_freq(mid_t mod_id, uint8_t cc_id, int32_t ul_freq_mhz_offset); /*set the the band */ -void flexran_agent_set_operating_eutra_band (mid_t mod_id, int cc_id); +void flexran_agent_set_operating_eutra_band(mid_t mod_id, uint8_t cc_id, uint8_t eutra_band); -/* set the bandwidth */ -void flexran_agent_set_operating_bandwidth (mid_t mod_id, int cc_id, int bandwidth); +/* set the bandwidth (in RB) */ +void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t N_RB); /*set frame type*/ -void flexran_agent_set_operating_frame_type (mid_t mod_id, int cc_id, int frame_type); +void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type); /*RRC status flexRAN*/ -int flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); +uint8_t flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); /***************************** PDCP ***********************/ @@ -399,28 +411,30 @@ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lc /*********************RRC**********************/ /*Get primary cell measuremeant id flexRAN*/ -int flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id); +MeasId_t flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id); /*Get primary cell RSRP measurement flexRAN*/ -int flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id); +float flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id); /*Get primary cell RSRQ measurement flexRAN*/ -int flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id); +float flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id); /* Get RRC neighbouring measurement */ int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id); /*Get physical cell id*/ -int flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id); +PhysCellId_t flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id); /*Get RSRP of neighbouring Cell*/ -int flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id); +float flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id); /*Get RSRQ of neighbouring Cell*/ -int flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id); +float flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id); /*Get MCC PLMN identity neighbouring Cell*/ -int flexran_get_rrc_neigh_plmn_mcc(mid_t mod_id, mid_t ue_id, int cell_id); +/* currently not implemented +int flexran_get_rrc_neigh_plmn_mcc(mid_t mod_id, mid_t ue_id, int cell_id); */ /*Get MNC PLMN identity neighbouring Cell*/ -int flexran_get_rrc_neigh_plmn_mnc(mid_t mod_id, mid_t ue_id, int cell_id); \ No newline at end of file +/* currently not implemented +int flexran_get_rrc_neigh_plmn_mnc(mid_t mod_id, mid_t ue_id, int cell_id); */ From b45a340b63f0f9695d3a1d4e218a79617bf03c50 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Jan 2018 15:47:40 +0100 Subject: [PATCH 071/141] RAN API: no set_RC_vars(), check use RC directly, give error messages --- openair2/ENB_APP/enb_app.c | 6 - openair2/ENB_APP/flexran_agent_ran_api.c | 419 ++++++++++++----------- openair2/ENB_APP/flexran_agent_ran_api.h | 2 - 3 files changed, 213 insertions(+), 214 deletions(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 636df458ae..3b3c8c24c7 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -342,12 +342,6 @@ void *eNB_app_task(void *args_p) enb_app_start_phy_rrc(enb_id_start, enb_id_end); -#ifdef FLEXRAN_AGENT_SB_IF - for (uint32_t enb_i = 0; enb_i <1; enb_i ++){ // To be handled for all of current eNB - flexran_set_RC_vars(enb_i, RAN_LTE_OAI); - } -#endif - # if defined(ENABLE_USE_MME) /* Try to register each eNB */ registered_enb = 0; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index af1d1be63d..75552526a7 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -28,48 +28,35 @@ #include "flexran_agent_ran_api.h" -/* - * generic info from RAN - */ - -PHY_VARS_eNB *phy[NUM_MAX_ENB][MAX_NUM_CCs] = { NULL }; -eNB_MAC_INST *mac[NUM_MAX_ENB] = { NULL }; -eNB_RRC_INST *rrc[NUM_MAX_ENB] = { NULL }; -UE_list_t *UE_list[NUM_MAX_ENB] = { NULL }; - -void flexran_set_RC_vars(mid_t mod_id, ran_name_t ran) +static inline int phy_is_present(mid_t mod_id, uint8_t cc_id) { - int i; - if (ran == RAN_LTE_OAI) { - if (RC.eNB && mod_id < RC.nb_RU && RC.eNB[mod_id] && RC.nb_CC) - for (i = 0; i < *RC.nb_CC; i++) - phy[mod_id][i] = RC.eNB[mod_id][i]; - if (RC.mac && mod_id < RC.nb_macrlc_inst && RC.mac[mod_id]) { - mac[mod_id] = RC.mac[mod_id]; - UE_list[mod_id] = &RC.mac[mod_id]->UE_list; - } - if (RC.rrc && mod_id < RC.nb_macrlc_inst && RC.rrc[mod_id]) - rrc[mod_id] = RC.rrc[mod_id]; - } - else { - LOG_E(FLEXRAN_AGENT, "unknown RAN name %d when setting RAN API variables\n", ran); - } + return RC.eNB && RC.eNB[mod_id] && RC.eNB[mod_id][cc_id]; +} + +static inline int mac_is_present(mid_t mod_id) +{ + return RC.mac && RC.mac[mod_id]; +} + +static inline int rrc_is_present(mid_t mod_id) +{ + return RC.rrc && RC.rrc[mod_id]; } uint32_t flexran_get_current_time_ms(mid_t mod_id, int subframe_flag) { - if (!mac[mod_id]) return 0; + if (!mac_is_present(mod_id)) return 0; if (subframe_flag == 1) - return mac[mod_id]->frame*10 + mac[mod_id]->subframe; + return RC.mac[mod_id]->frame*10 + RC.mac[mod_id]->subframe; else - return mac[mod_id]->frame*10; + return RC.mac[mod_id]->frame*10; } frame_t flexran_get_current_frame(mid_t mod_id) { - if (!mac[mod_id]) return 0; + if (!mac_is_present(mod_id)) return 0; // #warning "SFN will not be in [0-1023] when oaisim is used" - return mac[mod_id]->frame; + return RC.mac[mod_id]->frame; } frame_t flexran_get_current_system_frame_num(mid_t mod_id) @@ -79,8 +66,8 @@ frame_t flexran_get_current_system_frame_num(mid_t mod_id) sub_frame_t flexran_get_current_subframe(mid_t mod_id) { - if (!mac[mod_id]) return 0; - return mac[mod_id]->subframe; + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->subframe; } /* Why uint16_t, frame_t and sub_frame_t are defined as uint32_t? */ @@ -121,8 +108,8 @@ uint16_t flexran_get_future_sfn_sf(mid_t mod_id, int ahead_of_time) int flexran_get_num_ues(mid_t mod_id) { - if (!UE_list[mod_id]) return 0; - return UE_list[mod_id]->num_UEs; + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->UE_list.num_UEs; } rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id) @@ -132,20 +119,20 @@ rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id) uint8_t flexran_get_ue_bsr(mid_t mod_id, mid_t ue_id, lcid_t lcid) { - if (!UE_list[mod_id]) return 0; - return UE_list[mod_id]->UE_template[UE_PCCID(mod_id, ue_id)][ue_id].bsr_info[lcid]; + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->UE_list.UE_template[UE_PCCID(mod_id, ue_id)][ue_id].bsr_info[lcid]; } int8_t flexran_get_ue_phr(mid_t mod_id, mid_t ue_id) { - if (!UE_list[mod_id]) return 0; - return UE_list[mod_id]->UE_template[UE_PCCID(mod_id, ue_id)][ue_id].phr_info; + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->UE_list.UE_template[UE_PCCID(mod_id, ue_id)][ue_id].phr_info; } uint8_t flexran_get_ue_wcqi(mid_t mod_id, mid_t ue_id) { - if (!phy[mod_id][0]) return 0; - return phy[mod_id][0]->UE_stats[ue_id].DL_cqi[0]; + if (!phy_is_present(mod_id, 0)) return 0; + return RC.eNB[mod_id][0]->UE_stats[ue_id].DL_cqi[0]; } rlc_buffer_occupancy_t flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) @@ -177,9 +164,9 @@ frame_t flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t chann int32_t flexran_get_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; + if (!phy_is_present(mod_id, cc_id)) return 0; - int32_t tau = phy[mod_id][cc_id]->UE_stats[ue_id].timing_advance_update; + int32_t tau = RC.eNB[mod_id][cc_id]->UE_stats[ue_id].timing_advance_update; switch (flexran_get_N_RB_DL(mod_id, cc_id)) { case 6: return tau; @@ -203,8 +190,8 @@ int32_t flexran_get_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id) uint8_t flexran_get_ue_wpmi(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { - if (!UE_list[mod_id]) return 0; - return UE_list[mod_id]->UE_sched_ctrl[ue_id].periodic_wideband_pmi[cc_id]; + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->UE_list.UE_sched_ctrl[ue_id].periodic_wideband_pmi[cc_id]; } /* TODO needs to be revised */ @@ -235,7 +222,7 @@ void flexran_update_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id) int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { #warning "Implement flexran_get_MAC_CE_bitmap_TA() in RAN API" - if (!phy[mod_id][cc_id]) return 0; + if (!phy_is_present(mod_id, cc_id)) return 0; /* UE_stats can not be null, they are an array in RC LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); @@ -254,25 +241,25 @@ int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id, uint8_t cc_id) int flexran_get_active_CC(mid_t mod_id, mid_t ue_id) { - if (!UE_list[mod_id]) return 0; - return UE_list[mod_id]->numactiveCCs[ue_id]; + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->UE_list.numactiveCCs[ue_id]; } uint8_t flexran_get_current_RI(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->UE_stats[ue_id].rank; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->UE_stats[ue_id].rank; } int flexran_get_tpc(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; + if (!phy_is_present(mod_id, cc_id)) return 0; /* before: tested that UL_rssi != NULL and set parameter ([0]), but it is a * static array -> target_rx_power is useless in old ifs?! */ int pCCid = UE_PCCID(mod_id,ue_id); - int32_t target_rx_power = phy[mod_id][pCCid]->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; - int32_t normalized_rx_power = phy[mod_id][cc_id]->UE_stats[ue_id].UL_rssi[0]; + int32_t target_rx_power = RC.eNB[mod_id][pCCid]->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; + int32_t normalized_rx_power = RC.eNB[mod_id][cc_id]->UE_stats[ue_id].UL_rssi[0]; int tpc; if (normalized_rx_power > target_rx_power + 1) @@ -334,26 +321,26 @@ int flexran_get_harq(mid_t mod_id, int32_t flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_dBm; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_dBm; } int8_t flexran_get_p0_nominal_pucch(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.ul_power_control_config_common.p0_NominalPUCCH; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.ul_power_control_config_common.p0_NominalPUCCH; } int32_t flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_update; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_update; } int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - phy[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_update = 0; + if (!phy_is_present(mod_id, cc_id)) return 0; + RC.eNB[mod_id][cc_id]->UE_stats[ue_id].Po_PUCCH_update = 0; return 0; } @@ -365,46 +352,46 @@ int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, uint8_t cc_id) */ uint8_t flexran_get_threequarter_fs(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.threequarter_fs; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.threequarter_fs; } uint8_t flexran_get_hopping_offset(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.pusch_config_common.pusch_HoppingOffset; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.pusch_config_common.pusch_HoppingOffset; } PUSCH_HOPPING_t flexran_get_hopping_mode(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.pusch_config_common.hoppingMode; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.pusch_config_common.hoppingMode; } uint8_t flexran_get_n_SB(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.pusch_config_common.n_SB; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.pusch_config_common.n_SB; } uint8_t flexran_get_enable64QAM(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.pusch_config_common.enable64QAM; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.pusch_config_common.enable64QAM; } PHICH_DURATION_t flexran_get_phich_duration(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.phich_config_common.phich_duration; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.phich_config_common.phich_duration; } int flexran_get_phich_resource(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; + if (!phy_is_present(mod_id, cc_id)) return 0; /* TODO why don't we return phich_resource? */ - switch (phy[mod_id][cc_id]->frame_parms.phich_config_common.phich_resource) { + switch (RC.eNB[mod_id][cc_id]->frame_parms.phich_config_common.phich_resource) { case oneSixth: return 0; case half: @@ -420,122 +407,122 @@ int flexran_get_phich_resource(mid_t mod_id, uint8_t cc_id) uint16_t flexran_get_n1pucch_an(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.pucch_config_common.n1PUCCH_AN; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.pucch_config_common.n1PUCCH_AN; } uint8_t flexran_get_nRB_CQI(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.pucch_config_common.nRB_CQI; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.pucch_config_common.nRB_CQI; } uint8_t flexran_get_deltaPUCCH_Shift(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.pucch_config_common.deltaPUCCH_Shift; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.pucch_config_common.deltaPUCCH_Shift; } uint8_t flexran_get_prach_ConfigIndex(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex; } uint8_t flexran_get_prach_FreqOffset(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; } uint8_t flexran_get_maxHARQ_Msg3Tx(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.maxHARQ_Msg3Tx; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.maxHARQ_Msg3Tx; } lte_prefix_type_t flexran_get_ul_cyclic_prefix_length(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.Ncp_UL; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.Ncp_UL; } lte_prefix_type_t flexran_get_dl_cyclic_prefix_length(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.Ncp; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.Ncp; } uint16_t flexran_get_cell_id(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.Nid_cell; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.Nid_cell; } uint8_t flexran_get_srs_BandwidthConfig(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_BandwidthConfig; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_BandwidthConfig; } uint8_t flexran_get_srs_SubframeConfig(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_SubframeConfig; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_SubframeConfig; } uint8_t flexran_get_srs_MaxUpPts(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_MaxUpPts; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.soundingrs_ul_config_common.srs_MaxUpPts; } uint8_t flexran_get_N_RB_DL(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.N_RB_DL; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.N_RB_DL; } uint8_t flexran_get_N_RB_UL(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.N_RB_UL; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.N_RB_UL; } uint8_t flexran_get_N_RBG(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.N_RBG; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.N_RBG; } uint8_t flexran_get_subframe_assignment(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.tdd_config; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.tdd_config; } uint8_t flexran_get_special_subframe_assignment(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.tdd_config_S; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.tdd_config_S; } long flexran_get_ra_ResponseWindowSize(mid_t mod_id, uint8_t cc_id) { - if (!rrc[mod_id]) return 0; - return rrc[mod_id]->configuration.rach_raResponseWindowSize[cc_id]; + if (!rrc_is_present(mod_id)) return 0; + return RC.rrc[mod_id]->configuration.rach_raResponseWindowSize[cc_id]; } long flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, uint8_t cc_id) { - if (!rrc[mod_id]) return 0; - return rrc[mod_id]->configuration.rach_macContentionResolutionTimer[cc_id]; + if (!rrc_is_present(mod_id)) return 0; + return RC.rrc[mod_id]->configuration.rach_macContentionResolutionTimer[cc_id]; } Protocol__FlexDuplexMode flexran_get_duplex_mode(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - switch (phy[mod_id][cc_id]->frame_parms.frame_type) { + if (!phy_is_present(mod_id, cc_id)) return 0; + switch (RC.eNB[mod_id][cc_id]->frame_parms.frame_type) { case TDD: return PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD; case FDD: @@ -547,21 +534,21 @@ Protocol__FlexDuplexMode flexran_get_duplex_mode(mid_t mod_id, uint8_t cc_id) long flexran_get_si_window_length(mid_t mod_id, uint8_t cc_id) { - if (!rrc[mod_id] || !rrc[mod_id]->carrier[cc_id].sib1) return 0; - return rrc[mod_id]->carrier[cc_id].sib1->si_WindowLength; + if (!rrc_is_present(mod_id) || !RC.rrc[mod_id]->carrier[cc_id].sib1) return 0; + return RC.rrc[mod_id]->carrier[cc_id].sib1->si_WindowLength; } uint8_t flexran_get_sib1_length(mid_t mod_id, uint8_t cc_id) { - if (!rrc[mod_id]) return 0; - return rrc[mod_id]->carrier[cc_id].sizeof_SIB1; + if (!rrc_is_present(mod_id)) return 0; + return RC.rrc[mod_id]->carrier[cc_id].sizeof_SIB1; } uint8_t flexran_get_num_pdcch_symb(mid_t mod_id, uint8_t cc_id) { /* TODO: This should return the number of PDCCH symbols initially used by the * cell cc_id -> is the correction right? */ - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->pdcch_vars[0].num_pdcch_symbols; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->pdcch_vars[0].num_pdcch_symbols; //(PHY_vars_UE_g[mod_id][cc_id]->lte_ue_pdcch_vars[mod_id]->num_pdcch_symbols); } @@ -576,10 +563,10 @@ uint8_t flexran_get_num_pdcch_symb(mid_t mod_id, uint8_t cc_id) { TimeAlignmentTimer_t flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.mac_MainConfig) return -1; @@ -588,10 +575,10 @@ TimeAlignmentTimer_t flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id) Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.measGapConfig) return -1; @@ -609,10 +596,10 @@ Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, mid long flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.measGapConfig) return -1; @@ -631,9 +618,9 @@ long flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) /* TODO return type is unsigned, so we cannot return -1 in case of error! */ uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti) { - if (!rrc[mod_id]) return 0; + if (!rrc_is_present(mod_id)) return 0; - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return RRC_INACTIVE; return ue_context_p->ue_context.Status; @@ -641,14 +628,14 @@ uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti) uint64_t flexran_get_ue_aggregated_max_bitrate_dl(mid_t mod_id, mid_t ue_id) { - if (!UE_list[mod_id]) return 0; - return UE_list[mod_id]->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateDL; + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->UE_list.UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateDL; } uint64_t flexran_get_ue_aggregated_max_bitrate_ul(mid_t mod_id, mid_t ue_id) { - if (!UE_list[mod_id]) return 0; - return UE_list[mod_id]->UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL; + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->UE_list.UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL; } int flexran_get_half_duplex(mid_t ue_id) @@ -704,10 +691,10 @@ int flexran_get_res_alloc_type1(mid_t ue_id) long flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -717,10 +704,10 @@ long flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.mac_MainConfig) return -1; if (!ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config) return -1; @@ -729,10 +716,10 @@ BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id) long flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.mac_MainConfig) return -1; @@ -742,10 +729,10 @@ long flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id) long flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -755,10 +742,10 @@ long flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id) long flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -768,10 +755,10 @@ long flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id) long flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -781,10 +768,10 @@ long flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id) BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -795,17 +782,17 @@ BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id) BOOLEAN_t flexran_get_ack_nack_simultaneous_trans(mid_t mod_id, mid_t ue_id, uint8_t cc_id) { - if (!rrc[mod_id]) return -1; - if (!rrc[mod_id]->carrier[cc_id].sib2) return -1; - return rrc[mod_id]->carrier[cc_id].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; + if (!rrc_is_present(mod_id)) return -1; + if (!RC.rrc[mod_id]->carrier[cc_id].sib2) return -1; + return RC.rrc[mod_id]->carrier[cc_id].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; } CQI_ReportModeAperiodic_t flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -815,10 +802,10 @@ CQI_ReportModeAperiodic_t flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -829,10 +816,10 @@ long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, mid_t ue_id) long flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -842,10 +829,10 @@ long flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id) long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.mac_MainConfig) return -1; @@ -856,10 +843,10 @@ long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id) int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.physicalConfigDedicated) return -1; @@ -900,92 +887,112 @@ int flexran_get_direction(mid_t ue_id, mid_t lc_id) uint8_t flexran_get_antenna_ports(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.nb_antenna_ports_eNB; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.nb_antenna_ports_eNB; } /* TODO better give real value (without division)? */ uint32_t flexran_agent_get_operating_dl_freq(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.dl_CarrierFreq / 1000000; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.dl_CarrierFreq / 1000000; } /* TODO better give real value (without division)? */ uint32_t flexran_agent_get_operating_ul_freq(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.ul_CarrierFreq / 1000000; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.ul_CarrierFreq / 1000000; } uint8_t flexran_agent_get_operating_eutra_band(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.eutra_band; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.eutra_band; } int8_t flexran_agent_get_operating_pdsch_refpower(mid_t mod_id, uint8_t cc_id) { - if (!phy[mod_id][cc_id]) return 0; - return phy[mod_id][cc_id]->frame_parms.pdsch_config_common.referenceSignalPower; + if (!phy_is_present(mod_id, cc_id)) return 0; + return RC.eNB[mod_id][cc_id]->frame_parms.pdsch_config_common.referenceSignalPower; } long flexran_agent_get_operating_pusch_p0(mid_t mod_id, uint8_t cc_id) { - if (!rrc[mod_id]) return 0; - return rrc[mod_id]->configuration.pusch_p0_Nominal[cc_id]; + if (!rrc_is_present(mod_id)) return 0; + return RC.rrc[mod_id]->configuration.pusch_p0_Nominal[cc_id]; } void flexran_agent_set_operating_dl_freq(mid_t mod_id, uint8_t cc_id, uint32_t dl_freq_mhz) { - if (phy[mod_id][cc_id]) { - phy[mod_id][cc_id]->frame_parms.dl_CarrierFreq = dl_freq_mhz * 1000000; + if (phy_is_present(mod_id, cc_id)) { + RC.eNB[mod_id][cc_id]->frame_parms.dl_CarrierFreq = dl_freq_mhz * 1000000; + } else { + LOG_E(FLEXRAN_AGENT, "can not set dl_CarrierFreq to %d MHz in PHY: PHY is not present\n", dl_freq_mhz); } - if (rrc[mod_id]) { - rrc[mod_id]->configuration.downlink_frequency[cc_id] = dl_freq_mhz * 1000000; + if (rrc_is_present(mod_id)) { + RC.rrc[mod_id]->configuration.downlink_frequency[cc_id] = dl_freq_mhz * 1000000; + } else { + LOG_E(FLEXRAN_AGENT, "can not set downlink_frequency to %d MHz in RRC: RRC is not present\n", dl_freq_mhz); } } void flexran_agent_set_operating_ul_freq(mid_t mod_id, uint8_t cc_id, int32_t ul_freq_mhz_offset) { - if (phy[mod_id][cc_id]) { + if (phy_is_present(mod_id, cc_id)) { uint32_t new_ul_freq_mhz = flexran_agent_get_operating_dl_freq(mod_id, cc_id) + ul_freq_mhz_offset; - phy[mod_id][cc_id]->frame_parms.ul_CarrierFreq = new_ul_freq_mhz * 1000000; + RC.eNB[mod_id][cc_id]->frame_parms.ul_CarrierFreq = new_ul_freq_mhz * 1000000; + } else { + LOG_E(FLEXRAN_AGENT, "can not set ul_CarrierFreq using offset %d MHz in PHY: PHY is not present\n", ul_freq_mhz_offset); } - if (rrc[mod_id]) { - rrc[mod_id]->configuration.uplink_frequency_offset[cc_id] = ul_freq_mhz_offset; + if (rrc_is_present(mod_id)) { + RC.rrc[mod_id]->configuration.uplink_frequency_offset[cc_id] = ul_freq_mhz_offset; + } else { + LOG_E(FLEXRAN_AGENT, "can not set uplink_frequency_offset to %d MHz in RRC: RRC is not present\n", ul_freq_mhz_offset); } } void flexran_agent_set_operating_eutra_band(mid_t mod_id, uint8_t cc_id, uint8_t eutra_band) { - if (phy[mod_id][cc_id]) { - phy[mod_id][cc_id]->frame_parms.eutra_band = eutra_band; + if (phy_is_present(mod_id, cc_id)) { + RC.eNB[mod_id][cc_id]->frame_parms.eutra_band = eutra_band; + } else { + LOG_E(FLEXRAN_AGENT, "can not set eutra_band to %d in PHY: PHY is not present\n", eutra_band); } - if (rrc[mod_id]) { - rrc[mod_id]->configuration.eutra_band[cc_id] = eutra_band; + if (rrc_is_present(mod_id)) { + RC.rrc[mod_id]->configuration.eutra_band[cc_id] = eutra_band; + } else { + LOG_E(FLEXRAN_AGENT, "can not set eutra_band to %d in RRC: RRC is not present\n", eutra_band); } } /* Sets both DL/UL */ void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t N_RB) { - if (phy[mod_id][cc_id]) { - phy[mod_id][cc_id]->frame_parms.N_RB_DL = N_RB; - phy[mod_id][cc_id]->frame_parms.N_RB_UL = N_RB; + if (phy_is_present(mod_id, cc_id)) { + RC.eNB[mod_id][cc_id]->frame_parms.N_RB_DL = N_RB; + RC.eNB[mod_id][cc_id]->frame_parms.N_RB_UL = N_RB; + } else { + LOG_E(FLEXRAN_AGENT, "can not set N_RB_DL and N_RB_UL to %d in PHY: PHY is not present\n", N_RB); } - if (rrc[mod_id]) { - rrc[mod_id]->configuration.N_RB_DL[cc_id] = N_RB; + if (rrc_is_present(mod_id)) { + RC.rrc[mod_id]->configuration.N_RB_DL[cc_id] = N_RB; + } else { + LOG_E(FLEXRAN_AGENT, "can not set N_RB_DL to %d in RRC: RRC is not present\n", N_RB); } } void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type) { - if (phy[mod_id][cc_id]) { - phy[mod_id][cc_id]->frame_parms.frame_type = frame_type; + if (phy_is_present(mod_id, cc_id)) { + RC.eNB[mod_id][cc_id]->frame_parms.frame_type = frame_type; + } else { + LOG_E(FLEXRAN_AGENT, "can not set frame_type to %d in PHY: PHY is not present\n", frame_type); } - if (rrc[mod_id]) { - rrc[mod_id]->configuration.frame_type[cc_id] = frame_type; + if (rrc_is_present(mod_id)) { + RC.rrc[mod_id]->configuration.frame_type[cc_id] = frame_type; + } else { + LOG_E(FLEXRAN_AGENT, "can not set frame_type to %d in RRC: RRC is not present\n", frame_type); } } @@ -1097,10 +1104,10 @@ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id, const mid_t ue_id, const lc MeasId_t flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.measResults) return -1; @@ -1109,10 +1116,10 @@ MeasId_t flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id) float flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.measResults) return -1; @@ -1121,10 +1128,10 @@ float flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id) float flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.measResults) return -1; @@ -1134,10 +1141,10 @@ float flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id) /*Number of neighbouring cells for specific UE*/ int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id) { - if (!rrc[mod_id]) return 0; + if (!rrc_is_present(mod_id)) return 0; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return 0; if (!ue_context_p->ue_context.measResults) return 0; @@ -1148,10 +1155,10 @@ int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id) PhysCellId_t flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.measResults) return -1; @@ -1163,10 +1170,10 @@ PhysCellId_t flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int ce float flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.measResults) return -1; @@ -1179,10 +1186,10 @@ float flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id) float flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id) { - if (!rrc[mod_id]) return -1; + if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(rrc[mod_id], rnti); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; if (!ue_context_p->ue_context.measResults) return -1; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 6dc6fba377..25faa105a6 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -50,8 +50,6 @@ * get generic info from RAN ****************************/ -void flexran_set_RC_vars(mid_t mod_id, ran_name_t ran); - uint32_t flexran_get_current_time_ms(mid_t mod_id, int subframe_flag); /*Return the current frame number From a6098dbf09d5bc7caa3bd544c2594dec054a5608 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 15 Jan 2018 18:31:37 +0100 Subject: [PATCH 072/141] delete unnecessary FlexRAN source files all the FlexRAN scheduling code is now also handled by the general OAI scheduling code --- cmake_targets/CMakeLists.txt | 22 - .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 2 - openair2/LAYER2/MAC/eNB_scheduler.c | 1 - openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 +- openair2/LAYER2/MAC/flexran_agent_mac_proto.h | 323 --- .../MAC/flexran_agent_scheduler_dataplane.c | 583 ------ .../MAC/flexran_agent_scheduler_dlsch_ue.c | 1814 ----------------- .../flexran_agent_scheduler_dlsch_ue_remote.c | 202 -- .../flexran_agent_scheduler_dlsch_ue_remote.h | 70 - .../MAC/flexran_agent_scheduler_ulsch_ue.c | 1112 ---------- openair2/LAYER2/MAC/flexran_dci_conversions.h | 51 - 11 files changed, 1 insertion(+), 4181 deletions(-) delete mode 100644 openair2/LAYER2/MAC/flexran_agent_mac_proto.h delete mode 100644 openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c delete mode 100644 openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c delete mode 100644 openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c delete mode 100644 openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h delete mode 100644 openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c delete mode 100644 openair2/LAYER2/MAC/flexran_dci_conversions.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index da0c3fbc1f..b659819e25 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1191,17 +1191,6 @@ set (MAC_SRC ${MAC_DIR}/config.c ) -if (FLEXRAN_AGENT_SB_IF) - -set (MAC_SRC ${MAC_SRC} - ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue.c - ${MAC_DIR}/flexran_agent_scheduler_ulsch_ue.c - ${MAC_DIR}/flexran_agent_scheduler_dataplane.c - ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue_remote.c -) - -endif() - set (ENB_APP_SRC ${OPENAIR2_DIR}/ENB_APP/enb_app.c ${OPENAIR2_DIR}/ENB_APP/enb_config.c @@ -1213,17 +1202,6 @@ add_library(L2 ${ENB_APP_SRC}) # ${OPENAIR2_DIR}/RRC/L2_INTERFACE/openair_rrc_L2_interface.c) -if (FLEXRAN_AGENT_SB_IF) - -#Test for adding a shared library -add_library(default_sched SHARED ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue.c) -add_library(remote_sched SHARED ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue_remote.c) - -add_library(default_ul_sched SHARED ${MAC_DIR}/flexran_agent_scheduler_ulsch_ue.c) - - -endif() - # L3 Libs ########################## diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 02350eb0c1..d60a9eb3b7 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -35,8 +35,6 @@ #include "flexran_agent_ran_api.h" #include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/flexran_agent_mac_proto.h" -#include "LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h" #include "liblfds700.h" diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 432915eb8c..1195e05379 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -56,7 +56,6 @@ //Agent-related headers #include "flexran_agent_extern.h" #include "flexran_agent_mac.h" -#include "flexran_agent_mac_proto.h" #endif #if defined(ENABLE_ITTI) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 0d9f129fa6..a0da4f4961 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -62,7 +62,7 @@ #include "flexran_agent_ran_api.h" #include "header.pb-c.h" #include "flexran.pb-c.h" -#include "flexran_agent_mac.h" +#endif #include #endif diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h deleted file mode 100644 index be61fa1590..0000000000 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file flexran_agent_mac_proto.h - * \brief MAC functions for FlexRAN agent - * \author Xenofon Foukas and Navid Nikaein - * \date 2016 - * \email: x.foukas@sms.ed.ac.uk - * \version 0.1 - * @ingroup _mac - - */ - -#ifndef __LAYER2_MAC_FLEXRAN_AGENT_MAC_PROTO_H__ -#define __LAYER2_MAC_FLEXRAN_AGENT_MAC_PROTO_H__ - -#include "flexran_agent_defs.h" -#include "header.pb-c.h" -#include "flexran.pb-c.h" - -/* - * slice specific scheduler - */ -typedef void (*slice_scheduler_dl)(module_id_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); - -typedef void (*slice_scheduler_ul)(module_id_t mod_id, - frame_t frame, - unsigned char cooperation_flag, - uint32_t subframe, - unsigned char sched_subframe, - Protocol__FlexranMessage **ul_info); - - -/* - * top level flexran scheduler used by the eNB scheduler - */ -void flexran_schedule_ue_dl_spec_default(mid_t mod_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info); -/* - * slice specific scheduler for embb - */ -void -flexran_schedule_ue_spec_embb(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info); -/* - * slice specific scheduler for urllc - */ -void -flexran_schedule_ue_spec_urllc(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info); - -/* - * slice specific scheduler for mmtc - */ -void -flexran_schedule_ue_spec_mmtc(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info); -/* - * slice specific scheduler for best effort traffic - */ -void -flexran_schedule_ue_spec_be(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info); - -/* - * common flexran scheduler function - */ -void -<<<<<<< HEAD -flexran_schedule_ue_spec_common(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info); - -uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs); - -int flexran_slice_member(int UE_id, int slice_id); - -int flexran_slice_maxmcs(int slice_id); - -void _store_dlsch_buffer(module_id_t Mod_id, - int slice_id, - frame_t frameP, sub_frame_t subframeP); - - -void _assign_rbs_required(module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframe, - uint16_t - nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_allowed_slice[MAX_NUM_CCs] - [MAX_NUM_SLICES], int min_rb_unit[MAX_NUM_CCs]); - -void _dlsch_scheduler_pre_processor(module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int *mbsfn_flag); - -void _dlsch_scheduler_pre_processor_reset(int module_idP, - int UE_id, - uint8_t CC_id, - int frameP, - int subframeP, - int N_RBG, - uint16_t - nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_required_remaining - [MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_allowed_slice[MAX_NUM_CCs] - [MAX_NUM_SLICES], - unsigned char - rballoc_sub[MAX_NUM_CCs] - [N_RBG_MAX], - unsigned char - MIMO_mode_indicator[MAX_NUM_CCs] - [N_RBG_MAX]); - -void _dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, - int UE_id, - uint8_t CC_id, - int N_RBG, - int transmission_mode, - int min_rb_unit, - uint8_t N_RB_DL, - uint16_t - nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_required_remaining - [MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], - unsigned char - rballoc_sub[MAX_NUM_CCs] - [N_RBG_MAX], - unsigned char - MIMO_mode_indicator - [MAX_NUM_CCs][N_RBG_MAX]); -======= -flexran_schedule_ue_dl_spec_common(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); - -void -flexran_schedule_ue_ul_spec_default(mid_t mod_id, - uint32_t frame, - uint32_t cooperation_flag, - int subframe, - unsigned char sched_subframe, - Protocol__FlexranMessage **ul_info); - - -uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, - int total_rbs); - -int flexran_slice_member(int UE_id, - int slice_id); - -int flexran_slice_maxmcs(int slice_id) ; - -/* Downlink Primitivies */ - -void _store_dlsch_buffer (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframeP); - - -void _assign_rbs_required (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframe, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], - int min_rb_unit[MAX_NUM_CCs]); - - -/* Uplink Primitivies */ - -// 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 slice_id, int frameP, sub_frame_t subframeP, uint16_t *first_rb); - - -void _ulsch_scheduler_pre_processor(module_id_t module_idP, - int slice_id, - int frameP, - sub_frame_t subframeP, - uint16_t *first_rb); - - -void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, - unsigned char cooperation_flag, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframe, - uint16_t *first_rb); - -/* Downlink Primitives */ - -void _dlsch_scheduler_pre_processor (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int *mbsfn_flag); - -void _dlsch_scheduler_pre_processor_reset (int module_idP, - int UE_id, - uint8_t CC_id, - int frameP, - int subframeP, - int N_RBG, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); - -void _dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, - int UE_id, - uint8_t CC_id, - int N_RBG, - int transmission_mode, - int min_rb_unit, - uint8_t N_RB_DL, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); ->>>>>>> feature-68-enb-agent - -/* - * Default scheduler used by the eNB agent - */ -void flexran_schedule_ue_dl_spec_default(mid_t mod_id, uint32_t frame, uint32_t subframe, - int *mbsfn_flag, Protocol__FlexranMessage **dl_info); - -/* - Uplink scheduler used by MAC agent -*/ - -void flexran_agent_schedule_ulsch_ue_spec(module_id_t module_idP, frame_t frameP, unsigned char cooperation_flag, - sub_frame_t subframeP, - unsigned char sched_subframe, Protocol__FlexranMessage **ul_info); - -/* - * Data plane function for applying the DL decisions of the scheduler - */ -void flexran_apply_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, - Protocol__FlexranMessage *dl_scheduling_info); - -/* - * Data plane function for applying the UE specific DL decisions of the scheduler - */ -void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - uint32_t n_dl_ue_data, - Protocol__FlexDlData ** - dl_ue_data); - -/* - * Data plane function for filling the DCI structure - */ -void flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, - Protocol__FlexDlDci * dl_dci); - -#endif diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c deleted file mode 100644 index 6b1c2579b2..0000000000 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c +++ /dev/null @@ -1,583 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file flexran_agent_scheduler_dataplane.c - * \brief data plane procedures related to eNB scheduling - * \author Xenofon Foukas - * \date 2016 - * \email: x.foukas@sms.ed.ac.uk - * \version 0.1 - * @ingroup _mac - - */ - -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - -#include "LAYER2/MAC/flexran_agent_mac_proto.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/flexran_dci_conversions.h" - -#include "UTIL/LOG/log.h" -#include "UTIL/LOG/vcd_signal_dumper.h" -#include "UTIL/OPT/opt.h" -#include "OCG.h" -#include "OCG_extern.h" - -#include "RRC/LITE/extern.h" -#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" - -#include "header.pb-c.h" -#include "flexran.pb-c.h" -#include "flexran_agent_extern.h" - -#include "flexran_agent_common.h" - -#include "SIMULATION/TOOLS/defs.h" // for taus - -void -flexran_apply_dl_scheduling_decisions(mid_t mod_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage * - dl_scheduling_info) -{ - - Protocol__FlexDlMacConfig *mac_config = - dl_scheduling_info->dl_mac_config_msg; - - // Check if there is anything to schedule for random access - if (mac_config->n_dl_rar > 0) { - /*TODO: call the random access data plane function */ - } - // Check if there is anything to schedule for paging/broadcast - if (mac_config->n_dl_broadcast > 0) { - /*TODO: call the broadcast/paging data plane function */ - } - // Check if there is anything to schedule for the UEs - if (mac_config->n_dl_ue_data > 0) { - flexran_apply_ue_spec_scheduling_decisions(mod_id, frame, subframe, - mbsfn_flag, - mac_config-> - n_dl_ue_data, - mac_config->dl_ue_data); - } - -} - -void -flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - uint32_t n_dl_ue_data, - Protocol__FlexDlData ** - dl_ue_data) -{ - - uint8_t CC_id; - int UE_id; - mac_rlc_status_resp_t rlc_status; - unsigned char ta_len = 0; - unsigned char header_len = 0, header_len_tmp = 0; - unsigned char sdu_lcids[11], offset, num_sdus = 0; - uint16_t nb_rb; - uint16_t TBS, sdu_lengths[11], rnti, padding = 0, post_padding = 0; - unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; - uint8_t round = 0; - uint8_t harq_pid = 0; - // LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint16_t sdu_length_total = 0; - short ta_update = 0; - eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; - UE_list_t *UE_list = &eNB->UE_list; - // static int32_t tpc_accumulated=0; - UE_sched_ctrl *ue_sched_ctl; - - int last_sdu_header_len = 0; - - int i, j; - - Protocol__FlexDlData *dl_data; - Protocol__FlexDlDci *dl_dci; - - uint32_t rlc_size, n_lc, lcid; - - // For each UE-related command - for (i = 0; i < n_dl_ue_data; i++) { - - dl_data = dl_ue_data[i]; - dl_dci = dl_data->dl_dci; - - CC_id = dl_data->serv_cell_index; - // frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id); - - rnti = dl_data->rnti; - UE_id = find_ue(rnti, PHY_vars_eNB_g[mod_id][CC_id]); - - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - - round = dl_dci->rv[0]; - harq_pid = dl_dci->harq_process; - - //LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d] Scheduling harq %d\n", frame, subframe, harq_pid); - // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d]Now scheduling harq_pid %d (round %d)\n", frame, subframe, harq_pid, round); - - // If this is a new transmission - if (round == 0) { - // First we have to deal with the creation of the PDU based on the message instructions - rlc_status.bytes_in_buffer = 0; - - TBS = dl_dci->tbs_size[0]; - - if (dl_data->n_ce_bitmap > 0) { - //Check if there is TA command and set the length appropriately - ta_len = - (dl_data-> - ce_bitmap[0] & PROTOCOL__FLEX_CE_TYPE__FLPCET_TA) ? 2 - : 0; - } - - num_sdus = 0; - sdu_length_total = 0; - - n_lc = dl_data->n_rlc_pdu; - // Go through each one of the channel commands and create SDUs - header_len = 0; - last_sdu_header_len = 0; - for (j = 0; j < n_lc; j++) { - sdu_lengths[j] = 0; - lcid = - dl_data->rlc_pdu[j]->rlc_pdu_tb[0]->logical_channel_id; - rlc_size = dl_data->rlc_pdu[j]->rlc_pdu_tb[0]->size; - LOG_D(MAC, - "[TEST] [eNB %d] [Frame %d] [Subframe %d], LCID %d, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - mod_id, frame, subframe, lcid, CC_id, rlc_size); - if (rlc_size > 0) { - - rlc_status = mac_rlc_status_ind(mod_id, - rnti, - mod_id, - frame, - subframe, - ENB_FLAG_YES, - MBMS_FLAG_NO, lcid, 0); - - if (rlc_status.bytes_in_buffer > 0) { - - if (rlc_status.bytes_in_buffer < rlc_size) { - rlc_size = rlc_status.bytes_in_buffer; - } - - if (rlc_size <= 2) { - rlc_size = 3; - } - - rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, subframe, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, rlc_size); // transport block set size - - LOG_D(MAC, - "[TEST] RLC can give %d bytes for LCID %d during second call\n", - rlc_status.bytes_in_buffer, lcid); - - if (rlc_status.bytes_in_buffer > 0) { - - sdu_lengths[j] = mac_rlc_data_req(mod_id, rnti, mod_id, frame, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, rlc_size, //not used - (char *) - &dlsch_buffer - [sdu_length_total]); - - LOG_D(MAC, - "[eNB %d][LCID %d] CC_id %d Got %d bytes from RLC\n", - mod_id, lcid, CC_id, sdu_lengths[j]); - sdu_length_total += sdu_lengths[j]; - sdu_lcids[j] = lcid; - - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] - += 1; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_bytes_tx - [lcid] += sdu_lengths[j]; - - if (sdu_lengths[j] < 128) { - header_len += 2; - last_sdu_header_len = 2; - } else { - header_len += 3; - last_sdu_header_len = 3; - } - num_sdus++; - } - } - } - } // SDU creation end - - - if (((sdu_length_total + header_len + ta_len) > 0)) { - - header_len_tmp = header_len; - - // If we have only a single SDU, header length becomes 1 - if ((num_sdus) == 1) { - //if (header_len == 2 || header_len == 3) { - header_len = 1; - } else { - header_len = (header_len - last_sdu_header_len) + 1; - } - - // If we need a 1 or 2 bit padding or no padding at all - if ((TBS - header_len - sdu_length_total - ta_len) <= 2 || (TBS - header_len - sdu_length_total - ta_len) > TBS) { //protect from overflow - padding = - (TBS - header_len - sdu_length_total - ta_len); - post_padding = 0; - } else { // The last sdu needs to have a length field, since we add padding - padding = 0; - header_len = header_len_tmp; - post_padding = TBS - sdu_length_total - header_len - ta_len; // 1 is for the postpadding header - } - - if (ta_len > 0) { - // Reset the measurement - ta_update = flexran_get_TA(mod_id, UE_id, CC_id); - ue_sched_ctl->ta_timer = 20; - eNB_UE_stats->timing_advance_update = 0; - } else { - ta_update = 0; - } - - // If there is nothing to schedule, just leave - if ((sdu_length_total) <= 0) { - harq_pid_updated[UE_id][harq_pid] = 1; - harq_pid_round[UE_id][harq_pid] = 0; - continue; - } - // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d] TBS is %d and bytes are %d\n", frame, subframe, TBS, sdu_length_total); - - offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus - sdu_lengths, // - sdu_lcids, 255, // no drx - ta_update, // timing advance - NULL, // contention res id - padding, post_padding); - -#ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n"); - - for (i = 0; i < 16; i++) { - LOG_T(MAC, "%x.", dlsch_buffer[i]); - } - - LOG_T(MAC, "\n"); -#endif - // cycle through SDUs and place in dlsch_buffer - memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id]. - payload[0][offset], dlsch_buffer, sdu_length_total); - // 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++) { - 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 (opt_enabled == 1) { - trace_pdu(1, - (uint8_t *) - UE_list->DLSCH_pdu[CC_id][0][UE_id]. - payload[0], TBS, mod_id, 3, UE_RNTI(mod_id, - UE_id), - eNB->frame, eNB->subframe, 0, 0); - LOG_D(OPT, - "[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", - mod_id, CC_id, frame, UE_RNTI(mod_id, UE_id), - TBS); - } - // store stats - eNB->eNB_stats[CC_id].dlsch_bytes_tx += sdu_length_total; - eNB->eNB_stats[CC_id].dlsch_pdus_tx += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi = - eNB_UE_stats->DL_cqi[0]; - - UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = - mac_eNB_get_rrc_status(mod_id, rnti); - 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; - - //nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - //Find the number of resource blocks and set them to the template for retransmissions - nb_rb = get_min_rb_unit(mod_id, CC_id); - uint16_t stats_tbs = - mac_xface->get_TBS_DL(dl_dci->mcs[0], nb_rb); - - while (stats_tbs < TBS) { - nb_rb += get_min_rb_unit(mod_id, CC_id); - stats_tbs = - mac_xface->get_TBS_DL(dl_dci->mcs[0], nb_rb); - } - - // LOG_I(FLEXRAN_AGENT, "The MCS was %d\n", dl_dci->mcs[0]); - - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += - nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = - dl_dci->mcs[0]; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = - dl_dci->mcs[0]; - UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; - - UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes = - TBS - sdu_length_total; - UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes += - sdu_length_total; - UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes += TBS; - UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus += 1; - - //eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]]; - //eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); - } else { - LOG_D(FLEXRAN_AGENT, - "No need to schedule a dci after all. Just drop it\n"); - harq_pid_updated[UE_id][harq_pid] = 1; - harq_pid_round[UE_id][harq_pid] = 0; - continue; - } - } else { - // No need to create anything apart of DCI in case of retransmission - /*TODO: Must add these */ - // eNB_UE_stats->dlsch_trials[round]++; - //UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission+=1; - //UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx=nb_rb; - //UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx+=nb_rb; - //UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx=nCCECC_id]; - } - - // UE_list->UE_template[CC_id][UE_id].oldNDI[dl_dci->harq_process] = dl_dci->ndi[0]; - // eNB_UE_stats->dlsch_mcs1 = dl_dci->mcs[0]; - - //Fill the proper DCI of OAI - flexran_fill_oai_dci(mod_id, CC_id, rnti, dl_dci); - } -} - -void -flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, - Protocol__FlexDlDci * dl_dci) -{ - - void *DLSCH_dci = NULL; - DCI_PDU *DCI_pdu; - - unsigned char harq_pid = 0; - // unsigned char round = 0; - LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; - int size_bits = 0, size_bytes = 0; - eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; - UE_list_t *UE_list = &eNB->UE_list; - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - - int UE_id = find_ue(rnti, PHY_vars_eNB_g[mod_id][CC_id]); - - uint32_t format; - - harq_pid = dl_dci->harq_process; - // round = dl_dci->rv[0]; - - // Note this code is for a specific DCI format - DLSCH_dci = - (void *) UE_list->UE_template[CC_id][UE_id].DLSCH_DCI[harq_pid]; - DCI_pdu = &eNB->common_channels[CC_id].DCI_pdu; - - frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id); - - if (dl_dci->has_tpc == 1) { - // Check if tpc has been set and reset measurement */ - if ((dl_dci->tpc == 0) || (dl_dci->tpc == 2)) { - eNB_UE_stats = - mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - eNB_UE_stats->Po_PUCCH_update = 0; - } - } - - - switch (frame_parms[CC_id]->N_RB_DL) { - case 6: - if (frame_parms[CC_id]->frame_type == TDD) { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_TDD_1(DCI1_1_5MHz_TDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_1_5MHz_TDD_t); - size_bits = sizeof_DCI1_1_5MHz_TDD_t; - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } else { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_FDD_1(DCI1_1_5MHz_FDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_1_5MHz_FDD_t); - size_bits = sizeof_DCI1_1_5MHz_FDD_t; - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } - break; - case 25: - if (frame_parms[CC_id]->frame_type == TDD) { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_TDD_1(DCI1_5MHz_TDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_5MHz_TDD_t); - size_bits = sizeof_DCI1_5MHz_TDD_t; - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } else { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_FDD_1(DCI1_5MHz_FDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_5MHz_FDD_t); - size_bits = sizeof_DCI1_5MHz_FDD_t; - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } - break; - case 50: - if (frame_parms[CC_id]->frame_type == TDD) { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_TDD_1(DCI1_10MHz_TDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_10MHz_TDD_t); - size_bits = sizeof_DCI1_10MHz_TDD_t; - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } else { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_FDD_1(DCI1_10MHz_FDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_10MHz_FDD_t); - size_bits = sizeof_DCI1_10MHz_FDD_t; - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } - break; - case 100: - if (frame_parms[CC_id]->frame_type == TDD) { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_TDD_1(DCI1_20MHz_TDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_20MHz_TDD_t); - size_bits = sizeof_DCI1_20MHz_TDD_t; - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } else { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_FDD_1(DCI1_20MHz_FDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_20MHz_FDD_t); - size_bits = sizeof_DCI1_20MHz_FDD_t; - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == - PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } - break; - } - - //Set format to the proper type - switch (dl_dci->format) { - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1: - format = format1; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1A: - format = format1A; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1B: - format = format1B; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1C: - format = format1C; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D: - format = format1E_2A_M10PRB; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2: - format = format2; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A: - format = format2A; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2B: - format = format2B; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_3: - format = 3; - break; - default: - /*TODO: Need to deal with unsupported DCI type */ - return; - } - - add_ue_spec_dci(DCI_pdu, - DLSCH_dci, - rnti, - size_bytes, dl_dci->aggr_level, size_bits, format, 0); -} diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c deleted file mode 100644 index 6445fa0845..0000000000 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ /dev/null @@ -1,1814 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file flexran_agent_scheduler_dlsch_ue.c - * \brief procedures related to eNB for the DLSCH transport channel - * \author Xenofon Foukas, Navid Nikaein and Raymond Knopp - * \date 2016 - * \email: x.foukas@sms.ed.ac.uk - * \version 0.1 - * @ingroup _mac - - */ - -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - -#include "LAYER2/MAC/flexran_agent_mac_proto.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" -#include "UTIL/LOG/log.h" -#include "UTIL/LOG/vcd_signal_dumper.h" -#include "UTIL/OPT/opt.h" -#include "OCG.h" -#include "OCG_extern.h" - -#include "RRC/LITE/extern.h" -#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" - -#include "ENB_APP/flexran_agent_defs.h" -#include "flexran_agent_ran_api.h" -#include "pdcp.h" - -#include "header.pb-c.h" -#include "flexran.pb-c.h" -#include "flexran_agent_mac.h" -#include - -#include "SIMULATION/TOOLS/defs.h" // for taus - -#if defined(ENABLE_ITTI) -#include "intertask_interface.h" -#endif - -#define ENABLE_MAC_PAYLOAD_DEBUG - -/** - * Local variables to support slicing - * - */ - - -/*!\brief UE ULSCH scheduling states*/ -typedef enum { - MIN_SLICE_STRATEGY = 0, - SLICE_MASK, - UEID_TO_SLICEID, - MAX_SLICE_STRATEGY -} SLICING_STRATEGY; - -// this assumes a max of of 16 UE per eNB/CC -#define SLICE0_MASK 0x000f -#define SLICE1_MASK 0x00f0 -#define SLICE2_MASK 0x0f00 -#define SLICE3_MASK 0xf000 - - -// number of active slices for past and current time -int n_active_slices = 1; -int n_active_slices_current = 1; - -// ue to slice mapping -int slicing_strategy = UEID_TO_SLICEID; -int slicing_strategy_current = UEID_TO_SLICEID; - -// RB share for each slice for past and current time -float avg_slice_percentage=0.25; -float slice_percentage[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; -float slice_percentage_current[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; -float total_slice_percentage = 0; -float total_slice_percentage_current = 0; - -// MAX MCS for each slice for past and current time -int slice_maxmcs[MAX_NUM_SLICES] = { 28, 28, 28, 28 }; -int slice_maxmcs_current[MAX_NUM_SLICES] = { 28, 28, 28, 28 }; - -int update_dl_scheduler[MAX_NUM_SLICES] = { 1, 1, 1, 1 }; -int update_dl_scheduler_current[MAX_NUM_SLICES] = { 1, 1, 1, 1 }; - -// name of available scheduler -char *dl_scheduler_type[MAX_NUM_SLICES] = - { "flexran_schedule_ue_spec_embb", - "flexran_schedule_ue_spec_urllc", - "flexran_schedule_ue_spec_mmtc", - "flexran_schedule_ue_spec_be" // best effort -}; - -// pointer to the slice specific scheduler -slice_scheduler_dl slice_sched_dl[MAX_NUM_SLICES] = {0}; - - -/** - * preprocessor functions for scheduling - * - */ - - -// This function stores the downlink buffer for all the logical channels -void -_store_dlsch_buffer(module_id_t Mod_id, - int slice_id, frame_t frameP, sub_frame_t subframeP) -{ - - int UE_id, i; - rnti_t rnti; - mac_rlc_status_resp_t rlc_status; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - UE_TEMPLATE *UE_template; - - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] != TRUE) - continue; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - UE_template = - &UE_list->UE_template[UE_PCCID(Mod_id, UE_id)][UE_id]; - - // clear logical channel interface variables - UE_template->dl_buffer_total = 0; - UE_template->dl_pdus_total = 0; - - for (i = 0; i < MAX_NUM_LCID; i++) { - UE_template->dl_buffer_info[i] = 0; - UE_template->dl_pdus_in_buffer[i] = 0; - UE_template->dl_buffer_head_sdu_creation_time[i] = 0; - UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = 0; - } - - rnti = UE_RNTI(Mod_id, UE_id); - - for (i = 0; i < MAX_NUM_LCID; i++) { // loop over all the logical channels - - rlc_status = - mac_rlc_status_ind(Mod_id, rnti, Mod_id, frameP, subframeP, - 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; - UE_template->dl_buffer_head_sdu_creation_time_max = - cmax(UE_template->dl_buffer_head_sdu_creation_time_max, - rlc_status.head_sdu_creation_time); - UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = - rlc_status.head_sdu_remaining_size_to_send; - UE_template->dl_buffer_head_sdu_is_segmented[i] = - rlc_status.head_sdu_is_segmented; - UE_template->dl_buffer_total += UE_template->dl_buffer_info[i]; //storing the total dlsch buffer - UE_template->dl_pdus_total += - UE_template->dl_pdus_in_buffer[i]; - -#ifdef DEBUG_eNB_SCHEDULER - - /* note for dl_buffer_head_sdu_remaining_size_to_send[i] : - * 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][SLICE %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, slice_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], - UE_template-> - dl_buffer_head_sdu_remaining_size_to_send[i], - UE_template->dl_buffer_head_sdu_is_segmented[i]); - -#endif - - } - - //#ifdef DEBUG_eNB_SCHEDULER - if (UE_template->dl_buffer_total > 0) - LOG_D(MAC, - "[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n", - Mod_id, frameP, subframeP, UE_id, - UE_template->dl_buffer_total, - UE_template->dl_pdus_total); - - //#endif - } -} - - -// This function returns the estimated number of RBs required by each UE for downlink scheduling -void -_assign_rbs_required(module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframe, - uint16_t - nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs] - [MAX_NUM_SLICES], int min_rb_unit[MAX_NUM_CCs]) -{ - - - rnti_t rnti; - uint16_t TBS = 0; - LTE_eNB_UE_stats *eNB_UE_stats[MAX_NUM_CCs]; - int UE_id, n, i, j, CC_id, pCCid, tmp; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - // UE_TEMPLATE *UE_template; - - // clear rb allocations across all CC_ids - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] != TRUE) - continue; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - pCCid = UE_PCCID(Mod_id, UE_id); - rnti = UE_list->UE_template[pCCid][UE_id].rnti; - - /* skip UE not present in PHY (for any of its active CCs) */ - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - //update CQI information across component carriers - for (n = 0; n < UE_list->numactiveCCs[UE_id]; n++) { - CC_id = UE_list->ordered_CCids[n][UE_id]; - eNB_UE_stats[CC_id] = - mac_xface->get_eNB_UE_stats(Mod_id, CC_id, rnti); - eNB_UE_stats[CC_id]->dlsch_mcs1 = - cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]; - } - - // provide the list of CCs sorted according to MCS - for (i = 0; i < UE_list->numactiveCCs[UE_id]; i++) { - for (j = i + 1; j < UE_list->numactiveCCs[UE_id]; j++) { - DevAssert(j < MAX_NUM_CCs); - - if (eNB_UE_stats[UE_list->ordered_CCids[i][UE_id]]-> - dlsch_mcs1 > - eNB_UE_stats[UE_list->ordered_CCids[j][UE_id]]-> - dlsch_mcs1) { - tmp = UE_list->ordered_CCids[i][UE_id]; - UE_list->ordered_CCids[i][UE_id] = - UE_list->ordered_CCids[j][UE_id]; - UE_list->ordered_CCids[j][UE_id] = tmp; - } - } - } - /* NN --> RK - * check the index of UE_template" - */ - if (UE_list->UE_template[pCCid][UE_id].dl_buffer_total> 0) { - LOG_D(MAC,"[preprocessor] assign RB for UE %d\n",UE_id); - - for (i=0; inumactiveCCs[UE_id]; i++) { - CC_id = UE_list->ordered_CCids[i][UE_id]; - eNB_UE_stats[CC_id] = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti); - - if (cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)] == 0) {//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(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_required[CC_id][UE_id]); - nb_rbs_allowed_slice[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage[slice_id], - flexran_get_N_RB_DL(Mod_id, CC_id)); - LOG_D(MAC,"[preprocessor] start RB assignement for UE %d CC_id %d dl buffer %d (RB unit %d, MCS %d, TBS %d) \n", - UE_id, CC_id, UE_list->UE_template[pCCid][UE_id].dl_buffer_total, - nb_rbs_required[CC_id][UE_id], flexran_get_ue_wcqi(Mod_id, UE_id), TBS); - - /* calculating required number of RBs for each UE */ - while (TBS < UE_list->UE_template[pCCid][UE_id].dl_buffer_total) { - nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; - - if (nb_rbs_required[CC_id][UE_id] > nb_rbs_allowed_slice[CC_id][slice_id]) { - TBS = mac_xface->get_TBS_DL(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_allowed_slice[CC_id][slice_id]); - nb_rbs_required[CC_id][UE_id] = nb_rbs_allowed_slice[CC_id][slice_id]; - break; - } - - TBS = mac_xface->get_TBS_DL(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_required[CC_id][UE_id]); - } // end of while - - LOG_D(MAC,"[eNB %d][SLICE %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", - Mod_id, slice_id,frameP,UE_id, CC_id, min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], TBS, cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]); - } - } - } -} - -void -_dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, - int UE_id, - uint8_t CC_id, - int N_RBG, - int transmission_mode, - int min_rb_unit, - uint8_t N_RB_DL, - uint16_t - nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_required_remaining - [MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], unsigned char - rballoc_sub[MAX_NUM_CCs] - [N_RBG_MAX], unsigned char - MIMO_mode_indicator - [MAX_NUM_CCs][N_RBG_MAX]) -{ - int i; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - for (i = 0; i < N_RBG; i++) { - - if ((rballoc_sub[CC_id][i] == 0) && - (ue_sched_ctl->rballoc_sub_UE[CC_id][i] == 0) && - (nb_rbs_required_remaining[CC_id][UE_id] > 0) && - (ue_sched_ctl->pre_nb_available_rbs[CC_id] < - nb_rbs_required[CC_id][UE_id])) { - - // if this UE is not scheduled for TM5 - if (ue_sched_ctl->dl_pow_off[CC_id] != 0) { - - if ((i == N_RBG - 1) - && ((N_RB_DL == 25) || (N_RB_DL == 50))) { - rballoc_sub[CC_id][i] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; - MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - nb_rbs_required_remaining[CC_id][UE_id] = - nb_rbs_required_remaining[CC_id][UE_id] - - min_rb_unit + 1; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = - ue_sched_ctl->pre_nb_available_rbs[CC_id] + - min_rb_unit - 1; - } else { - if (nb_rbs_required_remaining[CC_id][UE_id] >= - min_rb_unit) { - rballoc_sub[CC_id][i] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; - MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - nb_rbs_required_remaining[CC_id][UE_id] = - nb_rbs_required_remaining[CC_id][UE_id] - - min_rb_unit; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = - ue_sched_ctl->pre_nb_available_rbs[CC_id] + - min_rb_unit; - } - } - } // dl_pow_off[CC_id][UE_id] ! = 0 - } - } -} - -void -_dlsch_scheduler_pre_processor_reset(int module_idP, - int UE_id, - uint8_t CC_id, - int frameP, - int subframeP, - int N_RBG, - uint16_t nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_required_remaining - [MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_allowed_slice[MAX_NUM_CCs] - [MAX_NUM_SLICES], unsigned char - rballoc_sub[MAX_NUM_CCs] - [N_RBG_MAX], unsigned char - MIMO_mode_indicator[MAX_NUM_CCs] - [N_RBG_MAX]) -{ - int i, j; - UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - uint8_t *vrb_map = - eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map; - int RBGsize = - PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL / N_RBG; -#ifdef SF05_LIMIT - //int subframe05_limit=0; - int sf05_upper = -1, sf05_lower = -1; -#endif - // LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); - - flexran_update_TA(module_idP, UE_id, CC_id); - - if (UE_id == 0) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME - (VCD_SIGNAL_DUMPER_VARIABLES_UE0_TIMING_ADVANCE, - ue_sched_ctl->ta_update); - } - nb_rbs_required[CC_id][UE_id] = 0; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; - ue_sched_ctl->dl_pow_off[CC_id] = 2; - nb_rbs_required_remaining[CC_id][UE_id] = 0; - for (i = 0; i < n_active_slices; i++) - nb_rbs_allowed_slice[CC_id][i] = 0; -#ifdef SF05_LIMIT - switch (N_RBG) { - case 6: - sf05_lower = 0; - sf05_upper = 5; - break; - case 8: - sf05_lower = 2; - sf05_upper = 5; - break; - case 13: - sf05_lower = 4; - sf05_upper = 7; - break; - case 17: - sf05_lower = 7; - sf05_upper = 9; - break; - case 25: - sf05_lower = 11; - sf05_upper = 13; - break; - } -#endif - // Initialize Subbands according to VRB map - for (i = 0; i < N_RBG; i++) { - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 0; - rballoc_sub[CC_id][i] = 0; -#ifdef SF05_LIMIT - // for avoiding 6+ PRBs around DC in subframe 0-5 (avoid excessive errors) - - if ((subframeP == 0 || subframeP == 5) && - (i >= sf05_lower && i <= sf05_upper)) - rballoc_sub[CC_id][i] = 1; -#endif - // for SI-RNTI,RA-RNTI and P-RNTI allocations - for (j = 0; j < RBGsize; j++) { - if (vrb_map[j + (i * RBGsize)] != 0) { - rballoc_sub[CC_id][i] = 1; - LOG_D(MAC, "Frame %d, subframe %d : vrb %d allocated\n", - frameP, subframeP, j + (i * RBGsize)); - break; - } - } - LOG_D(MAC, "Frame %d Subframe %d CC_id %d RBG %i : rb_alloc %d\n", - frameP, subframeP, CC_id, i, rballoc_sub[CC_id][i]); - MIMO_mode_indicator[CC_id][i] = 2; - } -} - -// This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done -void -_dlsch_scheduler_pre_processor(module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], int *mbsfn_flag) -{ - - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], total_ue_count; - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; - int UE_id, i; - uint8_t round = 0; - uint8_t harq_pid = 0; - uint16_t ii, j; - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t average_rbs_per_user[MAX_NUM_CCs] = { 0 }; - rnti_t rnti; - int min_rb_unit[MAX_NUM_CCs]; - uint16_t r1 = 0; - uint8_t CC_id; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs] = { 0 }; - - int transmission_mode = 0; - UE_sched_ctrl *ue_sched_ctl; - - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - - if (mbsfn_flag[CC_id] > 0) // If this CC is allocated for MBSFN skip it here - continue; - - frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id, CC_id); - - - min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); - - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) - continue; - - UE_id = i; - // Initialize scheduling information for all active UEs - - //if (flexran_slice_member(UE_id, slice_id) == 0) - //continue; - _dlsch_scheduler_pre_processor_reset(Mod_id, - UE_id, - CC_id, - frameP, - subframeP, - N_RBG[CC_id], - nb_rbs_required, - nb_rbs_required_remaining, - nb_rbs_allowed_slice, - rballoc_sub, - MIMO_mode_indicator); - - } - } - - - /* Store the DLSCH buffer for each logical channel for each UE */ - _store_dlsch_buffer (Mod_id,slice_id,frameP,subframeP); - - // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - _assign_rbs_required (Mod_id,slice_id, frameP,subframeP,nb_rbs_required,nb_rbs_allowed_slice,min_rb_unit); - - // Sorts the user on the basis of dlsch logical channel buffer and CQI - sort_UEs (Mod_id,frameP,subframeP); - - total_ue_count = 0; - - // loop over all active UEs - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { - rnti = flexran_get_ue_crnti(Mod_id, i); - if(rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - UE_id = i; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - for (ii=0; ii < UE_num_active_CC(UE_list,UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][slice_id]; - flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_DL); - - // if there is no available harq_process, skip the UE - if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id]<0) - continue; - - average_rbs_per_user[CC_id]=0; - - frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id,CC_id); - - // mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&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) { - total_ue_count = total_ue_count + 1; - } - - - // hypotetical assignement - /* - * If schedule is enabled and if the priority of the UEs is modified - * The average rbs per logical channel per user will depend on the level of - * priority. Concerning the hypothetical assignement, we should assign more - * rbs to prioritized users. Maybe, we can do a mapping between the - * average rbs per user and the level of priority or multiply the average rbs - * per user by a coefficient which represents the degree of priority. - */ - - if (total_ue_count == 0) { - average_rbs_per_user[CC_id] = 0; - } else if( (min_rb_unit[CC_id] * total_ue_count) <= nb_rbs_allowed_slice[CC_id][slice_id] ) { - average_rbs_per_user[CC_id] = (uint16_t) floor(nb_rbs_allowed_slice[CC_id][slice_id]/total_ue_count); - } 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); - - if(rnti == NOT_A_RNTI) - continue; - - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - if (flexran_slice_member(i, slice_id) == 0) - continue; - - for (ii=0; iiordered_CCids[ii][i]; - - // control channel - 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 { - nb_rbs_required_remaining_1[CC_id][i] = cmin(average_rbs_per_user[CC_id],nb_rbs_required[CC_id][i]); - - } - } - - // 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); - - if (rnti == NOT_A_RNTI) - continue; - - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - if (flexran_slice_member(i, slice_id) == 0) - continue; - - for (ii = 0; ii < UE_num_active_CC(UE_list, i); ii++) { - CC_id = UE_list->ordered_CCids[ii][i]; - - // control channel - 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 { - nb_rbs_required_remaining_1[CC_id][i] = - cmin(average_rbs_per_user[CC_id], - nb_rbs_required[CC_id][i]); - - } - } - } - - //Allocation to UEs is done in 2 rounds, - // 1st stage: average number of RBs allocated to each UE - // 2nd stage: remaining RBs are allocated to high priority UEs - for (r1 = 0; r1 < 2; r1++) { - - for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { - - if (flexran_slice_member(i, slice_id) == 0) - continue; - - for (ii = 0; ii < UE_num_active_CC(UE_list, i); ii++) { - CC_id = UE_list->ordered_CCids[ii][i]; - - 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 - 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", - r1, CC_id, i, - nb_rbs_required_remaining[CC_id][i], - nb_rbs_required_remaining_1[CC_id][i], - nb_rbs_required[CC_id][i], - UE_list->UE_sched_ctrl[i]. - pre_nb_available_rbs[CC_id], N_RBG[CC_id], - min_rb_unit[CC_id]); - - } - } - - if (total_ue_count > 0) { - for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { - UE_id = i; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - flexran_get_harq(Mod_id, CC_id, UE_id, frameP, - subframeP, &harq_pid, &round); - rnti = UE_RNTI(Mod_id, UE_id); - - // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); - if (rnti == NOT_A_RNTI) - continue; - - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) - continue; - - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - transmission_mode = - mac_xface->get_transmission_mode(Mod_id, CC_id, - rnti); - //rrc_status = mac_eNB_get_rrc_status(Mod_id,rnti); - /* 1st allocate for the retx */ - - // retransmission in data channels - // control channel in the 1st transmission - // data channel for all TM - LOG_T(MAC, - "calling dlsch_scheduler_pre_processor_allocate .. \n "); - _dlsch_scheduler_pre_processor_allocate(Mod_id, UE_id, - CC_id, - N_RBG[CC_id], - transmission_mode, - min_rb_unit - [CC_id], - frame_parms - [CC_id]-> - N_RB_DL, - nb_rbs_required, - nb_rbs_required_remaining, - rballoc_sub, - MIMO_mode_indicator); - } - } - } // total_ue_count - } // end of for for r1 and r2 - - for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { - UE_id = i; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - for (ii=0; iiordered_CCids[ii][UE_id]; - flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_DL); - rnti = UE_RNTI(Mod_id,UE_id); - - // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); - if(rnti == NOT_A_RNTI) - continue; - - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) - continue; - - if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { - LOG_D(MAC, - "******************DL Scheduling Information for UE%d ************************\n", - UE_id); - LOG_D(MAC, "dl power offset UE%d = %d \n", UE_id, - ue_sched_ctl->dl_pow_off[CC_id]); - LOG_D(MAC, - "***********RB Alloc for every subband for UE%d ***********\n", - UE_id); - - for (j = 0; j < N_RBG[CC_id]; j++) { - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; - LOG_D(MAC, "RB Alloc for UE%d and Subband%d = %d\n", - UE_id, j, - ue_sched_ctl->rballoc_sub_UE[CC_id][j]); - } - - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; - LOG_D(MAC, - "[eNB %d][SLICE %d] Total RBs allocated for UE%d = %d\n", - Mod_id, slice_id, UE_id, - ue_sched_ctl->pre_nb_available_rbs[CC_id]); - } - } - } - } -} - -#define SF05_LIMIT 1 - -/* - * Main Downlink Slicing - * - */ - -void -flexran_schedule_ue_dl_spec_default(mid_t mod_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) -//------------------------------------------------------------------------------ -{ - int i=0; - - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); - - total_slice_percentage=0; - avg_slice_percentage=1.0/n_active_slices; - - // reset the slice percentage for inactive slices - for (i = n_active_slices; i< MAX_NUM_SLICES; i++) { - slice_percentage[i]=0; - } - for (i = 0; i < n_active_slices; i++) { - if (slice_percentage[i] < 0 ){ - LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %f. resetting to zero", - mod_id, frame, subframe, i, slice_percentage[i]); - slice_percentage[i]=0; - } - total_slice_percentage+=slice_percentage[i]; - } - - for (i = 0; i < n_active_slices; i++) { - - // Load any updated functions - if (update_dl_scheduler[i] > 0 ) { - slice_sched_dl[i] = dlsym(NULL, dl_scheduler_type[i]); - update_dl_scheduler[i] = 0; - update_dl_scheduler_current[i] = 0; - LOG_N(MAC,"update dl scheduler slice %d\n", i); - } - - if (total_slice_percentage <= 1.0){ // the new total RB share is within the range - - // check if the number of slices has changed, and log - if (n_active_slices_current != n_active_slices ){ - if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { - LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active DL slices has changed: %d-->%d\n", - mod_id, frame, subframe, n_active_slices_current, n_active_slices); - - n_active_slices_current = n_active_slices; - - } else { - LOG_W(MAC,"invalid number of DL slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); - n_active_slices = n_active_slices_current; - } - } - - // check if the slice rb share has changed, and log the console - if (slice_percentage_current[i] != slice_percentage[i]){ // new slice percentage - LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: total percentage %f-->%f, slice RB percentage has changed: %f-->%f\n", - mod_id, i, frame, subframe, total_slice_percentage_current, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); - total_slice_percentage_current= total_slice_percentage; - slice_percentage_current[i] = slice_percentage[i]; - - } - - // check if the slice max MCS, and log the console - if (slice_maxmcs_current[i] != slice_maxmcs[i]){ - if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)){ - LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", - mod_id, i, frame, subframe, slice_maxmcs_current[i], slice_maxmcs[i]); - slice_maxmcs_current[i] = slice_maxmcs[i]; - } else { - LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs[i],slice_maxmcs_current[i]); - slice_maxmcs[i]= slice_maxmcs_current[i]; - } - } - - // check if a new scheduler, and log the console - if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ - LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", - mod_id, i, frame, subframe, dl_scheduler_type[i]); - update_dl_scheduler_current[i] = update_dl_scheduler[i]; - } - - } else { - // here we can correct the values, e.g. reduce proportionally - - if (n_active_slices == n_active_slices_current){ - LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid total RB share (%f->%f), reduce proportionally the RB share by 0.1\n", - mod_id,i, - total_slice_percentage_current, total_slice_percentage); - if (slice_percentage[i] >= avg_slice_percentage){ - slice_percentage[i]-=0.1; - total_slice_percentage-=0.1; - } - } else { - LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid total RB share (%f->%f), revert the number of slice to its previous value (%d->%d)\n", - mod_id,i, - total_slice_percentage_current, total_slice_percentage, - n_active_slices, n_active_slices_current ); - n_active_slices = n_active_slices_current; - slice_percentage[i] = slice_percentage_current[i]; - } - } - - // Run each enabled slice-specific schedulers one by one - slice_sched_dl[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); - } -} - -uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs) -{ - return (uint16_t) floor(rb_percentage * total_rbs); -} - -int flexran_slice_maxmcs(int slice_id) -{ - return slice_maxmcs[slice_id]; -} - -int flexran_slice_member(int UE_id, int slice_id) -{ - // group membership definition - int slice_member = 0; - - if ((slice_id < 0) || (slice_id > n_active_slices)) - LOG_W(MAC, "out of range slice id %d\n", slice_id); - - switch (slicing_strategy) { - case SLICE_MASK: - switch (slice_id) { - case 0: - if (SLICE0_MASK & UE_id) { - slice_member = 1; - } - break; - case 1: - if (SLICE1_MASK & UE_id) { - slice_member = 1; - } - break; - case 2: - if (SLICE2_MASK & UE_id) { - slice_member = 1; - } - break; - case 3: - if (SLICE3_MASK & UE_id) { - slice_member = 1; - } - break; - default: - LOG_W(MAC, "unknown slice_id %d\n", slice_id); - break; - - } - break; - case UEID_TO_SLICEID: - default: - if ((UE_id % n_active_slices) == slice_id) { - slice_member = 1; // this ue is a member of this slice - } - break; - } - - return slice_member; -} - -/* more aggressive rb and mcs allocation with medium priority and the traffic qci */ -void -flexran_schedule_ue_spec_embb(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info) -{ - flexran_schedule_ue_dl_spec_common(mod_id, - slice_id, - frame, - subframe, - mbsfn_flag, - dl_info); -} - -/* more conservative mcs allocation with high priority and the traffic qci */ -void -flexran_schedule_ue_spec_urllc(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info) -{ - flexran_schedule_ue_dl_spec_common(mod_id, - slice_id, - frame, - subframe, - mbsfn_flag, - dl_info); -} - -/* constant rb allocation with low mcs with low priority and given the UE capabilities */ -void -flexran_schedule_ue_spec_mmtc(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info) -{ - flexran_schedule_ue_dl_spec_common(mod_id, - slice_id, - frame, - subframe, - mbsfn_flag, - dl_info); -} - -/* regular rb and mcs allocation with low priority */ -void -flexran_schedule_ue_spec_be(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info) -{ - flexran_schedule_ue_dl_spec_common(mod_id, - slice_id, - frame, - subframe, - mbsfn_flag, - dl_info); -} - -//------------------------------------------------------------------------------ -void -flexran_schedule_ue_dl_spec_common(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) -//------------------------------------------------------------------------------ -{ - uint8_t CC_id; - int UE_id; - int N_RBG[MAX_NUM_CCs]; - unsigned char aggregation; - mac_rlc_status_resp_t rlc_status; - unsigned char header_len = 0, header_len_last = 0, ta_len = 0; - uint16_t nb_rb, nb_rb_temp, total_nb_available_rb[MAX_NUM_CCs], - nb_available_rb; - uint16_t TBS, j, rnti; - uint8_t round = 0; - uint8_t harq_pid = 0; - uint16_t sdu_length_total = 0; - int mcs, mcs_tmp; - uint16_t min_rb_unit[MAX_NUM_CCs]; - eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; - /* TODO: Must move the helper structs to scheduler implementation */ - UE_list_t *UE_list = &eNB->UE_list; - int32_t normalized_rx_power, target_rx_power; - int32_t tpc = 1; - static int32_t tpc_accumulated = 0; - UE_sched_ctrl *ue_sched_ctl; - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - Protocol__FlexDlData *dl_data[NUM_MAX_UE]; - int num_ues_added = 0; - int channels_added = 0; - - Protocol__FlexDlDci *dl_dci; - Protocol__FlexRlcPdu *rlc_pdus[11]; - uint32_t ce_flags = 0; - - uint8_t rballoc_sub[25]; - int i; - uint32_t data_to_request; - uint32_t dci_tbs; - uint8_t ue_has_transmission = 0; - uint32_t ndi; - -#if 0 - - if (UE_list->head == -1) { - return; - } -#endif - - start_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); - - //weight = get_ue_weight(module_idP,UE_id); - aggregation = 1; // set to the maximum aggregation level - - for (CC_id=0; CC_idcommon_channels[CC_id].vrb_map[i] != 0) - total_nb_available_rb[CC_id]--; - - N_RBG[CC_id] = flexran_get_N_RBG(mod_id, CC_id); - - // store the global enb stats: - eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; - eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].total_available_prbs += total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].dlsch_bytes_tx=0; - eNB->eNB_stats[CC_id].dlsch_pdus_tx=0; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN); - - start_meas(&eNB->schedule_dlsch_preprocessor); - _dlsch_scheduler_pre_processor(mod_id, - slice_id, - frame, - subframe, - N_RBG, - mbsfn_flag); - stop_meas(&eNB->schedule_dlsch_preprocessor); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); - - for (CC_id=0; CC_id0) - continue; - - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - - rnti = flexran_get_ue_crnti(mod_id, UE_id); - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - if (eNB_UE_stats==NULL) { - - LOG_D(MAC,"[eNB] Cannot find eNB_UE_stats\n"); - // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - continue; - } - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - 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; - } - - switch(mac_xface->get_transmission_mode(mod_id,CC_id,rnti)){ - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(mod_id,CC_id), - eNB_UE_stats->DL_cqi[0], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(mod_id,CC_id), - eNB_UE_stats->DL_cqi[0], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", mac_xface->get_transmission_mode(mod_id,CC_id,rnti)); - aggregation = 2; - } - - if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated - CCE_allocation_infeasible(mod_id, CC_id, 0, subframe, aggregation, rnti)) { - - LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", - mod_id, frame, UE_id, CC_id); - //if(mac_xface->get_transmission_mode(module_idP,rnti)==5) - continue; //to next user (there might be rbs availiable for other UEs in TM5 - // else - // break; - } - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - set_ue_dai (subframe, - flexran_get_subframe_assignment(mod_id, CC_id), - UE_id, - CC_id, - UE_list); - //TODO: update UL DAI after DLSCH scheduling - //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe,frame_parms); - } - - channels_added = 0; - - // After this point all the UEs will be scheduled - dl_data[num_ues_added] = (Protocol__FlexDlData *) malloc(sizeof(Protocol__FlexDlData)); - protocol__flex_dl_data__init(dl_data[num_ues_added]); - dl_data[num_ues_added]->has_rnti = 1; - dl_data[num_ues_added]->rnti = rnti; - dl_data[num_ues_added]->n_rlc_pdu = 0; - dl_data[num_ues_added]->has_serv_cell_index = 1; - dl_data[num_ues_added]->serv_cell_index = CC_id; - - flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round, openair_harq_DL); - sdu_length_total=0; - mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; - // LOG_I(FLEXRAN_AGENT, "The MCS is %d\n", mcs); - mcs = cmin(mcs,flexran_slice_maxmcs(slice_id)); -// #ifdef EXMIMO - -// if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti) == 5) { -// mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; -// mcs = cmin(mcs,16); -// } - -// #endif - - /*Get pre available resource blocks based on buffers*/ - nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - // initializing the rb allocation indicator for each UE - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0; - rballoc_sub[j] = 0; - } - - /* LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", */ - /* mod_id, frame, UE_id, CC_id, rnti, harq_pid, round, nb_available_rb, */ - /* eNB_UE_stats->DL_cqi[0], mcs, */ - /* UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); */ - - dl_dci = (Protocol__FlexDlDci*) malloc(sizeof(Protocol__FlexDlDci)); - protocol__flex_dl_dci__init(dl_dci); - dl_data[num_ues_added]->dl_dci = dl_dci; - - - dl_dci->has_rnti = 1; - dl_dci->rnti = rnti; - dl_dci->has_harq_process = 1; - dl_dci->harq_process = harq_pid; - - /* process retransmission */ - if (round > 0) { - - LOG_D(FLEXRAN_AGENT, "There was a retransmission just now and the round was %d\n", round); - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); - LOG_D(MAC,"DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", - CC_id, subframe,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); - } - - mcs = UE_list->UE_template[CC_id][UE_id].mcs[harq_pid]; - - // get freq_allocation - nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - - /*TODO: Must add this to FlexRAN agent API */ - dci_tbs = mac_xface->get_TBS_DL(mcs, nb_rb); - - if (nb_rb <= nb_available_rb) { - - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; - - while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && - ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| - (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; - } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; - } - } - j = j + 1; - } - } - - nb_available_rb -= nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j=0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } - - // Keep the old NDI, do not toggle - ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - tpc = UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid]; - UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; - - ue_has_transmission = 1; - num_ues_added++; - } else { - LOG_D(MAC,"[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", - mod_id, frame, CC_id, UE_id); - ue_has_transmission = 0; - } - //End of retransmission - } - - else { /* This is a potentially new SDU opportunity */ - rlc_status.bytes_in_buffer = 0; - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - //TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb); - TBS = mac_xface->get_TBS_DL(mcs, nb_available_rb); - dci_tbs = TBS; - LOG_D(FLEXRAN_AGENT, "TBS is %d\n", TBS); - - // check first for RLC data on DCCH - // add the length for all the control elements (timing adv, drx, etc) : header + payload - - ta_len = (ue_sched_ctl->ta_update != 0) ? 2 : 0; - - dl_data[num_ues_added]->n_ce_bitmap = 2; - dl_data[num_ues_added]->ce_bitmap = (uint32_t *) calloc(2, sizeof(uint32_t)); - - if (ta_len > 0) { - ce_flags |= PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; - } - - /*TODO: Add other flags if DRX and other CE are required*/ - - // Add the control element flags to the flexran message - dl_data[num_ues_added]->ce_bitmap[0] = ce_flags; - dl_data[num_ues_added]->ce_bitmap[1] = ce_flags; - - // TODO : Need to prioritize DRBs - // Loop through the UE logical channels (DCCH, DCCH1, DTCH for now) - header_len = 0; - header_len_last = 0; - sdu_length_total = 0; - for (j = 1; j < NB_RB_MAX; j++) { - header_len += 3; - // Need to see if we have space for data from this channel - if (dci_tbs - ta_len - header_len - sdu_length_total > 0) { - LOG_D(MAC, "[TEST]Requested %d bytes from RLC buffer on channel %d during first call\n", dci_tbs-ta_len-header_len, j); - //If we have space, we need to see how much data we can request at most (if any available) - rlc_status = mac_rlc_status_ind(mod_id, - rnti, - mod_id, - frame, - subframe, - ENB_FLAG_YES, - MBMS_FLAG_NO, - j, - (dci_tbs - ta_len - header_len - sdu_length_total)); // transport block set size - - //If data are available in channel j - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, "[TEST]Have %d bytes in DCCH buffer during first call\n", rlc_status.bytes_in_buffer); - //Fill in as much as possible - data_to_request = cmin(dci_tbs - ta_len - header_len - sdu_length_total, rlc_status.bytes_in_buffer); - LOG_D(FLEXRAN_AGENT, "Will request %d bytes from channel %d\n", data_to_request, j); - - if (data_to_request < 128) { //The header will be one byte less - header_len--; - header_len_last = 2; - } - else { - - header_len_last = 3; - } - /* if (j == 1 || j == 2) { - data_to_request+=0; - } */ - LOG_D(MAC, "[TEST]Will request %d from channel %d\n", data_to_request, j); - rlc_pdus[channels_added] = (Protocol__FlexRlcPdu *) malloc(sizeof(Protocol__FlexRlcPdu)); - protocol__flex_rlc_pdu__init(rlc_pdus[channels_added]); - rlc_pdus[channels_added]->n_rlc_pdu_tb = 2; - rlc_pdus[channels_added]->rlc_pdu_tb = (Protocol__FlexRlcPduTb **) malloc(sizeof(Protocol__FlexRlcPduTb *) * 2); - rlc_pdus[channels_added]->rlc_pdu_tb[0] = (Protocol__FlexRlcPduTb *) malloc(sizeof(Protocol__FlexRlcPduTb)); - protocol__flex_rlc_pdu_tb__init(rlc_pdus[channels_added]->rlc_pdu_tb[0]); - rlc_pdus[channels_added]->rlc_pdu_tb[0]->has_logical_channel_id = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->logical_channel_id = j; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->has_size = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->size = data_to_request; - rlc_pdus[channels_added]->rlc_pdu_tb[1] = (Protocol__FlexRlcPduTb *) malloc(sizeof(Protocol__FlexRlcPduTb)); - protocol__flex_rlc_pdu_tb__init(rlc_pdus[channels_added]->rlc_pdu_tb[1]); - rlc_pdus[channels_added]->rlc_pdu_tb[1]->has_logical_channel_id = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->logical_channel_id = j; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->has_size = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->size = data_to_request; - dl_data[num_ues_added]->n_rlc_pdu++; - channels_added++; - //Set this to the max value that we might request - sdu_length_total += data_to_request; - } else { - //Take back the assumption of a header for this channel - header_len -= 3; - } //End rlc_status.bytes_in_buffer <= 0 - } //end of if dci_tbs - ta_len - header_len > 0 - } // End of iterating the logical channels - - // Add rlc_pdus to the dl_data message - dl_data[num_ues_added]->rlc_pdu = (Protocol__FlexRlcPdu **) malloc(sizeof(Protocol__FlexRlcPdu *) * - dl_data[num_ues_added]->n_rlc_pdu); - for (i = 0; i < dl_data[num_ues_added]->n_rlc_pdu; i++) { - dl_data[num_ues_added]->rlc_pdu[i] = rlc_pdus[i]; - } - - if (header_len == 0) { - LOG_D(FLEXRAN_AGENT, "Header was empty\n"); - header_len_last = 0; - } - - // there is a payload - if ((dl_data[num_ues_added]->n_rlc_pdu > 0)) { - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - // adjust header lengths - LOG_D(FLEXRAN_AGENT, "We have %d bytes to transfer\n", sdu_length_total); - if (header_len != 0) { - LOG_D(FLEXRAN_AGENT, "Header length was %d ", header_len); - header_len_last--; - header_len -= header_len_last; - LOG_D(FLEXRAN_AGENT, "so we resized it to %d\n", header_len); - } - - /* if (header_len == 2 || header_len == 3) { //Only one SDU, remove length field */ - /* header_len = 1; */ - /* } else { //Remove length field from the last SDU */ - /* header_len--; */ - /* } */ - - mcs_tmp = mcs; - if (mcs_tmp == 0) { - nb_rb = 4; // don't let the TBS get too small - } else { - nb_rb=min_rb_unit[CC_id]; - } - - LOG_D(MAC,"[TEST]The initial number of resource blocks was %d\n", nb_rb); - LOG_D(MAC,"[TEST] The initial mcs was %d\n", mcs_tmp); - - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - LOG_D(MAC,"[TEST]The TBS during rate matching was %d\n", TBS); - - while (TBS < (sdu_length_total + header_len + ta_len)) { - nb_rb += min_rb_unit[CC_id]; // - LOG_D(MAC, "[TEST]Had to increase the number of RBs\n"); - if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_available_rb); - nb_rb = nb_available_rb; - break; - } - - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - LOG_D(MAC, "[TEST]We had the exact number of rbs. Time to fill the rballoc subband\n"); - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } - else { - nb_rb_temp = nb_rb; - j = 0; - LOG_D(MAC, "[TEST]Will only partially fill the bitmap\n"); - while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - if ((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && - ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| - (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1; - } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; - } - } - j = j+1; - } - } - - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - PHY_vars_eNB_g[mod_id][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 + ta_len)) && (mcs_tmp > 0)) { - mcs_tmp--; - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < (sdu_length_total + header_len + ta_len)) && - ((( ue_sched_ctl->dl_pow_off[CC_id] > 0) && (mcs_tmp < 28)) || ( (ue_sched_ctl->dl_pow_off[CC_id]==0) && (mcs_tmp <= 15)))) { - mcs_tmp++; - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - dci_tbs = TBS; - mcs = mcs_tmp; - LOG_D(FLEXRAN_AGENT, "Final mcs was %d\n", mcs); - - dl_dci->has_aggr_level = 1; - dl_dci->aggr_level = aggregation; - - UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; - - // if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - // UE_list->UE_template[CC_id][UE_id].DAI++; - // // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); - //#warning only for 5MHz channel - // update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); - // } - - // do PUCCH power control - // this is the normalized RX power - normalized_rx_power = flexran_get_p0_pucch_dbm(mod_id,UE_id, CC_id); //eNB_UE_stats->Po_PUCCH_dBm; - target_rx_power = flexran_get_p0_nominal_pucch(mod_id, CC_id) + 20; //mac_xface->get_target_pucch_rx_power(mod_id, CC_id) + 20; - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; - - if (((framex10psubframe+10)<=(frame*10+subframe)) || //normal case - ((framex10psubframe>(frame*10+subframe)) && (((10240-framex10psubframe+frame*10+subframe)>=10)))) //frame wrap-around - if (flexran_get_p0_pucch_status(mod_id, UE_id, CC_id) == 1) { - flexran_update_p0_pucch(mod_id, UE_id, CC_id); - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frame; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframe; - if (normalized_rx_power>(target_rx_power+1)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-1)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - mod_id, frame, subframe, harq_pid, tpc, - tpc_accumulated, normalized_rx_power, target_rx_power); - } // Po_PUCCH has been updated - else { - tpc = 1; //0 - } // time to do TPC update - else { - tpc = 1; //0 - } - - for(i=0; iframe_parms.N_RBG; i++) { - rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; - } - - // Toggle NDI - LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", - CC_id, frame, subframe, 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]; - ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - - UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; - UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid] = tpc; - - // Increase the pointer for the number of scheduled UEs - num_ues_added++; - ue_has_transmission = 1; - } else { // There is no data from RLC or MAC header, so don't schedule - ue_has_transmission = 0; - } - } // End of new scheduling - - // If we has transmission or retransmission - if (ue_has_transmission) { - switch (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)) { - case 1: - case 2: - default: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->n_tbs_size = 1; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 3: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 2; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->ndi[1] = ndi; - dl_dci->n_rv = 2; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->rv[1] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 2; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->mcs[1] = mcs; - dl_dci->n_tbs_size = 2; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - dl_dci->tbs_size[1] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 4: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 2; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->ndi[1] = ndi; - dl_dci->n_rv = 2; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->rv[1] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 2; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->mcs[1] = mcs; - dl_dci->n_tbs_size = 2; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - dl_dci->tbs_size[1] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 5: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->n_tbs_size = 1; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - - if(ue_sched_ctl->dl_pow_off[CC_id] == 2) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - - dl_dci->has_dl_power_offset = 1; - dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; - dl_dci->has_precoding_info = 1; - dl_dci->precoding_info = 5; // Is this right?? - - break; - case 6: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - - dl_dci->has_dl_power_offset = 1; - dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; - dl_dci->has_precoding_info = 1; - dl_dci->precoding_info = 5; // Is this right?? - break; - } - } - - // if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - - /* TODO */ - //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe, frame_parms); - // } - } // UE_id loop - } // CC_id loop - - // Add all the dl_data elements to the flexran message - int offset = (*dl_info)->dl_mac_config_msg->n_dl_ue_data; - (*dl_info)->dl_mac_config_msg->n_dl_ue_data += num_ues_added; - if ( num_ues_added > 0 ){ - (*dl_info)->dl_mac_config_msg->dl_ue_data = (Protocol__FlexDlData **) realloc( (*dl_info)->dl_mac_config_msg->dl_ue_data, - sizeof(Protocol__FlexDlData *) * ((*dl_info)->dl_mac_config_msg->n_dl_ue_data)); - if ((*dl_info)->dl_mac_config_msg->dl_ue_data == NULL ){ - LOG_E(MAC, "Request for memory reallocation failed\n"); - return; - } - for (i = 0; i < num_ues_added; i++) { - (*dl_info)->dl_mac_config_msg->dl_ue_data[offset+i] = dl_data[i]; - } - } - - stop_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); -} diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c deleted file mode 100644 index 2b0bf72015..0000000000 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file flexran_agent_scheduler_dlsch_ue_remote.c - * \brief procedures related to remote scheduling in the DLSCH transport channel - * \author Xenofon Foukas - * \date 2016 - * \email: x.foukas@sms.ed.ac.uk - * \version 0.1 - * @ingroup _mac - - */ - -#include "flexran_agent_common_internal.h" -#include "flexran_agent_ran_api.h" -#include "flexran_agent_scheduler_dlsch_ue_remote.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" - -struct DlMacConfigHead queue_head; - -int queue_initialized = 0; - -//uint32_t skip_subframe = 1; -//uint32_t period = 10; -//uint32_t sched [] = {1, 2, 3}; - -void -flexran_schedule_ue_spec_remote(mid_t mod_id, uint32_t frame, - uint32_t subframe, int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info) -{ - - - //if ((subframe == skip_subframe) && (frame % period == 0)) { - // LOG_I(MAC, "Will skip subframe %d %d\n", subframe, frame); - // for (int i = 0; i < 3; i++) { - // LOG_I(MAC, "%d\n", sched[i]); - // } - //} - - /* if (frame == 500 && subframe == 1) { */ - /* char policy[] = "rrc: \n - ul_scheduler: \n behavior : tester_function\n parameters:\n period: !!int 3\nmac: \n - dl_scheduler: \n parameters: \n period : !!int 40\n skip_subframe : !!int 3\n sched : [!!int 4, !!int 5, !!int 6]"; */ - /* apply_reconfiguration_policy(mod_id, policy, strlen(policy)); */ - /* } */ - - eNB_MAC_INST *eNB; - - if (!queue_initialized) { - TAILQ_INIT(&queue_head); - queue_initialized = 1; - } - - eNB = &eNB_mac_inst[mod_id]; - - dl_mac_config_element_t *dl_config_elem; - - int diff; - LOG_D(MAC, "[TEST] Current frame and subframe %d, %d\n", frame, - subframe); - // First we check to see if we have a scheduling decision for this sfn_sf already in our queue - while (queue_head.tqh_first != NULL) { - dl_config_elem = queue_head.tqh_first; - - diff = - get_sf_difference(mod_id, - dl_config_elem->dl_info-> - dl_mac_config_msg->sfn_sf); - // Check if this decision is for now, for a later or a previous subframe - if (diff == 0) { // Now - LOG_D(MAC, - "Found a decision for this subframe in the queue. Let's use it!\n"); - TAILQ_REMOVE(&queue_head, queue_head.tqh_first, configs); - *dl_info = dl_config_elem->dl_info; - free(dl_config_elem); - eNB->eNB_stats[mod_id].sched_decisions++; - return; - } else if (diff < 0) { //previous subframe , delete message and free memory - LOG_D(MAC, - "Found a decision for a previous subframe in the queue. Let's get rid of it\n"); - TAILQ_REMOVE(&queue_head, queue_head.tqh_first, configs); - flexran_agent_mac_destroy_dl_config(dl_config_elem->dl_info); - free(dl_config_elem); - eNB->eNB_stats[mod_id].sched_decisions++; - eNB->eNB_stats[mod_id].missed_deadlines++; - } else { // next subframe, nothing to do now - LOG_D(MAC, - "Found a decision for a future subframe in the queue. Nothing to do now\n"); - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); - return; - } - } - - //Done with the local cache. Now we need to check if something new arrived - flexran_agent_get_pending_dl_mac_config(mod_id, dl_info); - while (*dl_info != NULL) { - - diff = - get_sf_difference(mod_id, - (*dl_info)->dl_mac_config_msg->sfn_sf); - if (diff == 0) { // Got a command for this sfn_sf - LOG_D(MAC, - "Found a decision for this subframe pending. Let's use it\n"); - eNB->eNB_stats[mod_id].sched_decisions++; - return; - } else if (diff < 0) { - LOG_D(MAC, - "Found a decision for a previous subframe. Let's get rid of it\n"); - flexran_agent_mac_destroy_dl_config(*dl_info); - *dl_info = NULL; - flexran_agent_get_pending_dl_mac_config(mod_id, dl_info); - eNB->eNB_stats[mod_id].sched_decisions++; - eNB->eNB_stats[mod_id].missed_deadlines++; - } else { // Intended for future subframe. Store it in local cache - LOG_D(MAC, - "Found a decision for a future subframe in the queue. Let's store it in the cache\n"); - dl_mac_config_element_t *e = - malloc(sizeof(dl_mac_config_element_t)); - e->dl_info = *dl_info; - TAILQ_INSERT_TAIL(&queue_head, e, configs); - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); - // No need to look for another. Messages arrive ordered - return; - } - } - - // We found no pending command, so we will simply pass an empty one - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); -} - -int get_sf_difference(mid_t mod_id, uint32_t sfn_sf) -{ - int diff_in_subframes; - - uint16_t current_frame = flexran_get_current_system_frame_num(mod_id); - uint16_t current_subframe = flexran_get_current_subframe(mod_id); - uint32_t current_sfn_sf = flexran_get_sfn_sf(mod_id); - - if (sfn_sf == current_sfn_sf) { - return 0; - } - - uint16_t frame_mask = ((1 << 12) - 1); - uint16_t frame = (sfn_sf & (frame_mask << 4)) >> 4; - - uint16_t sf_mask = ((1 << 4) - 1); - uint16_t subframe = (sfn_sf & sf_mask); - - LOG_D(MAC, "[TEST] Target frame and subframe %d, %d\n", frame, - subframe); - - if (frame == current_frame) { - return subframe - current_subframe; - } else if (frame > current_frame) { - diff_in_subframes = - ((frame * 10) + subframe) - ((current_frame * 10) + - current_subframe); - - // diff_in_subframes = 9 - current_subframe; - //diff_in_subframes += (subframe + 1); - //diff_in_subframes += (frame-2) * 10; - if (diff_in_subframes > SCHED_AHEAD_SUBFRAMES) { - return -1; - } else { - return 1; - } - } else { //frame < current_frame - //diff_in_subframes = 9 - current_subframe; - //diff_in_subframes += (subframe + 1); - //if (frame > 0) { - // diff_in_subframes += (frame - 1) * 10; - //} - //diff_in_subframes += (1023 - current_frame) * 10; - diff_in_subframes = - 10240 - ((current_frame * 10) + current_subframe) + - ((frame * 10) + subframe); - if (diff_in_subframes > SCHED_AHEAD_SUBFRAMES) { - return -1; - } else { - return 1; - } - } -} diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h deleted file mode 100644 index 449ba1e8cd..0000000000 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file flexran_agent_scheduler_dlsch_ue_remote.h - * \brief Local stub for remote scheduler used by the controller - * \author Xenofon Foukas - * \date 2016 - * \email: x.foukas@sms.ed.ac.uk - * \version 0.1 - * @ingroup _mac - - */ - -#ifndef __LAYER2_MAC_FLEXRAN_AGENT_SCHEDULER_DLSCH_UE_REMOTE_H__ -#define __LAYER2_MAC_FLEXRAN_AGENT_SCHEDULER_DLSCH_UE_REMOTE_H___ - -#include "flexran.pb-c.h" -#include "header.pb-c.h" - -#include "ENB_APP/flexran_agent_defs.h" -#include "flexran_agent_mac.h" -#include "LAYER2/MAC/flexran_agent_mac_proto.h" - -#include - -// Maximum value of schedule ahead of time -// Required to identify if a dl_command is for the future or not -#define SCHED_AHEAD_SUBFRAMES 20 - -typedef struct dl_mac_config_element_s { - Protocol__FlexranMessage *dl_info; - TAILQ_ENTRY(dl_mac_config_element_s) configs; -} dl_mac_config_element_t; - -TAILQ_HEAD(DlMacConfigHead, dl_mac_config_element_s); - -/* - * Default scheduler used by the eNB agent - */ -void flexran_schedule_ue_spec_remote(mid_t mod_id, uint32_t frame, - uint32_t subframe, int *mbsfn_flag, - Protocol__FlexranMessage ** dl_info); - - -// Find the difference in subframes from the given subframe -// negative for older value -// 0 for equal -// positive for future value -// Based on -int get_sf_difference(mid_t mod_id, uint32_t sfn_sf); - -#endif diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c deleted file mode 100644 index 86ea61d943..0000000000 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_ulsch_ue.c +++ /dev/null @@ -1,1112 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file eNB_scheduler_ulsch.c - * \brief FlexRAN eNB procedures for the ULSCH transport channel - * \author Navid Nikaein and shahab SHARIAT BAGHERI - * \date 2017 - * \version 1.0 - * @ingroup _mac - - */ - -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - -#include "LAYER2/MAC/flexran_agent_mac_proto.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" -#include "UTIL/LOG/log.h" -#include "UTIL/LOG/vcd_signal_dumper.h" -#include "UTIL/OPT/opt.h" -#include "OCG.h" -#include "OCG_extern.h" - -#include "RRC/LITE/extern.h" -#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" - -//#include "LAYER2/MAC/pre_processor.c" -#include "ENB_APP/flexran_agent_defs.h" -#include "flexran_agent_ran_api.h" -#include "pdcp.h" - -#include "header.pb-c.h" -#include "flexran.pb-c.h" -#include "flexran_agent_mac.h" - -#if defined(ENABLE_ITTI) -# include "intertask_interface.h" -#endif - -#include "T.h" - -#include - -/* number of active slices for past and current time*/ -int n_active_slices_uplink = 1; -int n_active_slices_current_uplink = 1; - -/* RB share for each slice for past and current time*/ -float avg_slice_percentage_uplink=0.25; -float slice_percentage_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; -float slice_percentage_current_uplink[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; -float total_slice_percentage_uplink = 0; -float total_slice_percentage_current_uplink = 0; - -// MAX MCS for each slice for past and current time -int slice_maxmcs_uplink[MAX_NUM_SLICES] = {16, 16, 16, 16}; -int slice_maxmcs_current_uplink[MAX_NUM_SLICES] = {16,16,16,16}; - -/*resource blocks allowed*/ -uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; -/*Slice Update */ -int update_ul_scheduler[MAX_NUM_SLICES] = {1, 1, 1, 1}; -int update_ul_scheduler_current[MAX_NUM_SLICES] = {1, 1, 1, 1}; - - /* Slice Function Pointer */ -slice_scheduler_ul slice_sched_ul[MAX_NUM_SLICES] = {0}; - -/* name of available scheduler*/ -char *ul_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_ul_spec_embb", - "flexran_schedule_ue_ul_spec_embb", - "flexran_schedule_ue_ul_spec_embb", - "flexran_schedule_ue_ul_spec_embb" // best effort -}; - - -uint16_t flexran_nb_rbs_allowed_slice_uplink(float rb_percentage, int total_rbs){ - return (uint16_t) floor(rb_percentage * total_rbs); -} - - -void _assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, sub_frame_t subframeP, uint16_t *first_rb) -{ - - int i; - uint16_t n,UE_id; - uint8_t CC_id; - rnti_t rnti = -1; - int mcs; - int rb_table_index=0,tbs,tx_power; - eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP]; - UE_list_t *UE_list = &eNB->UE_list; - - UE_TEMPLATE *UE_template; - LTE_DL_FRAME_PARMS *frame_parms; - - - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) continue; - - rnti = UE_RNTI(module_idP,i); - - if (rnti==NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - if (!phy_stats_exist(module_idP, rnti)) - continue; - - if (UE_list->UE_sched_ctrl[i].phr_received == 1) - mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs - else - mcs = 10; // otherwise, limit to QPSK PUSCH - - UE_id = i; - - for (n=0; nnumactiveULCCs[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]; - nb_rbs_allowed_slice_uplink[CC_id][UE_id] = flexran_nb_rbs_allowed_slice_uplink(slice_percentage_uplink[UE_id], flexran_get_N_RB_UL(module_idP, CC_id)); - // if this UE has UL traffic - if (UE_template->ul_total_buffer > 0 ) { - - tbs = mac_xface->get_TBS_UL(mcs,3); // 1 or 2 PRB with cqi enabled does not work well! - // fixme: set use_srs flag - tx_power= mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); - - while ((((UE_template->phr_info - tx_power) < 0 ) || (tbs > UE_template->ul_total_buffer))&& - (mcs > 3)) { - // LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); - mcs--; - tbs = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); - tx_power = mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); // fixme: set use_srs - } - - while ((tbs < UE_template->ul_total_buffer) && - (rb_table[rb_table_index]<(nb_rbs_allowed_slice_uplink[CC_id][UE_id]-first_rb[CC_id])) && - ((UE_template->phr_info - tx_power) > 0) && - (rb_table_index < 32 )) { - // LOG_I(MAC,"tbs %d ul buffer %d rb table %d max ul rb %d\n", tbs, UE_template->ul_total_buffer, rb_table[rb_table_index], frame_parms->N_RB_UL-first_rb[CC_id]); - rb_table_index++; - tbs = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); - tx_power = mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); - } - - UE_template->ue_tx_power = tx_power; - - if (rb_table[rb_table_index]>(nb_rbs_allowed_slice_uplink[CC_id][UE_id]-first_rb[CC_id]-1)) { - rb_table_index--; - } - - // 1 or 2 PRB with cqi enabled does not work well! - 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; - UE_template->pre_allocated_nb_rb_ul= rb_table[rb_table_index]; - LOG_D(MAC,"[eNB %d] frame %d subframe %d: for UE %d CC %d: pre-assigned mcs %d, pre-allocated rb_table[%d]=%d RBs (phr %d, tx power %d)\n", - module_idP, frameP, subframeP, UE_id, CC_id, - UE_template->pre_assigned_mcs_ul, - UE_template->pre_allocated_rb_table_index_ul, - UE_template->pre_allocated_nb_rb_ul, - UE_template->phr_info,tx_power); - } else { - UE_template->pre_allocated_rb_table_index_ul=-1; - UE_template->pre_allocated_nb_rb_ul=0; - } - } - } -} - - - - -void _ulsch_scheduler_pre_processor(module_id_t module_idP, - int slice_id, - int frameP, - sub_frame_t subframeP, - uint16_t *first_rb) -{ - - int16_t i; - uint16_t UE_id,n,r; - uint8_t CC_id, round, harq_pid; - uint16_t nb_allocated_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX],total_allocated_rbs[MAX_NUM_CCs],average_rbs_per_user[MAX_NUM_CCs]; - uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; - int16_t total_remaining_rbs[MAX_NUM_CCs]; - uint16_t max_num_ue_to_be_scheduled=0,total_ue_count=0; - rnti_t rnti= -1; - UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; - UE_TEMPLATE *UE_template = 0; - // LTE_DL_FRAME_PARMS *frame_parms; //Not used yet - UE_sched_ctrl *ue_sched_ctl; - - - //LOG_I(MAC,"assign max mcs min rb\n"); - // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB - _assign_max_mcs_min_rb(module_idP, slice_id, frameP, subframeP, first_rb); - - //LOG_I(MAC,"sort ue \n"); - // sort ues - sort_ue_ul (module_idP,frameP, subframeP); - - - // we need to distribute RBs among UEs - // step1: reset the vars - for (CC_id=0; CC_idhead_ul; i>=0; i=UE_list->next_ul[i]) { - nb_allocated_rbs[CC_id][i]=0; - } - } - - //LOG_I(MAC,"step2 \n"); - // step 2: calculate the average rb per UE - total_ue_count =0; - max_num_ue_to_be_scheduled=0; - - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - - rnti = UE_RNTI(module_idP,i); - - if (rnti==NOT_A_RNTI) - continue; - - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - if (!phy_stats_exist(module_idP, rnti)) - continue; - - UE_id = i; - - for (n=0; nnumactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - UE_template = &UE_list->UE_template[CC_id][UE_id]; - average_rbs_per_user[CC_id]=0; - // frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); - - if (UE_template->pre_allocated_nb_rb_ul > 0) { - total_ue_count+=1; - } - /* - if((mac_xface->get_nCCE_max(module_idP,CC_id,3,subframeP) - nCCE_to_be_used[CC_id]) > (1< 0 ) { - average_rbs_per_user[CC_id] = (uint16_t) floor((nb_rbs_allowed_slice_uplink[CC_id][i]-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", - module_idP,frameP,subframeP,UE_id,CC_id); - } - } - } - if (total_ue_count > 0) - LOG_D(MAC,"[eNB %d] Frame %d subframe %d: total ue to be scheduled %d/%d\n", - module_idP, frameP, subframeP,total_ue_count, max_num_ue_to_be_scheduled); - - //LOG_D(MAC,"step3\n"); - - // step 3: assigne RBS - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - rnti = UE_RNTI(module_idP,i); - - if (rnti==NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - if (!phy_stats_exist(module_idP, rnti)) - continue; - - UE_id = i; - - for (n=0; nnumactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice_uplink[CC_id][UE_id]; - // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); - flexran_get_harq(module_idP, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_UL); - if(round>0) { - nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; - } 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]; - - } - } - - // step 4: assigne the remaining RBs and set the pre_allocated rbs accordingly - for(r=0; r<2; r++) { - - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - rnti = UE_RNTI(module_idP,i); - - if (rnti==NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - if (!phy_stats_exist(module_idP, rnti)) - continue; - - UE_id = i; - - for (n=0; nnumactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - UE_template = &UE_list->UE_template[CC_id][UE_id]; - // frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); - total_remaining_rbs[CC_id]=nb_rbs_allowed_slice_uplink[CC_id][UE_id] - first_rb[CC_id] - total_allocated_rbs[CC_id]; - - if (total_ue_count == 1 ) { - total_remaining_rbs[CC_id]+=1; - } - - if ( r == 0 ) { - while ( (UE_template->pre_allocated_nb_rb_ul > 0 ) && - (nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul) && - (total_remaining_rbs[CC_id] > 0)) { - nb_allocated_rbs[CC_id][UE_id] = cmin(nb_allocated_rbs[CC_id][UE_id]+1,UE_template->pre_allocated_nb_rb_ul); - total_remaining_rbs[CC_id]--; - total_allocated_rbs[CC_id]++; - } - } else { - UE_template->pre_allocated_nb_rb_ul= nb_allocated_rbs[CC_id][UE_id]; - LOG_D(MAC,"******************UL Scheduling Information for UE%d CC_id %d ************************\n",UE_id, CC_id); - LOG_D(MAC,"[eNB %d] total RB allocated for UE%d CC_id %d = %d\n", module_idP, UE_id, CC_id, UE_template->pre_allocated_nb_rb_ul); - } - } - } - } - - for (CC_id=0; CC_idget_lte_frame_parms(module_idP,CC_id); - - 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], nb_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id]); - } - } -} - -/* - * Main Uplink Slicing - * - */ - -void -flexran_schedule_ue_ul_spec_default(mid_t mod_id, - uint32_t frame, - uint32_t cooperation_flag, - int subframe, - unsigned char sched_subframe, - Protocol__FlexranMessage **ul_info) -//------------------------------------------------------------------------------ -{ - int i=0; - - flexran_agent_mac_create_empty_ul_config(mod_id, ul_info); - - total_slice_percentage_uplink=0; - avg_slice_percentage_uplink=1.0/n_active_slices_uplink; - - // reset the slice percentage for inactive slices - for (i = n_active_slices_uplink; i< MAX_NUM_SLICES; i++) { - slice_percentage_uplink[i]=0; - } - for (i = 0; i < n_active_slices_uplink; i++) { - if (slice_percentage_uplink[i] < 0 ){ - LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %f. resetting to zero", - mod_id, frame, subframe, i, slice_percentage_uplink[i]); - slice_percentage_uplink[i]=0; - } - total_slice_percentage_uplink+=slice_percentage_uplink[i]; - } - - for (i = 0; i < n_active_slices_uplink; i++) { - - // Load any updated functions - if (update_ul_scheduler[i] > 0 ) { - slice_sched_ul[i] = dlsym(NULL, ul_scheduler_type[i]); - update_ul_scheduler[i] = 0; - update_ul_scheduler_current[i] = 0; - //slice_percentage_current_uplink[i]= slice_percentage_uplink[i]; - //total_slice_percentage_current_uplink+=slice_percentage_uplink[i]; - //if (total_slice_percentage_current_uplink> 1) - // total_slice_percentage_current_uplink=1; - LOG_N(MAC,"update ul scheduler slice %d\n", i); - } - // the new total RB share is within the range - if (total_slice_percentage_uplink <= 1.0){ - - // check if the number of slices has changed, and log - if (n_active_slices_current_uplink != n_active_slices_uplink ){ - if ((n_active_slices_uplink > 0) && (n_active_slices_uplink <= MAX_NUM_SLICES)) { - LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active UL slices has changed: %d-->%d\n", - mod_id, frame, subframe, n_active_slices_current_uplink, n_active_slices_uplink); - - n_active_slices_current_uplink = n_active_slices_uplink; - - } else { - LOG_W(MAC,"invalid number of UL slices %d, revert to the previous value %d\n",n_active_slices_uplink, n_active_slices_current_uplink); - n_active_slices_uplink = n_active_slices_current_uplink; - } - } - - // check if the slice rb share has changed, and log the console - if (slice_percentage_current_uplink[i] != slice_percentage_uplink[i]){ - LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: total percentage %f-->%f, slice RB percentage has changed: %f-->%f\n", - mod_id, i, frame, subframe, total_slice_percentage_current_uplink, total_slice_percentage_uplink, slice_percentage_current_uplink[i], slice_percentage_uplink[i]); - total_slice_percentage_current_uplink= total_slice_percentage_uplink; - slice_percentage_current_uplink[i] = slice_percentage_uplink[i]; - - } - - // check if the slice max MCS, and log the console - if (slice_maxmcs_current_uplink[i] != slice_maxmcs_uplink[i]){ - if ((slice_maxmcs_uplink[i] >= 0) && (slice_maxmcs_uplink[i] <= 16)){ - LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", - mod_id, i, frame, subframe, slice_maxmcs_current_uplink[i], slice_maxmcs_uplink[i]); - slice_maxmcs_current_uplink[i] = slice_maxmcs_uplink[i]; - } else { - LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs_uplink[i],slice_maxmcs_current_uplink[i]); - slice_maxmcs_uplink[i]= slice_maxmcs_current_uplink[i]; - - } - } - - // check if a new scheduler, and log the console - if (update_ul_scheduler_current[i] != update_ul_scheduler[i]){ - LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: UL scheduler for this slice is updated: %s \n", - mod_id, i, frame, subframe, ul_scheduler_type[i]); - - update_ul_scheduler_current[i] = update_ul_scheduler[i]; - } - } - else { - - if (n_active_slices_uplink == n_active_slices_current_uplink){ - LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid total RB share (%f->%f), reduce proportionally the RB share by 0.1\n", - mod_id,i, - total_slice_percentage_current_uplink, total_slice_percentage_uplink); - if (slice_percentage_uplink[i] > avg_slice_percentage_uplink){ - slice_percentage_uplink[i]-=0.1; - total_slice_percentage_uplink-=0.1; - } - } else { - // here we can correct the values, e.g. reduce proportionally - LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid total RB share (%f->%f), revert the number of slice to its previous value (%d->%d)\n", - mod_id,i, - total_slice_percentage_current_uplink, total_slice_percentage_uplink, - n_active_slices_uplink, n_active_slices_current_uplink); - n_active_slices_uplink = n_active_slices_current_uplink; - slice_percentage_uplink[i] = slice_percentage_current_uplink[i]; - } - } - - // Run each enabled slice-specific schedulers one by one - slice_sched_ul[i](mod_id, frame, cooperation_flag, subframe, sched_subframe,ul_info); - } -} - -void -flexran_schedule_ue_ul_spec_embb(mid_t mod_id, - frame_t frame, - unsigned char cooperation_flag, - uint32_t subframe, - unsigned char sched_subframe, - Protocol__FlexranMessage **ul_info) - -{ - flexran_agent_schedule_ulsch_ue_spec(mod_id, - frame, - cooperation_flag, - subframe, - sched_subframe, - ul_info); - -} - - -void flexran_agent_schedule_ulsch_ue_spec(mid_t module_idP, - frame_t frameP, - unsigned char cooperation_flag, - sub_frame_t subframeP, - unsigned char sched_subframe, - Protocol__FlexranMessage **ul_info) { - - - uint16_t first_rb[MAX_NUM_CCs],i; - int CC_id; - eNB_MAC_INST *eNB=&eNB_mac_inst[module_idP]; - - start_meas(&eNB->schedule_ulsch); - - - for (CC_id=0; CC_idcommon_channels[CC_id].RA_template[i].RA_active == TRUE) && - (eNB->common_channels[CC_id].RA_template[i].generate_rar == 0) && - (eNB->common_channels[CC_id].RA_template[i].generate_Msg4 == 0) && - (eNB->common_channels[CC_id].RA_template[i].wait_ack_Msg4 == 0) && - (eNB->common_channels[CC_id].RA_template[i].Msg3_subframe == sched_subframe)) { - first_rb[CC_id]++; - eNB->common_channels[CC_id].RA_template[i].Msg3_subframe = -1; - break; - } - } - - /* - if (mac_xface->is_prach_subframe(&(mac_xface->lte_frame_parms),frameP,subframeP)) { - first_rb[CC_id] = (mac_xface->get_prach_prb_offset(&(mac_xface->lte_frame_parms), - */ - - } - - flexran_agent_schedule_ulsch_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe,first_rb); - - stop_meas(&eNB->schedule_ulsch); - -} - - - -void flexran_agent_schedule_ulsch_rnti(module_id_t module_idP, - unsigned char cooperation_flag, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframe, - uint16_t *first_rb) -{ - - int UE_id; - uint8_t aggregation = 2; - rnti_t rnti = -1; - uint8_t round = 0; - uint8_t harq_pid = 0; - void *ULSCH_dci = NULL; - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - DCI_PDU *DCI_pdu; - uint8_t status = 0; - uint8_t rb_table_index = -1; - uint16_t TBS = 0; - // int32_t buffer_occupancy=0; - uint32_t cqi_req,cshift,ndi,mcs=0,rballoc,tpc; - int32_t normalized_rx_power, target_rx_power=-90; - static int32_t tpc_accumulated=0; - - int n,CC_id = 0; - eNB_MAC_INST *eNB=&eNB_mac_inst[module_idP]; - UE_list_t *UE_list=&eNB->UE_list; - UE_TEMPLATE *UE_template; - UE_sched_ctrl *UE_sched_ctrl; - - // int rvidx_tab[4] = {0,2,3,1}; - LTE_DL_FRAME_PARMS *frame_parms; - int drop_ue=0; - - // LOG_I(MAC,"entering ulsch preprocesor\n"); - - - /*TODO*/ - int slice_id = 0; - - - _ulsch_scheduler_pre_processor(module_idP, - slice_id, - frameP, - subframeP, - first_rb); - - // LOG_I(MAC,"exiting ulsch preprocesor\n"); - - // loop over all active UEs - 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) { - LOG_I(MAC,"[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n", - module_idP,frameP,subframeP,UE_id); - continue; - } - - rnti = flexran_get_ue_crnti(module_idP, UE_id); - - if (rnti==NOT_A_RNTI) { - LOG_W(MAC,"[eNB %d] frame %d subfarme %d, UE %d: no RNTI \n", module_idP,frameP,subframeP,UE_id); - continue; - } - - /* let's drop the UE if get_eNB_UE_stats returns NULL when calling it with any of the UE's active UL CCs */ - /* TODO: refine? */ - drop_ue = 0; - for (n=0; nnumactiveULCCs[UE_id]; n++) { - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - if (mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti) == NULL) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: no PHY context\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); - drop_ue = 1; - break; - } - } - if (drop_ue == 1) { -/* we can't come here, ulsch_scheduler_pre_processor won't put in the list a UE with no PHY context */ -abort(); - /* TODO: this is a hack. Sometimes the UE has no PHY context but - * is still present in the MAC with 'ul_failure_timer' = 0 and - * 'ul_out_of_sync' = 0. It seems wrong and the UE stays there forever. Let's - * start an UL out of sync procedure in this case. - * The root cause of this problem has to be found and corrected. - * In the meantime, this hack... - */ - if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 0 && - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: UE in weird state, let's put it 'out of sync'\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - // inform RRC of failure and clear timer - mac_eNB_rrc_ul_failure(module_idP,CC_id,frameP,subframeP,rnti); - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0; - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=1; - } - continue; - } - - // loop over all active UL CC_ids for this UE - for (n=0; nnumactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); - eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); - - aggregation=get_aggregation(get_bw_index(module_idP,CC_id), - eNB_UE_stats->DL_cqi[0], - format0); - - if (CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,aggregation,rnti)) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); - continue; // break; - } else{ - LOG_D(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d mode %s: aggregation level %d\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id, mode_string[eNB_UE_stats->mode], 1<mode == PUSCH) { // ue has a ulsch channel - - DCI_pdu = &eNB->common_channels[CC_id].DCI_pdu; - UE_template = &UE_list->UE_template[CC_id][UE_id]; - UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - - if (flexran_get_harq(module_idP, CC_id, UE_id, frameP, subframeP, &harq_pid, &round, openair_harq_UL) == -1 ) { - LOG_W(MAC,"[eNB %d] Scheduler Frame %d, subframeP %d: candidate harq_pid from PHY for UE %d CC %d RNTI %x\n", - module_idP,frameP,subframeP, UE_id, CC_id, rnti); - continue; - } else - LOG_T(MAC,"[eNB %d] Frame %d, subframeP %d, UE %d CC %d : got harq pid %d round %d (rnti %x,mode %s)\n", - module_idP,frameP,subframeP,UE_id,CC_id, harq_pid, round,rnti,mode_string[eNB_UE_stats->mode]); - - PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]); - if (((UE_is_to_be_scheduled(module_idP,CC_id,UE_id)>0)) || (round>0))// || ((frameP%10)==0)) - // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames - { - LOG_D(MAC,"[eNB %d][PUSCH] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d)\n", - module_idP,frameP,subframeP,UE_id,rnti,round,UE_template->ul_SR, - UE_sched_ctrl->ul_inactivity_timer, - UE_sched_ctrl->ul_failure_timer); - // reset the scheduling request - UE_template->ul_SR = 0; - // status = mac_eNB_get_rrc_status(module_idP,rnti); - status = flexran_get_rrc_status(module_idP, rnti); - - if (status < RRC_CONNECTED) - cqi_req = 0; - else if (UE_sched_ctrl->cqi_req_timer>30) { - cqi_req = 1; - UE_sched_ctrl->cqi_req_timer=0; - } - else - cqi_req = 0; - - //power control - //compute the expected ULSCH RX power (for the stats) - - // this is the normalized RX power and this should be constant (regardless of mcs - normalized_rx_power = eNB_UE_stats->UL_rssi[0]; - target_rx_power = mac_xface->get_target_pusch_rx_power(module_idP,CC_id); - - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe; - if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case - ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - { - UE_template->pusch_tpc_tx_frame=frameP; - UE_template->pusch_tpc_tx_subframe=subframeP; - if (normalized_rx_power>(target_rx_power+1)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-1)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - } else { - tpc = 1; //0 - } - - if (tpc!=1) { - LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - module_idP,frameP,subframeP,harq_pid,tpc, - tpc_accumulated,normalized_rx_power,target_rx_power); - } - - // new transmission - if (round==0) { - - ndi = 1-UE_template->oldNDI_UL[harq_pid]; - UE_template->oldNDI_UL[harq_pid]=ndi; - UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; - mcs = UE_template->pre_assigned_mcs_ul;//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) { - rb_table_index=UE_template->pre_allocated_rb_table_index_ul; - } else { - mcs=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); - rb_table_index=5; // for PHR - } - - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; - // buffer_occupancy = UE_template->ul_total_buffer; - - while (((rb_table[rb_table_index]>(nb_rbs_allowed_slice_uplink[CC_id][UE_id]-1-first_rb[CC_id])) || - (rb_table[rb_table_index]>45)) && - (rb_table_index>0)) { - rb_table_index--; - } - - TBS = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=TBS; - // buffer_occupancy -= TBS; - rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, - first_rb[CC_id], - rb_table[rb_table_index]); - - T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(mcs), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(TBS), T_INT(ndi)); - - if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) - LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs, - first_rb[CC_id],rb_table[rb_table_index], - rb_table_index,TBS,harq_pid); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - // increment for next UE allocation - first_rb[CC_id]+=rb_table[rb_table_index]; - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; - UE_sched_ctrl->ul_scheduled |= (1<head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled); - - // adjust total UL buffer status by TBS, wait for UL sdus to do final update - LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,TBS); - if (UE_template->ul_total_buffer > TBS) - UE_template->ul_total_buffer -= TBS; - else - UE_template->ul_total_buffer = 0; - LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer); - // Cyclic shift for DM RS - 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) { - case 6: - ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; - - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = tpc; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_template->DAI_ul[sched_subframe]; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_1_5MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_1_5MHz_TDD_1_6_t, - format0, - 0); - break; - - default: - case 25: - ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; - - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = tpc; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_template->DAI_ul[sched_subframe]; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_5MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_5MHz_TDD_1_6_t, - format0, - 0); - break; - - case 50: - ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; - - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->TPC = tpc; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_template->DAI_ul[sched_subframe]; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_10MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_10MHz_TDD_1_6_t, - format0, - 0); - break; - - case 100: - ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; - - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->TPC = tpc; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->dai = UE_template->DAI_ul[sched_subframe]; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_20MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_20MHz_TDD_1_6_t, - format0, - 0); - break; - } - } // TDD - else { //FDD - switch (frame_parms->N_RB_UL) { - case 25: - default: - - ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; - - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->type = 0; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->TPC = tpc; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->padding = 0; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_5MHz_FDD_t), - aggregation, - sizeof_DCI0_5MHz_FDD_t, - format0, - 0); - break; - - case 6: - ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; - - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->type = 0; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->TPC = tpc; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->padding = 0; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_1_5MHz_FDD_t), - aggregation, - sizeof_DCI0_1_5MHz_FDD_t, - format0, - 0); - break; - - case 50: - ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; - - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->type = 0; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->hopping = 0; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->TPC = tpc; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->padding = 0; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_10MHz_FDD_t), - aggregation, - sizeof_DCI0_10MHz_FDD_t, - format0, - 0); - break; - - case 100: - ULSCH_dci = UE_template->ULSCH_DCI[harq_pid]; - - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->type = 0; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->hopping = 0; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->TPC = tpc; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->padding = 0; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_20MHz_FDD_t), - aggregation, - sizeof_DCI0_20MHz_FDD_t, - format0, - 0); - break; - - } - } - - - add_ue_ulsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_UL_SCHEDULED); - - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id); -#ifdef DEBUG - dump_dci(frame_parms, &DCI_pdu->dci_alloc[DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci-1]); -#endif - - } - else { - T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(mcs), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(round)); - - LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d,round %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs, - first_rb[CC_id],rb_table[rb_table_index], - rb_table_index,TBS,harq_pid,round); - }/* - else if (round > 0) { //we schedule a retransmission - - ndi = UE_template->oldNDI_UL[harq_pid]; - - if ((round&3)==0) { - mcs = openair_daq_vars.target_ue_ul_mcs; - } else { - mcs = rvidx_tab[round&3] + 28; //not correct for round==4! - - } - - LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, harq_pid %d, round %d)\n", - module_idP,UE_id,rnti,CC_id,frameP,subframeP,mcs, - first_rb[CC_id],UE_template->nb_rb_ul[harq_pid], - harq_pid, round); - - rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, - first_rb[CC_id], - UE_template->nb_rb_ul[harq_pid]); - first_rb[CC_id]+=UE_template->nb_rb_ul[harq_pid]; // increment for next UE allocation - - UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission_rx+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_rx=UE_template->nb_rb_ul[harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=UE_template->nb_rb_ul[harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=mcs; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; - } - */ - - } // UE_is_to_be_scheduled - } // UE is in PUSCH - } // loop over UE_id - } // loop of CC_id -} - diff --git a/openair2/LAYER2/MAC/flexran_dci_conversions.h b/openair2/LAYER2/MAC/flexran_dci_conversions.h deleted file mode 100644 index 5c18b43104..0000000000 --- a/openair2/LAYER2/MAC/flexran_dci_conversions.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file flexran_dci_conversions.h - * \brief Conversion helpers from flexran messages to OAI formats DCI - * \author Xenofon Foukas - * \date 2016 - * \version 0.1 - */ - -#ifndef LAYER2_MAC_FLEXRAN_DCI_CONVERISIONS_H__ -#define LAYER2_MAC_DCI_FLEXRAN_CONVERISIONS_H__ - -#define FILL_DCI_FDD_1(TYPE, DCI, FLEXRAN_DCI) \ - ((TYPE*)DCI)->harq_pid = FLEXRAN_DCI->harq_process; \ - ((TYPE*)DCI)->rv = FLEXRAN_DCI->rv[0]; \ - ((TYPE*)DCI)->rballoc = FLEXRAN_DCI->rb_bitmap; \ - ((TYPE*)DCI)->rah = FLEXRAN_DCI->res_alloc; \ - ((TYPE*)DCI)->mcs = FLEXRAN_DCI->mcs[0]; \ - ((TYPE*)DCI)->TPC = FLEXRAN_DCI->tpc; \ - ((TYPE*)DCI)->ndi = FLEXRAN_DCI->ndi[0]; - -#define FILL_DCI_TDD_1(TYPE, DCI, FLEXRAN_DCI) \ - ((TYPE*)DCI)->harq_pid = FLEXRAN_DCI->harq_process; \ - ((TYPE*)DCI)->rv = FLEXRAN_DCI->rv[0]; \ - ((TYPE*)DCI)->dai = FLEXRAN_DCI->dai; \ - ((TYPE*)DCI)->rballoc = FLEXRAN_DCI->rb_bitmap; \ - ((TYPE*)DCI)->rah = FLEXRAN_DCI->res_alloc; \ - ((TYPE*)DCI)->mcs = FLEXRAN_DCI->mcs[0]; \ - ((TYPE*)DCI)->TPC = FLEXRAN_DCI->tpc; \ - ((TYPE*)DCI)->ndi = FLEXRAN_DCI->ndi[0]; - -#endif From 024904db903a4246657056aeef07130c492e5829 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 15 Jan 2018 18:32:35 +0100 Subject: [PATCH 073/141] repair enb_app.c after merge, delete unnecessary code --- openair2/ENB_APP/enb_app.c | 155 ++----------------------------------- 1 file changed, 6 insertions(+), 149 deletions(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 3b3c8c24c7..f1a5437e98 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -50,10 +50,6 @@ # include "gtpv1u_eNB_task.h" # endif -#if defined(FLEXRAN_AGENT_SB_IF) -# include "targets/RT/USER/lte-softmodem.h" -#endif - extern unsigned char NB_eNB_INST; #endif @@ -102,102 +98,6 @@ static void configure_rrc(uint32_t enb_id) if (RC.rrc[enb_id]) { RCconfig_RRC(msg_p,enb_id, RC.rrc[enb_id]); - /* - RRC_CONFIGURATION_REQ (msg_p).cell_identity = enb_properties->properties[enb_id]->eNB_id; - RRC_CONFIGURATION_REQ (msg_p).tac = enb_properties->properties[enb_id]->tac; - RRC_CONFIGURATION_REQ (msg_p).mcc = enb_properties->properties[enb_id]->mcc; - RRC_CONFIGURATION_REQ (msg_p).mnc = enb_properties->properties[enb_id]->mnc; - RRC_CONFIGURATION_REQ (msg_p).mnc_digit_length = enb_properties->properties[enb_id]->mnc_digit_length; - - for (CC_id=0; CC_idproperties[enb_id]->frame_type[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).tdd_config[CC_id] = enb_properties->properties[enb_id]->tdd_config[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).tdd_config_s[CC_id] = enb_properties->properties[enb_id]->tdd_config_s[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).eutra_band[CC_id] = enb_properties->properties[enb_id]->eutra_band[CC_id]; - - // RACH-Config - RRC_CONFIGURATION_REQ (msg_p).rach_numberOfRA_Preambles[CC_id] = enb_properties->properties[enb_id]->rach_numberOfRA_Preambles[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_preamblesGroupAConfig[CC_id] = enb_properties->properties[enb_id]->rach_preamblesGroupAConfig[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_sizeOfRA_PreamblesGroupA[CC_id] = enb_properties->properties[enb_id]->rach_sizeOfRA_PreamblesGroupA[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[CC_id] = enb_properties->properties[enb_id]->rach_messageSizeGroupA[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[CC_id] = enb_properties->properties[enb_id]->rach_messagePowerOffsetGroupB[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_powerRampingStep[CC_id] = enb_properties->properties[enb_id]->rach_powerRampingStep[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_preambleInitialReceivedTargetPower[CC_id] = enb_properties->properties[enb_id]->rach_preambleInitialReceivedTargetPower[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[CC_id] = enb_properties->properties[enb_id]->rach_preambleTransMax[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_raResponseWindowSize[CC_id] = enb_properties->properties[enb_id]->rach_raResponseWindowSize[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_macContentionResolutionTimer[CC_id] = enb_properties->properties[enb_id]->rach_macContentionResolutionTimer[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).rach_maxHARQ_Msg3Tx[CC_id] = enb_properties->properties[enb_id]->rach_maxHARQ_Msg3Tx[CC_id]; - - // BCCH-Config - RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[CC_id] = enb_properties->properties[enb_id]->bcch_modificationPeriodCoeff[CC_id]; - - // PCCH-Config - RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[CC_id] = enb_properties->properties[enb_id]->pcch_defaultPagingCycle[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pcch_nB[CC_id] = enb_properties->properties[enb_id]->pcch_nB[CC_id]; - - // PRACH-Config - RRC_CONFIGURATION_REQ (msg_p).prach_root[CC_id] = enb_properties->properties[enb_id]->prach_root[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).prach_config_index[CC_id] = enb_properties->properties[enb_id]->prach_config_index[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).prach_high_speed[CC_id] = enb_properties->properties[enb_id]->prach_high_speed[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).prach_zero_correlation[CC_id] = enb_properties->properties[enb_id]->prach_zero_correlation[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).prach_freq_offset[CC_id] = enb_properties->properties[enb_id]->prach_freq_offset[CC_id]; - - // PDSCH-Config - RRC_CONFIGURATION_REQ (msg_p).pdsch_referenceSignalPower[CC_id] = enb_properties->properties[enb_id]->pdsch_referenceSignalPower[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pdsch_p_b[CC_id] = enb_properties->properties[enb_id]->pdsch_p_b[CC_id]; - - // PUSCH-Config - RRC_CONFIGURATION_REQ (msg_p).pusch_n_SB[CC_id] = enb_properties->properties[enb_id]->pusch_n_SB[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pusch_hoppingMode[CC_id] = enb_properties->properties[enb_id]->pusch_hoppingMode[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pusch_hoppingOffset[CC_id] = enb_properties->properties[enb_id]->pusch_hoppingOffset[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pusch_enable64QAM[CC_id] = enb_properties->properties[enb_id]->pusch_enable64QAM[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pusch_groupHoppingEnabled[CC_id] = enb_properties->properties[enb_id]->pusch_groupHoppingEnabled[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pusch_groupAssignment[CC_id] = enb_properties->properties[enb_id]->pusch_groupAssignment[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pusch_sequenceHoppingEnabled[CC_id] = enb_properties->properties[enb_id]->pusch_sequenceHoppingEnabled[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pusch_nDMRS1[CC_id] = enb_properties->properties[enb_id]->pusch_nDMRS1[CC_id]; - - // PUCCH-Config - - RRC_CONFIGURATION_REQ (msg_p).pucch_delta_shift[CC_id] = enb_properties->properties[enb_id]->pucch_delta_shift[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pucch_nRB_CQI[CC_id] = enb_properties->properties[enb_id]->pucch_nRB_CQI[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pucch_nCS_AN[CC_id] = enb_properties->properties[enb_id]->pucch_nCS_AN[CC_id]; -#if !defined(Rel10) && !defined(Rel14) - RRC_CONFIGURATION_REQ (msg_p).pucch_n1_AN[CC_id] = enb_properties->properties[enb_id]->pucch_n1_AN[CC_id]; -#endif - - // SRS Config - RRC_CONFIGURATION_REQ (msg_p).srs_enable[CC_id] = enb_properties->properties[enb_id]->srs_enable[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).srs_BandwidthConfig[CC_id] = enb_properties->properties[enb_id]->srs_BandwidthConfig[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).srs_SubframeConfig[CC_id] = enb_properties->properties[enb_id]->srs_SubframeConfig[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).srs_ackNackST[CC_id] = enb_properties->properties[enb_id]->srs_ackNackST[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).srs_MaxUpPts[CC_id] = enb_properties->properties[enb_id]->srs_MaxUpPts[CC_id]; - - // uplinkPowerControlCommon - - RRC_CONFIGURATION_REQ (msg_p).pusch_p0_Nominal[CC_id] = enb_properties->properties[enb_id]->pusch_p0_Nominal[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pucch_p0_Nominal[CC_id] = enb_properties->properties[enb_id]->pucch_p0_Nominal[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[CC_id] = enb_properties->properties[enb_id]->pusch_alpha[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1[CC_id] = enb_properties->properties[enb_id]->pucch_deltaF_Format1[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1b[CC_id] = enb_properties->properties[enb_id]->pucch_deltaF_Format1b[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[CC_id] = enb_properties->properties[enb_id]->pucch_deltaF_Format2[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2a[CC_id] = enb_properties->properties[enb_id]->pucch_deltaF_Format2a[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2b[CC_id] = enb_properties->properties[enb_id]->pucch_deltaF_Format2b[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).msg3_delta_Preamble[CC_id] = enb_properties->properties[enb_id]->msg3_delta_Preamble[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).ul_CyclicPrefixLength[CC_id] = enb_properties->properties[enb_id]->ul_CyclicPrefixLength[CC_id]; - - // UE Timers and Constants - - RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[CC_id] = enb_properties->properties[enb_id]->ue_TimersAndConstants_t300[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[CC_id] = enb_properties->properties[enb_id]->ue_TimersAndConstants_t301[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[CC_id] = enb_properties->properties[enb_id]->ue_TimersAndConstants_t310[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[CC_id] = enb_properties->properties[enb_id]->ue_TimersAndConstants_n310[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[CC_id] = enb_properties->properties[enb_id]->ue_TimersAndConstants_t311[CC_id]; - RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[CC_id] = enb_properties->properties[enb_id]->ue_TimersAndConstants_n311[CC_id]; - - RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[CC_id] = enb_properties->properties[enb_id]->ue_TransmissionMode[CC_id]; - - } - */ LOG_I(ENB_APP,"Sending configuration message to RRC task\n"); itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); @@ -206,15 +106,6 @@ static void configure_rrc(uint32_t enb_id) else AssertFatal(0,"RRC context for eNB %d not allocated\n",enb_id); } -void enb_app_start_phy_rrc(uint32_t enb_id_start, uint32_t enb_id_end) -{ - Enb_properties_array_t *enb_properties_p = enb_config_get(); - for (uint32_t enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - configure_phy(enb_id, enb_properties_p); - configure_rrc(enb_id, enb_properties_p); - } -} - /*------------------------------------------------------------------------------*/ # if defined(ENABLE_USE_MME) static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)//, const Enb_properties_array_t *enb_properties) @@ -240,44 +131,6 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)//, s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p); LOG_I(ENB_APP,"default drx %d\n",s1ap_register_eNB->default_drx); - /* - - s1ap_register_eNB->eNB_id = enb_properties->properties[enb_id]->eNB_id; - s1ap_register_eNB->cell_type = enb_properties->properties[enb_id]->cell_type; - s1ap_register_eNB->eNB_name = enb_properties->properties[enb_id]->eNB_name; - s1ap_register_eNB->tac = enb_properties->properties[enb_id]->tac; - s1ap_register_eNB->mcc = enb_properties->properties[enb_id]->mcc; - s1ap_register_eNB->mnc = enb_properties->properties[enb_id]->mnc; - s1ap_register_eNB->mnc_digit_length = enb_properties->properties[enb_id]->mnc_digit_length; - 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); - - 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; - s1ap_register_eNB->mme_ip_address[mme_id].ipv6 = enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv6; - strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv4_address, - enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv4_address, - sizeof(s1ap_register_eNB->mme_ip_address[0].ipv4_address)); - strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv6_address, - enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv6_address, - sizeof(s1ap_register_eNB->mme_ip_address[0].ipv6_address)); - } - - s1ap_register_eNB->sctp_in_streams = enb_properties->properties[enb_id]->sctp_in_streams; - s1ap_register_eNB->sctp_out_streams = enb_properties->properties[enb_id]->sctp_out_streams; - - - s1ap_register_eNB->enb_ip_address.ipv6 = 0; - s1ap_register_eNB->enb_ip_address.ipv4 = 1; - addr.s_addr = enb_properties->properties[enb_id]->enb_ipv4_address_for_S1_MME; - str = inet_ntoa(addr); - strcpy(s1ap_register_eNB->enb_ip_address.ipv4_address, str); - - */ LOG_I(ENB_APP,"[eNB %d] eNB_app_register for instance %d\n", enb_id, ENB_MODULE_ID_TO_INSTANCE(enb_id)); itti_send_msg_to_task (TASK_S1AP, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); @@ -297,13 +150,13 @@ void *eNB_app_task(void *args_p) #if defined(ENABLE_ITTI) uint32_t enb_nb = RC.nb_inst; uint32_t enb_id_start = 0; - uint32_t enb_i; uint32_t enb_id_end = enb_id_start + enb_nb; # if defined(ENABLE_USE_MME) uint32_t register_enb_pending; uint32_t registered_enb; long enb_register_retry_timer_id; # endif + uint32_t enb_id; MessageDef *msg_p = NULL; const char *msg_name = NULL; instance_t instance; @@ -340,7 +193,11 @@ void *eNB_app_task(void *args_p) RC.rrc = (eNB_RRC_INST **)malloc(RC.nb_inst*sizeof(eNB_RRC_INST *)); - enb_app_start_phy_rrc(enb_id_start, enb_id_end); + for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { + RC.rrc[enb_id] = (eNB_RRC_INST*)malloc(sizeof(eNB_RRC_INST)); + memset((void *)RC.rrc[enb_id],0,sizeof(eNB_RRC_INST)); + configure_rrc(enb_id); + } # if defined(ENABLE_USE_MME) /* Try to register each eNB */ From 7dfac059b0757f2e320d7adbc1779d44b29637d3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 15 Jan 2018 18:34:58 +0100 Subject: [PATCH 074/141] Review Navid: UL Scheduler: make slice aware --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 3 +++ openair2/LAYER2/MAC/pre_processor.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index b5256820bb..119f5b8074 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1233,6 +1233,9 @@ 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]) { + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + // don't schedule if Msg4 is not received yet if (UE_list->UE_template[UE_PCCID(module_idP, UE_id)][UE_id]. configured == FALSE) { diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index a0cc0dd412..af5b6f660b 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -614,6 +614,9 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, if (UE_list->active[i] != TRUE) continue; + if (!flexran_slice_member(UE_id, slice_id)) + continue; + UE_id = i; // Initialize scheduling information for all active UEs @@ -820,6 +823,8 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, continue; if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) continue; + if (flexran_slice_member(i, slice_id) == 0) + continue; transmission_mode = get_tmode(Mod_id, CC_id, UE_id); // mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); From a03877e7f710cf1c71496e36db5993aa50b8df44 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 15 Jan 2018 18:36:29 +0100 Subject: [PATCH 075/141] delete unnecessary code --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 17 ----------------- openair2/LAYER2/MAC/proto.h | 2 -- 2 files changed, 19 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 4a316cf92c..fe885d38cc 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1980,11 +1980,6 @@ uint8_t find_active_UEs(module_id_t module_idP,int CC_id){ } */ -int UE_BSR (uint8_t mod_id, uint8_t ue_id, uint8_t lcid) { - - if (eNB_mac_inst == NULL) return 0; - return eNB_mac_inst[mod_id].UE_list.UE_template[UE_PCCID(mod_id,ue_id)][ue_id].bsr_info[lcid]; -} // get aggregation (L) form phy for a give UE unsigned char @@ -2108,12 +2103,6 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP, int harq_pidP return (-1); } -int CC_id_rnti_downlink (uint8_t mod_id, int CC_index, uint16_t ue_rnti) { - - return eNB_mac_inst[mod_id].UE_list.ordered_CCids[CC_index][ue_rnti]; -} - - //------------------------------------------------------------------------------ int rrc_mac_remove_ue(module_id_t mod_idP, rnti_t rntiP) //------------------------------------------------------------------------------ @@ -4480,14 +4469,8 @@ uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs) return (uint16_t) floor(rb_percentage * total_rbs); } -int flexran_slice_maxmcs(int slice_id) -{ - return slice_maxmcs[slice_id]; -} - int flexran_slice_member(int UE_id, int slice_id) { - if ((slice_id < 0) || (slice_id > n_active_slices)) LOG_W(MAC, "out of range slice id %d\n", slice_id); diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index a83aabef27..f237bbf299 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -1168,7 +1168,5 @@ uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs); int flexran_slice_member(int UE_id, int slice_id); -int flexran_slice_maxmcs(int slice_id;) - #endif /** @}*/ From 9b4d3bbae75f90f5bd56c3952696b29fb38df216 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 15 Jan 2018 18:38:05 +0100 Subject: [PATCH 076/141] move scheduler function pointer typedef to proto.h --- openair2/LAYER2/MAC/proto.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index f237bbf299..00ea994ddf 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -35,6 +35,25 @@ * @{ */ +/** + * slice specific scheduler + */ +/* TODO Navid: Protocol__FlexranMessage -> unknown when compiling without + * FlexRAN, what to do with it? */ +typedef void (*slice_scheduler_dl)(module_id_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag/*, + Protocol__FlexranMessage **dl_info*/); + +typedef void (*slice_scheduler_ul)(module_id_t mod_id, + frame_t frame, + unsigned char cooperation_flag, + uint32_t subframe, + unsigned char sched_subframe/*, + Protocol__FlexranMessage **ul_info*/); + /** \fn void schedule_mib(module_id_t module_idP,frame_t frameP,sub_frame_t subframe); \brief MIB scheduling for PBCH. This function requests the MIB from RRC and provides it to L1. @param Mod_id Instance ID of eNB From dfece3ff58f9bee908e1ace4e38babb7c3a8d6ce Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 16 Jan 2018 17:23:26 +0100 Subject: [PATCH 077/141] correct scheduler typedefs --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 4 ++-- openair2/LAYER2/MAC/proto.h | 24 ++++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 119f5b8074..7076827896 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1174,8 +1174,8 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, } // Run each enabled slice-specific schedulers one by one - slice_sched_ul[i](module_idP, i,frameP, subframeP, sched_subframe, - first_rb); + /* TODO Navid What is the right call for this message? */ + slice_sched_ul[i](module_idP, i, frameP, subframeP, sched_subframe, first_rb); } diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 00ea994ddf..842e1d7080 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -39,20 +39,22 @@ * slice specific scheduler */ /* TODO Navid: Protocol__FlexranMessage -> unknown when compiling without - * FlexRAN, what to do with it? */ + * FlexRAN, what to do with it? Matches schedule_ue_spec now */ typedef void (*slice_scheduler_dl)(module_id_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag/*, - Protocol__FlexranMessage **dl_info*/); + slice_id_t slice_id, + frame_t frame, + sub_frame_t subframe, + int *mbsfn_flag + /* Protocol__FlexranMessage **dl_info*/); +/* TODO Navid: the same as above, matches schedule_ulsch_rnti now */ typedef void (*slice_scheduler_ul)(module_id_t mod_id, - frame_t frame, - unsigned char cooperation_flag, - uint32_t subframe, - unsigned char sched_subframe/*, - Protocol__FlexranMessage **ul_info*/); + slice_id_t slice_id, + frame_t frame, + sub_frame_t subframe, + unsigned char sched_subframe, + uint16_t *first_rb + /* Protocol__FlexranMessage **ul_info*/); /** \fn void schedule_mib(module_id_t module_idP,frame_t frameP,sub_frame_t subframe); \brief MIB scheduling for PBCH. This function requests the MIB from RRC and provides it to L1. From 6a6729bdaca3016286b9239ec9baaae1b67b1875 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 15 Jan 2018 18:38:29 +0100 Subject: [PATCH 078/141] fix various compilaton errors due to merge --- .../ENB_APP/flexran_agent_common_internal.c | 8 +- openair2/LAYER2/MAC/defs.h | 1 + openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 26 ++-- .../LAYER2/MAC/eNB_scheduler_primitives.c | 8 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 28 ++-- openair2/LAYER2/MAC/pre_processor.c | 26 ++-- openair2/LAYER2/MAC/proto.h | 4 +- openair2/RRC/LITE/rrc_eNB.c | 2 +- targets/RT/USER/lte-enb.c | 23 +-- targets/RT/USER/lte-softmodem.c | 137 ++---------------- targets/RT/USER/lte-softmodem.h | 2 +- 11 files changed, 72 insertions(+), 193 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index de937db0c6..e3fac4594b 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -37,6 +37,7 @@ #include "assertions.h" #include "enb_app.h" +#if 0 void handle_reconfiguration(mid_t mod_id) { /* NOTE: this function might be extended by using stop_modem() @@ -69,6 +70,7 @@ void handle_reconfiguration(mid_t mod_id) LOG_I(ENB_APP, "lte-softmodem restart succeeded in %d ms\n", diff_ms); } } +#endif int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy_length) { @@ -109,7 +111,8 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy if (parse_enb_id(mod_id, &parser) == -1) { goto error; } else { // succeful parse and setting - handle_reconfiguration(mod_id); + /* TODO implement */ + //handle_reconfiguration(mod_id); } } else if (strcmp((char *) event.data.scalar.value, "mac") == 0) { LOG_D(ENB_APP, "This is intended for the mac system\n"); @@ -293,8 +296,7 @@ int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) { yaml_event_delete(&event); } - /* reflect in RAN API */ - flexran_set_enb_vars(mod_id, RAN_LTE_OAI); + /* TODO: reflect in RAN API */ return 0; diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index e27ef3648a..36538a3364 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -800,6 +800,7 @@ typedef struct { ///Contention resolution timer used during random access uint8_t mac_ContentionResolutionTimer; + /* TODO Navid MAX_NUM_LCID -> MAX_NUM_CCs? */ uint16_t max_rbs_allowed_slice[MAX_NUM_LCID][MAX_NUM_SLICES]; uint8_t max_mcs[MAX_NUM_LCID]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index a0da4f4961..ae4afc8b42 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -64,7 +64,6 @@ #include "flexran.pb-c.h" #endif #include -#endif #include "T.h" @@ -449,7 +448,7 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, //------------------------------------------------------------------------------ void -schedule_dlsch(module_id_ module_idP, +schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) //------------------------------------------------------------------------------{ { @@ -466,7 +465,7 @@ schedule_dlsch(module_id_ module_idP, for (i = 0; i < n_active_slices; i++) { if (slice_percentage[i] < 0 ){ LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %f. resetting to zero", - mod_id, frame, subframe, i, slice_percentage[i]); + module_idP, frameP, subframeP, i, slice_percentage[i]); slice_percentage[i]=0; } total_slice_percentage+=slice_percentage[i]; @@ -488,7 +487,7 @@ schedule_dlsch(module_id_ module_idP, if (n_active_slices_current != n_active_slices ){ if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active DL slices has changed: %d-->%d\n", - mod_id, frame, subframe, n_active_slices_current, n_active_slices); + module_idP, frameP, subframeP, n_active_slices_current, n_active_slices); n_active_slices_current = n_active_slices; @@ -501,7 +500,7 @@ schedule_dlsch(module_id_ module_idP, // check if the slice rb share has changed, and log the console if (slice_percentage_current[i] != slice_percentage[i]){ // new slice percentage LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: total percentage %f-->%f, slice RB percentage has changed: %f-->%f\n", - mod_id, i, frame, subframe, total_slice_percentage_current, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); + module_idP, i, frameP, subframeP, total_slice_percentage_current, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); total_slice_percentage_current= total_slice_percentage; slice_percentage_current[i] = slice_percentage[i]; @@ -511,10 +510,10 @@ schedule_dlsch(module_id_ module_idP, if (slice_maxmcs_current[i] != slice_maxmcs[i]){ if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)){ LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", - mod_id, i, frame, subframe, slice_maxmcs_current[i], slice_maxmcs[i]); + module_idP, i, frameP, subframeP, slice_maxmcs_current[i], slice_maxmcs[i]); slice_maxmcs_current[i] = slice_maxmcs[i]; } else { - LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs[i],slice_maxmcs_current[i]); + LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid slice max mcs %d, revert the previous value %d\n",module_idP, i, slice_maxmcs[i],slice_maxmcs_current[i]); slice_maxmcs[i]= slice_maxmcs_current[i]; } } @@ -522,7 +521,7 @@ schedule_dlsch(module_id_ module_idP, // check if a new scheduler, and log the console if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", - mod_id, i, frame, subframe, dl_scheduler_type[i]); + module_idP, i, frameP, subframeP, dl_scheduler_type[i]); update_dl_scheduler_current[i] = update_dl_scheduler[i]; } @@ -531,16 +530,14 @@ schedule_dlsch(module_id_ module_idP, if (n_active_slices == n_active_slices_current){ LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid total RB share (%f->%f), reduce proportionally the RB share by 0.1\n", - mod_id,i, - total_slice_percentage_current, total_slice_percentage); + module_idP, i, total_slice_percentage_current, total_slice_percentage); if (slice_percentage[i] >= avg_slice_percentage){ slice_percentage[i]-=0.1; total_slice_percentage-=0.1; } } else { LOG_W(MAC,"[eNB %d][SLICE %d][DL] invalid total RB share (%f->%f), revert the number of slice to its previous value (%d->%d)\n", - mod_id,i, - total_slice_percentage_current, total_slice_percentage, + module_idP, i, total_slice_percentage_current, total_slice_percentage, n_active_slices, n_active_slices_current ); n_active_slices = n_active_slices_current; slice_percentage[i] = slice_percentage_current[i]; @@ -548,7 +545,8 @@ schedule_dlsch(module_id_ module_idP, } // Run each enabled slice-specific schedulers one by one - slice_sched_dl[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); + /* TODO Navid took out the dl_info additional information */ + slice_sched_dl[i](module_idP, i, frameP, subframeP, mbsfn_flag/*, dl_info*/); } } @@ -806,7 +804,7 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, */ eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; - eNB_UE_stats->dlsch_mcs1 =cmin(eNB_UE_stats->dlsch_mcs1, flexran_slice_maxmcs(slice_idP));//openair_daq_vars.target_ue_dl_mcs); + eNB_UE_stats->dlsch_mcs1 =cmin(eNB_UE_stats->dlsch_mcs1, slice_maxmcs[slice_idP]);//openair_daq_vars.target_ue_dl_mcs); // store stats diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index fe885d38cc..15f67871b1 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -61,6 +61,8 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 +extern int n_active_slices; + int choose(int n, int k) { int res = 1; @@ -1927,7 +1929,7 @@ int UE_num_active_CC(UE_list_t * listP, int ue_idP) int UE_PCCID(module_id_t mod_idP, int ue_idP) //------------------------------------------------------------------------------ { - if (RC.mac[mod_idP] == NULL) return 0; + if (!RC.mac || !RC.mac[mod_idP]) return 0; return (RC.mac[mod_idP]->UE_list.pCC_id[ue_idP]); } @@ -1935,7 +1937,7 @@ int UE_PCCID(module_id_t mod_idP, int ue_idP) rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP) //------------------------------------------------------------------------------ { - if (RC.mac[mod_idP] == NULL) return 0; + if (!RC.mac || !RC.mac[mod_idP]) return 0; rnti_t rnti = RC.mac[mod_idP]-> UE_list.UE_template[UE_PCCID(mod_idP, ue_idP)][ue_idP].rnti; @@ -1953,7 +1955,7 @@ rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP) boolean_t is_UE_active(module_id_t mod_idP, int ue_idP) //------------------------------------------------------------------------------ { - if (RC.mac[mod_idP] == NULL) return 0; + if (!RC.mac || !RC.mac[mod_idP]) return 0; return (RC.mac[mod_idP]->UE_list.active[ue_idP]); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 7076827896..f1bfac7949 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -63,8 +63,8 @@ #include "header.pb-c.h" #include "flexran.pb-c.h" #include "flexran_agent_mac.h" -#include #endif +#include #include "T.h" @@ -943,13 +943,13 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, * (done below in schedule_ulsch). */ void -set_msg3_subframe(module_id_t Mod_id, +set_msg3_subframe(module_id_t mod_id, int CC_id, int frame, int subframe, int rnti, int Msg3_frame, int Msg3_subframe) { - eNB_MAC_INST *mac = RC.mac[Mod_id]; + eNB_MAC_INST *mac = RC.mac[mod_id]; int i; for (i = 0; i < NB_RA_PROC_MAX; i++) { if (mac->common_channels[CC_id].ra[i].state != IDLE && @@ -1086,7 +1086,7 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, for (i = 0; i < n_active_slices_uplink; i++) { if (slice_percentage_uplink[i] < 0 ){ LOG_W(MAC, "[eNB %d] frame %d subframe %d:invalid slice %d percentage %f. resetting to zero", - mod_id, frame, subframe, i, slice_percentage_uplink[i]); + module_idP, frameP, subframeP, i, slice_percentage_uplink[i]); slice_percentage_uplink[i]=0; } total_slice_percentage_uplink+=slice_percentage_uplink[i]; @@ -1112,7 +1112,7 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, if (n_active_slices_current_uplink != n_active_slices_uplink ){ if ((n_active_slices_uplink > 0) && (n_active_slices_uplink <= MAX_NUM_SLICES)) { LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active UL slices has changed: %d-->%d\n", - mod_id, frame, subframe, n_active_slices_current_uplink, n_active_slices_uplink); + module_idP, frameP, subframeP, n_active_slices_current_uplink, n_active_slices_uplink); n_active_slices_current_uplink = n_active_slices_uplink; @@ -1125,7 +1125,7 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, // check if the slice rb share has changed, and log the console if (slice_percentage_current_uplink[i] != slice_percentage_uplink[i]){ LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: total percentage %f-->%f, slice RB percentage has changed: %f-->%f\n", - mod_id, i, frame, subframe, total_slice_percentage_current_uplink, total_slice_percentage_uplink, slice_percentage_current_uplink[i], slice_percentage_uplink[i]); + module_idP, i, frameP, subframeP, total_slice_percentage_current_uplink, total_slice_percentage_uplink, slice_percentage_current_uplink[i], slice_percentage_uplink[i]); total_slice_percentage_current_uplink= total_slice_percentage_uplink; slice_percentage_current_uplink[i] = slice_percentage_uplink[i]; @@ -1135,10 +1135,10 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, if (slice_maxmcs_current_uplink[i] != slice_maxmcs_uplink[i]){ if ((slice_maxmcs_uplink[i] >= 0) && (slice_maxmcs_uplink[i] <= 16)){ LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", - mod_id, i, frame, subframe, slice_maxmcs_current_uplink[i], slice_maxmcs_uplink[i]); + module_idP, i, frameP, subframeP, slice_maxmcs_current_uplink[i], slice_maxmcs_uplink[i]); slice_maxmcs_current_uplink[i] = slice_maxmcs_uplink[i]; } else { - LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_maxmcs_uplink[i],slice_maxmcs_current_uplink[i]); + LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid slice max mcs %d, revert the previous value %d\n",module_idP, i, slice_maxmcs_uplink[i],slice_maxmcs_current_uplink[i]); slice_maxmcs_uplink[i]= slice_maxmcs_current_uplink[i]; } @@ -1147,7 +1147,7 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, // check if a new scheduler, and log the console if (update_ul_scheduler_current[i] != update_ul_scheduler[i]){ LOG_N(MAC,"[eNB %d][SLICE %d][UL] frame %d subframe %d: UL scheduler for this slice is updated: %s \n", - mod_id, i, frame, subframe, ul_scheduler_type[i]); + module_idP, i, frameP, subframeP, ul_scheduler_type[i]); update_ul_scheduler_current[i] = update_ul_scheduler[i]; } @@ -1156,8 +1156,8 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, if (n_active_slices_uplink == n_active_slices_current_uplink){ LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid total RB share (%f->%f), reduce proportionally the RB share by 0.1\n", - mod_id,i, - total_slice_percentage_current_uplink, total_slice_percentage_uplink); + module_idP, i, total_slice_percentage_current_uplink, + total_slice_percentage_uplink); if (slice_percentage_uplink[i] > avg_slice_percentage_uplink){ slice_percentage_uplink[i]-=0.1; total_slice_percentage_uplink-=0.1; @@ -1165,9 +1165,9 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, } else { // here we can correct the values, e.g. reduce proportionally LOG_W(MAC,"[eNB %d][SLICE %d][UL] invalid total RB share (%f->%f), revert the number of slice to its previous value (%d->%d)\n", - mod_id,i, - total_slice_percentage_current_uplink, total_slice_percentage_uplink, - n_active_slices_uplink, n_active_slices_current_uplink); + module_idP, i, total_slice_percentage_current_uplink, + total_slice_percentage_uplink, n_active_slices_uplink, + n_active_slices_current_uplink); n_active_slices_uplink = n_active_slices_current_uplink; slice_percentage_uplink[i] = slice_percentage_current_uplink[i]; } diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index af5b6f660b..dbe0d820f2 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -57,6 +57,8 @@ #define DEBUG_HEADER_PARSING 1 //#define DEBUG_PACKET_TRACE 1 +extern float slice_percentage[MAX_NUM_SLICES]; + //#define ICIC 0 /* @@ -267,7 +269,8 @@ assign_rbs_required(module_id_t Mod_id, to_prb(RC.mac[Mod_id]->common_channels[CC_id]. mib->message.dl_Bandwidth); - UE_list->ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]= flexran_nb_rbs_allowed_slice(slice_percentage[slice_id],N_RB_DL); + /* TODO Navid: field max_rbs_allowed_slice is [MAX_NUM_LCID][MAX_NUM_SLICES] -> Why CC_id? or bug in definition? */ + UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]= flexran_nb_rbs_allowed_slice(slice_percentage[slice_id],N_RB_DL); /* calculating required number of RBs for each UE */ while (TBS < @@ -275,10 +278,13 @@ assign_rbs_required(module_id_t Mod_id, dl_buffer_total) { nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; - if (nb_rbs_required[CC_id][UE_id] > UE_list->ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]) { + /* TODO Navid: field max_rbs_allowed_slice is [MAX_NUM_LCID][MAX_NUM_SLICES] -> Why CC_id? or bug in definition? */ + if (nb_rbs_required[CC_id][UE_id] > UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]) { TBS = - get_TBS_DL(eNB_UE_stats->dlsch_mcs1, UE_list->ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]); - nb_rbs_required[CC_id][UE_id] = UE_list->ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]; + /* TODO Navid: field max_rbs_allowed_slice is [MAX_NUM_LCID][MAX_NUM_SLICES] -> Why CC_id? or bug in definition? */ + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]); + /* TODO Navid: field max_rbs_allowed_slice is [MAX_NUM_LCID][MAX_NUM_SLICES] -> Why CC_id? */ + nb_rbs_required[CC_id][UE_id] = UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]; break; } @@ -614,7 +620,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, if (UE_list->active[i] != TRUE) continue; - if (!flexran_slice_member(UE_id, slice_id)) + if (!flexran_slice_member(i, slice_id)) continue; UE_id = i; @@ -724,13 +730,15 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, message.dl_Bandwidth) - total_rbs_used[CC_id]; //recalcualte based on the what is left after retransmission - ue_sched_ctl.max_allowed_rbs[CC_id][slice_id]= flexran_nb_rbs_allowed_slice(slice_percentage[slice_id],N_RB_DL); + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + /* TODO Navid: as above */ + ue_sched_ctl->max_rbs_allowed_slice[CC_id][slice_id]= flexran_nb_rbs_allowed_slice(slice_percentage[slice_id],N_RB_DL); if (total_ue_count[CC_id] == 0) { average_rbs_per_user[CC_id] = 0; - } else if ((min_rb_unit[CC_id] * total_ue_count[CC_id]) <= (ue_sched_ctl.max_allowed_rbs[CC_id][slice_id])) { + } else if ((min_rb_unit[CC_id] * total_ue_count[CC_id]) <= (ue_sched_ctl->max_rbs_allowed_slice[CC_id][slice_id])) { average_rbs_per_user[CC_id] = - (uint16_t) floor(ue_sched_ctl.max_allowed_rbs[CC_id][slice_id] / total_ue_count[CC_id]); + (uint16_t) floor(ue_sched_ctl->max_rbs_allowed_slice[CC_id][slice_id] / total_ue_count[CC_id]); } else { average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; // consider the total number of use that can be scheduled UE } @@ -1390,7 +1398,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, int N_RB_UL; LOG_D(MAC, "In ulsch_preprocessor: assign max mcs min rb\n"); // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB - assign_max_mcs_min_rb(module_idP, frameP, subframeP, first_rb); + assign_max_mcs_min_rb(module_idP, slice_id, frameP, subframeP, first_rb); LOG_D(MAC, "In ulsch_preprocessor: sort ue \n"); // sort ues diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 842e1d7080..c7aa6290ae 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -217,6 +217,8 @@ void dlsch_scheduler_pre_processor_reset(int module_idP, int UE_id, uint16_t nb_rbs_required_remaining [MAX_NUM_CCs][NUMBER_OF_UE_MAX], + unsigned char total_ue_count[MAX_NUM_CCs], + unsigned char total_rbs_used[MAX_NUM_CCs], unsigned char rballoc_sub[MAX_NUM_CCs] [N_RBG_MAX], @@ -665,7 +667,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, slice_id_t slice_id, void store_ulsch_buffer(module_id_t module_idP, int frameP, sub_frame_t subframeP); 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, +void assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, sub_frame_t subframeP, uint16_t * first_rb); void adjust_bsr_info(int buffer_occupancy, uint16_t TBS, UE_TEMPLATE * UE_template); diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index c946dcf818..8402d1ba61 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2156,7 +2156,7 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt int i; // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE - eNB_RRC_INST* rrc_inst = &eNB_rrc_inst[ctxt_pP->module_id]; + eNB_RRC_INST* rrc_inst = RC.rrc[ctxt_pP->module_id]; struct PhysicalConfigDedicated** physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; struct SRB_ToAddMod *SRB2_config = NULL; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 0626ad7725..6b418bb8ff 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -239,9 +239,7 @@ static void* eNB_thread_rxtx( void* param ) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); -#ifdef DEBUG_THREADS - printf(" *** Exiting eNB thread RXn_TXnp4\n"); -#endif + LOG_D(PHY, " *** Exiting eNB thread RXn_TXnp4\n"); eNB_thread_rxtx_status = 0; return &eNB_thread_rxtx_status; @@ -624,8 +622,6 @@ void init_eNB_proc(int inst) { pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_RU,NULL); pthread_mutex_init( &proc->mutex_RU_PRACH,NULL); - pthread_mutex_init( &proc->mutex_synch,NULL); - pthread_mutex_init( &proc->mutex_FH, NULL); pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_asynch_rxtx, NULL); @@ -727,22 +723,12 @@ void kill_eNB_proc(int inst) { proc_rxtx[1].instance_cnt_rxtx = 0; pthread_mutex_unlock(&proc_rxtx[1].mutex_rxtx); } - pthread_mutex_lock(&PHY_vars_eNB_g[0][CC_id]->proc.mutex_synch); - PHY_vars_eNB_g[0][CC_id]->proc.instance_cnt_synch = 1; - pthread_mutex_unlock(&PHY_vars_eNB_g[0][CC_id]->proc.mutex_synch); proc->instance_cnt_prach = 0; pthread_cond_signal( &proc->cond_prach ); - pthread_cond_signal( &proc->cond_FH ); pthread_cond_signal( &proc->cond_asynch_rxtx ); - pthread_cond_signal( &proc->cond_synch ); pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); - LOG_D(PHY, "joining pthread_FH\n"); - pthread_join( proc->pthread_FH, (void**)&status ); - pthread_mutex_destroy( &proc->mutex_FH ); - pthread_cond_destroy( &proc->cond_FH ); - LOG_D(PHY, "joining pthread_prach\n"); pthread_join( proc->pthread_prach, (void**)&status ); @@ -776,12 +762,7 @@ void kill_eNB_proc(int inst) { LOG_D(PHY, "joining pthread_single\n"); pthread_join(proc->pthread_single, (void**)&status ); - - LOG_D(PHY, "joining pthread_synch\n"); - pthread_join(proc->pthread_synch, (void**)&status ); - pthread_mutex_destroy(&proc->mutex_synch); - pthread_cond_destroy(&proc->cond_synch); - LOG_D(PHY, "joined all threads\n"); + LOG_D(PHY, "joined all eNB threads\n"); } } diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 315eee23cd..eab0a88c45 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -229,8 +229,6 @@ uint8_t abstraction_flag=0; /* forward declarations */ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); -/* override the enb configuration parameters */ -static void reconfigure_enb_params(int enb_id); /*---------------------BMC: timespec helpers -----------------------------*/ @@ -691,54 +689,6 @@ static void get_options(void) { } -static void reconfigure_enb_params(int enb_id) -{ - int CC_id, k; - const Enb_properties_array_t *enb_properties=enb_config_get(); - - for (CC_id=0; CC_idproperties[enb_id]->cc_node_function[CC_id]; - node_timing[CC_id] = enb_properties->properties[enb_id]->cc_node_timing[CC_id]; - node_synch_ref[CC_id] = enb_properties->properties[enb_id]->cc_node_synch_ref[CC_id]; - - frame_parms[CC_id]->frame_type = enb_properties->properties[enb_id]->frame_type[CC_id]; - frame_parms[CC_id]->tdd_config = enb_properties->properties[enb_id]->tdd_config[CC_id]; - frame_parms[CC_id]->tdd_config_S = enb_properties->properties[enb_id]->tdd_config_s[CC_id]; - frame_parms[CC_id]->Ncp = enb_properties->properties[enb_id]->prefix_type[CC_id]; - - //for (j=0; j < enb_properties->properties[i]->nb_cc; j++ ){ - frame_parms[CC_id]->Nid_cell = enb_properties->properties[enb_id]->Nid_cell[CC_id]; - frame_parms[CC_id]->N_RB_DL = enb_properties->properties[enb_id]->N_RB_DL[CC_id]; - frame_parms[CC_id]->N_RB_UL = enb_properties->properties[enb_id]->N_RB_DL[CC_id]; - frame_parms[CC_id]->nb_antennas_tx = enb_properties->properties[enb_id]->nb_antennas_tx[CC_id]; - frame_parms[CC_id]->nb_antenna_ports_eNB = enb_properties->properties[enb_id]->nb_antenna_ports[CC_id]; - frame_parms[CC_id]->nb_antennas_rx = enb_properties->properties[enb_id]->nb_antennas_rx[CC_id]; - - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex = enb_properties->properties[enb_id]->prach_config_index[CC_id]; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset = enb_properties->properties[enb_id]->prach_freq_offset[CC_id]; - - frame_parms[CC_id]->mode1_flag = (frame_parms[CC_id]->nb_antenna_ports_eNB == 1) ? 1 : 0; - frame_parms[CC_id]->threequarter_fs = threequarter_fs; - - for (k = 0 ; k < 4; k++) { - downlink_frequency[CC_id][k] = enb_properties->properties[enb_id]->downlink_frequency[CC_id]; - uplink_frequency_offset[CC_id][k] = enb_properties->properties[enb_id]->uplink_frequency_offset[CC_id]; - rx_gain[CC_id][k] = (double)enb_properties->properties[enb_id]->rx_gain[CC_id]; - tx_gain[CC_id][k] = (double)enb_properties->properties[enb_id]->tx_gain[CC_id]; - } - - printf("Downlink frequency/ uplink offset of CC_id %d set to %ju/%d\n", CC_id, - enb_properties->properties[enb_id]->downlink_frequency[CC_id], - enb_properties->properties[enb_id]->uplink_frequency_offset[CC_id]); - - init_ul_hopping(frame_parms[CC_id]); - init_frame_parms(frame_parms[CC_id],1); - // phy_init_top(frame_parms[CC_id]); - phy_init_lte_top(frame_parms[CC_id]); - } // CC_id -} - #if T_TRACER int T_nowait = 0; /* by default we wait for the tracer */ int T_port = 2021; /* default port to listen to to wait for the tracer */ @@ -887,6 +837,7 @@ void init_openair0() { } } + void wait_RUs(void) { LOG_I(PHY,"Waiting for RUs to be configured ...\n"); @@ -923,70 +874,6 @@ void wait_eNBs(void) { printf("eNB L1 are configured\n"); } -void fill_PHY_vars_eNB_g(uint8_t abstraction_flag, uint8_t beta_ACK, uint8_t beta_RI, uint8_t beta_CQI) -{ - int CC_id, i, j, k, re; - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id], - 0, - frame_parms[CC_id]->Nid_cell, - node_function[CC_id], - abstraction_flag); - PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc = 0x1fff; - PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs = target_dl_mcs; - PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb = 6; - PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs = target_ul_mcs; - // initialization for phy-test - for (k = 0; k < NUMBER_OF_UE_MAX; k++) { - PHY_vars_eNB_g[0][CC_id]->transmission_mode[k] = transmission_mode; - if (transmission_mode == 7) - lte_gold_ue_spec_port5(PHY_vars_eNB_g[0][CC_id]->lte_gold_uespec_port5_table[k], - frame_parms[CC_id]->Nid_cell, - 0x1235+k); - } - if ((transmission_mode == 1) || (transmission_mode == 7)) { - for (j = 0; j < frame_parms[CC_id]->nb_antennas_tx; j++) - for (re = 0; re < frame_parms[CC_id]->ofdm_symbol_size; re++) - PHY_vars_eNB_g[0][CC_id]->common_vars.beam_weights[0][0][j][re] = 0x00007fff / frame_parms[CC_id]->nb_antennas_tx; - } - - if (phy_test==1) - PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0; - else - PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1; - - if (PHY_vars_eNB_g[0][CC_id]->mac_enabled == 0) { //set default parameters for testing mode - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; - - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i; - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3); - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; - } - } - - compute_prach_seq(&PHY_vars_eNB_g[0][CC_id]->frame_parms.prach_config_common, - PHY_vars_eNB_g[0][CC_id]->frame_parms.frame_type, - PHY_vars_eNB_g[0][CC_id]->X_u); - - - PHY_vars_eNB_g[0][CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0]; - - if (frame_parms[CC_id]->frame_type == FDD) { - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 0; - } else { - if (frame_parms[CC_id]->N_RB_DL == 100) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624; - else if (frame_parms[CC_id]->N_RB_DL == 50) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/2; - else if (frame_parms[CC_id]->N_RB_DL == 25) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/4; - } - } -} - #if defined(ENABLE_ITTI) && defined(FLEXRAN_AGENT_SB_IF) /* * helper function to terminate a certain ITTI task @@ -999,6 +886,7 @@ void terminate_task(task_id_t task_id, mid_t mod_id) itti_send_msg_to_task (task_id, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg); } +#if 0 int stop_L1L2(int enb_id) { int CC_id; @@ -1107,6 +995,7 @@ int restart_L1L2(int enb_id) return 0; } #endif +#endif int main( int argc, char **argv ) { @@ -1274,19 +1163,14 @@ int main( int argc, char **argv ) flexran_agent_start(i); } - LOG_I(ENB_APP, " * Waiting for FlexRAN RTController command *\n"); - pthread_mutex_lock(&mutex_node_ctrl); - while (ENB_NORMAL_OPERATION != node_control_state) - pthread_cond_wait(&cond_node_ctrl, &mutex_node_ctrl); - pthread_mutex_unlock(&mutex_node_ctrl); + /* TODO handle restart/initial blocking */ + //LOG_I(ENB_APP, " * Waiting for FlexRAN RTController command *\n"); + //pthread_mutex_lock(&mutex_node_ctrl); + //while (ENB_NORMAL_OPERATION != node_control_state) + // pthread_cond_wait(&cond_node_ctrl, &mutex_node_ctrl); + //pthread_mutex_unlock(&mutex_node_ctrl); - /* reconfigure eNB in case FlexRAN controller applied changes */ - /* TODO needs to be done? */ - //for (i=0; i < NB_eNB_INST; i++){ - // LOG_I(ENB_APP, "Reconfigure eNB module %d and FlexRAN eNB variables\n", i); - // reconfigure_enb_params(i); - // flexran_set_enb_vars(i, RAN_LTE_OAI); - //} + /* TODO do eNB reconfiguration (handled implicitly?) */ #endif if (UE_flag==1) { @@ -1611,6 +1495,7 @@ int main( int argc, char **argv ) } } } + #endif printf("stopping MODEM threads\n"); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 6274fc1610..13e5ba6b91 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -269,7 +269,7 @@ extern int restart_L1L2(int enb_id); #ifdef FLEXRAN_AGENT_SB_IF #include "flexran_agent.h" // for locking -volatile ENB_MODULE_STATE node_control_state; +//volatile ENB_MODULE_STATE node_control_state; pthread_cond_t cond_node_ctrl; pthread_mutex_t mutex_node_ctrl; #endif From 56d4d0ebef8e5b21987d4a5412c961f52952549d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 16 Jan 2018 12:27:55 +0100 Subject: [PATCH 079/141] Bugfix: avoid cyclic header dependency, use FlexRAN variables instead --- .../ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h | 1 - openair2/ENB_APP/flexran_agent_extern.h | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h index a101bab242..cf20c477de 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc_defs.h @@ -31,7 +31,6 @@ #ifndef __FLEXRAN_AGENT_RRC_PRIMITIVES_H__ #define __FLEXRAN_AGENT_RRC_PRIMITIVES_H__ -#include "PHY/extern.h" #include "flexran_agent_defs.h" #include "flexran.pb-c.h" #include "header.pb-c.h" diff --git a/openair2/ENB_APP/flexran_agent_extern.h b/openair2/ENB_APP/flexran_agent_extern.h index 589975b310..ae77e9227a 100644 --- a/openair2/ENB_APP/flexran_agent_extern.h +++ b/openair2/ENB_APP/flexran_agent_extern.h @@ -30,11 +30,10 @@ #ifndef __FLEXRAN_AGENT_EXTERN_H__ #define __FLEXRAN_AGENT_EXTERN_H__ -// #include "flexran_agent_defs.h" +#include "flexran_agent_defs.h" #include "flexran_agent_mac_defs.h" #include "flexran_agent_rrc_defs.h" #include "flexran_agent_pdcp_defs.h" -#include "common/ran_context.h" /* Control module interface for the communication of the MAC Control Module with the agent */ extern AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]; @@ -55,7 +54,7 @@ extern AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB]; extern unsigned int pdcp_agent_registered[NUM_MAX_ENB]; /* Requried to know which UEs had a harq updated over some subframe */ -extern int harq_pid_updated[NUMBER_OF_UE_MAX][8]; -extern int harq_pid_round[NUMBER_OF_UE_MAX][8]; +extern int harq_pid_updated[NUM_MAX_UE][8]; +extern int harq_pid_round[NUM_MAX_UE][8]; #endif From 3740afecc7081971dfcf8eb0e3c0b03495f1aaad Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 16 Jan 2018 12:30:34 +0100 Subject: [PATCH 080/141] consider changed RAN API --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 17 ++++++++++------- .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 9 +++++---- openair2/ENB_APP/flexran_agent_common.c | 9 +++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index d60a9eb3b7..4f91e65c6a 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -219,21 +219,21 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, if (flexran_get_antenna_ports(enb_id, j) == 2 && csi_reports[j]->ri == 1) { // TODO PMI - csi11->wb_pmi = flexran_get_ue_pmi(enb_id); + csi11->wb_pmi = flexran_get_ue_wpmi(enb_id, i, 0); csi11->has_wb_pmi = 1; } else if (flexran_get_antenna_ports(enb_id, j) == 2 && csi_reports[j]->ri == 2){ // TODO PMI - csi11->wb_pmi = flexran_get_ue_pmi(enb_id); + csi11->wb_pmi = flexran_get_ue_wpmi(enb_id, i, 0); csi11->has_wb_pmi = 1; } else if (flexran_get_antenna_ports(enb_id, j) == 4 && csi_reports[j]->ri == 2){ // TODO PMI - csi11->wb_pmi = flexran_get_ue_pmi(enb_id); + csi11->wb_pmi = flexran_get_ue_wpmi(enb_id, i, 0); csi11->has_wb_pmi = 1; @@ -868,13 +868,16 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle protocol__flex_ul_info__init(ul_info[i]); ul_info[i]->rnti = flexran_get_ue_crnti(mod_id, i); ul_info[i]->has_rnti = 1; - /*Fill in the Tx power control command for this UE (if available)*/ - if(flexran_get_tpc(mod_id,i) != 1){ - ul_info[i]->tpc = flexran_get_tpc(mod_id,i); + /* Fill in the Tx power control command for this UE (if available), + * primary carrier */ + if(flexran_get_tpc(mod_id, i, 0) != 1){ + /* assume primary carrier */ + ul_info[i]->tpc = flexran_get_tpc(mod_id, i, 0); ul_info[i]->has_tpc = 1; } else{ - ul_info[i]->tpc = flexran_get_tpc(mod_id,i); + /* assume primary carrier */ + ul_info[i]->tpc = flexran_get_tpc(mod_id, i, 0); ul_info[i]->has_tpc = 0; } /*TODO: fill in the amount of data in bytes in the MAC SDU received in this subframe for the diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index 6f42d1da97..590e9c870f 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -165,9 +165,10 @@ void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_ch config->beta_offset_cqi_index = flexran_get_beta_offset_cqi_index(mod_id,i); } - if(flexran_get_ack_nack_simultaneous_trans(mod_id,i) != -1) { + /* assume primary carrier */ + if(flexran_get_ack_nack_simultaneous_trans(mod_id,i,0) != -1) { config->has_ack_nack_simultaneous_trans = 1; - config->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id,i); + config->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id,i,0); } if(flexran_get_simultaneous_ack_nack_cqi(mod_id,i) != -1) { @@ -185,9 +186,9 @@ void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_ch } } - if(flexran_get_tdd_ack_nack_feedback(mod_id, i) != -1) { + if(flexran_get_tdd_ack_nack_feedback_mode(mod_id, i) != -1) { config->has_tdd_ack_nack_feedback = 1; - config->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback(mod_id,i); + config->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback_mode(mod_id,i); } if(flexran_get_ack_nack_repetition_factor(mod_id, i) != -1) { diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 00aa7e9263..33879714d9 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -676,9 +676,10 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl ue_config[i]->beta_offset_cqi_index = flexran_get_beta_offset_cqi_index(mod_id,i); } - if (flexran_get_ack_nack_simultaneous_trans(mod_id,i) != -1) { + /* assume primary carrier */ + if (flexran_get_ack_nack_simultaneous_trans(mod_id, i, 0) != -1) { ue_config[i]->has_ack_nack_simultaneous_trans = 1; - ue_config[i]->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id,i); + ue_config[i]->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id, i, 0); } if (flexran_get_simultaneous_ack_nack_cqi(mod_id,i) != -1) { @@ -696,9 +697,9 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl } } - if (flexran_get_tdd_ack_nack_feedback(mod_id, i) != -1) { + if (flexran_get_tdd_ack_nack_feedback_mode(mod_id, i) != -1) { ue_config[i]->has_tdd_ack_nack_feedback = 1; - ue_config[i]->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback(mod_id,i); + ue_config[i]->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback_mode(mod_id,i); } if(flexran_get_ack_nack_repetition_factor(mod_id, i) != -1) { From 356d406cffbbfa444aa7e05a7c96e637132c60e3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 16 Jan 2018 12:36:44 +0100 Subject: [PATCH 081/141] Navid: remove FlexRAN Agent MAC xface function callbacks for scheduling --- .../ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c | 5 ----- .../CONTROL_MODULES/MAC/flexran_agent_mac_defs.h | 11 ----------- .../CONTROL_MODULES/MAC/flexran_agent_mac_internal.c | 1 - 3 files changed, 17 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 4f91e65c6a..3d0d08efbb 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -1249,9 +1249,6 @@ int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->flexran_agent_send_sr_info = flexran_agent_send_sr_info; xface->flexran_agent_send_sf_trigger = flexran_agent_send_sf_trigger; //xface->flexran_agent_send_update_mac_stats = flexran_agent_send_update_mac_stats; - xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_dl_spec_default; - xface->flexran_agent_schedule_ul_spec = flexran_schedule_ue_ul_spec_default; - //xface->flexran_agent_schedule_ue_spec = flexran_schedule_ue_spec_remote; xface->flexran_agent_get_pending_dl_mac_config = flexran_agent_get_pending_dl_mac_config; xface->dl_scheduler_loaded_lib = NULL; @@ -1268,9 +1265,7 @@ int flexran_agent_unregister_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->flexran_agent_send_sr_info = NULL; xface->flexran_agent_send_sf_trigger = NULL; //xface->flexran_agent_send_update_mac_stats = NULL; - xface->flexran_agent_schedule_ue_spec = NULL; xface->flexran_agent_get_pending_dl_mac_config = NULL; - xface->flexran_agent_schedule_ul_spec = NULL; xface->dl_scheduler_loaded_lib = NULL; xface->ul_scheduler_loaded_lib = NULL; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h index 769ddbb1b6..5c1fc1379c 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_defs.h @@ -54,17 +54,6 @@ typedef struct { void (*flexran_agent_get_pending_dl_mac_config)(mid_t mod_id, Protocol__FlexranMessage **msg); - /// Run the UE DL scheduler and fill the Protocol__FlexranMessage. Assumes that - /// dl_info is already initialized as flex_dl_mac_config and fills the - /// flex_dl_data part of it - void (*flexran_agent_schedule_ue_spec)(mid_t mod_id, uint32_t frame, uint32_t subframe, - int *mbsfn_flag, Protocol__FlexranMessage **dl_info); - - /// Run the UE UL scheduler and fill the Protocol__FlexranMessage. Assumes that - - void (*flexran_agent_schedule_ul_spec)(mid_t module_idP, uint32_t frameP, uint32_t cooperation_flag, - int subframeP, unsigned char sched_subframe, Protocol__FlexranMessage **ul_info); - /// Notify the controller for a state change of a particular UE, by sending the proper /// UE state change message (ACTIVATION, DEACTIVATION, HANDOVER) // int (*flexran_agent_notify_ue_state_change)(mid_t mod_id, uint32_t rnti, diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index 2af6514ef6..b7a93b8491 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -883,7 +883,6 @@ int load_dl_scheduler_function(mid_t mod_id, const char *function_name) { void *loaded_scheduler = dlsym(lib, function_name); if (loaded_scheduler) { if (mac_agent_registered[mod_id]) { - agent_mac_xface[mod_id]->flexran_agent_schedule_ue_spec = loaded_scheduler; if (agent_mac_xface[mod_id]->dl_scheduler_loaded_lib != NULL) { dlclose(agent_mac_xface[mod_id]->dl_scheduler_loaded_lib); } From 6179d9d7481ddecc17802a2975dea60c578dfe69 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 16 Jan 2018 15:18:22 +0100 Subject: [PATCH 082/141] Navid: fix access to non-existent harq_pid_* variables via RC read --- .../ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 3d0d08efbb..4f5d8af250 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -785,7 +785,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle for (i = 0; i < NUMBER_OF_UE_MAX; i++) { for (j = 0; j < 8; j++) { - if (harq_pid_updated[i][j] == 1) { + if (RC.mac && RC.mac[mod_id] && RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid == 1) { available_harq[i] = j; sf_trigger_msg->n_dl_info++; break; @@ -828,14 +828,15 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle dl_info[i]->harq_process_id = available_harq[UE_id]; - harq_pid_updated[UE_id][available_harq[UE_id]] = 0; + if (RC.mac && RC.mac[mod_id]) + RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][UE_id].harq_pid = 0; dl_info[i]->has_harq_process_id = 1; /* Fill in the status of the HARQ process (2 TBs)*/ dl_info[i]->n_harq_status = 2; dl_info[i]->harq_status = malloc(sizeof(uint32_t) * dl_info[i]->n_harq_status); for (j = 0; j < dl_info[i]->n_harq_status; j++) { - dl_info[i]->harq_status[j] = harq_pid_round[UE_id][available_harq[UE_id]]; - // TODO: This should be different per TB + dl_info[i]->harq_status[j] = RC.mac[mod_id]->UE_list.UE_sched_ctrl[i].round[UE_PCCID(mod_id,i)][j]; + // TODO: This should be different per TB } // LOG_I(FLEXRAN_AGENT, "Sending subframe trigger for frame %d and subframe %d and harq %d (round %d)\n", flexran_get_current_frame(mod_id), (flexran_get_current_subframe(mod_id) + 1) % 10, dl_info[i]->harq_process_id, dl_info[i]->harq_status[0]); if(dl_info[i]->harq_status[0] > 0) { @@ -1168,7 +1169,8 @@ void flexran_agent_init_mac_agent(mid_t mod_id) { lfds700_ringbuffer_init_valid_on_current_logical_core( &ringbuffer_state[mod_id], dl_mac_config_array[mod_id], num_elements, &ps[mod_id], NULL ); for (i = 0; i < NUMBER_OF_UE_MAX; i++) { for (j = 0; j < 8; j++) { - harq_pid_updated[i][j] = 0; + if (RC.mac && RC.mac[mod_id]) + RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid = 0; } } } From 1576b7bd08ff7d060dfa8022c1e26af55dfeb2ba Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 29 Jan 2018 11:03:16 +0100 Subject: [PATCH 083/141] bugfix: max_rbs_allowed_slice is array over CC, not LCID --- openair2/LAYER2/MAC/defs.h | 3 +-- openair2/LAYER2/MAC/pre_processor.c | 8 +------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 36538a3364..2f71c0ee74 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -800,8 +800,7 @@ typedef struct { ///Contention resolution timer used during random access uint8_t mac_ContentionResolutionTimer; - /* TODO Navid MAX_NUM_LCID -> MAX_NUM_CCs? */ - uint16_t max_rbs_allowed_slice[MAX_NUM_LCID][MAX_NUM_SLICES]; + uint16_t max_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; uint8_t max_mcs[MAX_NUM_LCID]; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index dbe0d820f2..017e62b48f 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -269,7 +269,6 @@ assign_rbs_required(module_id_t Mod_id, to_prb(RC.mac[Mod_id]->common_channels[CC_id]. mib->message.dl_Bandwidth); - /* TODO Navid: field max_rbs_allowed_slice is [MAX_NUM_LCID][MAX_NUM_SLICES] -> Why CC_id? or bug in definition? */ UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]= flexran_nb_rbs_allowed_slice(slice_percentage[slice_id],N_RB_DL); /* calculating required number of RBs for each UE */ @@ -278,12 +277,8 @@ assign_rbs_required(module_id_t Mod_id, dl_buffer_total) { nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; - /* TODO Navid: field max_rbs_allowed_slice is [MAX_NUM_LCID][MAX_NUM_SLICES] -> Why CC_id? or bug in definition? */ if (nb_rbs_required[CC_id][UE_id] > UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]) { - TBS = - /* TODO Navid: field max_rbs_allowed_slice is [MAX_NUM_LCID][MAX_NUM_SLICES] -> Why CC_id? or bug in definition? */ - get_TBS_DL(eNB_UE_stats->dlsch_mcs1, UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]); - /* TODO Navid: field max_rbs_allowed_slice is [MAX_NUM_LCID][MAX_NUM_SLICES] -> Why CC_id? */ + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]); nb_rbs_required[CC_id][UE_id] = UE_list->UE_sched_ctrl[UE_id].max_rbs_allowed_slice[CC_id][slice_id]; break; } @@ -731,7 +726,6 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, //recalcualte based on the what is left after retransmission ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - /* TODO Navid: as above */ ue_sched_ctl->max_rbs_allowed_slice[CC_id][slice_id]= flexran_nb_rbs_allowed_slice(slice_percentage[slice_id],N_RB_DL); if (total_ue_count[CC_id] == 0) { From 9333c16ecbc7040fa45724534e4eaaad1e5d67e3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Jan 2018 17:27:15 +0100 Subject: [PATCH 084/141] bugfixes: correctly initialize mutexes, conds of RU_proc_t, unlock RU.mutex after using --- targets/RT/USER/lte-ru.c | 2 ++ targets/RT/USER/lte-softmodem.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 54693f43c8..8903438eb0 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1615,11 +1615,13 @@ void init_RU_proc(RU_t *ru) { pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_synch,NULL); pthread_mutex_init( &proc->mutex_FH,NULL); + pthread_mutex_init( &proc->mutex_eNBs, NULL); pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_FH, NULL); pthread_cond_init( &proc->cond_asynch_rxtx, NULL); pthread_cond_init( &proc->cond_synch,NULL); + pthread_cond_init( &proc->cond_eNBs, NULL); pthread_attr_init( &proc->attr_FH); pthread_attr_init( &proc->attr_prach); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index eab0a88c45..44512843d7 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -844,12 +844,10 @@ void wait_RUs(void) { // wait for all RUs to be configured over fronthaul pthread_mutex_lock(&RC.ru_mutex); - - - while (RC.ru_mask>0) { pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); } + pthread_mutex_unlock(&RC.ru_mutex); LOG_I(PHY,"RUs configured\n"); } From a91a35877dd8b8b2791e173063f9b5080088b69f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Jan 2018 17:28:08 +0100 Subject: [PATCH 085/141] join all RU threads --- targets/RT/USER/lte-ru.c | 119 ++++++++++++++++++++++++++++++-- targets/RT/USER/lte-softmodem.c | 3 +- 2 files changed, 115 insertions(+), 7 deletions(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 8903438eb0..3ff4c4e7ac 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -116,7 +116,7 @@ extern volatile int oai_exit; extern void phy_init_RU(RU_t*); void init_RU(char*); -void stop_RU(RU_t *ru); +void stop_RU(int nb_ru); void do_ru_sync(RU_t *ru); void configure_ru(int idx, @@ -1673,9 +1673,115 @@ void init_RU_proc(RU_t *ru) { } +void kill_RU_proc(int inst) +{ + RU_t *ru = RC.ru[inst]; + RU_proc_t *proc = &ru->proc; + pthread_mutex_lock(&proc->mutex_FH); + proc->instance_cnt_FH = 0; + pthread_mutex_unlock(&proc->mutex_FH); + pthread_cond_signal(&proc->cond_FH); + pthread_mutex_lock(&proc->mutex_prach); + proc->instance_cnt_prach = 0; + pthread_mutex_unlock(&proc->mutex_prach); + pthread_cond_signal(&proc->cond_prach); +#ifdef Rel14 + pthread_mutex_lock(&proc->mutex_prach_br); + proc->instance_cnt_prach_br = 0; + pthread_mutex_unlock(&proc->mutex_prach_br); + pthread_cond_signal(&proc->cond_prach_br); +#endif + + pthread_mutex_lock(&proc->mutex_synch); + proc->instance_cnt_synch = 0; + pthread_mutex_unlock(&proc->mutex_synch); + pthread_cond_signal(&proc->cond_synch); + + pthread_mutex_lock(&proc->mutex_eNBs); + proc->instance_cnt_eNBs = 0; + pthread_mutex_unlock(&proc->mutex_eNBs); + pthread_cond_signal(&proc->cond_eNBs); + + pthread_mutex_lock(&proc->mutex_asynch_rxtx); + proc->instance_cnt_asynch_rxtx = 0; + pthread_mutex_unlock(&proc->mutex_asynch_rxtx); + pthread_cond_signal(&proc->cond_asynch_rxtx); + + LOG_D(PHY, "Joining pthread_FH\n"); + pthread_join(proc->pthread_FH, NULL); + if (ru->function == NGFI_RRU_IF4p5) { + LOG_D(PHY, "Joining pthread_prach\n"); + pthread_join(proc->pthread_prach, NULL); +#ifdef Rel14 + LOG_D(PHY, "Joining pthread_prach_br\n"); + pthread_join(proc->pthread_prach_br, NULL); +#endif + if (ru->is_slave) { + LOG_D(PHY, "Joining pthread_\n"); + pthread_join(proc->pthread_synch, NULL); + } + + if ((ru->if_timing == synch_to_other) || + (ru->function == NGFI_RRU_IF5) || + (ru->function == NGFI_RRU_IF4p5)) { + LOG_D(PHY, "Joining pthread_asynch_rxtx\n"); + pthread_join(proc->pthread_asynch_rxtx, NULL); + } + } + if (get_nprocs() >= 2) { + if (ru->feprx) { + pthread_mutex_lock(&proc->mutex_fep); + proc->instance_cnt_fep = 0; + pthread_mutex_unlock(&proc->mutex_fep); + pthread_cond_signal(&proc->cond_fep); + LOG_D(PHY, "Joining pthread_fep\n"); + pthread_join(proc->pthread_fep, NULL); + pthread_mutex_destroy(&proc->mutex_fep); + pthread_cond_destroy(&proc->cond_fep); + } + if (ru->feptx_ofdm) { + pthread_mutex_lock(&proc->mutex_feptx); + proc->instance_cnt_feptx = 0; + pthread_mutex_unlock(&proc->mutex_feptx); + pthread_cond_signal(&proc->cond_feptx); + LOG_D(PHY, "Joining pthread_feptx\n"); + pthread_join(proc->pthread_feptx, NULL); + pthread_mutex_destroy(&proc->mutex_feptx); + pthread_cond_destroy(&proc->cond_feptx); + } + } + if (opp_enabled) { + LOG_D(PHY, "Joining ru_stats_thread\n"); + pthread_join(ru->ru_stats_thread, NULL); + } + + pthread_mutex_destroy(&proc->mutex_prach); + pthread_mutex_destroy(&proc->mutex_asynch_rxtx); + pthread_mutex_destroy(&proc->mutex_synch); + pthread_mutex_destroy(&proc->mutex_FH); + pthread_mutex_destroy(&proc->mutex_eNBs); + + pthread_cond_destroy(&proc->cond_prach); + pthread_cond_destroy(&proc->cond_FH); + pthread_cond_destroy(&proc->cond_asynch_rxtx); + pthread_cond_destroy(&proc->cond_synch); + pthread_cond_destroy(&proc->cond_eNBs); + + pthread_attr_destroy(&proc->attr_FH); + pthread_attr_destroy(&proc->attr_prach); + pthread_attr_destroy(&proc->attr_synch); + pthread_attr_destroy(&proc->attr_asynch_rxtx); + pthread_attr_destroy(&proc->attr_fep); + +#ifdef Rel14 + pthread_mutex_destroy(&proc->mutex_prach_br); + pthread_cond_destroy(&proc->cond_prach_br); + pthread_attr_destroy(&proc->attr_prach_br); +#endif +} int check_capabilities(RU_t *ru,RRU_capabilities_t *cap) { @@ -2062,9 +2168,10 @@ void init_RU(char *rf_config_file) { -void stop_ru(RU_t *ru) { - - printf("Stopping RU %p processing threads\n",(void*)ru); - +void stop_RU(int nb_ru) +{ + for (int inst = 0; inst < nb_ru; inst++) { + LOG_I(PHY, "Stopping RU %d processing threads\n", inst); + kill_RU_proc(inst); + } } - diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 44512843d7..181150c672 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1501,7 +1501,8 @@ int main( int argc, char **argv ) // cleanup if (UE_flag == 1) { } else { - stop_eNB(1); + stop_eNB(NB_eNB_INST); + stop_RU(NB_RU); } From 8e9d9807aee187dd649d7704242115d3929b62a3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Jan 2018 11:01:35 +0100 Subject: [PATCH 086/141] lte-ru.c: fct for interface -dependant config, export more functions - add set_function_spec_param() which configures RU_t instance depending on its function(al split) - export more functions like kill_RU_proc() so that they can be reused by restart functionality --- targets/RT/USER/lte-ru.c | 292 ++++++++++++++++---------------- targets/RT/USER/lte-softmodem.h | 4 + 2 files changed, 152 insertions(+), 144 deletions(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 3ff4c4e7ac..e2918091e9 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1959,13 +1959,159 @@ void init_precoding_weights(PHY_VARS_eNB *eNB) { } } +void set_function_spec_param(RU_t *ru) +{ + int ret; + + switch (ru->if_south) { + case LOCAL_RF: // this is an RU with integrated RF (RRU, eNB) + if (ru->function == NGFI_RRU_IF5) { // IF5 RRU + ru->do_prach = 0; // no prach processing in RU + ru->fh_north_in = NULL; // no shynchronous incoming fronthaul from north + ru->fh_north_out = fh_if5_north_out; // need only to do send_IF5 reception + ru->fh_south_out = tx_rf; // send output to RF + ru->fh_north_asynch_in = fh_if5_north_asynch_in; // TX packets come asynchronously + ru->feprx = NULL; // nothing (this is a time-domain signal) + ru->feptx_ofdm = NULL; // nothing (this is a time-domain signal) + ru->feptx_prec = NULL; // nothing (this is a time-domain signal) + ru->start_if = start_if; // need to start the if interface for if5 + ru->ifdevice.host_type = RRU_HOST; + ru->rfdevice.host_type = RRU_HOST; + ru->ifdevice.eth_params = &ru->eth_params; + reset_meas(&ru->rx_fhaul); + reset_meas(&ru->tx_fhaul); + reset_meas(&ru->compression); + reset_meas(&ru->transport); + + ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); + printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + } + else if (ru->function == NGFI_RRU_IF4p5) { + ru->do_prach = 1; // do part of prach processing in RU + ru->fh_north_in = NULL; // no synchronous incoming fronthaul from north + ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception + ru->fh_south_out = tx_rf; // send output to RF + ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously + ru->feprx = (get_nprocs()<=2) ? fep_full :ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) + ru->feptx_prec = NULL; + ru->start_if = start_if; // need to start the if interface for if4p5 + ru->ifdevice.host_type = RRU_HOST; + ru->rfdevice.host_type = RRU_HOST; + ru->ifdevice.eth_params = &ru->eth_params; + reset_meas(&ru->rx_fhaul); + reset_meas(&ru->tx_fhaul); + reset_meas(&ru->compression); + reset_meas(&ru->transport); + + ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); + printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + malloc_IF4p5_buffer(ru); + } + else if (ru->function == eNodeB_3GPP) { + ru->do_prach = 0; // no prach processing in RU + ru->feprx = (get_nprocs()<=2) ? fep_full : ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding + ru->feptx_prec = feptx_prec; // this is fep with idft and precoding + ru->fh_north_in = NULL; // no incoming fronthaul from north + ru->fh_north_out = NULL; // no outgoing fronthaul to north + ru->start_if = NULL; // no if interface + ru->rfdevice.host_type = RAU_HOST; + } + ru->fh_south_in = rx_rf; // local synchronous RF RX + ru->fh_south_out = tx_rf; // local synchronous RF TX + ru->start_rf = start_rf; // need to start the local RF interface + printf("configuring ru_id %d (start_rf %p)\n", ru->idx, start_rf); +/* + if (ru->function == eNodeB_3GPP) { // configure RF parameters only for 3GPP eNodeB, we need to get them from RAU otherwise + fill_rf_config(ru,rf_config_file); + init_frame_parms(&ru->frame_parms,1); + phy_init_RU(ru); + } + + ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + }*/ + break; + + case REMOTE_IF5: // the remote unit is IF5 RRU + ru->do_prach = 0; + ru->feprx = (get_nprocs()<=2) ? fep_full : fep_full; // this is frequency-shift + DFTs + ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs + ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs + if (ru->if_timing == synch_to_other) { + ru->fh_south_in = fh_slave_south_in; // synchronize to master + ru->fh_south_out = fh_if5_mobipass_south_out; // use send_IF5 for mobipass + ru->fh_south_asynch_in = fh_if5_south_asynch_in_mobipass; // UL is asynchronous + } + else { + ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception + ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission + ru->fh_south_asynch_in = NULL; // no asynchronous UL + } + ru->start_rf = NULL; // no local RF + ru->start_if = start_if; // need to start if interface for IF5 + ru->ifdevice.host_type = RAU_HOST; + ru->ifdevice.eth_params = &ru->eth_params; + ru->ifdevice.configure_rru = configure_ru; + + ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); + printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + break; + + case REMOTE_IF4p5: + ru->do_prach = 0; + ru->feprx = NULL; // DFTs + ru->feptx_prec = feptx_prec; // Precoding operation + ru->feptx_ofdm = NULL; // no OFDM mod + ru->fh_south_in = fh_if4p5_south_in; // synchronous IF4p5 reception + ru->fh_south_out = fh_if4p5_south_out; // synchronous IF4p5 transmission + ru->fh_south_asynch_in = (ru->if_timing == synch_to_other) ? fh_if4p5_south_in : NULL; // asynchronous UL if synch_to_other + ru->fh_north_out = NULL; + ru->fh_north_asynch_in = NULL; + ru->start_rf = NULL; // no local RF + ru->start_if = start_if; // need to start if interface for IF4p5 + ru->ifdevice.host_type = RAU_HOST; + ru->ifdevice.eth_params = &ru->eth_params; + ru->ifdevice.configure_rru = configure_ru; + + ret = openair0_transport_load(&ru->ifdevice, &ru->openair0_cfg, &ru->eth_params); + printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + + malloc_IF4p5_buffer(ru); + + break; + + default: + LOG_E(PHY,"RU with invalid or unknown southbound interface type %d\n",ru->if_south); + break; + } // switch on interface type +} + extern void RCconfig_RU(void); void init_RU(char *rf_config_file) { int ru_id; RU_t *ru; - int ret; PHY_VARS_eNB *eNB0; int i; int CC_id; @@ -2008,149 +2154,7 @@ void init_RU(char *rf_config_file) { } // LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); - - switch (ru->if_south) { - case LOCAL_RF: // this is an RU with integrated RF (RRU, eNB) - if (ru->function == NGFI_RRU_IF5) { // IF5 RRU - ru->do_prach = 0; // no prach processing in RU - ru->fh_north_in = NULL; // no shynchronous incoming fronthaul from north - ru->fh_north_out = fh_if5_north_out; // need only to do send_IF5 reception - ru->fh_south_out = tx_rf; // send output to RF - ru->fh_north_asynch_in = fh_if5_north_asynch_in; // TX packets come asynchronously - ru->feprx = NULL; // nothing (this is a time-domain signal) - ru->feptx_ofdm = NULL; // nothing (this is a time-domain signal) - ru->feptx_prec = NULL; // nothing (this is a time-domain signal) - ru->start_if = start_if; // need to start the if interface for if5 - ru->ifdevice.host_type = RRU_HOST; - ru->rfdevice.host_type = RRU_HOST; - ru->ifdevice.eth_params = &ru->eth_params; - reset_meas(&ru->rx_fhaul); - reset_meas(&ru->tx_fhaul); - reset_meas(&ru->compression); - reset_meas(&ru->transport); - - ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); - printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - } - else if (ru->function == NGFI_RRU_IF4p5) { - ru->do_prach = 1; // do part of prach processing in RU - ru->fh_north_in = NULL; // no synchronous incoming fronthaul from north - ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception - ru->fh_south_out = tx_rf; // send output to RF - ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously - ru->feprx = (get_nprocs()<=2) ? fep_full :ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) - ru->feptx_prec = NULL; - ru->start_if = start_if; // need to start the if interface for if4p5 - ru->ifdevice.host_type = RRU_HOST; - ru->rfdevice.host_type = RRU_HOST; - ru->ifdevice.eth_params = &ru->eth_params; - reset_meas(&ru->rx_fhaul); - reset_meas(&ru->tx_fhaul); - reset_meas(&ru->compression); - reset_meas(&ru->transport); - - ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); - printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - malloc_IF4p5_buffer(ru); - } - else if (ru->function == eNodeB_3GPP) { - ru->do_prach = 0; // no prach processing in RU - ru->feprx = (get_nprocs()<=2) ? fep_full : ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding - ru->feptx_prec = feptx_prec; // this is fep with idft and precoding - ru->fh_north_in = NULL; // no incoming fronthaul from north - ru->fh_north_out = NULL; // no outgoing fronthaul to north - ru->start_if = NULL; // no if interface - ru->rfdevice.host_type = RAU_HOST; - } - ru->fh_south_in = rx_rf; // local synchronous RF RX - ru->fh_south_out = tx_rf; // local synchronous RF TX - ru->start_rf = start_rf; // need to start the local RF interface - printf("configuring ru_id %d (start_rf %p)\n",ru_id,start_rf); -/* - if (ru->function == eNodeB_3GPP) { // configure RF parameters only for 3GPP eNodeB, we need to get them from RAU otherwise - fill_rf_config(ru,rf_config_file); - init_frame_parms(&ru->frame_parms,1); - phy_init_RU(ru); - } - - ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); - if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); - }*/ - break; - - case REMOTE_IF5: // the remote unit is IF5 RRU - ru->do_prach = 0; - ru->feprx = (get_nprocs()<=2) ? fep_full : fep_full; // this is frequency-shift + DFTs - ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs - if (ru->if_timing == synch_to_other) { - ru->fh_south_in = fh_slave_south_in; // synchronize to master - ru->fh_south_out = fh_if5_mobipass_south_out; // use send_IF5 for mobipass - ru->fh_south_asynch_in = fh_if5_south_asynch_in_mobipass; // UL is asynchronous - } - else { - ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception - ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission - ru->fh_south_asynch_in = NULL; // no asynchronous UL - } - ru->start_rf = NULL; // no local RF - ru->start_if = start_if; // need to start if interface for IF5 - ru->ifdevice.host_type = RAU_HOST; - ru->ifdevice.eth_params = &ru->eth_params; - ru->ifdevice.configure_rru = configure_ru; - - ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); - printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - break; - - case REMOTE_IF4p5: - ru->do_prach = 0; - ru->feprx = NULL; // DFTs - ru->feptx_prec = feptx_prec; // Precoding operation - ru->feptx_ofdm = NULL; // no OFDM mod - ru->fh_south_in = fh_if4p5_south_in; // synchronous IF4p5 reception - ru->fh_south_out = fh_if4p5_south_out; // synchronous IF4p5 transmission - ru->fh_south_asynch_in = (ru->if_timing == synch_to_other) ? fh_if4p5_south_in : NULL; // asynchronous UL if synch_to_other - ru->fh_north_out = NULL; - ru->fh_north_asynch_in = NULL; - ru->start_rf = NULL; // no local RF - ru->start_if = start_if; // need to start if interface for IF4p5 - ru->ifdevice.host_type = RAU_HOST; - ru->ifdevice.eth_params = &ru->eth_params; - ru->ifdevice.configure_rru = configure_ru; - - ret = openair0_transport_load(&ru->ifdevice, &ru->openair0_cfg, &ru->eth_params); - printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - - malloc_IF4p5_buffer(ru); - - break; - - default: - LOG_E(PHY,"RU with invalid or unknown southbound interface type %d\n",ru->if_south); - break; - } // switch on interface type - + set_function_spec_param(ru); LOG_I(PHY,"Starting ru_thread %d\n",ru_id); init_RU_proc(ru); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 13e5ba6b91..c1d63eef4c 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -244,6 +244,10 @@ extern void kill_eNB_proc(int inst); // In lte-ru.c extern void init_RU(const char*); +extern void init_RU_proc(RU_t *ru); +extern void stop_RU(int nb_ru); +extern void kill_RU_proc(int inst); +extern void set_function_spec_param(RU_t *ru); // In lte-ue.c extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); From 811ada242989071dac9fb83796cdaf44b949243c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Jan 2018 12:01:24 +0100 Subject: [PATCH 087/141] soft-restart (i.e. only layers PHY-RRC) the lte-softmodem --- .../ENB_APP/flexran_agent_common_internal.c | 65 +++++------ targets/RT/USER/lte-softmodem.c | 110 +++++++++--------- targets/RT/USER/lte-softmodem.h | 4 +- 3 files changed, 83 insertions(+), 96 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index e3fac4594b..416f13f241 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -32,45 +32,37 @@ #include "flexran_agent_common_internal.h" #include "flexran_agent_mac_internal.h" -/* the following is needed to soft-restart the lte-softmodem */ +/* needed to soft-restart the lte-softmodem */ #include "targets/RT/USER/lte-softmodem.h" -#include "assertions.h" -#include "enb_app.h" -#if 0 void handle_reconfiguration(mid_t mod_id) { - /* NOTE: this function might be extended by using stop_modem() - * to halt the modem so that it can later be resumed */ - int do_restart = 0; + struct timespec start, end; + clock_gettime(CLOCK_MONOTONIC, &start); - pthread_mutex_lock(&mutex_node_ctrl); - if (ENB_NORMAL_OPERATION != node_control_state) { - node_control_state = ENB_NORMAL_OPERATION; - pthread_cond_broadcast(&cond_node_ctrl); + if (stop_L1L2(mod_id) < 0) { + LOG_E(ENB_APP, "can not stop lte-softmodem, aborting restart\n"); + return; + } + + /* TODO wait state could be here IF IT IS NOT EXECUTED BY THE FLEXRAN THREAD */ + + if (restart_L1L2(mod_id) < 0) { + LOG_F(ENB_APP, "can not restart, killing lte-softmodem\n"); + itti_terminate_tasks(TASK_PHY_ENB); + return; + } + + clock_gettime(CLOCK_MONOTONIC, &end); + end.tv_sec -= start.tv_sec; + if (end.tv_nsec >= start.tv_nsec) { + end.tv_nsec -= start.tv_nsec; } else { - do_restart = 1; - } - pthread_mutex_unlock(&mutex_node_ctrl); - - if (do_restart) { - clock_t start_ms = 1000 * clock(); - /* operator || enforces sequence points */ - if (stop_L1L2(mod_id) < 0 || restart_L1L2(mod_id) < 0) { - LOG_E(ENB_APP, "could not restart, killing lte-softmodem\n"); - /* shutdown the whole lte-softmodem */ - itti_terminate_tasks(TASK_PHY_ENB); - return; - } - enb_app_start_phy_rrc(mod_id, mod_id+1); - MessageDef *msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE); - itti_send_msg_to_task(TASK_L2L1, INSTANCE_DEFAULT, msg_p); - - int diff_ms = (1000 * clock() - start_ms) / CLOCKS_PER_SEC; - LOG_I(ENB_APP, "lte-softmodem restart succeeded in %d ms\n", diff_ms); + end.tv_sec -= 1; + end.tv_nsec = end.tv_nsec - start.tv_nsec + 1000000000; } + LOG_I(ENB_APP, "lte-softmodem restart succeeded in %ld.%ld s\n", end.tv_sec, end.tv_nsec / 1000000); } -#endif int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy_length) { @@ -111,8 +103,7 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy if (parse_enb_id(mod_id, &parser) == -1) { goto error; } else { // succeful parse and setting - /* TODO implement */ - //handle_reconfiguration(mod_id); + handle_reconfiguration(mod_id); } } else if (strcmp((char *) event.data.scalar.value, "mac") == 0) { LOG_D(ENB_APP, "This is intended for the mac system\n"); @@ -265,9 +256,9 @@ int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) { } else if (strcmp((char *) event.data.scalar.value, "ul_freq_offset") == 0) { if (!yaml_parser_parse(parser, &event)) goto error; - flexran_agent_set_operating_ul_freq(mod_id, - 0, - strtol((char *) event.data.scalar.value, &endptr, 10)); + flexran_agent_set_operating_ul_freq(mod_id, + 0, + strtol((char *) event.data.scalar.value, &endptr, 10)); LOG_I(ENB_APP, "Setting ul_freq_offset to %s\n", event.data.scalar.value); } else if (strcmp((char *) event.data.scalar.value, "bandwidth") == 0) { if (!yaml_parser_parse(parser, &event)) @@ -296,8 +287,6 @@ int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) { yaml_event_delete(&event); } - /* TODO: reflect in RAN API */ - return 0; error: diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 181150c672..c8db435d46 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -872,11 +872,11 @@ void wait_eNBs(void) { printf("eNB L1 are configured\n"); } -#if defined(ENABLE_ITTI) && defined(FLEXRAN_AGENT_SB_IF) +#if defined(ENABLE_ITTI) /* * helper function to terminate a certain ITTI task */ -void terminate_task(task_id_t task_id, mid_t mod_id) +void terminate_task(task_id_t task_id, module_id_t mod_id) { LOG_I(ENB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id); MessageDef *msg; @@ -884,70 +884,71 @@ void terminate_task(task_id_t task_id, mid_t mod_id) itti_send_msg_to_task (task_id, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg); } -#if 0 -int stop_L1L2(int enb_id) +int stop_L1L2(module_id_t enb_id) { - int CC_id; - LOG_W(ENB_APP, "stopping lte-softmodem\n"); oai_exit = 1; - /* stop trx devices */ - for(CC_id=0; CC_idrfdevice.trx_stop_func) { - LOG_I(ENB_APP, "stopping PHY_vars_eNB_g[0][%d]->rfdevice (via trx_stop_func())\n", CC_id); - PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_stop_func(&PHY_vars_eNB_g[0][CC_id]->rfdevice); + if (!RC.ru) { + LOG_F(ENB_APP, "no RU configured\n"); + return -1; + } + + /* stop trx devices, multiple carrier currently not supported by RU */ + if (RC.ru[enb_id]) { + if (RC.ru[enb_id]->rfdevice.trx_stop_func) { + RC.ru[enb_id]->rfdevice.trx_stop_func(&RC.ru[enb_id]->rfdevice); + LOG_I(ENB_APP, "turned off RU rfdevice\n"); + } else { + LOG_W(ENB_APP, "can not turn off rfdevice due to missing trx_stop_func callback, proceding anyway!\n"); } - if (PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_stop_func) { - LOG_I(ENB_APP, "stopping PHY_vars_eNB_g[0][%d]->ifdevice (via trx_stop_func())\n", CC_id); - PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_stop_func(&PHY_vars_eNB_g[0][CC_id]->ifdevice); + if (RC.ru[enb_id]->ifdevice.trx_stop_func) { + RC.ru[enb_id]->ifdevice.trx_stop_func(&RC.ru[enb_id]->ifdevice); + LOG_I(ENB_APP, "turned off RU ifdevice\n"); + } else { + LOG_W(ENB_APP, "can not turn off ifdevice due to missing trx_stop_func callback, proceding anyway!\n"); } + } else { + LOG_W(ENB_APP, "no RU found for index %d\n", enb_id); + return -1; } /* these tasks need to pick up new configuration */ terminate_task(TASK_RRC_ENB, enb_id); terminate_task(TASK_L2L1, enb_id); - LOG_W(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id); + LOG_I(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id); kill_eNB_proc(enb_id); + LOG_I(ENB_APP, "calling kill_RU_proc() for instance %d\n", enb_id); + kill_RU_proc(enb_id); oai_exit = 0; return 0; } /* - * Restart the lte-softmodem. - * This function checks whether we are in ENB_NORMAL_OPERATION (defined by - * FlexRAN). If yes, first stop L1/L2/L3, then resume. + * Restart the lte-softmodem after it has been soft-stopped with stop_L1L2() */ -int restart_L1L2(int enb_id) +int restart_L1L2(module_id_t enb_id) { - int i, aa, CC_id; - /* needed for fill_PHY_vars_eNB_g(), defined locally in main(); - * abstraction flag is needed too, but defined both globally and in main () */ - uint8_t beta_ACK = 0, beta_RI = 0, beta_CQI = 2; - /* needed for macphy_init() */ - int eMBMS_active = 0; + RU_t *ru = RC.ru[enb_id]; + int cc_id; + MessageDef *msg_p = NULL; LOG_W(ENB_APP, "restarting lte-softmodem\n"); /* block threads */ sync_var = -1; - reconfigure_enb_params(enb_id); /* set frame parameters from configuration */ - - /* PHY_vars_eNB_g will be filled by init_lte_eNB(), so free and - * let the data structure be filled again */ - for (CC_id=0; CC_idconfigured = 0; } - dump_frame_parms(frame_parms[0]); - init_openair0(); - /* give MAC interface current cell information, the rest is the same. - * For more info, check l2_init(). Then, initialize it (cf. line 1904). */ - mac_xface->frame_parms = frame_parms[0]; - mac_xface->macphy_init(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,0,0); + /* TODO undo malloc_IF4p5_buffer() */ + RC.ru_mask |= (1 << ru->idx); + /* copy the changed frame parameters to the RU */ + /* TODO this should be done for all RUs associated to this eNB */ + memcpy(&ru->frame_parms, &RC.eNB[enb_id][0]->frame_parms, sizeof(LTE_DL_FRAME_PARMS)); + set_function_spec_param(RC.ru[enb_id]); LOG_I(ENB_APP, "attempting to create ITTI tasks\n"); if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) { @@ -963,28 +964,26 @@ int restart_L1L2(int enb_id) LOG_I(PDCP, "Re-created task for L2L1 successfully\n"); } + /* pass a reconfiguration request which will configure everything down to + * RC.eNB[i][j]->frame_parms, too */ + msg_p = itti_alloc_new_message(TASK_ENB_APP, RRC_CONFIGURATION_REQ); + RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration; + itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); + /* TODO XForms here */ - printf("Initializing eNB threads\n"); - init_eNB(node_function, node_timing, 1, eth_params, single_thread_flag, wait_for_sync); - for(CC_id=0; CC_idrf_map.card=0; - PHY_vars_eNB_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; - } + /* TODO check for memory leaks */ + /* TODO wait_eNBs() would wait for phy_config_request()? */ + //init_eNB(single_thread_flag,wait_for_sync); + wait_eNBs(); + init_RU_proc(ru); + ru->rf_map.card = 0; + ru->rf_map.chain = 0; /* CC_id + chain_offset;*/ + wait_RUs(); + init_eNB_afterRU(); - mlockall(MCL_CURRENT | MCL_FUTURE); - - printf("Setting eNB buffer to all-RX\n"); - // Set LSBs for antenna switch (ExpressMIMO) - for (CC_id=0; CC_idhw_timing_advance = 0; - for (i=0; isamples_per_tti*10; i++) - for (aa=0; aanb_antennas_tx; aa++) - PHY_vars_eNB_g[0][CC_id]->common_vars.txdata[0][aa][i] = 0x00010001; - } printf("Sending sync to all threads\n"); - pthread_mutex_lock(&sync_mutex); sync_var=0; pthread_cond_broadcast(&sync_cond); @@ -993,7 +992,6 @@ int restart_L1L2(int enb_id) return 0; } #endif -#endif int main( int argc, char **argv ) { diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index c1d63eef4c..c6f8d8d54c 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -268,8 +268,8 @@ PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t abstraction_flag); void init_eNB_afterRU(void); -extern int stop_L1L2(int enb_id); -extern int restart_L1L2(int enb_id); +extern int stop_L1L2(module_id_t enb_id); +extern int restart_L1L2(module_id_t enb_id); #ifdef FLEXRAN_AGENT_SB_IF #include "flexran_agent.h" // for locking From 3f043c7d73b62e4147267a32fb5927776753f55f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Jan 2018 15:20:15 +0100 Subject: [PATCH 088/141] FlexRAN: implement possibilty to await a configuration Through configuration, the lte-softmodem can be halted to await a reconfiguration from the lte-softmodem. A mutex and condition variable are used to implement this. Furthermore, the dependance of lte-softmodem.c on FlexRAN has been reduced to one include and the flexran_agent_start() call. --- openair2/ENB_APP/enb_config.c | 2 +- openair2/ENB_APP/flexran_agent.c | 45 ++++++++++++++----- openair2/ENB_APP/flexran_agent.h | 6 +-- .../ENB_APP/flexran_agent_common_internal.c | 21 ++++++++- openair2/ENB_APP/flexran_agent_defs.h | 12 ++++- targets/RT/USER/lte-softmodem.c | 33 +++----------- targets/RT/USER/lte-softmodem.h | 5 +-- 7 files changed, 74 insertions(+), 50 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index d2a35c3bd7..2056bfaa27 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -267,7 +267,7 @@ void RCconfig_flexran() RC.flexran[i]->remote_port = *(flexranParams[FLEXRAN_PORT_IDX].uptr); // DEFAULT_FLEXRAN_AGENT_CACHE RC.flexran[i]->cache_name = strdup(*(flexranParams[FLEXRAN_CACHE_IDX].strptr)); - RC.flexran[i]->await_reconf = strcmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0; + RC.flexran[i]->node_ctrl_state = strcmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0 ? ENB_WAIT : ENB_NORMAL_OPERATION; RC.flexran[i]->enb_id = i; } diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index 60239cbbbd..d32f3e660f 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -180,16 +180,17 @@ pthread_t new_thread(void *(*f)(void *), void *b) { int channel_container_init = 0; int flexran_agent_start(mid_t mod_id) { + flexran_agent_info_t *flexran = RC.flexran[mod_id]; int channel_id; - char *in_ip = RC.flexran[mod_id]->remote_ipv4_addr; - uint16_t in_port = RC.flexran[mod_id]->remote_port; + char *in_ip = flexran->remote_ipv4_addr; + uint16_t in_port = flexran->remote_port; - RC.flexran[mod_id]->enb_id = mod_id; + flexran->enb_id = mod_id; /* assume for the moment the monolithic case, i.e. agent can provide * information for all layers */ - RC.flexran[mod_id]->capability_mask = FLEXRAN_CAP_LOL1 | FLEXRAN_CAP_HIL1 - | FLEXRAN_CAP_LOL2 | FLEXRAN_CAP_HIL2 - | FLEXRAN_CAP_PDCP | FLEXRAN_CAP_RRC; + flexran->capability_mask = FLEXRAN_CAP_LOL1 | FLEXRAN_CAP_HIL1 + | FLEXRAN_CAP_LOL2 | FLEXRAN_CAP_HIL2 + | FLEXRAN_CAP_PDCP | FLEXRAN_CAP_RRC; /* * Initialize the channel container @@ -228,7 +229,7 @@ int flexran_agent_start(mid_t mod_id) /*Initialize the continuous stats update mechanism*/ flexran_agent_init_cont_stats_update(mod_id); - new_thread(receive_thread, RC.flexran[mod_id]); + new_thread(receive_thread, flexran); /*Initialize and register the mac xface. Must be modified later *for more flexibility in agent management */ @@ -239,8 +240,8 @@ int flexran_agent_start(mid_t mod_id) AGENT_RRC_xface *rrc_agent_xface = (AGENT_RRC_xface *) malloc(sizeof(AGENT_RRC_xface)); flexran_agent_register_rrc_xface(mod_id, rrc_agent_xface); - AGENT_PDCP_xface *pdcp_agent_xface = (AGENT_PDCP_xface *) malloc(sizeof(AGENT_PDCP_xface)); - flexran_agent_register_pdcp_xface(mod_id, pdcp_agent_xface); + AGENT_PDCP_xface *pdcp_agent_xface = (AGENT_PDCP_xface *) malloc(sizeof(AGENT_PDCP_xface)); + flexran_agent_register_pdcp_xface(mod_id, pdcp_agent_xface); /* * initilize a timer @@ -257,14 +258,34 @@ int flexran_agent_start(mid_t mod_id) * start the enb agent task for tx and interaction with the underlying network function */ if (!agent_task_created) { - if (itti_create_task (TASK_FLEXRAN_AGENT, flexran_agent_task, (void *) RC.flexran[mod_id]) < 0) { + if (itti_create_task (TASK_FLEXRAN_AGENT, flexran_agent_task, flexran) < 0) { LOG_E(FLEXRAN_AGENT, "Create task for FlexRAN Agent failed\n"); return -1; } agent_task_created = 1; } - - LOG_I(FLEXRAN_AGENT,"client ends\n"); + + pthread_mutex_init(&flexran->mutex_node_ctrl, NULL); + pthread_cond_init(&flexran->cond_node_ctrl, NULL); + + if (flexran->node_ctrl_state == ENB_WAIT) { + /* wait three seconds before showing message and waiting "for real". + * This way, the message is (hopefully...) the last one and the user knows + * what is happening. If the controller sends a reconfiguration message in + * the meantime, the softmodem will never wait */ + sleep(3); + LOG_I(ENB_APP, " * eNB %d: Waiting for FlexRAN RTController command *\n", mod_id); + pthread_mutex_lock(&flexran->mutex_node_ctrl); + while (ENB_NORMAL_OPERATION != flexran->node_ctrl_state) + pthread_cond_wait(&flexran->cond_node_ctrl, &flexran->mutex_node_ctrl); + pthread_mutex_unlock(&flexran->mutex_node_ctrl); + + /* reconfigure RRC again, the agent might have changed the configuration */ + MessageDef *msg_p = itti_alloc_new_message(TASK_ENB_APP, RRC_CONFIGURATION_REQ); + RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[mod_id]->configuration; + itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg_p); + } + return 0; error: diff --git a/openair2/ENB_APP/flexran_agent.h b/openair2/ENB_APP/flexran_agent.h index ed9ee444c3..aed8f9eb60 100644 --- a/openair2/ENB_APP/flexran_agent.h +++ b/openair2/ENB_APP/flexran_agent.h @@ -42,12 +42,8 @@ #include "log.h" #include "assertions.h" -#include "enb_config.h" // for enb properties - - -/* Initiation and termination of the eNodeB agent */ +/* Initiation of the eNodeB agent */ int flexran_agent_start(mid_t mod_id); -int flexran_agent_stop(mid_t mod_id); /* * enb agent task mainly wakes up the tx thread for periodic and oneshot messages to the controller diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index 416f13f241..0e65fe7236 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -39,13 +39,32 @@ void handle_reconfiguration(mid_t mod_id) { struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); + flexran_agent_info_t *flexran = RC.flexran[mod_id]; + + if (ENB_WAIT == flexran->node_ctrl_state) { + /* this is already waiting, just release */ + pthread_mutex_lock(&flexran->mutex_node_ctrl); + flexran->node_ctrl_state = ENB_NORMAL_OPERATION; + pthread_mutex_unlock(&flexran->mutex_node_ctrl); + pthread_cond_signal(&flexran->cond_node_ctrl); + return; + } if (stop_L1L2(mod_id) < 0) { LOG_E(ENB_APP, "can not stop lte-softmodem, aborting restart\n"); return; } - /* TODO wait state could be here IF IT IS NOT EXECUTED BY THE FLEXRAN THREAD */ + /* node_ctrl_state should have value ENB_MAKE_WAIT only if this method is not + * executed by the FlexRAN thread */ + if (ENB_MAKE_WAIT == flexran->node_ctrl_state) { + LOG_I(ENB_APP, " * eNB %d: Waiting for FlexRAN RTController command *\n", mod_id); + pthread_mutex_lock(&flexran->mutex_node_ctrl); + flexran->node_ctrl_state = ENB_WAIT; + while (ENB_NORMAL_OPERATION != flexran->node_ctrl_state) + pthread_cond_wait(&flexran->cond_node_ctrl, &flexran->mutex_node_ctrl); + pthread_mutex_unlock(&flexran->mutex_node_ctrl); + } if (restart_L1L2(mod_id) < 0) { LOG_F(ENB_APP, "can not restart, killing lte-softmodem\n"); diff --git a/openair2/ENB_APP/flexran_agent_defs.h b/openair2/ENB_APP/flexran_agent_defs.h index dc86a422c4..fd22b01e61 100644 --- a/openair2/ENB_APP/flexran_agent_defs.h +++ b/openair2/ENB_APP/flexran_agent_defs.h @@ -145,17 +145,27 @@ typedef enum { #define FLEXRAN_CAP_PDCP 0x16 #define FLEXRAN_CAP_RRC 0x32 +typedef enum { + ENB_NORMAL_OPERATION = 0x0, + ENB_WAIT = 0x1, + ENB_MAKE_WAIT = 0x2, +} flexran_enb_state_t; + typedef struct { /* general info */ char *interface_name; char *remote_ipv4_addr; uint16_t remote_port; char *cache_name; - uint8_t await_reconf; int enb_id; uint8_t capability_mask; + /* lock for waiting before starting or soft-restart */ + pthread_cond_t cond_node_ctrl; + pthread_mutex_t mutex_node_ctrl; + flexran_enb_state_t node_ctrl_state; + /* stats */ uint32_t total_rx_msg; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index c8db435d46..91d626c9d3 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1149,26 +1149,6 @@ int main( int argc, char **argv ) for (CC_id=0; CC_idrfdevice.trx_end_func) diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index c6f8d8d54c..dd178c2911 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -272,10 +272,7 @@ extern int stop_L1L2(module_id_t enb_id); extern int restart_L1L2(module_id_t enb_id); #ifdef FLEXRAN_AGENT_SB_IF -#include "flexran_agent.h" // for locking -//volatile ENB_MODULE_STATE node_control_state; -pthread_cond_t cond_node_ctrl; -pthread_mutex_t mutex_node_ctrl; +#include "flexran_agent.h" #endif #endif From d5b8310fb9b49990a5049eb1f75e274bb2ec4759 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Jan 2018 17:13:54 +0100 Subject: [PATCH 089/141] add some logging for RRM command parsing --- openair2/ENB_APP/flexran_agent_common_internal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair2/ENB_APP/flexran_agent_common_internal.c b/openair2/ENB_APP/flexran_agent_common_internal.c index 0e65fe7236..8874a0f648 100644 --- a/openair2/ENB_APP/flexran_agent_common_internal.c +++ b/openair2/ENB_APP/flexran_agent_common_internal.c @@ -120,6 +120,7 @@ int apply_reconfiguration_policy(mid_t mod_id, const char *policy, size_t policy LOG_I(ENB_APP, "This is intended for the enb system\n"); // Call the enb handler if (parse_enb_id(mod_id, &parser) == -1) { + LOG_E(ENB_APP, "cannot parse data for eNB\n"); goto error; } else { // succeful parse and setting handle_reconfiguration(mod_id); @@ -294,6 +295,7 @@ int parse_enb_config_parameters(mid_t mod_id, yaml_parser_t *parser) { strtol((char *) event.data.scalar.value, &endptr, 10)); LOG_I(ENB_APP, "Setting frame_type to %s\n", event.data.scalar.value); }else { // not supported tag + LOG_E(FLEXRAN_AGENT, "Unsupported tag %s\n", event.data.scalar.value); goto error; } From 2c8dd796e8c4910945a2442c2f47a4c8a9e9f8bb Mon Sep 17 00:00:00 2001 From: shahab SHARIAT BAGHERI Date: Fri, 19 Jan 2018 16:29:50 +0100 Subject: [PATCH 090/141] Scheduler must send FlexRAN stats updates --- openair2/LAYER2/MAC/eNB_scheduler.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 1195e05379..67d8f270db 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -751,6 +751,10 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, schedule_CSI(module_idP, frameP, subframeP); // This schedules DLSCH in subframeP schedule_dlsch(module_idP, frameP, subframeP, mbsfn_status); + +#if defined(FLEXRAN_AGENT_SB_IF) + flexran_agent_send_update_stats(module_idP); +#endif // Allocate CCEs for good after scheduling is done for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) From 4f1c51f38ca4812fd8423ce70f57cda7b97e9d17 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 25 Jan 2018 14:07:45 +0100 Subject: [PATCH 091/141] add phy_free_RU() and phy_free_lte_eNB() this methods free the memory that is allocated by the functions phy_init_RU() and phy_init_lte_eNB() --- openair1/PHY/INIT/defs.h | 7 ++ openair1/PHY/INIT/lte_init.c | 127 +++++++++++++++++++++++++++++++- openair1/PHY/defs.h | 6 ++ targets/RT/USER/lte-enb.c | 2 + targets/RT/USER/lte-ru.c | 3 + targets/RT/USER/lte-softmodem.c | 4 + 6 files changed, 147 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/defs.h b/openair1/PHY/INIT/defs.h index 744fb3d3ce..e7972335ab 100644 --- a/openair1/PHY/INIT/defs.h +++ b/openair1/PHY/INIT/defs.h @@ -90,6 +90,13 @@ int phy_init_lte_eNB(PHY_VARS_eNB *phy_vars_eNb, unsigned char is_secondary_eNb, unsigned char abstraction_flag); +/*! +\brief Free the PHY variables relevant to the LTE implementation (eNB). +\details Only a subset of phy_vars_eNb is freed (those who have been allocated with phy_init_lte_eNB()). +@param[in] phy_vars_eNb Pointer to eNB Variables + */ +void phy_free_lte_eNB(PHY_VARS_eNB *phy_vars_eNb); + /** \brief Configure LTE_DL_FRAME_PARMS with components derived after initial synchronization (MIB decoding + primary/secondary synch). \details The basically allows configuration of \f$N_{\mathrm{RB}}^{\mathrm{DL}}\f$, the cell id \f$N_{\mathrm{ID}}^{\mathrm{cell}}\f$, the normal/extended prefix mode, the frame type (FDD/TDD), \f$N_{\mathrm{cp}}\f$, the number of TX antennas at eNB (\f$p\f$) and the number of PHICH groups, \f$N_{\mathrm{group}}^{\mathrm{PHICH}}\f$ @param lte_frame_parms pointer to LTE parameter structure diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 283667134d..f5db781309 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -1777,7 +1777,55 @@ int phy_init_RU(RU_t *ru) { return(0); } - + +void phy_free_RU(RU_t *ru) +{ + int i,j; + int p; + + LOG_I(PHY, "Feeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx); + + if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so free memory for time-domain signals + for (i = 0; i < ru->nb_tx; i++) free_and_zero(ru->common.txdata[i]); + for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdata[i]); + free_and_zero(ru->common.txdata); + free_and_zero(ru->common.rxdata); + } // else: IF5 or local RF -> nothing to free() + + if (ru->function != NGFI_RRU_IF5) { // we need to do RX/TX RU processing + for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdata_7_5kHz[i]); + free_and_zero(ru->common.rxdata_7_5kHz); + + // free IFFT input buffers (TX) + for (i = 0; i < ru->nb_tx; i++) free_and_zero(ru->common.txdataF_BF[i]); + free_and_zero(ru->common.txdataF_BF); + + // free FFT output buffers (RX) + for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdataF[i]); + free_and_zero(ru->common.rxdataF); + + for (i = 0; i < ru->nb_rx; i++) { + free_and_zero(ru->prach_rxsigF[i]); +#ifdef Rel14 + for (j = 0; j < 4; j++) free_and_zero(ru->prach_rxsigF_br[j][i]); +#endif + } + for (j = 0; j < 4; j++) free_and_zero(ru->prach_rxsigF_br[j]); + free_and_zero(ru->prach_rxsigF); + /* ru->prach_rxsigF_br is not allocated -> don't free */ + + for (i = 0; i < RC.nb_L1_inst; i++) { + for (p = 0; p < 15; p++) { + if (p < ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB || p == 5) { + for (j=0; jnb_tx; j++) free_and_zero(ru->beam_weights[i][p][j]); + free_and_zero(ru->beam_weights[i][p]); + } + } + } + } + free_and_zero(ru->common.sync_corr); +} + int phy_init_lte_eNB(PHY_VARS_eNB *eNB, unsigned char is_secondary_eNB, unsigned char abstraction_flag) @@ -1911,7 +1959,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, AssertFatal(fp->N_RB_UL > 5, "fp->N_RB_UL %d < 6\n",fp->N_RB_UL); for (i=0; i<2; i++) { // RK 2 times because of output format of FFT! - // FIXME We should get rid of this + // FIXME We should get rid of this, consider also phy_free_lte_eNB() pusch_vars[UE_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( 2*sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); pusch_vars[UE_id]->rxdataF_ext2[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); pusch_vars[UE_id]->drs_ch_estimates[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); @@ -1934,3 +1982,78 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, return (0); } + + +void phy_free_lte_eNB(PHY_VARS_eNB *eNB) +{ + LTE_DL_FRAME_PARMS* const fp = &eNB->frame_parms; + LTE_eNB_COMMON* const common_vars = &eNB->common_vars; + LTE_eNB_PUSCH** const pusch_vars = eNB->pusch_vars; + LTE_eNB_SRS* const srs_vars = eNB->srs_vars; + LTE_eNB_PRACH* const prach_vars = &eNB->prach_vars; +#ifdef Rel14 + LTE_eNB_PRACH* const prach_vars_br = &eNB->prach_vars_br; +#endif + int i, UE_id; + + for (i = 0; i < NB_ANTENNA_PORTS_ENB; i++) { + if (i < fp->nb_antenna_ports_eNB || i == 5) { + free_and_zero(common_vars->txdataF[i]); + /* rxdataF[i] is not allocated -> don't free */ + } + } + free_and_zero(common_vars->txdataF); + free_and_zero(common_vars->rxdataF); + + // Channel estimates for SRS + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + for (i=0; i<64; i++) { + free_and_zero(srs_vars[UE_id].srs_ch_estimates[i]); + free_and_zero(srs_vars[UE_id].srs_ch_estimates_time[i]); + } + free_and_zero(srs_vars[UE_id].srs_ch_estimates); + free_and_zero(srs_vars[UE_id].srs_ch_estimates_time); + } //UE_id + + free_ul_ref_sigs(); + + for (UE_id=0; UE_idprachF); + + for (i = 0; i < 64; i++) free_and_zero(prach_vars->prach_ifft[0][i]); + free_and_zero(prach_vars->prach_ifft[0]); + +#ifdef Rel14 + for (int ce_level = 0; ce_level < 4; ce_level++) { + for (i = 0; i < 64; i++) free_and_zero(prach_vars_br->prach_ifft[ce_level][i]); + free_and_zero(prach_vars_br->prach_ifft[ce_level]); + free_and_zero(prach_vars->rxsigF[ce_level]); + } + free_and_zero(prach_vars_br->prachF); +#endif + free_and_zero(prach_vars->rxsigF[0]); + + for (UE_id=0; UE_idrxdataF_ext[i]); + free_and_zero(pusch_vars[UE_id]->rxdataF_ext2[i]); + free_and_zero(pusch_vars[UE_id]->drs_ch_estimates[i]); + free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time[i]); + free_and_zero(pusch_vars[UE_id]->rxdataF_comp[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_mag[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_magb[i]); + } + free_and_zero(pusch_vars[UE_id]->rxdataF_ext); + free_and_zero(pusch_vars[UE_id]->rxdataF_ext2); + free_and_zero(pusch_vars[UE_id]->drs_ch_estimates); + free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time); + free_and_zero(pusch_vars[UE_id]->rxdataF_comp); + free_and_zero(pusch_vars[UE_id]->ul_ch_mag); + free_and_zero(pusch_vars[UE_id]->ul_ch_magb); + free_and_zero(pusch_vars[UE_id]->llr); + free_and_zero(pusch_vars[UE_id]); + } //UE_id + + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) eNB->UE_stats_ptr[UE_id] = NULL; +} diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 0e44a7f8bd..b5c2e54fa5 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -79,6 +79,12 @@ #define bigmalloc16 malloc16 #define openair_free(y,x) free((y)) #define PAGE_SIZE 4096 +#define free_and_zero(PtR) do { \ + if (PtR) { \ + free(PtR); \ + PtR = NULL; \ + } \ + } while (0) #define RX_NB_TH_MAX 2 #define RX_NB_TH 2 diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 6b418bb8ff..ece2b75c77 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -974,5 +974,7 @@ void stop_eNB(int nb_inst) { for (int inst=0;inst Date: Fri, 26 Jan 2018 14:49:45 +0100 Subject: [PATCH 092/141] free memory when stopping/restarting lte-softmodem - add function free_td() -> complements init_td() [seems to not be used, added for completeness] - add function free_td8() -> undoes init_td8() [free memory of 8-bit LLR Turbo decoder] - add function free_td16() -> undoes init_td16() [free memory of 16-bit LLR Turbo decoder] - change function free_tdavx216() -> undoes init_tdavx216() [free memory of 16-bit LLR Turbo decoder, AVX2 version] - add free_lte_top() -> frees memory allocated by init_lte_top() - change free_ul_ref_sigs() to set freed pointers to NULL - add method free_transport() -> frees memory of ULSCH/DLSCH transport channels - use the above functions when stopping/restarting the lte-softmodem --- .../CODING/3gpplte_turbo_decoder_avx2_16bit.c | 8 ++++---- .../PHY/CODING/3gpplte_turbo_decoder_sse.c | 12 +++++++++++ .../CODING/3gpplte_turbo_decoder_sse_16bit.c | 8 ++++---- .../CODING/3gpplte_turbo_decoder_sse_8bit.c | 8 ++++---- openair1/PHY/CODING/defs.h | 10 ++++++++++ openair1/PHY/INIT/defs.h | 1 + openair1/PHY/INIT/lte_init.c | 12 +++++++++++ openair1/PHY/LTE_REFSIG/lte_ul_ref.c | 8 ++++++-- openair1/PHY/LTE_TRANSPORT/proto.h | 6 ++++++ targets/RT/USER/lte-enb.c | 20 ++++++++++++++++++- targets/RT/USER/lte-ru.c | 2 -- targets/RT/USER/lte-softmodem.c | 8 +++++++- 12 files changed, 85 insertions(+), 18 deletions(-) diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c index 616eed7446..83a50f214b 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c @@ -830,10 +830,10 @@ void free_td16avx2(void) int ind; for (ind=0; ind<188; ind++) { - free(pi2tab16avx2[ind]); - free(pi5tab16avx2[ind]); - free(pi4tab16avx2[ind]); - free(pi6tab16avx2[ind]); + free_and_zero(pi2tab16avx2[ind]); + free_and_zero(pi5tab16avx2[ind]); + free_and_zero(pi4tab16avx2[ind]); + free_and_zero(pi6tab16avx2[ind]); } } diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse.c index 9ec25367d9..f628bff55b 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse.c @@ -1907,6 +1907,18 @@ void compute_ext(llr_t* alpha,llr_t* beta,llr_t* m_11,llr_t* m_10,llr_t* ext, ll //int pi2[n],pi3[n+8],pi5[n+8],pi4[n+8],pi6[n+8], int *pi2tab[188],*pi5tab[188],*pi4tab[188],*pi6tab[188]; +void free_td() +{ + int ind; + + for (ind = 0; ind < 188; ind++) { + free_and_zero(pi2tab[ind]); + free_and_zero(pi5tab[ind]); + free_and_zero(pi4tab[ind]); + free_and_zero(pi6tab[ind]); + } +} + void init_td() { diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c index cb4a4e1f84..a32edd711d 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c @@ -1117,10 +1117,10 @@ void free_td16(void) int ind; for (ind=0; ind<188; ind++) { - free(pi2tab16[ind]); - free(pi5tab16[ind]); - free(pi4tab16[ind]); - free(pi6tab16[ind]); + free_and_zero(pi2tab16[ind]); + free_and_zero(pi5tab16[ind]); + free_and_zero(pi4tab16[ind]); + free_and_zero(pi6tab16[ind]); } } diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c index d6ef84b218..4754e26f38 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c @@ -838,10 +838,10 @@ void free_td8(void) int ind; for (ind=0; ind<188; ind++) { - free(pi2tab8[ind]); - free(pi5tab8[ind]); - free(pi4tab8[ind]); - free(pi6tab8[ind]); + free_and_zero(pi2tab8[ind]); + free_and_zero(pi5tab8[ind]); + free_and_zero(pi4tab8[ind]); + free_and_zero(pi6tab8[ind]); } } diff --git a/openair1/PHY/CODING/defs.h b/openair1/PHY/CODING/defs.h index 06311a188b..9150e19bf1 100644 --- a/openair1/PHY/CODING/defs.h +++ b/openair1/PHY/CODING/defs.h @@ -356,10 +356,17 @@ void ccodedab_init_inv(void); \brief This function initializes the different crc tables.*/ void crcTableInit (void); +/*!\fn void free_td8(void) +\brief This function frees the tables for 8-bit LLR Turbo decoder.*/ +void free_td8(void); + /*!\fn void init_td8(void) \brief This function initializes the tables for 8-bit LLR Turbo decoder.*/ void init_td8 (void); +/*!\fn void free_td16(void) +\brief This function frees the tables for 16-bit LLR Turbo decoder.*/ +void free_td16(void); /*!\fn void init_td16(void) \brief This function initializes the tables for 16-bit LLR Turbo decoder.*/ @@ -370,6 +377,9 @@ void init_td16 (void); \brief This function initializes the tables for 8-bit LLR Turbo decoder (AVX2).*/ void init_td8avx2 (void); +/*!\fn void free_td16avx2(void) +\brief This function frees the tables for 16-bit LLR Turbo decoder (AVX2).*/ +void free_td16avx2(void); /*!\fn void init_td16(void) \brief This function initializes the tables for 16-bit LLR Turbo decoder (AVX2).*/ diff --git a/openair1/PHY/INIT/defs.h b/openair1/PHY/INIT/defs.h index e7972335ab..55d220824e 100644 --- a/openair1/PHY/INIT/defs.h +++ b/openair1/PHY/INIT/defs.h @@ -324,6 +324,7 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *phy_vars_eNB); */ int phy_init_secsys_eNB(PHY_VARS_eNB *phy_vars_eNb); +void free_lte_top(void); void init_lte_top(LTE_DL_FRAME_PARMS *lte_frame_parms); diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index f5db781309..86ed62040f 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -1247,6 +1247,18 @@ void phy_config_cba_rnti (module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uin } } +void free_lte_top(void) +{ + free_td8(); + free_td16(); +#ifdef __AVX2__ + free_td16avx2(); +#endif + lte_sync_time_free(); + + /* free_ul_ref_sigs() is called in phy_free_lte_eNB() */ +} + void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) { diff --git a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c index cddb642b2b..cacd0f4292 100644 --- a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c +++ b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c @@ -188,11 +188,15 @@ void free_ul_ref_sigs(void) for (Msc_RS=2; Msc_RS<33; Msc_RS++) { for (u=0; u<30; u++) { for (v=0; v<2; v++) { - if (ul_ref_sigs[u][v][Msc_RS]) + if (ul_ref_sigs[u][v][Msc_RS]) { free16(ul_ref_sigs[u][v][Msc_RS],2*sizeof(int16_t)*dftsizes[Msc_RS]); + ul_ref_sigs_rx[u][v][Msc_RS] = NULL; + } - if (ul_ref_sigs_rx[u][v][Msc_RS]) + if (ul_ref_sigs_rx[u][v][Msc_RS]) { free16(ul_ref_sigs_rx[u][v][Msc_RS],4*sizeof(int16_t)*dftsizes[Msc_RS]); + ul_ref_sigs_rx[u][v][Msc_RS] = NULL; + } } } } diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 8a0e160f23..98a32f68a0 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -83,6 +83,12 @@ void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch); +/** \fn free_eNB_ulsch(LTE_eNB_DLSCH_t *dlsch) + \brief This function frees memory allocated for a particular ULSCH at eNB + @param ulsch Pointer to ULSCH to be removed +*/ +void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch); + LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index ece2b75c77..bd9fbab19d 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -794,6 +794,21 @@ void print_opp_meas(void) { } } +void free_transport(PHY_VARS_eNB *eNB) +{ + int i; + int j; + + for (i=0; idlsch[i][j]); + + LOG_I(PHY, "Freeing Transport Channel Buffer for ULSCH, UE %d\n",i); + free_eNB_ulsch(eNB->ulsch[1+i]); + } + free_eNB_ulsch(eNB->ulsch[0]); +} + void init_transport(PHY_VARS_eNB *eNB) { int i; @@ -975,6 +990,9 @@ void stop_eNB(int nb_inst) { LOG_I(PHY,"Killing eNB %d processing threads\n",inst); kill_eNB_proc(inst); /* release memory used by these threads (incomplete) */ - for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) phy_free_lte_eNB(RC.eNB[inst][cc_id]); + for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) { + free_transport(RC.eNB[inst][cc_id]); + phy_free_lte_eNB(RC.eNB[inst][cc_id]); + } } } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 6459b6a58d..5a2f49212c 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1557,8 +1557,6 @@ void *ru_thread_synch(void *arg) { if (release_thread(&ru->proc.mutex_synch,&ru->proc.instance_cnt_synch,"ru_synch_thread") < 0) break; } // oai_exit - lte_sync_time_free(); - ru_thread_synch_status = 0; return &ru_thread_synch_status; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 6ae35a9bf0..8df540bc49 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -884,6 +884,7 @@ void terminate_task(task_id_t task_id, module_id_t mod_id) itti_send_msg_to_task (task_id, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg); } +extern void free_transport(PHY_VARS_eNB *); extern void phy_free_RU(RU_t*); int stop_L1L2(module_id_t enb_id) @@ -923,8 +924,12 @@ int stop_L1L2(module_id_t enb_id) LOG_I(ENB_APP, "calling kill_RU_proc() for instance %d\n", enb_id); kill_RU_proc(enb_id); oai_exit = 0; - for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) phy_free_lte_eNB(RC.eNB[enb_id][cc_id]); + for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) { + free_transport(RC.eNB[enb_id][cc_id]); + phy_free_lte_eNB(RC.eNB[enb_id][cc_id]); + } phy_free_RU(RC.ru[enb_id]); + free_lte_top(); return 0; } @@ -1491,6 +1496,7 @@ int main( int argc, char **argv ) } else { stop_eNB(NB_eNB_INST); stop_RU(NB_RU); + free_lte_top(); } From 6dcac9234cb0d13317f311e1c5633ce76af6010f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 29 Jan 2018 10:25:16 +0100 Subject: [PATCH 093/141] Navid: revise FlexRAN --- openair2/ENB_APP/flexran_agent_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 33879714d9..de0de15c0a 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -467,6 +467,7 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl //Set this according to the current state of the UE. This is only a temporary fix int status = 0; status = mac_eNB_get_rrc_status(mod_id, flexran_get_ue_crnti(mod_id, i)); + /* TODO needs to be revised and appropriate API to be implemented */ if (status < RRC_CONNECTED) { lc_ue_config[i]->n_lc_config = 0; } else if (status == RRC_CONNECTED) { @@ -505,6 +506,7 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl lc_config[j]->has_qci = 1; lc_config[j]->qci = 1; if (lc_config[j]->direction == PROTOCOL__FLEX_QOS_BEARER_TYPE__FLQBT_GBR) { + /* TODO all of the need to be taken from API */ //TODO: Set the max bitrate (UL) lc_config[j]->has_e_rab_max_bitrate_ul = 0; lc_config[j]->e_rab_max_bitrate_ul = 0; From e669f83dc1789c3dbc75c13a290e70d659cc3a3f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 29 Jan 2018 11:05:04 +0100 Subject: [PATCH 094/141] Navid: revise RAN API --- openair2/ENB_APP/flexran_agent_ran_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 75552526a7..2e1878f5e5 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -861,6 +861,7 @@ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) } } +/* TODO Navid: Get the same for eNB */ long flexran_get_lcg(mid_t ue_id, mid_t lc_id) { if (!UE_mac_inst) return -1; @@ -870,10 +871,9 @@ long flexran_get_lcg(mid_t ue_id, mid_t lc_id) return *(UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters->logicalChannelGroup); } +/* TODO Navid: needs to be revised */ int flexran_get_direction(mid_t ue_id, mid_t lc_id) { - /* TODO: fill with the value for the rest of LCID -> Robert: What does that - * mean? */ switch (lc_id) { case DCCH: case DCCH1: From dd7d2ef63b4f8b49aabcc921f42cdd8ca6a34cfa Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 29 Jan 2018 11:05:52 +0100 Subject: [PATCH 095/141] Navid: revise RRC --- openair2/RRC/LITE/rrc_eNB.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 8402d1ba61..9fb1165beb 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2141,7 +2141,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons } #if defined(FLEXRAN_AGENT_SB_IF) - +/* TODO Navid: does this belong here? */ //----------------------------------------------------------------------------- void flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, From 6eeb25771727db8bf7368096b19acf97ec857960 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 29 Jan 2018 14:47:52 +0100 Subject: [PATCH 096/141] add UE_Capability to type eNB_RRC_UE_t and read it when received --- openair2/RRC/LITE/defs.h | 2 ++ openair2/RRC/LITE/rrc_eNB.c | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index 9a346f7fb7..91e50a16d8 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -395,6 +395,8 @@ typedef struct eNB_RRC_UE_s { MeasConfig_t* measConfig; HANDOVER_INFO* handover_info; MeasResults_t* measResults; + + UE_EUTRA_Capability_t* UE_Capability; #if defined(ENABLE_SECURITY) /* KeNB as derived from KASME received from EPC */ diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 9fb1165beb..bae9138b5f 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -4994,7 +4994,6 @@ rrc_eNB_decode_dcch( 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; @@ -5385,18 +5384,33 @@ rrc_eNB_decode_dcch( xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void *)ul_dcch_msg); #endif LOG_I(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti); + if (ue_context_p->ue_context.UE_Capability) { + LOG_I(RRC, "freeing old UE capabilities for UE %x\n", ctxt_pP->rnti); + asn_DEF_UE_EUTRA_Capability.free_struct(&asn_DEF_UE_EUTRA_Capability, + ue_context_p->ue_context.UE_Capability, 0); + ue_context_p->ue_context.UE_Capability = 0; + } dec_rval = uper_decode(NULL, &asn_DEF_UE_EUTRA_Capability, - (void **)&UE_EUTRA_Capability, + (void **)&ue_context_p->ue_context.UE_Capability, ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions. choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list. array[0]->ueCapabilityRAT_Container.buf, ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions. choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list. array[0]->ueCapabilityRAT_Container.size, 0, 0); - //#ifdef XER_PRINT - //xer_fprint(stdout, &asn_DEF_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability); - //#endif +#ifdef XER_PRINT + xer_fprint(stdout, &asn_DEF_UE_EUTRA_Capability, ue_context_p->ue_context.UE_Capability); +#endif + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Failed to decode UE capabilities (%zu bytes)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + dec_rval.consumed); + asn_DEF_UE_EUTRA_Capability.free_struct(&asn_DEF_UE_EUTRA_Capability, + ue_context_p->ue_context.UE_Capability, 0); + ue_context_p->ue_context.UE_Capability = 0; + } #if defined(ENABLE_USE_MME) From fcddbc2b441ead0d8d026e6c40362348e9d11176 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 29 Jan 2018 14:48:41 +0100 Subject: [PATCH 097/141] RAN API: add functions using UE_Capability - flexran_get_half_duplex() - flexran_get_intra_sf_hopping() - flexran_get_type2_sb_1() - flexran_get_ue_category() - flexran_get_res_alloc_type1() --- openair2/ENB_APP/flexran_agent_ran_api.c | 102 +++++++++++++++-------- openair2/ENB_APP/flexran_agent_ran_api.h | 27 ++---- 2 files changed, 76 insertions(+), 53 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 2e1878f5e5..ddbc3ad869 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -638,55 +638,87 @@ uint64_t flexran_get_ue_aggregated_max_bitrate_ul(mid_t mod_id, mid_t ue_id) return RC.mac[mod_id]->UE_list.UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL; } -int flexran_get_half_duplex(mid_t ue_id) +int flexran_get_half_duplex(mid_t mod_id, mid_t ue_id) { -#warning "Implement flexran_get_half_duplex() in RAN API" - // TODO - //int halfduplex = 0; - //int bands_to_scan = ((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count; - //for (int i =0; i < bands_to_scan; i++){ - //if(((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->halfDuplex > 0) - // halfduplex = 1; - //} - //return halfduplex; + if (!rrc_is_present(mod_id)) return -1; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.UE_Capability) return -1; + SupportedBandListEUTRA_t *bands = &ue_context_p->ue_context.UE_Capability->rf_Parameters.supportedBandListEUTRA; + for (int i = 0; i < bands->list.count; i++) { + if (bands->list.array[i]->halfDuplex > 0) return 1; + } return 0; } -int flexran_get_intra_sf_hopping(mid_t ue_id) +int flexran_get_intra_sf_hopping(mid_t mod_id, mid_t ue_id) { -#warning "Implement flexran_get_intra_sf_hopping() in RAN API" - //TODO:Get proper value - //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); - //return (0 & ( 1 << (31))); - return 0; + if (!rrc_is_present(mod_id)) return -1; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.UE_Capability) return -1; + if (!ue_context_p->ue_context.UE_Capability->featureGroupIndicators) return -1; + /* According to TS 36.331 Annex B.1, Intra SF Hopping is bit 1 (leftmost bit) + * in this bitmap, i.e. the eighth bit (from right) in the first bye (from + * left) */ + BIT_STRING_t *fgi = ue_context_p->ue_context.UE_Capability->featureGroupIndicators; + uint8_t buf = fgi->buf[0]; + return (buf >> 7) & 1; } -int flexran_get_type2_sb_1(mid_t ue_id) +int flexran_get_type2_sb_1(mid_t mod_id, mid_t ue_id) { -#warning "Implement flexran_get_type2_sb_1() in RAN API" - //TODO:Get proper value - //uint8_t temp = 0; - //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); - //return (temp & ( 1 << (11))); - return 0; + if (!rrc_is_present(mod_id)) return -1; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.UE_Capability) return -1; + if (!ue_context_p->ue_context.UE_Capability->featureGroupIndicators) return -1; + /* According to TS 36.331 Annex B.1, Predefined intra- and inter-sf or + * predfined inter-sf frequency hopping for PUSCH with N_sb>1 is bit 21 (bit + * 1 is leftmost bit) in this bitmap, i.e. the fourth bit (from right) in the + * third byte (from left) */ + BIT_STRING_t *fgi = ue_context_p->ue_context.UE_Capability->featureGroupIndicators; + uint8_t buf = fgi->buf[2]; + return (buf >> 3) & 1; } -int flexran_get_ue_category(mid_t ue_id) +long flexran_get_ue_category(mid_t mod_id, mid_t ue_id) { -#warning "Implement flexran_get_ue_category() in RAN API" - //TODO:Get proper value - //return (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->ue_Category); - return 0; + if (!rrc_is_present(mod_id)) return -1; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.UE_Capability) return -1; + return ue_context_p->ue_context.UE_Capability->ue_Category; } -int flexran_get_res_alloc_type1(mid_t ue_id) +int flexran_get_res_alloc_type1(mid_t mod_id, mid_t ue_id) { -#warning "Implement flexran_get_res_alloc_type1() in RAN API" - //TODO:Get proper value - //uint8_t temp = 0; - //temp = (((UE_RRC_INST *)enb_ue_rrc[ue_id])->UECap->UE_EUTRA_Capability->featureGroupIndicators->buf); - //return (temp & ( 1 << (30))); - return 0; + if (!rrc_is_present(mod_id)) return -1; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + if (!ue_context_p->ue_context.UE_Capability) return -1; + if (!ue_context_p->ue_context.UE_Capability->featureGroupIndicators) return -1; + /* According to TS 36.331 Annex B.1, Resource allocation type 1 for PDSCH is + * bit 2 (bit 1 is leftmost bit) in this bitmap, i.e. the seventh bit (from + * right) in the first byte (from left) */ + BIT_STRING_t *fgi = ue_context_p->ue_context.UE_Capability->featureGroupIndicators; + uint8_t buf = fgi->buf[0]; + return (buf >> 6) & 1; } long flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 25faa105a6..62752f1308 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -246,29 +246,20 @@ uint64_t flexran_get_ue_aggregated_max_bitrate_dl(mid_t mod_id, mid_t ue_id); per UE. See TS 36.413 */ uint64_t flexran_get_ue_aggregated_max_bitrate_ul(mid_t mod_id, mid_t ue_id); -/* Only half-duplex support. FDD - operation. Boolean value */ -/* currently broken -int flexran_get_half_duplex(mid_t ue_id); */ +/* Only half-duplex support. FDD operation. Boolean value */ +int flexran_get_half_duplex(mid_t mod_id, mid_t ue_id); -/* Support of intra-subframe hopping. - Boolean value */ -/* currently broken -int flexran_get_intra_sf_hopping(mid_t ue_id); */ +/* Support of intra-subframe hopping. Boolean value */ +int flexran_get_intra_sf_hopping(mid_t mod_id, mid_t ue_id); -/* UE support for type 2 hopping with - n_sb>1 */ -/* currently broken -int flexran_get_type2_sb_1(mid_t ue_id); */ +/* UE support for type 2 hopping with n_sb>1 */ +int flexran_get_type2_sb_1(mid_t mod_id, mid_t ue_id); /* Get the UE category */ -/* currently broken -int flexran_get_ue_category(mid_t ue_id); */ +long flexran_get_ue_category(mid_t mod_id, mid_t ue_id); -/* UE support for resource allocation - type 1 */ -/* currently broken -int flexran_get_res_alloc_type1(mid_t ue_id); */ +/* UE support for resource allocation type 1 */ +int flexran_get_res_alloc_type1(mid_t mod_id, mid_t ue_id); /* Get UE transmission mode */ long flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id); From c8ae5b7c09bd7d0c77f97c731e8c5825f23344da Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 8 Feb 2018 18:55:23 +0100 Subject: [PATCH 098/141] decrease warning --- targets/RT/USER/lte-ru.c | 1 - 1 file changed, 1 deletion(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index e553fc3702..5f60553fe1 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -2161,7 +2161,6 @@ void init_RU(char *rf_config_file) { int ru_id; RU_t *ru; - int ret; PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; int i; int CC_id; From 1a1ad6ed8f3e1ad9c7e55a661aa1e9ddfc423d0e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 8 Feb 2018 19:11:57 +0100 Subject: [PATCH 099/141] remove non-existing files from build description file --- cmake_targets/CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 120d029a0c..44d80d4633 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1394,14 +1394,6 @@ add_library(L2_UE include_directories(${NFAPI_USER_DIR}) -if (FLEXRAN_AGENT_SB_IF) - -#Test for adding a shared library -add_library(default_sched SHARED ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue.c) -add_library(remote_sched SHARED ${MAC_DIR}/flexran_agent_scheduler_dlsch_ue_remote.c) - -endif() - # L3 Libs ########################## From c518ed89e288767ca030991f1b2354684da7fcd3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 8 Feb 2018 19:12:20 +0100 Subject: [PATCH 100/141] bugfix after merge --- openair2/RRC/LITE/rrc_eNB.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 9526be83f4..f51ac31a79 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -6694,7 +6694,7 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { #if defined(FLEXRAN_AGENT_SB_IF) //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future if (mac_agent_registered[ctxt_pP->module_id]) { - agent_mac_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, ue_context_p->ue_id_rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); } From 6cff88b9c8e7d8291bd754a3ac4877fd9baa45ec Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 9 Feb 2018 10:56:14 +0100 Subject: [PATCH 101/141] free memory on teardown after all RU/eNB threads have been released --- targets/RT/USER/lte-enb.c | 5 ----- targets/RT/USER/lte-ru.c | 2 -- targets/RT/USER/lte-softmodem.c | 11 +++++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 928b41ad44..58967612dc 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -1139,10 +1139,5 @@ void stop_eNB(int nb_inst) { for (int inst=0;inst Date: Fri, 9 Feb 2018 10:59:59 +0100 Subject: [PATCH 102/141] free all memory for lte_ul_ref* structures --- openair1/PHY/LTE_REFSIG/lte_ul_ref.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c index cacd0f4292..93ca7646e6 100644 --- a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c +++ b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c @@ -185,12 +185,12 @@ void free_ul_ref_sigs(void) unsigned int u,v,Msc_RS; - for (Msc_RS=2; Msc_RS<33; Msc_RS++) { + for (Msc_RS=0; Msc_RS<33; Msc_RS++) { for (u=0; u<30; u++) { for (v=0; v<2; v++) { if (ul_ref_sigs[u][v][Msc_RS]) { free16(ul_ref_sigs[u][v][Msc_RS],2*sizeof(int16_t)*dftsizes[Msc_RS]); - ul_ref_sigs_rx[u][v][Msc_RS] = NULL; + ul_ref_sigs[u][v][Msc_RS] = NULL; } if (ul_ref_sigs_rx[u][v][Msc_RS]) { From 386fd21c937215bf43b02f2ca8e6d7334a3998ea Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 9 Feb 2018 15:31:59 +0100 Subject: [PATCH 103/141] free_eNB_{d,u}lsch(): remove log, complete function dlsch --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 37 ++++------------------- openair1/PHY/LTE_TRANSPORT/ulsch_coding.c | 22 -------------- 2 files changed, 6 insertions(+), 53 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index bd3c92454f..f1cb58ba26 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -56,42 +56,20 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { - int i; - int r; + int i, r, aa, layer; if (dlsch) { -#ifdef DEBUG_DLSCH_FREE - printf("Freeing dlsch %p\n",dlsch); -#endif - + for (layer=0; layer<4; layer++) { + for (aa=0; aa<64; aa++) free16(dlsch->ue_spec_bf_weights[layer][aa], OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t)); + free16(dlsch->ue_spec_bf_weights[layer], 64*sizeof(int32_t*)); + } for (i=0; iMdlharq; i++) { -#ifdef DEBUG_DLSCH_FREE - printf("Freeing dlsch process %d\n",i); -#endif - if (dlsch->harq_processes[i]) { -#ifdef DEBUG_DLSCH_FREE - printf("Freeing dlsch process %d (%p)\n",i,dlsch->harq_processes[i]); -#endif - if (dlsch->harq_processes[i]->b) { free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES); dlsch->harq_processes[i]->b = NULL; -#ifdef DEBUG_DLSCH_FREE - printf("Freeing dlsch process %d b (%p)\n",i,dlsch->harq_processes[i]->b); -#endif } - -#ifdef DEBUG_DLSCH_FREE - printf("Freeing dlsch process %d c (%p)\n",i,dlsch->harq_processes[i]->c); -#endif - for (r=0; rharq_processes[i]->c[r]); -#endif - if (dlsch->harq_processes[i]->c[r]) { free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); dlsch->harq_processes[i]->c[r] = NULL; @@ -100,17 +78,14 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) free16(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144))); dlsch->harq_processes[i]->d[r] = NULL; } - } free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t)); dlsch->harq_processes[i] = NULL; } } - free16(dlsch,sizeof(LTE_eNB_DLSCH_t)); dlsch = NULL; - } - + } } LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t Nsoft,unsigned char N_RB_DL, uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms) diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c index 87209e190b..9b761f3cc3 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c @@ -66,33 +66,12 @@ void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch) #endif for (i=0; i<8; i++) { -#ifdef DEBUG_ULSCH_FREE - printf("Freeing ulsch process %d\n",i); -#endif - if (ulsch->harq_processes[i]) { -#ifdef DEBUG_ULSCH_FREE - printf("Freeing ulsch process %d (%p)\n",i,ulsch->harq_processes[i]); -#endif - if (ulsch->harq_processes[i]->b) { free16(ulsch->harq_processes[i]->b,MAX_ULSCH_PAYLOAD_BYTES); ulsch->harq_processes[i]->b = NULL; -#ifdef DEBUG_ULSCH_FREE - printf("Freeing ulsch process %d b (%p)\n",i,ulsch->harq_processes[i]->b); -#endif } - -#ifdef DEBUG_ULSCH_FREE - printf("Freeing ulsch process %d c (%p)\n",i,ulsch->harq_processes[i]->c); -#endif - for (r=0; rharq_processes[i]->c[r]); -#endif - if (ulsch->harq_processes[i]->c[r]) { free16(ulsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); ulsch->harq_processes[i]->c[r] = NULL; @@ -103,7 +82,6 @@ void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch) ulsch->harq_processes[i] = NULL; } } - free16(ulsch,sizeof(LTE_UE_ULSCH_t)); ulsch = NULL; } From 1eabadb137b9c8c534cb5782ae410afa76f070e2 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 9 Feb 2018 15:47:59 +0100 Subject: [PATCH 104/141] remove unnecessary code from lte-enb.c --- targets/RT/USER/lte-enb.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 58967612dc..5ccc99c041 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -859,15 +859,6 @@ void kill_eNB_proc(int inst) { pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); } } - - LOG_D(PHY, "joining pthread_asynch_rxtx\n"); - pthread_join(proc->pthread_asynch_rxtx, (void**)&status ); - pthread_mutex_destroy(&proc->mutex_asynch_rxtx); - pthread_cond_destroy(&proc->cond_asynch_rxtx); - - LOG_D(PHY, "joining pthread_single\n"); - pthread_join(proc->pthread_single, (void**)&status ); - LOG_D(PHY, "joined all eNB threads\n"); } } From d746ff61274b101f53728b114f0aa4f62e38ea85 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 9 Feb 2018 16:29:59 +0100 Subject: [PATCH 105/141] update comments in restart_L1L2() --- targets/RT/USER/lte-softmodem.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 3aebf6d279..42a4a7c950 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -969,8 +969,6 @@ int restart_L1L2(module_id_t enb_id) RC.eNB[enb_id][cc_id]->configured = 0; } - - /* TODO undo malloc_IF4p5_buffer() */ RC.ru_mask |= (1 << ru->idx); /* copy the changed frame parameters to the RU */ /* TODO this should be done for all RUs associated to this eNB */ @@ -997,11 +995,9 @@ int restart_L1L2(module_id_t enb_id) RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration; itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); - /* TODO XForms here */ + /* TODO XForms might need to be restarted, but it is currently (09/02/18) + * broken, so we cannot test it */ - /* TODO check for memory leaks */ - /* TODO wait_eNBs() would wait for phy_config_request()? */ - //init_eNB(single_thread_flag,wait_for_sync); wait_eNBs(); init_RU_proc(ru); ru->rf_map.card = 0; @@ -1009,7 +1005,6 @@ int restart_L1L2(module_id_t enb_id) wait_RUs(); init_eNB_afterRU(); - printf("Sending sync to all threads\n"); pthread_mutex_lock(&sync_mutex); sync_var=0; From 8877b18a9a59342905f0c3c4ca3969f1bbd2d717 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 9 Feb 2018 19:05:36 +0100 Subject: [PATCH 106/141] fix eNB_ulsch_dlsch_scheduler() broken by merge 2c8443121d65c2a48 --- openair2/LAYER2/MAC/eNB_scheduler.c | 71 +++++++++++------------------ 1 file changed, 26 insertions(+), 45 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index cf7f84eed2..0e2f84b25b 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -504,22 +504,20 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, int mbsfn_status[MAX_NUM_CCs]; protocol_ctxt_t ctxt; - int CC_id, i; + int CC_id, i = -1; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; rnti_t rnti; COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; -#if defined(FLEXRAN_AGENT_SB_IF) - Protocol__FlexranMessage *msg; -#endif - - start_meas(&RC.mac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, VCD_FUNCTION_IN); + RC.mac[module_idP]->frame = frameP; + RC.mac[module_idP]->subframe = subframeP; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { mbsfn_status[CC_id] = 0; @@ -531,9 +529,29 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, #if defined(Rel10) || defined(Rel14) cc[CC_id].mcch_active = 0; #endif - RC.mac[module_idP]->frame = frameP; - RC.mac[module_idP]->subframe = subframeP; + clear_nfapi_information(RC.mac[module_idP], CC_id, frameP, subframeP); + } + + // refresh UE list based on UEs dropped by PHY in previous subframe + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; + + rnti = UE_RNTI(module_idP, i); + CC_id = UE_PCCID(module_idP, i); + + if ((frameP == 0) && (subframeP == 0)) { + LOG_I(MAC, + "UE rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", + rnti, + UE_list->UE_sched_ctrl[i].ul_out_of_sync == + 0 ? "in synch" : "out of sync", + UE_list->UE_template[CC_id][i].phr_info, + UE_list->UE_sched_ctrl[i].dl_cqi[CC_id], + (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2, + (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2); + } RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP * 10) + subframeP] = -63; @@ -601,42 +619,6 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, } } - // refresh UE list based on UEs dropped by PHY in previous subframe - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) continue; - - rnti = UE_RNTI(module_idP, i); - CC_id = UE_PCCID(module_idP, i); - - if ((frameP == 0) && (subframeP == 0)) { - LOG_I(MAC, - "UE rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", - rnti, - UE_list->UE_sched_ctrl[i].ul_out_of_sync == - 0 ? "in synch" : "out of sync", - UE_list->UE_template[CC_id][i].phr_info, - UE_list->UE_sched_ctrl[i].dl_cqi[CC_id], - (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2, - (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2); - } - - RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP * 10) + subframeP] = -63; - if (i == UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME - (VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR, - RC.eNB[module_idP][CC_id]-> - pusch_stats_bsr[i][(frameP * 10) + subframeP]); - // increment this, it is cleared when we receive an sdu - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++; - - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++; - LOG_D(MAC, "UE %d/%x : ul_inactivity %d, cqi_req %d\n", i, rnti, - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i]. - ul_inactivity_timer, - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer); - check_ul_failure(module_idP, CC_id, i, frameP, subframeP); - } - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, subframeP, module_idP); @@ -687,7 +669,6 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) allocate_CCEs(module_idP, CC_id, subframeP, 0); - stop_meas(&RC.mac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME From b073445f9986ae48b2764108aa969fbe540b6e7d Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 9 Feb 2018 19:15:30 +0100 Subject: [PATCH 107/141] removed NFAPI libraries from oaisim target. added #define to allow ue_ip.ko to compile. This should be revisited, there's a problem in CMakelists.txt, no flags.cmake generate for all 3 kernel modules. --- cmake_targets/CMakeLists.txt | 5 +---- openair2/NETWORK_DRIVER/UE_IP/local.h | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 616adf3a82..09dfbf7483 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2065,7 +2065,6 @@ add_executable(oaisim ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c - ${GTPU_need_ITTI} ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${XFORMS_SOURCE} ${T_SOURCE} @@ -2077,9 +2076,7 @@ add_executable(oaisim target_include_directories(oaisim PUBLIC ${OPENAIR_TARGETS}/SIMU/USER) target_link_libraries (oaisim -Wl,-ldl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_UE LFDS L2 ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} - NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB - NFAPI_USER_LIB + RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_UE LFDS L2_UE ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} -Wl,--end-group z dl) target_link_libraries (oaisim ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES}) diff --git a/openair2/NETWORK_DRIVER/UE_IP/local.h b/openair2/NETWORK_DRIVER/UE_IP/local.h index ac3b040995..15fa7a0f91 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/local.h +++ b/openair2/NETWORK_DRIVER/UE_IP/local.h @@ -57,6 +57,7 @@ #include "platform_types.h" #include "sap.h" +#define OAI_NW_DRIVER_USE_NETLINK 1 typedef struct ue_ip_priv_s { int irq; From a78aaa451cfc6452c4f95f4747d09a77488300c8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 9 Feb 2018 19:08:59 +0100 Subject: [PATCH 108/141] fix slicing capability in ulsch scheduler --- openair2/LAYER2/MAC/defs.h | 3 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 15 +- openair2/LAYER2/MAC/pre_processor.c | 496 +++++++++++----------- 3 files changed, 248 insertions(+), 266 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 8d99433eb0..de53479e6f 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -692,7 +692,7 @@ typedef struct { uint16_t cshift[8]; // num_max_harq /// Number of Allocated RBs by the ulsch preprocessor - uint8_t pre_allocated_nb_rb_ul; + uint8_t pre_allocated_nb_rb_ul[MAX_NUM_SLICES]; /// index of Allocated RBs by the ulsch preprocessor int8_t pre_allocated_rb_table_index_ul; @@ -804,6 +804,7 @@ typedef struct { uint8_t mac_ContentionResolutionTimer; uint16_t max_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; + uint16_t max_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; uint8_t max_mcs[MAX_NUM_LCID]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 72b9013d93..b24a3f42ac 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -850,7 +850,7 @@ set_msg3_subframe(module_id_t mod_id, int subframe, int rnti, int Msg3_frame, int Msg3_subframe) { - eNB_MAC_INST *mac = RC.mac[Mod_id]; + eNB_MAC_INST *mac = RC.mac[mod_id]; int i; for (i = 0; i < NB_RA_PROC_MAX; i++) { if (mac->common_channels[CC_id].ra[i].state != IDLE && @@ -1069,7 +1069,6 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, } // Run each enabled slice-specific schedulers one by one - /* TODO Navid What is the right call for this message? */ slice_sched_ul[i](module_idP, i, frameP, subframeP, sched_subframe, first_rb); } @@ -1296,10 +1295,9 @@ schedule_ulsch_rnti(module_id_t module_idP, normalized_rx_power = normalized_rx_power; UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power = target_rx_power; UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1 = UE_template->pre_assigned_mcs_ul; - UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul; //cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + UE_template->mcs_UL[harq_pid] = cmin(UE_template->pre_assigned_mcs_ul, slice_maxmcs_uplink[slice_id]);//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) { - rb_table_index = - UE_template->pre_allocated_rb_table_index_ul; + rb_table_index = UE_template->pre_allocated_rb_table_index_ul; } else { UE_template->mcs_UL[harq_pid] = 10; //cmin (10, openair_daq_vars.target_ue_ul_mcs); rb_table_index = 5; // for PHR @@ -1309,10 +1307,9 @@ schedule_ulsch_rnti(module_id_t module_idP, // buffer_occupancy = UE_template->ul_total_buffer; - while (((rb_table[rb_table_index] > - (N_RB_UL - 1 - first_rb[CC_id])) - || (rb_table[rb_table_index] > 45)) - && (rb_table_index > 0)) { + while (((rb_table[rb_table_index] > (N_RB_UL - 1 - first_rb[CC_id])) + || (rb_table[rb_table_index] > 45)) + && (rb_table_index > 0)) { rb_table_index--; } diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 544a48b80b..6d0d56668d 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -58,6 +58,7 @@ //#define DEBUG_PACKET_TRACE 1 extern float slice_percentage[MAX_NUM_SLICES]; +extern float slice_percentage_uplink[MAX_NUM_SLICES]; //#define ICIC 0 @@ -1377,13 +1378,13 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, total_allocated_rbs[MAX_NUM_CCs], average_rbs_per_user[MAX_NUM_CCs]; int16_t total_remaining_rbs[MAX_NUM_CCs]; - uint16_t max_num_ue_to_be_scheduled = 0; - uint16_t total_ue_count = 0; + uint16_t total_ue_count[MAX_NUM_CCs]; rnti_t rnti = -1; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; UE_TEMPLATE *UE_template = 0; - int N_RB_DL; - int N_RB_UL; + UE_sched_ctrl *ue_sched_ctl; + int N_RB_UL = 0; + LOG_D(MAC, "In ulsch_preprocessor: assign max mcs min rb\n"); // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB assign_max_mcs_min_rb(module_idP, slice_id, frameP, subframeP, first_rb); @@ -1396,186 +1397,180 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, // we need to distribute RBs among UEs // step1: reset the vars for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - N_RB_DL = - to_prb(RC.mac[module_idP]->common_channels[CC_id].mib-> - message.dl_Bandwidth); - N_RB_UL = - to_prb(RC.mac[module_idP]->common_channels[CC_id]. - ul_Bandwidth); - total_allocated_rbs[CC_id] = 0; - total_remaining_rbs[CC_id] = 0; - average_rbs_per_user[CC_id] = 0; + total_allocated_rbs[CC_id] = 0; + total_remaining_rbs[CC_id] = 0; + average_rbs_per_user[CC_id] = 0; + total_ue_count[CC_id] = 0; + } - for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { - nb_allocated_rbs[CC_id][i] = 0; - } + // Step 1.5: Calculate total_ue_count + for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { + for (n = 0; n < UE_list->numactiveULCCs[i]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][i]; + UE_template = &UE_list->UE_template[CC_id][i]; + if (flexran_slice_member(i, slice_id) == 0) + continue; + if (UE_template->pre_allocated_nb_rb_ul[slice_id] > 0) { + total_ue_count[CC_id] += 1; + } + } } LOG_D(MAC, "In ulsch_preprocessor: step2 \n"); // step 2: calculate the average rb per UE - total_ue_count = 0; - max_num_ue_to_be_scheduled = 0; - for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { - rnti = UE_RNTI(module_idP, i); + rnti = UE_RNTI(module_idP, i); - if (rnti == NOT_A_RNTI) - continue; + if (rnti == NOT_A_RNTI) + continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + + UE_id = i; + + LOG_D(MAC, "In ulsch_preprocessor: handling UE %d/%x\n", UE_id, + rnti); + 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]; + LOG_D(MAC, + "In ulsch_preprocessor: handling UE %d/%x CCid %d\n", + UE_id, rnti, CC_id); + + average_rbs_per_user[CC_id] = 0; + + /* + if((mac_xface->get_nCCE_max(module_idP,CC_id,3,subframeP) - nCCE_to_be_used[CC_id]) > (1<numactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - LOG_D(MAC, - "In ulsch_preprocessor: handling UE %d/%x CCid %d\n", - UE_id, rnti, CC_id); - UE_template = &UE_list->UE_template[CC_id][UE_id]; - average_rbs_per_user[CC_id] = 0; + N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth); + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage_uplink[slice_id],N_RB_UL); - if (UE_template->pre_allocated_nb_rb_ul > 0) { - total_ue_count += 1; - } - /* - if((mac_xface->get_nCCE_max(module_idP,CC_id,3,subframeP) - nCCE_to_be_used[CC_id]) > (1< 0) { - average_rbs_per_user[CC_id] = - (uint16_t) floor((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", - module_idP, frameP, subframeP, UE_id, CC_id); - } - } + if (total_ue_count[CC_id] == 0) { + average_rbs_per_user[CC_id] = 0; + } else if (total_ue_count[CC_id] == 1) { // increase the available RBs, special case, + average_rbs_per_user[CC_id] = ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id] + 1; + } else if (total_ue_count[CC_id] <= (ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id])) { + average_rbs_per_user[CC_id] = (uint16_t) floor((ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id]) / total_ue_count[CC_id]); + } 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", + module_idP, frameP, subframeP, UE_id, CC_id); + } + if (total_ue_count[CC_id] > 0) + LOG_D(MAC, "[eNB %d] Frame %d subframe %d: total ue to be scheduled %d\n", + module_idP, frameP, subframeP, total_ue_count[CC_id]); + } } - if (total_ue_count > 0) - LOG_D(MAC, - "[eNB %d] Frame %d subframe %d: total ue to be scheduled %d/%d\n", - module_idP, frameP, subframeP, total_ue_count, - max_num_ue_to_be_scheduled); - - //LOG_D(MAC,"step3\n"); // step 3: assigne RBS for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { - rnti = UE_RNTI(module_idP, i); + rnti = UE_RNTI(module_idP, i); - if (rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - UE_id = i; - - 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]; - harq_pid = - subframe2harqpid(&RC.mac[module_idP]-> - common_channels[CC_id], frameP, - subframeP); + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (flexran_slice_member(i, slice_id) == 0) + continue; - // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); + UE_id = i; - if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id] > 0) { - nb_allocated_rbs[CC_id][UE_id] = - UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; - } 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]); - } + 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]; + UE_template = &UE_list->UE_template[CC_id][UE_id]; + harq_pid = subframe2harqpid(&RC.mac[module_idP]->common_channels[CC_id], + frameP, subframeP); - total_allocated_rbs[CC_id] += nb_allocated_rbs[CC_id][UE_id]; - LOG_D(MAC, - "In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d\n", - nb_allocated_rbs[CC_id][UE_id], UE_id, rnti, CC_id, - harq_pid); - } + // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); + + if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id] > 0) { + nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; + } else { + nb_allocated_rbs[CC_id][UE_id] = + cmin(UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[slice_id], + average_rbs_per_user[CC_id]); + } + + total_allocated_rbs[CC_id] += nb_allocated_rbs[CC_id][UE_id]; + LOG_D(MAC, + "In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d\n", + nb_allocated_rbs[CC_id][UE_id], UE_id, rnti, CC_id, + harq_pid); + } } // step 4: assigne the remaining RBs and set the pre_allocated rbs accordingly - for (r = 0; r < 2; r++) { + for (r = 0; r < 2; r++) { - for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { - rnti = UE_RNTI(module_idP, i); + for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { + rnti = UE_RNTI(module_idP, i); - if (rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - UE_id = i; + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (flexran_slice_member(i, slice_id) == 0) + continue; - 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]; - UE_template = &UE_list->UE_template[CC_id][UE_id]; - total_remaining_rbs[CC_id] = - N_RB_UL - first_rb[CC_id] - total_allocated_rbs[CC_id]; + UE_id = i; - if (total_ue_count == 1) { - total_remaining_rbs[CC_id] += 1; - } + 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]; + UE_template = &UE_list->UE_template[CC_id][UE_id]; + total_remaining_rbs[CC_id] = + ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id] - total_allocated_rbs[CC_id]; - if (r == 0) { - while ((UE_template->pre_allocated_nb_rb_ul > 0) && - (nb_allocated_rbs[CC_id][UE_id] < - UE_template->pre_allocated_nb_rb_ul) - && (total_remaining_rbs[CC_id] > 0)) { - nb_allocated_rbs[CC_id][UE_id] = - cmin(nb_allocated_rbs[CC_id][UE_id] + 1, - UE_template->pre_allocated_nb_rb_ul); - total_remaining_rbs[CC_id]--; - total_allocated_rbs[CC_id]++; - } - } else { - UE_template->pre_allocated_nb_rb_ul = - nb_allocated_rbs[CC_id][UE_id]; - LOG_D(MAC, - "******************UL Scheduling Information for UE%d CC_id %d ************************\n", - UE_id, CC_id); - LOG_D(MAC, - "[eNB %d] total RB allocated for UE%d CC_id %d = %d\n", - module_idP, UE_id, CC_id, - UE_template->pre_allocated_nb_rb_ul); - } - } - } + if (total_ue_count[CC_id] == 1) { + total_remaining_rbs[CC_id] += 1; + } + + if (r == 0) { + while ((UE_template->pre_allocated_nb_rb_ul[slice_id] > 0) + && (nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul[slice_id]) + && (total_remaining_rbs[CC_id] > 0)) { + nb_allocated_rbs[CC_id][UE_id] = + cmin(nb_allocated_rbs[CC_id][UE_id] + 1, + UE_template->pre_allocated_nb_rb_ul[slice_id]); + total_remaining_rbs[CC_id]--; + total_allocated_rbs[CC_id]++; + } + } else { + UE_template->pre_allocated_nb_rb_ul[slice_id] = + nb_allocated_rbs[CC_id][UE_id]; + LOG_D(MAC, + "******************UL Scheduling Information for UE%d CC_id %d ************************\n", + UE_id, CC_id); + LOG_D(MAC, + "[eNB %d] total RB allocated for UE%d CC_id %d = %d\n", + module_idP, UE_id, CC_id, + UE_template->pre_allocated_nb_rb_ul[slice_id]); + } + } } + } for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { 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], - N_RB_UL - first_rb[CC_id]); + ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id]); } } } @@ -1586,134 +1581,123 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, sub_frame_t subframeP, uint16_t * first_rb) { - int i; - uint16_t n, UE_id; - uint8_t CC_id; - rnti_t rnti = -1; - int mcs; - int rb_table_index = 0, tbs, tx_power; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - UE_list_t *UE_list = &eNB->UE_list; + int i; + uint16_t n, UE_id; + uint8_t CC_id; + rnti_t rnti = -1; + int mcs; + int rb_table_index = 0, tbs, tx_power; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; - UE_TEMPLATE *UE_template; - int Ncp; - int N_RB_UL; + UE_TEMPLATE *UE_template; + UE_sched_ctrl *ue_sched_ctl; + int Ncp; + int N_RB_UL; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) - continue; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; - rnti = UE_RNTI(module_idP, i); + rnti = UE_RNTI(module_idP, i); - if (rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (flexran_slice_member(i, slice_id) == 0) + continue; - if (UE_list->UE_sched_ctrl[i].phr_received == 1) - mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs - else - mcs = 10; // otherwise, limit to QPSK PUSCH + if (UE_list->UE_sched_ctrl[i].phr_received == 1) + mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs + else + mcs = 10; // otherwise, limit to QPSK PUSCH - UE_id = i; + UE_id = i; - 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]; + 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]); - } + 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]); + 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]); - UE_template = &UE_list->UE_template[CC_id][UE_id]; + UE_template = &UE_list->UE_template[CC_id][UE_id]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - Ncp = RC.mac[module_idP]->common_channels[CC_id].Ncp; - N_RB_UL = - to_prb(RC.mac[module_idP]->common_channels[CC_id]. - ul_Bandwidth); - // if this UE has UL traffic - int bytes_to_schedule = UE_template->estimated_ul_buffer - UE_template->scheduled_ul_bytes; - if (bytes_to_schedule < 0) bytes_to_schedule = 0; - int bits_to_schedule = bytes_to_schedule * 8; + Ncp = RC.mac[module_idP]->common_channels[CC_id].Ncp; + N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth); + ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage_uplink[slice_id],N_RB_UL); - if (bits_to_schedule > 0) { - tbs = get_TBS_UL(mcs, 3) << 3; // 1 or 2 PRB with cqi enabled does not work well! - rb_table_index = 2; + // if this UE has UL traffic + if (UE_template->ul_total_buffer > 0) { + tbs = get_TBS_UL(mcs, 3) << 3; // 1 or 2 PRB with cqi enabled does not work well! + rb_table_index = 2; - // fixme: set use_srs flag - tx_power = - estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, - Ncp, 0); + // fixme: set use_srs flag + tx_power = estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, Ncp, 0); - while ((((UE_template->phr_info - tx_power) < 0) - || (tbs > bits_to_schedule)) - && (mcs > 3)) { - // LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); - mcs--; - tbs = get_TBS_UL(mcs, rb_table[rb_table_index]) << 3; - tx_power = estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, Ncp, 0); // fixme: set use_srs - } + while ((((UE_template->phr_info - tx_power) < 0) + || (tbs > UE_template->ul_total_buffer)) + && (mcs > 3)) { + // LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); + mcs--; + tbs = get_TBS_UL(mcs, rb_table[rb_table_index]) << 3; + tx_power = estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, Ncp, 0); // fixme: set use_srs + } - while ((tbs < bits_to_schedule) && - (rb_table[rb_table_index] < - (N_RB_UL - first_rb[CC_id])) - && ((UE_template->phr_info - tx_power) > 0) - && (rb_table_index < 32)) { + while ((tbs < bits_to_schedule) + && (rb_table[rb_table_index] < (ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id] - first_rb[CC_id])) + && ((UE_template->phr_info - tx_power) > 0) + && (rb_table_index < 32)) { + rb_table_index++; + tbs = get_TBS_UL(mcs, rb_table[rb_table_index]) << 3; + tx_power = estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, Ncp, 0); + } - rb_table_index++; - tbs = get_TBS_UL(mcs, rb_table[rb_table_index]) << 3; - tx_power = - estimate_ue_tx_power(tbs, rb_table[rb_table_index], - 0, Ncp, 0); - } + UE_template->ue_tx_power = tx_power; - UE_template->ue_tx_power = tx_power; + if (rb_table[rb_table_index] > (ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id] - first_rb[CC_id] - 1)) { + rb_table_index--; + } + // 1 or 2 PRB with cqi enabled does not work well + if (rb_table[rb_table_index] < 3) { + rb_table_index = 2; //3PRB + } - if (rb_table[rb_table_index] > - (N_RB_UL - first_rb[CC_id] - 1)) { - rb_table_index--; - } - // 1 or 2 PRB with cqi enabled does not work well - 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; - UE_template->pre_allocated_nb_rb_ul = - rb_table[rb_table_index]; - LOG_D(MAC, - "[eNB %d] frame %d subframe %d: for UE %d CC %d: pre-assigned mcs %d, pre-allocated rb_table[%d]=%d RBs (phr %d, tx power %d)\n", - module_idP, frameP, subframeP, UE_id, CC_id, - UE_template->pre_assigned_mcs_ul, - UE_template->pre_allocated_rb_table_index_ul, - UE_template->pre_allocated_nb_rb_ul, - UE_template->phr_info, tx_power); - } else { - /* if UE has pending scheduling request then pre-allocate 3 RBs */ - //if (UE_template->ul_active == 1 && UE_template->ul_SR == 1) { - if (UE_is_to_be_scheduled(module_idP, CC_id, i)) { - /* use QPSK mcs */ - UE_template->pre_assigned_mcs_ul = 10; - UE_template->pre_allocated_rb_table_index_ul = 2; - UE_template->pre_allocated_nb_rb_ul = 3; - } else { - UE_template->pre_assigned_mcs_ul = 0; - UE_template->pre_allocated_rb_table_index_ul = -1; - UE_template->pre_allocated_nb_rb_ul = 0; - } - } - } + UE_template->pre_assigned_mcs_ul = mcs; + UE_template->pre_allocated_rb_table_index_ul = rb_table_index; + UE_template->pre_allocated_nb_rb_ul[slice_id] = rb_table[rb_table_index]; + LOG_D(MAC, + "[eNB %d] frame %d subframe %d: for UE %d CC %d: pre-assigned mcs %d, pre-allocated rb_table[%d]=%d RBs (phr %d, tx power %d)\n", + module_idP, frameP, subframeP, UE_id, CC_id, + UE_template->pre_assigned_mcs_ul, + UE_template->pre_allocated_rb_table_index_ul, + UE_template->pre_allocated_nb_rb_ul[slice_id], + UE_template->phr_info, tx_power); + } else { + /* if UE has pending scheduling request then pre-allocate 3 RBs */ + //if (UE_template->ul_active == 1 && UE_template->ul_SR == 1) { + if (UE_is_to_be_scheduled(module_idP, CC_id, i)) { + /* use QPSK mcs */ + UE_template->pre_assigned_mcs_ul = 10; + UE_template->pre_allocated_rb_table_index_ul = 2; + UE_template->pre_allocated_nb_rb_ul[slice_id] = 3; + } else { + UE_template->pre_assigned_mcs_ul = 0; + UE_template->pre_allocated_rb_table_index_ul = -1; + UE_template->pre_allocated_nb_rb_ul[slice_id] = 0; + } + } } + } } struct sort_ue_ul_params { From cf0a5ca9205e2a9fb8650e6c06373257921d2e0f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 9 Feb 2018 19:10:41 +0100 Subject: [PATCH 109/141] fix RAN API due to merge + repair functions --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 2 +- openair2/ENB_APP/flexran_agent_common.c | 4 +-- openair2/ENB_APP/flexran_agent_ran_api.c | 30 +++++++------------ openair2/ENB_APP/flexran_agent_ran_api.h | 10 +++---- 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 4f5d8af250..f875264967 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -83,7 +83,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, goto error; for (j = 0; j < ue_report[i]->n_bsr; j++) { // NN: we need to know the cc_id here, consider the first one - elem[j] = flexran_get_ue_bsr (enb_id, i, j); + elem[j] = flexran_get_ue_bsr_ul_buffer_info (enb_id, i, j); } ue_report[i]->bsr = elem; diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index de0de15c0a..f837d575d5 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -489,10 +489,10 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl lc_config[j]->has_lcid = 1; lc_config[j]->lcid = j+1; - int lcg = flexran_get_lcg(i, j+1); + int lcg = flexran_get_lcg(mod_id, i, j+1); if (lcg >= 0 && lcg <= 3) { lc_config[j]->has_lcg = 1; - lc_config[j]->lcg = flexran_get_lcg(i,j+1); + lc_config[j]->lcg = flexran_get_lcg(mod_id, i,j+1); } lc_config[j]->has_direction = 1; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index ddbc3ad869..97a77a634c 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -117,10 +117,10 @@ rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id) return UE_RNTI(mod_id, ue_id); } -uint8_t flexran_get_ue_bsr(mid_t mod_id, mid_t ue_id, lcid_t lcid) +int flexran_get_ue_bsr_ul_buffer_info(mid_t mod_id, mid_t ue_id, lcid_t lcid) { - if (!mac_is_present(mod_id)) return 0; - return RC.mac[mod_id]->UE_list.UE_template[UE_PCCID(mod_id, ue_id)][ue_id].bsr_info[lcid]; + if (!mac_is_present(mod_id)) return -1; + return RC.mac[mod_id]->UE_list.UE_template[UE_PCCID(mod_id, ue_id)][ue_id].ul_buffer_info[lcid]; } int8_t flexran_get_ue_phr(mid_t mod_id, mid_t ue_id) @@ -390,7 +390,6 @@ PHICH_DURATION_t flexran_get_phich_duration(mid_t mod_id, uint8_t cc_id) int flexran_get_phich_resource(mid_t mod_id, uint8_t cc_id) { if (!phy_is_present(mod_id, cc_id)) return 0; - /* TODO why don't we return phich_resource? */ switch (RC.eNB[mod_id][cc_id]->frame_parms.phich_config_common.phich_resource) { case oneSixth: return 0; @@ -544,12 +543,10 @@ uint8_t flexran_get_sib1_length(mid_t mod_id, uint8_t cc_id) return RC.rrc[mod_id]->carrier[cc_id].sizeof_SIB1; } -uint8_t flexran_get_num_pdcch_symb(mid_t mod_id, uint8_t cc_id) { - /* TODO: This should return the number of PDCCH symbols initially used by the - * cell cc_id -> is the correction right? */ +uint8_t flexran_get_num_pdcch_symb(mid_t mod_id, uint8_t cc_id) +{ if (!phy_is_present(mod_id, cc_id)) return 0; return RC.eNB[mod_id][cc_id]->pdcch_vars[0].num_pdcch_symbols; - //(PHY_vars_UE_g[mod_id][cc_id]->lte_ue_pdcch_vars[mod_id]->num_pdcch_symbols); } @@ -614,12 +611,11 @@ long flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id) } } -/* TODO is there a reason we take the RNTI and not the UE ID? */ -/* TODO return type is unsigned, so we cannot return -1 in case of error! */ -uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti) +uint8_t flexran_get_rrc_status(mid_t mod_id, mid_t ue_id) { if (!rrc_is_present(mod_id)) return 0; + rnti_t rnti = flexran_get_ue_crnti(mod_id, ue_id); struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return RRC_INACTIVE; @@ -893,14 +889,10 @@ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) } } -/* TODO Navid: Get the same for eNB */ -long flexran_get_lcg(mid_t ue_id, mid_t lc_id) +long flexran_get_lcg(mid_t mod_id, mid_t ue_id, mid_t lc_id) { - if (!UE_mac_inst) return -1; - if (!UE_mac_inst[ue_id].logicalChannelConfig[lc_id]) return -1; - if (!UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters) return -1; - if (!UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters->logicalChannelGroup) return -1; - return *(UE_mac_inst[ue_id].logicalChannelConfig[lc_id]->ul_SpecificParameters->logicalChannelGroup); + if (!mac_is_present(mod_id)) return 0; + return RC.mac[mod_id]->UE_list.UE_template[UE_PCCID(mod_id, ue_id)][ue_id].lcgidmap[lc_id]; } /* TODO Navid: needs to be revised */ @@ -923,14 +915,12 @@ uint8_t flexran_get_antenna_ports(mid_t mod_id, uint8_t cc_id) return RC.eNB[mod_id][cc_id]->frame_parms.nb_antenna_ports_eNB; } -/* TODO better give real value (without division)? */ uint32_t flexran_agent_get_operating_dl_freq(mid_t mod_id, uint8_t cc_id) { if (!phy_is_present(mod_id, cc_id)) return 0; return RC.eNB[mod_id][cc_id]->frame_parms.dl_CarrierFreq / 1000000; } -/* TODO better give real value (without division)? */ uint32_t flexran_agent_get_operating_ul_freq(mid_t mod_id, uint8_t cc_id) { if (!phy_is_present(mod_id, cc_id)) return 0; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 62752f1308..b3515c9c6c 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -77,9 +77,9 @@ int flexran_get_num_ues(mid_t mod_id); /* Get the rnti of a UE with id ue_id */ rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id); -/* Get the RLC buffer status report of a ue for a designated - logical channel id */ -uint8_t flexran_get_ue_bsr(mid_t mod_id, mid_t ue_id, lcid_t lcid); +/* Get the RLC buffer status report in bytes of a ue for a designated + * logical channel id */ +int flexran_get_ue_bsr_ul_buffer_info(mid_t mod_id, mid_t ue_id, lcid_t lcid); /* Get power headroom of UE with id ue_id */ int8_t flexran_get_ue_phr(mid_t mod_id, mid_t ue_id); @@ -302,7 +302,7 @@ long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id); int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id); /* Get logical channel group of a channel with id lc_id */ -long flexran_get_lcg(mid_t ue_id, mid_t lc_id); +long flexran_get_lcg(mid_t mod_id, mid_t ue_id, mid_t lc_id); /* Get direction of logical channel with id lc_id */ int flexran_get_direction(mid_t ue_id, mid_t lc_id); @@ -338,7 +338,7 @@ void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type); /*RRC status flexRAN*/ -uint8_t flexran_get_rrc_status(const mid_t mod_id, const rnti_t rntiP); +uint8_t flexran_get_rrc_status(mid_t mod_id, mid_t ue_id); /***************************** PDCP ***********************/ From 8108d59a0bdb2eba243173b5fa8b9548631e617e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 12:10:21 +0100 Subject: [PATCH 110/141] no regression, fixes compilation warnings&errors --- openair2/LAYER2/MAC/pre_processor.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 6d0d56668d..12c80e9efe 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -1422,6 +1422,7 @@ 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); + UE_id = i; if (rnti == NOT_A_RNTI) continue; @@ -1432,8 +1433,6 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, if (flexran_slice_member(UE_id, slice_id) == 0) continue; - UE_id = i; - LOG_D(MAC, "In ulsch_preprocessor: handling UE %d/%x\n", UE_id, rnti); for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { @@ -1528,6 +1527,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, continue; UE_id = i; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { // This is the actual CC_id in the list @@ -1636,8 +1636,12 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth); ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage_uplink[slice_id],N_RB_UL); + int bytes_to_schedule = UE_template->estimated_ul_buffer - UE_template->scheduled_ul_bytes; + if (bytes_to_schedule < 0) bytes_to_schedule = 0; + int bits_to_schedule = bytes_to_schedule * 8; + // if this UE has UL traffic - if (UE_template->ul_total_buffer > 0) { + if (bits_to_schedule > 0) { tbs = get_TBS_UL(mcs, 3) << 3; // 1 or 2 PRB with cqi enabled does not work well! rb_table_index = 2; @@ -1645,7 +1649,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, tx_power = estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, Ncp, 0); while ((((UE_template->phr_info - tx_power) < 0) - || (tbs > UE_template->ul_total_buffer)) + || (tbs > bits_to_schedule)) && (mcs > 3)) { // LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); mcs--; @@ -1654,7 +1658,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, } while ((tbs < bits_to_schedule) - && (rb_table[rb_table_index] < (ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id] - first_rb[CC_id])) + && (rb_table[rb_table_index] < (ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id])) && ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32)) { rb_table_index++; @@ -1664,7 +1668,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, UE_template->ue_tx_power = tx_power; - if (rb_table[rb_table_index] > (ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id] - first_rb[CC_id] - 1)) { + if (rb_table[rb_table_index] > (ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_id] - first_rb[CC_id] - 1)) { rb_table_index--; } // 1 or 2 PRB with cqi enabled does not work well From ceece5694dda2a80f1a36abf18bccd6b6c2b50ef Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 12:30:36 +0100 Subject: [PATCH 111/141] rename flexran_slice_member() -> ue_slice_membership() --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 +- .../LAYER2/MAC/eNB_scheduler_primitives.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/MAC/pre_processor.c | 24 +++++++++---------- openair2/LAYER2/MAC/proto.h | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 7c836c9e72..bed97e47c6 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -710,7 +710,7 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, LOG_D(MAC, "[eNB] Cannot find eNB_UE_stats\n"); continue_flag = 1; } - if (flexran_slice_member(UE_id, slice_idP) == 0) + if (!ue_slice_membership(UE_id, slice_idP)) continue; if (continue_flag != 1) { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 046a823a87..341db67934 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -4050,7 +4050,7 @@ uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs) return (uint16_t) floor(rb_percentage * total_rbs); } -int flexran_slice_member(int UE_id, int slice_id) +int ue_slice_membership(int UE_id, int slice_id) { if ((slice_id < 0) || (slice_id > n_active_slices)) LOG_W(MAC, "out of range slice id %d\n", slice_id); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index b24a3f42ac..2403ec2d13 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1126,7 +1126,7 @@ 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]) { - if (flexran_slice_member(UE_id, slice_id) == 0) + if (!ue_slice_membership(UE_id, slice_id)) continue; // don't schedule if Msg4 is not received yet diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 12c80e9efe..c179c211b2 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -107,7 +107,7 @@ store_dlsch_buffer(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, if (UE_list->active[UE_id] != TRUE) continue; - if (flexran_slice_member(UE_id, slice_id) == 0) + if (!ue_slice_membership(UE_id, slice_id)) continue; UE_template = @@ -201,7 +201,7 @@ assign_rbs_required(module_id_t Mod_id, for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { if (UE_list->active[UE_id] != TRUE) continue; - if (flexran_slice_member(UE_id, slice_id) == 0) + if (!ue_slice_membership(UE_id, slice_id)) continue; pCCid = UE_PCCID(Mod_id, UE_id); @@ -610,7 +610,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, if (UE_list->active[i] != TRUE) continue; - if (!flexran_slice_member(i, slice_id)) + if (!ue_slice_membership(i, slice_id)) continue; UE_id = i; @@ -659,7 +659,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; UE_id = i; - if (flexran_slice_member(UE_id, slice_id) == 0) + if (!ue_slice_membership(UE_id, slice_id)) continue; for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { @@ -698,7 +698,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; UE_id = i; - if (flexran_slice_member(UE_id, slice_id) == 0) + if (!ue_slice_membership(UE_id, slice_id)) continue; for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { @@ -743,7 +743,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; - if (flexran_slice_member(i, slice_id) == 0) + if (!ue_slice_membership(i, slice_id)) continue; for (ii = 0; ii < UE_num_active_CC(UE_list, i); ii++) { @@ -820,7 +820,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, continue; if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) continue; - if (flexran_slice_member(i, slice_id) == 0) + if (!ue_slice_membership(i, slice_id)) continue; transmission_mode = get_tmode(Mod_id, CC_id, UE_id); @@ -1409,7 +1409,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][i]; UE_template = &UE_list->UE_template[CC_id][i]; - if (flexran_slice_member(i, slice_id) == 0) + if (!ue_slice_membership(i, slice_id)) continue; if (UE_template->pre_allocated_nb_rb_ul[slice_id] > 0) { total_ue_count[CC_id] += 1; @@ -1430,7 +1430,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; - if (flexran_slice_member(UE_id, slice_id) == 0) + if (!ue_slice_membership(UE_id, slice_id)) continue; LOG_D(MAC, "In ulsch_preprocessor: handling UE %d/%x\n", UE_id, @@ -1482,7 +1482,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; - if (flexran_slice_member(i, slice_id) == 0) + if (!ue_slice_membership(i, slice_id)) continue; @@ -1523,7 +1523,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; - if (flexran_slice_member(i, slice_id) == 0) + if (!ue_slice_membership(i, slice_id)) continue; UE_id = i; @@ -1605,7 +1605,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; - if (flexran_slice_member(i, slice_id) == 0) + if (!ue_slice_membership(i, slice_id)) continue; if (UE_list->UE_sched_ctrl[i].phr_received == 1) diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index ba13f45e26..c0d294ded6 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -1197,7 +1197,7 @@ int l2_init_ue(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, /*Slice related functions */ uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs); -int flexran_slice_member(int UE_id, int slice_id); +int ue_slice_membership(int UE_id, int slice_id); #endif /** @}*/ From 3768723c62e0bc3871ff211d9ac20e97bcc83fb5 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 12:40:27 +0100 Subject: [PATCH 112/141] remove unnecessary comments --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 1 - openair2/LAYER2/MAC/proto.h | 9 ++------- openair2/RRC/LITE/rrc_eNB.c | 1 - 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index bed97e47c6..fb123134f8 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -541,7 +541,6 @@ schedule_dlsch(module_id_t module_idP, } // Run each enabled slice-specific schedulers one by one - /* TODO Navid took out the dl_info additional information */ slice_sched_dl[i](module_idP, i, frameP, subframeP, mbsfn_flag/*, dl_info*/); } diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index c0d294ded6..be09385ac9 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -38,23 +38,18 @@ /** * slice specific scheduler */ -/* TODO Navid: Protocol__FlexranMessage -> unknown when compiling without - * FlexRAN, what to do with it? Matches schedule_ue_spec now */ typedef void (*slice_scheduler_dl)(module_id_t mod_id, slice_id_t slice_id, frame_t frame, sub_frame_t subframe, - int *mbsfn_flag - /* Protocol__FlexranMessage **dl_info*/); + int *mbsfn_flag); -/* TODO Navid: the same as above, matches schedule_ulsch_rnti now */ typedef void (*slice_scheduler_ul)(module_id_t mod_id, slice_id_t slice_id, frame_t frame, sub_frame_t subframe, unsigned char sched_subframe, - uint16_t *first_rb - /* Protocol__FlexranMessage **ul_info*/); + uint16_t *first_rb); /** \fn void schedule_mib(module_id_t module_idP,frame_t frameP,sub_frame_t subframe); \brief MIB scheduling for PBCH. This function requests the MIB from RRC and provides it to L1. diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 6f35f28ebd..c49b9283e2 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -3362,7 +3362,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons } #if defined(FLEXRAN_AGENT_SB_IF) -/* TODO Navid: does this belong here? */ //----------------------------------------------------------------------------- void flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, From adec4e39df7dcb692c4c4ce27bc6703d2a68ca60 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 14:38:44 +0100 Subject: [PATCH 113/141] remove all conditional FlexRAN-related compilation directives --- common/ran_context.h | 4 ---- openair2/ENB_APP/enb_config.c | 2 -- openair2/ENB_APP/enb_config.h | 2 -- openair2/LAYER2/MAC/eNB_scheduler.c | 6 ------ openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 -- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 -- openair2/RRC/LITE/L2_interface.c | 4 ---- openair2/RRC/LITE/proto.h | 6 ------ openair2/RRC/LITE/rrc_eNB.c | 13 ------------- targets/RT/USER/lte-softmodem.c | 3 +-- targets/RT/USER/lte-softmodem.h | 6 ++---- targets/SIMU/USER/oaisim.c | 4 +--- 12 files changed, 4 insertions(+), 50 deletions(-) diff --git a/common/ran_context.h b/common/ran_context.h index d5e2a1f172..f59fd8a79c 100644 --- a/common/ran_context.h +++ b/common/ran_context.h @@ -40,9 +40,7 @@ #include "PHY/impl_defs_top.h" #include "PHY/impl_defs_lte.h" #include "RRC/LITE/defs.h" -#ifdef FLEXRAN_AGENT_SB_IF #include "flexran_agent_defs.h" -#endif #include "gtpv1u.h" #include "NwGtpv1u.h" @@ -67,10 +65,8 @@ typedef struct { int *nb_L1_CC; /// Number of RU instances in this node int nb_RU; -#ifdef FLEXRAN_AGENT_SB_IF /// FlexRAN context variables flexran_agent_info_t **flexran; -#endif /// eNB context variables struct PHY_VARS_eNB_s ***eNB; /// RRC context variables diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index d6f676b83a..1bf2807e81 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -98,7 +98,6 @@ static int enb_check_band_frequencies(char* lib_config_file_name_pP, return errors; } -#ifdef FLEXRAN_AGENT_SB_IF void RCconfig_flexran() { int i; @@ -134,7 +133,6 @@ void RCconfig_flexran() /* TODO: show FlexRAN config now? */ } -#endif void RCconfig_L1(void) { int i,j; diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h index 4e4434ad70..42bef9c4e9 100644 --- a/openair2/ENB_APP/enb_config.h +++ b/openair2/ENB_APP/enb_config.h @@ -94,9 +94,7 @@ typedef struct ru_config_s { } ru_config_t; extern void RCconfig_RU(void); -#ifdef FLEXRAN_AGENT_SB_IF extern void RCconfig_flexran(void); -#endif extern void RCconfig_L1(void); extern void RCconfig_macrlc(void); extern int RCconfig_gtpu(void ); diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 0e2f84b25b..45c1a422dd 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -52,11 +52,9 @@ //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" -#if defined(FLEXRAN_AGENT_SB_IF) //Agent-related headers #include "flexran_agent_extern.h" #include "flexran_agent_mac.h" -#endif #if defined(ENABLE_ITTI) #include "intertask_interface.h" @@ -419,12 +417,10 @@ check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, } // ul_failure_timer>0 //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future -#if defined(FLEXRAN_AGENT_SB_IF) if (rrc_agent_registered[module_idP]) { agent_rrc_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP, rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); } -#endif UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer++; if(UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer > (U_PLANE_INACTIVITY_VALUE*subframe_num(&RC.eNB[module_idP][CC_id]->frame_parms))){ @@ -661,9 +657,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, // This schedules DLSCH in subframeP schedule_dlsch(module_idP, frameP, subframeP, mbsfn_status); -#if defined(FLEXRAN_AGENT_SB_IF) flexran_agent_send_update_stats(module_idP); -#endif // Allocate CCEs for good after scheduling is done for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index fb123134f8..0936a9d0ef 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -57,12 +57,10 @@ #include "intertask_interface.h" #endif -#if defined FLEXRAN_AGENT_SB_IF #include "ENB_APP/flexran_agent_defs.h" #include "flexran_agent_ran_api.h" #include "header.pb-c.h" #include "flexran.pb-c.h" -#endif #include #include "T.h" diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 2403ec2d13..47b6a075cf 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -57,13 +57,11 @@ #include "intertask_interface.h" #endif -#if defined FLEXRAN_AGENT_SB_IF #include "ENB_APP/flexran_agent_defs.h" #include "flexran_agent_ran_api.h" #include "header.pb-c.h" #include "flexran.pb-c.h" #include "flexran_agent_mac.h" -#endif #include #include "T.h" diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index f285330854..91834d9c9d 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -53,9 +53,7 @@ extern UE_MAC_INST *UE_mac_inst; # include "intertask_interface.h" #endif -#if defined(FLEXRAN_AGENT_SB_IF) #include "flexran_agent_extern.h" -#endif //#define RRC_DATA_REQ_DEBUG //#define DEBUG_RRC 1 @@ -470,13 +468,11 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, else { LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP); } -#if defined(FLEXRAN_AGENT_SB_IF) if (rrc_agent_registered[Mod_instP]) { agent_rrc_xface[Mod_instP]->flexran_agent_notify_ue_state_change(Mod_instP, rntiP, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); } -#endif // rrc_mac_remove_ue(Mod_instP,rntiP); } diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h index 0f5ccdef1b..9ece5bcfdd 100644 --- a/openair2/RRC/LITE/proto.h +++ b/openair2/RRC/LITE/proto.h @@ -33,9 +33,7 @@ #include "RRC/LITE/defs.h" -#if defined(FLEXRAN_AGENT_SB_IF) #include "flexran_agent_extern.h" -#endif //main.c int rrc_init_global_param(void); @@ -274,8 +272,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( ); -#if defined(FLEXRAN_AGENT_SB_IF) - void flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration( const protocol_ctxt_t* const ctxt_pP, @@ -284,8 +280,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration( agent_reconf_rrc * trig_param ); -#endif - int freq_to_arfcn10(int band, unsigned long freq); void diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index c49b9283e2..2c8be5cfc6 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -871,12 +871,10 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* } } -#if defined(FLEXRAN_AGENT_SB_IF) if (rrc_agent_registered[enb_mod_idP]) { agent_rrc_xface[enb_mod_idP]->flexran_agent_notify_ue_state_change(enb_mod_idP, rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); } -#endif for(j = 0; j < 10; j++){ ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; @@ -3361,7 +3359,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons PDCP_TRANSMISSION_MODE_CONTROL); } -#if defined(FLEXRAN_AGENT_SB_IF) //----------------------------------------------------------------------------- void flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, @@ -3952,8 +3949,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt PDCP_TRANSMISSION_MODE_CONTROL); } -#endif - //----------------------------------------------------------------------------- int @@ -6294,13 +6289,11 @@ rrc_eNB_decode_ccch( } else { // no context available -#if defined(FLEXRAN_AGENT_SB_IF) if (rrc_agent_registered[ctxt_pP->module_id]) { agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, ctxt_pP->rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); } -#endif 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), random_value); @@ -6562,14 +6555,12 @@ rrc_eNB_decode_dcch( ue_context_p, ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); -#if defined(FLEXRAN_AGENT_SB_IF) //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future if (rrc_agent_registered[ctxt_pP->module_id]) { agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, ue_context_p->ue_id_rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED); } -#endif } #if defined(ENABLE_ITTI) # if defined(ENABLE_USE_MME) @@ -6704,14 +6695,12 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.rrc_TransactionIdentifier, &ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.choice.rrcConnectionReestablishmentComplete_r8); -#if defined(FLEXRAN_AGENT_SB_IF) //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future if (mac_agent_registered[ctxt_pP->module_id]) { agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, ue_context_p->ue_id_rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); } -#endif } //ue_context_p->ue_context.ue_release_timer = 0; ue_context_p->ue_context.ue_reestablishment_timer = 1; @@ -6761,14 +6750,12 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); -#if defined(FLEXRAN_AGENT_SB_IF) //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future if (rrc_agent_registered[ctxt_pP->module_id]) { agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, ue_context_p->ue_id_rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); } -#endif } } diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 42a4a7c950..f6789086b4 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1319,12 +1319,11 @@ int main( int argc, char **argv ) } #endif -#ifdef FLEXRAN_AGENT_SB_IF + /* Start the agent. If it is turned off in the configuration, it won't start */ RCconfig_flexran(); for (i = 0; i < RC.nb_L1_inst; i++) { flexran_agent_start(i); } -#endif // init UE_PF_PO and mutex lock pthread_mutex_init(&ue_pf_po_mutex, NULL); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index d8f6e3c7e9..5cc4d5fea2 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -31,6 +31,8 @@ #include "PHY/defs.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" +#include "flexran_agent.h" + #if defined(ENABLE_ITTI) #if defined(ENABLE_USE_MME) #include "s1ap_eNB.h" @@ -271,8 +273,4 @@ void init_eNB_afterRU(void); extern int stop_L1L2(module_id_t enb_id); extern int restart_L1L2(module_id_t enb_id); -#ifdef FLEXRAN_AGENT_SB_IF -#include "flexran_agent.h" -#endif - #endif diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 7d8b33f12c..302b77b60f 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -76,9 +76,7 @@ uint8_t config_smbv = 0; char smbv_ip[16]; #endif -#if defined(FLEXRAN_AGENT_SB_IF) -# include "flexran_agent.h" -#endif +#include "flexran_agent.h" #include "oaisim_functions.h" From 219b5bc92f25bca7203ac42bc3203381170cb50b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 15:11:19 +0100 Subject: [PATCH 114/141] make FlexRAN Agent activation configurable --- openair2/ENB_APP/enb_config.c | 7 ++----- openair2/ENB_APP/enb_paramdef.h | 13 ++++++++----- openair2/ENB_APP/flexran_agent.c | 6 ++++++ openair2/ENB_APP/flexran_agent_defs.h | 1 + 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 1bf2807e81..a30dc28c94 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -119,19 +119,16 @@ void RCconfig_flexran() AssertFatal(RC.flexran[i] != NULL, "can't ALLOCATE %zu Bytes for flexran agent info (iteration %d/%d)\n", sizeof(flexran_agent_info_t), i + 1, RC.nb_L1_inst); + /* if config says "yes", enable Agent, in all other cases it's like "no" */ + RC.flexran[i]->enabled = strcmp(*(flexranParams[FLEXRAN_ENABLED].strptr), "yes") == 0; RC.flexran[i]->interface_name = strdup(*(flexranParams[FLEXRAN_INTERFACE_NAME_IDX].strptr)); //inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN); - //strcpy(in_ip, DEFAULT_FLEXRAN_AGENT_IPv4_ADDRESS ); RC.flexran[i]->remote_ipv4_addr = strdup(*(flexranParams[FLEXRAN_IPV4_ADDRESS_IDX].strptr)); - // DEFAULT_FLEXRAN_AGENT_PORT RC.flexran[i]->remote_port = *(flexranParams[FLEXRAN_PORT_IDX].uptr); - // DEFAULT_FLEXRAN_AGENT_CACHE RC.flexran[i]->cache_name = strdup(*(flexranParams[FLEXRAN_CACHE_IDX].strptr)); RC.flexran[i]->node_ctrl_state = strcmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0 ? ENB_WAIT : ENB_NORMAL_OPERATION; RC.flexran[i]->enb_id = i; } - - /* TODO: show FlexRAN config now? */ } void RCconfig_L1(void) { diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 0203380314..2d65e09b58 100755 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -613,19 +613,22 @@ static int DEFENBS[] = {0}; /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CONFIG_STRING_NETWORK_CONTROLLER_CONFIG "NETWORK_CONTROLLER" +#define CONFIG_STRING_FLEXRAN_ENABLED "FLEXRAN_ENABLED" #define CONFIG_STRING_FLEXRAN_INTERFACE_NAME "FLEXRAN_INTERFACE_NAME" #define CONFIG_STRING_FLEXRAN_IPV4_ADDRESS "FLEXRAN_IPV4_ADDRESS" #define CONFIG_STRING_FLEXRAN_PORT "FLEXRAN_PORT" #define CONFIG_STRING_FLEXRAN_CACHE "FLEXRAN_CACHE" #define CONFIG_STRING_FLEXRAN_AWAIT_RECONF "FLEXRAN_AWAIT_RECONF" -#define FLEXRAN_INTERFACE_NAME_IDX 0 -#define FLEXRAN_IPV4_ADDRESS_IDX 1 -#define FLEXRAN_PORT_IDX 2 -#define FLEXRAN_CACHE_IDX 3 -#define FLEXRAN_AWAIT_RECONF_IDX 4 +#define FLEXRAN_ENABLED 0 +#define FLEXRAN_INTERFACE_NAME_IDX 1 +#define FLEXRAN_IPV4_ADDRESS_IDX 2 +#define FLEXRAN_PORT_IDX 3 +#define FLEXRAN_CACHE_IDX 4 +#define FLEXRAN_AWAIT_RECONF_IDX 5 #define FLEXRANPARAMS_DESC { \ +{CONFIG_STRING_FLEXRAN_ENABLED, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \ {CONFIG_STRING_FLEXRAN_INTERFACE_NAME, NULL, 0, strptr:NULL, defstrval:"lo", TYPE_STRING, 0}, \ {CONFIG_STRING_FLEXRAN_IPV4_ADDRESS, NULL, 0, strptr:NULL, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ {CONFIG_STRING_FLEXRAN_PORT, NULL, 0, uptr:NULL, defintval:2210, TYPE_UINT, 0}, \ diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index d32f3e660f..bd46ecc49d 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -184,6 +184,12 @@ int flexran_agent_start(mid_t mod_id) int channel_id; char *in_ip = flexran->remote_ipv4_addr; uint16_t in_port = flexran->remote_port; + + /* if this agent is disabled, return and don't do anything */ + if (!flexran->enabled) { + LOG_I(FLEXRAN_AGENT, "FlexRAN Agent for eNB %d is DISABLED\n", mod_id); + return 100; + } flexran->enb_id = mod_id; /* assume for the moment the monolithic case, i.e. agent can provide diff --git a/openair2/ENB_APP/flexran_agent_defs.h b/openair2/ENB_APP/flexran_agent_defs.h index fd22b01e61..6364bc6281 100644 --- a/openair2/ENB_APP/flexran_agent_defs.h +++ b/openair2/ENB_APP/flexran_agent_defs.h @@ -153,6 +153,7 @@ typedef enum { typedef struct { /* general info */ + int enabled; char *interface_name; char *remote_ipv4_addr; uint16_t remote_port; From 1056604b25eb8ba2e0469842818d1a8dc26e1b72 Mon Sep 17 00:00:00 2001 From: Emad Date: Mon, 12 Feb 2018 13:56:08 +0100 Subject: [PATCH 115/141] I tried to change rx and tx attenuation by the config file, but they are not changed. The bug is because att_rx and att_tx do not put in RC.rru when local_rf is "yes" in config file. We need to put att_rx and att_rx for both local_rf = "yes" and "no". Also RF config which send to RF device must be fill by this parameters. --- targets/RT/USER/lte-ru.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 65d945dd7e..d2455266ce 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1273,8 +1273,8 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->tx_freq[i] = (double)fp->dl_CarrierFreq; cfg->rx_freq[i] = (double)fp->ul_CarrierFreq; - cfg->tx_gain[i] = (double)fp->att_tx; - cfg->rx_gain[i] = ru->max_rxgain-(double)fp->att_rx; + cfg->tx_gain[i] = ru->att_tx; + cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx; cfg->configFilename = rf_config_file; printf("channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", @@ -2256,13 +2256,13 @@ void RCconfig_RU(void) { RC.ru[j]->if_timing = synch_to_other; RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF5_MOBIPASS; } - RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); - RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); } /* strcmp(local_rf, "yes") != 0 */ RC.ru[j]->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); RC.ru[j]->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); + RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); }// j=0..num_rus } else { RC.nb_RU = 0; From 135b06ae66ab485a1cd0ca7945a57e3a6675f664 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 15:21:02 +0100 Subject: [PATCH 116/141] bugfix: only send eNB stats to controller if agent enabled --- openair2/LAYER2/MAC/eNB_scheduler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 45c1a422dd..fb4fd6553b 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -657,7 +657,8 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, // This schedules DLSCH in subframeP schedule_dlsch(module_idP, frameP, subframeP, mbsfn_status); - flexran_agent_send_update_stats(module_idP); + if (RC.flexran[module_idP]->enabled) + flexran_agent_send_update_stats(module_idP); // Allocate CCEs for good after scheduling is done for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) From 54e803e71a3647f3e109e74cf75de9cc01eed8d3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 15:21:44 +0100 Subject: [PATCH 117/141] Sample configuration FlexRAN: Agent is disabled --- .../GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf index 227decbcd6..c4307f8ff2 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf @@ -191,6 +191,7 @@ RUs = ( NETWORK_CONTROLLER : { + FLEXRAN_ENABLED = "no"; FLEXRAN_INTERFACE_NAME = "lo"; FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; FLEXRAN_PORT = 2210; From 6210eb056f880a52edfe9de64c6839154a5c7429 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 12 Feb 2018 15:26:45 +0100 Subject: [PATCH 118/141] bugfix: fix ue_ip.ko compilation Not sure that the use of __KERNEL__ is the correct solution. To be checked at some point. After this commit, the following works: ./build_oai --UE -c --- cmake_targets/CMakeLists.txt | 2 +- common/utils/itti/itti_types.h | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 616adf3a82..31b3f8e4c7 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2297,7 +2297,7 @@ add_custom_command ( # retrieve the compiler options to send it to gccxml get_directory_property(DirDefs COMPILE_DEFINITIONS ) foreach( d ${DirDefs} ) - set(module_cc_opt_tmp "${module_cc_opt_tmp} -D${d}") + set(module_cc_opt "${module_cc_opt} -D${d}") endforeach() get_directory_property( DirDefs INCLUDE_DIRECTORIES ) foreach( d ${DirDefs} ) diff --git a/common/utils/itti/itti_types.h b/common/utils/itti/itti_types.h index d07853133b..2607c003b1 100644 --- a/common/utils/itti/itti_types.h +++ b/common/utils/itti/itti_types.h @@ -27,7 +27,18 @@ #ifndef _ITTI_TYPES_H_ #define _ITTI_TYPES_H_ -#include +/* The current file is included in the ue_ip.ko compilation. + * For it to work we need to include linux/types.h and + * not stdint.h. + * A solution to this problem is to use #ifndef __KERNEL__. + * Maybe a better solution would be to clean things up + * so that ue_ip.ko does not include the current file. + */ +#ifndef __KERNEL__ +# include +#else +# include +#endif #define CHARS_TO_UINT32(c1, c2, c3, c4) (((c4) << 24) | ((c3) << 16) | ((c2) << 8) | (c1)) From 4bf4ad8e98b4a9d920e165cf46c38ec4ddea3608 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 15:30:30 +0100 Subject: [PATCH 119/141] change build scripts: always compile FlexRAN --- cmake_targets/CMakeLists.txt | 158 +++++++++++++++++------------------ cmake_targets/build_oai | 23 +---- 2 files changed, 81 insertions(+), 100 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 44d80d4633..56c3ea651b 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -599,8 +599,6 @@ add_boolean_option(MESSAGE_CHART_GENERATOR False "For generating sequenc add_boolean_option(MESSAGE_CHART_GENERATOR_RLC_MAC False "trace RLC-MAC exchanges in sequence diagrams") add_boolean_option(MESSAGE_CHART_GENERATOR_PHY False "trace some PHY exchanges in sequence diagrams") -add_boolean_option(FLEXRAN_AGENT_SB_IF False "enable FlexRAN agent to inteface with a SDN controller") - ######################## # Include order ########################## @@ -789,96 +787,94 @@ include_directories("${OPENAIR_DIR}") # Utilities Library ################ -if (FLEXRAN_AGENT_SB_IF) - # set the version of protobuf messages, V3 not supported yet - add_list1_option(FLPT_VERSION V2 "FLPT MSG protobuf grammar version" V2 V3) +# set the version of protobuf messages, V3 not supported yet +add_list1_option(FLPT_VERSION V2 "FLPT MSG protobuf grammar version" V2 V3) - if (${FLPT_VERSION} STREQUAL "V2") - set (FLPTDIR V2) - elseif (${FLPT_VERSION} STREQUAL "V3") - set (FLPTDIR V3) - endif(${FLPT_VERSION} STREQUAL "V2") +if (${FLPT_VERSION} STREQUAL "V2") + set (FLPTDIR V2) +elseif (${FLPT_VERSION} STREQUAL "V3") + set (FLPTDIR V3) +endif(${FLPT_VERSION} STREQUAL "V2") - set(FLPT_MSG_DIR ${OPENAIR2_DIR}/ENB_APP/MESSAGES/${FLPTDIR} ) - set(FLPT_MSG_FILES - ${FLPT_MSG_DIR}/header.proto - ${FLPT_MSG_DIR}/flexran.proto - ${FLPT_MSG_DIR}/stats_common.proto - ${FLPT_MSG_DIR}/stats_messages.proto - ${FLPT_MSG_DIR}/time_common.proto - ${FLPT_MSG_DIR}/controller_commands.proto - ${FLPT_MSG_DIR}/mac_primitives.proto - ${FLPT_MSG_DIR}/config_messages.proto - ${FLPT_MSG_DIR}/config_common.proto - ${FLPT_MSG_DIR}/control_delegation.proto - ) +set(FLPT_MSG_DIR ${OPENAIR2_DIR}/ENB_APP/MESSAGES/${FLPTDIR} ) +set(FLPT_MSG_FILES + ${FLPT_MSG_DIR}/header.proto + ${FLPT_MSG_DIR}/flexran.proto + ${FLPT_MSG_DIR}/stats_common.proto + ${FLPT_MSG_DIR}/stats_messages.proto + ${FLPT_MSG_DIR}/time_common.proto + ${FLPT_MSG_DIR}/controller_commands.proto + ${FLPT_MSG_DIR}/mac_primitives.proto + ${FLPT_MSG_DIR}/config_messages.proto + ${FLPT_MSG_DIR}/config_common.proto + ${FLPT_MSG_DIR}/control_delegation.proto + ) - set(FLPT_C_DIR ${protobuf_generated_dir}/${FLPTDIR}) - #message("calling protoc_call=${protoc_call} FLPT_C_DIR=${FLPT_C_DIR} FLPT_MSG_FILES=${FLPT_MSG_FILES}") - execute_process(COMMAND ${protoc_call} ${FLPT_C_DIR} ${FLPT_MSG_DIR} ${FLPT_MSG_FILES}) - file(GLOB FLPT_source ${FLPT_C_DIR}/*.c) - set(FLPT_OAI_generated - ${FLPT_C_DIR}/header.pb-c.c - ${FLPT_C_DIR}/flexran.pb-c.c - ${FLPT_C_DIR}/stats_common.pb-c.c - ${FLPT_C_DIR}/stats_messages.pb-c.c - ${FLPT_C_DIR}/time_common.pb-c.c - ${FLPT_C_DIR}/controller_commands.pb-c.c - ${FLPT_C_DIR}/mac_primitives.pb-c.c - ${FLPT_C_DIR}/config_messages.pb-c.c - ${FLPT_C_DIR}/config_common.pb-c.c - ${FLPT_C_DIR}/control_delegation.pb-c.c - ) +set(FLPT_C_DIR ${protobuf_generated_dir}/${FLPTDIR}) +#message("calling protoc_call=${protoc_call} FLPT_C_DIR=${FLPT_C_DIR} FLPT_MSG_FILES=${FLPT_MSG_FILES}") +execute_process(COMMAND ${protoc_call} ${FLPT_C_DIR} ${FLPT_MSG_DIR} ${FLPT_MSG_FILES}) +file(GLOB FLPT_source ${FLPT_C_DIR}/*.c) +set(FLPT_OAI_generated + ${FLPT_C_DIR}/header.pb-c.c + ${FLPT_C_DIR}/flexran.pb-c.c + ${FLPT_C_DIR}/stats_common.pb-c.c + ${FLPT_C_DIR}/stats_messages.pb-c.c + ${FLPT_C_DIR}/time_common.pb-c.c + ${FLPT_C_DIR}/controller_commands.pb-c.c + ${FLPT_C_DIR}/mac_primitives.pb-c.c + ${FLPT_C_DIR}/config_messages.pb-c.c + ${FLPT_C_DIR}/config_common.pb-c.c + ${FLPT_C_DIR}/control_delegation.pb-c.c + ) - file(GLOB flpt_h ${FLPT_C_DIR}/*.h) - set(flpt_h ${flpt_h} ) +file(GLOB flpt_h ${FLPT_C_DIR}/*.h) +set(flpt_h ${flpt_h} ) - add_library(FLPT_MSG - ${FLPT_OAI_generated} - ${FLPT_source} - ) - set(FLPT_MSG_LIB FLPT_MSG) - #message("prpt c dir is : ${FLPT_C_DIR}") - include_directories (${FLPT_C_DIR}) +add_library(FLPT_MSG + ${FLPT_OAI_generated} + ${FLPT_source} + ) +set(FLPT_MSG_LIB FLPT_MSG) +#message("prpt c dir is : ${FLPT_C_DIR}") +include_directories (${FLPT_C_DIR}) - add_library(ASYNC_IF - ${OPENAIR2_DIR}/UTIL/ASYNC_IF/socket_link.c - ${OPENAIR2_DIR}/UTIL/ASYNC_IF/link_manager.c - ${OPENAIR2_DIR}/UTIL/ASYNC_IF/message_queue.c - ${OPENAIR2_DIR}/UTIL/ASYNC_IF/ringbuffer_queue.c - ) - set(ASYNC_IF_LIB ASYNC_IF) - include_directories(${OPENAIR2_DIR}/UTIL/ASYNC_IF) +add_library(ASYNC_IF + ${OPENAIR2_DIR}/UTIL/ASYNC_IF/socket_link.c + ${OPENAIR2_DIR}/UTIL/ASYNC_IF/link_manager.c + ${OPENAIR2_DIR}/UTIL/ASYNC_IF/message_queue.c + ${OPENAIR2_DIR}/UTIL/ASYNC_IF/ringbuffer_queue.c + ) +set(ASYNC_IF_LIB ASYNC_IF) +include_directories(${OPENAIR2_DIR}/UTIL/ASYNC_IF) - add_library(FLEXRAN_AGENT - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_handler.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_common.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_ran_api.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_timer.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_common_internal.c - ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c - ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c - ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_task_manager.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_net_comm.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_async.c - ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c - ) - set(FLEXRAN_AGENT_LIB FLEXRAN_AGENT) - #include_directories(${OPENAIR2_DIR}/ENB_APP) +add_library(FLEXRAN_AGENT + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_handler.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_common.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_ran_api.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_timer.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_common_internal.c + ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c + ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c + ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_task_manager.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_net_comm.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_async.c + ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c + ) +set(FLEXRAN_AGENT_LIB FLEXRAN_AGENT) +#include_directories(${OPENAIR2_DIR}/ENB_APP) - set(PROTOBUF_LIB "protobuf-c") +set(PROTOBUF_LIB "protobuf-c") - FIND_PATH(LIBYAML_INCLUDE_DIR NAMES yaml.h) - FIND_LIBRARY(LIBYAML_LIBRARIES NAMES yaml libyaml) +FIND_PATH(LIBYAML_INCLUDE_DIR NAMES yaml.h) +FIND_LIBRARY(LIBYAML_LIBRARIES NAMES yaml libyaml) - INCLUDE(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Yaml DEFAULT_MSG LIBYAML_LIBRARIES LIBYAML_INCLUDE_DIR) - MARK_AS_ADVANCED(LIBYAML_INCLUDE_DIR LIBYAML_LIBRARIES) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Yaml DEFAULT_MSG LIBYAML_LIBRARIES LIBYAML_INCLUDE_DIR) +MARK_AS_ADVANCED(LIBYAML_INCLUDE_DIR LIBYAML_LIBRARIES) - #set(PROTOBUF_LIB "protobuf") #for Cpp -endif() +#set(PROTOBUF_LIB "protobuf") #for Cpp add_library(HASHTABLE diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 0d48f51df9..7e0c0ca169 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -42,7 +42,6 @@ conf_nvram_path=$OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf MSC_GEN="False" XFORMS="True" -FLEXRAN_AGENT_SB_IF="True" PRINT_STATS="False" VCD_TIMING="False" DEADLINE_SCHEDULER_FLAG_USER="False" @@ -100,8 +99,6 @@ Options Specify conf_nvram_path (default \"$conf_nvram_path\") --UE-gen-nvram [output path] Specify gen_nvram_path (default \"$gen_nvram_path\") --a | --agent - Enables agent for software-defined control of the eNB -r | --3gpp-release default is Rel14, Rel8 limits the implementation to 3GPP Release 8 version @@ -204,8 +201,7 @@ function main() { echo_info "Will compile eNB" shift;; -a | --agent) - FLEXRAN_AGENT=1 - echo_info "Will compile eNB with agent support" + echo_info "FlexRAN support is always compiled into the eNB" shift;; --UE) UE=1 @@ -465,11 +461,9 @@ function main() { flash_firmware_bladerf fi fi - if [ "$FLEXRAN_AGENT" == "1" ] ; then - echo_info "installing protobuf/protobuf-c for flexran agent support" - install_protobuf_from_source - install_protobuf_c_from_source - fi + echo_info "installing protobuf/protobuf-c for flexran agent support" + install_protobuf_from_source + install_protobuf_c_from_source fi if [ "$INSTALL_OPTIONAL" = "1" ] ; then @@ -517,9 +511,6 @@ function main() { echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file echo "set ( XFORMS $XFORMS )" >> $cmake_file - if [ "$FLEXRAN_AGENT" = "1" ] ; then - echo "set ( FLEXRAN_AGENT_SB_IF $FLEXRAN_AGENT_SB_IF )" >> $cmake_file - fi echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file echo "set ( RF_BOARD \"${HW}\")" >> $cmake_file @@ -679,9 +670,6 @@ function main() { echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file echo "set ( XFORMS $XFORMS )" >> $cmake_file - if [ "$FLEXRAN_AGENT" = "1" ] ; then - echo "set ( FLEXRAN_AGENT_SB_IF $FLEXRAN_AGENT_SB_IF )" >> $cmake_file - fi echo "set ( PRINT_STATS $PRINT_STATS )" >> $cmake_file echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file @@ -762,9 +750,6 @@ function main() { cp $DIR/oaisim_mme_build_oai/CMakeLists.template $cmake_file echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file echo "set ( XFORMS $XFORMS )" >> $cmake_file - if [ "$FLEXRAN_AGENT" = "1" ] ; then - echo "set ( FLEXRAN_AGENT_SB_IF $FLEXRAN_AGENT_SB_IF )" >> $cmake_file - fi echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file echo "set ( T_TRACER $T_TRACER )" >> $cmake_file From ddd3e97f141917e7868a953b918915f6cdb11d94 Mon Sep 17 00:00:00 2001 From: Emad Date: Thu, 8 Feb 2018 07:54:47 +0100 Subject: [PATCH 120/141] srb_id must be between [1,3] --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 91621ab50f..bb264a8906 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -993,7 +993,7 @@ pdcp_remove_UE( } } - for (srb_id=0; srb_id<2; srb_id++) { + for (srb_id=1; srb_id<3; srb_id++) { 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); } From e794f920c73ff0d891ae8c3033027be9d649a2ab Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 12 Feb 2018 16:13:04 +0100 Subject: [PATCH 121/141] integration fix: remove definition of OAI_NW_DRIVER_USE_NETLINK in source file This is done better by commit 6210eb056f880a52edfe9de64c6839154a5c7429. --- openair2/NETWORK_DRIVER/UE_IP/local.h | 1 - 1 file changed, 1 deletion(-) diff --git a/openair2/NETWORK_DRIVER/UE_IP/local.h b/openair2/NETWORK_DRIVER/UE_IP/local.h index 15fa7a0f91..ac3b040995 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/local.h +++ b/openair2/NETWORK_DRIVER/UE_IP/local.h @@ -57,7 +57,6 @@ #include "platform_types.h" #include "sap.h" -#define OAI_NW_DRIVER_USE_NETLINK 1 typedef struct ue_ip_priv_s { int irq; From 5865c141d03a89aed04c8496cd2b260e1800b017 Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Tue, 13 Feb 2018 11:45:16 +0100 Subject: [PATCH 122/141] Improve UL/DL MCS assignment --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 8 ++++---- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 8 ++++---- openair2/LAYER2/MAC/pre_processor.c | 24 ++++++++++++----------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 0936a9d0ef..7d0a93c2bf 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -789,12 +789,12 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); */ if (nfapi_mode) { - eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; } - else { - eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + else { // this operation is also done in the preprocessor + eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, slice_maxmcs[slice_idP]); //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); } - eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, slice_maxmcs[slice_idP]); //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); + // store stats diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 47b6a075cf..a8d686dac9 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1289,11 +1289,11 @@ schedule_ulsch_rnti(module_id_t module_idP, ndi = 1 - UE_template->oldNDI_UL[harq_pid]; UE_template->oldNDI_UL[harq_pid] = ndi; - UE_list->eNB_UE_stats[CC_id][UE_id]. - normalized_rx_power = normalized_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power = normalized_rx_power; UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power = target_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1 = UE_template->pre_assigned_mcs_ul; - UE_template->mcs_UL[harq_pid] = cmin(UE_template->pre_assigned_mcs_ul, slice_maxmcs_uplink[slice_id]);//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + UE_template->mcs_UL[harq_pid] = cmin(UE_template->pre_assigned_mcs_ul, slice_maxmcs_uplink[slice_id]); + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1= UE_template->mcs_UL[harq_pid]; + //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) { rb_table_index = UE_template->pre_allocated_rb_table_index_ul; } else { diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index c179c211b2..3a27f70009 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -60,6 +60,10 @@ extern float slice_percentage[MAX_NUM_SLICES]; extern float slice_percentage_uplink[MAX_NUM_SLICES]; +extern int slice_maxmcs[MAX_NUM_SLICES]; +extern int slice_maxmcs_uplink[MAX_NUM_SLICES]; + + //#define ICIC 0 /* this function checks that get_eNB_UE_stats returns @@ -211,8 +215,8 @@ assign_rbs_required(module_id_t Mod_id, CC_id = UE_list->ordered_CCids[n][UE_id]; eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - eNB_UE_stats->dlsch_mcs1 = - cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; + eNB_UE_stats->dlsch_mcs1 =cmin(cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]], + slice_maxmcs[slice_id]); } @@ -1585,7 +1589,6 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, uint16_t n, UE_id; uint8_t CC_id; rnti_t rnti = -1; - int mcs; int rb_table_index = 0, tbs, tx_power; eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_list_t *UE_list = &eNB->UE_list; @@ -1609,9 +1612,9 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, continue; if (UE_list->UE_sched_ctrl[i].phr_received == 1) - mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs + UE_template->pre_assigned_mcs_ul = cmin(20, slice_maxmcs_uplink[slice_id]); // if we've received the power headroom information the UE, we can go to maximum mcs else - mcs = 10; // otherwise, limit to QPSK PUSCH + UE_template->pre_assigned_mcs_ul = cmin(10, slice_maxmcs_uplink[slice_id]); // otherwise, limit to QPSK PUSCH UE_id = i; @@ -1642,7 +1645,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, // if this UE has UL traffic if (bits_to_schedule > 0) { - tbs = get_TBS_UL(mcs, 3) << 3; // 1 or 2 PRB with cqi enabled does not work well! + tbs = get_TBS_UL(UE_template->pre_assigned_mcs_ul, 3) << 3; // 1 or 2 PRB with cqi enabled does not work well! rb_table_index = 2; // fixme: set use_srs flag @@ -1650,10 +1653,10 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, while ((((UE_template->phr_info - tx_power) < 0) || (tbs > bits_to_schedule)) - && (mcs > 3)) { + && (UE_template->pre_assigned_mcs_ul > 3)) { // LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); - mcs--; - tbs = get_TBS_UL(mcs, rb_table[rb_table_index]) << 3; + UE_template->pre_assigned_mcs_ul--; + tbs = get_TBS_UL(UE_template->pre_assigned_mcs_ul, rb_table[rb_table_index]) << 3; tx_power = estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, Ncp, 0); // fixme: set use_srs } @@ -1662,7 +1665,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, && ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32)) { rb_table_index++; - tbs = get_TBS_UL(mcs, rb_table[rb_table_index]) << 3; + tbs = get_TBS_UL(UE_template->pre_assigned_mcs_ul, rb_table[rb_table_index]) << 3; tx_power = estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, Ncp, 0); } @@ -1676,7 +1679,6 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, rb_table_index = 2; //3PRB } - UE_template->pre_assigned_mcs_ul = mcs; UE_template->pre_allocated_rb_table_index_ul = rb_table_index; UE_template->pre_allocated_nb_rb_ul[slice_id] = rb_table[rb_table_index]; LOG_D(MAC, From a68d70a13d2768fdfb6eb6614d403eccde48e0c4 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 13 Feb 2018 14:23:54 +0100 Subject: [PATCH 123/141] bugfix: prevent segfault in pre_processor.c --- openair2/LAYER2/MAC/pre_processor.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 3a27f70009..8f7a6bddff 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -1589,6 +1589,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, uint16_t n, UE_id; uint8_t CC_id; rnti_t rnti = -1; + int mcs; int rb_table_index = 0, tbs, tx_power; eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_list_t *UE_list = &eNB->UE_list; @@ -1611,10 +1612,14 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, if (!ue_slice_membership(i, slice_id)) continue; - if (UE_list->UE_sched_ctrl[i].phr_received == 1) - UE_template->pre_assigned_mcs_ul = cmin(20, slice_maxmcs_uplink[slice_id]); // if we've received the power headroom information the UE, we can go to maximum mcs - else - UE_template->pre_assigned_mcs_ul = cmin(10, slice_maxmcs_uplink[slice_id]); // otherwise, limit to QPSK PUSCH + if (UE_list->UE_sched_ctrl[i].phr_received == 1) { + /* if we've received the power headroom information the UE, we can go to + * maximum mcs */ + mcs = cmin(20, slice_maxmcs_uplink[slice_id]); + } else { + /* otherwise, limit to QPSK PUSCH */ + mcs = cmin(10, slice_maxmcs_uplink[slice_id]); + } UE_id = i; @@ -1633,6 +1638,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, UE_list->numactiveULCCs[UE_id]); UE_template = &UE_list->UE_template[CC_id][UE_id]; + UE_template->pre_assigned_mcs_ul = mcs; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; Ncp = RC.mac[module_idP]->common_channels[CC_id].Ncp; From c33e184ddeee3f80de691146e8dbd3a8b27cf210 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 13 Feb 2018 14:25:50 +0100 Subject: [PATCH 124/141] bugfix: selectively inform FlexRAN RTController of UE state change --- openair2/LAYER2/MAC/eNB_scheduler.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index fb4fd6553b..a7c79a70d5 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -413,15 +413,16 @@ check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, subframeP,rnti); UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; + + //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future + if (rrc_agent_registered[module_idP]) { + LOG_W(MAC, "notify flexran Agent of UE state change\n"); + agent_rrc_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP, + rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + } } } // ul_failure_timer>0 - //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future - if (rrc_agent_registered[module_idP]) { - agent_rrc_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP, - rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); - } - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer++; if(UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer > (U_PLANE_INACTIVITY_VALUE*subframe_num(&RC.eNB[module_idP][CC_id]->frame_parms))){ LOG_D(MAC,"UE %d rnti %x: U-Plane Failure after repeated PDCCH orders: Triggering RRC \n",UE_id,rnti); From 12ac8b180da8f919dc2d2d7105bade4561be235d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 12 Feb 2018 18:34:56 +0100 Subject: [PATCH 125/141] prevent warnings: init Protocol__FlexHeader to NULL --- .../CONTROL_MODULES/MAC/flexran_agent_mac.c | 8 ++++---- .../MAC/flexran_agent_mac_internal.c | 2 +- .../CONTROL_MODULES/RRC/flexran_agent_rrc.c | 4 ++-- openair2/ENB_APP/flexran_agent_common.c | 14 +++++++------- openair2/ENB_APP/flexran_agent_handler.c | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index f875264967..230917f673 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -670,7 +670,7 @@ int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg) { } int flexran_agent_mac_sr_info(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; int i; const int xid = *((int *)params); @@ -738,7 +738,7 @@ int flexran_agent_mac_destroy_sr_info(Protocol__FlexranMessage *msg) { } int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; int i, j, UE_id; int available_harq[NUMBER_OF_UE_MAX]; @@ -954,7 +954,7 @@ int flexran_agent_mac_destroy_sf_trigger(Protocol__FlexranMessage *msg) { int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMessage **msg) { int xid = 0; - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_DL_MAC_CONFIG, &header) != 0) goto error; @@ -1049,7 +1049,7 @@ int flexran_agent_mac_destroy_dl_config(Protocol__FlexranMessage *msg) { int flexran_agent_mac_create_empty_ul_config(mid_t mod_id, Protocol__FlexranMessage **msg) { int xid = 0; - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_UL_MAC_CONFIG, &header) != 0) goto error; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index b7a93b8491..2acee0686f 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -101,7 +101,7 @@ Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol if (n_cell_report > 0 || n_ue_report > 0) { /*Create header*/ int xid = old_report->header->xid; - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) { goto error; } diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c index 590e9c870f..e88c4eaccf 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c +++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c @@ -45,8 +45,8 @@ AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]; void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) { int size; - Protocol__FlexranMessage *msg; - Protocol__FlexHeader *header; + Protocol__FlexranMessage *msg = NULL; + Protocol__FlexHeader *header = NULL; void *data; int priority = 0; err_code_t err_code; diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index f837d575d5..2df5959815 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -106,7 +106,7 @@ int flexran_create_header(xid_t xid, Protocol__FlexType type, Protocol__FlexHea int flexran_agent_hello(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; /*TODO: Need to set random xid or xid from received hello message*/ xid_t xid = 1; @@ -161,7 +161,7 @@ int flexran_agent_destroy_hello(Protocol__FlexranMessage *msg) { int flexran_agent_echo_request(mid_t mod_id, const void* params, Protocol__FlexranMessage **msg) { - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; /*TODO: Need to set a random xid*/ xid_t xid = 1; @@ -216,6 +216,7 @@ int flexran_agent_destroy_echo_request(Protocol__FlexranMessage *msg) { int flexran_agent_echo_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { xid_t xid; + Protocol__FlexHeader *header = NULL; Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params; Protocol__FlexEchoRequest *echo_req = input->echo_request_msg; xid = (echo_req->header)->xid; @@ -226,7 +227,6 @@ int flexran_agent_echo_reply(mid_t mod_id, const void *params, Protocol__Flexran goto error; protocol__flex_echo_reply__init(echo_reply_msg); - Protocol__FlexHeader *header; if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_ECHO_REPLY, &header) != 0) goto error; @@ -429,6 +429,7 @@ int flexran_agent_destroy_agent_reconfiguration(Protocol__FlexranMessage *msg) { int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { xid_t xid; + Protocol__FlexHeader *header = NULL; Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params; Protocol__FlexLcConfigRequest *lc_config_request_msg = input->lc_config_request_msg; xid = (lc_config_request_msg->header)->xid; @@ -441,7 +442,6 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl goto error; protocol__flex_lc_config_reply__init(lc_config_reply_msg); - Protocol__FlexHeader *header; if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_LC_CONFIG_REPLY, &header) != 0) goto error; @@ -557,6 +557,7 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { xid_t xid; + Protocol__FlexHeader *header = NULL; Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params; Protocol__FlexUeConfigRequest *ue_config_request_msg = input->ue_config_request_msg; xid = (ue_config_request_msg->header)->xid; @@ -569,7 +570,6 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl goto error; protocol__flex_ue_config_reply__init(ue_config_reply_msg); - Protocol__FlexHeader *header; if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_UE_CONFIG_REPLY, &header) != 0) goto error; @@ -762,7 +762,7 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl int flexran_agent_enb_config_request(mid_t mod_id, const void* params, Protocol__FlexranMessage **msg) { - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; xid_t xid = 1; Protocol__FlexEnbConfigRequest *enb_config_request_msg; @@ -801,6 +801,7 @@ int flexran_agent_enb_config_request(mid_t mod_id, const void* params, Protocol_ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { xid_t xid; + Protocol__FlexHeader *header = NULL; Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params; Protocol__FlexEnbConfigRequest *enb_config_req_msg = input->enb_config_request_msg; xid = (enb_config_req_msg->header)->xid; @@ -814,7 +815,6 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F goto error; protocol__flex_enb_config_reply__init(enb_config_reply_msg); - Protocol__FlexHeader *header; if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_ENB_CONFIG_REPLY, &header) != 0) goto error; diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index 3597463ae3..6c20c635a1 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -393,7 +393,7 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *report_config, Protocol__FlexranMessage **msg){ - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; err_code_t err_code; int i; @@ -514,7 +514,7 @@ int flexran_agent_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg) { - Protocol__FlexHeader *header; + Protocol__FlexHeader *header = NULL; int i; Protocol__FlexStatsRequest *stats_request_msg; From 22742a4c9c771441dd4d3de8c635584421d53092 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 13 Feb 2018 15:30:39 +0100 Subject: [PATCH 126/141] hack: get oaisim to compile on Ubuntu 17.10 The following did not work before this commit on ubuntu 17.10: ./build_oai --oaisim -c oaisim has not been tested. It may fail to work. To be tested. --- cmake_targets/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 8d62652556..3bfc2d54ee 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1880,6 +1880,16 @@ if(EXISTS "/usr/include/atlas/cblas.h" OR EXISTS "/usr/include/cblas.h") endif() list(APPEND ATLAS_LIBRARIES lapack) + +# for ubuntu 17.10, directories are different +elseif(EXISTS "/usr/include/x86_64-linux-gnu/cblas.h") + + include_directories("/usr/include/x86_64-linux-gnu") + LINK_DIRECTORIES("/usr/lib/x86_64-linux-gnu") + list(APPEND ATLAS_LIBRARIES cblas) + list(APPEND ATLAS_LIBRARIES atlas) + list(APPEND ATLAS_LIBRARIES lapack) + else() message("No Blas/Atlas libs found, some targets will fail") endif() From ef78dcde5595784122a62824e044ed99251de207 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 13 Feb 2018 19:00:34 +0100 Subject: [PATCH 127/141] send UE Capabilities to Flexran RTController --- openair2/ENB_APP/flexran_agent_common.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 2df5959815..c663d5cad1 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -630,21 +630,16 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl Protocol__FlexUeCapabilities *capabilities; capabilities = malloc(sizeof(Protocol__FlexUeCapabilities)); protocol__flex_ue_capabilities__init(capabilities); - //TODO: Set half duplex (FDD operation) - capabilities->has_half_duplex = 0; - capabilities->half_duplex = 0;//flexran_get_half_duplex(i); - //TODO: Set intra-frame hopping flag - capabilities->has_intra_sf_hopping = 0; - capabilities->intra_sf_hopping = 1;//flexran_get_intra_sf_hopping(i); - //TODO: Set support for type 2 hopping with n_sb > 1 - capabilities->has_type2_sb_1 = 0; - capabilities->type2_sb_1 = 1;//flexran_get_type2_sb_1(i); - //TODO: Set ue category - capabilities->has_ue_category = 0; - capabilities->ue_category = 1;//flexran_get_ue_category(i); - //TODO: Set UE support for resource allocation type 1 - capabilities->has_res_alloc_type1 = 0; - capabilities->res_alloc_type1 = 1;//flexran_get_res_alloc_type1(i); + capabilities->has_half_duplex = 1; + capabilities->half_duplex = flexran_get_half_duplex(mod_id, i); + capabilities->has_intra_sf_hopping = 1; + capabilities->intra_sf_hopping = flexran_get_intra_sf_hopping(mod_id, i); + capabilities->has_type2_sb_1 = 1; + capabilities->type2_sb_1 = flexran_get_type2_sb_1(mod_id, i); + capabilities->has_ue_category = 1; + capabilities->ue_category = flexran_get_ue_category(mod_id, i); + capabilities->has_res_alloc_type1 = 1; + capabilities->res_alloc_type1 = flexran_get_res_alloc_type1(mod_id, i); //Set the capabilites to the message ue_config[i]->capabilities = capabilities; From 9d05a9a3b10e6959a68228883e4670d2dba7e65e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 13 Feb 2018 16:08:35 +0100 Subject: [PATCH 128/141] track IMSIs by decoding NAS messages Original Author: Xenofon Foukas Changed formatting does not compile RS: cast to get rid of compiler warning -> ImsiEpsMobileIdentity_t to ImsiMobileIdentity_t which is defined the same way --- openair2/RRC/LITE/rrc_eNB_S1AP.c | 228 +++++++++++++++++++++++++++++-- 1 file changed, 219 insertions(+), 9 deletions(-) diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index d2c0d0acbe..a2c570c009 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -59,6 +59,10 @@ #include "gtpv1u_eNB_task.h" #include "RRC/LITE/rrc_eNB_GTPV1U.h" +#include "TLVDecoder.h" +#include "S1ap-NAS-PDU.h" +#include "flexran_agent_common_internal.h" + extern RAN_CONTEXT_t RC; /* Value to indicate an invalid UE initial id */ @@ -542,6 +546,74 @@ rrc_eNB_send_S1AP_UPLINK_NAS( S1AP_UPLINK_NAS (msg_p).nas_pdu.length = pdu_length; S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer = pdu_buffer; + /* Process NAS message locally to get the IMSI */ + nas_message_t nas_msg; + memset(&nas_msg, 0, sizeof(nas_message_t)); + int size = 0; + uint32_t pdu_len = S1AP_UPLINK_NAS (msg_p).nas_pdu.length; + uint8_t *pdu_buff = malloc(pdu_len * sizeof(uint8_t)); + memcpy(pdu_buff, S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer, pdu_len * sizeof(uint8_t)); + + nas_message_security_header_t *header = &nas_msg.header; + /* Decode the first octet of the header (security header type or EPS + * bearer identity, and protocol discriminator) */ + DECODE_U8((char *) pdu_buff, *(uint8_t*) (header), size); + + /* Decode NAS message */ + if (header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED + && header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE + && pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE) { + + if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { + /* Decode the message authentication code */ + DECODE_U32((char *) pdu_buff+size, header->message_authentication_code, size); + /* Decode the sequence number */ + DECODE_U8((char *) pdu_buff+size, header->sequence_number, size); + } + + if (size > 1) { + pdu_buff += size; + pdu_len -= size; + } + + /* Decode plain NAS message */ + EMM_msg *e_msg = &nas_msg.plain.emm; + emm_msg_header_t *emm_header = &e_msg->header; + + /* First decode the EMM message header */ + int e_head_size = 0; + + /* Check the buffer length */ + if (pdu_len > sizeof(emm_msg_header_t)) { + + /* Decode the security header type and the protocol discriminator */ + DECODE_U8(pdu_buff + e_head_size, *(uint8_t *)(emm_header), e_head_size); + /* Decode the message type */ + DECODE_U8(pdu_buff + e_head_size, emm_header->message_type, e_head_size); + + /* Check the protocol discriminator */ + if (emm_header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE) { + + pdu_buff += e_head_size; + pdu_len -= e_head_size; + + if (emm_header->message_type == IDENTITY_RESPONSE) { + decode_identity_response(&e_msg->identity_response, pdu_buff, pdu_len); + + if (e_msg->identity_response.mobileidentity.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { + ue_context_pP->ue_context.imsi = compute_imsi(&(e_msg->identity_response.mobileidentity.imsi)); + } + } + + pdu_buff -= e_head_size; + if (size > 1) { + pdu_buff -= size; + } + } + } + } + free(pdu_buff); + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } } @@ -563,16 +635,82 @@ rrc_eNB_send_S1AP_UPLINK_NAS( &ulInformationTransfer->criticalExtensions.choice. c1.choice.ulInformationTransfer_r8; - if (ulInformationTransferR8->dedicatedInfoType. - present == - ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS) + if (ulInformationTransferR8->dedicatedInfoType.present == + ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS) { + + /* Process NAS message locally to get the IMSI */ + nas_message_t nas_msg; + memset(&nas_msg, 0, sizeof(nas_message_t)); + + int size = 0; + uint32_t pdu_len = ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size; + uint8_t *pdu_buff = malloc(pdu_len * sizeof(uint8_t)); + memcpy(pdu_buff, ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, pdu_len * sizeof(uint8_t)); + + nas_message_security_header_t *header = &nas_msg.header; + /* Decode the first octet of the header (security header type or EPS + * bearer identity, and protocol discriminator) */ + DECODE_U8((char *) pdu_buff, *(uint8_t*) (header), size); + + /* Decode NAS message */ + if (header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED && + header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE && + pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE) { + + if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { + /* Decode the message authentication code */ + DECODE_U32((char *) pdu_buff+size, header->message_authentication_code, size); + /* Decode the sequence number */ + DECODE_U8((char *) pdu_buff+size, header->sequence_number, size); + } + + if (size > 1) { + pdu_buff += size; + pdu_len -= size; + } + + /* Decode plain NAS message */ + EMM_msg *e_msg = &nas_msg.plain.emm; + emm_msg_header_t *emm_header = &e_msg->header; + + /* First decode the EMM message header */ + int e_head_size = 0; + + /* Check the buffer length */ + if (pdu_len > sizeof(emm_msg_header_t)) { + + /* Decode the security header type and the protocol discriminator */ + DECODE_U8(pdu_buff + e_head_size, *(uint8_t *)(emm_header), e_head_size); + /* Decode the message type */ + DECODE_U8(pdu_buff + e_head_size, emm_header->message_type, e_head_size); + + /* Check the protocol discriminator */ + if (emm_header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE) { + + pdu_buff += e_head_size; + pdu_len -= e_head_size; + + if (emm_header->message_type == IDENTITY_RESPONSE) { + decode_identity_response(&e_msg->identity_response, pdu_buff, pdu_len); + + if (e_msg->identity_response.mobileidentity.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { + ue_context_pP->ue_context.imsi = compute_imsi(&(e_msg->identity_response.mobileidentity.imsi)); + } + } + + pdu_buff -= e_head_size; + if (size > 1) { + pdu_buff -= size; + } + } + } + } + free(pdu_buff); + s1ap_eNB_new_data_request (mod_id, ue_index, - ulInformationTransferR8-> - dedicatedInfoType.choice. - dedicatedInfoNAS.buf, - ulInformationTransferR8-> - dedicatedInfoType.choice. - dedicatedInfoNAS.size); + ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, + ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size); + } } } } @@ -674,6 +812,78 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( rrcConnectionSetupComplete->dedicatedInfoNAS.buf; S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length = rrcConnectionSetupComplete->dedicatedInfoNAS.size; + // Process NAS message locally to get the IMSI + nas_message_t nas_msg; + memset(&nas_msg, 0, sizeof(nas_message_t)); + + int size = 0; + uint32_t pdu_len = S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length; + uint8_t *pdu_buff = malloc(pdu_len * sizeof(uint8_t)); + memcpy(pdu_buff, S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer, pdu_len * sizeof(uint8_t)); + + nas_message_security_header_t *header = &nas_msg.header; + /* Decode the first octet of the header (security header type or EPS + * bearer identity, and protocol discriminator) */ + DECODE_U8((char *) pdu_buff, *(uint8_t*) (header), size); + + /* Decode NAS message */ + if (header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED && + header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE && + pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE) { + + if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { + /* Decode the message authentication code */ + DECODE_U32((char *) pdu_buff+size, header->message_authentication_code, size); + /* Decode the sequence number */ + DECODE_U8((char *) pdu_buff+size, header->sequence_number, size); + } + + if (size > 1) { + pdu_buff += size; + pdu_len -= size; + } + + /* Decode plain NAS message */ + EMM_msg *e_msg = &nas_msg.plain.emm; + emm_msg_header_t *emm_header = &e_msg->header; + + /* First decode the EMM message header */ + int e_head_size = 0; + + /* Check the buffer length */ + if (pdu_len > sizeof(emm_msg_header_t)) { + + /* Decode the security header type and the protocol discriminator */ + DECODE_U8(pdu_buff + e_head_size, *(uint8_t *)(emm_header), e_head_size); + /* Decode the message type */ + DECODE_U8(pdu_buff + e_head_size, emm_header->message_type, e_head_size); + + /* Check the protocol discriminator */ + if (emm_header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE) { + + pdu_buff += e_head_size; + pdu_len -= e_head_size; + + if (emm_header->message_type == ATTACH_REQUEST) { + decode_attach_request(&e_msg->attach_request, pdu_buff, pdu_len); + + if (e_msg->attach_request.oldgutiorimsi.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { + /* the following is very dirty, we cast from + * ImsiEpsMobileIdentity_t to ImsiMobileIdentity_t*/ + ue_context_pP->ue_context.imsi = compute_imsi((ImsiMobileIdentity_t *)&(e_msg->attach_request.oldgutiorimsi.imsi)); + } else { + ue_context_pP->ue_context.imsi = e_msg->attach_request.oldgutiorimsi.guti.mtmsi; + } + } + pdu_buff -= e_head_size; + if (size > 1) { + pdu_buff -= size; + } + } + } + } + free(pdu_buff); + /* Fill UE identities with available information */ { S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask = UE_IDENTITIES_NONE; From d8a6715395e2094a0c1761e180daf3351cb1e963 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 7 Feb 2018 18:57:06 +0100 Subject: [PATCH 129/141] store IMSI information + provide FlexRAN API to query UE's IMSI --- openair2/ENB_APP/flexran_agent_ran_api.c | 11 +++++++++++ openair2/ENB_APP/flexran_agent_ran_api.h | 3 +++ openair2/RRC/LITE/defs.h | 3 ++- openair2/RRC/LITE/rrc_eNB_S1AP.c | 21 +++++++++++++++++++-- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 97a77a634c..b81d030c43 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -889,6 +889,17 @@ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) } } +uint64_t flexran_get_ue_imsi(mid_t mod_id, mid_t ue_id) +{ + if (!rrc_is_present(mod_id)) return -1; + + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); + + if (!ue_context_p) return -1; + return ue_context_p->ue_context.imsi; +} + long flexran_get_lcg(mid_t mod_id, mid_t ue_id, mid_t lc_id) { if (!mac_is_present(mod_id)) return 0; diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index b3515c9c6c..aafb82077e 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -301,6 +301,9 @@ long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id); /* Get number of UE transmission antennas */ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id); +/* Get the IMSI of UE */ +uint64_t flexran_get_ue_imsi(mid_t mod_id, mid_t ue_id); + /* Get logical channel group of a channel with id lc_id */ long flexran_get_lcg(mid_t mod_id, mid_t ue_id, mid_t lc_id); diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index 9a9840273b..763a55c559 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -394,7 +394,8 @@ typedef struct eNB_RRC_UE_s { MeasResults_t* measResults; UE_EUTRA_Capability_t* UE_Capability; - + uint64_t imsi; + #if defined(ENABLE_SECURITY) /* KeNB as derived from KASME received from EPC */ uint8_t kenb[32]; diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index a2c570c009..87bbe8857d 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -86,8 +86,25 @@ static const uint16_t S1AP_INTEGRITY_EIA2_MASK = 0x4000; #endif #endif - - +uint64_t compute_imsi(ImsiMobileIdentity_t *id) { + uint64_t imsi; + imsi = id->digit15; + imsi += id->digit14 * 10; // pow(10, 1) + imsi += id->digit13 * 100; // pow(10, 2) + imsi += id->digit12 * 1000; // pow(10, 3) + imsi += id->digit11 * 10000; // pow(10, 4) + imsi += id->digit10 * 100000; // pow(10, 5) + imsi += id->digit9 * 1000000; // pow(10, 6) + imsi += id->digit8 * 10000000; // pow(10, 7) + imsi += id->digit7 * 100000000; // pow(10, 8) + imsi += id->digit6 * 1000000000; // pow(10, 9) + imsi += id->digit5 * 10000000000; // pow(10, 10) + imsi += id->digit4 * 100000000000; // pow(10, 11) + imsi += id->digit3 * 1000000000000; // pow(10, 12) + imsi += id->digit2 * 10000000000000; // pow(10, 13) + imsi += id->digit1 * 100000000000000; // pow(10, 14) + return imsi; +} # if defined(ENABLE_ITTI) //------------------------------------------------------------------------------ From df43d19c356f0b9cb1642b9c409b3c3e97011d77 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 13 Feb 2018 15:02:38 +0100 Subject: [PATCH 130/141] refactoring of the original IMSI extraction code - move IMSI extraction code to function, remove FLEXRAN comp. directive - refactor the code, esp. don't do deep if-nesting - remove m-tmsi part (does not give correct value) - copy complete IMSI info to UE context, decode in RAN API --- openair2/ENB_APP/flexran_agent_ran_api.c | 19 +- openair2/RRC/LITE/defs.h | 2 +- openair2/RRC/LITE/rrc_eNB_S1AP.c | 306 ++++++----------------- 3 files changed, 101 insertions(+), 226 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index b81d030c43..3c98d63fcf 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -891,13 +891,30 @@ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) uint64_t flexran_get_ue_imsi(mid_t mod_id, mid_t ue_id) { + uint64_t imsi; if (!rrc_is_present(mod_id)) return -1; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); if (!ue_context_p) return -1; - return ue_context_p->ue_context.imsi; + + imsi = ue_context_p->ue_context.imsi.digit15; + imsi += ue_context_p->ue_context.imsi.digit14 * 10; // pow(10, 1) + imsi += ue_context_p->ue_context.imsi.digit13 * 100; // pow(10, 2) + imsi += ue_context_p->ue_context.imsi.digit12 * 1000; // pow(10, 3) + imsi += ue_context_p->ue_context.imsi.digit11 * 10000; // pow(10, 4) + imsi += ue_context_p->ue_context.imsi.digit10 * 100000; // pow(10, 5) + imsi += ue_context_p->ue_context.imsi.digit9 * 1000000; // pow(10, 6) + imsi += ue_context_p->ue_context.imsi.digit8 * 10000000; // pow(10, 7) + imsi += ue_context_p->ue_context.imsi.digit7 * 100000000; // pow(10, 8) + imsi += ue_context_p->ue_context.imsi.digit6 * 1000000000; // pow(10, 9) + imsi += ue_context_p->ue_context.imsi.digit5 * 10000000000; // pow(10, 10) + imsi += ue_context_p->ue_context.imsi.digit4 * 100000000000; // pow(10, 11) + imsi += ue_context_p->ue_context.imsi.digit3 * 1000000000000; // pow(10, 12) + imsi += ue_context_p->ue_context.imsi.digit2 * 10000000000000; // pow(10, 13) + imsi += ue_context_p->ue_context.imsi.digit1 * 100000000000000; // pow(10, 14) + return imsi; } long flexran_get_lcg(mid_t mod_id, mid_t ue_id, mid_t lc_id) diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index 763a55c559..01475715f4 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -394,7 +394,7 @@ typedef struct eNB_RRC_UE_s { MeasResults_t* measResults; UE_EUTRA_Capability_t* UE_Capability; - uint64_t imsi; + ImsiMobileIdentity_t imsi; #if defined(ENABLE_SECURITY) /* KeNB as derived from KASME received from EPC */ diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index 87bbe8857d..80ae1c9ba5 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -86,24 +86,79 @@ static const uint16_t S1AP_INTEGRITY_EIA2_MASK = 0x4000; #endif #endif -uint64_t compute_imsi(ImsiMobileIdentity_t *id) { - uint64_t imsi; - imsi = id->digit15; - imsi += id->digit14 * 10; // pow(10, 1) - imsi += id->digit13 * 100; // pow(10, 2) - imsi += id->digit12 * 1000; // pow(10, 3) - imsi += id->digit11 * 10000; // pow(10, 4) - imsi += id->digit10 * 100000; // pow(10, 5) - imsi += id->digit9 * 1000000; // pow(10, 6) - imsi += id->digit8 * 10000000; // pow(10, 7) - imsi += id->digit7 * 100000000; // pow(10, 8) - imsi += id->digit6 * 1000000000; // pow(10, 9) - imsi += id->digit5 * 10000000000; // pow(10, 10) - imsi += id->digit4 * 100000000000; // pow(10, 11) - imsi += id->digit3 * 1000000000000; // pow(10, 12) - imsi += id->digit2 * 10000000000000; // pow(10, 13) - imsi += id->digit1 * 100000000000000; // pow(10, 14) - return imsi; +void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_context_pP) +{ + /* Process NAS message locally to get the IMSI */ + nas_message_t nas_msg; + memset(&nas_msg, 0, sizeof(nas_message_t)); + + int size = 0; + + nas_message_security_header_t *header = &nas_msg.header; + /* Decode the first octet of the header (security header type or EPS + * bearer identity, and protocol discriminator) */ + DECODE_U8((char *) pdu_buf, *(uint8_t*) (header), size); + + /* Decode NAS message only if decodable*/ + if (!(header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED + && header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE + && pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE)) + return; + + if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { + /* Decode the message authentication code */ + DECODE_U32((char *) pdu_buf+size, header->message_authentication_code, size); + /* Decode the sequence number */ + DECODE_U8((char *) pdu_buf+size, header->sequence_number, size); + } + + /* Note: the value of the pointer (i.e. the address) is given by value, so we + * can modify it as we want. The callee retains the original address! */ + pdu_buf += size; + pdu_len -= size; + + /* Decode plain NAS message */ + EMM_msg *e_msg = &nas_msg.plain.emm; + emm_msg_header_t *emm_header = &e_msg->header; + + /* First decode the EMM message header */ + int e_head_size = 0; + + /* Check that buffer contains more than only the header */ + if (pdu_len <= sizeof(emm_msg_header_t)) + return; + + /* Decode the security header type and the protocol discriminator */ + DECODE_U8(pdu_buf + e_head_size, *(uint8_t *)(emm_header), e_head_size); + /* Decode the message type */ + DECODE_U8(pdu_buf + e_head_size, emm_header->message_type, e_head_size); + + /* Check that this is the right message */ + if (emm_header->protocol_discriminator != EPS_MOBILITY_MANAGEMENT_MESSAGE) + return; + + pdu_buf += e_head_size; + pdu_len -= e_head_size; + + if (emm_header->message_type == IDENTITY_RESPONSE) { + decode_identity_response(&e_msg->identity_response, pdu_buf, pdu_len); + + if (e_msg->identity_response.mobileidentity.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { + memcpy(&ue_context_pP->ue_context.imsi, + &e_msg->identity_response.mobileidentity.imsi, + sizeof(ImsiMobileIdentity_t)); + } + } else if (emm_header->message_type == ATTACH_REQUEST) { + decode_attach_request(&e_msg->attach_request, pdu_buf, pdu_len); + + if (e_msg->attach_request.oldgutiorimsi.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { + /* the following is very dirty, we cast (implicitly) from + * ImsiEpsMobileIdentity_t to ImsiMobileIdentity_t*/ + memcpy(&ue_context_pP->ue_context.imsi, + &e_msg->attach_request.oldgutiorimsi.imsi, + sizeof(ImsiMobileIdentity_t)); + } + } } # if defined(ENABLE_ITTI) @@ -563,73 +618,9 @@ rrc_eNB_send_S1AP_UPLINK_NAS( S1AP_UPLINK_NAS (msg_p).nas_pdu.length = pdu_length; S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer = pdu_buffer; - /* Process NAS message locally to get the IMSI */ - nas_message_t nas_msg; - memset(&nas_msg, 0, sizeof(nas_message_t)); - int size = 0; - uint32_t pdu_len = S1AP_UPLINK_NAS (msg_p).nas_pdu.length; - uint8_t *pdu_buff = malloc(pdu_len * sizeof(uint8_t)); - memcpy(pdu_buff, S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer, pdu_len * sizeof(uint8_t)); - - nas_message_security_header_t *header = &nas_msg.header; - /* Decode the first octet of the header (security header type or EPS - * bearer identity, and protocol discriminator) */ - DECODE_U8((char *) pdu_buff, *(uint8_t*) (header), size); - - /* Decode NAS message */ - if (header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED - && header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE - && pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE) { - - if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { - /* Decode the message authentication code */ - DECODE_U32((char *) pdu_buff+size, header->message_authentication_code, size); - /* Decode the sequence number */ - DECODE_U8((char *) pdu_buff+size, header->sequence_number, size); - } - - if (size > 1) { - pdu_buff += size; - pdu_len -= size; - } - - /* Decode plain NAS message */ - EMM_msg *e_msg = &nas_msg.plain.emm; - emm_msg_header_t *emm_header = &e_msg->header; - - /* First decode the EMM message header */ - int e_head_size = 0; - - /* Check the buffer length */ - if (pdu_len > sizeof(emm_msg_header_t)) { - - /* Decode the security header type and the protocol discriminator */ - DECODE_U8(pdu_buff + e_head_size, *(uint8_t *)(emm_header), e_head_size); - /* Decode the message type */ - DECODE_U8(pdu_buff + e_head_size, emm_header->message_type, e_head_size); - - /* Check the protocol discriminator */ - if (emm_header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE) { - - pdu_buff += e_head_size; - pdu_len -= e_head_size; - - if (emm_header->message_type == IDENTITY_RESPONSE) { - decode_identity_response(&e_msg->identity_response, pdu_buff, pdu_len); - - if (e_msg->identity_response.mobileidentity.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { - ue_context_pP->ue_context.imsi = compute_imsi(&(e_msg->identity_response.mobileidentity.imsi)); - } - } - - pdu_buff -= e_head_size; - if (size > 1) { - pdu_buff -= size; - } - } - } - } - free(pdu_buff); + extract_imsi(S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer, + S1AP_UPLINK_NAS (msg_p).nas_pdu.length, + ue_context_pP); itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } @@ -655,74 +646,9 @@ rrc_eNB_send_S1AP_UPLINK_NAS( if (ulInformationTransferR8->dedicatedInfoType.present == ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS) { - /* Process NAS message locally to get the IMSI */ - nas_message_t nas_msg; - memset(&nas_msg, 0, sizeof(nas_message_t)); - - int size = 0; - uint32_t pdu_len = ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size; - uint8_t *pdu_buff = malloc(pdu_len * sizeof(uint8_t)); - memcpy(pdu_buff, ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, pdu_len * sizeof(uint8_t)); - - nas_message_security_header_t *header = &nas_msg.header; - /* Decode the first octet of the header (security header type or EPS - * bearer identity, and protocol discriminator) */ - DECODE_U8((char *) pdu_buff, *(uint8_t*) (header), size); - - /* Decode NAS message */ - if (header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED && - header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE && - pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE) { - - if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { - /* Decode the message authentication code */ - DECODE_U32((char *) pdu_buff+size, header->message_authentication_code, size); - /* Decode the sequence number */ - DECODE_U8((char *) pdu_buff+size, header->sequence_number, size); - } - - if (size > 1) { - pdu_buff += size; - pdu_len -= size; - } - - /* Decode plain NAS message */ - EMM_msg *e_msg = &nas_msg.plain.emm; - emm_msg_header_t *emm_header = &e_msg->header; - - /* First decode the EMM message header */ - int e_head_size = 0; - - /* Check the buffer length */ - if (pdu_len > sizeof(emm_msg_header_t)) { - - /* Decode the security header type and the protocol discriminator */ - DECODE_U8(pdu_buff + e_head_size, *(uint8_t *)(emm_header), e_head_size); - /* Decode the message type */ - DECODE_U8(pdu_buff + e_head_size, emm_header->message_type, e_head_size); - - /* Check the protocol discriminator */ - if (emm_header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE) { - - pdu_buff += e_head_size; - pdu_len -= e_head_size; - - if (emm_header->message_type == IDENTITY_RESPONSE) { - decode_identity_response(&e_msg->identity_response, pdu_buff, pdu_len); - - if (e_msg->identity_response.mobileidentity.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { - ue_context_pP->ue_context.imsi = compute_imsi(&(e_msg->identity_response.mobileidentity.imsi)); - } - } - - pdu_buff -= e_head_size; - if (size > 1) { - pdu_buff -= size; - } - } - } - } - free(pdu_buff); + extract_imsi(ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, + ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size, + ue_context_pP); s1ap_eNB_new_data_request (mod_id, ue_index, ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, @@ -829,77 +755,9 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( rrcConnectionSetupComplete->dedicatedInfoNAS.buf; S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length = rrcConnectionSetupComplete->dedicatedInfoNAS.size; - // Process NAS message locally to get the IMSI - nas_message_t nas_msg; - memset(&nas_msg, 0, sizeof(nas_message_t)); - - int size = 0; - uint32_t pdu_len = S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length; - uint8_t *pdu_buff = malloc(pdu_len * sizeof(uint8_t)); - memcpy(pdu_buff, S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer, pdu_len * sizeof(uint8_t)); - - nas_message_security_header_t *header = &nas_msg.header; - /* Decode the first octet of the header (security header type or EPS - * bearer identity, and protocol discriminator) */ - DECODE_U8((char *) pdu_buff, *(uint8_t*) (header), size); - - /* Decode NAS message */ - if (header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED && - header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE && - pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE) { - - if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { - /* Decode the message authentication code */ - DECODE_U32((char *) pdu_buff+size, header->message_authentication_code, size); - /* Decode the sequence number */ - DECODE_U8((char *) pdu_buff+size, header->sequence_number, size); - } - - if (size > 1) { - pdu_buff += size; - pdu_len -= size; - } - - /* Decode plain NAS message */ - EMM_msg *e_msg = &nas_msg.plain.emm; - emm_msg_header_t *emm_header = &e_msg->header; - - /* First decode the EMM message header */ - int e_head_size = 0; - - /* Check the buffer length */ - if (pdu_len > sizeof(emm_msg_header_t)) { - - /* Decode the security header type and the protocol discriminator */ - DECODE_U8(pdu_buff + e_head_size, *(uint8_t *)(emm_header), e_head_size); - /* Decode the message type */ - DECODE_U8(pdu_buff + e_head_size, emm_header->message_type, e_head_size); - - /* Check the protocol discriminator */ - if (emm_header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE) { - - pdu_buff += e_head_size; - pdu_len -= e_head_size; - - if (emm_header->message_type == ATTACH_REQUEST) { - decode_attach_request(&e_msg->attach_request, pdu_buff, pdu_len); - - if (e_msg->attach_request.oldgutiorimsi.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { - /* the following is very dirty, we cast from - * ImsiEpsMobileIdentity_t to ImsiMobileIdentity_t*/ - ue_context_pP->ue_context.imsi = compute_imsi((ImsiMobileIdentity_t *)&(e_msg->attach_request.oldgutiorimsi.imsi)); - } else { - ue_context_pP->ue_context.imsi = e_msg->attach_request.oldgutiorimsi.guti.mtmsi; - } - } - pdu_buff -= e_head_size; - if (size > 1) { - pdu_buff -= size; - } - } - } - } - free(pdu_buff); + extract_imsi(S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer, + S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length, + ue_context_pP); /* Fill UE identities with available information */ { From d741b951fa22426d668169872c4dcddb5d682b7a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 13 Feb 2018 18:51:36 +0100 Subject: [PATCH 131/141] define&send IMSI in Protobuf --- openair2/ENB_APP/MESSAGES/V2/config_messages.proto | 1 + openair2/ENB_APP/flexran_agent_common.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto index 995865f1ab..f734686f01 100644 --- a/openair2/ENB_APP/MESSAGES/V2/config_messages.proto +++ b/openair2/ENB_APP/MESSAGES/V2/config_messages.proto @@ -81,6 +81,7 @@ message flex_ue_config { optional uint32 pcell_carrier_index = 27; // Index of primary cell repeated flex_scell_config scell_config = 28; // Secondary cells configuration optional uint32 scell_deactivation_timer = 29;// Deactivation timer for secondary cell + optional uint64 imsi = 30; } message flex_lc_ue_config { diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index c663d5cad1..6d32aeedbb 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -589,6 +589,8 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl ue_config[i]->rnti = flexran_get_ue_crnti(mod_id,i); ue_config[i]->has_rnti = 1; + ue_config[i]->imsi = flexran_get_ue_imsi(mod_id, i); + ue_config[i]->has_imsi = 1; //TODO: Set the DRX configuration (optional) //Not supported for now, so we do not set it From 50f7053159558287031df145b3a7c153be22a2fb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Feb 2018 16:44:29 +0100 Subject: [PATCH 132/141] return 0 for unsigned in RAN API --- openair2/ENB_APP/flexran_agent_ran_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 3c98d63fcf..c1743bf744 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -892,12 +892,12 @@ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id) uint64_t flexran_get_ue_imsi(mid_t mod_id, mid_t ue_id) { uint64_t imsi; - if (!rrc_is_present(mod_id)) return -1; + if (!rrc_is_present(mod_id)) return 0; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti); - if (!ue_context_p) return -1; + if (!ue_context_p) return 0; imsi = ue_context_p->ue_context.imsi.digit15; imsi += ue_context_p->ue_context.imsi.digit14 * 10; // pow(10, 1) From 9dcd1f9b89198057d6c8309bb0fd3135108d77ec Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Feb 2018 14:25:18 +0100 Subject: [PATCH 133/141] bugfix: max_allowed_rbs has been renamed max_rbs_allowed_slice --- targets/SIMU/USER/event_handler.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/targets/SIMU/USER/event_handler.c b/targets/SIMU/USER/event_handler.c index 7c9f6b73fc..dbdce23df2 100644 --- a/targets/SIMU/USER/event_handler.c +++ b/targets/SIMU/USER/event_handler.c @@ -524,9 +524,9 @@ void update_mac(Event_t event) for(j=0; jmac_config[i].max_allowed_rbs[j]= mac_config[i].max_allowed_rbs[j]; - UE_list->UE_sched_ctrl[i].max_allowed_rbs[j] = oai_emulation->mac_config[i].max_allowed_rbs[j]; + UE_list->UE_sched_ctrl[i].max_rbs_allowed_slice[j][0] = oai_emulation->mac_config[i].max_allowed_rbs[j]; LOG_I(EMU,"max_allowed_rbs UE %d LCID %d:",i,j); - LOG_I(EMU,"%" PRIu16 "\n",UE_list->UE_sched_ctrl[i].max_allowed_rbs[j]); + LOG_I(EMU,"%" PRIu16 "\n",UE_list->UE_sched_ctrl[i].max_rbs_allowed_slice[j][0]); } } @@ -646,9 +646,9 @@ void update_mac(Event_t event) if(mac_config->max_allowed_rbs !=NULL) { oai_emulation->mac_config[i].max_allowed_rbs[j]= mac_config[i].max_allowed_rbs[j]; - UE_list->UE_sched_ctrl[i].max_allowed_rbs[j] = oai_emulation->mac_config[i].max_allowed_rbs[j]; + UE_list->UE_sched_ctrl[i].max_rbs_allowed_slice[j][0] = oai_emulation->mac_config[i].max_allowed_rbs[j]; LOG_I(EMU,"max_allowed_rbs UE %d LCID %d:",i,j); - LOG_I(EMU,"%" PRIu16 "\n",UE_list->UE_sched_ctrl[i].max_allowed_rbs[j]); + LOG_I(EMU,"%" PRIu16 "\n",UE_list->UE_sched_ctrl[i].max_rbs_allowed_slice[j][0]); } @@ -951,18 +951,18 @@ void update_mac(Event_t event) if(&mac_config[i].max_allowed_rbs[j]!=NULL) { oai_emulation->mac_config[i].max_allowed_rbs[j]= mac_config[i].max_allowed_rbs[j]; - UE_list->UE_sched_ctrl[i].max_allowed_rbs[j] = oai_emulation->mac_config[i].max_allowed_rbs[j]; + UE_list->UE_sched_ctrl[i].max_rbs_allowed_slice[j][0] = oai_emulation->mac_config[i].max_allowed_rbs[j]; LOG_I(EMU,"max_allowed_rbs UE %d LCID %d:",i,j); - LOG_I(EMU,"%" PRIu16 "\n",UE_list->UE_sched_ctrl[i].max_allowed_rbs[j]); + LOG_I(EMU,"%" PRIu16 "\n",UE_list->UE_sched_ctrl[i].max_rbs_allowed_slice[j][0]); } } } } } else { oai_emulation->mac_config[event.ue].max_allowed_rbs[event.lcid]= mac_config[event.ue].max_allowed_rbs[event.lcid]; - UE_list->UE_sched_ctrl[event.ue].max_allowed_rbs[event.lcid] = oai_emulation->mac_config[event.ue].max_allowed_rbs[event.lcid]; + UE_list->UE_sched_ctrl[event.ue].max_rbs_allowed_slice[event.lcid][0] = oai_emulation->mac_config[event.ue].max_allowed_rbs[event.lcid]; LOG_I(EMU,"max_allowed_rbs UE %d LCID %d:",event.ue,event.lcid); - LOG_I(EMU,"%" PRIu16 "\n",UE_list->UE_sched_ctrl[event.ue].max_allowed_rbs[event.lcid]); + LOG_I(EMU,"%" PRIu16 "\n",UE_list->UE_sched_ctrl[event.ue].max_rbs_allowed_slice[event.lcid][0]); } } else if(!strcmp((char *) event.key, "max_mcs") && event.value!=NULL && validate_mac(event)) { From 7b1afbb0bfb2defebbf0e60b4331309513cfee43 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Feb 2018 12:07:42 +0100 Subject: [PATCH 134/141] provide stop_L1L2()/restart_L1L2() in oaisim the functions are meant to restart the lte-softmodem (lower layers) and are not supported in oaisim. They are provided to make oaisim compile. --- targets/SIMU/USER/oaisim.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 302b77b60f..9434b2dd83 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -988,6 +988,25 @@ l2l1_task (void *args_p) return NULL; } +#if defined(FLEXRAN_AGENT_SB_IF) +/* + * The following two functions are meant to restart *the lte-softmodem* and are + * here to make oaisim compile. A restart command from the controller will be + * ignored in oaisim. + */ +int stop_L1L2(int enb_id) +{ + LOG_W(FLEXRAN_AGENT, "stop_L1L2() not supported in oaisim\n"); + return 0; +} + +int restart_L1L2(int enb_id) +{ + LOG_W(FLEXRAN_AGENT, "restart_L1L2() not supported in oaisim\n"); + return 0; +} +#endif + #if T_TRACER int T_wait = 1; /* by default we wait for the tracer */ int T_port = 2021; /* default port to listen to to wait for the tracer */ From 7e3b1f5d0a765626b8f3ccc32ffea9f1bb386ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Iardella?= Date: Tue, 13 Feb 2018 13:20:58 +0100 Subject: [PATCH 135/141] Niccolo: Add sorting policy --- openair2/COMMON/platform_types.h | 9 ++ openair2/LAYER2/MAC/defs.h | 4 + openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 15 +- openair2/LAYER2/MAC/pre_processor.c | 162 +++++++++++++--------- openair2/LAYER2/MAC/proto.h | 2 +- 5 files changed, 126 insertions(+), 66 deletions(-) diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 1236b93366..0ab8d96701 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -100,6 +100,15 @@ typedef enum rb_type_e { RADIO_ACCESS_BEARER = 2 } rb_type_t; +typedef enum { + CR_ROUND = 0, + CR_SRB12 = 1, + CR_HOL = 2, + CR_LC = 3, + CR_CQI = 4, + CR_NUM = 5 +} sorting_criterion_t; + //----------------------------------------------------------------------------- // PHY TYPES //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index de53479e6f..ef1d710138 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -963,6 +963,10 @@ typedef struct { int avail; int num_UEs; boolean_t active[NUMBER_OF_UE_MAX]; + + /// Sorting criteria for the UE list in the MAC preprocessor + uint16_t sorting_criteria[MAX_NUM_SLICES][CR_NUM]; + } UE_list_t; /*! \brief eNB common channels */ diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 7d0a93c2bf..48b19b0919 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -98,6 +98,10 @@ char *dl_scheduler_type[MAX_NUM_SLICES] = "schedule_ue_spec" }; +// The lists of criteria that enforce the sorting policies of the slices +uint32_t sorting_policy[MAX_NUM_SLICES] = {0x01234, 0x01234, 0x01234, 0x01234}; +uint32_t sorting_policy_current[MAX_NUM_SLICES] = {0x01234, 0x01234, 0x01234, 0x01234}; + // pointer to the slice specific scheduler slice_scheduler_dl slice_sched_dl[MAX_NUM_SLICES] = {0}; @@ -447,7 +451,7 @@ schedule_dlsch(module_id_t module_idP, //------------------------------------------------------------------------------{ { - int i=0; + int i = 0; total_slice_percentage=0; avg_slice_percentage=1.0/n_active_slices; @@ -470,7 +474,7 @@ schedule_dlsch(module_id_t module_idP, // Load any updated functions if (update_dl_scheduler[i] > 0 ) { slice_sched_dl[i] = dlsym(NULL, dl_scheduler_type[i]); - update_dl_scheduler[i] = 0; + update_dl_scheduler[i] = 0 ; update_dl_scheduler_current[i] = 0; LOG_N(MAC,"update dl scheduler slice %d\n", i); } @@ -538,6 +542,13 @@ schedule_dlsch(module_id_t module_idP, } } + // Check for new sorting policy + if (sorting_policy_current[i] != sorting_policy[i]) { + LOG_N(MAC,"[eNB %d][SLICE %d][DL] frame %d subframe %d: UE sorting policy has changed (%x-->%x)\n", + module_idP, i, frameP, subframeP, sorting_policy_current[i], sorting_policy[i]); + sorting_policy_current[i] = sorting_policy[i]; + } + // Run each enabled slice-specific schedulers one by one slice_sched_dl[i](module_idP, i, frameP, subframeP, mbsfn_flag/*, dl_info*/); } diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 8f7a6bddff..759bc591dd 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -52,13 +52,13 @@ #include "rlc.h" - #define DEBUG_eNB_SCHEDULER 1 #define DEBUG_HEADER_PARSING 1 //#define DEBUG_PACKET_TRACE 1 extern float slice_percentage[MAX_NUM_SLICES]; extern float slice_percentage_uplink[MAX_NUM_SLICES]; +extern uint32_t sorting_policy[MAX_NUM_SLICES]; extern int slice_maxmcs[MAX_NUM_SLICES]; extern int slice_maxmcs_uplink[MAX_NUM_SLICES]; @@ -352,6 +352,7 @@ struct sort_ue_dl_params { int Mod_idP; int frameP; int subframeP; + int slice_id; }; static int ue_dl_compare(const void *_a, const void *_b, void *_params) @@ -359,62 +360,73 @@ static int ue_dl_compare(const void *_a, const void *_b, void *_params) struct sort_ue_dl_params *params = _params; UE_list_t *UE_list = &RC.mac[params->Mod_idP]->UE_list; + int i; + int slice_id = params->slice_id; int UE_id1 = *(const int *) _a; int UE_id2 = *(const int *) _b; int rnti1 = UE_RNTI(params->Mod_idP, UE_id1); int pCC_id1 = UE_PCCID(params->Mod_idP, UE_id1); - int round1 = - maxround(params->Mod_idP, rnti1, params->frameP, params->subframeP, - 1); + int round1 = maxround(params->Mod_idP, rnti1, params->frameP, params->subframeP, 1); int rnti2 = UE_RNTI(params->Mod_idP, UE_id2); int pCC_id2 = UE_PCCID(params->Mod_idP, UE_id2); - int round2 = - maxround(params->Mod_idP, rnti2, params->frameP, params->subframeP, - 1); + int round2 = maxround(params->Mod_idP, rnti2, params->frameP, params->subframeP, 1); int cqi1 = maxcqi(params->Mod_idP, UE_id1); int cqi2 = maxcqi(params->Mod_idP, UE_id2); - if (round1 > round2) - return -1; - if (round1 < round2) - return 1; + for (i = 0; i < CR_NUM; ++i) { + switch (UE_list->sorting_criteria[slice_id][i]) { - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + - UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] > - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) - return -1; - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + - UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) - return 1; + case CR_ROUND : + if (round1 > round2) + return -1; + if (round1 < round2) + return 1; + break; - if (UE_list-> - UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max > - UE_list-> - UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) - return -1; - if (UE_list-> - UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < - UE_list-> - UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) - return 1; + case CR_SRB12 : + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] > + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) + return -1; + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) + return 1; + break; - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total > - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) - return -1; - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) - return 1; + case CR_HOL : + if (UE_list-> UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max > + UE_list-> UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) + return -1; + if (UE_list-> UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < + UE_list-> UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) + return 1; + break; - if (cqi1 > cqi2) - return -1; - if (cqi1 < cqi2) - return 1; + case CR_LC : + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total > + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) + return -1; + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) + return 1; + break; + + case CR_CQI : + if (cqi1 > cqi2) + return -1; + if (cqi1 < cqi2) + return 1; + + default : + break; + } + } return 0; #if 0 @@ -449,40 +461,64 @@ static int ue_dl_compare(const void *_a, const void *_b, void *_params) #endif } +void decode_sorting_policy(module_id_t Mod_idP, slice_id_t slice_id) { + int i; + + UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list; + uint32_t policy = sorting_policy[slice_id]; + uint32_t mask = 0x0000000F; + uint16_t criterion; + + for(i = 0; i < CR_NUM; ++i) { + criterion = (uint16_t)(policy >> 4*(CR_NUM - 1 - i) & mask); + if (criterion >= CR_NUM) { + LOG_W(MAC, "Invalid criterion in slice %d policy, revert to default policy \n", slice_id); + sorting_policy[slice_id] = 0x1234; + break; + } + UE_list->sorting_criteria[slice_id][i] = criterion; + } +} + + // This fuction sorts the UE in order their dlsch buffer and CQI -void sort_UEs(module_id_t Mod_idP, int frameP, sub_frame_t subframeP) +void sort_UEs(module_id_t Mod_idP, slice_id_t slice_id, int frameP, sub_frame_t subframeP) { int i; int list[NUMBER_OF_UE_MAX]; int list_size = 0; int rnti; - struct sort_ue_dl_params params = { Mod_idP, frameP, subframeP }; + struct sort_ue_dl_params params = { Mod_idP, frameP, subframeP, slice_id }; UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] == FALSE) - continue; - if ((rnti = UE_RNTI(Mod_idP, i)) == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; + if (UE_list->active[i] == FALSE) + continue; + if ((rnti = UE_RNTI(Mod_idP, i)) == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + if (!ue_slice_membership(i, slice_id)) + continue; - list[list_size] = i; - list_size++; - } + list[list_size] = i; + list_size++; + } - qsort_r(list, list_size, sizeof(int), ue_dl_compare, ¶ms); + decode_sorting_policy(Mod_idP, slice_id); - if (list_size) { - for (i = 0; i < list_size - 1; i++) - UE_list->next[list[i]] = list[i + 1]; - UE_list->next[list[list_size - 1]] = -1; - UE_list->head = list[0]; - } else { - UE_list->head = -1; - } + qsort_r(list, list_size, sizeof(int), ue_dl_compare, ¶ms); + + if (list_size) { + for (i = 0; i < list_size - 1; i++) + UE_list->next[list[i]] = list[i + 1]; + UE_list->next[list[list_size - 1]] = -1; + UE_list->head = list[0]; + } else { + UE_list->head = -1; + } #if 0 @@ -651,7 +687,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, // Sorts the user on the basis of dlsch logical channel buffer and CQI - sort_UEs(Mod_id, frameP, subframeP); + sort_UEs(Mod_id, slice_id, frameP, subframeP); // loop over all active UEs diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index be09385ac9..348b080d1e 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -675,7 +675,7 @@ void assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, void adjust_bsr_info(int buffer_occupancy, uint16_t TBS, UE_TEMPLATE * UE_template); int phy_stats_exist(module_id_t Mod_id, int rnti); -void sort_UEs (module_id_t Mod_idP, int frameP, sub_frame_t subframeP); +void sort_UEs(module_id_t Mod_idP, slice_id_t slice_id, int frameP, sub_frame_t subframeP); /*! \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. From a4f260f5a4d1e345b34485b23731d9d2d67339bb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Feb 2018 17:50:41 +0100 Subject: [PATCH 136/141] fix: no FLEXRAN_AGENT_SB_IF compilation directive --- targets/SIMU/USER/oaisim.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 9434b2dd83..3a282e1d44 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -988,7 +988,6 @@ l2l1_task (void *args_p) return NULL; } -#if defined(FLEXRAN_AGENT_SB_IF) /* * The following two functions are meant to restart *the lte-softmodem* and are * here to make oaisim compile. A restart command from the controller will be @@ -1005,7 +1004,6 @@ int restart_L1L2(int enb_id) LOG_W(FLEXRAN_AGENT, "restart_L1L2() not supported in oaisim\n"); return 0; } -#endif #if T_TRACER int T_wait = 1; /* by default we wait for the tracer */ From 91332d3906e577df9032a766af4fd4600e2fc2fe Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Wed, 14 Feb 2018 17:49:50 +0100 Subject: [PATCH 137/141] fixup previous bad merge (UE disconnection did not work properly anymore) Doing airplane mode off to connect a cots UE followed by airplane mode on to disconnect it gives very bad results (bad disconnection with lots of UL failures followed by lots of logs in the eNB). It used to work properly after the work done by Xu Bo. It turns out that in 2018.w04 things were still working okay. But in 2018.w05 no. So I ran: git diff 2018.w04 2018.w05 And I checked all the modifications that I thought were relevant (everything related to the UE, oaisim, if4 and fapi has not been checked). This commits takes back the version of 2018.w04. The modifications in openair2/RRC/LITE/rrc_eNB.c are necessary, I think. The other modifications may not be necessary or even wrong. To be checked at some point. --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 2 +- openair1/SCHED/fapi_l1.c | 9 +++-- openair1/SCHED/phy_procedures_lte_eNb.c | 6 ++- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 1 + openair2/RRC/LITE/rrc_eNB.c | 50 +++++++++++++++++++++++-- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index c6c1322504..086f77e14c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -6556,7 +6556,7 @@ uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) else ul_subframe = ((n+4)%10); - // AssertFatal(frame_parms->frame_type == FDD || subframe_select(frame_parms,ul_subframe) == SF_UL,"illegal ul_subframe %d (n %d)\n",ul_subframe,n); + AssertFatal(frame_parms->frame_type == FDD || subframe_select(frame_parms,ul_subframe) == SF_UL,"illegal ul_subframe %d (n %d)\n",ul_subframe,n); LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", n, ul_subframe); return ul_subframe; diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index b9024bdfbf..9c855d0ac8 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -629,7 +629,8 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) fp = &eNB->frame_parms; proc = &eNB->proc.proc_rxtx[0]; - if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)==SF_UL)) return; + /* TODO: check that following line is correct - in the meantime it is disabled */ + //if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)==SF_UL)) return; ul_subframe = pdcch_alloc2ul_subframe(fp,subframe); ul_frame = pdcch_alloc2ul_frame(fp,frame,subframe); @@ -664,8 +665,10 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) int do_oai =0; int dont_send =0; - if ((ul_subframe<10)&& - (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is an ul_subframe that can be configured here + /* TODO: check the following test - in the meantime it is put back as it was before */ + //if ((ul_subframe<10)&& + // (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is an ul_subframe that can be configured here + if (ul_subframe<10) { // This means that there is an ul_subframe that can be configured here LOG_D(PHY,"NFAPI: Clearing dci allocations for potential UL subframe %d\n",ul_subframe); harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 2ae79b53b6..9aaf6752fb 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -452,8 +452,10 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, } /* save old HARQ information needed for PHICH generation */ - if ((ul_subframe < 10)&& - (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is a potential UL subframe that will be scheduled here + /* TODO: check the following test - in the meantime it is put back as it was before */ + //if ((ul_subframe < 10)&& + // (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is a potential UL subframe that will be scheduled here + if (ul_subframe < 10) { // This means that there is a potential UL subframe that will be scheduled here for (i=0; iulsch[i]) { diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index bb264a8906..d5d5da8741 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -634,6 +634,7 @@ pdcp_data_ind( 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, __func__); // free_mem_block(new_sdu, __func__); diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 946da42920..25c04b8cfb 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -6682,26 +6682,58 @@ rrc_rx_tx( RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe==0)) { if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { - LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/20000\n", + LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/8\n", ue_context_p->ue_context.rnti, ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, ue_context_p->ue_context.ul_failure_timer); } else { - LOG_I(RRC,"UE rnti %x failure timer %d/20000\n", + LOG_I(RRC,"UE rnti %x failure timer %d/8\n", ue_context_p->ue_context.rnti, ue_context_p->ue_context.ul_failure_timer); } } if (ue_context_p->ue_context.ul_failure_timer>0) { ue_context_p->ue_context.ul_failure_timer++; - if (ue_context_p->ue_context.ul_failure_timer >= 20000) { + if (ue_context_p->ue_context.ul_failure_timer >= 8) { // remove UE after 20 seconds after MAC has indicated UL failure LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); ue_to_be_removed = ue_context_p; break; } } + if (ue_context_p->ue_context.ue_release_timer_s1>0) { + ue_context_p->ue_context.ue_release_timer_s1++; + if (ue_context_p->ue_context.ue_release_timer_s1 >= + ue_context_p->ue_context.ue_release_timer_thres_s1) { + LOG_I(RRC,"Removing UE %x instance Because of UE_CONTEXT_RELEASE_COMMAND not received after %d ms from sending request\n", + ue_context_p->ue_context.rnti, ue_context_p->ue_context.ue_release_timer_thres_s1); + ue_to_be_removed = ue_context_p; + break; + } + } + + if (ue_context_p->ue_context.ue_release_timer_rrc>0) { + ue_context_p->ue_context.ue_release_timer_rrc++; + if (ue_context_p->ue_context.ue_release_timer_rrc >= + ue_context_p->ue_context.ue_release_timer_thres_rrc) { + LOG_I(RRC,"Removing UE %x instance After UE_CONTEXT_RELEASE_Complete\n", ue_context_p->ue_context.rnti); + ue_to_be_removed = ue_context_p; + break; + } + } + + if (ue_context_p->ue_context.ue_reestablishment_timer>0) { + ue_context_p->ue_context.ue_reestablishment_timer++; + if (ue_context_p->ue_context.ue_reestablishment_timer >= + ue_context_p->ue_context.ue_reestablishment_timer_thres) { + LOG_I(RRC,"UE %d reestablishment_timer max\n",ue_context_p->ue_context.rnti); + ue_context_p->ue_context.ul_failure_timer = 20000; + ue_to_be_removed = ue_context_p; + ue_context_p->ue_context.ue_reestablishment_timer = 0; + break; + } + } if (ue_context_p->ue_context.ue_release_timer>0) { ue_context_p->ue_context.ue_release_timer++; if (ue_context_p->ue_context.ue_release_timer >= @@ -6712,8 +6744,18 @@ rrc_rx_tx( } } } - if (ue_to_be_removed) + if (ue_to_be_removed) { + if(ue_to_be_removed->ue_context.ul_failure_timer >= 8) { + ue_to_be_removed->ue_context.ue_release_timer_s1 = 1; + ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100; + ue_to_be_removed->ue_context.ue_release_timer = 0; + ue_to_be_removed->ue_context.ue_reestablishment_timer = 0; + } rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed); + if(ue_to_be_removed->ue_context.ul_failure_timer >= 8){ + ue_to_be_removed->ue_context.ul_failure_timer = 0; + } + } #ifdef RRC_LOCALIZATION From e4a5470d4754b674d833b7af85f74dda0c742bcc Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 15 Feb 2018 11:34:53 +0100 Subject: [PATCH 138/141] integration fix: noS1 compilation The following compilation did not work anymore: ./build_oai --eNB -c -w USRP --noS1 Neither did: ./build_oai --UE --noS1 --- openair2/RRC/LITE/defs.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index 01475715f4..08ac30f836 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -65,6 +65,9 @@ #include "UE-EUTRA-Capability.h" #include "MeasResults.h" +/* for ImsiMobileIdentity_t */ +#include "MobileIdentity.h" + /* correct Rel(8|10)/Rel14 differences * the code is in favor of Rel14, those defines do the translation */ From b2ac257ef5b728c52912ba7156ad2ff01f1c346f Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 15 Feb 2018 13:40:34 +0100 Subject: [PATCH 139/141] integration fix: compilation failed The following compilation failed before this commit: ./build_oai --eNB -w USRP -c --T-tracer --- openair2/ENB_APP/enb_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index a1d3da9ccc..481bfaa521 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -204,7 +204,7 @@ void *eNB_app_task(void *args_p) switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: - LOG_W(TASK_ENB_APP, " *** Exiting ENB_APP thread\n"); + LOG_W(ENB_APP, " *** Exiting ENB_APP thread\n"); itti_exit_task (); break; From c0be5a129cae522ea29c29039403ca775128b587 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 15 Feb 2018 16:50:30 +0100 Subject: [PATCH 140/141] integration fix: set default max MCS for UL back to 20 Doing an iperf UDP uplink test, we could reach only 6Mb/s with very good radio conditions instead of around 8Mb/s. It turns out the MCS was limited to 16. With this commit, we are back to a bit more than 8Mb/s as it used to be. (This is with a 5MHz bandwidth.) --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index a8d686dac9..ac87498560 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -95,8 +95,8 @@ float total_slice_percentage_uplink = 0; float total_slice_percentage_current_uplink = 0; // MAX MCS for each slice for past and current time -int slice_maxmcs_uplink[MAX_NUM_SLICES] = {16, 16, 16, 16}; -int slice_maxmcs_current_uplink[MAX_NUM_SLICES] = {16,16,16,16}; +int slice_maxmcs_uplink[MAX_NUM_SLICES] = {20, 20, 20, 20}; +int slice_maxmcs_current_uplink[MAX_NUM_SLICES] = {20,20,20,20}; /*resource blocks allowed*/ uint16_t nb_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; From 2d6dd02b95321cef2349dbc17dc8fb3461f6c4c6 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 16 Feb 2018 11:08:39 +0100 Subject: [PATCH 141/141] bugfix: fix bad conflict resolutions from previous commits Some more fixes for some bad conflict resolutions. I ran: git diff 2018.w04 2018.w05 And saw some problems with config_sib2. There was also something strange in openair2/LAYER2/openair2_proc.c in the function dump_eNB_l2_stats. Maybe the fix is wrong for this one. To be checked. --- openair2/LAYER2/MAC/config.c | 242 ++++++++++++++++++++------------ openair2/LAYER2/openair2_proc.c | 4 +- 2 files changed, 156 insertions(+), 90 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 55585acd23..f45cc45af1 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -437,59 +437,31 @@ config_sib2(int Mod_idP, cfg->num_tlv++; - nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP]; - - cfg->subframe_config.pb.value = radioResourceConfigCommonP->pdsch_ConfigCommon.p_b; - cfg->rf_config.reference_signal_power.value = radioResourceConfigCommonP->pdsch_ConfigCommon.referenceSignalPower; - cfg->nfapi_config.max_transmit_power.value = cfg->rf_config.reference_signal_power.value + - power_off_dB[cfg->rf_config.dl_channel_bandwidth.value]; - - cfg->prach_config.configuration_index.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.prach_ConfigIndex; - cfg->prach_config.root_sequence_index.value = radioResourceConfigCommonP->prach_Config.rootSequenceIndex; - cfg->prach_config.zero_correlation_zone_configuration.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; - cfg->prach_config.high_speed_flag.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.highSpeedFlag; - cfg->prach_config.frequency_offset.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.prach_FreqOffset; - - cfg->pusch_config.hopping_mode.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; - cfg->pusch_config.number_of_subbands.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; - cfg->pusch_config.hopping_offset.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; - - cfg->pucch_config.delta_pucch_shift.value = radioResourceConfigCommonP->pucch_ConfigCommon.deltaPUCCH_Shift; - cfg->pucch_config.n_cqi_rb.value = radioResourceConfigCommonP->pucch_ConfigCommon.nRB_CQI; - cfg->pucch_config.n_an_cs.value = radioResourceConfigCommonP->pucch_ConfigCommon.nCS_AN; - cfg->pucch_config.n1_pucch_an.value = radioResourceConfigCommonP->pucch_ConfigCommon.n1PUCCH_AN; - - if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled == true) - cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 1; - else if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled == true) - cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 2; - else // No hopping - cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 0; - - cfg->uplink_reference_signal_config.group_assignment.value = radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; - cfg->uplink_reference_signal_config.cyclic_shift_1_for_drms.value = radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift; - - // how to enable/disable SRS? - if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.present == SoundingRS_UL_ConfigCommon_PR_setup) { - cfg->srs_config.bandwidth_configuration.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig; - cfg->srs_config.srs_subframe_configuration.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig; - cfg->srs_config.srs_acknack_srs_simultaneous_transmission.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; - - if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) - cfg->srs_config.max_up_pts.value = 1; - else - cfg->srs_config.max_up_pts.value = 0; + if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) { + cfg->srs_config.max_up_pts.value = 1; } + else { + cfg->srs_config.max_up_pts.value = 0; + } + cfg->srs_config.max_up_pts.tl.tag = NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG; + cfg->num_tlv++; } + #ifdef Rel14 if (RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.schedulingInfoSIB1_BR_r13 > 0) { - AssertFatal(radioResourceConfigCommon_BRP != NULL, - "radioResource rou is missing\n"); - AssertFatal(radioResourceConfigCommon_BRP->ext4 != NULL, - "ext4 is missing\n"); + AssertFatal(radioResourceConfigCommon_BRP != NULL, "radioResource rou is missing\n"); + AssertFatal(radioResourceConfigCommon_BRP->ext4 != NULL, "ext4 is missing\n"); cfg->emtc_config.prach_catm_root_sequence_index.value = radioResourceConfigCommon_BRP->prach_Config.rootSequenceIndex; + cfg->emtc_config.prach_catm_root_sequence_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.value = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; + cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_catm_high_speed_flag.value = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.highSpeedFlag; + cfg->emtc_config.prach_catm_high_speed_flag.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG; + cfg->num_tlv++; struct PRACH_ConfigSIB_v1310 *ext4_prach = radioResourceConfigCommon_BRP->ext4->prach_ConfigCommon_v1310; @@ -497,94 +469,186 @@ config_sib2(int Mod_idP, PRACH_ParametersCE_r13_t *p; cfg->emtc_config.prach_ce_level_0_enable.value = 0; + cfg->emtc_config.prach_ce_level_0_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_enable.value = 0; + cfg->emtc_config.prach_ce_level_1_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_enable.value = 0; + cfg->emtc_config.prach_ce_level_2_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_3_enable.value = 0; + cfg->emtc_config.prach_ce_level_3_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG; + cfg->num_tlv++; + switch (prach_ParametersListCE_r13->list.count) { case 4: p = prach_ParametersListCE_r13->list.array[3]; cfg->emtc_config.prach_ce_level_3_enable.value = 1; + cfg->emtc_config.prach_ce_level_3_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_3_configuration_index.value = p->prach_ConfigIndex_r13; + cfg->emtc_config.prach_ce_level_3_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_3_frequency_offset.value = p->prach_FreqOffset_r13; + cfg->emtc_config.prach_ce_level_3_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13; - if (p->prach_StartingSubframe_r13) + cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + cfg->num_tlv++; + + if (p->prach_StartingSubframe_r13) { cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value = *p->prach_StartingSubframe_r13; + cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->num_tlv++; + } + cfg->emtc_config.prach_ce_level_3_hopping_enable.value = p->prach_HoppingConfig_r13; + cfg->emtc_config.prach_ce_level_3_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_3_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + cfg->emtc_config.prach_ce_level_3_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG; + cfg->num_tlv++; + case 3: p = prach_ParametersListCE_r13->list.array[2]; cfg->emtc_config.prach_ce_level_2_enable.value = 1; + cfg->emtc_config.prach_ce_level_2_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_configuration_index.value = p->prach_ConfigIndex_r13; + cfg->emtc_config.prach_ce_level_2_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_frequency_offset.value = p->prach_FreqOffset_r13; + cfg->emtc_config.prach_ce_level_2_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13; - if (p->prach_StartingSubframe_r13) + cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + cfg->num_tlv++; + + if (p->prach_StartingSubframe_r13) { cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value = *p->prach_StartingSubframe_r13; + cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->num_tlv++; + } + cfg->emtc_config.prach_ce_level_2_hopping_enable.value = p->prach_HoppingConfig_r13; + cfg->emtc_config.prach_ce_level_2_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + cfg->emtc_config.prach_ce_level_2_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG; + cfg->num_tlv++; + case 2: p = prach_ParametersListCE_r13->list.array[1]; cfg->emtc_config.prach_ce_level_1_enable.value = 1; + cfg->emtc_config.prach_ce_level_1_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_configuration_index.value = p->prach_ConfigIndex_r13; + cfg->emtc_config.prach_ce_level_1_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_frequency_offset.value = p->prach_FreqOffset_r13; + cfg->emtc_config.prach_ce_level_1_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13; - if (p->prach_StartingSubframe_r13) + cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + cfg->num_tlv++; + + if (p->prach_StartingSubframe_r13) { cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value = *p->prach_StartingSubframe_r13; + cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->num_tlv++; + } + cfg->emtc_config.prach_ce_level_1_hopping_enable.value = p->prach_HoppingConfig_r13; + cfg->emtc_config.prach_ce_level_1_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + cfg->emtc_config.prach_ce_level_1_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG; + cfg->num_tlv++; + case 1: p = prach_ParametersListCE_r13->list.array[0]; cfg->emtc_config.prach_ce_level_0_enable.value = 1; + cfg->emtc_config.prach_ce_level_0_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_configuration_index.value = p->prach_ConfigIndex_r13; + cfg->emtc_config.prach_ce_level_0_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_frequency_offset.value = p->prach_FreqOffset_r13; + cfg->emtc_config.prach_ce_level_0_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13; - if (p->prach_StartingSubframe_r13) + cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + cfg->num_tlv++; + + if (p->prach_StartingSubframe_r13) { cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value = *p->prach_StartingSubframe_r13; + cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->num_tlv++; + } + cfg->emtc_config.prach_ce_level_0_hopping_enable.value = p->prach_HoppingConfig_r13; + cfg->emtc_config.prach_ce_level_0_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + cfg->emtc_config.prach_ce_level_0_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG; + cfg->num_tlv++; } struct FreqHoppingParameters_r13 *ext4_freqHoppingParameters = radioResourceConfigCommonP->ext4->freqHoppingParameters_r13; - if ((ext4_freqHoppingParameters)&& - (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13)) - { - switch (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->present) { - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_NOTHING: /* No components present */ - break; - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_FDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = - ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13-> - choice.interval_FDD_r13; - break; - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_TDD_r13: - cfg->emtc_config. - pucch_interval_ulhoppingconfigcommonmodea.value = - ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13-> - choice.interval_TDD_r13; - break; - } - } if ((ext4_freqHoppingParameters) && - (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13)) - { - switch - (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13-> - present) { - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_NOTHING: /* No components present */ - break; - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_FDD_r13: - cfg->emtc_config. - pucch_interval_ulhoppingconfigcommonmodeb.value = - ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13-> - choice.interval_FDD_r13; - break; - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_TDD_r13: - cfg->emtc_config. - pucch_interval_ulhoppingconfigcommonmodeb.value = - ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13-> - choice.interval_TDD_r13; - break; - } + (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13)){ + switch(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->present) { + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_NOTHING: /* No components present */ + break; + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_FDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_FDD_r13; + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; + cfg->num_tlv++; + break; + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_TDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_TDD_r13; + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; + cfg->num_tlv++; + break; } + } + if ((ext4_freqHoppingParameters) && + (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13)){ + switch(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->present) { + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_NOTHING: /* No components present */ + break; + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_FDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_FDD_r13; + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; + cfg->num_tlv++; + break; + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_TDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_TDD_r13; + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; + cfg->num_tlv++; + break; + } + } } #endif diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c index f66d1142ab..7cb6ce0d2c 100644 --- a/openair2/LAYER2/openair2_proc.c +++ b/openair2/LAYER2/openair2_proc.c @@ -228,7 +228,9 @@ int dump_eNB_l2_stats(char *buffer, int length) PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, eNB_id, ENB_FLAG_YES, - UE_list->eNB_UE_stats[0][UE_id].crnti,//UE_PCCID(eNB_id,UE_id)][UE_id].crnti, + /* the following is suspicious, let's put back what was there before */ + /*UE_list->eNB_UE_stats[0][UE_id].crnti,//UE_PCCID(eNB_id,UE_id)][UE_id].crnti, */ + UE_list->eNB_UE_stats[UE_PCCID(eNB_id,UE_id)][UE_id].crnti, eNB->frame, eNB->subframe, eNB_id);