2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2019-10-18 07:16:13 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2019-10-18 07:16:13 -07:00
|
|
|
*
|
2021-03-19 03:45:56 -07:00
|
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
2019-10-18 07:16:13 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* By using this file, you agree to the terms and conditions set
|
|
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
|
|
* the distribution.
|
2019-10-18 07:16:13 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#ifndef SRSRAN_SCHED_CARRIER_H
|
|
|
|
#define SRSRAN_SCHED_CARRIER_H
|
2019-10-18 07:16:13 -07:00
|
|
|
|
2020-11-20 02:54:16 -08:00
|
|
|
#include "sched.h"
|
2020-11-27 09:21:35 -08:00
|
|
|
#include "schedulers/sched_base.h"
|
2021-05-05 12:57:52 -07:00
|
|
|
#include "srsran/adt/pool/cached_alloc.h"
|
2021-03-19 03:45:56 -07:00
|
|
|
#include "srsran/srslog/srslog.h"
|
2019-10-18 07:16:13 -07:00
|
|
|
|
|
|
|
namespace srsenb {
|
|
|
|
|
|
|
|
class bc_sched;
|
|
|
|
class ra_sched;
|
|
|
|
|
|
|
|
class sched::carrier_sched
|
|
|
|
{
|
|
|
|
public:
|
2021-05-06 11:53:48 -07:00
|
|
|
explicit carrier_sched(rrc_interface_mac* rrc_,
|
|
|
|
sched_ue_list* ue_db_,
|
|
|
|
uint32_t enb_cc_idx_,
|
|
|
|
sched_result_ringbuffer* sched_results_);
|
2020-04-27 06:34:55 -07:00
|
|
|
~carrier_sched();
|
2020-03-04 15:39:42 -08:00
|
|
|
void reset();
|
|
|
|
void carrier_cfg(const sched_cell_params_t& sched_params_);
|
|
|
|
void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs);
|
2021-03-19 03:45:56 -07:00
|
|
|
const cc_sched_result& generate_tti_result(srsran::tti_point tti_rx);
|
2020-03-04 15:39:42 -08:00
|
|
|
int dl_rach_info(dl_sched_rar_info_t rar_info);
|
2019-10-18 07:16:13 -07:00
|
|
|
|
2019-11-28 09:45:26 -08:00
|
|
|
// getters
|
2020-01-25 04:31:20 -08:00
|
|
|
const ra_sched* get_ra_sched() const { return ra_sched_ptr.get(); }
|
2020-03-04 15:39:42 -08:00
|
|
|
//! Get a subframe result for a given tti
|
2020-11-27 16:44:03 -08:00
|
|
|
const sf_sched_result* get_sf_result(tti_point tti_rx) const;
|
2019-11-28 09:45:26 -08:00
|
|
|
|
|
|
|
private:
|
2019-10-18 07:16:13 -07:00
|
|
|
//! Compute DL scheduler result for given TTI
|
2020-01-25 04:31:20 -08:00
|
|
|
void alloc_dl_users(sf_sched* tti_result);
|
2019-10-18 07:16:13 -07:00
|
|
|
//! Compute UL scheduler result for given TTI
|
2020-01-25 04:31:20 -08:00
|
|
|
int alloc_ul_users(sf_sched* tti_sched);
|
2020-03-04 15:39:42 -08:00
|
|
|
//! Get sf_sched for a given TTI
|
2021-03-19 03:45:56 -07:00
|
|
|
sf_sched* get_sf_sched(srsran::tti_point tti_rx);
|
2019-10-18 07:16:13 -07:00
|
|
|
|
|
|
|
// args
|
2021-05-06 11:53:48 -07:00
|
|
|
const sched_cell_params_t* cc_cfg = nullptr;
|
|
|
|
srslog::basic_logger& logger;
|
|
|
|
rrc_interface_mac* rrc = nullptr;
|
|
|
|
sched_ue_list* ue_db = nullptr;
|
|
|
|
const uint32_t enb_cc_idx;
|
2019-10-18 07:16:13 -07:00
|
|
|
|
2020-06-09 04:28:19 -07:00
|
|
|
// Subframe scheduling logic
|
2021-03-19 03:45:56 -07:00
|
|
|
srsran::circular_array<sf_sched, TTIMOD_SZ> sf_scheds;
|
2020-06-09 04:28:19 -07:00
|
|
|
|
|
|
|
// scheduling results
|
2021-03-17 06:09:39 -07:00
|
|
|
sched_result_ringbuffer* prev_sched_results;
|
2020-03-04 15:39:42 -08:00
|
|
|
|
|
|
|
std::vector<uint8_t> sf_dl_mask; ///< Some TTIs may be forbidden for DL sched due to MBMS
|
2019-10-18 07:16:13 -07:00
|
|
|
|
2020-11-27 09:21:35 -08:00
|
|
|
std::unique_ptr<bc_sched> bc_sched_ptr;
|
|
|
|
std::unique_ptr<ra_sched> ra_sched_ptr;
|
|
|
|
std::unique_ptr<sched_base> sched_algo;
|
2019-10-18 07:16:13 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
//! Broadcast (SIB + paging) scheduler
|
|
|
|
class bc_sched
|
|
|
|
{
|
|
|
|
public:
|
2020-01-31 03:17:04 -08:00
|
|
|
explicit bc_sched(const sched_cell_params_t& cfg_, rrc_interface_mac* rrc_);
|
2020-01-25 04:31:20 -08:00
|
|
|
void dl_sched(sf_sched* tti_sched);
|
2019-10-18 07:16:13 -07:00
|
|
|
void reset();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct sched_sib_t {
|
2020-11-27 16:44:03 -08:00
|
|
|
bool is_in_window = false;
|
|
|
|
tti_point window_start{};
|
|
|
|
uint32_t n_tx = 0;
|
2019-10-18 07:16:13 -07:00
|
|
|
};
|
|
|
|
|
2020-01-25 04:31:20 -08:00
|
|
|
void update_si_windows(sf_sched* tti_sched);
|
|
|
|
void alloc_sibs(sf_sched* tti_sched);
|
|
|
|
void alloc_paging(sf_sched* tti_sched);
|
2019-10-18 07:16:13 -07:00
|
|
|
|
|
|
|
// args
|
2020-01-31 03:17:04 -08:00
|
|
|
const sched_cell_params_t* cc_cfg = nullptr;
|
|
|
|
rrc_interface_mac* rrc = nullptr;
|
2021-03-15 06:01:19 -07:00
|
|
|
srslog::basic_logger& logger;
|
2019-10-18 07:16:13 -07:00
|
|
|
|
|
|
|
std::array<sched_sib_t, sched_interface::MAX_SIBS> pending_sibs;
|
|
|
|
|
|
|
|
// TTI specific
|
2020-11-27 16:44:03 -08:00
|
|
|
tti_point current_tti{};
|
|
|
|
uint32_t bc_aggr_level = 2;
|
2019-10-18 07:16:13 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
//! RAR/Msg3 scheduler
|
|
|
|
class ra_sched
|
|
|
|
{
|
|
|
|
public:
|
2019-11-08 03:53:59 -08:00
|
|
|
using dl_sched_rar_info_t = sched_interface::dl_sched_rar_info_t;
|
|
|
|
using dl_sched_rar_t = sched_interface::dl_sched_rar_t;
|
2019-10-18 07:16:13 -07:00
|
|
|
using dl_sched_rar_grant_t = sched_interface::dl_sched_rar_grant_t;
|
|
|
|
|
2021-02-16 09:23:15 -08:00
|
|
|
explicit ra_sched(const sched_cell_params_t& cfg_, sched_ue_list& ue_db_);
|
2020-01-26 16:49:57 -08:00
|
|
|
void dl_sched(sf_sched* tti_sched);
|
2020-03-12 11:09:45 -07:00
|
|
|
void ul_sched(sf_sched* sf_dl_sched, sf_sched* sf_msg3_sched);
|
2020-01-26 16:49:57 -08:00
|
|
|
int dl_rach_info(dl_sched_rar_info_t rar_info);
|
|
|
|
void reset();
|
2019-10-18 07:16:13 -07:00
|
|
|
|
|
|
|
private:
|
2021-03-17 16:20:16 -07:00
|
|
|
alloc_result allocate_pending_rar(sf_sched* tti_sched, const pending_rar_t& rar, uint32_t& nof_grants_alloc);
|
2021-03-15 10:13:30 -07:00
|
|
|
|
2019-10-18 07:16:13 -07:00
|
|
|
// args
|
2021-02-16 09:23:15 -08:00
|
|
|
srslog::basic_logger& logger;
|
|
|
|
const sched_cell_params_t* cc_cfg = nullptr;
|
|
|
|
sched_ue_list* ue_db = nullptr;
|
2019-10-18 07:16:13 -07:00
|
|
|
|
2021-05-05 12:57:52 -07:00
|
|
|
srsran::deque<pending_rar_t> pending_rars;
|
|
|
|
uint32_t rar_aggr_level = 2;
|
|
|
|
static const uint32_t PRACH_RAR_OFFSET = 3; // TS 36.321 Sec. 5.1.4
|
2019-10-18 07:16:13 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace srsenb
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#endif // SRSRAN_SCHED_CARRIER_H
|