SRSUE NR: use correct rnti in rar and make NR proc ra

master
David Rupprecht 4 years ago committed by David Rupprecht
parent 6ba9f8fd41
commit f6f6ee406b

@ -68,7 +68,6 @@ int gnb_stack_nr::init(const srsenb::stack_args_t& args_, const rrc_nr_cfg_t& rr
mac_args.sched = args.mac.sched; mac_args.sched = args.mac.sched;
mac_args.tb_size = args.mac.nr_tb_size; mac_args.tb_size = args.mac.nr_tb_size;
mac_args.rnti = args.coreless.rnti; mac_args.rnti = args.coreless.rnti;
mac_args.drb_lcid = args.coreless.drb_lcid;
m_mac->init(mac_args, phy, this, m_rlc.get(), m_rrc.get()); m_mac->init(mac_args, phy, this, m_rlc.get(), m_rrc.get());
srslte::logmap::get("RLC")->set_level(args.log.rlc_level); srslte::logmap::get("RLC")->set_level(args.log.rlc_level);

@ -229,9 +229,7 @@ int mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu)
subpdu.get_lcid(), subpdu.get_lcid(),
subpdu.get_sdu_length()); subpdu.get_sdu_length());
if (subpdu.get_lcid() == args.drb_lcid) { // rlc_h->write_pdu(args.rnti, subpdu.get_lcid(), subpdu.get_sdu(), subpdu.get_sdu_length());
rlc_h->write_pdu(args.rnti, subpdu.get_lcid(), subpdu.get_sdu(), subpdu.get_sdu_length());
}
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }

