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,23 +44,15 @@ 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() {
log()
{
service_name = "";
tti = 0;
level = LOG_LEVEL_NONE;
@ -68,38 +60,37 @@ public:
add_string_en = false;
}
log(std::string service_name_) {
service_name = service_name_;
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_) {
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,16 +108,10 @@ 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;
@ -139,13 +124,21 @@ public:
// 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");}
{
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");}
{
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");}
{
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");}
{
error("debug_hex not implemented.\n");
}
protected:
std::string get_service_name() { return service_name; }
@ -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)
@ -94,7 +92,6 @@ public:
} cell_cfg_t;
typedef struct {
int priority;
int bsd;
@ -125,7 +122,6 @@ public:
uint32_t nbytes;
} dl_sched_pdu_t;
typedef struct {
uint32_t lcid;
uint32_t lcid_buffer_size;
@ -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;
@ -202,9 +196,7 @@ public:
typedef struct {
uint16_t rnti;
enum phich_elem {
ACK, NACK
} phich;
enum phich_elem { ACK, NACK } phich;
} ul_sched_phich_t;
typedef struct {
@ -260,6 +252,6 @@ public:
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,8 +115,12 @@ 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);
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);
@ -230,13 +234,6 @@ 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;

@ -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];
@ -121,12 +121,21 @@ public:
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,8 +165,13 @@ 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);
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);
@ -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];
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,12 +84,13 @@ 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;
@ -111,11 +100,10 @@ private:
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
@ -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,
@ -731,7 +737,8 @@ void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sc
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,
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
@ -749,7 +756,9 @@ void ra_sched::dl_sched(srsenb::sched::carrier_sched::tti_sched_result_t* tti_sc
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);
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;

@ -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)
{
log_h = NULL;
sched_ue::sched_ue()
{
log_h = nullptr;
bzero(&cell, sizeof(cell));
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;
}
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);
@ -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;
}
@ -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;

