From 9a5e29ccabd31fbe4cab5b37c2297bf55a224ec4 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 13 Jun 2018 10:15:52 +0200 Subject: [PATCH] Added mutex to phch_common --- srsenb/hdr/phy/phch_common.h | 2 + srsenb/src/phy/phch_common.cc | 82 ++++++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 26 deletions(-) diff --git a/srsenb/hdr/phy/phch_common.h b/srsenb/hdr/phy/phch_common.h index 8cebcb042..b94042182 100644 --- a/srsenb/hdr/phy/phch_common.h +++ b/srsenb/hdr/phy/phch_common.h @@ -154,6 +154,8 @@ private: uint32_t nof_workers; uint32_t nof_mutex; uint32_t max_mutex; + + pthread_mutex_t user_mutex; phy_interface_rrc::phy_cfg_mbsfn_t mbsfn; bool sib13_configured; diff --git a/srsenb/src/phy/phch_common.cc b/srsenb/src/phy/phch_common.cc index 5a5cd7f36..9b3ea75e0 100644 --- a/srsenb/src/phy/phch_common.cc +++ b/srsenb/src/phy/phch_common.cc @@ -57,7 +57,7 @@ bool phch_common::init(srslte_cell_t *cell_, srslte::radio* radio_h_, mac_interf mac = mac_; memcpy(&cell, cell_, sizeof(srslte_cell_t)); - + pthread_mutex_init(&user_mutex, NULL); is_first_of_burst = true; is_first_tx = true; @@ -107,80 +107,110 @@ void phch_common::ue_db_clear(uint32_t sf_idx) void phch_common::ue_db_add_rnti(uint16_t rnti) { + pthread_mutex_lock(&user_mutex); for (int sf_idx=0;sf_idxmbsfn_encode = false; cfg->is_mcch = false; // Check for MCCH - if(is_mcch_subframe(cfg, phy_tti)) { + if (is_mcch_subframe(cfg, phy_tti)) { return true; } @@ -273,16 +303,16 @@ bool phch_common::is_mch_subframe(subframe_cfg_t *cfg, uint32_t phy_tti) offset = subfr_cnfg->radio_fr_alloc_offset; period = liblte_rrc_radio_frame_allocation_period_num[subfr_cnfg->radio_fr_alloc_period]; - if(LIBLTE_RRC_SUBFRAME_ALLOCATION_NUM_FRAMES_ONE == subfr_cnfg->subfr_alloc_num_frames) { - if((sfn%period == offset) && (mch_table[sf] > 0)) { - if(sib13_configured) { + if (LIBLTE_RRC_SUBFRAME_ALLOCATION_NUM_FRAMES_ONE == subfr_cnfg->subfr_alloc_num_frames) { + if ((sfn%period == offset) && (mch_table[sf] > 0)) { + if (sib13_configured) { cfg->mbsfn_area_id = area_info->mbsfn_area_id_r9; cfg->non_mbsfn_region_length = liblte_rrc_non_mbsfn_region_length_num[area_info->non_mbsfn_region_length]; - if(mcch_configured) { + if (mcch_configured) { // Iterate through PMCH configs to see which one applies in the current frame LIBLTE_RRC_MCCH_MSG_STRUCT *mcch = &mbsfn.mcch; uint32_t sf_alloc_idx = sfn%liblte_rrc_mbsfn_common_sf_alloc_period_r9_num[mcch->commonsf_allocperiod_r9]; - for(uint32_t i=0; ipmch_infolist_r9_size; i++) { + for (uint32_t i=0; ipmch_infolist_r9_size; i++) { //if(sf_alloc_idx < mch_period_stop) { cfg->mbsfn_mcs = mcch->pmch_infolist_r9[i].pmch_config_r9.datamcs_r9; cfg->mbsfn_encode = true; @@ -293,11 +323,11 @@ bool phch_common::is_mch_subframe(subframe_cfg_t *cfg, uint32_t phy_tti) } return true; } - }else if(LIBLTE_RRC_SUBFRAME_ALLOCATION_NUM_FRAMES_FOUR == subfr_cnfg->subfr_alloc_num_frames) { + } else if (LIBLTE_RRC_SUBFRAME_ALLOCATION_NUM_FRAMES_FOUR == subfr_cnfg->subfr_alloc_num_frames) { uint8_t idx = sfn%period; - if((idx >= offset) && (idx < offset+4)) { - if(mch_table[(idx*10)+sf] > 0){ - if(sib13_configured) { + if ((idx >= offset) && (idx < offset+4)) { + if (mch_table[(idx*10)+sf] > 0){ + if (sib13_configured) { cfg->mbsfn_area_id = area_info->mbsfn_area_id_r9; cfg->non_mbsfn_region_length = liblte_rrc_non_mbsfn_region_length_num[area_info->non_mbsfn_region_length]; // TODO: check for MCCH configuration, set MCS and decode