sched,nr: implemented basic UE buffer status manager

master
Francisco Paisana 3 years ago
parent 2fb2598f8c
commit de06dbc684

@ -0,0 +1,37 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 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 SRSRAN_SCHED_CONFIG_H
#define SRSRAN_SCHED_CONFIG_H
#include <cstdint>
namespace srsenb {
/**
* Structure used in UE logical channel configuration
*/
struct logical_channel_cfg_t {
enum direction_t { IDLE = 0, UL, DL, BOTH } direction = IDLE;
int priority = 1; // channel priority (1 is highest)
uint32_t bsd = 1000; // msec
uint32_t pbr = -1; // prioritised bit rate
int group = 0; // logical channel group
bool is_active() const { return direction != IDLE; }
bool is_dl() const { return direction == DL or direction == BOTH; }
bool is_ul() const { return direction == UL or direction == BOTH; }
};
} // namespace srsenb
#endif // SRSRAN_SCHED_CONFIG_H

@ -16,6 +16,7 @@
#include "sched_nr_cfg.h"
#include "sched_nr_harq.h"
#include "sched_nr_interface.h"
#include "sched_nr_ue_buffer_manager.h"
#include "srsran/adt/circular_map.h"
#include "srsran/adt/move_callback.h"
#include "srsran/adt/pool/cached_alloc.h"
@ -88,6 +89,7 @@ public:
const ue_cfg_t& cfg() const { return ue_cfg; }
void ul_sr_info(slot_point slot_rx) { pending_sr = true; }
void ul_bsr(uint32_t lcg, uint32_t bsr_val) { buffers.ul_bsr(lcg, bsr_val); }
bool has_ca() const { return ue_cfg.carriers.size() > 1; }
uint32_t pcell_cc() const { return ue_cfg.carriers[0].cc; }
@ -99,6 +101,7 @@ private:
const sched_params& sched_cfg;
bool pending_sr = false;
ue_buffer_manager buffers;
ue_cfg_t ue_cfg;
};

@ -0,0 +1,66 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 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 SRSRAN_SCHED_NR_UE_BUFFER_MANAGER_H
#define SRSRAN_SCHED_NR_UE_BUFFER_MANAGER_H
#include "srsenb/hdr/stack/mac/common/sched_config.h"
#include "srsran/srslog/srslog.h"
#include "srsran/support/srsran_assert.h"
namespace srsenb {
namespace sched_nr_impl {
class ue_buffer_manager
{
const static uint32_t MAX_LCG_ID = 7;
const static uint32_t MAX_LC_ID = 32;
const static uint32_t MAX_SRB_LC_ID = 3;
public:
explicit ue_buffer_manager(srslog::basic_logger& logger_);
// Configuration getters
bool is_channel_active(uint32_t lcid) const { return get_cfg(lcid).is_active(); }
bool is_bearer_ul(uint32_t lcid) const { return get_cfg(lcid).is_ul(); }
bool is_bearer_dl(uint32_t lcid) const { return get_cfg(lcid).is_dl(); }
const logical_channel_cfg_t& get_cfg(uint32_t lcid) const
{
srsran_assert(lcid < MAX_LC_ID, "Provided LCID=%d is above limit=%d", lcid, MAX_LC_ID);
return channels[lcid].cfg;
}
// Buffer Status update
void ul_bsr(uint32_t lcg_id, uint32_t val);
void dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue);
// UL BSR methods
bool is_lcg_active(uint32_t lcg) const;
int get_bsr(uint32_t lcg) const;
private:
srslog::basic_logger& logger;
struct logical_channel {
logical_channel_cfg_t cfg;
int buf_tx = 0;
int buf_retx = 0;
};
std::array<logical_channel, MAX_LC_ID> channels;
std::array<int, MAX_LCG_ID> lcg_bsr{0};
};
} // namespace sched_nr_impl
} // namespace srsenb
#endif // SRSRAN_SCHED_NR_UE_BUFFER_MANAGER_H

@ -19,6 +19,7 @@ set(SOURCES mac_nr.cc
sched_nr_cell.cc
sched_nr_rb.cc
sched_nr_time_rr.cc
harq_softbuffer.cc)
harq_softbuffer.cc
sched_nr_ue_buffer_manager.cc)
add_library(srsgnb_mac STATIC ${SOURCES})

@ -12,6 +12,7 @@
#include "srsenb/hdr/stack/mac/nr/sched_nr_ue.h"
#include "srsenb/hdr/stack/mac/nr/sched_nr_pdcch.h"
#include "srsran/common/string_helpers.h"
namespace srsenb {
namespace sched_nr_impl {
@ -83,7 +84,7 @@ slot_ue ue_carrier::try_reserve(slot_point pdcch_slot)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ue::ue(uint16_t rnti_, const ue_cfg_t& cfg, const sched_params& sched_cfg_) :
rnti(rnti_), sched_cfg(sched_cfg_), ue_cfg(cfg)
rnti(rnti_), sched_cfg(sched_cfg_), ue_cfg(cfg), buffers(srslog::fetch_basic_logger(sched_cfg_.sched_cfg.logger_name))
{
for (uint32_t cc = 0; cc < cfg.carriers.size(); ++cc) {
if (cfg.carriers[cc].active) {

@ -0,0 +1,70 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 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 "srsenb/hdr/stack/mac/nr/sched_nr_ue_buffer_manager.h"
#include "srsran/common/string_helpers.h"
#include "srsran/srslog/bundled/fmt/format.h"
#include "srsran/srslog/bundled/fmt/ranges.h"
namespace srsenb {
namespace sched_nr_impl {
ue_buffer_manager::ue_buffer_manager(srslog::basic_logger& logger_) : logger(logger_) {}
bool ue_buffer_manager::is_lcg_active(uint32_t lcg) const
{
if (lcg == 0) {
return true;
}
for (uint32_t lcid = 0; lcid < MAX_LC_ID; ++lcid) {
if (is_bearer_ul(lcid) and channels[lcid].cfg.group == (int)lcg) {
return true;
}
}
return false;
}
int ue_buffer_manager::get_bsr(uint32_t lcg) const
{
return is_lcg_active(lcg) ? lcg_bsr[lcg] : 0;
}
void ue_buffer_manager::ul_bsr(uint32_t lcg_id, uint32_t val)
{
srsran_assert(lcg_id < MAX_LCG_ID, "Provided LCG_ID=%d is above its limit=%d", lcg_id, MAX_LCG_ID);
lcg_bsr[lcg_id] = val;
if (logger.debug.enabled()) {
fmt::memory_buffer str_buffer;
fmt::format_to(str_buffer, "{}", lcg_bsr);
logger.debug("SCHED: lcg_id=%d, bsr=%s. Current state=%s", lcg_id, val, srsran::to_c_str(str_buffer));
}
}
void ue_buffer_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue)
{
if (lcid >= MAX_LC_ID) {
logger.warning("The provided lcid=%d is not valid", lcid);
return;
}
if (lcid <= MAX_SRB_LC_ID and
(channels[lcid].buf_tx != (int)tx_queue or channels[lcid].buf_retx != (int)retx_queue)) {
logger.info("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue);
} else {
logger.debug("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue);
}
channels[lcid].buf_retx = retx_queue;
channels[lcid].buf_tx = tx_queue;
}
} // namespace sched_nr_impl
} // namespace srsenb
Loading…
Cancel
Save