Added mux class and packing of msg3

master
David Rupprecht 4 years ago committed by David Rupprecht
parent f90f10f6a8
commit 3af0342418

@ -21,7 +21,7 @@
#include "srslte/interfaces/ue_nr_interfaces.h" #include "srslte/interfaces/ue_nr_interfaces.h"
#include "srslte/mac/mac_sch_pdu_nr.h" #include "srslte/mac/mac_sch_pdu_nr.h"
#include "srslte/srslog/srslog.h" #include "srslte/srslog/srslog.h"
#include "srsue/hdr/stack/mac/mux.h" #include "srsue/hdr/stack/mac_nr/mux_nr.h"
#include "srsue/hdr/stack/ue_stack_base.h" #include "srsue/hdr/stack/ue_stack_base.h"
namespace srsue { namespace srsue {
@ -77,10 +77,11 @@ public:
uint16_t get_c_rnti(); uint16_t get_c_rnti();
void set_c_rnti(uint64_t c_rnti_); void set_c_rnti(uint64_t c_rnti_);
bool msg3_is_transmitted() { return true; } void msg3_flush() { mux.msg3_flush(); }
void msg3_flush() {} bool msg3_is_transmitted() { return mux.msg3_is_transmitted(); }
void msg3_prepare() {} void msg3_prepare() { mux.msg3_prepare(); }
bool msg3_is_empty() { return true; } bool msg3_is_pending() { return mux.msg3_is_pending(); }
bool msg3_is_empty() { return mux.msg3_is_empty(); }
/// stack interface /// stack interface
void process_pdus(); void process_pdus();
@ -140,6 +141,7 @@ private:
// MAC Uplink-related procedures // MAC Uplink-related procedures
proc_ra_nr proc_ra; proc_ra_nr proc_ra;
mux_nr mux;
}; };
} // namespace srsue } // namespace srsue

@ -0,0 +1,46 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 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.
*
*/
#ifndef SRSUE_MUX_NR_H
#define SRSUE_MUX_NR_H
#include "srslte/common/byte_buffer.h"
#include "srslte/common/common.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
namespace srsue {
class mux_nr
{
public:
explicit mux_nr(srslog::basic_logger& logger);
~mux_nr(){};
void reset();
void init();
void step();
void msg3_flush();
void msg3_prepare();
bool msg3_is_transmitted();
bool msg3_is_pending();
bool msg3_is_empty();
private:
srslog::basic_logger& logger;
srslte::unique_byte_buffer_t msg3_buff = nullptr;
typedef enum { none, pending, transmitted } msg3_state_t;
msg3_state_t msg3_state = none;
};
} // namespace srsue
#endif // SRSUE_MUX_NR_H

@ -37,6 +37,8 @@ public:
bool is_rar_opportunity(uint32_t tti); bool is_rar_opportunity(uint32_t tti);
uint16_t get_rar_rnti(); uint16_t get_rar_rnti();
bool has_temp_rnti();
uint16_t get_temp_rnti();
// PHY interfaces // PHY interfaces
void prach_sent(uint32_t tti, uint32_t s_id, uint32_t t_id, uint32_t f_id, uint32_t ul_carrier_id); void prach_sent(uint32_t tti, uint32_t s_id, uint32_t t_id, uint32_t f_id, uint32_t ul_carrier_id);

@ -6,6 +6,6 @@
# the distribution. # the distribution.
# #
set(SOURCES mac_nr.cc proc_ra_nr.cc) set(SOURCES mac_nr.cc proc_ra_nr.cc mux_nr.cc)
add_library(srsue_mac_nr STATIC ${SOURCES}) add_library(srsue_mac_nr STATIC ${SOURCES})
target_link_libraries(srsue_mac_nr srslte_mac) target_link_libraries(srsue_mac_nr srslte_mac)

