Fixes repeating proc RA due to SR trigger

master
David Rupprecht 4 years ago committed by Andre Puschmann
parent 5a3a2a6d6f
commit eeddbe69ce

@ -35,6 +35,7 @@ struct mac_nr_args_t {};
class mac_nr final : public mac_interface_phy_nr,
public mac_interface_rrc_nr,
public mac_interface_proc_ra_nr,
public mac_interface_sr_nr,
public mac_interface_mux_nr
{
public:
@ -85,6 +86,9 @@ public:
uint64_t get_contention_id();
uint16_t get_crnti();
/// procedure sr nr interface
void start_ra() { proc_ra.start_by_mac(); }
/// Interface for MUX
srsran::mac_sch_subpdu_nr::lcg_bsr_t generate_sbsr();

@ -39,7 +39,17 @@ public:
};
/**
* @brief Interface from MAC NR parent class to mux ubclass
* @brief Interface from MAC NR parent class to SR subclass
*/
class mac_interface_sr_nr
{
public:
// MUX can query MAC for current C-RNTI for Msg3 transmission
virtual void start_ra() = 0;
};
/**
* @brief Interface from MAC NR parent class to mux subclass
*/
class mac_interface_mux_nr
{

@ -13,7 +13,9 @@
#ifndef SRSUE_PROC_SR_NR_H
#define SRSUE_PROC_SR_NR_H
#include "srsue/hdr/stack/mac_nr/mac_nr_interfaces.h"
#include "srsran/interfaces/ue_mac_interfaces.h"
#include "srsran/interfaces/ue_nr_interfaces.h"
#include "srsran/srslog/srslog.h"
#include <stdint.h>
@ -23,14 +25,13 @@
namespace srsue {
class proc_ra_nr;
class phy_interface_mac_nr;
class rrc_interface_mac;
class proc_sr_nr
{
public:
explicit proc_sr_nr(srslog::basic_logger& logger);
int32_t init(proc_ra_nr* ra_, phy_interface_mac_nr* phy_, rrc_interface_mac* rrc_);
int32_t init(mac_interface_sr_nr* mac_, phy_interface_mac_nr* phy_, rrc_interface_mac* rrc_);
void step(uint32_t tti);
int32_t set_config(const srsran::sr_cfg_nr_t& cfg);
void reset();
@ -39,11 +40,11 @@ public:
private:
int sr_counter = 0;
bool is_pending_sr = 0;
bool is_pending_sr = false;
srsran::sr_cfg_nr_t cfg = {};
proc_ra_nr* ra = nullptr;
mac_interface_sr_nr* mac = nullptr;
rrc_interface_mac* rrc = nullptr;
phy_interface_mac_nr* phy = nullptr;
srslog::basic_logger& logger;

@ -47,7 +47,7 @@ int mac_nr::init(const mac_nr_args_t& args_,
// Init MAC sub procedures
proc_ra.init(phy, &task_sched);
proc_sr.init(&proc_ra, phy, rrc);
proc_sr.init(this, phy, rrc);
if (proc_bsr.init(&proc_sr, &mux, rlc, &task_sched) != SRSRAN_SUCCESS) {
logger.error("Couldn't initialize BSR procedure.");

@ -114,7 +114,7 @@ void proc_bsr_nr::set_trigger(bsr_trigger_type_t new_trigger)
// Trigger SR always when Regular BSR is triggered in the current TTI. Will be cancelled if a grant is received
if (triggered_bsr_type == REGULAR) {
logger.debug("BSR: Triggering SR procedure");
// sr->start();
sr->start();
}
}

@ -14,16 +14,15 @@
#include "srsran/common/standard_streams.h"
#include "srsran/interfaces/ue_phy_interfaces.h"
#include "srsran/interfaces/ue_rrc_interfaces.h"
#include "srsue/hdr/stack/mac_nr/proc_ra_nr.h"
namespace srsue {
proc_sr_nr::proc_sr_nr(srslog::basic_logger& logger) : logger(logger) {}
int32_t proc_sr_nr::init(proc_ra_nr* ra_, phy_interface_mac_nr* phy_, rrc_interface_mac* rrc_)
int32_t proc_sr_nr::init(mac_interface_sr_nr* mac_, phy_interface_mac_nr* phy_, rrc_interface_mac* rrc_)
{
rrc = rrc_;
ra = ra_;
mac = mac_;
phy = phy_;
initiated = true;
sr_counter = 0;
@ -77,10 +76,10 @@ void proc_sr_nr::step(uint32_t tti)
}
// 1> if the MAC entity has no valid PUCCH resource configured for the pending SR:
if (!cfg.enabled || not phy->has_valid_sr_resource(0)) {
if (not phy->has_valid_sr_resource(cfg.item[0].sched_request_id)) {
// 2> initiate a Random Access procedure (see clause 5.1) on the SpCell and cancel the pending SR.
logger.info("SR: PUCCH not configured. Starting RA procedure");
ra->start_by_mac();
mac->start_ra();
reset();
return;
}
@ -98,7 +97,7 @@ void proc_sr_nr::step(uint32_t tti)
// 4> clear any PUSCH resources for semi-persistent CSI reporting;
// ... TODO
ra->start_by_mac();
mac->start_ra();
reset();
}
}

@ -14,6 +14,10 @@ add_executable(proc_bsr_nr_test proc_bsr_nr_test.cc)
target_link_libraries(proc_bsr_nr_test srsue_mac_nr srsran_common)
add_test(proc_bsr_nr_test proc_bsr_nr_test)
add_executable(proc_sr_nr_test proc_sr_nr_test.cc)
target_link_libraries(proc_sr_nr_test srsue_mac_nr srsran_common)
add_test(proc_sr_nr_test proc_sr_nr_test)
add_executable(mac_nr_test mac_nr_test.cc)
target_link_libraries(mac_nr_test srsue_mac_nr srsran_common)
add_test(mac_nr_test mac_nr_test)

@ -0,0 +1,104 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include "srsran/common/buffer_pool.h"
#include "srsran/common/common.h"
#include "srsran/common/test_common.h"
#include "srsue/hdr/stack/mac_nr/proc_sr_nr.h"
#include "srsran/interfaces/ue_rrc_interfaces.h"
using namespace srsue;
class dummy_phy : public phy_interface_mac_nr
{
public:
dummy_phy() {}
void send_prach(const uint32_t prach_occasion_,
const int preamble_index_,
const float preamble_received_target_power_,
const float ta_base_sec_ = 0.0f) override
{
prach_occasion = prach_occasion_;
preamble_index = preamble_index_;
preamble_received_target_power = preamble_received_target_power_;
}
int tx_request(const tx_request_t& request) override { return 0; }
int set_ul_grant(std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS>, uint16_t rnti, srsran_rnti_type_t rnti_type) override
{
return 0;
}
void get_last_send_prach(uint32_t* prach_occasion_, uint32_t* preamble_index_, int* preamble_received_target_power_)
{
*prach_occasion_ = prach_occasion;
*preamble_index_ = preamble_index;
*preamble_received_target_power_ = preamble_received_target_power;
}
bool has_valid_sr_resource(uint32_t sr_id) override { return false; }
void clear_pending_grants() override {}
private:
uint32_t prach_occasion = 0;
uint32_t preamble_index = 0;
int preamble_received_target_power = 0;
};
class dummy_rrc : public rrc_interface_mac
{
void ra_completed() {}
void ra_problem() {}
void release_pucch_srs() {}
};
class dummy_mac : public mac_interface_sr_nr
{
public:
void start_ra() { ra_started = true; }
bool check_ra_started() { return ra_started; }
void reset_ra_started() { ra_started = false; }
private:
bool ra_started = false;
};
int proc_sr_basic_test()
{
proc_sr_nr proc_sr_nr(srslog::fetch_basic_logger("MAC"));
dummy_rrc dummy_rrc;
dummy_phy dummy_phy;
dummy_mac dummy_mac;
srsran::sr_cfg_nr_t cfg;
cfg.enabled = true;
cfg.num_items = 1;
cfg.item[0].prohibit_timer = 0;
cfg.item[0].sched_request_id = 0;
cfg.item[0].trans_max = 64;
proc_sr_nr.init(&dummy_mac, &dummy_phy, &dummy_rrc);
proc_sr_nr.set_config(cfg);
proc_sr_nr.start();
proc_sr_nr.step(0);
TESTASSERT(dummy_mac.check_ra_started() == true);
return SRSRAN_SUCCESS;
}
int main()
{
srslog::init();
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.set_level(srslog::basic_levels::debug);
mac_logger.set_hex_dump_max_size(-1);
TESTASSERT(proc_sr_basic_test() == SRSRAN_SUCCESS);
return SRSRAN_SUCCESS;
}
Loading…
Cancel
Save