Skip to content

Commit 42ad6ba

Browse files
committed
du: fix bad_access to optional
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent 5028ce1 commit 42ad6ba

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,19 @@ error_type<std::string> du_ran_resource_manager_impl::allocate_cell_resources(du
164164
}
165165
ue_res.cell_group.pcg_cfg.pdsch_harq_codebook = pdsch_harq_ack_codebook::dynamic;
166166

167+
if (not srs_res_mng->alloc_resources(ue_res.cell_group)) {
168+
// Deallocate dedicated Search Spaces.
169+
ue_res.cell_group.cells[0].serv_cell_cfg.init_dl_bwp.pdcch_cfg->search_spaces.clear();
170+
return make_unexpected(fmt::format("Unable to allocate SRS resources for cell={}", cell_index));
171+
}
172+
167173
if (not pucch_res_mng.alloc_resources(ue_res.cell_group)) {
168174
// Deallocate previously allocated SRS + dedicated Search Spaces.
175+
srs_res_mng->dealloc_resources(ue_res.cell_group);
169176
ue_res.cell_group.cells[0].serv_cell_cfg.init_dl_bwp.pdcch_cfg->search_spaces.clear();
170177
return make_unexpected(fmt::format("Unable to allocate dedicated PUCCH resources for cell={}", cell_index));
171178
}
179+
172180
} else {
173181
srsran_assert(not ue_res.cell_group.cells.contains(serv_cell_index), "Reallocation of SCell detected");
174182
ue_res.cell_group.cells.emplace(serv_cell_index);
@@ -190,6 +198,7 @@ void du_ran_resource_manager_impl::deallocate_cell_resources(du_ue_index_t ue_in
190198
ue_res.cell_group.cells[0].serv_cell_cfg.cell_index != INVALID_DU_CELL_INDEX,
191199
"Double deallocation of same UE cell resources detected");
192200
pucch_res_mng.dealloc_resources(ue_res.cell_group);
201+
srs_res_mng->dealloc_resources(ue_res.cell_group);
193202
ue_res.cell_group.cells[0].serv_cell_cfg.cell_index = INVALID_DU_CELL_INDEX;
194203
} else {
195204
// TODO: Remove of SCell params.

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,24 @@ du_srs_policy_max_ul_th::du_srs_policy_max_ul_th(span<const du_cell_config> cell
171171

172172
bool du_srs_policy_max_ul_th::alloc_resources(cell_group_config& cell_grp_cfg)
173173
{
174-
// Allocation of SR PUCCH offset.
174+
// TODO: Adapt this to the case of UEs with multiple cells configs.
175+
srsran_assert(
176+
cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index].cell_cfg.ue_ded_serv_cell_cfg.ul_config.has_value(),
177+
"UE UL config is empty");
178+
179+
// If periodic SRS is not enabled, don't allocate anything and exit with success.
180+
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]
181+
.cell_cfg.ue_ded_serv_cell_cfg.ul_config.value()
182+
.init_ul_bwp.srs_cfg.has_value()) {
183+
return true;
184+
}
185+
186+
// The UE SRS configuration is taken from a base configuration, saved in the GNB. The details that are UE specific
187+
// will be added later on in this function.
175188
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.emplace(
176-
cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index].default_srs_cfg);
189+
cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index]
190+
.cell_cfg.ue_ded_serv_cell_cfg.ul_config.value()
191+
.init_ul_bwp.srs_cfg.value());
177192
srs_config& ue_srs_cfg = cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.value();
178193
auto& free_srs_list = cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index].srs_res_offset_free_list;
179194

@@ -273,7 +288,8 @@ du_srs_policy_max_ul_th::cell_context::find_optimal_ue_srs_resource()
273288

274289
void du_srs_policy_max_ul_th::dealloc_resources(cell_group_config& cell_grp_cfg)
275290
{
276-
if (not cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.has_value()) {
291+
if (not cells[0].cell_cfg.srs_cfg.srs_period.has_value() or
292+
not cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.has_value()) {
277293
return;
278294
}
279295

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ class du_srs_policy_max_ul_th : public du_srs_resource_manager
5151

5252
private:
5353
struct cell_context {
54-
cell_context(const du_cell_config& cfg) :
55-
cell_cfg(cfg), default_srs_cfg(cfg.ue_ded_serv_cell_cfg.ul_config.value().init_ul_bwp.srs_cfg.value()){};
54+
cell_context(const du_cell_config& cfg) : cell_cfg(cfg){};
5655

5756
using pair_res_id_offset = std::pair<unsigned, unsigned>;
5857

@@ -84,7 +83,6 @@ class du_srs_policy_max_ul_th : public du_srs_resource_manager
8483
using pair_cnt_max = std::pair<unsigned, const unsigned>;
8584

8685
const du_cell_config& cell_cfg;
87-
const srs_config default_srs_cfg;
8886
srs_cell_common srs_common_params;
8987
// List of all SRS resources available to the cell; these resources can be allocated over to different UEs over
9088
// different offsets.

0 commit comments

Comments
 (0)