added allocate_rnti method to mac. Useful both during PRACH and handover UE resource allocation

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent 6ddedd5972
commit d183d64409

@ -282,6 +282,9 @@ public:
virtual void phy_config_enabled(uint16_t rnti, bool enabled) = 0;
virtual void
write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch) = 0;
/* Allocation of C-RNTI during HO */
virtual uint16_t allocate_rnti() = 0;
};
class mac_interface_rlc
@ -487,8 +490,7 @@ public:
// Combined interface for stack (MAC and RRC) to access PHY
class phy_interface_stack_lte : public phy_interface_mac_lte, public phy_interface_rrc_lte
{
};
{};
typedef struct {
uint32_t enb_id; // 20-bit id (lsb bits)
@ -524,8 +526,7 @@ public:
// STACK interface for MAC
class stack_interface_mac_lte : public srslte::task_handler_interface
{
};
{};
} // namespace srsenb

@ -99,11 +99,16 @@ public:
void
write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch) override;
/* Allocate C-RNTI */
uint16_t allocate_rnti() final;
private:
static const int MAX_LOCATIONS = 20;
static const uint32_t cfi = 3;
srslte_dci_location_t locations[MAX_LOCATIONS] = {};
std::mutex rnti_mutex;
// We use a rwlock in MAC to allow multiple workers to access MAC simultaneously. No conflicts will happen since
// access for different TTIs
pthread_rwlock_t rwlock = {};

@ -212,7 +212,7 @@ private:
uint32_t cfi,
const srslte_dci_dl_t& dci);
static bool bearer_is_ul(ue_bearer_t* lch);
static bool bearer_is_ul(const ue_bearer_t* lch);
static bool bearer_is_dl(const ue_bearer_t* lch);
uint32_t get_pending_ul_old_data_unlocked(uint32_t cc_idx);

@ -37,7 +37,10 @@ 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)
last_rnti(0),
rar_pdu_msg(sched_interface::MAX_RAR_LIST),
rar_payload(),
common_buffers(SRSLTE_MAX_CARRIERS)
{
pthread_rwlock_init(&rwlock, nullptr);
}
@ -445,34 +448,38 @@ int mac::sr_detected(uint32_t tti, uint16_t rnti)
return ret;
}
uint16_t mac::allocate_rnti()
{
std::lock_guard<std::mutex> lock(rnti_mutex);
// Assign a c-rnti
uint16_t rnti = last_rnti++;
if (last_rnti >= 60000) {
last_rnti = 70;
}
return rnti;
}
void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx, uint32_t time_adv)
{
static srslte::mutexed_tprof<srslte::avg_time_stats> rach_tprof("rach_tprof", "MAC", 1);
log_h->step(tti);
uint16_t rnti;
auto rach_tprof_meas = rach_tprof.start();
{
srslte::rwlock_write_guard lock(rwlock);
rnti = last_rnti;
uint16_t rnti = allocate_rnti();
// Create new UE
if (ue_db.count(rnti) == 0) {
ue_db[rnti] =
std::unique_ptr<ue>{new ue(rnti, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size())};
}
std::unique_ptr<ue> ue_ptr{new ue(rnti, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size())};
// Set PCAP if available
if (pcap != nullptr) {
ue_db[rnti]->start_pcap(pcap);
ue_ptr->start_pcap(pcap);
}
// Increase RNTI counter
last_rnti++;
if (last_rnti >= 60000) {
last_rnti = 70;
}
{
srslte::rwlock_write_guard lock(rwlock);
ue_db[rnti] = std::move(ue_ptr);
}
stack_task_queue.push([this, rnti, tti, enb_cc_idx, preamble_idx, time_adv, rach_tprof_meas]() mutable {

@ -748,7 +748,7 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data,
*
*******************************************************/
bool sched_ue::bearer_is_ul(ue_bearer_t* lch)
bool sched_ue::bearer_is_ul(const ue_bearer_t* lch)
{
return lch->cfg.direction == sched_interface::ue_bearer_cfg_t::UL ||
lch->cfg.direction == sched_interface::ue_bearer_cfg_t::BOTH;

Loading…
Cancel
Save