created harq entity class

This commit is contained in:
Francisco Paisana 2020-03-05 12:12:47 +00:00
parent dfb1cd1361
commit 1c041b2c1d
2 changed files with 79 additions and 0 deletions

View File

@ -149,6 +149,40 @@ private:
typedef srslte::bounded_bitset<100, true> prbmask_t;
class dl_harq_entity : private std::vector<dl_harq_proc>
{
using base_t = std::vector<dl_harq_proc>;
public:
static const bool is_async = ASYNC_DL_SCHED;
using base_t::const_iterator;
using base_t::iterator;
using base_t::operator[];
using base_t::begin;
using base_t::data;
using base_t::end;
using base_t::size;
explicit dl_harq_entity(size_t nof_harqs) : base_t(nof_harqs) {}
/**
* Get the DL harq proc based on tti_tx_dl
* @param tti_tx_dl assumed to always be equal or ahead in time in comparison to current harqs
* @return pointer to found dl_harq
*/
dl_harq_proc* get_pending_harq(uint32_t tti_tx_dl);
/**
* Get empty DL Harq
* @param tti_tx_dl only used in case of sync dl sched
* @return pointer to found dl_harq
*/
dl_harq_proc* get_empty_harq(uint32_t tti_tx_dl);
private:
dl_harq_proc* get_oldest_harq(uint32_t tti_tx_dl);
};
} // namespace srsenb
#endif // SRSENB_SCHEDULER_HARQ_H

View File

@ -303,4 +303,49 @@ uint32_t ul_harq_proc::get_pending_data() const
return (uint32_t)pending_data;
}
/********************
* Harq Entity
*******************/
dl_harq_proc* dl_harq_entity::get_empty_harq(uint32_t tti_tx_dl)
{
if (not is_async) {
dl_harq_proc* h = &(*this)[tti_tx_dl % size()];
return h->is_empty() ? h : nullptr;
}
auto it = std::find_if(begin(), end(), [](dl_harq_proc& h) { return h.is_empty(); });
return it != end() ? &(*it) : nullptr;
}
dl_harq_proc* dl_harq_entity::get_pending_harq(uint32_t tti_tx_dl)
{
if (not is_async) {
dl_harq_proc* h = &(*this)[tti_tx_dl % size()];
return (h->has_pending_retx(0, tti_tx_dl) or h->has_pending_retx(1, tti_tx_dl)) ? h : nullptr;
}
return get_oldest_harq(tti_tx_dl);
}
/**
* Get the oldest DL Harq Proc that has pending retxs
* @param tti_tx_dl assumed to always be equal or ahead in time in comparison to current harqs
* @return pointer to found dl_harq
*/
dl_harq_proc* dl_harq_entity::get_oldest_harq(uint32_t tti_tx_dl)
{
int oldest_idx = -1;
uint32_t oldest_tti = 0;
for (const dl_harq_proc& h : *this) {
if (h.has_pending_retx(0, tti_tx_dl) or h.has_pending_retx(1, tti_tx_dl)) {
uint32_t x = srslte_tti_interval(tti_tx_dl, h.get_tti());
if (x > oldest_tti) {
oldest_idx = h.get_id();
oldest_tti = x;
}
}
}
return (oldest_idx >= 0) ? &(*this)[oldest_idx] : nullptr;
}
} // namespace srsenb