sched,nr: move ssb_sched test to different file...

and also:
- correct half-frame bit in MIB package
- rename slot_index variable in ssb_sched function

Signed-off-by: Carlo Galiotto <carlo@srs.io>
master
Carlo Galiotto 3 years ago committed by Andre Puschmann
parent d18af603aa
commit 9887c17c17

@ -41,8 +41,8 @@ struct harq_ack_t {
}; };
using harq_ack_list_t = srsran::bounded_vector<harq_ack_t, MAX_GRANTS>; using harq_ack_list_t = srsran::bounded_vector<harq_ack_t, MAX_GRANTS>;
// save data for scheduler to keep track of previous allocations /// save data for scheduler to keep track of previous allocations
// This only contains information about a given slot /// This only contains information about a given slot
struct bwp_slot_grid { struct bwp_slot_grid {
uint32_t slot_idx = 0; uint32_t slot_idx = 0;
const bwp_params* cfg = nullptr; const bwp_params* cfg = nullptr;

@ -44,24 +44,33 @@ void sched_ssb_basic(const slot_point& sl_point, uint32_t ssb_periodicity, ssb_l
{ {
// If the periodicity is 0, it means that the parameter was not passed by the upper layers. // If the periodicity is 0, it means that the parameter was not passed by the upper layers.
// In that case, we use default value of 5ms (see Clause 4.1, TS 38.213) // In that case, we use default value of 5ms (see Clause 4.1, TS 38.213)
if (ssb_periodicity == 0) if (ssb_periodicity == 0) {
ssb_periodicity = DEFAULT_SSB_PERIODICITY; ssb_periodicity = DEFAULT_SSB_PERIODICITY;
}
uint32_t sl_idx = sl_point.to_uint(); uint32_t sl_cnt = sl_point.to_uint();
// mod operation of slot index by ssb_periodicity. With current subcarrier spacing, 1 slot = 1ms // Perform mod operation of slot index by ssb_periodicity;
uint32_t sl_point_mod = sl_point.to_uint() % ssb_periodicity; // "ssb_periodicity * nof_slots_per_subframe" gives the number of slots in 1 ssb_periodicity time interval
uint32_t sl_point_mod = sl_cnt % (ssb_periodicity * (uint32_t)sl_point.nof_slots_per_subframe());
// code below is simplified // code below is simplified, it assumes 15kHz subcarrier spacing and sub 3GHz carrier
if (sl_point_mod == 0) { if (sl_point_mod == 0) {
ssb_t ssb_msg = {}; ssb_t ssb_msg = {};
srsran_mib_nr_t mib_msg = {}; srsran_mib_nr_t mib_msg = {};
mib_msg.sfn = sl_point.sfn(); mib_msg.sfn = sl_point.sfn();
mib_msg.hrf = (sl_idx % SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) < mib_msg.hrf = (sl_point.slot_idx() % SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) >=
SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) / 2); SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) / 2);
// This corresponds to "Position in Burst" = 1000 // This corresponds to "Position in Burst" = 1000
mib_msg.ssb_idx = 0; mib_msg.ssb_idx = 0;
// Setting the following 4 parameters is redundant, but it makes it explicit what values are passed to PHY
mib_msg.dmrs_typeA_pos = srsran_dmrs_sch_typeA_pos_2;
mib_msg.scs_common = srsran_subcarrier_spacing_15kHz;
mib_msg.coreset0_idx = 0;
mib_msg.ss0_idx = 0;
// Pack mib message to be sent to PHY // Pack mib message to be sent to PHY
srsran_pbch_msg_nr_mib_pack(&mib_msg, &ssb_msg.pbch_msg); int packing_ret_code = srsran_pbch_msg_nr_mib_pack(&mib_msg, &ssb_msg.pbch_msg);
srsran_assert(packing_ret_code == SRSRAN_SUCCESS, "SSB packing returned en error");
ssb_list.push_back(ssb_msg); ssb_list.push_back(ssb_msg);
} }
} }

