Skip to content

Commit d125d73

Browse files
committed
sched: add missing methods to unique_ue_harq_entity
1 parent 9b8eb8b commit d125d73

File tree

3 files changed

+92
-20
lines changed

3 files changed

+92
-20
lines changed

lib/scheduler/cell/cell_harq_manager.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class noop_harq_timeout_notifier : public harq_timeout_notifier
2121
{
2222
public:
2323
void on_harq_timeout(du_ue_index_t ue_idx, bool is_dl, bool ack) override
24-
{ /* do nothing */
24+
{ // do nothing
2525
}
2626
};
2727

@@ -322,6 +322,12 @@ void harq_utils::base_harq_process_handle<IsDl>::cancel_retxs()
322322
harq_repo->cancel_retxs(*impl);
323323
}
324324

325+
template <bool IsDl>
326+
void harq_utils::base_harq_process_handle<IsDl>::reset()
327+
{
328+
harq_repo->dealloc_harq(*impl);
329+
}
330+
325331
template class harq_utils::base_harq_process_handle<true>;
326332
template class harq_utils::base_harq_process_handle<false>;
327333

@@ -472,7 +478,7 @@ void dl_harq_process_handle::increment_pucch_counter()
472478
++impl->pucch_ack_to_receive;
473479
}
474480

475-
void dl_harq_process_handle::save_grant_params(const dl_harq_sched_context& ctx, const pdsch_information& pdsch)
481+
void dl_harq_process_handle::save_grant_params(const dl_harq_alloc_context& ctx, const pdsch_information& pdsch)
476482
{
477483
srsran_assert(pdsch.codewords.size() == 1, "Only one codeword supported");
478484
srsran_sanity_check(pdsch.rnti == impl->rnti, "RNTI mismatch");
@@ -530,7 +536,7 @@ int ul_harq_process_handle::ul_crc_info(bool ack)
530536
return ack ? (int)impl->prev_tx_params.tbs_bytes : 0;
531537
}
532538

533-
void ul_harq_process_handle::save_grant_params(const ul_harq_sched_context& ctx, const pusch_information& pusch)
539+
void ul_harq_process_handle::save_grant_params(const ul_harq_alloc_context& ctx, const pusch_information& pusch)
534540
{
535541
srsran_sanity_check(pusch.rnti == impl->rnti, "RNTI mismatch");
536542
srsran_sanity_check(pusch.harq_id == impl->h_id, "HARQ-id mismatch");
@@ -626,6 +632,15 @@ std::optional<dl_harq_process_handle> unique_ue_harq_entity::find_pending_dl_ret
626632
return dl_harq_process_handle(cell_harq_mgr->dl, *h);
627633
}
628634

635+
std::optional<const dl_harq_process_handle> unique_ue_harq_entity::find_pending_dl_retx() const
636+
{
637+
dl_harq_process_impl* h = cell_harq_mgr->dl.find_ue_harq_in_state(ue_index, harq_state_t::pending_retx);
638+
if (h == nullptr) {
639+
return std::nullopt;
640+
}
641+
return dl_harq_process_handle(cell_harq_mgr->dl, *h);
642+
}
643+
629644
std::optional<ul_harq_process_handle> unique_ue_harq_entity::find_pending_ul_retx()
630645
{
631646
ul_harq_process_impl* h = cell_harq_mgr->ul.find_ue_harq_in_state(ue_index, harq_state_t::pending_retx);
@@ -635,6 +650,15 @@ std::optional<ul_harq_process_handle> unique_ue_harq_entity::find_pending_ul_ret
635650
return ul_harq_process_handle(cell_harq_mgr->ul, *h);
636651
}
637652

653+
std::optional<const ul_harq_process_handle> unique_ue_harq_entity::find_pending_ul_retx() const
654+
{
655+
ul_harq_process_impl* h = cell_harq_mgr->ul.find_ue_harq_in_state(ue_index, harq_state_t::pending_retx);
656+
if (h == nullptr) {
657+
return std::nullopt;
658+
}
659+
return ul_harq_process_handle(cell_harq_mgr->ul, *h);
660+
}
661+
638662
std::optional<dl_harq_process_handle> unique_ue_harq_entity::find_dl_harq_waiting_ack()
639663
{
640664
dl_harq_process_impl* h = cell_harq_mgr->dl.find_ue_harq_in_state(ue_index, harq_state_t::waiting_ack);
@@ -675,3 +699,17 @@ std::optional<ul_harq_process_handle> unique_ue_harq_entity::find_ul_harq(slot_p
675699
}
676700
return std::nullopt;
677701
}
702+
703+
void unique_ue_harq_entity::uci_sched_failed(slot_point uci_slot)
704+
{
705+
std::vector<dl_harq_process_impl>& dl_harqs = cell_harq_mgr->dl.ues[ue_index].harqs;
706+
for (dl_harq_process_impl& h : dl_harqs) {
707+
if (h.status == harq_utils::harq_state_t::waiting_ack and h.slot_ack == uci_slot) {
708+
unsigned nof_nacks = std::max(h.pucch_ack_to_receive, 1U);
709+
auto h_handle = dl_harq_process_handle(cell_harq_mgr->dl, h);
710+
for (unsigned i = 0; i != nof_nacks; ++i) {
711+
h_handle.dl_ack_info(mac_harq_ack_report_status::dtx, std::nullopt);
712+
}
713+
}
714+
}
715+
}

