diff --git a/lib/include/srslte/asn1/rrc_asn1_utils.h b/lib/include/srslte/asn1/rrc_asn1_utils.h index f16341459..9e8c42ee6 100644 --- a/lib/include/srslte/asn1/rrc_asn1_utils.h +++ b/lib/include/srslte/asn1/rrc_asn1_utils.h @@ -24,6 +24,7 @@ #include "srslte/common/interfaces_common.h" #include "srslte/interfaces/rrc_interface_types.h" +#include "srslte/interfaces/sched_interface.h" /************************ * Forward declarations @@ -36,10 +37,13 @@ struct s_tmsi_s; struct rlc_cfg_c; struct pdcp_cfg_s; struct srb_to_add_mod_s; +// mac struct sched_request_cfg_c; struct mac_main_cfg_s; struct rach_cfg_common_s; struct time_align_timer_opts; +struct ant_info_ded_s; + struct phys_cfg_ded_s; struct prach_cfg_info_s; struct pdsch_cfg_common_s; @@ -98,6 +102,8 @@ void set_mac_cfg_t_main_cfg(mac_cfg_t* cfg, const asn1::rrc::mac_main_cfg_s& asn void set_mac_cfg_t_rach_cfg_common(mac_cfg_t* cfg, const asn1::rrc::rach_cfg_common_s& asn1_type); void set_mac_cfg_t_time_alignment(mac_cfg_t* cfg, const asn1::rrc::time_align_timer_opts asn1_type); +srsenb::sched_interface::ant_info_ded_t make_ant_info_ded(const asn1::rrc::ant_info_ded_s& asn1_type); + /*************************** * PHY Config **************************/ diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 9370db150..dbd3fc596 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -144,7 +144,7 @@ public: /* Manages UE bearers and associated configuration */ virtual int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) = 0; virtual int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) = 0; - virtual int set_dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dl_ant_info) = 0; + virtual int set_dl_ant_info(uint16_t rnti, const sched_interface::ant_info_ded_t& dl_ant_info) = 0; virtual void phy_config_enabled(uint16_t rnti, bool enabled) = 0; virtual void write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch) = 0; diff --git a/lib/include/srslte/interfaces/sched_interface.h b/lib/include/srslte/interfaces/sched_interface.h index b699bce63..331795f28 100644 --- a/lib/include/srslte/interfaces/sched_interface.h +++ b/lib/include/srslte/interfaces/sched_interface.h @@ -109,6 +109,23 @@ public: enum { IDLE = 0, UL, DL, BOTH } direction; } ue_bearer_cfg_t; + struct ant_info_ded_t { + enum class tx_mode_t { tm1, tm2, tm3, tm4, tm5, tm6, tm7, tm8_v920, nulltype } tx_mode; + enum class codebook_t { + n2_tx_ant_tm3, + n4_tx_ant_tm3, + n2_tx_ant_tm4, + n4_tx_ant_tm4, + n2_tx_ant_tm5, + n4_tx_ant_tm5, + n2_tx_ant_tm6, + n4_tx_ant_tm6, + none + } cookbook_subset_type; + uint64_t codebook_subset_restrict; + enum class ue_tx_ant_sel_t { release, closed_loop, open_loop } ue_tx_ant_sel; + }; + struct ue_cfg_t { /* ue capabilities, etc */ uint32_t maxharq_tx; diff --git a/lib/src/asn1/rrc_asn1_utils.cc b/lib/src/asn1/rrc_asn1_utils.cc index 86e4fb546..55cdece33 100644 --- a/lib/src/asn1/rrc_asn1_utils.cc +++ b/lib/src/asn1/rrc_asn1_utils.cc @@ -317,6 +317,54 @@ void set_mac_cfg_t_time_alignment(mac_cfg_t* cfg, const asn1::rrc::time_align_ti cfg->time_alignment_timer = asn1_type.to_number(); } +srsenb::sched_interface::ant_info_ded_t make_ant_info_ded(const asn1::rrc::ant_info_ded_s& asn1_type) +{ + srsenb::sched_interface::ant_info_ded_t ant_ded = {}; + ant_ded.tx_mode = static_cast(asn1_type.tx_mode.value); + ant_ded.cookbook_subset_type = srsenb::sched_interface::ant_info_ded_t::codebook_t::none; + if (asn1_type.codebook_subset_restrict_present) { + auto& asn1code = asn1_type.codebook_subset_restrict; + ant_ded.cookbook_subset_type = + static_cast(asn1code.type().value); + switch (asn1code.type().value) { + case ant_info_ded_s::codebook_subset_restrict_c_::types_opts::n2_tx_ant_tm3: + ant_ded.codebook_subset_restrict = asn1code.n2_tx_ant_tm3().to_number(); + break; + case ant_info_ded_s::codebook_subset_restrict_c_::types_opts::n4_tx_ant_tm3: + ant_ded.codebook_subset_restrict = asn1code.n4_tx_ant_tm3().to_number(); + break; + case ant_info_ded_s::codebook_subset_restrict_c_::types_opts::n2_tx_ant_tm4: + ant_ded.codebook_subset_restrict = asn1code.n2_tx_ant_tm4().to_number(); + break; + case ant_info_ded_s::codebook_subset_restrict_c_::types_opts::n4_tx_ant_tm4: + ant_ded.codebook_subset_restrict = asn1code.n4_tx_ant_tm4().to_number(); + break; + case ant_info_ded_s::codebook_subset_restrict_c_::types_opts::n2_tx_ant_tm5: + ant_ded.codebook_subset_restrict = asn1code.n2_tx_ant_tm5().to_number(); + break; + case ant_info_ded_s::codebook_subset_restrict_c_::types_opts::n4_tx_ant_tm5: + ant_ded.codebook_subset_restrict = asn1code.n4_tx_ant_tm5().to_number(); + break; + case ant_info_ded_s::codebook_subset_restrict_c_::types_opts::n2_tx_ant_tm6: + ant_ded.codebook_subset_restrict = asn1code.n2_tx_ant_tm6().to_number(); + break; + case ant_info_ded_s::codebook_subset_restrict_c_::types_opts::n4_tx_ant_tm6: + ant_ded.codebook_subset_restrict = asn1code.n4_tx_ant_tm6().to_number(); + break; + default: + asn1::rrc::rrc_log_print(LOG_LEVEL_ERROR, "Failed to convert antenna codebook type to number\n"); + } + } + ant_ded.ue_tx_ant_sel = srsenb::sched_interface::ant_info_ded_t::ue_tx_ant_sel_t::release; + if (asn1_type.ue_tx_ant_sel.type().value == setup_opts::setup) { + ant_ded.ue_tx_ant_sel = + (asn1_type.ue_tx_ant_sel.setup().value == ant_info_ded_s::ue_tx_ant_sel_c_::setup_opts::closed_loop) + ? srsenb::sched_interface::ant_info_ded_t::ue_tx_ant_sel_t::closed_loop + : srsenb::sched_interface::ant_info_ded_t::ue_tx_ant_sel_t::open_loop; + } + return ant_ded; +} + void set_phy_cfg_t_dedicated_cfg(phy_cfg_t* cfg, const asn1::rrc::phys_cfg_ded_s& asn1_type) { if (asn1_type.pucch_cfg_ded_present) { diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index b4d8cd4ad..664470e29 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -56,7 +56,7 @@ public: int sr_detected(uint32_t tti, uint16_t rnti) final; int rach_detected(uint32_t tti, uint32_t primary_cc_idx, uint32_t preamble_idx, uint32_t time_adv) final; - int set_dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dl_ant_info); + int set_dl_ant_info(uint16_t rnti, const sched_interface::ant_info_ded_t& dl_ant_info) override; int ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value); int pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value); diff --git a/srsenb/hdr/stack/mac/scheduler.h b/srsenb/hdr/stack/mac/scheduler.h index 640b2957d..f69fabf49 100644 --- a/srsenb/hdr/stack/mac/scheduler.h +++ b/srsenb/hdr/stack/mac/scheduler.h @@ -144,7 +144,7 @@ public: int dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) final; int dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code) final; - int dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dedicated); + int dl_ant_info(uint16_t rnti, const sched_interface::ant_info_ded_t& ant_info); int dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t tb_idx, bool ack) final; int dl_rach_info(uint32_t cc_idx, dl_sched_rar_info_t rar_info) final; int dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t ri_value) final; diff --git a/srsenb/hdr/stack/mac/scheduler_ue.h b/srsenb/hdr/stack/mac/scheduler_ue.h index bb856d5d2..69ed40c78 100644 --- a/srsenb/hdr/stack/mac/scheduler_ue.h +++ b/srsenb/hdr/stack/mac/scheduler_ue.h @@ -28,7 +28,6 @@ #include #include "scheduler_harq.h" -#include "srslte/asn1/rrc_asn1.h" #include namespace srsenb { @@ -105,7 +104,7 @@ public: void reset(); void phy_config_enabled(uint32_t tti, bool enabled); void init(uint16_t rnti, const std::vector& cell_list_params_); - void set_cfg(sched_interface::ue_cfg_t* cfg); + void set_cfg(const sched_interface::ue_cfg_t& cfg); void set_bearer_cfg(uint32_t lc_id, srsenb::sched_interface::ue_bearer_cfg_t* cfg); void rem_bearer(uint32_t lc_id); @@ -115,7 +114,7 @@ public: void ul_phr(int phr); void mac_buffer_state(uint32_t ce_code); void ul_recv_len(uint32_t lcid, uint32_t len); - void set_dl_ant_info(asn1::rrc::phys_cfg_ded_s::ant_info_c_* dedicated); + void set_dl_ant_info(const sched_interface::ant_info_ded_t& dedicated); void set_ul_cqi(uint32_t tti, uint32_t cc_idx, uint32_t cqi, uint32_t ul_ch_code); void set_dl_ri(uint32_t tti, uint32_t cc_idx, uint32_t ri); void set_dl_pmi(uint32_t tti, uint32_t cc_idx, uint32_t ri); @@ -276,8 +275,8 @@ private: int next_tpc_pusch = 0; int next_tpc_pucch = 0; - bool phy_config_dedicated_enabled = false; - asn1::rrc::phys_cfg_ded_s::ant_info_c_ dl_ant_info; + bool phy_config_dedicated_enabled = false; + sched_interface::ant_info_ded_t dl_ant_info; std::vector carriers; ///< map of UE CellIndex to carrier configuration std::map enb_ue_cellindex_map; ///< map cc idx eNB -> UE diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 901d7e7ff..38fe54057 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -352,7 +352,7 @@ int mac::crc_info(uint32_t tti, uint16_t rnti, uint32_t nof_bytes, bool crc) return ret; } -int mac::set_dl_ant_info(uint16_t rnti, phys_cfg_ded_s::ant_info_c_* dl_ant_info) +int mac::set_dl_ant_info(uint16_t rnti, const sched_interface::ant_info_ded_t& dl_ant_info) { int ret = -1; pthread_rwlock_rdlock(&rwlock); diff --git a/srsenb/src/stack/mac/scheduler.cc b/srsenb/src/stack/mac/scheduler.cc index 54c71ab3f..8052428c7 100644 --- a/srsenb/src/stack/mac/scheduler.cc +++ b/srsenb/src/stack/mac/scheduler.cc @@ -204,10 +204,16 @@ int sched::ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* ue_cfg) { // Add or config user pthread_rwlock_rdlock(&rwlock); - if (ue_db.count(rnti) == 0) { + auto it = ue_db.find(rnti); + if (it == ue_db.end()) { + pthread_rwlock_unlock(&rwlock); + // create new user + pthread_rwlock_wrlock(&rwlock); ue_db[rnti].init(rnti, sched_cell_params); + it = ue_db.find(rnti); + pthread_rwlock_rdlock(&rwlock); } - ue_db[rnti].set_cfg(ue_cfg); + it->second.set_cfg(*ue_cfg); pthread_rwlock_unlock(&rwlock); return 0; @@ -286,9 +292,9 @@ int sched::dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code) return ue_db_access(rnti, [ce_code](sched_ue& ue) { ue.mac_buffer_state(ce_code); }); } -int sched::dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dl_ant_info) +int sched::dl_ant_info(uint16_t rnti, const sched_interface::ant_info_ded_t& ant_info) { - return ue_db_access(rnti, [dl_ant_info](sched_ue& ue) { ue.set_dl_ant_info(dl_ant_info); }); + return ue_db_access(rnti, [ant_info](sched_ue& ue) { ue.set_dl_ant_info(ant_info); }); } int sched::dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t tb_idx, bool ack) diff --git a/srsenb/src/stack/mac/scheduler_ue.cc b/srsenb/src/stack/mac/scheduler_ue.cc index 2af2cd669..c6b25c550 100644 --- a/srsenb/src/stack/mac/scheduler_ue.cc +++ b/srsenb/src/stack/mac/scheduler_ue.cc @@ -55,7 +55,6 @@ sched_ue::sched_ue() bzero(&cell, sizeof(cell)); bzero(&lch, sizeof(lch)); - bzero(&dl_ant_info, sizeof(dl_ant_info)); reset(); } @@ -70,14 +69,17 @@ void sched_ue::init(uint16_t rnti_, const std::vector& cell Info("SCHED: Added user rnti=0x%x\n", rnti); } -void sched_ue::set_cfg(sched_interface::ue_cfg_t* cfg_) +void sched_ue::set_cfg(const sched_interface::ue_cfg_t& cfg_) { { std::lock_guard lock(mutex); + + // calculate diffs and update + // store previous supported cc idxs std::vector prev_cc_idxs(std::move(cfg.supported_cc_idxs)); - cfg = *cfg_; + cfg = cfg_; // if no list of supported cc idxs is provided, we keep the previous one if (cfg.supported_cc_idxs.empty()) { @@ -357,10 +359,10 @@ void sched_ue::set_dl_cqi(uint32_t tti, uint32_t cc_idx, uint32_t cqi) carriers[cc_idx].dl_cqi_tti = tti; } -void sched_ue::set_dl_ant_info(asn1::rrc::phys_cfg_ded_s::ant_info_c_* d) +void sched_ue::set_dl_ant_info(const sched_interface::ant_info_ded_t& ant_info) { std::lock_guard lock(mutex); - dl_ant_info = *d; + dl_ant_info = ant_info; } void sched_ue::set_ul_cqi(uint32_t tti, uint32_t cc_idx, uint32_t cqi, uint32_t ul_ch_code) @@ -984,25 +986,23 @@ srslte_dci_format_t sched_ue::get_dci_format() if (phy_config_dedicated_enabled) { /* TODO: Assumes UE-Specific Search Space (Not common) */ - switch (dl_ant_info.explicit_value().tx_mode) { - case asn1::rrc::ant_info_ded_s::tx_mode_e_::tm1: - case asn1::rrc::ant_info_ded_s::tx_mode_e_::tm2: + switch (dl_ant_info.tx_mode) { + case sched_interface::ant_info_ded_t::tx_mode_t::tm1: + case sched_interface::ant_info_ded_t::tx_mode_t::tm2: ret = SRSLTE_DCI_FORMAT1; break; - case asn1::rrc::ant_info_ded_s::tx_mode_e_::tm3: + case sched_interface::ant_info_ded_t::tx_mode_t::tm3: ret = SRSLTE_DCI_FORMAT2A; break; - case asn1::rrc::ant_info_ded_s::tx_mode_e_::tm4: + case sched_interface::ant_info_ded_t::tx_mode_t::tm4: ret = SRSLTE_DCI_FORMAT2; break; - case asn1::rrc::ant_info_ded_s::tx_mode_e_::tm5: - case asn1::rrc::ant_info_ded_s::tx_mode_e_::tm6: - case asn1::rrc::ant_info_ded_s::tx_mode_e_::tm7: - case asn1::rrc::ant_info_ded_s::tx_mode_e_::tm8_v920: + case sched_interface::ant_info_ded_t::tx_mode_t::tm5: + case sched_interface::ant_info_ded_t::tx_mode_t::tm6: + case sched_interface::ant_info_ded_t::tx_mode_t::tm7: + case sched_interface::ant_info_ded_t::tx_mode_t::tm8_v920: default: - Warning("Incorrect transmission mode (rnti=%04x; tm=%s)\n", - rnti, - dl_ant_info.explicit_value().tx_mode.to_string().c_str()); + Warning("Incorrect transmission mode (rnti=%04x; tm=%d)\n", rnti, static_cast(dl_ant_info.tx_mode)); } } diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 1bfab8ed3..846a38584 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -1619,7 +1619,7 @@ void rrc::ue::send_connection_setup(bool is_setup) // Configure PHY layer parent->phy->set_config_dedicated(rnti, phy_cfg); - parent->mac->set_dl_ant_info(rnti, &phy_cfg->ant_info); + parent->mac->set_dl_ant_info(rnti, srslte::make_ant_info_ded(phy_cfg->ant_info.explicit_value())); parent->mac->phy_config_enabled(rnti, false); rr_cfg->drb_to_add_mod_list_present = false; @@ -1792,7 +1792,7 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) phy_cfg->pdsch_cfg_ded.p_a = parent->cfg.pdsch_cfg; parent->phy->set_config_dedicated(rnti, phy_cfg); - parent->mac->set_dl_ant_info(rnti, &phy_cfg->ant_info); + parent->mac->set_dl_ant_info(rnti, srslte::make_ant_info_ded(phy_cfg->ant_info.explicit_value())); parent->mac->phy_config_enabled(rnti, false); // Add SRB2 to the message diff --git a/srsenb/test/common/dummy_classes.h b/srsenb/test/common/dummy_classes.h index 5d663cc6b..2fb5d266c 100644 --- a/srsenb/test/common/dummy_classes.h +++ b/srsenb/test/common/dummy_classes.h @@ -35,7 +35,7 @@ public: int ue_rem(uint16_t rnti) override { return 0; } int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) override { return 0; } int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) override { return 0; } - int set_dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dl_ant_info) override { return 0; } + int set_dl_ant_info(uint16_t rnti, const sched_interface::ant_info_ded_t& dl_ant_info) override { return 0; } void phy_config_enabled(uint16_t rnti, bool enabled) override {} void write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch) override {