Skip to content

Commit 9b9c5dc

Browse files
committed
sched: pending HARQ retxs are now ordered based on time of ACK arrival
1 parent afbce26 commit 9b9c5dc

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

include/srsran/adt/intrusive_list.h

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class intrusive_double_linked_list
137137
template <typename U>
138138
class iterator_impl
139139
{
140-
using elem_t = typename std::conditional<std::is_const<U>::value, const node_t, node_t>::type;
140+
using elem_t = std::conditional_t<std::is_const<U>::value, const node_t, node_t>;
141141

142142
public:
143143
using iterator_category = std::bidirectional_iterator_tag;
@@ -173,24 +173,28 @@ class intrusive_double_linked_list
173173

174174
intrusive_double_linked_list()
175175
{
176-
static_assert(std::is_base_of<node_t, T>::value,
176+
static_assert(std::is_base_of_v<node_t, T>,
177177
"Provided template argument T must have intrusive_forward_list_element<Tag> as base class");
178178
}
179179
intrusive_double_linked_list(const intrusive_double_linked_list&) = default;
180-
intrusive_double_linked_list(intrusive_double_linked_list&& other) noexcept : node(other.node)
180+
intrusive_double_linked_list(intrusive_double_linked_list&& other) noexcept : node(other.node), tail(other.tail)
181181
{
182182
other.node = nullptr;
183+
other.tail = nullptr;
183184
}
184185
intrusive_double_linked_list& operator=(const intrusive_double_linked_list&) = default;
185186
intrusive_double_linked_list& operator=(intrusive_double_linked_list&& other) noexcept
186187
{
187188
node = other.node;
189+
tail = other.tail;
188190
other.node = nullptr;
191+
other.tail = nullptr;
189192
return *this;
190193
}
191194
~intrusive_double_linked_list() { clear(); }
192195

193196
T& front() const { return *static_cast<T*>(node); }
197+
T& back() const { return *static_cast<T*>(tail); }
194198

195199
void push_front(T* t)
196200
{
@@ -199,15 +203,36 @@ class intrusive_double_linked_list
199203
new_head->next_node = node;
200204
if (node != nullptr) {
201205
node->prev_node = new_head;
206+
} else {
207+
tail = new_head;
202208
}
203209
node = new_head;
204210
}
205211

212+
void push_back(T* t)
213+
{
214+
node_t* new_tail = static_cast<node_t*>(t);
215+
new_tail->prev_node = tail;
216+
new_tail->next_node = nullptr;
217+
if (tail != nullptr) {
218+
tail->next_node = new_tail;
219+
} else {
220+
node = new_tail;
221+
}
222+
tail = new_tail;
223+
}
224+
206225
void pop(T* t)
207226
{
208227
node_t* to_rem = static_cast<node_t*>(t);
209228
if (to_rem == node) {
210229
node = to_rem->next_node;
230+
if (node == nullptr) {
231+
tail = nullptr;
232+
}
233+
} else if (to_rem == tail) {
234+
tail = to_rem->prev_node;
235+
// tail==head checked in first if condition.
211236
}
212237
if (to_rem->prev_node != nullptr) {
213238
to_rem->prev_node->next_node = to_rem->next_node;
@@ -218,7 +243,11 @@ class intrusive_double_linked_list
218243
to_rem->next_node = nullptr;
219244
to_rem->prev_node = nullptr;
220245
}
246+
221247
void pop_front() { pop(static_cast<T*>(node)); }
248+
249+
void pop_back() { pop(static_cast<T*>(tail)); }
250+
222251
void clear()
223252
{
224253
while (node != nullptr) {
@@ -227,6 +256,7 @@ class intrusive_double_linked_list
227256
torem->next_node = nullptr;
228257
torem->prev_node = nullptr;
229258
}
259+
tail = nullptr;
230260
}
231261

232262
bool empty() const { return node == nullptr; }
@@ -238,6 +268,7 @@ class intrusive_double_linked_list
238268

239269
private:
240270
node_t* node = nullptr;
271+
node_t* tail = nullptr;
241272
};
242273

243274
} // namespace srsran

lib/scheduler/ue_scheduling/cell_harq_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void cell_harq_repository<IsDl>::set_pending_retx(harq_type& h)
217217
harq_timeout_wheel[h.slot_ack_timeout.to_uint() % harq_timeout_wheel.size()].pop(&h);
218218

219219
// Add HARQ to pending Retx list.
220-
harq_pending_retx_list.push_front(&h);
220+
harq_pending_retx_list.push_back(&h);
221221

222222
// Update HARQ process state.
223223
h.status = harq_state_t::pending_retx;

tests/unittests/scheduler/ue_scheduling/harq_manager_test.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,3 +936,35 @@ TEST_F(multi_ue_harq_manager_test, when_harq_entities_are_nacked_then_they_appea
936936
}
937937
ASSERT_EQ(count, 1);
938938
}
939+
940+
TEST_F(multi_ue_harq_manager_test, pending_harq_retxs_are_ordered_from_oldest_to_newest_ack)
941+
{
942+
const unsigned k1 = 4, k2 = 6, max_retxs = 4;
943+
unique_ue_harq_entity harq_ent1 = cell_harqs.add_ue(to_du_ue_index(1), to_rnti(0x4601), nof_harqs, nof_harqs);
944+
unique_ue_harq_entity harq_ent2 = cell_harqs.add_ue(to_du_ue_index(2), to_rnti(0x4602), nof_harqs, nof_harqs);
945+
946+
ASSERT_TRUE(harq_ent1.alloc_dl_harq(current_slot, k1, max_retxs, 0).has_value());
947+
ASSERT_TRUE(harq_ent2.alloc_ul_harq(current_slot + k2, max_retxs).has_value());
948+
ASSERT_TRUE(harq_ent2.alloc_dl_harq(current_slot, k1, max_retxs, 0).has_value());
949+
ASSERT_TRUE(harq_ent1.alloc_ul_harq(current_slot + k2, max_retxs).has_value());
950+
951+
ASSERT_EQ(harq_ent1.find_dl_harq(current_slot + k1, 0)->dl_ack_info(mac_harq_ack_report_status::nack, std::nullopt),
952+
dl_harq_process_handle::status_update::nacked);
953+
ASSERT_EQ(harq_ent2.find_dl_harq(current_slot + k1, 0)->dl_ack_info(mac_harq_ack_report_status::nack, std::nullopt),
954+
dl_harq_process_handle::status_update::nacked);
955+
ASSERT_EQ(harq_ent2.find_ul_harq(current_slot + k2)->ul_crc_info(false), 0);
956+
ASSERT_EQ(harq_ent1.find_ul_harq(current_slot + k2)->ul_crc_info(false), 0);
957+
958+
unsigned count = 0;
959+
for (dl_harq_process_handle h : cell_harqs.pending_dl_retxs()) {
960+
ASSERT_EQ(h.rnti(), to_rnti(0x4601 + count));
961+
count++;
962+
}
963+
ASSERT_EQ(count, 2);
964+
count = 0;
965+
for (ul_harq_process_handle h : cell_harqs.pending_ul_retxs()) {
966+
ASSERT_EQ(h.rnti(), to_rnti(0x4602 - count));
967+
count++;
968+
}
969+
ASSERT_EQ(count, 2);
970+
}

0 commit comments

Comments
 (0)