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 class srslte_gw_config_t
{ {
public: 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; uint32_t lcid;
}; };

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

@ -48,7 +48,6 @@ public:
uint32_t period_rf; uint32_t period_rf;
} cell_cfg_sib_t; } cell_cfg_sib_t;
typedef struct { typedef struct {
int pdsch_mcs; int pdsch_mcs;
int pdsch_max_mcs; int pdsch_max_mcs;
@ -58,7 +57,6 @@ public:
int max_aggr_level; int max_aggr_level;
} sched_args_t; } sched_args_t;
typedef struct { typedef struct {
// Main cell configuration (used to calculate DCI locations in scheduler) // Main cell configuration (used to calculate DCI locations in scheduler)
@ -94,13 +92,12 @@ public:
} cell_cfg_t; } cell_cfg_t;
typedef struct { typedef struct {
int priority; int priority;
int bsd; int bsd;
int pbr; int pbr;
int group; int group;
enum {IDLE = 0, UL, DL, BOTH} direction; enum { IDLE = 0, UL, DL, BOTH } direction;
} ue_bearer_cfg_t; } ue_bearer_cfg_t;
typedef struct { typedef struct {
@ -125,7 +122,6 @@ public:
uint32_t nbytes; uint32_t nbytes;
} dl_sched_pdu_t; } dl_sched_pdu_t;
typedef struct { typedef struct {
uint32_t lcid; uint32_t lcid;
uint32_t lcid_buffer_size; uint32_t lcid_buffer_size;
@ -137,7 +133,7 @@ public:
dl_sched_pdu_t pdu[20]; dl_sched_pdu_t pdu[20];
dl_mtch_sched_t mtch_sched[8]; dl_mtch_sched_t mtch_sched[8];
uint32_t num_mtch_sched; uint32_t num_mtch_sched;
uint8_t *mcch_payload; uint8_t* mcch_payload;
uint32_t current_sf_allocation_num; uint32_t current_sf_allocation_num;
} dl_pdu_mch_t; } dl_pdu_mch_t;
@ -180,9 +176,7 @@ public:
typedef struct { typedef struct {
srslte_dci_dl_t dci; srslte_dci_dl_t dci;
enum bc_type { enum bc_type { BCCH, PCCH } type;
BCCH, PCCH
} type;
uint32_t index; uint32_t index;
@ -202,9 +196,7 @@ public:
typedef struct { typedef struct {
uint16_t rnti; uint16_t rnti;
enum phich_elem { enum phich_elem { ACK, NACK } phich;
ACK, NACK
} phich;
} ul_sched_phich_t; } ul_sched_phich_t;
typedef struct { typedef struct {
@ -217,16 +209,16 @@ public:
/******************* Scheduler Control ****************************/ /******************* Scheduler Control ****************************/
/* Provides cell configuration including SIB periodicity, etc. */ /* Provides cell configuration including SIB periodicity, etc. */
virtual int cell_cfg(cell_cfg_t *cell_cfg) = 0; virtual int cell_cfg(cell_cfg_t* cell_cfg) = 0;
virtual int reset() = 0; virtual int reset() = 0;
/* Manages UE scheduling context */ /* Manages UE scheduling context */
virtual int ue_cfg(uint16_t rnti, ue_cfg_t *cfg) = 0; virtual int ue_cfg(uint16_t rnti, ue_cfg_t* cfg) = 0;
virtual int ue_rem(uint16_t rnti) = 0; virtual int ue_rem(uint16_t rnti) = 0;
virtual bool ue_exists(uint16_t rnti) = 0; virtual bool ue_exists(uint16_t rnti) = 0;
/* Manages UE bearers and associated configuration */ /* 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_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_rem(uint16_t rnti, uint32_t lc_id) = 0;
virtual uint32_t get_ul_buffer(uint16_t rnti) = 0; virtual uint32_t get_ul_buffer(uint16_t rnti) = 0;
@ -253,13 +245,13 @@ public:
virtual int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi, uint32_t ul_ch_code) = 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 */ /* Run Scheduler for this tti */
virtual int dl_sched(uint32_t tti, dl_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; virtual int ul_sched(uint32_t tti, ul_sched_res_t* sched_result) = 0;
/* Custom */ /* Custom */
virtual void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) = 0; virtual void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) = 0;
}; };
} } // namespace srsenb
#endif // SRSLTE_SCHED_INTERFACE_H #endif // SRSLTE_SCHED_INTERFACE_H

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

