Skip to content

Commit

Permalink
phy: adjust PUSCH payload buffer buffer pool size to bandwidth and nu…
Browse files Browse the repository at this point in the history
…mber of layers

phy: fix compilation

phy: fix symbol handler buffer
  • Loading branch information
Xavier Arteaga authored and codebot committed Feb 10, 2025
1 parent a52bbdf commit 6babd07
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
1 change: 1 addition & 0 deletions lib/phy/upper/upper_phy_factories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ class upper_phy_factory_impl : public upper_phy_factory
{
upper_phy_impl_config phy_config;
phy_config.ul_bw_rb = config.ul_bw_rb;
phy_config.pusch_max_nof_layers = config.pusch_max_nof_layers;
phy_config.nof_rx_ports = config.nof_rx_ports;
phy_config.log_level = config.log_level;
phy_config.rx_symbol_printer_filename = config.rx_symbol_printer_filename;
Expand Down
4 changes: 3 additions & 1 deletion lib/phy/upper/upper_phy_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ upper_phy_impl::upper_phy_impl(upper_phy_impl_config&& config) :
rx_symbol_handler(std::make_unique<upper_phy_rx_symbol_handler_impl>(*ul_processor_pool,
pdu_repository,
rx_buf_pool->get_pool(),
rx_results_notifier)),
rx_results_notifier,
config.ul_bw_rb,
config.pusch_max_nof_layers)),
timing_handler(notifier_dummy)
{
srsran_assert(dl_processor_pool, "Invalid downlink processor pool");
Expand Down
2 changes: 2 additions & 0 deletions lib/phy/upper/upper_phy_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct upper_phy_impl_config {
unsigned ul_bw_rb;
/// Number of receive antenna ports.
unsigned nof_rx_ports;
/// Maximum number of layers for PUSCH transmissions.
unsigned pusch_max_nof_layers;
/// Downlink processor pool.
std::unique_ptr<downlink_processor_pool> dl_processor_pool;
/// Uplink processor pool.
Expand Down
14 changes: 8 additions & 6 deletions lib/phy/upper/upper_phy_rx_symbol_handler_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@

using namespace srsran;

upper_phy_rx_symbol_handler_impl::upper_phy_rx_symbol_handler_impl(
uplink_processor_pool& ul_processor_pool_,
uplink_slot_pdu_repository& ul_pdu_repository_,
rx_buffer_pool& rm_buffer_pool_,
upper_phy_rx_results_notifier& rx_results_notifier_) :
upper_phy_rx_symbol_handler_impl::upper_phy_rx_symbol_handler_impl(uplink_processor_pool& ul_processor_pool_,
uplink_slot_pdu_repository& ul_pdu_repository_,
rx_buffer_pool& rm_buffer_pool_,
upper_phy_rx_results_notifier& rx_results_notifier_,
unsigned max_nof_prb,
unsigned max_nof_layers) :
ul_processor_pool(ul_processor_pool_),
ul_pdu_repository(ul_pdu_repository_),
rm_buffer_pool(rm_buffer_pool_),
rx_results_notifier(rx_results_notifier_)
rx_results_notifier(rx_results_notifier_),
rx_payload_pool(max_nof_prb, max_nof_layers)
{
}

Expand Down
21 changes: 16 additions & 5 deletions lib/phy/upper/upper_phy_rx_symbol_handler_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,24 @@ class rx_payload_buffer_pool
{
/// Maximum number of slots to store.
static constexpr size_t nof_slots = 40U;
/// Maximum number of bits that could potentially be allocated in a slot.
static constexpr units::bits max_buffer_size = units::bits(MAX_RB * 156 * 8 * 2);
/// Minimum block size. It ensures that the payload offsets are selected using multiples of blocks.
static constexpr unsigned min_block_size = 64;

public:
/// Create the receive transport block buffer pool from the maximum number of PRB and layers.
rx_payload_buffer_pool(unsigned max_nof_prb, unsigned max_nof_layers) :
max_buffer_size(units::bits(max_nof_prb * 156 * 8 * max_nof_layers)),
pool(max_buffer_size.truncate_to_bytes().value() * nof_slots)
{
srsran_assert(max_nof_prb != 0, "Invalid number of PRB.");
srsran_assert(max_nof_layers != 0, "Invalid number of layers.");
}

/// Returns the next available portion of the pool.
span<uint8_t> acquire_payload_buffer(units::bytes size)
{
// Convert the maximum buffer size from bits to bytes for comparison and allocation.
static constexpr units::bytes max_buffer_size_bytes = max_buffer_size.truncate_to_bytes();
units::bytes max_buffer_size_bytes = max_buffer_size.truncate_to_bytes();

srsran_assert(
size <= max_buffer_size_bytes, "Buffer size (i.e., {}) exceeds maximum {}.", size, max_buffer_size_bytes);
Expand All @@ -65,8 +72,10 @@ class rx_payload_buffer_pool
}

private:
/// Maximum number of bits that could potentially be allocated in a slot.
units::bits max_buffer_size;
/// Pool.
std::array<uint8_t, max_buffer_size.truncate_to_bytes().value() * nof_slots> pool;
std::vector<uint8_t> pool;
/// Span that points to the unused portion of the pool.
span<uint8_t> available;
};
Expand All @@ -83,7 +92,9 @@ class upper_phy_rx_symbol_handler_impl : public upper_phy_rx_symbol_handler
upper_phy_rx_symbol_handler_impl(uplink_processor_pool& ul_processor_pool_,
uplink_slot_pdu_repository& ul_pdu_repository_,
rx_buffer_pool& buffer_pool_,
upper_phy_rx_results_notifier& rx_results_notifier_);
upper_phy_rx_results_notifier& rx_results_notifier_,
unsigned max_nof_prb,
unsigned max_nof_layers);

// See interface for documentation.
void handle_rx_symbol(const upper_phy_rx_symbol_context& context, const shared_resource_grid& grid) override;
Expand Down
11 changes: 9 additions & 2 deletions tests/unittests/phy/upper/upper_phy_rx_symbol_handler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace {
class UpperPhyRxSymbolHandlerFixture : public ::testing::Test
{
protected:
static constexpr unsigned max_nof_prb = 1;
static constexpr unsigned max_nof_layers = 1;
std::unique_ptr<rx_buffer_pool_controller> rm_buffer_pool;
uplink_processor_spy* ul_proc_spy;
std::unique_ptr<uplink_processor_pool> ul_processor_pool;
Expand Down Expand Up @@ -87,7 +89,7 @@ class UpperPhyRxSymbolHandlerFixture : public ::testing::Test

void handle_pucch_pdu()
{
const unsigned nof_symbols = 2;
static constexpr unsigned nof_symbols = 2;

uplink_processor::pucch_pdu pdu = {};
auto& format0 = pdu.config.emplace<pucch_processor::format0_configuration>();
Expand All @@ -110,7 +112,12 @@ class UpperPhyRxSymbolHandlerFixture : public ::testing::Test
rm_buffer_pool(create_rx_buffer_pool(rx_buffer_pool_config{16, 2, 2, 16})),
ul_processor_pool(create_ul_processor_pool()),
pdu_repo(2),
rx_handler(*ul_processor_pool, pdu_repo, rm_buffer_pool->get_pool(), rx_results_wrapper),
rx_handler(*ul_processor_pool,
pdu_repo,
rm_buffer_pool->get_pool(),
rx_results_wrapper,
max_nof_prb,
max_nof_layers),
shared_rg(rg)
{
srslog::fetch_basic_logger("TEST").set_level(srslog::basic_levels::warning);
Expand Down

0 comments on commit 6babd07

Please sign in to comment.