cleaned up some old patterns and run clang-format in RRC and scheduler

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent b2e6ef772b
commit 690a9850e7

@ -60,7 +60,7 @@ typedef struct {
class srslte_gw_config_t
{
public:
srslte_gw_config_t(uint32_t lcid_ = 0) : lcid(lcid_) {}
explicit srslte_gw_config_t(uint32_t lcid_ = 0) : lcid(lcid_) {}
uint32_t lcid;
};

@ -44,62 +44,53 @@ typedef enum {
LOG_LEVEL_DEBUG,
LOG_LEVEL_N_ITEMS
} LOG_LEVEL_ENUM;
static const char log_level_text[LOG_LEVEL_N_ITEMS][16] = {"None ",
"Error ",
"Warning",
"Info ",
"Debug "};
static const char log_level_text_short[LOG_LEVEL_N_ITEMS][16] = {"[-]",
"[E]",
"[W]",
"[I]",
"[D]"};
static const char log_level_text[LOG_LEVEL_N_ITEMS][16] = {"None ", "Error ", "Warning", "Info ", "Debug "};
static const char log_level_text_short[LOG_LEVEL_N_ITEMS][16] = {"[-]", "[E]", "[W]", "[I]", "[D]"};
class log
{
public:
log() {
service_name = "";
tti = 0;
level = LOG_LEVEL_NONE;
hex_limit = 0;
log()
{
service_name = "";
tti = 0;
level = LOG_LEVEL_NONE;
hex_limit = 0;
add_string_en = false;
}
log(std::string service_name_) {
service_name = service_name_;
tti = 0;
level = LOG_LEVEL_NONE;
hex_limit = 0;
explicit log(std::string service_name_)
{
service_name = std::move(service_name_);
tti = 0;
level = LOG_LEVEL_NONE;
hex_limit = 0;
add_string_en = false;
}
virtual ~log() {};
virtual ~log() = default;
// This function shall be called at the start of every tti for printing tti
void step(uint32_t tti_) {
tti = tti_;
add_string_en = false;
void step(uint32_t tti_)
{
tti = tti_;
add_string_en = false;
}
void prepend_string(std::string s) {
void prepend_string(std::string s)
{
add_string_en = true;
add_string_val = s;
add_string_val = std::move(s);
}
uint32_t get_tti() {
return tti;
}
uint32_t get_tti() { return tti; }
void set_level(LOG_LEVEL_ENUM l) {
level = l;
}
void set_level(LOG_LEVEL_ENUM l) { level = l; }
void set_level(std::string l) { set_level(get_level_from_string(l)); }
void set_level(std::string l) { set_level(get_level_from_string(std::move(l))); }
srslte::LOG_LEVEL_ENUM get_level_from_string(std::string l)
static srslte::LOG_LEVEL_ENUM get_level_from_string(std::string l)
{
std::transform(l.begin(), l.end(), l.begin(), ::toupper);
if ("NONE" == l) {
@ -117,42 +108,44 @@ public:
}
}
LOG_LEVEL_ENUM get_level() {
return level;
}
LOG_LEVEL_ENUM get_level() { return level; }
void set_hex_limit(int limit) {
hex_limit = limit;
}
int get_hex_limit() {
return hex_limit;
}
void set_hex_limit(int limit) { hex_limit = limit; }
int get_hex_limit() { return hex_limit; }
// Pure virtual methods for logging
virtual void console(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0;
virtual void error(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0;
virtual void warning(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0;
virtual void info(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0;
virtual void console(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void error(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void warning(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void info(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void info_long(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0;
virtual void debug(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void debug_long(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
// Same with hex dump
virtual void error_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5)))
{error("error_hex not implemented.\n");}
virtual void warning_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5)))
{error("warning_hex not implemented.\n");}
virtual void info_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5)))
{error("info_hex not implemented.\n");}
virtual void debug_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5)))
{error("debug_hex not implemented.\n");}
virtual void error_hex(const uint8_t*, int, const char*, ...) __attribute__((format(printf, 4, 5)))
{
error("error_hex not implemented.\n");
}
virtual void warning_hex(const uint8_t*, int, const char*, ...) __attribute__((format(printf, 4, 5)))
{
error("warning_hex not implemented.\n");
}
virtual void info_hex(const uint8_t*, int, const char*, ...) __attribute__((format(printf, 4, 5)))
{
error("info_hex not implemented.\n");
}
virtual void debug_hex(const uint8_t*, int, const char*, ...) __attribute__((format(printf, 4, 5)))
{
error("debug_hex not implemented.\n");
}
protected:
std::string get_service_name() { return service_name; }
uint32_t tti;
LOG_LEVEL_ENUM level;
int hex_limit;
std::string service_name;
std::string get_service_name() { return service_name; }
uint32_t tti;
LOG_LEVEL_ENUM level;
int hex_limit;
std::string service_name;
bool add_string_en;
std::string add_string_val;
@ -161,4 +154,3 @@ protected:
} // namespace srslte
#endif // SRSLTE_LOG_H

@ -48,7 +48,6 @@ public:
uint32_t period_rf;
} cell_cfg_sib_t;
typedef struct {
int pdsch_mcs;
int pdsch_max_mcs;
@ -58,7 +57,6 @@ public:
int max_aggr_level;
} sched_args_t;
typedef struct {
// Main cell configuration (used to calculate DCI locations in scheduler)
@ -66,7 +64,7 @@ public:
/* SIB configuration */
cell_cfg_sib_t sibs[MAX_SIBS];
uint32_t si_window_ms;
uint32_t si_window_ms;
/* pusch configuration */
srslte_pusch_hopping_cfg_t pusch_hopping_cfg;
@ -83,7 +81,7 @@ public:
uint32_t delta_pucch_shift;
// If non-negative, statically allocate N prbs at the edges of the uplink for PUCCH
int nrb_pucch;
int nrb_pucch;
uint32_t nrb_cqi;
uint32_t ncs_an;
@ -94,13 +92,12 @@ public:
} cell_cfg_t;
typedef struct {
int priority;
int bsd;
int pbr;
int group;
enum {IDLE = 0, UL, DL, BOTH} direction;
enum { IDLE = 0, UL, DL, BOTH } direction;
} ue_bearer_cfg_t;
typedef struct {
@ -113,7 +110,7 @@ public:
srslte_uci_offset_cfg_t uci_offset;
srslte_pucch_cfg_t pucch_cfg;
uint32_t aperiodic_cqi_period; // if 0 is periodic CQI
uint32_t aperiodic_cqi_period; // if 0 is periodic CQI
srslte_dl_cfg_t dl_cfg;
ue_bearer_cfg_t ue_bearers[MAX_LC];
@ -125,7 +122,6 @@ public:
uint32_t nbytes;
} dl_sched_pdu_t;
typedef struct {
uint32_t lcid;
uint32_t lcid_buffer_size;
@ -134,20 +130,20 @@ public:
} dl_mtch_sched_t;
typedef struct {
dl_sched_pdu_t pdu[20];
dl_sched_pdu_t pdu[20];
dl_mtch_sched_t mtch_sched[8];
uint32_t num_mtch_sched;
uint8_t *mcch_payload;
uint32_t current_sf_allocation_num;
uint32_t num_mtch_sched;
uint8_t* mcch_payload;
uint32_t current_sf_allocation_num;
} dl_pdu_mch_t;
typedef struct {
srslte_dci_dl_t dci;
uint32_t tbs[SRSLTE_MAX_TB];
bool mac_ce_ta;
bool mac_ce_rnti;
uint32_t nof_pdu_elems[SRSLTE_MAX_TB];
dl_sched_pdu_t pdu[SRSLTE_MAX_TB][MAX_RLC_PDU_LIST];
srslte_dci_dl_t dci;
uint32_t tbs[SRSLTE_MAX_TB];
bool mac_ce_ta;
bool mac_ce_rnti;
uint32_t nof_pdu_elems[SRSLTE_MAX_TB];
dl_sched_pdu_t pdu[SRSLTE_MAX_TB][MAX_RLC_PDU_LIST];
} dl_sched_data_t;
typedef struct {
@ -180,9 +176,7 @@ public:
typedef struct {
srslte_dci_dl_t dci;
enum bc_type {
BCCH, PCCH
} type;
enum bc_type { BCCH, PCCH } type;
uint32_t index;
@ -191,10 +185,10 @@ public:
} dl_sched_bc_t;
typedef struct {
uint32_t cfi;
uint32_t nof_data_elems;
uint32_t nof_rar_elems;
uint32_t nof_bc_elems;
uint32_t cfi;
uint32_t nof_data_elems;
uint32_t nof_rar_elems;
uint32_t nof_bc_elems;
dl_sched_data_t data[MAX_DATA_LIST];
dl_sched_rar_t rar[MAX_RAR_LIST];
dl_sched_bc_t bc[MAX_BC_LIST];
@ -202,14 +196,12 @@ public:
typedef struct {
uint16_t rnti;
enum phich_elem {
ACK, NACK
} phich;
enum phich_elem { ACK, NACK } phich;
} ul_sched_phich_t;
typedef struct {
uint32_t nof_dci_elems;
uint32_t nof_phich_elems;
uint32_t nof_dci_elems;
uint32_t nof_phich_elems;
ul_sched_data_t pusch[MAX_DATA_LIST];
ul_sched_phich_t phich[MAX_PHICH_LIST];
} ul_sched_res_t;
@ -217,17 +209,17 @@ public:
/******************* Scheduler Control ****************************/
/* Provides cell configuration including SIB periodicity, etc. */
virtual int cell_cfg(cell_cfg_t *cell_cfg) = 0;
virtual int reset() = 0;
virtual int cell_cfg(cell_cfg_t* cell_cfg) = 0;
virtual int reset() = 0;
/* Manages UE scheduling context */
virtual int ue_cfg(uint16_t rnti, ue_cfg_t *cfg) = 0;
virtual int ue_rem(uint16_t rnti) = 0;
virtual bool ue_exists(uint16_t rnti) = 0;
virtual int ue_cfg(uint16_t rnti, ue_cfg_t* cfg) = 0;
virtual int ue_rem(uint16_t rnti) = 0;
virtual bool ue_exists(uint16_t rnti) = 0;
/* Manages UE bearers and associated configuration */
virtual int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, ue_bearer_cfg_t *cfg) = 0;
virtual int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) = 0;
virtual int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, ue_bearer_cfg_t* cfg) = 0;
virtual int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) = 0;
virtual uint32_t get_ul_buffer(uint16_t rnti) = 0;
virtual uint32_t get_dl_buffer(uint16_t rnti) = 0;
@ -235,31 +227,31 @@ public:
/******************* Scheduling Interface ***********************/
/* DL buffer status report */
virtual int dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) = 0;
virtual int dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code) = 0;
virtual int dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code) = 0;
/* DL information */
virtual int dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t tb_idx, bool ack) = 0;
virtual int dl_rach_info(dl_sched_rar_info_t rar_info) = 0;
virtual int dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value) = 0;
virtual int dl_pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value) = 0;
virtual int dl_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value) = 0;
virtual int dl_rach_info(dl_sched_rar_info_t rar_info) = 0;
virtual int dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value) = 0;
virtual int dl_pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value) = 0;
virtual int dl_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value) = 0;
/* UL information */
virtual int ul_crc_info(uint32_t tti, uint16_t rnti, bool crc) = 0;
virtual int ul_sr_info(uint32_t tti, uint16_t rnti) = 0;
virtual int ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value = true) = 0;
virtual int ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len) = 0;
virtual int ul_phr(uint16_t rnti, int phr) = 0;
virtual int ul_crc_info(uint32_t tti, uint16_t rnti, bool crc) = 0;
virtual int ul_sr_info(uint32_t tti, uint16_t rnti) = 0;
virtual int ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value = true) = 0;
virtual int ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len) = 0;
virtual int ul_phr(uint16_t rnti, int phr) = 0;
virtual int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi, uint32_t ul_ch_code) = 0;
/* Run Scheduler for this tti */
virtual int dl_sched(uint32_t tti, dl_sched_res_t *sched_result) = 0;
virtual int ul_sched(uint32_t tti, ul_sched_res_t *sched_result) = 0;
virtual int dl_sched(uint32_t tti, dl_sched_res_t* sched_result) = 0;
virtual int ul_sched(uint32_t tti, ul_sched_res_t* sched_result) = 0;
/* Custom */
virtual void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) = 0;
};
}
} // namespace srsenb
#endif // SRSLTE_SCHED_INTERFACE_H

