Skip to content

Commit a11bb33

Browse files
committed
du: fix RAN resource deallocation + add unittest
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent 38a9635 commit a11bb33

File tree

5 files changed

+450
-45
lines changed

5 files changed

+450
-45
lines changed

lib/du/du_high/du_manager/ran_resource_management/du_pucch_resource_manager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ void du_pucch_resource_manager::dealloc_resources(cell_group_config& cell_grp_cf
348348
srsran_assert(cells[0].pucch_grants_per_slot_cnt[offset] != 0, "Index exceeds the size of the PUCCH grants vector");
349349
--cells[0].pucch_grants_per_slot_cnt[offset];
350350
}
351+
352+
// Disable the PUCCH configuration in this UE. This makes sure the DU will exit this function immediately when it gets
353+
// call again for the same UE (upon destructor's call).
354+
disable_pucch_cfg(cell_grp_cfg);
351355
}
352356

353357
std::vector<std::pair<unsigned, unsigned>>::const_iterator

lib/du/du_high/du_manager/ran_resource_management/du_ran_resource_manager_impl.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ du_ue_ran_resource_updater_impl::update(du_cell_index_t pc
3838

3939
///////////////////////////
4040

41+
static void initialize_serv_cell_cfg(serving_cell_config& serv_cell_cfg)
42+
{
43+
srsran_assert(serv_cell_cfg.ul_config.has_value() and
44+
serv_cell_cfg.ul_config.value().init_ul_bwp.pucch_cfg.has_value() and
45+
serv_cell_cfg.ul_config.value().init_ul_bwp.srs_cfg.has_value(),
46+
"UL configuration in Serving cell config not configured");
47+
48+
serv_cell_cfg.ul_config->init_ul_bwp.pucch_cfg.reset();
49+
if (serv_cell_cfg.csi_meas_cfg.has_value()) {
50+
serv_cell_cfg.csi_meas_cfg.value().csi_report_cfg_list.clear();
51+
}
52+
53+
serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.reset();
54+
}
55+
4156
du_ran_resource_manager_impl::du_ran_resource_manager_impl(span<const du_cell_config> cell_cfg_list_,
4257
const scheduler_expert_config& scheduler_cfg,
4358
const std::map<srb_id_t, du_srb_config>& srb_config,
@@ -64,7 +79,6 @@ du_ran_resource_manager_impl::create_ue_resource_configurator(du_ue_index_t ue_i
6479
// UE initialized PCell.
6580
// Note: In case of lack of RAN resource availability, the return will be error type.
6681
error_type<std::string> err = allocate_cell_resources(ue_index, pcell_index, SERVING_CELL_PCELL_IDX);
67-
6882
return ue_ran_resource_configurator{std::make_unique<du_ue_ran_resource_updater_impl>(&mcg, *this, ue_index),
6983
err.has_value() ? std::string{} : err.error()};
7084
}
@@ -164,6 +178,10 @@ error_type<std::string> du_ran_resource_manager_impl::allocate_cell_resources(du
164178
}
165179
ue_res.cell_group.pcg_cfg.pdsch_harq_codebook = pdsch_harq_ack_codebook::dynamic;
166180

181+
// Start with removing PUCCH and SRS configurations. This step simplifies the handling of the allocation failure
182+
// path.
183+
initialize_serv_cell_cfg(ue_res.cell_group.cells[0].serv_cell_cfg);
184+
167185
if (not srs_res_mng->alloc_resources(ue_res.cell_group)) {
168186
// Deallocate dedicated Search Spaces.
169187
ue_res.cell_group.cells[0].serv_cell_cfg.init_dl_bwp.pdcch_cfg->search_spaces.clear();

lib/du/du_high/du_manager/ran_resource_management/du_srs_resource_manager.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,17 @@ du_srs_policy_max_ul_th::du_srs_policy_max_ul_th(span<const du_cell_config> cell
158158
// Handle TDD and FDD configurations separately, as we treat partially-UL slots differently from
159159
// fully-UL slots.
160160
if (cell_cfg_list_[0].tdd_ul_dl_cfg_common.has_value()) {
161+
const auto& tdd_cfg = cell_cfg_list_[0].tdd_ul_dl_cfg_common.value();
161162
// For partially-UL slots, we need to check if the SRS can be placed in the UL symbols of the
162163
// slot.
163164
if (is_partually_ul_slot(offset, cell_cfg_list_[0].tdd_ul_dl_cfg_common.value())) {
164-
// TODO: Fix check for pattern 2.
165-
if (res.symbols.start() < NOF_OFDM_SYM_PER_SLOT_NORMAL_CP -
166-
cell_cfg_list_[0].tdd_ul_dl_cfg_common.value().pattern1.nof_ul_symbols) {
165+
const unsigned slot_index =
166+
offset % (NOF_SUBFRAMES_PER_FRAME * get_nof_slots_per_subframe(tdd_cfg.ref_scs));
167+
static constexpr unsigned max_srs_symbols = 6U;
168+
const unsigned nof_ul_symbols_for_srs =
169+
std::min(srsran::get_active_tdd_ul_symbols(tdd_cfg, slot_index, cyclic_prefix::NORMAL).length(),
170+
max_srs_symbols);
171+
if (res.symbols.start() < NOF_OFDM_SYM_PER_SLOT_NORMAL_CP - nof_ul_symbols_for_srs) {
167172
continue;
168173
}
169174
}
@@ -191,13 +196,15 @@ bool du_srs_policy_max_ul_th::alloc_resources(cell_group_config& cell_grp_cfg)
191196
{
192197
// TODO: Adapt this to the case of UEs with multiple cells configs.
193198
srsran_assert(
194-
cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index].cell_cfg.ue_ded_serv_cell_cfg.ul_config.has_value(),
195-
"UE UL config is empty");
199+
cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index].cell_cfg.ue_ded_serv_cell_cfg.ul_config.has_value() and
200+
not cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.has_value(),
201+
"UE UL config should be non-empty but with an empty SRS config");
202+
203+
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.emplace(
204+
cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index].default_srs_cfg);
196205

197206
// If periodic SRS is not enabled, don't allocate anything and exit with success.
198-
if (not cells[0].cell_cfg.srs_cfg.srs_period.has_value() or not cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index]
199-
.cell_cfg.ue_ded_serv_cell_cfg.ul_config.value()
200-
.init_ul_bwp.srs_cfg.has_value()) {
207+
if (not cells[0].cell_cfg.srs_cfg.srs_period.has_value()) {
201208
return true;
202209
}
203210

@@ -210,19 +217,25 @@ bool du_srs_policy_max_ul_th::alloc_resources(cell_group_config& cell_grp_cfg)
210217

211218
// Verify where there are SRS resources to allocate a new UE.
212219
if (free_srs_list.empty()) {
220+
// If the allocation failed, reset the SRS configuration.
221+
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.reset();
213222
return false;
214223
}
215224

216225
// Find the best resource ID and offset for this UE.
217226
auto srs_res_id_offset = cells[0].find_optimal_ue_srs_resource();
218227

219228
if (srs_res_id_offset == free_srs_list.end()) {
229+
// If the allocation failed, reset the SRS configuration.
230+
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.reset();
220231
return false;
221232
}
222233

223234
const auto& du_res_it = cells[0].get_du_srs_res_cfg(srs_res_id_offset->first);
224235

225236
if (du_res_it == cells[0].cell_srs_res_list.end()) {
237+
// If the allocation failed, reset the SRS configuration.
238+
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.reset();
226239
return false;
227240
}
228241

@@ -256,6 +269,9 @@ bool du_srs_policy_max_ul_th::alloc_resources(cell_group_config& cell_grp_cfg)
256269
only_ue_srs_res.freq_domain_shift =
257270
cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index].srs_common_params.freq_shift;
258271

272+
only_ue_srs_res.periodicity_and_offset.emplace(srs_config::srs_periodicity_and_offset{
273+
.period = cells[0].cell_cfg.srs_cfg.srs_period.value(), .offset = static_cast<uint16_t>(srs_offset)});
274+
259275
// Update the SRS resource set with the SRS id.
260276
ue_srs_cfg.srs_res_set_list.front().srs_res_id_list.front() = only_ue_srs_res.id.ue_res_id;
261277

@@ -294,7 +310,8 @@ du_srs_policy_max_ul_th::cell_context::find_optimal_ue_srs_resource()
294310

295311
// Give priority to the last symbols within a slot. This reduces the space used for the SRS in a slot.
296312
const unsigned symb_weight =
297-
(NOF_OFDM_SYM_PER_SLOT_NORMAL_CP - srs_res_cfg_it->symbols.start()) * symbol_weight_base;
313+
symbol_weight_base *
314+
((NOF_OFDM_SYM_PER_SLOT_NORMAL_CP - srs_res_cfg_it->symbols.start()) / srs_res_cfg_it->symbols.length());
298315

299316
// We consider a discount if the offset is already used but not full; this way, we give an incentive
300317
// to the SRS resources not to be allocated on a new slot, to avoid taking PUSCH symbols on a new
@@ -332,4 +349,8 @@ void du_srs_policy_max_ul_th::dealloc_resources(cell_group_config& cell_grp_cfg)
332349
srsran_assert(cells[0].slot_resource_cnt[offset_to_deallocate].first != 0, "The offset is expected to be non-zero");
333350
--cells[0].slot_resource_cnt[offset_to_deallocate].first;
334351
}
352+
353+
// Reset the SRS configuration in this UE. This makes sure the DU will exit this function immediately when it gets
354+
// call again for the same UE (upon destructor's call).
355+
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.reset();
335356
}

