Skip to content

Commit d3c0d7c

Browse files
carlo-galcodebot
authored andcommitted
sched: cap max nof_prbs in prbs_calculator
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent 6937db8 commit d3c0d7c

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

lib/scheduler/support/prbs_calculator.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static float estimate_nof_info_payload_higher_3824_bits(unsigned payload_bits, f
3333
}
3434

3535
/// \brief Obtain an initial estimate for the minimum number of PRBs needed so that the TBS >= payload size.
36-
unsigned srsran::estimate_required_nof_prbs(const prbs_calculator_sch_config& sch_config)
36+
unsigned srsran::estimate_required_nof_prbs(const prbs_calculator_sch_config& sch_config,
37+
unsigned max_nof_available_rbs)
3738
{
3839
// Convert size into bits, as per TS procedures for TBS.
3940
unsigned payload_size = sch_config.payload_size_bytes * NOF_BITS_PER_BYTE;
@@ -58,11 +59,14 @@ unsigned srsran::estimate_required_nof_prbs(const prbs_calculator_sch_config& sc
5859
tbs_calculator_pdsch_get_scaling_factor(sch_config.tb_scaling_field));
5960

6061
// N_info_prime as per Section 5.1.3.2, TS 38.214.
61-
unsigned nof_re_prime = static_cast<unsigned>(NOF_SUBCARRIERS_PER_RB) * sch_config.nof_symb_sh -
62-
sch_config.nof_dmrs_prb - sch_config.nof_oh_prb;
63-
64-
// Get the estimated number of PRBs from the N_re and N_info_prime.
65-
return divide_ceil(nof_re, std::min(nof_re_prime, 156U));
62+
int nof_re_prime = static_cast<int>(NOF_SUBCARRIERS_PER_RB) * static_cast<int>(sch_config.nof_symb_sh) -
63+
static_cast<int>(sch_config.nof_dmrs_prb) - static_cast<int>(sch_config.nof_oh_prb);
64+
srsran_assert(nof_re_prime > 0, "nof_re_prime is expected to be positive");
65+
66+
// Get the estimated number of PRBs from the N_re and N_info_prime. Cap the returned value to the maximum nof RBs for
67+
// FR1.
68+
return std::min(max_nof_available_rbs,
69+
divide_ceil(static_cast<unsigned>(nof_re), std::min(static_cast<unsigned>(nof_re_prime), 156U)));
6670
}
6771