@ -30,8 +30,8 @@
#include "srslte/interfaces/sched_interface.h"
#include <map>
#include <mutex>
#include <queue>
#include <pthread.h>
#include <queue>
namespace srsenb {
@ -142,8 +142,11 @@ public:
const static int rv_idx[4] = {0, 2, 3, 1};
return rv_idx[retx_idx % 4];
}
static void generate_cce_location(
srslte_regs_t* regs, sched_ue::sched_dci_cce_t* location, uint32_t cfi, uint32_t sf_idx = 0, uint16_t rnti = 0);
static void generate_cce_location(srslte_regs_t* regs,
sched_ue::sched_dci_cce_t* location,
uint32_t cfi,
uint32_t sf_idx = 0,
uint16_t rnti = 0);
static uint32_t aggr_level(uint32_t aggr_idx) { return 1u << aggr_idx; }
class carrier_sched;

@ -115,12 +115,16 @@ public:
ul_harq_proc::ul_alloc_t alloc,
tti_sched_result_t::ul_alloc_t::type_t alloc_type,
uint32_t msg3 = 0);
int generate_format1a(
uint32_t rb_start, uint32_t l_crb, uint32_t tbs, uint32_t rv, uint16_t rnti, srslte_dci_dl_t* dci);
void set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
void set_rar_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
void set_dl_data_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
void set_ul_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
int generate_format1a(uint32_t rb_start,
uint32_t l_crb,
uint32_t tbs,
uint32_t rv,
uint16_t rnti,
srslte_dci_dl_t* dci);
void set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
void set_rar_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
void set_dl_data_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
void set_ul_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
// consts
carrier_sched* parent_carrier = nullptr;
@ -210,8 +214,8 @@ private:
class ra_sched
{
public:
using dl_sched_rar_info_t = sched_interface::dl_sched_rar_info_t;
using dl_sched_rar_t = sched_interface::dl_sched_rar_t;
using dl_sched_rar_info_t = sched_interface::dl_sched_rar_info_t;
using dl_sched_rar_t = sched_interface::dl_sched_rar_t;
using dl_sched_rar_grant_t = sched_interface::dl_sched_rar_grant_t;
struct pending_msg3_t {
bool enabled = false;
@ -230,22 +234,15 @@ public:
const pending_msg3_t& find_pending_msg3(uint32_t tti);
private:
struct sched_rar_t {
int buf_rar = 0;
uint16_t rnti = 0;
uint32_t ra_id = 0;
uint32_t rar_tti = 0;
};
// args
srslte::log* log_h = nullptr;
sched::cell_cfg_t* cfg;
std::map<uint16_t, sched_ue>* ue_db = nullptr;
std::queue<dl_sched_rar_info_t> pending_rars;
std::array<pending_msg3_t, TTIMOD_SZ> pending_msg3;
uint32_t tti_tx_dl = 0;
uint32_t rar_aggr_level = 2;
std::queue<dl_sched_rar_info_t> pending_rars;
std::array<pending_msg3_t, TTIMOD_SZ> pending_msg3;
uint32_t tti_tx_dl = 0;
uint32_t rar_aggr_level = 2;
};
} // namespace srsenb

