mac_nr: tiny cleanups of MAC class, use of new logger

master
Andre Puschmann 4 years ago
parent 73cb0dabf2
commit 1aadc5c53e

@ -14,11 +14,11 @@
#define SRSUE_MAC_NR_H #define SRSUE_MAC_NR_H
#include "srslte/common/block_queue.h" #include "srslte/common/block_queue.h"
#include "srslte/common/logmap.h"
#include "srslte/common/mac_nr_pcap.h" #include "srslte/common/mac_nr_pcap.h"
#include "srslte/interfaces/mac_interface_types.h" #include "srslte/interfaces/mac_interface_types.h"
#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 "srsue/hdr/stack/mac/mux.h" #include "srsue/hdr/stack/mac/mux.h"
#include "srsue/hdr/stack/ue_stack_base.h" #include "srsue/hdr/stack/ue_stack_base.h"
@ -71,13 +71,19 @@ private:
void handle_pdu(srslte::unique_byte_buffer_t pdu); void handle_pdu(srslte::unique_byte_buffer_t pdu);
void get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr::tx_request_t* tx_request); void get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr::tx_request_t* tx_request);
bool is_si_opportunity();
bool is_paging_opportunity();
bool has_crnti();
uint16_t get_crnti();
/// Interaction with rest of the stack /// Interaction with rest of the stack
phy_interface_mac_nr* phy = nullptr; phy_interface_mac_nr* phy = nullptr;
rlc_interface_mac* rlc = nullptr; rlc_interface_mac* rlc = nullptr;
srslte::ext_task_sched_handle task_sched; srslte::ext_task_sched_handle task_sched;
std::unique_ptr<srslte::mac_nr_pcap> pcap = nullptr; std::unique_ptr<srslte::mac_nr_pcap> pcap = nullptr;
srslte::log_ref log_h; srslog::basic_logger& logger;
srslte::byte_buffer_pool* pool = nullptr; srslte::byte_buffer_pool* pool = nullptr;
mac_nr_args_t args = {}; mac_nr_args_t args = {};

@ -11,14 +11,11 @@
*/ */
#include "srsue/hdr/stack/mac_nr/mac_nr.h" #include "srsue/hdr/stack/mac_nr/mac_nr.h"
#include "srslte/common/log_helper.h"
using namespace asn1::rrc;
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_) :
pool(srslte::byte_buffer_pool::get_instance()), log_h("MAC"), task_sched(task_sched_) pool(srslte::byte_buffer_pool::get_instance()), task_sched(task_sched_), logger(srslog::fetch_basic_logger("MAC"))
{ {
tx_buffer = srslte::allocate_unique_buffer(*pool); tx_buffer = srslte::allocate_unique_buffer(*pool);
rlc_buffer = srslte::allocate_unique_buffer(*pool); rlc_buffer = srslte::allocate_unique_buffer(*pool);
@ -63,15 +60,13 @@ void mac_nr::stop()
// Implement Section 5.9 // Implement Section 5.9
void mac_nr::reset() void mac_nr::reset()
{ {
Info("Resetting MAC"); logger.info("Resetting MAC-NR");
} }
void mac_nr::run_tti(const uint32_t tti) void mac_nr::run_tti(const uint32_t tti)
{ {
log_h->step(tti);
// Step all procedures // Step all procedures
Debug("Running MAC tti=%d", tti); logger.debug("Running MAC tti=%d", tti);
} }
uint16_t mac_nr::get_ul_sched_rnti(uint32_t tti) uint16_t mac_nr::get_ul_sched_rnti(uint32_t tti)
@ -79,7 +74,53 @@ uint16_t mac_nr::get_ul_sched_rnti(uint32_t tti)
return crnti; return crnti;
} }
bool mac_nr::is_si_opportunity()
{
// TODO: ask RRC if we need SI
return false;
}
bool mac_nr::is_paging_opportunity()
{
return false;
}
uint16_t mac_nr::get_dl_sched_rnti(uint32_t tti) uint16_t mac_nr::get_dl_sched_rnti(uint32_t tti)
{
// Priority: SI-RNTI, P-RNTI, RA-RNTI, Temp-RNTI, CRNTI
if (is_si_opportunity()) {
return SRSLTE_SIRNTI;
}
if (is_paging_opportunity()) {
return SRSLTE_PRNTI;
}
// TODO: add new RA proc shortly
#if 0
if (proc_ra->is_rar_opportunity()) {
return proc_ra->get_rar_rnti();
}
if (proc_ra->has_temp_rnti() && has_crnti() == false) {
return proc_ra->get_temp_rnti();
}
#endif
if (has_crnti()) {
return get_crnti();
}
// turn off DCI search for this TTI
return SRSLTE_INVALID_RNTI;
}
bool mac_nr::has_crnti()
{
return crnti != SRSLTE_INVALID_RNTI;
}
uint16_t mac_nr::get_crnti()
{ {
return crnti; return crnti;
} }
@ -126,13 +167,11 @@ void mac_nr::tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant)
pcap->write_dl_crnti(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti); pcap->write_dl_crnti(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti);
} }
pdu_queue.push(std::move(grant.tb[i])); pdu_queue.push(std::move(grant.tb[i]));
metrics[cc_idx].rx_pkts++;
} }
} }
stack_task_dispatch_queue.push([this]() { process_pdus(); });
} }
metrics[cc_idx].rx_pkts++;
stack_task_dispatch_queue.push([this]() { process_pdus(); });
} }
void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant) void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant)
@ -165,11 +204,11 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr:
// 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;
log_h->info_hex(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) {
log_h->error("Error packing MAC PDU"); logger.error("Error packing MAC PDU");
} }
} else { } else {
break; break;
@ -179,7 +218,7 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr:
// Pack PDU // Pack PDU
tx_pdu.pack(); tx_pdu.pack();
log_h->info_hex(tx_buffer->msg, tx_buffer->N_bytes, "Generated MAC PDU (%d B)", tx_buffer->N_bytes); logger.info(tx_buffer->msg, tx_buffer->N_bytes, "Generated MAC PDU (%d B)", tx_buffer->N_bytes);
tx_request->data = tx_buffer->msg; tx_request->data = tx_buffer->msg;
tx_request->tb_len = tx_buffer->N_bytes; tx_request->tb_len = tx_buffer->N_bytes;
@ -196,7 +235,7 @@ void mac_nr::timer_expired(uint32_t timer_id)
void mac_nr::setup_lcid(const srslte::logical_channel_config_t& config) void mac_nr::setup_lcid(const srslte::logical_channel_config_t& config)
{ {
Info("Logical Channel Setup: LCID=%d, LCG=%d, priority=%d, PBR=%d, BSD=%dms, bucket_size=%d", logger.info("Logical Channel Setup: LCID=%d, LCG=%d, priority=%d, PBR=%d, BSD=%dms, bucket_size=%d",
config.lcid, config.lcid,
config.lcg, config.lcg,
config.priority, config.priority,
@ -209,14 +248,14 @@ void mac_nr::setup_lcid(const srslte::logical_channel_config_t& config)
void mac_nr::set_config(const srslte::bsr_cfg_t& bsr_cfg) void mac_nr::set_config(const srslte::bsr_cfg_t& bsr_cfg)
{ {
Info("BSR config periodic timer %d retx timer %d", bsr_cfg.periodic_timer, bsr_cfg.retx_timer); logger.info("BSR config periodic timer %d retx timer %d", bsr_cfg.periodic_timer, bsr_cfg.retx_timer);
Warning("Not handling BSR config yet"); logger.warning("Not handling BSR config yet");
} }
void mac_nr::set_config(const srslte::sr_cfg_t& sr_cfg) void mac_nr::set_config(const srslte::sr_cfg_t& sr_cfg)
{ {
Info("Scheduling Request Config DSR tansmax %d", sr_cfg.dsr_transmax); logger.info("Scheduling Request Config DSR tansmax %d", sr_cfg.dsr_transmax);
Warning("Not Scheduling Request Config yet"); logger.warning("Not Scheduling Request Config yet");
} }
void mac_nr::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]) {} void mac_nr::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]) {}
@ -235,14 +274,14 @@ void mac_nr::process_pdus()
void mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu) void mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu)
{ {
log_h->info_hex(pdu->msg, pdu->N_bytes, "Handling MAC PDU (%d B)", pdu->N_bytes); logger.info(pdu->msg, pdu->N_bytes, "Handling MAC PDU (%d B)", pdu->N_bytes);
rx_pdu.init_rx(); rx_pdu.init_rx();
rx_pdu.unpack(pdu->msg, pdu->N_bytes); rx_pdu.unpack(pdu->msg, pdu->N_bytes);
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);
log_h->info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d", logger.info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d",
i, i,
rx_pdu.get_num_subpdus(), rx_pdu.get_num_subpdus(),
subpdu.get_lcid(), subpdu.get_lcid(),

Loading…
Cancel
Save