1+ /*
2+ *
3+ * Copyright 2021-2024 Software Radio Systems Limited
4+ *
5+ * By using this file, you agree to the terms and conditions set
6+ * forth in the LICENSE file which can be found at the top level of
7+ * the distribution.
8+ *
9+ */
10+
11+ #pragma once
12+
13+ #include " ran_slice_instance.h"
14+
15+ namespace srsran {
16+ namespace detail {
17+
18+ template <bool IsDl>
19+ class common_ran_slice_candidate
20+ {
21+ struct candidate_deleter {
22+ void operator ()(ran_slice_instance* p)
23+ {
24+ if (p != nullptr ) {
25+ if constexpr (IsDl) {
26+ p->pdsch_completed ();
27+ } else {
28+ p->pusch_completed ();
29+ }
30+ }
31+ }
32+ };
33+
34+ public:
35+ common_ran_slice_candidate (ran_slice_instance* instance_) : inst(instance_, candidate_deleter{}) {}
36+
37+ ran_slice_id_t id () const { return inst->id ; }
38+ [[nodiscard]] const cell_rrm_policy_config& cfg () const { return inst->cfg ; }
39+ scheduler_policy& policy () { return *inst->policy ; }
40+
41+ bool is_candidate (du_ue_index_t ue_idx) const { return inst->is_candidate (ue_idx); }
42+ bool is_candidate (du_ue_index_t ue_idx, lcid_t lcid) const { return inst->is_candidate (ue_idx, lcid); }
43+
44+ // / Signal that the allocations for this slice are complete.
45+ void clear () { inst.reset (); }
46+
47+ // / Register that a new grant was allocated for a given UE.
48+ void store_grant (unsigned nof_rbs)
49+ {
50+ if constexpr (IsDl) {
51+ inst->store_pdsch_grant (nof_rbs);
52+ } else {
53+ inst->store_pusch_grant (nof_rbs);
54+ }
55+ }
56+
57+ // / Remaining bytes to allocate for the given slice.
58+ [[nodiscard]] unsigned remaining_rbs () const
59+ {
60+ if constexpr (IsDl) {
61+ return inst->cfg .max_prb_ratio < inst->pdsch_rb_count ? 0 : inst->cfg .max_prb_ratio - inst->pdsch_rb_count ;
62+ }
63+ return inst->cfg .max_prb_ratio < inst->pusch_rb_count ? 0 : inst->cfg .max_prb_ratio - inst->pusch_rb_count ;
64+ }
65+
66+ protected:
67+ std::unique_ptr<ran_slice_instance, candidate_deleter> inst;
68+ };
69+
70+ } // namespace detail
71+
72+ // / \brief Handle to fetch and update the state of a RAN slice in a given DL slot.
73+ // /
74+ // / On destruction, the slice is marked as completed for the current slot and won't be considered as a candidate again.
75+ using dl_ran_slice_candidate = detail::common_ran_slice_candidate<true >;
76+
77+ // / Interface to fetch and update the state of a RAN slice in a given UL slot.
78+ // /
79+ // / On destruction, the slice is marked as completed for the current slot and won't be considered as a candidate again.
80+ using ul_ran_slice_candidate = detail::common_ran_slice_candidate<false >;
81+
82+ } // namespace srsran
0 commit comments