From 7548402632c5b5acbc9b2642e0fa1a2977c262cd Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Wed, 11 Mar 2020 16:15:25 +0000 Subject: [PATCH] change scell activation interface to use arrays. Added a method to the scheduler to get the current set of activated carriers --- lib/include/srslte/common/pdu.h | 3 +- .../srslte/interfaces/enb_interfaces.h | 3 +- .../srslte/interfaces/sched_interface.h | 12 ++++---- lib/src/common/pdu.cc | 10 ++++--- lib/test/common/pdu_test.cc | 9 +++++- srsenb/hdr/phy/phy.h | 3 +- srsenb/hdr/stack/mac/scheduler.h | 8 +++--- srsenb/src/phy/phy.cc | 2 +- srsenb/src/stack/mac/mac.cc | 14 +++++++--- srsenb/src/stack/mac/scheduler.cc | 16 ++++++++--- srsenb/src/stack/mac/ue.cc | 28 +++++++++++-------- srsenb/test/mac/scheduler_ca_test.cc | 6 +++- srsenb/test/mac/scheduler_test_common.cc | 9 ++++++ srsenb/test/mac/scheduler_test_common.h | 2 ++ srsenb/test/phy/enb_phy_test.cc | 2 +- 15 files changed, 85 insertions(+), 42 deletions(-) diff --git a/lib/include/srslte/common/pdu.h b/lib/include/srslte/common/pdu.h index 166e26bde..b8e2ebd59 100644 --- a/lib/include/srslte/common/pdu.h +++ b/lib/include/srslte/common/pdu.h @@ -24,7 +24,6 @@ #include "srslte/common/interfaces_common.h" #include "srslte/common/log.h" -#include #include #include #include @@ -271,7 +270,7 @@ public: bool set_bsr(uint32_t buff_size[4], sch_subh::cetype format); bool set_con_res_id(uint64_t con_res_id); bool set_ta_cmd(uint8_t ta_cmd); - bool set_scell_activation_cmd(std::bitset<8> active_cc_idxs); + bool set_scell_activation_cmd(const std::array& active_scell_idxs); bool set_phr(float phr); void set_padding(); void set_padding(uint32_t padding_len); diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index acb12679f..3b0ffbfda 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -225,7 +225,8 @@ public: * @param rnti identifier of the user * @param activation vector with the activate/deactivate. */ - virtual void set_activation_deactivation_scell(uint16_t rnti, bool activation[SRSLTE_MAX_CARRIERS]) = 0; + virtual void set_activation_deactivation_scell(uint16_t rnti, + const std::array& activation) = 0; }; /* Interface RRC -> PHY */ diff --git a/lib/include/srslte/interfaces/sched_interface.h b/lib/include/srslte/interfaces/sched_interface.h index b960aa5b9..4bf703fed 100644 --- a/lib/include/srslte/interfaces/sched_interface.h +++ b/lib/include/srslte/interfaces/sched_interface.h @@ -103,10 +103,10 @@ public: }; struct ue_bearer_cfg_t { - int priority = 0; - int bsd = 0; - int pbr = 0; - int group = 0; + int priority = 0; + int bsd = 0; + int pbr = 0; + int group = 0; enum { IDLE = 0, UL, DL, BOTH } direction = IDLE; }; @@ -276,8 +276,8 @@ public: virtual int ul_sched(uint32_t tti, uint32_t enb_cc_idx, ul_sched_res_t& sched_result) = 0; /* Custom */ - virtual void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) = 0; - virtual const ue_cfg_t* get_ue_cfg(uint16_t rnti) = 0; + virtual void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) = 0; + virtual std::array get_enb_ue_cc_map(uint16_t rnti) = 0; }; } // namespace srsenb diff --git a/lib/src/common/pdu.cc b/lib/src/common/pdu.cc index ae041bc2d..8442ac196 100644 --- a/lib/src/common/pdu.cc +++ b/lib/src/common/pdu.cc @@ -628,16 +628,18 @@ bool sch_subh::set_ta_cmd(uint8_t ta_cmd) } } -bool sch_subh::set_scell_activation_cmd(std::bitset<8> active_cc_idxs) +bool sch_subh::set_scell_activation_cmd(const std::array& active_scell_idxs) { const uint32_t nof_octets = 1; if (not((sch_pdu*)parent)->has_space_ce(nof_octets)) { return false; } // first bit is reserved - active_cc_idxs.set(0, false); - w_payload_ce[0] = (uint8_t)(active_cc_idxs.to_ulong() & 0xffu); - lcid = SCELL_ACTIVATION; + w_payload_ce[0] = 0; + for (uint8_t i = 1; i < SRSLTE_MAX_CARRIERS; ++i) { + w_payload_ce[0] |= (static_cast(active_scell_idxs[i]) << i); + } + lcid = SCELL_ACTIVATION; ((sch_pdu*)parent)->update_space_ce(nof_octets); nof_bytes = nof_octets; return true; diff --git a/lib/test/common/pdu_test.cc b/lib/test/common/pdu_test.cc index 8a2fa56af..4cff0c5f8 100644 --- a/lib/test/common/pdu_test.cc +++ b/lib/test/common/pdu_test.cc @@ -26,6 +26,7 @@ #include "srslte/common/pdu.h" #include "srslte/common/test_common.h" #include "srslte/interfaces/ue_interfaces.h" +#include #include #include #include @@ -556,6 +557,8 @@ int mac_sch_pdu_pack_test8() uint8_t tv[pdu_size] = {0b00011011, (uint8_t)cc_mask.to_ulong()}; // ensure reserved bit tv[1] &= ~(0x1u); + // limit to max carriers + tv[1] &= ((1u << (uint32_t)SRSLTE_MAX_CARRIERS) - 1u); byte_buffer_t buffer; pdu.init_tx(&buffer, pdu_size, true); @@ -567,7 +570,11 @@ int mac_sch_pdu_pack_test8() // Try SCell activation CE TESTASSERT(pdu.new_subh()); - TESTASSERT(pdu.get()->set_scell_activation_cmd(cc_mask)); + std::array cc_activ_list = {}; + for (uint8_t i = 1; i < SRSLTE_MAX_CARRIERS; ++i) { + cc_activ_list[i] = cc_mask.test(i); + } + TESTASSERT(pdu.get()->set_scell_activation_cmd(cc_activ_list)); // write PDU pdu.write_packet(log_h.get()); diff --git a/srsenb/hdr/phy/phy.h b/srsenb/hdr/phy/phy.h index 2ac8be27f..db1d50c24 100644 --- a/srsenb/hdr/phy/phy.h +++ b/srsenb/hdr/phy/phy.h @@ -54,7 +54,8 @@ public: int add_rnti(uint16_t rnti, uint32_t pcell_index, bool is_temporal) override; void rem_rnti(uint16_t rnti) final; void set_mch_period_stop(uint32_t stop) final; - void set_activation_deactivation_scell(uint16_t rnti, bool activation[SRSLTE_MAX_CARRIERS]) override; + void set_activation_deactivation_scell(uint16_t rnti, + const std::array& activation) override; /*RRC-PHY interface*/ void diff --git a/srsenb/hdr/stack/mac/scheduler.h b/srsenb/hdr/stack/mac/scheduler.h index 43253229d..7bfc0dc75 100644 --- a/srsenb/hdr/stack/mac/scheduler.h +++ b/srsenb/hdr/stack/mac/scheduler.h @@ -129,10 +129,10 @@ public: /* Custom functions */ - void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) final; - void tpc_inc(uint16_t rnti); - void tpc_dec(uint16_t rnti); - const ue_cfg_t* get_ue_cfg(uint16_t rnti) final; + void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) final; + void tpc_inc(uint16_t rnti); + void tpc_dec(uint16_t rnti); + std::array get_enb_ue_cc_map(uint16_t rnti) final; class carrier_sched; diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index f8d00493d..352808c02 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -183,7 +183,7 @@ void phy::set_mch_period_stop(uint32_t stop) workers_common.set_mch_period_stop(stop); } -void phy::set_activation_deactivation_scell(uint16_t rnti, bool activation[SRSLTE_MAX_CARRIERS]) +void phy::set_activation_deactivation_scell(uint16_t rnti, const std::array& activation) { // Iterate all elements except 0 that is reserved for primary cell for (uint32_t scell_idx = 1; scell_idx < SRSLTE_MAX_CARRIERS; scell_idx++) { diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 58c8f2100..7a0ccf20b 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -67,7 +67,7 @@ bool mac::init(const mac_args_t& args_, stack = stack_; log_h = log_h_; - args = args_; + args = args_; cells = cells_; stack_task_queue = stack->get_task_queue(); @@ -323,7 +323,12 @@ int mac::crc_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof ue_db[rnti]->set_tti(tti); ue_db[rnti]->metrics_rx(crc, nof_bytes); - uint32_t ue_cc_idx = 0; // FIXME: mapping between eNB->UE CC idx + std::array enb_ue_cc_map = scheduler.get_enb_ue_cc_map(rnti); + if (enb_ue_cc_map[enb_cc_idx] < 0) { + Error("User rnti=0x%x is not activated for carrier %d\n", rnti, enb_cc_idx); + return ret; + } + uint32_t ue_cc_idx = enb_ue_cc_map[enb_cc_idx]; // push the pdu through the queue if received correctly if (crc) { @@ -528,7 +533,8 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list) dl_sched_res->pdsch[n].dci = sched_result.data[i].dci; for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { - dl_sched_res->pdsch[n].softbuffer_tx[tb] = ue_db[rnti]->get_tx_softbuffer(sched_result.data[i].dci.ue_cc_idx, sched_result.data[i].dci.pid, tb); + dl_sched_res->pdsch[n].softbuffer_tx[tb] = + ue_db[rnti]->get_tx_softbuffer(sched_result.data[i].dci.ue_cc_idx, sched_result.data[i].dci.pid, tb); if (sched_result.data[i].nof_pdu_elems[tb] > 0) { /* Get PDU if it's a new transmission */ @@ -784,7 +790,7 @@ int mac::get_ul_sched(uint32_t tti, ul_sched_list_t& ul_sched_res_list) // Copy DCI grants phy_ul_sched_res->nof_grants = 0; - int n = 0; + int n = 0; for (uint32_t i = 0; i < sched_result.nof_dci_elems; i++) { if (sched_result.pusch[i].tbs > 0) { diff --git a/srsenb/src/stack/mac/scheduler.cc b/srsenb/src/stack/mac/scheduler.cc index 62d5b3ea6..9ed3319bc 100644 --- a/srsenb/src/stack/mac/scheduler.cc +++ b/srsenb/src/stack/mac/scheduler.cc @@ -357,11 +357,19 @@ void sched::tpc_dec(uint16_t rnti) ue_db_access(rnti, [](sched_ue& ue) { ue.tpc_dec(); }); } -const sched::ue_cfg_t* sched::get_ue_cfg(uint16_t rnti) +std::array sched::get_enb_ue_cc_map(uint16_t rnti) { - const ue_cfg_t* cfg = nullptr; - ue_db_access(rnti, [&cfg](sched_ue& ue) { cfg = &ue.get_ue_cfg(); }); - return cfg; + std::array ret{}; + ret.fill(-1); // -1 for inactive carriers + ue_db_access(rnti, [this, &ret](sched_ue& ue) { + for (size_t enb_cc_idx = 0; enb_cc_idx < carrier_schedulers.size(); ++enb_cc_idx) { + auto p = ue.get_cell_index(enb_cc_idx); + if (p.second < SRSLTE_MAX_CARRIERS) { + ret[enb_cc_idx] = p.second; + } + } + }); + return ret; } /******************************************************* diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index e2713d91d..61cafd0ef 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -174,7 +174,7 @@ uint8_t* ue::request_buffer(const uint32_t ue_cc_idx, const uint32_t tti, const uint8_t* ret = nullptr; if (len > 0) { if (!pending_buffers.at(ue_cc_idx).at(tti % nof_rx_harq_proc)) { - ret = pdus.request(len); + ret = pdus.request(len); pending_buffers.at(ue_cc_idx).at(tti % nof_rx_harq_proc) = ret; } else { log_h->console("Error requesting buffer for pid %d, not pushed yet\n", tti % nof_rx_harq_proc); @@ -460,19 +460,23 @@ void ue::allocate_ce(srslte::sch_pdu* pdu, uint32_t lcid) break; case srslte::sch_subh::SCELL_ACTIVATION: if (pdu->new_subh()) { - const sched_interface::ue_cfg_t* sched_cfg = sched->get_ue_cfg(rnti); - if (sched_cfg->supported_cc_list.size() <= 8) { - std::bitset<8> active_cc_list; - for (uint32_t i = 0; i < sched_cfg->supported_cc_list.size(); ++i) { - active_cc_list.set(i, sched_cfg->supported_cc_list[i].active); + std::array enb_ue_cc_map = sched->get_enb_ue_cc_map(rnti); + std::array active_scell_list = {}; + size_t enb_cc_idx = 0; + for (; enb_cc_idx < enb_ue_cc_map.size(); ++enb_cc_idx) { + if (enb_ue_cc_map[enb_cc_idx] >= 8) { + break; } - if (pdu->get()->set_scell_activation_cmd(active_cc_list)) { - Info("CE: Added SCell Activation CE.\n"); - // Allocate and initialize Rx/Tx softbuffers for new carriers (exclude PCell) - allocate_cc_buffers(active_cc_list.size() - 1); - } else { - Error("CE: Setting SCell Activation CE\n"); + if (enb_ue_cc_map[enb_cc_idx] <= 0) { + // inactive or PCell + continue; } + active_scell_list[enb_ue_cc_map[enb_cc_idx]] = true; + } + if (enb_cc_idx == enb_ue_cc_map.size() and pdu->get()->set_scell_activation_cmd(active_scell_list)) { + Info("CE: Added SCell Activation CE.\n"); + // Allocate and initialize Rx/Tx softbuffers for new carriers (exclude PCell) + allocate_cc_buffers(active_scell_list.size() - 1); } else { Error("CE: Setting SCell Activation CE\n"); } diff --git a/srsenb/test/mac/scheduler_ca_test.cc b/srsenb/test/mac/scheduler_ca_test.cc index 53812b0b8..f1be3ff84 100644 --- a/srsenb/test/mac/scheduler_ca_test.cc +++ b/srsenb/test/mac/scheduler_ca_test.cc @@ -162,13 +162,17 @@ int test_scell_activation(test_scell_activation_params params) // Event: Reconf Complete. Activate SCells. Check if CE correctly transmitted generator.step_tti(); user = generator.user_reconf(rnti1); - *user->ue_cfg = *tester.get_ue_cfg(rnti1); // use current cfg as starting point, and add more supported ccs + *user->ue_cfg = *tester.get_current_ue_cfg(rnti1); // use current cfg as starting point, and add more supported ccs user->ue_cfg->supported_cc_list.resize(nof_ccs); for (uint32_t i = 0; i < user->ue_cfg->supported_cc_list.size(); ++i) { user->ue_cfg->supported_cc_list[i].active = true; user->ue_cfg->supported_cc_list[i].enb_cc_idx = cc_idxs[i]; } tester.test_next_ttis(generator.tti_events); + auto activ_list = tester.get_enb_ue_cc_map(rnti1); + for (uint32_t i = 0; i < cc_idxs.size(); ++i) { + TESTASSERT(activ_list[i] >= 0); + } // TEST: When a DL newtx takes place, it should also encode the CE for (uint32_t i = 0; i < 100; ++i) { diff --git a/srsenb/test/mac/scheduler_test_common.cc b/srsenb/test/mac/scheduler_test_common.cc index ed0cdd271..6a3a4ad49 100644 --- a/srsenb/test/mac/scheduler_test_common.cc +++ b/srsenb/test/mac/scheduler_test_common.cc @@ -615,6 +615,15 @@ sched_result_stats::user_stats* sched_result_stats::get_user(uint16_t rnti) * Common Sched Tester **********************/ +const sched::ue_cfg_t* common_sched_tester::get_current_ue_cfg(uint16_t rnti) const +{ + auto it = ue_db.find(rnti); + if (it == ue_db.end()) { + return nullptr; + } + return &it->second.get_ue_cfg(); +} + int common_sched_tester::sim_cfg(sim_sched_args args) { sim_args0 = std::move(args); diff --git a/srsenb/test/mac/scheduler_test_common.h b/srsenb/test/mac/scheduler_test_common.h index 0a660e0cd..98eb402c7 100644 --- a/srsenb/test/mac/scheduler_test_common.h +++ b/srsenb/test/mac/scheduler_test_common.h @@ -175,6 +175,8 @@ public: ~common_sched_tester() override = default; + const ue_cfg_t* get_current_ue_cfg(uint16_t rnti) const; + int sim_cfg(sim_sched_args args); virtual int add_user(uint16_t rnti, const ue_cfg_t& ue_cfg_); virtual void rem_user(uint16_t rnti); diff --git a/srsenb/test/phy/enb_phy_test.cc b/srsenb/test/phy/enb_phy_test.cc index 0caaf597f..6928ed38a 100644 --- a/srsenb/test/phy/enb_phy_test.cc +++ b/srsenb/test/phy/enb_phy_test.cc @@ -1091,7 +1091,7 @@ public: dedicated.ul_cfg.pusch.uci_offset.I_offset_ack = 7; // Configure UE PHY - bool activation[SRSLTE_MAX_CARRIERS] = {}; ///< Activation/Deactivation vector + std::array activation = {}; ///< Activation/Deactivation vector phy_rrc_cfg.resize(args.ue_cell_list.size()); for (uint32_t i = 0; i < args.ue_cell_list.size(); i++) { phy_rrc_cfg[i].enb_cc_idx = args.ue_cell_list[i]; ///< First element is PCell