6872
/// \brief Linearly searches an upper-bound for the number of PRBs, such that the TBS >= payload size, starting from
@@ -74,6 +78,7 @@ unsigned srsran::estimate_required_nof_prbs(const prbs_calculator_sch_config& sc
7478
/// \return Optimal number of PRBs and TBS.
7579
static sch_prbs_tbs linear_search_nof_prbs_upper_bound(const prbs_calculator_sch_config& pdsch_cfg,
7680
unsigned nof_prbs_estimate,
81+
unsigned max_nof_available_rbs,
7782
unsigned max_prb_inc_iterations = 5)
7883
{
7984
unsigned payload_size_bits = pdsch_cfg.payload_size_bytes * NOF_BITS_PER_BYTE;
@@ -86,6 +91,12 @@ static sch_prbs_tbs linear_search_nof_prbs_upper_bound(const prbs_calculator_sch
8691
nof_prbs_estimate};
8792
unsigned tbs_bits_ub = tbs_calculator_calculate(tbs_cfg);
8893

94+
// Given that the nof_prbs_estimate is an estimate of the required PRBs, this can be greater (leading to a TBS >>
95+
// payload size) or smaller than the actual wanted value (leading to a TBS < payload size). Depending on the two
96+
// cases, we perform a fine tuning of the number of PRBs by reducing (former case) or by increasing the estimate of
97+
// RBs (latter case).
98+
99+
// First case: the nof_prbs_estimate is too big.
89100
// Linearly searches for an "nof_prb_dec" integer value so that TBS(nof_prbs_estimate - nof_prb_dec) < payload size.
90101
// Once an "nof_prb_dec" is found, the function will return "nof_prbs_estimate - nof_prb_dec + 1" as the solution.
91102
unsigned tbs_bits_lb = tbs_bits_ub;
@@ -100,9 +111,11 @@ static sch_prbs_tbs linear_search_nof_prbs_upper_bound(const prbs_calculator_sch
100111
tbs_bits_ub = tbs_bits_lb;
101112
}
102113

114+
// Second case: the nof_prbs_estimate is too small.
103115
// Linearly searches for an "nof_prb_inc" so that TBS(nof_prb_estimate + nof_prb_inc) >= payload_size.
104116
// Implementation-defined value to avoid too many iterations in the search for the optimal TBS.
105-
for (unsigned nof_prb_inc = 1; nof_prb_inc < max_prb_inc_iterations and tbs_bits_ub < payload_size_bits;
117+
for (unsigned nof_prb_inc = 1; nof_prb_inc < max_prb_inc_iterations and tbs_bits_ub < payload_size_bits and
118+
tbs_cfg.n_prb < max_nof_available_rbs;
106119
++nof_prb_inc) {
107120
tbs_cfg.n_prb = nof_prbs_estimate + nof_prb_inc;
108121
tbs_bits_ub = tbs_calculator_calculate(tbs_cfg);
@@ -111,11 +124,11 @@ static sch_prbs_tbs linear_search_nof_prbs_upper_bound(const prbs_calculator_sch
111124
return {tbs_cfg.n_prb, tbs_bits_ub / NOF_BITS_PER_BYTE};
112125
}
113126

114-
sch_prbs_tbs srsran::get_nof_prbs(const prbs_calculator_sch_config& sch_config)
127+
sch_prbs_tbs srsran::get_nof_prbs(const prbs_calculator_sch_config& sch_config, unsigned max_nof_available_rbs)
115128
{
116129
// Get a first estimate for the number of PRBs.
117-
unsigned nof_prbs_estimate = estimate_required_nof_prbs(sch_config);
130+
unsigned nof_prbs_estimate = estimate_required_nof_prbs(sch_config, max_nof_available_rbs);
118131

119132
// Linearly search for the optimal number of PRBs using "nof_prbs_estimate" as initial guess.
120-
return linear_search_nof_prbs_upper_bound(sch_config, nof_prbs_estimate);
133+
return linear_search_nof_prbs_upper_bound(sch_config, nof_prbs_estimate, max_nof_available_rbs);
121134
}

lib/scheduler/support/prbs_calculator.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,20 @@ struct sch_prbs_tbs {
6868
/// derive the number of PRBs from a given payload in bytes.
6969
///
7070
/// \param[in] sch_config is a struct with the PDSCH configuration to compute the num. of PRBs.
71+
/// \param[in] max_nof_available_rbs is the maximum number or available of PRBs within the BWP. By default, this is set
72+
/// to the maximum number of RBs for FR1, as per Table 5.3.2-1, TS 38.104.
7173
/// \return Returns a struct with the number of PRBs and the corresponding TBS. If the payload_size is greater than 478
7274
/// bytes (3824 bits), it returns the number of PRBs and TBS corresponding to maximum allowed payload size of 478 bytes.
73-
sch_prbs_tbs get_nof_prbs(const prbs_calculator_sch_config& sch_config);
75+
sch_prbs_tbs get_nof_prbs(const prbs_calculator_sch_config& sch_config, unsigned max_nof_available_rbs = 273U);
7476

7577
/// \brief Computes a coarse estimate of the number of required PRBs to transmit a given payload size. This estimate
7678
/// might lead to a TBS that is smaller or larger than the given payload size.
7779
///
7880
/// \param[in] sch_config is a struct with the PDSCH configuration to compute the num. of PRBs.
81+
/// \param[in] max_nof_available_rbs is the maximum number or available of PRBs within the BWP. By default, this is set
82+
/// to the maximum number of RBs for FR1, as per Table 5.3.2-1, TS 38.104.
7983
/// \return estimate of the number of PRBs.
80-
unsigned estimate_required_nof_prbs(const prbs_calculator_sch_config& sch_config);
84+
unsigned estimate_required_nof_prbs(const prbs_calculator_sch_config& sch_config,
85+
unsigned max_nof_available_rbs = 273U);
8186

8287
} // namespace srsran

0 commit comments

Comments
 (0)