@ -115,8 +115,12 @@ public:
ul_harq_proc::ul_alloc_t alloc, ul_harq_proc::ul_alloc_t alloc,
tti_sched_result_t::ul_alloc_t::type_t alloc_type, tti_sched_result_t::ul_alloc_t::type_t alloc_type,
uint32_t msg3 = 0); uint32_t msg3 = 0);
int generate_format1a( int generate_format1a(uint32_t rb_start,
uint32_t rb_start, uint32_t l_crb, uint32_t tbs, uint32_t rv, uint16_t rnti, srslte_dci_dl_t* dci); 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_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_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_dl_data_sched_result(const pdcch_grid_t::alloc_result_t& dci_result);
@ -230,13 +234,6 @@ public:
const pending_msg3_t& find_pending_msg3(uint32_t tti); const pending_msg3_t& find_pending_msg3(uint32_t tti);
private: private:
struct sched_rar_t {
int buf_rar = 0;
uint16_t rnti = 0;
uint32_t ra_id = 0;
uint32_t rar_tti = 0;
};
// args // args
srslte::log* log_h = nullptr; srslte::log* log_h = nullptr;
sched::cell_cfg_t* cfg; sched::cell_cfg_t* cfg;

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

@ -42,7 +42,7 @@ class sched_ue
public: public:
// used by sched_metric to store the pdsch/pusch allocations // used by sched_metric to store the pdsch/pusch allocations
bool has_pucch; bool has_pucch = false;
typedef struct { typedef struct {
uint32_t cce_start[4][6]; uint32_t cce_start[4][6];
@ -121,12 +121,21 @@ public:
void set_needs_ta_cmd(uint32_t nof_ta_cmd); void set_needs_ta_cmd(uint32_t nof_ta_cmd);
int generate_format1( int generate_format1(dl_harq_proc* h,
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask); sched_interface::dl_sched_data_t* data,
int generate_format2a( uint32_t tti,
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask); uint32_t cfi,
int generate_format2( const rbgmask_t& user_mask);
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, int generate_format0(sched_interface::ul_sched_data_t* data,
uint32_t tti, uint32_t tti,
ul_harq_proc::ul_alloc_t alloc, ul_harq_proc::ul_alloc_t alloc,
@ -156,8 +165,13 @@ private:
int alloc_pdu(int tbs, sched_interface::dl_sched_pdu_t* pdu); 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 uint32_t format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb);
static int cqi_to_tbs( static int cqi_to_tbs(uint32_t cqi,
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); 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_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_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); int alloc_tbs(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, bool is_ul, int* mcs);
@ -172,55 +186,58 @@ private:
bool needs_cqi_unlocked(uint32_t tti, bool will_send = false); bool needs_cqi_unlocked(uint32_t tti, bool will_send = false);
int generate_format2a_unlocked( int generate_format2a_unlocked(dl_harq_proc* h,
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask); sched_interface::dl_sched_data_t* data,
uint32_t tti,
uint32_t cfi,
const rbgmask_t& user_mask);
bool is_first_dl_tx(); bool is_first_dl_tx();
sched_interface::ue_cfg_t cfg; sched_interface::ue_cfg_t cfg = {};
srslte_cell_t cell; srslte_cell_t cell = {};
srslte::log* log_h; srslte::log* log_h = nullptr;
std::mutex mutex; std::mutex mutex;
/* Buffer states */ /* Buffer states */
bool sr; bool sr = false;
int buf_mac; int buf_mac = 0;
int buf_ul; int buf_ul = 0;
ue_bearer_t lch[sched_interface::MAX_LC]; std::array<ue_bearer_t, sched_interface::MAX_LC> lch = {};
int power_headroom; int power_headroom = 0;
uint32_t dl_ri; uint32_t dl_ri = 0;
uint32_t dl_ri_tti; uint32_t dl_ri_tti = 0;
uint32_t dl_pmi; uint32_t dl_pmi = 0;
uint32_t dl_pmi_tti; uint32_t dl_pmi_tti = 0;
uint32_t dl_cqi; uint32_t dl_cqi = 0;
uint32_t dl_cqi_tti; uint32_t dl_cqi_tti = 0;
uint32_t cqi_request_tti; uint32_t cqi_request_tti = 0;
uint32_t ul_cqi; uint32_t ul_cqi = 0;
uint32_t ul_cqi_tti; uint32_t ul_cqi_tti = 0;
uint16_t rnti; uint16_t rnti = 0;
uint32_t max_mcs_dl; uint32_t max_mcs_dl = 0;
uint32_t max_aggr_level; uint32_t max_aggr_level = 0;
uint32_t max_mcs_ul; uint32_t max_mcs_ul = 0;
uint32_t max_msg3retx; uint32_t max_msg3retx = 0;
int fixed_mcs_ul; int fixed_mcs_ul = 0;
int fixed_mcs_dl; int fixed_mcs_dl = 0;
uint32_t P; uint32_t P = 0;
uint32_t nof_ta_cmd; uint32_t nof_ta_cmd = 0;
int next_tpc_pusch; int next_tpc_pusch = 0;
int next_tpc_pucch; int next_tpc_pucch = 0;
// Allowed DCI locations per CFI and per subframe // 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; const static int SCHED_MAX_HARQ_PROC = SRSLTE_FDD_NOF_HARQ;
dl_harq_proc dl_harq[SCHED_MAX_HARQ_PROC]; std::array<dl_harq_proc, SCHED_MAX_HARQ_PROC> dl_harq = {};
ul_harq_proc ul_harq[SCHED_MAX_HARQ_PROC]; 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; asn1::rrc::phys_cfg_ded_s::ant_info_c_ dl_ant_info;
}; };
} // namespace srsenb } // namespace srsenb

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

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

@ -217,7 +217,8 @@ bool sched::ue_exists(uint16_t rnti)
return ue_db_access(rnti, [](sched_ue& ue) {}) >= 0; 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); pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) { if (ue_db.count(rnti)) {
ue_db[rnti].set_needs_ta_cmd(nof_ta_cmd); 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( void sched::generate_cce_location(srslte_regs_t* regs_,
srslte_regs_t* regs_, sched_ue::sched_dci_cce_t* location, uint32_t cfi, uint32_t sf_idx, uint16_t rnti) 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)); 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::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{}; ctrl_alloc_t ctrl_alloc{};
// based on rnti, check which type of alloc // based on rnti, check which type of alloc
@ -153,8 +154,11 @@ alloc_outcome_t sched::carrier_sched::tti_sched_result_t::alloc_paging(uint32_t
return ret.first; return ret.first;
} }
sched::carrier_sched::tti_sched_result_t::rar_code_t sched::carrier_sched::tti_sched_result_t::alloc_rar( sched::carrier_sched::tti_sched_result_t::rar_code_t
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::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 // RA-RNTI = 1 + t_id + f_id
// t_id = index of first subframe specified by PRACH (0<=t_id<10) // 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); return tti_alloc.get_cfi() + ((parent_carrier->cfg->cell.nof_prb <= 10) ? 1 : 0);
} }
int sched::carrier_sched::tti_sched_result_t::generate_format1a( int sched::carrier_sched::tti_sched_result_t::generate_format1a(uint32_t rb_start,
uint32_t rb_start, uint32_t l_crb, uint32_t tbs_bytes, uint32_t rv, uint16_t rnti, srslte_dci_dl_t* dci) 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 */ /* Calculate I_tbs for this TBS */
int tbs = tbs_bytes * 8; 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 // 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) void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sched)
{ {
tti_tx_dl = tti_sched->get_tti_tx_dl(); 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 // 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()) { while (!pending_rars.empty()) {
dl_sched_rar_info_t rar = pending_rars.front(); dl_sched_rar_info_t rar = pending_rars.front();
if (not sched_utils::is_in_tti_interval(tti_tx_dl, if (not sched_utils::is_in_tti_interval(tti_tx_dl, rar.prach_tti + 3, rar.prach_tti + 3 + cfg->prach_rar_window)) {
rar.prach_tti + 3,
rar.prach_tti + 3 + cfg->prach_rar_window))
{
if (tti_tx_dl >= 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", log_h->console("SCHED: Could not transmit RAR within the window (RA TTI=%d, Window=%d, Now=%d)\n",
rar.prach_tti, rar.prach_tti,
@ -719,11 +725,11 @@ void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sc
*/ */
dl_sched_rar_t rar_grant; dl_sched_rar_t rar_grant;
uint32_t L_prb = 3; uint32_t L_prb = 3;
uint32_t n_prb = cfg->nrb_pucch>0?cfg->nrb_pucch:2; uint32_t n_prb = cfg->nrb_pucch > 0 ? cfg->nrb_pucch : 2;
bzero(&rar_grant, sizeof(rar_grant)); bzero(&rar_grant, sizeof(rar_grant));
uint32_t rba = srslte_ra_type2_to_riv(L_prb, n_prb, cfg->cell.nof_prb); 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]; dl_sched_rar_grant_t* grant = &rar_grant.msg3_grant[0];
grant->grant.tpc_pusch = 3; grant->grant.tpc_pusch = 3;
grant->grant.trunc_mcs = 0; grant->grant.trunc_mcs = 0;
grant->grant.rba = rba; grant->grant.rba = rba;
@ -731,10 +737,11 @@ void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sc
rar_grant.nof_grants++; rar_grant.nof_grants++;
// Try to schedule DCI + RBGs for RAR Grant // 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, sched::carrier_sched::tti_sched_result_t::rar_code_t ret =
tti_sched->alloc_rar(rar_aggr_level,
rar_grant, rar_grant,
rar.prach_tti, rar.prach_tti,
7 * rar_grant.nof_grants); //fixme: check RAR size 7 * rar_grant.nof_grants); // fixme: check RAR size
// If we can allocate, schedule Msg3 and remove from pending // If we can allocate, schedule Msg3 and remove from pending
if (!ret.first) { if (!ret.first) {
@ -747,9 +754,11 @@ void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sc
pending_msg3[pending_tti].rnti = rar.temp_crnti; // FIXME pending_msg3[pending_tti].rnti = rar.temp_crnti; // FIXME
pending_msg3[pending_tti].L = L_prb; pending_msg3[pending_tti].L = L_prb;
pending_msg3[pending_tti].n_prb = n_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]; 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; 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); 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 // Remove pending RAR and exit
pending_rars.pop(); 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) 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", 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); pending_rars.push(rar_info);
return 0; 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); new_tx_common(tb_idx, tti, mcs, tbs);
} }
void dl_harq_proc::new_retx( void dl_harq_proc::new_retx(const rbgmask_t& new_mask,
const rbgmask_t& new_mask, uint32_t tb_idx, uint32_t tti_, int* mcs, int* tbs, uint32_t n_cce_) uint32_t tb_idx,
uint32_t tti_,
int* mcs,
int* tbs,
uint32_t n_cce_)
{ {
n_cce = n_cce_; n_cce = n_cce_;
rbgmask = new_mask; rbgmask = new_mask;

@ -46,18 +46,9 @@ namespace srsenb {
* *
*******************************************************/ *******************************************************/
sched_ue::sched_ue() : sched_ue::sched_ue()
has_pucch(false), {
power_headroom(0), log_h = nullptr;
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)
{
log_h = NULL;
bzero(&cell, sizeof(cell)); bzero(&cell, sizeof(cell));
bzero(&lch, sizeof(lch)); bzero(&lch, sizeof(lch));
@ -154,7 +145,8 @@ void sched_ue::set_fixed_mcs(int mcs_ul, int mcs_dl)
fixed_mcs_dl = 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); std::lock_guard<std::mutex> lock(mutex);
if (mcs_ul < 0) { if (mcs_ul < 0) {
max_mcs_ul = 28; 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); std::lock_guard<std::mutex> lock(mutex);
if (lc_id < sched_interface::MAX_LC) { 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_tx = 0;
lch[lc_id].buf_retx = 0; lch[lc_id].buf_retx = 0;
if (lch[lc_id].cfg.direction != sched_interface::ue_bearer_cfg_t::IDLE) { if (lch[lc_id].cfg.direction != sched_interface::ue_bearer_cfg_t::IDLE) {
@ -250,7 +242,8 @@ void sched_ue::unset_sr()
sr = false; 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_; nof_ta_cmd = nof_ta_cmd_;
Info("SCHED: rnti=0x%x needs %d TA CMD\n", rnti, 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) int sched_ue::set_ack_info(uint32_t tti, uint32_t tb_idx, bool ack)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
int ret = -1; int ret;
for (int i = 0; i < SCHED_MAX_HARQ_PROC; i++) { for (int i = 0; i < SCHED_MAX_HARQ_PROC; i++) {
if (TTI_TX(dl_harq[i].get_tti()) == tti) { 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); 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 // Generates a Format1 dci
// > return 0 if TBS<MIN_DATA_TBS // > return 0 if TBS<MIN_DATA_TBS
int sched_ue::generate_format1( int sched_ue::generate_format1(dl_harq_proc* h,
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask) 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); std::lock_guard<std::mutex> lock(mutex);
@ -484,7 +480,7 @@ int sched_ue::generate_format1(
} else { } else {
// Add TA CE. TODO: Common interface to add MAC CE // Add TA CE. TODO: Common interface to add MAC CE
// FIXME: Can't put it in Msg4 because current srsUE doesn't read it // 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->pdu[0][data->nof_pdu_elems[0]].lcid = srslte::sch_subh::TA_CMD;
data->nof_pdu_elems[0]++; data->nof_pdu_elems[0]++;
Info("SCHED: Added MAC TA CMD CE for rnti=0x%x\n", rnti); 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 // Generates a Format2a dci
int sched_ue::generate_format2a( int sched_ue::generate_format2a(dl_harq_proc* h,
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask) 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); std::lock_guard<std::mutex> lock(mutex);
int ret = generate_format2a_unlocked(h, data, tti, cfi, user_mask); int ret = generate_format2a_unlocked(h, data, tti, cfi, user_mask);
@ -534,8 +533,11 @@ int sched_ue::generate_format2a(
} }
// Generates a Format2a dci // Generates a Format2a dci
int sched_ue::generate_format2a_unlocked( int sched_ue::generate_format2a_unlocked(dl_harq_proc* h,
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask) 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}; bool tb_en[SRSLTE_MAX_TB] = {false};
@ -637,8 +639,11 @@ int sched_ue::generate_format2a_unlocked(
} }
// Generates a Format2 dci // Generates a Format2 dci
int sched_ue::generate_format2( int sched_ue::generate_format2(dl_harq_proc* h,
dl_harq_proc* h, sched_interface::dl_sched_data_t* data, uint32_t tti, uint32_t cfi, const rbgmask_t& user_mask) 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); 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) { 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; data->dci.pinfo = (uint8_t)(dl_pmi + 1) % (uint8_t)5;
} else { } else {
data->dci.pinfo = (uint8_t)(dl_pmi & 1); data->dci.pinfo = (uint8_t)(dl_pmi & 1u);
} }
return ret; return ret;
@ -698,7 +703,7 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data,
} else { } else {
// retx // 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; 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) { if (!is_first_dl_tx() && nof_ta_cmd) {
pending_data += nof_ta_cmd*2; pending_data += nof_ta_cmd * 2;
} }
return pending_data; 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) { if (oldest_idx >= 0) {
h = &dl_harq[oldest_idx]; 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); 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++) { for (int i = 0; i < SCHED_MAX_HARQ_PROC && !h; i++) {
if (dl_harq[i].is_empty(0) && dl_harq[i].is_empty(1)) { if (dl_harq[i].is_empty(0) && dl_harq[i].is_empty(1)) {
h = &dl_harq[i]; 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; uint32_t nof_prb = 0;
for (uint32_t i = 0; i < nb; i++) { 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++) { for (uint32_t j = 0; j < P; j++) {
if (i * P + j < cell_nof_prb) { if (i * P + j < cell_nof_prb) {
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; return nof_prb;
} }
int sched_ue::cqi_to_tbs( int sched_ue::cqi_to_tbs(uint32_t cqi,
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) 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); float max_coderate = srslte_cqi_to_coderate(cqi);
int sel_mcs = max_mcs + 1; int sel_mcs = max_mcs + 1;

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