lib/scheduler/cell/cell_harq_manager.h

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,24 @@ class base_harq_process_handle
170170
base_harq_process_handle() = default;
171171
base_harq_process_handle(harq_pool& pool_, harq_impl_type& h_) : harq_repo(&pool_), impl(&h_) {}
172172

173-
rnti_t rnti() const { return impl->rnti; }
174-
harq_id_t id() const { return impl->h_id; }
175-
bool is_waiting_ack() const { return impl->status == harq_utils::harq_state_t::waiting_ack; }
176-
bool has_pending_retx() const { return impl->status == harq_utils::harq_state_t::pending_retx; }
177-
bool empty() const { return impl->status == harq_utils::harq_state_t::empty; }
178-
unsigned max_nof_retxs() const { return impl->max_nof_harq_retxs; }
179-
unsigned nof_retxs() const { return impl->nof_retxs; }
180-
bool ndi() const { return impl->ndi; }
173+
du_ue_index_t ue_index() const { return impl->ue_idx; }
174+
rnti_t rnti() const { return impl->rnti; }
175+
harq_id_t id() const { return impl->h_id; }
176+
bool is_waiting_ack() const { return impl->status == harq_utils::harq_state_t::waiting_ack; }
177+
bool has_pending_retx() const { return impl->status == harq_utils::harq_state_t::pending_retx; }
178+
bool empty() const { return impl->status == harq_utils::harq_state_t::empty; }
179+
unsigned max_nof_retxs() const { return impl->max_nof_harq_retxs; }
180+
unsigned nof_retxs() const { return impl->nof_retxs; }
181+
bool ndi() const { return impl->ndi; }
181182

182183
/// \brief Cancels any retransmissions for this HARQ process.
183184
/// If the HARQ process has a pending retransmission, it is reset. If the ACK/CRC info has not been received yet, the
184185
/// HARQ process waits for it to arrive before being reset.
185186
void cancel_retxs();
186187

188+
/// Empty the HARQ process.
189+
void reset();
190+
187191
bool operator==(const base_harq_process_handle& other) const
188192
{
189193
return harq_repo == other.harq_repo and impl == other.impl;
@@ -198,7 +202,7 @@ class base_harq_process_handle
198202
} // namespace harq_utils
199203