@ -43,7 +43,9 @@ struct rbg_range_t {
};
// Range of PRBs
struct prb_range_t {
class prb_range_t
{
public:
uint32_t prb_start = 0, prb_end = 0;
prb_range_t() = default;
prb_range_t(uint32_t s, uint32_t e) : prb_start(s), prb_end(e) {}

@ -42,7 +42,7 @@ class sched_ue
public:
// used by sched_metric to store the pdsch/pusch allocations
bool has_pucch;
bool has_pucch = false;
typedef struct {
uint32_t cce_start[4][6];
@ -119,14 +119,23 @@ public:
void set_sr();
void unset_sr();
void set_needs_ta_cmd(uint32_t nof_ta_cmd);
void set_needs_ta_cmd(uint32_t nof_ta_cmd);
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_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,
@ -156,11 +165,16 @@ private:
int alloc_pdu(int tbs, sched_interface::dl_sched_pdu_t* pdu);
static uint32_t format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb);
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);
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);
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);
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);
static bool bearer_is_ul(ue_bearer_t* lch);
static bool bearer_is_dl(ue_bearer_t* lch);
@ -172,55 +186,58 @@ private:
bool needs_cqi_unlocked(uint32_t tti, bool will_send = false);
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);
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);
bool is_first_dl_tx();
sched_interface::ue_cfg_t cfg;
srslte_cell_t cell;
srslte::log* log_h;
sched_interface::ue_cfg_t cfg = {};
srslte_cell_t cell = {};
srslte::log* log_h = nullptr;
std::mutex mutex;
/* Buffer states */
bool sr;
int buf_mac;
int buf_ul;
ue_bearer_t lch[sched_interface::MAX_LC];
int power_headroom;
uint32_t dl_ri;
uint32_t dl_ri_tti;
uint32_t dl_pmi;
uint32_t dl_pmi_tti;
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;
uint32_t max_mcs_dl;
uint32_t max_aggr_level;
uint32_t max_mcs_ul;
uint32_t max_msg3retx;
int fixed_mcs_ul;
int fixed_mcs_dl;
uint32_t P;
uint32_t nof_ta_cmd;
int next_tpc_pusch;
int next_tpc_pucch;
bool sr = false;
int buf_mac = 0;
int buf_ul = 0;
std::array<ue_bearer_t, sched_interface::MAX_LC> lch = {};
int power_headroom = 0;
uint32_t dl_ri = 0;
uint32_t dl_ri_tti = 0;
uint32_t dl_pmi = 0;
uint32_t dl_pmi_tti = 0;
uint32_t dl_cqi = 0;
uint32_t dl_cqi_tti = 0;
uint32_t cqi_request_tti = 0;
uint32_t ul_cqi = 0;
uint32_t ul_cqi_tti = 0;
uint16_t rnti = 0;
uint32_t max_mcs_dl = 0;
uint32_t max_aggr_level = 0;
uint32_t max_mcs_ul = 0;
uint32_t max_msg3retx = 0;
int fixed_mcs_ul = 0;
int fixed_mcs_dl = 0;
uint32_t P = 0;
uint32_t nof_ta_cmd = 0;
int next_tpc_pusch = 0;
int next_tpc_pucch = 0;
// Allowed DCI locations per CFI and per subframe
sched_dci_cce_t dci_locations[3][10];
std::array<std::array<sched_dci_cce_t, 10>, 3> dci_locations = {};
const static int SCHED_MAX_HARQ_PROC = SRSLTE_FDD_NOF_HARQ;
dl_harq_proc dl_harq[SCHED_MAX_HARQ_PROC];
ul_harq_proc ul_harq[SCHED_MAX_HARQ_PROC];
const static int SCHED_MAX_HARQ_PROC = SRSLTE_FDD_NOF_HARQ;
std::array<dl_harq_proc, SCHED_MAX_HARQ_PROC> dl_harq = {};
std::array<ul_harq_proc, SCHED_MAX_HARQ_PROC> ul_harq = {};
bool phy_config_dedicated_enabled;
bool phy_config_dedicated_enabled = false;
asn1::rrc::phys_cfg_ded_s::ant_info_c_ dl_ant_info;
};
} // namespace srsenb