@ -17,7 +17,7 @@
namespace srsue { namespace srsue {
mac_nr::mac_nr(srslte::ext_task_sched_handle task_sched_) : mac_nr::mac_nr(srslte::ext_task_sched_handle task_sched_) :
task_sched(task_sched_), logger(srslog::fetch_basic_logger("MAC")), proc_ra(logger) task_sched(task_sched_), logger(srslog::fetch_basic_logger("MAC")), proc_ra(logger), mux(logger)
{ {
tx_buffer = srslte::make_byte_buffer(); tx_buffer = srslte::make_byte_buffer();
rlc_buffer = srslte::make_byte_buffer(); rlc_buffer = srslte::make_byte_buffer();
@ -45,6 +45,8 @@ int mac_nr::init(const mac_nr_args_t& args_, phy_interface_mac_nr* phy_, rlc_int
proc_ra.init(phy, this, &task_sched); proc_ra.init(phy, this, &task_sched);
mux.init();
started = true; started = true;
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -104,11 +106,9 @@ mac_interface_phy_nr::sched_rnti_t mac_nr::get_dl_sched_rnti_nr(const uint32_t t
return {proc_ra.get_rar_rnti(), srslte_rnti_type_ra}; return {proc_ra.get_rar_rnti(), srslte_rnti_type_ra};
} }
#if 0
if (proc_ra.has_temp_rnti() && has_crnti() == false) { if (proc_ra.has_temp_rnti() && has_crnti() == false) {
return proc_ra->get_temp_rnti(); return {proc_ra.get_temp_rnti(), srslte_rnti_type_c};
} }
#endif
if (has_crnti()) { if (has_crnti()) {
return {get_crnti(), srslte_rnti_type_c}; return {get_crnti(), srslte_rnti_type_c};
@ -159,7 +159,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 (SRSLTE_RNTI_ISRAR(grant.rnti)) { // TODO: replace with proc_ra->get_rar_rnti() if (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);
@ -219,6 +219,17 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr:
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, true);
if (mux.msg3_is_pending()) {
// If message 3 is pending pack message 3 for uplink transmission
tx_pdu.add_crnti_ce(proc_ra.get_temp_rnti());
srslte::mac_sch_subpdu_nr::lcg_bsr_t sbsr = {};
sbsr.lcg_id = 0;
sbsr.buffer_size = 1;
tx_pdu.add_sbsr_ce(sbsr);
} else {
// 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();
@ -238,6 +249,7 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr:
break; break;
} }
} }
}
// Pack PDU // Pack PDU
tx_pdu.pack(); tx_pdu.pack();

@ -0,0 +1,51 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 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 "srsue/hdr/stack/mac_nr/mux_nr.h"
#include "srslte/common/buffer_pool.h"
namespace srsue {
mux_nr::mux_nr(srslog::basic_logger& logger_) : logger(logger_)
{
msg3_buff = srslte::make_byte_buffer();
};
void mux_nr::init() {}
void mux_nr::msg3_flush()
{
msg3_buff->clear();
msg3_state = msg3_state_t::none;
}
void mux_nr::msg3_prepare()
{
msg3_state = msg3_state_t::pending;
}
bool mux_nr::msg3_is_transmitted()
{
return msg3_state == msg3_state_t::transmitted;
}
bool mux_nr::msg3_is_pending()
{
return msg3_state == msg3_state_t::pending;
}
bool mux_nr::msg3_is_empty()
{
return msg3_buff->N_bytes == 0;
}
} // namespace srsue

@ -93,6 +93,16 @@ uint16_t proc_ra_nr::get_rar_rnti()
return rar_rnti; return rar_rnti;
} }
bool proc_ra_nr::has_temp_rnti()
{
return temp_rnti != SRSLTE_INVALID_RNTI;
}
uint16_t proc_ra_nr::get_temp_rnti()
{
return temp_rnti;
}
void proc_ra_nr::timer_expired(uint32_t timer_id) void proc_ra_nr::timer_expired(uint32_t timer_id)
{ {
if (prach_send_timer.id() == timer_id) { if (prach_send_timer.id() == timer_id) {
@ -228,7 +238,7 @@ void proc_ra_nr::ra_completion()
mac->set_c_rnti(temp_rnti); 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 = 0; temp_rnti = SRSLTE_INVALID_RNTI;
reset(); reset();
} }

Loading…
Cancel
Save