@ -28,8 +28,6 @@ namespace srsue {
struct mac_nr_args_t { struct mac_nr_args_t {
srsue::pcap_args_t pcap; srsue::pcap_args_t pcap;
// TODO: remove temp variable
uint32_t drb_lcid;
}; };
class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr, public mac_interface_proc_ra_nr class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr, public mac_interface_proc_ra_nr

@ -31,6 +31,7 @@ public:
void msg3_flush(); void msg3_flush();
void msg3_prepare(); void msg3_prepare();
void msg3_transmitted();
bool msg3_is_transmitted(); bool msg3_is_transmitted();
bool msg3_is_pending(); bool msg3_is_pending();
bool msg3_is_empty(); bool msg3_is_empty();

@ -36,6 +36,7 @@ public:
bool is_contention_resolution(); bool is_contention_resolution();
bool is_rar_opportunity(uint32_t tti); bool is_rar_opportunity(uint32_t tti);
bool has_rar_rnti();
uint16_t get_rar_rnti(); uint16_t get_rar_rnti();
bool has_temp_rnti(); bool has_temp_rnti();
uint16_t get_temp_rnti(); uint16_t get_temp_rnti();

@ -107,10 +107,12 @@ mac_interface_phy_nr::sched_rnti_t mac_nr::get_dl_sched_rnti_nr(const uint32_t t
} }
if (proc_ra.has_temp_rnti() && has_crnti() == false) { if (proc_ra.has_temp_rnti() && has_crnti() == false) {
logger.debug("SCHED: Searching temp C-RNTI=0x%x (proc_ra)", proc_ra.get_temp_rnti());
return {proc_ra.get_temp_rnti(), srslte_rnti_type_c}; return {proc_ra.get_temp_rnti(), srslte_rnti_type_c};
} }
if (has_crnti()) { if (has_crnti()) {
logger.debug("SCHED: Searching C-RNTI=0x%x", get_crnti());
return {get_crnti(), srslte_rnti_type_c}; return {get_crnti(), srslte_rnti_type_c};
} }
@ -159,7 +161,7 @@ void mac_nr::write_pcap(const uint32_t cc_idx, mac_nr_grant_dl_t& grant)
if (pcap) { if (pcap) {
for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; ++i) { for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; ++i) {
if (grant.tb[i] != nullptr) { if (grant.tb[i] != nullptr) {
if (grant.rnti == proc_ra.get_rar_rnti()) { if (proc_ra.has_rar_rnti() && grant.rnti == proc_ra.get_rar_rnti()) {
pcap->write_dl_ra_rnti_nr(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti); pcap->write_dl_ra_rnti_nr(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti);
} else if (grant.rnti == SRSLTE_PRNTI) { } else if (grant.rnti == SRSLTE_PRNTI) {
pcap->write_dl_pch_nr(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti); pcap->write_dl_pch_nr(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti);
@ -183,7 +185,7 @@ void mac_nr::tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant)
{ {
write_pcap(cc_idx, grant); write_pcap(cc_idx, grant);
// handle PDU // handle PDU
if (grant.rnti == proc_ra.get_rar_rnti()) { if (proc_ra.has_rar_rnti() && grant.rnti == proc_ra.get_rar_rnti()) {
proc_ra.handle_rar_pdu(grant); proc_ra.handle_rar_pdu(grant);
} else { } else {
// Push DL PDUs to queue for back-ground processing // Push DL PDUs to queue for back-ground processing
@ -200,6 +202,10 @@ void mac_nr::tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant)
void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, srslte::byte_buffer_t* phy_tx_pdu) void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, srslte::byte_buffer_t* phy_tx_pdu)
{ {
// if proc ra is in contention resolution and c_rnti == grant.c_rnti resolve contention resolution
if (proc_ra.is_contention_resolution() && grant.rnti == c_rnti) {
proc_ra.pdcch_to_crnti();
}
get_ul_data(grant, phy_tx_pdu); get_ul_data(grant, phy_tx_pdu);
metrics[cc_idx].tx_pkts++; metrics[cc_idx].tx_pkts++;
@ -209,34 +215,36 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, srslte::byte_buffer_t*
{ {
// initialize MAC PDU // initialize MAC PDU
tx_buffer->clear(); tx_buffer->clear();
tx_pdu.init_tx(tx_buffer.get(), grant.tbs, true); tx_pdu.init_tx(tx_buffer.get(), grant.tbs / 8U, true);
if (mux.msg3_is_pending()) { if (mux.msg3_is_pending()) {
// If message 3 is pending pack message 3 for uplink transmission // If message 3 is pending pack message 3 for uplink transmission
tx_pdu.add_crnti_ce(proc_ra.get_temp_rnti()); // Use the CRNTI which is provided in the RRC reconfiguration (only for DC mode maybe other)
tx_pdu.add_crnti_ce(c_rnti);
srslte::mac_sch_subpdu_nr::lcg_bsr_t sbsr = {}; srslte::mac_sch_subpdu_nr::lcg_bsr_t sbsr = {};
sbsr.lcg_id = 0; sbsr.lcg_id = 0;
sbsr.buffer_size = 1; sbsr.buffer_size = 1;
tx_pdu.add_sbsr_ce(sbsr); tx_pdu.add_sbsr_ce(sbsr);
logger.info("Generated msg3 with RNTI 0x%x", c_rnti);
mux.msg3_transmitted();
} else { } else {
// Pack normal UL data PDU // Pack normal UL data PDU
while (tx_pdu.get_remaing_len() >= MIN_RLC_PDU_LEN) { while (tx_pdu.get_remaing_len() >= MIN_RLC_PDU_LEN) {
// read RLC PDU // read RLC PDU
rlc_buffer->clear(); rlc_buffer->clear();
uint8_t* rd = rlc_buffer->msg; uint8_t* rd = rlc_buffer->msg;
int pdu_len = rlc->read_pdu(args.drb_lcid, rd, tx_pdu.get_remaing_len() - 2); int pdu_len = 0;
// pdu_len = rlc->read_pdu(args.drb_lcid, rd, tx_pdu.get_remaing_len() - 2);
// Add SDU if RLC has something to tx // Add SDU if RLC has something to tx
if (pdu_len > 0) { if (pdu_len > 0) {
rlc_buffer->N_bytes = pdu_len; // rlc_buffer->N_bytes = pdu_len;
logger.info(rlc_buffer->msg, rlc_buffer->N_bytes, "Read %d B from RLC", rlc_buffer->N_bytes); // logger.info(rlc_buffer->msg, rlc_buffer->N_bytes, "Read %d B from RLC", rlc_buffer->N_bytes);
// add to MAC PDU and pack // // add to MAC PDU and pack
if (tx_pdu.add_sdu(args.drb_lcid, rlc_buffer->msg, rlc_buffer->N_bytes) != SRSLTE_SUCCESS) { // if (tx_pdu.add_sdu(args.drb_lcid, rlc_buffer->msg, rlc_buffer->N_bytes) != SRSLTE_SUCCESS) {
logger.error("Error packing MAC PDU"); // logger.error("Error packing MAC PDU");
} // }
} else { } else {
break; break;
} }
@ -341,16 +349,15 @@ void mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu)
for (uint32_t i = 0; i < rx_pdu.get_num_subpdus(); ++i) { for (uint32_t i = 0; i < rx_pdu.get_num_subpdus(); ++i) {
srslte::mac_sch_subpdu_nr subpdu = rx_pdu.get_subpdu(i); srslte::mac_sch_subpdu_nr subpdu = rx_pdu.get_subpdu(i);
logger.info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d", logger.info("Handling subPDU %d/%d: rnti=0x%x lcid=%d, sdu_len=%d",
i, i,
rx_pdu.get_num_subpdus(), rx_pdu.get_num_subpdus(),
subpdu.get_c_rnti(),
subpdu.get_lcid(), subpdu.get_lcid(),
subpdu.get_sdu_length()); subpdu.get_sdu_length());
if (subpdu.get_lcid() == args.drb_lcid) { // rlc->write_pdu(subpdu.get_lcid(), subpdu.get_sdu(), subpdu.get_sdu_length());
rlc->write_pdu(subpdu.get_lcid(), subpdu.get_sdu(), subpdu.get_sdu_length()); }
}
}
} }
uint64_t mac_nr::get_contention_id() uint64_t mac_nr::get_contention_id()

@ -33,6 +33,11 @@ void mux_nr::msg3_prepare()
msg3_state = msg3_state_t::pending; msg3_state = msg3_state_t::pending;
} }
void mux_nr::msg3_transmitted()
{
msg3_state = msg3_state_t::transmitted;
}
bool mux_nr::msg3_is_transmitted() bool mux_nr::msg3_is_transmitted()
{ {
return msg3_state == msg3_state_t::transmitted; return msg3_state == msg3_state_t::transmitted;

@ -93,6 +93,14 @@ uint16_t proc_ra_nr::get_rar_rnti()
return rar_rnti; return rar_rnti;
} }
bool proc_ra_nr::has_rar_rnti()
{
if (rar_rnti != SRSLTE_INVALID_RNTI) {
return true;
}
return false;
}
bool proc_ra_nr::has_temp_rnti() bool proc_ra_nr::has_temp_rnti()
{ {
return temp_rnti != SRSLTE_INVALID_RNTI; return temp_rnti != SRSLTE_INVALID_RNTI;
@ -239,7 +247,6 @@ void proc_ra_nr::ra_completion()
srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_COMPLETION)); srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_COMPLETION));
return; return;
} }
mac->set_c_rnti(temp_rnti);
srslte::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", mac->get_c_rnti(), current_ta); srslte::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", mac->get_c_rnti(), current_ta);
logger.info("Random Access Complete. c-rnti=0x%x, ta=%d", mac->get_c_rnti(), current_ta); logger.info("Random Access Complete. c-rnti=0x%x, ta=%d", mac->get_c_rnti(), current_ta);
temp_rnti = SRSLTE_INVALID_RNTI; temp_rnti = SRSLTE_INVALID_RNTI;

@ -66,7 +66,6 @@ int ue_stack_nr::init(const stack_args_t& args_)
mac_nr_args_t mac_args = {}; mac_nr_args_t mac_args = {};
mac_args.pcap = args.pcap; mac_args.pcap = args.pcap;
mac_args.drb_lcid = 4;
mac->init(mac_args, phy, rlc.get()); mac->init(mac_args, phy, rlc.get());
rlc->init(pdcp.get(), rrc.get(), task_sched.get_timer_handler(), 0 /* RB_ID_SRB0 */); rlc->init(pdcp.get(), rrc.get(), task_sched.get_timer_handler(), 0 /* RB_ID_SRB0 */);
pdcp->init(rlc.get(), rrc.get(), gw); pdcp->init(rlc.get(), rrc.get(), gw);

Loading…
Cancel
Save