@ -46,7 +46,7 @@ struct rrc_cfg_sr_t {
uint32_t nof_subframes;
};
typedef enum { RRC_CFG_CQI_MODE_PERIODIC = 0, RRC_CFG_CQI_MODE_APERIODIC, RRC_CFG_CQI_MODE_N_ITEMS } rrc_cfg_cqi_mode_t;
enum rrc_cfg_cqi_mode_t { RRC_CFG_CQI_MODE_PERIODIC = 0, RRC_CFG_CQI_MODE_APERIODIC, RRC_CFG_CQI_MODE_N_ITEMS };
static const char rrc_cfg_cqi_mode_text[RRC_CFG_CQI_MODE_N_ITEMS][20] = {"periodic", "aperiodic"};
@ -141,30 +141,29 @@ public:
void get_metrics(rrc_metrics_t& m);
// rrc_interface_mac
void rl_failure(uint16_t rnti);
void add_user(uint16_t rnti);
void upd_user(uint16_t new_rnti, uint16_t old_rnti);
void set_activity_user(uint16_t rnti);
bool is_paging_opportunity(uint32_t tti, uint32_t* payload_len);
void rl_failure(uint16_t rnti) override;
void add_user(uint16_t rnti) override;
void upd_user(uint16_t new_rnti, uint16_t old_rnti) override;
void set_activity_user(uint16_t rnti) override;
bool is_paging_opportunity(uint32_t tti, uint32_t* payload_len) override;
// rrc_interface_rlc
void read_pdu_bcch_dlsch(uint32_t sib_idx, uint8_t* payload);
void read_pdu_pcch(uint8_t* payload, uint32_t buffer_size);
void max_retx_attempted(uint16_t rnti);
void read_pdu_bcch_dlsch(uint32_t sib_idx, uint8_t* payload) override;
void read_pdu_pcch(uint8_t* payload, uint32_t buffer_size) override;
void max_retx_attempted(uint16_t rnti) override;
// rrc_interface_s1ap
void write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu);
void release_complete(uint16_t rnti);
bool setup_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPREQUEST_STRUCT* msg);
bool modify_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONREQUEST_STRUCT* msg);
bool setup_ue_erabs(uint16_t rnti, LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT* msg);
bool release_erabs(uint32_t rnti);
void add_paging_id(uint32_t ueid, LIBLTE_S1AP_UEPAGINGID_STRUCT UEPagingID);
void write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu) override;
void release_complete(uint16_t rnti) override;
bool setup_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPREQUEST_STRUCT* msg) override;
bool modify_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONREQUEST_STRUCT* msg) override;
bool setup_ue_erabs(uint16_t rnti, LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT* msg) override;
bool release_erabs(uint32_t rnti) override;
void add_paging_id(uint32_t ueid, LIBLTE_S1AP_UEPAGINGID_STRUCT UEPagingID) override;
// rrc_interface_pdcp
void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu);
void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) override;
void parse_sibs();
uint32_t get_nof_users();
// logging
@ -180,16 +179,16 @@ public:
};
void set_connect_notifer(connect_notifier* cnotifier);
class activity_monitor : public thread
class activity_monitor final : public thread
{
public:
activity_monitor(rrc* parent_);
explicit activity_monitor(rrc* parent_);
void stop();
private:
rrc* parent;
bool running;
void run_thread();
void run_thread() override;
};
class ue
@ -261,12 +260,12 @@ public:
uint16_t rnti;
rrc* parent;
bool connect_notified;
bool connect_notified = false;
bool is_csfb;
bool is_csfb = false;
private:
srslte::byte_buffer_pool* pool;
srslte::byte_buffer_pool* pool = nullptr;
struct timeval t_last_activity;
struct timeval t_ue_init;
@ -274,13 +273,13 @@ public:
std::unique_ptr<rrc_mobility> mobility_handler;
// S-TMSI for this UE
bool has_tmsi;
uint32_t m_tmsi;
uint8_t mmec;
bool has_tmsi = false;
uint32_t m_tmsi = 0;
uint8_t mmec = 0;
uint32_t rlf_cnt;
uint8_t transaction_id;
rrc_state_t state;
uint32_t rlf_cnt = 0;
uint8_t transaction_id = 0;
rrc_state_t state = RRC_STATE_IDLE;
std::map<uint32_t, asn1::rrc::srb_to_add_mod_s> srbs;
std::map<uint32_t, asn1::rrc::drb_to_add_mod_s> drbs;
@ -306,18 +305,18 @@ public:
uint32_t teid_in;
} erab_t;
std::map<uint8_t, erab_t> erabs;
int sr_sched_sf_idx;
int sr_sched_prb_idx;
bool sr_allocated;
uint32_t sr_N_pucch;
uint32_t sr_I;
uint32_t cqi_pucch;
uint32_t cqi_idx;
bool cqi_allocated;
int cqi_sched_sf_idx;
int cqi_sched_prb_idx;
int sr_sched_sf_idx = 0;
int sr_sched_prb_idx = 0;
bool sr_allocated = false;
uint32_t sr_N_pucch = 0;
uint32_t sr_I = 0;
uint32_t cqi_pucch = 0;
uint32_t cqi_idx = 0;
bool cqi_allocated = false;
int cqi_sched_sf_idx = 0;
int cqi_sched_prb_idx = 0;
int get_drbid_config(asn1::rrc::drb_to_add_mod_s* drb, int drbid);
bool nas_pending;
bool nas_pending = false;
srslte::byte_buffer_t erab_info;
};
@ -375,7 +374,7 @@ private:
const static uint32_t LCID_RLF_USER = 0xffff0003;
const static uint32_t LCID_ACT_USER = 0xffff0004;
bool running;
bool running = false;
static const int RRC_THREAD_PRIO = 65;
srslte::block_queue<rrc_pdu> rx_pdu_queue;
@ -386,7 +385,7 @@ private:
sr_sched_t sr_sched;
sr_sched_t cqi_sched;
asn1::rrc::mcch_msg_s mcch;
bool enable_mbms;
bool enable_mbms = false;
rrc_cfg_t cfg;
uint32_t nof_si_messages;
asn1::rrc::sib_type2_s sib2;

