enb_mac: pre-allocate UE object for quicker PRACH/RAR handling

we've seen long delays in handling PRACH on low-power devices
such as the RPi4. This was mainly caused by long delays
in creating the UE object on the fly during PRACH handling.

This patch pre-allocates one UE object that is then used
during the PRACH.
This commit is contained in:
Andre Puschmann 2020-05-22 11:36:36 +02:00
parent 3ddbc258ea
commit 084a813449
3 changed files with 27 additions and 6 deletions

View File

@ -136,7 +136,10 @@ private:
/* Map of active UEs */
std::map<uint16_t, std::unique_ptr<ue> > ue_db;
uint16_t last_rnti = 0;
uint16_t last_rnti = 70;
srslte::block_queue<std::unique_ptr<ue> > ue_pool; ///< Pool of pre-allocated UE objects
void prealloc_ue(uint32_t nof_ue);
uint8_t* assemble_rar(sched_interface::dl_sched_rar_grant_t* grants,
uint32_t nof_grants,

View File

@ -57,6 +57,8 @@ public:
void set_tti(uint32_t tti);
uint16_t get_rnti() { return rnti; }
uint32_t set_ta(int ta) override;
void start_ta() { ta_fsm.start(); };

View File

@ -37,7 +37,6 @@ using namespace asn1::rrc;
namespace srsenb {
mac::mac() :
last_rnti(0),
rar_pdu_msg(sched_interface::MAX_RAR_LIST),
rar_payload(),
common_buffers(SRSLTE_MAX_CARRIERS)
@ -93,6 +92,9 @@ bool mac::init(const mac_args_t& args_,
reset();
// Pre-alloc UE objects for first attaching users
prealloc_ue(10);
started = true;
}
@ -487,10 +489,12 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx
log_h->step(tti);
auto rach_tprof_meas = rach_tprof.start();
uint16_t rnti = allocate_rnti();
// Create new UE
std::unique_ptr<ue> ue_ptr{new ue(rnti, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size())};
// Get pre-allocated UE object
if (ue_pool.empty()) {
Error("Ignoring RACH attempt. UE pool empty.\n");
}
auto ue_ptr = ue_pool.wait_pop();
uint16_t rnti = ue_ptr->get_rnti();
// Set PCAP if available
if (pcap != nullptr) {
@ -539,6 +543,18 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx
log_h->info("RACH: tti=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", tti, preamble_idx, time_adv, rnti);
log_h->console("RACH: tti=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", tti, preamble_idx, time_adv, rnti);
});
// Allocate one new UE object in advance
prealloc_ue(1);
}
void mac::prealloc_ue(uint32_t nof_ue)
{
for (uint32_t i = 0; i < nof_ue; i++) {
std::unique_ptr<ue> ptr = std::unique_ptr<ue>(
new ue(allocate_rnti(), args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size()));
ue_pool.push(std::move(ptr));
}
}
int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)