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.
225 lines
7.5 KiB
C
225 lines
7.5 KiB
C
6 years ago
|
/*
|
||
|
* Copyright 2013-2019 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_UE_H
|
||
|
#define SRSENB_SCHEDULER_UE_H
|
||
8 years ago
|
|
||
|
#include <map>
|
||
|
#include "srslte/common/log.h"
|
||
|
#include "srslte/interfaces/sched_interface.h"
|
||
|
|
||
|
#include "scheduler_harq.h"
|
||
6 years ago
|
#include "srslte/asn1/rrc_asn1.h"
|
||
8 years ago
|
|
||
|
namespace srsenb {
|
||
|
|
||
7 years ago
|
|
||
|
/** This class is designed to be thread-safe because it is called from workers through scheduler thread and from
|
||
|
* higher layers and mac threads.
|
||
|
*
|
||
|
* 1 mutex is created for every user and only access to same user variables are mutexed
|
||
|
*/
|
||
8 years ago
|
class sched_ue {
|
||
7 years ago
|
|
||
6 years ago
|
public:
|
||
|
// used by sched_metric to store the pdsch/pusch allocations
|
||
7 years ago
|
bool has_pucch;
|
||
8 years ago
|
|
||
|
typedef struct {
|
||
|
uint32_t cce_start[4][6];
|
||
|
uint32_t nof_loc[4];
|
||
|
} sched_dci_cce_t;
|
||
|
|
||
|
/*************************************************************
|
||
|
*
|
||
|
* FAPI-like Interface
|
||
|
*
|
||
|
************************************************************/
|
||
|
sched_ue();
|
||
7 years ago
|
~sched_ue();
|
||
8 years ago
|
void reset();
|
||
|
void phy_config_enabled(uint32_t tti, bool enabled);
|
||
|
void set_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg, sched_interface::cell_cfg_t *cell_cfg,
|
||
|
srslte_regs_t *regs, srslte::log *log_h);
|
||
|
|
||
|
void set_bearer_cfg(uint32_t lc_id, srsenb::sched_interface::ue_bearer_cfg_t* cfg);
|
||
|
void rem_bearer(uint32_t lc_id);
|
||
|
|
||
|
void dl_buffer_state(uint8_t lc_id, uint32_t tx_queue, uint32_t retx_queue);
|
||
7 years ago
|
void ul_buffer_state(uint8_t lc_id, uint32_t bsr, bool set_value = true);
|
||
8 years ago
|
void ul_phr(int phr);
|
||
|
void mac_buffer_state(uint32_t ce_code);
|
||
|
void ul_recv_len(uint32_t lcid, uint32_t len);
|
||
6 years ago
|
void set_dl_ant_info(asn1::rrc::phys_cfg_ded_s::ant_info_c_* dedicated);
|
||
8 years ago
|
void set_ul_cqi(uint32_t tti, uint32_t cqi, uint32_t ul_ch_code);
|
||
7 years ago
|
void set_dl_ri(uint32_t tti, uint32_t ri);
|
||
7 years ago
|
void set_dl_pmi(uint32_t tti, uint32_t ri);
|
||
8 years ago
|
void set_dl_cqi(uint32_t tti, uint32_t cqi);
|
||
7 years ago
|
int set_ack_info(uint32_t tti, uint32_t tb_idx, bool ack);
|
||
8 years ago
|
void set_ul_crc(uint32_t tti, bool crc_res);
|
||
|
|
||
|
/*******************************************************
|
||
|
* Custom functions
|
||
|
*******************************************************/
|
||
|
|
||
|
void tpc_inc();
|
||
|
void tpc_dec();
|
||
|
|
||
6 years ago
|
void set_max_mcs(int mcs_ul, int mcs_dl);
|
||
|
void set_fixed_mcs(int mcs_ul, int mcs_dl);
|
||
|
|
||
6 years ago
|
dl_harq_proc* find_dl_harq(uint32_t tti);
|
||
|
dl_harq_proc* get_dl_harq(uint32_t idx);
|
||
|
uint16_t get_rnti() const { return rnti; }
|
||
6 years ago
|
|
||
|
/*******************************************************
|
||
|
* Functions used by scheduler metric objects
|
||
|
*******************************************************/
|
||
8 years ago
|
|
||
7 years ago
|
uint32_t get_required_prb_dl(uint32_t req_bytes, uint32_t nof_ctrl_symbols);
|
||
|
uint32_t get_required_prb_ul(uint32_t req_bytes);
|
||
|
uint32_t prb_to_rbg(uint32_t nof_prb);
|
||
|
uint32_t rgb_to_prb(uint32_t nof_rbg);
|
||
|
|
||
8 years ago
|
|
||
|
uint32_t get_pending_dl_new_data(uint32_t tti);
|
||
|
uint32_t get_pending_ul_new_data(uint32_t tti);
|
||
7 years ago
|
uint32_t get_pending_ul_old_data();
|
||
7 years ago
|
uint32_t get_pending_dl_new_data_total(uint32_t tti);
|
||
8 years ago
|
|
||
6 years ago
|
void reset_pending_pids(uint32_t tti_rx);
|
||
8 years ago
|
dl_harq_proc *get_pending_dl_harq(uint32_t tti);
|
||
6 years ago
|
dl_harq_proc* get_empty_dl_harq();
|
||
|
ul_harq_proc* get_ul_harq(uint32_t tti);
|
||
8 years ago
|
|
||
6 years ago
|
/*******************************************************
|
||
|
* Functions used by the scheduler object
|
||
|
*******************************************************/
|
||
8 years ago
|
|
||
|
void set_sr();
|
||
|
void unset_sr();
|
||
|
|
||
6 years ago
|
int generate_format1(
|
||
|
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask);
|
||
|
int generate_format2a(
|
||
|
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask);
|
||
|
int generate_format2(
|
||
|
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask);
|
||
|
int generate_format0(sched_interface::ul_sched_data_t* data,
|
||
|
uint32_t tti,
|
||
|
ul_harq_proc::ul_alloc_t alloc,
|
||
|
bool needs_pdcch,
|
||
|
srslte_dci_location_t cce_range,
|
||
|
int explicit_mcs = -1);
|
||
7 years ago
|
|
||
|
srslte_dci_format_t get_dci_format();
|
||
8 years ago
|
uint32_t get_aggr_level(uint32_t nof_bits);
|
||
|
sched_dci_cce_t *get_locations(uint32_t current_cfi, uint32_t sf_idx);
|
||
|
|
||
|
bool needs_cqi(uint32_t tti, bool will_send = false);
|
||
|
uint32_t get_max_retx();
|
||
|
|
||
7 years ago
|
bool get_pucch_sched(uint32_t current_tti, uint32_t prb_idx[2]);
|
||
7 years ago
|
bool pucch_sr_collision(uint32_t current_tti, uint32_t n_cce);
|
||
|
|
||
8 years ago
|
private:
|
||
|
|
||
|
typedef struct {
|
||
|
sched_interface::ue_bearer_cfg_t cfg;
|
||
|
int buf_tx;
|
||
|
int buf_retx;
|
||
|
int bsr;
|
||
|
} ue_bearer_t;
|
||
|
|
||
|
bool is_sr_triggered();
|
||
7 years ago
|
int alloc_pdu(int tbs, sched_interface::dl_sched_pdu_t* pdu);
|
||
8 years ago
|
|
||
6 years ago
|
static uint32_t format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb);
|
||
6 years ago
|
static int cqi_to_tbs(
|
||
|
uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t max_mcs, uint32_t max_Qm, bool is_ul, uint32_t* mcs);
|
||
7 years ago
|
int alloc_tbs_dl(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int *mcs);
|
||
|
int alloc_tbs_ul(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int *mcs);
|
||
|
int alloc_tbs(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, bool is_ul, int *mcs);
|
||
8 years ago
|
|
||
|
static bool bearer_is_ul(ue_bearer_t *lch);
|
||
|
static bool bearer_is_dl(ue_bearer_t *lch);
|
||
7 years ago
|
|
||
7 years ago
|
uint32_t get_pending_dl_new_data_unlocked(uint32_t tti);
|
||
|
uint32_t get_pending_ul_old_data_unlocked();
|
||
|
uint32_t get_pending_ul_new_data_unlocked(uint32_t tti);
|
||
6 years ago
|
uint32_t get_pending_dl_new_data_total_unlocked(uint32_t tti);
|
||
7 years ago
|
|
||
|
bool needs_cqi_unlocked(uint32_t tti, bool will_send = false);
|
||
|
|
||
6 years ago
|
int generate_format2a_unlocked(
|
||
|
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask);
|
||
7 years ago
|
|
||
8 years ago
|
bool is_first_dl_tx();
|
||
7 years ago
|
|
||
|
sched_interface::ue_cfg_t cfg;
|
||
8 years ago
|
srslte_cell_t cell;
|
||
|
srslte::log* log_h;
|
||
7 years ago
|
|
||
|
pthread_mutex_t mutex;
|
||
8 years ago
|
|
||
|
/* Buffer states */
|
||
|
bool sr;
|
||
|
int buf_mac;
|
||
|
int buf_ul;
|
||
|
ue_bearer_t lch[sched_interface::MAX_LC];
|
||
|
|
||
|
int power_headroom;
|
||
7 years ago
|
uint32_t dl_ri;
|
||
|
uint32_t dl_ri_tti;
|
||
7 years ago
|
uint32_t dl_pmi;
|
||
|
uint32_t dl_pmi_tti;
|
||
8 years ago
|
uint32_t dl_cqi;
|
||
|
uint32_t dl_cqi_tti;
|
||
|
uint32_t cqi_request_tti;
|
||
|
uint32_t ul_cqi;
|
||
|
uint32_t ul_cqi_tti;
|
||
|
uint16_t rnti;
|
||
6 years ago
|
uint32_t max_mcs_dl;
|
||
|
uint32_t max_mcs_ul;
|
||
|
uint32_t max_msg3retx;
|
||
8 years ago
|
int fixed_mcs_ul;
|
||
7 years ago
|
int fixed_mcs_dl;
|
||
|
uint32_t P;
|
||
8 years ago
|
|
||
|
int next_tpc_pusch;
|
||
6 years ago
|
int next_tpc_pucch;
|
||
8 years ago
|
|
||
6 years ago
|
// Allowed DCI locations per CFI and per subframe
|
||
|
sched_dci_cce_t dci_locations[3][10];
|
||
8 years ago
|
|
||
6 years ago
|
const static int SCHED_MAX_HARQ_PROC = SRSLTE_FDD_NOF_HARQ;
|
||
8 years ago
|
dl_harq_proc dl_harq[SCHED_MAX_HARQ_PROC];
|
||
|
ul_harq_proc ul_harq[SCHED_MAX_HARQ_PROC];
|
||
|
|
||
|
bool phy_config_dedicated_enabled;
|
||
6 years ago
|
asn1::rrc::phys_cfg_ded_s::ant_info_c_ dl_ant_info;
|
||
6 years ago
|
|
||
|
};
|
||
8 years ago
|
}
|
||
|
|
||
|
|
||
7 years ago
|
#endif // SRSENB_SCHEDULER_UE_H
|