From 0b83862fc29012effdba3147a4b3eb6d1b40984c Mon Sep 17 00:00:00 2001 From: shahab SHARIATBAGHERI Date: Tue, 28 Mar 2017 18:28:30 +0200 Subject: [PATCH 01/64] 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 02/64] 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 03/64] 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 04/64] 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 05/64] 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 06/64] 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 07/64] 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 08/64] 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 09/64] 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 10/64] 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 11/64] 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 12/64] 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 13/64] 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 14/64] 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 15/64] 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 16/64] 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 17/64] 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 18/64] 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 19/64] 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 20/64] 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 21/64] 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 22/64] 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 23/64] 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 24/64] 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 25/64] 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 26/64] 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 27/64] 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 28/64] 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 29/64] 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 30/64] 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 31/64] 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 32/64] 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 33/64] 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 34/64] 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 35/64] 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 36/64] 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 37/64] 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 38/64] 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 39/64] 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 40/64] 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 41/64] 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 42/64] 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 43/64] 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 44/64] *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 45/64] 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 46/64] 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 47/64] 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 48/64] 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 49/64] 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 50/64] 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 51/64] 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 52/64] 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 53/64] 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 54/64] 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 55/64] 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 56/64] 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 57/64] 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 58/64] 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 59/64] 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 60/64] 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 61/64] 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 62/64] 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 63/64] 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 64/64] 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; } }