@@ -424,6 +424,113 @@ TEST_P(EthFramePoolFixture, read_interval_should_return_correct_data)
424424 pool.clear_sent_frame_buffers (interval);
425425}
426426
427+ // Pool should have enough space to store C-Plane and U-Plane packets for all antennas.
428+ TEST_P (EthFramePoolFixture, pool_should_have_enough_space)
429+ {
430+ slot_point slot (to_numerology_value (scs), 0 );
431+ for (unsigned slot_count = 0 ; slot_count < TEST_NUM_SLOTS; ++slot_count) {
432+ for (unsigned symbol = 0 ; symbol < nof_symbols; ++symbol) {
433+ ofh::slot_symbol_point symbol_point (slot, symbol, nof_symbols);
434+ ether::frame_pool_context ctx{{ofh_type, ofh::data_direction::downlink}, symbol_point};
435+ unsigned nof_requested_buffers = ofh::MAX_NOF_SUPPORTED_EAXC;
436+ // DL C-Plane and U-Plane
437+ for (unsigned i = 0 ; i != nof_requested_buffers; ++i) {
438+ span<frame_buffer> frame_buffers = pool.get_frame_buffers (ctx);
439+ ASSERT_TRUE (!frame_buffers.empty ()) << " Non-empty span of buffers expected" ;
440+ for (auto & buffer : frame_buffers) {
441+ buffer.set_size (64 );
442+ }
443+ pool.push_frame_buffers (ctx, frame_buffers);
444+ }
445+ pool.read_frame_buffers (ctx);
446+ pool.clear_sent_frame_buffers (ctx);
447+
448+ if (ofh_type == ofh::message_type::user_plane) {
449+ continue ;
450+ }
451+ // UL C-Plane
452+ // We may need to write Type 1 and Type 3 C-Plane messages in the same slot and symbol.
453+ nof_requested_buffers *= 2 ;
454+ ctx = {{ofh_type, ofh::data_direction::uplink}, symbol_point};
455+ for (unsigned i = 0 ; i != nof_requested_buffers; ++i) {
456+ span<frame_buffer> frame_buffers = pool.get_frame_buffers (ctx);
457+ ASSERT_TRUE (!frame_buffers.empty ()) << " Non-empty span of buffers expected" ;
458+ for (auto & buffer : frame_buffers) {
459+ buffer.set_size (64 );
460+ }
461+ pool.push_frame_buffers (ctx, frame_buffers);
462+ }
463+ pool.read_frame_buffers (ctx);
464+ pool.clear_sent_frame_buffers (ctx);
465+ }
466+ ++slot;
467+ }
468+ }
469+
470+ TEST_P (EthFramePoolFixture, clearing_full_pool_should_allow_adding_more_data)
471+ {
472+ slot_point slot (to_numerology_value (scs), 0 );
473+ for (unsigned slot_count = 0 ; slot_count < TEST_NUM_SLOTS; ++slot_count) {
474+ for (unsigned symbol = 0 ; symbol < nof_symbols; ++symbol) {
475+ ofh::slot_symbol_point symbol_point (slot, symbol, nof_symbols);
476+
477+ if (ofh_type == ofh::message_type::control_plane && symbol != 0 ) {
478+ continue ;
479+ }
480+
481+ // DL C-Plane and U-Plane
482+ bool pool_has_space = true ;
483+ ether::frame_pool_context ctx{{ofh_type, ofh::data_direction::downlink}, symbol_point};
484+ unsigned nof_requested_buffers = ofh::MAX_NOF_SUPPORTED_EAXC;
485+ while (pool_has_space) {
486+ span<frame_buffer> frame_buffers = pool.get_frame_buffers (ctx);
487+ pool_has_space = !frame_buffers.empty ();
488+ for (auto & buffer : frame_buffers) {
489+ buffer.set_size (64 );
490+ }
491+ pool.push_frame_buffers (ctx, frame_buffers);
492+ }
493+ // Clear full slot in the pool and try to get buffers again.
494+ pool.clear_slot (slot);
495+ for (unsigned i = 0 ; i != nof_requested_buffers; ++i) {
496+ span<frame_buffer> frame_buffers = pool.get_frame_buffers (ctx);
497+ ASSERT_TRUE (!frame_buffers.empty ()) << " Non-empty span of buffers expected" ;
498+ pool.push_frame_buffers (ctx, frame_buffers);
499+ }
500+ pool.read_frame_buffers (ctx);
501+ pool.clear_sent_frame_buffers (ctx);
502+
503+ if (ofh_type == ofh::message_type::user_plane) {
504+ continue ;
505+ }
506+
507+ // UL C-Plane
508+ // We may need to write Type 1 and Type 3 C-Plane messages in the same slot and symbol.
509+ nof_requested_buffers *= 2 ;
510+ ctx = {{ofh_type, ofh::data_direction::uplink}, symbol_point};
511+ pool_has_space = true ;
512+ while (pool_has_space) {
513+ span<frame_buffer> frame_buffers = pool.get_frame_buffers (ctx);
514+ pool_has_space = !frame_buffers.empty ();
515+ for (auto & buffer : frame_buffers) {
516+ buffer.set_size (64 );
517+ }
518+ pool.push_frame_buffers (ctx, frame_buffers);
519+ }
520+ // Clear full slot in the pool and try to get buffers again.
521+ pool.clear_slot (slot);
522+ for (unsigned i = 0 ; i != nof_requested_buffers; ++i) {
523+ span<frame_buffer> frame_buffers = pool.get_frame_buffers (ctx);
524+ ASSERT_TRUE (!frame_buffers.empty ()) << " Non-empty span of buffers expected" ;
525+ pool.push_frame_buffers (ctx, frame_buffers);
526+ }
527+ pool.read_frame_buffers (ctx);
528+ pool.clear_sent_frame_buffers (ctx);
529+ }
530+ ++slot;
531+ }
532+ }
533+
427534INSTANTIATE_TEST_SUITE_P (EthFramePoolTestSuite,
428535 EthFramePoolFixture,
429536 ::testing::Combine (::testing::Values(mtu::MTU_9000, mtu::MTU_5000, mtu::MTU_1500),
0 commit comments