mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
169 lines
4.9 KiB
C
169 lines
4.9 KiB
C
3 years ago
|
/**
|
||
|
*
|
||
|
* \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_HARQ_H
|
||
|
#define SRSRAN_SCHED_NR_HARQ_H
|
||
|
|
||
3 years ago
|
#include "sched_nr_cfg.h"
|
||
3 years ago
|
#include "srsgnb/hdr/stack/mac/harq_softbuffer.h"
|
||
3 years ago
|
#include "srsran/common/slot_point.h"
|
||
3 years ago
|
#include <array>
|
||
|
|
||
|
namespace srsenb {
|
||
|
namespace sched_nr_impl {
|
||
|
|
||
3 years ago
|
class harq_proc
|
||
3 years ago
|
{
|
||
|
public:
|
||
3 years ago
|
explicit harq_proc(uint32_t id_) : pid(id_) {}
|
||
3 years ago
|
|
||
3 years ago
|
bool empty() const
|
||
|
{
|
||
3 years ago
|
return std::all_of(tb.begin(), tb.end(), [](const tb_t& t) { return not t.active; });
|
||
3 years ago
|
}
|
||
3 years ago
|
bool empty(uint32_t tb_idx) const { return not tb[tb_idx].active; }
|
||
3 years ago
|
bool has_pending_retx(slot_point slot_rx) const
|
||
|
{
|
||
|
return not empty() and not tb[0].ack_state and slot_ack <= slot_rx;
|
||
|
}
|
||
3 years ago
|
uint32_t nof_retx() const { return tb[0].n_rtx; }
|
||
|
uint32_t max_nof_retx() const { return max_retx; }
|
||
|
uint32_t tbs() const { return tb[0].tbs; }
|
||
|
uint32_t ndi() const { return tb[0].ndi; }
|
||
|
uint32_t mcs() const { return tb[0].mcs; }
|
||
|
const prb_grant& prbs() const { return prbs_; }
|
||
3 years ago
|
slot_point harq_slot_tx() const { return slot_tx; }
|
||
3 years ago
|
slot_point harq_slot_ack() const { return slot_ack; }
|
||
3 years ago
|
|
||
3 years ago
|
int ack_info(uint32_t tb_idx, bool ack);
|
||
3 years ago
|
|
||
3 years ago
|
bool clear_if_maxretx(slot_point slot_rx);
|
||
3 years ago
|
void reset();
|
||
3 years ago
|
bool new_tx(slot_point slot_tx, slot_point slot_ack, const prb_grant& grant, uint32_t mcs, uint32_t max_retx);
|
||
3 years ago
|
bool new_retx(slot_point slot_tx, slot_point slot_ack, const prb_grant& grant);
|
||
|
bool new_retx(slot_point slot_tx, slot_point slot_ack);
|
||
3 years ago
|
|
||
|
// NOTE: Has to be used before first tx is dispatched
|
||
3 years ago
|
bool set_tbs(uint32_t tbs);
|
||
|
bool set_mcs(uint32_t mcs);
|
||
3 years ago
|
|
||
3 years ago
|
const uint32_t pid;
|
||
|
|
||
3 years ago
|
private:
|
||
|
struct tb_t {
|
||
|
bool active = false;
|
||
|
bool ack_state = false;
|
||
|
bool ndi = false;
|
||
|
uint32_t n_rtx = 0;
|
||
|
uint32_t mcs = 0;
|
||
3 years ago
|
uint32_t tbs = 0;
|
||
3 years ago
|
};
|
||
|
|
||
3 years ago
|
uint32_t max_retx = 1;
|
||
3 years ago
|
slot_point slot_tx;
|
||
|
slot_point slot_ack;
|
||
3 years ago
|
prb_grant prbs_;
|
||
3 years ago
|
std::array<tb_t, SCHED_NR_MAX_TB> tb;
|
||
3 years ago
|
};
|
||
|
|
||
3 years ago
|
class dl_harq_proc : public harq_proc
|
||
|
{
|
||
|
public:
|
||
3 years ago
|
dl_harq_proc(uint32_t id_, uint32_t nprb);
|
||
3 years ago
|
|
||
3 years ago
|
tx_harq_softbuffer& get_softbuffer() { return *softbuffer; }
|
||
3 years ago
|
srsran::unique_byte_buffer_t* get_tx_pdu() { return &pdu; }
|
||
3 years ago
|
|
||
3 years ago
|
bool new_tx(slot_point slot_tx, slot_point slot_ack, const prb_grant& grant, uint32_t mcs, uint32_t max_retx);
|
||
3 years ago
|
|
||
3 years ago
|
private:
|
||
|
srsran::unique_pool_ptr<tx_harq_softbuffer> softbuffer;
|
||
3 years ago
|
srsran::unique_byte_buffer_t pdu;
|
||
3 years ago
|
};
|
||
|
|
||
|
class ul_harq_proc : public harq_proc
|
||
|
{
|
||
|
public:
|
||
|
ul_harq_proc(uint32_t id_, uint32_t nprb) :
|
||
|
harq_proc(id_), softbuffer(harq_softbuffer_pool::get_instance().get_rx(nprb))
|
||
|
{}
|
||
|
|
||
|
rx_harq_softbuffer& get_softbuffer() { return *softbuffer; }
|
||
|
|
||
|
bool set_tbs(uint32_t tbs)
|
||
|
{
|
||
3 years ago
|
softbuffer->reset(tbs);
|
||
3 years ago
|
return harq_proc::set_tbs(tbs);
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
srsran::unique_pool_ptr<rx_harq_softbuffer> softbuffer;
|
||
|
};
|
||
|
|
||
3 years ago
|
class harq_entity
|
||
|
{
|
||
|
public:
|
||
3 years ago
|
explicit harq_entity(uint16_t rnti, uint32_t nprb, uint32_t nof_harq_procs, srslog::basic_logger& logger);
|
||
3 years ago
|
void new_slot(slot_point slot_rx_);
|
||
3 years ago
|
|
||
3 years ago
|
int dl_ack_info(uint32_t pid, uint32_t tb_idx, bool ack) { return dl_harqs[pid].ack_info(tb_idx, ack); }
|
||
|
int ul_crc_info(uint32_t pid, bool ack) { return ul_harqs[pid].ack_info(0, ack); }
|
||
3 years ago
|
|
||
3 years ago
|
uint32_t nof_dl_harqs() const { return dl_harqs.size(); }
|
||
|
uint32_t nof_ul_harqs() const { return ul_harqs.size(); }
|
||
|
const dl_harq_proc& dl_harq(uint32_t pid) const { return dl_harqs[pid]; }
|
||
|
const ul_harq_proc& ul_harq(uint32_t pid) const { return ul_harqs[pid]; }
|
||
|
|
||
3 years ago
|
dl_harq_proc* find_pending_dl_retx()
|
||
3 years ago
|
{
|
||
3 years ago
|
return find_dl([this](const dl_harq_proc& h) { return h.has_pending_retx(slot_rx); });
|
||
3 years ago
|
}
|
||
3 years ago
|
ul_harq_proc* find_pending_ul_retx()
|
||
3 years ago
|
{
|
||
3 years ago
|
return find_ul([this](const ul_harq_proc& h) { return h.has_pending_retx(slot_rx); });
|
||
3 years ago
|
}
|
||
3 years ago
|
dl_harq_proc* find_empty_dl_harq()
|
||
3 years ago
|
{
|
||
3 years ago
|
return find_dl([](const dl_harq_proc& h) { return h.empty(); });
|
||
3 years ago
|
}
|
||
3 years ago
|
ul_harq_proc* find_empty_ul_harq()
|
||
3 years ago
|
{
|
||
3 years ago
|
return find_ul([](const ul_harq_proc& h) { return h.empty(); });
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
private:
|
||
3 years ago
|
template <typename Predicate>
|
||
3 years ago
|
dl_harq_proc* find_dl(Predicate p)
|
||
3 years ago
|
{
|
||
|
auto it = std::find_if(dl_harqs.begin(), dl_harqs.end(), p);
|
||
|
return (it == dl_harqs.end()) ? nullptr : &(*it);
|
||
|
}
|
||
|
template <typename Predicate>
|
||
3 years ago
|
ul_harq_proc* find_ul(Predicate p)
|
||
3 years ago
|
{
|
||
|
auto it = std::find_if(ul_harqs.begin(), ul_harqs.end(), p);
|
||
|
return (it == ul_harqs.end()) ? nullptr : &(*it);
|
||
|
}
|
||
|
|
||
3 years ago
|
uint16_t rnti;
|
||
|
srslog::basic_logger& logger;
|
||
|
|
||
3 years ago
|
slot_point slot_rx;
|
||
3 years ago
|
std::vector<dl_harq_proc> dl_harqs;
|
||
|
std::vector<ul_harq_proc> ul_harqs;
|
||
3 years ago
|
};
|
||
|
|
||
|
} // namespace sched_nr_impl
|
||
|
} // namespace srsenb
|
||
|
|
||
|
#endif // SRSRAN_SCHED_NR_HARQ_H
|