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

@ -99,11 +99,16 @@ public:
void void
write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch) override; 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: private:
static const int MAX_LOCATIONS = 20; static const int MAX_LOCATIONS = 20;
static const uint32_t cfi = 3; static const uint32_t cfi = 3;
srslte_dci_location_t locations[MAX_LOCATIONS] = {}; 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 // We use a rwlock in MAC to allow multiple workers to access MAC simultaneously. No conflicts will happen since
// access for different TTIs // access for different TTIs
pthread_rwlock_t rwlock = {}; pthread_rwlock_t rwlock = {};

@ -212,7 +212,7 @@ private:
uint32_t cfi, uint32_t cfi,
const srslte_dci_dl_t& dci); 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); static bool bearer_is_dl(const ue_bearer_t* lch);
uint32_t get_pending_ul_old_data_unlocked(uint32_t cc_idx); uint32_t get_pending_ul_old_data_unlocked(uint32_t cc_idx);

@ -37,7 +37,10 @@ using namespace asn1::rrc;
namespace srsenb { namespace srsenb {
mac::mac() : 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); pthread_rwlock_init(&rwlock, nullptr);
} }
@ -445,34 +448,38 @@ int mac::sr_detected(uint32_t tti, uint16_t rnti)
return ret; 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) 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); static srslte::mutexed_tprof<srslte::avg_time_stats> rach_tprof("rach_tprof", "MAC", 1);
log_h->step(tti); log_h->step(tti);
uint16_t rnti; auto rach_tprof_meas = rach_tprof.start();
auto rach_tprof_meas = rach_tprof.start();
{ uint16_t rnti = allocate_rnti();
srslte::rwlock_write_guard lock(rwlock);
rnti = last_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())};
// Create new UE // Set PCAP if available
if (ue_db.count(rnti) == 0) { if (pcap != nullptr) {
ue_db[rnti] = ue_ptr->start_pcap(pcap);
std::unique_ptr<ue>{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);
}
// Increase RNTI counter {
last_rnti++; srslte::rwlock_write_guard lock(rwlock);
if (last_rnti >= 60000) { ue_db[rnti] = std::move(ue_ptr);
last_rnti = 70;
}
} }
stack_task_queue.push([this, rnti, tti, enb_cc_idx, preamble_idx, time_adv, rach_tprof_meas]() mutable { 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 || return lch->cfg.direction == sched_interface::ue_bearer_cfg_t::UL ||
lch->cfg.direction == sched_interface::ue_bearer_cfg_t::BOTH; lch->cfg.direction == sched_interface::ue_bearer_cfg_t::BOTH;
@ -1186,8 +1186,8 @@ int sched_ue::cqi_to_tbs(uint32_t cqi,
coderate = srslte_coderate(tbs, nof_re); coderate = srslte_coderate(tbs, nof_re);
srslte_mod_t mod = srslte_mod_t mod =
(is_ul) ? srslte_ra_ul_mod_from_mcs(sel_mcs) : srslte_ra_dl_mod_from_mcs(sel_mcs, use_tbs_index_alt); (is_ul) ? srslte_ra_ul_mod_from_mcs(sel_mcs) : srslte_ra_dl_mod_from_mcs(sel_mcs, use_tbs_index_alt);
Qm = SRSLTE_MIN(max_Qm, srslte_mod_bits_x_symbol(mod)); Qm = SRSLTE_MIN(max_Qm, srslte_mod_bits_x_symbol(mod));
eff_coderate = coderate / Qm; eff_coderate = coderate / Qm;
} while ((sel_mcs > 0 && coderate > max_coderate) || eff_coderate > 0.930); } while ((sel_mcs > 0 && coderate > max_coderate) || eff_coderate > 0.930);
if (mcs != nullptr) { if (mcs != nullptr) {
@ -1217,8 +1217,8 @@ sched_ue_carrier::sched_ue_carrier(const sched_interface::ue_cfg_t& cfg_,
dl_cqi = (ue_cc_idx == 0) ? cell_params->cfg.initial_dl_cqi : 0; dl_cqi = (ue_cc_idx == 0) ? cell_params->cfg.initial_dl_cqi : 0;
// set max mcs // set max mcs
max_mcs_ul = cell_params->sched_cfg->pusch_max_mcs >= 0 ? cell_params->sched_cfg->pusch_max_mcs : 28; max_mcs_ul = cell_params->sched_cfg->pusch_max_mcs >= 0 ? cell_params->sched_cfg->pusch_max_mcs : 28;
max_mcs_dl = cell_params->sched_cfg->pdsch_max_mcs >= 0 ? cell_params->sched_cfg->pdsch_max_mcs : 28; max_mcs_dl = cell_params->sched_cfg->pdsch_max_mcs >= 0 ? cell_params->sched_cfg->pdsch_max_mcs : 28;
max_mcs_dl_alt = max_mcs_dl_alt =
cell_params->sched_cfg->pdsch_max_mcs >= 0 ? SRSLTE_MIN(cell_params->sched_cfg->pdsch_max_mcs, 27) : 27; cell_params->sched_cfg->pdsch_max_mcs >= 0 ? SRSLTE_MIN(cell_params->sched_cfg->pdsch_max_mcs, 27) : 27;
max_aggr_level = cell_params->sched_cfg->max_aggr_level >= 0 ? cell_params->sched_cfg->max_aggr_level : 3; max_aggr_level = cell_params->sched_cfg->max_aggr_level >= 0 ? cell_params->sched_cfg->max_aggr_level : 3;

Loading…
Cancel
Save