lib/du/du_high/du_manager/ran_resource_management/du_srs_resource_manager.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class du_srs_resource_manager
3636
virtual void dealloc_resources(cell_group_config& cell_grp_cfg) = 0;
3737
};
3838

39-
/// This class implements the MAX UL throughput policy for the SRS allocation. The SRS resources are allocated to
40-
/// minimize the number of slots that contains the SRS resources; furthermore, within a given slot, the SRS resources
41-
/// are allocated to minimize the number of symbols that are used for SRS. The drawback of this policy is that it can
42-
/// increase the inter slot SRS interference among different UEs.
39+
/// This class implements the MAX UL throughput policy for the SRS allocation. The SRS resources are allocated with the
40+
/// objective to minimize the number of slots that contains the SRS resources; furthermore, within a given slot, the SRS
41+
/// resources are allocated to minimize the number of symbols that are used for SRS. The drawback of this policy is that
42+
/// it can increase the inter slot SRS interference among different UEs.
4343
class du_srs_policy_max_ul_th : public du_srs_resource_manager
4444
{
4545
public:
@@ -58,9 +58,11 @@ class du_srs_policy_max_ul_th : public du_srs_resource_manager
5858
// Returns the DU SRS resource with the given cell resource ID from the cell list of resources.
5959
std::vector<du_srs_resource>::const_iterator get_du_srs_res_cfg(unsigned cell_res_id)
6060
{
61-
return std::find_if(cell_srs_res_list.begin(),
62-
cell_srs_res_list.end(),
63-
[cell_res_id](const du_srs_resource& res) { return res.cell_res_id == cell_res_id; });
61+
if (cell_res_id >= cell_srs_res_list.size() or cell_srs_res_list[cell_res_id].cell_res_id != cell_res_id) {
62+
srsran_assertion_failure("Cell resource ID out of range or invalid");
63+
return cell_srs_res_list.end();
64+
}
65+
return cell_srs_res_list.cbegin() + cell_res_id;
6466
}
6567

6668
// Returns the best SRS resource ID and offset for this UE, according to the policy defined in this class.
@@ -85,8 +87,6 @@ class du_srs_policy_max_ul_th : public du_srs_resource_manager
8587
// Maximum number of SRS resources that can be generated in a cell.
8688
// [Implementation-defined] We assume each UE has one and only one resource.
8789
static const unsigned max_nof_srs_res = MAX_NOF_DU_UES;
88-
// We need to save an object with the cell configuration parameters (not a reference), as this config is a modified
89-
// version of the default cell config.
9090
const du_cell_config& cell_cfg;
9191
// Default SRS configuration for the cell.
9292
const srs_config default_srs_cfg;

0 commit comments

Comments
 (0)