From d18af603aa1408873cc86d00c101ace28e60805f Mon Sep 17 00:00:00 2001 From: Carlo Galiotto Date: Thu, 30 Sep 2021 19:27:35 +0200 Subject: [PATCH] sched,nr: address comments in PR (code formatting) Signed-off-by: Carlo Galiotto --- srsenb/hdr/stack/mac/nr/sched_nr_signalling.h | 17 +++- .../src/stack/mac/nr/sched_nr_signalling.cc | 88 ++++--------------- srsenb/test/mac/nr/sched_nr_test.cc | 17 ++-- 3 files changed, 40 insertions(+), 82 deletions(-) diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_signalling.h b/srsenb/hdr/stack/mac/nr/sched_nr_signalling.h index e66152481..6c8384ca2 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_signalling.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_signalling.h @@ -24,7 +24,22 @@ void sched_nzp_csi_rs(srsran::const_span nzp_csi_rs_set const srsran_slot_cfg_t& slot_cfg, nzp_csi_rs_list& csi_rs_list); -void sched_ssb_basic(const slot_point& sl_point, uint32_t ssb_periodicity, ssb_list& ssb_list); +/** + * @brief Schedule grant for SSB. + * + * The functions schedules the SSB according to a given periodicity. This function is a simplified version of an + * SSB scheduler and has several hard-coded parameters. + * + * @param[out] sl_point Slot point carrying information about current slot. + * @param[in] ssb_periodicity Periodicity of SSB in ms. + * @param[in] ssb_list List of SSB messages to be sent to PHY. + * + * @remark This function a is basic scheduling function that uses the following simplified assumption: + * 1) Subcarrier spacing: 15kHz + * 2) Frequency below 3GHz + * 3) Position in Burst is 1000, i.e., Only the first SSB of the 4 opportunities gets scheduled + */ +void sched_ssb_basic(const slot_point& sl_point, uint32_t ssb_periodicity, ssb_list& ssb_list); /// For a given BWP and slot, schedule SSB, NZP CSI RS and SIBs void sched_dl_signalling(const bwp_params& bwp_params, diff --git a/srsenb/src/stack/mac/nr/sched_nr_signalling.cc b/srsenb/src/stack/mac/nr/sched_nr_signalling.cc index a50bf8f76..1235fe012 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_signalling.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_signalling.cc @@ -12,10 +12,10 @@ #include "srsenb/hdr/stack/mac/nr/sched_nr_signalling.h" -#define POS_IN_BURST_FIRST_BIT_IDX 0 +#define POS_IN_BURST_FIRST_BIT_IDX 0 #define POS_IN_BURST_SECOND_BIT_IDX 1 -#define POS_IN_BURST_THIRD_BIT_IDX 2 -#define POS_IN_BURST_FOURTH_BIT_IDX 3 +#define POS_IN_BURST_THIRD_BIT_IDX 2 +#define POS_IN_BURST_FOURTH_BIT_IDX 3 #define DEFAULT_SSB_PERIODICITY 5 @@ -40,85 +40,31 @@ void sched_nzp_csi_rs(srsran::const_span nzp_csi_rs_set } } -void sched_ssb_basic(const slot_point& sl_point, uint32_t ssb_periodicity, ssb_list& ssb_list) +void sched_ssb_basic(const slot_point& sl_point, uint32_t ssb_periodicity, ssb_list& ssb_list) { - /* This function is extremely simplified. - * It works based on the following assumptions (hard-coded parameters) - * 1) 15kHz subcarrier spacing - * 2) Below 3GHz - * 3) Position in Burst 1000 - * */ - + // 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) if (ssb_periodicity == 0) ssb_periodicity = DEFAULT_SSB_PERIODICITY; uint32_t sl_idx = sl_point.to_uint(); - uint32_t ssb_sf_idx = sl_point.to_uint() % ssb_periodicity; + // mod operation of slot index by ssb_periodicity. With current subcarrier spacing, 1 slot = 1ms + uint32_t sl_point_mod = sl_point.to_uint() % ssb_periodicity; // code below is simplified - if (ssb_sf_idx == 0) - { - ssb_t ssb_msg = {}; - srsran_mib_nr_t mib_msg = {}; - mib_msg.sfn = sl_point.sfn(); - mib_msg.hrf = (sl_idx % SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) < SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) / 2); - mib_msg.ssb_idx = 0; // This corresponds to "Position in Burst" = 1000 + if (sl_point_mod == 0) { + ssb_t ssb_msg = {}; + srsran_mib_nr_t mib_msg = {}; + mib_msg.sfn = sl_point.sfn(); + mib_msg.hrf = (sl_idx % SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) < + SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz) / 2); + // This corresponds to "Position in Burst" = 1000 + mib_msg.ssb_idx = 0; + // Pack mib message to be sent to PHY srsran_pbch_msg_nr_mib_pack(&mib_msg, &ssb_msg.pbch_msg); ssb_list.push_back(ssb_msg); } - -} - -#if 0 -void sched_ssb(int slot_idx, int ssb_periodicity, srsran::bounded_bitset<4>& pos_in_burst) -{ - /* Input needed: - * - slot_idx: slot index - * - ssb_periodicity: Periodicity of SSB in ms - * - pos_in_burst: position in Burst (bit map indicating in which SSB opportunities gNB needs to tx - * - * Parameters that could be passed but are currently hard-coded - * - Subcarrier spacing: 15kHz - * - Frequency (info on whether carrier is above or below 3GHz) - * - * NOTE: this function is hard coded for frequency < 3GHz, - * and SubCarrierSpacing 15kHz. Therefore, we assume - * 1 slot = 1ms - * */ - - // NOTE: This - // This function only implements SSB for frequency < 3GHz, and SubCarrierSpacing 15kHz - // In this case, 1 slot = 1ms - int ssb_sf_idx = slot_idx % ssb_periodicity; - - // if slot falls into the correct periodicity, continue with further checks - // check if slot is - - // code below will be simplified, depending on struct used - if (ssb_sf_idx == 0) - { - // check first two bit in bitmap (position in burst) - // and pack corresponding SSB for slot 0 - if ( pos_in_burst.test(POS_IN_BURST_FIRST_BIT_IDX) ) - printf("Pack first SSB in slot 0 "); - if ( pos_in_burst.test(POS_IN_BURST_SECOND_BIT_IDX) ) - printf("Pack second SSB in slot 0 "); - } - else if (ssb_sf_idx == 1) - { - // check second two bit in bitmap (position in burst) - // and pack corresponding SSB for slot 1 - if ( pos_in_burst.test(POS_IN_BURST_FIRST_BIT_IDX) ) - printf("Pack first SSB in slot 1 "); - if ( pos_in_burst.test(POS_IN_BURST_SECOND_BIT_IDX) ) - printf("Pack second SSB in slot 1 "); - } - else - // nothing to do here - return; - } -#endif void sched_dl_signalling(const bwp_params& bwp_params, slot_point sl_pdcch, diff --git a/srsenb/test/mac/nr/sched_nr_test.cc b/srsenb/test/mac/nr/sched_nr_test.cc index 2ef3a3e50..18fa0bea1 100644 --- a/srsenb/test/mac/nr/sched_nr_test.cc +++ b/srsenb/test/mac/nr/sched_nr_test.cc @@ -127,13 +127,12 @@ void sched_nr_cfg_serialized_test() } /* - * This test runs the scheduler and verify that the SSB grant is present - * with the required periodicity + * @brief Test whether the SSB grant gets scheduled with the correct periodicity. + * */ void sched_nr_ssb_test() { const uint32_t ssb_periodicity = 5; - int tmp = 0; uint32_t max_nof_ttis = 1000, nof_sectors = 4; task_job_manager tasks; @@ -167,20 +166,18 @@ void sched_nr_ssb_test() sched_tester.update(out); tasks.finish_cc(slot_rx, dl_res, ul_res); /* - * Verify that with SSB periodicity, dl_res has: + * Verify that, with correct SSB periodicity, dl_res has: * 1) SSB grant - * 2) 4 LSB of SFN in packed MIB message is correct + * 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 ); + 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 - */ + /// Verify that, outside SSB periodicity, dl_res HAS NO SSB grant else TESTASSERT(dl_res.dl_sched.ssb.size() == 0); }