From 7ea7af3ab81b8605e5df91d2d30eafb97151d1c6 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Fri, 24 Aug 2018 08:56:06 +0200 Subject: [PATCH 01/43] initial commit --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..3e530027e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +cmake_targets/log/ +cmake_targets/lte_build_oai/ +targets/bin/ -- GitLab From a8f6accc9a4bb8dac375ce894b3083b04ba2fccc Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Mon, 27 Aug 2018 14:41:29 +0200 Subject: [PATCH 02/43] rm .gitignore for repo consistancy --- .gitignore | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 3e530027e0..0000000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -cmake_targets/log/ -cmake_targets/lte_build_oai/ -targets/bin/ -- GitLab From c12e3234b035b8960374c0b6d25397181f3b815e Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Tue, 28 Aug 2018 14:03:37 +0200 Subject: [PATCH 03/43] modification of tracer/gui/x.c for T tracer to work on screen --- common/utils/T/tracer/gui/x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/utils/T/tracer/gui/x.c b/common/utils/T/tracer/gui/x.c index 94448eb666..9c7456b5cd 100644 --- a/common/utils/T/tracer/gui/x.c +++ b/common/utils/T/tracer/gui/x.c @@ -141,7 +141,7 @@ x_image *x_create_image(x_connection *_x, unsigned char *data, ret = calloc(1, sizeof(struct x_image)); if (ret == NULL) OOM; template.class = TrueColor; - template.depth = 24; + template.depth = 32; template.red_mask = 0xff0000; template.green_mask = 0x00ff00; template.blue_mask = 0x0000ff; -- GitLab From ec702c88f38fb716f251f0fc1bafa6706b791cd2 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Wed, 29 Aug 2018 14:27:09 +0200 Subject: [PATCH 04/43] Commentaries modifications --- openair2/RRC/LTE/MESSAGES/asn1_msg.c | 48 +++++++++---------- openair2/RRC/LTE/MESSAGES/asn1_msg.h | 2 +- .../asn1c/ASN1_files/lte-rrc-13.9.1.asn1 | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index 66aae4237a..41e72d59c1 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -183,45 +183,45 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich { asn_enc_rval_t enc_rval; - BCCH_BCH_Message_t *mib=&carrier->mib ; + BCCH_BCH_Message_t *mib = &carrier->mib ; uint8_t sfn = (uint8_t)((frame>>2)&0xff); - uint16_t *spare= calloc(1, sizeof(uint16_t)); + uint16_t *spare = calloc(1, sizeof(uint16_t)); if (spare == NULL) abort(); switch (N_RB_DL) { + + case 6: + mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6; + break; - case 6: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6; - break; - - case 15: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n15; - break; + case 15: + mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n15; + break; - case 25: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n25; - break; + case 25: + mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n25; + break; - case 50: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n50; - break; + case 50: + mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n50; + break; - case 75: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n75; - break; + case 75: + mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n75; + break; - case 100: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n100; - break; - default: - AssertFatal(1==0,"Unknown dl_Bandwidth %d\n",N_RB_DL); + case 100: + mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n100; + break; + default: + AssertFatal(1==0,"Unknown dl_Bandwidth %d\n",N_RB_DL); } AssertFatal(phich_Resource <= PHICH_Config__phich_Resource_two,"Illegal phich_Resource\n"); mib->message.phich_Config.phich_Resource = phich_Resource; AssertFatal(phich_duration <= PHICH_Config__phich_Duration_extended,"Illegal phich_Duration\n"); mib->message.phich_Config.phich_Duration = phich_duration; - LOG_I(RRC,"[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x,sfn %x\n", + LOG_I(RRC,"[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x, sfn %x\n", (uint32_t)mib->message.dl_Bandwidth, (uint32_t)phich_duration, (uint32_t)phich_Resource, diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h index a4da38c019..db24521cd5 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h @@ -57,7 +57,7 @@ uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index); uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId); /** -\brief Generate configuration for SIB1 (eNB). +\brief Generate configuration for MIB (eNB). @param carrier pointer to Carrier information @param N_RB_DL Number of downlink PRBs @param phich_Resource PHICH resoure parameter diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 index b6f64a99ed..ceb4a7cd37 100755 --- a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 +++ b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 @@ -735,7 +735,7 @@ Paging-v1130-IEs ::= SEQUENCE { } Paging-v1310-IEs ::= SEQUENCE { - redistributionIndication-r13 ENUMERATED {true} OPTIONAL, --Need ON + redistributionIndication-r13 ENUMERATED {true} OPTIONAL, -- Need ON systemInfoModification-eDRX-r13 ENUMERATED {true} OPTIONAL, -- Need ON nonCriticalExtension SEQUENCE {} OPTIONAL } -- GitLab From 80920618e6e62b8ce6c1fb4009114ead7095a489 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Fri, 31 Aug 2018 14:14:28 +0200 Subject: [PATCH 05/43] Code guidelines --- openair2/RRC/LTE/MESSAGES/asn1_msg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index 41e72d59c1..373a3efa48 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -183,13 +183,13 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich { asn_enc_rval_t enc_rval; - BCCH_BCH_Message_t *mib = &carrier->mib ; + BCCH_BCH_Message_t *mib = &carrier->mib; uint8_t sfn = (uint8_t)((frame>>2)&0xff); uint16_t *spare = calloc(1, sizeof(uint16_t)); if (spare == NULL) abort(); switch (N_RB_DL) { - + case 6: mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6; break; @@ -698,6 +698,9 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->pcch_defaultPagingCycle[CC_id]; (*sib2)->radioResourceConfigCommon.pcch_Config.nB = configuration->pcch_nB[CC_id]; + LOG_E(RRC,"[SIB2] With ITTI. Basic config of paging cycle DRX: radio frame cycle length %x, paging occasion number %x\n", + (uint32_t)configuration->pcch_defaultPagingCycle[CC_id], + (uint32_t)configuration->pcch_nB[CC_id]); // PRACH-Config (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex -- GitLab From 506edcaec26869922c0da3d2cb36743648c3a0b7 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 20 Oct 2018 09:16:24 +0200 Subject: [PATCH 06/43] lowered debug level for RF simulator --- targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf index ba2e7f1ada..750936cfea 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf @@ -31,9 +31,9 @@ log_config = { global_log_verbosity ="medium"; hw_log_level ="info"; hw_log_verbosity ="medium"; - phy_log_level ="debug"; + phy_log_level ="info"; phy_log_verbosity ="medium"; - mac_log_level ="debug"; + mac_log_level ="info"; mac_log_verbosity ="high"; rlc_log_level ="info"; rlc_log_verbosity ="medium"; -- GitLab From 2e5ae1eac65ee07935501d9c8da18b150c698b2f Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Tue, 23 Oct 2018 16:20:14 +0200 Subject: [PATCH 07/43] Format of function rrc_rx_tx() --- openair2/RRC/LTE/rrc_eNB.c | 310 +++++++++++++++++++++---------------- 1 file changed, 175 insertions(+), 135 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 00f814b8b1..6bce1c21f0 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -7705,7 +7705,6 @@ SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool( const protocol_ctxt_t* cons return *sl_CommConfig; } - SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, int n_discoveryMessages ){ //TODO SL_DiscConfig_r12_t sl_DiscConfig; @@ -7717,178 +7716,213 @@ SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( const protocol_ctxt_t* cons //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discTxConfig_r12; return sl_DiscConfig; } + RRC_status_t rrc_rx_tx( protocol_ctxt_t* const ctxt_pP, - const int CC_id + const int CC_id ) //----------------------------------------------------------------------------- { - //uint8_t UE_id; - int32_t current_timestamp_ms, ref_timestamp_ms; + int32_t current_timestamp_ms = 0; + int32_t ref_timestamp_ms = 0; struct timeval ts; - struct rrc_eNB_ue_context_s *ue_context_p = NULL,*ue_to_be_removed = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_to_be_removed = NULL; #ifdef LOCALIZATION - double estimated_distance; - protocol_ctxt_t ctxt; + + double estimated_distance = 0; + protocol_ctxt_t ctxt; + #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN); - check_handovers(ctxt_pP); - // counetr, and get the value and aggregate + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX, VCD_FUNCTION_IN); - // check for UL failure + check_handovers(ctxt_pP); // counter, get the value and aggregate + + // check for UL failure or for UE to be released RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { ctxt_pP->rnti = ue_context_p->ue_id_rnti; - if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe==0)) { - if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { - LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/8\n", - ue_context_p->ue_context.rnti, - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, - ue_context_p->ue_context.ul_failure_timer); - } - else { - LOG_I(RRC,"UE rnti %x failure timer %d/8\n", - ue_context_p->ue_context.rnti, - ue_context_p->ue_context.ul_failure_timer); - } + + if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe == 0)) { + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { + LOG_I(RRC, "UE rnti %x: S-TMSI %x failure timer %d/8\n", + ue_context_p->ue_context.rnti, + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.ul_failure_timer); + } else { + LOG_I(RRC, "UE rnti %x failure timer %d/8\n", + ue_context_p->ue_context.rnti, + ue_context_p->ue_context.ul_failure_timer); + } } - if (ue_context_p->ue_context.ul_failure_timer>0) { - ue_context_p->ue_context.ul_failure_timer++; - if (ue_context_p->ue_context.ul_failure_timer >= 20000) { - // remove UE after 20 seconds after MAC has indicated UL failure - LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); - ue_to_be_removed = ue_context_p; - break; - } + + if (ue_context_p->ue_context.ul_failure_timer > 0) { + ue_context_p->ue_context.ul_failure_timer++; + + if (ue_context_p->ue_context.ul_failure_timer >= 20000) { + // remove UE after 20 seconds after MAC (or else) has indicated UL failure + LOG_I(RRC, "Removing UE %x instance, because of uplink failure timer timeout\n", + ue_context_p->ue_context.rnti); + + ue_to_be_removed = ue_context_p; + break; // break RB_FOREACH + } } - if (ue_context_p->ue_context.ue_release_timer_s1>0) { + + if (ue_context_p->ue_context.ue_release_timer_s1 > 0) { ue_context_p->ue_context.ue_release_timer_s1++; - if (ue_context_p->ue_context.ue_release_timer_s1 >= - ue_context_p->ue_context.ue_release_timer_thres_s1) { - LOG_I(RRC,"Removing UE %x instance Because of UE_CONTEXT_RELEASE_COMMAND not received after %d ms from sending request\n", - ue_context_p->ue_context.rnti, ue_context_p->ue_context.ue_release_timer_thres_s1); -// ue_context_p->ue_context.ue_release_timer_s1 = 0; + + if (ue_context_p->ue_context.ue_release_timer_s1 >= ue_context_p->ue_context.ue_release_timer_thres_s1) { + LOG_I(RRC, "Removing UE %x instance, because of UE_CONTEXT_RELEASE_COMMAND not received after %d ms from sending request\n", + ue_context_p->ue_context.rnti, + ue_context_p->ue_context.ue_release_timer_thres_s1); + #if defined(ENABLE_USE_MME) #if defined(ENABLE_ITTI) + rrc_eNB_generate_RRCConnectionRelease(ctxt_pP, ue_context_p); + #endif #else + ue_to_be_removed = ue_context_p; + #endif ue_context_p->ue_context.ue_release_timer_s1 = 0; - break; - } - } + break; // break RB_FOREACH + } // end if timer_s1 timeout + } // end if timer_s1 > 0 (S1 UE_CONTEXT_RELEASE_REQ ongoing) - if (ue_context_p->ue_context.ue_release_timer_rrc>0) { + if (ue_context_p->ue_context.ue_release_timer_rrc > 0) { ue_context_p->ue_context.ue_release_timer_rrc++; - if (ue_context_p->ue_context.ue_release_timer_rrc >= - ue_context_p->ue_context.ue_release_timer_thres_rrc) { - LOG_I(RRC,"Removing UE %x instance After UE_CONTEXT_RELEASE_Complete\n", ue_context_p->ue_context.rnti); + + if (ue_context_p->ue_context.ue_release_timer_rrc >= ue_context_p->ue_context.ue_release_timer_thres_rrc) { + LOG_I(RRC, "Removing UE %x instance after UE_CONTEXT_RELEASE_Complete (ue_release_timer_rrc timeout)\n", + ue_context_p->ue_context.rnti); + ue_context_p->ue_context.ue_release_timer_rrc = 0; ue_to_be_removed = ue_context_p; - ue_context_p->ue_context.ue_release_timer_rrc = 0; - break; + break; // break RB_FOREACH } } - pthread_mutex_lock(&rrc_release_freelist); - if(rrc_release_info.num_UEs > 0){ + + pthread_mutex_lock(&rrc_release_freelist); + if (rrc_release_info.num_UEs > 0) { uint16_t release_total = 0; - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ + + for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if (rrc_release_info.RRC_release_ctrl[release_num].flag > 0) { release_total++; } - if( (rrc_release_info.RRC_release_ctrl[release_num].flag > 2) && - (rrc_release_info.RRC_release_ctrl[release_num].rnti == ue_context_p->ue_context.rnti)){ - ue_context_p->ue_context.ue_release_timer_rrc = 1; - ue_context_p->ue_context.ue_release_timer_thres_rrc = 100; + + if ((rrc_release_info.RRC_release_ctrl[release_num].flag > 2) && + (rrc_release_info.RRC_release_ctrl[release_num].rnti == ue_context_p->ue_context.rnti)) { + + ue_context_p->ue_context.ue_release_timer_rrc = 1; + ue_context_p->ue_context.ue_release_timer_thres_rrc = 100; + #if defined(ENABLE_USE_MME) #if defined(ENABLE_ITTI) - int e_rab; - MessageDef *msg_complete_p = NULL; - MessageDef *msg_delete_tunnels_p = NULL; - uint32_t eNB_ue_s1ap_id = ue_context_p->ue_context.eNB_ue_s1ap_id; - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 4){ - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - NULL,0, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", - eNB_ue_s1ap_id); - msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); - S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - itti_send_msg_to_task(TASK_S1AP, ctxt_pP->module_id, msg_complete_p); - } - MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_GTPU_ENB, NULL,0, "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ", eNB_ue_s1ap_id); - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); - memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); - // do not wait response - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - for (e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = - ue_context_p->ue_context.enb_gtp_ebi[e_rab]; - // erase data - ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; - memset(&ue_context_p->ue_context.enb_gtp_addrs[e_rab], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); - ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; - } - itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->module_id, msg_delete_tunnels_p); - struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; - rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids( - RC.rrc[ctxt_pP->module_id], - 0, - eNB_ue_s1ap_id); - if (NULL != rrc_ue_s1ap_ids) { - rrc_eNB_S1AP_remove_ue_ids( - RC.rrc[ctxt_pP->module_id], - rrc_ue_s1ap_ids); - } + + int e_rab = 0; + MessageDef *msg_complete_p = NULL; + MessageDef *msg_delete_tunnels_p = NULL; + uint32_t eNB_ue_s1ap_id = ue_context_p->ue_context.eNB_ue_s1ap_id; + + if (rrc_release_info.RRC_release_ctrl[release_num].flag == 4) { // if timer_s1 == 0 + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_S1AP_ENB, NULL, 0, + "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", + eNB_ue_s1ap_id); + + msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); + S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; + itti_send_msg_to_task(TASK_S1AP, ctxt_pP->module_id, msg_complete_p); + } + + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_GTPU_ENB, NULL,0, "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ", eNB_ue_s1ap_id); + + msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); + memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); + + // do not wait response + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; + + for (e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = + ue_context_p->ue_context.enb_gtp_ebi[e_rab]; + + // erase data + ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; + memset(&ue_context_p->ue_context.enb_gtp_addrs[e_rab], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); + ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; + } + + itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->module_id, msg_delete_tunnels_p); + + struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; + + rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[ctxt_pP->module_id], 0, eNB_ue_s1ap_id); + + if (rrc_ue_s1ap_ids != NULL) { + rrc_eNB_S1AP_remove_ue_ids(RC.rrc[ctxt_pP->module_id], rrc_ue_s1ap_ids); + } + #endif #endif + rrc_release_info.RRC_release_ctrl[release_num].flag = 0; - rrc_release_info.num_UEs--; - break; - } - if(release_total >= rrc_release_info.num_UEs) - break; - } - } - pthread_mutex_unlock(&rrc_release_freelist); + rrc_release_info.num_UEs--; + break; // break for (release_num) + } // end if ((rrc_release_info.RRC_release_ctrl[release_num].flag > 2) && ... - if (ue_context_p->ue_context.ue_reestablishment_timer>0) { + if (release_total >= rrc_release_info.num_UEs) { + break; // break for (release_num) + } + } // end for (release_num) + } // end if (rrc_release_info.num_UEs > 0) + pthread_mutex_unlock(&rrc_release_freelist); + + if (ue_context_p->ue_context.ue_reestablishment_timer > 0) { ue_context_p->ue_context.ue_reestablishment_timer++; - if (ue_context_p->ue_context.ue_reestablishment_timer >= - ue_context_p->ue_context.ue_reestablishment_timer_thres) { - LOG_I(RRC,"UE %d reestablishment_timer max\n",ue_context_p->ue_context.rnti); - ue_context_p->ue_context.ul_failure_timer = 20000; + + if (ue_context_p->ue_context.ue_reestablishment_timer >= ue_context_p->ue_context.ue_reestablishment_timer_thres) { + LOG_I(RRC, "Removing UE %x instance because of reestablishment_timer timeout\n", + ue_context_p->ue_context.rnti); + + ue_context_p->ue_context.ul_failure_timer = 20000; // lead to send S1 UE_CONTEXT_RELEASE_REQ ue_to_be_removed = ue_context_p; ue_context_p->ue_context.ue_reestablishment_timer = 0; - break; + break; // break RB_FOREACH } } - if (ue_context_p->ue_context.ue_release_timer>0) { - ue_context_p->ue_context.ue_release_timer++; - if (ue_context_p->ue_context.ue_release_timer >= - ue_context_p->ue_context.ue_release_timer_thres) { - LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); - ue_to_be_removed = ue_context_p; + if (ue_context_p->ue_context.ue_release_timer > 0) { + ue_context_p->ue_context.ue_release_timer++; + + if (ue_context_p->ue_context.ue_release_timer >= ue_context_p->ue_context.ue_release_timer_thres) { + LOG_I(RRC, "Removing UE %x instance because of RRC Connection Setup timer timeout\n", + ue_context_p->ue_context.rnti); + + ue_to_be_removed = ue_context_p; ue_context_p->ue_context.ue_release_timer = 0; - break; - } + break; // break RB_FOREACH + } } - } + } // end RB_FOREACH + if (ue_to_be_removed) { - if(ue_to_be_removed->ue_context.ul_failure_timer >= 20000) { - ue_to_be_removed->ue_context.ue_release_timer_s1 = 1; - ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100; - ue_to_be_removed->ue_context.ue_release_timer = 0; - ue_to_be_removed->ue_context.ue_reestablishment_timer = 0; + if (ue_to_be_removed->ue_context.ul_failure_timer >= 20000) { + ue_to_be_removed->ue_context.ue_release_timer_s1 = 1; + ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100; + ue_to_be_removed->ue_context.ue_release_timer = 0; + ue_to_be_removed->ue_context.ue_reestablishment_timer = 0; } - rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed); - if(ue_to_be_removed->ue_context.ul_failure_timer >= 20000){ + + rrc_eNB_free_UE(ctxt_pP->module_id, ue_to_be_removed); + + if (ue_to_be_removed->ue_context.ul_failure_timer >= 20000) { ue_to_be_removed->ue_context.ul_failure_timer = 0; } } @@ -7897,37 +7931,43 @@ rrc_rx_tx( /* for the localization, only primary CC_id might be relevant*/ gettimeofday(&ts, NULL); + current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; ref_timestamp_ms = RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms; + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { ctxt = *ctxt_pP; ctxt.rnti = ue_context_p->ue_context.rnti; - estimated_distance = rrc_get_estimated_ue_distance( - &ctxt, - CC_id, - RC.rrc[ctxt_pP->module_id]->loc_type); + + estimated_distance = rrc_get_estimated_ue_distance(&ctxt, CC_id, RC.rrc[ctxt_pP->module_id]->loc_type); if ((current_timestamp_ms - ref_timestamp_ms > RC.rrc[ctxt_pP->module_id]->aggregation_period_ms) && estimated_distance != -1) { - LOG_D(LOCALIZE, " RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n", + + LOG_D(LOCALIZE, "RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n", ctxt.rnti, ctxt_pP->module_id, current_timestamp_ms, ctxt_pP->frame, estimated_distance); - LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.Status); - push_front(&RC.rrc[ctxt_pP->module_id]->loc_list, - estimated_distance); + + LOG_D(LOCALIZE, "RRC status %d\n", + ue_context_p->ue_context.Status); + + push_front(&RC.rrc[ctxt_pP->module_id]->loc_list, estimated_distance); + RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms = current_timestamp_ms; - } - } + } // end if + } // end RB_FOREACH #endif + (void)ts; /* remove gcc warning "unused variable" */ (void)ref_timestamp_ms; /* remove gcc warning "unused variable" */ (void)current_timestamp_ms; /* remove gcc warning "unused variable" */ - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); - return (RRC_OK); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX, VCD_FUNCTION_OUT); + + return RRC_OK; } -- GitLab From 57a383e77c096f57deed32ad9f669b74ebc69c54 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Tue, 23 Oct 2018 16:51:55 +0200 Subject: [PATCH 08/43] Format rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND() and rrc_eNB_free_UE() --- openair2/RRC/LTE/rrc_eNB.c | 152 ++++++++++++++++++-------------- openair2/RRC/LTE/rrc_eNB_S1AP.c | 66 +++++++------- 2 files changed, 119 insertions(+), 99 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 6bce1c21f0..a3deeec800 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -832,45 +832,58 @@ rrc_eNB_free_mem_UE_context( } //----------------------------------------------------------------------------- -// should be called when UE is lost by eNB +/* +* Should be called when UE context in eNB should be released +* or when S1 command UE_CONTEXT_RELEASE_REQ should be sent +*/ void -rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* const ue_context_pP) +rrc_eNB_free_UE( + const module_id_t enb_mod_idP, + const struct rrc_eNB_ue_context_s *const ue_context_pP) //----------------------------------------------------------------------------- { - - - protocol_ctxt_t ctxt; + protocol_ctxt_t ctxt; rnti_t rnti = ue_context_pP->ue_context.rnti; + if (enb_mod_idP >= NB_eNB_INST) { - LOG_I(RRC, "eNB inst invalid (%d/%d) for UE %x!\n",enb_mod_idP, NB_eNB_INST,rnti); - return; + LOG_I(RRC, "eNB instance invalid (%d/%d) for UE %x!\n", + enb_mod_idP, + NB_eNB_INST, + rnti); + + return; } - /* ue_context_p = rrc_eNB_get_ue_context( - &RC.rrc[enb_mod_idP], - rntiP - ); - */ + if (NULL != ue_context_pP) { - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0,enb_mod_idP); - LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rnti); - - if(EPC_MODE_ENABLED) { - - if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && - (mac_eNB_get_rrc_status(enb_mod_idP,rnti) >= RRC_CONNECTED)) { - LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ RNTI %x\n", enb_mod_idP, rnti); - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost - /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) - * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before - * triggering the S1 UE Context Release Request procedure - * in order to allow the UE to perform the NAS recovery - * procedure, see TS 23.401 [17]. - */ - return; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0, enb_mod_idP); + + LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", + enb_mod_idP, + rnti); + + if (EPC_MODE_ENABLED) { + if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP,rnti) >= RRC_CONNECTED)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x\n", + enb_mod_idP, + rnti); + + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); + // send cause 21: connection with ue lost + /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) + * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before + * triggering the S1 UE Context Release Request procedure in order to allow the UE to perform the NAS recovery + * procedure, see TS 23.401 [17]. + */ + + return; + } + // TODO : add here cause ul inactivity } - } + // add UE info to freeList - LOG_I(RRC, "put UE %x into freeList\n", rnti); + LOG_I(RRC, "Put UE %x into freeList\n", + rnti); + put_UE_in_freelist(enb_mod_idP, rnti, 1); } } @@ -1980,44 +1993,40 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject( } //----------------------------------------------------------------------------- +/* +* Generate the RRC Connection Release to UE. +* If received, UE should switch to RRC_IDLE mode. +*/ void rrc_eNB_generate_RRCConnectionRelease( const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + rrc_eNB_ue_context_t* const ue_context_pP ) //----------------------------------------------------------------------------- { - - uint8_t buffer[RRC_BUF_SIZE]; - uint16_t size; + uint8_t buffer[RRC_BUF_SIZE] = 0; + uint16_t size = 0; T(T_ENB_RRC_CONNECTION_RELEASE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); memset(buffer, 0, RRC_BUF_SIZE); size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); - // set release timer - //ue_context_pP->ue_context.ue_release_timer=1; - // remove UE after 10 frames after RRCConnectionRelease is triggered - //ue_context_pP->ue_context.ue_release_timer_thres=100; - // set release timer -// ue_context_pP->ue_context.ue_release_timer_rrc = 1; - // remove UE after 10 frames after RRCConnectionRelease is triggered -// ue_context_pP->ue_context.ue_release_timer_thres_rrc = 100; + ue_context_pP->ue_context.ue_reestablishment_timer = 0; ue_context_pP->ue_context.ue_release_timer = 0; - //ue_context_pP->ue_context.ue_release_timer_s1 = 0; + LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - size); + PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size); LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - size, - rrc_eNB_mui, - DCCH); + PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size, + rrc_eNB_mui, + DCCH); MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, @@ -2029,31 +2038,39 @@ rrc_eNB_generate_RRCConnectionRelease( ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); + pthread_mutex_lock(&rrc_release_freelist); - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 0){ - if(ue_context_pP->ue_context.ue_release_timer_s1 > 0){ + for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if (rrc_release_info.RRC_release_ctrl[release_num].flag == 0) { + + if (ue_context_pP->ue_context.ue_release_timer_s1 > 0) { rrc_release_info.RRC_release_ctrl[release_num].flag = 1; - }else{ + } else { rrc_release_info.RRC_release_ctrl[release_num].flag = 2; } + rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt_pP->rnti; rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = rrc_eNB_mui; rrc_release_info.num_UEs++; - LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num, - ctxt_pP->rnti, rrc_eNB_mui,rrc_release_info.RRC_release_ctrl[release_num].flag); + + LOG_D(RRC, "Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n", + release_num, + ctxt_pP->rnti, + rrc_eNB_mui, + rrc_release_info.RRC_release_ctrl[release_num].flag); + break; } } pthread_mutex_unlock(&rrc_release_freelist); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + + rrc_data_req(ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } uint8_t qci_to_priority[9]={2,4,3,5,1,6,7,8,9}; @@ -7904,6 +7921,11 @@ rrc_rx_tx( if (ue_context_p->ue_context.ue_release_timer >= ue_context_p->ue_context.ue_release_timer_thres) { LOG_I(RRC, "Removing UE %x instance because of RRC Connection Setup timer timeout\n", ue_context_p->ue_context.rnti); + /* + * TODO: Naming problem here: ue_release_timer seems to have been used when RRC Connection Release was sent. + * It is no more the case. + * The timer should be renamed. + */ ue_to_be_removed = ue_context_p; ue_context_p->ue_context.ue_release_timer = 0; diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index d225b6eae0..0bec59f647 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -1201,66 +1201,64 @@ void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( } -/*------------------------------------------------------------------------------*/ -int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const char *msg_name, instance_t instance) +//----------------------------------------------------------------------------- +/* +* Process the S1 command UE_CONTEXT_RELEASE_COMMAND, sent by MME. +* The eNB should remove all e-rab, S1 context, and other context of the UE. +*/ +int +rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND ( + MessageDef *msg_p, + const char *msg_name, + instance_t instance) { +//----------------------------------------------------------------------------- uint32_t eNB_ue_s1ap_id; - protocol_ctxt_t ctxt; + protocol_ctxt_t ctxt; struct rrc_eNB_ue_context_s *ue_context_p = NULL; - struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; + struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p).eNB_ue_s1ap_id; - - ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); if (ue_context_p == NULL) { /* Can not associate this message to an UE index */ - MessageDef *msg_complete_p; + MessageDef *msg_complete_p = NULL; - LOG_W(RRC, - "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: unknown UE from eNB_ue_s1ap_id (%d)\n", - instance, - eNB_ue_s1ap_id); + LOG_W(RRC, "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: unknown UE from eNB_ue_s1ap_id (%d)\n", + instance, + eNB_ue_s1ap_id); - MSC_LOG_EVENT( - MSC_RRC_ENB, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" context not found", + MSC_LOG_EVENT(MSC_RRC_ENB, "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" context not found", eNB_ue_s1ap_id); - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - NULL,0, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, + MSC_S1AP_ENB, + NULL, + 0, + "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", eNB_ue_s1ap_id); msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; itti_send_msg_to_task(TASK_S1AP, instance, msg_complete_p); - rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids( - RC.rrc[instance], - UE_INITIAL_ID_INVALID, - eNB_ue_s1ap_id); + rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[instance], UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); if (NULL != rrc_ue_s1ap_ids) { - rrc_eNB_S1AP_remove_ue_ids( - RC.rrc[instance], - rrc_ue_s1ap_ids); + rrc_eNB_S1AP_remove_ue_ids(RC.rrc[instance], rrc_ue_s1ap_ids); } - return (-1); + + return -1; } else { ue_context_p->ue_context.ue_release_timer_s1 = 0; + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + rrc_eNB_generate_RRCConnectionRelease(&ctxt, ue_context_p); - /* - LOG_W(RRC, - "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: TODO call rrc_eNB_connection_release for eNB %d\n", - instance, - eNB_ue_s1ap_id); - */ - return (0); + + return 0; } } -- GitLab From 2966cdf1c0f5df5aaadb61c1857ecf26ae6406cb Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Tue, 23 Oct 2018 17:12:45 +0200 Subject: [PATCH 09/43] Format rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ() --- openair2/RRC/LTE/rrc_eNB.c | 2 +- openair2/RRC/LTE/rrc_eNB_S1AP.c | 36 ++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index a3deeec800..56d68117c4 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -7890,7 +7890,7 @@ rrc_rx_tx( #endif rrc_release_info.RRC_release_ctrl[release_num].flag = 0; - rrc_release_info.num_UEs--; + rrc_release_info.num_UEs--; break; // break for (release_num) } // end if ((rrc_release_info.RRC_release_ctrl[release_num].flag > 2) && ... diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 0bec59f647..6aa4f9485e 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -1172,30 +1172,34 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char * } //------------------------------------------------------------------------------ -void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( - const module_id_t enb_mod_idP, - const rrc_eNB_ue_context_t* const ue_context_pP, - const s1ap_Cause_t causeP, - const long cause_valueP -) +/* +* Send the S1 command UE_CONTEXT_RELEASE_REQUEST to the MME. +*/ +void +rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ( + const module_id_t enb_mod_idP, + const rrc_eNB_ue_context_t *const ue_context_pP, + const s1ap_Cause_t causeP, + const long cause_valueP) //------------------------------------------------------------------------------ { if (ue_context_pP == NULL) { - LOG_W(RRC, - "[eNB] In S1AP_UE_CONTEXT_RELEASE_COMMAND: invalid UE\n"); + LOG_W(RRC, "[eNB] In S1AP_UE_CONTEXT_RELEASE_REQ: invalid UE\n"); } else { - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - NULL,0, - "0 S1AP_UE_CONTEXT_RELEASE_REQ eNB_ue_s1ap_id 0x%06"PRIX32" ", - ue_context_pP->ue_context.eNB_ue_s1ap_id); + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, + MSC_S1AP_ENB, + NULL, + 0, + "0 S1AP_UE_CONTEXT_RELEASE_REQ eNB_ue_s1ap_id 0x%06"PRIX32" ", + ue_context_pP->ue_context.eNB_ue_s1ap_id); MessageDef *msg_context_release_req_p = NULL; msg_context_release_req_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_REQ); + S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).cause = causeP; S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).cause_value = cause_valueP; + itti_send_msg_to_task(TASK_S1AP, ENB_MODULE_ID_TO_INSTANCE(enb_mod_idP), msg_context_release_req_p); } } @@ -1207,13 +1211,13 @@ void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( * The eNB should remove all e-rab, S1 context, and other context of the UE. */ int -rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND ( +rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND( MessageDef *msg_p, const char *msg_name, instance_t instance) { //----------------------------------------------------------------------------- - uint32_t eNB_ue_s1ap_id; + uint32_t eNB_ue_s1ap_id = 0; protocol_ctxt_t ctxt; struct rrc_eNB_ue_context_s *ue_context_p = NULL; struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; -- GitLab From a321e160cf38c54e190ede5aaddfe0504248a850 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Thu, 25 Oct 2018 16:03:38 +0200 Subject: [PATCH 10/43] rrc inactivity timer created, S1 ue context release request sent on timeout, timer set at RRC connection complete reception --- openair2/RRC/LTE/L2_interface.c | 7 ++-- openair2/RRC/LTE/rrc_defs.h | 13 ++++--- openair2/RRC/LTE/rrc_eNB.c | 68 ++++++++++++++++++++++++--------- 3 files changed, 62 insertions(+), 26 deletions(-) diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c index d201732177..74e735bc85 100644 --- a/openair2/RRC/LTE/L2_interface.c +++ b/openair2/RRC/LTE/L2_interface.c @@ -279,6 +279,9 @@ mac_rrc_data_ind( } //------------------------------------------------------------------------------ +/* +* Get RRC status (Connected, Idle...) of UE from RNTI +*/ int mac_eNB_get_rrc_status( const module_id_t Mod_idP, @@ -287,9 +290,7 @@ mac_eNB_get_rrc_status( //------------------------------------------------------------------------------ { struct rrc_eNB_ue_context_s* ue_context_p = NULL; - ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[Mod_idP], - rntiP); + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[Mod_idP], rntiP); if (ue_context_p != NULL) { return(ue_context_p->ue_context.Status); diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index ae87075489..3756acc457 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -387,10 +387,10 @@ typedef enum SL_TRIGGER_e { #define RRC_TRANSACTION_IDENTIFIER_NUMBER 3 typedef struct { - unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */ - unsigned short max_transport_blocks; /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */ - unsigned long Guaranteed_bit_rate; /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/ - unsigned long Max_bit_rate; /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/ + unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */ + unsigned short max_transport_blocks; /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */ + unsigned long Guaranteed_bit_rate; /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/ + unsigned long Max_bit_rate; /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/ uint8_t Delay_class; /*!< \brief Delay class offered by MAC layer scheduling*/ uint8_t Target_bler; /*!< \brief Target Average Transport Block Error rate*/ uint8_t Lchan_t; /*!< \brief Logical Channel Type (BCCH,CCCH,DCCH,DTCH_B,DTCH,MRBCH)*/ @@ -552,7 +552,7 @@ typedef struct eNB_RRC_UE_s { CipheringAlgorithm_r12_t ciphering_algorithm; e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; - uint8_t Status; + uint8_t Status; // RRC status, type enum UE_STATE_t rnti_t rnti; uint64_t random_ue_identity; @@ -599,6 +599,9 @@ typedef struct eNB_RRC_UE_s { uint32_t ue_release_timer_thres_rrc; uint32_t ue_reestablishment_timer; uint32_t ue_reestablishment_timer_thres; + /* RRC inactivity timer: on timeout, should release RRC connection for inactivity on all E-RABs */ + uint32_t ue_rrc_inactivity_timer; + uint32_t ue_rrc_inactivity_timer_thres; uint8_t e_rab_release_command_flag; int8_t reestablishment_xid; } eNB_RRC_UE_t; diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 56d68117c4..54b94f8c35 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -862,13 +862,13 @@ rrc_eNB_free_UE( rnti); if (EPC_MODE_ENABLED) { - if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP,rnti) >= RRC_CONNECTED)) { - LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x\n", + if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 21, radio connection with ue lost\n", enb_mod_idP, rnti); rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); - // send cause 21: connection with ue lost + // send cause 21: radio connection with ue lost /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before * triggering the S1 UE Context Release Request procedure in order to allow the UE to perform the NAS recovery @@ -877,7 +877,18 @@ rrc_eNB_free_UE( return; } - // TODO : add here cause ul inactivity + + if((ue_context_pP->ue_context.ue_rrc_inactivity_timer >= ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres) && + (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 20, user inactivity\n", + enb_mod_idP, + rnti); + + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 20); + // send cause 20: user inactivity + + return; + } } // add UE info to freeList @@ -1012,11 +1023,14 @@ void release_UE_in_freeList(module_id_t mod_id) } //----------------------------------------------------------------------------- +/* +* Process the rrc connection setup complete message from UE (SRB1 Active) +*/ void rrc_eNB_process_RRCConnectionSetupComplete( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, - RRCConnectionSetupComplete_r8_IEs_t * rrcConnectionSetupComplete + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, + RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete ) //----------------------------------------------------------------------------- { @@ -1024,22 +1038,19 @@ rrc_eNB_process_RRCConnectionSetupComplete( PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing RRCConnectionSetupComplete from UE (SRB1 Active)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - ue_context_pP->ue_context.Srb1.Active=1; + ue_context_pP->ue_context.Srb1.Active = 1; + ue_context_pP->ue_context.Status = RRC_CONNECTED; + ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED + T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); if (EPC_MODE_ENABLED == 1) { // Forward message to S1AP layer - rrc_eNB_send_S1AP_NAS_FIRST_REQ( - ctxt_pP, - ue_context_pP, - rrcConnectionSetupComplete); + rrc_eNB_send_S1AP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcConnectionSetupComplete); } else { // RRC loop back (no S1AP), send SecurityModeCommand to UE - rrc_eNB_generate_SecurityModeCommand( - ctxt_pP, - ue_context_pP); - // rrc_eNB_generate_UECapabilityEnquiry(enb_mod_idP,frameP,ue_mod_idP); + rrc_eNB_generate_SecurityModeCommand(ctxt_pP, ue_context_pP); } } @@ -5364,6 +5375,11 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( */ //----------------------------------------------------------------------------- +/* +* TODO: * add function description +* * add ue_rrc_inactivity_timer set +* * format the function correctly +*/ void rrc_eNB_process_RRCConnectionReconfigurationComplete( const protocol_ctxt_t* const ctxt_pP, @@ -6868,7 +6884,6 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { ctxt_pP, ue_context_p, &ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8); - ue_context_p->ue_context.Status = RRC_CONNECTED; LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); @@ -7901,6 +7916,18 @@ rrc_rx_tx( } // end if (rrc_release_info.num_UEs > 0) pthread_mutex_unlock(&rrc_release_freelist); + if (ue_context_p->ue_context.ue_rrc_inactivity_timer > 0) { + ue_context_p->ue_context.ue_rrc_inactivity_timer++; + + if (ue_context_p->ue_context.ue_rrc_inactivity_timer >= ue_context_p->ue_context.ue_rrc_inactivity_timer_thres) { + LOG_I(RRC, "Removing UE %x instance because of rrc_inactivity_timer timeout\n", + ue_context_p->ue_context.rnti); + + ue_to_be_removed = ue_context_p; + break; // break RB_FOREACH + } + } + if (ue_context_p->ue_context.ue_reestablishment_timer > 0) { ue_context_p->ue_context.ue_reestablishment_timer++; @@ -7935,7 +7962,8 @@ rrc_rx_tx( } // end RB_FOREACH if (ue_to_be_removed) { - if (ue_to_be_removed->ue_context.ul_failure_timer >= 20000) { + if ((ue_to_be_removed->ue_context.ul_failure_timer >= 20000) || + (ue_to_be_removed->ue_context.ue_rrc_inactivity_timer >= ue_to_be_removed->ue_context.ue_rrc_inactivity_timer_thres)) { ue_to_be_removed->ue_context.ue_release_timer_s1 = 1; ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100; ue_to_be_removed->ue_context.ue_release_timer = 0; @@ -7947,6 +7975,10 @@ rrc_rx_tx( if (ue_to_be_removed->ue_context.ul_failure_timer >= 20000) { ue_to_be_removed->ue_context.ul_failure_timer = 0; } + + if (ue_to_be_removed->ue_context.ue_rrc_inactivity_timer >= ue_to_be_removed->ue_context.ue_rrc_inactivity_timer_thres) { + ue_to_be_removed->ue_context.ue_rrc_inactivity_timer = 0; //reset timer after S1 command UE context release request is sent + } } #ifdef RRC_LOCALIZATION -- GitLab From 78051a314a3b41e2b104e06262f77114ae9265ba Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Fri, 26 Oct 2018 08:14:47 +0200 Subject: [PATCH 11/43] RRC inactivity timer on RRC connection setup: to be tested --- openair2/RRC/LTE/rrc_eNB.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 54b94f8c35..5f6580d316 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -1041,6 +1041,7 @@ rrc_eNB_process_RRCConnectionSetupComplete( ue_context_pP->ue_context.Srb1.Active = 1; ue_context_pP->ue_context.Status = RRC_CONNECTED; ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED + ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres = 10000; // SHOULD NOT BE DONE HERE !!!!! T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); -- GitLab From 266645d98d0af1f05f72445476fe8522f31ec978 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 26 Oct 2018 09:50:01 +0200 Subject: [PATCH 12/43] Minor corrections, compilation ok --- openair2/RRC/LTE/rrc_eNB.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 5f6580d316..8842e8be9f 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -862,7 +862,7 @@ rrc_eNB_free_UE( rnti); if (EPC_MODE_ENABLED) { - if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { + if ((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 21, radio connection with ue lost\n", enb_mod_idP, rnti); @@ -2016,13 +2016,14 @@ rrc_eNB_generate_RRCConnectionRelease( ) //----------------------------------------------------------------------------- { - uint8_t buffer[RRC_BUF_SIZE] = 0; + uint8_t buffer[RRC_BUF_SIZE]; uint16_t size = 0; + memset(buffer, 0, RRC_BUF_SIZE); + T(T_ENB_RRC_CONNECTION_RELEASE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - memset(buffer, 0, RRC_BUF_SIZE); size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); ue_context_pP->ue_context.ue_reestablishment_timer = 0; -- GitLab From 6ae27efac0d1f259b5fcf73572a4f3ddef809e17 Mon Sep 17 00:00:00 2001 From: OAI-admin Date: Wed, 31 Oct 2018 16:24:29 +0100 Subject: [PATCH 13/43] minor update in format, variable ctxt removed in rrc_eNB_free_UE() --- openair2/RRC/LTE/rrc_eNB.c | 74 ++++++++++++++++----------------- openair2/RRC/LTE/rrc_eNB_S1AP.c | 2 +- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 8842e8be9f..6beeb9e68c 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -842,11 +842,11 @@ rrc_eNB_free_UE( const struct rrc_eNB_ue_context_s *const ue_context_pP) //----------------------------------------------------------------------------- { - protocol_ctxt_t ctxt; + //protocol_ctxt_t ctxt; // rm ? rnti_t rnti = ue_context_pP->ue_context.rnti; if (enb_mod_idP >= NB_eNB_INST) { - LOG_I(RRC, "eNB instance invalid (%d/%d) for UE %x!\n", + LOG_E(RRC, "eNB instance invalid (%d/%d) for UE %x!\n", enb_mod_idP, NB_eNB_INST, rnti); @@ -854,49 +854,47 @@ rrc_eNB_free_UE( return; } - if (NULL != ue_context_pP) { - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0, enb_mod_idP); - - LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", - enb_mod_idP, - rnti); + //PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0, enb_mod_idP); // rm ? - if (EPC_MODE_ENABLED) { - if ((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { - LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 21, radio connection with ue lost\n", - enb_mod_idP, - rnti); - - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); - // send cause 21: radio connection with ue lost - /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) - * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before - * triggering the S1 UE Context Release Request procedure in order to allow the UE to perform the NAS recovery - * procedure, see TS 23.401 [17]. - */ - - return; - } + if (EPC_MODE_ENABLED) { + if ((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 21, radio connection with ue lost\n", + enb_mod_idP, + rnti); - if((ue_context_pP->ue_context.ue_rrc_inactivity_timer >= ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres) && - (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { - LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 20, user inactivity\n", - enb_mod_idP, - rnti); + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); + // send cause 21: radio connection with ue lost + /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) + * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before + * triggering the S1 UE Context Release Request procedure in order to allow the UE to perform the NAS recovery + * procedure, see TS 23.401 [17]. + */ - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 20); - // send cause 20: user inactivity + return; + } + + if((ue_context_pP->ue_context.ue_rrc_inactivity_timer >= ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres) && + (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 20, user inactivity\n", + enb_mod_idP, + rnti); + + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 20); + // send cause 20: user inactivity - return; - } + return; } + } - // add UE info to freeList - LOG_I(RRC, "Put UE %x into freeList\n", - rnti); + LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", + enb_mod_idP, + rnti); - put_UE_in_freelist(enb_mod_idP, rnti, 1); - } + // add UE info to freeList + LOG_I(RRC, "Put UE %x into freeList\n", + rnti); + + put_UE_in_freelist(enb_mod_idP, rnti, 1); } void remove_UE_from_freelist(module_id_t mod_id, rnti_t rnti) diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 6aa4f9485e..bb3f5a3851 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -1184,7 +1184,7 @@ rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ( //------------------------------------------------------------------------------ { if (ue_context_pP == NULL) { - LOG_W(RRC, "[eNB] In S1AP_UE_CONTEXT_RELEASE_REQ: invalid UE\n"); + LOG_E(RRC, "[eNB] In S1AP_UE_CONTEXT_RELEASE_REQ: invalid UE\n"); } else { MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_S1AP_ENB, -- GitLab From 1bb53286bb5fa6beafc7bef461eb191f8929bc4d Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Fri, 2 Nov 2018 16:23:32 +0100 Subject: [PATCH 14/43] Bug fixed: S1 setup requst sends the correct default DRX value --- openair2/ENB_APP/enb_config.c | 270 +++++++++++++++++++++++---- openair2/RRC/LTE/MESSAGES/asn1_msg.c | 2 +- openair2/RRC/LTE/rrc_eNB.c | 3 - 3 files changed, 233 insertions(+), 42 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 2675e4454c..40d9551ef2 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -2041,37 +2041,162 @@ int RCconfig_gtpu(void ) { return 0; } - -int RCconfig_S1(MessageDef *msg_p, uint32_t i) { - int j,k = 0; - int enb_id; - int32_t my_int; - const char *active_enb[MAX_ENB]; - char *address = NULL; - char *cidr = NULL; +//----------------------------------------------------------------------------- +/* +* Configure the s1ap_register_enb_req in itti message for future +* communications between eNB(s) and MME. +*/ +int RCconfig_S1( + MessageDef *msg_p, + uint32_t i) +//----------------------------------------------------------------------------- +{ + int enb_id = 0; + int32_t my_int = 0; + const char *active_enb[MAX_ENB]; + char *address = NULL; + char *cidr = NULL; + /*------------------------------------------------------------------------------*/ + /* + * the only reason for all these variables is, that they are "hard-encoded" into + * the CCPARAMS_DESC macro and we need it for the default_DRX value ... + */ + char *frame_type = NULL; + int32_t tdd_config = 0; + int32_t tdd_config_s = 0; + char *prefix_type = NULL; + char *pbch_repetition = NULL; + int32_t eutra_band = 0; + long long int downlink_frequency = 0; + int32_t uplink_frequency_offset = 0; + int32_t Nid_cell = 0; + int32_t Nid_cell_mbsfn = 0; + int32_t N_RB_DL = 0; + int32_t nb_antenna_ports = 0; + int32_t prach_root = 0; + int32_t prach_config_index = 0; + char *prach_high_speed = NULL; + int32_t prach_zero_correlation = 0; + int32_t prach_freq_offset = 0; + int32_t pucch_delta_shift = 0; + int32_t pucch_nRB_CQI = 0; + int32_t pucch_nCS_AN = 0; + int32_t pucch_n1_AN = 0; + int32_t pdsch_referenceSignalPower = 0; + int32_t pdsch_p_b = 0; + int32_t pusch_n_SB = 0; + char *pusch_hoppingMode = NULL; + int32_t pusch_hoppingOffset = 0; + char *pusch_enable64QAM = NULL; + char *pusch_groupHoppingEnabled = NULL; + int32_t pusch_groupAssignment = 0; + char *pusch_sequenceHoppingEnabled = NULL; + int32_t pusch_nDMRS1 = 0; + char *phich_duration = NULL; + char *phich_resource = NULL; + char *srs_enable = NULL; + int32_t srs_BandwidthConfig = 0; + int32_t srs_SubframeConfig = 0; + char *srs_ackNackST = NULL; + char *srs_MaxUpPts = NULL; + int32_t pusch_p0_Nominal = 0; + char *pusch_alpha = NULL; + int32_t pucch_p0_Nominal = 0; + int32_t msg3_delta_Preamble = 0; + char *pucch_deltaF_Format1 = NULL; + char *pucch_deltaF_Format1b = NULL; + char *pucch_deltaF_Format2 = NULL; + char *pucch_deltaF_Format2a = NULL; + char *pucch_deltaF_Format2b = NULL; + int32_t rach_numberOfRA_Preambles = 0; + char *rach_preamblesGroupAConfig = NULL; + int32_t rach_sizeOfRA_PreamblesGroupA = 0; + int32_t rach_messageSizeGroupA = 0; + char *rach_messagePowerOffsetGroupB = NULL; + int32_t rach_powerRampingStep = 0; + int32_t rach_preambleInitialReceivedTargetPower = 0; + int32_t rach_preambleTransMax = 0; + int32_t rach_raResponseWindowSize = 10; + int32_t rach_macContentionResolutionTimer = 0; + int32_t rach_maxHARQ_Msg3Tx = 0; + int32_t pcch_defaultPagingCycle = 0; + char *pcch_nB = NULL; + int32_t bcch_modificationPeriodCoeff = 0; + int32_t ue_TimersAndConstants_t300 = 0; + int32_t ue_TimersAndConstants_t301 = 0; + int32_t ue_TimersAndConstants_t310 = 0; + int32_t ue_TimersAndConstants_t311 = 0; + int32_t ue_TimersAndConstants_n310 = 0; + int32_t ue_TimersAndConstants_n311 = 0; + int32_t ue_TransmissionMode = 0; + int32_t ue_multiple_max = 0; + //TTN - for D2D + //SIB18 + const char *rxPool_sc_CP_Len = NULL; + const char *rxPool_sc_Period = NULL; + const char *rxPool_data_CP_Len = NULL; + libconfig_int rxPool_ResourceConfig_prb_Num = 0; + libconfig_int rxPool_ResourceConfig_prb_Start = 0; + libconfig_int rxPool_ResourceConfig_prb_End = 0; + const char *rxPool_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int rxPool_ResourceConfig_offsetIndicator_choice = 0; + const char *rxPool_ResourceConfig_subframeBitmap_present = NULL; + char *rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + //SIB19 + //For discRxPool + const char *discRxPool_cp_Len = NULL; + const char *discRxPool_discPeriod = NULL; + libconfig_int discRxPool_numRetx = 0; + libconfig_int discRxPool_numRepetition = 0; + libconfig_int discRxPool_ResourceConfig_prb_Num = 0; + libconfig_int discRxPool_ResourceConfig_prb_Start = 0; + libconfig_int discRxPool_ResourceConfig_prb_End = 0; + const char *discRxPool_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int discRxPool_ResourceConfig_offsetIndicator_choice = 0; + const char *discRxPool_ResourceConfig_subframeBitmap_present = NULL; + char *discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + //For discRxPoolPS + const char *discRxPoolPS_cp_Len = NULL; + const char *discRxPoolPS_discPeriod = NULL; + libconfig_int discRxPoolPS_numRetx = 0; + libconfig_int discRxPoolPS_numRepetition = 0; + libconfig_int discRxPoolPS_ResourceConfig_prb_Num = 0; + libconfig_int discRxPoolPS_ResourceConfig_prb_Start = 0; + libconfig_int discRxPoolPS_ResourceConfig_prb_End = 0; + const char *discRxPoolPS_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int discRxPoolPS_ResourceConfig_offsetIndicator_choice = 0; + const char *discRxPoolPS_ResourceConfig_subframeBitmap_present = NULL; + char *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + /*------------------------------------------------------------------------------*/ // for no gcc warnings (void)my_int; - memset((char *)active_enb, 0, MAX_ENB * sizeof(char *)); + memset((char *)active_enb, 0, MAX_ENB * sizeof(char *)); paramdef_t ENBSParams[] = ENBSPARAMS_DESC; - paramdef_t ENBParams[] = ENBPARAMS_DESC; - paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0}; + paramdef_t ENBParams[] = ENBPARAMS_DESC; + paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST, NULL, 0}; /* get global parameters, defined outside any section in the config file */ - config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL); - AssertFatal (i0) { + if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt > 0) { // Output a list of all eNBs. - config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL); + config_getlist(&ENBParamList, ENBParams, sizeof(ENBParams)/sizeof(paramdef_t), NULL); if (ENBParamList.numelt > 0) { - for (k = 0; k < ENBParamList.numelt; k++) { + for (int k = 0; k < ENBParamList.numelt; k++) { if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) { // Calculate a default eNB ID if (EPC_MODE_ENABLED) { - uint32_t hash; - hash = s1ap_generate_eNB_id (); + uint32_t hash = 0; + hash = s1ap_generate_eNB_id(); enb_id = k + (hash & 0xFFFF8); } else { enb_id = k; @@ -2081,22 +2206,33 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { } // search if in active list - for (j=0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) { + for (int j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) { if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) { paramdef_t PLMNParams[] = PLMNPARAMS_DESC; paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0}; + + paramdef_t CCsParams[] = CCPARAMS_DESC; + + /* map parameter checking array instances to parameter definition array instances */ + checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK; + for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) { + CCsParams[I].chkPptr = &(config_check_CCparams[I]); + } + /* map parameter checking array instances to parameter definition array instances */ checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK; - - for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) + for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) { PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); + } + + paramdef_t S1Params[] = S1PARAMS_DESC; + paramlist_def_t S1ParamList = {ENB_CONFIG_STRING_MME_IP_ADDRESS, NULL, 0}; + paramdef_t SCTPParams[] = SCTPPARAMS_DESC; + paramdef_t NETParams[] = NETPARAMS_DESC; - paramdef_t S1Params[] = S1PARAMS_DESC; - paramlist_def_t S1ParamList = {ENB_CONFIG_STRING_MME_IP_ADDRESS,NULL,0}; - paramdef_t SCTPParams[] = SCTPPARAMS_DESC; - paramdef_t NETParams[] = NETPARAMS_DESC; char aprefix[MAX_OPTNAME_SIZE*2 + 8]; - sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); + sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k); + S1AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id; if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) { @@ -2104,13 +2240,16 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { } else if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) { S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB; } else { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", - RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); + AssertFatal(0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", + RC.config_file_name, + i, + *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); } - S1AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); - S1AP_REGISTER_ENB_REQ(msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; + S1AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); + S1AP_REGISTER_ENB_REQ(msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; + AssertFatal(!ENBParamList.paramarray[k][ENB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr && !ENBParamList.paramarray[k][ENB_MOBILE_NETWORK_CODE_IDX_OLD].strptr, "It seems that you use an old configuration file. Please change the existing\n" @@ -2120,11 +2259,13 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { "to\n" " tracking_area_code = 1; // no string!!\n" " plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n"); + config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); - if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) + if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6){ AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n", PLMNParamList.numelt); + } S1AP_REGISTER_ENB_REQ(msg_p).num_plmn = PLMNParamList.numelt; @@ -2132,34 +2273,82 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { S1AP_REGISTER_ENB_REQ(msg_p).mcc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; S1AP_REGISTER_ENB_REQ(msg_p).mnc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_NETWORK_CODE_IDX].uptr; S1AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length[l] = *PLMNParamList.paramarray[l][ENB_MNC_DIGIT_LENGTH].u8ptr; + AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length[l] == 3 || S1AP_REGISTER_ENB_REQ(msg_p).mnc[l] < 100, "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n", S1AP_REGISTER_ENB_REQ(msg_p).mnc[l]); } - S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; - config_getlist( &S1ParamList,S1Params,sizeof(S1Params)/sizeof(paramdef_t),aprefix); + /* Default DRX param */ + /* + * Here we get the config of the first CC, since the s1ap_register_enb_req_t doesn't support multiple CC. + * It is not clear in the spec if the eNB can have different default paging values in case of several SIB2 from the same eNB. + * Yet, from the spec and logically, there should be a unique value associated with eNB. + * Hence, it should be stated somewhere that the value should be the same for every CC, or put the value outside the CC + * in the conf file. + */ + sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, 0); + config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix); + switch (pcch_defaultPagingCycle) { + case 32: { + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; + break; + } + + case 64: { + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 1; + break; + } + + case 128: { + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 2; + break; + } + + case 256: { + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 3; + break; + } + + default: { + LOG_E(S1AP, "Default I-DRX value in conf file is invalid (%i). Should be 32, 64, 128 or 256. \ + Default DRX set to 32 in MME configuration\n", + pcch_defaultPagingCycle); + + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; + } + } + + /* MME connection params */ + sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k); + + config_getlist(&S1ParamList, S1Params, sizeof(S1Params)/sizeof(paramdef_t), aprefix); + S1AP_REGISTER_ENB_REQ (msg_p).nb_mme = 0; for (int l = 0; l < S1ParamList.numelt; l++) { S1AP_REGISTER_ENB_REQ (msg_p).nb_mme += 1; + strcpy(S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4_address,*(S1ParamList.paramarray[l][ENB_MME_IPV4_ADDRESS_IDX].strptr)); strcpy(S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6_address,*(S1ParamList.paramarray[l][ENB_MME_IPV6_ADDRESS_IDX].strptr)); if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) { S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4 = 1; + } else if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) { S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6 = 1; + } else if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) { S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4 = 1; S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6 = 1; } - if (S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].iptr) + if (S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].iptr) { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].numelt; - else + } else { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = 0; + } AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] <= S1AP_REGISTER_ENB_REQ(msg_p).num_plmn, "List of broadcast PLMN to be sent to MME can not be longer than actual " @@ -2170,6 +2359,7 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l]; ++el) { /* UINTARRAY gets mapped to int, see config_libconfig.c:223 */ S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] = S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].iptr[el]; + AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] >= 0 && S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn, "index for MME's MCC/MNC (%d) is an invalid index for the registered PLMN IDs (%d)\n", @@ -2181,8 +2371,9 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { if (S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] == 0) { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; - for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; ++el) + for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; ++el){ S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] = el; + } } } @@ -2192,15 +2383,18 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { if (EPC_MODE_ENABLED) { sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG); + config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); + S1AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); S1AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); } sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); + // NETWORK_INTERFACES config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); - // S1AP_REGISTER_ENB_REQ (msg_p).enb_interface_name_for_S1U = strdup(enb_interface_name_for_S1U); + cidr = *(NETParams[ENB_IPV4_ADDRESS_FOR_S1_MME_IDX].strptr); address = strtok(cidr, "/"); S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv6 = 0; diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index d70550c82d..70bb3dda49 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -704,7 +704,7 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->pcch_defaultPagingCycle[CC_id]; (*sib2)->radioResourceConfigCommon.pcch_Config.nB = configuration->pcch_nB[CC_id]; - LOG_E(RRC,"[SIB2] With ITTI. Basic config of paging cycle DRX: radio frame cycle length %x, paging occasion number %x\n", + LOG_I(RRC,"[SIB2] With ITTI. Basic config of paging cycle DRX: radio frame cycle length %x, paging occasion number %x\n", (uint32_t)configuration->pcch_defaultPagingCycle[CC_id], (uint32_t)configuration->pcch_nB[CC_id]); diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 6beeb9e68c..8673567e6b 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -842,7 +842,6 @@ rrc_eNB_free_UE( const struct rrc_eNB_ue_context_s *const ue_context_pP) //----------------------------------------------------------------------------- { - //protocol_ctxt_t ctxt; // rm ? rnti_t rnti = ue_context_pP->ue_context.rnti; if (enb_mod_idP >= NB_eNB_INST) { @@ -853,8 +852,6 @@ rrc_eNB_free_UE( return; } - - //PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0, enb_mod_idP); // rm ? if (EPC_MODE_ENABLED) { if ((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { -- GitLab From 1c196a9eff54c115923f26ded3a9f706442a7b9c Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Mon, 5 Nov 2018 16:48:50 +0100 Subject: [PATCH 15/43] rrc inactivity timer reset in RRC Connection Release generation --- openair2/ENB_APP/enb_config.c | 3 +-- openair2/RRC/LTE/rrc_eNB.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 40d9551ef2..036a4cdd91 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -2283,8 +2283,7 @@ int RCconfig_S1( /* Default DRX param */ /* * Here we get the config of the first CC, since the s1ap_register_enb_req_t doesn't support multiple CC. - * It is not clear in the spec if the eNB can have different default paging values in case of several SIB2 from the same eNB. - * Yet, from the spec and logically, there should be a unique value associated with eNB. + * There is a unique value of defaultPagingCycle per eNB (same for multiple cells). * Hence, it should be stated somewhere that the value should be the same for every CC, or put the value outside the CC * in the conf file. */ diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 8673567e6b..d63b289e32 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -2023,6 +2023,7 @@ rrc_eNB_generate_RRCConnectionRelease( ue_context_pP->ue_context.ue_reestablishment_timer = 0; ue_context_pP->ue_context.ue_release_timer = 0; + ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0; LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", -- GitLab From b8ce24febb3e0cb6e588137889534f45bfb9fc63 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Tue, 6 Nov 2018 07:42:04 +0100 Subject: [PATCH 16/43] add changes to s1ap_eNB.c --- openair3/S1AP/s1ap_eNB.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/openair3/S1AP/s1ap_eNB.c b/openair3/S1AP/s1ap_eNB.c index 3edc5be0d5..2e89bf97f7 100644 --- a/openair3/S1AP/s1ap_eNB.c +++ b/openair3/S1AP/s1ap_eNB.c @@ -444,16 +444,22 @@ void *s1ap_eNB_task(void *arg) return NULL; } +//----------------------------------------------------------------------------- +/* +* eNB generate a S1 setup request towards MME +*/ static int s1ap_eNB_generate_s1_setup_request( - s1ap_eNB_instance_t *instance_p, s1ap_eNB_mme_data_t *s1ap_mme_data_p) + s1ap_eNB_instance_t *instance_p, + s1ap_eNB_mme_data_t *s1ap_mme_data_p) +//----------------------------------------------------------------------------- { - S1AP_S1AP_PDU_t pdu; - S1AP_S1SetupRequest_t *out; - S1AP_S1SetupRequestIEs_t *ie; - S1AP_SupportedTAs_Item_t *ta; - S1AP_PLMNidentity_t *plmn; - uint8_t *buffer; - uint32_t len; + S1AP_S1AP_PDU_t pdu; + S1AP_S1SetupRequest_t *out = NULL; + S1AP_S1SetupRequestIEs_t *ie = NULL; + S1AP_SupportedTAs_Item_t *ta = NULL; + S1AP_PLMNidentity_t *plmn = NULL; + uint8_t *buffer = NULL; + uint32_t len = 0; int ret = 0; DevAssert(instance_p != NULL); -- GitLab From 94bf32b0d462f340cfc881fe7dd88018ac433e18 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Thu, 8 Nov 2018 08:31:23 +0100 Subject: [PATCH 17/43] Bug fix: S1 id unknown after Detach Request (need to test) --- openair2/RRC/LTE/rrc_defs.h | 2 +- openair2/RRC/LTE/rrc_eNB_S1AP.c | 280 ++++++++++++++++++------ openair3/S1AP/s1ap_eNB_nas_procedures.c | 3 - 3 files changed, 211 insertions(+), 74 deletions(-) diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index 3756acc457..c5ca527b44 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -573,7 +573,7 @@ typedef struct eNB_RRC_UE_s { security_capabilities_t security_capabilities; /* Total number of e_rab already setup in the list */ - uint8_t setup_e_rabs; + uint8_t setup_e_rabs; /* Number of e_rab to be setup in the list */ uint8_t nb_of_e_rabs; /* Number of e_rab to be modified in the list */ diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index bb3f5a3851..81d5a6ae2b 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -36,6 +36,11 @@ # include "rrc_eNB_S1AP.h" # include "enb_config.h" # include "common/ran_context.h" +/****************************************/ +//# include "../../S1AP/s1ap_eNB_defs.h" +//# include "s1ap_eNB_management_procedures.h" +# include "s1ap_eNB_ue_context.h" +/****************************************/ # if defined(ENABLE_ITTI) # include "asn1_conversions.h" @@ -161,6 +166,9 @@ void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_c # if defined(ENABLE_ITTI) //------------------------------------------------------------------------------ +/* +* TODO +*/ struct rrc_ue_s1ap_ids_s* rrc_eNB_S1AP_get_ue_ids( eNB_RRC_INST* const rrc_instance_pP, @@ -171,48 +179,169 @@ rrc_eNB_S1AP_get_ue_ids( { rrc_ue_s1ap_ids_t *result = NULL; rrc_ue_s1ap_ids_t *result2 = NULL; + /*****************************/ + instance_t instance = 0; + s1ap_eNB_instance_t *s1ap_eNB_instance_p = NULL; + s1ap_eNB_ue_context_t *ue_desc_p = NULL; + /*****************************/ hashtable_rc_t h_rc; + if (ue_initial_id != UE_INITIAL_ID_INVALID) { + h_rc = hashtable_get(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&result); + + if (h_rc == HASH_TABLE_OK) { + + if (eNB_ue_s1ap_id > 0) { + h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result2); + + if (h_rc != HASH_TABLE_OK) { // this case is equivalent to associate eNB_ue_s1ap_id and ue_initial_id + result2 = malloc(sizeof(*result2)); + + if (NULL != result2) { + *result2 = *result; + + result2->eNB_ue_s1ap_id = eNB_ue_s1ap_id; + result->eNB_ue_s1ap_id = eNB_ue_s1ap_id; + + h_rc = hashtable_insert(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, result2); + + if (h_rc != HASH_TABLE_OK) { + LOG_E(S1AP, "[eNB %ld] Error while hashtable_insert in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32"\n", + rrc_instance_pP - RC.rrc[0], + eNB_ue_s1ap_id); + } + } + + } else { // here we should check that the association was done correctly + + if ((result->ue_initial_id != result2->ue_initial_id) || (result->eNB_ue_s1ap_id != result2->eNB_ue_s1ap_id)) { + + LOG_E(S1AP, "[eNB %ld] Error while hashtable_get, two rrc_ue_s1ap_ids_t that should be equal, are not: \ + ue_initial_id 1 = %"PRIu16", \ + ue_initial_id 2 = %"PRIu16", \ + eNB_ue_s1ap_id 1 = %"PRIu32", \ + eNB_ue_s1ap_id 2 = %"PRIu32"\n", + rrc_instance_pP - RC.rrc[0], + result->ue_initial_id, + result2->ue_initial_id, + result->eNB_ue_s1ap_id, + result2->eNB_ue_s1ap_id); + + } + + } + } // end if if (eNB_ue_s1ap_id > 0) + + } else { // end if (h_rc == HASH_TABLE_OK) + + LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in initial_id2_s1ap_ids ue_initial_id %"PRIu16"\n", + rrc_instance_pP - RC.rrc[0], + ue_initial_id); + /* + * At the moment this is written, this case shouldn't (cannot) happen and is equivalent to an error. + * One could try to find the struct instance based on s1ap_id2_s1ap_ids and eNB_ue_s1ap_id (if > 0), + * but this behavior is not expected at the moment. + */ + + } // end else (h_rc != HASH_TABLE_OK) + + } else { // end if (ue_initial_id != UE_INITIAL_ID_INVALID) + + if (eNB_ue_s1ap_id > 0) { + h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result); + + if (h_rc != HASH_TABLE_OK) { + /* + * This case is uncommon, but can happen when: + * -> if the first NAS message was a Detach Request (non exhaustiv), the UE RRC context exist + * but is not associated with eNB_ue_s1ap_id + * -> if the UE is in IDLE, hence no S1 context exist (in this case [h_rc != HASH_TABLE_OK] is normal) + * -> ... (?) + */ + LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", trying \ + to find it through S1AP context\n", + rrc_instance_pP - RC.rrc[0], + eNB_ue_s1ap_id); + + instance = ENB_MODULE_ID_TO_INSTANCE(rrc_instance_pP - RC.rrc[0]); // get eNB instance + + s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); // get s1ap_eNB_instance + + ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, eNB_ue_s1ap_id); // get s1ap_eNB_ue_context + + if (ue_desc_p != NULL) { + result = rrc_eNB_S1AP_get_ue_ids(rrc_instance_pP, ue_desc_p->ue_initial_id, eNB_ue_s1ap_id); + + } else { + + LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", even \ + when looking at S1AP context\n", + rrc_instance_pP - RC.rrc[0], + eNB_ue_s1ap_id); + + } + + } // end if (h_rc != HASH_TABLE_OK) + } // end if (eNB_ue_s1ap_id > 0) + } // end else (ue_initial_id == UE_INITIAL_ID_INVALID) + + return result; + // we assume that a rrc_ue_s1ap_ids_s is initially inserted in initial_id2_s1ap_ids + /* if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result); + h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result); } + if (ue_initial_id != UE_INITIAL_ID_INVALID) { h_rc = hashtable_get(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&result); - if (h_rc == HASH_TABLE_OK) { - if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result2); - if (h_rc != HASH_TABLE_OK) { - result2 = malloc(sizeof(*result2)); - if (NULL != result2) { - *result2 = *result; - result2->eNB_ue_s1ap_id = eNB_ue_s1ap_id; - result->eNB_ue_s1ap_id = eNB_ue_s1ap_id; - h_rc = hashtable_insert(rrc_instance_pP->s1ap_id2_s1ap_ids, - (hash_key_t)eNB_ue_s1ap_id, - result2); + + if (h_rc == HASH_TABLE_OK) { + + if (eNB_ue_s1ap_id > 0) { + h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result2); + + if (h_rc != HASH_TABLE_OK) { + result2 = malloc(sizeof(*result2)); + + if (NULL != result2) { + *result2 = *result; + + result2->eNB_ue_s1ap_id = eNB_ue_s1ap_id; + result->eNB_ue_s1ap_id = eNB_ue_s1ap_id; + + h_rc = hashtable_insert(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, result2); + if (h_rc != HASH_TABLE_OK) { - LOG_E(S1AP, "[eNB %ld] Error while hashtable_insert in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32"\n", - rrc_instance_pP - RC.rrc[0], eNB_ue_s1ap_id); + LOG_E(S1AP, "[eNB %ld] Error while hashtable_insert in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32"\n", + rrc_instance_pP - RC.rrc[0], + eNB_ue_s1ap_id); } - } - } - } - } + } + } + } + } } return result; + */ } + //------------------------------------------------------------------------------ +/* +* TODO +*/ void rrc_eNB_S1AP_remove_ue_ids( - eNB_RRC_INST* const rrc_instance_pP, - struct rrc_ue_s1ap_ids_s* const ue_ids_pP + eNB_RRC_INST *const rrc_instance_pP, + struct rrc_ue_s1ap_ids_s *const ue_ids_pP ) //------------------------------------------------------------------------------ { const uint16_t ue_initial_id = ue_ids_pP->ue_initial_id; const uint32_t eNB_ue_s1ap_id = ue_ids_pP->eNB_ue_s1ap_id; + hashtable_rc_t h_rc; + if (rrc_instance_pP == NULL) { LOG_E(RRC, "Bad RRC instance\n"); return; @@ -224,21 +353,23 @@ rrc_eNB_S1AP_remove_ue_ids( } if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_remove(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id); - if (h_rc != HASH_TABLE_OK) { - LOG_W(RRC, "S1AP Did not find entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id); - } else { - LOG_W(RRC, "S1AP removed entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id); - } + h_rc = hashtable_remove(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id); + + if (h_rc != HASH_TABLE_OK) { + LOG_W(RRC, "S1AP Did not find entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id); + } else { + LOG_W(RRC, "S1AP removed entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id); + } } if (ue_initial_id != UE_INITIAL_ID_INVALID) { h_rc = hashtable_remove(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id); - if (h_rc != HASH_TABLE_OK) { - LOG_W(RRC, "S1AP Did not find entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id); - } else { - LOG_W(RRC, "S1AP removed entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id); - } + + if (h_rc != HASH_TABLE_OK) { + LOG_W(RRC, "S1AP Did not find entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id); + } else { + LOG_W(RRC, "S1AP removed entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id); + } } } @@ -284,17 +415,11 @@ rrc_eNB_get_ue_context_from_s1ap_ids( ) { rrc_ue_s1ap_ids_t* temp = NULL; - temp = - rrc_eNB_S1AP_get_ue_ids( - RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)], - ue_initial_idP, - eNB_ue_s1ap_idP); - if (temp) { + temp = rrc_eNB_S1AP_get_ue_ids(RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)], ue_initial_idP, eNB_ue_s1ap_idP); - return rrc_eNB_get_ue_context( - RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)], - temp->ue_rnti); + if (temp != NULL) { + return rrc_eNB_get_ue_context(RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)], temp->ue_rnti); } return NULL; @@ -686,28 +811,31 @@ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( } //------------------------------------------------------------------------------ +/* +* TODO +*/ void rrc_eNB_send_S1AP_NAS_FIRST_REQ( const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + rrc_eNB_ue_context_t* const ue_context_pP, RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete ) //------------------------------------------------------------------------------ - - { - eNB_RRC_INST *rrc=RC.rrc[ctxt_pP->module_id]; + eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id]; + #if defined(ENABLE_ITTI) { MessageDef* message_p = NULL; rrc_ue_s1ap_ids_t* rrc_ue_s1ap_ids_p = NULL; hashtable_rc_t h_rc; - message_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_NAS_FIRST_REQ); + message_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_NAS_FIRST_REQ); memset(&message_p->ittiMsg.s1ap_nas_first_req, 0, sizeof(s1ap_nas_first_req_t)); - ue_context_pP->ue_context.ue_initial_id = get_next_ue_initial_id (ctxt_pP->module_id); - S1AP_NAS_FIRST_REQ (message_p).ue_initial_id = ue_context_pP->ue_context.ue_initial_id; + ue_context_pP->ue_context.ue_initial_id = get_next_ue_initial_id(ctxt_pP->module_id); + + S1AP_NAS_FIRST_REQ(message_p).ue_initial_id = ue_context_pP->ue_context.ue_initial_id; rrc_ue_s1ap_ids_p = malloc(sizeof(*rrc_ue_s1ap_ids_p)); rrc_ue_s1ap_ids_p->ue_initial_id = ue_context_pP->ue_context.ue_initial_id; @@ -715,22 +843,26 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; h_rc = hashtable_insert(RC.rrc[ctxt_pP->module_id]->initial_id2_s1ap_ids, - (hash_key_t)ue_context_pP->ue_context.ue_initial_id, - rrc_ue_s1ap_ids_p); + (hash_key_t)ue_context_pP->ue_context.ue_initial_id, + rrc_ue_s1ap_ids_p); + if (h_rc != HASH_TABLE_OK) { LOG_E(S1AP, "[eNB %d] Error while hashtable_insert in initial_id2_s1ap_ids ue_initial_id %u\n", - ctxt_pP->module_id, ue_context_pP->ue_context.ue_initial_id); + ctxt_pP->module_id, + ue_context_pP->ue_context.ue_initial_id); } /* Assume that cause is coded in the same way in RRC and S1ap, just check that the value is in S1ap range */ AssertFatal(ue_context_pP->ue_context.establishment_cause < RRC_CAUSE_LAST, - "Establishment cause invalid (%jd/%d) for eNB %d!", - ue_context_pP->ue_context.establishment_cause, RRC_CAUSE_LAST, ctxt_pP->module_id); + "Establishment cause invalid (%jd/%d) for eNB %d!", + ue_context_pP->ue_context.establishment_cause, + RRC_CAUSE_LAST, + ctxt_pP->module_id); S1AP_NAS_FIRST_REQ (message_p).establishment_cause = ue_context_pP->ue_context.establishment_cause; - /* Forward NAS message */S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer = - rrcConnectionSetupComplete->dedicatedInfoNAS.buf; + /* Forward NAS message */ + S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer = rrcConnectionSetupComplete->dedicatedInfoNAS.buf; S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length = rrcConnectionSetupComplete->dedicatedInfoNAS.size; extract_imsi(S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer, @@ -748,12 +880,13 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask |= UE_IDENTITIES_s_tmsi; S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code = s_TMSI->mme_code; S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi = s_TMSI->m_tmsi; + LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ with s_TMSI: MME code %u M-TMSI %u ue %x\n", ctxt_pP->module_id, S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code, S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi, ue_context_pP->ue_context.rnti); - } + } // end if S-TMSI presence /* selected_plmn_identity: IE is 1-based, convert to 0-based (C array) */ int selected_plmn_identity = rrcConnectionSetupComplete->selectedPLMN_Identity - 1; @@ -769,31 +902,33 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( if ((r_mme->plmn_Identity->mcc != NULL) && (r_mme->plmn_Identity->mcc->list.count > 0)) { /* Use first indicated PLMN MCC if it is defined */ S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc = *r_mme->plmn_Identity->mcc->list.array[selected_plmn_identity]; + LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI MCC %u ue %x\n", - ctxt_pP->module_id, - S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc, - ue_context_pP->ue_context.rnti); + ctxt_pP->module_id, + S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc, + ue_context_pP->ue_context.rnti); } if (r_mme->plmn_Identity->mnc.list.count > 0) { /* Use first indicated PLMN MNC if it is defined */ S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc = *r_mme->plmn_Identity->mnc.list.array[selected_plmn_identity]; + LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI MNC %u ue %x\n", - ctxt_pP->module_id, - S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc, - ue_context_pP->ue_context.rnti); + ctxt_pP->module_id, + S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc, + ue_context_pP->ue_context.rnti); } - } else { + + } else { // end if plmn_Identity != NULL S1AP_NAS_FIRST_REQ(message_p).ue_identity.gummei.mcc = rrc->configuration.mcc[selected_plmn_identity]; S1AP_NAS_FIRST_REQ(message_p).ue_identity.gummei.mnc = rrc->configuration.mnc[selected_plmn_identity]; S1AP_NAS_FIRST_REQ(message_p).ue_identity.gummei.mnc_len = rrc->configuration.mnc_digit_length[selected_plmn_identity]; - } + } // end else (plmn_Identity == NULL) S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code = BIT_STRING_to_uint8 (&r_mme->mmec); S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id = BIT_STRING_to_uint16 (&r_mme->mmegi); - MSC_LOG_TX_MESSAGE( - MSC_S1AP_ENB, + MSC_LOG_TX_MESSAGE(MSC_S1AP_ENB, MSC_S1AP_MME, (const char *)&message_p->ittiMsg.s1ap_nas_first_req, sizeof(s1ap_nas_first_req_t), @@ -807,11 +942,15 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code, S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id, ue_context_pP->ue_context.rnti); - } - } + + } // end if MME info present + } // end "Fill UE identities with available information" sub-part + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, message_p); } + #else + { s1ap_eNB_new_data_request ( ctxt_pP->module_id, @@ -821,6 +960,7 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( rrcConnectionSetupComplete->dedicatedInfoNAS. size); } + #endif } @@ -847,7 +987,6 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); - LOG_I(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d\n", instance, msg_name, @@ -1250,11 +1389,12 @@ rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND( rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[instance], UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); - if (NULL != rrc_ue_s1ap_ids) { + if (rrc_ue_s1ap_ids != NULL) { rrc_eNB_S1AP_remove_ue_ids(RC.rrc[instance], rrc_ue_s1ap_ids); } return -1; + } else { ue_context_p->ue_context.ue_release_timer_s1 = 0; diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.c b/openair3/S1AP/s1ap_eNB_nas_procedures.c index 80266a4d9c..0e2b809189 100644 --- a/openair3/S1AP/s1ap_eNB_nas_procedures.c +++ b/openair3/S1AP/s1ap_eNB_nas_procedures.c @@ -573,9 +573,6 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id, ie->value.choice.NAS_PDU.buf, ie->value.choice.NAS_PDU.size); - // LG: Why set to 0 ?? - //ue_desc_p->ue_initial_id = 0; - return 0; } -- GitLab From d3f8f9d65b83fb150b95a54018dbdbeb87e35107 Mon Sep 17 00:00:00 2001 From: OAI-admin Date: Mon, 12 Nov 2018 07:46:32 +0100 Subject: [PATCH 18/43] End of bug fix: S1 id unknown after detach request for switch off in idle --- openair2/RRC/LTE/rrc_eNB_S1AP.c | 81 ++++++++++++------------------- openair3/S1AP/s1ap_eNB_handlers.c | 11 +++-- 2 files changed, 37 insertions(+), 55 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 81d5a6ae2b..f89bb76cff 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -37,8 +37,8 @@ # include "enb_config.h" # include "common/ran_context.h" /****************************************/ -//# include "../../S1AP/s1ap_eNB_defs.h" -//# include "s1ap_eNB_management_procedures.h" +# include "s1ap_eNB_defs.h" +# include "s1ap_eNB_management_procedures.h" # include "s1ap_eNB_ue_context.h" /****************************************/ @@ -183,12 +183,13 @@ rrc_eNB_S1AP_get_ue_ids( instance_t instance = 0; s1ap_eNB_instance_t *s1ap_eNB_instance_p = NULL; s1ap_eNB_ue_context_t *ue_desc_p = NULL; + rrc_eNB_ue_context_t *ue_context_p = NULL; /*****************************/ hashtable_rc_t h_rc; if (ue_initial_id != UE_INITIAL_ID_INVALID) { h_rc = hashtable_get(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&result); - + if (h_rc == HASH_TABLE_OK) { if (eNB_ue_s1ap_id > 0) { @@ -216,10 +217,10 @@ rrc_eNB_S1AP_get_ue_ids( if ((result->ue_initial_id != result2->ue_initial_id) || (result->eNB_ue_s1ap_id != result2->eNB_ue_s1ap_id)) { - LOG_E(S1AP, "[eNB %ld] Error while hashtable_get, two rrc_ue_s1ap_ids_t that should be equal, are not: \ - ue_initial_id 1 = %"PRIu16", \ - ue_initial_id 2 = %"PRIu16", \ - eNB_ue_s1ap_id 1 = %"PRIu32", \ + LOG_E(S1AP, "[eNB %ld] Error while hashtable_get, two rrc_ue_s1ap_ids_t that should be equal, are not:\n \ + ue_initial_id 1 = %"PRIu16",\n \ + ue_initial_id 2 = %"PRIu16",\n \ + eNB_ue_s1ap_id 1 = %"PRIu32",\n \ eNB_ue_s1ap_id 2 = %"PRIu32"\n", rrc_instance_pP - RC.rrc[0], result->ue_initial_id, @@ -258,8 +259,7 @@ rrc_eNB_S1AP_get_ue_ids( * -> if the UE is in IDLE, hence no S1 context exist (in this case [h_rc != HASH_TABLE_OK] is normal) * -> ... (?) */ - LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", trying \ - to find it through S1AP context\n", + LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", trying to find it through S1AP context\n", rrc_instance_pP - RC.rrc[0], eNB_ue_s1ap_id); @@ -267,15 +267,34 @@ rrc_eNB_S1AP_get_ue_ids( s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); // get s1ap_eNB_instance + // s1ap_eNB_instance_p = s1ap_eNB_get_instance((uint8_t) rrc_instance_pP - RC.rrc[0]); // get s1ap_eNB_instance + // s1ap_eNB_instance_t *s1ap_eNB_get_instance(uint8_t mod_id); + ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, eNB_ue_s1ap_id); // get s1ap_eNB_ue_context if (ue_desc_p != NULL) { + result = rrc_eNB_S1AP_get_ue_ids(rrc_instance_pP, ue_desc_p->ue_initial_id, eNB_ue_s1ap_id); + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instance)], result->ue_rnti); + + if ((ue_context_p != NULL) && (ue_context_p->ue_context.eNB_ue_s1ap_id == 0)) { + + ue_context_p->ue_context.eNB_ue_s1ap_id = eNB_ue_s1ap_id; + + } else { + + LOG_E(RRC, "[eNB %ld] Incoherence between RRC context and S1AP context (%d != %d) for UE RNTI %d or UE RRC context doesn't exist\n", + rrc_instance_pP - RC.rrc[0], + ue_context_p->ue_context.eNB_ue_s1ap_id, + eNB_ue_s1ap_id, + result->ue_rnti); + + } + } else { - LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", even \ - when looking at S1AP context\n", + LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", even when looking at S1AP context\n", rrc_instance_pP - RC.rrc[0], eNB_ue_s1ap_id); @@ -286,44 +305,6 @@ rrc_eNB_S1AP_get_ue_ids( } // end else (ue_initial_id == UE_INITIAL_ID_INVALID) return result; - - // we assume that a rrc_ue_s1ap_ids_s is initially inserted in initial_id2_s1ap_ids - /* - if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result); - } - - if (ue_initial_id != UE_INITIAL_ID_INVALID) { - h_rc = hashtable_get(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&result); - - if (h_rc == HASH_TABLE_OK) { - - if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result2); - - if (h_rc != HASH_TABLE_OK) { - result2 = malloc(sizeof(*result2)); - - if (NULL != result2) { - *result2 = *result; - - result2->eNB_ue_s1ap_id = eNB_ue_s1ap_id; - result->eNB_ue_s1ap_id = eNB_ue_s1ap_id; - - h_rc = hashtable_insert(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, result2); - - if (h_rc != HASH_TABLE_OK) { - LOG_E(S1AP, "[eNB %ld] Error while hashtable_insert in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32"\n", - rrc_instance_pP - RC.rrc[0], - eNB_ue_s1ap_id); - } - } - } - } - } - } - return result; - */ } //------------------------------------------------------------------------------ @@ -1364,7 +1345,7 @@ rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND( eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); - + if (ue_context_p == NULL) { /* Can not associate this message to an UE index */ MessageDef *msg_complete_p = NULL; diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index 5c6b208b87..4a16450206 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -863,11 +863,7 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, "existing UE context 0x%06lx\n", assoc_id, enb_ue_s1ap_id); - /*MessageDef *msg_complete_p; - msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); - S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; - itti_send_msg_to_task(TASK_S1AP, ue_desc_p->eNB_instance->instance <=> 0, msg_complete_p); - */ + return -1; } else { MSC_LOG_TX_MESSAGE( @@ -877,6 +873,11 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, "0 S1AP_UE_CONTEXT_RELEASE_COMMAND/%d eNB_ue_s1ap_id "S1AP_UE_ID_FMT" ", enb_ue_s1ap_id); message_p = itti_alloc_new_message(TASK_S1AP, S1AP_UE_CONTEXT_RELEASE_COMMAND); + + if (ue_desc_p->mme_ue_s1ap_id == 0) { // case of Detach Request and switch off from RRC_IDLE mode + ue_desc_p->mme_ue_s1ap_id = mme_ue_s1ap_id; + } + S1AP_UE_CONTEXT_RELEASE_COMMAND(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); return 0; -- GitLab From 76e163625858c025c4dc6b217c3e2cb8cfd07ecf Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Mon, 12 Nov 2018 17:38:19 +0100 Subject: [PATCH 19/43] RRC timer reset in scheduler: format of some functions before first test --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 94 +++++++------ openair2/LAYER2/MAC/eNB_scheduler_fairRR.c | 146 +++++++++++---------- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 113 +++++++++------- openair2/RRC/LTE/rrc_eNB_S1AP.c | 4 - 4 files changed, 198 insertions(+), 159 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index d4f7c04d03..4b922e89a5 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1033,68 +1033,82 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, // TODO: check if the lcid is active LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", - module_idP, frameP, lcid, TBS, - TBS - ta_len - header_length_total - sdu_length_total - 3); + module_idP, + frameP, + lcid, + TBS, + TBS - ta_len - header_length_total - sdu_length_total - 3); if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - header_length_total - sdu_length_total - 3 + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_length_total - sdu_length_total - 3 #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + , 0, 0 #endif - ); - - + ); if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, - "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", - module_idP, frameP, - TBS - ta_len - header_length_total - sdu_length_total - 3, + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, + frameP, + TBS - ta_len - header_length_total - sdu_length_total - 3, lcid, header_length_total); - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, - TBS, //not used - (char *)&dlsch_buffer[sdu_length_total] + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + , 0, 0 #endif - ); - - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_INT(lcid), T_INT(sdu_lengths[num_sdus])); - - LOG_D(MAC, - "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_idP, sdu_lengths[num_sdus], lcid); + ); + + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(lcid), + T_INT(sdu_lengths[num_sdus])); + + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, + sdu_lengths[num_sdus], + lcid); sdu_lcids[num_sdus] = lcid; sdu_length_total += sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid]++; - UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = lcid; - UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[lcid] = sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = lcid; + UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[lcid] = sdu_lengths[num_sdus]; UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; - header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); - header_length_total += header_length_last; + header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); + header_length_total += header_length_last; num_sdus++; UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - } - } else { - // no TBS left - break; + + } // end if (rlc_status.bytes_in_buffer > 0) + } else { // no TBS left + break; // break for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c index 9ab4306000..282d906098 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -1404,85 +1404,95 @@ schedule_ue_spec_fairRR(module_id_t module_idP, header_len_dtch = 0; header_len_dtch_last = 0; // the header length of the last mac sdu // lcid has to be sorted before the actual allocation (similar struct as ue_list). - /* TODO limited lcid for performance */ - for (lcid = DTCH; lcid >= DTCH; lcid--) { - // TBD: check if the lcid is active - - header_len_dtch += 3; - header_len_dtch_last = 3; - LOG_D(MAC, - "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", - module_idP, frameP, lcid, TBS, - TBS - ta_len - header_len_dcch - - sdu_length_total - header_len_dtch); - - if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? - rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - - header_len_dcch - - sdu_length_total - - header_len_dtch + /* TODO limited lcid for performance */ + for (lcid = DTCH; lcid >= DTCH; lcid--) { + // TBD: check if the lcid is active + header_len_dtch += 3; + header_len_dtch_last = 3; + + LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, + frameP, + lcid, + TBS, + TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch); + + if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch #ifdef Rel14 - ,0, 0 + , 0, 0 #endif - ); + ); - if (rlc_status.bytes_in_buffer > 0) { - - LOG_D(MAC, - "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", - module_idP, frameP, - TBS - header_len_dcch - - sdu_length_total - header_len_dtch, lcid, + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, + frameP, + TBS - header_len_dcch - sdu_length_total - header_len_dtch, + lcid, header_len_dtch); - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, TBS, //not used - (char - *) - &dlsch_buffer - [sdu_length_total] -#ifdef Rel14 - ,0, 0 + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] +#ifdef Rel14 + , 0, 0 #endif - ); - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_INT(lcid), T_INT(sdu_lengths[num_sdus])); + ); + + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(lcid), + T_INT(sdu_lengths[num_sdus])); + + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, + sdu_lengths[num_sdus], + lcid); - LOG_D(MAC, - "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_idP, sdu_lengths[num_sdus], lcid); sdu_lcids[num_sdus] = lcid; sdu_length_total += sdu_lengths[num_sdus]; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] - += 1; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_bytes_tx - [lcid] += sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) { - header_len_dtch--; - header_len_dtch_last--; + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; + + if (sdu_lengths[num_sdus] < 128) { + header_len_dtch--; + header_len_dtch_last--; } + num_sdus++; - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - } // no data for this LCID - else { - header_len_dtch -= 3; - } - } // no TBS left - else { - header_len_dtch -= 3; - break; - } + + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + + } else { // no data for this LCID + header_len_dtch -= 3; + } + + } else { // no TBS left + header_len_dtch -= 3; + + break; + } } if (header_len_dtch == 0) header_len_dtch_last = 0; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 31c11e2c0a..8ad23798f7 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -669,69 +669,88 @@ rx_sdu(const module_id_t enb_mod_idP, // } break; - // all the DRBS + // 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)); + (unsigned char) ((unsigned char *) payload_ptr - sduP)); + for (j = 0; j < 32; j++) { - LOG_T(MAC, "%x ", payload_ptr[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 (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 (lcgid_updated[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] == 0) { - 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 (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; + } UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; - //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; } - if ((rx_lengths[i] < SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0)) { // MAX SIZE OF transport block - mac_rlc_data_ind(enb_mod_idP, current_rnti, 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]; - //clear uplane_inactivity_timer - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - } 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); - } + if ((rx_lengths[i] < SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0)) { // MAX SIZE OF transport block + mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); + + 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]; + + //clear uplane_inactivity_timer + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + + } 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; diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index f89bb76cff..c1371e2ef1 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -256,7 +256,6 @@ rrc_eNB_S1AP_get_ue_ids( * This case is uncommon, but can happen when: * -> if the first NAS message was a Detach Request (non exhaustiv), the UE RRC context exist * but is not associated with eNB_ue_s1ap_id - * -> if the UE is in IDLE, hence no S1 context exist (in this case [h_rc != HASH_TABLE_OK] is normal) * -> ... (?) */ LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", trying to find it through S1AP context\n", @@ -267,9 +266,6 @@ rrc_eNB_S1AP_get_ue_ids( s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); // get s1ap_eNB_instance - // s1ap_eNB_instance_p = s1ap_eNB_get_instance((uint8_t) rrc_instance_pP - RC.rrc[0]); // get s1ap_eNB_instance - // s1ap_eNB_instance_t *s1ap_eNB_get_instance(uint8_t mod_id); - ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, eNB_ue_s1ap_id); // get s1ap_eNB_ue_context if (ue_desc_p != NULL) { -- GitLab From 287010f82fcf15213a2549368dac7c776689d64e Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Tue, 13 Nov 2018 10:21:38 +0100 Subject: [PATCH 20/43] RRC timer: last format done. Timer reset in scheduling of DTCH (DL/UL). Commit to test. --- openair2/COMMON/platform_types.h | 2 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 17 +++++++++++++++++ openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 20 +++++++++++++++++++- openair2/RRC/LTE/rrc_eNB.c | 4 +++- openair2/RRC/LTE/rrc_eNB_S1AP.c | 7 ++++--- 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 843f645816..0578e92cbc 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -65,7 +65,7 @@ typedef int32_t sdu_size_t; typedef uint32_t frame_t; typedef int32_t sframe_t; typedef uint32_t sub_frame_t; -typedef uint16_t module_id_t; +typedef uint16_t module_id_t; typedef uint8_t slice_id_t; typedef uint8_t eNB_index_t; typedef uint16_t ue_id_t; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 4b922e89a5..a77d5f36d2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -43,6 +43,10 @@ #include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +/************************************************/ +//#include "RRC/LTE/rrc_eNB_UE_context.h" +//#include "RRC/LTE/rrc_defs.h" +/************************************************/ //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" @@ -466,6 +470,8 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, int header_length_last; int header_length_total; + rrc_eNB_ue_context_t *ue_contextP; // added by LA + start_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); @@ -1106,6 +1112,17 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + // reset RRC inactivity timer after uplane activity + ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti); + ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; + + LOG_W(RRC, "After reset, rrc_inactivity_timer is %d, of UE rntiP %d, ue_context_rnti %d, UE_id %d, ue_initial_id %d\n", + ue_contextP->ue_context.ue_rrc_inactivity_timer, + rnti, + ue_contextP->ue_id_rnti, + UE_id, + ue_contextP->ue_context.ue_initial_id); + } // end if (rlc_status.bytes_in_buffer > 0) } else { // no TBS left break; // break for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 8ad23798f7..d8418e7b11 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -45,6 +45,10 @@ #include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +/************************************************/ +//#include "RRC/LTE/rrc_eNB_UE_context.h" +//#include "RRC/LTE/rrc_defs.h" +/************************************************/ #include "assertions.h" //#include "LAYER2/MAC/pre_processor.c" @@ -111,6 +115,8 @@ rx_sdu(const module_id_t enb_mod_idP, (RA_t *) & RC.mac[enb_mod_idP]->common_channels[CC_idP].ra[0]; int first_rb = 0; + rrc_eNB_ue_context_t *ue_contextP; // added by LA + start_meas(&mac->rx_ulsch_sdu); if ((UE_id > MAX_MOBILES_PER_ENB) || (UE_id == -1)) @@ -732,6 +738,18 @@ rx_sdu(const module_id_t enb_mod_idP, //clear uplane_inactivity_timer UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + // reset RRC inactivity timer after uplane activity + ue_contextP = rrc_eNB_get_ue_context(RC.rrc[enb_mod_idP], rntiP); + ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; + + LOG_W(RRC, "After reset, rrc_inactivity_timer is %d, of UE rntiP %d, ue_context_rnti %d, UE_id %d, ue_initial_id %d\n", + ue_contextP->ue_context.ue_rrc_inactivity_timer, + rntiP, + ue_contextP->ue_id_rnti, + UE_id, + ue_contextP->ue_context.ue_initial_id); + + } else { /* rx_length[i] */ UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx += 1; @@ -743,7 +761,7 @@ rx_sdu(const module_id_t enb_mod_idP, UE_id); } - } else { /*(UE_id != -1 */ + } else { // end if (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, diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index d63b289e32..240712aec4 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -1036,7 +1036,7 @@ rrc_eNB_process_RRCConnectionSetupComplete( ue_context_pP->ue_context.Srb1.Active = 1; ue_context_pP->ue_context.Status = RRC_CONNECTED; ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED - ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres = 10000; // SHOULD NOT BE DONE HERE !!!!! + ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres = 10000; // The value should come from config file T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); @@ -1369,6 +1369,8 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( uint8_t next_xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); ue_context_pP->ue_context.Status = RRC_CONNECTED; + ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED + ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres = 10000; // The value should come from config file ue_context_pP->ue_context.reestablishment_xid = next_xid; SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[xid]; diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index c1371e2ef1..f7116ff8a4 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -167,7 +167,8 @@ void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_c # if defined(ENABLE_ITTI) //------------------------------------------------------------------------------ /* -* TODO +* Get the UE S1 struct containing hashtables S1_id/UE_id. +* Is also used to set the S1_id of the UE, depending on inputs. */ struct rrc_ue_s1ap_ids_s* rrc_eNB_S1AP_get_ue_ids( @@ -305,7 +306,7 @@ rrc_eNB_S1AP_get_ue_ids( //------------------------------------------------------------------------------ /* -* TODO +* Remove UE ids (ue_initial_id and S1_id) from hashtables. */ void rrc_eNB_S1AP_remove_ue_ids( @@ -789,7 +790,7 @@ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( //------------------------------------------------------------------------------ /* -* TODO +* Initial UE NAS message on S1AP. */ void rrc_eNB_send_S1AP_NAS_FIRST_REQ( -- GitLab From 961a70a04e1f2332567793659e1df3e6aaf707ba Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Tue, 13 Nov 2018 11:20:14 +0100 Subject: [PATCH 21/43] Fusion wasn't ok, needed some modifications --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 24 +++++++++++------------ openair2/RRC/LTE/MESSAGES/asn1_msg.c | 12 ++++++------ openair2/RRC/LTE/rrc_eNB.c | 2 +- openair2/RRC/LTE/rrc_eNB_S1AP.c | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index a010c4ab9c..76dbd2a0a1 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1047,18 +1047,18 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - header_length_total - sdu_length_total - 3 -#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , 0, 0 + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_length_total - sdu_length_total - 3 +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + , 0, 0 #endif - ); + ); if (rlc_status.bytes_in_buffer > 0) { LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", @@ -1077,7 +1077,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, lcid, TBS, //not used (char *)&dlsch_buffer[sdu_length_total] -#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , 0, 0 #endif ); diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index 4dc6c987ab..566661bd20 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -190,27 +190,27 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich switch (N_RB_DL) { case 6: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6; + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n6; break; case 15: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n15; + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n15; break; case 25: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n25; + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n25; break; case 50: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n50; + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n50; break; case 75: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n75; + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n75; break; case 100: - mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n100; + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n100; break; default: AssertFatal(1==0,"Unknown dl_Bandwidth %d\n",N_RB_DL); diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index d9ce73f038..c20a13bf00 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -1025,7 +1025,7 @@ void rrc_eNB_process_RRCConnectionSetupComplete( const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *ue_context_pP, - RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete + LTE_RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete ) //----------------------------------------------------------------------------- { diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 73316f4673..5fd32d038a 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -796,7 +796,7 @@ void rrc_eNB_send_S1AP_NAS_FIRST_REQ( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, - RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete + LTE_RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete ) //------------------------------------------------------------------------------ { -- GitLab From 9a080adec57d9761babe49d2a1238a071e670a36 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Tue, 13 Nov 2018 14:20:16 +0100 Subject: [PATCH 22/43] RRC inactivity timer: first commit to DRX_master --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 13 +------------ openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 16 ++-------------- openair2/RRC/LTE/rrc_eNB_S1AP.c | 3 +-- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 76dbd2a0a1..a79b273a81 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -43,10 +43,6 @@ #include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -/************************************************/ -//#include "RRC/LTE/rrc_eNB_UE_context.h" -//#include "RRC/LTE/rrc_defs.h" -/************************************************/ //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" @@ -470,7 +466,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, int header_length_last; int header_length_total; - rrc_eNB_ue_context_t *ue_contextP; // added by LA + rrc_eNB_ue_context_t *ue_contextP = NULL; start_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); @@ -1116,13 +1112,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti); ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; - LOG_W(RRC, "After reset, rrc_inactivity_timer is %d, of UE rntiP %d, ue_context_rnti %d, UE_id %d, ue_initial_id %d\n", - ue_contextP->ue_context.ue_rrc_inactivity_timer, - rnti, - ue_contextP->ue_id_rnti, - UE_id, - ue_contextP->ue_context.ue_initial_id); - } // end if (rlc_status.bytes_in_buffer > 0) } else { // no TBS left break; // break for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index fcd87d926a..997877d7a8 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -45,10 +45,6 @@ #include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -/************************************************/ -//#include "RRC/LTE/rrc_eNB_UE_context.h" -//#include "RRC/LTE/rrc_defs.h" -/************************************************/ #include "assertions.h" //#include "LAYER2/MAC/pre_processor.c" @@ -115,7 +111,7 @@ rx_sdu(const module_id_t enb_mod_idP, (RA_t *) & RC.mac[enb_mod_idP]->common_channels[CC_idP].ra[0]; int first_rb = 0; - rrc_eNB_ue_context_t *ue_contextP; // added by LA + rrc_eNB_ue_context_t *ue_contextP = NULL; start_meas(&mac->rx_ulsch_sdu); @@ -743,15 +739,7 @@ rx_sdu(const module_id_t enb_mod_idP, // reset RRC inactivity timer after uplane activity ue_contextP = rrc_eNB_get_ue_context(RC.rrc[enb_mod_idP], rntiP); - ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; - - LOG_W(RRC, "After reset, rrc_inactivity_timer is %d, of UE rntiP %d, ue_context_rnti %d, UE_id %d, ue_initial_id %d\n", - ue_contextP->ue_context.ue_rrc_inactivity_timer, - rntiP, - ue_contextP->ue_id_rnti, - UE_id, - ue_contextP->ue_context.ue_initial_id); - + ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; } else { /* rx_length[i] */ UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx += 1; diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 5fd32d038a..b7d15da58d 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -36,11 +36,10 @@ # include "rrc_eNB_S1AP.h" # include "enb_config.h" # include "common/ran_context.h" -/****************************************/ + # include "s1ap_eNB_defs.h" # include "s1ap_eNB_management_procedures.h" # include "s1ap_eNB_ue_context.h" -/****************************************/ # if defined(ENABLE_ITTI) # include "asn1_conversions.h" -- GitLab From af892cc0580107177e1652a938aa57e61722215d Mon Sep 17 00:00:00 2001 From: laurent Date: Wed, 14 Nov 2018 20:51:41 +0100 Subject: [PATCH 23/43] start fixing parallel threads --- common/utils/LOG/log.c | 4 - nfapi/oai_integration/nfapi_vnf.c | 4 +- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 2 +- .../PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c | 19 ++--- openair1/PHY/defs_common.h | 53 ++++++++++-- openair1/PHY/defs_eNB.h | 3 +- openair1/SCHED/phy_procedures_lte_eNb.c | 4 +- openair1/SIMULATION/LTE_PHY/common_sim.h | 42 ++++++---- openair1/SIMULATION/LTE_PHY/dlsim.c | 80 +++++++----------- openair1/SIMULATION/LTE_PHY/ulsim.c | 83 +++++++------------ targets/RT/USER/lte-enb.c | 13 +-- targets/RT/USER/lte-softmodem.c | 26 +----- targets/RT/USER/lte-uesoftmodem.c | 24 +----- 13 files changed, 151 insertions(+), 206 deletions(-) diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index d6dd97e34f..4f0f379f12 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -39,10 +39,6 @@ #include "vcd_signal_dumper.h" #include "assertions.h" -#if defined(ENABLE_ITTI) -# include "intertask_interface.h" -#endif - # include # include #include diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 8022bc53f4..bd9ce8dc1c 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -196,14 +196,12 @@ void oai_create_enb(void) { int bodge_counter=0; PHY_VARS_eNB *eNB = RC.eNB[0][0]; - printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d td:%p te:%p if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, eNB->single_thread_flag, eNB->td, eNB->te, eNB->if_inst); + printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, eNB->single_thread_flag, eNB->if_inst); eNB->Mod_id = bodge_counter; eNB->CC_id = bodge_counter; eNB->abstraction_flag = 0; eNB->single_thread_flag = 0;//single_thread_flag; - eNB->td = ulsch_decoding_data_all;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding_all;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; RC.nb_CC[bodge_counter] = 1; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 046e456916..50b9ef17ac 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -1505,7 +1505,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, // Do ULSCH Decoding for data portion - ret = eNB->td(eNB,UE_id,harq_pid,llr8_flag); + ret = ulsch_decoding_data_all(eNB,UE_id,harq_pid,llr8_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,0); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index e8f20c85de..89b15ece93 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -1298,7 +1298,7 @@ void dlsch_channel_compensation(int **rxdataF_ext, unsigned short rb; unsigned char aatx,aarx,symbol_mod,pilots=0; __m128i *dl_ch128,*dl_ch128_2,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128,*rho128; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; @@ -1311,9 +1311,9 @@ void dlsch_channel_compensation(int **rxdataF_ext, } for (aatx=0; aatxnb_antenna_ports_eNB; aatx++) { + __m128i QAM_amp128b = _mm_setzero_si128(); if (mod_order == 4) { QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) - QAM_amp128b = _mm_setzero_si128(); } else if (mod_order == 6) { QAM_amp128 = _mm_set1_epi16(QAM64_n1); // QAM_amp128b = _mm_set1_epi16(QAM64_n2); @@ -1766,11 +1766,11 @@ void dlsch_channel_compensation_core(int **rxdataF_ext, int length_mod8 = 0; int length2; __m128i *dl_ch128,*dl_ch_mag128,*dl_ch_mag128b, *dl_ch128_2, *rxdataF128,*rxdataF_comp128,*rho128; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128; int aatx = 0, aarx = 0; for (aatx=0; aatx=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; @@ -2167,10 +2167,9 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext, //printf("comp prec: symbol %d, pilots %d\n",symbol, pilots); - + __m128i QAM_amp128b = _mm_setzero_si128(); if (mod_order == 4) { QAM_amp128 = _mm_set1_epi16(QAM16_n1); - QAM_amp128b = _mm_setzero_si128(); } else if (mod_order == 6) { QAM_amp128 = _mm_set1_epi16(QAM64_n1); QAM_amp128b = _mm_set1_epi16(QAM64_n2); @@ -2621,7 +2620,7 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms, int **rxdataF_comp0 = pdsch_vars->rxdataF_comp0; int **rxdataF_comp1 = pdsch_vars->rxdataF_comp1[harq_pid][round]; unsigned char *pmi_ext = pdsch_vars->pmi_ext; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp0_128,QAM_amp0_128b,QAM_amp1_128,QAM_amp1_128b; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp0_128,QAM_amp1_128; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; @@ -2632,17 +2631,17 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms, // printf("comp prec: symbol %d, pilots %d\n",symbol, pilots); + __m128i QAM_amp0_128b = _mm_setzero_si128(); if (mod_order0 == 4) { QAM_amp0_128 = _mm_set1_epi16(QAM16_n1); - QAM_amp0_128b = _mm_setzero_si128(); } else if (mod_order0 == 6) { QAM_amp0_128 = _mm_set1_epi16(QAM64_n1); QAM_amp0_128b = _mm_set1_epi16(QAM64_n2); } + __m128i QAM_amp1_128b = _mm_setzero_si128(); if (mod_order1 == 4) { QAM_amp1_128 = _mm_set1_epi16(QAM16_n1); - QAM_amp1_128b = _mm_setzero_si128(); } else if (mod_order1 == 6) { QAM_amp1_128 = _mm_set1_epi16(QAM64_n1); QAM_amp1_128b = _mm_set1_epi16(QAM64_n2); diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index ae0168b53c..9f4a196a9b 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -58,6 +58,7 @@ #include #include "common_lib.h" #include "msc.h" +#include //#include @@ -862,22 +863,60 @@ typedef enum { RESYNCH=4 } UE_MODE_t; -/// Threading Parameter +#define FOREACH_PARALLEL(GEN) \ + GEN(PARALLEL_SINGLE_THREAD) \ + GEN(PARALLEL_RU_L1_SPLIT) \ + GEN(PARALLEL_RU_L1_TRX_SPLIT) + +#define GENERATE_ENUM(N) N, +#define GENERATE_ENUMTXT(N) {(char*)#N, N}, + typedef enum { - PARALLEL_SINGLE_THREAD =0, - PARALLEL_RU_L1_SPLIT =1, - PARALLEL_RU_L1_TRX_SPLIT =2 -}PARALLEL_CONF_t; + FOREACH_PARALLEL(GENERATE_ENUM) +} PARALLEL_CONF_t; +#define FOREACH_WORKER(GEN) GEN(WORKER_DISABLE) GEN(WORKER_ENABLE) typedef enum { - WORKER_DISABLE =0, - WORKER_ENABLE =1 + FOREACH_WORKER(GENERATE_ENUM) }WORKER_CONF_t; typedef struct THREAD_STRUCT_s { PARALLEL_CONF_t parallel_conf; WORKER_CONF_t worker_conf; } THREAD_STRUCT; +extern THREAD_STRUCT thread_struct; + +static inline void set_parallel_conf(char *parallel_conf) { + mapping config[]= { + FOREACH_PARALLEL(GENERATE_ENUMTXT) + {NULL,-1} + }; + thread_struct.parallel_conf = (PARALLEL_CONF_t)map_str_to_int(config, parallel_conf); + if (thread_struct.parallel_conf == -1 ) { + LOG_E(ENB_APP,"Impossible value: %s\n", parallel_conf); + thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; + } +} + +static inline void set_worker_conf(char *worker_conf) { + mapping config[]={ + FOREACH_WORKER(GENERATE_ENUMTXT) + {NULL, -1} + }; + thread_struct.worker_conf = (WORKER_CONF_t)map_str_to_int(config, worker_conf); + if (thread_struct.worker_conf == -1 ) { + LOG_E(ENB_APP,"Impossible value: %s\n", worker_conf); + thread_struct.worker_conf = WORKER_DISABLE ; + } +} + +static inline PARALLEL_CONF_t get_thread_parallel_conf(void) { + return thread_struct.parallel_conf; +} + +static inline WORKER_CONF_t get_thread_worker_conf(void) { + return thread_struct.worker_conf; +} typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 2db81aef77..bb147a3963 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -904,8 +904,6 @@ typedef struct PHY_VARS_eNB_s { /// Ethernet parameters for fronthaul interface eth_params_t eth_params; int rx_total_gain_dB; - int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag); - int (*te)(struct PHY_VARS_eNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *); int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); uint8_t local_flag; LTE_DL_FRAME_PARMS frame_parms; @@ -1080,6 +1078,7 @@ typedef struct PHY_VARS_eNB_s { time_stats_t ofdm_mod_stats; time_stats_t dlsch_common_and_dci; + time_stats_t dlsch_ue_specific; time_stats_t dlsch_encoding_stats; time_stats_t dlsch_modulation_stats; time_stats_t dlsch_scrambling_stats; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index b1d09ba8e9..141f6e43ff 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -400,7 +400,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, start_meas(&eNB->dlsch_encoding_stats); - eNB->te(eNB, + dlsch_encoding_all(eNB, dlsch_harq->pdu, dlsch_harq->pdsch_start, dlsch, @@ -582,6 +582,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, } if (do_meas==1) stop_meas(&eNB->dlsch_common_and_dci); + if (do_meas==1) start_meas(&eNB->dlsch_ue_specific); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0); @@ -649,6 +650,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_PHICH,0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),0); + if (do_meas==1) stop_meas(&eNB->dlsch_ue_specific); if (do_meas==1) stop_meas(&eNB->phy_proc_tx); } diff --git a/openair1/SIMULATION/LTE_PHY/common_sim.h b/openair1/SIMULATION/LTE_PHY/common_sim.h index 46f4cdf161..e9ad4dc888 100644 --- a/openair1/SIMULATION/LTE_PHY/common_sim.h +++ b/openair1/SIMULATION/LTE_PHY/common_sim.h @@ -49,38 +49,46 @@ void sumUpStatsSlot(time_stats_t *res, time_stats_t src[RX_NB_TH][2], int lastAc res->p_time=src[lastActive][last].p_time; } -void printStatIndent(time_stats_t *ptr, char *txt) { - printf("|__ %-50s %.2f us (%d trials)\n", +double squareRoot(time_stats_t *ptr) { + double timeBase=1/(1000*cpu_freq_GHz); + return sqrt((double)ptr->diff_square*pow(timeBase,2)/ptr->trials - + pow((double)ptr->diff/ptr->trials*timeBase,2)); +} + +void printDistribution(time_stats_t *ptr, varArray_t *sortedList, char *txt) { + double timeBase=1/(1000*cpu_freq_GHz); + printf("%-43s %6.2f us (%d trials)\n", txt, - ptr->trials?inMicroS(ptr->diff/ptr->trials):0, + (double)ptr->diff/ptr->trials*timeBase, ptr->trials); + printf(" Statistics std=%.2f, median=%.2f, q1=%.2f, q3=%.2f µs (on %ld trials)\n", + squareRoot(ptr), median(sortedList),q1(sortedList),q3(sortedList), sortedList->size); } -void printStatIndent2(time_stats_t *ptr, char *txt, int turbo_iter) { - double timeBase=1/(1000*cpu_freq_GHz); - printf(" |__ %-45s %.2f us (cycles/block %ld, %5d trials)\n", +void printStatIndent(time_stats_t *ptr, char *txt) { + printf("|__ %-38s %6.2f us (%3d trials)\n", txt, - ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0, - turbo_iter?(uint64_t)round(((double)ptr->diff)/turbo_iter):0, + ptr->trials?inMicroS(ptr->diff/ptr->trials):0, ptr->trials); } -double squareRoot(time_stats_t *ptr) { +void printStatIndent2(time_stats_t *ptr, char *txt) { double timeBase=1/(1000*cpu_freq_GHz); - return sqrt((double)ptr->diff_square*pow(timeBase,2)/ptr->trials - - pow((double)ptr->diff/ptr->trials*timeBase,2)); + printf(" |__ %-34s %6.2f us (%3d trials)\n", + txt, + ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0, + ptr->trials); } -void printDistribution(time_stats_t *ptr, varArray_t *sortedList, char *txt) { +void printStatIndent3(time_stats_t *ptr, char *txt) { double timeBase=1/(1000*cpu_freq_GHz); - printf("%-50s :%.2f us (%d trials)\n", + printf(" |__ %-30s %6.2f us (%3d trials)\n", txt, - (double)ptr->diff/ptr->trials*timeBase, - ptr->trials); - printf("|__ Statistics std=%.2f, median=%.2f, q1=%.2f, q3=%.2f µs (on %ld trials)\n", - squareRoot(ptr), median(sortedList),q1(sortedList),q3(sortedList), sortedList->size); + ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0, + ptr->trials); } + void logDistribution(FILE* fd, time_stats_t *ptr, varArray_t *sortedList, int dropped) { fprintf(fd,"%f;%f;%f;%f;%f;%f;%d;", squareRoot(ptr), diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 0f4655eb2c..dde026f418 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -85,30 +85,7 @@ double t_rx_min = 1000000000; /*!< \brief initial min process time for rx */ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ -char *parallel_config = NULL; -char *worker_config = NULL; -static THREAD_STRUCT thread_struct; -void set_parallel_conf(char *parallel_conf) -{ - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) -{ - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) -{ - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) -{ - return thread_struct.worker_conf; -} +THREAD_STRUCT thread_struct; int emulate_rf = 0; @@ -715,7 +692,7 @@ int main(int argc, char **argv) DL_req.dl_config_request_body.dl_config_pdu_list = dl_config_pdu_list; TX_req.tx_request_body.tx_pdu_list = tx_pdu_list; - + set_parallel_conf("PARALLEL_SINGLE_THREAD"); cpuf = cpu_freq_GHz; //signal(SIGSEGV, handler); @@ -758,6 +735,7 @@ int main(int argc, char **argv) { "Subframe", "subframe ",0, iptr:&subframe, defintval:7, TYPE_INT, 0 }, { "Trnti", "rnti",0, u16ptr:&n_rnti, defuintval:0x1234, TYPE_UINT16, 0 }, { "vi_mod", "i_mod",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, + { "Qparallel", "Enable parallel execution",0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0 }, { "Performance", "Display CPU perfomance of each L1 piece", PARAMFLAG_BOOL, iptr:&print_perf, defintval:0, TYPE_INT, 0 }, { "q_tx_port", "Number of TX antennas ports used in eNB",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, { "uEdual", "Enables the Interference Aware Receiver for TM5 (default is normal receiver)",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, @@ -965,6 +943,10 @@ int main(int argc, char **argv) break; + case 'Q': + set_parallel_conf(optarg); + break; + default: printf("Wrong option: %s\n",long_options[option_index].name); exit(1); @@ -982,8 +964,8 @@ int main(int argc, char **argv) if (help) exit(0); - set_parallel_conf("PARALLEL_RU_L1_TRX_SPLIT"); - set_worker_conf("WORKER_ENABLE"); + if (thread_struct.parallel_conf != PARALLEL_SINGLE_THREAD) + set_worker_conf("WORKER_ENABLE"); if (transmission_mode>1) pa=dBm3; printf("dlsim: tmode %d, pa %d\n",transmission_mode,pa); @@ -1079,11 +1061,7 @@ int main(int argc, char **argv) ru->do_precoding=1; eNB->mac_enabled=1; - if (two_thread_flag == 0) { - eNB->te = dlsch_encoding; - } - else { - eNB->te = dlsch_encoding_2threads; + if(get_thread_worker_conf() == WORKER_ENABLE) { extern void init_td_thread(PHY_VARS_eNB *); extern void init_te_thread(PHY_VARS_eNB *); init_td_thread(eNB); @@ -1442,6 +1420,8 @@ int main(int argc, char **argv) reset_meas(&eNB->dlsch_interleaving_stats); reset_meas(&eNB->dlsch_rate_matching_stats); reset_meas(&eNB->dlsch_turbo_encoding_stats); + reset_meas(&eNB->dlsch_common_and_dci); + reset_meas(&eNB->dlsch_ue_specific); for (int i=0; iphy_proc_rx[i]); // total UE rx reset_meas(&UE->ue_front_end_stat[i]); @@ -1783,9 +1763,6 @@ int main(int argc, char **argv) } - - - if (UE->dlsch[UE->current_thread_id[subframe]][eNB_id][0]->harq_ack[subframe].ack == 1) { avg_iter += UE->dlsch[UE->current_thread_id[subframe]][eNB_id][0]->last_iteration_cnt; @@ -2011,21 +1988,22 @@ int main(int argc, char **argv) printf("\neNB TX function statistics (per 1ms subframe)\n"); printDistribution(&eNB->phy_proc_tx,table_tx,"PHY proc tx"); printStatIndent(&eNB->dlsch_common_and_dci,"DL common channels and dci time"); - printStatIndent(&eNB->dlsch_encoding_stats,"DLSCH encoding time"); - printStatIndent2(&eNB->dlsch_rate_matching_stats,"DLSCH rate matching time",eNB->dlsch_rate_matching_stats.trials); - printStatIndent2(&eNB->dlsch_turbo_encoding_stats,"DLSCH turbo encoding time", eNB->dlsch_turbo_encoding_stats.trials); - printStatIndent2(&eNB->dlsch_interleaving_stats,"DLSCH interleaving time", eNB->dlsch_interleaving_stats.trials); - printStatIndent(&eNB->dlsch_scrambling_stats, "DLSCH scrambling time"); - printStatIndent(&eNB->dlsch_modulation_stats, "DLSCH modulation time"); + printStatIndent(&eNB->dlsch_ue_specific,"DL per ue part time"); + printStatIndent2(&eNB->dlsch_encoding_stats,"DLSCH encoding time"); + printStatIndent3(&eNB->dlsch_rate_matching_stats,"DLSCH rate matching time"); + printStatIndent3(&eNB->dlsch_turbo_encoding_stats,"DLSCH turbo encoding time"); + printStatIndent3(&eNB->dlsch_interleaving_stats,"DLSCH interleaving time"); + printStatIndent2(&eNB->dlsch_scrambling_stats, "DLSCH scrambling time"); + printStatIndent2(&eNB->dlsch_modulation_stats, "DLSCH modulation time"); printDistribution(&eNB->ofdm_mod_stats,table_tx_ifft,"OFDM_mod (idft) time"); printf("\nUE RX function statistics (per 1ms subframe)\n"); printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx"); printStatIndent(&ue_front_end_tot,"Front end processing"); printStatIndent(&dlsch_llr_tot,"rx_pdsch processing"); - printStatIndent2(&pdsch_procedures_tot,"pdsch processing", pdsch_procedures_tot.trials); - printStatIndent2(&dlsch_procedures_tot,"dlsch processing", dlsch_procedures_tot.trials); - printStatIndent2(&UE->crnti_procedures_stats,"C-RNTI processing", UE->crnti_procedures_stats.trials); + printStatIndent2(&pdsch_procedures_tot,"pdsch processing"); + printStatIndent2(&dlsch_procedures_tot,"dlsch processing"); + printStatIndent2(&UE->crnti_procedures_stats,"C-RNTI processing"); printStatIndent(&UE->ofdm_demod_stats,"ofdm demodulation"); printStatIndent(&UE->dlsch_channel_estimation_stats,"DLSCH channel estimation time"); printStatIndent(&UE->dlsch_freq_offset_estimation_stats,"DLSCH frequency offset estimation time"); @@ -2041,13 +2019,13 @@ int main(int argc, char **argv) (double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials*timeBase, (int)((double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials), UE->dlsch_turbo_decoding_stats.trials); - printStatIndent2(&UE->dlsch_tc_init_stats,"init", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_alpha_stats,"alpha", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_beta_stats,"beta", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_gamma_stats,"gamma", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_ext_stats,"ext", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_intl1_stats,"turbo internal interleaver", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC", UE->dlsch_tc_init_stats.trials); + printStatIndent2(&UE->dlsch_tc_init_stats,"init"); + printStatIndent2(&UE->dlsch_tc_alpha_stats,"alpha"); + printStatIndent2(&UE->dlsch_tc_beta_stats,"beta"); + printStatIndent2(&UE->dlsch_tc_gamma_stats,"gamma"); + printStatIndent2(&UE->dlsch_tc_ext_stats,"ext"); + printStatIndent2(&UE->dlsch_tc_intl1_stats,"turbo internal interleaver"); + printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC"); } diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index c015063b60..52d7f023f1 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -96,30 +96,7 @@ nfapi_tx_request_pdu_t tx_pdu_list[MAX_NUM_TX_REQUEST_PDU]; nfapi_tx_request_t TX_req; Sched_Rsp_t sched_resp; -char *parallel_config = NULL; -char *worker_config = NULL; -static THREAD_STRUCT thread_struct; -void set_parallel_conf(char *parallel_conf) -{ - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) -{ - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) -{ - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) -{ - return thread_struct.worker_conf; -} +THREAD_STRUCT thread_struct; void fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu, @@ -410,7 +387,6 @@ int main(int argc, char **argv) { double effective_rate=0.0; char channel_model_input[10]= {0}; static int max_turbo_iterations=4; - static int parallel_flag=0; int nb_rb_set = 0; int sf; static int threequarter_fs=0; @@ -428,6 +404,8 @@ int main(int argc, char **argv) { TX_req.tx_request_body.tx_pdu_list = tx_pdu_list; cpu_freq_GHz = (double)get_cpu_freq_GHz(); cpuf = cpu_freq_GHz; + set_parallel_conf("PARALLEL_SINGLE_THREAD"); + printf("Detected cpu_freq %f GHz\n",cpu_freq_GHz); AssertFatal(load_configmodule(argc,argv) != NULL, "cannot load configuration module, exiting\n"); @@ -455,7 +433,7 @@ int main(int argc, char **argv) { { "Doppler", "Maximum doppler shift",0, dblptr:&maxDoppler, defdblval:0.0, TYPE_DOUBLE, 0 }, { "Zdump", "dump table",PARAMFLAG_BOOL, iptr:&dump_table, defintval:0, TYPE_INT, 0 }, { "Forms", "Display the soft scope", PARAMFLAG_BOOL, iptr:&xforms, defintval:0, TYPE_INT, 0 }, - { "Lparallel", "Enable parallel execution", PARAMFLAG_BOOL, iptr:¶llel_flag, defintval:0, TYPE_INT, 0 }, + { "Lparallel", "Enable parallel execution",0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0 }, { "Iterations", "Number of iterations of turbo decoder", 0, iptr:&max_turbo_iterations, defintval:4, TYPE_INT, 0 }, { "Performance", "Display CPU perfomance of each L1 piece", PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0 }, { "Q_cqi", "Enable CQI", PARAMFLAG_BOOL, iptr:&cqi_flag, defintval:0, TYPE_INT, 0 }, @@ -600,6 +578,10 @@ int main(int argc, char **argv) { opp_enabled=1; break; + case 'L': + set_parallel_conf(optarg); + break; + default: printf("Wrong option: %s\n",long_options[option_index].name); exit(1); @@ -618,8 +600,8 @@ int main(int argc, char **argv) { if (help) exit(0); - set_parallel_conf("PARALLEL_RU_L1_TRX_SPLIT"); - set_worker_conf("WORKER_ENABLE"); + if (thread_struct.parallel_conf != PARALLEL_SINGLE_THREAD) + set_worker_conf("WORKER_ENABLE"); RC.nb_L1_inst = 1; RC.nb_RU = 1; lte_param_init(&eNB,&UE,&ru, @@ -767,7 +749,7 @@ int main(int argc, char **argv) { UE->ulsch[0] = new_ue_ulsch(N_RB_DL,0); printf("ULSCH %p\n",UE->ulsch[0]); - if (parallel_flag == 1) { + if(get_thread_worker_conf() == WORKER_ENABLE) { extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_td_thread(PHY_VARS_eNB *); init_fep_thread(eNB,NULL); @@ -1175,8 +1157,7 @@ int main(int argc, char **argv) { } start_meas(&eNB->phy_proc_rx); - ru->feprx = (parallel_flag == 1) ? ru_fep_full_2thread : fep_full; - eNB->td = (parallel_flag == 1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; + ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? ru_fep_full_2thread : fep_full; ru->feprx(ru); phy_procedures_eNB_uespec_RX(eNB,proc_rxtx); stop_meas(&eNB->phy_proc_rx); @@ -1377,20 +1358,18 @@ int main(int argc, char **argv) { printStatIndent(&UE->ulsch_rate_matching_stats,"ULSCH rate-matching time"); printStatIndent(&UE->ulsch_interleaving_stats,"ULSCH sub-block interleaving"); printStatIndent(&UE->ulsch_multiplexing_stats,"ULSCH multiplexing time"); - printDistribution(&eNB->phy_proc_rx,table_rx,"\nTotal PHY proc rx subframe"); - printDistribution(&ru->ofdm_demod_stats,table_rx_fft,"OFDM_demod time"); - printDistribution(&eNB->ulsch_demodulation_stats,table_rx_demod,"ULSCH demodulation time"); - printf("ULSCH Decoding time (%.2f Mbit/s, avg iter %.2f) :%.2f us (%d trials, max %.2f)\n", - UE->ulsch[0]->harq_processes[harq_pid]->TBS/1000.0,(double)iter_trials, - (double)eNB->ulsch_decoding_stats.diff/eNB->ulsch_decoding_stats.trials*timeBase, - eNB->ulsch_decoding_stats.trials, - (double)eNB->ulsch_decoding_stats.max*timeBase); - printf("|__ Statistics std: %.2fus median %.2fus q1 %.2fus q3 %.2fus \n", - squareRoot(&eNB->ulsch_decoding_stats), - median(table_rx_dec), q1(table_rx_dec), q3(table_rx_dec)); - printStatIndent(&eNB->ulsch_deinterleaving_stats,"sub-block interleaving" ); - printStatIndent(&eNB->ulsch_demultiplexing_stats,"sub-block demultiplexing" ); - printStatIndent(&eNB->ulsch_rate_unmatching_stats,"sub-block rate-matching" ); + printf("\n"); + printDistribution(&eNB->phy_proc_rx,table_rx,"Total PHY proc rx subframe"); + printDistribution(&ru->ofdm_demod_stats,table_rx_fft,"|__ OFDM_demod time"); + printDistribution(&eNB->ulsch_demodulation_stats,table_rx_demod,"|__ ULSCH demodulation time"); + printDistribution(&eNB->ulsch_decoding_stats,table_rx_dec,"|__ ULSCH Decoding time"); + printf(" (%.2f Mbit/s, avg iter %.2f, max %.2f)\n", + UE->ulsch[0]->harq_processes[harq_pid]->TBS/1000.0, + (double)iter_trials, + (double)eNB->ulsch_decoding_stats.max*timeBase); + printStatIndent2(&eNB->ulsch_deinterleaving_stats,"sub-block interleaving" ); + printStatIndent2(&eNB->ulsch_demultiplexing_stats,"sub-block demultiplexing" ); + printStatIndent2(&eNB->ulsch_rate_unmatching_stats,"sub-block rate-matching" ); printf("|__ turbo_decoder(%d bits), avg iterations: %.1f %.2f us (%d cycles, %d trials)\n", eNB->ulsch[0]->harq_processes[harq_pid]->Cminus ? eNB->ulsch[0]->harq_processes[harq_pid]->Kminus : @@ -1399,13 +1378,13 @@ int main(int argc, char **argv) { (double)eNB->ulsch_turbo_decoding_stats.diff/eNB->ulsch_turbo_decoding_stats.trials*timeBase, (int)((double)eNB->ulsch_turbo_decoding_stats.diff/eNB->ulsch_turbo_decoding_stats.trials), eNB->ulsch_turbo_decoding_stats.trials); - printStatIndent2(&eNB->ulsch_tc_init_stats,"init", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_alpha_stats,"alpha", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_beta_stats,"beta", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_gamma_stats,"gamma", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_ext_stats,"ext", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_intl1_stats,"turbo internal interleaver", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_intl2_stats,"intl2+HardDecode+CRC", eNB->ulsch_tc_init_stats.trials); + printStatIndent3(&eNB->ulsch_tc_init_stats,"init"); + printStatIndent3(&eNB->ulsch_tc_alpha_stats,"alpha"); + printStatIndent3(&eNB->ulsch_tc_beta_stats,"beta"); + printStatIndent3(&eNB->ulsch_tc_gamma_stats,"gamma"); + printStatIndent3(&eNB->ulsch_tc_ext_stats,"ext"); + printStatIndent3(&eNB->ulsch_tc_intl1_stats,"turbo internal interleaver"); + printStatIndent3(&eNB->ulsch_tc_intl2_stats,"intl2+HardDecode+CRC"); } if(abstx) { //ABSTRACTION diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 6bda86d603..509ee6c0ac 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -149,8 +149,6 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #endif -extern PARALLEL_CONF_t get_thread_parallel_conf(void); -extern WORKER_CONF_t get_thread_worker_conf(void); extern uint8_t nfapi_mode; extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); @@ -855,9 +853,9 @@ static void* process_stats_thread(void* param) { while (!oai_exit) { sleep(1); if (opp_enabled == 1) { - if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); - if (eNB->te) - { + if ( eNB->ulsch_decoding_stats.trials>0) + print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); + if (eNB->dlsch_encoding_stats.trials >0) { print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_crc",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_segmentation_stats,"dlsch_segmentation",NULL,NULL); print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); @@ -1319,11 +1317,6 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { #ifndef OCP_FRAMEWORK LOG_I(PHY,"Initializing eNB %d CC_id %d\n",inst,CC_id); #endif - - - eNB->td = ulsch_decoding_data_all; - eNB->te = dlsch_encoding_all; - LOG_I(PHY,"Registering with MAC interface module\n"); AssertFatal((eNB->if_inst = IF_Module_init(inst))!=NULL,"Cannot register interface"); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 03a461454f..74eb37355b 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -219,31 +219,7 @@ int numerology = 0; char *parallel_config = NULL; char *worker_config = NULL; -static THREAD_STRUCT thread_struct; -void set_parallel_conf(char *parallel_conf) -{ - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) -{ - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) -{ - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) -{ - return thread_struct.worker_conf; -} - - - +THREAD_STRUCT thread_struct; /* struct for ethernet specific parameters given in eNB conf file */ eth_params_t *eth_params; diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 3071544133..5c4ca6ed2e 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -226,29 +226,7 @@ char *worker_config = NULL; char* usrp_args=NULL; char* usrp_clksrc=NULL; -static THREAD_STRUCT thread_struct; -void set_parallel_conf(char *parallel_conf) -{ - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) -{ - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) -{ - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) -{ - return thread_struct.worker_conf; -} - +THREAD_STRUCT thread_struct; /* struct for ethernet specific parameters given in eNB conf file */ eth_params_t *eth_params; -- GitLab From 2f11541973ea24b54cae0cbabe6aaf05129620dd Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Thu, 15 Nov 2018 13:21:48 +0100 Subject: [PATCH 24/43] test commit --- targets/RT/USER/lte-enb.c | 181 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 6bda86d603..d194ea42ae 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -724,12 +724,193 @@ void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { } } +<<<<<<< HEAD // check if we have to detect PRACH first if (is_prach_subframe(fp,frame,subframe)>0) { LOG_D(PHY,"Triggering prach br processing, frame %d, subframe %d\n",frame,subframe); if (proc->instance_cnt_prach_br == 0) { LOG_W(PHY,"[eNB] Frame %d Subframe %d, dropping PRACH BR\n", frame,subframe); return; +======= + } + + eNB_thread_asynch_rxtx_status=0; + return(&eNB_thread_asynch_rxtx_status); +} + + + + + +void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { + + eNB_proc_t *proc = &eNB->proc; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + void *rxp[fp->nb_antennas_rx],*txp[fp->nb_antennas_tx]; + unsigned int rxs,txs; + int i; + int tx_sfoffset = (eNB->single_thread_flag == 1) ? 3 : 2; + openair0_timestamp ts,old_ts; + + if (proc->first_rx==0) { + + // Transmit TX buffer based on timestamp from RX + // printf("trx_write -> USRP TS %llu (sf %d)\n", (proc->timestamp_rx+(3*fp->samples_per_tti)),(proc->subframe_rx+2)%10); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance)&0xffffffff ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + // prepare tx buffer pointers + + lte_subframe_t SF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset)%10); + lte_subframe_t prevSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+9)%10); + lte_subframe_t nextSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+1)%10); + int sf_extension = 0; + + if ((SF_type == SF_DL) || + (SF_type == SF_S)) { + + int siglen=fp->samples_per_tti,flags=1; + + if (SF_type == SF_S) { + siglen = (fp->dl_symbols_in_S_subframe+1)*(fp->ofdm_symbol_size+fp->nb_prefix_samples0); + flags=3; // end of burst + } + if ((fp->frame_type == TDD) && + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_DL)) { + flags = 2; // start of burst + sf_extension = eNB->N_TA_offset<<1; + } + if ((fp->frame_type == TDD) && + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_UL)) { + flags = 4; // start of burst and end of burst (only one DL SF between two UL) + sf_extension = eNB->N_TA_offset<<1; + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS,flags); + + for (i=0; inb_antennas_tx; i++) + txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti-sf_extension]; + + txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, + proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance-sf_extension, + txp, + siglen+sf_extension, + fp->nb_antennas_tx, + flags); + clock_gettime( CLOCK_MONOTONIC, &end_rf); + end_rf_ts = proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance; + if (recv_if_count != 0 ) { + recv_if_count = recv_if_count-1; + LOG_D(HW,"[From Timestamp %"PRId64" to Timestamp %"PRId64"] RTT_RF: %"PRId64"; RTT_RF\n", start_rf_prev_ts, end_rf_ts, clock_difftime_ns(start_rf_prev, end_rf)); + LOG_D(HW,"[From Timestamp %"PRId64" to Timestamp %"PRId64"] RTT_RF: %"PRId64"; RTT_RF\n",start_rf_prev2_ts, end_rf_ts, clock_difftime_ns(start_rf_prev2, end_rf)); + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); + + + + if (txs != siglen+sf_extension) { + LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti); + exit_fun( "problem transmitting samples" ); + } + } + } + + for (i=0; inb_antennas_rx; i++) + rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][*subframe*fp->samples_per_tti]; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); + + old_ts = proc->timestamp_rx; + + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &ts, + rxp, + fp->samples_per_tti, + fp->nb_antennas_rx); + start_rf_prev2= start_rf_prev; + start_rf_prev2_ts= start_rf_prev_ts; + start_rf_prev = start_rf_new; + start_rf_prev_ts = start_rf_new_ts; + clock_gettime( CLOCK_MONOTONIC, &start_rf_new); + start_rf_new_ts = ts; + LOG_D(PHY,"rx_rf: first_rx %d received ts %"PRId64" (sptti %d)\n",proc->first_rx,ts,fp->samples_per_tti); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); + + proc->timestamp_rx = ts-eNB->ts_offset; + + if (rxs != fp->samples_per_tti) + LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); + + if (proc->first_rx == 1) { + eNB->ts_offset = proc->timestamp_rx; + proc->timestamp_rx=0; + } + else { + + if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { + LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,eNB->ts_offset); + eNB->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); + proc->timestamp_rx = ts-eNB->ts_offset; + } + } + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; + proc->frame_rx = (proc->frame_rx+proc->frame_offset)&1023; + proc->frame_tx = proc->frame_rx; + if (proc->subframe_rx > 5) proc->frame_tx=(proc->frame_tx+1)&1023; + // synchronize first reception to frame 0 subframe 0 + + proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); + // printf("trx_read <- USRP TS %lu (offset %d sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,eNB->ts_offset,proc->subframe_rx,proc->frame_rx,proc->first_rx); + + if (proc->first_rx == 0) { + if (proc->subframe_rx != *subframe){ + LOG_E(PHY,"rx_rf: Received Timestamp (%"PRId64") doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe); + exit_fun("Exiting"); + } + int f2 = (*frame+proc->frame_offset)&1023; + if (proc->frame_rx != f2) { + LOG_E(PHY,"rx_rf: Received Timestamp (%"PRId64") doesn't correspond to the time we think it is (proc->frame_rx %d frame %d, frame_offset %d, f2 %d)\n",proc->timestamp_rx,proc->frame_rx,*frame,proc->frame_offset,f2); + exit_fun("Exiting"); + } + } else { + proc->first_rx--; + *frame = proc->frame_rx; + *subframe = proc->subframe_rx; + } + + //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",proc->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe); + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); + + if (rxs != fp->samples_per_tti) + exit_fun( "problem receiving samples" ); + + + +} + +void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) { + + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + eNB_proc_t *proc = &eNB->proc; + + recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); + + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; + + if (proc->first_rx == 0) { + if (proc->subframe_rx != *subframe){ + LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe); + exit_fun("Exiting"); +>>>>>>> ae0494b0bc431bf664e300b0b5a10f348d6b6757 } // wake up thread for PRACH RX -- GitLab From 22e44306f884fe9d1c191da3c0b147ca097d8728 Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Thu, 15 Nov 2018 13:28:59 +0100 Subject: [PATCH 25/43] RRC inactivity timer deactivated --- openair2/RRC/LTE/rrc_eNB.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index c20a13bf00..412128b017 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -5375,7 +5375,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( //----------------------------------------------------------------------------- /* * TODO: * add function description -* * add ue_rrc_inactivity_timer set * * format the function correctly */ void @@ -7915,7 +7914,7 @@ rrc_rx_tx( pthread_mutex_unlock(&rrc_release_freelist); if (ue_context_p->ue_context.ue_rrc_inactivity_timer > 0) { - ue_context_p->ue_context.ue_rrc_inactivity_timer++; + // ue_context_p->ue_context.ue_rrc_inactivity_timer++; // (un)comment this line to (de)activate the RRC inactivity timer if (ue_context_p->ue_context.ue_rrc_inactivity_timer >= ue_context_p->ue_context.ue_rrc_inactivity_timer_thres) { LOG_I(RRC, "Removing UE %x instance because of rrc_inactivity_timer timeout\n", -- GitLab From 700437f184332e4198f465f0750e4dd4663fb0be Mon Sep 17 00:00:00 2001 From: Louis Adrien Dufrene Date: Fri, 16 Nov 2018 08:49:28 +0100 Subject: [PATCH 26/43] astyle applied --- common/utils/T/tracer/gui/x.c | 281 +- openair2/COMMON/platform_types.h | 108 +- openair2/ENB_APP/enb_config.c | 60 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 1373 ++--- openair2/LAYER2/MAC/eNB_scheduler_fairRR.c | 4048 +++++++------ openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 1949 +++--- openair2/RRC/LTE/L2_interface.c | 330 +- openair2/RRC/LTE/MESSAGES/asn1_msg.c | 1745 +++--- openair2/RRC/LTE/MESSAGES/asn1_msg.h | 86 +- openair2/RRC/LTE/rrc_defs.h | 256 +- openair2/RRC/LTE/rrc_eNB.c | 6408 +++++++++----------- openair2/RRC/LTE/rrc_eNB_S1AP.c | 1280 ++-- openair3/S1AP/s1ap_eNB.c | 115 +- openair3/S1AP/s1ap_eNB_handlers.c | 238 +- openair3/S1AP/s1ap_eNB_nas_procedures.c | 134 +- targets/RT/USER/lte-enb.c | 1628 +++-- 16 files changed, 9346 insertions(+), 10693 deletions(-) diff --git a/common/utils/T/tracer/gui/x.c b/common/utils/T/tracer/gui/x.c index 7b8c130ea8..3176810ec3 100644 --- a/common/utils/T/tracer/gui/x.c +++ b/common/utils/T/tracer/gui/x.c @@ -7,21 +7,19 @@ #include #include -int x_connection_fd(x_connection *_x) -{ +int x_connection_fd(x_connection *_x) { struct x_connection *x = _x; return ConnectionNumber(x->d); } -static GC create_gc(Display *d, char *color) -{ +static GC create_gc(Display *d, char *color) { GC ret = XCreateGC(d, DefaultRootWindow(d), 0, NULL); XGCValues gcv; XColor rcol, scol; - XCopyGC(d, DefaultGC(d, DefaultScreen(d)), -1L, ret); + if (XAllocNamedColor(d, DefaultColormap(d, DefaultScreen(d)), - color, &scol, &rcol)) { + color, &scol, &rcol)) { gcv.foreground = scol.pixel; XChangeGC(d, ret, GCForeground, &gcv); } else ERR("X: could not allocate color '%s'\n", color); @@ -29,82 +27,81 @@ static GC create_gc(Display *d, char *color) return ret; } -int x_new_color(x_connection *_x, char *color) -{ +int x_new_color(x_connection *_x, char *color) { struct x_connection *x = _x; x->ncolors++; - x->colors = realloc(x->colors, x->ncolors * sizeof(GC)); + if (x->colors == NULL) OOM; - x->colors[x->ncolors-1] = create_gc(x->d, color); + x->colors[x->ncolors-1] = create_gc(x->d, color); x->xft_colors = realloc(x->xft_colors, x->ncolors * sizeof(XftColor)); + if (x->xft_colors == NULL) OOM; + if (XftColorAllocName(x->d, DefaultVisual(x->d, DefaultScreen(x->d)), - DefaultColormap(x->d, DefaultScreen(x->d)), - color, &x->xft_colors[x->ncolors-1]) == False) + DefaultColormap(x->d, DefaultScreen(x->d)), + color, &x->xft_colors[x->ncolors-1]) == False) ERR("could not allocate color '%s'\n", color); return x->ncolors - 1; } -int x_new_font(x_connection *_x, char *font) -{ +int x_new_font(x_connection *_x, char *font) { struct x_connection *x = _x; /* TODO: allocate fonts only once */ x->nfonts++; x->fonts = realloc(x->fonts, x->nfonts * sizeof(XftFont *)); + if (x->fonts == NULL) OOM; + x->fonts[x->nfonts-1] = XftFontOpenName(x->d, DefaultScreen(x->d), font); + if (x->fonts[x->nfonts-1] == NULL) ERR("failed allocating font '%s'\n", font); + return x->nfonts - 1; } -x_connection *x_open(void) -{ +x_connection *x_open(void) { struct x_connection *ret; - ret = calloc(1, sizeof(struct x_connection)); + if (ret == NULL) OOM; ret->d = XOpenDisplay(0); LOGD("XOpenDisplay display %p return x_connection %p\n", ret->d, ret); + if (ret->d == NULL) ERR("error calling XOpenDisplay: no X? you root?\n"); x_new_color(ret, "white"); /* background color */ x_new_color(ret, "black"); /* foreground color */ - x_new_font(ret, "sans-8"); - return ret; } x_window *x_create_window(x_connection *_x, int width, int height, - char *title) -{ + char *title) { struct x_connection *x = _x; struct x_window *ret; - ret = calloc(1, sizeof(struct x_window)); + if (ret == NULL) OOM; ret->w = XCreateSimpleWindow(x->d, DefaultRootWindow(x->d), 0, 0, - width, height, 0, WhitePixel(x->d, DefaultScreen(x->d)), - WhitePixel(x->d, DefaultScreen(x->d))); + width, height, 0, WhitePixel(x->d, DefaultScreen(x->d)), + WhitePixel(x->d, DefaultScreen(x->d))); ret->width = width; ret->height = height; - XStoreName(x->d, ret->w, title); - ret->p = XCreatePixmap(x->d, ret->w, width, height, - DefaultDepth(x->d, DefaultScreen(x->d))); + DefaultDepth(x->d, DefaultScreen(x->d))); XFillRectangle(x->d, ret->p, x->colors[BACKGROUND_COLOR], - 0, 0, width, height); - + 0, 0, width, height); ret->xft = XftDrawCreate(x->d, ret->p, - DefaultVisual(x->d, DefaultScreen(x->d)), - DefaultColormap(x->d, DefaultScreen(x->d))); + DefaultVisual(x->d, DefaultScreen(x->d)), + DefaultColormap(x->d, DefaultScreen(x->d))); + if (ret->xft == NULL) ERR("XftDrawCreate failed\n"); /* enable backing store */ @@ -113,23 +110,19 @@ x_window *x_create_window(x_connection *_x, int width, int height, att.backing_store = Always; XChangeWindowAttributes(x->d, ret->w, CWBackingStore, &att); } - XSelectInput(x->d, ret->w, - KeyPressMask | - ButtonPressMask | - ButtonReleaseMask | - PointerMotionMask | - ExposureMask | - StructureNotifyMask); - + KeyPressMask | + ButtonPressMask | + ButtonReleaseMask | + PointerMotionMask | + ExposureMask | + StructureNotifyMask); XMapWindow(x->d, ret->w); - return ret; } x_image *x_create_image(x_connection *_x, unsigned char *data, - int width, int height) -{ + int width, int height) { struct x_connection *x = _x; struct x_image *ret; XImage *ximage; @@ -137,8 +130,9 @@ x_image *x_create_image(x_connection *_x, unsigned char *data, XVisualInfo template; int nvs; Visual *v; + ret = calloc(1, sizeof(struct x_image)); - ret = calloc(1, sizeof(struct x_image)); if (ret == NULL) OOM; + if (ret == NULL) OOM; template.class = TrueColor; template.depth = 32; @@ -146,68 +140,65 @@ x_image *x_create_image(x_connection *_x, unsigned char *data, template.green_mask = 0x00ff00; template.blue_mask = 0x0000ff; template.bits_per_rgb = 8; - vs = XGetVisualInfo(x->d, VisualDepthMask | VisualClassMask | - VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask | - VisualBitsPerRGBMask, &template, &nvs); + VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask | + VisualBitsPerRGBMask, &template, &nvs); if (vs == NULL) { /* try again with 32 bpp */ template.depth = 32; vs = XGetVisualInfo(x->d, VisualDepthMask | VisualClassMask | - VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask | - VisualBitsPerRGBMask, &template, &nvs); + VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask | + VisualBitsPerRGBMask, &template, &nvs); } if (vs == NULL) ERR("no good visual found\n"); v = vs[0].visual; XFree(vs); - ximage = XCreateImage(x->d, v, 24, ZPixmap, 0, - (char*)data, width, height, 32, 0); + (char *)data, width, height, 32, 0); + if (ximage == NULL) ERR("image creation failed\n"); ret->p = XCreatePixmap(x->d, DefaultRootWindow(x->d), width, height, 24); - XPutImage(x->d, ret->p, DefaultGC(x->d, DefaultScreen(x->d)), - ximage, 0, 0, 0, 0, width, height); - + ximage, 0, 0, 0, 0, width, height); /* TODO: be sure it's fine to set data to NULL */ ximage->data = NULL; XDestroyImage(ximage); - ret->width = width; ret->height = height; - return ret; } -static struct toplevel_window_widget *find_x_window(struct gui *g, Window id) -{ +static struct toplevel_window_widget *find_x_window(struct gui *g, Window id) { struct widget_list *cur; struct toplevel_window_widget *w; struct x_window *xw; cur = g->toplevel; + while (cur) { w = (struct toplevel_window_widget *)cur->item; xw = w->x; + if (xw->w == id) return w; + cur = cur->next; } + return NULL; } -void x_events(gui *_gui) -{ +void x_events(gui *_gui) { struct gui *g = _gui; struct widget_list *cur; struct x_connection *x = g->x; struct toplevel_window_widget *w; - LOGD("x_events START\n"); /* preprocessing (to "compress" events) */ cur = g->toplevel; + while (cur) { struct x_window *xw; w = (struct toplevel_window_widget *)cur->item; @@ -222,58 +213,84 @@ void x_events(gui *_gui) XEvent ev; XNextEvent(x->d, &ev); LOGD("XEV %d\n", ev.type); + switch (ev.type) { - case MapNotify: - case Expose: - if ((w = find_x_window(g, ev.xexpose.window)) != NULL) { - struct x_window *xw = w->x; - xw->redraw = 1; - } - break; - case ConfigureNotify: - if ((w = find_x_window(g, ev.xconfigure.window)) != NULL) { - struct x_window *xw = w->x; - xw->resize = 1; - xw->new_width = ev.xconfigure.width; - xw->new_height = ev.xconfigure.height; - if (xw->new_width < 10) xw->new_width = 10; - if (xw->new_height < 10) xw->new_height = 10; - LOGD("ConfigureNotify %d %d\n", ev.xconfigure.width, ev.xconfigure.height); - } - break; - case ButtonPress: - if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { - int key_modifiers = 0; - if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; - if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; - if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; - w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, - ev.xbutton.button, 0); - } - break; - case ButtonRelease: - if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { - int key_modifiers = 0; - if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; - if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; - if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; - w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, - ev.xbutton.button, 1); - } - break; - default: if (gui_logd) WARN("TODO: X event type %d\n", ev.type); break; + case MapNotify: + case Expose: + if ((w = find_x_window(g, ev.xexpose.window)) != NULL) { + struct x_window *xw = w->x; + xw->redraw = 1; + } + + break; + + case ConfigureNotify: + if ((w = find_x_window(g, ev.xconfigure.window)) != NULL) { + struct x_window *xw = w->x; + xw->resize = 1; + xw->new_width = ev.xconfigure.width; + xw->new_height = ev.xconfigure.height; + + if (xw->new_width < 10) xw->new_width = 10; + + if (xw->new_height < 10) xw->new_height = 10; + + LOGD("ConfigureNotify %d %d\n", ev.xconfigure.width, ev.xconfigure.height); + } + + break; + + case ButtonPress: + if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { + int key_modifiers = 0; + + if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; + + if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; + + if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; + + w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, + ev.xbutton.button, 0); + } + + break; + + case ButtonRelease: + if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { + int key_modifiers = 0; + + if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; + + if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; + + if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; + + w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, + ev.xbutton.button, 1); + } + + break; + + default: + if (gui_logd) WARN("TODO: X event type %d\n", ev.type); + + break; } } /* postprocessing */ LOGD("post processing\n"); cur = g->toplevel; + while (cur) { struct toplevel_window_widget *w = - (struct toplevel_window_widget *)cur->item; + (struct toplevel_window_widget *)cur->item; struct x_window *xw = w->x; + if (xw->resize) { LOGD("resize old %d %d new %d %d\n", xw->width, xw->height, xw->new_width, xw->new_height); + if (xw->width != xw->new_width || xw->height != xw->new_height) { w->common.allocate(g, w, 0, 0, xw->new_width, xw->new_height); xw->width = xw->new_width; @@ -281,46 +298,47 @@ void x_events(gui *_gui) XftDrawDestroy(xw->xft); XFreePixmap(x->d, xw->p); xw->p = XCreatePixmap(x->d, xw->w, xw->width, xw->height, - DefaultDepth(x->d, DefaultScreen(x->d))); + DefaultDepth(x->d, DefaultScreen(x->d))); XFillRectangle(x->d, xw->p, x->colors[BACKGROUND_COLOR], - 0, 0, xw->width, xw->height); + 0, 0, xw->width, xw->height); xw->xft = XftDrawCreate(x->d, xw->p, - DefaultVisual(x->d, DefaultScreen(x->d)), - DefaultColormap(x->d, DefaultScreen(x->d))); + DefaultVisual(x->d, DefaultScreen(x->d)), + DefaultColormap(x->d, DefaultScreen(x->d))); + if (xw->xft == NULL) ERR("XftDrawCreate failed\n"); //xw->repaint = 1; } } + if (xw->repaint) { w->common.paint(g, w); xw->redraw = 1; } + if (xw->redraw) { struct x_connection *x = g->x; LOGD("XCopyArea w h %d %d\n", xw->width, xw->height); XCopyArea(x->d, xw->p, xw->w, x->colors[1], - 0, 0, xw->width, xw->height, 0, 0); + 0, 0, xw->width, xw->height, 0, 0); } + cur = cur->next; } + LOGD("x_events DONE\n"); } -void x_flush(x_connection *_x) -{ +void x_flush(x_connection *_x) { struct x_connection *x = _x; XFlush(x->d); } void x_text_get_dimensions(x_connection *_c, int font, const char *t, - int *width, int *height, int *baseline) -{ + int *width, int *height, int *baseline) { struct x_connection *c = _c; XGlyphInfo ext; - XftTextExtentsUtf8(c->d, c->fonts[font], (FcChar8 *)t, strlen(t), &ext); - *width = ext.width; *height = c->fonts[font]->height; *baseline = c->fonts[font]->ascent; @@ -331,63 +349,57 @@ void x_text_get_dimensions(x_connection *_c, int font, const char *t, /***********************************************************************/ void x_draw_line(x_connection *_c, x_window *_w, int color, - int x1, int y1, int x2, int y2) -{ + int x1, int y1, int x2, int y2) { struct x_connection *c = _c; struct x_window *w = _w; XDrawLine(c->d, w->p, c->colors[color], x1, y1, x2, y2); } void x_draw_rectangle(x_connection *_c, x_window *_w, int color, - int x, int y, int width, int height) -{ + int x, int y, int width, int height) { struct x_connection *c = _c; struct x_window *w = _w; XDrawRectangle(c->d, w->p, c->colors[color], x, y, width, height); } void x_fill_rectangle(x_connection *_c, x_window *_w, int color, - int x, int y, int width, int height) -{ + int x, int y, int width, int height) { struct x_connection *c = _c; struct x_window *w = _w; XFillRectangle(c->d, w->p, c->colors[color], x, y, width, height); } void x_draw_string(x_connection *_c, x_window *_w, int font, int color, - int x, int y, const char *t) -{ + int x, int y, const char *t) { struct x_connection *c = _c; struct x_window *w = _w; int tlen = strlen(t); XftDrawStringUtf8(w->xft, &c->xft_colors[color], c->fonts[font], - x, y, (const unsigned char *)t, tlen); + x, y, (const unsigned char *)t, tlen); } void x_draw_clipped_string(x_connection *_c, x_window *_w, int font, - int color, int x, int y, const char *t, - int clipx, int clipy, int clipwidth, int clipheight) -{ + int color, int x, int y, const char *t, + int clipx, int clipy, int clipwidth, int clipheight) { struct x_window *w = _w; - XRectangle clip = { clipx, clipy, clipwidth, clipheight }; + if (XftDrawSetClipRectangles(w->xft, 0, 0, &clip, 1) == False) abort(); + x_draw_string(_c, _w, font, color, x, y, t); + if (XftDrawSetClip(w->xft, NULL) == False) abort(); } -void x_draw_image(x_connection *_c, x_window *_w, x_image *_img, int x, int y) -{ +void x_draw_image(x_connection *_c, x_window *_w, x_image *_img, int x, int y) { struct x_connection *c = _c; struct x_window *w = _w; struct x_image *img = _img; - XCopyArea(c->d, img->p, w->p, DefaultGC(c->d, DefaultScreen(c->d)), - 0, 0, img->width, img->height, x, y); + 0, 0, img->width, img->height, x, y); } -void x_draw(x_connection *_c, x_window *_w) -{ +void x_draw(x_connection *_c, x_window *_w) { struct x_connection *c = _c; struct x_window *w = _w; LOGD("x_draw XCopyArea w h %d %d display %p window %d pixmap %d\n", w->width, w->height, c->d, (int)w->w, (int)w->p); @@ -397,13 +409,13 @@ void x_draw(x_connection *_c, x_window *_w) /* those two special functions are to plot many points * first call x_add_point many times then x_plot_points once */ -void x_add_point(x_connection *_c, int x, int y) -{ +void x_add_point(x_connection *_c, int x, int y) { struct x_connection *c = _c; if (c->pts_size == c->pts_maxsize) { c->pts_maxsize += 65536; c->pts = realloc(c->pts, c->pts_maxsize * sizeof(XPoint)); + if (c->pts == NULL) OOM; } @@ -412,12 +424,11 @@ void x_add_point(x_connection *_c, int x, int y) c->pts_size++; } -void x_plot_points(x_connection *_c, x_window *_w, int color) -{ +void x_plot_points(x_connection *_c, x_window *_w, int color) { struct x_connection *c = _c; LOGD("x_plot_points %d points\n", c->pts_size); struct x_window *w = _w; XDrawPoints(c->d, w->p, c->colors[color], c->pts, c->pts_size, - CoordModeOrigin); + CoordModeOrigin); c->pts_size = 0; } diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 0578e92cbc..d24be0575e 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -31,7 +31,7 @@ # define __PLATFORM_TYPES_H__ #if !defined(NAS_NETLINK) -#include + #include #endif //----------------------------------------------------------------------------- @@ -42,19 +42,19 @@ * let's protect potential redefinition */ #ifndef _BOOLEAN_T_DEFINED_ -#define _BOOLEAN_T_DEFINED_ + #define _BOOLEAN_T_DEFINED_ -typedef signed char boolean_t; + typedef signed char boolean_t; -#if !defined(TRUE) -#define TRUE (boolean_t)0x01 -#endif + #if !defined(TRUE) + #define TRUE (boolean_t)0x01 + #endif -#if !defined(FALSE) -#define FALSE (boolean_t)0x00 -#endif + #if !defined(FALSE) + #define FALSE (boolean_t)0x00 + #endif -#define BOOL_NOT(b) (b^TRUE) + #define BOOL_NOT(b) (b^TRUE) #endif /* _BOOLEAN_T_DEFINED_ */ @@ -102,19 +102,19 @@ typedef enum rb_type_e { } rb_type_t; typedef enum { - CR_ROUND = 0, - CR_SRB12 = 1, - CR_HOL = 2, - CR_LC = 3, - CR_CQI = 4, - CR_LCP = 5, - CR_NUM = 6 + CR_ROUND = 0, + CR_SRB12 = 1, + CR_HOL = 2, + CR_LC = 3, + CR_CQI = 4, + CR_LCP = 5, + CR_NUM = 6 } sorting_criterion_t; typedef enum { - POL_FAIR = 0, - POL_GREEDY = 1, - POL_NUM = 2 + POL_FAIR = 0, + POL_GREEDY = 1, + POL_NUM = 2 } accounting_policy_t; //----------------------------------------------------------------------------- // PHY TYPES @@ -188,19 +188,19 @@ typedef uint32_t m_tmsi_t; //Random UE identity length = 40 bits #if ! defined(NOT_A_RANDOM_UE_IDENTITY) -#define NOT_A_RANDOM_UE_IDENTITY (uint64_t)0xFFFFFFFF + #define NOT_A_RANDOM_UE_IDENTITY (uint64_t)0xFFFFFFFF #endif #if ! defined(NOT_A_RNTI) -#define NOT_A_RNTI (rnti_t)0 + #define NOT_A_RNTI (rnti_t)0 #endif #if ! defined(M_RNTI) -#define M_RNTI (rnti_t)0xFFFD + #define M_RNTI (rnti_t)0xFFFD #endif #if ! defined(P_RNTI) -#define P_RNTI (rnti_t)0xFFFE + #define P_RNTI (rnti_t)0xFFFE #endif #if ! defined(SI_RNTI) -#define SI_RNTI (rnti_t)0xFFFF + #define SI_RNTI (rnti_t)0xFFFF #endif typedef enum config_action_e { CONFIG_ACTION_NULL = 0, @@ -225,7 +225,7 @@ typedef uint8_t ebi_t; // eps bearer id //----------------------------------------------------------------------------- // may be ITTI not enabled, but type instance is useful also for OTG, #if !defined(instance_t) -typedef uint16_t instance_t; + typedef uint16_t instance_t; #endif typedef struct protocol_ctxt_s { module_id_t module_id; /*!< \brief Virtualized module identifier */ @@ -247,51 +247,51 @@ typedef struct protocol_ctxt_s { #define MODULE_ID_TO_INSTANCE(mODULE_iD, iNSTANCE, eNB_fLAG) \ - if(eNB_fLAG == ENB_FLAG_YES) \ - iNSTANCE = ENB_MODULE_ID_TO_INSTANCE(mODULE_iD); \ - else \ - iNSTANCE = UE_MODULE_ID_TO_INSTANCE(mODULE_iD) + if(eNB_fLAG == ENB_FLAG_YES) \ + iNSTANCE = ENB_MODULE_ID_TO_INSTANCE(mODULE_iD); \ + else \ + iNSTANCE = UE_MODULE_ID_TO_INSTANCE(mODULE_iD) #define INSTANCE_TO_MODULE_ID(iNSTANCE, mODULE_iD, eNB_fLAG) \ - if(eNB_fLAG == ENB_FLAG_YES) \ - mODULE_iD = ENB_INSTANCE_TO_MODULE_ID(iNSTANCE); \ - else \ - mODULE_iD = UE_INSTANCE_TO_MODULE_ID(iNSTANCE) + if(eNB_fLAG == ENB_FLAG_YES) \ + mODULE_iD = ENB_INSTANCE_TO_MODULE_ID(iNSTANCE); \ + else \ + mODULE_iD = UE_INSTANCE_TO_MODULE_ID(iNSTANCE) #define PROTOCOL_CTXT_COMPUTE_MODULE_ID(CtXt_h) \ - INSTANCE_TO_MODULE_ID( (CtXt_h)->instance , (CtXt_h)->module_id , (CtXt_h)->enb_flag ) + INSTANCE_TO_MODULE_ID( (CtXt_h)->instance , (CtXt_h)->module_id , (CtXt_h)->enb_flag ) #define PROTOCOL_CTXT_COMPUTE_INSTANCE(CtXt_h) \ - MODULE_ID_TO_INSTANCE( (CtXt_h)->module_id , (CtXt_h)->instance , (CtXt_h)->enb_flag ) + MODULE_ID_TO_INSTANCE( (CtXt_h)->module_id , (CtXt_h)->instance , (CtXt_h)->enb_flag ) #define PROTOCOL_CTXT_SET_BY_MODULE_ID(Ctxt_Pp, mODULE_iD, eNB_fLAG, rNTI, fRAME, sUBfRAME, eNB_iNDEX) \ - (Ctxt_Pp)->module_id = mODULE_iD; \ - (Ctxt_Pp)->enb_flag = eNB_fLAG; \ - (Ctxt_Pp)->rnti = rNTI; \ - (Ctxt_Pp)->frame = fRAME; \ - (Ctxt_Pp)->subframe = sUBfRAME; \ - (Ctxt_Pp)->eNB_index = eNB_iNDEX; \ - PROTOCOL_CTXT_COMPUTE_INSTANCE(Ctxt_Pp) + (Ctxt_Pp)->module_id = mODULE_iD; \ + (Ctxt_Pp)->enb_flag = eNB_fLAG; \ + (Ctxt_Pp)->rnti = rNTI; \ + (Ctxt_Pp)->frame = fRAME; \ + (Ctxt_Pp)->subframe = sUBfRAME; \ + (Ctxt_Pp)->eNB_index = eNB_iNDEX; \ + PROTOCOL_CTXT_COMPUTE_INSTANCE(Ctxt_Pp) #define PROTOCOL_CTXT_SET_BY_INSTANCE(Ctxt_Pp, iNSTANCE, eNB_fLAG, rNTI, fRAME, sUBfRAME) \ - (Ctxt_Pp)->instance = iNSTANCE; \ - (Ctxt_Pp)->enb_flag = eNB_fLAG; \ - (Ctxt_Pp)->rnti = rNTI; \ - (Ctxt_Pp)->frame = fRAME; \ - (Ctxt_Pp)->subframe = sUBfRAME; \ - PROTOCOL_CTXT_COMPUTE_MODULE_ID(Ctxt_Pp) + (Ctxt_Pp)->instance = iNSTANCE; \ + (Ctxt_Pp)->enb_flag = eNB_fLAG; \ + (Ctxt_Pp)->rnti = rNTI; \ + (Ctxt_Pp)->frame = fRAME; \ + (Ctxt_Pp)->subframe = sUBfRAME; \ + PROTOCOL_CTXT_COMPUTE_MODULE_ID(Ctxt_Pp) #define PROTOCOL_CTXT_FMT "[FRAME %05u][%s][MOD %02u][RNTI %" PRIx16 "]" #define PROTOCOL_CTXT_ARGS(CTXT_Pp) \ - (CTXT_Pp)->frame, \ - ((CTXT_Pp)->enb_flag == ENB_FLAG_YES) ? "eNB":" UE", \ - (CTXT_Pp)->module_id, \ - (CTXT_Pp)->rnti + (CTXT_Pp)->frame, \ + ((CTXT_Pp)->enb_flag == ENB_FLAG_YES) ? "eNB":" UE", \ + (CTXT_Pp)->module_id, \ + (CTXT_Pp)->rnti #define CHECK_CTXT_ARGS(CTXT_Pp) #define exit_fun(msg) exit_function(__FILE__,__FUNCTION__,__LINE__,msg) -void exit_function(const char* file, const char* function, const int line, const char* s); +void exit_function(const char *file, const char *function, const int line, const char *s); #endif diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index d9dedc8e17..3eaa2ad7ad 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -36,13 +36,13 @@ #include "UTIL/OTG/otg.h" #include "UTIL/OTG/otg_externs.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" -#if defined(ENABLE_USE_MME) -#include "s1ap_eNB.h" -#include "sctp_eNB_task.h" -#else -#define EPC_MODE_ENABLED 0 -#endif + #include "intertask_interface.h" + #if defined(ENABLE_USE_MME) + #include "s1ap_eNB.h" + #include "sctp_eNB_task.h" + #else + #define EPC_MODE_ENABLED 0 + #endif #endif #include "sctp_default_values.h" #include "LTE_SystemInformationBlockType2.h" @@ -2043,12 +2043,12 @@ int RCconfig_gtpu(void ) { //----------------------------------------------------------------------------- /* -* Configure the s1ap_register_enb_req in itti message for future +* Configure the s1ap_register_enb_req in itti message for future * communications between eNB(s) and MME. */ int RCconfig_S1( - MessageDef *msg_p, - uint32_t i) + MessageDef *msg_p, + uint32_t i) //----------------------------------------------------------------------------- { int enb_id = 0; @@ -2210,17 +2210,17 @@ int RCconfig_S1( if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) { paramdef_t PLMNParams[] = PLMNPARAMS_DESC; paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0}; - paramdef_t CCsParams[] = CCPARAMS_DESC; - /* map parameter checking array instances to parameter definition array instances */ checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK; + for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) { CCsParams[I].chkPptr = &(config_check_CCparams[I]); } - + /* map parameter checking array instances to parameter definition array instances */ checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK; + for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) { PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); } @@ -2229,10 +2229,8 @@ int RCconfig_S1( paramlist_def_t S1ParamList = {ENB_CONFIG_STRING_MME_IP_ADDRESS, NULL, 0}; paramdef_t SCTPParams[] = SCTPPARAMS_DESC; paramdef_t NETParams[] = NETPARAMS_DESC; - char aprefix[MAX_OPTNAME_SIZE*2 + 8]; sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k); - S1AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id; if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) { @@ -2242,14 +2240,13 @@ int RCconfig_S1( } else { AssertFatal(0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", - RC.config_file_name, - i, + RC.config_file_name, + i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); } S1AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); S1AP_REGISTER_ENB_REQ(msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; - AssertFatal(!ENBParamList.paramarray[k][ENB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr && !ENBParamList.paramarray[k][ENB_MOBILE_NETWORK_CODE_IDX_OLD].strptr, "It seems that you use an old configuration file. Please change the existing\n" @@ -2259,10 +2256,9 @@ int RCconfig_S1( "to\n" " tracking_area_code = 1; // no string!!\n" " plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n"); - config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); - if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6){ + if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) { AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n", PLMNParamList.numelt); } @@ -2273,7 +2269,6 @@ int RCconfig_S1( S1AP_REGISTER_ENB_REQ(msg_p).mcc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; S1AP_REGISTER_ENB_REQ(msg_p).mnc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_NETWORK_CODE_IDX].uptr; S1AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length[l] = *PLMNParamList.paramarray[l][ENB_MNC_DIGIT_LENGTH].u8ptr; - AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length[l] == 3 || S1AP_REGISTER_ENB_REQ(msg_p).mnc[l] < 100, "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n", @@ -2289,12 +2284,13 @@ int RCconfig_S1( */ sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, 0); config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix); + switch (pcch_defaultPagingCycle) { case 32: { S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; break; } - + case 64: { S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 1; break; @@ -2312,32 +2308,26 @@ int RCconfig_S1( default: { LOG_E(S1AP, "Default I-DRX value in conf file is invalid (%i). Should be 32, 64, 128 or 256. \ - Default DRX set to 32 in MME configuration\n", - pcch_defaultPagingCycle); - + Default DRX set to 32 in MME configuration\n", + pcch_defaultPagingCycle); S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; } } /* MME connection params */ sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k); - config_getlist(&S1ParamList, S1Params, sizeof(S1Params)/sizeof(paramdef_t), aprefix); - S1AP_REGISTER_ENB_REQ (msg_p).nb_mme = 0; for (int l = 0; l < S1ParamList.numelt; l++) { S1AP_REGISTER_ENB_REQ (msg_p).nb_mme += 1; - strcpy(S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4_address,*(S1ParamList.paramarray[l][ENB_MME_IPV4_ADDRESS_IDX].strptr)); strcpy(S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6_address,*(S1ParamList.paramarray[l][ENB_MME_IPV6_ADDRESS_IDX].strptr)); if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) { S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4 = 1; - } else if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) { S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6 = 1; - } else if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) { S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4 = 1; S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6 = 1; @@ -2358,7 +2348,6 @@ int RCconfig_S1( for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l]; ++el) { /* UINTARRAY gets mapped to int, see config_libconfig.c:223 */ S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] = S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].iptr[el]; - AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] >= 0 && S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn, "index for MME's MCC/MNC (%d) is an invalid index for the registered PLMN IDs (%d)\n", @@ -2370,7 +2359,7 @@ int RCconfig_S1( if (S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] == 0) { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; - for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; ++el){ + for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; ++el) { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] = el; } } @@ -2382,18 +2371,14 @@ int RCconfig_S1( if (EPC_MODE_ENABLED) { sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG); - config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); - S1AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); S1AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); } sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); - // NETWORK_INTERFACES config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); - cidr = *(NETParams[ENB_IPV4_ADDRESS_FOR_S1_MME_IDX].strptr); address = strtok(cidr, "/"); S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv6 = 0; @@ -2583,10 +2568,8 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100, "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n", X2AP_REGISTER_ENB_REQ(msg_p).mnc); - /* CC params */ config_getlist(&CCsParamList, NULL, 0, aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt; if (CCsParamList.numelt > 0) { @@ -2633,7 +2616,6 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS, "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n", X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS); - X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0; for (l = 0; l < X2ParamList.numelt; l++) { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index a79b273a81..4073c54846 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -47,12 +47,12 @@ //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" -#include "SIMULATION/TOOLS/sim.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #include "assertions.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" + #include "intertask_interface.h" #endif #include @@ -74,15 +74,12 @@ add_ue_dlsch_info(module_id_t module_idP, //------------------------------------------------------------------------------ { //LOG_D(MAC, "%s(module_idP:%d, CC_id:%d, UE_id:%d, subframeP:%d, status:%d) serving_num:%d rnti:%x\n", __FUNCTION__, module_idP, CC_id, UE_id, subframeP, status, eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num, UE_RNTI(module_idP,UE_id)); - eNB_dlsch_info[module_idP][CC_id][UE_id].rnti = - UE_RNTI(module_idP, UE_id); + UE_RNTI(module_idP, UE_id); // eNB_dlsch_info[module_idP][CC_id][ue_mod_idP].weight = weight; eNB_dlsch_info[module_idP][CC_id][UE_id].subframe = subframeP; eNB_dlsch_info[module_idP][CC_id][UE_id].status = status; - eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num++; - } //------------------------------------------------------------------------------ @@ -91,7 +88,6 @@ schedule_next_dlue(module_id_t module_idP, int CC_id, sub_frame_t subframeP) //------------------------------------------------------------------------------ { - int next_ue; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; @@ -111,7 +107,6 @@ schedule_next_dlue(module_id_t module_idP, int CC_id, } return (-1); //next_ue; - } //------------------------------------------------------------------------------ @@ -127,11 +122,9 @@ generate_dlsch_header(unsigned char *mac_header, unsigned short post_padding) //------------------------------------------------------------------------------ { - SCH_SUBHEADER_FIXED *mac_header_ptr = (SCH_SUBHEADER_FIXED *) mac_header; uint8_t first_element = 0, last_size = 0, i; uint8_t mac_header_control_elements[16], *ce_ptr; - ce_ptr = &mac_header_control_elements[0]; // compute header components @@ -194,10 +187,10 @@ generate_dlsch_header(unsigned char *mac_header, if (first_element > 0) { mac_header_ptr->E = 1; /* - printf("[eNB][MAC] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + printf("[eNB][MAC] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); */ mac_header_ptr++; } else { @@ -208,16 +201,15 @@ generate_dlsch_header(unsigned char *mac_header, mac_header_ptr->E = 0; mac_header_ptr->LCID = UE_CONT_RES; last_size = 1; - LOG_T(MAC, "[eNB ][RAPROC] Generate contention resolution msg: %x.%x.%x.%x.%x.%x\n", ue_cont_res_id[0], ue_cont_res_id[1], ue_cont_res_id[2], ue_cont_res_id[3], ue_cont_res_id[4], ue_cont_res_id[5]); - memcpy(ce_ptr, ue_cont_res_id, 6); ce_ptr += 6; // msg("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); } + //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); for (i = 0; i < num_sdus; i++) { @@ -227,9 +219,9 @@ generate_dlsch_header(unsigned char *mac_header, if (first_element > 0) { mac_header_ptr->E = 1; /*msg("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); */ mac_header_ptr += last_size; //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); @@ -255,10 +247,10 @@ generate_dlsch_header(unsigned char *mac_header, last_size = 3; #ifdef DEBUG_HEADER_PARSING LOG_D(MAC, - "[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n", - sdu_lengths[i], - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB, - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB); + "[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n", + sdu_lengths[i], + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB, + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB); #endif } } @@ -300,10 +292,10 @@ generate_dlsch_header(unsigned char *mac_header, memcpy((void *) mac_header_ptr, mac_header_control_elements, ce_ptr - mac_header_control_elements); mac_header_ptr += - (unsigned char) (ce_ptr - mac_header_control_elements); + (unsigned char) (ce_ptr - mac_header_control_elements); } - //msg("After CEs %d\n",(uint8_t*)mac_header_ptr - mac_header); + //msg("After CEs %d\n",(uint8_t*)mac_header_ptr - mac_header); return ((unsigned char *) mac_header_ptr - mac_header); } @@ -313,11 +305,11 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, int subframeP) //------------------------------------------------------------------------------ { - eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_list_t *UE_list = &eNB->UE_list; unsigned char DAI; COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; + if (cc->tdd_Config != NULL) { //TDD DAI = (UE_list->UE_template[CC_idP][UE_idP].DAI - 1) & 3; LOG_D(MAC, @@ -332,24 +324,25 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, case 1: switch (subframeP) { - case 0: - case 1: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[7] = DAI; - break; + case 0: + case 1: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[7] = DAI; + break; - case 4: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[8] = DAI; - break; + case 4: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[8] = DAI; + break; - case 5: - case 6: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; - break; + case 5: + case 6: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; + break; - case 9: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI; - break; + case 9: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI; + break; } + break; case 2: @@ -410,7 +403,6 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, //------------------------------------------------------------------------------ void schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) { - int i = 0; slice_info_t *sli = &RC.mac[module_idP]->slice_info; memset(sli->rballoc_sub, 0, sizeof(sli->rballoc_sub)); @@ -419,7 +411,6 @@ schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, in // Run each enabled slice-specific schedulers one by one sli->dl[i].sched_cb(module_idP, i, frameP, subframeP, mbsfn_flag/*, dl_info*/); } - } // changes to pre-processor for eMTC @@ -445,7 +436,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, int harq_pid = 0; eNB_UE_STATS *eNB_UE_stats = NULL; int sdu_length_total = 0; - eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = eNB->common_channels; UE_list_t *UE_list = &eNB->UE_list; @@ -465,65 +455,79 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, int ta_update; int header_length_last; int header_length_total; - rrc_eNB_ue_context_t *ue_contextP = NULL; - start_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); // for TDD: check that we have to act here, otherwise return if (cc[0].tdd_Config) { tdd_sfa = cc[0].tdd_Config->subframeAssignment; + switch (subframeP) { case 0: // always continue break; + case 1: return; break; + case 2: return; break; + case 3: if ((tdd_sfa != 2) && (tdd_sfa != 5)) return; + break; + case 4: if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) && (tdd_sfa != 5)) return; + break; + case 5: break; + case 6: case 7: if ((tdd_sfa != 3) && (tdd_sfa != 4) && (tdd_sfa != 5)) return; + break; + case 8: if ((tdd_sfa != 2) && (tdd_sfa != 3) && (tdd_sfa != 4) && (tdd_sfa != 5)) return; + break; + case 9: if (tdd_sfa == 0) return; + break; } } + //weight = get_ue_weight(module_idP,UE_id); aggregation = 2; + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id); // get number of PRBs less those used by common channels total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; + for (i = 0; i < N_RB_DL[CC_id]; i++) if (cc[CC_id].vrb_map[i] != 0) total_nb_available_rb[CC_id]--; N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); - // store the global enb stats: eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id]; @@ -535,7 +539,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, // CALLING Pre_Processor for downlink scheduling // (Returns estimation of RBs required by each UE and the allocation on sub-band) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_IN); - start_meas(&eNB->schedule_dlsch_preprocessor); dlsch_scheduler_pre_processor(module_idP, slice_idxP, @@ -544,15 +547,14 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, mbsfn_flag, eNB->slice_info.rballoc_sub); stop_meas(&eNB->schedule_dlsch_preprocessor); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_OUT); //RC.mac[module_idP]->slice_info.slice_counter--; // Do the multiplexing and actual allocation only when all slices have been pre-processed. //if (RC.mac[module_idP]->slice_info.slice_counter > 0) { - //stop_meas(&eNB->schedule_dlsch); - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT); - //return; + //stop_meas(&eNB->schedule_dlsch); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT); + //return; //} if (RC.mac[module_idP]->slice_info.interslice_share_active) { @@ -564,7 +566,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n", CC_id); - dl_req = &eNB->DL_req[CC_id].dl_config_request_body; if (mbsfn_flag[CC_id] > 0) @@ -604,11 +605,13 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, ue_sched_ctl->dl_cqi[CC_id], format1); break; + case 3: aggregation = get_aggregation(get_bw_index(module_idP, CC_id), ue_sched_ctl->dl_cqi[CC_id], format2A); break; + default: LOG_W(MAC, "Unsupported transmission mode %d\n", get_tmode(module_idP, CC_id, UE_id)); aggregation = 2; @@ -616,13 +619,13 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } /* if (continue_flag != 1 */ - if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated - CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, - aggregation, rnti)) { - LOG_D(MAC, - "[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", - module_idP, frameP, UE_id, CC_id); - continue_flag = 1; //to next user (there might be rbs availiable for other UEs in TM5 + if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated + CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, + aggregation, rnti)) { + LOG_D(MAC, + "[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", + module_idP, frameP, UE_id, CC_id); + continue_flag = 1; //to next user (there might be rbs availiable for other UEs in TM5 } // If TDD @@ -642,10 +645,8 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = mac_eNB_get_rrc_status(module_idP, rnti); UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; @@ -689,21 +690,20 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, /* process retransmission */ if (round != 8) { - // get freq_allocation nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; TBS = get_TBS_DL(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid], nb_rb); - if (nb_rb <= nb_available_rb) { - if (cc[CC_id].tdd_Config != NULL) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP, CC_id, rnti, - UE_list->UE_template[CC_id][UE_id].DAI, subframeP); - LOG_D(MAC, - "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", - CC_id, subframeP, UE_id, - UE_list->UE_template[CC_id][UE_id].DAI); - } + if (nb_rb <= nb_available_rb) { + if (cc[CC_id].tdd_Config != NULL) { + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(module_idP, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id].DAI, subframeP); + LOG_D(MAC, + "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframeP, UE_id, + UE_list->UE_template[CC_id][UE_id].DAI); + } if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { for (j = 0; j < N_RBG[CC_id]; ++j) { // for indicating the rballoc for each sub-band @@ -717,6 +717,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { if (UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]) printf("WARN: rballoc_subband not free for retrans?\n"); + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; if ((j == N_RBG[CC_id] - 1) && ((N_RB_DL[CC_id] == 25) || (N_RB_DL[CC_id] == 50))) { @@ -746,7 +747,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, case 7: default: LOG_D(MAC, "retransmission DL_REQ: rnti:%x\n", rnti); - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; @@ -754,13 +754,12 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = - get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); + get_aggregation(get_bw_index(module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI: see Table 4-10 from SCF082 - nFAPI specifications dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // Don't adjust power when retransmitting dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; @@ -770,7 +769,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, // TDD if (cc[CC_id].tdd_Config != NULL) { dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = - (UE_list->UE_template[CC_id][UE_id].DAI - 1) & 3; + (UE_list->UE_template[CC_id][UE_id].DAI - 1) & 3; LOG_D(MAC, "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", module_idP, CC_id, harq_pid, round, @@ -781,17 +780,15 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", module_idP, CC_id, harq_pid, round, UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]); + } - } - if (!CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, rnti)) { - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; - eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - + if (!CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, rnti)) { + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1, /* retransmission, no pdu_index */ rnti, 0, // type 0 allocation from 7.1.6 in 36.213 @@ -804,7 +801,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme 1, // number of layers 1, // number of subbands - // uint8_t codebook_index, + // uint8_t codebook_index, 4, // UE category capacity UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 @@ -813,12 +810,10 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode 0, //number of PRBs treated as one subband, not used here 0 // number of beamforming vectors, not used here - ); - + ); LOG_D(MAC, "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", eNB->pdu_index[CC_id], round); - program_dlsch_acknak(module_idP, CC_id, UE_id, frameP, subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); // No TX request for retransmission (check if null request for FAPI) @@ -830,32 +825,32 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } add_ue_dlsch_info(module_idP, CC_id, UE_id, subframeP, S_DL_SCHEDULED); + //eNB_UE_stats->dlsch_trials[round]++; + UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = eNB_UE_stats->dlsch_mcs1; + } 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", + module_idP, frameP, CC_id, UE_id); + } + } else { /* This is a potentially new SDU opportunity */ + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); - //eNB_UE_stats->dlsch_trials[round]++; - UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx += nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = eNB_UE_stats->dlsch_mcs1; - } 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", - module_idP, frameP, CC_id, UE_id); - } - } else { /* This is a potentially new SDU opportunity */ - rlc_status.bytes_in_buffer = 0; - - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); - - // add the length for all the control elements (timing adv, drx, etc) : header + payload + // add the length for all the control elements (timing adv, drx, etc) : header + payload if (ue_sched_ctl->ta_timer == 0) { ta_update = ue_sched_ctl->ta_update; + /* if we send TA then set timer to not send it for a while */ if (ta_update != 31) ue_sched_ctl->ta_timer = 20; + /* reset ta_update */ ue_sched_ctl->ta_update = 31; } else { @@ -864,44 +859,43 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, ta_len = (ta_update != 31) ? 2 : 0; - // RLC data on DCCH - if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { - rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, + // RLC data on DCCH + if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS - ta_len - header_length_total - sdu_length_total - 3 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - + ); sdu_lengths[0] = 0; - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, subframeP, CC_id, - TBS - ta_len - header_length_total - sdu_length_total - 3); - - sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, subframeP, CC_id, + TBS - ta_len - header_length_total - sdu_length_total - 3); + sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used - (char *)&dlsch_buffer[0] + (char *)&dlsch_buffer[0] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - + ); pthread_mutex_lock(&rrc_release_freelist); - if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)){ + + if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)) { uint16_t release_total = 0; - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ + + for(uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0) { release_total++; - }else{ + } else { continue; } - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1){ - if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1) { + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]) { rrc_release_info.RRC_release_ctrl[release_num].flag = 3; LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 1->3\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); break; @@ -909,10 +903,11 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } } } - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2){ - if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2) { + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]) { rrc_release_info.RRC_release_ctrl[release_num].flag = 4; LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 2->4\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); break; @@ -920,17 +915,19 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } } } + if(release_total >= rrc_release_info.num_UEs) break; } } - pthread_mutex_unlock(&rrc_release_freelist); + pthread_mutex_unlock(&rrc_release_freelist); RA_t *ra = &eNB->common_channels[CC_id].ra[0]; + for (uint8_t ra_ii = 0; ra_ii < NB_RA_PROC_MAX; ra_ii++) { - if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]){ + if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]) { ra[ra_ii].crnti_harq_pid = harq_pid; ra[ra_ii].state = MSGCRNTI_ACK; break; @@ -943,26 +940,21 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0])); - - LOG_D(MAC, "[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n", - module_idP, CC_id, sdu_lengths[0]); - - sdu_length_total = sdu_lengths[0]; - sdu_lcids[0] = DCCH; + LOG_D(MAC, "[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n", + module_idP, CC_id, sdu_lengths[0]); + sdu_length_total = sdu_lengths[0]; + sdu_lcids[0] = DCCH; UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[0] = DCCH; UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[DCCH] = sdu_lengths[0]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH] += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] += sdu_lengths[0]; - + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH] += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] += sdu_lengths[0]; header_length_last = 1 + 1 + (sdu_lengths[0] >= 128); header_length_total += header_length_last; - - num_sdus = 1; - + num_sdus = 1; #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC, - "[eNB %d][DCCH] CC_id %d Got %d bytes :", - module_idP, CC_id, sdu_lengths[0]); + "[eNB %d][DCCH] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[0]); for (j = 0; j < sdu_lengths[0]; ++j) { LOG_T(MAC, "%x ", dlsch_buffer[j]); @@ -970,55 +962,48 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, LOG_T(MAC, "\n"); #endif - } - } + } + } - // RLC data on DCCH1 - if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { - rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, + // RLC data on DCCH1 + if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS - ta_len - header_length_total - sdu_length_total - 3 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif ); - - // DCCH SDU - sdu_lengths[num_sdus] = 0; - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, CC_id, - TBS - ta_len - header_length_total - sdu_length_total - 3); - - sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, - TBS, //not used - (char *)&dlsch_buffer[sdu_length_total] + // DCCH SDU + sdu_lengths[num_sdus] = 0; + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, CC_id, + TBS - ta_len - header_length_total - sdu_length_total - 3); + sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - + ); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus])); - - sdu_lcids[num_sdus] = DCCH1; - sdu_length_total += sdu_lengths[num_sdus]; + sdu_lcids[num_sdus] = DCCH1; + sdu_length_total += sdu_lengths[num_sdus]; UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = DCCH1; UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[DCCH1] = sdu_lengths[num_sdus]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus]; - + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus]; header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); header_length_total += header_length_last; - - num_sdus++; - + num_sdus++; #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC, - "[eNB %d][DCCH1] CC_id %d Got %d bytes :", - module_idP, CC_id, sdu_lengths[num_sdus]); + "[eNB %d][DCCH1] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[num_sdus]); for (j = 0; j < sdu_lengths[num_sdus]; ++j) { LOG_T(MAC, "%x ", dlsch_buffer[j]); @@ -1026,97 +1011,85 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, LOG_T(MAC, "\n"); #endif + } + } - } - } - - // TODO: lcid has to be sorted before the actual allocation (similar struct as ue_list). - for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { - // TODO: check if the lcid is active - - LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", - module_idP, - frameP, - lcid, - TBS, - TBS - ta_len - header_length_total - sdu_length_total - 3); - - if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { - rlc_status = mac_rlc_status_ind(module_idP, + // TODO: lcid has to be sorted before the actual allocation (similar struct as ue_list). + for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { + // TODO: check if the lcid is active + LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, + frameP, + lcid, + TBS, + TBS - ta_len - header_length_total - sdu_length_total - 3); + + if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_length_total - sdu_length_total - 3 +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + , 0, 0 +#endif + ); + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, + frameP, + TBS - ta_len - header_length_total - sdu_length_total - 3, + lcid, + header_length_total); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, - subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, - TBS - ta_len - header_length_total - sdu_length_total - 3 + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , 0, 0 + , 0, 0 #endif - ); - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", - module_idP, - frameP, - TBS - ta_len - header_length_total - sdu_length_total - 3, - lcid, - header_length_total); - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS, //not used - (char *)&dlsch_buffer[sdu_length_total] -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , 0, 0 -#endif - ); - - T(T_ENB_MAC_UE_DL_SDU, - T_INT(module_idP), - T_INT(CC_id), - T_INT(rnti), - T_INT(frameP), - T_INT(subframeP), - T_INT(harq_pid), - T_INT(lcid), - T_INT(sdu_lengths[num_sdus])); - - LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_idP, - sdu_lengths[num_sdus], - lcid); - - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid]++; - UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = lcid; - UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[lcid] = sdu_lengths[num_sdus]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; - - header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); - header_length_total += header_length_last; - - num_sdus++; - - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - - // reset RRC inactivity timer after uplane activity - ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti); - ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; - - } // end if (rlc_status.bytes_in_buffer > 0) - } else { // no TBS left - break; // break for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) - } - } + ); + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(lcid), + T_INT(sdu_lengths[num_sdus])); + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, + sdu_lengths[num_sdus], + lcid); + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid]++; + UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = lcid; + UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[lcid] = sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; + header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); + header_length_total += header_length_last; + num_sdus++; + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + // reset RRC inactivity timer after uplane activity + ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti); + ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; + } // end if (rlc_status.bytes_in_buffer > 0) + } else { // no TBS left + break; // break for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) + } + } /* last header does not have length field */ if (header_length_total) { @@ -1124,13 +1097,11 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, header_length_total++; } - // there is at least one SDU or TA command - // if (num_sdus > 0 ){ - if (ta_len + sdu_length_total + header_length_total > 0) { - - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - + // there is at least one SDU or TA command + // if (num_sdus > 0 ){ + if (ta_len + sdu_length_total + header_length_total > 0) { + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 mcs = eNB_UE_stats->dlsch_mcs1; if (mcs == 0) { @@ -1138,17 +1109,18 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } else { nb_rb = min_rb_unit[CC_id]; } + TBS = get_TBS_DL(mcs, nb_rb); - while (TBS < sdu_length_total + header_length_total + ta_len) { - nb_rb += min_rb_unit[CC_id]; // + while (TBS < sdu_length_total + header_length_total + ta_len) { + nb_rb += min_rb_unit[CC_id]; // - if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); - nb_rb = nb_available_rb; - break; - } + if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); + nb_rb = nb_available_rb; + break; + } TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb); } @@ -1176,41 +1148,40 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } } - // decrease mcs until TBS falls below required length - while ((TBS > sdu_length_total + header_length_total + ta_len) && (mcs > 0)) { - mcs--; - TBS = get_TBS_DL(mcs, nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < sdu_length_total + header_length_total + ta_len) - && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) - && (mcs < 28)) - || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) - && (mcs <= 15)))) { - mcs++; - TBS = get_TBS_DL(mcs, nb_rb); - } + // decrease mcs until TBS falls below required length + while ((TBS > sdu_length_total + header_length_total + ta_len) && (mcs > 0)) { + mcs--; + TBS = get_TBS_DL(mcs, nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < sdu_length_total + header_length_total + ta_len) + && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) + && (mcs < 28)) + || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) + && (mcs <= 15)))) { + mcs++; + TBS = get_TBS_DL(mcs, nb_rb); + } LOG_D(MAC, "dlsch_mcs before and after the rate matching = (%d, %d)\n", eNB_UE_stats->dlsch_mcs1, mcs); - #ifdef DEBUG_eNB_SCHEDULER LOG_D(MAC, - "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", - module_idP, CC_id, mcs, TBS, nb_rb); + "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", + module_idP, CC_id, mcs, TBS, nb_rb); // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); #endif - if (TBS - header_length_total - sdu_length_total - ta_len <= 2) { - padding = TBS - header_length_total - sdu_length_total - ta_len; - post_padding = 0; - } else { - padding = 0; - post_padding = 1; - } + if (TBS - header_length_total - sdu_length_total - ta_len <= 2) { + padding = TBS - header_length_total - sdu_length_total - ta_len; + post_padding = 0; + } else { + padding = 0; + post_padding = 1; + } offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus @@ -1220,17 +1191,18 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, NULL, // contention res id padding, post_padding); - //#ifdef DEBUG_eNB_SCHEDULER - if (ta_update != 31) { - LOG_D(MAC, - "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_length %d\n", - module_idP, frameP, UE_id, CC_id, - sdu_length_total, num_sdus, sdu_lengths[0], - sdu_lcids[0], offset, ta_update, padding, - post_padding, mcs, TBS, nb_rb, - header_length_total); - } - //#endif + //#ifdef DEBUG_eNB_SCHEDULER + if (ta_update != 31) { + LOG_D(MAC, + "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_length %d\n", + module_idP, frameP, UE_id, CC_id, + sdu_length_total, num_sdus, sdu_lengths[0], + sdu_lcids[0], offset, ta_update, padding, + post_padding, mcs, TBS, nb_rb, + header_length_total); + } + + //#endif #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n"); @@ -1240,98 +1212,91 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, LOG_T(MAC, "\n"); #endif - // cycle through SDUs and place in dlsch_buffer memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total); // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); - // fill remainder of DLSCH with 0 - for (j = 0; j < (TBS - sdu_length_total - offset); j++) { - UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = 0; - } - - if (opt_enabled == 1) { - trace_pdu(DIRECTION_DOWNLINK, - (uint8_t *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], - TBS, module_idP, WS_C_RNTI, - UE_RNTI(module_idP, UE_id), eNB->frame, - eNB->subframe, 0, 0); - LOG_D(OPT, - "[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", - module_idP, CC_id, frameP, - UE_RNTI(module_idP, UE_id), TBS); - } - - T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); + // fill remainder of DLSCH with 0 + for (j = 0; j < (TBS - sdu_length_total - offset); j++) { + UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = 0; + } + + if (opt_enabled == 1) { + trace_pdu(DIRECTION_DOWNLINK, + (uint8_t *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], + TBS, module_idP, WS_C_RNTI, + UE_RNTI(module_idP, UE_id), eNB->frame, + eNB->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", + module_idP, CC_id, frameP, + UE_RNTI(module_idP, UE_id), TBS); + } + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; - add_ue_dlsch_info(module_idP, CC_id, UE_id, subframeP, S_DL_SCHEDULED); // store stats eNB->eNB_stats[CC_id].dlsch_bytes_tx += sdu_length_total; eNB->eNB_stats[CC_id].dlsch_pdus_tx += 1; - - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; UE_list->eNB_UE_stats[CC_id][UE_id].num_mac_sdu_tx = num_sdus; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = mcs; - UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; - + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = mcs; + UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes = TBS - sdu_length_total; UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes += sdu_length_total; UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes += TBS; UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus += 1; - if (cc[CC_id].tdd_Config != NULL) { // TDD - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP, CC_id, rnti, - UE_list->UE_template[CC_id][UE_id].DAI, + if (cc[CC_id].tdd_Config != NULL) { // TDD + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(module_idP, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id].DAI, subframeP); - } - - // do PUCCH power control - // this is the normalized RX power - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - - /* unit is not dBm, it's special from nfapi */ - // converting to dBm: ToDo: Noise power hard coded to 30 - normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30; - target_rx_power= eNB->puCch10xSnr/10 + 30; - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; - if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case - ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around - if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { - ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP; - - if (normalized_rx_power > (target_rx_power + 4)) { - tpc = 0; //-1 - } else if (normalized_rx_power < (target_rx_power - 4)) { - tpc = 2; //+1 - } else { - tpc = 1; //0 - } - - LOG_D(MAC, - "[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n", - module_idP, frameP, subframeP, harq_pid, tpc, - normalized_rx_power, target_rx_power); - - } // Po_PUCCH has been updated - else { - tpc = 1; //0 - } // time to do TPC update - else { - tpc = 1; //0 - } + } + + // do PUCCH power control + // this is the normalized RX power + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + /* unit is not dBm, it's special from nfapi */ + // converting to dBm: ToDo: Noise power hard coded to 30 + normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30; + target_rx_power= eNB->puCch10xSnr/10 + 30; + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + + if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case + ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around + if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { + ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP; + + if (normalized_rx_power > (target_rx_power + 4)) { + tpc = 0; //-1 + } else if (normalized_rx_power < (target_rx_power - 4)) { + tpc = 2; //+1 + } else { + tpc = 1; //0 + } + + LOG_D(MAC, + "[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n", + module_idP, frameP, subframeP, harq_pid, tpc, + normalized_rx_power, target_rx_power); + } // Po_PUCCH has been updated + else { + tpc = 1; //0 + } // time to do TPC update + else { + tpc = 1; //0 + } dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); @@ -1339,16 +1304,15 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = - get_aggregation(get_bw_index(module_idP, CC_id), ue_sched_ctl->dl_cqi[CC_id], format1); + get_aggregation(get_bw_index(module_idP, CC_id), ue_sched_ctl->dl_cqi[CC_id], format1); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = - 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; //deactivate second codeword @@ -1357,7 +1321,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, if (cc[CC_id].tdd_Config != NULL) { //TDD dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = - (UE_list->UE_template[CC_id][UE_id].DAI - 1) & 3; + (UE_list->UE_template[CC_id][UE_id].DAI - 1) & 3; LOG_D(MAC, "[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", module_idP, CC_id, harq_pid, @@ -1367,115 +1331,102 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, LOG_D(MAC, "[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", module_idP, CC_id, harq_pid, mcs); + } - } - - LOG_D(MAC, "Checking feasibility pdu %d (new sdu)\n", - dl_req->number_pdu); - - if (!CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.aggregation_level, rnti)) { - ue_sched_ctl->round[CC_id][harq_pid] = 0; - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + LOG_D(MAC, "Checking feasibility pdu %d (new sdu)\n", + dl_req->number_pdu); + if (!CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, rnti)) { + ue_sched_ctl->round[CC_id][harq_pid] = 0; + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; eNB->DL_req[CC_id].sfn_sf = frameP << 4 | subframeP; eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - // Toggle NDI for next time LOG_D(MAC, "CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", CC_id, frameP, subframeP, UE_id, rnti, harq_pid, UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); - - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid] = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; - UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, - "physicalConfigDedicated is NULL\n"); - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated != NULL, - "physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); - - fill_nfapi_dlsch_config(eNB, dl_req, TBS, eNB->pdu_index[CC_id], rnti, 0, // type 0 allocation from 7.1.6 in 36.213 - 0, // virtual_resource_block_assignment_flag, unused here - 0, // resource_block_coding, to be filled in later - getQm(mcs), 0, // redundancy version - 1, // transport blocks - 0, // transport block to codeword swap flag - cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - // uint8_t codebook_index, - 4, // UE category capacity - UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 - 0, // ngap - 0, // nprb - cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode - 0, //number of PRBs treated as one subband, not used here - 0 // number of beamforming vectors, not used here - ); - eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, - (frameP * 10) + subframeP, - TBS, eNB->pdu_index[CC_id], - eNB->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0]); - - LOG_D(MAC, - "Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n", - eNB->pdu_index[CC_id]); - - eNB->pdu_index[CC_id]++; - program_dlsch_acknak(module_idP, CC_id, UE_id, - frameP, subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - } else { - LOG_W(MAC, - "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", - frameP, subframeP, UE_id, rnti); - } - } else { // There is no data from RLC or MAC header, so don't schedule - - } + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid] = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, + "physicalConfigDedicated is NULL\n"); + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated != NULL, + "physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); + fill_nfapi_dlsch_config(eNB, dl_req, TBS, eNB->pdu_index[CC_id], rnti, 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(mcs), 0, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, + (frameP * 10) + subframeP, + TBS, eNB->pdu_index[CC_id], + eNB->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0]); + LOG_D(MAC, + "Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n", + eNB->pdu_index[CC_id]); + eNB->pdu_index[CC_id]++; + program_dlsch_acknak(module_idP, CC_id, UE_id, + frameP, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + } else { + LOG_W(MAC, + "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", + frameP, subframeP, UE_id, rnti); + } + } else { // There is no data from RLC or MAC header, so don't schedule + } } if (cc[CC_id].tdd_Config != NULL) { // TDD set_ul_DAI(module_idP, UE_id, CC_id, frameP, subframeP); } - } // UE_id loop - } // CC_id loop + } // UE_id loop + } // CC_id loop fill_DLSCH_dci(module_idP, frameP, subframeP, mbsfn_flag); - stop_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT); } //------------------------------------------------------------------------------ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, - int frameP, - sub_frame_t subframeP, - uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX]) + int frameP, + sub_frame_t subframeP, + uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX]) //------------------------------------------------------------------------------ { // FIXME: I'm prototyping the algorithm, so there may be arrays and variables that carry redundant information here and in pre_processor_results struct. - int UE_id, CC_id, rbg, i; int N_RB_DL, min_rb_unit, tm; int owned, used; - UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; slice_info_t *sli = &RC.mac[Mod_id]->slice_info; UE_sched_ctrl *ue_sched_ctl; COMMON_channels_t *cc; int N_RBG[NFAPI_CC_MAX]; - int slice_sorted_list[MAX_NUM_SLICES]; int slice_idx; int8_t free_rbgs_map[NFAPI_CC_MAX][N_RBG_MAX]; int has_traffic[NFAPI_CC_MAX][MAX_NUM_SLICES]; uint8_t allocation_mask[NFAPI_CC_MAX][N_RBG_MAX]; - uint16_t (*nb_rbs_remaining)[MAX_MOBILES_PER_ENB]; uint16_t (*nb_rbs_required)[MAX_MOBILES_PER_ENB]; uint8_t (*MIMO_mode_indicator)[N_RBG_MAX]; @@ -1488,9 +1439,11 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; ++CC_id) { cc = &RC.mac[Mod_id]->common_channels[CC_id]; N_RBG[CC_id] = to_rbg(cc->mib->message.dl_Bandwidth); + for (rbg = 0; rbg < N_RBG[CC_id]; ++rbg) { for (i = 0; i < sli->n_dl; ++i) { owned = sli->pre_processor_results[i].slice_allocation_mask[CC_id][rbg]; + if (owned) { used = rballoc_sub[CC_id][rbg]; free_rbgs_map[CC_id][rbg] = used ? -1 : i; @@ -1505,6 +1458,7 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; ++CC_id) { for (i = 0; i < sli->n_dl; ++i) { has_traffic[CC_id][i] = 0; + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; ++UE_id) { if (sli->pre_processor_results[i].nb_rbs_remaining[CC_id][UE_id] > 0) { has_traffic[CC_id][i] = 1; @@ -1519,7 +1473,6 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, // MULTIPLEXING // This part is an adaptation of dlsch_scheduler_pre_processor_allocate() code for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; ++CC_id) { - N_RB_DL = to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth); min_rb_unit = get_min_rb_unit(Mod_id, CC_id); @@ -1535,11 +1488,13 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, allocation_mask[CC_id][rbg] = 0; continue; } + if (sli->dl[free_rbgs_map[CC_id][rbg]].isol == 1) { // RBG belongs to an isolated slice allocation_mask[CC_id][rbg] = 0; continue; } + // RBG is free allocation_mask[CC_id][rbg] = 1; } @@ -1548,7 +1503,6 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, // (UE list gets sorted every time pre_processor is called so it is probably dirty at this point) // FIXME: There is only one UE_list for all slices, so it must be sorted again each time we use it sort_UEs(Mod_id, slice_idx, frameP, subframeP); - nb_rbs_remaining = sli->pre_processor_results[slice_idx].nb_rbs_remaining; nb_rbs_required = sli->pre_processor_results[slice_idx].nb_rbs_required; MIMO_mode_indicator = sli->pre_processor_results[slice_idx].MIMO_mode_indicator; @@ -1559,13 +1513,17 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, tm = get_tmode(Mod_id, CC_id, UE_id); for (rbg = 0; rbg < N_RBG[CC_id]; ++rbg) { - // FIXME: I think that some of these checks are redundant if (allocation_mask[CC_id][rbg] == 0) continue; + if (rballoc_sub[CC_id][rbg] != 0) continue; + if (ue_sched_ctl->rballoc_sub_UE[CC_id][rbg] != 0) continue; + if (nb_rbs_remaining[CC_id][UE_id] <= 0) continue; + if (ue_sched_ctl->pre_nb_available_rbs[CC_id] >= nb_rbs_required[CC_id][UE_id]) continue; + if (ue_sched_ctl->dl_pow_off[CC_id] == 0) continue; if ((rbg == N_RBG[CC_id] - 1) && ((N_RB_DL == 25) || (N_RB_DL == 50))) { @@ -1575,9 +1533,11 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, free_rbgs_map[CC_id][rbg] = -1; ue_sched_ctl->rballoc_sub_UE[CC_id][rbg] = 1; MIMO_mode_indicator[CC_id][rbg] = 1; + if (tm == 5) { ue_sched_ctl->dl_pow_off[CC_id] = 1; } + nb_rbs_remaining[CC_id][UE_id] = nb_rbs_remaining[CC_id][UE_id] - min_rb_unit + 1; ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit - 1; } @@ -1588,9 +1548,11 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, free_rbgs_map[CC_id][rbg] = -1; ue_sched_ctl->rballoc_sub_UE[CC_id][rbg] = 1; MIMO_mode_indicator[CC_id][rbg] = 1; + if (tm == 5) { ue_sched_ctl->dl_pow_off[CC_id] = 1; } + nb_rbs_remaining[CC_id][UE_id] = nb_rbs_remaining[CC_id][UE_id] - min_rb_unit; ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit; } @@ -1612,14 +1574,12 @@ void dlsch_scheduler_qos_multiplexing(module_id_t Mod_id, int frameP, sub_frame_ for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; ++CC_id) { for (i = 0; i < sli->n_dl; ++i) { - // Sort UE again // FIXME: There is only one UE_list for all slices, so it must be sorted again each time we use it sort_UEs(Mod_id, (uint8_t)i, frameP, subframeP); for (UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { //ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - // TODO: Do something here // ue_sched_ctl->pre_nb_available_rbs[CC_id]; } @@ -1634,7 +1594,6 @@ fill_DLSCH_dci(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, int *mbsfn_flagP) //------------------------------------------------------------------------------ { - // loop over all allocated UEs and compute frequency allocations for PDSCH int UE_id = -1; uint8_t /* first_rb, */ nb_rb = 3; @@ -1642,7 +1601,6 @@ fill_DLSCH_dci(module_id_t module_idP, //unsigned char *vrb_map; uint8_t rballoc_sub[25]; //uint8_t number_of_subbands=13; - //unsigned char round; unsigned char harq_pid; int i; @@ -1652,7 +1610,6 @@ fill_DLSCH_dci(module_id_t module_idP, int N_RBG; int N_RB_DL; COMMON_channels_t *cc; - start_meas(&eNB->fill_DLSCH_dci); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_IN); @@ -1674,11 +1631,10 @@ fill_DLSCH_dci(module_id_t module_idP, eNB_dlsch_info[module_idP][CC_id][UE_id].status); if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) { - // clear scheduling flag eNB_dlsch_info[module_idP][CC_id][UE_id].status = S_DL_WAITING; rnti = UE_RNTI(module_idP, UE_id); - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; /// Synchronizing rballoc with rballoc_sub @@ -1693,22 +1649,22 @@ fill_DLSCH_dci(module_id_t module_idP, i < DL_req[CC_id].dl_config_request_body.number_pdu; i++) { dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[i]; + if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) && (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti) && (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1)) { dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb, N_RB_DL, N_RBG, - rballoc_sub); + rballoc_sub); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; } else if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) && (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti) && (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type == 0)) { dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb, N_RB_DL, N_RBG, - rballoc_sub); + rballoc_sub); } } } } - } stop_meas(&eNB->fill_DLSCH_dci); @@ -1721,20 +1677,17 @@ unsigned char *get_dlsch_sdu(module_id_t module_idP, uint8_t TBindex) //------------------------------------------------------------------------------ { - int UE_id; eNB_MAC_INST *eNB = RC.mac[module_idP]; if (rntiP == SI_RNTI) { LOG_D(MAC, "[eNB %d] CC_id %d Frame %d Get DLSCH sdu for BCCH \n", module_idP, CC_id, frameP); - return ((unsigned char *) &eNB->common_channels[CC_id].BCCH_pdu.payload[0]); } if (rntiP == P_RNTI) { LOG_D(MAC, "[eNB %d] CC_id %d Frame %d Get PCH sdu for PCCH \n", module_idP, CC_id, frameP); - return ((unsigned char *) &eNB->common_channels[CC_id].PCCH_pdu.payload[0]); } @@ -1751,34 +1704,29 @@ unsigned char *get_dlsch_sdu(module_id_t module_idP, module_idP, frameP, CC_id, rntiP); return NULL; } - } //------------------------------------------------------------------------------ void update_ul_dci(module_id_t module_idP, - uint8_t CC_idP, rnti_t rntiP, uint8_t daiP, sub_frame_t subframe) + uint8_t CC_idP, rnti_t rntiP, uint8_t daiP, sub_frame_t subframe) //------------------------------------------------------------------------------ { - nfapi_hi_dci0_request_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP][subframe]; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = - &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; + &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_idP]; int i; - - if (cc->tdd_Config != NULL) { // TDD + if (cc->tdd_Config != NULL) { // TDD for (i = 0; - i hi_dci0_request_body.number_of_dci + HI_DCI0_req->hi_dci0_request_body.number_of_hi; - i++) { - + i hi_dci0_request_body.number_of_dci + HI_DCI0_req->hi_dci0_request_body.number_of_hi; + i++) { if ((hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) && (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti == rntiP)) hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.dl_assignment_index = (daiP - 1) & 3; - } } } @@ -1884,7 +1832,6 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) uint8_t Lcrbs = 0; uint16_t rb_bit = 168; /* RB bit number value is unsure */ #endif - start_meas(&eNB->schedule_pch); for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { @@ -1892,10 +1839,12 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) vrb_map = (void *) &cc->vrb_map; n_rb_dl = to_prb(cc->mib->message.dl_Bandwidth); dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + for (uint16_t i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_PF_PO[CC_id][i].enable_flag != TRUE) { continue; } + if (frameP % UE_PF_PO[CC_id][i].T == UE_PF_PO[CC_id][i].PF_min && subframeP == UE_PF_PO[CC_id][i].PO) { pcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, @@ -1903,140 +1852,166 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) PCCH, 1, &cc->PCCH_pdu.payload[0], i); // used for ue index + if (pcch_sdu_length == 0) { LOG_D(MAC, "[eNB %d] Frame %d subframe %d: PCCH not active(size = 0 byte)\n", module_idP, frameP, subframeP); continue; } + LOG_D(MAC, "[eNB %d] Frame %d subframe %d: PCCH->PCH CC_id %d UE_id %d, Received %d bytes \n", module_idP, frameP, subframeP, CC_id, i, pcch_sdu_length); #ifdef FORMAT1C - //NO SIB - if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || - (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { - switch (n_rb_dl) { - case 25: - n_gap = GAP_MAP[3][0]; /* expect: 12 */ - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ - first_rb = 10; - break; - case 50: - n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ - if (gap_index > 0) { - n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ - } else { - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ - } - first_rb = 24; - break; - case 100: - n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ - if (gap_index > 0) { - n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ - } else { - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ - } - first_rb = 48; - break; - } - } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging - switch (n_rb_dl) { - case 25: - n_gap = GAP_MAP[3][0]; /* expect: 12 */ - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ - first_rb = 14; - break; - case 50: - n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ - if (gap_index > 0) { - n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ - } else { - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ - } - first_rb = 28; - break; - case 100: - n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ - if (gap_index > 0) { - n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ - } else { - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ - } - first_rb = 52; - break; - } - } - /* Get MCS for length of PCH */ - if (pcch_sdu_length <= TBStable1C[0]) { - mcs=0; - } else if (pcch_sdu_length <= TBStable1C[1]) { - mcs=1; - } else if (pcch_sdu_length <= TBStable1C[2]) { - mcs=2; - } else if (pcch_sdu_length <= TBStable1C[3]) { - mcs=3; - } else if (pcch_sdu_length <= TBStable1C[4]) { - mcs=4; - } else if (pcch_sdu_length <= TBStable1C[5]) { - mcs=5; - } else if (pcch_sdu_length <= TBStable1C[6]) { - mcs=6; - } else if (pcch_sdu_length <= TBStable1C[7]) { - mcs=7; - } else if (pcch_sdu_length <= TBStable1C[8]) { - mcs=8; - } else if (pcch_sdu_length <= TBStable1C[9]) { - mcs=9; - } else { - /* unexpected: pcch sdb size is over max value*/ - LOG_E(MAC,"[eNB %d] Frame %d : PCCH->PCH CC_id %d, Received %d bytes is over max length(256) \n", - module_idP, frameP,CC_id, pcch_sdu_length); - return; - } - rb_num = TBStable1C[mcs] / rb_bit + ( (TBStable1C[mcs] % rb_bit == 0)? 0: 1) + 1; - /* calculate N_RB_STEP and Lcrbs */ - if (n_rb_dl < 50) { - n_rb_step = 2; - Lcrbs = rb_num / 2 + ((rb_num % 2 == 0) ? 0:2); - } else { - n_rb_step = 4; - Lcrbs = rb_num / 4 + ((rb_num % 4 == 0) ? 0:4); - } - for(i = 0;i < Lcrbs ;i++){ - vrb_map[first_rb+i] = 1; - } + + //NO SIB + if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || + (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { + switch (n_rb_dl) { + case 25: + n_gap = GAP_MAP[3][0]; /* expect: 12 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ + first_rb = 10; + break; + + case 50: + n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ + + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ + } + + first_rb = 24; + break; + + case 100: + n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ + + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ + } + + first_rb = 48; + break; + } + } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging + switch (n_rb_dl) { + case 25: + n_gap = GAP_MAP[3][0]; /* expect: 12 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ + first_rb = 14; + break; + + case 50: + n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ + + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ + } + + first_rb = 28; + break; + + case 100: + n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ + + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ + } + + first_rb = 52; + break; + } + } + + /* Get MCS for length of PCH */ + if (pcch_sdu_length <= TBStable1C[0]) { + mcs=0; + } else if (pcch_sdu_length <= TBStable1C[1]) { + mcs=1; + } else if (pcch_sdu_length <= TBStable1C[2]) { + mcs=2; + } else if (pcch_sdu_length <= TBStable1C[3]) { + mcs=3; + } else if (pcch_sdu_length <= TBStable1C[4]) { + mcs=4; + } else if (pcch_sdu_length <= TBStable1C[5]) { + mcs=5; + } else if (pcch_sdu_length <= TBStable1C[6]) { + mcs=6; + } else if (pcch_sdu_length <= TBStable1C[7]) { + mcs=7; + } else if (pcch_sdu_length <= TBStable1C[8]) { + mcs=8; + } else if (pcch_sdu_length <= TBStable1C[9]) { + mcs=9; + } else { + /* unexpected: pcch sdb size is over max value*/ + LOG_E(MAC,"[eNB %d] Frame %d : PCCH->PCH CC_id %d, Received %d bytes is over max length(256) \n", + module_idP, frameP,CC_id, pcch_sdu_length); + return; + } + + rb_num = TBStable1C[mcs] / rb_bit + ( (TBStable1C[mcs] % rb_bit == 0)? 0: 1) + 1; + + /* calculate N_RB_STEP and Lcrbs */ + if (n_rb_dl < 50) { + n_rb_step = 2; + Lcrbs = rb_num / 2 + ((rb_num % 2 == 0) ? 0:2); + } else { + n_rb_step = 4; + Lcrbs = rb_num / 4 + ((rb_num % 4 == 0) ? 0:4); + } + + for(i = 0; i < Lcrbs ; i++) { + vrb_map[first_rb+i] = 1; + } + #else - //NO SIB - if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || - (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { - switch (n_rb_dl) { - case 25: - first_rb = 10; - break; - case 50: - first_rb = 24; - break; - case 100: - first_rb = 48; - break; - } - } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging - switch (n_rb_dl) { - case 25: - first_rb = 14; - break; - case 50: - first_rb = 28; - break; - case 100: - first_rb = 52; - break; - } - } + + //NO SIB + if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || + (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { + switch (n_rb_dl) { + case 25: + first_rb = 10; + break; + + case 50: + first_rb = 24; + break; + + case 100: + first_rb = 48; + break; + } + } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging + switch (n_rb_dl) { + case 25: + first_rb = 14; + break; + + case 50: + first_rb = 28; + break; + + case 100: + first_rb = 52; + break; + } + } vrb_map[first_rb] = 1; vrb_map[first_rb + 1] = 1; vrb_map[first_rb + 2] = 1; vrb_map[first_rb + 3] = 1; + /* Get MCS for length of PCH */ if (pcch_sdu_length <= get_TBS_DL(0, 3)) { mcs = 0; @@ -2059,6 +2034,7 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) } else if (pcch_sdu_length <= get_TBS_DL(9, 3)) { mcs = 9; } + #endif dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); @@ -2083,20 +2059,19 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; - if (!CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, P_RNTI)) { - LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for P_RNTI\n", frameP,subframeP); - dl_req->number_dci++; - dl_req->number_pdu++; + if (!CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, P_RNTI)) { + LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for P_RNTI\n", frameP,subframeP); + dl_req->number_dci++; + dl_req->number_pdu++; dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFE; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFE; #ifdef FORMAT1C dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 3; // format 1C dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_vrb_dl/n_rb_step, first_rb/n_rb_step, Lcrbs/n_rb_step); @@ -2105,86 +2080,83 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_rb_dl, first_rb, 4); dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized #endif - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - - // Rel10 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + // Rel10 fields #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; #endif - // Rel13 fields + // Rel13 fields #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 0; // regular UE - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not BR - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 0; // regular UE + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not BR + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; #endif + dl_req->number_pdu++; + eNB->TX_req[CC_id].sfn_sf = (frameP<<4)+subframeP; + TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; + TX_req->pdu_length = pcch_sdu_length; + TX_req->pdu_index = eNB->pdu_index[CC_id]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = pcch_sdu_length; + TX_req->segments[0].segment_data = cc[CC_id].PCCH_pdu.payload; + eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; + } else { + LOG_E(MAC,"[eNB %d] CCid %d Frame %d, subframe %d : Cannot add DCI 1A/1C for Paging\n",module_idP, CC_id, frameP, subframeP); + continue; + } - dl_req->number_pdu++; + if (opt_enabled == 1) { + trace_pdu(DIRECTION_DOWNLINK, + &eNB->common_channels[CC_id].PCCH_pdu.payload[0], + pcch_sdu_length, + 0xffff, + PCCH, + P_RNTI, + eNB->frame, + eNB->subframe, + 0, + 0); + LOG_D(OPT,"[eNB %d][PCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, 0xffff, pcch_sdu_length); + } - eNB->TX_req[CC_id].sfn_sf = (frameP<<4)+subframeP; - TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; - TX_req->pdu_length = pcch_sdu_length; - TX_req->pdu_index = eNB->pdu_index[CC_id]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = pcch_sdu_length; - TX_req->segments[0].segment_data = cc[CC_id].PCCH_pdu.payload; - eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; - } else { - LOG_E(MAC,"[eNB %d] CCid %d Frame %d, subframe %d : Cannot add DCI 1A/1C for Paging\n",module_idP, CC_id, frameP, subframeP); - continue; - } - - if (opt_enabled == 1) { - trace_pdu(DIRECTION_DOWNLINK, - &eNB->common_channels[CC_id].PCCH_pdu.payload[0], - pcch_sdu_length, - 0xffff, - PCCH, - P_RNTI, - eNB->frame, - eNB->subframe, - 0, - 0); - LOG_D(OPT,"[eNB %d][PCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, 0xffff, pcch_sdu_length); - } - eNB->eNB_stats[CC_id].total_num_pcch_pdu+=1; - eNB->eNB_stats[CC_id].pcch_buffer=pcch_sdu_length; - eNB->eNB_stats[CC_id].total_pcch_buffer+=pcch_sdu_length; - eNB->eNB_stats[CC_id].pcch_mcs=mcs; - //paging first_rb log - LOG_D(MAC,"[eNB %d] Frame %d subframe %d PCH: paging_ue_index %d pcch_sdu_length %d mcs %d first_rb %d\n", - module_idP, frameP, subframeP, UE_PF_PO[CC_id][i].ue_index_value, pcch_sdu_length, mcs, first_rb); - - pthread_mutex_lock(&ue_pf_po_mutex); - memset(&UE_PF_PO[CC_id][i], 0, sizeof(UE_PF_PO_t)); - pthread_mutex_unlock(&ue_pf_po_mutex); + eNB->eNB_stats[CC_id].total_num_pcch_pdu+=1; + eNB->eNB_stats[CC_id].pcch_buffer=pcch_sdu_length; + eNB->eNB_stats[CC_id].total_pcch_buffer+=pcch_sdu_length; + eNB->eNB_stats[CC_id].pcch_mcs=mcs; + //paging first_rb log + LOG_D(MAC,"[eNB %d] Frame %d subframe %d PCH: paging_ue_index %d pcch_sdu_length %d mcs %d first_rb %d\n", + module_idP, frameP, subframeP, UE_PF_PO[CC_id][i].ue_index_value, pcch_sdu_length, mcs, first_rb); + pthread_mutex_lock(&ue_pf_po_mutex); + memset(&UE_PF_PO[CC_id][i], 0, sizeof(UE_PF_PO_t)); + pthread_mutex_unlock(&ue_pf_po_mutex); } } } + /* this might be misleading when pcch is inactive */ stop_meas(&eNB->schedule_pch); return; } -static int slice_priority_compare(const void *_a, const void *_b, void *_c) -{ +static int slice_priority_compare(const void *_a, const void *_b, void *_c) { const int slice_id1 = *(const int *) _a; const int slice_id2 = *(const int *) _b; const module_id_t Mod_id = *(int *) _c; @@ -2193,12 +2165,13 @@ static int slice_priority_compare(const void *_a, const void *_b, void *_c) if (sli->dl[slice_id1].prio > sli->dl[slice_id2].prio) { return -1; } + return 1; } -void slice_priority_sort(module_id_t Mod_id, int slice_list[MAX_NUM_SLICES]) -{ +void slice_priority_sort(module_id_t Mod_id, int slice_list[MAX_NUM_SLICES]) { int i; + for (i = 0; i < RC.mac[Mod_id]->slice_info.n_dl; ++i) { slice_list[i] = i; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c index 4e718456f5..61617f1bb9 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -51,8 +51,8 @@ extern uint8_t nfapi_mode; #ifdef PHY_TX_THREAD -extern volatile int16_t phy_tx_txdataF_end; -extern int oai_exit; + extern volatile int16_t phy_tx_txdataF_end; + extern int oai_exit; #endif extern uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset); extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); @@ -63,11 +63,11 @@ int last_dlsch_ue_id[MAX_NUM_CCs] = {-1}; int last_ulsch_ue_id[MAX_NUM_CCs] = {-1}; #if defined(PRE_SCD_THREAD) -uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; -uint8_t dlsch_ue_select_tbl_in_use; -uint8_t new_dlsch_ue_select_tbl_in_use; -boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; -eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint8_t dlsch_ue_select_tbl_in_use; + uint8_t new_dlsch_ue_select_tbl_in_use; + boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; + eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; #endif #define DEBUG_eNB_SCHEDULER 1 @@ -89,92 +89,92 @@ void set_dl_ue_select_msg4(int CC_idP, uint16_t nb_rb, int UE_id, rnti_t rnti) { dlsch_ue_select[CC_idP].ue_num++; } #if defined(PRE_SCD_THREAD) -inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, uint16_t step_size){ +inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, uint16_t step_size) { uint16_t nb_rb,i_TBS,tmp_TBS; i_TBS=get_I_TBS(mcs); - for(nb_rb=step_size;nb_rb>3; + if(TBScommon_channels[CC_id].mib->message.dl_Bandwidth); - if(N_RB_DL==50) step_size=3; - if(N_RB_DL==100) step_size=4; - memset(nb_rbs_required, 0, sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); - UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - - for (UE_id = 0; UE_id common_channels[CC_id].mib->message.dl_Bandwidth); - // store dlsch buffer + if(N_RB_DL==50) step_size=3; - // clear logical channel interface variables - UE_template.dl_buffer_total = 0; + if(N_RB_DL==100) step_size=4; - rnti = UE_RNTI(module_idP, UE_id); + memset(nb_rbs_required, 0, sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - for (lc_id = DCCH; lc_id <= DTCH; lc_id++) { - rlc_status = - mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, - ENB_FLAG_YES, MBMS_FLAG_NO, lc_id, 0 -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 -#endif - ); - UE_template.dl_buffer_total += rlc_status.bytes_in_buffer; //storing the total dlsch buffer - } - // end of store dlsch buffer + for (UE_id = 0; UE_id dlsch_mcs1 = cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; + for (lc_id = DCCH; lc_id <= DTCH; lc_id++) { + rlc_status = + mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, + ENB_FLAG_YES, MBMS_FLAG_NO, lc_id, 0 +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,0, 0 +#endif + ); + UE_template.dl_buffer_total += rlc_status.bytes_in_buffer; //storing the total dlsch buffer + } + // end of store dlsch buffer + // assgin rbs required + // Calculate the number of RBs required by each UE on the basis of logical channel's buffer + //update CQI information across component carriers + eNB_UE_stats = &pre_scd_eNB_UE_stats[CC_id][UE_id]; + eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; - if (UE_template.dl_buffer_total > 0) { - nb_rbs_required[CC_id][UE_id] = search_rbs_required(eNB_UE_stats->dlsch_mcs1, UE_template.dl_buffer_total, N_RB_DL, step_size); - } + if (UE_template.dl_buffer_total > 0) { + nb_rbs_required[CC_id][UE_id] = search_rbs_required(eNB_UE_stats->dlsch_mcs1, UE_template.dl_buffer_total, N_RB_DL, step_size); } + } } #endif -int cc_id_end(uint8_t *cc_id_flag ) -{ +int cc_id_end(uint8_t *cc_id_flag ) { int end_flag = 1; - for (int CC_id=0;CC_idcommon_channels; UE_list_t *UE_list = &eNB->UE_list; @@ -196,7 +196,6 @@ void dlsch_scheduler_pre_ue_select_fairRR( // Initialization for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { dlsch_ue_max_num[CC_id] = (uint16_t)RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; - // save origin DL PDU number DL_req = &eNB->DL_req[CC_id].dl_config_request_body; saved_dlsch_dci[CC_id] = DL_req->number_pdu; @@ -209,60 +208,66 @@ void dlsch_scheduler_pre_ue_select_fairRR( } DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { if (UE_list->active[UE_id] == FALSE) { continue; } rnti = UE_RNTI(module_idP, UE_id); + if (rnti == NOT_A_RNTI) { continue; } - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) { continue; } ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); - + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; + if (round != 8) { // retransmission - if(UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] == 0){ + if(UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] == 0) { continue; } + switch (get_tmode(module_idP, CC_id, UE_id)) { case 1: case 2: case 7: aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); + ue_sched_ctl->dl_cqi[CC_id], + format1); break; + case 3: aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); + ue_sched_ctl->dl_cqi[CC_id], + format2A); break; + default: LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); aggregation = 2; break; } + format_flag = 1; + if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; DL_req->number_pdu++; - nb_rbs_required[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; // Insert DLSCH(retransmission) UE into selected UE list dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; @@ -270,6 +275,7 @@ void dlsch_scheduler_pre_ue_select_fairRR( dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; dlsch_ue_select[CC_id].ue_num++; + if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { end_flag[CC_id] = 1; break; @@ -277,10 +283,10 @@ void dlsch_scheduler_pre_ue_select_fairRR( } else { if (cc[CC_id].tdd_Config != NULL) { //TDD set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); // update UL DAI after DLSCH scheduling set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); } @@ -296,227 +302,249 @@ void dlsch_scheduler_pre_ue_select_fairRR( } } } - if(cc_id_end(end_flag) == 1){ + + if(cc_id_end(end_flag) == 1) { for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { DL_req = &eNB->DL_req[CC_id].dl_config_request_body; DL_req->number_pdu = saved_dlsch_dci[CC_id]; } + return; } // Insert DLSCH(first transmission) UE into selected UE list (UE_id > last_dlsch_ue_id[CC_id]) for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (mbsfn_flag[CC_id]>0) { + if (mbsfn_flag[CC_id]>0) { + continue; + } + + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + + for (UE_id = (last_dlsch_ue_id[CC_id]+1); UE_id active[UE_id] == FALSE) { continue; } - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - for (UE_id = (last_dlsch_ue_id[CC_id]+1); UE_id UE_sched_ctrl[UE_id]; + + for(i = 0; iactive[UE_id] == FALSE) { - continue; - } + if(i < dlsch_ue_select[CC_id].ue_num) + continue; - rnti = UE_RNTI(module_idP,UE_id); - if (rnti == NOT_A_RNTI) - continue; + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP,subframeP); + round = ue_sched_ctl->round[CC_id][harq_pid]; - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + if (round == 8) { + if (nb_rbs_required[CC_id][UE_id] == 0) { continue; } - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - for(i = 0;idl_cqi[CC_id], + format1); + break; + + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; } - if(i < dlsch_ue_select[CC_id].ue_num) - continue; - harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); + format_flag = 1; - round = ue_sched_ctl->round[CC_id][harq_pid]; - if (round == 8) { - if (nb_rbs_required[CC_id][UE_id] == 0) { - continue; - } - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } - format_flag = 1; - if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { - dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; - DL_req->number_pdu++; - - // Insert DLSCH(first transmission) UE into selected selected UE list - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; - dlsch_ue_select[CC_id].ue_num++; + if (!CCE_allocation_infeasible(module_idP, + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { + dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; + DL_req->number_pdu++; + // Insert DLSCH(first transmission) UE into selected selected UE list + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; + dlsch_ue_select[CC_id].ue_num++; if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { - end_flag[CC_id] = 1; - break; - } - }else { - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } - add_ue_dlsch_info(module_idP, + end_flag[CC_id] = 1; + break; + } + } else { + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai (subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } + + add_ue_dlsch_info(module_idP, CC_id, UE_id, subframeP, S_DL_NONE); - end_flag[CC_id] = 1; - break; - } + end_flag[CC_id] = 1; + break; + } } } } - if(cc_id_end(end_flag) == 1){ + + if(cc_id_end(end_flag) == 1) { for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { DL_req = &eNB->DL_req[CC_id].dl_config_request_body; DL_req->number_pdu = saved_dlsch_dci[CC_id]; } + return; } // Insert DLSCH(first transmission) UE into selected UE list (UE_id <= last_dlsch_ue_id[CC_id]) for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (mbsfn_flag[CC_id]>0) { + if (mbsfn_flag[CC_id]>0) { + continue; + } + + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + + for (UE_id = 0; UE_id <= last_dlsch_ue_id[CC_id]; UE_id++) { + if(end_flag[CC_id] == 1) { + break; + } + + if (UE_list->active[UE_id] == FALSE) { continue; } - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - for (UE_id = 0; UE_id <= last_dlsch_ue_id[CC_id]; UE_id++) { - if(end_flag[CC_id] == 1){ + rnti = UE_RNTI(module_idP,UE_id); + + if (rnti == NOT_A_RNTI) + continue; + + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) { + continue; + } + + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + for(i = 0; iactive[UE_id] == FALSE) { - continue; - } + if(i < dlsch_ue_select[CC_id].ue_num) + continue; - rnti = UE_RNTI(module_idP,UE_id); - if (rnti == NOT_A_RNTI) - continue; + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP,subframeP); + round = ue_sched_ctl->round[CC_id][harq_pid]; - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + if (round == 8) { + if (nb_rbs_required[CC_id][UE_id] == 0) { continue; } - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - for(i = 0;idl_cqi[CC_id], + format1); + break; + + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; } - if(i < dlsch_ue_select[CC_id].ue_num) - continue; - harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); + format_flag = 1; + + if (!CCE_allocation_infeasible(module_idP, + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { + dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; + DL_req->number_pdu++; + // Insert DLSCH(first transmission) UE into selected selected UE list + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; + dlsch_ue_select[CC_id].ue_num++; + + if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { + end_flag[CC_id] = 1; + break; + } + } else { + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai (subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } - round = ue_sched_ctl->round[CC_id][harq_pid]; - if (round == 8) { - if (nb_rbs_required[CC_id][UE_id] == 0) { - continue; - } - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } - format_flag = 1; - if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { - dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; - DL_req->number_pdu++; - - // Insert DLSCH(first transmission) UE into selected selected UE list - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; - dlsch_ue_select[CC_id].ue_num++; - - if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { - end_flag[CC_id] = 1; - break; - } - } else { - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } add_ue_dlsch_info(module_idP, CC_id, UE_id, subframeP, S_DL_NONE); - end_flag[CC_id] = 1; - break; - } + end_flag[CC_id] = 1; + break; + } } } } @@ -525,6 +553,7 @@ void dlsch_scheduler_pre_ue_select_fairRR( DL_req = &eNB->DL_req[CC_id].dl_config_request_body; DL_req->number_pdu = saved_dlsch_dci[CC_id]; } + return; } @@ -532,88 +561,74 @@ void dlsch_scheduler_pre_ue_select_fairRR( // This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, - frame_t frameP, - sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int *mbsfn_flag) -{ - + frame_t frameP, + sub_frame_t subframeP, + int N_RBG[MAX_NUM_CCs], + int *mbsfn_flag) { unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX],harq_pid=0,Round=0; uint16_t temp_total_rbs_count; unsigned char temp_total_ue_count; unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; uint8_t slice_allocation[MAX_NUM_CCs][N_RBG_MAX]; - int UE_id, i; + int UE_id, i; uint16_t j,c; uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; -// uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + // uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t average_rbs_per_user[MAX_NUM_CCs] = {0}; rnti_t rnti; int min_rb_unit[MAX_NUM_CCs]; -// uint16_t r1=0; + // uint16_t r1=0; uint8_t CC_id; UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; - UE_sched_ctrl *ue_sched_ctl; // int rrc_status = RRC_IDLE; COMMON_channels_t *cc; - #ifdef TM5 - int harq_pid1 = 0; - int round1 = 0, round2 = 0; - int UE_id2; - uint16_t i1, i2, i3; - rnti_t rnti1, rnti2; - LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; - LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; - UE_sched_ctrl *ue_sched_ctl1, *ue_sched_ctl2; + int harq_pid1 = 0; + int round1 = 0, round2 = 0; + int UE_id2; + uint16_t i1, i2, i3; + rnti_t rnti1, rnti2; + LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; + LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; + UE_sched_ctrl *ue_sched_ctl1, *ue_sched_ctl2; #endif memset(min_rb_unit,0,sizeof(min_rb_unit)); - for (CC_id=0; CC_id 0) // If this CC is allocated for MBSFN skip it here - continue; - - - - min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); - - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) - continue; - - UE_id = i; - // Initialize scheduling information for all active UEs + for (CC_id=0; CC_id 0) // If this CC is allocated for MBSFN skip it here + continue; + min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); - dlsch_scheduler_pre_processor_reset(Mod_id, - 0, - frameP, - subframeP, - min_rb_unit, - (uint16_t (*)[NUMBER_OF_UE_MAX])nb_rbs_required, - rballoc_sub, - MIMO_mode_indicator, - mbsfn_flag); + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; - } + UE_id = i; + // Initialize scheduling information for all active UEs + dlsch_scheduler_pre_processor_reset(Mod_id, + 0, + frameP, + subframeP, + min_rb_unit, + (uint16_t (*)[NUMBER_OF_UE_MAX])nb_rbs_required, + rballoc_sub, + MIMO_mode_indicator, + mbsfn_flag); } + } #if (!defined(PRE_SCD_THREAD)) - // Store the DLSCH buffer for each logical channel - store_dlsch_buffer(Mod_id,0, frameP, subframeP); - - - - // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - assign_rbs_required(Mod_id, 0, frameP, subframeP, nb_rbs_required, - min_rb_unit); + // Store the DLSCH buffer for each logical channel + store_dlsch_buffer(Mod_id,0, frameP, subframeP); + // Calculate the number of RBs required by each UE on the basis of logical channel's buffer + assign_rbs_required(Mod_id, 0, frameP, subframeP, nb_rbs_required, + min_rb_unit); #else - memcpy(nb_rbs_required, pre_nb_rbs_required[dlsch_ue_select_tbl_in_use] , sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); + memcpy(nb_rbs_required, pre_nb_rbs_required[dlsch_ue_select_tbl_in_use], sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); #endif - dlsch_scheduler_pre_ue_select_fairRR(Mod_id,frameP,subframeP, mbsfn_flag,nb_rbs_required,dlsch_ue_select); for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { @@ -624,19 +639,21 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, temp_total_ue_count = dlsch_ue_select[CC_id].ue_num; for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ - temp_total_ue_count--; - continue; + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2) { + temp_total_ue_count--; + continue; } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ - temp_total_ue_count--; - continue; + + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4) { + temp_total_ue_count--; + continue; } + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; nb_rbs_required[CC_id][UE_id] = dlsch_ue_select[CC_id].list[i].nb_rb; - average_rbs_per_user[CC_id] = (uint16_t)round((double)temp_total_rbs_count/(double)temp_total_ue_count); - if( average_rbs_per_user[CC_id] < min_rb_unit[CC_id] ){ + + if( average_rbs_per_user[CC_id] < min_rb_unit[CC_id] ) { temp_total_ue_count--; dlsch_ue_select[CC_id].ue_num--; i--; @@ -644,9 +661,8 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, } rnti = dlsch_ue_select[CC_id].list[i].rnti; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); Round = ue_sched_ctl->round[CC_id][harq_pid]; //if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED || round > 0) { @@ -685,9 +701,11 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, dlsch_ue_select[CC_id].ue_num = i+1; break; } - LOG_D(MAC,"DLSCH UE Select: frame %d subframe %d pre_nb_available_rbs %d(i %d UE_id %d nb_rbs_required %d nb_rbs_required_remaining %d average_rbs_per_user %d (temp_total rbs_count %d ue_num %d) available_prbs %d)\n", - frameP,subframeP,ue_sched_ctl->pre_nb_available_rbs[CC_id],i,UE_id,nb_rbs_required[CC_id][UE_id],nb_rbs_required_remaining[CC_id][UE_id], - average_rbs_per_user[CC_id],temp_total_rbs_count,temp_total_ue_count,RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs); + + LOG_D(MAC, + "DLSCH UE Select: frame %d subframe %d pre_nb_available_rbs %d(i %d UE_id %d nb_rbs_required %d nb_rbs_required_remaining %d average_rbs_per_user %d (temp_total rbs_count %d ue_num %d) available_prbs %d)\n", + frameP,subframeP,ue_sched_ctl->pre_nb_available_rbs[CC_id],i,UE_id,nb_rbs_required[CC_id][UE_id],nb_rbs_required_remaining[CC_id][UE_id], + average_rbs_per_user[CC_id],temp_total_rbs_count,temp_total_ue_count,RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs); #ifdef TM5 // TODO: data channel TM5: to be re-visited #endif @@ -696,231 +714,240 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, #ifdef TM5 - // This has to be revisited!!!! - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - i1 = 0; - i2 = 0; - i3 = 0; - - for (j = 0; j < N_RBG[CC_id]; j++) { - if (MIMO_mode_indicator[CC_id][j] == 2) { - i1 = i1 + 1; - } else if (MIMO_mode_indicator[CC_id][j] == 1) { - i2 = i2 + 1; - } else if (MIMO_mode_indicator[CC_id][j] == 0) { - i3 = i3 + 1; - } - } - - if ((i1 < N_RBG[CC_id]) && (i2 > 0) && (i3 == 0)) { - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = - PHY_vars_eNB_g[Mod_id][CC_id]-> - check_for_SUMIMO_transmissions + 1; - } - - if (i3 == N_RBG[CC_id] && i1 == 0 && i2 == 0) { - PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = - PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + - 1; - } - - if((i1 < N_RBG[CC_id]) && (i3 > 0)) { - PHY_vars_eNB_g[Mod_id][CC_id]-> - check_for_MUMIMO_transmissions + 1; - } - - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + - 1; - + // This has to be revisited!!!! + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + i1 = 0; + i2 = 0; + i3 = 0; + + for (j = 0; j < N_RBG[CC_id]; j++) { + if (MIMO_mode_indicator[CC_id][j] == 2) { + i1 = i1 + 1; + } else if (MIMO_mode_indicator[CC_id][j] == 1) { + i2 = i2 + 1; + } else if (MIMO_mode_indicator[CC_id][j] == 0) { + i3 = i3 + 1; + } } -#endif - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ - continue; - } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ - continue; - } - UE_id = dlsch_ue_select[CC_id].list[i].UE_id; - ue_sched_ctl = &RC.mac[Mod_id]->UE_list.UE_sched_ctrl[UE_id]; - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; - - if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { - LOG_D(MAC, - "******************DL Scheduling Information for UE%d ************************\n", - UE_id); - LOG_D(MAC, "dl power offset UE%d = %d \n", UE_id, - ue_sched_ctl->dl_pow_off[CC_id]); - LOG_D(MAC, - "***********RB Alloc for every subband for UE%d ***********\n", - UE_id); - - for (j = 0; j < N_RBG[CC_id]; j++) { - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; - LOG_D(MAC, "RB Alloc for UE%d and Subband%d = %d\n", - UE_id, j, - ue_sched_ctl->rballoc_sub_UE[CC_id][j]); - } - - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; - LOG_D(MAC, "Total RBs allocated for UE%d = %d\n", UE_id, - ue_sched_ctl->pre_nb_available_rbs[CC_id]); - } - } + if ((i1 < N_RBG[CC_id]) && (i2 > 0) && (i3 == 0)) { + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]-> + check_for_SUMIMO_transmissions + 1; } -} + if (i3 == N_RBG[CC_id] && i1 == 0 && i2 == 0) { + PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + + 1; + } -//------------------------------------------------------------------------------ -void -schedule_ue_spec_fairRR(module_id_t module_idP, - frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) -//------------------------------------------------------------------------------ -{ + if((i1 < N_RBG[CC_id]) && (i3 > 0)) { + PHY_vars_eNB_g[Mod_id][CC_id]-> + check_for_MUMIMO_transmissions + 1; + } + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + + 1; + } - uint8_t CC_id; - int UE_id; -// unsigned char aggregation; - mac_rlc_status_resp_t rlc_status; - unsigned char header_len_dcch = 0, header_len_dcch_tmp = 0; - unsigned char header_len_dtch = 0, header_len_dtch_tmp = 0, header_len_dtch_last = 0; - unsigned char ta_len = 0; - unsigned char sdu_lcids[NB_RB_MAX], lcid, offset, num_sdus = 0; - uint16_t nb_rb, nb_rb_temp, nb_available_rb; - uint16_t TBS, j, sdu_lengths[NB_RB_MAX], rnti, padding = 0, post_padding = 0; - unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; - unsigned char round = 0; - unsigned char harq_pid = 0; - eNB_UE_STATS *eNB_UE_stats = NULL; - uint16_t sdu_length_total = 0; - - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - UE_list_t *UE_list = &eNB->UE_list; - // int continue_flag = 0; - int32_t normalized_rx_power, target_rx_power; - int32_t tpc = 1; - static int32_t tpc_accumulated = 0; - UE_sched_ctrl *ue_sched_ctl; - int mcs; - int i; - int min_rb_unit[MAX_NUM_CCs]; - int N_RB_DL[MAX_NUM_CCs]; - int total_nb_available_rb[MAX_NUM_CCs]; - int N_RBG[MAX_NUM_CCs]; - nfapi_dl_config_request_body_t *dl_req; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - int tdd_sfa; - int ta_update; -#ifdef DEBUG_eNB_SCHEDULER - int k; #endif - - start_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); - - - // for TDD: check that we have to act here, otherwise return - if (cc[0].tdd_Config) { - tdd_sfa = cc[0].tdd_Config->subframeAssignment; - switch (subframeP) { - case 0: - // always continue - break; - case 1: - return; - break; - case 2: - return; - break; - case 3: - if ((tdd_sfa != 2) && (tdd_sfa != 5)) - return; - break; - case 4: - if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) - && (tdd_sfa != 5)) - return; - break; - case 5: - break; - case 6: - case 7: - if ((tdd_sfa != 3)&& (tdd_sfa != 4) && (tdd_sfa != 5)) - return; - break; - case 8: - if ((tdd_sfa != 2) && (tdd_sfa != 3) && (tdd_sfa != 4) - && (tdd_sfa != 5)) - return; - break; - case 9: - if (tdd_sfa == 0) - return; - break; - - } + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2) { + continue; + } + + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4) { + continue; + } + + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; + ue_sched_ctl = &RC.mac[Mod_id]->UE_list.UE_sched_ctrl[UE_id]; + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; + + if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { + LOG_D(MAC, + "******************DL Scheduling Information for UE%d ************************\n", + UE_id); + LOG_D(MAC, "dl power offset UE%d = %d \n", UE_id, + ue_sched_ctl->dl_pow_off[CC_id]); + LOG_D(MAC, + "***********RB Alloc for every subband for UE%d ***********\n", + UE_id); + + for (j = 0; j < N_RBG[CC_id]; j++) { + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; + LOG_D(MAC, "RB Alloc for UE%d and Subband%d = %d\n", + UE_id, j, + ue_sched_ctl->rballoc_sub_UE[CC_id][j]); + } + + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; + LOG_D(MAC, "Total RBs allocated for UE%d = %d\n", UE_id, + ue_sched_ctl->pre_nb_available_rbs[CC_id]); + } } + } +} - //weight = get_ue_weight(module_idP,UE_id); -// aggregation = 2; - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); - min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id); - // get number of PRBs less those used by common channels - total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; - for (i = 0; i < N_RB_DL[CC_id]; i++) - if (cc[CC_id].vrb_map[i] != 0) - total_nb_available_rb[CC_id]--; - - N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); - - // store the global enb stats: - eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; - eNB->eNB_stats[CC_id].available_prbs = - total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].total_available_prbs += - total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0; - eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0; + +//------------------------------------------------------------------------------ +void +schedule_ue_spec_fairRR(module_id_t module_idP, + frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) +//------------------------------------------------------------------------------ +{ + uint8_t CC_id; + int UE_id; + // unsigned char aggregation; + mac_rlc_status_resp_t rlc_status; + unsigned char header_len_dcch = 0, header_len_dcch_tmp = 0; + unsigned char header_len_dtch = 0, header_len_dtch_tmp = 0, header_len_dtch_last = 0; + unsigned char ta_len = 0; + unsigned char sdu_lcids[NB_RB_MAX], lcid, offset, num_sdus = 0; + uint16_t nb_rb, nb_rb_temp, nb_available_rb; + uint16_t TBS, j, sdu_lengths[NB_RB_MAX], rnti, padding = 0, post_padding = 0; + unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; + unsigned char round = 0; + unsigned char harq_pid = 0; + eNB_UE_STATS *eNB_UE_stats = NULL; + uint16_t sdu_length_total = 0; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + UE_list_t *UE_list = &eNB->UE_list; + // int continue_flag = 0; + int32_t normalized_rx_power, target_rx_power; + int32_t tpc = 1; + static int32_t tpc_accumulated = 0; + UE_sched_ctrl *ue_sched_ctl; + int mcs; + int i; + int min_rb_unit[MAX_NUM_CCs]; + int N_RB_DL[MAX_NUM_CCs]; + int total_nb_available_rb[MAX_NUM_CCs]; + int N_RBG[MAX_NUM_CCs]; + nfapi_dl_config_request_body_t *dl_req; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + int tdd_sfa; + int ta_update; +#ifdef DEBUG_eNB_SCHEDULER + int k; +#endif + start_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); + + // for TDD: check that we have to act here, otherwise return + if (cc[0].tdd_Config) { + tdd_sfa = cc[0].tdd_Config->subframeAssignment; + + switch (subframeP) { + case 0: + // always continue + break; + + case 1: + return; + break; + + case 2: + return; + break; + + case 3: + if ((tdd_sfa != 2) && (tdd_sfa != 5)) + return; + + break; + + case 4: + if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + + break; + + case 5: + break; + + case 6: + case 7: + if ((tdd_sfa != 3)&& (tdd_sfa != 4) && (tdd_sfa != 5)) + return; + + break; + + case 8: + if ((tdd_sfa != 2) && (tdd_sfa != 3) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + + break; + + case 9: + if (tdd_sfa == 0) + return; + + break; } + } - /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band) + //weight = get_ue_weight(module_idP,UE_id); + // aggregation = 2; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); + min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id); + // get number of PRBs less those used by common channels + total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; + + for (i = 0; i < N_RB_DL[CC_id]; i++) + if (cc[CC_id].vrb_map[i] != 0) + total_nb_available_rb[CC_id]--; + + N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); + // store the global enb stats: + eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; + eNB->eNB_stats[CC_id].available_prbs = + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].total_available_prbs += + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0; + eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0; + } + /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN); start_meas(&eNB->schedule_dlsch_preprocessor); dlsch_scheduler_pre_processor_fairRR(module_idP, - frameP, - subframeP, - N_RBG, - mbsfn_flag); + frameP, + subframeP, + N_RBG, + mbsfn_flag); stop_meas(&eNB->schedule_dlsch_preprocessor); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); - for (CC_id=0; CC_idDL_req[CC_id].dl_config_request_body; if (mbsfn_flag[CC_id]>0) continue; for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2) { continue; } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ + + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4) { continue; } + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; rnti = UE_RNTI(module_idP,UE_id); + if (rnti==NOT_A_RNTI) { LOG_E(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n",UE_id,UE_list->num_UEs); continue; @@ -928,387 +955,377 @@ schedule_ue_spec_fairRR(module_id_t module_idP, eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; -/* - switch(get_tmode(module_idP,CC_id,UE_id)){ - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } -*/ + + /* + switch(get_tmode(module_idP,CC_id,UE_id)){ + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; + } + */ if (cc[CC_id].tdd_Config != NULL) { //TDD set_ue_dai (subframeP, UE_id, CC_id, - cc[CC_id].tdd_Config->subframeAssignment, + cc[CC_id].tdd_Config->subframeAssignment, UE_list); // update UL DAI after DLSCH scheduling set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); } - nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; + nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); + round = ue_sched_ctl->round[CC_id][harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = + mac_eNB_get_rrc_status(module_idP, rnti); + UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; + UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; + + if (UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status < + RRC_CONNECTED) + continue; - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + sdu_length_total = 0; + num_sdus = 0; - round = ue_sched_ctl->round[CC_id][harq_pid]; + /* + DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), + eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); + */ + if (nfapi_mode) { + eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + } else { + eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + } + + eNB_UE_stats->dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); - UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = - mac_eNB_get_rrc_status(module_idP, rnti); - UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; - UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; + // store stats + //UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->dl_cqi; + // initializing the rb allocation indicator for each UE + for (j = 0; j < N_RBG[CC_id]; j++) { + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband[harq_pid][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", + module_idP, frameP, UE_id, CC_id, rnti, harq_pid, round, + nb_available_rb, ue_sched_ctl->dl_cqi[CC_id], + eNB_UE_stats->dlsch_mcs1, + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); - if (UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status < - RRC_CONNECTED) - continue; + /* process retransmission */ - sdu_length_total = 0; - num_sdus = 0; + if (round != 8) { + // get freq_allocation + nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + TBS = + get_TBS_DL(UE_list-> + UE_template[CC_id][UE_id].oldmcs1[harq_pid], + nb_rb); - /* - DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), - eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); - */ - if (nfapi_mode) { - eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + if (nb_rb <= nb_available_rb) { + if (cc[CC_id].tdd_Config != NULL) { + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(module_idP, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id]. + DAI,subframeP); + LOG_D(MAC, + "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframeP, UE_id, + UE_list->UE_template[CC_id][UE_id].DAI); + } + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < N_RBG[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 { - eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + } else { + nb_rb_temp = nb_rb; + j = 0; + + while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + if (UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j]) + printf + ("WARN: rballoc_subband not free for retrans?\n"); + + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if ((j == N_RBG[CC_id] - 1) && + ((N_RB_DL[CC_id] == 25) || + (N_RB_DL[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; } - eNB_UE_stats->dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); - - - // store stats - //UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->dl_cqi; - - // initializing the rb allocation indicator for each UE - for (j = 0; j < N_RBG[CC_id]; j++) { - UE_list-> - UE_template[CC_id][UE_id].rballoc_subband[harq_pid][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", - module_idP, frameP, UE_id, CC_id, rnti, harq_pid, round, - nb_available_rb, ue_sched_ctl->dl_cqi[CC_id], - eNB_UE_stats->dlsch_mcs1, - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); - - - - /* process retransmission */ - - if (round != 8) { - - // get freq_allocation - nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - TBS = - get_TBS_DL(UE_list-> - UE_template[CC_id][UE_id].oldmcs1[harq_pid], - nb_rb); - - if (nb_rb <= nb_available_rb) { - if (cc[CC_id].tdd_Config != NULL) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP, CC_id, rnti, - UE_list->UE_template[CC_id][UE_id]. - DAI,subframeP); - LOG_D(MAC, - "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", - CC_id, subframeP, UE_id, - UE_list->UE_template[CC_id][UE_id].DAI); - } - - if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for (j = 0; j < N_RBG[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 < N_RBG[CC_id])) { - if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == - 1) { - if (UE_list-> - UE_template[CC_id] - [UE_id].rballoc_subband[harq_pid][j]) - printf - ("WARN: rballoc_subband not free for retrans?\n"); - UE_list-> - UE_template[CC_id] - [UE_id].rballoc_subband[harq_pid][j] = - ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if ((j == N_RBG[CC_id] - 1) && - ((N_RB_DL[CC_id] == 25) || - (N_RB_DL[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; - /* - eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j=0; jmu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } - */ - - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - default: - LOG_D(MAC,"retransmission DL_REQ: rnti:%x\n",rnti); - - dl_config_pdu = - &dl_req->dl_config_pdu_list[dl_req-> - number_pdu]; - memset((void *) dl_config_pdu, 0, - sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = - NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = - (uint8_t) (2 + - sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. - dci_format = NFAPI_DL_DCI_FORMAT_1; - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.aggregation_level = - get_aggregation(get_bw_index - (module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = - rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. - harq_process = harq_pid; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // dont adjust power when retransmitting - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.new_data_indicator_1 = - UE_list->UE_template[CC_id][UE_id]. - oldNDI[harq_pid]; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = - UE_list->UE_template[CC_id][UE_id]. - oldmcs1[harq_pid]; - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.redundancy_version_1 = - round & 3; - - if (cc[CC_id].tdd_Config != NULL) { //TDD - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.downlink_assignment_index = - (UE_list->UE_template[CC_id][UE_id].DAI - - 1) & 3; - LOG_D(MAC, - "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", - module_idP, CC_id, harq_pid, round, - (UE_list->UE_template[CC_id][UE_id].DAI - - 1), - UE_list-> - UE_template[CC_id][UE_id].oldmcs1 - [harq_pid]); - } else { - LOG_D(MAC, - "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", - module_idP, CC_id, harq_pid, round, - UE_list-> - UE_template[CC_id][UE_id].oldmcs1 - [harq_pid]); - - } - if (!CCE_allocation_infeasible - (module_idP, CC_id, 1, subframeP, - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.aggregation_level, rnti)) { - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; - eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1 - /* retransmission, no pdu_index */ - , rnti, 0, // type 0 allocation from 7.1.6 in 36.213 - 0, // virtual_resource_block_assignment_flag, unused here - 0, // resource_block_coding, to be filled in later - getQm(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]), round & 3, // redundancy version - 1, // transport blocks - 0, // transport block to codeword swap flag - cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - // uint8_t codebook_index, - 4, // UE category capacity - UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 - 0, // ngap - 0, // nprb - cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode - 0, //number of PRBs treated as one subband, not used here - 0 // number of beamforming vectors, not used here - ); - - LOG_D(MAC, - "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", - eNB->pdu_index[CC_id], round); - - program_dlsch_acknak(module_idP, CC_id, UE_id, - frameP, subframeP, - dl_config_pdu-> - dci_dl_pdu.dci_dl_pdu_rel8. - cce_idx); - // No TX request for retransmission (check if null request for FAPI) - } else { - LOG_W(MAC, - "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d\%x, infeasible CCE allocation\n", - frameP, subframeP, UE_id, rnti); - } - } - - - add_ue_dlsch_info(module_idP, - CC_id, UE_id, subframeP, - S_DL_SCHEDULED); - - //eNB_UE_stats->dlsch_trials[round]++; - UE_list->eNB_UE_stats[CC_id][UE_id]. - num_retransmission += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = - nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id]. - total_rbs_used_retx += nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = - eNB_UE_stats->dlsch_mcs1; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = - eNB_UE_stats->dlsch_mcs1; - } 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", - module_idP, frameP, CC_id, UE_id); - } - } else { /* This is a potentially new SDU opportunity */ - - rlc_status.bytes_in_buffer = 0; - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - TBS = - get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); - // check first for RLC data on DCCH - // add the length for all the control elements (timing adv, drx, etc) : header + payload - - if (ue_sched_ctl->ta_timer == 0) { - ta_update = ue_sched_ctl->ta_update; - /* if we send TA then set timer to not send it for a while */ - if (ta_update != 31) - ue_sched_ctl->ta_timer = 20; - /* reset ta_update */ - ue_sched_ctl->ta_update = 31; - } else { - ta_update = 31; - } - - ta_len = (ta_update != 31) ? 2 : 0; - - header_len_dcch = 2; // 2 bytes DCCH SDU subheader - - if (TBS - ta_len - header_len_dcch > 0) { - rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, (TBS - ta_len - header_len_dcch) + } + + nb_available_rb -= nb_rb; + /* + eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; + + for(j=0; jmu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } + */ + + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + default: + LOG_D(MAC,"retransmission DL_REQ: rnti:%x\n",rnti); + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req-> + number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = + NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level = + get_aggregation(get_bw_index + (module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = + rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.new_data_indicator_1 = + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = + UE_list->UE_template[CC_id][UE_id]. + oldmcs1[harq_pid]; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.redundancy_version_1 = + round & 3; + + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.downlink_assignment_index = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + LOG_D(MAC, + "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", + module_idP, CC_id, harq_pid, round, + (UE_list->UE_template[CC_id][UE_id].DAI - + 1), + UE_list-> + UE_template[CC_id][UE_id].oldmcs1 + [harq_pid]); + } else { + LOG_D(MAC, + "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", + module_idP, CC_id, harq_pid, round, + UE_list-> + UE_template[CC_id][UE_id].oldmcs1 + [harq_pid]); + } + + if (!CCE_allocation_infeasible + (module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, rnti)) { + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; + fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1 + /* retransmission, no pdu_index */ + , rnti, 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]), round & 3, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + LOG_D(MAC, + "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", + eNB->pdu_index[CC_id], round); + program_dlsch_acknak(module_idP, CC_id, UE_id, + frameP, subframeP, + dl_config_pdu-> + dci_dl_pdu.dci_dl_pdu_rel8. + cce_idx); + // No TX request for retransmission (check if null request for FAPI) + } else { + LOG_W(MAC, + "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d\%x, infeasible CCE allocation\n", + frameP, subframeP, UE_id, rnti); + } + } + + add_ue_dlsch_info(module_idP, + CC_id, UE_id, subframeP, + S_DL_SCHEDULED); + //eNB_UE_stats->dlsch_trials[round]++; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_retransmission += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = + nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id]. + total_rbs_used_retx += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = + eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = + eNB_UE_stats->dlsch_mcs1; + } 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", + module_idP, frameP, CC_id, UE_id); + } + } else { /* This is a potentially new SDU opportunity */ + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); + // check first for RLC data on DCCH + // add the length for all the control elements (timing adv, drx, etc) : header + payload + + if (ue_sched_ctl->ta_timer == 0) { + ta_update = ue_sched_ctl->ta_update; + + /* if we send TA then set timer to not send it for a while */ + if (ta_update != 31) + ue_sched_ctl->ta_timer = 20; + + /* reset ta_update */ + ue_sched_ctl->ta_update = 31; + } else { + ta_update = 31; + } + + ta_len = (ta_update != 31) ? 2 : 0; + header_len_dcch = 2; // 2 bytes DCCH SDU subheader + + if (TBS - ta_len - header_len_dcch > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, (TBS - ta_len - header_len_dcch) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); // transport block set size - - sdu_lengths[0] = 0; - - if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit - LOG_D(MAC, - "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, subframeP, CC_id, - TBS - header_len_dcch); - sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used - (char *) - &dlsch_buffer - [0] + ); // transport block set size + sdu_lengths[0] = 0; + + if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit + LOG_D(MAC, + "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, subframeP, CC_id, + TBS - header_len_dcch); + sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used + (char *) + &dlsch_buffer + [0] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); + ); pthread_mutex_lock(&rrc_release_freelist); - if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)){ + + if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)) { uint16_t release_total = 0; - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ + + for(uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0) { release_total++; - }else{ + } else { continue; } - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1){ - if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1) { + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]) { rrc_release_info.RRC_release_ctrl[release_num].flag = 3; LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 1->3\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); break; - } - } + } + } } } - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2){ - if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ - rrc_release_info.RRC_release_ctrl[release_num].flag = 4; - LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 2->4\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); - break; + + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2) { + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]) { + rrc_release_info.RRC_release_ctrl[release_num].flag = 4; + LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 2->4\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); + break; } } } } + if(release_total >= rrc_release_info.num_UEs) break; } } - pthread_mutex_unlock(&rrc_release_freelist); + pthread_mutex_unlock(&rrc_release_freelist); RA_t *ra = &eNB->common_channels[CC_id].ra[0]; + for (uint8_t ra_ii = 0; ra_ii < NB_RA_PROC_MAX; ra_ii++) { - if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]){ + if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]) { ra[ra_ii].crnti_harq_pid = harq_pid; ra[ra_ii].state = MSGCRNTI_ACK; break; @@ -1316,347 +1333,339 @@ schedule_ue_spec_fairRR(module_id_t module_idP, } } } - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), - T_INT(sdu_lengths[0])); - LOG_D(MAC, - "[eNB %d][DCCH] CC_id %d frame %d subframe %d UE_id %d/%x Got %d bytes bytes_in_buffer %d from release_num %d\n", - module_idP, CC_id, frameP, subframeP, UE_id, rnti, sdu_lengths[0],rlc_status.bytes_in_buffer,rrc_release_info.num_UEs); - - sdu_length_total = sdu_lengths[0]; - sdu_lcids[0] = DCCH; - UE_list->eNB_UE_stats[CC_id][UE_id]. - num_pdu_tx[DCCH] += 1; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] - += sdu_lengths[0]; - num_sdus = 1; + + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), + T_INT(sdu_lengths[0])); + LOG_D(MAC, + "[eNB %d][DCCH] CC_id %d frame %d subframe %d UE_id %d/%x Got %d bytes bytes_in_buffer %d from release_num %d\n", + module_idP, CC_id, frameP, subframeP, UE_id, rnti, sdu_lengths[0],rlc_status.bytes_in_buffer,rrc_release_info.num_UEs); + sdu_length_total = sdu_lengths[0]; + sdu_lcids[0] = DCCH; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_pdu_tx[DCCH] += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] + += sdu_lengths[0]; + num_sdus = 1; #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC, - "[eNB %d][DCCH] CC_id %d Got %d bytes :", - module_idP, CC_id, sdu_lengths[0]); + LOG_T(MAC, + "[eNB %d][DCCH] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[0]); - for (k = 0; k < sdu_lengths[0]; k++) { - LOG_T(MAC, "%x ", dlsch_buffer[k]); - } + for (k = 0; k < sdu_lengths[0]; k++) { + LOG_T(MAC, "%x ", dlsch_buffer[k]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif - } else { - header_len_dcch = 0; - sdu_length_total = 0; - } - } - // check for DCCH1 and update header information (assume 2 byte sub-header) - if (TBS - ta_len - header_len_dcch - sdu_length_total > 0) { - rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, (TBS - ta_len - header_len_dcch - sdu_length_total) + } else { + header_len_dcch = 0; + sdu_length_total = 0; + } + } + + // check for DCCH1 and update header information (assume 2 byte sub-header) + if (TBS - ta_len - header_len_dcch - sdu_length_total > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, (TBS - ta_len - header_len_dcch - sdu_length_total) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); // transport block set size less allocations for timing advance and - // DCCH SDU - sdu_lengths[num_sdus] = 0; - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, - "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, CC_id, - TBS - header_len_dcch - sdu_length_total); - sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS, //not used - (char *) - &dlsch_buffer - [sdu_length_total] + ); // transport block set size less allocations for timing advance and + // DCCH SDU + sdu_lengths[num_sdus] = 0; + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, + "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, CC_id, + TBS - header_len_dcch - sdu_length_total); + sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS, //not used + (char *) + &dlsch_buffer + [sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus])); - - sdu_lcids[num_sdus] = DCCH1; - sdu_length_total += sdu_lengths[num_sdus]; - header_len_dcch += 2; - UE_list->eNB_UE_stats[CC_id][UE_id]. - num_pdu_tx[DCCH1] += 1; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] - += sdu_lengths[num_sdus]; - num_sdus++; + ); + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus])); + sdu_lcids[num_sdus] = DCCH1; + sdu_length_total += sdu_lengths[num_sdus]; + header_len_dcch += 2; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_pdu_tx[DCCH1] += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] + += sdu_lengths[num_sdus]; + num_sdus++; #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC, - "[eNB %d][DCCH1] CC_id %d Got %d bytes :", - module_idP, CC_id, sdu_lengths[num_sdus]); + LOG_T(MAC, + "[eNB %d][DCCH1] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[num_sdus]); - for (k = 0; k < sdu_lengths[num_sdus]; k++) { - LOG_T(MAC, "%x ", dlsch_buffer[k]); - } + for (k = 0; k < sdu_lengths[num_sdus]; k++) { + LOG_T(MAC, "%x ", dlsch_buffer[k]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif + } + } - } - } - // assume the max dtch header size, and adjust it later - header_len_dtch = 0; - header_len_dtch_last = 0; // the header length of the last mac sdu - // lcid has to be sorted before the actual allocation (similar struct as ue_list). - /* TODO limited lcid for performance */ - for (lcid = DTCH; lcid >= DTCH; lcid--) { - // TBD: check if the lcid is active - header_len_dtch += 3; - header_len_dtch_last = 3; - - LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", - module_idP, - frameP, - lcid, - TBS, - TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch); - - if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? - rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch + // assume the max dtch header size, and adjust it later + header_len_dtch = 0; + header_len_dtch_last = 0; // the header length of the last mac sdu + + // lcid has to be sorted before the actual allocation (similar struct as ue_list). + /* TODO limited lcid for performance */ + for (lcid = DTCH; lcid >= DTCH; lcid--) { + // TBD: check if the lcid is active + header_len_dtch += 3; + header_len_dtch_last = 3; + LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, + frameP, + lcid, + TBS, + TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch); + + if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch #ifdef Rel14 - , 0, 0 + , 0, 0 #endif - ); - - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", - module_idP, - frameP, - TBS - header_len_dcch - sdu_length_total - header_len_dtch, - lcid, - header_len_dtch); - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS, //not used - (char *)&dlsch_buffer[sdu_length_total] -#ifdef Rel14 - , 0, 0 + ); + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, + frameP, + TBS - header_len_dcch - sdu_length_total - header_len_dtch, + lcid, + header_len_dtch); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] +#ifdef Rel14 + , 0, 0 #endif - ); - - T(T_ENB_MAC_UE_DL_SDU, - T_INT(module_idP), - T_INT(CC_id), - T_INT(rnti), - T_INT(frameP), - T_INT(subframeP), - T_INT(harq_pid), - T_INT(lcid), - T_INT(sdu_lengths[num_sdus])); - - LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_idP, - sdu_lengths[num_sdus], - lcid); - - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; - - if (sdu_lengths[num_sdus] < 128) { - header_len_dtch--; - header_len_dtch_last--; - } - - num_sdus++; - - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - - } else { // no data for this LCID - header_len_dtch -= 3; + ); + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(lcid), + T_INT(sdu_lengths[num_sdus])); + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, + sdu_lengths[num_sdus], + lcid); + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; + + if (sdu_lengths[num_sdus] < 128) { + header_len_dtch--; + header_len_dtch_last--; + } + + num_sdus++; + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + } else { // no data for this LCID + header_len_dtch -= 3; + } + } else { // no TBS left + header_len_dtch -= 3; + break; + } } - - } else { // no TBS left - header_len_dtch -= 3; - - break; - } - } - if (header_len_dtch == 0) - header_len_dtch_last = 0; - // there is at least one SDU - // if (num_sdus > 0 ){ - if ((sdu_length_total + header_len_dcch + - header_len_dtch) > 0) { - - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - // adjust header lengths - header_len_dcch_tmp = header_len_dcch; - header_len_dtch_tmp = header_len_dtch; - if (header_len_dtch == 0) { - header_len_dcch = (header_len_dcch > 0) ? 1 : 0; //header_len_dcch; // remove length field - } else { - header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU - header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU - } - - mcs = eNB_UE_stats->dlsch_mcs1; - nb_rb = min_rb_unit[CC_id]; - TBS = get_TBS_DL(mcs, nb_rb); - - while (TBS < - (sdu_length_total + header_len_dcch + - header_len_dtch + ta_len)) { - nb_rb += min_rb_unit[CC_id]; // - - if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = - get_TBS_DL(eNB_UE_stats->dlsch_mcs1, - nb_available_rb); - nb_rb = nb_available_rb; - break; - } - - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb); - } - - if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for (j = 0; j < N_RBG[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 < N_RBG[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 == N_RBG[CC_id] - 1) && - ((N_RB_DL[CC_id] == 25) || - (N_RB_DL[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; - } - } - - // decrease mcs until TBS falls below required length - while ((TBS > - (sdu_length_total + header_len_dcch + - header_len_dtch + ta_len)) && (mcs > 0)) { - mcs--; - TBS = get_TBS_DL(mcs, nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < - (sdu_length_total + header_len_dcch + - header_len_dtch + ta_len)) - && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) - && (mcs < 28)) - || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) - && (mcs <= 15)))) { - mcs++; - TBS = get_TBS_DL(mcs, nb_rb); - } - - LOG_D(MAC, - "dlsch_mcs before and after the rate matching = (%d, %d)\n", - eNB_UE_stats->dlsch_mcs1, mcs); + if (header_len_dtch == 0) + header_len_dtch_last = 0; + + // there is at least one SDU + // if (num_sdus > 0 ){ + if ((sdu_length_total + header_len_dcch + + header_len_dtch) > 0) { + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 + // adjust header lengths + header_len_dcch_tmp = header_len_dcch; + header_len_dtch_tmp = header_len_dtch; + + if (header_len_dtch == 0) { + header_len_dcch = (header_len_dcch > 0) ? 1 : 0; //header_len_dcch; // remove length field + } else { + header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU + header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU + } + + mcs = eNB_UE_stats->dlsch_mcs1; + nb_rb = min_rb_unit[CC_id]; + TBS = get_TBS_DL(mcs, nb_rb); + + while (TBS < + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) { + nb_rb += min_rb_unit[CC_id]; // + + if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, + nb_available_rb); + nb_rb = nb_available_rb; + break; + } + + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb); + } + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < N_RBG[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 < N_RBG[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 == N_RBG[CC_id] - 1) && + ((N_RB_DL[CC_id] == 25) || + (N_RB_DL[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; + } + } + + // decrease mcs until TBS falls below required length + while ((TBS > + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) && (mcs > 0)) { + mcs--; + TBS = get_TBS_DL(mcs, nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) + && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) + && (mcs < 28)) + || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) + && (mcs <= 15)))) { + mcs++; + TBS = get_TBS_DL(mcs, nb_rb); + } + + LOG_D(MAC, + "dlsch_mcs before and after the rate matching = (%d, %d)\n", + eNB_UE_stats->dlsch_mcs1, mcs); #ifdef DEBUG_eNB_SCHEDULER - LOG_D(MAC, - "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", - module_idP, CC_id, mcs, TBS, nb_rb); - // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", - // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); + LOG_D(MAC, + "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", + module_idP, CC_id, mcs, TBS, nb_rb); + // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", + // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); #endif - if ((TBS - header_len_dcch - header_len_dtch - - sdu_length_total - ta_len) <= 2) { - padding = - (TBS - header_len_dcch - header_len_dtch - - sdu_length_total - ta_len); - post_padding = 0; - } else { - padding = 0; - - // adjust the header len - if (header_len_dtch == 0) { - header_len_dcch = header_len_dcch_tmp; - } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) - header_len_dtch = header_len_dtch_tmp; - } - - post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header - } + if ((TBS - header_len_dcch - header_len_dtch - + sdu_length_total - ta_len) <= 2) { + padding = + (TBS - header_len_dcch - header_len_dtch - + sdu_length_total - ta_len); + post_padding = 0; + } else { + padding = 0; + + // adjust the header len + if (header_len_dtch == 0) { + header_len_dcch = header_len_dcch_tmp; + } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) + header_len_dtch = header_len_dtch_tmp; + } + + post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header + } #ifdef PHY_TX_THREAD - struct timespec time_req, time_rem; - time_req.tv_sec = 0; - time_req.tv_nsec = 10000; - while((!oai_exit)&&(phy_tx_txdataF_end == 0)){ - nanosleep(&time_req,&time_rem); - continue; - } + struct timespec time_req, time_rem; + time_req.tv_sec = 0; + time_req.tv_nsec = 10000; + + while((!oai_exit)&&(phy_tx_txdataF_end == 0)) { + nanosleep(&time_req,&time_rem); + continue; + } + #endif + offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus + sdu_lengths, // + sdu_lcids, 255, // no drx + ta_update, // timing advance + NULL, // contention res id + padding, post_padding); + + //#ifdef DEBUG_eNB_SCHEDULER + if (ta_update != 31) { + LOG_D(MAC, + "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", + module_idP, frameP, UE_id, CC_id, + sdu_length_total, num_sdus, sdu_lengths[0], + sdu_lcids[0], offset, ta_update, padding, + post_padding, mcs, TBS, nb_rb, + header_len_dcch, header_len_dtch); + } - offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus - sdu_lengths, // - sdu_lcids, 255, // no drx - ta_update, // timing advance - NULL, // contention res id - padding, post_padding); - - //#ifdef DEBUG_eNB_SCHEDULER - if (ta_update != 31) { - LOG_D(MAC, - "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", - module_idP, frameP, UE_id, CC_id, - sdu_length_total, num_sdus, sdu_lengths[0], - sdu_lcids[0], offset, ta_update, padding, - post_padding, mcs, TBS, nb_rb, - header_len_dcch, header_len_dtch); - } - //#endif + //#endif #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n",module_idP ); + LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n",module_idP ); - for (k = 0; k < 16; k++) { - LOG_T(MAC, "%x.", dlsch_buffer[k]); - } + for (k = 0; k < 16; k++) { + LOG_T(MAC, "%x.", dlsch_buffer[k]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif - // cycle through SDUs and place in dlsch_buffer memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset],dlsch_buffer,sdu_length_total); // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); @@ -1676,9 +1685,7 @@ schedule_ue_spec_fairRR(module_id_t module_idP, T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); - - UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; - + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; add_ue_dlsch_info(module_idP, CC_id, UE_id, @@ -1687,13 +1694,11 @@ schedule_ue_spec_fairRR(module_id_t module_idP, // store stats eNB->eNB_stats[CC_id].dlsch_bytes_tx+=sdu_length_total; eNB->eNB_stats[CC_id].dlsch_pdus_tx+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2=mcs; UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; - UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes= TBS- sdu_length_total; UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes+= sdu_length_total; UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes+= TBS; @@ -1704,168 +1709,152 @@ schedule_ue_spec_fairRR(module_id_t module_idP, update_ul_dci(module_idP,CC_id,rnti,UE_list->UE_template[CC_id][UE_id].DAI,subframeP); } - // do PUCCH power control + // do PUCCH power control // this is the normalized RX power - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; /* Unit is not dBm, it's special from nfapi */ - normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30;//(+eNB->measurements.n0_power_dB[0]) - target_rx_power= eNB->puCch10xSnr/10 + 30;//(+eNB->measurements.n0_power_dB[0]) - + normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30;//(+eNB->measurements.n0_power_dB[0]) + target_rx_power= eNB->puCch10xSnr/10 + 30;//(+eNB->measurements.n0_power_dB[0]) // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case - ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { - ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; - - if (normalized_rx_power>(target_rx_power+4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - - LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - module_idP,frameP, subframeP,harq_pid,tpc, - tpc_accumulated,normalized_rx_power,target_rx_power); - - } // Po_PUCCH has been updated - else { - tpc = 1; //0 - } // time to do TPC update - else { - tpc = 1; //0 - } - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),ue_sched_ctl->dl_cqi[CC_id],format1); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; - //deactivate second codeword - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1; - if (cc[CC_id].tdd_Config != NULL) { //TDD - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", - module_idP,CC_id,harq_pid, - (UE_list->UE_template[CC_id][UE_id].DAI-1), - mcs); - } else { - LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", - module_idP,CC_id,harq_pid,mcs); - - } - LOG_D(MAC,"Checking feasibility pdu %d (new sdu)\n",dl_req->number_pdu); - if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,rnti)) { - - - ue_sched_ctl->round[CC_id][harq_pid] = 0; - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; - eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - // Toggle NDI for next time - LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", - CC_id, frameP,subframeP,UE_id, - rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); - - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; - UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated is NULL\n"); - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated!=NULL,"physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); - - fill_nfapi_dlsch_config(eNB,dl_req, - TBS, - eNB->pdu_index[CC_id], - rnti, - 0, // type 0 allocation from 7.1.6 in 36.213 - 0, // virtual_resource_block_assignment_flag, unused here - 0, // resource_block_coding, to be filled in later - getQm(mcs), - 0, // redundancy version - 1, // transport blocks - 0, // transport block to codeword swap flag - cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - // uint8_t codebook_index, - 4, // UE category capacity - UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, - 0, // delta_power_offset for TM5 - 0, // ngap - 0, // nprb - cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode - 0, //number of PRBs treated as one subband, not used here - 0 // number of beamforming vectors, not used here - ); - eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, - (frameP*10)+subframeP, - TBS, - eNB->pdu_index[CC_id], - eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); - - LOG_D(MAC,"Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n",eNB->pdu_index[CC_id]); - - eNB->pdu_index[CC_id]++; - program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - last_dlsch_ue_id[CC_id] = UE_id; - } - else { - LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", - frameP,subframeP,UE_id,rnti); - } - } else { // There is no data from RLC or MAC header, so don't schedule + ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around + if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { + ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; + + if (normalized_rx_power>(target_rx_power+4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power<(target_rx_power-4)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + + LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + module_idP,frameP, subframeP,harq_pid,tpc, + tpc_accumulated,normalized_rx_power,target_rx_power); + } // Po_PUCCH has been updated + else { + tpc = 1; //0 + } // time to do TPC update + else { + tpc = 1; //0 + } + + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),ue_sched_ctl->dl_cqi[CC_id],format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; + //deactivate second codeword + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1; + + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", + module_idP,CC_id,harq_pid, + (UE_list->UE_template[CC_id][UE_id].DAI-1), + mcs); + } else { + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", + module_idP,CC_id,harq_pid,mcs); + } + LOG_D(MAC,"Checking feasibility pdu %d (new sdu)\n",dl_req->number_pdu); + + if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,rnti)) { + ue_sched_ctl->round[CC_id][harq_pid] = 0; + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; + // Toggle NDI for next time + LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", + CC_id, frameP,subframeP,UE_id, + rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated is NULL\n"); + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated!=NULL,"physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); + fill_nfapi_dlsch_config(eNB,dl_req, + TBS, + eNB->pdu_index[CC_id], + rnti, + 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(mcs), + 0, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, + 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, + (frameP*10)+subframeP, + TBS, + eNB->pdu_index[CC_id], + eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); + LOG_D(MAC,"Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n",eNB->pdu_index[CC_id]); + eNB->pdu_index[CC_id]++; + program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + last_dlsch_ue_id[CC_id] = UE_id; + } else { + LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", + frameP,subframeP,UE_id,rnti); + } + } else { // There is no data from RLC or MAC header, so don't schedule } } - if (cc[CC_id].tdd_Config != NULL){ // TDD + if (cc[CC_id].tdd_Config != NULL) { // TDD set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); } - } // UE_id loop } // CC_id loop - fill_DLSCH_dci_fairRR(module_idP,frameP,subframeP,mbsfn_flag); stop_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); - - } //------------------------------------------------------------------------------ void fill_DLSCH_dci_fairRR( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - int* mbsfn_flagP) + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int *mbsfn_flagP) //------------------------------------------------------------------------------ { - // loop over all allocated UEs and compute frequency allocations for PDSCH int UE_id = -1; uint8_t /* first_rb, */ nb_rb=3; @@ -1873,7 +1862,6 @@ fill_DLSCH_dci_fairRR( //unsigned char *vrb_map; uint8_t rballoc_sub[25]; //uint8_t number_of_subbands=13; - //unsigned char round; unsigned char harq_pid; int i; @@ -1899,65 +1887,63 @@ fill_DLSCH_dci_fairRR( // UE specific DCIs for (j = 0; j < dlsch_ue_select[CC_id].ue_num; j++) { - if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG2){ + if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG2) { continue; } - if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG4){ + + if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG4) { continue; } + UE_id = dlsch_ue_select[CC_id].list[j].UE_id; LOG_T(MAC,"CC_id %d, UE_id: %d => status %d\n",CC_id,UE_id,eNB_dlsch_info[module_idP][CC_id][UE_id].status); if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) { - // clear scheduling flag eNB_dlsch_info[module_idP][CC_id][UE_id].status = S_DL_WAITING; rnti = UE_RNTI(module_idP,UE_id); - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - - /// Synchronizing rballoc with rballoc_sub for(i=0; iUE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; } - nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; - nfapi_dl_config_request_pdu_t* dl_config_pdu; - - for (i=0;ipdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& - (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti) && - (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1)) { - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; - } - else if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE)&& - (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti) && - (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type==0)) { - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); - } - } - } + nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + + for (i=0; ipdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& + (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti) && + (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1)) { + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; + } else if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE)&& + (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti) && + (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type==0)) { + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); + } + } } } + } - stop_meas(&eNB->fill_DLSCH_dci); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_OUT); + stop_meas(&eNB->fill_DLSCH_dci); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_OUT); } void ulsch_scheduler_pre_ue_select_fairRR( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - sub_frame_t sched_subframeP, - ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) -{ + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + sub_frame_t sched_subframeP, + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) { eNB_MAC_INST *eNB=RC.mac[module_idP]; COMMON_channels_t *cc; int CC_id,UE_id; @@ -1968,7 +1954,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( uint8_t first_ue_id[MAX_NUM_CCs][20]; uint8_t ul_inactivity_num[MAX_NUM_CCs]; uint8_t ul_inactivity_id[MAX_NUM_CCs][20]; -// LTE_DL_FRAME_PARMS *frame_parms; + // LTE_DL_FRAME_PARMS *frame_parms; uint8_t ulsch_ue_max_num[MAX_NUM_CCs]; uint16_t saved_ulsch_dci[MAX_NUM_CCs]; rnti_t rnti; @@ -1976,127 +1962,134 @@ void ulsch_scheduler_pre_ue_select_fairRR( uint8_t cc_id_flag[MAX_NUM_CCs]; uint8_t harq_pid = 0,round = 0; UE_list_t *UE_list= &eNB->UE_list; - - uint8_t aggregation = 2; int format_flag; nfapi_hi_dci0_request_body_t *HI_DCI0_req; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { - //save ulsch dci number - saved_ulsch_dci[CC_id] = eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body.number_of_dci; - // maximum multiplicity number - ulsch_ue_max_num[CC_id] =RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; - - cc_id_flag[CC_id] = 0; - ue_first_num[CC_id] = 0; - ul_inactivity_num[CC_id] = 0; - + //save ulsch dci number + saved_ulsch_dci[CC_id] = eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body.number_of_dci; + // maximum multiplicity number + ulsch_ue_max_num[CC_id] =RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; + cc_id_flag[CC_id] = 0; + ue_first_num[CC_id] = 0; + ul_inactivity_num[CC_id] = 0; } + // UE round >0 for ( UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++ ) { - if (UE_list->active[UE_id] == FALSE) - continue; + if (UE_list->active[UE_id] == FALSE) + continue; - rnti = UE_RNTI(module_idP,UE_id); - if (rnti ==NOT_A_RNTI) + rnti = UE_RNTI(module_idP,UE_id); + + if (rnti ==NOT_A_RNTI) + continue; + + CC_id = UE_PCCID(module_idP,UE_id); + + if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) + continue; + + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) + continue; + + // UL DCI + HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + + if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { + cc_id_flag[CC_id] = 1; + HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; + ret = cc_id_end(cc_id_flag); + + if ( ret == 0 ) { continue; + } + + if ( ret == 1 ) { + return; + } + } + + cc = &eNB->common_channels[CC_id]; + //harq_pid + harq_pid = subframe2harqpid(cc,(frameP+(sched_subframePUE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]; + + if ( round > 0 ) { + hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; + format_flag = 2; - CC_id = UE_PCCID(module_idP,UE_id); - if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { + cc_id_flag[CC_id] = 1; + continue; + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_RETRANS; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = eNB->UE_list.UE_template[CC_id][UE_id].first_rb_ul[harq_pid]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = eNB->UE_list.UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; + ulsch_ue_select[CC_id].ue_num++; continue; + } + } - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) + // + int bytes_to_schedule = UE_list->UE_template[CC_id][UE_id].estimated_ul_buffer - UE_list->UE_template[CC_id][UE_id].scheduled_ul_bytes; + + if (bytes_to_schedule < 0) bytes_to_schedule = 0; + + if ( UE_id > last_ulsch_ue_id[CC_id] && ((ulsch_ue_select[CC_id].ue_num+ue_first_num[CC_id]) < ulsch_ue_max_num[CC_id]) ) { + if ( bytes_to_schedule > 0 ) { + first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; + first_ue_total[CC_id][ue_first_num[CC_id]] = bytes_to_schedule; + ue_first_num[CC_id]++; continue; + } - // UL DCI - HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; - if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { - cc_id_flag[CC_id] = 1; - HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; - ret = cc_id_end(cc_id_flag); - if ( ret == 0 ) { - continue; - } - if ( ret == 1 ) { - return; - } + if ( UE_list->UE_template[CC_id][UE_id].ul_SR > 0 ) { + first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; + first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; + ue_first_num[CC_id]++; + continue; } - cc = &eNB->common_channels[CC_id]; - //harq_pid - harq_pid = subframe2harqpid(cc,(frameP+(sched_subframePUE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]; + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - if ( round > 0 ) { - hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; - format_flag = 2; - if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - continue; - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_RETRANS; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = eNB->UE_list.UE_template[CC_id][UE_id].first_rb_ul[harq_pid]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = eNB->UE_list.UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; - ulsch_ue_select[CC_id].ue_num++; - continue; - } + if ( ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { + first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; + first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; + ue_first_num[CC_id]++; + continue; } - // - int bytes_to_schedule = UE_list->UE_template[CC_id][UE_id].estimated_ul_buffer - UE_list->UE_template[CC_id][UE_id].scheduled_ul_bytes; - if (bytes_to_schedule < 0) bytes_to_schedule = 0; - if ( UE_id > last_ulsch_ue_id[CC_id] && ((ulsch_ue_select[CC_id].ue_num+ue_first_num[CC_id]) < ulsch_ue_max_num[CC_id]) ) { - if ( bytes_to_schedule > 0 ) { - first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; - first_ue_total[CC_id][ue_first_num[CC_id]] = bytes_to_schedule; - ue_first_num[CC_id]++; - continue; - } - if ( UE_list->UE_template[CC_id][UE_id].ul_SR > 0 ) { - first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; - first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; - ue_first_num[CC_id]++; - continue; - } - UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - if ( ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + /*if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id] ) < ulsch_ue_max_num[CC_id] ) { + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + uint8_t ul_period = 0; + if (cc->tdd_Config) { + ul_period = 50; + } else { + ul_period = 20; + } + if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { - first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; - first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; - ue_first_num[CC_id]++; + ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; + ul_inactivity_num[CC_id] ++; continue; } - /*if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id] ) < ulsch_ue_max_num[CC_id] ) { - UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - uint8_t ul_period = 0; - if (cc->tdd_Config) { - ul_period = 50; - } else { - ul_period = 20; - } - if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || - ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { - ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; - ul_inactivity_num[CC_id] ++; - continue; - } - }*/ - } - + }*/ + } } for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + for ( int temp = 0; temp < ue_first_num[CC_id]; temp++ ) { if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { cc_id_flag[CC_id] = 1; @@ -2107,113 +2100,121 @@ void ulsch_scheduler_pre_ue_select_fairRR( hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; format_flag = 2; rnti = UE_RNTI(module_idP,first_ue_id[CC_id][temp]); + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - break; + cc_id_flag[CC_id] = 1; + break; } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = first_ue_total[CC_id][temp]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = first_ue_id[CC_id][temp]; - ulsch_ue_select[CC_id].ue_num++; + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = first_ue_total[CC_id][temp]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = first_ue_id[CC_id][temp]; + ulsch_ue_select[CC_id].ue_num++; } } } for ( UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++ ) { if (UE_list->active[UE_id] == FALSE) - continue; + continue; rnti = UE_RNTI(module_idP,UE_id); + if (rnti ==NOT_A_RNTI) - continue; + continue; CC_id = UE_PCCID(module_idP,UE_id); if (UE_id > last_ulsch_ue_id[CC_id]) - continue; + continue; if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) - continue; + continue; if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) - continue; + continue; if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { - cc_id_flag[CC_id] = 1; - HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; - ret = cc_id_end(cc_id_flag); - if ( ret == 0 ) { - continue; - } - if ( ret == 1 ) { - return; - } + cc_id_flag[CC_id] = 1; + HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; + ret = cc_id_end(cc_id_flag); + + if ( ret == 0 ) { + continue; + } + + if ( ret == 1 ) { + return; + } } - for(i = 0;iHI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; //SR BSR - UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; int bytes_to_schedule = UE_list->UE_template[CC_id][UE_id].estimated_ul_buffer - UE_list->UE_template[CC_id][UE_id].scheduled_ul_bytes; + if (bytes_to_schedule < 0) bytes_to_schedule = 0; if ( (bytes_to_schedule > 0) || (UE_list->UE_template[CC_id][UE_id].ul_SR > 0) || - ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || - ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED)) ){ - hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; - format_flag = 2; - if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - continue; - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; - if(bytes_to_schedule > 0) - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = bytes_to_schedule; - else if(UE_list->UE_template[CC_id][UE_id].ul_SR > 0) - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; - ulsch_ue_select[CC_id].ue_num++; - continue; - } + ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED)) ) { + hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; + format_flag = 2; + + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { + cc_id_flag[CC_id] = 1; + continue; + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; + + if(bytes_to_schedule > 0) + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = bytes_to_schedule; + else if(UE_list->UE_template[CC_id][UE_id].ul_SR > 0) + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; + + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; + ulsch_ue_select[CC_id].ue_num++; + continue; + } } + //inactivity UE -/* if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id]) < ulsch_ue_max_num[CC_id] ) { - UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - uint8_t ul_period = 0; - if (cc->tdd_Config) { - ul_period = 50; - } else { - ul_period = 20; - } - if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || - ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { - ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; - ul_inactivity_num[CC_id]++; - continue; - } - }*/ + /* if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id]) < ulsch_ue_max_num[CC_id] ) { + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + uint8_t ul_period = 0; + if (cc->tdd_Config) { + ul_period = 50; + } else { + ul_period = 20; + } + if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || + ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { + ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; + ul_inactivity_num[CC_id]++; + continue; + } + }*/ } for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + for ( int temp = 0; temp < ul_inactivity_num[CC_id]; temp++ ) { if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; @@ -2224,43 +2225,45 @@ void ulsch_scheduler_pre_ue_select_fairRR( hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; format_flag = 2; rnti = UE_RNTI(module_idP,ul_inactivity_id[CC_id][temp]); + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - continue; + cc_id_flag[CC_id] = 1; + continue; } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_INACTIVE; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = ul_inactivity_id[CC_id][temp]; - ulsch_ue_select[CC_id].ue_num++; + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_INACTIVE; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = ul_inactivity_id[CC_id][temp]; + ulsch_ue_select[CC_id].ue_num++; } } + HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; } + return; } -uint8_t find_rb_table_index(uint8_t average_rbs) -{ +uint8_t find_rb_table_index(uint8_t average_rbs) { int i; + for ( i = 0; i < 34; i++ ) { if ( rb_table[i] > average_rbs ) { return (i-1); } } + return i; } void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - sub_frame_t sched_subframeP, - ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) -{ + frame_t frameP, + sub_frame_t subframeP, + sub_frame_t sched_subframeP, + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) { int CC_id,ulsch_ue_num; eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_list_t *UE_list= &eNB->UE_list; @@ -2285,26 +2288,27 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { cc = &RC.mac[module_idP]->common_channels[CC_id]; frame_parms = &(RC.eNB[module_idP][CC_id]->frame_parms); + if (cc->tdd_Config) { //TDD if (frame_parms->N_RB_UL == 25) { - num_pucch_rb = 1; + num_pucch_rb = 1; } else if (frame_parms->N_RB_UL == 50) { - num_pucch_rb = 2; + num_pucch_rb = 2; } else { - num_pucch_rb = 3; + num_pucch_rb = 3; } } else {//FDD if (frame_parms->N_RB_UL == 25) { - num_pucch_rb = 1; + num_pucch_rb = 1; } else { - num_pucch_rb = 2; + num_pucch_rb = 2; } } first_rb[CC_id] = num_pucch_rb; ue_num_temp = ulsch_ue_select[CC_id].ue_num; - for ( ulsch_ue_num = 0; ulsch_ue_num < ulsch_ue_select[CC_id].ue_num; ulsch_ue_num++ ) { + for ( ulsch_ue_num = 0; ulsch_ue_num < ulsch_ue_select[CC_id].ue_num; ulsch_ue_num++ ) { UE_id = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_MSG3) { @@ -2319,52 +2323,59 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, continue; } - if (first_rb[CC_id] >= frame_parms->N_RB_UL-num_pucch_rb ) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,UE_RNTI(CC_id,UE_id),CC_id); - break; + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,UE_RNTI(CC_id,UE_id),CC_id); + break; } - total_rbs = frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id]; + total_rbs = frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id]; average_rbs = (int)round((double)total_rbs/(double)ue_num_temp); + if ( average_rbs < 3 ) { ue_num_temp--; ulsch_ue_num--; ulsch_ue_select[CC_id].ue_num--; continue; } + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS ) { if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb <= average_rbs ) { - // assigne RBS(nb_rb) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + // assigne RBS(nb_rb) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; } + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb > average_rbs ) { if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb <= total_rbs ) { - // assigne RBS(average_rbs) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + // assigne RBS(average_rbs) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; } else { - // assigne RBS(remain rbs) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - rb_table_index = 2; - while(rb_table[rb_table_index] <= total_rbs){ - rb_table_index++; - } - ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb = rb_table[rb_table_index-1]; - first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index-1]; + // assigne RBS(remain rbs) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + rb_table_index = 2; + + while(rb_table[rb_table_index] <= total_rbs) { + rb_table_index++; + } + + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb = rb_table[rb_table_index-1]; + first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index-1]; } } - }else{ + } else { UE_template = &UE_list->UE_template[CC_id][UE_id]; + if ( UE_list->UE_sched_ctrl[UE_id].phr_received == 1 ) { mcs = 20; } else { mcs = 10; } + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST ) { int bytes_to_schedule = UE_template->estimated_ul_buffer - UE_template->scheduled_ul_bytes; + if (bytes_to_schedule < 0) bytes_to_schedule = 0; if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ul_total_buffer > 0 ) { @@ -2379,7 +2390,7 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, } while ( (tbs < bytes_to_schedule) && (rb_table[rb_table_index]<(frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id])) && - ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { + ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { rb_table_index++; tbs = get_TBS_UL(mcs,rb_table[rb_table_index])<<3; tx_power= estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); @@ -2388,6 +2399,7 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, if ( rb_table[rb_table_index]<3 ) { rb_table_index=2; } + if ( rb_table[rb_table_index] <= average_rbs ) { // assigne RBS( nb_rb) first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index]; @@ -2395,27 +2407,30 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = rb_table_index; UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = mcs; } + if ( rb_table[rb_table_index] > average_rbs ) { // assigne RBS(average_rbs) rb_table_index = find_rb_table_index(average_rbs); - if (rb_table_index>=34){ - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: average RBs %d > 100\n", - module_idP,frameP,subframeP,UE_id,UE_RNTI(CC_id,UE_id),CC_id,average_rbs); - break; + + if (rb_table_index>=34) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: average RBs %d > 100\n", + module_idP,frameP,subframeP,UE_id,UE_RNTI(CC_id,UE_id),CC_id,average_rbs); + break; } + first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index]; UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[0] = rb_table[rb_table_index]; UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = rb_table_index; UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = mcs; } - }else { + } else { // assigne RBS( 3 RBs) first_rb[CC_id] = first_rb[CC_id] + 3; UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[0] = 3; UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = 2; UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; } - }else if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE ) { + } else if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE ) { // assigne RBS( 3 RBs) first_rb[CC_id] = first_rb[CC_id] + 3; UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[0] = 3; @@ -2423,6 +2438,7 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; } } + ue_num_temp--; } } @@ -2431,105 +2447,126 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, void schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, - sub_frame_t subframeP) -{ + sub_frame_t subframeP) { uint16_t i; int CC_id; eNB_MAC_INST *mac = RC.mac[module_idP]; COMMON_channels_t *cc; int sched_frame=frameP; - start_meas(&mac->schedule_ulsch); - int sched_subframe = (subframeP+4)%10; - cc = &mac->common_channels[0]; int tdd_sfa; + // for TDD: check subframes where we have to act and return if nothing should be done now if (cc->tdd_Config) { tdd_sfa = cc->tdd_Config->subframeAssignment; + switch (subframeP) { - case 0: - if ((tdd_sfa == 0)|| - (tdd_sfa == 3)) sched_subframe = 4; - else if (tdd_sfa==6) sched_subframe = 7; - else return; - break; - case 1: - if ((tdd_sfa==0)|| - (tdd_sfa==1)) sched_subframe = 7; - else if (tdd_sfa==6) sched_subframe = 8; - else return; - break; - case 2: // Don't schedule UL in subframe 2 for TDD - return; - case 3: - if (tdd_sfa==2) sched_subframe = 7; - else return; - break; - case 4: - if (tdd_sfa==1) sched_subframe = 8; - else return; - break; - case 5: - if (tdd_sfa==0) sched_subframe = 9; - else if (tdd_sfa==6) sched_subframe = 2; - else return; - break; - case 6: - if (tdd_sfa==0 || tdd_sfa==1) sched_subframe = 2; - else if (tdd_sfa==6) sched_subframe = 3; - else return; - break; - case 7: - return; - case 8: - if ((tdd_sfa>=2) && (tdd_sfa<=5)) sched_subframe=2; - else return; - break; - case 9: - if ((tdd_sfa==1) || (tdd_sfa==3) || (tdd_sfa==4)) sched_subframe=3; - else if (tdd_sfa==6) sched_subframe=4; - else return; - break; + case 0: + if ((tdd_sfa == 0)|| + (tdd_sfa == 3)) sched_subframe = 4; + else if (tdd_sfa==6) sched_subframe = 7; + else return; + + break; + + case 1: + if ((tdd_sfa==0)|| + (tdd_sfa==1)) sched_subframe = 7; + else if (tdd_sfa==6) sched_subframe = 8; + else return; + + break; + + case 2: // Don't schedule UL in subframe 2 for TDD + return; + + case 3: + if (tdd_sfa==2) sched_subframe = 7; + else return; + + break; + + case 4: + if (tdd_sfa==1) sched_subframe = 8; + else return; + + break; + + case 5: + if (tdd_sfa==0) sched_subframe = 9; + else if (tdd_sfa==6) sched_subframe = 2; + else return; + + break; + + case 6: + if (tdd_sfa==0 || tdd_sfa==1) sched_subframe = 2; + else if (tdd_sfa==6) sched_subframe = 3; + else return; + + break; + + case 7: + return; + + case 8: + if ((tdd_sfa>=2) && (tdd_sfa<=5)) sched_subframe=2; + else return; + + break; + + case 9: + if ((tdd_sfa==1) || (tdd_sfa==3) || (tdd_sfa==4)) sched_subframe=3; + else if (tdd_sfa==6) sched_subframe=4; + else return; + + break; } } + if (sched_subframe < subframeP) sched_frame++; + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]; memset(ulsch_ue_select, 0, sizeof(ulsch_ue_select)); - LTE_DL_FRAME_PARMS *frame_parms ; for (CC_id=0; CC_idcommon_channels[CC_id]; frame_parms= &RC.eNB[module_idP][CC_id]->frame_parms; + // output of scheduling, the UE numbers in RBs, where it is in the code??? // check if RA (Msg3) is active in this subframeP, if so skip the PRBs used for Msg3 // Msg3 is using 1 PRB so we need to increase first_rb accordingly // not sure about the break (can there be more than 1 active RA procedure?) for (i=0; ira[i].state == WAITMSG3) &&(cc->ra[i].Msg3_subframe == sched_subframe)) { + if ((cc->ra[i].state == WAITMSG3) &&(cc->ra[i].Msg3_subframe == sched_subframe)) { ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_MSG3; + if (cc->tdd_Config == NULL) { - if(frame_parms->N_RB_UL == 25){ - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; - }else{ - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; - } + if(frame_parms->N_RB_UL == 25) { + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; + } else { + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; + } } else { - switch(frame_parms->N_RB_UL){ + switch(frame_parms->N_RB_UL) { case 25: default: ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; break; + case 50: ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; break; + case 100: ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 3; break; - } + } } + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = 1; ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = -1; ulsch_ue_select[CC_id].ue_num++; @@ -2541,11 +2578,11 @@ schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, if (is_prach_subframe(frame_parms,sched_frame,sched_subframe)==1) { ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_PRACH; ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = get_prach_prb_offset( - frame_parms, - frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset, - 0,//tdd_mapindex - frameP); //Nf + frame_parms, + frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset, + 0,//tdd_mapindex + frameP); //Nf ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = 6; ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = -1; ulsch_ue_select[CC_id].ue_num++; @@ -2557,11 +2594,10 @@ schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, } void schedule_ulsch_rnti_fairRR(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframeP, - ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) -{ + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) { int16_t UE_id; uint8_t aggregation = 2; uint16_t first_rb[MAX_NUM_CCs]; @@ -2570,7 +2606,7 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, uint8_t round = 0; uint8_t harq_pid = 0; uint8_t status = 0; - uint8_t rb_table_index = -1; + uint8_t rb_table_index = -1; uint32_t cqi_req,cshift,ndi,tpc; int32_t normalized_rx_power; int32_t target_rx_power=-90; @@ -2586,99 +2622,102 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, int rvidx_tab[4] = {0,2,3,1}; uint16_t ul_req_index; uint8_t dlsch_flag; + if (sched_subframeP < subframeP) sched_frame++; nfapi_hi_dci0_request_body_t *hi_dci0_req; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - nfapi_ul_config_request_body_t *ul_req_tmp; nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; LOG_D(MAC,"entering ulsch preprocesor\n"); ulsch_scheduler_pre_processor_fairRR(module_idP, - frameP, - subframeP, - sched_subframeP, - ulsch_ue_select); - + frameP, + subframeP, + sched_subframeP, + ulsch_ue_select); LOG_D(MAC,"exiting ulsch preprocesor\n"); - - // loop over all active UEs for (CC_id=0; CC_idHI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; - eNB->HI_DCI0_req[CC_id][subframeP].sfn_sf = (frameP<<4)+subframeP; - ul_req_tmp = &eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body; - nfapi_ul_config_request_t *ul_req = &eNB->UL_req_tmp[CC_id][sched_subframeP]; - + hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + eNB->HI_DCI0_req[CC_id][subframeP].sfn_sf = (frameP<<4)+subframeP; + ul_req_tmp = &eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body; + nfapi_ul_config_request_t *ul_req = &eNB->UL_req_tmp[CC_id][sched_subframeP]; ULSCH_first_end = 0; cc = &eNB->common_channels[CC_id]; // This is the actual CC_id in the list N_RB_UL = to_prb(cc->mib->message.dl_Bandwidth); + //leave out first RB for PUCCH if (cc->tdd_Config == NULL) { - if(N_RB_UL == 25){ - first_rb[CC_id] = 1; - }else{ - first_rb[CC_id] = 2; - } - }else { - switch(N_RB_UL){ + if(N_RB_UL == 25) { + first_rb[CC_id] = 1; + } else { + first_rb[CC_id] = 2; + } + } else { + switch(N_RB_UL) { case 25: default: - first_rb[CC_id] = 1; + first_rb[CC_id] = 1; break; + case 50: - first_rb[CC_id] = 2; + first_rb[CC_id] = 2; break; + case 100: - first_rb[CC_id] = 3; + first_rb[CC_id] = 3; break; - } + } } + for ( ulsch_ue_num = 0; ulsch_ue_num < ulsch_ue_select[CC_id].ue_num; ulsch_ue_num++ ) { UE_id = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; + /* be sure that there are some free RBs */ - if (cc->tdd_Config == NULL){ - if(N_RB_UL == 25){ - if (first_rb[CC_id] >= N_RB_UL-1) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - break; - } - }else{ - if (first_rb[CC_id] >= N_RB_UL-2) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - break; - } + if (cc->tdd_Config == NULL) { + if(N_RB_UL == 25) { + if (first_rb[CC_id] >= N_RB_UL-1) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + break; + } + } else { + if (first_rb[CC_id] >= N_RB_UL-2) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + break; } + } } else { - if(N_RB_UL == 25){ - if (first_rb[CC_id] >= N_RB_UL-1) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); - break; - } - }else if(N_RB_UL == 50){ - if (first_rb[CC_id] >= N_RB_UL-2) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); - break; - } - }else if(N_RB_UL == 100){ - if (first_rb[CC_id] >= N_RB_UL-3) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); - break; - } + if(N_RB_UL == 25) { + if (first_rb[CC_id] >= N_RB_UL-1) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); + break; } + } else if(N_RB_UL == 50) { + if (first_rb[CC_id] >= N_RB_UL-2) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); + break; + } + } else if(N_RB_UL == 100) { + if (first_rb[CC_id] >= N_RB_UL-3) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); + break; + } + } } + //MSG3 if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_MSG3) { first_rb[CC_id] ++; continue; } + //PRACH if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_PRACH) { first_rb[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb+ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; @@ -2691,376 +2730,389 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, rnti = UE_RNTI(CC_id,UE_id); LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", module_idP,frameP,subframeP,harq_pid,UE_id,rnti,CC_id, aggregation,N_RB_UL); - int bytes_to_schedule = UE_template->estimated_ul_buffer - UE_template->scheduled_ul_bytes; + if (bytes_to_schedule < 0) bytes_to_schedule = 0; RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = bytes_to_schedule; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]); - 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; - // To be safe , do not ask CQI in special SFs:36.213/7.2.3 CQI definition - if (cc->tdd_Config) { - switch (cc->tdd_Config->subframeAssignment) { - case 1: - if( subframeP == 1 || subframeP == 6 ) cqi_req=0; - break; - case 3: - if( subframeP == 1 ) cqi_req=0; - break; - default: - LOG_E(MAC," TDD config not supported\n"); - break; - } - } - if(cqi_req == 1){ - UE_sched_ctrl->cqi_req_timer=0; - UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; - } - } - else + cqi_req = 1; + + // To be safe , do not ask CQI in special SFs:36.213/7.2.3 CQI definition + if (cc->tdd_Config) { + switch (cc->tdd_Config->subframeAssignment) { + case 1: + if( subframeP == 1 || subframeP == 6 ) cqi_req=0; + + break; + + case 3: + if( subframeP == 1 ) cqi_req=0; + + break; + + default: + LOG_E(MAC," TDD config not supported\n"); + break; + } + } + + if(cqi_req == 1) { + UE_sched_ctrl->cqi_req_timer=0; + UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; + } + } 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 = (5*UE_sched_ctrl->pusch_snr[CC_id]-640)/10+30; //(+eNB->measurements.n0_power_dB[0]) target_rx_power= eNB->puSch10xSnr/10 + 30; //(+eNB->measurements.n0_power_dB[0]) - // 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+4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } + ((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+4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power<(target_rx_power-4)) { + tpc = 2; //+1 + tpc_accumulated++; } 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", + } 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 ((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) || + (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE)) { + LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x (SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", + module_idP,harq_pid,frameP,subframeP,UE_id,rnti,UE_template->ul_SR, + UE_sched_ctrl->ul_inactivity_timer, + UE_sched_ctrl->ul_failure_timer, + UE_sched_ctrl->cqi_req_timer); + 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; + UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + + if (UE_template->pre_allocated_rb_table_index_ul >=0) { + rb_table_index=UE_template->pre_allocated_rb_table_index_ul; + } else { + UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); + rb_table_index=5; // for PHR } - // new transmission - if ((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) || - (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE)) { - LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x (SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", - module_idP,harq_pid,frameP,subframeP,UE_id,rnti,UE_template->ul_SR, - UE_sched_ctrl->ul_inactivity_timer, - UE_sched_ctrl->ul_failure_timer, - UE_sched_ctrl->cqi_req_timer); - - 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; - UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS - if (UE_template->pre_allocated_rb_table_index_ul >=0) { - rb_table_index=UE_template->pre_allocated_rb_table_index_ul; - } else { - UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); - rb_table_index=5; // for PHR - } - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid]; - - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],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=UE_template->TBS_UL[harq_pid]; - - 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(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); - - if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) - LOG_D(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,UE_template->mcs_UL[harq_pid], - first_rb[CC_id],rb_table[rb_table_index], - rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; - UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; - - 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,UE_template->TBS_UL[harq_pid]); - if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid]) - UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid]; - 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) - // save it for a potential retransmission - UE_template->cshift[harq_pid] = cshift; - - hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; - memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; - - hi_dci0_req->number_of_dci++; - hi_dci0_req->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4) - hi_dci0_req->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - nfapi_hi_dci0_request_t *nfapi_hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP]; - nfapi_hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! - nfapi_hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); - - ul_req_index = 0; - dlsch_flag = 0; - for(ul_req_index = 0;ul_req_index < ul_req_tmp->number_of_pdus;ul_req_index++){ - if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && - (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ - dlsch_flag = 1; - LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); - break; - } - } - // Add UL_config PDUs - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - first_rb[CC_id], // resource_block_start - rb_table[rb_table_index], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - ndi, // new_data_indication - 0, // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - get_TBS_UL(UE_template->mcs_UL[harq_pid], - rb_table[rb_table_index]) - ); + + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid]; + UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],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=UE_template->TBS_UL[harq_pid]; + 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(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), + T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); + + if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) + LOG_D(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,UE_template->mcs_UL[harq_pid], + first_rb[CC_id],rb_table[rb_table_index], + rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; + UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; + 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,UE_template->TBS_UL[harq_pid]); + if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid]) + UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid]; + 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) + // save it for a potential retransmission + UE_template->cshift[harq_pid] = cshift; + hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; + memset((void *)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; + hi_dci0_req->number_of_dci++; + hi_dci0_req->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4) + hi_dci0_req->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + nfapi_hi_dci0_request_t *nfapi_hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP]; + nfapi_hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! + nfapi_hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + + for(ul_req_index = 0; ul_req_index < ul_req_tmp->number_of_pdus; ul_req_index++) { + if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && + (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) { + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } + + // Add UL_config PDUs + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], + cqi_req, + cc, + UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + first_rb[CC_id], // resource_block_start + rb_table[rb_table_index], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL(UE_template->mcs_UL[harq_pid], + rb_table[rb_table_index]) + ); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], - UE_template->rach_resource_type>2 ? 2 : 1, - 1, //total_number_of_repetitions - 1, //repetition_number - (frameP*10)+subframeP); - } + + if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], + UE_template->rach_resource_type>2 ? 2 : 1, + 1, //total_number_of_repetitions + 1, //repetition_number + (frameP*10)+subframeP); + } + #endif - if(dlsch_flag == 1){ - if(cqi_req == 1){ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; - - }else{ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; - } - fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - }else{ - ul_req_tmp->number_of_pdus++; - } - eNB->ul_handle++; - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - uint16_t ul_sched_frame = sched_frame; - uint16_t ul_sched_subframeP = sched_subframeP; - add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); - ul_req->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; - - 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); - - // increment first rb for next UE allocation - first_rb[CC_id]+=rb_table[rb_table_index]; - if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) { - UE_template->scheduled_ul_bytes += get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); - UE_template->ul_SR = 0; - } - if((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE) && (ULSCH_first_end == 0)) { - ULSCH_first_end = 1; - last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num-1].UE_id; - } - if((ulsch_ue_num == ulsch_ue_select[CC_id].ue_num-1) && (ULSCH_first_end == 0)) { - ULSCH_first_end = 1; - last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; - } + + if(dlsch_flag == 1) { + if(cqi_req == 1) { + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag= + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + } else { + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; } - else if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS) { // round > 0 => retransmission - 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(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(round)); - - round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; - 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; - uint8_t mcs_rv = 0; - if(rvidx_tab[round&3]==1){ - mcs_rv = 29; - }else if(rvidx_tab[round&3]==2){ - mcs_rv = 30; - }else if(rvidx_tab[round&3]==3){ - mcs_rv = 31; - } - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb); - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; - - - if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) - LOG_D(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_rv,first_rb[CC_id],rb_table[rb_table_index],rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - UE_template->first_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; - - UE_sched_ctrl->ul_scheduled |= (1<hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; - memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs_rv; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = UE_template->oldNDI_UL[harq_pid]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; - - hi_dci0_req->number_of_dci++; - // Add UL_config PDUs - LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); - ul_req_index = 0; - dlsch_flag = 0; - for(ul_req_index = 0;ul_req_index < ul_req_tmp->number_of_pdus;ul_req_index++){ - if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && - (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ - dlsch_flag = 1; - LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(phich)\n",frameP,subframeP,rnti,ul_req_index); - break; - } - } - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb, // resource_block_start - ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb, // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round&3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - UE_template->TBS_UL[harq_pid] - ); + + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); + } else { + ul_req_tmp->number_of_pdus++; + } + + eNB->ul_handle++; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + uint16_t ul_sched_frame = sched_frame; + uint16_t ul_sched_subframeP = sched_subframeP; + add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); + ul_req->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; + 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); + // increment first rb for next UE allocation + first_rb[CC_id]+=rb_table[rb_table_index]; + + if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) { + UE_template->scheduled_ul_bytes += get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); + UE_template->ul_SR = 0; + } + + if((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE) && (ULSCH_first_end == 0)) { + ULSCH_first_end = 1; + last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num-1].UE_id; + } + + if((ulsch_ue_num == ulsch_ue_select[CC_id].ue_num-1) && (ULSCH_first_end == 0)) { + ULSCH_first_end = 1; + last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; + } + } else if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS) { // round > 0 => retransmission + 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(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), + T_INT(round)); + round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; + 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; + uint8_t mcs_rv = 0; + + if(rvidx_tab[round&3]==1) { + mcs_rv = 29; + } else if(rvidx_tab[round&3]==2) { + mcs_rv = 30; + } else if(rvidx_tab[round&3]==3) { + mcs_rv = 31; + } + + UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb); + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; + + if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) + LOG_D(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_rv,first_rb[CC_id],rb_table[rb_table_index],rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + UE_template->first_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; + UE_sched_ctrl->ul_scheduled |= (1<hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; + memset((void *)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs_rv; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = UE_template->oldNDI_UL[harq_pid]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; + hi_dci0_req->number_of_dci++; + // Add UL_config PDUs + LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + + for(ul_req_index = 0; ul_req_index < ul_req_tmp->number_of_pdus; ul_req_index++) { + if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && + (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) { + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(phich)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } + + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], + cqi_req, + cc, + UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb, // resource_block_start + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb, // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round&3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + UE_template->TBS_UL[harq_pid] + ); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], - UE_template->rach_resource_type>2 ? 2 : 1, - 1, //total_number_of_repetitions - 1, //repetition_number - (frameP*10)+subframeP); - } -#endif - if(dlsch_flag == 1){ - if(cqi_req == 1){ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - - }else{ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - } - fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - }else{ - ul_req_tmp->number_of_pdus++; - } - eNB->ul_handle++; - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - ul_req->sfn_sf = sched_frame<<4|sched_subframeP; - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0(round >0)\n", module_idP,CC_id,frameP,subframeP,UE_id); + if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], + UE_template->rach_resource_type>2 ? 2 : 1, + 1, //total_number_of_repetitions + 1, //repetition_number + (frameP*10)+subframeP); + } + +#endif - // increment first rb for next UE allocation - first_rb[CC_id]+=ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + if(dlsch_flag == 1) { + if(cqi_req == 1) { + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag= + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + } else { + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; } + + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); + } else { + ul_req_tmp->number_of_pdus++; + } + + eNB->ul_handle++; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req->sfn_sf = sched_frame<<4|sched_subframeP; + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0(round >0)\n", module_idP,CC_id,frameP,subframeP,UE_id); + // increment first rb for next UE allocation + first_rb[CC_id]+=ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + } } // loop over UE_id } // loop of CC_id } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 997877d7a8..e67ddb6aae 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -51,7 +51,7 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "ENB_APP/flexran_agent_defs.h" @@ -76,10 +76,10 @@ extern int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req); extern uint8_t nfapi_mode; // This table holds the allowable PRB sizes for ULSCH transmissions -uint8_t rb_table[34] = - { 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, 64, 72, 75, 80, 81, 90, 96, 100 - }; +uint8_t rb_table[34] = { + 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, 64, 72, 75, 80, 81, 90, 96, 100 +}; extern mui_t rrc_eNB_mui; @@ -89,10 +89,9 @@ rx_sdu(const module_id_t enb_mod_idP, const frame_t frameP, const sub_frame_t subframeP, const rnti_t rntiP, - uint8_t * sduP, + uint8_t *sduP, const uint16_t sdu_lenP, - const uint16_t timing_advance, const uint8_t ul_cqi) -{ + const uint16_t timing_advance, const uint8_t ul_cqi) { int current_rnti = rntiP; unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; @@ -104,15 +103,12 @@ rx_sdu(const module_id_t enb_mod_idP, int harq_pid = subframe2harqpid(&mac->common_channels[CC_idP], frameP, subframeP); int lcgid_updated[4] = {0, 0, 0, 0}; - UE_list_t *UE_list = &mac->UE_list; int crnti_rx = 0; RA_t *ra = (RA_t *) & RC.mac[enb_mod_idP]->common_channels[CC_idP].ra[0]; int first_rb = 0; - rrc_eNB_ue_context_t *ue_contextP = NULL; - start_meas(&mac->rx_ulsch_sdu); if ((UE_id > MAX_MOBILES_PER_ENB) || (UE_id == -1)) @@ -121,23 +117,24 @@ rx_sdu(const module_id_t enb_mod_idP, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1); + (VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1); + if (opt_enabled == 1) { trace_pdu(DIRECTION_UPLINK, sduP, sdu_lenP, 0, WS_C_RNTI, current_rnti, frameP, subframeP, - 0, 0); + 0, 0); LOG_D(OPT, "[eNB %d][ULSCH] Frame %d rnti %x with size %d\n", - enb_mod_idP, frameP, current_rnti, sdu_lenP); + enb_mod_idP, frameP, current_rnti, sdu_lenP); } if (UE_id != -1) { LOG_D(MAC, - "[eNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n", - enb_mod_idP, harq_pid, CC_idP,frameP,subframeP, - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], - current_rnti, UE_id, ul_cqi); - + "[eNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP,frameP,subframeP, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], + current_rnti, UE_id, ul_cqi); AssertFatal(UE_list->UE_sched_ctrl[UE_id]. - round_UL[CC_idP][harq_pid] < 8, "round >= 8\n"); + round_UL[CC_idP][harq_pid] < 8, "round >= 8\n"); + if (sduP != NULL) { UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; @@ -147,58 +144,60 @@ rx_sdu(const module_id_t enb_mod_idP, * lte_est_timing_advance_pusch, maybe it's not necessary? * maybe it's even not correct at all? */ - UE_list->UE_sched_ctrl[UE_id].ta_update = (UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + timing_advance) / 4; + UE_list->UE_sched_ctrl[UE_id].ta_update = (UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + timing_advance) / 4; UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors = 0; first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; 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, UE_RNTI(enb_mod_idP, - UE_id)); + 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)); } /* update scheduled bytes */ UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes -= UE_list->UE_template[CC_idP][UE_id].TBS_UL[harq_pid]; + if (UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes < 0) UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes = 0; - } else { // we've got an error + } else { // we've got an error LOG_I(MAC, - "[eNB %d][PUSCH %d] CC_id %d %d.%d ULSCH in error in round %d, ul_cqi %d\n", - enb_mod_idP, harq_pid, CC_idP,frameP,subframeP, - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], - ul_cqi); + "[eNB %d][PUSCH %d] CC_id %d %d.%d ULSCH in error in round %d, ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP,frameP,subframeP, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], + ul_cqi); - if(ul_cqi>200){ // too high energy pattern + if(ul_cqi>200) { // too high energy pattern UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; } // AssertFatal(1==0,"ulsch in error\n"); if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] == 3) { - UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1 << harq_pid)); - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; - if (UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors++ == 10) - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; + UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1 << harq_pid)); + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; + + if (UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors++ == 10) + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; /* update scheduled bytes */ UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes -= UE_list->UE_template[CC_idP][UE_id].TBS_UL[harq_pid]; + if (UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes < 0) UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes = 0; if (find_RA_id(enb_mod_idP, CC_idP, current_rnti) != -1) cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); } else - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; - // Program NACK for PHICH LOG_D(MAC, - "Programming PHICH NACK for rnti %x harq_pid %d (first_rb %d)\n", - current_rnti, harq_pid, first_rb); + "Programming PHICH NACK for rnti %x harq_pid %d (first_rb %d)\n", + current_rnti, harq_pid, first_rb); nfapi_hi_dci0_request_t *hi_dci0_req; - uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP] , subframeP); + uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP); hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP+sf_ahead_dl)%10]; nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = @@ -215,64 +214,59 @@ rx_sdu(const module_id_t enb_mod_idP, hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP,subframeP, sf_ahead_dl); hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - return; - } - } else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti + } else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti AssertFatal(mac->common_channels[CC_idP]. - radioResourceConfigCommon->rach_ConfigCommon. - maxHARQ_Msg3Tx > 1, - "maxHARQ %d should be greater than 1\n", - (int) mac->common_channels[CC_idP]. - radioResourceConfigCommon->rach_ConfigCommon. - maxHARQ_Msg3Tx); - + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx > 1, + "maxHARQ %d should be greater than 1\n", + (int) mac->common_channels[CC_idP]. + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx); LOG_D(MAC, - "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n", - enb_mod_idP, harq_pid, CC_idP, ra[RA_id].msg3_round, - current_rnti, RA_id, ul_cqi); - + "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP, ra[RA_id].msg3_round, + current_rnti, RA_id, ul_cqi); first_rb = ra->msg3_first_rb; - if (sduP == NULL) { // we've got an error on Msg3 + if (sduP == NULL) { // we've got an error on Msg3 LOG_D(MAC, - "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n", - enb_mod_idP, CC_idP, RA_id, - ra[RA_id].msg3_round, - (int) mac->common_channels[CC_idP]. - radioResourceConfigCommon->rach_ConfigCommon. - maxHARQ_Msg3Tx); - if (ra[RA_id].msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { - cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); - } + "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n", + enb_mod_idP, CC_idP, RA_id, + ra[RA_id].msg3_round, + (int) mac->common_channels[CC_idP]. + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx); - else { - first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; - ra[RA_id].msg3_round++; - // prepare handling of retransmission + if (ra[RA_id].msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { + cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); + } else { + first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; + ra[RA_id].msg3_round++; + // prepare handling of retransmission get_Msg3allocret(&mac->common_channels[CC_idP], - ra[RA_id].Msg3_subframe, ra[RA_id].Msg3_frame, - &ra[RA_id].Msg3_frame, &ra[RA_id].Msg3_subframe); - add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP); + ra[RA_id].Msg3_subframe, ra[RA_id].Msg3_frame, + &ra[RA_id].Msg3_frame, &ra[RA_id].Msg3_subframe); + add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP); } /* TODO: program NACK for PHICH? */ - return; } } else { LOG_W(MAC, - "Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", - current_rnti); + "Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", + current_rnti); return; } + payload_ptr = parse_ulsch_header(sduP, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths, sdu_lenP); - if(payload_ptr == NULL){ - LOG_E(MAC,"[eNB %d][PUSCH %d] CC_id %d ulsch header unknown lcid(rnti %x, UE_id %d)\n", - enb_mod_idP, harq_pid, CC_idP,current_rnti, UE_id); - return; + if(payload_ptr == NULL) { + LOG_E(MAC,"[eNB %d][PUSCH %d] CC_id %d ulsch header unknown lcid(rnti %x, UE_id %d)\n", + enb_mod_idP, harq_pid, CC_idP,current_rnti, UE_id); + return; } T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), @@ -282,65 +276,65 @@ rx_sdu(const module_id_t enb_mod_idP, T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP)); - mac->eNB_stats[CC_idP].ulsch_bytes_rx = sdu_lenP; mac->eNB_stats[CC_idP].total_ulsch_bytes_rx += sdu_lenP; mac->eNB_stats[CC_idP].total_ulsch_pdus_rx += 1; - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; // control element for (i = 0; i < num_ce; i++) { - T(T_ENB_MAC_UE_UL_CE, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), T_INT(rx_ces[i])); - switch (rx_ces[i]) { // implement and process BSR + CRNTI + - case POWER_HEADROOM: - if (UE_id != -1) { - UE_list->UE_template[CC_idP][UE_id].phr_info = - (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET + (int8_t)(hundred_times_log10_NPRB[UE_list->UE_template[CC_idP][UE_id].nb_rb_ul[harq_pid]-1]/100); - if(UE_list->UE_template[CC_idP][UE_id].phr_info > 40) - UE_list->UE_template[CC_idP][UE_id].phr_info = 40; - - 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; + switch (rx_ces[i]) { // implement and process BSR + CRNTI + + case POWER_HEADROOM: + if (UE_id != -1) { + UE_list->UE_template[CC_idP][UE_id].phr_info = + (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET + (int8_t)(hundred_times_log10_NPRB[UE_list->UE_template[CC_idP][UE_id].nb_rb_ul[harq_pid]-1]/100); - case CRNTI: - { - int old_rnti = - (((uint16_t) payload_ptr[0]) << 8) + payload_ptr[1]; - int old_UE_id = find_UE_id(enb_mod_idP, old_rnti); - LOG_D(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", - enb_mod_idP, frameP, subframeP, CC_idP, rx_ces[i], i, - num_ce, old_rnti, old_UE_id); - /* receiving CRNTI means that the current rnti has to go away */ - //cancel_ra_proc(enb_mod_idP, CC_idP, frameP, - // current_rnti); - if (old_UE_id != -1) { - /* TODO: if the UE did random access (followed by a MAC uplink with - * CRNTI) because none of its scheduling request was granted, then - * according to 36.321 5.4.4 the UE's MAC will notify RRC to release - * PUCCH/SRS. According to 36.331 5.3.13 the UE will then apply - * default configuration for CQI reporting and scheduling requests, - * which basically means that the CQI requests won't work anymore and - * that the UE won't do any scheduling request anymore as long as the - * eNB doesn't reconfigure the UE. - * We have to take care of this. As the code is, nothing is done and - * the UE state in the eNB is wrong. - */ + if(UE_list->UE_template[CC_idP][UE_id].phr_info > 40) + UE_list->UE_template[CC_idP][UE_id].phr_info = 40; + + 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: { + int old_rnti = + (((uint16_t) payload_ptr[0]) << 8) + payload_ptr[1]; + int old_UE_id = find_UE_id(enb_mod_idP, old_rnti); + LOG_D(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", + enb_mod_idP, frameP, subframeP, CC_idP, rx_ces[i], i, + num_ce, old_rnti, old_UE_id); + + /* receiving CRNTI means that the current rnti has to go away */ + //cancel_ra_proc(enb_mod_idP, CC_idP, frameP, + // current_rnti); + if (old_UE_id != -1) { + /* TODO: if the UE did random access (followed by a MAC uplink with + * CRNTI) because none of its scheduling request was granted, then + * according to 36.321 5.4.4 the UE's MAC will notify RRC to release + * PUCCH/SRS. According to 36.331 5.3.13 the UE will then apply + * default configuration for CQI reporting and scheduling requests, + * which basically means that the CQI requests won't work anymore and + * that the UE won't do any scheduling request anymore as long as the + * eNB doesn't reconfigure the UE. + * We have to take care of this. As the code is, nothing is done and + * the UE state in the eNB is wrong. + */ for (ii = 0; ii < NB_RA_PROC_MAX; ii++) { ra = &mac->common_channels[CC_idP].ra[ii]; + if ((ra->rnti == current_rnti) && (ra->state != IDLE)) { mac_rrc_data_ind(enb_mod_idP, CC_idP, @@ -355,7 +349,6 @@ rx_sdu(const module_id_t enb_mod_idP, LOG_I(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d : (rnti %x UE_id %d) RRCConnectionReconfiguration(Msg4)\n", enb_mod_idP, frameP, subframeP, CC_idP, old_rnti, old_UE_id); - UE_id = old_UE_id; current_rnti = old_rnti; ra->rnti = old_rnti; @@ -365,11 +358,13 @@ rx_sdu(const module_id_t enb_mod_idP, UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; 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, old_rnti); } + UE_list->UE_template[CC_idP][UE_id].ul_SR = 1; UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 1; break; @@ -378,391 +373,371 @@ rx_sdu(const module_id_t enb_mod_idP, } else { cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti); } - crnti_rx = 1; - payload_ptr += 2; - break; + + crnti_rx = 1; + payload_ptr += 2; + 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_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 (UE_id != -1) { - int bsr = payload_ptr[0] & 0x3f; + 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); - lcgid_updated[lcgid] = 1; + if (crnti_rx == 1) + 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 (UE_id != -1) { + int bsr = payload_ptr[0] & 0x3f; + lcgid_updated[lcgid] = 1; // update buffer info UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid] = BSR_TABLE[bsr]; - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; + RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP * 10) + subframeP] = (payload_ptr[0] & 0x3f); - RC.eNB[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, - RC.eNB[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_D(MAC, - "[eNB %d] CC_id %d MAC CE_LCID %d : estimated_ul_buffer = %d (lcg increment %d)\n", - enb_mod_idP, CC_idP, rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer, - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]); - } else { - - } - payload_ptr += 1; //sizeof(SHORT_BSR); // fixme + if (UE_id == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR, + RC.eNB[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_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : estimated_ul_buffer = %d (lcg increment %d)\n", + enb_mod_idP, CC_idP, rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].estimated_ul_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) { - int bsr0 = (payload_ptr[0] & 0xFC) >> 2; - int bsr1 = ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); - int bsr2 = ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); - int bsr3 = payload_ptr[2] & 0x3F; - - lcgid_updated[LCGID0] = 1; - lcgid_updated[LCGID1] = 1; - lcgid_updated[LCGID2] = 1; - lcgid_updated[LCGID3] = 1; - - // update buffer info - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] = BSR_TABLE[bsr0]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] = BSR_TABLE[bsr1]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] = BSR_TABLE[bsr2]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3] = BSR_TABLE[bsr3]; - - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = + case LONG_BSR: + if (UE_id != -1) { + int bsr0 = (payload_ptr[0] & 0xFC) >> 2; + int bsr1 = ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); + int bsr2 = ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); + int bsr3 = payload_ptr[2] & 0x3F; + lcgid_updated[LCGID0] = 1; + lcgid_updated[LCGID1] = 1; + lcgid_updated[LCGID2] = 1; + lcgid_updated[LCGID3] = 1; + // update buffer info + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] = BSR_TABLE[bsr0]; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] = BSR_TABLE[bsr1]; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] = BSR_TABLE[bsr2]; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3] = BSR_TABLE[bsr3]; + UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; - //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; - - LOG_D(MAC, - "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR. Size is 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].ul_buffer_info[LCGID0], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]); - if (crnti_rx == 1) + //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR. Size is LCGID0 = %u LCGID1 = " - "%u LCGID2 = %u LCGID3 = %u\n", enb_mod_idP, - CC_idP, rx_ces[i], + "%u LCGID2 = %u LCGID3 = %u\n", enb_mod_idP, CC_idP, + rx_ces[i], UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0], UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1], UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2], UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]); - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_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].ul_buffer_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].ul_buffer_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].ul_buffer_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; - - } - } + if (crnti_rx == 1) + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR. Size is 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].ul_buffer_info[LCGID0], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]); + + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_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; + } - payload_ptr += 3; ////sizeof(LONG_BSR); - break; + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_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; + } - 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; + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_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].ul_buffer_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 < num_sdu; i++) { LOG_D(MAC, "SDU Number %d MAC Subheader SDU_LCID %d, length %d\n", - i, rx_lcids[i], rx_lengths[i]); - + i, rx_lcids[i], rx_lengths[i]); T(T_ENB_MAC_UE_UL_SDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), T_INT(rx_lcids[i]), T_INT(rx_lengths[i])); T(T_ENB_MAC_UE_UL_SDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), T_INT(rx_lcids[i]), T_INT(rx_lengths[i]), T_BUFFER(payload_ptr, - rx_lengths - [i])); + rx_lengths + [i])); switch (rx_lcids[i]) { - case CCCH: - if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) { - LOG_E(MAC, - "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n", - enb_mod_idP, CC_idP, frameP, rx_lengths[i], - CCCH_PAYLOAD_SIZE_MAX, sdu_lenP); - break; - } - LOG_D(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], current_rnti); - 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; ii < NB_RA_PROC_MAX; ii++) { - RA_t *ra = &mac->common_channels[CC_idP].ra[ii]; - - LOG_D(MAC, - "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n", - enb_mod_idP, CC_idP, ii, ra->rnti, - current_rnti, ra->state); - - if ((ra->rnti == current_rnti) && (ra->state != IDLE)) { - - //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); - - if (UE_id < 0) { - memcpy(&ra->cont_res_id[0], payload_ptr, 6); - LOG_D(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, - mac->common_channels[CC_idP]. - ra[ii].rnti, harq_pid + case CCCH: + if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) { + LOG_E(MAC, + "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], + CCCH_PAYLOAD_SIZE_MAX, sdu_lenP); + break; + } + + LOG_D(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], current_rnti); + 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; ii < NB_RA_PROC_MAX; ii++) { + RA_t *ra = &mac->common_channels[CC_idP].ra[ii]; + LOG_D(MAC, + "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n", + enb_mod_idP, CC_idP, ii, ra->rnti, + current_rnti, ra->state); + + if ((ra->rnti == current_rnti) && (ra->state != IDLE)) { + //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); + if (UE_id < 0) { + memcpy(&ra->cont_res_id[0], payload_ptr, 6); + LOG_D(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, + mac->common_channels[CC_idP]. + ra[ii].rnti, harq_pid #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , - mac->common_channels[CC_idP]. - ra[ii].rach_resource_type + , + mac->common_channels[CC_idP]. + ra[ii].rach_resource_type #endif - )) == -1) { - LOG_E(MAC,"[MAC][eNB] Max user count reached\n"); - cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti); - break; - // kill RA procedure - } else - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n", - enb_mod_idP, CC_idP, frameP, ra->rnti, - UE_id); - } else { - LOG_D(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 - } - - mac_rrc_data_ind(enb_mod_idP, - CC_idP, - frameP, subframeP, - current_rnti, - CCCH, - (uint8_t *) payload_ptr, - rx_lengths[i], - 0); - - - if (num_ce > 0) { // handle msg3 which is not RRCConnectionRequest - // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); - } - // prepare transmission of Msg4 - ra->state = MSG4; - - - - if(mac->common_channels[CC_idP].tdd_Config!=NULL){ - switch(mac->common_channels[CC_idP].tdd_Config->subframeAssignment){ - case 1: - ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0); - ra->Msg4_subframe = (subframeP + 7) % 10; - break; - default: printf("%s:%d: TODO\n", __FILE__, __LINE__); abort(); - // TODO need to be complete for other tdd configs. + )) == -1) { + LOG_E(MAC,"[MAC][eNB] Max user count reached\n"); + cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti); + break; + // kill RA procedure + } else + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n", + enb_mod_idP, CC_idP, frameP, ra->rnti, + UE_id); + } else { + LOG_D(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 } - }else{ - // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different - ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0); - ra->Msg4_subframe = (subframeP + 4) % 10; - } - UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 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) { - if (lcgid_updated[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] == 0) { - // 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; - - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; - //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; - } - - 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_rrc_data_ind(enb_mod_idP, + CC_idP, + frameP, subframeP, + current_rnti, + CCCH, + (uint8_t *) payload_ptr, + rx_lengths[i], + 0); + + if (num_ce > 0) { // handle msg3 which is not RRCConnectionRequest + // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); + } - mac_rlc_data_ind(enb_mod_idP, current_rnti, 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]; + // prepare transmission of Msg4 + ra->state = MSG4; + if(mac->common_channels[CC_idP].tdd_Config!=NULL) { + switch(mac->common_channels[CC_idP].tdd_Config->subframeAssignment) { + case 1: + ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0); + ra->Msg4_subframe = (subframeP + 7) % 10; + break; - } + default: + printf("%s:%d: TODO\n", __FILE__, __LINE__); + abort(); + // TODO need to be complete for other tdd configs. + } + } else { + // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different + ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0); + ra->Msg4_subframe = (subframeP + 4) % 10; + } - /* UE_id != -1 */ - // } - break; + UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0; + } // if process is active + } // loop on RA processes - // all the DRBS - case DTCH: - - default: + 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"); + LOG_T(MAC, "offset: %d\n", + (unsigned char) ((unsigned char *) payload_ptr - sduP)); -#endif + for (j = 0; j < 32; j++) { + LOG_T(MAC, "%x ", payload_ptr[j]); + } - 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]]]); + LOG_T(MAC, "\n"); +#endif + if (UE_id != -1) { if (lcgid_updated[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] == 0) { - 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]) { + // 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; - } + 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; UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; + //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; } - if ((rx_lengths[i] < SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0)) { // MAX SIZE OF transport block - mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); + 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, current_rnti, 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_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; - //clear uplane_inactivity_timer - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + // 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)); - // reset RRC inactivity timer after uplane activity - ue_contextP = rrc_eNB_get_ue_context(RC.rrc[enb_mod_idP], rntiP); - ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; + for (j = 0; j < 32; j++) { + LOG_T(MAC, "%x ", payload_ptr[j]); + } - } 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); - } + LOG_T(MAC, "\n"); +#endif - } else { // end if (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); - } - } + 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 (lcgid_updated[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] == 0) { + 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; + } - break; + UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; + } + + if ((rx_lengths[i] < SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0)) { // MAX SIZE OF transport block + mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); + 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]; + //clear uplane_inactivity_timer + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + // reset RRC inactivity timer after uplane activity + ue_contextP = rrc_eNB_get_ue_context(RC.rrc[enb_mod_idP], rntiP); + ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; + } 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 { // end if (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]; @@ -770,12 +745,11 @@ rx_sdu(const module_id_t enb_mod_idP, // Program ACK for PHICH LOG_D(MAC, - "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n", - current_rnti, harq_pid, first_rb); + "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n", + current_rnti, harq_pid, first_rb); nfapi_hi_dci0_request_t *hi_dci0_req; - uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP] , subframeP); + uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP); hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP+sf_ahead_dl)%10]; - nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; @@ -796,6 +770,7 @@ rx_sdu(const module_id_t enb_mod_idP, 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 ) { @@ -815,8 +790,7 @@ rx_sdu(const module_id_t enb_mod_idP, stop_meas(&mac->rx_ulsch_sdu); } -uint32_t bytes_to_bsr_index(int32_t nbytes) -{ +uint32_t bytes_to_bsr_index(int32_t nbytes) { uint32_t i = 0; if (nbytes < 0) { @@ -832,30 +806,26 @@ uint32_t bytes_to_bsr_index(int32_t nbytes) void add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id, - sub_frame_t subframeP, UE_ULSCH_STATUS status) -{ + sub_frame_t subframeP, UE_ULSCH_STATUS status) { eNB_ulsch_info[module_idP][CC_id][UE_id].rnti = UE_RNTI(module_idP, UE_id); eNB_ulsch_info[module_idP][CC_id][UE_id].subframe = subframeP; eNB_ulsch_info[module_idP][CC_id][UE_id].status = status; - eNB_ulsch_info[module_idP][CC_id][UE_id].serving_num++; } unsigned char *parse_ulsch_header(unsigned char *mac_header, - unsigned char *num_ce, - unsigned char *num_sdu, - unsigned char *rx_ces, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) -{ + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { unsigned char not_done = 1, num_ces = 0, num_sdus = - 0, lcid, num_sdu_cnt; + 0, lcid, num_sdu_cnt; unsigned char *mac_header_ptr = mac_header; unsigned short length, ce_len = 0; while (not_done == 1) { - if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { not_done = 0; } @@ -863,62 +833,61 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, 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]; - } + 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); - } + 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); + "[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 + } else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI if (lcid == SHORT_PADDING) { - mac_header_ptr++; + 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); - //AssertFatal(1 == 0, "unknown CE"); + 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); + //AssertFatal(1 == 0, "unknown CE"); return NULL; - } + } } } } *num_ce = num_ces; *num_sdu = num_sdus; - return (mac_header_ptr); } @@ -929,18 +898,18 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, */ void set_msg3_subframe(module_id_t mod_id, - int CC_id, - int frame, - int subframe, int rnti, int Msg3_frame, - int Msg3_subframe) -{ + int CC_id, + int frame, + int subframe, int rnti, int Msg3_frame, + int Msg3_subframe) { eNB_MAC_INST *mac = RC.mac[mod_id]; int i; + for (i = 0; i < NB_RA_PROC_MAX; i++) { if (mac->common_channels[CC_id].ra[i].state != IDLE && - mac->common_channels[CC_id].ra[i].rnti == rnti) { + mac->common_channels[CC_id].ra[i].rnti == rnti) { mac->common_channels[CC_id].ra[i].Msg3_subframe = - Msg3_subframe; + Msg3_subframe; break; } } @@ -948,90 +917,105 @@ set_msg3_subframe(module_id_t mod_id, void schedule_ulsch(module_id_t module_idP, frame_t frameP, - sub_frame_t subframeP) -{ + sub_frame_t subframeP) { uint16_t first_rb[NFAPI_CC_MAX], i; int CC_id; eNB_MAC_INST *mac = RC.mac[module_idP]; slice_info_t *sli = &RC.mac[module_idP]->slice_info; COMMON_channels_t *cc; - start_meas(&mac->schedule_ulsch); - int sched_frame=frameP; int sched_subframe = (subframeP + 4) % 10; - cc = &mac->common_channels[0]; int tdd_sfa; + // for TDD: check subframes where we have to act and return if nothing should be done now if (cc->tdd_Config) { tdd_sfa = cc->tdd_Config->subframeAssignment; + switch (subframeP) { - case 0: - if ((tdd_sfa == 0) || (tdd_sfa == 3)) - sched_subframe = 4; - else if (tdd_sfa == 6) - sched_subframe = 7; - else - return; - break; - case 1: - if ((tdd_sfa == 0) || (tdd_sfa == 1)) - sched_subframe = 7; - else if (tdd_sfa == 6) - sched_subframe = 8; - else + case 0: + if ((tdd_sfa == 0) || (tdd_sfa == 3)) + sched_subframe = 4; + else if (tdd_sfa == 6) + sched_subframe = 7; + else + return; + + break; + + case 1: + if ((tdd_sfa == 0) || (tdd_sfa == 1)) + sched_subframe = 7; + else if (tdd_sfa == 6) + sched_subframe = 8; + else + return; + + break; + + default: return; - break; - default: - return; - case 2: // Don't schedule UL in subframe 2 for TDD - return; - case 3: - if (tdd_sfa == 2) - sched_subframe = 7; - else - return; - break; - case 4: - if (tdd_sfa == 1) - sched_subframe = 8; - else - return; - break; - case 5: - if (tdd_sfa == 0) - sched_subframe = 9; - else if (tdd_sfa == 6) - sched_subframe = 2; - else - return; - break; - case 6: - if (tdd_sfa == 0 || tdd_sfa == 1) - sched_subframe = 2; - else if (tdd_sfa == 6) - sched_subframe = 3; - else - return; - break; - case 7: - return; - case 8: - if ((tdd_sfa >= 2) && (tdd_sfa <= 5)) - sched_subframe = 2; - else + case 2: // Don't schedule UL in subframe 2 for TDD return; - break; - case 9: - if ((tdd_sfa == 1) || (tdd_sfa == 3) || (tdd_sfa == 4)) - sched_subframe = 3; - else if (tdd_sfa == 6) - sched_subframe = 4; - else + + case 3: + if (tdd_sfa == 2) + sched_subframe = 7; + else + return; + + break; + + case 4: + if (tdd_sfa == 1) + sched_subframe = 8; + else + return; + + break; + + case 5: + if (tdd_sfa == 0) + sched_subframe = 9; + else if (tdd_sfa == 6) + sched_subframe = 2; + else + return; + + break; + + case 6: + if (tdd_sfa == 0 || tdd_sfa == 1) + sched_subframe = 2; + else if (tdd_sfa == 6) + sched_subframe = 3; + else + return; + + break; + + case 7: return; - break; + + case 8: + if ((tdd_sfa >= 2) && (tdd_sfa <= 5)) + sched_subframe = 2; + else + return; + + break; + + case 9: + if ((tdd_sfa == 1) || (tdd_sfa == 3) || (tdd_sfa == 4)) + sched_subframe = 3; + else if (tdd_sfa == 6) + sched_subframe = 4; + else + return; + + break; } } @@ -1056,11 +1040,12 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, for (i = 0; i < NB_RA_PROC_MAX; i++) { if ((cc->ra[i].state == WAITMSG3) && - (cc->ra[i].Msg3_subframe == sched_subframe)) { + (cc->ra[i].Msg3_subframe == sched_subframe)) { if (first_rb[CC_id] < cc->ra[i].msg3_first_rb + cc->ra[i].msg3_nb_rb) first_rb[CC_id] = cc->ra[i].msg3_first_rb + cc->ra[i].msg3_nb_rb; - // cc->ray[i].Msg3_subframe = -1; - break; + + // cc->ray[i].Msg3_subframe = -1; + break; } } } @@ -1075,11 +1060,10 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, void schedule_ulsch_rnti(module_id_t module_idP, - int slice_idx, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframeP, uint16_t * first_rb) -{ + int slice_idx, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, uint16_t *first_rb) { int UE_id; uint8_t aggregation = 2; rnti_t rnti = -1; @@ -1107,56 +1091,55 @@ schedule_ulsch_rnti(module_id_t module_idP, int first_rb_slice[NFAPI_CC_MAX]; if (sched_subframeP < subframeP) - sched_frame++; + sched_frame++; nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_id][subframeP]; nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - nfapi_ul_config_request_t *ul_req_tmp = &mac->UL_req_tmp[CC_id][sched_subframeP]; nfapi_ul_config_request_body_t *ul_req_tmp_body = &ul_req_tmp->ul_config_request_body; nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; - for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; ++CC_id) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; ++CC_id) { N_RB_UL = to_prb(cc[CC_id].ul_Bandwidth); - UE_list->first_rb_offset[CC_id][slice_idx] = cmin(N_RB_UL, sli->ul[slice_idx].first_rb); - } + UE_list->first_rb_offset[CC_id][slice_idx] = cmin(N_RB_UL, sli->ul[slice_idx].first_rb); + } //LOG_D(MAC, "entering ulsch preprocesor\n"); ulsch_scheduler_pre_processor(module_idP, slice_idx, frameP, subframeP, sched_subframeP, first_rb); - for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; ++CC_id) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; ++CC_id) { first_rb_slice[CC_id] = first_rb[CC_id] + UE_list->first_rb_offset[CC_id][slice_idx]; } - //LOG_D(MAC, "exiting ulsch preprocesor\n"); + //LOG_D(MAC, "exiting ulsch preprocesor\n"); hi_dci0_req->sfn_sf = (frameP << 4) + subframeP; // loop over all active UEs for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) { - if (!ue_ul_slice_membership(module_idP, UE_id, slice_idx)) - continue; + continue; // don't schedule if Msg4 is not received yet if (UE_list->UE_template[UE_PCCID(module_idP, UE_id)][UE_id]. configured == FALSE) { - LOG_D(MAC, - "[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n", - module_idP, frameP, subframeP, UE_id); - continue; + LOG_D(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); + module_idP, frameP, subframeP, UE_id); continue; } drop_ue = 0; + /* 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? @@ -1172,6 +1155,7 @@ schedule_ulsch_rnti(module_id_t module_idP, 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 @@ -1180,18 +1164,20 @@ schedule_ulsch_rnti(module_id_t module_idP, * 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; + 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; n < UE_list->numactiveULCCs[UE_id]; n++) { // This is the actual CC_id in the list @@ -1199,416 +1185,421 @@ schedule_ulsch_rnti(module_id_t module_idP, N_RB_UL = to_prb(cc[CC_id].ul_Bandwidth); /* - aggregation=get_aggregation(get_bw_index(module_idP,CC_id), - eNB_UE_stats->dl_cqi, - format0); + aggregation=get_aggregation(get_bw_index(module_idP,CC_id), + eNB_UE_stats->dl_cqi, + format0); */ if (CCE_allocation_infeasible - (module_idP, CC_id, 1, 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; + (module_idP, CC_id, 1, 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; } /* be sure that there are some free RBs */ if (first_rb_slice[CC_id] >= N_RB_UL - 1) { - LOG_W(MAC, - "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP, frameP, subframeP, UE_id, rnti, CC_id); - continue; + LOG_W(MAC, + "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP, frameP, subframeP, UE_id, rnti, CC_id); + continue; } - // if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel + // if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel UE_template = &UE_list->UE_template[CC_id][UE_id]; UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; harq_pid = subframe2harqpid(&cc[CC_id], sched_frame, sched_subframeP); round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; AssertFatal(round < 8, "round %d > 7 for UE %d/%x\n", round, - UE_id, rnti); + UE_id, rnti); LOG_D(MAC, - "[eNB %d] frame %d subframe %d (sched_frame %d, sched_subframe %d), Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", - module_idP, frameP, subframeP, sched_frame, sched_subframeP, harq_pid, UE_id, rnti, - CC_id, aggregation, N_RB_UL); - + "[eNB %d] frame %d subframe %d (sched_frame %d, sched_subframe %d), Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", + module_idP, frameP, subframeP, sched_frame, sched_subframeP, harq_pid, UE_id, rnti, + CC_id, aggregation, N_RB_UL); RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP * 10) + subframeP] = UE_template->estimated_ul_buffer; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[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 %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", - module_idP, harq_pid, frameP, subframeP, UE_id, rnti, - round, UE_template->ul_SR, - UE_sched_ctrl->ul_inactivity_timer, - UE_sched_ctrl->ul_failure_timer, - UE_sched_ctrl->cqi_req_timer); - // reset the scheduling request - UE_template->ul_SR = 0; - status = mac_eNB_get_rrc_status(module_idP, rnti); - cqi_req = 0; - - if (status >= RRC_CONNECTED && UE_sched_ctrl->cqi_req_timer > 30) { - if (UE_sched_ctrl->cqi_received == 0) { - if (nfapi_mode) { - cqi_req = 0; - } else { - cqi_req = 1; - // To be safe , do not ask CQI in special Subframes:36.213/7.2.3 CQI definition - if (cc[CC_id].tdd_Config) { - switch (cc[CC_id].tdd_Config->subframeAssignment) { - case 1: - if( subframeP == 1 || subframeP == 6 ) cqi_req=0; - break; - case 3: - if( subframeP == 1 ) cqi_req=0; - break; - default: - LOG_E(MAC," TDD config not supported\n"); - break; - } - } - if(cqi_req == 1) UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; - } - } - else if (UE_sched_ctrl->cqi_received == 1) { - UE_sched_ctrl->cqi_req_flag = 0; - UE_sched_ctrl->cqi_received = 0; - UE_sched_ctrl->cqi_req_timer = 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 - //is not in dBm, unit from nfapi, converting to dBm: ToDo: Noise power hard coded to 30 - normalized_rx_power = (5*UE_sched_ctrl->pusch_snr[CC_id]-640)/10+30; - target_rx_power= mac->puSch10xSnr/10 + 30; - //printf("\n mac->puSch10xSnr = %d, normalized_rx_power = %d, target_rx_power = %d \n",mac->puSch10xSnr,normalized_rx_power,target_rx_power); - // 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 + 4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power < (target_rx_power - 4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - } else { - tpc = 1; //0 - } - //tpc = 1; - 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_template->mcs_UL[harq_pid] = cmin(UE_template->pre_assigned_mcs_ul, sli->ul[slice_idx].maxmcs); - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1= UE_template->mcs_UL[harq_pid]; - //cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS - if (UE_template->pre_allocated_rb_table_index_ul >= 0) { - rb_table_index = UE_template->pre_allocated_rb_table_index_ul; - } else { - UE_template->mcs_UL[harq_pid] = 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 = UE_template->mcs_UL[harq_pid]; - // buffer_occupancy = UE_template->ul_total_buffer; - - - while (((rb_table[rb_table_index] > (N_RB_UL - first_rb_slice[CC_id])) - || (rb_table[rb_table_index] > 45)) - && (rb_table_index > 0)) { - rb_table_index--; - } - - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid], - 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 = UE_template->TBS_UL[harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].total_ulsch_TBS += UE_template->TBS_UL[harq_pid]; - // buffer_occupancy -= TBS; - - 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(UE_template->mcs_UL[harq_pid]), - T_INT(first_rb_slice[CC_id]), - T_INT(rb_table[rb_table_index]), - T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); - - if (mac_eNB_get_rrc_status(module_idP, rnti) < RRC_CONNECTED) - LOG_D(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, - UE_template->mcs_UL[harq_pid], - first_rb_slice[CC_id], rb_table[rb_table_index], - rb_table_index, - UE_template->TBS_UL[harq_pid], harq_pid); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; - UE_template->first_rb_ul[harq_pid] = first_rb_slice[CC_id]; - - UE_sched_ctrl->ul_scheduled |= (1 << harq_pid); - if (UE_id == UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED, - UE_sched_ctrl->ul_scheduled); - - // adjust scheduled UL bytes by TBS, wait for UL sdus to do final update - LOG_D(MAC, - "[eNB %d] CC_id %d UE %d/%x : adjusting scheduled_ul_bytes, old %d, TBS %d\n", - module_idP, CC_id, UE_id, rnti, - UE_template->scheduled_ul_bytes, - UE_template->TBS_UL[harq_pid]); - - UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid]; - - LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes); - - // 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) - // save it for a potential retransmission - UE_template->cshift[harq_pid] = cshift; - - hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; - memset((void *) hi_dci0_pdu, 0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_dci_pdu); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb_slice[CC_id]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; - - hi_dci0_req_body->number_of_dci++; - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4); - hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - - hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! - hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - - LOG_D(MAC, - "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid, frameP, subframeP, UE_id, rnti, - sched_frame, sched_subframeP); - - ul_req_index = 0; - dlsch_flag = 0; - for(ul_req_index = 0;ul_req_index < ul_req_tmp_body->number_of_pdus;ul_req_index++){ - if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti){ - dlsch_flag = 1; - LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); - break; - } - } + 10) + + subframeP]); - // Add UL_config PDUs - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, first_rb_slice[CC_id], // resource_block_start - rb_table[rb_table_index], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - ndi, // new_data_indication - 0, // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - get_TBS_UL - (UE_template-> - mcs_UL[harq_pid], - rb_table - [rb_table_index])); -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions - 1, //repetition_number - (frameP * - 10) + - subframeP); - } -#endif - if(dlsch_flag == 1){ - if(cqi_req == 1){ - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; - - }else{ - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + 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 %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", + module_idP, harq_pid, frameP, subframeP, UE_id, rnti, + round, UE_template->ul_SR, + UE_sched_ctrl->ul_inactivity_timer, + UE_sched_ctrl->ul_failure_timer, + UE_sched_ctrl->cqi_req_timer); + // reset the scheduling request + UE_template->ul_SR = 0; + status = mac_eNB_get_rrc_status(module_idP, rnti); + cqi_req = 0; + + if (status >= RRC_CONNECTED && UE_sched_ctrl->cqi_req_timer > 30) { + if (UE_sched_ctrl->cqi_received == 0) { + if (nfapi_mode) { + cqi_req = 0; + } else { + cqi_req = 1; + + // To be safe , do not ask CQI in special Subframes:36.213/7.2.3 CQI definition + if (cc[CC_id].tdd_Config) { + switch (cc[CC_id].tdd_Config->subframeAssignment) { + case 1: + if( subframeP == 1 || subframeP == 6 ) cqi_req=0; + + break; + + case 3: + if( subframeP == 1 ) cqi_req=0; + + break; + + default: + LOG_E(MAC," TDD config not supported\n"); + break; + } } - fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - }else{ - ul_req_tmp_body->number_of_pdus++; + + if(cqi_req == 1) UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; } + } else if (UE_sched_ctrl->cqi_received == 1) { + UE_sched_ctrl->cqi_req_flag = 0; + UE_sched_ctrl->cqi_received = 0; + UE_sched_ctrl->cqi_req_timer = 0; + } + } - ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - mac->ul_handle++; - - uint16_t ul_sched_frame = sched_frame; - uint16_t ul_sched_subframeP = sched_subframeP; - - //add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); - ul_req_tmp->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; - - 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); - LOG_D(MAC,"[PUSCH %d] SFN/SF:%04d%d UL_CFG:SFN/SF:%04d%d CQI:%d for UE %d/%x\n", harq_pid,frameP,subframeP,ul_sched_frame,ul_sched_subframeP,cqi_req,UE_id,rnti); - - // increment first rb for next UE allocation - first_rb_slice[CC_id] += rb_table[rb_table_index]; - } else { // round > 0 => retransmission - 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(UE_template->mcs_UL[harq_pid]), - T_INT(first_rb_slice[CC_id]), - T_INT(rb_table[rb_table_index]), T_INT(round)); - - // Add UL_config PDUs - LOG_D(MAC, - "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid, frameP, subframeP, UE_id, rnti, - sched_frame, sched_subframeP); - ul_req_index = 0; - dlsch_flag = 0; - for(ul_req_index = 0;ul_req_index < ul_req_tmp_body->number_of_pdus;ul_req_index++){ - if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti){ - dlsch_flag = 1; - LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); - break; - } + //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 + //is not in dBm, unit from nfapi, converting to dBm: ToDo: Noise power hard coded to 30 + normalized_rx_power = (5*UE_sched_ctrl->pusch_snr[CC_id]-640)/10+30; + target_rx_power= mac->puSch10xSnr/10 + 30; + //printf("\n mac->puSch10xSnr = %d, normalized_rx_power = %d, target_rx_power = %d \n",mac->puSch10xSnr,normalized_rx_power,target_rx_power); + // 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 + 4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power < (target_rx_power - 4)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + } else { + tpc = 1; //0 + } + + //tpc = 1; + 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_template->mcs_UL[harq_pid] = cmin(UE_template->pre_assigned_mcs_ul, sli->ul[slice_idx].maxmcs); + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1= UE_template->mcs_UL[harq_pid]; + + //cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + if (UE_template->pre_allocated_rb_table_index_ul >= 0) { + rb_table_index = UE_template->pre_allocated_rb_table_index_ul; + } else { + UE_template->mcs_UL[harq_pid] = 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 = UE_template->mcs_UL[harq_pid]; + // buffer_occupancy = UE_template->ul_total_buffer; + + while (((rb_table[rb_table_index] > (N_RB_UL - first_rb_slice[CC_id])) + || (rb_table[rb_table_index] > 45)) + && (rb_table_index > 0)) { + rb_table_index--; + } + + UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid], + 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 = UE_template->TBS_UL[harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].total_ulsch_TBS += UE_template->TBS_UL[harq_pid]; + // buffer_occupancy -= TBS; + 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(UE_template->mcs_UL[harq_pid]), + T_INT(first_rb_slice[CC_id]), + T_INT(rb_table[rb_table_index]), + T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); + + if (mac_eNB_get_rrc_status(module_idP, rnti) < RRC_CONNECTED) + LOG_D(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, + UE_template->mcs_UL[harq_pid], + first_rb_slice[CC_id], rb_table[rb_table_index], + rb_table_index, + UE_template->TBS_UL[harq_pid], harq_pid); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; + UE_template->first_rb_ul[harq_pid] = first_rb_slice[CC_id]; + UE_sched_ctrl->ul_scheduled |= (1 << harq_pid); + + if (UE_id == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED, + UE_sched_ctrl->ul_scheduled); + + // adjust scheduled UL bytes by TBS, wait for UL sdus to do final update + LOG_D(MAC, + "[eNB %d] CC_id %d UE %d/%x : adjusting scheduled_ul_bytes, old %d, TBS %d\n", + module_idP, CC_id, UE_id, rnti, + UE_template->scheduled_ul_bytes, + UE_template->TBS_UL[harq_pid]); + UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid]; + LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes); + // 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) + // save it for a potential retransmission + UE_template->cshift[harq_pid] = cshift; + hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; + memset((void *) hi_dci0_pdu, 0,sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb_slice[CC_id]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; + hi_dci0_req_body->number_of_dci++; + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4); + hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + LOG_D(MAC, + "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid, frameP, subframeP, UE_id, rnti, + sched_frame, sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + + for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) { + if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) { + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; } - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, UE_template->first_rb_ul[harq_pid], // resource_block_start - UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round & 3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - UE_template-> - TBS_UL[harq_pid]); + } + + // Add UL_config PDUs + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, + first_rb_slice[CC_id], // resource_block_start + rb_table[rb_table_index], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL + (UE_template-> + mcs_UL[harq_pid], + rb_table + [rb_table_index])); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions - 1, //repetition_number - (frameP * - 10) + - subframeP); - } + + if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions + 1, //repetition_number + (frameP * + 10) + + subframeP); + } + #endif - if(dlsch_flag == 1){ - if(cqi_req == 1){ - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = UE_template->nb_rb_ul[harq_pid]; - - }else{ - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = UE_template->nb_rb_ul[harq_pid]; - } - fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - }else{ - ul_req_tmp_body->number_of_pdus++; + + if(dlsch_flag == 1) { + if(cqi_req == 1) { + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag= + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + rb_table[rb_table_index]; + } else { + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + } + + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); + } else { + ul_req_tmp_body->number_of_pdus++; + } + + ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + mac->ul_handle++; + uint16_t ul_sched_frame = sched_frame; + uint16_t ul_sched_subframeP = sched_subframeP; + //add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); + ul_req_tmp->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; + 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); + LOG_D(MAC,"[PUSCH %d] SFN/SF:%04d%d UL_CFG:SFN/SF:%04d%d CQI:%d for UE %d/%x\n", harq_pid,frameP,subframeP,ul_sched_frame,ul_sched_subframeP,cqi_req,UE_id,rnti); + // increment first rb for next UE allocation + first_rb_slice[CC_id] += rb_table[rb_table_index]; + } else { // round > 0 => retransmission + 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(UE_template->mcs_UL[harq_pid]), + T_INT(first_rb_slice[CC_id]), + T_INT(rb_table[rb_table_index]), T_INT(round)); + // Add UL_config PDUs + LOG_D(MAC, + "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid, frameP, subframeP, UE_id, rnti, + sched_frame, sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + + for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) { + if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) { + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; } + } - mac->ul_handle++; + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, + UE_template->first_rb_ul[harq_pid], // resource_block_start + UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round & 3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + UE_template-> + TBS_UL[harq_pid]); +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions + 1, //repetition_number + (frameP * + 10) + + subframeP); + } - ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP; - ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; +#endif - LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d cqi_req %d\n", - harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,cqi_req); - } /* - else if (round > 0) { //we schedule a retransmission + if(dlsch_flag == 1) { + if(cqi_req == 1) { + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag= + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + UE_template->nb_rb_ul[harq_pid]; + } else { + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + UE_template->nb_rb_ul[harq_pid]; + } - ndi = UE_template->oldNDI_UL[harq_pid]; + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); + } else { + ul_req_tmp_body->number_of_pdus++; + } - if ((round&3)==0) { - mcs = openair_daq_vars.target_ue_ul_mcs; - } else { - mcs = rvidx_tab[round&3] + 28; //not correct for round==4! + mac->ul_handle++; + ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP; + ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; + LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d cqi_req %d\n", + harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,cqi_req); + } /* - } + else if (round > 0) { //we schedule a retransmission - 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); + ndi = UE_template->oldNDI_UL[harq_pid]; - 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 + if ((round&3)==0) { + mcs = openair_daq_vars.target_ue_ul_mcs; + } else { + mcs = rvidx_tab[round&3] + 28; //not correct for round==4! - 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 - } // loop over UE_id - } // loop of CC_id + 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 + } // loop over UE_id + } // loop of CC_id } diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c index db3d7947fb..4265a841e9 100644 --- a/openair2/RRC/LTE/L2_interface.c +++ b/openair2/RRC/LTE/L2_interface.c @@ -38,7 +38,7 @@ #include "common/ran_context.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "flexran_agent_extern.h" @@ -54,7 +54,7 @@ mac_rrc_data_req( const frame_t frameP, const rb_id_t Srb_id, const uint8_t Nb_tb, - uint8_t* const buffer_pP, + uint8_t *const buffer_pP, const uint8_t mbsfn_sync_area ) //-------------------------------------------------------------------------- @@ -64,7 +64,6 @@ mac_rrc_data_req( uint8_t Sdu_size = 0; uint8_t sfn = (uint8_t)((frameP>>2)&0xff); - if (LOG_DEBUGFLAG(DEBUG_RRC)) { LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); } @@ -72,156 +71,151 @@ mac_rrc_data_req( eNB_RRC_INST *rrc; rrc_eNB_carrier_data_t *carrier; LTE_BCCH_BCH_Message_t *mib; + rrc = RC.rrc[Mod_idP]; + carrier = &rrc->carrier[0]; + mib = &carrier->mib; + if((Srb_id & RAB_OFFSET) == BCCH) { + if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) { + return 0; + } - rrc = RC.rrc[Mod_idP]; - carrier = &rrc->carrier[0]; - mib = &carrier->mib; - - if((Srb_id & RAB_OFFSET) == BCCH) { - if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) { - return 0; - } + // All even frames transmit SIB in SF 5 + AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255, + "[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP); - // All even frames transmit SIB in SF 5 - AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255, - "[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP); + if ((frameP%2) == 0) { + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB1, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1); - if ((frameP%2) == 0) { - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].SIB1, - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1); + if (LOG_DEBUGFLAG(DEBUG_RRC)) { + LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP); - if (LOG_DEBUGFLAG(DEBUG_RRC)) { - LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP); + for (int i=0; icarrier[CC_id].sizeof_SIB1; i++) { + LOG_T(RRC,"%x.",buffer_pP[i]); + } - for (int i=0; icarrier[CC_id].sizeof_SIB1; i++) { - LOG_T(RRC,"%x.",buffer_pP[i]); - } + LOG_T(RRC,"\n"); + } /* LOG_DEBUGFLAG(DEBUG_RRC) */ - LOG_T(RRC,"\n"); - } /* LOG_DEBUGFLAG(DEBUG_RRC) */ + return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1); + } // All RFN mod 8 transmit SIB2-3 in SF 5 + else if ((frameP%8) == 1) { + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB23, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23); - return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1); - } // All RFN mod 8 transmit SIB2-3 in SF 5 - else if ((frameP%8) == 1) { - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].SIB23, - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23); + if (LOG_DEBUGFLAG(DEBUG_RRC)) { + LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP); - if (LOG_DEBUGFLAG(DEBUG_RRC)) { - LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP); + for (int i=0; icarrier[CC_id].sizeof_SIB23; i++) { + LOG_T(RRC,"%x.",buffer_pP[i]); + } - for (int i=0; icarrier[CC_id].sizeof_SIB23; i++) { - LOG_T(RRC,"%x.",buffer_pP[i]); - } + LOG_T(RRC,"\n"); + } /* LOG_DEBUGFLAG(DEBUG_RRC) */ - LOG_T(RRC,"\n"); - } /* LOG_DEBUGFLAG(DEBUG_RRC) */ - return(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23); - } else { - return(0); - } - } - if( (Srb_id & RAB_OFFSET ) == MIBCH) { - - mib->message.systemFrameNumber.buf = &sfn; - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_BCH_Message, - NULL, - (void*)mib, - carrier->MIB, - 24); - LOG_D(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded); - buffer_pP[0]=carrier->MIB[0]; - buffer_pP[1]=carrier->MIB[1]; - buffer_pP[2]=carrier->MIB[2]; - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return(3); + return(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23); + } else { + return(0); } + } - if( (Srb_id & RAB_OFFSET ) == CCCH) { - LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); - - if(RC.rrc[Mod_idP]->carrier[CC_id].Srb0.Active==0) { - LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP); - return -1; - } + if( (Srb_id & RAB_OFFSET ) == MIBCH) { + mib->message.systemFrameNumber.buf = &sfn; + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_BCH_Message, + NULL, + (void *)mib, + carrier->MIB, + 24); + LOG_D(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded); + buffer_pP[0]=carrier->MIB[0]; + buffer_pP[1]=carrier->MIB[1]; + buffer_pP[2]=carrier->MIB[2]; + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return(3); + } - Srb_info=&RC.rrc[Mod_idP]->carrier[CC_id].Srb0; + if( (Srb_id & RAB_OFFSET ) == CCCH) { + LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); - // check if data is there for MAC - if(Srb_info->Tx_buffer.payload_size>0) { //Fill buffer - LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_idP,Srb_info,Srb_info->Tx_buffer.payload_size,buffer_pP,Srb_info->Tx_buffer.Payload); + if(RC.rrc[Mod_idP]->carrier[CC_id].Srb0.Active==0) { + LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP); + return -1; + } - memcpy(buffer_pP,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size); - Sdu_size = Srb_info->Tx_buffer.payload_size; - Srb_info->Tx_buffer.payload_size=0; - } + Srb_info=&RC.rrc[Mod_idP]->carrier[CC_id].Srb0; - return (Sdu_size); + // check if data is there for MAC + if(Srb_info->Tx_buffer.payload_size>0) { //Fill buffer + LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_idP,Srb_info,Srb_info->Tx_buffer.payload_size,buffer_pP,Srb_info->Tx_buffer.Payload); + memcpy(buffer_pP,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size); + Sdu_size = Srb_info->Tx_buffer.payload_size; + Srb_info->Tx_buffer.payload_size=0; } - if( (Srb_id & RAB_OFFSET ) == PCCH) { - LOG_T(RRC,"[eNB %d] Frame %d PCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); + return (Sdu_size); + } - // check if data is there for MAC - if(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] > 0) { //Fill buffer - LOG_D(RRC,"[eNB %d] PCCH (%p) has %d bytes\n",Mod_idP,&RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); + if( (Srb_id & RAB_OFFSET ) == PCCH) { + LOG_T(RRC,"[eNB %d] Frame %d PCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); - memcpy(buffer_pP, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); - Sdu_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]; - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] = 0; - } - - return (Sdu_size); + // check if data is there for MAC + if(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] > 0) { //Fill buffer + LOG_D(RRC,"[eNB %d] PCCH (%p) has %d bytes\n",Mod_idP,&RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); + memcpy(buffer_pP, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); + Sdu_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]; + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] = 0; } + return (Sdu_size); + } + #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - if((Srb_id & RAB_OFFSET) == MCCH) { - if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) { - return 0; // this parameter is set in function init_mcch in rrc_eNB.c - } + if((Srb_id & RAB_OFFSET) == MCCH) { + if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) { + return 0; // this parameter is set in function init_mcch in rrc_eNB.c + } - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area], - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area], + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); - if (LOG_DEBUGFLAG(DEBUG_RRC)) { - LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP); + if (LOG_DEBUGFLAG(DEBUG_RRC)) { + LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP); - for (int i=0; icarrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) { - LOG_T(RRC,"%x.",buffer_pP[i]); - } + for (int i=0; icarrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) { + LOG_T(RRC,"%x.",buffer_pP[i]); + } - LOG_T(RRC,"\n"); - } /* LOG_DEBUGFLAG(DEBUG_RRC) */ + LOG_T(RRC,"\n"); + } /* LOG_DEBUGFLAG(DEBUG_RRC) */ - return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); - } + return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); + } #endif // #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - if ((Srb_id & RAB_OFFSET) == BCCH_SIB1_BR){ - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].SIB1_BR, - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR); - return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR); - } - if ((Srb_id & RAB_OFFSET) == BCCH_SI_BR){ // First SI message with SIB2/3 - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].SIB23_BR, - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR); - return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR); - } - -#endif + if ((Srb_id & RAB_OFFSET) == BCCH_SIB1_BR) { + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB1_BR, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR); + return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR); + } + if ((Srb_id & RAB_OFFSET) == BCCH_SI_BR) { // First SI message with SIB2/3 + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB23_BR, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR); + return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR); + } +#endif return(0); } @@ -234,7 +228,7 @@ mac_rrc_data_ind( const sub_frame_t sub_frameP, const rnti_t rntiP, const rb_id_t srb_idP, - const uint8_t* sduP, + const uint8_t *sduP, const sdu_size_t sdu_lenP, const uint8_t mbsfn_sync_areaP ) @@ -243,39 +237,38 @@ mac_rrc_data_ind( SRB_INFO *Srb_info; protocol_ctxt_t ctxt; sdu_size_t sdu_size = 0; - /* for no gcc warnings */ (void)sdu_size; - /* int si_window; */ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, rntiP, frameP, sub_frameP,0); - if((srb_idP & RAB_OFFSET) == CCCH) { + if((srb_idP & RAB_OFFSET) == CCCH) { Srb_info = &RC.rrc[module_idP]->carrier[CC_id].Srb0; LOG_D(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",module_idP,Srb_info->Srb_id); - + // msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id); if (sdu_lenP > 0) { memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP); Srb_info->Rx_buffer.payload_size = sdu_lenP; rrc_eNB_decode_ccch(&ctxt, Srb_info, CC_id); } + } + + if((srb_idP & RAB_OFFSET) == DCCH) { + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.module_id],rntiP); + + if(ue_context_p) { + rrc_eNB_generate_defaultRRCConnectionReconfiguration(&ctxt, + ue_context_p, + 0); + ue_context_p->ue_context.Status = RRC_RECONFIGURED; } - if((srb_idP & RAB_OFFSET) == DCCH) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.module_id],rntiP); - if(ue_context_p){ - rrc_eNB_generate_defaultRRCConnectionReconfiguration(&ctxt, - ue_context_p, - 0); - ue_context_p->ue_context.Status = RRC_RECONFIGURED; - } - } + } return(0); - } //------------------------------------------------------------------------------ @@ -289,7 +282,7 @@ mac_eNB_get_rrc_status( ) //------------------------------------------------------------------------------ { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; ue_context_p = rrc_eNB_get_ue_context(RC.rrc[Mod_idP], rntiP); if (ue_context_p != NULL) { @@ -300,60 +293,59 @@ mac_eNB_get_rrc_status( } void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP) -{ - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) { + struct rrc_eNB_ue_context_s *ue_context_p = NULL; ue_context_p = rrc_eNB_get_ue_context( RC.rrc[Mod_instP], rntiP); if (ue_context_p != NULL) { LOG_I(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP); + if(ue_context_p->ue_context.ul_failure_timer == 0) ue_context_p->ue_context.ul_failure_timer=1; - } - else { + } else { LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP); } + 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); + rntiP, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); } + rrc_mac_remove_ue(Mod_instP,rntiP); } void mac_eNB_rrc_uplane_failure(const module_id_t Mod_instP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP) -{ - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[Mod_instP], - rntiP); - if (ue_context_p != NULL) { - LOG_I(RRC,"Frame %d, Subframe %d: UE %x U-Plane failure, activating timer\n",frameP,subframeP,rntiP); - - if(ue_context_p->ue_context.ul_failure_timer == 0) - ue_context_p->ue_context.ul_failure_timer=19999; - } - else { - LOG_W(RRC,"Frame %d, Subframe %d: U-Plane failure: UE %x unknown \n",frameP,subframeP,rntiP); - } + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) { + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_eNB_get_ue_context( + RC.rrc[Mod_instP], + rntiP); + + if (ue_context_p != NULL) { + LOG_I(RRC,"Frame %d, Subframe %d: UE %x U-Plane failure, activating timer\n",frameP,subframeP,rntiP); + + if(ue_context_p->ue_context.ul_failure_timer == 0) + ue_context_p->ue_context.ul_failure_timer=19999; + } else { + LOG_W(RRC,"Frame %d, Subframe %d: U-Plane failure: UE %x unknown \n",frameP,subframeP,rntiP); + } } -void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP) -{ - struct rrc_eNB_ue_context_s* ue_context_p = NULL; +void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) { + struct rrc_eNB_ue_context_s *ue_context_p = NULL; ue_context_p = rrc_eNB_get_ue_context( RC.rrc[Mod_instP], rntiP); diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index 566661bd20..f0248f34be 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -53,8 +53,8 @@ #include "LTE_SRB-ToAddModList.h" #include "LTE_DRB-ToAddModList.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) -#include "LTE_MCCH-Message.h" -//#define MRB1 1 + #include "LTE_MCCH-Message.h" + //#define MRB1 1 #endif #include "RRC/LTE/rrc_defs.h" @@ -81,14 +81,14 @@ #include "enb_config.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "common/ran_context.h" #include "secu_defs.h" #if !defined (msg) -#define msg printf + #define msg printf #endif @@ -117,8 +117,7 @@ uint16_t two_tier_hexagonal_adjacent_cellIds[7][6] = {{1,2,4,5,7,8}, // CellI * This is a helper function for xer_sprint, which directs all incoming data * into the provided string. */ -static int xer__print2s (const void *buffer, size_t size, void *app_key) -{ +static int xer__print2s (const void *buffer, size_t size, void *app_key) { xer_sprint_string_t *string_buffer = (xer_sprint_string_t *) app_key; size_t string_remaining = string_buffer->string_size - string_buffer->string_index; @@ -134,15 +133,12 @@ static int xer__print2s (const void *buffer, size_t size, void *app_key) return 0; } -int xer_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, void *sptr) -{ +int xer_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, void *sptr) { asn_enc_rval_t er; xer_sprint_string_t string_buffer; - string_buffer.string = string; string_buffer.string_size = string_size; string_buffer.string_index = 0; - er = xer_encode(td, sptr, XER_F_BASIC, xer__print2s, &string_buffer); if (er.encoded < 0) { @@ -158,14 +154,12 @@ int xer_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, voi return er.encoded; } -uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index) -{ +uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index) { return(two_tier_hexagonal_adjacent_cellIds[Mod_id][index]); } /* This only works for the hexagonal topology...need a more general function for other topologies */ -uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId) -{ +uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId) { uint8_t i; for(i=0; i<7; i++) { @@ -178,17 +172,15 @@ uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId) return 0xFF; //error! } -uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame) -{ - +uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame) { asn_enc_rval_t enc_rval; LTE_BCCH_BCH_Message_t *mib=&carrier->mib ; uint8_t sfn = (uint8_t)((frame>>2)&0xff); uint16_t *spare = calloc(1, sizeof(uint16_t)); + if (spare == NULL) abort(); switch (N_RB_DL) { - case 6: mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n6; break; @@ -212,6 +204,7 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich case 100: mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n100; break; + default: AssertFatal(1==0,"Unknown dl_Bandwidth %d\n",N_RB_DL); } @@ -221,11 +214,10 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich AssertFatal(phich_duration <= LTE_PHICH_Config__phich_Duration_extended,"Illegal phich_Duration\n"); mib->message.phich_Config.phich_Duration = phich_duration; LOG_I(RRC,"[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x, sfn %x\n", - (uint32_t)mib->message.dl_Bandwidth, - (uint32_t)phich_duration, - (uint32_t)phich_Resource, - (uint32_t)sfn); - + (uint32_t)mib->message.dl_Bandwidth, + (uint32_t)phich_duration, + (uint32_t)phich_Resource, + (uint32_t)sfn); mib->message.systemFrameNumber.buf = &sfn; mib->message.systemFrameNumber.size = 1; mib->message.systemFrameNumber.bits_unused=0; @@ -238,18 +230,17 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich mib->message.spare.bits_unused = 3; // This makes a spare of 5 bits mib->message.schedulingInfoSIB1_BR_r13 = 0; // turn off eMTC #endif - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_BCH_Message, NULL, - (void*)mib, + (void *)mib, carrier->MIB, 24); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); /* -#if defined(ENABLE_ITTI) -# if !defined(DISABLE_XER_SPRINT) + #if defined(ENABLE_ITTI) + # if !defined(DISABLE_XER_SPRINT) { char message_string[20000]; size_t message_string_size; @@ -264,8 +255,8 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich itti_send_msg_to_task(TASK_UNKNOWN, enb_module_idP, msg_p); } } -# endif -#endif + # endif + #endif */ if (enc_rval.encoded==-1) { return(-1); @@ -276,58 +267,55 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich //TTN for D2D // 3GPP 36.331 (Section 5.10.7.4) -uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, uint32_t frame, uint8_t subframe, uint8_t in_coverage, uint8_t mode) -{ +uint8_t do_MIB_SL(const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, uint32_t frame, uint8_t subframe, uint8_t in_coverage, uint8_t mode) { + asn_enc_rval_t enc_rval; + LTE_SBCCH_SL_BCH_MessageType_t *mib_sl = &UE_rrc_inst[ctxt_pP->module_id].mib_sl[eNB_index]; + uint8_t sfn = (uint8_t)((frame>>2)&0xff); + UE_rrc_inst[ctxt_pP->module_id].MIB = (uint8_t *) malloc16(4); - asn_enc_rval_t enc_rval; - LTE_SBCCH_SL_BCH_MessageType_t *mib_sl = &UE_rrc_inst[ctxt_pP->module_id].mib_sl[eNB_index]; - uint8_t sfn = (uint8_t)((frame>>2)&0xff); - UE_rrc_inst[ctxt_pP->module_id].MIB = (uint8_t*) malloc16(4); - - if (in_coverage > 0 ){ - //in coverage - mib_sl->inCoverage_r12 = TRUE; - mib_sl->sl_Bandwidth_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth; - if (UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config) { - mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config->subframeAssignment; - } else { - mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = LTE_TDD_ConfigSL_r12__subframeAssignmentSL_r12_none; - } - //if triggered by sl communication - if (UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){ - mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; - } - //if triggered by sl discovery - if (UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){ - mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; - } - //Todo - if triggered by v2x - } else { - //Todo - out of coverage for V2X - // Todo - UE has a selected SyncRef UE - mib_sl->inCoverage_r12 = FALSE; - //set sl-Bandwidth, subframeAssignmentSL and reserved from the pre-configured parameters - } - - //set FrameNumber, subFrameNumber - mib_sl->directFrameNumber_r12.buf = &sfn; - mib_sl->directFrameNumber_r12.size = 1; - mib_sl->directFrameNumber_r12.bits_unused=0; - mib_sl->directSubframeNumber_r12 = subframe; + if (in_coverage > 0 ) { + //in coverage + mib_sl->inCoverage_r12 = TRUE; + mib_sl->sl_Bandwidth_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth; + if (UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config) { + mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config->subframeAssignment; + } else { + mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = LTE_TDD_ConfigSL_r12__subframeAssignmentSL_r12_none; + } - LOG_I(RRC,"[MIB-SL] sfn %x, subframe %x\n", (uint32_t)sfn, (uint8_t)subframe); + //if triggered by sl communication + if (UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12) { + mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; + } + + //if triggered by sl discovery + if (UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12) { + mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; + } + //Todo - if triggered by v2x + } else { + //Todo - out of coverage for V2X + // Todo - UE has a selected SyncRef UE + mib_sl->inCoverage_r12 = FALSE; + //set sl-Bandwidth, subframeAssignmentSL and reserved from the pre-configured parameters + } + //set FrameNumber, subFrameNumber + mib_sl->directFrameNumber_r12.buf = &sfn; + mib_sl->directFrameNumber_r12.size = 1; + mib_sl->directFrameNumber_r12.bits_unused=0; + mib_sl->directSubframeNumber_r12 = subframe; + LOG_I(RRC,"[MIB-SL] sfn %x, subframe %x\n", (uint32_t)sfn, (uint8_t)subframe); enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_SBCCH_SL_BCH_Message, NULL, - (void*)mib_sl, + (void *)mib_sl, UE_rrc_inst[ctxt_pP->module_id].MIB, 24); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - if (enc_rval.encoded==-1) { return(-1); } @@ -337,13 +325,11 @@ uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, - int Mod_id,int CC_id + int Mod_id,int CC_id #if defined(ENABLE_ITTI) - , RrcConfigurationReq *configuration + , RrcConfigurationReq *configuration #endif - ) -{ - + ) { // SystemInformation_t systemInformation; #if defined(ENABLE_ITTI) int num_plmn = configuration->num_plmn; @@ -355,20 +341,15 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, asn_enc_rval_t enc_rval; LTE_SchedulingInfo_t schedulingInfo; LTE_SIB_Type_t sib_type; - uint8_t *buffer = carrier->SIB1; LTE_BCCH_DL_SCH_Message_t *bcch_message = &carrier->siblock1; LTE_SystemInformationBlockType1_t **sib1 = &carrier->sib1; int i; - - memset(bcch_message,0,sizeof(LTE_BCCH_DL_SCH_Message_t)); bcch_message->message.present = LTE_BCCH_DL_SCH_MessageType_PR_c1; bcch_message->message.choice.c1.present = LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1; // memcpy(&bcch_message.message.choice.c1.choice.systemInformationBlockType1,sib1,sizeof(SystemInformationBlockType1_t)); - *sib1 = &bcch_message->message.choice.c1.choice.systemInformationBlockType1; - memset(PLMN_identity_info,0,num_plmn * sizeof(LTE_PLMN_IdentityInfo_t)); memset(&schedulingInfo,0,sizeof(LTE_SchedulingInfo_t)); memset(&sib_type,0,sizeof(LTE_SIB_Type_t)); @@ -377,9 +358,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, for (i = 0; i < configuration->num_plmn; ++i) { PLMN_identity_info[i].plmn_Identity.mcc = CALLOC(1,sizeof(*PLMN_identity_info[i].plmn_Identity.mcc)); memset(PLMN_identity_info[i].plmn_Identity.mcc,0,sizeof(*PLMN_identity_info[i].plmn_Identity.mcc)); - asn_set_empty(&PLMN_identity_info[i].plmn_Identity.mcc->list);//.size=0; - #if defined(ENABLE_ITTI) dummy_mcc[i][0] = (configuration->mcc[i] / 100) % 10; dummy_mcc[i][1] = (configuration->mcc[i] / 10) % 10; @@ -392,7 +371,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, ASN_SEQUENCE_ADD(&PLMN_identity_info[i].plmn_Identity.mcc->list,&dummy_mcc[i][0]); ASN_SEQUENCE_ADD(&PLMN_identity_info[i].plmn_Identity.mcc->list,&dummy_mcc[i][1]); ASN_SEQUENCE_ADD(&PLMN_identity_info[i].plmn_Identity.mcc->list,&dummy_mcc[i][2]); - PLMN_identity_info[i].plmn_Identity.mnc.list.size=0; PLMN_identity_info[i].plmn_Identity.mnc.list.count=0; #if defined(ENABLE_ITTI) @@ -427,11 +405,9 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, //assign_enum(&PLMN_identity_info.cellReservedForOperatorUse,PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved); PLMN_identity_info[i].cellReservedForOperatorUse=LTE_PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved; - ASN_SEQUENCE_ADD(&(*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list,&PLMN_identity_info[i]); } - // 16 bits (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf = MALLOC(2); #if defined(ENABLE_ITTI) @@ -443,7 +419,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, #endif (*sib1)->cellAccessRelatedInfo.trackingAreaCode.size=2; (*sib1)->cellAccessRelatedInfo.trackingAreaCode.bits_unused=0; - // 28 bits (*sib1)->cellAccessRelatedInfo.cellIdentity.buf = MALLOC(8); #if defined(ENABLE_ITTI) @@ -459,14 +434,11 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, #endif (*sib1)->cellAccessRelatedInfo.cellIdentity.size=4; (*sib1)->cellAccessRelatedInfo.cellIdentity.bits_unused=4; - // assign_enum(&(*sib1)->cellAccessRelatedInfo.cellBarred,SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred); (*sib1)->cellAccessRelatedInfo.cellBarred=LTE_SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred; - // assign_enum(&(*sib1)->cellAccessRelatedInfo.intraFreqReselection,SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed); (*sib1)->cellAccessRelatedInfo.intraFreqReselection=LTE_SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_notAllowed; (*sib1)->cellAccessRelatedInfo.csg_Indication=0; - (*sib1)->cellSelectionInfo.q_RxLevMin=-65; (*sib1)->cellSelectionInfo.q_RxLevMinOffset=NULL; //(*sib1)->p_Max = CALLOC(1, sizeof(P_Max_t)); @@ -477,53 +449,45 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, #else 7; #endif - schedulingInfo.si_Periodicity=LTE_SchedulingInfo__si_Periodicity_rf8; - // This is for SIB2/3 sib_type=LTE_SIB_Type_sibType3; ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type); ASN_SEQUENCE_ADD(&(*sib1)->schedulingInfoList.list,&schedulingInfo); - // ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,NULL); - #if defined(ENABLE_ITTI) if (configuration->frame_type[CC_id] == TDD) #endif { (*sib1)->tdd_Config = CALLOC(1,sizeof(struct LTE_TDD_Config)); - (*sib1)->tdd_Config->subframeAssignment = #if defined(ENABLE_ITTI) configuration->tdd_config[CC_id]; #else 3; #endif - (*sib1)->tdd_Config->specialSubframePatterns = #if defined(ENABLE_ITTI) configuration->tdd_config_s[CC_id]; #else - 0; + 0; #endif } (*sib1)->si_WindowLength=LTE_SystemInformationBlockType1__si_WindowLength_ms20; (*sib1)->systemInfoValueTag=0; // (*sib1).nonCriticalExtension = calloc(1,sizeof(*(*sib1).nonCriticalExtension)); - #ifdef XER_PRINT - xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message); + xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message); #endif enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_DL_SCH_Message, NULL, - (void*)bcch_message, + (void *)bcch_message, buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -532,7 +496,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size); @@ -541,7 +504,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, } # endif #endif - LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); if (enc_rval.encoded==-1) { @@ -555,13 +517,10 @@ uint8_t do_SIB23(uint8_t Mod_id, int CC_id #if defined(ENABLE_ITTI) - , RrcConfigurationReq *configuration + , RrcConfigurationReq *configuration #endif - ) -{ - + ) { struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib2_part,*sib3_part; - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) //TTN - for D2D struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib18_part, *sib19_part, *sib21_part; @@ -573,7 +532,6 @@ uint8_t do_SIB23(uint8_t Mod_id, //struct SL_DiscResourcePool_r12 *SL_DiscResourcePoolPS; //for SIB19 (discRxPoolPS) //struct SL_V2X_ConfigCommon_r14 *SL_V2X_ConfigCommon; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib13_part; LTE_MBSFN_SubframeConfigList_t *MBSFNSubframeConfigList; @@ -581,7 +539,6 @@ uint8_t do_SIB23(uint8_t Mod_id, struct LTE_MBSFN_AreaInfo_r9 *MBSFN_Area1, *MBSFN_Area2; #endif asn_enc_rval_t enc_rval; - uint8_t *buffer = RC.rrc[Mod_id]->carrier[CC_id].SIB23; LTE_BCCH_DL_SCH_Message_t *bcch_message = &RC.rrc[Mod_id]->carrier[CC_id].systemInformation; LTE_SystemInformationBlockType2_t **sib2 = &RC.rrc[Mod_id]->carrier[CC_id].sib2; @@ -590,7 +547,6 @@ uint8_t do_SIB23(uint8_t Mod_id, LTE_SystemInformationBlockType13_r9_t **sib13 = &RC.rrc[Mod_id]->carrier[CC_id].sib13; uint8_t MBMS_flag = RC.rrc[Mod_id]->carrier[CC_id].MBMS_flag; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //TTN - for D2D LTE_SystemInformationBlockType18_r12_t **sib18 = &RC.rrc[Mod_id]->carrier[CC_id].sib18; @@ -624,13 +580,10 @@ uint8_t do_SIB23(uint8_t Mod_id, sib3_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); memset(sib2_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); memset(sib3_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); - sib2_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2; sib3_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3; - *sib2 = &sib2_part->choice.sib2; *sib3 = &sib3_part->choice.sib3; - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flag > 0) { @@ -641,7 +594,6 @@ uint8_t do_SIB23(uint8_t Mod_id, } #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //TTN - for D2D sib18_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); @@ -650,28 +602,20 @@ uint8_t do_SIB23(uint8_t Mod_id, memset(sib18_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); memset(sib19_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); memset(sib21_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); - sib18_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250; sib19_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250; sib21_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430; - *sib18 = &sib18_part->choice.sib18_v1250; *sib19 = &sib19_part->choice.sib19_v1250; *sib21 = &sib21_part->choice.sib21_v1430; - #endif - - // sib2 - (*sib2)->ac_BarringInfo = NULL; #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (*sib2)->ext1 = NULL; (*sib2)->ext2 = NULL; #endif - #if defined(ENABLE_ITTI) - (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles = configuration->rach_numberOfRA_Preambles[CC_id]; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL; @@ -694,20 +638,17 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer = configuration->rach_macContentionResolutionTimer[CC_id]; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = configuration->rach_maxHARQ_Msg3Tx[CC_id]; - // BCCH-Config (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff = configuration->bcch_modificationPeriodCoeff[CC_id]; - // PCCH-Config (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle = configuration->pcch_defaultPagingCycle[CC_id]; (*sib2)->radioResourceConfigCommon.pcch_Config.nB = configuration->pcch_nB[CC_id]; LOG_I(RRC,"[SIB2] With ITTI. Basic config of paging cycle DRX: radio frame cycle length %x, paging occasion number %x\n", - (uint32_t)configuration->pcch_defaultPagingCycle[CC_id], - (uint32_t)configuration->pcch_nB[CC_id]); - + (uint32_t)configuration->pcch_defaultPagingCycle[CC_id], + (uint32_t)configuration->pcch_nB[CC_id]); // PRACH-Config (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex = configuration->prach_root[CC_id]; @@ -719,13 +660,11 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->prach_zero_correlation[CC_id]; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset = configuration->prach_freq_offset[CC_id]; - // PDSCH-Config (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower = configuration->pdsch_referenceSignalPower[CC_id]; (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b = configuration->pdsch_p_b[CC_id]; - // PUSCH-Config (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB = configuration->pusch_n_SB[CC_id]; @@ -743,19 +682,17 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->pusch_sequenceHoppingEnabled[CC_id]; (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift = configuration->pusch_nDMRS1[CC_id]; - // PUCCH-Config - (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift = configuration->pucch_delta_shift[CC_id]; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI = configuration->pucch_nRB_CQI[CC_id]; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN = configuration->pucch_nCS_AN[CC_id]; -//#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0)) + //#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0)) (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN = configuration->pucch_n1_AN[CC_id]; -//#endif + //#endif // SRS Config if (configuration->srs_enable[CC_id]==1) { @@ -775,6 +712,7 @@ uint8_t do_SIB23(uint8_t Mod_id, } else { (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts = NULL; } + RC.rrc[Mod_id]->srs_enable[CC_id] = 1; } else { RC.rrc[Mod_id]->srs_enable[CC_id] = 0; @@ -783,7 +721,6 @@ uint8_t do_SIB23(uint8_t Mod_id, } // uplinkPowerControlCommon - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH = configuration->pusch_p0_Nominal[CC_id]; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH @@ -804,9 +741,7 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->msg3_delta_Preamble[CC_id]; (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength = configuration->ul_CyclicPrefixLength[CC_id]; - // UE Timers and Constants - (*sib2)->ue_TimersAndConstants.t300 = configuration->ue_TimersAndConstants_t300[CC_id]; (*sib2)->ue_TimersAndConstants.t301 @@ -819,7 +754,6 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->ue_TimersAndConstants_t311[CC_id]; (*sib2)->ue_TimersAndConstants.n311 = configuration->ue_TimersAndConstants_n311[CC_id]; - #else (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles=LTE_RACH_ConfigCommon__preambleInfo__numberOfRA_Preambles_n64; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL; @@ -831,27 +765,20 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer= LTE_RACH_ConfigCommon__ra_SupervisionInfo__mac_ContentionResolutionTimer_sf48; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = 4; - // BCCH-Config (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff=BCCH_Config__modificationPeriodCoeff_n2; - // PCCH-Config (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle = LTE_PCCH_Config__defaultPagingCycle_rf128; (*sib2)->radioResourceConfigCommon.pcch_Config.nB=LTE_PCCH_Config__nB_oneT; - // PRACH-Config (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex=Mod_id;//0;//384; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex = 0;//3; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag = 0; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig = 1;//12; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset = 2; - // PDSCH-Config (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower=0; // corresponds to 24.7 dBm 5 MHz/ 27.7 10 MHz/ 30.7 20 MHz - - (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=0; - // PUSCH-Config (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB=1; (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode=LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame; @@ -861,55 +788,35 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH=0; (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled=0; (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift=0; - // PUCCH-Config - (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift=LTE_PUCCH_ConfigCommon__deltaPUCCH_Shift_ds1; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI = 1; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN = 0; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN = 32; - - (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present=LTE_SoundingRS_UL_ConfigCommon_PR_release; (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.release=0; - // uplinkPowerControlCommon - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH = -108; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH = -108; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.alpha=LTE_UplinkPowerControlCommon__alpha_al1; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3; - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0; - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0; - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0; - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 = 6; - (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength=UL_CyclicPrefixLength_len1; - (*sib2)->ue_TimersAndConstants.t300=UE_TimersAndConstants__t300_ms1000; - (*sib2)->ue_TimersAndConstants.t301=UE_TimersAndConstants__t301_ms1000; - (*sib2)->ue_TimersAndConstants.t310=UE_TimersAndConstants__t310_ms1000; - (*sib2)->ue_TimersAndConstants.n310=UE_TimersAndConstants__n310_n20; - (*sib2)->ue_TimersAndConstants.t311=UE_TimersAndConstants__t311_ms10000; - (*sib2)->ue_TimersAndConstants.n311=UE_TimersAndConstants__n311_n1; - #endif - (*sib2)->freqInfo.additionalSpectrumEmission = 1; (*sib2)->freqInfo.ul_CarrierFreq = NULL; (*sib2)->freqInfo.ul_Bandwidth = NULL; // (*sib2)->mbsfn_SubframeConfigList = NULL; - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flag > 0) { @@ -917,37 +824,29 @@ uint8_t do_SIB23(uint8_t Mod_id, LTE_MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig1; (*sib2)->mbsfn_SubframeConfigList = CALLOC(1,sizeof(struct LTE_MBSFN_SubframeConfigList)); MBSFNSubframeConfigList = (*sib2)->mbsfn_SubframeConfigList; - sib2_mbsfn_SubframeConfig1= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig1)); - memset((void*)sib2_mbsfn_SubframeConfig1,0,sizeof(*sib2_mbsfn_SubframeConfig1)); - + memset((void *)sib2_mbsfn_SubframeConfig1,0,sizeof(*sib2_mbsfn_SubframeConfig1)); sib2_mbsfn_SubframeConfig1->radioframeAllocationPeriod= LTE_MBSFN_SubframeConfig__radioframeAllocationPeriod_n4; sib2_mbsfn_SubframeConfig1->radioframeAllocationOffset= 1; sib2_mbsfn_SubframeConfig1->subframeAllocation.present= LTE_MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame; sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf= MALLOC(1); sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.size= 1; sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.bits_unused= 2; - sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2; - ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig1); if (MBMS_flag == 4 ) { LOG_I(RRC,"Adding MBSFN subframe Configuration 2 to SIB2\n"); LTE_MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig2; sib2_mbsfn_SubframeConfig2= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig2)); - memset((void*)sib2_mbsfn_SubframeConfig2,0,sizeof(*sib2_mbsfn_SubframeConfig2)); - + memset((void *)sib2_mbsfn_SubframeConfig2,0,sizeof(*sib2_mbsfn_SubframeConfig2)); sib2_mbsfn_SubframeConfig2->radioframeAllocationPeriod= LTE_MBSFN_SubframeConfig__radioframeAllocationPeriod_n4; sib2_mbsfn_SubframeConfig2->radioframeAllocationOffset= 1; sib2_mbsfn_SubframeConfig2->subframeAllocation.present= LTE_MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame; sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf= MALLOC(1); sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.size= 1; sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.bits_unused= 2; - sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2; - - ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig2); } } @@ -955,29 +854,22 @@ uint8_t do_SIB23(uint8_t Mod_id, #else // no MBMS transmission (*sib2)->mbsfn_SubframeConfigList = NULL; #endif - (*sib2)->timeAlignmentTimerCommon=LTE_TimeAlignmentTimer_infinity;//TimeAlignmentTimer_sf5120; - /// (*SIB3) #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (*sib3)->ext1 = NULL; #endif (*sib3)->cellReselectionInfoCommon.q_Hyst=LTE_SystemInformationBlockType3__cellReselectionInfoCommon__q_Hyst_dB4; - (*sib3)->cellReselectionInfoCommon.speedStateReselectionPars=NULL; - (*sib3)->cellReselectionServingFreqInfo.s_NonIntraSearch=NULL; (*sib3)->cellReselectionServingFreqInfo.threshServingLow=31; (*sib3)->cellReselectionServingFreqInfo.cellReselectionPriority=7; - (*sib3)->intraFreqCellReselectionInfo.q_RxLevMin = -70; (*sib3)->intraFreqCellReselectionInfo.p_Max = NULL; (*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch)); *(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = 31; (*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth=CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth)); - *(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth = LTE_AllowedMeasBandwidth_mbw6; - (*sib3)->intraFreqCellReselectionInfo.presenceAntennaPort1 = 0; (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.buf = CALLOC(8,1); (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.size = 1; @@ -985,7 +877,6 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.bits_unused = 6; (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA = 1; (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA_SF = (struct LTE_SpeedStateScaleFactors *)NULL; - // SIB13 // fill in all elements of SIB13 if present #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) @@ -995,7 +886,6 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib13)->notificationConfig_r9.notificationRepetitionCoeff_r9= LTE_MBMS_NotificationConfig_r9__notificationRepetitionCoeff_r9_n2; (*sib13)->notificationConfig_r9.notificationOffset_r9= 0; (*sib13)->notificationConfig_r9.notificationSF_Index_r9= 1; - // MBSFN-AreaInfoList MBSFNArea_list= &(*sib13)->mbsfn_AreaInfoList_r9;//CALLOC(1,sizeof(*MBSFNArea_list)); memset(MBSFNArea_list,0,sizeof(*MBSFNArea_list)); @@ -1010,14 +900,9 @@ uint8_t do_SIB23(uint8_t Mod_id, // Subframe Allocation Info MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1); MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.size= 1; - MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x20<<2; // FDD: SF1 - - MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2; - MBSFN_Area1->mcch_Config_r9.signallingMCS_r9= LTE_MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7; - ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area1); //MBSFN Area 2: currently only activated for eMBMS relaying @@ -1033,12 +918,8 @@ uint8_t do_SIB23(uint8_t Mod_id, MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1); MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.size= 1; MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2; - MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x04<<2; // FDD: SF6 - - MBSFN_Area2->mcch_Config_r9.signallingMCS_r9= LTE_MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7; - ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area2); } @@ -1046,8 +927,6 @@ uint8_t do_SIB23(uint8_t Mod_id, } #endif - - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //TTN - for D2D // SIB18 @@ -1055,10 +934,8 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib18)->commConfig_r12 = CALLOC (1, sizeof(*(*sib18)->commConfig_r12)); SL_CommRxPoolList= &(*sib18)->commConfig_r12->commRxPool_r12; memset(SL_CommRxPoolList,0,sizeof(*SL_CommRxPoolList)); - SL_CommResourcePool = CALLOC(1, sizeof(*SL_CommResourcePool)); memset(SL_CommResourcePool,0,sizeof(*SL_CommResourcePool)); - SL_CommResourcePool->sc_CP_Len_r12 = configuration->rxPool_sc_CP_Len[CC_id]; SL_CommResourcePool->sc_Period_r12 = configuration->rxPool_sc_Period[CC_id]; SL_CommResourcePool->data_CP_Len_r12 = configuration->rxPool_data_CP_Len[CC_id]; @@ -1069,54 +946,54 @@ uint8_t do_SIB23(uint8_t Mod_id, SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = configuration->rxPool_ResourceConfig_offsetIndicator_present[CC_id]; if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_small_r12 ) { - SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; - } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ){ - SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ) { + SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; } SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = configuration->rxPool_ResourceConfig_subframeBitmap_present[CC_id]; - if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12){ - //for BS4 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12){ - //for BS8 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12){ - //for BS12 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12){ - //for BS16 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12){ - //for BS30 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12){ - //for BS40 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12){ - //for BS42 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + + if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12) { + //for BS4 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12) { + //for BS8 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12) { + //for BS12 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12) { + //for BS16 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12) { + //for BS30 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12) { + //for BS40 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12) { + //for BS42 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; } //dataHoppingConfig_r12 SL_CommResourcePool->dataHoppingConfig_r12.hoppingParameter_r12 = 0; SL_CommResourcePool->dataHoppingConfig_r12.numSubbands_r12 = LTE_SL_HoppingConfigComm_r12__numSubbands_r12_ns1; SL_CommResourcePool->dataHoppingConfig_r12.rb_Offset_r12 = 0; - //ue_SelectedResourceConfig_r12 SL_CommResourcePool->ue_SelectedResourceConfig_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->ue_SelectedResourceConfig_r12)); SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Num_r12 = 20; @@ -1144,13 +1021,11 @@ uint8_t do_SIB23(uint8_t Mod_id, SL_CommResourcePool->txParameters_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->txParameters_r12)); SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.alpha_r12 = LTE_Alpha_r12_al0; SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.p0_r12 = 0; - SL_CommResourcePool->ext1 = NULL ; //end SL_CommResourcePool //add SL_CommResourcePool to SL_CommRxPoolList ASN_SEQUENCE_ADD(&SL_CommRxPoolList->list,SL_CommResourcePool); //end commRxPool_r12 - //TODO: commTxPoolNormalCommon_r12, similar to commRxPool_r12 //TODO: commTxPoolExceptional_r12 //TODO: commSyncConfig_r12 @@ -1158,17 +1033,14 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib18)->ext1 = NULL; (*sib18)->lateNonCriticalExtension = NULL; // end SIB18 - // SIB19 // fill in all elements of SIB19 if present - //discConfig_r12 (*sib19)->discConfig_r12 = CALLOC (1, sizeof(*(*sib19)->discConfig_r12)); SL_DiscRxPoolList = &(*sib19)->discConfig_r12->discRxPool_r12; memset(SL_DiscRxPoolList,0,sizeof(*SL_DiscRxPoolList)); //fill SL_DiscResourcePool SL_DiscResourcePool = CALLOC(1, sizeof(*SL_DiscResourcePool)); - SL_DiscResourcePool->cp_Len_r12 = configuration->discRxPool_cp_Len[CC_id]; SL_DiscResourcePool->discPeriod_r12 = configuration->discRxPool_discPeriod[CC_id]; //sc_TF_ResourceConfig_r12 @@ -1178,137 +1050,134 @@ uint8_t do_SIB23(uint8_t Mod_id, SL_DiscResourcePool->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPool_ResourceConfig_prb_Start[CC_id]; SL_DiscResourcePool->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPool_ResourceConfig_prb_End[CC_id]; SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPool_ResourceConfig_offsetIndicator_present[CC_id]; + if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_small_r12 ) { - SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; - } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ){ - SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ) { + SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; } + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPool_ResourceConfig_subframeBitmap_present[CC_id]; - if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12){ - //for BS4 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12){ - //for BS8 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12){ - //for BS12 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12){ - //for BS16 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12){ - //for BS30 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12){ - //for BS40 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12){ - //for BS42 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + + if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12) { + //for BS4 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12) { + //for BS8 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12) { + //for BS12 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12) { + //for BS16 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12) { + //for BS30 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12) { + //for BS40 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12) { + //for BS42 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; } //add SL_DiscResourcePool to SL_DiscRxPoolList ASN_SEQUENCE_ADD(&SL_DiscRxPoolList->list,SL_DiscResourcePool); + /* + //for DiscRxPoolPS + (*sib19)->ext1 = CALLOC (1, sizeof(*(*sib19)->ext1)); + (*sib19)->ext1->discConfigPS_13 = CALLOC (1, sizeof(*((*sib19)->ext1->discConfigPS_13))); + + SL_DiscRxPoolPSList = &(*sib19)->ext1->discConfigPS_13->discRxPoolPS_r13; + memset(SL_DiscRxPoolPSList,0,sizeof(*SL_DiscRxPoolPSList)); + //fill SL_DiscResourcePool + SL_DiscResourcePoolPS = CALLOC(1, sizeof(*SL_DiscResourcePoolPS)); + + SL_DiscResourcePoolPS->cp_Len_r12 = configuration->discRxPoolPS_cp_Len[CC_id]; + SL_DiscResourcePoolPS->discPeriod_r12 = configuration->discRxPoolPS_discPeriod[CC_id]; + //sc_TF_ResourceConfig_r12 + SL_DiscResourcePoolPS->numRetx_r12 = configuration->discRxPoolPS_numRetx[CC_id]; + SL_DiscResourcePoolPS->numRepetition_r12 = configuration->discRxPoolPS_numRepetition[CC_id]; + + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Num[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Start[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPoolPS_ResourceConfig_prb_End[CC_id]; + + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_present[CC_id]; + if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_small_r12 ) { + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_large_r12 ){ + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; + } -/* - //for DiscRxPoolPS - (*sib19)->ext1 = CALLOC (1, sizeof(*(*sib19)->ext1)); - (*sib19)->ext1->discConfigPS_13 = CALLOC (1, sizeof(*((*sib19)->ext1->discConfigPS_13))); - - SL_DiscRxPoolPSList = &(*sib19)->ext1->discConfigPS_13->discRxPoolPS_r13; - memset(SL_DiscRxPoolPSList,0,sizeof(*SL_DiscRxPoolPSList)); - //fill SL_DiscResourcePool - SL_DiscResourcePoolPS = CALLOC(1, sizeof(*SL_DiscResourcePoolPS)); - - SL_DiscResourcePoolPS->cp_Len_r12 = configuration->discRxPoolPS_cp_Len[CC_id]; - SL_DiscResourcePoolPS->discPeriod_r12 = configuration->discRxPoolPS_discPeriod[CC_id]; - //sc_TF_ResourceConfig_r12 - SL_DiscResourcePoolPS->numRetx_r12 = configuration->discRxPoolPS_numRetx[CC_id]; - SL_DiscResourcePoolPS->numRepetition_r12 = configuration->discRxPoolPS_numRepetition[CC_id]; - - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Num[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Start[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPoolPS_ResourceConfig_prb_End[CC_id]; - - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_present[CC_id]; - if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_small_r12 ) { - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; - } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_large_r12 ){ - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; - } - - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_present[CC_id]; - if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs4_r12){ - //for BS4 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs8_r12){ - //for BS8 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs12_r12){ - //for BS12 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs16_r12){ - //for BS16 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs30_r12){ - //for BS30 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs40_r12){ - //for BS40 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs42_r12){ - //for BS42 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } - - //add SL_DiscResourcePool to SL_DiscRxPoolList - ASN_SEQUENCE_ADD(&SL_DiscRxPoolPSList->list,SL_DiscResourcePoolPS); -*/ + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_present[CC_id]; + if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs4_r12){ + //for BS4 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs8_r12){ + //for BS8 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs12_r12){ + //for BS12 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs16_r12){ + //for BS16 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs30_r12){ + //for BS30 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs40_r12){ + //for BS40 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs42_r12){ + //for BS42 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } + //add SL_DiscResourcePool to SL_DiscRxPoolList + ASN_SEQUENCE_ADD(&SL_DiscRxPoolPSList->list,SL_DiscResourcePoolPS); + */ (*sib19)->lateNonCriticalExtension = NULL; //end SIB19 - //SIB21 (*sib21)->sl_V2X_ConfigCommon_r14 = CALLOC (1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14)); //SL_V2X_ConfigCommon= (*sib21)->sl_V2X_ConfigCommon_r14; memset((*sib21)->sl_V2X_ConfigCommon_r14,0,sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14)); - struct LTE_SL_CommRxPoolListV2X_r14 *SL_CommRxPoolListV2X; struct LTE_SL_CommResourcePoolV2X_r14 *SL_CommResourcePoolV2X; (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14 = CALLOC(1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14)); SL_CommRxPoolListV2X = (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14; - SL_CommResourcePoolV2X = CALLOC(1, sizeof(*SL_CommResourcePoolV2X)); memset(SL_CommResourcePoolV2X,0,sizeof(*SL_CommResourcePoolV2X)); - SL_CommResourcePoolV2X->sl_OffsetIndicator_r14 = CALLOC(1, sizeof(*SL_CommResourcePoolV2X->sl_OffsetIndicator_r14)); SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->present = LTE_SL_OffsetIndicator_r12_PR_small_r12; SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->choice.small_r12 = 0; @@ -1321,34 +1190,26 @@ uint8_t do_SIB23(uint8_t Mod_id, SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[2] = 0xFF; SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[3] = 0xFF; SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[4] = 0xFF; - SL_CommResourcePoolV2X->adjacencyPSCCH_PSSCH_r14 = 1; SL_CommResourcePoolV2X->sizeSubchannel_r14 = 10; SL_CommResourcePoolV2X->numSubchannel_r14 = 5; SL_CommResourcePoolV2X->startRB_Subchannel_r14 = 10; - //rxParametersNCell_r12 SL_CommResourcePoolV2X->rxParametersNCell_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14)); SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14)); SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->subframeAssignment = 0 ; SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->specialSubframePatterns = 0; SL_CommResourcePoolV2X->rxParametersNCell_r14->syncConfigIndex_r14 = 0; - ASN_SEQUENCE_ADD(&SL_CommRxPoolListV2X->list,SL_CommResourcePoolV2X); //end SIB21 #endif - - bcch_message->message.present = LTE_BCCH_DL_SCH_MessageType_PR_c1; bcch_message->message.choice.c1.present = LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformation; - /* memcpy((void*)&bcch_message.message.choice.c1.choice.systemInformation, (void*)systemInformation, sizeof(SystemInformation_t));*/ - bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = LTE_SystemInformation__criticalExtensions_PR_systemInformation_r8; bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count=0; - // asn_set_empty(&systemInformation->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list);//.size=0; // systemInformation->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count=0; ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, @@ -1360,20 +1221,20 @@ uint8_t do_SIB23(uint8_t Mod_id, if (MBMS_flag > 0) { ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list,sib13_part); } + #endif if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_BCCH_DL_SCH_Message, (void*)bcch_message); + xer_fprint(stdout, &asn_DEF_LTE_BCCH_DL_SCH_Message, (void *)bcch_message); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_DL_SCH_Message, NULL, - (void*)bcch_message, + (void *)bcch_message, buffer, 900); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - - #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1382,17 +1243,14 @@ uint8_t do_SIB23(uint8_t Mod_id, if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); } } # endif #endif - LOG_D(RRC,"[eNB] SystemInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); if (enc_rval.encoded==-1) { @@ -1403,22 +1261,15 @@ uint8_t do_SIB23(uint8_t Mod_id, return((enc_rval.encoded+7)/8); } -uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) -{ - +uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { asn_enc_rval_t enc_rval; uint8_t buf[5],buf2=0; - LTE_UL_CCCH_Message_t ul_ccch_msg; - LTE_RRCConnectionRequest_t *rrcConnectionRequest; - memset((void *)&ul_ccch_msg,0,sizeof(LTE_UL_CCCH_Message_t)); - ul_ccch_msg.message.present = LTE_UL_CCCH_MessageType_PR_c1; ul_ccch_msg.message.choice.c1.present = LTE_UL_CCCH_MessageType__c1_PR_rrcConnectionRequest; rrcConnectionRequest = &ul_ccch_msg.message.choice.c1.choice.rrcConnectionRequest; - rrcConnectionRequest->criticalExtensions.present = LTE_RRCConnectionRequest__criticalExtensions_PR_rrcConnectionRequest_r8; if (1) { @@ -1447,20 +1298,16 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) } rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.establishmentCause = LTE_EstablishmentCause_mo_Signalling; //EstablishmentCause_mo_Data; - rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.buf = &buf2; rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.size=1; rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.bits_unused = 7; - - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_CCCH_Message, NULL, - (void*)&ul_ccch_msg, + (void *)&ul_ccch_msg, buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1469,219 +1316,196 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_UL_CCCH_Message, (void *) &ul_ccch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_CCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_ul_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ul_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); } } # endif #endif - LOG_D(RRC,"[UE] RRCConnectionRequest Encoded %zd bits (%zd bytes) \n",enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); - } //TTN for D2D - 3GPP TS 36.331 (Section 5.10.2.3) -uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer, LTE_SL_DestinationInfoList_r12_t *destinationInfoList, long *discTxResourceReq, SL_TRIGGER_t mode) -{ - - asn_enc_rval_t enc_rval; - LTE_UL_DCCH_Message_t ul_dcch_msg; - LTE_SidelinkUEInformation_r12_t *sidelinkUEInformation; - LTE_ARFCN_ValueEUTRA_r9_t carrierFreq = 25655;//sidelink communication frequency (hardcoded - should come from SIB2) - - memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_messageClassExtension; - ul_dcch_msg.message.choice.messageClassExtension.present = LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2; - ul_dcch_msg.message.choice.messageClassExtension.choice.c2.present = LTE_UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12; - sidelinkUEInformation = &ul_dcch_msg.message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12; - - //3GPP TS 36.331 (Section 5.10.2.3) - sidelinkUEInformation->criticalExtensions.present = LTE_SidelinkUEInformation_r12__criticalExtensions_PR_c1; - sidelinkUEInformation->criticalExtensions.choice.c1.present = LTE_SidelinkUEInformation_r12__criticalExtensions__c1_PR_sidelinkUEInformation_r12; - switch(mode) { - //if SIB18 is available - case SL_RECEIVE_COMMUNICATION: // to receive sidelink communication +uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer, LTE_SL_DestinationInfoList_r12_t *destinationInfoList, long *discTxResourceReq, SL_TRIGGER_t mode) { + asn_enc_rval_t enc_rval; + LTE_UL_DCCH_Message_t ul_dcch_msg; + LTE_SidelinkUEInformation_r12_t *sidelinkUEInformation; + LTE_ARFCN_ValueEUTRA_r9_t carrierFreq = 25655;//sidelink communication frequency (hardcoded - should come from SIB2) + memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); + ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_messageClassExtension; + ul_dcch_msg.message.choice.messageClassExtension.present = LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2; + ul_dcch_msg.message.choice.messageClassExtension.choice.c2.present = LTE_UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12; + sidelinkUEInformation = &ul_dcch_msg.message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12; + //3GPP TS 36.331 (Section 5.10.2.3) + sidelinkUEInformation->criticalExtensions.present = LTE_SidelinkUEInformation_r12__criticalExtensions_PR_c1; + sidelinkUEInformation->criticalExtensions.choice.c1.present = LTE_SidelinkUEInformation_r12__criticalExtensions__c1_PR_sidelinkUEInformation_r12; + + switch(mode) { + //if SIB18 is available + case SL_RECEIVE_COMMUNICATION: // to receive sidelink communication sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12)); - memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12, (void*)&carrierFreq, - sizeof(LTE_ARFCN_ValueEUTRA_r9_t)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12)); + memcpy((void *)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12, (void *)&carrierFreq, + sizeof(LTE_ARFCN_ValueEUTRA_r9_t)); break; - case SL_TRANSMIT_NON_RELAY_ONE_TO_MANY: //to transmit non-relay related one-to-many sidelink communication + case SL_TRANSMIT_NON_RELAY_ONE_TO_MANY: //to transmit non-relay related one-to-many sidelink communication //commTxResourceReq sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12)); - memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12, (void*)&carrierFreq, - sizeof(LTE_ARFCN_ValueEUTRA_r9_t)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12)); + memcpy((void *)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12, (void *)&carrierFreq, + sizeof(LTE_ARFCN_ValueEUTRA_r9_t)); memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12, - destinationInfoList, - sizeof(LTE_SL_DestinationInfoList_r12_t)); + destinationInfoList, + sizeof(LTE_SL_DestinationInfoList_r12_t)); break; - case SL_TRANSMIT_NON_RELAY_ONE_TO_ONE://transmit non-relay related one-to-one sidelink communication + case SL_TRANSMIT_NON_RELAY_ONE_TO_ONE://transmit non-relay related one-to-one sidelink communication //if commTxResourceUC-ReqAllowed is included in SIB18 sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); - + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12)); - memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12, (void*)&carrierFreq, - sizeof (LTE_ARFCN_ValueEUTRA_r9_t)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12)); + memcpy((void *)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12, (void *)&carrierFreq, + sizeof (LTE_ARFCN_ValueEUTRA_r9_t)); memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12, - destinationInfoList, - sizeof(LTE_SL_DestinationInfoList_r12_t)); + destinationInfoList, + sizeof(LTE_SL_DestinationInfoList_r12_t)); break; - case SL_TRANSMIT_RELAY_ONE_TO_ONE: //transmit relay related one-to-one sidelink communication + case SL_TRANSMIT_RELAY_ONE_TO_ONE: //transmit relay related one-to-one sidelink communication //if SIB19 includes discConfigRelay and UE acts a relay or UE has a selected relay sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13= CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13)); memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12, - destinationInfoList, - sizeof(*destinationInfoList)); + destinationInfoList, + sizeof(*destinationInfoList)); //set ue-type to relayUE or remoteUE - sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 =LTE_SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 + =LTE_SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; //sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12->nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 =SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_remoteUE; break; - case SL_TRANSMIT_RELAY_ONE_TO_MANY: //transmit relay related one-to-many sidelink communication + case SL_TRANSMIT_RELAY_ONE_TO_MANY: //transmit relay related one-to-many sidelink communication //if SIB19 includes discConfigRelay and UE acts a relay //set ue-type to relayUE sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13= CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13)); - sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 = LTE_SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 = + LTE_SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12, - destinationInfoList, - sizeof(*destinationInfoList)); + destinationInfoList, + sizeof(*destinationInfoList)); break; - //if SIB19 is available - //we consider only one frequency - a serving frequency - case SL_RECEIVE_DISCOVERY: //receive sidelink discovery announcements - + //if SIB19 is available + //we consider only one frequency - a serving frequency + case SL_RECEIVE_DISCOVERY: //receive sidelink discovery announcements sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12)); *sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12 = LTE_SidelinkUEInformation_r12_IEs__discRxInterest_r12_true; break; - case SL_TRANSMIT_NON_PS_DISCOVERY://to transmit non-PS related sidelink discovery announcements + + case SL_TRANSMIT_NON_PS_DISCOVERY://to transmit non-PS related sidelink discovery announcements //for the first frequency sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12)); - - memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12, - (void*)discTxResourceReq, - sizeof(long)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12)); + memcpy((void *)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12, + (void *)discTxResourceReq, + sizeof(long)); //for additional frequency break; - case SL_TRANSMIT_PS_DISCOVERY://to transmit PS related sidelink discovery announcements + case SL_TRANSMIT_PS_DISCOVERY://to transmit PS related sidelink discovery announcements //if to transmit non-relay PS related discovery announcements and SIB19 includes discConfigPS //if UE is acting as relay UE and SIB includes discConfigRelay (relay threshold condition) //if relay UE/has a selected relay UE and if SIB19 includes discConfigRelay sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13 = *discTxResourceReq; break; - //SIB21 - case SL_RECEIVE_V2X: + + //SIB21 + case SL_RECEIVE_V2X: //TODO break; - case SL_TRANSMIT_V2X: + + case SL_TRANSMIT_V2X: //TODO break; - //TODO: request sidelink discovery transmission/reception gaps - //TODO: report the system information parameters related to sidelink discovery of carriers other than the primary - default: - break; - } - - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void*)&ul_dcch_msg); - } + //TODO: request sidelink discovery transmission/reception gaps + //TODO: report the system information parameters related to sidelink discovery of carriers other than the primary + default: + break; + } - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, - NULL, - (void*)&ul_dcch_msg, - buffer, - 100); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); + } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, + NULL, + (void *)&ul_dcch_msg, + buffer, + 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) - { - char message_string[20000]; - size_t message_string_size; - - if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { - MessageDef *msg_p; - - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); - msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; - memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); + { + char message_string[20000]; + size_t message_string_size; - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); - } - } + if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { + MessageDef *msg_p; + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); + itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); + } + } # endif #endif - #ifdef USER_MODE - LOG_D(RRC,"SidelinkUEInformation Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_D(RRC,"SidelinkUEInformation Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); #endif - - return((enc_rval.encoded+7)/8); - + return((enc_rval.encoded+7)/8); } -uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS) -{ - - +uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS) { asn_enc_rval_t enc_rval; - LTE_UL_DCCH_Message_t ul_dcch_msg; - LTE_RRCConnectionSetupComplete_t *rrcConnectionSetupComplete; - memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete; rrcConnectionSetupComplete = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionSetupComplete; - rrcConnectionSetupComplete->rrc_TransactionIdentifier = Transaction_id; rrcConnectionSetupComplete->criticalExtensions.present = LTE_RRCConnectionSetupComplete__criticalExtensions_PR_c1; rrcConnectionSetupComplete->criticalExtensions.choice.c1.present = LTE_RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8; - rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension=CALLOC(1, sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension)); - rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 1; - rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME = NULL;//calloc(1,sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME)); /* @@ -1695,22 +1519,19 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin memset(&rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.dedicatedInfoNAS,0,sizeof(OCTET_STRING_t)); OCTET_STRING_fromBuf(&rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.dedicatedInfoNAS, dedicatedInfoNAS, dedicatedInfoNASLength); - /* rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.buf = calloc(1,1); rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.buf[0] = 0x98; rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.size=1; rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.bits_unused=0; */ - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, - (void*)&ul_dcch_msg, + (void *)&ul_dcch_msg, buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1719,59 +1540,45 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); } } # endif #endif - LOG_D(RRC,"RRCConnectionSetupComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); - } //------------------------------------------------------------------------------ uint8_t do_RRCConnectionReconfigurationComplete( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, const uint8_t Transaction_id ) //------------------------------------------------------------------------------ { - - asn_enc_rval_t enc_rval; - LTE_UL_DCCH_Message_t ul_dcch_msg; - LTE_RRCConnectionReconfigurationComplete_t *rrcConnectionReconfigurationComplete; - memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete; rrcConnectionReconfigurationComplete = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionReconfigurationComplete; - rrcConnectionReconfigurationComplete->rrc_TransactionIdentifier = Transaction_id; rrcConnectionReconfigurationComplete->criticalExtensions.present = LTE_RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8; rrcConnectionReconfigurationComplete->criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.nonCriticalExtension=NULL; - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, - (void*)&ul_dcch_msg, + (void *)&ul_dcch_msg, buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1780,19 +1587,15 @@ do_RRCConnectionReconfigurationComplete( if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif - LOG_D(RRC,"RRCConnectionReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); } @@ -1800,39 +1603,31 @@ do_RRCConnectionReconfigurationComplete( //------------------------------------------------------------------------------ uint8_t do_RRCConnectionSetup( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, int CC_id, - uint8_t* const buffer, + uint8_t *const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, LTE_SRB_ToAddModList_t **SRB_configList, - struct LTE_PhysicalConfigDedicated **physicalConfigDedicated) -{ - + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated) { asn_enc_rval_t enc_rval; eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id]; rrc_eNB_carrier_data_t *carrier = &rrc->carrier[CC_id]; - - long* logicalchannelgroup = NULL; - struct LTE_SRB_ToAddMod* SRB1_config = NULL; - struct LTE_SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL; - struct LTE_SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL; - struct LTE_LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL; - + long *logicalchannelgroup = NULL; + struct LTE_SRB_ToAddMod *SRB1_config = NULL; + struct LTE_SRB_ToAddMod__rlc_Config *SRB1_rlc_config = NULL; + struct LTE_SRB_ToAddMod__logicalChannelConfig *SRB1_lchan_config = NULL; + struct LTE_LogicalChannelConfig__ul_SpecificParameters *SRB1_ul_SpecificParameters = NULL; #ifdef CBA - struct LTE_PUSCH_CBAConfigDedicated_vlola* pusch_CBAConfigDedicated_vlola = NULL; - long* betaOffset_CBA_Index = NULL; - long* cShift_CBA = NULL; + struct LTE_PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola = NULL; + long *betaOffset_CBA_Index = NULL; + long *cShift_CBA = NULL; #endif - LTE_PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL; - + LTE_PhysicalConfigDedicated_t *physicalConfigDedicated2 = NULL; LTE_DL_CCCH_Message_t dl_ccch_msg; - - LTE_RRCConnectionSetup_t* rrcConnectionSetup = NULL; - + LTE_RRCConnectionSetup_t *rrcConnectionSetup = NULL; LTE_DL_FRAME_PARMS *frame_parms = &RC.eNB[ctxt_pP->module_id][CC_id]->frame_parms; - memset((void *)&dl_ccch_msg,0,sizeof(LTE_DL_CCCH_Message_t)); dl_ccch_msg.message.present = LTE_DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup; @@ -1847,14 +1642,11 @@ do_RRCConnectionSetup( } *SRB_configList = CALLOC(1,sizeof(LTE_SRB_ToAddModList_t)); - /// SRB1 SRB1_config = CALLOC(1,sizeof(*SRB1_config)); - SRB1_config->srb_Identity = 1; SRB1_rlc_config = CALLOC(1,sizeof(*SRB1_rlc_config)); SRB1_config->rlc_Config = SRB1_rlc_config; - SRB1_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB1_rlc_config->choice.explicitValue.present=LTE_RLC_Config_PR_am; #if defined(ENABLE_ITTI) @@ -1864,44 +1656,31 @@ do_RRCConnectionSetup( SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = rrc->srb1_max_retx_threshold; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = rrc->srb1_timer_reordering; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = rrc->srb1_timer_status_prohibit; -#else +#else SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms20;; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = LTE_PollPDU_p4;; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms0; -#endif - +#endif SRB1_lchan_config = CALLOC(1,sizeof(*SRB1_lchan_config)); SRB1_config->logicalChannelConfig = SRB1_lchan_config; - SRB1_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; SRB1_ul_SpecificParameters = CALLOC(1,sizeof(*SRB1_ul_SpecificParameters)); - SRB1_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB1_ul_SpecificParameters; - - SRB1_ul_SpecificParameters->priority = 1; - //assign_enum(&SRB1_ul_SpecificParameters->prioritisedBitRate,LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity); SRB1_ul_SpecificParameters->prioritisedBitRate=LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50); SRB1_ul_SpecificParameters->bucketSizeDuration=LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - logicalchannelgroup = CALLOC(1,sizeof(long)); *logicalchannelgroup=0; SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; - - ASN_SEQUENCE_ADD(&(*SRB_configList)->list,SRB1_config); - // PhysicalConfigDedicated - physicalConfigDedicated2 = CALLOC(1,sizeof(*physicalConfigDedicated2)); *physicalConfigDedicated = physicalConfigDedicated2; - physicalConfigDedicated2->pdsch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pdsch_ConfigDedicated)); physicalConfigDedicated2->pucch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pucch_ConfigDedicated)); physicalConfigDedicated2->pusch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pusch_ConfigDedicated)); @@ -1909,10 +1688,12 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH)); physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH)); physicalConfigDedicated2->cqi_ReportConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig)); + if (rrc->srs_enable[CC_id]==1) physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); else physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = NULL; + physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->schedulingRequestConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->schedulingRequestConfig)); @@ -1940,7 +1721,6 @@ do_RRCConnectionSetup( physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_ACK_Index = 0; // 2.00 physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_RI_Index = 0; // 1.25 physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_CQI_Index = 8; // 2.25 - // UplinkPowerControlDedicated physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUSCH = 0; // 0 dB //assign_enum(&physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled, @@ -1953,9 +1733,7 @@ do_RRCConnectionSetup( sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient)); // assign_enum(physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient,FilterCoefficient_fc4); // fc4 dB *physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient=LTE_FilterCoefficient_fc4; // fc4 dB - // TPC-PDCCH-Config - physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->present=LTE_TPC_PDCCH_Config_PR_setup; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.present = LTE_TPC_Index_PR_indexOfFormat3; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1; @@ -1964,7 +1742,6 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[0]=0x12; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.bits_unused=0; - physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->present=LTE_TPC_PDCCH_Config_PR_setup; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.present = LTE_TPC_Index_PR_indexOfFormat3; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1; @@ -1973,9 +1750,7 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0]=0x22; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused=0; - // CQI ReportConfig - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic)); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) *physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic= LTE_CQI_ReportModeAperiodic_rm30; @@ -1984,65 +1759,67 @@ do_RRCConnectionSetup( #endif physicalConfigDedicated2->cqi_ReportConfig->nomPDSCH_RS_EPRE_Offset = 0; // 0 dB //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=NULL; - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic)); physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present = LTE_CQI_ReportPeriodic_PR_release; - /* - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present = CQI_ReportPeriodic_PR_setup; - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex = 0; // n2_pucch - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex = 0; // Icqi/pmi - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present = CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI; // subband CQI - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k=4; - - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL; - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0; - */ + /* + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present = CQI_ReportPeriodic_PR_setup; + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex = 0; // n2_pucch + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex = 0; // Icqi/pmi + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present = CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI; // subband CQI + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k=4; + + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL; + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0; + */ //soundingRS-UL-ConfigDedicated if (rrc->srs_enable[CC_id]==1) { physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = LTE_SoundingRS_UL_ConfigDedicated_PR_setup; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth = - LTE_SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0; + LTE_SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth = - LTE_SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0; + LTE_SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition=0; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.duration=1; + if (carrier->sib1->tdd_Config==NULL) { // FDD if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present - == LTE_SoundingRS_UL_ConfigCommon_PR_setup) - if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=0) - LOG_W(RRC,"This code has been optimized for SRS Subframe Config 0, but current config is %zd. Expect undefined behaviour!\n", - carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig); - if (ue_context_pP->local_uid >=20) - LOG_W(RRC,"This code has been optimized for up to 10 UEs, but current UE_id is %d. Expect undefined behaviour!\n", - ue_context_pP->local_uid); + == LTE_SoundingRS_UL_ConfigCommon_PR_setup) + if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=0) + LOG_W(RRC,"This code has been optimized for SRS Subframe Config 0, but current config is %zd. Expect undefined behaviour!\n", + carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig); + + if (ue_context_pP->local_uid >=20) + LOG_W(RRC,"This code has been optimized for up to 10 UEs, but current UE_id is %d. Expect undefined behaviour!\n", + ue_context_pP->local_uid); + //the current code will allow for 20 UEs - to be revised for more physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=7+ue_context_pP->local_uid/2; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb= ue_context_pP->local_uid%2; - } - else { + } else { if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present - == LTE_SoundingRS_UL_ConfigCommon_PR_setup) - if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=7) { - LOG_W(RRC,"This code has been optimized for SRS Subframe Config 7 and TDD config 3, but current configs are %zd and %zd. Expect undefined behaviour!\n", - carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig, - carrier->sib1->tdd_Config->subframeAssignment); - } - if (ue_context_pP->local_uid >=6) - LOG_W(RRC,"This code has been optimized for up to 6 UEs, but current UE_id is %d. Expect undefined behaviour!\n", - ue_context_pP->local_uid); + == LTE_SoundingRS_UL_ConfigCommon_PR_setup) + if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=7) { + LOG_W(RRC,"This code has been optimized for SRS Subframe Config 7 and TDD config 3, but current configs are %zd and %zd. Expect undefined behaviour!\n", + carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig, + carrier->sib1->tdd_Config->subframeAssignment); + } + + if (ue_context_pP->local_uid >=6) + LOG_W(RRC,"This code has been optimized for up to 6 UEs, but current UE_id is %d. Expect undefined behaviour!\n", + ue_context_pP->local_uid); + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=17+ue_context_pP->local_uid/2; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb= ue_context_pP->local_uid%2; } - LOG_W(RRC,"local UID %d, srs ConfigIndex %zd, TransmissionComb %zd\n",ue_context_pP->local_uid, - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex, - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb); + LOG_W(RRC,"local UID %d, srs ConfigIndex %zd, TransmissionComb %zd\n",ue_context_pP->local_uid, + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex, + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb); physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift= - LTE_SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0; + LTE_SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0; } - //AntennaInfoDedicated physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->antennaInfo->present = LTE_PhysicalConfigDedicated__antennaInfo_PR_explicitValue; @@ -2050,99 +1827,102 @@ do_RRCConnectionSetup( // AntennaInfoDedicated__transmissionMode_tm2); switch (transmission_mode) { - default: - LOG_W(RRC,"At RRCConnectionSetup Transmission mode can only take values 1 or 2! Defaulting to 1!\n"); - case 1: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; - break; - - case 2: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; - break; - /* - case 3: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm3; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction= CALLOC(1, - sizeof(*physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction)); - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; - - break; - - case 4: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm4; - break; - - case 5: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm5; - break; - - case 6: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm6; - break; - - case 7: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm7; - break; - */ - } + default: + LOG_W(RRC,"At RRCConnectionSetup Transmission mode can only take values 1 or 2! Defaulting to 1!\n"); + case 1: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; + break; + + case 2: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; + break; + /* + case 3: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm3; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction= CALLOC(1, + sizeof(*physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction)); + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; + + break; + + case 4: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm4; + break; + + case 5: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm5; + break; + + case 6: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm6; + break; + + case 7: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm7; + break; + */ + } physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.present = LTE_AntennaInfoDedicated__ue_TransmitAntennaSelection_PR_release; physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.release = 0; - // SchedulingRequestConfig - physicalConfigDedicated2->schedulingRequestConfig->present = LTE_SchedulingRequestConfig_PR_setup; + if (carrier->sib1->tdd_Config == NULL) { physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; } else { - switch (carrier->sib1->tdd_Config->subframeAssignment) { + switch (carrier->sib1->tdd_Config->subframeAssignment) { case 1: - switch(frame_parms->N_RB_UL){ + switch(frame_parms->N_RB_UL) { case 25: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 15 - ue_context_pP->local_uid/4; - break; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 15 - ue_context_pP->local_uid/4; + break; + case 50: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 31 - ue_context_pP->local_uid/4; - break; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 31 - ue_context_pP->local_uid/4; + break; + case 100: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 63 - ue_context_pP->local_uid/4; - break; - } - break; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 63 - ue_context_pP->local_uid/4; + break; + } + + break; + default: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; - break; - } + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; + break; + } } if (carrier->sib1->tdd_Config == NULL) { // FDD physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5+(ue_context_pP->local_uid%10); // Isr = 5 (every 10 subframes, offset=2+UE_id mod3) } else { switch (carrier->sib1->tdd_Config->subframeAssignment) { - case 1: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(ue_context_pP->local_uid&1)+(( - ue_context_pP->local_uid&3)>>1)*5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) - break; + case 1: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(ue_context_pP->local_uid&1)+(( + ue_context_pP->local_uid&3)>>1)*5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) + break; - case 3: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ - (ue_context_pP->local_uid%3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) - break; + case 3: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ + (ue_context_pP->local_uid%3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + break; - case 4: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ - (ue_context_pP->local_uid&1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) - break; + case 4: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ + (ue_context_pP->local_uid&1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + break; - default: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7; // Isr = 5 (every 10 subframes, offset=2 for all UE0 etc..) - break; + default: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7; // Isr = 5 (every 10 subframes, offset=2 for all UE0 etc..) + break; } } @@ -2150,7 +1930,6 @@ do_RRCConnectionSetup( //SchedulingRequestConfig__setup__dsr_TransMax_n4); // assign_enum(&physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4; physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = LTE_SchedulingRequestConfig__setup__dsr_TransMax_n4; - rrcConnectionSetup->rrc_TransactionIdentifier = Transaction_id; rrcConnectionSetup->criticalExtensions.present = LTE_RRCConnectionSetup__criticalExtensions_PR_c1; rrcConnectionSetup->criticalExtensions.choice.c1.present = LTE_RRCConnectionSetup__criticalExtensions__c1_PR_rrcConnectionSetup_r8 ; @@ -2170,21 +1949,22 @@ do_RRCConnectionSetup( rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.sps_CBA_ConfigList_vlola = NULL; #endif - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void*)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message, NULL, - (void*)&dl_ccch_msg, + (void *)&dl_ccch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2193,34 +1973,29 @@ do_RRCConnectionSetup( if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_CCCH_Message, (void *) &dl_ccch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif - LOG_D(RRC,"RRCConnectionSetup Encoded %zd bits (%zd bytes) \n", enc_rval.encoded,(enc_rval.encoded+7)/8); - // FREEMEM(SRB_list); // free(SRB1_config); // free(SRB1_rlc_config); // free(SRB1_lchan_config); // free(SRB1_ul_SpecificParameters); - return((enc_rval.encoded+7)/8); } //------------------------------------------------------------------------------ uint8_t do_SecurityModeCommand( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* const buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *const buffer, const uint8_t Transaction_id, const uint8_t cipheringAlgorithm, const uint8_t integrityProtAlgorithm @@ -2229,15 +2004,11 @@ do_SecurityModeCommand( { LTE_DL_DCCH_Message_t dl_dcch_msg; asn_enc_rval_t enc_rval; - memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_securityModeCommand; - dl_dcch_msg.message.choice.c1.choice.securityModeCommand.rrc_TransactionIdentifier = Transaction_id; dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.present = LTE_SecurityModeCommand__criticalExtensions_PR_c1; - dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.present = LTE_SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8; // the two following information could be based on the mod_id @@ -2247,19 +2018,21 @@ do_SecurityModeCommand( = (e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm)integrityProtAlgorithm; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void*)&dl_dcch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, - (void*)&dl_dcch_msg, + (void *)&dl_dcch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2268,17 +2041,14 @@ do_SecurityModeCommand( if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_DCCH_Message, (void *) &dl_dcch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_DCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif - LOG_D(RRC,"[eNB %d] securityModeCommand for UE %x Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rnti, @@ -2300,25 +2070,19 @@ do_SecurityModeCommand( //------------------------------------------------------------------------------ uint8_t do_UECapabilityEnquiry( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* const buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *const buffer, const uint8_t Transaction_id ) //------------------------------------------------------------------------------ { - LTE_DL_DCCH_Message_t dl_dcch_msg; - LTE_RAT_Type_t rat=LTE_RAT_Type_eutra; asn_enc_rval_t enc_rval; - memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry; - dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.rrc_TransactionIdentifier = Transaction_id; - dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.present = LTE_UECapabilityEnquiry__criticalExtensions_PR_c1; dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present = LTE_UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8; @@ -2327,19 +2091,21 @@ do_UECapabilityEnquiry( &rat); if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void*)&dl_dcch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, - (void*)&dl_dcch_msg, + (void *)&dl_dcch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2348,17 +2114,14 @@ do_UECapabilityEnquiry( if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_DCCH_Message, (void *) &dl_dcch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif - LOG_D(RRC,"[eNB %d] UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rnti, @@ -2378,7 +2141,7 @@ do_UECapabilityEnquiry( //------------------------------------------------------------------------------ uint16_t do_RRCConnectionReconfiguration( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, uint8_t Transaction_id, LTE_SRB_ToAddModList_t *SRB_list, @@ -2407,24 +2170,17 @@ do_RRCConnectionReconfiguration( ) //------------------------------------------------------------------------------ { - asn_enc_rval_t enc_rval; - LTE_DL_DCCH_Message_t dl_dcch_msg; LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration; - - memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration; rrcConnectionReconfiguration = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionReconfiguration; - // RRCConnectionReconfiguration rrcConnectionReconfiguration->rrc_TransactionIdentifier = Transaction_id; rrcConnectionReconfiguration->criticalExtensions.present = LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1; rrcConnectionReconfiguration->criticalExtensions.choice.c1.present = LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8 ; - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated)); rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList = SRB_list; @@ -2451,9 +2207,8 @@ do_RRCConnectionReconfiguration( if (MeasId_list != NULL) { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig)); - memset((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig, + memset((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig, 0, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list; rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; @@ -2485,9 +2240,8 @@ do_RRCConnectionReconfiguration( if (mobilityInfo !=NULL) { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo)); - memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo, (void*)mobilityInfo, + memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo, (void *)mobilityInfo, sizeof(LTE_MobilityControlInfo_t)); - } else { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo = NULL; } @@ -2498,55 +2252,64 @@ do_RRCConnectionReconfiguration( //TTN for D2D //allocate dedicated resource pools for SL communication (sl_CommConfig_r12) if (sl_CommConfig != NULL) { - LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL communication \n"); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12 = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12)); - memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12, (void*)sl_CommConfig, - sizeof(LTE_SL_CommConfig_r12_t)); + LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL communication \n"); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension + = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12 + = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12)); + memcpy((void *) + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12, + (void *)sl_CommConfig, + sizeof(LTE_SL_CommConfig_r12_t)); } //allocate dedicated resource pools for SL discovery (sl_DiscConfig) - if (sl_DiscConfig != NULL){ - LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL discovery \n"); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12)); - memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12, (void*)sl_DiscConfig, - sizeof(LTE_SL_DiscConfig_r12_t)); + if (sl_DiscConfig != NULL) { + LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL discovery \n"); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension + = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 + = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12)); + memcpy((void *) + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12, + (void *)sl_DiscConfig, + sizeof(LTE_SL_DiscConfig_r12_t)); } enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, - (void*)&dl_dcch_msg, + (void *)&dl_dcch_msg, buffer, RRC_BUF_SIZE); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout,&asn_DEF_LTE_DL_DCCH_Message,(void*)&dl_dcch_msg); + xer_fprint(stdout,&asn_DEF_LTE_DL_DCCH_Message,(void *)&dl_dcch_msg); } #if defined(ENABLE_ITTI) @@ -2557,67 +2320,57 @@ do_RRCConnectionReconfiguration( if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_DCCH_Message, (void *) &dl_dcch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_DCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif - LOG_I(RRC,"RRCConnectionReconfiguration Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); // for (i=0;i<30;i++) // msg("%x.",buffer[i]); // msg("\n"); - - return((enc_rval.encoded+7)/8); } //------------------------------------------------------------------------------ uint8_t do_RRCConnectionReestablishment( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, int CC_id, - uint8_t* const buffer, + uint8_t *const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, LTE_SRB_ToAddModList_t **SRB_configList, - struct LTE_PhysicalConfigDedicated **physicalConfigDedicated) -{ + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated) { asn_enc_rval_t enc_rval; - - long* logicalchannelgroup = NULL; - struct LTE_SRB_ToAddMod* SRB1_config = NULL; - struct LTE_SRB_ToAddMod* SRB2_config = NULL; - struct LTE_SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL; - struct LTE_SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL; - struct LTE_LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL; + long *logicalchannelgroup = NULL; + struct LTE_SRB_ToAddMod *SRB1_config = NULL; + struct LTE_SRB_ToAddMod *SRB2_config = NULL; + struct LTE_SRB_ToAddMod__rlc_Config *SRB1_rlc_config = NULL; + struct LTE_SRB_ToAddMod__logicalChannelConfig *SRB1_lchan_config = NULL; + struct LTE_LogicalChannelConfig__ul_SpecificParameters *SRB1_ul_SpecificParameters = NULL; eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id]; - #ifdef CBA - struct LTE_PUSCH_CBAConfigDedicated_vlola* pusch_CBAConfigDedicated_vlola = NULL; - long* betaOffset_CBA_Index = NULL; - long* cShift_CBA = NULL; + struct LTE_PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola = NULL; + long *betaOffset_CBA_Index = NULL; + long *cShift_CBA = NULL; #endif - LTE_PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL; - + LTE_PhysicalConfigDedicated_t *physicalConfigDedicated2 = NULL; LTE_DL_CCCH_Message_t dl_ccch_msg; - - LTE_RRCConnectionReestablishment_t* rrcConnectionReestablishment = NULL; - + LTE_RRCConnectionReestablishment_t *rrcConnectionReestablishment = NULL; int i = 0; LTE_SRB_ToAddModList_t **SRB_configList2 = NULL; SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[Transaction_id]; + if (*SRB_configList2) { free(*SRB_configList2); } - *SRB_configList2 = CALLOC(1, sizeof(LTE_SRB_ToAddModList_t)); + *SRB_configList2 = CALLOC(1, sizeof(LTE_SRB_ToAddModList_t)); memset((void *)&dl_ccch_msg, 0, sizeof(LTE_DL_CCCH_Message_t)); dl_ccch_msg.message.present = LTE_DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment; @@ -2626,15 +2379,15 @@ do_RRCConnectionReestablishment( // RRCConnectionReestablishment // Configure SRB1 - // get old configuration of SRB2 if (*SRB_configList != NULL) { for (i = 0; (i < (*SRB_configList)->list.count) && (i < 3); i++) { LOG_D(RRC, "(*SRB_configList)->list.array[%d]->srb_Identity=%ld\n", - i, (*SRB_configList)->list.array[i]->srb_Identity); - if ((*SRB_configList)->list.array[i]->srb_Identity == 2 ){ + i, (*SRB_configList)->list.array[i]->srb_Identity); + + if ((*SRB_configList)->list.array[i]->srb_Identity == 2 ) { SRB2_config = (*SRB_configList)->list.array[i]; - } else if ((*SRB_configList)->list.array[i]->srb_Identity == 1 ){ + } else if ((*SRB_configList)->list.array[i]->srb_Identity == 1 ) { SRB1_config = (*SRB_configList)->list.array[i]; } } @@ -2645,44 +2398,36 @@ do_RRCConnectionReestablishment( LOG_W(RRC,"SRB1 configuration does not exist in SRB configuration list, use default\n"); /// SRB1 SRB1_config = CALLOC(1, sizeof(*SRB1_config)); - SRB1_config->srb_Identity = 1; SRB1_rlc_config = CALLOC(1, sizeof(*SRB1_rlc_config)); SRB1_config->rlc_Config = SRB1_rlc_config; - SRB1_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB1_rlc_config->choice.explicitValue.present=LTE_RLC_Config_PR_am; - #if defined(ENABLE_ITTI) +#if defined(ENABLE_ITTI) SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = rrc->srb1_timer_poll_retransmit; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = rrc->srb1_poll_pdu; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = rrc->srb1_poll_byte; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = rrc->srb1_max_retx_threshold; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = rrc->srb1_timer_reordering; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = rrc->srb1_timer_status_prohibit; - #else +#else SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms20;; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = LTE_PollPDU_p4;; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms0; - #endif - +#endif SRB1_lchan_config = CALLOC(1, sizeof(*SRB1_lchan_config)); SRB1_config->logicalChannelConfig = SRB1_lchan_config; - SRB1_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; SRB1_ul_SpecificParameters = CALLOC(1, sizeof(*SRB1_ul_SpecificParameters)); - SRB1_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB1_ul_SpecificParameters; SRB1_ul_SpecificParameters->priority = 1; - //assign_enum(&SRB1_ul_SpecificParameters->prioritisedBitRate,LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity); SRB1_ul_SpecificParameters->prioritisedBitRate=LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50); SRB1_ul_SpecificParameters->bucketSizeDuration=LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - logicalchannelgroup = CALLOC(1, sizeof(long)); *logicalchannelgroup = 0; SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; @@ -2699,11 +2444,8 @@ do_RRCConnectionReestablishment( } *SRB_configList = CALLOC(1, sizeof(LTE_SRB_ToAddModList_t)); - ASN_SEQUENCE_ADD(&(*SRB_configList)->list,SRB1_config); - physicalConfigDedicated2 = *physicalConfigDedicated; - rrcConnectionReestablishment->rrc_TransactionIdentifier = Transaction_id; rrcConnectionReestablishment->criticalExtensions.present = LTE_RRCConnectionReestablishment__criticalExtensions_PR_c1; rrcConnectionReestablishment->criticalExtensions.choice.c1.present = LTE_RRCConnectionReestablishment__criticalExtensions__c1_PR_rrcConnectionReestablishment_r8; @@ -2713,27 +2455,28 @@ do_RRCConnectionReestablishment( rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.sps_Config = NULL; rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.physicalConfigDedicated = physicalConfigDedicated2; rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.mac_MainConfig = NULL; - uint8_t KeNB_star[32] = { 0 }; uint16_t pci = rrc->carrier[CC_id].physCellId; uint32_t earfcn_dl = (uint32_t)freq_to_arfcn10(RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band, - rrc->carrier[CC_id].dl_CarrierFreq); + rrc->carrier[CC_id].dl_CarrierFreq); bool is_rel8_only = true; + if (earfcn_dl > 65535) { is_rel8_only = false; } LOG_D(RRC, "pci=%d, eutra_band=%d, downlink_frequency=%d, earfcn_dl=%u, is_rel8_only=%s\n", - pci, - RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band, - rrc->carrier[CC_id].dl_CarrierFreq, - earfcn_dl, - is_rel8_only == true ? "true": "false"); + pci, + RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band, + rrc->carrier[CC_id].dl_CarrierFreq, + earfcn_dl, + is_rel8_only == true ? "true": "false"); #if defined(ENABLE_SECURITY) + if (ue_context_pP->ue_context.nh_ncc >= 0) { derive_keNB_star(ue_context_pP->ue_context.nh, pci, earfcn_dl, is_rel8_only, KeNB_star); rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = ue_context_pP->ue_context.nh_ncc; - } else { // first HO + } else { // first HO derive_keNB_star (ue_context_pP->ue_context.kenb, pci, earfcn_dl, is_rel8_only, KeNB_star); // LG: really 1 rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = 0; @@ -2745,23 +2488,24 @@ do_RRCConnectionReestablishment( #else rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = 0; #endif - rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nonCriticalExtension = NULL; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void*)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message, NULL, - (void*)&dl_ccch_msg, + (void *)&dl_ccch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2770,22 +2514,18 @@ do_RRCConnectionReestablishment( if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_CCCH_Message, (void *) &dl_ccch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } # endif #endif - #ifdef USER_MODE LOG_D(RRC,"RRCConnectionReestablishment Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); #endif - return((enc_rval.encoded+7)/8); } @@ -2793,37 +2533,35 @@ do_RRCConnectionReestablishment( uint8_t do_RRCConnectionReestablishmentReject( uint8_t Mod_id, - uint8_t* const buffer) + uint8_t *const buffer) //------------------------------------------------------------------------------ { - asn_enc_rval_t enc_rval; - LTE_DL_CCCH_Message_t dl_ccch_msg; LTE_RRCConnectionReestablishmentReject_t *rrcConnectionReestablishmentReject; - memset((void *)&dl_ccch_msg,0,sizeof(LTE_DL_CCCH_Message_t)); dl_ccch_msg.message.present = LTE_DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject; rrcConnectionReestablishmentReject = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReestablishmentReject; - // RRCConnectionReestablishmentReject rrcConnectionReestablishmentReject->criticalExtensions.present = LTE_RRCConnectionReestablishmentReject__criticalExtensions_PR_rrcConnectionReestablishmentReject_r8; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void*)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message, NULL, - (void*)&dl_ccch_msg, + (void *)&dl_ccch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2832,20 +2570,16 @@ do_RRCConnectionReestablishmentReject( if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_CCCH_Message, (void *) &dl_ccch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); } } # endif #endif - LOG_D(RRC,"RRCConnectionReestablishmentReject Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); } @@ -2853,20 +2587,16 @@ do_RRCConnectionReestablishmentReject( uint8_t do_RRCConnectionReject( uint8_t Mod_id, - uint8_t* const buffer) + uint8_t *const buffer) //------------------------------------------------------------------------------ { - asn_enc_rval_t enc_rval; - LTE_DL_CCCH_Message_t dl_ccch_msg; LTE_RRCConnectionReject_t *rrcConnectionReject; - memset((void *)&dl_ccch_msg,0,sizeof(LTE_DL_CCCH_Message_t)); dl_ccch_msg.message.present = LTE_DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReject; rrcConnectionReject = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReject; - // RRCConnectionReject rrcConnectionReject->criticalExtensions.present = LTE_RRCConnectionReject__criticalExtensions_PR_c1; rrcConnectionReject->criticalExtensions.choice.c1.present = LTE_RRCConnectionReject__criticalExtensions__c1_PR_rrcConnectionReject_r8; @@ -2874,19 +2604,21 @@ do_RRCConnectionReject( rrcConnectionReject->criticalExtensions.choice.c1.choice.rrcConnectionReject_r8.waitTime = 1; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void*)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message, NULL, - (void*)&dl_ccch_msg, + (void *)&dl_ccch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2895,59 +2627,44 @@ do_RRCConnectionReject( if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_CCCH_Message, (void *) &dl_ccch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); } } # endif #endif - LOG_D(RRC,"RRCConnectionReject Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); } uint8_t do_RRCConnectionRelease( uint8_t Mod_id, uint8_t *buffer, - uint8_t Transaction_id) -{ - + uint8_t Transaction_id) { asn_enc_rval_t enc_rval; - LTE_DL_DCCH_Message_t dl_dcch_msg; LTE_RRCConnectionRelease_t *rrcConnectionRelease; - - memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionRelease; rrcConnectionRelease = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionRelease; - // RRCConnectionRelease rrcConnectionRelease->rrc_TransactionIdentifier = Transaction_id; rrcConnectionRelease->criticalExtensions.present = LTE_RRCConnectionRelease__criticalExtensions_PR_c1; rrcConnectionRelease->criticalExtensions.choice.c1.present =LTE_RRCConnectionRelease__criticalExtensions__c1_PR_rrcConnectionRelease_r8 ; - rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause = LTE_ReleaseCause_other; rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.redirectedCarrierInfo = NULL; rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.idleModeMobilityControlInfo = NULL; - rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.nonCriticalExtension=CALLOC(1, sizeof(*rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.nonCriticalExtension)); - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, - (void*)&dl_dcch_msg, + (void *)&dl_dcch_msg, buffer, RRC_BUF_SIZE); - return((enc_rval.encoded+7)/8); } @@ -2959,9 +2676,7 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, uint8_t sync_area, uint8_t *buffer, LTE_MCCH_Message_t *mcch_message, - LTE_MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration) -{ - + LTE_MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration) { asn_enc_rval_t enc_rval; LTE_MBSFN_SubframeConfig_t *mbsfn_SubframeConfig1; LTE_PMCH_Info_r9_t *pmch_Info_1; @@ -2969,17 +2684,13 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, // MBMS_SessionInfo_r9_t *mbms_Session_2; eNB_RRC_INST *rrc = RC.rrc[Mod_id]; rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0]; - - memset(mcch_message,0,sizeof(LTE_MCCH_Message_t)); mcch_message->message.present = LTE_MCCH_MessageType_PR_c1; mcch_message->message.choice.c1.present = LTE_MCCH_MessageType__c1_PR_mbsfnAreaConfiguration_r9; *mbsfnAreaConfiguration = &mcch_message->message.choice.c1.choice.mbsfnAreaConfiguration_r9; - // Common Subframe Allocation (CommonSF-Alloc-r9) - mbsfn_SubframeConfig1= CALLOC(1,sizeof(*mbsfn_SubframeConfig1)); - memset((void*)mbsfn_SubframeConfig1,0,sizeof(*mbsfn_SubframeConfig1)); + memset((void *)mbsfn_SubframeConfig1,0,sizeof(*mbsfn_SubframeConfig1)); // mbsfn_SubframeConfig1->radioframeAllocationPeriod= LTE_MBSFN_SubframeConfig__radioframeAllocationPeriod_n4; mbsfn_SubframeConfig1->radioframeAllocationOffset= 1; @@ -2990,36 +2701,33 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, // CURRENTLY WE ARE SUPPORITNG ONLY ONE sf ALLOCATION switch (sync_area) { - case 0: - if (carrier->sib1->tdd_Config != NULL) {// pattern 001110 for TDD - mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused. - } else { //111000 - mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2; - } + case 0: + if (carrier->sib1->tdd_Config != NULL) {// pattern 001110 for TDD + mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused. + } else { //111000 + mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2; + } - break; + break; - case 1: - if (carrier->sib1->tdd_Config != NULL) { - mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused. - } else { // 000111 - mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2; - } + case 1: + if (carrier->sib1->tdd_Config != NULL) { + mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused. + } else { // 000111 + mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2; + } - default : - break; + default : + break; } ASN_SEQUENCE_ADD(&(*mbsfnAreaConfiguration)->commonSF_Alloc_r9.list,mbsfn_SubframeConfig1); - // commonSF-AllocPeriod-r9 (*mbsfnAreaConfiguration)->commonSF_AllocPeriod_r9= LTE_MBSFNAreaConfiguration_r9__commonSF_AllocPeriod_r9_rf16; - // PMCHs Information List (PMCH-InfoList-r9) // PMCH_1 Config pmch_Info_1 = CALLOC(1,sizeof(LTE_PMCH_Info_r9_t)); - memset((void*)pmch_Info_1,0,sizeof(LTE_PMCH_Info_r9_t)); - + memset((void *)pmch_Info_1,0,sizeof(LTE_PMCH_Info_r9_t)); /* * take the value of last mbsfn subframe in this CSA period because there is only one PMCH in this mbsfn area * Note: this has to be set based on the subframeAllocation and CSA @@ -3027,7 +2735,6 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, pmch_Info_1->pmch_Config_r9.sf_AllocEnd_r9= 3; pmch_Info_1->pmch_Config_r9.dataMCS_r9= 7; pmch_Info_1->pmch_Config_r9.mch_SchedulingPeriod_r9= LTE_PMCH_Config_r9__mch_SchedulingPeriod_r9_rf16; - // MBMSs-SessionInfoList-r9 // pmch_Info_1->mbms_SessionInfoList_r9 = CALLOC(1,sizeof(struct MBMS_SessionInfoList_r9)); // Session 1 @@ -3038,7 +2745,7 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, mbms_Session_1->tmgi_r9.plmn_Id_r9.choice.plmn_Index_r9= 1; // Service ID memset(&mbms_Session_1->tmgi_r9.serviceId_r9,0,sizeof(OCTET_STRING_t));// need to check - OCTET_STRING_fromBuf(&mbms_Session_1->tmgi_r9.serviceId_r9,(const char*)&TMGI[2],3); + OCTET_STRING_fromBuf(&mbms_Session_1->tmgi_r9.serviceId_r9,(const char *)&TMGI[2],3); // Session ID is still missing here, it can be used as an rab id or mrb id mbms_Session_1->sessionId_r9 = CALLOC(1,sizeof(OCTET_STRING_t)); mbms_Session_1->sessionId_r9->buf= MALLOC(1); @@ -3047,7 +2754,6 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, // Logical Channel ID mbms_Session_1->logicalChannelIdentity_r9= MTCH; ASN_SEQUENCE_ADD(&pmch_Info_1->mbms_SessionInfoList_r9.list,mbms_Session_1); - /* // Session 2 //mbms_Session_2 = CALLOC(1,sizeof(MBMS_SessionInfo_r9_t)); memset(mbms_Session_2,0,sizeof(MBMS_SessionInfo_r9_t)); @@ -3068,19 +2774,21 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, ASN_SEQUENCE_ADD(&(*mbsfnAreaConfiguration)->pmch_InfoList_r9.list,pmch_Info_1); if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout,&asn_DEF_LTE_MCCH_Message,(void*)mcch_message); + xer_fprint(stdout,&asn_DEF_LTE_MCCH_Message,(void *)mcch_message); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_MCCH_Message, NULL, - (void*)mcch_message, + (void *)mcch_message, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -3089,17 +2797,14 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_MCCH_Message, (void *) &mcch_message)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_MCCH, message_string_size); msg_p->ittiMsg.rrc_dl_mcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_mcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); } } # endif #endif - LOG_D(RRC,"[eNB] MCCH Message Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); if (enc_rval.encoded==-1) { @@ -3111,24 +2816,17 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, } #endif -uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t) -{ - +uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t) { asn_enc_rval_t enc_rval; - LTE_UL_DCCH_Message_t ul_dcch_msg; - LTE_MeasurementReport_t *measurementReport; - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_measurementReport; measurementReport = &ul_dcch_msg.message.choice.c1.choice.measurementReport; - measurementReport->criticalExtensions.present=LTE_MeasurementReport__criticalExtensions_PR_c1; measurementReport->criticalExtensions.choice.c1.present=LTE_MeasurementReport__criticalExtensions__c1_PR_measurementReport_r8; measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension=CALLOC(1, sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension)); - measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measId=measid; #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrpResult=rsrp_s; @@ -3140,24 +2838,17 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells=CALLOC(1, sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells)); measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells->present=LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA; - LTE_MeasResultListEUTRA_t *measResultListEUTRA2; measResultListEUTRA2 = CALLOC(1,sizeof(*measResultListEUTRA2)); - struct LTE_MeasResultEUTRA *measresulteutra2; measresulteutra2 = CALLOC(1,sizeof(*measresulteutra2)); measresulteutra2->physCellId=phy_id;//1; - struct LTE_MeasResultEUTRA__cgi_Info *measresult_cgi2; measresult_cgi2 = CALLOC(1,sizeof(*measresult_cgi2)); - memset(&measresult_cgi2->cellGlobalId.plmn_Identity,0,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity)); - // measresult_cgi2->cellGlobalId.plmn_Identity.mcc=CALLOC(1,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity.mcc)); measresult_cgi2->cellGlobalId.plmn_Identity.mcc = CALLOC(1, sizeof(*measresult_cgi2->cellGlobalId.plmn_Identity.mcc)); - asn_set_empty(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list);//.size=0; - LTE_MCC_MNC_Digit_t dummy; dummy=2; ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy); @@ -3165,14 +2856,12 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy); dummy=2; ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy); - measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list.size=0; measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list.count=0; dummy=8; ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list,&dummy); dummy=0; ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list,&dummy); - measresult_cgi2->cellGlobalId.cellIdentity.buf=MALLOC(8); measresult_cgi2->cellGlobalId.cellIdentity.buf[0]=0x01; measresult_cgi2->cellGlobalId.cellIdentity.buf[1]=0x48; @@ -3180,40 +2869,32 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ measresult_cgi2->cellGlobalId.cellIdentity.buf[3]=0x03; measresult_cgi2->cellGlobalId.cellIdentity.size=4; measresult_cgi2->cellGlobalId.cellIdentity.bits_unused=4; - measresult_cgi2->trackingAreaCode.buf = MALLOC(2); measresult_cgi2->trackingAreaCode.buf[0]=0x00; measresult_cgi2->trackingAreaCode.buf[1]=0x10; measresult_cgi2->trackingAreaCode.size=2; measresult_cgi2->trackingAreaCode.bits_unused=0; - - measresulteutra2->cgi_Info=measresult_cgi2; - struct LTE_MeasResultEUTRA__measResult meas2; // int rsrp_va=10; - meas2.rsrpResult=&(rsrp_t); //&rsrp_va; meas2.rsrqResult=&(rsrq_t); - measresulteutra2->measResult=meas2; - ASN_SEQUENCE_ADD(&measResultListEUTRA2->list,measresulteutra2); - measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells->choice.measResultListEUTRA=*(measResultListEUTRA2); - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, - (void*)&ul_dcch_msg, + (void *)&ul_dcch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -3222,30 +2903,22 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_DCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); } } # endif #endif - printf("Measurement Report Encoded %zu bits (%zu bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); } -uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer) -{ +uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer) { ssize_t encoded; - LTE_DL_DCCH_Message_t dl_dcch_msg; - memset(&dl_dcch_msg, 0, sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_dlInformationTransfer; dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.rrc_TransactionIdentifier = transaction_id; @@ -3255,12 +2928,10 @@ uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t trans LTE_DLInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS; dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length; dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer; - - encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_DL_DCCH_Message, NULL, (void*) &dl_dcch_msg, (void **) buffer); - + encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_DL_DCCH_Message, NULL, (void *) &dl_dcch_msg, (void **) buffer); /* -#if defined(ENABLE_ITTI) -# if !defined(DISABLE_XER_SPRINT) + #if defined(ENABLE_ITTI) + # if !defined(DISABLE_XER_SPRINT) { char message_string[10000]; size_t message_string_size; @@ -3275,31 +2946,24 @@ uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t trans itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p); } } -# endif -#endif + # endif + #endif */ - return encoded; } -uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain) -{ +uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain) { LOG_D(RRC, "[eNB %d] do_Paging start\n", Mod_id); asn_enc_rval_t enc_rval; - LTE_PCCH_Message_t pcch_msg; LTE_PagingRecord_t *paging_record_p; int j; - pcch_msg.message.present = LTE_PCCH_MessageType_PR_c1; pcch_msg.message.choice.c1.present = LTE_PCCH_MessageType__c1_PR_paging; - pcch_msg.message.choice.c1.choice.paging.pagingRecordList = CALLOC(1,sizeof(*pcch_msg.message.choice.c1.choice.paging.pagingRecordList)); - pcch_msg.message.choice.c1.choice.paging.systemInfoModification = NULL; pcch_msg.message.choice.c1.choice.paging.etws_Indication = NULL; pcch_msg.message.choice.c1.choice.paging.nonCriticalExtension = NULL; - asn_set_empty(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list); pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count = 0; @@ -3317,11 +2981,12 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin &paging_record_p->ue_Identity.choice.s_TMSI.mmec); paging_record_p->ue_Identity.choice.s_TMSI.mmec.bits_unused = 0; M_TMSI_TO_OCTET_STRING(ue_paging_identity.choice.s_tmsi.m_tmsi, - &paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI); + &paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI); paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI.bits_unused = 0; } else if (ue_paging_identity.presenceMask == UE_PAGING_IDENTITY_imsi) { paging_record_p->ue_Identity.present = LTE_PagingUE_Identity_PR_imsi; LTE_IMSI_Digit_t imsi_digit[21]; + for (j = 0; j< ue_paging_identity.choice.imsi.length; j++) { /* IMSI size */ imsi_digit[j] = (LTE_IMSI_Digit_t)ue_paging_identity.choice.imsi.buffer[j]; ASN_SEQUENCE_ADD(&paging_record_p->ue_Identity.choice.imsi.list, &imsi_digit[j]); @@ -3334,33 +2999,30 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin } else { paging_record_p->cn_Domain = LTE_PagingRecord__cn_Domain_cs; } + /* add to list */ ASN_SEQUENCE_ADD(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list, paging_record_p); LOG_D(RRC, "[eNB %d] do_Paging paging_record: cn_Domain %ld, ue_paging_identity.presenceMask %d, PagingRecordList.count %d\n", - Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count); + Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count); + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_PCCH_Message, NULL, (void *)&pcch_msg, buffer, RRC_BUF_SIZE); - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_PCCH_Message, NULL, (void*)&pcch_msg, buffer, RRC_BUF_SIZE); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_PCCH_Message, (void*)&pcch_msg); + xer_fprint(stdout, &asn_DEF_LTE_PCCH_Message, (void *)&pcch_msg); } return((enc_rval.encoded+7)/8); } -uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer) -{ +uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer) { ssize_t encoded; - LTE_UL_DCCH_Message_t ul_dcch_msg; - memset(&ul_dcch_msg, 0, sizeof(LTE_UL_DCCH_Message_t)); - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_ulInformationTransfer; ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.present = LTE_ULInformationTransfer__criticalExtensions_PR_c1; @@ -3369,33 +3031,24 @@ uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS; ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length; ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer; - - encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_UL_DCCH_Message, NULL, (void*) &ul_dcch_msg, (void **) buffer); - + encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, (void **) buffer); return encoded; } -OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) -{ +OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) { static OAI_UECapability_t UECapability; /* TODO declared static to allow returning this has an address should be allocated in a cleaner way. */ static LTE_SupportedBandEUTRA_t Bandlist[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it static LTE_InterFreqBandInfo_t InterFreqBandInfo[4][4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it static LTE_BandInfoEUTRA_t BandInfoEUTRA[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it - asn_enc_rval_t enc_rval; asn_dec_rval_t dec_rval; - long maxNumberROHC_ContextSessions = LTE_PDCP_Parameters__maxNumberROHC_ContextSessions_cs16; int i; - LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability; char UE_EUTRA_Capability_xer[8192]; size_t size; - LOG_I(RRC,"Allocating %zu bytes for UE_EUTRA_Capability\n",sizeof(*UE_EUTRA_Capability)); - UE_EUTRA_Capability = CALLOC(1, sizeof(*UE_EUTRA_Capability)); - assert(UE_EUTRA_Capability); if (!UE_EUTRA_Capability_xer_fname) { @@ -3407,10 +3060,8 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) Bandlist[2].halfDuplex = 0; Bandlist[3].bandEUTRA = 38; // UL/DL 2570-2620, TDD Bandlist[3].halfDuplex = 0; - - memset((void*)InterFreqBandInfo, 0, sizeof(InterFreqBandInfo)); - memset((void*)BandInfoEUTRA, 0, sizeof(BandInfoEUTRA)); - + memset((void *)InterFreqBandInfo, 0, sizeof(InterFreqBandInfo)); + memset((void *)BandInfoEUTRA, 0, sizeof(BandInfoEUTRA)); InterFreqBandInfo[0][0].interFreqNeedForGaps = 0; InterFreqBandInfo[0][1].interFreqNeedForGaps = 1; InterFreqBandInfo[0][2].interFreqNeedForGaps = 1; @@ -3427,8 +3078,6 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) InterFreqBandInfo[3][1].interFreqNeedForGaps = 1; InterFreqBandInfo[3][2].interFreqNeedForGaps = 1; InterFreqBandInfo[3][3].interFreqNeedForGaps = 0; - - UE_EUTRA_Capability->accessStratumRelease = 0;//AccessStratumRelease_rel8; UE_EUTRA_Capability->ue_Category = 4; UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0001=0; @@ -3440,47 +3089,39 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0102=0; UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0103=0; UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0104=0; - UE_EUTRA_Capability->pdcp_Parameters.maxNumberROHC_ContextSessions = &maxNumberROHC_ContextSessions; - UE_EUTRA_Capability->phyLayerParameters.ue_TxAntennaSelectionSupported = 0; UE_EUTRA_Capability->phyLayerParameters.ue_SpecificRefSigsSupported = 0; UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count = 0; - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][3]); // UE_EUTRA_Capability->measParameters.bandListEUTRA.list.count = 0; // no measurements on other bands // UE_EUTRA_Capability->featureGroupIndicators // null - if(usim_test == 1) - { + if(usim_test == 1) { // featureGroup is mandatory for CMW tests // featureGroup is filled only for usim-test mode BIT_STRING_t *bit_string = CALLOC(1, sizeof(*bit_string)); @@ -3494,8 +3135,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) // UE_EUTRA_Capability->interRAT_Parameters // null } else { - - FILE* f = fopen(UE_EUTRA_Capability_xer_fname, "r"); + FILE *f = fopen(UE_EUTRA_Capability_xer_fname, "r"); assert(f); size = fread(UE_EUTRA_Capability_xer, 1, sizeof UE_EUTRA_Capability_xer, f); fclose(f); @@ -3506,30 +3146,29 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) return(NULL); } - dec_rval = xer_decode(0, &asn_DEF_LTE_UE_EUTRA_Capability, (void*)UE_EUTRA_Capability, UE_EUTRA_Capability_xer, size); + dec_rval = xer_decode(0, &asn_DEF_LTE_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability, UE_EUTRA_Capability_xer, size); assert(dec_rval.code == RC_OK); } UECapability.UE_EUTRA_Capability = UE_EUTRA_Capability; + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout,&asn_DEF_LTE_UE_EUTRA_Capability,(void *)UE_EUTRA_Capability); + xer_fprint(stdout,&asn_DEF_LTE_UE_EUTRA_Capability,(void *)UE_EUTRA_Capability); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UE_EUTRA_Capability, NULL, - (void*)UE_EUTRA_Capability, + (void *)UE_EUTRA_Capability, &UECapability.sdu[0], MAX_UE_CAPABILITY_SIZE); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - #if defined(ENABLE_ITTI) # if defined(DISABLE_XER_SPRINT) { MessageDef *msg_p; - msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_UE_EUTRA_CAPABILITY); memcpy (&msg_p->ittiMsg, (void *) UE_EUTRA_Capability, sizeof(RrcUeEutraCapability)); - itti_send_msg_to_task (TASK_UNKNOWN, NB_eNB_INST, msg_p); } # else @@ -3539,17 +3178,14 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability)) > 0) { MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UE_EUTRA_CAPABILITY, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_ue_eutra_capability.size = message_string_size; memcpy(&msg_p->ittiMsg.rrc_ue_eutra_capability.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, msg_p); } } # endif #endif - UECapability.sdu_size = (enc_rval.encoded + 7) / 8; LOG_I(PHY, "[RRC]UE Capability encoded, %d bytes (%zd bits)\n", UECapability.sdu_size, enc_rval.encoded + 7); @@ -3564,7 +3200,6 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) LOG_D(PHY, "[RRC]UE Capability encoded, %s\n", sdu); free(sdu); } - return(&UECapability); } diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h index 562f7c33ba..2d0c6ba7b6 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h @@ -71,7 +71,7 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich @param carrier pointer to Carrier information @param Mod_id Instance of eNB @param Component carrier Component carrier to configure -@param configuration Pointer Configuration Request structure +@param configuration Pointer Configuration Request structure @return size of encoded bit stream in bytes*/ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,int Mod_id,int CC_id, RrcConfigurationReq *configuration @@ -91,7 +91,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,int Mod_id,int CC_id, RrcConfigu uint8_t do_SIB23(uint8_t Mod_id, int CC_id #if defined(ENABLE_ITTI) - , RrcConfigurationReq *configuration + , RrcConfigurationReq *configuration #endif ); @@ -115,16 +115,16 @@ uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer, LTE_SL_Destina /** \brief Generate an RRCConnectionSetupComplete UL-DCCH-Message (UE) @param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t* buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, - const char* dedicatedInfoNAS); +uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, + const char *dedicatedInfoNAS); /** \brief Generate an RRCConnectionReconfigurationComplete UL-DCCH-Message (UE) @param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionReconfigurationComplete( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, const uint8_t Transaction_id ); @@ -143,14 +143,14 @@ PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionSetup( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, int CC_id, - uint8_t* const buffer, + uint8_t *const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, - LTE_SRB_ToAddModList_t** SRB_configList, - struct LTE_PhysicalConfigDedicated** physicalConfigDedicated + LTE_SRB_ToAddModList_t **SRB_configList, + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated ); /** @@ -177,31 +177,31 @@ do_RRCConnectionSetup( uint16_t do_RRCConnectionReconfiguration( - const protocol_ctxt_t* const ctxt_pP, - uint8_t *buffer, - uint8_t Transaction_id, - LTE_SRB_ToAddModList_t *SRB_list, - LTE_DRB_ToAddModList_t *DRB_list, - LTE_DRB_ToReleaseList_t *DRB_list2, - struct LTE_SPS_Config *sps_Config, - struct LTE_PhysicalConfigDedicated *physicalConfigDedicated, - LTE_MeasObjectToAddModList_t *MeasObj_list, - LTE_ReportConfigToAddModList_t *ReportConfig_list, - LTE_QuantityConfig_t *quantityConfig, - LTE_MeasIdToAddModList_t *MeasId_list, - LTE_MAC_MainConfig_t *mac_MainConfig, - LTE_MeasGapConfig_t *measGapConfig, - LTE_MobilityControlInfo_t *mobilityInfo, - struct LTE_MeasConfig__speedStatePars *speedStatePars, - LTE_RSRP_Range_t *rsrp, - LTE_C_RNTI_t *cba_rnti, - struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList* dedicatedInfoNASList, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, + uint8_t Transaction_id, + LTE_SRB_ToAddModList_t *SRB_list, + LTE_DRB_ToAddModList_t *DRB_list, + LTE_DRB_ToReleaseList_t *DRB_list2, + struct LTE_SPS_Config *sps_Config, + struct LTE_PhysicalConfigDedicated *physicalConfigDedicated, + LTE_MeasObjectToAddModList_t *MeasObj_list, + LTE_ReportConfigToAddModList_t *ReportConfig_list, + LTE_QuantityConfig_t *quantityConfig, + LTE_MeasIdToAddModList_t *MeasId_list, + LTE_MAC_MainConfig_t *mac_MainConfig, + LTE_MeasGapConfig_t *measGapConfig, + LTE_MobilityControlInfo_t *mobilityInfo, + struct LTE_MeasConfig__speedStatePars *speedStatePars, + LTE_RSRP_Range_t *rsrp, + LTE_C_RNTI_t *cba_rnti, + struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList, LTE_SL_CommConfig_r12_t *sl_CommConfig, LTE_SL_DiscConfig_r12_t *sl_DiscConfig #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , LTE_SCellToAddMod_r10_t *SCell_config + , LTE_SCellToAddMod_r10_t *SCell_config #endif - ); +); /** \brief Generate an RRCConnectionReestablishment DL-CCCH-Message (eNB). This routine configures SRB_ToAddMod (SRB1/SRB2) and PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting (PUCCH format 2/2a/2b) or SRS. @@ -216,10 +216,10 @@ PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionReestablishment( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, int CC_id, - uint8_t* const buffer, + uint8_t *const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, LTE_SRB_ToAddModList_t **SRB_configList, @@ -232,8 +232,8 @@ do_RRCConnectionReestablishment( @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionReestablishmentReject( - uint8_t Mod_id, - uint8_t* const buffer); + uint8_t Mod_id, + uint8_t *const buffer); /** \brief Generate an RRCConnectionReject DL-CCCH-Message (eNB). @@ -242,8 +242,8 @@ do_RRCConnectionReestablishmentReject( @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionReject( - uint8_t Mod_id, - uint8_t* const buffer); + uint8_t Mod_id, + uint8_t *const buffer); /** \brief Generate an RRCConnectionRequest UL-CCCH-Message (UE) based on random string or S-TMSI. This @@ -286,14 +286,14 @@ OAI_UECapability_t *fill_ue_capability(char *LTE_UE_EUTRA_Capability_xer); uint8_t do_UECapabilityEnquiry( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* const buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *const buffer, const uint8_t Transaction_id ); uint8_t do_SecurityModeCommand( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* const buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *const buffer, const uint8_t Transaction_id, const uint8_t cipheringAlgorithm, const uint8_t integrityProtAlgorithm); diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index fd54ab5892..1d9e447984 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -64,10 +64,10 @@ #define IPV4_ADDR "%u.%u.%u.%u" #define IPV4_ADDR_FORMAT(aDDRESS) \ - (uint8_t)((aDDRESS) & 0x000000ff), \ - (uint8_t)(((aDDRESS) & 0x0000ff00) >> 8 ), \ - (uint8_t)(((aDDRESS) & 0x00ff0000) >> 16), \ - (uint8_t)(((aDDRESS) & 0xff000000) >> 24) + (uint8_t)((aDDRESS) & 0x000000ff), \ + (uint8_t)(((aDDRESS) & 0x0000ff00) >> 8 ), \ + (uint8_t)(((aDDRESS) & 0x00ff0000) >> 16), \ + (uint8_t)(((aDDRESS) & 0xff000000) >> 24) //----------------------------------------------------- @@ -84,74 +84,74 @@ #define GROUP_COMMUNICATION_RELEASE_RSP 8 #define PC5S_ESTABLISH_REQ 9 #define PC5S_ESTABLISH_RSP 10 -#define PC5_DISCOVERY_MESSAGE 11 +#define PC5_DISCOVERY_MESSAGE 11 -#define PC5_DISCOVERY_PAYLOAD_SIZE 29 +#define PC5_DISCOVERY_PAYLOAD_SIZE 29 typedef enum { - UE_STATE_OFF_NETWORK, - UE_STATE_ON_NETWORK + UE_STATE_OFF_NETWORK, + UE_STATE_ON_NETWORK } SL_UE_STATE_t; typedef enum { - GROUP_COMMUNICATION_RELEASE_OK = 0, - GROUP_COMMUNICATION_RELEASE_FAILURE + GROUP_COMMUNICATION_RELEASE_OK = 0, + GROUP_COMMUNICATION_RELEASE_FAILURE } Group_Communication_Status_t; struct GroupCommunicationEstablishReq { - uint32_t sourceL2Id; - uint32_t groupL2Id; - uint32_t groupIpAddress; - uint8_t pppp; + uint32_t sourceL2Id; + uint32_t groupL2Id; + uint32_t groupIpAddress; + uint8_t pppp; }; struct GroupCommunicationReleaseReq { - uint32_t sourceL2Id; - uint32_t groupL2Id; - int slrb_id; + uint32_t sourceL2Id; + uint32_t groupL2Id; + int slrb_id; }; struct DirectCommunicationEstablishReq { - uint32_t sourceL2Id; - uint32_t destinationL2Id; - uint32_t pppp; + uint32_t sourceL2Id; + uint32_t destinationL2Id; + uint32_t pppp; }; -struct PC5SEstablishReq{ - uint8_t type; - uint32_t sourceL2Id; - uint32_t destinationL2Id; +struct PC5SEstablishReq { + uint8_t type; + uint32_t sourceL2Id; + uint32_t destinationL2Id; }; -struct PC5SEstablishRsp{ - uint32_t slrbid_lcid28; - uint32_t slrbid_lcid29; - uint32_t slrbid_lcid30; +struct PC5SEstablishRsp { + uint32_t slrbid_lcid28; + uint32_t slrbid_lcid29; + uint32_t slrbid_lcid30; }; //PC5_DISCOVERY MESSAGE typedef struct { - unsigned char payload[PC5_DISCOVERY_PAYLOAD_SIZE]; - uint32_t measuredPower; + unsigned char payload[PC5_DISCOVERY_PAYLOAD_SIZE]; + uint32_t measuredPower; } __attribute__((__packed__)) PC5DiscoveryMessage ; struct sidelink_ctrl_element { - unsigned short type; - union { - struct GroupCommunicationEstablishReq group_comm_establish_req; - struct DirectCommunicationEstablishReq direct_comm_establish_req; - Group_Communication_Status_t group_comm_release_rsp; - //struct DirectCommunicationReleaseReq direct_comm_release_req; - SL_UE_STATE_t ue_state; - int slrb_id; - struct PC5SEstablishReq pc5s_establish_req; - struct PC5SEstablishRsp pc5s_establish_rsp; - PC5DiscoveryMessage pc5_discovery_message; - } sidelinkPrimitive; + unsigned short type; + union { + struct GroupCommunicationEstablishReq group_comm_establish_req; + struct DirectCommunicationEstablishReq direct_comm_establish_req; + Group_Communication_Status_t group_comm_release_rsp; + //struct DirectCommunicationReleaseReq direct_comm_release_req; + SL_UE_STATE_t ue_state; + int slrb_id; + struct PC5SEstablishReq pc5s_establish_req; + struct PC5SEstablishRsp pc5s_establish_rsp; + PC5DiscoveryMessage pc5_discovery_message; + } sidelinkPrimitive; }; @@ -167,7 +167,7 @@ void *send_UE_status_notification(void *); //#include "COMMON/openair_defs.h" #ifndef USER_MODE -//#include + //#include #endif #include "LTE_SystemInformationBlockType1.h" @@ -182,18 +182,18 @@ void *send_UE_status_notification(void *); #include "LTE_SBCCH-SL-BCH-MessageType.h" #include "LTE_BCCH-BCH-Message.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) -#include "LTE_MCCH-Message.h" -#include "LTE_MBSFNAreaConfiguration-r9.h" + #include "LTE_MCCH-Message.h" + #include "LTE_MBSFNAreaConfiguration-r9.h" #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) -#include "LTE_SCellToAddMod-r10.h" + #include "LTE_SCellToAddMod-r10.h" #endif #include "LTE_AS-Config.h" #include "LTE_AS-Context.h" #include "LTE_UE-EUTRA-Capability.h" #include "LTE_MeasResults.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(12, 0, 0)) -#include "LTE_SidelinkUEInformation-r12.h" + #include "LTE_SidelinkUEInformation-r12.h" #endif /* for ImsiMobileIdentity_t */ @@ -203,66 +203,66 @@ void *send_UE_status_notification(void *); * the code is in favor of Rel14, those defines do the translation */ #if (LTE_RRC_VERSION < MAKE_VERSION(14, 0, 0)) -# define CipheringAlgorithm_r12_t e_SecurityAlgorithmConfig__cipheringAlgorithm -# define CipheringAlgorithm_r12_eea0 SecurityAlgorithmConfig__cipheringAlgorithm_eea0 -# define CipheringAlgorithm_r12_eea1 SecurityAlgorithmConfig__cipheringAlgorithm_eea1 -# define CipheringAlgorithm_r12_eea2 SecurityAlgorithmConfig__cipheringAlgorithm_eea2 -# define CipheringAlgorithm_r12_spare1 SecurityAlgorithmConfig__cipheringAlgorithm_spare1 -# define Alpha_r12_al0 UplinkPowerControlCommon__alpha_al0 -# define Alpha_r12_al04 UplinkPowerControlCommon__alpha_al04 -# define Alpha_r12_al05 UplinkPowerControlCommon__alpha_al05 -# define Alpha_r12_al06 UplinkPowerControlCommon__alpha_al06 -# define Alpha_r12_al07 UplinkPowerControlCommon__alpha_al07 -# define Alpha_r12_al08 UplinkPowerControlCommon__alpha_al08 -# define Alpha_r12_al09 UplinkPowerControlCommon__alpha_al09 -# define Alpha_r12_al1 UplinkPowerControlCommon__alpha_al1 -# define PreambleTransMax_n3 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3 -# define PreambleTransMax_n4 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4 -# define PreambleTransMax_n5 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5 -# define PreambleTransMax_n6 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6 -# define PreambleTransMax_n7 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7 -# define PreambleTransMax_n8 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8 -# define PreambleTransMax_n10 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10 -# define PreambleTransMax_n20 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20 -# define PreambleTransMax_n50 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50 -# define PreambleTransMax_n100 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100 -# define PreambleTransMax_n200 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200 -# define PeriodicBSR_Timer_r12_sf5 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf5 -# define PeriodicBSR_Timer_r12_sf10 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf10 -# define PeriodicBSR_Timer_r12_sf16 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf16 -# define PeriodicBSR_Timer_r12_sf20 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf20 -# define PeriodicBSR_Timer_r12_sf32 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf32 -# define PeriodicBSR_Timer_r12_sf40 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf40 -# define PeriodicBSR_Timer_r12_sf64 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf64 -# define PeriodicBSR_Timer_r12_sf80 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf80 -# define PeriodicBSR_Timer_r12_sf128 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf128 -# define PeriodicBSR_Timer_r12_sf160 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf160 -# define PeriodicBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf320 -# define PeriodicBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf640 -# define PeriodicBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf1280 -# define PeriodicBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf2560 -# define PeriodicBSR_Timer_r12_infinity MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity -# define RetxBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf320 -# define RetxBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf640 -# define RetxBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf1280 -# define RetxBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560 -# define RetxBSR_Timer_r12_sf5120 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf5120 -# define RetxBSR_Timer_r12_sf10240 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf10240 + #define CipheringAlgorithm_r12_t e_SecurityAlgorithmConfig__cipheringAlgorithm + #define CipheringAlgorithm_r12_eea0 SecurityAlgorithmConfig__cipheringAlgorithm_eea0 + #define CipheringAlgorithm_r12_eea1 SecurityAlgorithmConfig__cipheringAlgorithm_eea1 + #define CipheringAlgorithm_r12_eea2 SecurityAlgorithmConfig__cipheringAlgorithm_eea2 + #define CipheringAlgorithm_r12_spare1 SecurityAlgorithmConfig__cipheringAlgorithm_spare1 + #define Alpha_r12_al0 UplinkPowerControlCommon__alpha_al0 + #define Alpha_r12_al04 UplinkPowerControlCommon__alpha_al04 + #define Alpha_r12_al05 UplinkPowerControlCommon__alpha_al05 + #define Alpha_r12_al06 UplinkPowerControlCommon__alpha_al06 + #define Alpha_r12_al07 UplinkPowerControlCommon__alpha_al07 + #define Alpha_r12_al08 UplinkPowerControlCommon__alpha_al08 + #define Alpha_r12_al09 UplinkPowerControlCommon__alpha_al09 + #define Alpha_r12_al1 UplinkPowerControlCommon__alpha_al1 + #define PreambleTransMax_n3 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3 + #define PreambleTransMax_n4 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4 + #define PreambleTransMax_n5 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5 + #define PreambleTransMax_n6 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6 + #define PreambleTransMax_n7 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7 + #define PreambleTransMax_n8 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8 + #define PreambleTransMax_n10 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10 + #define PreambleTransMax_n20 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20 + #define PreambleTransMax_n50 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50 + #define PreambleTransMax_n100 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100 + #define PreambleTransMax_n200 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200 + #define PeriodicBSR_Timer_r12_sf5 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf5 + #define PeriodicBSR_Timer_r12_sf10 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf10 + #define PeriodicBSR_Timer_r12_sf16 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf16 + #define PeriodicBSR_Timer_r12_sf20 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf20 + #define PeriodicBSR_Timer_r12_sf32 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf32 + #define PeriodicBSR_Timer_r12_sf40 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf40 + #define PeriodicBSR_Timer_r12_sf64 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf64 + #define PeriodicBSR_Timer_r12_sf80 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf80 + #define PeriodicBSR_Timer_r12_sf128 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf128 + #define PeriodicBSR_Timer_r12_sf160 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf160 + #define PeriodicBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf320 + #define PeriodicBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf640 + #define PeriodicBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf1280 + #define PeriodicBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf2560 + #define PeriodicBSR_Timer_r12_infinity MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity + #define RetxBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf320 + #define RetxBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf640 + #define RetxBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf1280 + #define RetxBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560 + #define RetxBSR_Timer_r12_sf5120 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf5120 + #define RetxBSR_Timer_r12_sf10240 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf10240 #endif // This corrects something generated by asn1c which is different between Rel8 and Rel10 #if (LTE_RRC_VERSION <= MAKE_VERSION(10, 0, 0)) -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member SystemInformation_r8_IEs_sib_TypeAndInfo_Member -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member SystemInformation_r8_IEs_sib_TypeAndInfo_Member + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11 #endif @@ -279,13 +279,13 @@ void *send_UE_status_notification(void *); */ //#include "L3_rrc_defs.h" #ifndef NO_RRM -#include "L3_rrc_interface.h" -#include "rrc_rrm_msg.h" -#include "rrc_rrm_interface.h" + #include "L3_rrc_interface.h" + #include "rrc_rrm_msg.h" + #include "rrc_rrm_interface.h" #endif #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif /* TODO: be sure this include is correct. @@ -293,11 +293,11 @@ void *send_UE_status_notification(void *); * issue #186. */ #if !defined(ENABLE_ITTI) -# include "as_message.h" + #include "as_message.h" #endif #if defined(ENABLE_USE_MME) -# include "commonDef.h" + #include "commonDef.h" #endif //-------- @@ -516,29 +516,29 @@ typedef struct eNB_RRC_UE_s { #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) LTE_SCellToAddMod_r10_t sCell_config[2]; #endif - LTE_SRB_ToAddModList_t* SRB_configList; - LTE_SRB_ToAddModList_t* SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; - LTE_DRB_ToAddModList_t* DRB_configList; - LTE_DRB_ToAddModList_t* DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; - LTE_DRB_ToReleaseList_t* DRB_Release_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + LTE_SRB_ToAddModList_t *SRB_configList; + LTE_SRB_ToAddModList_t *SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + LTE_DRB_ToAddModList_t *DRB_configList; + LTE_DRB_ToAddModList_t *DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + LTE_DRB_ToReleaseList_t *DRB_Release_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; uint8_t DRB_active[8]; - struct LTE_PhysicalConfigDedicated* physicalConfigDedicated; - struct LTE_SPS_Config* sps_Config; - LTE_MeasObjectToAddMod_t* MeasObj[MAX_MEAS_OBJ]; - struct LTE_ReportConfigToAddMod* ReportConfig[MAX_MEAS_CONFIG]; - struct LTE_QuantityConfig* QuantityConfig; - struct LTE_MeasIdToAddMod* MeasId[MAX_MEAS_ID]; - LTE_MAC_MainConfig_t* mac_MainConfig; - LTE_MeasGapConfig_t* measGapConfig; + struct LTE_PhysicalConfigDedicated *physicalConfigDedicated; + struct LTE_SPS_Config *sps_Config; + LTE_MeasObjectToAddMod_t *MeasObj[MAX_MEAS_OBJ]; + struct LTE_ReportConfigToAddMod *ReportConfig[MAX_MEAS_CONFIG]; + struct LTE_QuantityConfig *QuantityConfig; + struct LTE_MeasIdToAddMod *MeasId[MAX_MEAS_ID]; + LTE_MAC_MainConfig_t *mac_MainConfig; + LTE_MeasGapConfig_t *measGapConfig; SRB_INFO SI; SRB_INFO Srb0; SRB_INFO_TABLE_ENTRY Srb1; SRB_INFO_TABLE_ENTRY Srb2; - LTE_MeasConfig_t* measConfig; - HANDOVER_INFO* handover_info; - LTE_MeasResults_t* measResults; + LTE_MeasConfig_t *measConfig; + HANDOVER_INFO *handover_info; + LTE_MeasResults_t *measResults; - LTE_UE_EUTRA_Capability_t* UE_Capability; + LTE_UE_EUTRA_Capability_t *UE_Capability; ImsiMobileIdentity_t imsi; #if defined(ENABLE_SECURITY) @@ -601,7 +601,7 @@ typedef struct eNB_RRC_UE_s { uint32_t ue_reestablishment_timer_thres; /* RRC inactivity timer: on timeout, should release RRC connection for inactivity on all E-RABs */ uint32_t ue_rrc_inactivity_timer; - uint32_t ue_rrc_inactivity_timer_thres; + uint32_t ue_rrc_inactivity_timer_thres; uint8_t e_rab_release_command_flag; int8_t reestablishment_xid; } eNB_RRC_UE_t; @@ -771,7 +771,7 @@ typedef struct UE_RRC_INST_s { //current destination uint32_t destinationL2Id; //List of destinations - uint32_t destinationList[MAX_NUM_DEST]; + uint32_t destinationList[MAX_NUM_DEST]; //sl_discovery.. SRB_INFO SL_Discovery[NB_CNX_UE]; #endif diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 412128b017..3f3248aaca 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -75,29 +75,29 @@ #include "OCG_extern.h" #if defined(ENABLE_SECURITY) -# include "UTIL/OSA/osa_defs.h" + #include "UTIL/OSA/osa_defs.h" #endif #if defined(ENABLE_USE_MME) -# include "rrc_eNB_S1AP.h" -# include "rrc_eNB_GTPV1U.h" -# if defined(ENABLE_ITTI) -# else -# include "../../S1AP/s1ap_eNB.h" -# endif + #include "rrc_eNB_S1AP.h" + #include "rrc_eNB_GTPV1U.h" + #if defined(ENABLE_ITTI) + #else + #include "../../S1AP/s1ap_eNB.h" + #endif #else -# define EPC_MODE_ENABLED 0 + #define EPC_MODE_ENABLED 0 #endif #include "pdcp.h" #include "gtpv1u_eNB_task.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif #if ENABLE_RAL -# include "rrc_eNB_ral.h" + #include "rrc_eNB_ral.h" #endif #include "SIMULATION/TOOLS/sim.h" // for taus @@ -106,12 +106,12 @@ extern RAN_CONTEXT_t RC; #ifdef PHY_EMUL -extern EMULATION_VARS *Emul_vars; + extern EMULATION_VARS *Emul_vars; #endif extern eNB_MAC_INST *eNB_mac_inst; extern UE_MAC_INST *UE_mac_inst; #ifdef BIGPHYSAREA -extern void* bigphys_malloc(int); + extern void *bigphys_malloc(int); #endif extern uint16_t two_tier_hexagonal_cellIds[7]; @@ -120,30 +120,30 @@ mui_t rrc_eNB_mui = 0; void openair_rrc_on( - const protocol_ctxt_t* const ctxt_pP + const protocol_ctxt_t *const ctxt_pP ) //----------------------------------------------------------------------------- { int CC_id; + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" ENB:OPENAIR RRC IN....\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" ENB:OPENAIR RRC IN....\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1; - rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1; - } + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1; + rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1; + } } //----------------------------------------------------------------------------- static void init_SI( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const int CC_id #if defined(ENABLE_ITTI) , - RrcConfigurationReq * configuration + RrcConfigurationReq *configuration #endif ) //----------------------------------------------------------------------------- @@ -151,14 +151,11 @@ init_SI( #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) int i; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 1, 0)) LTE_SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext=(LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL; #endif - LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__); - - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t *) malloc16(4); // copy basic parameters RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId = configuration->Nid_cell[CC_id]; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB = configuration->nb_antenna_ports[CC_id]; @@ -168,84 +165,74 @@ init_SI( #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition = configuration->pbch_repetition[CC_id]; #endif - LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", - (int)configuration->N_RB_DL[CC_id], - (int)configuration->phich_resource[CC_id], - (int)configuration->phich_duration[CC_id]); + LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", + (int)configuration->N_RB_DL[CC_id], + (int)configuration->phich_resource[CC_id], + (int)configuration->phich_duration[CC_id]); do_MIB(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id], #ifdef ENABLE_ITTI - configuration->N_RB_DL[CC_id], - configuration->phich_resource[CC_id], - configuration->phich_duration[CC_id] + configuration->N_RB_DL[CC_id], + configuration->phich_resource[CC_id], + configuration->phich_duration[CC_id] #else - 50,0,0 + 50,0,0 #endif - ,0); - - + ,0); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = 0; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = 0; - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1 = (uint8_t*) malloc16(32); - + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1 = (uint8_t *) malloc16(32); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1!=NULL,PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB1 allocated\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = do_SIB1(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],ctxt_pP->module_id,CC_id #if defined(ENABLE_ITTI) - , configuration + , configuration #endif - ); - + ); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 != 255,"FATAL, RC.rrc[enb_mod_idP].carrier[CC_id].sizeof_SIB1 == 255"); - - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t*) malloc16(64); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t *) malloc16(64); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23!=NULL,"cannot allocate memory for SIB"); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = do_SIB23( - ctxt_pP->module_id, - - CC_id + ctxt_pP->module_id, + CC_id #if defined(ENABLE_ITTI) - , configuration + , configuration #endif - ); - + ); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 != 255,"FATAL, RC.rrc[mod].carrier[CC_id].sizeof_SIB23 == 255"); - - LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" SIB2/3 Contents (partial)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.n_SB = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - pusch_ConfigBasic.n_SB); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + pusch_ConfigBasic.n_SB); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.hoppingMode = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - pusch_ConfigBasic.hoppingMode); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + pusch_ConfigBasic.hoppingMode); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.pusch_HoppingOffset = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - pusch_ConfigBasic.pusch_HoppingOffset); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + pusch_ConfigBasic.pusch_HoppingOffset); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.enable64QAM = %d\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - pusch_ConfigBasic.enable64QAM); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + pusch_ConfigBasic.enable64QAM); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupHoppingEnabled = %d\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.groupHoppingEnabled); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.groupHoppingEnabled); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupAssignmentPUSCH = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.sequenceHoppingEnabled = %d\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.cyclicShift = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.cyclicShift); - + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.cyclicShift); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag > 0) { @@ -253,177 +240,174 @@ init_SI( // SIB 2 // LOG_D(RRC, "[eNB %d] mbsfn_SubframeConfigList.list.count = %ld\n", enb_mod_idP, RC.rrc[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.count); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN subframe allocation %d/%d(partial)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - i, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + i, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" mbsfn_Subframe_pattern is = %x\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_period = %ld (just index number, not the real value)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod); // need to display the real value, using array of char (like in dumping SIB2) + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod); // need to display the real value, using array of char (like in dumping SIB2) LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_offset = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset); } #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) + // SIB13 for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) { LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN sync area %d/%d (partial)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - i, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + i, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Repetition Period: %ld (just index number, not real value)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Offset: %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); } + #endif - } - else memset((void*)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13)); + } else memset((void *)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13)); //TTN - SIB 18 for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count; j++) { - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB18 %d/%d \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - j+1, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 rxPool_sc_CP_Len: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 sc_Period_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 data_CP_Len_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Num_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Start_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_End_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 offsetIndicator: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 subframeBitmap_choice_bs_buf: %s \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); - + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB18 %d/%d \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + j+1, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 rxPool_sc_CP_Len: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 sc_Period_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 data_CP_Len_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Num_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Start_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_End_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 offsetIndicator: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 subframeBitmap_choice_bs_buf: %s \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); } //TTN - SIB 19 for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count; j++) { - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB19 %d/%d \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - j+1, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 cp_Len_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 discPeriod_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRetx_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRepetition_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Num_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Start_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_End_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 offsetIndicator: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 subframeBitmap_choice_bs_buf: %s \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); - + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB19 %d/%d \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + j+1, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 cp_Len_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 discPeriod_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRetx_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRepetition_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Num_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Start_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_End_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 offsetIndicator: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 subframeBitmap_choice_bs_buf: %s \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); } #endif - LOG_D(RRC, - PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - + PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - if ((RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib.message.schedulingInfoSIB1_BR_r13>0) && + + if ((RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib.message.schedulingInfoSIB1_BR_r13>0) && (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR!=NULL)) { - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v8.9)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v9.2)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v11.3)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v12.5)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v13.10)\n"); - sib1_v13ext = RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension; + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v8.9)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v9.2)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v11.3)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v12.5)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v13.10)\n"); + sib1_v13ext = RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension; } -#endif +#endif LOG_D(RRC, "About to call rrc_mac_config_req_eNB\n"); - rrc_mac_config_req_eNB(ctxt_pP->module_id, CC_id, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition, #endif - 0, // rnti - (LTE_BCCH_BCH_Message_t *) - &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib, - (LTE_RadioResourceConfigCommonSIB_t *) & - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon, + 0, // rnti + (LTE_BCCH_BCH_Message_t *) + &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib, + (LTE_RadioResourceConfigCommonSIB_t *) & + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) & - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon, + (LTE_RadioResourceConfigCommonSIB_t *) & + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon, #endif - (struct LTE_PhysicalConfigDedicated *)NULL, + (struct LTE_PhysicalConfigDedicated *)NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - (LTE_MAC_MainConfig_t *) NULL, 0, - (struct LTE_LogicalChannelConfig *)NULL, - (LTE_MeasGapConfig_t *) NULL, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->tdd_Config, - NULL, - &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->schedulingInfoList, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.ul_Bandwidth, - &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission, - (LTE_MBSFN_SubframeConfigList_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + (LTE_MAC_MainConfig_t *) NULL, 0, + (struct LTE_LogicalChannelConfig *)NULL, + (LTE_MeasGapConfig_t *) NULL, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->tdd_Config, + NULL, + &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->schedulingInfoList, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.ul_Bandwidth, + &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission, + (LTE_MBSFN_SubframeConfigList_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag, - (LTE_MBSFN_AreaInfoList_r9_t*) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9, - (LTE_PMCH_InfoList_r9_t *) NULL + , + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag, + (LTE_MBSFN_AreaInfoList_r9_t *) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9, + (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - sib1_v13ext + , + sib1_v13ext #endif - ); + ); } #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) @@ -435,92 +419,81 @@ init_MCCH( ) //----------------------------------------------------------------------------- { - int sync_area = 0; // initialize RRC_eNB_INST MCCH entry RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE = - malloc(RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area * sizeof(uint8_t*)); + malloc(RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area * sizeof(uint8_t *)); for (sync_area = 0; sync_area < RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area; sync_area++) { - RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = 0; RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area] = (uint8_t *) malloc16(32); - AssertFatal(RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area] != NULL, - "[eNB %d]init_MCCH: FATAL, no memory for MCCH MESSAGE allocated \n", enb_mod_idP); + "[eNB %d]init_MCCH: FATAL, no memory for MCCH MESSAGE allocated \n", enb_mod_idP); RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = do_MBSFNAreaConfig(enb_mod_idP, - sync_area, - (uint8_t *)RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], - &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch, - &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message); - + sync_area, + (uint8_t *)RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], + &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch, + &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message); LOG_I(RRC, "mcch message pointer %p for sync area %d \n", - RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], - sync_area); + RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], + sync_area); LOG_D(RRC, "[eNB %d] MCCH_MESSAGE contents for Sync Area %d (partial)\n", enb_mod_idP, sync_area); LOG_D(RRC, "[eNB %d] CommonSF_AllocPeriod_r9 %ld\n", enb_mod_idP, - RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_AllocPeriod_r9); + RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_AllocPeriod_r9); LOG_D(RRC, - "[eNB %d] CommonSF_Alloc_r9.list.count (number of MBSFN Subframe Pattern) %d\n", - enb_mod_idP, RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.count); + "[eNB %d] CommonSF_Alloc_r9.list.count (number of MBSFN Subframe Pattern) %d\n", + enb_mod_idP, RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.count); LOG_D(RRC, "[eNB %d] MBSFN Subframe Pattern: %02x (in hex)\n", - enb_mod_idP, - RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation. - choice.oneFrame.buf[0]); - + enb_mod_idP, + RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation. + choice.oneFrame.buf[0]); AssertFatal(RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] != 255, - "RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255"); + "RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255"); RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESS[sync_area].Active = 1; } - //Set the RC.rrc[enb_mod_idP]->MCCH_MESS.Active to 1 (allow to transfer MCCH message RRC->MAC in function mac_rrc_data_req) - // ??Configure MCCH logical channel // call mac_config_req with appropriate structure from ASN.1 description - - // LOG_I(RRC, "DUY: serviceID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->tmgi_r9.serviceId_r9.buf[2]); // LOG_I(RRC, "DUY: session ID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->sessionId_r9->buf[0]); rrc_mac_config_req_eNB(enb_mod_idP, CC_id, - 0,0,0,0,0, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - 0,//rnti - (LTE_BCCH_BCH_Message_t *)NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + 0,//rnti + (LTE_BCCH_BCH_Message_t *)NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - (struct LTE_PhysicalConfigDedicated *)NULL, + (struct LTE_PhysicalConfigDedicated *)NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - (LTE_MAC_MainConfig_t *) NULL, - 0, - (struct LTE_LogicalChannelConfig *)NULL, - (LTE_MeasGapConfig_t *) NULL, - (LTE_TDD_Config_t *) NULL, - (LTE_MobilityControlInfo_t *)NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + (LTE_MAC_MainConfig_t *) NULL, + 0, + (struct LTE_LogicalChannelConfig *)NULL, + (LTE_MeasGapConfig_t *) NULL, + (LTE_TDD_Config_t *) NULL, + (LTE_MobilityControlInfo_t *)NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , - 0, - (LTE_MBSFN_AreaInfoList_r9_t *) NULL, - (LTE_PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) + , + 0, + (LTE_MBSFN_AreaInfoList_r9_t *) NULL, + (LTE_PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + , + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); - + ); //LOG_I(RRC,"DUY: lcid after rrc_mac_config_req is %02d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9); - } //----------------------------------------------------------------------------- @@ -536,13 +509,11 @@ static void init_MBMS( if (RC.rrc[enb_mod_idP]->carrier[CC_id].MBMS_flag > 0) { PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,enb_mod_idP); - LOG_D(RRC, "[eNB %d] Frame %d : Radio Bearer config request for MBMS\n", enb_mod_idP, frameP); //check the lcid // Configuring PDCP and RLC for MBMS Radio Bearer - rrc_pdcp_config_asn1_req(&ctxt, - (LTE_SRB_ToAddModList_t *)NULL, // LTE_SRB_ToAddModList - (LTE_DRB_ToAddModList_t *)NULL, // LTE_DRB_ToAddModList + (LTE_SRB_ToAddModList_t *)NULL, // LTE_SRB_ToAddModList + (LTE_DRB_ToAddModList_t *)NULL, // LTE_DRB_ToAddModList (LTE_DRB_ToReleaseList_t *)NULL, 0, // security mode NULL, // key rrc encryption @@ -552,18 +523,15 @@ static void init_MBMS( , &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) #endif ,NULL); - rrc_rlc_config_asn1_req(&ctxt, NULL, // LTE_SRB_ToAddModList NULL, // LTE_DRB_ToAddModList NULL, // DRB_ToReleaseList &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,0, 0 #endif - ); - + ); //rrc_mac_config_req(); } } @@ -616,14 +584,14 @@ rrc_eNB_get_next_transaction_identifier( //----------------------------------------------------------------------------- // return the ue context if there is already an UE with ue_identityP, NULL otherwise -static struct rrc_eNB_ue_context_s* +static struct rrc_eNB_ue_context_s * rrc_eNB_ue_context_random_exist( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint64_t ue_identityP ) //----------------------------------------------------------------------------- { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { if (ue_context_p->ue_context.random_ue_identity == ue_identityP) return ue_context_p; @@ -632,47 +600,47 @@ rrc_eNB_ue_context_random_exist( } //----------------------------------------------------------------------------- // return the ue context if there is already an UE with the same S-TMSI(MMEC+M-TMSI), NULL otherwise -static struct rrc_eNB_ue_context_s* +static struct rrc_eNB_ue_context_s * rrc_eNB_ue_context_stmsi_exist( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const mme_code_t mme_codeP, const m_tmsi_t m_tmsiP ) //----------------------------------------------------------------------------- { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { LOG_I(RRC,"checking for UE S-TMSI %x, mme %x (%p): rnti %x", - m_tmsiP, mme_codeP, ue_context_p, - ue_context_p->ue_context.rnti); + m_tmsiP, mme_codeP, ue_context_p, + ue_context_p->ue_context.rnti); + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { printf("=> S-TMSI %x, MME %x\n", - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, - ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code); + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code); + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi == m_tmsiP) if (ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code == mme_codeP) return ue_context_p; - } - else + } else printf("\n"); - } return NULL; } //----------------------------------------------------------------------------- // return a new ue context structure if ue_identityP, ctxt_pP->rnti not found in collection -static struct rrc_eNB_ue_context_s* +static struct rrc_eNB_ue_context_s * rrc_eNB_get_next_free_ue_context( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint64_t ue_identityP ) //----------------------------------------------------------------------------- { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[ctxt_pP->module_id], - ctxt_pP->rnti); + RC.rrc[ctxt_pP->module_id], + ctxt_pP->rnti); if (ue_context_p == NULL) { ue_context_p = rrc_eNB_allocate_new_UE_context(RC.rrc[ctxt_pP->module_id]); @@ -693,7 +661,6 @@ rrc_eNB_get_next_free_ue_context( PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), ue_context_p->local_uid); return ue_context_p; - } else { LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist\n", @@ -705,8 +672,8 @@ rrc_eNB_get_next_free_ue_context( //----------------------------------------------------------------------------- void rrc_eNB_free_mem_UE_context( - const protocol_ctxt_t* const ctxt_pP, - struct rrc_eNB_ue_context_s* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + struct rrc_eNB_ue_context_s *const ue_context_pP ) //----------------------------------------------------------------------------- { @@ -725,11 +692,11 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.SRB_configList = NULL; } - for(i = 0;i < RRC_TRANSACTION_IDENTIFIER_NUMBER;i++){ - if (ue_context_pP->ue_context.SRB_configList2[i]) { - free(ue_context_pP->ue_context.SRB_configList2[i]); - ue_context_pP->ue_context.SRB_configList2[i] = NULL; - } + for(i = 0; i < RRC_TRANSACTION_IDENTIFIER_NUMBER; i++) { + if (ue_context_pP->ue_context.SRB_configList2[i]) { + free(ue_context_pP->ue_context.SRB_configList2[i]); + ue_context_pP->ue_context.SRB_configList2[i] = NULL; + } } if (ue_context_pP->ue_context.DRB_configList) { @@ -737,15 +704,16 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.DRB_configList = NULL; } - for(i = 0;i < RRC_TRANSACTION_IDENTIFIER_NUMBER;i++){ - if (ue_context_pP->ue_context.DRB_configList2[i]) { - free(ue_context_pP->ue_context.DRB_configList2[i]); - ue_context_pP->ue_context.DRB_configList2[i] = NULL; - } - if (ue_context_pP->ue_context.DRB_Release_configList2[i]) { - free(ue_context_pP->ue_context.DRB_Release_configList2[i]); - ue_context_pP->ue_context.DRB_Release_configList2[i] = NULL; - } + for(i = 0; i < RRC_TRANSACTION_IDENTIFIER_NUMBER; i++) { + if (ue_context_pP->ue_context.DRB_configList2[i]) { + free(ue_context_pP->ue_context.DRB_configList2[i]); + ue_context_pP->ue_context.DRB_configList2[i] = NULL; + } + + if (ue_context_pP->ue_context.DRB_Release_configList2[i]) { + free(ue_context_pP->ue_context.DRB_Release_configList2[i]); + ue_context_pP->ue_context.DRB_Release_configList2[i] = NULL; + } } memset(ue_context_pP->ue_context.DRB_active, 0, sizeof(ue_context_pP->ue_context.DRB_active)); @@ -784,14 +752,14 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.mac_MainConfig = NULL; } -/* if (ue_context_pP->ue_context.measGapConfig) { - ASN_STRUCT_FREE(asn_DEF_LTE_MeasGapConfig, ue_context_pP->ue_context.measGapConfig); - ue_context_pP->ue_context.measGapConfig = NULL; - }*/ - if (ue_context_pP->ue_context.handover_info) { - ASN_STRUCT_FREE(asn_DEF_LTE_Handover, ue_context_pP->ue_context.handover_info); - ue_context_pP->ue_context.handover_info = NULL; - } + /* if (ue_context_pP->ue_context.measGapConfig) { + ASN_STRUCT_FREE(asn_DEF_LTE_MeasGapConfig, ue_context_pP->ue_context.measGapConfig); + ue_context_pP->ue_context.measGapConfig = NULL; + }*/ + if (ue_context_pP->ue_context.handover_info) { + ASN_STRUCT_FREE(asn_DEF_LTE_Handover, ue_context_pP->ue_context.handover_info); + ue_context_pP->ue_context.handover_info = NULL; + } //SRB_INFO SI; //SRB_INFO Srb0; @@ -833,9 +801,9 @@ rrc_eNB_free_mem_UE_context( //----------------------------------------------------------------------------- /* -* Should be called when UE context in eNB should be released +* Should be called when UE context in eNB should be released * or when S1 command UE_CONTEXT_RELEASE_REQ should be sent -*/ +*/ void rrc_eNB_free_UE( const module_id_t enb_mod_idP, @@ -846,175 +814,180 @@ rrc_eNB_free_UE( if (enb_mod_idP >= NB_eNB_INST) { LOG_E(RRC, "eNB instance invalid (%d/%d) for UE %x!\n", - enb_mod_idP, - NB_eNB_INST, - rnti); - + enb_mod_idP, + NB_eNB_INST, + rnti); return; } if (EPC_MODE_ENABLED) { if ((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { - LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 21, radio connection with ue lost\n", - enb_mod_idP, - rnti); - - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 21, radio connection with ue lost\n", + enb_mod_idP, + rnti); + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: radio connection with ue lost /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before * triggering the S1 UE Context Release Request procedure in order to allow the UE to perform the NAS recovery * procedure, see TS 23.401 [17]. */ - return; } - + if((ue_context_pP->ue_context.ue_rrc_inactivity_timer >= ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres) && - (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { - LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 20, user inactivity\n", - enb_mod_idP, - rnti); - - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 20); + (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 20, user inactivity\n", + enb_mod_idP, + rnti); + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 20); // send cause 20: user inactivity - return; } } - LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", - enb_mod_idP, - rnti); - + LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", + enb_mod_idP, + rnti); // add UE info to freeList LOG_I(RRC, "Put UE %x into freeList\n", - rnti); - + rnti); put_UE_in_freelist(enb_mod_idP, rnti, 1); } -void remove_UE_from_freelist(module_id_t mod_id, rnti_t rnti) -{ - - eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; - pthread_mutex_lock(&lock_ue_freelist); - UE_free_list_t *free_list = &eNB_MAC->UE_free_list; - free_list->UE_free_ctrl[free_list->head_freelist].rnti = 0; - free_list->head_freelist = (free_list->head_freelist + 1) % (NUMBER_OF_UE_MAX+1); - free_list->num_UEs--; - pthread_mutex_unlock(&lock_ue_freelist); +void remove_UE_from_freelist(module_id_t mod_id, rnti_t rnti) { + eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; + pthread_mutex_lock(&lock_ue_freelist); + UE_free_list_t *free_list = &eNB_MAC->UE_free_list; + free_list->UE_free_ctrl[free_list->head_freelist].rnti = 0; + free_list->head_freelist = (free_list->head_freelist + 1) % (NUMBER_OF_UE_MAX+1); + free_list->num_UEs--; + pthread_mutex_unlock(&lock_ue_freelist); } -void put_UE_in_freelist(module_id_t mod_id, rnti_t rnti, boolean_t removeFlag) -{ - UE_free_list_t *free_list = NULL; - eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; - pthread_mutex_lock(&lock_ue_freelist); - free_list = &eNB_MAC->UE_free_list; - free_list->UE_free_ctrl[free_list->tail_freelist].rnti = rnti; - free_list->UE_free_ctrl[free_list->tail_freelist].removeContextFlg = removeFlag; - free_list->num_UEs++; - free_list->tail_freelist = (free_list->tail_freelist + 1) % (NUMBER_OF_UE_MAX+1); - pthread_mutex_unlock(&lock_ue_freelist); +void put_UE_in_freelist(module_id_t mod_id, rnti_t rnti, boolean_t removeFlag) { + UE_free_list_t *free_list = NULL; + eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; + pthread_mutex_lock(&lock_ue_freelist); + free_list = &eNB_MAC->UE_free_list; + free_list->UE_free_ctrl[free_list->tail_freelist].rnti = rnti; + free_list->UE_free_ctrl[free_list->tail_freelist].removeContextFlg = removeFlag; + free_list->num_UEs++; + free_list->tail_freelist = (free_list->tail_freelist + 1) % (NUMBER_OF_UE_MAX+1); + pthread_mutex_unlock(&lock_ue_freelist); } -void release_UE_in_freeList(module_id_t mod_id) -{ - int i, j , CC_id, pdu_number; - protocol_ctxt_t ctxt; - LTE_eNB_ULSCH_t *ulsch = NULL; - LTE_eNB_DLSCH_t *dlsch = NULL; - nfapi_ul_config_request_body_t *ul_req_tmp = NULL; - PHY_VARS_eNB *eNB_PHY = NULL; - struct rrc_eNB_ue_context_s *ue_context_pP = NULL; - eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; - boolean_t remove_UEContext; - rnti_t rnti; - int head, tail, ue_num; - - pthread_mutex_lock(&lock_ue_freelist); - head = eNB_MAC->UE_free_list.head_freelist; - tail = eNB_MAC->UE_free_list.tail_freelist; - if(head == tail){ - pthread_mutex_unlock(&lock_ue_freelist); - return; - } - if(tail < head){ - tail = head + eNB_MAC->UE_free_list.num_UEs; - } +void release_UE_in_freeList(module_id_t mod_id) { + int i, j, CC_id, pdu_number; + protocol_ctxt_t ctxt; + LTE_eNB_ULSCH_t *ulsch = NULL; + LTE_eNB_DLSCH_t *dlsch = NULL; + nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + PHY_VARS_eNB *eNB_PHY = NULL; + struct rrc_eNB_ue_context_s *ue_context_pP = NULL; + eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; + boolean_t remove_UEContext; + rnti_t rnti; + int head, tail, ue_num; + pthread_mutex_lock(&lock_ue_freelist); + head = eNB_MAC->UE_free_list.head_freelist; + tail = eNB_MAC->UE_free_list.tail_freelist; + + if(head == tail) { pthread_mutex_unlock(&lock_ue_freelist); + return; + } - for(ue_num = head; ue_num < tail; ue_num++){ - ue_num = ue_num % (NUMBER_OF_UE_MAX+1); - rnti = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].rnti; - if(rnti != 0){ - remove_UEContext = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].removeContextFlg; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, rnti, 0, 0,mod_id); - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - eNB_PHY = RC.eNB[mod_id][CC_id]; - for (i=0; iulsch[i]; - if((ulsch != NULL) && (ulsch->rnti == rnti)){ - void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); - LOG_I(RRC, "clean_eNb_ulsch ulsch[%d] UE %x\n", i, rnti); - clean_eNb_ulsch(ulsch); - } - if(eNB_PHY->uci_vars[i].rnti == rnti){ - LOG_I(MAC, "clean eNb uci_vars[%d] UE %x \n",i, rnti); - memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); - } - } - for (i=0; idlsch[i][0]; - if((dlsch != NULL) && (dlsch->rnti == rnti)){ - void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); - LOG_I(RRC, "clean_eNb_dlsch dlsch[%d] UE %x \n", i, rnti); - clean_eNb_dlsch(dlsch); - } - } + if(tail < head) { + tail = head + eNB_MAC->UE_free_list.num_UEs; + } - if (rrc_agent_registered[mod_id]) { - agent_rrc_xface[mod_id]->flexran_agent_notify_ue_state_change(mod_id, - rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); - } + pthread_mutex_unlock(&lock_ue_freelist); + + for(ue_num = head; ue_num < tail; ue_num++) { + ue_num = ue_num % (NUMBER_OF_UE_MAX+1); + rnti = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].rnti; + + if(rnti != 0) { + remove_UEContext = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].removeContextFlg; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, rnti, 0, 0,mod_id); + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + eNB_PHY = RC.eNB[mod_id][CC_id]; + + for (i=0; iulsch[i]; + + if((ulsch != NULL) && (ulsch->rnti == rnti)) { + void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); + LOG_I(RRC, "clean_eNb_ulsch ulsch[%d] UE %x\n", i, rnti); + clean_eNb_ulsch(ulsch); + } + + if(eNB_PHY->uci_vars[i].rnti == rnti) { + LOG_I(MAC, "clean eNb uci_vars[%d] UE %x \n",i, rnti); + memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); + } + } + + for (i=0; idlsch[i][0]; + + if((dlsch != NULL) && (dlsch->rnti == rnti)) { + void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); + LOG_I(RRC, "clean_eNb_dlsch dlsch[%d] UE %x \n", i, rnti); + clean_eNb_dlsch(dlsch); + } + } + + if (rrc_agent_registered[mod_id]) { + agent_rrc_xface[mod_id]->flexran_agent_notify_ue_state_change(mod_id, + rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + } + + for(j = 0; j < 10; j++) { + ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; + + if(ul_req_tmp) { + pdu_number = ul_req_tmp->number_of_pdus; + + for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--) { + if((ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_cqi_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].srs_pdu.srs_pdu_rel8.rnti == rnti)) { + LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); - for(j = 0; j < 10; j++){ - ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; - if(ul_req_tmp){ - pdu_number = ul_req_tmp->number_of_pdus; - for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ - if((ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || - (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) || - (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_cqi_pdu.ue_information.ue_information_rel8.rnti == rnti) || - (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti) || - (ul_req_tmp->ul_config_pdu_list[pdu_index].srs_pdu.srs_pdu_rel8.rnti == rnti)){ - LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); - if(pdu_index < pdu_number -1){ - memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); - } - ul_req_tmp->number_of_pdus--; - } - } + if(pdu_index < pdu_number -1) { + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); } + + ul_req_tmp->number_of_pdus--; } } - rrc_mac_remove_ue(mod_id,rnti); - rrc_rlc_remove_ue(&ctxt); - pdcp_remove_UE(&ctxt); - - if(remove_UEContext){ - ue_context_pP = rrc_eNB_get_ue_context( - RC.rrc[mod_id],rnti); - if(ue_context_pP){ - rrc_eNB_remove_ue_context(&ctxt,RC.rrc[mod_id], - (struct rrc_eNB_ue_context_s*) ue_context_pP); - } - } - LOG_I(RRC, "[release_UE_in_freeList] remove UE %x from freeList\n", rnti); - remove_UE_from_freelist(mod_id, rnti); + } + } + } + + rrc_mac_remove_ue(mod_id,rnti); + rrc_rlc_remove_ue(&ctxt); + pdcp_remove_UE(&ctxt); + + if(remove_UEContext) { + ue_context_pP = rrc_eNB_get_ue_context( + RC.rrc[mod_id],rnti); + + if(ue_context_pP) { + rrc_eNB_remove_ue_context(&ctxt,RC.rrc[mod_id], + (struct rrc_eNB_ue_context_s *) ue_context_pP); } + } + + LOG_I(RRC, "[release_UE_in_freeList] remove UE %x from freeList\n", rnti); + remove_UE_from_freelist(mod_id, rnti); } + } } //----------------------------------------------------------------------------- @@ -1032,12 +1005,10 @@ rrc_eNB_process_RRCConnectionSetupComplete( LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing LTE_RRCConnectionSetupComplete from UE (SRB1 Active)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - ue_context_pP->ue_context.Srb1.Active = 1; ue_context_pP->ue_context.Status = RRC_CONNECTED; ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres = 10000; // The value should come from config file - T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); @@ -1053,39 +1024,32 @@ rrc_eNB_process_RRCConnectionSetupComplete( //----------------------------------------------------------------------------- void rrc_eNB_generate_SecurityModeCommand( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ) //----------------------------------------------------------------------------- { uint8_t buffer[100]; uint8_t size; - T(T_ENB_RRC_SECURITY_MODE_COMMAND, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - size = do_SecurityModeCommand( ctxt_pP, buffer, rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), ue_context_pP->ue_context.ciphering_algorithm, ue_context_pP->ue_context.integrity_algorithm); - - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Security Mode Command\n"); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size); - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (securityModeCommand to UE MUI %d) --->[PDCP][RB %02d]\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, rrc_eNB_mui, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -1096,50 +1060,42 @@ rrc_eNB_generate_SecurityModeCommand( 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); - + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } //----------------------------------------------------------------------------- void rrc_eNB_generate_UECapabilityEnquiry( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ) //----------------------------------------------------------------------------- { - uint8_t buffer[100]; uint8_t size; - T(T_ENB_RRC_UE_CAPABILITY_ENQUIRY, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - size = do_UECapabilityEnquiry( ctxt_pP, buffer, rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate UECapabilityEnquiry (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size); - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (UECapabilityEnquiry MUI %d) --->[PDCP][RB %02d]\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, rrc_eNB_mui, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -1150,40 +1106,34 @@ rrc_eNB_generate_UECapabilityEnquiry( 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); - + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionReject( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ) //----------------------------------------------------------------------------- { - T(T_ENB_RRC_CONNECTION_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionReject(ctxt_pP->module_id, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload); - + (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload); LOG_DUMPMSG(RRC,DEBUG_RRC, (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, "[MSG] RRCConnectionReject\n"); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -1193,7 +1143,6 @@ rrc_eNB_generate_RRCConnectionReject( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP == NULL ? -1 : ue_context_pP->ue_context.rnti, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionReject (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), @@ -1203,8 +1152,8 @@ rrc_eNB_generate_RRCConnectionReject( //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionReestablishment( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ) //----------------------------------------------------------------------------- @@ -1213,16 +1162,14 @@ rrc_eNB_generate_RRCConnectionReestablishment( LTE_SRB_ToAddModList_t **SRB_configList; LTE_SRB_ToAddMod_t *SRB1_config; int cnt; - T(T_ENB_RRC_CONNECTION_REESTABLISHMENT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - SRB_configList = &ue_context_pP->ue_context.SRB_configList; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionReestablishment(ctxt_pP, ue_context_pP, CC_id, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, + (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), SRB_configList, @@ -1231,7 +1178,7 @@ rrc_eNB_generate_RRCConnectionReestablishment( (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, "[MSG] RRCConnectionReestablishment\n" - ); + ); // configure SRB1 for UE if (*SRB_configList != NULL) { @@ -1254,38 +1201,38 @@ rrc_eNB_generate_RRCConnectionReestablishment( PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_eNB\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); rrc_mac_config_req_eNB(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - 0,0,0,0,0, + ue_context_pP->ue_context.primaryCC_id, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - ctxt_pP->rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + ctxt_pP->rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - (struct LTE_PhysicalConfigDedicated* ) ue_context_pP->ue_context.physicalConfigDedicated, + (struct LTE_PhysicalConfigDedicated * ) ue_context_pP->ue_context.physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - ue_context_pP->ue_context.mac_MainConfig, - 1, - SRB1_logicalChannelConfig, - ue_context_pP->ue_context.measGapConfig, - (LTE_TDD_Config_t *) NULL, - NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + 1, + SRB1_logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (LTE_TDD_Config_t *) NULL, + NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - ,(LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + ,(LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); + ); break; } } @@ -1299,23 +1246,23 @@ rrc_eNB_generate_RRCConnectionReestablishment( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP->ue_context.rnti, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionReestablishment (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); - if(UE_id != -1){ + + if(UE_id != -1) { // activate release timer, if RRCComplete not received after 100 frames, remove UE RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1; // remove UE after 100 frames after LTE_RRCConnectionReestablishmentRelease is triggered RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 1000; - }else{ + } else { LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Generating LTE_RRCConnectionReestablishment without UE_id(MAC) rnti %x\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); + PROTOCOL_RRC_CTXT_UE_FMT" Generating LTE_RRCConnectionReestablishment without UE_id(MAC) rnti %x\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); } + // activate release timer, if RRCComplete not received after 100 frames, remove UE ue_context_pP->ue_context.ue_reestablishment_timer = 1; // remove UE after 100 frames after LTE_RRCConnectionReestablishmentRelease is triggered @@ -1325,25 +1272,23 @@ rrc_eNB_generate_RRCConnectionReestablishment( //----------------------------------------------------------------------------- void rrc_eNB_process_RRCConnectionReestablishmentComplete( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rnti_t reestablish_rnti, - rrc_eNB_ue_context_t* ue_context_pP, + rrc_eNB_ue_context_t *ue_context_pP, const uint8_t xid, - LTE_RRCConnectionReestablishmentComplete_r8_IEs_t * LTE_RRCConnectionReestablishmentComplete + LTE_RRCConnectionReestablishmentComplete_r8_IEs_t *LTE_RRCConnectionReestablishmentComplete ) //----------------------------------------------------------------------------- { LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, processing LTE_RRCConnectionReestablishmentComplete from UE (SRB1 Active)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - LTE_DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList; - LTE_SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; - LTE_SRB_ToAddModList_t** SRB_configList2 = NULL; - LTE_DRB_ToAddModList_t** DRB_configList2 = NULL; + LTE_DRB_ToAddModList_t *DRB_configList = ue_context_pP->ue_context.DRB_configList; + LTE_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; + LTE_SRB_ToAddModList_t **SRB_configList2 = NULL; + LTE_DRB_ToAddModList_t **DRB_configList2 = NULL; struct LTE_SRB_ToAddMod *SRB2_config = NULL; struct LTE_DRB_ToAddMod *DRB_config = NULL; int i = 0; @@ -1367,185 +1312,175 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( (void)dedicatedInfoNas; LTE_C_RNTI_t *cba_RNTI = NULL; uint8_t next_xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); - ue_context_pP->ue_context.Status = RRC_CONNECTED; ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres = 10000; // The value should come from config file ue_context_pP->ue_context.reestablishment_xid = next_xid; - SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[xid]; + // get old configuration of SRB2 if (*SRB_configList2 != NULL) { - if((*SRB_configList2)->list.count!=0){ + if((*SRB_configList2)->list.count!=0) { LOG_D(RRC, "SRB_configList2(%p) count is %d\n SRB_configList2->list.array[0] addr is %p", - SRB_configList2, (*SRB_configList2)->list.count, (*SRB_configList2)->list.array[0]); + SRB_configList2, (*SRB_configList2)->list.count, (*SRB_configList2)->list.array[0]); } + for (i = 0; (i < (*SRB_configList2)->list.count) && (i < 3); i++) { - if ((*SRB_configList2)->list.array[i]->srb_Identity == 2 ){ + if ((*SRB_configList2)->list.array[i]->srb_Identity == 2 ) { LOG_D(RRC, "get SRB2_config from (ue_context_pP->ue_context.SRB_configList2[%d])\n", xid); SRB2_config = (*SRB_configList2)->list.array[i]; break; } } } + SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[next_xid]; DRB_configList2 = &ue_context_pP->ue_context.DRB_configList2[next_xid]; - if(SRB_configList2!=NULL){ + if(SRB_configList2!=NULL) { if (*SRB_configList2) { free(*SRB_configList2); LOG_D(RRC, "free(ue_context_pP->ue_context.SRB_configList2[%d])\n", next_xid); } - }else{ - LOG_E(RRC, "SRB_configList2 is null\n"); + } else { + LOG_E(RRC, "SRB_configList2 is null\n"); } + *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2)); + if (SRB2_config != NULL) { // Add SRB2 to SRB configuration list - ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); ASN_SEQUENCE_ADD(&(*SRB_configList2)->list, SRB2_config); - LOG_D(RRC, "Add SRB2_config (srb_Identity:%ld) to ue_context_pP->ue_context.SRB_configList\n", - SRB2_config->srb_Identity); + SRB2_config->srb_Identity); LOG_D(RRC, "Add SRB2_config (srb_Identity:%ld) to ue_context_pP->ue_context.SRB_configList2[%d]\n", - SRB2_config->srb_Identity, next_xid); + SRB2_config->srb_Identity, next_xid); } else { // SRB configuration list only contains SRB1. LOG_W(RRC,"SRB2 configuration does not exist in SRB configuration list\n"); } - - - if(DRB_configList2!=NULL){ + if(DRB_configList2!=NULL) { if (*DRB_configList2) { free(*DRB_configList2); LOG_D(RRC, "free(ue_context_pP->ue_context.DRB_configList2[%d])\n", next_xid); } - }else{ - LOG_E(RRC, "DRB_configList2 is null\n"); + } else { + LOG_E(RRC, "DRB_configList2 is null\n"); } + *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); if (DRB_configList != NULL) { LOG_D(RRC, "get DRB_config from (ue_context_pP->ue_context.DRB_configList)\n"); + for (i = 0; (i < DRB_configList->list.count) && (i < 3); i++) { DRB_config = DRB_configList->list.array[i]; - // Add DRB to DRB configuration list, for LTE_RRCConnectionReconfigurationComplete ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); } } + ue_context_pP->ue_context.Srb1.Active = 1; //ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = 2; - -#if defined(ENABLE_USE_MME) - hashtable_rc_t h_rc; - int j; - rrc_ue_s1ap_ids_t* rrc_ue_s1ap_ids_p = NULL; - uint16_t ue_initial_id = ue_context_pP->ue_context.ue_initial_id; - uint32_t eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; - eNB_RRC_INST *rrc_instance_p = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]; - if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_p->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&rrc_ue_s1ap_ids_p); - if (h_rc == HASH_TABLE_OK) { - rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; - } - } - if (ue_initial_id != 0) { - h_rc = hashtable_get(rrc_instance_p->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&rrc_ue_s1ap_ids_p); - if (h_rc == HASH_TABLE_OK) { - rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; - } +#if defined(ENABLE_USE_MME) + hashtable_rc_t h_rc; + int j; + rrc_ue_s1ap_ids_t *rrc_ue_s1ap_ids_p = NULL; + uint16_t ue_initial_id = ue_context_pP->ue_context.ue_initial_id; + uint32_t eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; + eNB_RRC_INST *rrc_instance_p = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]; + + if (eNB_ue_s1ap_id > 0) { + h_rc = hashtable_get(rrc_instance_p->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&rrc_ue_s1ap_ids_p); + + if (h_rc == HASH_TABLE_OK) { + rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; } + } - gtpv1u_enb_create_tunnel_req_t create_tunnel_req; - - /* Save e RAB information for later */ - memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); - - for ( j = 0, i = 0; i < NB_RB_MAX; i++) { - if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED || ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_DONE) { - create_tunnel_req.eps_bearer_id[j] = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; - create_tunnel_req.sgw_S1u_teid[j] = ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + if (ue_initial_id != 0) { + h_rc = hashtable_get(rrc_instance_p->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void **)&rrc_ue_s1ap_ids_p); - memcpy(&create_tunnel_req.sgw_addr[j], - &ue_context_pP->ue_context.e_rab[i].param.sgw_addr, - sizeof(transport_layer_addr_t)); - j++; - } + if (h_rc == HASH_TABLE_OK) { + rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; } + } - create_tunnel_req.rnti = ctxt_pP->rnti; // warning put zero above - create_tunnel_req.num_tunnels = j; + gtpv1u_enb_create_tunnel_req_t create_tunnel_req; + /* Save e RAB information for later */ + memset(&create_tunnel_req, 0, sizeof(create_tunnel_req)); + + for ( j = 0, i = 0; i < NB_RB_MAX; i++) { + if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED || ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_DONE) { + create_tunnel_req.eps_bearer_id[j] = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + create_tunnel_req.sgw_S1u_teid[j] = ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + memcpy(&create_tunnel_req.sgw_addr[j], + &ue_context_pP->ue_context.e_rab[i].param.sgw_addr, + sizeof(transport_layer_addr_t)); + j++; + } + } - gtpv1u_update_s1u_tunnel( - ctxt_pP->instance, - &create_tunnel_req, - reestablish_rnti); + create_tunnel_req.rnti = ctxt_pP->rnti; // warning put zero above + create_tunnel_req.num_tunnels = j; + gtpv1u_update_s1u_tunnel( + ctxt_pP->instance, + &create_tunnel_req, + reestablish_rnti); #endif /* Update RNTI in ue_context */ ue_context_pP->ue_id_rnti = ctxt_pP->rnti; // here ue_id_rnti is just a key, may be something else ue_context_pP->ue_context.rnti = ctxt_pP->rnti; #if defined(ENABLE_USE_MME) - uint8_t send_security_mode_command = FALSE; - rrc_pdcp_config_security( - ctxt_pP, - ue_context_pP, - send_security_mode_command); - LOG_D(RRC, "set security successfully \n"); + uint8_t send_security_mode_command = FALSE; + rrc_pdcp_config_security( + ctxt_pP, + ue_context_pP, + send_security_mode_command); + LOG_D(RRC, "set security successfully \n"); #endif // 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); - MeasId1 = CALLOC(1, sizeof(*MeasId1)); MeasId1->measId = 2; MeasId1->measObjectId = 1; MeasId1->reportConfigId = 2; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId1); - MeasId2 = CALLOC(1, sizeof(*MeasId2)); MeasId2->measId = 3; MeasId2->measObjectId = 1; MeasId2->reportConfigId = 3; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId2); - MeasId3 = CALLOC(1, sizeof(*MeasId3)); MeasId3->measId = 4; MeasId3->measObjectId = 1; MeasId3->reportConfigId = 4; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId3); - MeasId4 = CALLOC(1, sizeof(*MeasId4)); MeasId4->measId = 5; MeasId4->measObjectId = 1; MeasId4->reportConfigId = 5; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId4); - MeasId5 = CALLOC(1, sizeof(*MeasId5)); MeasId5->measId = 6; MeasId5->measObjectId = 1; MeasId5->reportConfigId = 6; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5); - // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list; - // 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 = LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA; MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz @@ -1557,10 +1492,8 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( 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 = (LTE_CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList)); - CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList; // Add adjacent cell lists (6 per eNB) @@ -1569,28 +1502,19 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( CellToAdd->cellIndex = i + 1; CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); CellToAdd->cellIndividualOffset = LTE_Q_OffsetRange_dB0; - ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); } ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj); // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; - // Report Configurations for periodical, A1-A5 events ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list)); - ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per)); - ReportConfig_A1 = CALLOC(1, sizeof(*ReportConfig_A1)); - ReportConfig_A2 = CALLOC(1, sizeof(*ReportConfig_A2)); - ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3)); - ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4)); - ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5)); - ReportConfig_per->reportConfigId = 1; ReportConfig_per->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1602,9 +1526,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per); - ReportConfig_A1->reportConfigId = 2; ReportConfig_A1->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1615,13 +1537,11 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( a1_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1. a1_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1); if (RC.rrc[ctxt_pP->module_id]->HO_flag == 1 /*HO_MEASURMENT */ ) { @@ -1637,39 +1557,32 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( eventA2.a2_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA2.a2_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A2); - ReportConfig_A3->reportConfigId = 4; ReportConfig_A3->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.present = LTE_ReportConfigEUTRA__triggerType_PR_event; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present = LTE_ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset = 1; //10; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA3.reportOnLeave = 1; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis = 0.5; // FIXME ...hysteresis is of type long! ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = LTE_TimeToTrigger_ms40; ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A3); - ReportConfig_A4->reportConfigId = 5; ReportConfig_A4->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1680,16 +1593,13 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( eventA4.a4_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA4.a4_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A4); - ReportConfig_A5->reportConfigId = 6; ReportConfig_A5->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1704,20 +1614,16 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( eventA5.a5_Threshold1.choice.threshold_RSRP = 10; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA5.a5_Threshold2.choice.threshold_RSRP = 10; - ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5); // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; - rsrp = CALLOC(1, sizeof(LTE_RSRP_Range_t)); *rsrp = 20; - Sparams = CALLOC(1, sizeof(*Sparams)); Sparams->present = LTE_MeasConfig__speedStatePars_PR_setup; Sparams->choice.setup.timeToTrigger_SF.sf_High = LTE_SpeedStateScaleFactors__sf_Medium_oDot75; @@ -1726,7 +1632,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( Sparams->choice.setup.mobilityStateParameters.n_CellChangeMedium = 5; Sparams->choice.setup.mobilityStateParameters.t_Evaluation = LTE_MobilityStateParameters__t_Evaluation_s60; Sparams->choice.setup.mobilityStateParameters.t_HystNormal = LTE_MobilityStateParameters__t_HystNormal_s120; - quantityConfig = CALLOC(1, sizeof(*quantityConfig)); memset((void *)quantityConfig, 0, sizeof(*quantityConfig)); quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct LTE_QuantityConfigEUTRA)); @@ -1740,7 +1645,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ))); *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = LTE_FilterCoefficient_fc4; *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = LTE_FilterCoefficient_fc4; - LOG_I(RRC, "[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n", ctxt_pP->module_id, ctxt_pP->frame); @@ -1754,15 +1658,14 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig = CALLOC(1, sizeof(*ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig)); - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, (void *)ue_context_pP->ue_context.mac_MainConfig, sizeof(LTE_MAC_MainConfig_t)); ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated = CALLOC(1, sizeof(LTE_PhysicalConfigDedicated_t)); - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, - (void*)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(LTE_PhysicalConfigDedicated_t)); + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, + (void *)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(LTE_PhysicalConfigDedicated_t)); ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.sps_Config = NULL; //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config,(void *)rrc_inst->sps_Config[ue_mod_idP],sizeof(SPS_Config_t)); - } #ifdef CBA @@ -1790,7 +1693,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } #endif - #if defined(ENABLE_ITTI) /* Initialize NAS list */ dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); @@ -1801,7 +1703,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( dedicatedInfoNas = CALLOC(1, sizeof(LTE_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, + (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); LOG_D(RRC, "Add LTE_DedicatedInfoNAS(%d) to LTE_DedicatedInfoNASList\n", i); ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); @@ -1813,11 +1715,10 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( // 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"); + 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 */ @@ -1827,44 +1728,40 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } #endif - // send LTE_RRCConnectionReconfiguration memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, next_xid, //Transaction_id, - (LTE_SRB_ToAddModList_t*)*SRB_configList2, // SRB_configList - (LTE_DRB_ToAddModList_t*)DRB_configList, - (LTE_DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct LTE_SPS_Config*)NULL, // maybe ue_context_pP->ue_context.sps_Config, - (struct LTE_PhysicalConfigDedicated*)ue_context_pP->ue_context.physicalConfigDedicated, + (LTE_SRB_ToAddModList_t *)*SRB_configList2, // SRB_configList + (LTE_DRB_ToAddModList_t *)DRB_configList, + (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, + (struct LTE_SPS_Config *)NULL, // maybe ue_context_pP->ue_context.sps_Config, + (struct LTE_PhysicalConfigDedicated *)ue_context_pP->ue_context.physicalConfigDedicated, #ifdef EXMIMO_IOT NULL, NULL, NULL,NULL, #else - (LTE_MeasObjectToAddModList_t*)MeasObj_list, // MeasObj_list, - (LTE_ReportConfigToAddModList_t*)ReportConfig_list, // ReportConfig_list, - (LTE_QuantityConfig_t*)quantityConfig, //quantityConfig, - (LTE_MeasIdToAddModList_t*)NULL, -#endif - (LTE_MAC_MainConfig_t*)ue_context_pP->ue_context.mac_MainConfig, - (LTE_MeasGapConfig_t*)NULL, - (LTE_MobilityControlInfo_t*)NULL, - (struct LTE_MeasConfig__speedStatePars*)Sparams, // Sparams, - (LTE_RSRP_Range_t*)rsrp, // rsrp, - (LTE_C_RNTI_t*)cba_RNTI, // cba_RNTI - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, //dedicatedInfoNASList - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL + (LTE_MeasObjectToAddModList_t *)MeasObj_list, // MeasObj_list, + (LTE_ReportConfigToAddModList_t *)ReportConfig_list, // ReportConfig_list, + (LTE_QuantityConfig_t *)quantityConfig, //quantityConfig, + (LTE_MeasIdToAddModList_t *)NULL, +#endif + (LTE_MAC_MainConfig_t *)ue_context_pP->ue_context.mac_MainConfig, + (LTE_MeasGapConfig_t *)NULL, + (LTE_MobilityControlInfo_t *)NULL, + (struct LTE_MeasConfig__speedStatePars *)Sparams, // Sparams, + (LTE_RSRP_Range_t *)rsrp, // rsrp, + (LTE_C_RNTI_t *)cba_RNTI, // cba_RNTI + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList, //dedicatedInfoNASList + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL + , (LTE_SCellToAddMod_r10_t *)NULL #endif ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); - - -#if defined(ENABLE_ITTI) +#if defined(ENABLE_ITTI) /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { @@ -1876,19 +1773,18 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } #endif - if(size==65535){ + + if(size==65535) { LOG_E(RRC,"RRC decode err!!! do_RRCConnectionReconfiguration\n"); put_UE_in_freelist(ctxt_pP->module_id, reestablish_rnti, 0); return; - }else{ + } else { LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_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, @@ -1899,55 +1795,55 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( 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); + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } + // delete UE data of prior RNTI. UE use current RNTI. -// protocol_ctxt_t ctxt_prior = *ctxt_pP; -// ctxt_prior.rnti = reestablish_rnti; -// -// LTE_eNB_ULSCH_t *ulsch = NULL; -// nfapi_ul_config_request_body_t *ul_req_tmp = NULL; -// PHY_VARS_eNB *eNB_PHY = NULL; -// eNB_MAC_INST *eNB_MAC = RC.mac[ctxt_prior.module_id]; -// for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { -// eNB_PHY = RC.eNB[ctxt_prior.module_id][CC_id]; -// for (int i=0; iulsch[i]; -// if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)){ -// void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); -// LOG_I(RRC, "clean_eNb_ulsch UE %x \n", ctxt_prior.rnti); -// clean_eNb_ulsch(ulsch); -// break; -// } -// } -// -// for(int j = 0; j < 10; j++){ -// ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; -// if(ul_req_tmp){ -// int pdu_number = ul_req_tmp->number_of_pdus; -// for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ -// if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == ctxt_prior.rnti){ -// LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", ctxt_prior.rnti, pdu_index, pdu_number); -// if(pdu_index < pdu_number -1){ -// memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); -// } -// ul_req_tmp->number_of_pdus--; -// } -// } -// } -// } -// } -// rrc_mac_remove_ue(ctxt_prior.module_id, ctxt_prior.rnti); -// rrc_rlc_remove_ue(&ctxt_prior); -// pdcp_remove_UE(&ctxt_prior); + // protocol_ctxt_t ctxt_prior = *ctxt_pP; + // ctxt_prior.rnti = reestablish_rnti; + // + // LTE_eNB_ULSCH_t *ulsch = NULL; + // nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + // PHY_VARS_eNB *eNB_PHY = NULL; + // eNB_MAC_INST *eNB_MAC = RC.mac[ctxt_prior.module_id]; + // for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + // eNB_PHY = RC.eNB[ctxt_prior.module_id][CC_id]; + // for (int i=0; iulsch[i]; + // if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)){ + // void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); + // LOG_I(RRC, "clean_eNb_ulsch UE %x \n", ctxt_prior.rnti); + // clean_eNb_ulsch(ulsch); + // break; + // } + // } + // + // for(int j = 0; j < 10; j++){ + // ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; + // if(ul_req_tmp){ + // int pdu_number = ul_req_tmp->number_of_pdus; + // for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ + // if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == ctxt_prior.rnti){ + // LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", ctxt_prior.rnti, pdu_index, pdu_number); + // if(pdu_index < pdu_number -1){ + // memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + // } + // ul_req_tmp->number_of_pdus--; + // } + // } + // } + // } + // } + // rrc_mac_remove_ue(ctxt_prior.module_id, ctxt_prior.rnti); + // rrc_rlc_remove_ue(&ctxt_prior); + // pdcp_remove_UE(&ctxt_prior); // add UE info to freeList for RU_thread to remove the UE instead of remove it here LOG_I(RRC, "[RRCConnectionReestablishment]put UE %x into freeList\n", reestablish_rnti); put_UE_in_freelist(ctxt_pP->module_id, reestablish_rnti, 0); @@ -1956,34 +1852,32 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionReestablishmentReject( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ) //----------------------------------------------------------------------------- { int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); - if(UE_id != -1){ + + if(UE_id != -1) { RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1; RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment