Wrote logging functions for SCHED MAC CE/LCID allocations

master
Francisco 4 years ago committed by Andre Puschmann
parent c1fb161004
commit 0ffea62411

@ -48,6 +48,7 @@ enum class dl_sch_lcid {
PADDING = 0b11111
};
const char* to_string(dl_sch_lcid v);
const char* to_string_short(dl_sch_lcid v);
uint32_t ce_size(dl_sch_lcid v);
uint32_t ce_subheader_size(dl_sch_lcid v);
uint32_t ce_total_size(dl_sch_lcid v);

@ -40,6 +40,28 @@ namespace srslte {
* DL-SCH LCID
*************************/
const char* to_string_short(dl_sch_lcid v)
{
switch (v) {
case dl_sch_lcid::CCCH:
return "CCCH";
case dl_sch_lcid::SCELL_ACTIVATION_4_OCTET:
return "SCellAct4";
case dl_sch_lcid::SCELL_ACTIVATION:
return "SCellAct";
case dl_sch_lcid::CON_RES_ID:
return "ConResId";
case dl_sch_lcid::TA_CMD:
return "TA_CMD";
case dl_sch_lcid::DRX_CMD:
return "DRX_CMD";
case dl_sch_lcid::PADDING:
return "PAD";
default:
return "Unrecognized LCID";
}
}
const char* to_string(dl_sch_lcid v)
{
switch (v) {

@ -0,0 +1,34 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSLTE_SCHED_INTERFACE_HELPERS_H
#define SRSLTE_SCHED_INTERFACE_HELPERS_H
#include "srslte/interfaces/sched_interface.h"
#include "srslte/common/logmap.h"
namespace srsenb {
void log_dl_cc_results(srslte::log_ref log_h, uint32_t enb_cc_idx, const sched_interface::dl_sched_res_t& result);
}
#endif // SRSLTE_SCHED_INTERFACE_HELPERS_H

@ -90,6 +90,17 @@ private:
uint32_t
allocate_mac_sdus(sched_interface::dl_sched_data_t* data, lch_manager& lch_handler, uint32_t total_tbs, uint32_t tbidx);
/**
* Allocate space for pending MAC CEs
* @param data struct where the MAC CEs allocations are stored
* @param total_tbs available space in bytes for allocations
* @return number of bytes allocated
*/
uint32_t allocate_mac_ces(sched_interface::dl_sched_data_t* data,
lch_manager& lch_handler,
uint32_t total_tbs,
uint32_t ue_cc_idx);
} // namespace srsenb
#endif // SRSLTE_SCHED_LCH_H

@ -211,7 +211,6 @@ private:
void check_ue_cfg_correctness() const;
bool is_sr_triggered();
uint32_t allocate_mac_ces(sched_interface::dl_sched_data_t* data, uint32_t total_tbs, uint32_t ue_cc_idx);
std::pair<int, int> allocate_new_dl_mac_pdu(sched_interface::dl_sched_data_t* data,
dl_harq_proc* h,
const rbgmask_t& user_mask,

@ -18,7 +18,8 @@
# and at http://www.gnu.org/licenses/.
#
set(SOURCES mac.cc ue.cc sched.cc sched_carrier.cc sched_grid.cc sched_harq.cc sched_metric.cc sched_ue.cc sched_lch.cc)
set(SOURCES mac.cc ue.cc sched.cc sched_carrier.cc sched_grid.cc sched_harq.cc sched_metric.cc sched_ue.cc
sched_lch.cc sched_interface_helpers.cc)
add_library(srsenb_mac STATIC ${SOURCES})
if(ENABLE_5GNR)

@ -23,6 +23,7 @@
#include "srsenb/hdr/stack/mac/sched_metric.h"
#include "srslte/common/log_helper.h"
#include "srslte/common/logmap.h"
#include "srsenb/hdr/stack/mac/sched_interface_helpers.h"
namespace srsenb {
@ -138,9 +139,7 @@ void bc_sched::reset()
*******************************************************/
ra_sched::ra_sched(const sched_cell_params_t& cfg_, std::map<uint16_t, sched_ue>& ue_db_) :
cc_cfg(&cfg_),
log_h(srslte::logmap::get("MAC")),
ue_db(&ue_db_)
cc_cfg(&cfg_), log_h(srslte::logmap::get("MAC")), ue_db(&ue_db_)
{}
// Schedules RAR
@ -356,6 +355,8 @@ const cc_sched_result& sched::carrier_sched::generate_tti_result(tti_point tti_r
user.second.finish_tti(cc_result->tti_params, enb_cc_idx);
}
log_dl_cc_results(log_h, enb_cc_idx, cc_result->dl_sched_result);
return *cc_result;
}

@ -0,0 +1,131 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include "srsenb/hdr/stack/mac/sched_interface_helpers.h"
#include "srslte/mac/pdu.h"
#include "srslte/srslog/bundled/fmt/format.h"
#include <array>
namespace srsenb {
using dl_sched_res_t = sched_interface::dl_sched_res_t;
using dl_sched_data_t = sched_interface::dl_sched_data_t;
using custom_mem_buffer = fmt::basic_memory_buffer<char, 1024>;
const char* to_string_short(srslte_dci_format_t dcifmt)
{
switch (dcifmt) {
case SRSLTE_DCI_FORMAT0:
return "0";
case SRSLTE_DCI_FORMAT1:
return "1";
case SRSLTE_DCI_FORMAT1A:
return "1A";
case SRSLTE_DCI_FORMAT1B:
return "1B";
case SRSLTE_DCI_FORMAT2:
return "2";
case SRSLTE_DCI_FORMAT2A:
return "2A";
case SRSLTE_DCI_FORMAT2B:
return "2B";
default:
return "unknown";
}
}
void fill_dl_cc_result_info(custom_mem_buffer& strbuf, const dl_sched_data_t& data)
{
uint32_t first_ce = sched_interface::MAX_RLC_PDU_LIST;
for (uint32_t i = 0; i < data.nof_pdu_elems[0]; ++i) {
if (srslte::is_mac_ce(static_cast<srslte::dl_sch_lcid>(data.pdu[i]->lcid))) {
first_ce = i;
break;
}
}
if (first_ce == sched_interface::MAX_RLC_PDU_LIST) {
return;
}
const char* prefix = strbuf.size() > 0 ? " | " : "";
fmt::format_to(strbuf, "{}rnti={:0x}: [", prefix, data.dci.rnti);
bool ces_found = false;
for (uint32_t i = 0; i < data.nof_pdu_elems[0]; ++i) {
const auto& pdu = data.pdu[0][i];
prefix = (ces_found) ? " | " : "";
srslte::dl_sch_lcid lcid = static_cast<srslte::dl_sch_lcid>(pdu.lcid);
if (srslte::is_mac_ce(lcid)) {
fmt::format_to(strbuf, "{}MAC CE \"{}\"", prefix, srslte::to_string_short(lcid));
ces_found = true;
}
}
fmt::format_to(strbuf, "]");
}
void fill_dl_cc_result_debug(custom_mem_buffer& strbuf, const dl_sched_data_t& data)
{
if (data.nof_pdu_elems[0] == 0 and data.nof_pdu_elems[1] == 0) {
return;
}
fmt::format_to(strbuf,
" > rnti={:0x}, tbs={}, f={}, mcs={}: [",
data.dci.rnti,
data.tbs[0],
to_string_short(data.dci.format),
data.dci.tb[0].mcs_idx);
for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; ++tb) {
for (uint32_t i = 0; i < data.nof_pdu_elems[tb]; ++i) {
const auto& pdu = data.pdu[tb][i];
const char* prefix = (i == 0) ? "" : " | ";
srslte::dl_sch_lcid lcid = static_cast<srslte::dl_sch_lcid>(pdu.lcid);
if (srslte::is_mac_ce(lcid)) {
fmt::format_to(strbuf, "{}MAC CE \"{}\"", prefix, srslte::to_string_short(lcid));
} else {
fmt::format_to(strbuf, "{}MAC SDU lcid={}, tb={}, len={} B", prefix, pdu.lcid, tb, pdu.nbytes);
}
}
}
fmt::format_to(strbuf, "]\n");
}
void log_dl_cc_results(srslte::log_ref log_h, uint32_t enb_cc_idx, const sched_interface::dl_sched_res_t& result)
{
if (log_h->get_level() < srslte::LOG_LEVEL_INFO) {
return;
}
custom_mem_buffer strbuf;
for (uint32_t i = 0; i < result.nof_data_elems; ++i) {
const dl_sched_data_t& data = result.data[i];
if (log_h->get_level() == srslte::LOG_LEVEL_INFO) {
fill_dl_cc_result_info(strbuf, data);
} else if (log_h->get_level() == srslte::LOG_LEVEL_DEBUG) {
fill_dl_cc_result_debug(strbuf, data);
}
}
if (strbuf.size() != 0) {
if (log_h->get_level() == srslte::LOG_LEVEL_DEBUG) {
log_h->debug("SCHED: MAC LCID allocs cc=%d:\n%s", enb_cc_idx, fmt::to_string(strbuf).c_str());
} else {
log_h->info("SCHED: MAC CE allocs cc=%d: %s", enb_cc_idx, fmt::to_string(strbuf).c_str());
}
}
}
} // namespace srsenb

@ -220,7 +220,6 @@ int lch_manager::alloc_rlc_pdu(sched_interface::dl_sched_pdu_t* rlc_pdu, int rem
if (alloc_bytes > 0) {
rlc_pdu->nbytes = alloc_bytes;
rlc_pdu->lcid = lcid;
Debug("SCHED: Allocated lcid=%d, nbytes=%d, tbs_bytes=%d\n", rlc_pdu->lcid, rlc_pdu->nbytes, rem_bytes);
}
return alloc_bytes;
}
@ -322,4 +321,27 @@ allocate_mac_sdus(sched_interface::dl_sched_data_t* data, lch_manager& lch_handl
return total_tbs - rem_tbs;
}
uint32_t allocate_mac_ces(sched_interface::dl_sched_data_t* data,
lch_manager& lch_handler,
uint32_t total_tbs,
uint32_t ue_cc_idx)
{
if (ue_cc_idx != 0) {
return 0;
}
int rem_tbs = total_tbs;
while (not lch_handler.pending_ces.empty() and data->nof_pdu_elems[0] < sched_interface::MAX_RLC_PDU_LIST) {
int toalloc = srslte::ce_total_size(lch_handler.pending_ces.front());
if (rem_tbs < toalloc) {
break;
}
data->pdu[0][data->nof_pdu_elems[0]].lcid = (uint32_t)lch_handler.pending_ces.front();
data->nof_pdu_elems[0]++;
rem_tbs -= toalloc;
lch_handler.pending_ces.pop_front();
}
return total_tbs - rem_tbs;
}
} // namespace srsenb

@ -453,33 +453,6 @@ void sched_ue::tpc_dec()
*
*******************************************************/
/**
* Allocate space for pending MAC CEs
* @param data struct where the MAC CEs allocations are stored
* @param total_tbs available space in bytes for allocations
* @return number of bytes allocated
*/
uint32_t sched_ue::allocate_mac_ces(sched_interface::dl_sched_data_t* data, uint32_t total_tbs, uint32_t ue_cc_idx)
{
if (ue_cc_idx != 0) {
return 0;
}
int rem_tbs = total_tbs;
while (not lch_handler.pending_ces.empty() and data->nof_pdu_elems[0] < sched_interface::MAX_RLC_PDU_LIST) {
int toalloc = srslte::ce_total_size(lch_handler.pending_ces.front());
if (rem_tbs < toalloc) {
break;
}
data->pdu[0][data->nof_pdu_elems[0]].lcid = (uint32_t)lch_handler.pending_ces.front();
data->nof_pdu_elems[0]++;
rem_tbs -= toalloc;
Info("SCHED: Added a MAC %s CE for rnti=0x%x\n", srslte::to_string(lch_handler.pending_ces.front()), rnti);
lch_handler.pending_ces.pop_front();
}
return total_tbs - rem_tbs;
}
/**
* Allocate space
* @param data
@ -504,13 +477,12 @@ std::pair<int, int> sched_ue::allocate_new_dl_mac_pdu(sched::dl_sched_data_t* da
// Allocate MAC PDU (subheaders, CEs, and SDUS)
int rem_tbs = tbs;
rem_tbs -= allocate_mac_ces(data, rem_tbs, ue_cc_idx);
rem_tbs -= allocate_mac_ces(data, lch_handler, rem_tbs, ue_cc_idx);
rem_tbs -= allocate_mac_sdus(data, lch_handler, rem_tbs, tb);
// Allocate DL UE Harq
if (rem_tbs != tbs) {
h->new_tx(user_mask, tb, tti_tx_dl, mcs, tbs, data->dci.location.ncce, get_ue_cfg().maxharq_tx);
Debug("SCHED: Alloc DCI format%s new mcs=%d, tbs=%d, nof_prb=%d\n", dci_format, mcs, tbs, nof_prb);
} else {
Warning("SCHED: Failed to allocate DL harq pid=%d\n", h->get_id());
}
@ -699,10 +671,7 @@ int sched_ue::generate_format2a(uint32_t pid,
int tbs = 0;
if (!h->is_empty(tb)) {
h->new_retx(user_mask, tb, tti_tx_dl, &mcs, &tbs, data->dci.location.ncce);
Debug("SCHED: Alloc format2/2a previous mcs=%d, tbs=%d\n", mcs, tbs);
} else if (tb_en[tb] && req_bytes > 0 && no_retx) {
auto ret = allocate_new_dl_mac_pdu(data, h, user_mask, tti_tx_dl, ue_cc_idx, cfi, tb, "2/2a");
tbs = ret.first;

Loading…
Cancel
Save