@ -22,13 +22,13 @@
#ifndef ENB_CFG_PARSER_SIB1_H
#define ENB_CFG_PARSER_SIB1_H
#include <string>
#include <stdlib.h>
#include <stdint.h>
#include "srsenb/hdr/parser.h"
#include <iostream>
#include <libconfig.h++>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include "srsenb/hdr/parser.h"
#include <string>
#include "srsenb/hdr/stack/rrc/rrc.h"
#include "srslte/asn1/asn1_utils.h"
@ -37,57 +37,45 @@ namespace srsenb {
using namespace libconfig;
class field_sched_info : public parser::field_itf
class field_sched_info final : public parser::field_itf
{
public:
field_sched_info(asn1::rrc::sib_type1_s* data_) { data = data_; }
~field_sched_info() {}
int parse(Setting &root);
const char* get_name() {
return "sched_info";
}
explicit field_sched_info(asn1::rrc::sib_type1_s* data_) { data = data_; }
int parse(Setting& root) override;
const char* get_name() override { return "sched_info"; }
private:
asn1::rrc::sib_type1_s* data;
};
class field_intra_neigh_cell_list : public parser::field_itf
class field_intra_neigh_cell_list final : public parser::field_itf
{
public:
field_intra_neigh_cell_list(asn1::rrc::sib_type4_s* data_) { data = data_; }
~field_intra_neigh_cell_list(){}
int parse(Setting& root);
const char* get_name() {
return "intra_neigh_cell_list";
}
explicit field_intra_neigh_cell_list(asn1::rrc::sib_type4_s* data_) { data = data_; }
int parse(Setting& root) override;
const char* get_name() override { return "intra_neigh_cell_list"; }
private:
asn1::rrc::sib_type4_s* data;
};
class field_intra_black_cell_list : public parser::field_itf
class field_intra_black_cell_list final : public parser::field_itf
{
public:
field_intra_black_cell_list(asn1::rrc::sib_type4_s* data_) { data = data_; }
~field_intra_black_cell_list(){}
int parse(Setting &root);
const char* get_name() {
return "intra_black_cell_list";
}
explicit field_intra_black_cell_list(asn1::rrc::sib_type4_s* data_) { data = data_; }
int parse(Setting& root) override;
const char* get_name() override { return "intra_black_cell_list"; }
private:
asn1::rrc::sib_type4_s* data;
};
class field_carrier_freqs_info_list : public parser::field_itf
class field_carrier_freqs_info_list final : public parser::field_itf
{
public:
field_carrier_freqs_info_list(asn1::rrc::sib_type7_s* data_) { data = data_; }
~field_carrier_freqs_info_list(){}
int parse(Setting &root);
const char* get_name() {
return "carrier_freqs_info_list";
}
explicit field_carrier_freqs_info_list(asn1::rrc::sib_type7_s* data_) { data = data_; }
int parse(Setting& root) override;
const char* get_name() override { return "carrier_freqs_info_list"; }
private:
asn1::rrc::sib_type7_s* data;
@ -96,26 +84,26 @@ private:
class field_sf_mapping : public parser::field_itf
{
public:
field_sf_mapping(uint32_t *sf_mapping_, uint32_t *nof_subframes_) { sf_mapping = sf_mapping_; nof_subframes = nof_subframes_; }
~field_sf_mapping(){}
int parse(Setting &root);
const char* get_name() {
return "sf_mapping";
field_sf_mapping(uint32_t* sf_mapping_, uint32_t* nof_subframes_)
{
sf_mapping = sf_mapping_;
nof_subframes = nof_subframes_;
}
int parse(Setting& root) override;
const char* get_name() override { return "sf_mapping"; }
private:
uint32_t *sf_mapping;
uint32_t *nof_subframes;
uint32_t* sf_mapping;
uint32_t* nof_subframes;
};
class field_qci : public parser::field_itf
{
public:
field_qci(rrc_cfg_qci_t *cfg_) { cfg = cfg_; }
~field_qci(){}
const char* get_name() { return "field_cqi"; }
explicit field_qci(rrc_cfg_qci_t* cfg_) { cfg = cfg_; }
const char* get_name() override { return "field_cqi"; }
int parse(Setting& root);
int parse(Setting& root) override;
private:
rrc_cfg_qci_t* cfg;
@ -138,32 +126,6 @@ private:
rrc_meas_cfg_t* meas_cfg;
};
class field_meas_cell_list final : public parser::field_itf
{
public:
explicit field_meas_cell_list(rrc_meas_cfg_t* meas_cfg_) : meas_cfg(meas_cfg_) {}
int parse(Setting& root) override;
const char* get_name() override { return "meas_cell_list"; }
private:
rrc_meas_cfg_t* meas_cfg;
};
class field_meas_report_desc final : public parser::field_itf
{
public:
explicit field_meas_report_desc(rrc_meas_cfg_t* meas_cfg_) : meas_cfg(meas_cfg_) {}
int parse(Setting& root) override;
const char* get_name() override { return "meas_report_desc"; }
private:
rrc_meas_cfg_t* meas_cfg;
};
} // namespace rr_sections
// ASN1 parsers
@ -171,15 +133,15 @@ private:
class field_asn1 : public parser::field_itf
{
public:
field_asn1(const char* name_, bool* enabled_value_ = NULL)
explicit field_asn1(const char* name_, bool* enabled_value_ = nullptr)
{
name = name_;
enabled_value = enabled_value_;
}
const char* get_name() { return name; }
const char* get_name() override { return name; }
int parse(Setting& root)
int parse(Setting& root) override
{
if (root.exists(name)) {
@ -210,13 +172,13 @@ class field_asn1_seqof_size : public field_asn1
ListType* store_ptr;
public:
field_asn1_seqof_size(const char* name_, ListType* store_ptr_, bool* enabled_value_ = NULL) :
field_asn1_seqof_size(const char* name_, ListType* store_ptr_, bool* enabled_value_ = nullptr) :
field_asn1(name_, enabled_value_),
store_ptr(store_ptr_)
{
}
int parse_value(Setting& root)
int parse_value(Setting& root) override
{
uint32_t size_val;
if (root.lookupValue(name, size_val)) {
@ -228,8 +190,8 @@ public:
};
template <class ListType>
field_asn1_seqof_size<ListType>* make_asn1_seqof_size_parser(const char* name, ListType* store_ptr,
bool* enabled = NULL)
field_asn1_seqof_size<ListType>*
make_asn1_seqof_size_parser(const char* name, ListType* store_ptr, bool* enabled = nullptr)
{
return new field_asn1_seqof_size<ListType>(name, store_ptr, enabled);
}
@ -240,13 +202,13 @@ class field_asn1_choice_type_number : public field_asn1
ChoiceType* store_ptr;
public:
field_asn1_choice_type_number(const char* name_, ChoiceType* store_ptr_, bool* enabled_value_ = NULL) :
field_asn1_choice_type_number(const char* name_, ChoiceType* store_ptr_, bool* enabled_value_ = nullptr) :
field_asn1(name_, enabled_value_),
store_ptr(store_ptr_)
{
}
int parse_value(Setting& root)
int parse_value(Setting& root) override
{
NumberType val;
if (root.lookupValue(name, val)) {
@ -345,13 +307,13 @@ class field_asn1_enum_number : public field_asn1
EnumType* store_ptr;
public:
field_asn1_enum_number(const char* name_, EnumType* store_ptr_, bool* enabled_value_ = NULL) :
field_asn1_enum_number(const char* name_, EnumType* store_ptr_, bool* enabled_value_ = nullptr) :
field_asn1(name_, enabled_value_),
store_ptr(store_ptr_)
{
}
int parse_value(Setting& root)
int parse_value(Setting& root) override
{
bool found = parse_enum_by_number(*store_ptr, name, root);
return found ? 0 : -1;
@ -359,8 +321,8 @@ public:
};
template <class EnumType>
field_asn1_enum_number<EnumType>* make_asn1_enum_number_parser(const char* name, EnumType* store_ptr,
bool* enabled = NULL)
field_asn1_enum_number<EnumType>*
make_asn1_enum_number_parser(const char* name, EnumType* store_ptr, bool* enabled = nullptr)
{
return new field_asn1_enum_number<EnumType>(name, store_ptr, enabled);
}
@ -371,13 +333,13 @@ class field_asn1_enum_str : public field_asn1
EnumType* store_ptr;
public:
field_asn1_enum_str(const char* name_, EnumType* store_ptr_, bool* enabled_value_ = NULL) :
field_asn1_enum_str(const char* name_, EnumType* store_ptr_, bool* enabled_value_ = nullptr) :
field_asn1(name_, enabled_value_),
store_ptr(store_ptr_)
{
}
int parse_value(Setting& root)
int parse_value(Setting& root) override
{
bool found = parse_enum_by_str(*store_ptr, name, root);
return found ? 0 : -1;
@ -385,7 +347,7 @@ public:
};
template <class EnumType>
field_asn1_enum_str<EnumType>* make_asn1_enum_str_parser(const char* name, EnumType* store_ptr, bool* enabled = NULL)
field_asn1_enum_str<EnumType>* make_asn1_enum_str_parser(const char* name, EnumType* store_ptr, bool* enabled = nullptr)
{
return new field_asn1_enum_str<EnumType>(name, store_ptr, enabled);
}
@ -396,13 +358,13 @@ class field_asn1_enum_number_str : public field_asn1
EnumType* store_ptr;
public:
field_asn1_enum_number_str(const char* name_, EnumType* store_ptr_, bool* enabled_value_ = NULL) :
field_asn1_enum_number_str(const char* name_, EnumType* store_ptr_, bool* enabled_value_ = nullptr) :
field_asn1(name_, enabled_value_),
store_ptr(store_ptr_)
{
}
int parse_value(Setting& root)
int parse_value(Setting& root) override
{
bool found = parse_enum_by_number_str(*store_ptr, name, root);
return found ? 0 : -1;
@ -410,8 +372,8 @@ public:
};
template <class EnumType>
field_asn1_enum_number_str<EnumType>* make_asn1_enum_number_str_parser(const char* name, EnumType* store_ptr,
bool* enabled = NULL)
field_asn1_enum_number_str<EnumType>*
make_asn1_enum_number_str_parser(const char* name, EnumType* store_ptr, bool* enabled = nullptr)
{
return new field_asn1_enum_number_str<EnumType>(name, store_ptr, enabled);
}
@ -421,8 +383,11 @@ class field_asn1_choice_str : public field_asn1
{
public:
typedef bool (*func_ptr)(ChoiceType*, const char*, Setting&);
field_asn1_choice_str(const char* name_, const char* choicetypename_, func_ptr f_, ChoiceType* store_ptr_,
bool* enabled_value_ = NULL) :
field_asn1_choice_str(const char* name_,
const char* choicetypename_,
func_ptr f_,
ChoiceType* store_ptr_,
bool* enabled_value_ = nullptr) :
field_asn1(name_, enabled_value_),
store_ptr(store_ptr_),
choicetypename(choicetypename_),
@ -430,7 +395,7 @@ public:
{
}
int parse_value(Setting& root)
int parse_value(Setting& root) override
{
typename ChoiceType::types type;
bool found = parse_enum_by_str(type, choicetypename, root);
@ -451,8 +416,11 @@ private:
};
template <class ChoiceType, class FuncOper>
field_asn1_choice_str<ChoiceType>* make_asn1_choice_str_parser(const char* name, const char* choicetypename,
ChoiceType* store_ptr, FuncOper f, bool* enabled = NULL)
field_asn1_choice_str<ChoiceType>* make_asn1_choice_str_parser(const char* name,
const char* choicetypename,
ChoiceType* store_ptr,
FuncOper f,
bool* enabled = nullptr)
{
return new field_asn1_choice_str<ChoiceType>(name, choicetypename, f, store_ptr, enabled);
}
@ -462,8 +430,11 @@ class field_asn1_choice_number : public field_asn1
{
public:
typedef bool (*func_ptr)(ChoiceType*, const char*, Setting&);
field_asn1_choice_number(const char* name_, const char* choicetypename_, func_ptr f_, ChoiceType* store_ptr_,
bool* enabled_value_ = NULL) :
field_asn1_choice_number(const char* name_,
const char* choicetypename_,
func_ptr f_,
ChoiceType* store_ptr_,
bool* enabled_value_ = nullptr) :
field_asn1(name_, enabled_value_),
store_ptr(store_ptr_),
choicetypename(choicetypename_),
@ -471,7 +442,7 @@ public:
{
}
int parse_value(Setting& root)
int parse_value(Setting& root) override
{
typename ChoiceType::types type;
bool found = parse_enum_by_number(type, choicetypename, root);
@ -497,13 +468,13 @@ class field_asn1_bitstring_number : public field_asn1
BitString* store_ptr;
public:
field_asn1_bitstring_number(const char* name_, BitString* store_ptr_, bool* enabled_value_ = NULL) :
field_asn1_bitstring_number(const char* name_, BitString* store_ptr_, bool* enabled_value_ = nullptr) :
field_asn1(name_, enabled_value_),
store_ptr(store_ptr_)
{
}
int parse_value(Setting& root)
int parse_value(Setting& root) override
{
NumType val;
if (parser::lookupValue(root, name, &val)) {
@ -512,8 +483,8 @@ public:
} else {
std::string str_val;
if (parser::lookupValue(root, name, &str_val)) {
fprintf(stderr, "PARSER ERROR: Expected number for field %s but got the string \"%s\"\n", name,
str_val.c_str());
fprintf(
stderr, "PARSER ERROR: Expected number for field %s but got the string \"%s\"\n", name, str_val.c_str());
}
}
return -1;
@ -530,10 +501,10 @@ field_asn1_bitstring_number<BitString, uint32_t>* make_asn1_bitstring_number_par
class phr_cnfg_parser : public parser::field_itf
{
public:
phr_cnfg_parser(asn1::rrc::mac_main_cfg_s::phr_cfg_c_* phr_cfg_) { phr_cfg = phr_cfg_; }
~phr_cnfg_parser() {}
int parse(Setting& root);
const char* get_name() { return "phr_cnfg"; }
explicit phr_cnfg_parser(asn1::rrc::mac_main_cfg_s::phr_cfg_c_* phr_cfg_) { phr_cfg = phr_cfg_; }
~phr_cnfg_parser() override = default;
int parse(Setting& root) override;
const char* get_name() override { return "phr_cnfg"; }
private:
asn1::rrc::mac_main_cfg_s::phr_cfg_c_* phr_cfg;
@ -547,16 +518,16 @@ public:
enabled(enabled_)
{
}
~mbsfn_sf_cfg_list_parser() {}
int parse(Setting& root);
const char* get_name() { return "mbsfnSubframeConfigList"; }
~mbsfn_sf_cfg_list_parser() override = default;
int parse(Setting& root) override;
const char* get_name() override { return "mbsfnSubframeConfigList"; }
private:
asn1::rrc::mbsfn_sf_cfg_list_l* mbsfn_list;
bool* enabled;
};
class mbsfn_area_info_list_parser : public parser::field_itf
class mbsfn_area_info_list_parser final : public parser::field_itf
{
public:
mbsfn_area_info_list_parser(asn1::rrc::mbsfn_area_info_list_r9_l* mbsfn_list_, bool* enabled_) :
@ -564,15 +535,14 @@ public:
enabled(enabled_)
{
}
~mbsfn_area_info_list_parser() {}
int parse(Setting& root);
const char* get_name() { return "mbsfn_area_info_list"; }
~mbsfn_area_info_list_parser() override = default;
int parse(Setting& root) override;
const char* get_name() override { return "mbsfn_area_info_list"; }
private:
asn1::rrc::mbsfn_area_info_list_r9_l* mbsfn_list;
bool* enabled;
};
}
} // namespace srsenb
#endif

@ -217,7 +217,8 @@ bool sched::ue_exists(uint16_t rnti)
return ue_db_access(rnti, [](sched_ue& ue) {}) >= 0;
}
void sched::ue_needs_ta_cmd(uint16_t rnti, uint32_t nof_ta_cmd) {
void sched::ue_needs_ta_cmd(uint16_t rnti, uint32_t nof_ta_cmd)
{
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
ue_db[rnti].set_needs_ta_cmd(nof_ta_cmd);
@ -395,8 +396,11 @@ int sched::ul_sched(uint32_t tti, srsenb::sched_interface::ul_sched_res_t* sched
*
*******************************************************/
void sched::generate_cce_location(
srslte_regs_t* regs_, sched_ue::sched_dci_cce_t* location, uint32_t cfi, uint32_t sf_idx, uint16_t rnti)
void sched::generate_cce_location(srslte_regs_t* regs_,
sched_ue::sched_dci_cce_t* location,
uint32_t cfi,
uint32_t sf_idx,
uint16_t rnti)
{
bzero(location, sizeof(sched_ue::sched_dci_cce_t));

@ -86,7 +86,8 @@ bool sched::carrier_sched::tti_sched_result_t::is_ul_alloc(sched_ue* user) const
}
sched::carrier_sched::tti_sched_result_t::ctrl_code_t
sched::carrier_sched::tti_sched_result_t::alloc_dl_ctrl(uint32_t aggr_lvl, uint32_t tbs_bytes, uint16_t rnti) {
sched::carrier_sched::tti_sched_result_t::alloc_dl_ctrl(uint32_t aggr_lvl, uint32_t tbs_bytes, uint16_t rnti)
{
ctrl_alloc_t ctrl_alloc{};
// based on rnti, check which type of alloc
@ -104,10 +105,10 @@ sched::carrier_sched::tti_sched_result_t::alloc_dl_ctrl(uint32_t aggr_lvl, uint3
}
// Allocation Successful
ctrl_alloc.dci_idx = tti_alloc.get_pdcch_grid().nof_allocs() - 1;
ctrl_alloc.rbg_range = ret.rbg_range;
ctrl_alloc.rnti = rnti;
ctrl_alloc.req_bytes = tbs_bytes;
ctrl_alloc.dci_idx = tti_alloc.get_pdcch_grid().nof_allocs() - 1;
ctrl_alloc.rbg_range = ret.rbg_range;
ctrl_alloc.rnti = rnti;
ctrl_alloc.req_bytes = tbs_bytes;
ctrl_alloc.alloc_type = alloc_type;
return {ret.outcome, ctrl_alloc};
@ -153,8 +154,11 @@ alloc_outcome_t sched::carrier_sched::tti_sched_result_t::alloc_paging(uint32_t
return ret.first;
}
sched::carrier_sched::tti_sched_result_t::rar_code_t sched::carrier_sched::tti_sched_result_t::alloc_rar(
uint32_t aggr_lvl, const dl_sched_rar_t& rar_grant, uint32_t prach_tti, uint32_t buf_rar)
sched::carrier_sched::tti_sched_result_t::rar_code_t
sched::carrier_sched::tti_sched_result_t::alloc_rar(uint32_t aggr_lvl,
const dl_sched_rar_t& rar_grant,
uint32_t prach_tti,
uint32_t buf_rar)
{
// RA-RNTI = 1 + t_id + f_id
// t_id = index of first subframe specified by PRACH (0<=t_id<10)
@ -518,8 +522,12 @@ uint32_t sched::carrier_sched::tti_sched_result_t::get_nof_ctrl_symbols() const
return tti_alloc.get_cfi() + ((parent_carrier->cfg->cell.nof_prb <= 10) ? 1 : 0);
}
int sched::carrier_sched::tti_sched_result_t::generate_format1a(
uint32_t rb_start, uint32_t l_crb, uint32_t tbs_bytes, uint32_t rv, uint16_t rnti, srslte_dci_dl_t* dci)
int sched::carrier_sched::tti_sched_result_t::generate_format1a(uint32_t rb_start,
uint32_t l_crb,
uint32_t tbs_bytes,
uint32_t rv,
uint16_t rnti,
srslte_dci_dl_t* dci)
{
/* Calculate I_tbs for this TBS */
int tbs = tbs_bytes * 8;
@ -683,7 +691,8 @@ void ra_sched::init(srslte::log* log_, std::map<uint16_t, sched_ue>& ue_db_)
}
// Schedules RAR
// On every call to this function, we schedule the oldest RAR which is still within the window. If outside the window we discard it.
// On every call to this function, we schedule the oldest RAR which is still within the window. If outside the window we
// discard it.
void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sched)
{
tti_tx_dl = tti_sched->get_tti_tx_dl();
@ -692,10 +701,7 @@ void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sc
// Discard all RARs out of the window. The first one inside the window is scheduled, if we can't we exit
while (!pending_rars.empty()) {
dl_sched_rar_info_t rar = pending_rars.front();
if (not sched_utils::is_in_tti_interval(tti_tx_dl,
rar.prach_tti + 3,
rar.prach_tti + 3 + cfg->prach_rar_window))
{
if (not sched_utils::is_in_tti_interval(tti_tx_dl, rar.prach_tti + 3, rar.prach_tti + 3 + cfg->prach_rar_window)) {
if (tti_tx_dl >= rar.prach_tti + 3 + cfg->prach_rar_window) {
log_h->console("SCHED: Could not transmit RAR within the window (RA TTI=%d, Window=%d, Now=%d)\n",
rar.prach_tti,
@ -718,23 +724,24 @@ void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sc
* Msg3 transmission
*/
dl_sched_rar_t rar_grant;
uint32_t L_prb = 3;
uint32_t n_prb = cfg->nrb_pucch>0?cfg->nrb_pucch:2;
uint32_t L_prb = 3;
uint32_t n_prb = cfg->nrb_pucch > 0 ? cfg->nrb_pucch : 2;
bzero(&rar_grant, sizeof(rar_grant));
uint32_t rba = srslte_ra_type2_to_riv(L_prb, n_prb, cfg->cell.nof_prb);
dl_sched_rar_grant_t *grant = &rar_grant.msg3_grant[0];
grant->grant.tpc_pusch = 3;
grant->grant.trunc_mcs = 0;
grant->grant.rba = rba;
grant->data = rar;
dl_sched_rar_grant_t* grant = &rar_grant.msg3_grant[0];
grant->grant.tpc_pusch = 3;
grant->grant.trunc_mcs = 0;
grant->grant.rba = rba;
grant->data = rar;
rar_grant.nof_grants++;
// Try to schedule DCI + RBGs for RAR Grant
sched::carrier_sched::tti_sched_result_t::rar_code_t ret = tti_sched->alloc_rar(rar_aggr_level,
rar_grant,
rar.prach_tti,
7 * rar_grant.nof_grants); //fixme: check RAR size
sched::carrier_sched::tti_sched_result_t::rar_code_t ret =
tti_sched->alloc_rar(rar_aggr_level,
rar_grant,
rar.prach_tti,
7 * rar_grant.nof_grants); // fixme: check RAR size
// If we can allocate, schedule Msg3 and remove from pending
if (!ret.first) {
@ -742,14 +749,16 @@ void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sc
}
// Schedule Msg3 only if there is a requirement for Msg3 data
uint32_t pending_tti = (tti_sched->get_tti_tx_dl() + MSG3_DELAY_MS + TX_DELAY) % TTIMOD_SZ;
uint32_t pending_tti = (tti_sched->get_tti_tx_dl() + MSG3_DELAY_MS + TX_DELAY) % TTIMOD_SZ;
pending_msg3[pending_tti].enabled = true;
pending_msg3[pending_tti].rnti = rar.temp_crnti; // FIXME
pending_msg3[pending_tti].L = L_prb;
pending_msg3[pending_tti].n_prb = n_prb;
dl_sched_rar_grant_t *last_msg3 = &rar_grant.msg3_grant[rar_grant.nof_grants - 1];
pending_msg3[pending_tti].mcs = last_msg3->grant.trunc_mcs;
log_h->info("SCHED: Allocating Msg3 for rnti=%d at tti=%d\n", rar.temp_crnti, tti_sched->get_tti_tx_dl() + MSG3_DELAY_MS + TX_DELAY);
pending_msg3[pending_tti].rnti = rar.temp_crnti; // FIXME
pending_msg3[pending_tti].L = L_prb;
pending_msg3[pending_tti].n_prb = n_prb;
dl_sched_rar_grant_t* last_msg3 = &rar_grant.msg3_grant[rar_grant.nof_grants - 1];
pending_msg3[pending_tti].mcs = last_msg3->grant.trunc_mcs;
log_h->info("SCHED: Allocating Msg3 for rnti=%d at tti=%d\n",
rar.temp_crnti,
tti_sched->get_tti_tx_dl() + MSG3_DELAY_MS + TX_DELAY);
// Remove pending RAR and exit
pending_rars.pop();
@ -786,7 +795,11 @@ void ra_sched::ul_sched(sched::carrier_sched::tti_sched_result_t* tti_sched)
int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info)
{
log_h->info("SCHED: New RAR tti=%d, preamble=%d, temp_crnti=0x%x, ta_cmd=%d, msg3_size=%d\n",
rar_info.prach_tti, rar_info.preamble_idx, rar_info.temp_crnti, rar_info.ta_cmd, rar_info.msg3_size);
rar_info.prach_tti,
rar_info.preamble_idx,
rar_info.temp_crnti,
rar_info.ta_cmd,
rar_info.msg3_size);
pending_rars.push(rar_info);
return 0;
}

@ -192,8 +192,12 @@ void dl_harq_proc::new_tx(const rbgmask_t& new_mask, uint32_t tb_idx, uint32_t t
new_tx_common(tb_idx, tti, mcs, tbs);
}
void dl_harq_proc::new_retx(
const rbgmask_t& new_mask, uint32_t tb_idx, uint32_t tti_, int* mcs, int* tbs, uint32_t n_cce_)
void dl_harq_proc::new_retx(const rbgmask_t& new_mask,
uint32_t tb_idx,
uint32_t tti_,
int* mcs,
int* tbs,
uint32_t n_cce_)
{
n_cce = n_cce_;
rbgmask = new_mask;

@ -26,10 +26,10 @@
#include "srslte/common/pdu.h"
#include "srslte/srslte.h"
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define MCS_FIRST_DL 4
#define MIN_DATA_TBS 4
@ -46,18 +46,9 @@ namespace srsenb {
*
*******************************************************/
sched_ue::sched_ue() :
has_pucch(false),
power_headroom(0),
rnti(0),
max_mcs_dl(0),
max_mcs_ul(0),
fixed_mcs_ul(0),
fixed_mcs_dl(0),
phy_config_dedicated_enabled(false),
nof_ta_cmd(0)
sched_ue::sched_ue()
{
log_h = NULL;
log_h = nullptr;
bzero(&cell, sizeof(cell));
bzero(&lch, sizeof(lch));
@ -84,10 +75,10 @@ void sched_ue::set_cfg(uint16_t rnti_,
memcpy(&cell, &cell_cfg->cell, sizeof(srslte_cell_t));
P = srslte_ra_type0_P(cell.nof_prb);
max_mcs_dl = 28;
max_mcs_ul = 28;
max_mcs_dl = 28;
max_mcs_ul = 28;
max_aggr_level = 3;
max_msg3retx = cell_cfg->maxharq_msg3tx;
max_msg3retx = cell_cfg->maxharq_msg3tx;
cfg = *cfg_;
@ -154,7 +145,8 @@ void sched_ue::set_fixed_mcs(int mcs_ul, int mcs_dl)
fixed_mcs_dl = mcs_dl;
}
void sched_ue::set_max_mcs(int mcs_ul, int mcs_dl, int max_aggr_level_) {
void sched_ue::set_max_mcs(int mcs_ul, int mcs_dl, int max_aggr_level_)
{
std::lock_guard<std::mutex> lock(mutex);
if (mcs_ul < 0) {
max_mcs_ul = 28;
@ -179,11 +171,11 @@ void sched_ue::set_max_mcs(int mcs_ul, int mcs_dl, int max_aggr_level_) {
*
*******************************************************/
void sched_ue::set_bearer_cfg(uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg)
void sched_ue::set_bearer_cfg(uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg_)
{
std::lock_guard<std::mutex> lock(mutex);
if (lc_id < sched_interface::MAX_LC) {
memcpy(&lch[lc_id].cfg, cfg, sizeof(sched_interface::ue_bearer_cfg_t));
memcpy(&lch[lc_id].cfg, cfg_, sizeof(sched_interface::ue_bearer_cfg_t));
lch[lc_id].buf_tx = 0;
lch[lc_id].buf_retx = 0;
if (lch[lc_id].cfg.direction != sched_interface::ue_bearer_cfg_t::IDLE) {
@ -250,7 +242,8 @@ void sched_ue::unset_sr()
sr = false;
}
void sched_ue::set_needs_ta_cmd(uint32_t nof_ta_cmd_) {
void sched_ue::set_needs_ta_cmd(uint32_t nof_ta_cmd_)
{
nof_ta_cmd = nof_ta_cmd_;
Info("SCHED: rnti=0x%x needs %d TA CMD\n", rnti, nof_ta_cmd);
}
@ -319,7 +312,7 @@ bool sched_ue::get_pucch_sched(uint32_t current_tti, uint32_t prb_idx[2])
int sched_ue::set_ack_info(uint32_t tti, uint32_t tb_idx, bool ack)
{
std::lock_guard<std::mutex> lock(mutex);
int ret = -1;
int ret;
for (int i = 0; i < SCHED_MAX_HARQ_PROC; i++) {
if (TTI_TX(dl_harq[i].get_tti()) == tti) {
Debug("SCHED: Set ACK=%d for rnti=0x%x, pid=%d, tb=%d, tti=%d\n", ack, rnti, i, tb_idx, tti);
@ -422,8 +415,11 @@ void sched_ue::tpc_dec()
// Generates a Format1 dci
// > return 0 if TBS<MIN_DATA_TBS
int sched_ue::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 sched_ue::generate_format1(dl_harq_proc* h,
sched_interface::dl_sched_data_t* data,
uint32_t tti,
uint32_t cfi,
const rbgmask_t& user_mask)
{
std::lock_guard<std::mutex> lock(mutex);
@ -484,7 +480,7 @@ int sched_ue::generate_format1(
} else {
// Add TA CE. TODO: Common interface to add MAC CE
// FIXME: Can't put it in Msg4 because current srsUE doesn't read it
while(nof_ta_cmd > 0 && rem_tbs > 2) {
while (nof_ta_cmd > 0 && rem_tbs > 2) {
data->pdu[0][data->nof_pdu_elems[0]].lcid = srslte::sch_subh::TA_CMD;
data->nof_pdu_elems[0]++;
Info("SCHED: Added MAC TA CMD CE for rnti=0x%x\n", rnti);
@ -525,8 +521,11 @@ int sched_ue::generate_format1(
}
// Generates a Format2a dci
int sched_ue::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 sched_ue::generate_format2a(dl_harq_proc* h,
sched_interface::dl_sched_data_t* data,
uint32_t tti,
uint32_t cfi,
const rbgmask_t& user_mask)
{
std::lock_guard<std::mutex> lock(mutex);
int ret = generate_format2a_unlocked(h, data, tti, cfi, user_mask);
@ -534,8 +533,11 @@ int sched_ue::generate_format2a(
}
// Generates a Format2a dci
int sched_ue::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)
int sched_ue::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)
{
bool tb_en[SRSLTE_MAX_TB] = {false};
@ -637,8 +639,11 @@ int sched_ue::generate_format2a_unlocked(
}
// Generates a Format2 dci
int sched_ue::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 sched_ue::generate_format2(dl_harq_proc* h,
sched_interface::dl_sched_data_t* data,
uint32_t tti,
uint32_t cfi,
const rbgmask_t& user_mask)
{
std::lock_guard<std::mutex> lock(mutex);
@ -651,7 +656,7 @@ int sched_ue::generate_format2(
if ((SRSLTE_DCI_IS_TB_EN(data->dci.tb[0]) + SRSLTE_DCI_IS_TB_EN(data->dci.tb[1])) == 1) {
data->dci.pinfo = (uint8_t)(dl_pmi + 1) % (uint8_t)5;
} else {
data->dci.pinfo = (uint8_t)(dl_pmi & 1);
data->dci.pinfo = (uint8_t)(dl_pmi & 1u);
}
return ret;
@ -698,7 +703,7 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data,
} else {
// retx
h->new_retx(0, tti, &mcs, NULL, alloc);
h->new_retx(0, tti, &mcs, nullptr, alloc);
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(mcs, true), alloc.L) / 8;
}
@ -825,7 +830,7 @@ uint32_t sched_ue::get_pending_dl_new_data_unlocked(uint32_t tti)
}
}
if (!is_first_dl_tx() && nof_ta_cmd) {
pending_data += nof_ta_cmd*2;
pending_data += nof_ta_cmd * 2;
}
return pending_data;
}
@ -1002,7 +1007,7 @@ dl_harq_proc* sched_ue::get_pending_dl_harq(uint32_t tti)
}
}
}
dl_harq_proc* h = NULL;
dl_harq_proc* h = nullptr;
if (oldest_idx >= 0) {
h = &dl_harq[oldest_idx];
}
@ -1018,7 +1023,7 @@ dl_harq_proc* sched_ue::get_empty_dl_harq()
{
std::lock_guard<std::mutex> lock(mutex);
dl_harq_proc* h = NULL;
dl_harq_proc* h = nullptr;
for (int i = 0; i < SCHED_MAX_HARQ_PROC && !h; i++) {
if (dl_harq[i].is_empty(0) && dl_harq[i].is_empty(1)) {
h = &dl_harq[i];
@ -1145,7 +1150,7 @@ uint32_t sched_ue::format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb)
uint32_t nof_prb = 0;
for (uint32_t i = 0; i < nb; i++) {
if (bitmask & (1 << (nb - i - 1))) {
if (bitmask & (1u << (nb - i - 1))) {
for (uint32_t j = 0; j < P; j++) {
if (i * P + j < cell_nof_prb) {
nof_prb++;
@ -1156,8 +1161,13 @@ uint32_t sched_ue::format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb)
return nof_prb;
}
int sched_ue::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)
int sched_ue::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)
{
float max_coderate = srslte_cqi_to_coderate(cqi);
int sel_mcs = max_mcs + 1;

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save