@ -12,6 +12,7 @@
#include "sched_nr_common_test.h" #include "sched_nr_common_test.h"
#include "srsran/support/srsran_test.h" #include "srsran/support/srsran_test.h"
#include <srsenb/hdr/stack/mac/nr/sched_nr_cfg.h>
namespace srsenb { namespace srsenb {
@ -40,4 +41,31 @@ void test_pdsch_consistency(srsran::const_span<mac_interface_phy_nr::pdsch_t> pd
} }
} }
void test_ssb_scheduled_grant(
srsran::slot_point& sl_point,
const srsran::bounded_vector<mac_interface_phy_nr::ssb_t, mac_interface_phy_nr::MAX_SSB>& ssb_list)
{
const uint32_t ssb_periodicity = 5;
/*
* Verify that, with correct SSB periodicity, dl_res has:
* 1) SSB grant
* 2) 4 LSBs of SFN in packed MIB message are correct
* 3) SSB index is 0
*/
if (sl_point.to_uint() % (ssb_periodicity * (uint32_t)sl_point.nof_slots_per_subframe()) == 0) {
TESTASSERT(ssb_list.size() == 1);
auto& ssb_item = ssb_list.back();
TESTASSERT(ssb_item.pbch_msg.sfn_4lsb == ((uint8_t)sl_point.sfn() & 0b1111));
bool expected_hrf = sl_point.slot_idx() % SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) >=
SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) / 2;
TESTASSERT(ssb_item.pbch_msg.hrf == expected_hrf);
TESTASSERT(ssb_item.pbch_msg.ssb_idx == 0);
}
// Verify that, outside SSB periodicity, there is NO SSB grant
else {
TESTASSERT(ssb_list.size() == 0);
}
}
} // namespace srsenb } // namespace srsenb

@ -20,6 +20,10 @@ namespace srsenb {
void test_dl_pdcch_consistency(srsran::const_span<sched_nr_impl::pdcch_dl_t> dl_pdcch); void test_dl_pdcch_consistency(srsran::const_span<sched_nr_impl::pdcch_dl_t> dl_pdcch);
void test_pdsch_consistency(srsran::const_span<mac_interface_phy_nr::pdsch_t> dl_pdcch); void test_pdsch_consistency(srsran::const_span<mac_interface_phy_nr::pdsch_t> dl_pdcch);
/// @brief Test whether the SSB grant gets scheduled with the correct periodicity.
void test_ssb_scheduled_grant(
srsran::slot_point& sl_point,
const srsran::bounded_vector<mac_interface_phy_nr::ssb_t, mac_interface_phy_nr::MAX_SSB>& ssb_list);
} // namespace srsenb } // namespace srsenb

@ -162,6 +162,8 @@ void sched_nr_sim_base::update(sched_nr_cc_output_res_t& cc_out)
// Run common tests // Run common tests
test_dl_pdcch_consistency(cc_out.dl_cc_result->dl_sched.pdcch_dl); test_dl_pdcch_consistency(cc_out.dl_cc_result->dl_sched.pdcch_dl);
test_pdsch_consistency(cc_out.dl_cc_result->dl_sched.pdsch); test_pdsch_consistency(cc_out.dl_cc_result->dl_sched.pdsch);
test_ssb_scheduled_grant(cc_out.slot, cc_out.dl_cc_result->dl_sched.ssb);
// Run UE-dedicated tests // Run UE-dedicated tests
test_dl_sched_result(ctxt, cc_out); test_dl_sched_result(ctxt, cc_out);

