From f90f10f6a89a4ec80dbd484ed0585ae6d3aca817 Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Thu, 18 Feb 2021 19:32:12 +0100 Subject: [PATCH] SRSUE: NR handle rar pdu in tb decoded, fixed tti_tx issue, log RA procedure and adjusted testcase --- srsue/src/phy/nr/sf_worker.cc | 2 +- srsue/src/stack/mac_nr/mac_nr.cc | 6 ++---- srsue/src/stack/mac_nr/proc_ra_nr.cc | 10 +++++----- srsue/src/stack/rrc/rrc_nr.cc | 2 +- srsue/test/mac_nr/proc_ra_nr_test.cc | 8 ++++---- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/srsue/src/phy/nr/sf_worker.cc b/srsue/src/phy/nr/sf_worker.cc index 4133a832b..fea8876d2 100644 --- a/srsue/src/phy/nr/sf_worker.cc +++ b/srsue/src/phy/nr/sf_worker.cc @@ -83,7 +83,7 @@ void sf_worker::work_imp() tx_buffer.set(0, prach_ptr); // Notify MAC about PRACH transmission - phy_state->stack->prach_sent(tti_rx, 7, 1, 0, 0); + phy_state->stack->prach_sent(TTI_TX(tti_rx), 7, 1, 0, 0); // Transmit NR PRACH phy->worker_end(this, false, tx_buffer, dummy_ts, true); diff --git a/srsue/src/stack/mac_nr/mac_nr.cc b/srsue/src/stack/mac_nr/mac_nr.cc index a1304e407..1ca19c888 100644 --- a/srsue/src/stack/mac_nr/mac_nr.cc +++ b/srsue/src/stack/mac_nr/mac_nr.cc @@ -182,11 +182,9 @@ void mac_nr::write_pcap(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) void mac_nr::tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) { write_pcap(cc_idx, grant); - // handle PDU - if (SRSLTE_RNTI_ISRAR(grant.rnti)) { // TODO: replace with proc_ra->get_rar_rnti() - // TODO: pass to RA proc - // handle_rar_pdu(grant); + if (grant.rnti == proc_ra.get_rar_rnti()) { + proc_ra.handle_rar_pdu(grant); } else { // Push DL PDUs to queue for back-ground processing for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; ++i) { diff --git a/srsue/src/stack/mac_nr/proc_ra_nr.cc b/srsue/src/stack/mac_nr/proc_ra_nr.cc index 43b55c50d..f855360a5 100644 --- a/srsue/src/stack/mac_nr/proc_ra_nr.cc +++ b/srsue/src/stack/mac_nr/proc_ra_nr.cc @@ -87,7 +87,7 @@ bool proc_ra_nr::is_rar_opportunity(uint32_t tti) uint16_t proc_ra_nr::get_rar_rnti() { if (rar_rnti == SRSLTE_INVALID_RNTI || state != WAITING_FOR_RESPONSE_RECEPTION) { - logger.error("Requested ra rnti is invalid. Anyway we return an invalid ra rnti\n"); + logger.error("Requested ra rnti is invalid. Anyway we return an invalid ra rnti"); return SRSLTE_INVALID_RNTI; } return rar_rnti; @@ -160,7 +160,7 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::mac_nr_grant_ if (grant.tb[i] != nullptr) { srslte::mac_rar_pdu_nr pdu; if (!pdu.unpack(grant.tb[i]->msg, grant.tb[i]->N_bytes)) { - logger.warning("Error unpacking RAR PDU"); + logger.warning("Error unpacking RAR PDU (%d)", i); return; } logger.info(pdu.to_string()); @@ -234,7 +234,7 @@ void proc_ra_nr::ra_completion() void proc_ra_nr::ra_error() { - logger.error("NR random access procedure error recovery not implemented yet\n"); + logger.error("NR random access procedure error recovery not implemented yet"); } // Is called by PHY once it has transmitted the prach transmitted, than configure RA-RNTI and wait for RAR reception @@ -265,8 +265,8 @@ void proc_ra_nr::prach_sent(uint32_t tti, uint32_t s_id, uint32_t t_id, uint32_t rar_rnti, tti); uint32_t rar_window_st = TTI_ADD(tti, 3); - // TODO check ra_response window (delayed start)? - rar_timeout_timer.set(rach_cfg.ra_responseWindow + 3, [this](uint32_t tid) { timer_expired(tid); }); + // TODO check ra_response window (delayed start)? // last 3 check if needed when we have a delayed start + rar_timeout_timer.set(rach_cfg.ra_responseWindow + 3 + 3, [this](uint32_t tid) { timer_expired(tid); }); rar_timeout_timer.run(); // Wait for RAR reception ra_window_length = rach_cfg.ra_responseWindow; diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index 9759b54b4..01397d628 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -755,7 +755,7 @@ void rrc_nr::connection_reconf_no_ho_proc::then(const srslte::proc_state_t& resu { if (result.is_success()) { Info("Finished %s successfully", name()); - srslte::console("RRC NR reconfiguration successful."); + srslte::console("RRC NR reconfiguration successful.\n"); return; } diff --git a/srsue/test/mac_nr/proc_ra_nr_test.cc b/srsue/test/mac_nr/proc_ra_nr_test.cc index 50501da88..0d883182a 100644 --- a/srsue/test/mac_nr/proc_ra_nr_test.cc +++ b/srsue/test/mac_nr/proc_ra_nr_test.cc @@ -96,7 +96,7 @@ int main() TESTASSERT(preamble_received_target_power == -114); // Simulate PHY and call prach_sent (random values) uint32_t tti_start = 0; - proc_ra_nr.prach_sent(tti_start, 6, 0, 4, 1); + proc_ra_nr.prach_sent(tti_start, 7, 1, 0, 0); for (uint32_t i = tti_start; i < rach_cfg.ra_responseWindow; i++) { // update clock and run internal tasks @@ -107,14 +107,14 @@ int main() TESTASSERT(rar_opportunity == false); } else if (3 + tti_start > i && i < 3 + rach_cfg.ra_responseWindow) { TESTASSERT(rar_opportunity == true); - TESTASSERT(proc_ra_nr.get_rar_rnti() == 0x3487); + TESTASSERT(proc_ra_nr.get_rar_rnti() == 0x16); } } mac_interface_phy_nr::mac_nr_grant_dl_t grant; - grant.rnti = 0x3487; + grant.rnti = 0x16; grant.tti = rach_cfg.ra_responseWindow + tti_start + 3; grant.pid = 0x0123; - uint8_t mac_dl_rar_pdu[] = {0x40, 0x05, 0xa0, 0x00, 0x11, 0x46, 0x46, 0x16, 0x00, 0x00, 0x00}; + uint8_t mac_dl_rar_pdu[] = {0x40, 0x06, 0x68, 0x03, 0x21, 0x46, 0x46, 0x02, 0x00, 0x00, 0x00}; grant.tb[0] = srslte::make_byte_buffer(); grant.tb[0].get()->append_bytes(mac_dl_rar_pdu, sizeof(mac_dl_rar_pdu)); proc_ra_nr.handle_rar_pdu(grant);