mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
5.8 KiB
C
170 lines
5.8 KiB
C
6 years ago
|
/*
|
||
5 years ago
|
* Copyright 2013-2020 Software Radio Systems Limited
|
||
8 years ago
|
*
|
||
|
* This file is part of srsLTE.
|
||
|
*
|
||
6 years ago
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
8 years ago
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of
|
||
|
* the License, or (at your option) any later version.
|
||
|
*
|
||
6 years ago
|
* srsLTE is distributed in the hope that it will be useful,
|
||
8 years ago
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* A copy of the GNU Affero General Public License can be found in
|
||
|
* the LICENSE file in the top-level directory of this distribution
|
||
|
* and at http://www.gnu.org/licenses/.
|
||
|
*
|
||
|
*/
|
||
8 years ago
|
|
||
7 years ago
|
#ifndef SRSENB_SCHEDULER_H
|
||
|
#define SRSENB_SCHEDULER_H
|
||
8 years ago
|
|
||
4 years ago
|
#include "sched_grid.h"
|
||
|
#include "sched_harq.h"
|
||
|
#include "sched_ue.h"
|
||
8 years ago
|
#include "srslte/common/log.h"
|
||
|
#include "srslte/interfaces/enb_interfaces.h"
|
||
|
#include "srslte/interfaces/sched_interface.h"
|
||
6 years ago
|
#include <map>
|
||
6 years ago
|
#include <mutex>
|
||
8 years ago
|
#include <pthread.h>
|
||
5 years ago
|
#include <queue>
|
||
8 years ago
|
|
||
|
namespace srsenb {
|
||
7 years ago
|
|
||
5 years ago
|
namespace sched_utils {
|
||
|
|
||
|
inline bool is_in_tti_interval(uint32_t tti, uint32_t tti1, uint32_t tti2)
|
||
|
{
|
||
|
tti %= 10240;
|
||
|
tti1 %= 10240;
|
||
|
tti2 %= 10240;
|
||
|
if (tti1 <= tti2) {
|
||
|
return tti >= tti1 and tti <= tti2;
|
||
|
}
|
||
|
return tti >= tti1 or tti <= tti2;
|
||
|
}
|
||
|
|
||
|
} // namespace sched_utils
|
||
7 years ago
|
|
||
|
/* Caution: User addition (ue_cfg) and removal (ue_rem) are not thread-safe
|
||
|
* Rest of operations are thread-safe
|
||
|
*
|
||
|
* The subclass sched_ue is thread-safe so that access to shared variables like buffer states
|
||
|
* from scheduler thread and other threads is protected for each individual user.
|
||
|
*/
|
||
|
|
||
8 years ago
|
class sched : public sched_interface
|
||
6 years ago
|
{
|
||
|
public:
|
||
8 years ago
|
/*************************************************************
|
||
5 years ago
|
*
|
||
8 years ago
|
* Scheduling metric interface definition
|
||
5 years ago
|
*
|
||
8 years ago
|
************************************************************/
|
||
6 years ago
|
|
||
8 years ago
|
class metric_dl
|
||
|
{
|
||
5 years ago
|
public:
|
||
5 years ago
|
virtual ~metric_dl() = default;
|
||
8 years ago
|
/* Virtual methods for user metric calculation */
|
||
5 years ago
|
virtual void set_params(const sched_cell_params_t& cell_params_) = 0;
|
||
5 years ago
|
virtual void sched_users(std::map<uint16_t, sched_ue>& ue_db, dl_sf_sched_itf* tti_sched) = 0;
|
||
8 years ago
|
};
|
||
|
|
||
|
class metric_ul
|
||
|
{
|
||
5 years ago
|
public:
|
||
5 years ago
|
virtual ~metric_ul() = default;
|
||
8 years ago
|
/* Virtual methods for user metric calculation */
|
||
5 years ago
|
virtual void set_params(const sched_cell_params_t& cell_params_) = 0;
|
||
5 years ago
|
virtual void sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_sf_sched_itf* tti_sched) = 0;
|
||
8 years ago
|
};
|
||
|
|
||
|
/*************************************************************
|
||
5 years ago
|
*
|
||
|
* FAPI-like Interface
|
||
|
*
|
||
8 years ago
|
************************************************************/
|
||
5 years ago
|
|
||
|
sched();
|
||
5 years ago
|
~sched() override;
|
||
7 years ago
|
|
||
5 years ago
|
void init(rrc_interface_mac* rrc);
|
||
5 years ago
|
int cell_cfg(const std::vector<cell_cfg_t>& cell_cfg) override;
|
||
5 years ago
|
void set_sched_cfg(sched_args_t* sched_cfg);
|
||
|
int reset() final;
|
||
8 years ago
|
|
||
5 years ago
|
int ue_cfg(uint16_t rnti, const ue_cfg_t& ue_cfg) final;
|
||
5 years ago
|
int ue_rem(uint16_t rnti) final;
|
||
|
bool ue_exists(uint16_t rnti) final;
|
||
5 years ago
|
|
||
5 years ago
|
void phy_config_enabled(uint16_t rnti, bool enabled);
|
||
8 years ago
|
|
||
5 years ago
|
int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, ue_bearer_cfg_t* cfg) final;
|
||
|
int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) final;
|
||
8 years ago
|
|
||
5 years ago
|
uint32_t get_ul_buffer(uint16_t rnti) final;
|
||
|
uint32_t get_dl_buffer(uint16_t rnti) final;
|
||
|
|
||
|
int dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) final;
|
||
5 years ago
|
int dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code, uint32_t nof_cmds = 1) final;
|
||
6 years ago
|
|
||
5 years ago
|
int dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack) final;
|
||
|
int dl_rach_info(uint32_t enb_cc_idx, dl_sched_rar_info_t rar_info) final;
|
||
|
int dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t ri_value) final;
|
||
|
int dl_pmi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t pmi_value) final;
|
||
|
int dl_cqi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t cqi_value) final;
|
||
|
int ul_crc_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, bool crc) final;
|
||
5 years ago
|
int ul_sr_info(uint32_t tti, uint16_t rnti) override;
|
||
5 years ago
|
int ul_bsr(uint16_t rnti, uint32_t lcg_id, uint32_t bsr) final;
|
||
5 years ago
|
int ul_phr(uint16_t rnti, int phr) final;
|
||
5 years ago
|
int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t cqi, uint32_t ul_ch_code) final;
|
||
6 years ago
|
|
||
5 years ago
|
int dl_sched(uint32_t tti, uint32_t enb_cc_idx, dl_sched_res_t& sched_result) final;
|
||
|
int ul_sched(uint32_t tti, uint32_t enb_cc_idx, ul_sched_res_t& sched_result) final;
|
||
8 years ago
|
|
||
6 years ago
|
/* Custom functions
|
||
8 years ago
|
*/
|
||
4 years ago
|
void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) final;
|
||
|
void tpc_inc(uint16_t rnti);
|
||
|
void tpc_dec(uint16_t rnti);
|
||
|
std::array<int, SRSLTE_MAX_CARRIERS> get_enb_ue_cc_map(uint16_t rnti) final;
|
||
|
std::array<bool, SRSLTE_MAX_CARRIERS> get_scell_activation_mask(uint16_t rnti) final;
|
||
|
int ul_buffer_add(uint16_t rnti, uint32_t lcid, uint32_t bytes) final;
|
||
8 years ago
|
|
||
5 years ago
|
class carrier_sched;
|
||
|
|
||
6 years ago
|
protected:
|
||
4 years ago
|
void new_tti(srslte::tti_point tti_rx);
|
||
|
bool is_generated(srslte::tti_point, uint32_t enb_cc_idx) const;
|
||
5 years ago
|
// Helper methods
|
||
|
template <typename Func>
|
||
5 years ago
|
int ue_db_access(uint16_t rnti, Func, const char* func_name = nullptr);
|
||
5 years ago
|
|
||
|
// args
|
||
5 years ago
|
srslte::log_ref log_h;
|
||
5 years ago
|
rrc_interface_mac* rrc = nullptr;
|
||
|
sched_args_t sched_cfg = {};
|
||
|
std::vector<sched_cell_params_t> sched_cell_params;
|
||
7 years ago
|
|
||
5 years ago
|
std::map<uint16_t, sched_ue> ue_db;
|
||
6 years ago
|
|
||
5 years ago
|
// independent schedulers for each carrier
|
||
5 years ago
|
std::vector<std::unique_ptr<carrier_sched> > carrier_schedulers;
|
||
5 years ago
|
|
||
5 years ago
|
// Storage of past scheduling results
|
||
|
sched_result_list sched_results;
|
||
|
|
||
4 years ago
|
srslte::tti_point last_tti;
|
||
|
std::mutex sched_mutex;
|
||
|
bool configured = false;
|
||
8 years ago
|
};
|
||
|
|
||
5 years ago
|
} // namespace srsenb
|
||
8 years ago
|
|
||
7 years ago
|
#endif // SRSENB_SCHEDULER_H
|