@ -126,74 +126,6 @@ void sched_nr_cfg_serialized_test()
printf("Total time taken per slot: %f usec\n", final_avg_usec); printf("Total time taken per slot: %f usec\n", final_avg_usec);
} }
/*
* @brief Test whether the SSB grant gets scheduled with the correct periodicity.
*
*/
void sched_nr_ssb_test()
{
const uint32_t ssb_periodicity = 5;
uint32_t max_nof_ttis = 1000, nof_sectors = 4;
task_job_manager tasks;
sched_nr_interface::sched_cfg_t cfg;
cfg.auto_refill_buffer = true;
std::vector<sched_nr_interface::cell_cfg_t> cells_cfg = get_default_cells_cfg(nof_sectors);
sched_nr_sim_base sched_tester(cfg, cells_cfg, "Serialized Test");
sched_nr_interface::ue_cfg_t uecfg = get_default_ue_cfg(nof_sectors);
uecfg.fixed_dl_mcs = 15;
uecfg.fixed_ul_mcs = 15;
sched_tester.add_user(0x46, uecfg, slot_point{0, 0}, 0);
std::vector<long> count_per_cc(nof_sectors, 0);
for (uint32_t nof_slots = 0; nof_slots < max_nof_ttis; ++nof_slots) {
slot_point slot_rx(0, nof_slots % 10240);
slot_point slot_tx = slot_rx + TX_ENB_DELAY;
tasks.start_slot(slot_rx, nof_sectors);
sched_tester.new_slot(slot_tx);
for (uint32_t cc = 0; cc < cells_cfg.size(); ++cc) {
sched_nr_interface::dl_sched_res_t dl_res;
sched_nr_interface::ul_sched_t ul_res;
auto tp1 = std::chrono::steady_clock::now();
TESTASSERT(sched_tester.get_sched()->get_dl_sched(slot_tx, cc, dl_res) == SRSRAN_SUCCESS);
TESTASSERT(sched_tester.get_sched()->get_ul_sched(slot_tx, cc, ul_res) == SRSRAN_SUCCESS);
auto tp2 = std::chrono::steady_clock::now();
count_per_cc[cc] += std::chrono::duration_cast<std::chrono::nanoseconds>(tp2 - tp1).count();
sched_nr_cc_output_res_t out{slot_tx, cc, &dl_res, &ul_res};
sched_tester.update(out);
tasks.finish_cc(slot_rx, dl_res, ul_res);
/*
* Verify that, with correct SSB periodicity, dl_res has:
* 1) SSB grant
* 2) 4 LSBs of SFN in packed MIB message are correct
* 3) SSB index is 0
*/
if (slot_tx.to_uint() % ssb_periodicity == 0) {
TESTASSERT(dl_res.dl_sched.ssb.size() == 1);
auto& ssb_item = dl_res.dl_sched.ssb.back();
TESTASSERT(ssb_item.pbch_msg.sfn_4lsb == ((uint8_t)slot_tx.sfn() & 0b1111));
TESTASSERT(ssb_item.pbch_msg.ssb_idx == 0);
}
/// Verify that, outside SSB periodicity, dl_res HAS NO SSB grant
else
TESTASSERT(dl_res.dl_sched.ssb.size() == 0);
}
}
tasks.print_results();
TESTASSERT(tasks.pdsch_count == (int)(max_nof_ttis * nof_sectors * 0.6));
double final_avg_usec = 0;
for (uint32_t cc = 0; cc < cells_cfg.size(); ++cc) {
final_avg_usec += count_per_cc[cc];
}
final_avg_usec = final_avg_usec / 1000.0 / max_nof_ttis;
printf("Total time taken per slot: %f usec\n", final_avg_usec);
}
void sched_nr_cfg_parallel_cc_test() void sched_nr_cfg_parallel_cc_test()
{ {
uint32_t nof_sectors = 4; uint32_t nof_sectors = 4;
@ -266,5 +198,4 @@ int main()
srsenb::sched_nr_cfg_serialized_test(); srsenb::sched_nr_cfg_serialized_test();
srsenb::sched_nr_cfg_parallel_cc_test(); srsenb::sched_nr_cfg_parallel_cc_test();
srsenb::sched_nr_ssb_test();
} }

Loading…
Cancel
Save