200204
/// \brief Context of the scheduler during the current PDSCH allocation.
201-
struct dl_harq_sched_context {
205+
struct dl_harq_alloc_context {
202206
/// DCI format used to signal the PDSCH allocation.
203207
dci_dl_rnti_config_type dci_cfg_type;
204208
/// MCS suggested by the OLLA.
@@ -212,7 +216,7 @@ struct dl_harq_sched_context {
212216
};
213217

214218
/// \brief Context of the scheduler during the current PUSCH allocation.
215-
struct ul_harq_sched_context {
219+
struct ul_harq_alloc_context {
216220
/// DCI format used to signal the PUSCH allocation.
217221
dci_ul_rnti_config_type dci_cfg_type;
218222
/// MCS suggested by the OLLA.
@@ -261,7 +265,7 @@ class dl_harq_process_handle : public harq_utils::base_harq_process_handle<true>
261265

262266
/// \brief Stores grant parameters that are associated with the HARQ process (e.g. DCI format, PRBs, MCS) so that
263267
/// they can be later fetched and optionally reused.
264-
void save_grant_params(const dl_harq_sched_context& ctx, const pdsch_information& pdsch);
268+
void save_grant_params(const dl_harq_alloc_context& ctx, const pdsch_information& pdsch);
265269

266270
slot_point pdsch_slot() const { return impl->slot_tx; }
267271
slot_point uci_slot() const { return impl->slot_ack; }
@@ -300,7 +304,7 @@ class ul_harq_process_handle : public harq_utils::base_harq_process_handle<false
300304

301305
/// \brief Stores grant parameters that are associated with the HARQ process (e.g. DCI format, PRBs, MCS) so that
302306
/// they can be later fetched and optionally reused.
303-
void save_grant_params(const ul_harq_sched_context& ctx, const pusch_information& pusch);
307+
void save_grant_params(const ul_harq_alloc_context& ctx, const pusch_information& pusch);
304308

305309
slot_point pusch_slot() const { return impl->slot_tx; }
306310

@@ -436,6 +440,8 @@ class unique_ue_harq_entity
436440
unique_ue_harq_entity& operator=(const unique_ue_harq_entity&) = delete;
437441
unique_ue_harq_entity& operator=(unique_ue_harq_entity&& other) noexcept;
438442

443+
bool empty() const { return cell_harq_mgr == nullptr; }
444+
439445
/// Gets the maximum number of HARQ processes a UE can use, which depends on its configuration.
440446
unsigned nof_dl_harqs() const { return get_dl_ue().harqs.size(); }
441447
unsigned nof_ul_harqs() const { return get_ul_ue().harqs.size(); }
@@ -454,20 +460,36 @@ class unique_ue_harq_entity
454460
}
455461
return std::nullopt;
456462
}
463+
std::optional<const dl_harq_process_handle> dl_harq(harq_id_t h_id) const
464+
{
465+
if (get_dl_ue().harqs[h_id].status != harq_utils::harq_state_t::empty) {
466+
return dl_harq_process_handle{cell_harq_mgr->dl, cell_harq_mgr->dl.ues[ue_index].harqs[h_id]};
467+
}
468+
return std::nullopt;
469+
}
457470
std::optional<ul_harq_process_handle> ul_harq(harq_id_t h_id)
458471
{
459472
if (get_ul_ue().harqs[h_id].status != harq_utils::harq_state_t::empty) {
460473
return ul_harq_process_handle{cell_harq_mgr->ul, get_ul_ue().harqs[h_id]};
461474
}
462475
return std::nullopt;
463476
}
477+
std::optional<const ul_harq_process_handle> ul_harq(harq_id_t h_id) const
478+
{
479+
if (get_ul_ue().harqs[h_id].status != harq_utils::harq_state_t::empty) {
480+
return ul_harq_process_handle{cell_harq_mgr->ul, cell_harq_mgr->ul.ues[ue_index].harqs[h_id]};
481+
}
482+
return std::nullopt;
483+
}
464484

465485
std::optional<dl_harq_process_handle>
466486
alloc_dl_harq(slot_point sl_tx, unsigned k1, unsigned max_harq_nof_retxs, unsigned harq_bit_idx);
467487
std::optional<ul_harq_process_handle> alloc_ul_harq(slot_point sl_tx, unsigned max_harq_nof_retxs);
468488

469-
std::optional<dl_harq_process_handle> find_pending_dl_retx();
470-
std::optional<ul_harq_process_handle> find_pending_ul_retx();
489+
std::optional<dl_harq_process_handle> find_pending_dl_retx();
490+
std::optional<const dl_harq_process_handle> find_pending_dl_retx() const;
491+
std::optional<ul_harq_process_handle> find_pending_ul_retx();
492+
std::optional<const ul_harq_process_handle> find_pending_ul_retx() const;
471493

472494
std::optional<dl_harq_process_handle> find_dl_harq_waiting_ack();
473495
std::optional<ul_harq_process_handle> find_ul_harq_waiting_ack();
@@ -483,6 +505,18 @@ class unique_ue_harq_entity
483505
/// \return Active UL HARQ process with matching PUSCH slot, if found.
484506
std::optional<ul_harq_process_handle> find_ul_harq(slot_point pusch_slot);
485507

508+
/// \brief The UCI scheduling associated with a given slot was cancelled. The associated DL HARQs will be NACKed, and
509+
/// won't expect further UCIs.
510+
///
511+
/// This function can be called for instance when there is an error indication coming from lower layers.
512+
void uci_sched_failed(slot_point uci_slot);
513+
514+
unsigned ntn_get_tbs_pending_crcs() const
515+
{
516+
// TODO
517+
return 0;
518+
}
519+
486520
private:
487521
dl_harq_ent_impl& get_dl_ue() { return cell_harq_mgr->dl.ues[ue_index]; }
488522
const dl_harq_ent_impl& get_dl_ue() const { return cell_harq_mgr->dl.ues[ue_index]; }
@@ -494,4 +528,4 @@ class unique_ue_harq_entity
494528
rnti_t crnti = rnti_t::INVALID_RNTI;
495529
};
496530

497-
} // namespace srsran
531+
} // namespace srsran

tests/unittests/scheduler/cell/cell_harq_manager_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ class single_harq_process_test : public base_single_harq_entity_test, public ::t
155155
single_harq_process_test()
156156
{
157157
pdsch_info = make_dummy_pdsch_info();
158-
dl_harq_sched_context harq_ctxt{dci_dl_rnti_config_type::c_rnti_f1_0};
158+
dl_harq_alloc_context harq_ctxt{dci_dl_rnti_config_type::c_rnti_f1_0};
159159
h_dl.save_grant_params(harq_ctxt, pdsch_info);
160160
pusch_info = make_dummy_pusch_info();
161-
ul_harq_sched_context ul_harq_ctxt{dci_ul_rnti_config_type::c_rnti_f0_0};
161+
ul_harq_alloc_context ul_harq_ctxt{dci_ul_rnti_config_type::c_rnti_f0_0};
162162
h_ul.save_grant_params(ul_harq_ctxt, pusch_info);
163163
}
164164

0 commit comments

Comments
 (0)