mirror of https://github.com/pvnis/srsRAN_4G.git
sched,nr: implemented basic UE buffer status manager
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
|
@ -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
|
@ -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…
Reference in New Issue