@ -29,8 +29,8 @@
#include "srslte/interfaces/sched_interface.h"
#include "srslte/srslte.h"
using srslte::byte_buffer_t;
using srslte::bit_buffer_t;
using srslte::byte_buffer_t;
using srslte::uint32_to_uint8;
using srslte::uint8_to_uint32;
@ -38,19 +38,19 @@ using namespace asn1::rrc;
namespace srsenb {
rrc::rrc() : act_monitor(this), cnotifier(NULL), running(false), nof_si_messages(0), thread("RRC")
rrc::rrc() : act_monitor(this), cnotifier(nullptr), nof_si_messages(0), thread("RRC")
{
users.clear();
pending_paging.clear();
pool = NULL;
phy = NULL;
mac = NULL;
rlc = NULL;
pdcp = NULL;
gtpu = NULL;
s1ap = NULL;
rrc_log = NULL;
pool = nullptr;
phy = nullptr;
mac = nullptr;
rlc = nullptr;
pdcp = nullptr;
gtpu = nullptr;
s1ap = nullptr;
rrc_log = nullptr;
bzero(&sr_sched, sizeof(sr_sched));
bzero(&cqi_sched, sizeof(cqi_sched));
@ -78,7 +78,7 @@ void rrc::init(rrc_cfg_t* cfg_,
gtpu = gtpu_;
s1ap = s1ap_;
rrc_log = log_rrc;
cnotifier = NULL;
cnotifier = nullptr;
running = false;
pool = srslte::byte_buffer_pool::get_instance();
@ -94,8 +94,8 @@ void rrc::init(rrc_cfg_t* cfg_,
config_mac();
enb_mobility_cfg.reset(new mobility_cfg(&cfg, log_rrc));
pthread_mutex_init(&user_mutex, NULL);
pthread_mutex_init(&paging_mutex, NULL);
pthread_mutex_init(&user_mutex, nullptr);
pthread_mutex_init(&paging_mutex, nullptr);
act_monitor.start(RRC_THREAD_PRIO);
bzero(&sr_sched, sizeof(sr_sched_t));
@ -112,7 +112,7 @@ void rrc::stop()
{
if (running) {
running = false;
rrc_pdu p = {0, LCID_EXIT, NULL};
rrc_pdu p = {0, LCID_EXIT, nullptr};
rx_pdu_queue.push(std::move(p));
wait_thread_finish();
}
@ -124,7 +124,6 @@ void rrc::stop()
pthread_mutex_destroy(&paging_mutex);
}
/*******************************************************************************
Public functions
@ -136,7 +135,7 @@ void rrc::get_metrics(rrc_metrics_t &m)
if (running) {
pthread_mutex_lock(&user_mutex);
m.n_ues = 0;
for(std::map<uint16_t, ue>::iterator iter=users.begin(); m.n_ues < ENB_METRICS_MAX_USERS &&iter!=users.end(); ++iter) {
for (auto iter = users.begin(); m.n_ues < ENB_METRICS_MAX_USERS && iter != users.end(); ++iter) {
ue* u = (ue*)&iter->second;
if (iter->first != SRSLTE_MRNTI) {
m.ues[m.n_ues++].state = u->get_state();
@ -162,46 +161,54 @@ void rrc::read_pdu_bcch_dlsch(uint32_t sib_index, uint8_t* payload)
void rrc::rl_failure(uint16_t rnti)
{
rrc_pdu p = {rnti, LCID_RLF_USER, NULL};
rrc_pdu p = {rnti, LCID_RLF_USER, nullptr};
rx_pdu_queue.push(std::move(p));
}
void rrc::set_activity_user(uint16_t rnti)
{
rrc_pdu p = {rnti, LCID_ACT_USER, NULL};
rrc_pdu p = {rnti, LCID_ACT_USER, nullptr};
rx_pdu_queue.push(std::move(p));
}
void rrc::rem_user_thread(uint16_t rnti)
{
rrc_pdu p = {rnti, LCID_REM_USER, NULL};
rrc_pdu p = {rnti, LCID_REM_USER, nullptr};
rx_pdu_queue.push(std::move(p));
}
uint32_t rrc::get_nof_users() {
uint32_t rrc::get_nof_users()
{
return users.size();
}
template <class T>
void rrc::log_rrc_message(const std::string& source, const direction_t dir, const srslte::byte_buffer_t* pdu,
void rrc::log_rrc_message(const std::string& source,
const direction_t dir,
const srslte::byte_buffer_t* pdu,
const T& msg)
{
if (rrc_log->get_level() == srslte::LOG_LEVEL_INFO) {
rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx",
msg.msg.c1().type().to_string().c_str(), pdu->N_bytes);
rrc_log->info("%s - %s %s (%d B)\n",
source.c_str(),
dir == Tx ? "Tx" : "Rx",
msg.msg.c1().type().to_string().c_str(),
pdu->N_bytes);
} else if (rrc_log->get_level() >= srslte::LOG_LEVEL_DEBUG) {
asn1::json_writer json_writer;
msg.to_json(json_writer);
rrc_log->debug_hex(pdu->msg, pdu->N_bytes, "%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx",
msg.msg.c1().type().to_string().c_str(), pdu->N_bytes);
rrc_log->debug_hex(pdu->msg,
pdu->N_bytes,
"%s - %s %s (%d B)\n",
source.c_str(),
dir == Tx ? "Tx" : "Rx",
msg.msg.c1().type().to_string().c_str(),
pdu->N_bytes);
rrc_log->debug("Content:\n%s\n", json_writer.to_string().c_str());
}
}
void rrc::max_retx_attempted(uint16_t rnti)
{
}
void rrc::max_retx_attempted(uint16_t rnti) {}
// This function is called from PRACH worker (can wait)
void rrc::add_user(uint16_t rnti)
@ -218,18 +225,16 @@ void rrc::add_user(uint16_t rnti)
}
if (rnti == SRSLTE_MRNTI) {
srslte::pdcp_config_t pdcp_cfg = {.bearer_id = 1,
.rb_type = srslte::PDCP_RB_IS_DRB,
.tx_direction = srslte::SECURITY_DIRECTION_DOWNLINK,
.rx_direction = srslte::SECURITY_DIRECTION_UPLINK,
.sn_len = srslte::PDCP_SN_LEN_12,
.t_reorderding = srslte::pdcp_t_reordering_t::ms500};
srslte::pdcp_config_t pdcp_cfg{1,
srslte::PDCP_RB_IS_DRB,
srslte::SECURITY_DIRECTION_DOWNLINK,
srslte::SECURITY_DIRECTION_UPLINK,
srslte::PDCP_SN_LEN_12,
srslte::pdcp_t_reordering_t::ms500};
uint32_t teid_in = 1;
for (uint32_t i = 0; i < mcch.msg.c1().mbsfn_area_cfg_r9().pmch_info_list_r9[0].mbms_session_info_list_r9.size();
i++) {
uint32_t lcid = mcch.msg.c1().mbsfn_area_cfg_r9().pmch_info_list_r9[0].mbms_session_info_list_r9[i].lc_ch_id_r9;
for (auto& mbms_item : mcch.msg.c1().mbsfn_area_cfg_r9().pmch_info_list_r9[0].mbms_session_info_list_r9) {
uint32_t lcid = mbms_item.lc_ch_id_r9;
rlc->add_bearer_mrb(SRSLTE_MRNTI, lcid);
pdcp->add_bearer(SRSLTE_MRNTI, lcid, pdcp_cfg);
gtpu->add_bearer(SRSLTE_MRNTI, lcid, 1, 1, &teid_in);
@ -261,8 +266,6 @@ void rrc::upd_user(uint16_t new_rnti, uint16_t old_rnti)
pthread_mutex_unlock(&user_mutex);
}
/*******************************************************************************
PDCP interface
*******************************************************************************/
@ -292,7 +295,8 @@ void rrc::write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu)
dl_info_r8->ded_info_type.set_ded_info_nas();
dl_info_r8->ded_info_type.ded_info_nas().resize(sdu->N_bytes);
memcpy(msg_c1->dl_info_transfer().crit_exts.c1().dl_info_transfer_r8().ded_info_type.ded_info_nas().data(),
sdu->msg, sdu->N_bytes);
sdu->msg,
sdu->N_bytes);
sdu->clear();
@ -304,8 +308,9 @@ void rrc::write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu)
pthread_mutex_unlock(&user_mutex);
}
void rrc::release_complete(uint16_t rnti) {
rrc_pdu p = {rnti, LCID_REL_USER, NULL};
void rrc::release_complete(uint16_t rnti)
{
rrc_pdu p = {rnti, LCID_REL_USER, nullptr};
rx_pdu_queue.push(std::move(p));
}
@ -459,7 +464,6 @@ bool rrc::modify_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIO
return true;
}
bool rrc::setup_ue_erabs(uint16_t rnti, LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT* msg)
{
pthread_mutex_lock(&user_mutex);
@ -546,8 +550,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len)
std::vector<uint32_t> ue_to_remove;
int n = 0;
for (std::map<uint32_t, LIBLTE_S1AP_UEPAGINGID_STRUCT>::iterator iter = pending_paging.begin();
n < ASN1_RRC_MAX_PAGE_REC && iter != pending_paging.end(); ++iter) {
for (auto iter = pending_paging.begin(); n < ASN1_RRC_MAX_PAGE_REC && iter != pending_paging.end(); ++iter) {
LIBLTE_S1AP_UEPAGINGID_STRUCT u = (LIBLTE_S1AP_UEPAGINGID_STRUCT)iter->second;
uint32_t ueid = ((uint32_t)iter->first) % 1024;
uint32_t i_s = (ueid / N) % Ns;
@ -571,7 +574,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len)
paging_elem.ue_id.s_tmsi().mmec.from_number(u.choice.s_TMSI.mMEC.buffer[0]);
uint32_t m_tmsi = 0;
for (int i = 0; i < LIBLTE_S1AP_M_TMSI_OCTET_STRING_LEN; i++) {
m_tmsi |= u.choice.s_TMSI.m_TMSI.buffer[i] << (8 * (LIBLTE_S1AP_M_TMSI_OCTET_STRING_LEN - i - 1));
m_tmsi |= u.choice.s_TMSI.m_TMSI.buffer[i] << (8u * (LIBLTE_S1AP_M_TMSI_OCTET_STRING_LEN - i - 1));
}
paging_elem.ue_id.s_tmsi().m_tmsi.from_number(m_tmsi);
}
@ -601,7 +604,9 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len)
*payload_len = byte_buf_paging.N_bytes;
}
rrc_log->info("Assembling PCCH payload with %d UE identities, payload_len=%d bytes, nbits=%d\n",
paging_rec->paging_record_list.size(), byte_buf_paging.N_bytes, N_bits);
paging_rec->paging_record_list.size(),
byte_buf_paging.N_bytes,
N_bits);
log_rrc_message("PCCH-Message", Tx, &byte_buf_paging, pcch_msg);
return true;
@ -790,7 +795,8 @@ void rrc::config_mac()
}
}
sched_cfg.prach_config = cfg.sibs[1].sib2().rr_cfg_common.prach_cfg.prach_cfg_info.prach_cfg_idx;
sched_cfg.prach_nof_preambles = cfg.sibs[1].sib2().rr_cfg_common.rach_cfg_common.preamb_info.nof_ra_preambs.to_number();
sched_cfg.prach_nof_preambles =
cfg.sibs[1].sib2().rr_cfg_common.rach_cfg_common.preamb_info.nof_ra_preambs.to_number();
sched_cfg.si_window_ms = cfg.sib1.si_win_len.to_number();
sched_cfg.prach_rar_window =
cfg.sibs[1].sib2().rr_cfg_common.rach_cfg_common.ra_supervision_info.ra_resp_win_size.to_number();
@ -836,8 +842,8 @@ uint32_t rrc::generate_sibs()
}
// Add other SIBs to this message, if any
for (uint32_t mapping = 0; mapping < sched_info[sched_info_elem].sib_map_info.size(); mapping++) {
sib_list.push_back(cfg.sibs[(int)sched_info[sched_info_elem].sib_map_info[mapping] + 2]);
for (auto& mapping_enum : sched_info[sched_info_elem].sib_map_info) {
sib_list.push_back(cfg.sibs[(int)mapping_enum + 2]);
}
}
@ -861,7 +867,7 @@ uint32_t rrc::generate_sibs()
return nof_messages;
}
void rrc::configure_mbsfn_sibs(sib_type2_s* sib2, sib_type13_r9_s* sib13)
void rrc::configure_mbsfn_sibs(sib_type2_s* sib2_, sib_type13_r9_s* sib13_)
{
// Temp assignment of MCCH, this will eventually come from a cfg file
mcch.msg.set_c1();
@ -894,15 +900,16 @@ void rrc::configure_mbsfn_sibs(sib_type2_s* sib2, sib_type13_r9_s* sib13)
pmch_item->mbms_session_info_list_r9[1].tmgi_r9.plmn_id_r9.set_explicit_value_r9() =
pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9();
byte[2] = 1;
memcpy(&pmch_item->mbms_session_info_list_r9[1].tmgi_r9.service_id_r9[0], &byte[0],
memcpy(&pmch_item->mbms_session_info_list_r9[1].tmgi_r9.service_id_r9[0],
&byte[0],
3); // FIXME: Check if service is set to 1
}
pmch_item->pmch_cfg_r9.data_mcs_r9 = 20;
pmch_item->pmch_cfg_r9.mch_sched_period_r9 = pmch_cfg_r9_s::mch_sched_period_r9_e_::rf64;
pmch_item->pmch_cfg_r9.sf_alloc_end_r9 = 64 * 6;
phy->configure_mbsfn(sib2, sib13, mcch);
mac->write_mcch(sib2, sib13, &mcch);
phy->configure_mbsfn(sib2_, sib13_, mcch);
mac->write_mcch(sib2_, sib13_, &mcch);
}
void rrc::configure_security(uint16_t rnti,
@ -979,8 +986,6 @@ void rrc::run_thread()
}
}
/*******************************************************************************
Activity monitor class
*******************************************************************************/
@ -1002,12 +1007,11 @@ void rrc::activity_monitor::stop()
void rrc::activity_monitor::run_thread()
{
while(running)
{
while (running) {
usleep(10000);
pthread_mutex_lock(&parent->user_mutex);
uint16_t rem_rnti = 0;
for(std::map<uint16_t, ue>::iterator iter=parent->users.begin(); rem_rnti == 0 && iter!=parent->users.end(); ++iter) {
for (auto iter = parent->users.begin(); rem_rnti == 0 && iter != parent->users.end(); ++iter) {
if (iter->first != SRSLTE_MRNTI) {
ue* u = (ue*)&iter->second;
uint16_t rnti = (uint16_t)iter->first;
@ -1018,7 +1022,8 @@ void rrc::activity_monitor::run_thread()
}
if (u->is_timeout()) {
parent->rrc_log->info("User rnti=0x%x timed out. Exists in s1ap=%s\n", rnti, parent->s1ap->user_exists(rnti)?"yes":"no");
parent->rrc_log->info(
"User rnti=0x%x timed out. Exists in s1ap=%s\n", rnti, parent->s1ap->user_exists(rnti) ? "yes" : "no");
rem_rnti = rnti;
}
}
@ -1048,26 +1053,9 @@ rrc::ue::ue(rrc* outer_rrc, uint16_t rnti_) :
pool(srslte::byte_buffer_pool::get_instance())
{
set_activity();
has_tmsi = false;
connect_notified = false;
transaction_id = 0;
sr_allocated = false;
sr_sched_sf_idx = 0;
sr_sched_prb_idx = 0;
sr_N_pucch = 0;
sr_I = 0;
cqi_allocated = false;
cqi_pucch = 0;
cqi_idx = 0;
cqi_sched_sf_idx = 0;
cqi_sched_prb_idx = 0;
rlf_cnt = 0;
integ_algo = srslte::INTEGRITY_ALGORITHM_ID_EIA0;
cipher_algo = srslte::CIPHERING_ALGORITHM_ID_EEA0;
nas_pending = false;
is_csfb = false;
state = RRC_STATE_IDLE;
gettimeofday(&t_ue_init, NULL);
gettimeofday(&t_ue_init, nullptr);
mobility_handler.reset(new rrc_mobility(this));
}
@ -1076,14 +1064,15 @@ rrc_state_t rrc::ue::get_state()
return state;
}
uint32_t rrc::ue::rl_failure() {
uint32_t rrc::ue::rl_failure()
{
rlf_cnt++;
return rlf_cnt;
}
void rrc::ue::set_activity()
{
gettimeofday(&t_last_activity, NULL);
gettimeofday(&t_last_activity, nullptr);
if (parent) {
if (parent->rrc_log) {
parent->rrc_log->debug("Activity registered rnti=0x%x\n", rnti);
@ -1091,11 +1080,13 @@ void rrc::ue::set_activity()
}
}
bool rrc::ue::is_connected() {
bool rrc::ue::is_connected()
{
return state == RRC_STATE_REGISTERED;
}
bool rrc::ue::is_idle() {
bool rrc::ue::is_idle()
{
return state == RRC_STATE_IDLE;
}
@ -1108,9 +1099,9 @@ bool rrc::ue::is_timeout()
struct timeval t[3];
uint32_t deadline_s = 0;
uint32_t deadline_us = 0;
const char *deadline_str = NULL;
const char* deadline_str = nullptr;
memcpy(&t[1], &t_last_activity, sizeof(struct timeval));
gettimeofday(&t[2], NULL);
gettimeofday(&t[2], nullptr);
get_time_interval(t);
switch (state) {
@ -1142,9 +1133,12 @@ bool rrc::ue::is_timeout()
int64_t elapsed = t[0].tv_sec * 1e6 + t[0].tv_usec;
if (elapsed > deadline && elapsed > 0) {
parent->rrc_log->warning("User rnti=0x%x expired %s deadline: %ld:%ld>%d:%d us\n",
rnti, deadline_str,
t[0].tv_sec, t[0].tv_usec,
deadline_s, deadline_us);
rnti,
deadline_str,
t[0].tv_sec,
t[0].tv_usec,
deadline_s,
deadline_us);
memcpy(&t_last_activity, &t[2], sizeof(struct timeval));
state = RRC_STATE_RELEASE_REQUEST;
return true;
@ -1248,7 +1242,6 @@ void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_r8_ies_s* msg)
{
// TODO: Check Short-MAC-I value
parent->rrc_log->error("Not Supported: ConnectionReestablishment. \n");
}
void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srslte::unique_byte_buffer_t pdu)
@ -1344,16 +1337,9 @@ void rrc::ue::set_security_key(uint8_t* key, uint32_t length)
srslte::security_generate_k_rrc(k_enb, cipher_algo, integ_algo, k_rrc_enc, k_rrc_int);
// Generate K_up_enc and K_up_int
security_generate_k_up( k_enb,
cipher_algo,
integ_algo,
k_up_enc,
k_up_int);
security_generate_k_up(k_enb, cipher_algo, integ_algo, k_up_enc, k_up_int);
parent->configure_security(rnti, RB_ID_SRB1,
k_rrc_enc, k_rrc_int,
k_up_enc, k_up_int,
cipher_algo, integ_algo);
parent->configure_security(rnti, RB_ID_SRB1, k_rrc_enc, k_rrc_int, k_up_enc, k_up_int, cipher_algo, integ_algo);
parent->enable_integrity(rnti, RB_ID_SRB1);
@ -1379,9 +1365,9 @@ bool rrc::ue::setup_erabs(LIBLTE_S1AP_E_RABTOBESETUPLISTCTXTSUREQ_STRUCT *e)
uint32_t teid_out;
uint8_to_uint32(erab->gTP_TEID.buffer, &teid_out);
LIBLTE_S1AP_NAS_PDU_STRUCT *nas_pdu = erab->nAS_PDU_present ? &erab->nAS_PDU : NULL;
setup_erab(erab->e_RAB_ID.E_RAB_ID, &erab->e_RABlevelQoSParameters,
&erab->transportLayerAddress, teid_out, nas_pdu);
LIBLTE_S1AP_NAS_PDU_STRUCT* nas_pdu = erab->nAS_PDU_present ? &erab->nAS_PDU : nullptr;
setup_erab(
erab->e_RAB_ID.E_RAB_ID, &erab->e_RABlevelQoSParameters, &erab->transportLayerAddress, teid_out, nas_pdu);
}
return true;
}
@ -1403,8 +1389,11 @@ bool rrc::ue::setup_erabs(LIBLTE_S1AP_E_RABTOBESETUPLISTBEARERSUREQ_STRUCT *e)
uint32_t teid_out;
uint8_to_uint32(erab->gTP_TEID.buffer, &teid_out);
setup_erab(erab->e_RAB_ID.E_RAB_ID, &erab->e_RABlevelQoSParameters,
&erab->transportLayerAddress, teid_out, &erab->nAS_PDU);
setup_erab(erab->e_RAB_ID.E_RAB_ID,
&erab->e_RABlevelQoSParameters,
&erab->transportLayerAddress,
teid_out,
&erab->nAS_PDU);
}
// Work in progress
@ -1413,8 +1402,10 @@ bool rrc::ue::setup_erabs(LIBLTE_S1AP_E_RABTOBESETUPLISTBEARERSUREQ_STRUCT *e)
return true;
}
void rrc::ue::setup_erab(uint8_t id, LIBLTE_S1AP_E_RABLEVELQOSPARAMETERS_STRUCT *qos,
LIBLTE_S1AP_TRANSPORTLAYERADDRESS_STRUCT *addr, uint32_t teid_out,
void rrc::ue::setup_erab(uint8_t id,
LIBLTE_S1AP_E_RABLEVELQOSPARAMETERS_STRUCT* qos,
LIBLTE_S1AP_TRANSPORTLAYERADDRESS_STRUCT* addr,
uint32_t teid_out,
LIBLTE_S1AP_NAS_PDU_STRUCT* nas_pdu)
{
erabs[id].id = id;
@ -1439,10 +1430,7 @@ void rrc::ue::setup_erab(uint8_t id, LIBLTE_S1AP_E_RABLEVELQOSPARAMETERS_STRUCT
bool rrc::ue::release_erabs()
{
typedef std::map<uint8_t, erab_t>::iterator it_t;
for(it_t it=erabs.begin(); it!=erabs.end(); ++it) {
// TODO: notify GTPU layer
}
// TODO: notify GTPU layer for each ERAB
erabs.clear();
return true;
}
@ -1457,14 +1445,13 @@ void rrc::ue::notify_s1ap_ue_ctxt_setup_complete()
res.E_RABSetupListCtxtSURes.len = 0;
res.E_RABFailedToSetupListCtxtSURes.len = 0;
typedef std::map<uint8_t, erab_t>::iterator it_t;
for(it_t it=erabs.begin(); it!=erabs.end(); ++it) {
for (auto& erab : erabs) {
uint32_t j = res.E_RABSetupListCtxtSURes.len++;
res.E_RABSetupListCtxtSURes.buffer[j].ext = false;
res.E_RABSetupListCtxtSURes.buffer[j].iE_Extensions_present = false;
res.E_RABSetupListCtxtSURes.buffer[j].e_RAB_ID.ext = false;
res.E_RABSetupListCtxtSURes.buffer[j].e_RAB_ID.E_RAB_ID = it->second.id;
uint32_to_uint8(it->second.teid_in, res.E_RABSetupListCtxtSURes.buffer[j].gTP_TEID.buffer);
res.E_RABSetupListCtxtSURes.buffer[j].e_RAB_ID.E_RAB_ID = erab.second.id;
uint32_to_uint8(erab.second.teid_in, res.E_RABSetupListCtxtSURes.buffer[j].gTP_TEID.buffer);
}
parent->s1ap->ue_ctxt_setup_complete(rnti, &res);
@ -1518,7 +1505,7 @@ void rrc::ue::send_connection_setup(bool is_setup)
dl_ccch_msg_s dl_ccch_msg;
dl_ccch_msg.msg.set_c1();
rr_cfg_ded_s* rr_cfg = NULL;
rr_cfg_ded_s* rr_cfg = nullptr;
if (is_setup) {
dl_ccch_msg.msg.c1().set_rrc_conn_setup();
dl_ccch_msg.msg.c1().rrc_conn_setup().rrc_transaction_id = (uint8_t)((transaction_id++) % 4);
@ -1569,7 +1556,8 @@ void rrc::ue::send_connection_setup(bool is_setup)
phy_cfg->ant_info.explicit_value().ue_tx_ant_sel.set(setup_e::release);
if (is_setup) {
if (sr_allocate(parent->cfg.sr_cfg.period, &phy_cfg->sched_request_cfg.setup().sr_cfg_idx,
if (sr_allocate(parent->cfg.sr_cfg.period,
&phy_cfg->sched_request_cfg.setup().sr_cfg_idx,
&phy_cfg->sched_request_cfg.setup().sr_pucch_res_idx)) {
parent->rrc_log->error("Allocating SR resources for rnti=%d\n", rnti);
return;
@ -1604,7 +1592,8 @@ void rrc::ue::send_connection_setup(bool is_setup)
cqi_report_periodic_c::setup_s_::cqi_format_ind_periodic_c_::types::wideband_cqi);
phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().simul_ack_nack_and_cqi = false;
if (is_setup) {
if (cqi_allocate(parent->cfg.cqi_cfg.period, &phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pmi_cfg_idx,
if (cqi_allocate(parent->cfg.cqi_cfg.period,
&phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pmi_cfg_idx,
&phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pucch_res_idx)) {
parent->rrc_log->error("Allocating CQI resources for rnti=%d\n", rnti);
return;
@ -1621,7 +1610,8 @@ void rrc::ue::send_connection_setup(bool is_setup)
bzero(&sched_cfg, sizeof(srsenb::sched_interface::ue_cfg_t));
sched_cfg.maxharq_tx = parent->cfg.mac_cnfg.ul_sch_cfg.max_harq_tx.to_number();
sched_cfg.continuous_pusch = false;
sched_cfg.aperiodic_cqi_period = parent->cfg.cqi_cfg.mode == RRC_CFG_CQI_MODE_APERIODIC?parent->cfg.cqi_cfg.period:0;
sched_cfg.aperiodic_cqi_period =
parent->cfg.cqi_cfg.mode == RRC_CFG_CQI_MODE_APERIODIC ? parent->cfg.cqi_cfg.period : 0;
sched_cfg.ue_bearers[0].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH;
sched_cfg.ue_bearers[1].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH;
if (parent->cfg.cqi_cfg.mode == RRC_CFG_CQI_MODE_APERIODIC) {
@ -1647,12 +1637,12 @@ void rrc::ue::send_connection_setup(bool is_setup)
parent->rlc->add_bearer(rnti, 1, srslte::rlc_config_t::srb_config(1));
// Configure SRB1 in PDCP
srslte::pdcp_config_t pdcp_cnfg{.bearer_id = 1,
.rb_type = srslte::PDCP_RB_IS_SRB,
.tx_direction = srslte::SECURITY_DIRECTION_DOWNLINK,
.rx_direction = srslte::SECURITY_DIRECTION_UPLINK,
.sn_len = srslte::PDCP_SN_LEN_5,
.t_reorderding = srslte::pdcp_t_reordering_t::ms500};
srslte::pdcp_config_t pdcp_cnfg{1,
srslte::PDCP_RB_IS_SRB,
srslte::SECURITY_DIRECTION_DOWNLINK,
srslte::SECURITY_DIRECTION_UPLINK,
srslte::PDCP_SN_LEN_5,
srslte::pdcp_t_reordering_t::ms500};
parent->pdcp->add_bearer(rnti, 1, pdcp_cnfg);
@ -1777,7 +1767,6 @@ void rrc::ue::send_connection_reconf_upd(srslte::unique_byte_buffer_t pdu)
send_dl_dcch(&dl_dcch_msg, std::move(pdu));
state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE;
}
void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu)
@ -1868,12 +1857,12 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu)
parent->rlc->add_bearer(rnti, 2, srslte::rlc_config_t::srb_config(2));
// Configure SRB2 in PDCP
srslte::pdcp_config_t pdcp_cnfg_srb = {.bearer_id = 2,
.rb_type = srslte::PDCP_RB_IS_SRB,
.tx_direction = srslte::SECURITY_DIRECTION_DOWNLINK,
.rx_direction = srslte::SECURITY_DIRECTION_UPLINK,
.sn_len = srslte::PDCP_SN_LEN_5,
.t_reorderding = srslte::pdcp_t_reordering_t::ms500};
srslte::pdcp_config_t pdcp_cnfg_srb = {2,
srslte::PDCP_RB_IS_SRB,
srslte::SECURITY_DIRECTION_DOWNLINK,
srslte::SECURITY_DIRECTION_UPLINK,
srslte::PDCP_SN_LEN_5,
srslte::pdcp_t_reordering_t::ms500};
parent->pdcp->add_bearer(rnti, 2, pdcp_cnfg_srb);
parent->pdcp->config_security(rnti, 2, k_rrc_enc, k_rrc_int, k_up_enc, cipher_algo, integ_algo);
@ -1884,12 +1873,12 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu)
parent->rlc->add_bearer(rnti, 3, srslte::make_rlc_config_t(conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].rlc_cfg));
// Configure DRB1 in PDCP
srslte::pdcp_config_t pdcp_cnfg_drb = {.bearer_id = 1,
.rb_type = srslte::PDCP_RB_IS_DRB,
.tx_direction = srslte::SECURITY_DIRECTION_DOWNLINK,
.rx_direction = srslte::SECURITY_DIRECTION_UPLINK,
.sn_len = srslte::PDCP_SN_LEN_12,
.t_reorderding = srslte::pdcp_t_reordering_t::ms500};
srslte::pdcp_config_t pdcp_cnfg_drb = {1,
srslte::PDCP_RB_IS_DRB,
srslte::SECURITY_DIRECTION_DOWNLINK,
srslte::SECURITY_DIRECTION_UPLINK,
srslte::PDCP_SN_LEN_12,
srslte::pdcp_t_reordering_t::ms500};
if (conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].pdcp_cfg.rlc_um_present) {
if (conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].pdcp_cfg.rlc_um.pdcp_sn_size.value ==
@ -1905,7 +1894,8 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu)
// Add NAS Attach accept
if (nas_pending) {
parent->rrc_log->info_hex(erab_info.buffer, erab_info.N_bytes, "connection_reconf erab_info -> nas_info rnti 0x%x\n", rnti);
parent->rrc_log->info_hex(
erab_info.buffer, erab_info.N_bytes, "connection_reconf erab_info -> nas_info rnti 0x%x\n", rnti);
conn_reconf->ded_info_nas_list_present = true;
conn_reconf->ded_info_nas_list.resize(1);
conn_reconf->ded_info_nas_list[0].resize(erab_info.N_bytes);
@ -1959,12 +1949,12 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE
// Configure DRB in PDCP
srslte::pdcp_config_t pdcp_config = {
.bearer_id = (uint8_t)(drb_item.drb_id - 1), // TODO: Review all ID mapping LCID DRB ERAB EPSBID Mapping
.rb_type = srslte::PDCP_RB_IS_DRB,
.tx_direction = srslte::SECURITY_DIRECTION_DOWNLINK,
.rx_direction = srslte::SECURITY_DIRECTION_UPLINK,
.sn_len = srslte::PDCP_SN_LEN_12,
.t_reorderding = srslte::pdcp_t_reordering_t::ms500};
(uint8_t)(drb_item.drb_id - 1), // TODO: Review all ID mapping LCID DRB ERAB EPSBID Mapping
srslte::PDCP_RB_IS_DRB,
srslte::SECURITY_DIRECTION_DOWNLINK,
srslte::SECURITY_DIRECTION_UPLINK,
srslte::PDCP_SN_LEN_12,
srslte::pdcp_t_reordering_t::ms500};
parent->pdcp->add_bearer(rnti, lcid, pdcp_config);
@ -1973,7 +1963,8 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE
conn_reconf->rr_cfg_ded.drb_to_add_mod_list.push_back(drb_item);
// Add NAS message
parent->rrc_log->info_hex(erab_info.buffer, erab_info.N_bytes, "reconf_new_bearer erab_info -> nas_info rnti 0x%x\n", rnti);
parent->rrc_log->info_hex(
erab_info.buffer, erab_info.N_bytes, "reconf_new_bearer erab_info -> nas_info rnti 0x%x\n", rnti);
asn1::dyn_octstring octstr(erab_info.N_bytes);
memcpy(octstr.data(), erab_info.msg, erab_info.N_bytes);
conn_reconf->ded_info_nas_list.push_back(octstr);
@ -2031,8 +2022,8 @@ bool rrc::ue::select_security_algorithms()
bool enc_algo_found = false;
bool integ_algo_found = false;
for (int i = 0; i < srslte::CIPHERING_ALGORITHM_ID_N_ITEMS; i++) {
switch (parent->cfg.eea_preference_list[i]) {
for (auto& cipher_item : parent->cfg.eea_preference_list) {
switch (cipher_item) {
case srslte::CIPHERING_ALGORITHM_ID_EEA0:
// “all bits equal to 0” UE supports no other algorithm than EEA0,
// specification does not cover the case in which EEA0 is supported with other algorithms
@ -2043,8 +2034,7 @@ bool rrc::ue::select_security_algorithms()
break;
case srslte::CIPHERING_ALGORITHM_ID_128_EEA1:
// “first bit” 128-EEA1,
if (security_capabilities.encryptionAlgorithms
.buffer[srslte::CIPHERING_ALGORITHM_ID_128_EEA1 - 1]) {
if (security_capabilities.encryptionAlgorithms.buffer[srslte::CIPHERING_ALGORITHM_ID_128_EEA1 - 1]) {
cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA1;
enc_algo_found = true;
parent->rrc_log->info("Selected EEA1 as RRC encryption algorithm\n");
@ -2055,8 +2045,7 @@ bool rrc::ue::select_security_algorithms()
break;
case srslte::CIPHERING_ALGORITHM_ID_128_EEA2:
// “second bit” 128-EEA2,
if (security_capabilities.encryptionAlgorithms
.buffer[srslte::CIPHERING_ALGORITHM_ID_128_EEA2 - 1]) {
if (security_capabilities.encryptionAlgorithms.buffer[srslte::CIPHERING_ALGORITHM_ID_128_EEA2 - 1]) {
cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA2;
enc_algo_found = true;
parent->rrc_log->info("Selected EEA2 as RRC encryption algorithm\n");
@ -2085,8 +2074,8 @@ bool rrc::ue::select_security_algorithms()
}
}
for (int i = 0; i < srslte::INTEGRITY_ALGORITHM_ID_N_ITEMS; i++) {
switch (parent->cfg.eia_preference_list[i]) {
for (auto& eia_enum : parent->cfg.eia_preference_list) {
switch (eia_enum) {
case srslte::INTEGRITY_ALGORITHM_ID_EIA0:
// Null integrity is not supported
parent->rrc_log->info("Skipping EIA0 as RRC integrity algorithm. Null integrity is not supported.\n");
@ -2190,9 +2179,11 @@ int rrc::ue::sr_free()
if (parent->sr_sched.nof_users[sr_sched_prb_idx][sr_sched_sf_idx] > 0) {
parent->sr_sched.nof_users[sr_sched_prb_idx][sr_sched_sf_idx]--;
} else {
parent->rrc_log->warning("Removing SR resources: no users in time-frequency slot (%d, %d)\n", sr_sched_prb_idx, sr_sched_sf_idx);
parent->rrc_log->warning(
"Removing SR resources: no users in time-frequency slot (%d, %d)\n", sr_sched_prb_idx, sr_sched_sf_idx);
}
parent->rrc_log->info("Deallocated SR resources for time-frequency slot (%d, %d)\n", sr_sched_prb_idx, sr_sched_sf_idx);
parent->rrc_log->info(
"Deallocated SR resources for time-frequency slot (%d, %d)\n", sr_sched_prb_idx, sr_sched_sf_idx);
}
return 0;
}
@ -2236,7 +2227,8 @@ int rrc::ue::sr_allocate(uint32_t period, uint8_t* I_sr, uint16_t* N_pucch_sr)
if (parent->cfg.sr_cfg.sf_mapping[j_min] < period) {
*I_sr = period - 5 + parent->cfg.sr_cfg.sf_mapping[j_min];
} else {
parent->rrc_log->error("Allocating SR: invalid sf_idx=%d for period=%d\n", parent->cfg.sr_cfg.sf_mapping[j_min], period);
parent->rrc_log->error(
"Allocating SR: invalid sf_idx=%d for period=%d\n", parent->cfg.sr_cfg.sf_mapping[j_min], period);
return -1;
}
@ -2255,7 +2247,10 @@ int rrc::ue::sr_allocate(uint32_t period, uint8_t* I_sr, uint16_t* N_pucch_sr)
sr_N_pucch = *N_pucch_sr;
parent->rrc_log->info("Allocated SR resources for time-frequency slot (%d, %d), N_pucch_sr=%d, I_sr=%d\n",
sr_sched_prb_idx, sr_sched_sf_idx, *N_pucch_sr, *I_sr);
sr_sched_prb_idx,
sr_sched_sf_idx,
*N_pucch_sr,
*I_sr);
return 0;
}
@ -2266,9 +2261,11 @@ int rrc::ue::cqi_free()
if (parent->cqi_sched.nof_users[cqi_sched_prb_idx][cqi_sched_sf_idx] > 0) {
parent->cqi_sched.nof_users[cqi_sched_prb_idx][cqi_sched_sf_idx]--;
} else {
parent->rrc_log->warning("Removing CQI resources: no users in time-frequency slot (%d, %d)\n", cqi_sched_prb_idx, cqi_sched_sf_idx);
parent->rrc_log->warning(
"Removing CQI resources: no users in time-frequency slot (%d, %d)\n", cqi_sched_prb_idx, cqi_sched_sf_idx);
}
parent->rrc_log->info("Deallocated CQI resources for time-frequency slot (%d, %d)\n", cqi_sched_prb_idx, cqi_sched_sf_idx);
parent->rrc_log->info(
"Deallocated CQI resources for time-frequency slot (%d, %d)\n", cqi_sched_prb_idx, cqi_sched_sf_idx);
}
return 0;
}
@ -2305,8 +2302,8 @@ int rrc::ue::cqi_allocate(uint32_t period, uint16_t* pmi_idx, uint16_t* n_pucch)
}
// Compute I_sr
if (period != 2 && period != 5 && period != 10 && period != 20 && period != 40 && period != 80 &&
period != 160 && period != 32 && period != 64 && period != 128) {
if (period != 2 && period != 5 && period != 10 && period != 20 && period != 40 && period != 80 && period != 160 &&
period != 32 && period != 64 && period != 128) {
parent->rrc_log->error("Invalid CQI Report period %d ms\n", period);
return -1;
}
@ -2327,7 +2324,8 @@ int rrc::ue::cqi_allocate(uint32_t period, uint16_t* pmi_idx, uint16_t* n_pucch)
}
}
} else {
parent->rrc_log->error("Allocating SR: invalid sf_idx=%d for period=%d\n", parent->cfg.cqi_cfg.sf_mapping[j_min], period);
parent->rrc_log->error(
"Allocating SR: invalid sf_idx=%d for period=%d\n", parent->cfg.cqi_cfg.sf_mapping[j_min], period);
return -1;
}
@ -2393,4 +2391,4 @@ int rrc::ue::ri_get(uint32_t m_ri, uint16_t* ri_idx)
return ret;
}
}
} // namespace srsenb

Loading…
Cancel
Save