From b8976ca463a34edd8ffc0d8a530b238186db2598 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 7 Oct 2021 14:34:58 +0100 Subject: [PATCH] nr,ue,rrc: avoid configuring the CSI until NR RA is complete --- srsue/hdr/stack/mac_nr/mac_nr.h | 1 + srsue/hdr/stack/mac_nr/mac_nr_interfaces.h | 9 +++---- srsue/hdr/stack/mac_nr/proc_ra_nr.h | 24 +++++++++---------- srsue/src/stack/mac_nr/mac_nr.cc | 5 ++++ srsue/src/stack/mac_nr/proc_ra_nr.cc | 13 +++++----- .../src/stack/mac_nr/test/proc_ra_nr_test.cc | 7 +++--- srsue/src/stack/rrc/rrc_nr.cc | 16 +++++++++++-- 7 files changed, 48 insertions(+), 27 deletions(-) diff --git a/srsue/hdr/stack/mac_nr/mac_nr.h b/srsue/hdr/stack/mac_nr/mac_nr.h index e7e5e03db..ee32663d5 100644 --- a/srsue/hdr/stack/mac_nr/mac_nr.h +++ b/srsue/hdr/stack/mac_nr/mac_nr.h @@ -108,6 +108,7 @@ public: /// RRC void rrc_ra_problem(); + void rrc_ra_completed(); /// stack interface void process_pdus(); diff --git a/srsue/hdr/stack/mac_nr/mac_nr_interfaces.h b/srsue/hdr/stack/mac_nr/mac_nr_interfaces.h index 9d0302122..6421dcd7d 100644 --- a/srsue/hdr/stack/mac_nr/mac_nr_interfaces.h +++ b/srsue/hdr/stack/mac_nr/mac_nr_interfaces.h @@ -24,9 +24,9 @@ class mac_interface_proc_ra_nr { public: // Functions for identity handling, e.g., contention id and c-rnti - virtual uint64_t get_contention_id() = 0; - virtual uint16_t get_crnti() = 0; - virtual bool set_crnti(uint16_t c_rnti) = 0; + virtual uint64_t get_contention_id() = 0; + virtual uint16_t get_crnti() = 0; + virtual bool set_crnti(uint16_t c_rnti) = 0; // Functions for msg3 manipulation which shall be transparent to the procedure virtual bool msg3_is_transmitted() = 0; @@ -35,7 +35,8 @@ public: virtual bool msg3_is_empty() = 0; // RRC functions - virtual void rrc_ra_problem() = 0; + virtual void rrc_ra_problem() = 0; + virtual void rrc_ra_completed() = 0; }; /** diff --git a/srsue/hdr/stack/mac_nr/proc_ra_nr.h b/srsue/hdr/stack/mac_nr/proc_ra_nr.h index 3658c0c59..0e8ee707f 100644 --- a/srsue/hdr/stack/mac_nr/proc_ra_nr.h +++ b/srsue/hdr/stack/mac_nr/proc_ra_nr.h @@ -35,8 +35,8 @@ public: void set_config(const srsran::rach_nr_cfg_t& rach_cfg); bool is_contention_resolution(); - bool is_rar_opportunity(uint32_t tti); - bool has_rar_rnti(); + bool is_rar_opportunity(uint32_t tti); + bool has_rar_rnti(); uint16_t get_rar_rnti(); bool has_temp_crnti(); uint16_t get_temp_crnti(); @@ -61,9 +61,9 @@ private: srsran::ext_task_sched_handle* task_sched = nullptr; srsran::task_multiqueue::queue_handle task_queue; - int ra_window_length = -1, ra_window_start = -1; - uint16_t rar_rnti = SRSRAN_INVALID_RNTI; - uint16_t temp_crnti = SRSRAN_INVALID_RNTI; + int ra_window_length = -1, ra_window_start = -1; + uint16_t rar_rnti = SRSRAN_INVALID_RNTI; + uint16_t temp_crnti = SRSRAN_INVALID_RNTI; std::mutex mutex; srsran::rach_nr_cfg_t rach_cfg = {}; @@ -90,18 +90,18 @@ private: srsran::timer_handler::unique_timer backoff_timer; // 38.321 5.1.1 Variables - uint32_t preamble_index = 0; - uint32_t preamble_transmission_counter = 0; + uint32_t preamble_index = 0; + uint32_t preamble_transmission_counter = 0; uint32_t preamble_backoff = 0; // in ms - uint32_t preamble_power_ramping_step = 0; - int preamble_received_target_power = 0; - uint32_t scaling_factor_bi = 0; + uint32_t preamble_power_ramping_step = 0; + int preamble_received_target_power = 0; + uint32_t scaling_factor_bi = 0; // uint32_t temporary_c_rnti; uint32_t power_offset_2step_ra = 0; // not explicty mentioned uint32_t preambleTransMax = 0; - uint32_t prach_occasion = 0; + uint32_t prach_occasion = 0; uint32_t current_ta = 0; void timer_expired(uint32_t timer_id); @@ -112,7 +112,7 @@ private: void ra_response_reception(const mac_interface_phy_nr::tb_action_dl_result_t& tb); void ra_contention_resolution(); void ra_contention_resolution(uint64_t rx_contention_id); - void ra_completion(); + void ra_completion(); void ra_error(); }; } // namespace srsue diff --git a/srsue/src/stack/mac_nr/mac_nr.cc b/srsue/src/stack/mac_nr/mac_nr.cc index 49a4dd325..a5d0fd09b 100644 --- a/srsue/src/stack/mac_nr/mac_nr.cc +++ b/srsue/src/stack/mac_nr/mac_nr.cc @@ -506,6 +506,11 @@ void mac_nr::rrc_ra_problem() rrc->ra_problem(); } +void mac_nr::rrc_ra_completed() +{ + rrc->ra_completed(); +} + /** * Called from the main stack thread to process received PDUs */ diff --git a/srsue/src/stack/mac_nr/proc_ra_nr.cc b/srsue/src/stack/mac_nr/proc_ra_nr.cc index 745216473..1c088c5f0 100644 --- a/srsue/src/stack/mac_nr/proc_ra_nr.cc +++ b/srsue/src/stack/mac_nr/proc_ra_nr.cc @@ -128,7 +128,7 @@ void proc_ra_nr::timer_expired(uint32_t timer_id) { if (prach_send_timer.id() == timer_id) { logger.warning("PRACH Send timer expired. PRACH was not transmitted within %d ttis by phy. (TODO)", - prach_send_timer.duration()); + prach_send_timer.duration()); ra_error(); } else if (rar_timeout_timer.id() == timer_id) { logger.warning("RAR Timer expired. RA response not received within the response window"); @@ -149,10 +149,10 @@ void proc_ra_nr::ra_procedure_initialization() { mac.msg3_flush(); preamble_transmission_counter = 1; - preamble_power_ramping_step = rach_cfg.powerRampingStep; - scaling_factor_bi = 1; + preamble_power_ramping_step = rach_cfg.powerRampingStep; + scaling_factor_bi = 1; preamble_backoff = 0; - preambleTransMax = rach_cfg.preambleTransMax; + preambleTransMax = rach_cfg.preambleTransMax; ra_resource_selection(); } @@ -278,6 +278,7 @@ void proc_ra_nr::ra_completion() srsran::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", mac.get_crnti(), current_ta); logger.info("Random Access Complete. c-rnti=0x%x, ta=%d", mac.get_crnti(), current_ta); temp_crnti = SRSRAN_INVALID_RNTI; + mac.rrc_ra_completed(); reset(); } @@ -293,9 +294,9 @@ void proc_ra_nr::ra_error() if (preamble_transmission_counter >= rach_cfg.preambleTransMax + 1) { logger.warning("Maximum number of transmissions reached (%d)", rach_cfg.preambleTransMax); // if the Random Access Preamble is transmitted on the SpCell assumption (TODO) - mac.rrc_ra_problem(); // indicate a Random Access problem to upper layers; + mac.rrc_ra_problem(); // indicate a Random Access problem to upper layers; if (started_by == initiators_t::MAC) { // if this Random Access procedure was triggered for SI request - ra_procedure_completed = true; // consider the Random Access procedure unsuccessfully completed. + ra_procedure_completed = true; // consider the Random Access procedure unsuccessfully completed. reset(); } } else { diff --git a/srsue/src/stack/mac_nr/test/proc_ra_nr_test.cc b/srsue/src/stack/mac_nr/test/proc_ra_nr_test.cc index fabf2632e..de994fea7 100644 --- a/srsue/src/stack/mac_nr/test/proc_ra_nr_test.cc +++ b/srsue/src/stack/mac_nr/test/proc_ra_nr_test.cc @@ -73,6 +73,7 @@ public: void msga_flush(){}; // RRC RA problem void rrc_ra_problem() { logger.warning("Dummy MAC RRC ra problem"); } + void rrc_ra_completed() { logger.info("Dummy MAC RRC ra completed"); } private: uint16_t crnti = SRSRAN_INVALID_RNTI; @@ -127,10 +128,10 @@ int proc_ra_normal_test() mac_interface_phy_nr::mac_nr_grant_dl_t grant; grant.rnti = 0x16; grant.tti = rach_cfg.ra_responseWindow + tti_start + 3; - grant.pid = 0x0; + grant.pid = 0x0; uint8_t mac_dl_rar_pdu[] = {0x40, 0x06, 0x68, 0x03, 0x21, 0x46, 0x46, 0x02, 0x00, 0x00, 0x00}; - mac_interface_phy_nr::tb_action_dl_result_t result = {}; - result.payload = srsran::make_byte_buffer(); + mac_interface_phy_nr::tb_action_dl_result_t result = {}; + result.payload = srsran::make_byte_buffer(); TESTASSERT(result.payload != nullptr); result.payload.get()->append_bytes(mac_dl_rar_pdu, sizeof(mac_dl_rar_pdu)); proc_ra_nr.handle_rar_pdu(result); diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index af12af83d..e0e59c991 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -1143,6 +1143,7 @@ bool rrc_nr::apply_sp_cell_ded_ul_pusch(const asn1::rrc_nr::pusch_cfg_s& pusch_c bool rrc_nr::apply_sp_cell_cfg(const sp_cell_cfg_s& sp_cell_cfg) { + srsran_csi_hl_cfg_t prev_csi = phy_cfg.csi; if (sp_cell_cfg.recfg_with_sync_present) { const recfg_with_sync_s& recfg_with_sync = sp_cell_cfg.recfg_with_sync; mac->set_crnti(recfg_with_sync.new_ue_id); @@ -1305,7 +1306,14 @@ bool rrc_nr::apply_sp_cell_cfg(const sp_cell_cfg_s& sp_cell_cfg) logger.warning("Option sp_cell_cfg_ded not present"); return false; } - phy->set_config(phy_cfg); + + // Configure PHY + // Note: CSI config is deferred to when RA is complete. See TS 38.331, Section 5.3.5.3 + srsran::phy_cfg_nr_t current_phycfg = phy_cfg; + current_phycfg.csi = prev_csi; + phy->set_config(current_phycfg); + + // Start RA procedure mac->start_ra_procedure(); return true; } @@ -1501,7 +1509,11 @@ void rrc_nr::max_retx_attempted() {} void rrc_nr::protocol_failure() {} // MAC interface -void rrc_nr::ra_completed() {} +void rrc_nr::ra_completed() +{ + logger.info("RA completed. Applying remaining CSI configuration."); + phy->set_config(phy_cfg); +} void rrc_nr::ra_problem() { rrc_eutra->nr_scg_failure_information(scg_failure_cause_t::random_access_problem);