Skip to content

Commit d698462

Browse files
xavierarteagacodebot
authored andcommitted
phy: fix PUSCH data buffer pool
1 parent ccd9023 commit d698462

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

include/srsran/phy/upper/uplink_processor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class uplink_processor
4040
struct pusch_pdu {
4141
/// HARQ process number.
4242
unsigned harq_id;
43-
/// Transport block size in bytes.
44-
unsigned tb_size;
43+
/// Transport block size.
44+
units::bytes tb_size;
4545
/// PUSCH processor PDU.
4646
pusch_processor::pdu_t pdu;
4747
};

lib/fapi_adaptor/phy/messages/pusch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static void fill_codeword(uplink_processor::pusch_pdu& pdu, const fapi::ul_pusch
2626
cw.new_data = fapi_pdu.pusch_data.new_data;
2727

2828
pdu.harq_id = fapi_pdu.pusch_data.harq_process_id;
29-
pdu.tb_size = fapi_pdu.pusch_data.tb_size.value();
29+
pdu.tb_size = fapi_pdu.pusch_data.tb_size;
3030

3131
pdu.pdu.codeword = optional<pusch_processor::codeword_description>(std::move(cw));
3232
}

lib/phy/upper/upper_phy_rx_symbol_handler_impl.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,24 @@ class upper_phy_rx_results_notifier;
2727
class rx_payload_buffer_pool
2828
{
2929
/// Maximum number of payloads contained by the pool.
30-
static const size_t MAX_NUM_PAYLOAD = 4096U;
31-
static const size_t MAX_BUFFER_SIZE = MAX_RB * 156 * 8;
30+
static constexpr size_t MAX_NUM_PAYLOAD = 4096U;
31+
static constexpr units::bits MAX_BUFFER_SIZE = units::bits(MAX_RB * 156 * 8);
3232

3333
public:
3434
/// Returns the next available buffer from the pool.
35-
span<uint8_t> acquire_payload_buffer(size_t size)
35+
span<uint8_t> acquire_payload_buffer(units::bytes size)
3636
{
37-
srsran_assert(size <= MAX_BUFFER_SIZE, "Buffer size (i.e., {}) exceeds maximum {}.", size, pool[index].size());
37+
srsran_assert(size.to_bits() <= static_cast<units::bits>(MAX_BUFFER_SIZE),
38+
"Buffer size (i.e., {}) exceeds maximum {}.",
39+
size,
40+
pool[index].size());
3841
unsigned i = index++ % MAX_NUM_PAYLOAD;
39-
return span<uint8_t>(pool[i]).first(size);
42+
return span<uint8_t>(pool[i]).first(size.value());
4043
}
4144

4245
private:
4346
/// Buffer pool.
44-
circular_array<std::array<uint8_t, MAX_BUFFER_SIZE>, MAX_NUM_PAYLOAD> pool;
47+
circular_array<std::array<uint8_t, MAX_BUFFER_SIZE.truncate_to_bytes().value()>, MAX_NUM_PAYLOAD> pool;
4548
/// Index used to retrieve the next container.
4649
unsigned index = 0;
4750
};

tests/unittests/fapi_adaptor/phy/messages/ul_pusch_pdu_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ TEST(fapi_phy_ul_pusch_adaptor_test, valid_pdu_pass)
8686
ASSERT_EQ(fapi_pdu.pusch_data.rv_index, phy_pdu.codeword.value().rv);
8787
ASSERT_EQ(fapi_pdu.pusch_data.new_data, phy_pdu.codeword.value().new_data);
8888
ASSERT_EQ(fapi_pdu.pusch_maintenance_v3.ldpc_base_graph, phy_pdu.codeword.value().ldpc_base_graph);
89-
ASSERT_EQ(fapi_pdu.pusch_data.tb_size.value(), pdu.tb_size);
89+
ASSERT_EQ(fapi_pdu.pusch_data.tb_size.value(), pdu.tb_size.value());
9090
ASSERT_EQ(fapi_pdu.pusch_data.harq_process_id, pdu.harq_id);
9191
}

0 commit comments

Comments
 (0)