diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index c15e0308f..b33d666cd 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -43,14 +43,14 @@ srslte_rf_t rf; #pragma message "Compiling pdsch_ue with no RF support" #endif -char* output_file_name = NULL; +static char* output_file_name = NULL; #define LEFT_KEY 68 #define RIGHT_KEY 67 #define UP_KEY 65 #define DOWN_KEY 66 -srslte_cell_t cell = { +static srslte_cell_t cell = { 25, // nof_prb 1, // nof_ports 0, // cell_id @@ -61,65 +61,59 @@ srslte_cell_t cell = { }; -uint16_t c = -1; - -int net_port = -1; // -1 generates random dataThat means there is some problem sending samples to the device - -uint32_t cfi = 2; -uint32_t mcs_idx = 1, last_mcs_idx = 1; -int nof_frames = -1; - -srslte_tm_t transmission_mode = SRSLTE_TM1; -uint32_t nof_tb = 1; -uint32_t multiplex_pmi = 0; -uint32_t multiplex_nof_layers = 1; -uint8_t mbsfn_sf_mask = 32; -int mbsfn_area_id = -1; -char* rf_args = ""; -char* rf_dev = ""; -float rf_amp = 0.8, rf_gain = 60.0, rf_freq = 2400000000; -static bool enable_256qam = false; - -float output_file_snr = +INFINITY; - -bool null_file_sink = false; -srslte_filesink_t fsink; -srslte_ofdm_t ifft[SRSLTE_MAX_PORTS]; -srslte_ofdm_t ifft_mbsfn; -srslte_pbch_t pbch; -srslte_pcfich_t pcfich; -srslte_pdcch_t pdcch; -srslte_pdsch_t pdsch; -srslte_pdsch_cfg_t pdsch_cfg; -srslte_pmch_t pmch; -srslte_pmch_cfg_t pmch_cfg; -srslte_softbuffer_tx_t* softbuffers[SRSLTE_MAX_CODEWORDS]; -srslte_regs_t regs; -srslte_dci_dl_t dci_dl; -int rvidx[SRSLTE_MAX_CODEWORDS] = {0, 0}; - -cf_t *sf_buffer[SRSLTE_MAX_PORTS] = {NULL}, *output_buffer[SRSLTE_MAX_PORTS] = {NULL}; - -uint32_t sf_n_re, sf_n_samples; - -pthread_t net_thread; -void* net_thread_fnc(void* arg); -sem_t net_sem; -bool net_packet_ready = false; -srslte_netsource_t net_source; -srslte_netsink_t net_sink; - -int prbset_num = 1, last_prbset_num = 1; -int prbset_orig = 0; +static int net_port = -1; // -1 generates random dataThat means there is some problem sending samples to the device +static uint32_t cfi = 2; +static uint32_t mcs_idx = 1, last_mcs_idx = 1; +static int nof_frames = -1; +static srslte_tm_t transmission_mode = SRSLTE_TM1; +static uint32_t nof_tb = 1; +static uint32_t multiplex_pmi = 0; +static uint32_t multiplex_nof_layers = 1; +static uint8_t mbsfn_sf_mask = 32; +static int mbsfn_area_id = -1; +static char* rf_args = ""; +static char* rf_dev = ""; +static float rf_amp = 0.8, rf_gain = 60.0, rf_freq = 2400000000; +static bool enable_256qam = false; +static float output_file_snr = +INFINITY; + +static bool null_file_sink = false; +static srslte_filesink_t fsink; +static srslte_ofdm_t ifft[SRSLTE_MAX_PORTS]; +static srslte_ofdm_t ifft_mbsfn; +static srslte_pbch_t pbch; +static srslte_pcfich_t pcfich; +static srslte_pdcch_t pdcch; +static srslte_pdsch_t pdsch; +static srslte_pdsch_cfg_t pdsch_cfg; +static srslte_pmch_t pmch; +static srslte_pmch_cfg_t pmch_cfg; +static srslte_softbuffer_tx_t* softbuffers[SRSLTE_MAX_CODEWORDS]; +static srslte_regs_t regs; +static srslte_dci_dl_t dci_dl; +static int rvidx[SRSLTE_MAX_CODEWORDS] = {0, 0}; + +static cf_t * sf_buffer[SRSLTE_MAX_PORTS] = {NULL}, *output_buffer[SRSLTE_MAX_PORTS] = {NULL}; +static uint32_t sf_n_re, sf_n_samples; + +static pthread_t net_thread; +static void* net_thread_fnc(void* arg); +static sem_t net_sem; +static bool net_packet_ready = false; +static srslte_netsource_t net_source; +static srslte_netsink_t net_sink; + +static int prbset_num = 1, last_prbset_num = 1; +static int prbset_orig = 0; //#define DATA_BUFF_SZ 1024*128 // uint8_t data[8*DATA_BUFF_SZ], data2[DATA_BUFF_SZ]; // uint8_t data_tmp[DATA_BUFF_SZ]; #define DATA_BUFF_SZ 1024 * 1024 -uint8_t *data_mbms, *data[2], data2[DATA_BUFF_SZ]; -uint8_t data_tmp[DATA_BUFF_SZ]; +static uint8_t *data_mbms, *data[2], data2[DATA_BUFF_SZ]; +static uint8_t data_tmp[DATA_BUFF_SZ]; -void usage(char* prog) +static void usage(char* prog) { printf("Usage: %s [Iagmfoncvpuxb]\n", prog); #ifndef DISABLE_RF @@ -150,7 +144,7 @@ void usage(char* prog) printf("\t*: See 3GPP 36.212 Table 5.3.3.1.5-4 for more information\n"); } -void parse_args(int argc, char** argv) +static void parse_args(int argc, char** argv) { int opt; while ((opt = getopt(argc, argv, "IadglfmoncpqvutxbwMsB")) != -1) { @@ -226,7 +220,7 @@ void parse_args(int argc, char** argv) #endif } -void base_init() +static void base_init() { int i; @@ -395,7 +389,7 @@ void base_init() } } -void base_free() +static void base_free() { int i; for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { @@ -449,16 +443,16 @@ void base_free() bool go_exit = false; #ifndef DISABLE_RF -void sig_int_handler(int signo) +static void sig_int_handler(int signo) { printf("SIGINT received. Exiting...\n"); if (signo == SIGINT) { go_exit = true; } } -#endif +#endif /* DISABLE_RF */ -unsigned int reverse(register unsigned int x) +static unsigned int reverse(register unsigned int x) { x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); @@ -467,7 +461,7 @@ unsigned int reverse(register unsigned int x) return ((x >> 16) | (x << 16)); } -uint32_t prbset_to_bitmask() +static uint32_t prbset_to_bitmask() { uint32_t mask = 0; int nb = (int)ceilf((float)cell.nof_prb / srslte_ra_type0_P(cell.nof_prb)); @@ -479,7 +473,7 @@ uint32_t prbset_to_bitmask() return reverse(mask) >> (32 - nb); } -int update_radl() +static int update_radl() { ZERO_OBJECT(dci_dl); @@ -546,7 +540,7 @@ int update_radl() } /* Read new MCS from stdin */ -int update_control() +static int update_control() { char input[128]; @@ -644,7 +638,7 @@ int update_control() } /** Function run in a separate thread to receive UDP data */ -void* net_thread_fnc(void* arg) +static void* net_thread_fnc(void* arg) { int n; int rpm = 0, wpm = 0; diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index ba47056b4..c19665035 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -244,8 +244,9 @@ public: phy_cfg_mbsfn_t mbsfn; } phy_rrc_cfg_t; - virtual void - configure_mbsfn(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s mcch) = 0; + virtual void configure_mbsfn(asn1::rrc::sib_type2_s* sib2, + asn1::rrc::sib_type13_r9_s* sib13, + const asn1::rrc::mcch_msg_s& mcch) = 0; typedef struct { bool configured = false; ///< Indicates whether PHY shall consider configuring this cell/carrier diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 9695482b9..5bb60eb6d 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -268,7 +268,7 @@ public: virtual void reset() = 0; virtual void reestablish() = 0; virtual void reestablish(uint32_t lcid) = 0; - virtual void add_bearer(uint32_t lcid, srslte::rlc_config_t cnfg) = 0; + virtual void add_bearer(uint32_t lcid, const srslte::rlc_config_t& cnfg) = 0; virtual void add_bearer_mrb(uint32_t lcid) = 0; virtual void del_bearer(uint32_t lcid) = 0; virtual void suspend_bearer(uint32_t lcid) = 0; @@ -397,7 +397,7 @@ public: virtual void mch_decoded(uint32_t len, bool crc) = 0; /* Obtain action for a new MCH subframe. */ - virtual void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action) = 0; + virtual void new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action) = 0; /* Communicate the number of mbsfn services available */ virtual void set_mbsfn_config(uint32_t nof_mbsfn_services) = 0; diff --git a/lib/include/srslte/phy/utils/simd.h b/lib/include/srslte/phy/utils/simd.h index 01e601727..b8dcf7745 100644 --- a/lib/include/srslte/phy/utils/simd.h +++ b/lib/include/srslte/phy/utils/simd.h @@ -116,6 +116,8 @@ typedef _Complex float cf_t; #endif /* LV_HAVE_AVX */ #endif /* LV_HAVE_AVX512 */ +#define srslte_simd_aligned __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) + /* Memory Sizes for Single Floating Point and fixed point */ #ifdef LV_HAVE_AVX512 diff --git a/lib/include/srslte/upper/rlc.h b/lib/include/srslte/upper/rlc.h index 34ad76c74..23bbbe9d2 100644 --- a/lib/include/srslte/upper/rlc.h +++ b/lib/include/srslte/upper/rlc.h @@ -75,7 +75,7 @@ public: void reestablish(uint32_t lcid); void reset(); void empty_queue(); - void add_bearer(uint32_t lcid, rlc_config_t cnfg); + void add_bearer(uint32_t lcid, const rlc_config_t& cnfg); void add_bearer_mrb(uint32_t lcid); void del_bearer(uint32_t lcid); void del_bearer_mrb(uint32_t lcid); diff --git a/lib/include/srslte/upper/rlc_am_lte.h b/lib/include/srslte/upper/rlc_am_lte.h index 35f445bc6..04bc2fcc6 100644 --- a/lib/include/srslte/upper/rlc_am_lte.h +++ b/lib/include/srslte/upper/rlc_am_lte.h @@ -69,7 +69,7 @@ public: srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, srslte::timer_handler* timers_); - bool configure(rlc_config_t cfg_); + bool configure(const rlc_config_t& cfg_); void reestablish(); void stop(); @@ -99,7 +99,7 @@ private: rlc_am_lte_tx(rlc_am_lte* parent_); ~rlc_am_lte_tx(); - bool configure(rlc_config_t cfg_); + bool configure(const rlc_config_t& cfg_); void empty_queue(); void reestablish(); diff --git a/lib/include/srslte/upper/rlc_common.h b/lib/include/srslte/upper/rlc_common.h index f4866c61a..507de1d65 100644 --- a/lib/include/srslte/upper/rlc_common.h +++ b/lib/include/srslte/upper/rlc_common.h @@ -214,11 +214,11 @@ public: // Size of the Uplink buffer in number of PDUs const static int RLC_BUFFER_NOF_PDU = 128; - virtual ~rlc_common() {} - virtual bool configure(rlc_config_t cnfg) = 0; - virtual void stop() = 0; - virtual void reestablish() = 0; - virtual void empty_queue() = 0; + virtual ~rlc_common() = default; + virtual bool configure(const rlc_config_t& cnfg) = 0; + virtual void stop() = 0; + virtual void reestablish() = 0; + virtual void empty_queue() = 0; bool suspend() { diff --git a/lib/include/srslte/upper/rlc_tm.h b/lib/include/srslte/upper/rlc_tm.h index f92bcd280..0ddf32fea 100644 --- a/lib/include/srslte/upper/rlc_tm.h +++ b/lib/include/srslte/upper/rlc_tm.h @@ -31,7 +31,7 @@ namespace srslte { -class rlc_tm : public rlc_common +class rlc_tm final : public rlc_common { public: rlc_tm(srslte::log_ref log_, @@ -41,7 +41,7 @@ public: srslte::timer_handler* timers_, uint32_t queue_len = 16); ~rlc_tm(); - bool configure(rlc_config_t cnfg); + bool configure(const rlc_config_t& cnfg) override; void stop(); void reestablish(); void empty_queue(); diff --git a/lib/include/srslte/upper/rlc_um_base.h b/lib/include/srslte/upper/rlc_um_base.h index 8edc8e4c5..9782ffa90 100644 --- a/lib/include/srslte/upper/rlc_um_base.h +++ b/lib/include/srslte/upper/rlc_um_base.h @@ -73,7 +73,7 @@ protected: public: rlc_um_base_tx(rlc_um_base* parent_); virtual ~rlc_um_base_tx(); - virtual bool configure(rlc_config_t cfg, std::string rb_name) = 0; + virtual bool configure(const rlc_config_t& cfg, std::string rb_name) = 0; int build_data_pdu(uint8_t* payload, uint32_t nof_bytes); void stop(); void reestablish(); diff --git a/lib/include/srslte/upper/rlc_um_lte.h b/lib/include/srslte/upper/rlc_um_lte.h index dffff2885..096d4d3b9 100644 --- a/lib/include/srslte/upper/rlc_um_lte.h +++ b/lib/include/srslte/upper/rlc_um_lte.h @@ -49,7 +49,7 @@ public: srsue::rrc_interface_rlc* rrc_, srslte::timer_handler* timers_); ~rlc_um_lte(); - bool configure(rlc_config_t cnfg); + bool configure(const rlc_config_t& cnfg); private: // Transmitter sub-class for LTE @@ -58,7 +58,7 @@ private: public: rlc_um_lte_tx(rlc_um_base* parent_); - bool configure(rlc_config_t cfg, std::string rb_name); + bool configure(const rlc_config_t& cfg, std::string rb_name); int build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes); uint32_t get_buffer_state(); diff --git a/lib/src/common/snow_3g.cc b/lib/src/common/snow_3g.cc index b24e80ab6..13ab0c102 100644 --- a/lib/src/common/snow_3g.cc +++ b/lib/src/common/snow_3g.cc @@ -39,7 +39,7 @@ u32 FSM_R3 = 0x00; /* Rijndael S-box SR */ -u8 SR[256] = { +static u8 snow_3g_SR[256] = { 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, @@ -57,7 +57,7 @@ u8 SR[256] = { /* S-box SQ */ -u8 SQ[256] = { +static u8 snow_3g_SQ[256] = { 0x25, 0x24, 0x73, 0x67, 0xD7, 0xAE, 0x5C, 0x30, 0xA4, 0xEE, 0x6E, 0xCB, 0x7D, 0xB5, 0x82, 0xDB, 0xE4, 0x8E, 0x48, 0x49, 0x4F, 0x5D, 0x6A, 0x78, 0x70, 0x88, 0xE8, 0x5F, 0x5E, 0x84, 0x65, 0xE2, 0xD8, 0xE9, 0xCC, 0xED, 0x40, 0x2F, 0x11, 0x28, 0x57, 0xD2, 0xAC, 0xE3, 0x4A, 0x15, 0x1B, 0xB9, 0xB2, 0x80, 0x85, 0xA6, 0x2E, 0x02, 0x47, 0x29, 0x07, @@ -137,10 +137,10 @@ u32 DIValpha(u8 c) u32 S1(u32 w) { u8 r0 = 0, r1 = 0, r2 = 0, r3 = 0; - u8 srw0 = SR[(u8)((w >> 24) & 0xff)]; - u8 srw1 = SR[(u8)((w >> 16) & 0xff)]; - u8 srw2 = SR[(u8)((w >> 8) & 0xff)]; - u8 srw3 = SR[(u8)((w)&0xff)]; + u8 srw0 = snow_3g_SR[(u8)((w >> 24) & 0xff)]; + u8 srw1 = snow_3g_SR[(u8)((w >> 16) & 0xff)]; + u8 srw2 = snow_3g_SR[(u8)((w >> 8) & 0xff)]; + u8 srw3 = snow_3g_SR[(u8)((w)&0xff)]; r0 = ((MULx(srw0, 0x1b)) ^ (srw1) ^ (srw2) ^ ((MULx(srw3, 0x1b)) ^ srw3)); r1 = (((MULx(srw0, 0x1b)) ^ srw0) ^ (MULx(srw1, 0x1b)) ^ (srw2) ^ (srw3)); r2 = ((srw0) ^ ((MULx(srw1, 0x1b)) ^ srw1) ^ (MULx(srw2, 0x1b)) ^ (srw3)); @@ -158,10 +158,10 @@ u32 S1(u32 w) u32 S2(u32 w) { u8 r0 = 0, r1 = 0, r2 = 0, r3 = 0; - u8 sqw0 = SQ[(u8)((w >> 24) & 0xff)]; - u8 sqw1 = SQ[(u8)((w >> 16) & 0xff)]; - u8 sqw2 = SQ[(u8)((w >> 8) & 0xff)]; - u8 sqw3 = SQ[(u8)((w)&0xff)]; + u8 sqw0 = snow_3g_SQ[(u8)((w >> 24) & 0xff)]; + u8 sqw1 = snow_3g_SQ[(u8)((w >> 16) & 0xff)]; + u8 sqw2 = snow_3g_SQ[(u8)((w >> 8) & 0xff)]; + u8 sqw3 = snow_3g_SQ[(u8)((w)&0xff)]; r0 = ((MULx(sqw0, 0x69)) ^ (sqw1) ^ (sqw2) ^ ((MULx(sqw3, 0x69)) ^ sqw3)); r1 = (((MULx(sqw0, 0x69)) ^ sqw0) ^ (MULx(sqw1, 0x69)) ^ (sqw2) ^ (sqw3)); r2 = ((sqw0) ^ ((MULx(sqw1, 0x69)) ^ sqw1) ^ (MULx(sqw2, 0x69)) ^ (sqw3)); diff --git a/lib/src/phy/ch_estimation/refsignal_ul.c b/lib/src/phy/ch_estimation/refsignal_ul.c index f2f960bfc..96bdd1324 100644 --- a/lib/src/phy/ch_estimation/refsignal_ul.c +++ b/lib/src/phy/ch_estimation/refsignal_ul.c @@ -361,8 +361,7 @@ int srslte_refsignal_dmrs_pusch_pregen_init(srslte_refsignal_ul_dmrs_pregen_t* p for (uint32_t n = 0; n <= max_prb; n++) { if (srslte_dft_precoding_valid_prb(n)) { pregen->r[cs][sf_idx][n] = srslte_vec_cf_malloc(n * 2 * SRSLTE_NRE); - if (pregen->r[cs][sf_idx][n]) { - } else { + if (!pregen->r[cs][sf_idx][n]) { return SRSLTE_ERROR; } } diff --git a/lib/src/phy/mimo/precoding.c b/lib/src/phy/mimo/precoding.c index 5c491e3f8..cc29e9856 100644 --- a/lib/src/phy/mimo/precoding.c +++ b/lib/src/phy/mimo/precoding.c @@ -2376,10 +2376,10 @@ int srslte_precoding_pmi_select_1l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX for (uint32_t j = 0; j < nof_symbols - PMI_SEL_PRECISION * SRSLTE_SIMD_CF_SIZE + 1; j += PMI_SEL_PRECISION * SRSLTE_SIMD_CF_SIZE) { // 0. Load channel matrix - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t h00_v[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t h01_v[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t h10_v[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t h11_v[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t h00_v[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t h01_v[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t h10_v[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t h11_v[SRSLTE_SIMD_CF_SIZE]; for (uint32_t k = 0; k < SRSLTE_SIMD_CF_SIZE; k++) { h00_v[k] = h[0][0][j + PMI_SEL_PRECISION * k]; @@ -2445,7 +2445,7 @@ int srslte_precoding_pmi_select_1l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX } // Temporal store accumulated values - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) float v[SRSLTE_SIMD_F_SIZE]; + srslte_simd_aligned float v[SRSLTE_SIMD_F_SIZE]; srslte_simd_f_store(v, gamma); // Average and accumulate SINR loop @@ -2629,10 +2629,10 @@ int srslte_precoding_pmi_select_2l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX for (uint32_t j = 0; j < nof_symbols - PMI_SEL_PRECISION * SRSLTE_SIMD_CF_SIZE + 1; j += PMI_SEL_PRECISION * SRSLTE_SIMD_CF_SIZE) { // 0. Load channel matrix - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t h00_v[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t h01_v[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t h10_v[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t h11_v[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t h00_v[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t h01_v[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t h10_v[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t h11_v[SRSLTE_SIMD_CF_SIZE]; for (uint32_t k = 0; k < SRSLTE_SIMD_CF_SIZE; k++) { h00_v[k] = h[0][0][j + PMI_SEL_PRECISION * k]; @@ -2725,7 +2725,7 @@ int srslte_precoding_pmi_select_2l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX } // Temporal store accumulated values - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) float v[SRSLTE_SIMD_F_SIZE]; + srslte_simd_aligned float v[SRSLTE_SIMD_F_SIZE]; srslte_simd_f_store(v, gamma_sum); // Average and accumulate SINR loop diff --git a/lib/src/phy/phch/pdcch.c b/lib/src/phy/phch/pdcch.c index 57cca9172..b1c5fe680 100644 --- a/lib/src/phy/phch/pdcch.c +++ b/lib/src/phy/phch/pdcch.c @@ -423,8 +423,6 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dc return ret; } -int cnt = 0; - /** Performs PDCCH receiver processing to extract LLR for all control region. LLR bits are stored in srslte_pdcch_t * object. DCI can be decoded from given locations in successive calls to srslte_pdcch_decode_msg() */ diff --git a/lib/src/phy/sync/psss.c b/lib/src/phy/sync/psss.c index e69ae4a27..521a78da6 100644 --- a/lib/src/phy/sync/psss.c +++ b/lib/src/phy/sync/psss.c @@ -197,7 +197,7 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ float corr_peak_value[2] = {}; uint32_t corr_peak_pos[2] = {}; - uint32_t sf_n_samples = srslte_symbol_sz(nof_prb) * 15; + uint32_t sf_n_samples = (uint32_t)SRSLTE_SF_LEN_PRB(nof_prb); uint32_t fft_size = sf_n_samples * 2; srslte_vec_cf_zero(q->input_pad_freq, fft_size); @@ -215,8 +215,8 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ srslte_dft_run_c(&q->plan_out, q->dot_prod_output, q->dot_prod_output_time); srslte_vec_cf_zero(q->shifted_output, fft_size); - memcpy(q->shifted_output, &q->dot_prod_output_time[fft_size / 2], sizeof(cf_t) * fft_size / 2); - memcpy(&q->shifted_output[fft_size / 2], q->dot_prod_output_time, sizeof(cf_t) * fft_size / 2); + srs_vec_cf_copy(q->shifted_output, &q->dot_prod_output_time[fft_size / 2], fft_size / 2); + srs_vec_cf_copy(&q->shifted_output[fft_size / 2], q->dot_prod_output_time, fft_size / 2); // Peak detection q->corr_peak_pos = -1; @@ -224,7 +224,7 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ srslte_vec_abs_cf_simd(q->shifted_output, q->shifted_output_abs, fft_size); // Experimental Validation - int symbol_sz = srslte_symbol_sz(nof_prb); + uint32_t symbol_sz = (uint32_t)srslte_symbol_sz(nof_prb); int cp_len = SRSLTE_CP_SZ(symbol_sz, cp); // Correlation output peaks: @@ -250,8 +250,10 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ float peak_1_value = q->shifted_output_abs[peak_1_pos]; if ((peak_1_pos >= (q->corr_peak_pos - (symbol_sz + cp_len) - 2)) && (peak_1_pos <= (q->corr_peak_pos - (symbol_sz + cp_len) + 2))) { + ; // Do nothing } else if ((peak_1_pos >= (q->corr_peak_pos + (symbol_sz + cp_len) - 2)) && (peak_1_pos <= (q->corr_peak_pos + (symbol_sz + cp_len) + 2))) { + ; // Do nothing } else { q->corr_peak_pos = -1; continue; @@ -263,32 +265,34 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ float peak_2_value = q->shifted_output_abs[peak_2_pos]; if ((peak_2_pos >= (q->corr_peak_pos - (symbol_sz + cp_len) - 2)) && (peak_2_pos <= (q->corr_peak_pos - (symbol_sz + cp_len) + 2))) { + ; // Do nothing } else if ((peak_2_pos >= (q->corr_peak_pos + (symbol_sz + cp_len) - 2)) && (peak_2_pos <= (q->corr_peak_pos + (symbol_sz + cp_len) + 2))) { + ; // Do nothing } else { q->corr_peak_pos = -1; continue; } srslte_vec_f_zero(&q->shifted_output_abs[peak_2_pos - (symbol_sz / 2)], symbol_sz); - float threshold_above = q->corr_peak_value / 2.0 * 1.4; + float threshold_above = q->corr_peak_value / 2.0f * 1.4f; if ((peak_1_value > threshold_above) || (peak_2_value > threshold_above)) { q->corr_peak_pos = -1; continue; } - float threshold_below = q->corr_peak_value / 2.0 * 0.6; + float threshold_below = q->corr_peak_value / 2.0f * 0.6f; if ((peak_1_value < threshold_below) || (peak_2_value < threshold_below)) { q->corr_peak_pos = -1; continue; } corr_peak_value[i] = q->corr_peak_value; - corr_peak_pos[i] = q->corr_peak_pos; + corr_peak_pos[i] = (uint32_t)q->corr_peak_pos; } q->N_id_2 = srslte_vec_max_fi(corr_peak_value, 2); - if (corr_peak_value[q->N_id_2] == 0.0) { + if (corr_peak_value[q->N_id_2] == 0.0f) { return SRSLTE_ERROR; } diff --git a/lib/src/phy/sync/sync.c b/lib/src/phy/sync/sync.c index 5cc84063f..b25b0f8f6 100644 --- a/lib/src/phy/sync/sync.c +++ b/lib/src/phy/sync/sync.c @@ -585,10 +585,10 @@ srslte_pss_t* srslte_sync_get_cur_pss_obj(srslte_sync_t* q) static float cfo_cp_estimate(srslte_sync_t* q, const cf_t* input) { uint32_t cp_offset = 0; - cp_offset = - srslte_cp_synch(&q->cp_synch, input, q->max_offset, q->cfo_cp_nsymbols, SRSLTE_CP_LEN_NORM(1, q->fft_size)); + cp_offset = srslte_cp_synch( + &q->cp_synch, input, q->max_offset, q->cfo_cp_nsymbols, (uint32_t)SRSLTE_CP_LEN_NORM(1, q->fft_size)); cf_t cp_corr_max = srslte_cp_synch_corr_output(&q->cp_synch, cp_offset); - float cfo = -cargf(cp_corr_max) / M_PI / 2; + float cfo = -cargf(cp_corr_max) / ((float)M_PI * 2.0f); return cfo; } @@ -598,9 +598,9 @@ static int cfo_i_estimate(srslte_sync_t* q, const cf_t* input, int find_offset, float max_peak_value = -99; int max_cfo_i = 0; srslte_pss_t* pss_obj[3] = {&q->pss_i[0], &q->pss, &q->pss_i[1]}; - for (int cfo_i = 0; cfo_i < 3; cfo_i++) { - srslte_pss_set_N_id_2(pss_obj[cfo_i], q->N_id_2); - int p = srslte_pss_find_pss(pss_obj[cfo_i], &input[find_offset], &peak_value); + for (int cfo = 0; cfo < 3; cfo++) { + srslte_pss_set_N_id_2(pss_obj[cfo], q->N_id_2); + int p = srslte_pss_find_pss(pss_obj[cfo], &input[find_offset], &peak_value); if (p < 0) { return -1; } @@ -610,7 +610,7 @@ static int cfo_i_estimate(srslte_sync_t* q, const cf_t* input, int find_offset, *peak_pos = p; } q->peak_value = peak_value; - max_cfo_i = cfo_i - 1; + max_cfo_i = cfo - 1; } } if (cfo_i) { diff --git a/lib/src/phy/ue/test/ue_mib_sync_test_nbiot_usrp.c b/lib/src/phy/ue/test/ue_mib_sync_test_nbiot_usrp.c index ec02aa7b4..e1b0022ac 100644 --- a/lib/src/phy/ue/test/ue_mib_sync_test_nbiot_usrp.c +++ b/lib/src/phy/ue/test/ue_mib_sync_test_nbiot_usrp.c @@ -133,19 +133,19 @@ int main(int argc, char** argv) printf("Frame length %d samples\n", flen); printf("Opening RF device...\n"); - srslte_rf_t rf; - if (srslte_rf_open(&rf, rf_args)) { + srslte_rf_t rf_device; + if (srslte_rf_open(&rf_device, rf_args)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } - printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf, srate) / 1000000); - printf("Set RX gain: %.1f dB\n", srslte_rf_set_rx_gain(&rf, rf_gain)); - printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); + printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf_device, srate) / 1000000); + printf("Set RX gain: %.1f dB\n", srslte_rf_set_rx_gain(&rf_device, rf_gain)); + printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf_device, 0, rf_freq) / 1000000); srslte_ue_mib_sync_nbiot_t mib_sync; if (srslte_ue_mib_sync_nbiot_init_multi( - &mib_sync, srslte_rf_recv_wrapper, SRSLTE_NBIOT_NUM_RX_ANTENNAS, (void*)&rf)) { + &mib_sync, srslte_rf_recv_wrapper, SRSLTE_NBIOT_NUM_RX_ANTENNAS, (void*)&rf_device)) { fprintf(stderr, "Error initializing MIB sync object\n"); exit(-1); } @@ -155,7 +155,7 @@ int main(int argc, char** argv) exit(-1); } - srslte_rf_start_rx_stream(&rf, false); + srslte_rf_start_rx_stream(&rf_device, false); int max_frames = 2 * SRSLTE_NPBCH_NUM_FRAMES; @@ -173,8 +173,7 @@ int main(int argc, char** argv) } srslte_ue_mib_sync_nbiot_free(&mib_sync); - srslte_rf_close(&rf); - + srslte_rf_close(&rf_device); return SRSLTE_SUCCESS; } diff --git a/lib/src/phy/utils/test/mat_test.c b/lib/src/phy/utils/test/mat_test.c index bcf89aeca..6f1c287f5 100644 --- a/lib/src/phy/utils/test/mat_test.c +++ b/lib/src/phy/utils/test/mat_test.c @@ -173,8 +173,8 @@ bool test_zf_solver_simd(void) srslte_mat_2x2_zf_simd(_y0, _y1, _h00, _h01, _h10, _h11, &_x0, &_x1, 1.0f); - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN))) cf_t x0[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN))) cf_t x1[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t x0[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t x1[SRSLTE_SIMD_CF_SIZE]; srslte_simd_cfi_store(x0, _x0); srslte_simd_cfi_store(x1, _x1); @@ -223,8 +223,8 @@ bool test_mmse_solver_simd(void) srslte_mat_2x2_mmse_simd(_y0, _y1, _h00, _h01, _h10, _h11, &_x0, &_x1, 0.0f, 1.0f); - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN))) cf_t x0[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN))) cf_t x1[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t x0[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t x1[SRSLTE_SIMD_CF_SIZE]; srslte_simd_cfi_store(x0, _x0); srslte_simd_cfi_store(x1, _x1); diff --git a/lib/src/phy/utils/vector_simd.c b/lib/src/phy/utils/vector_simd.c index 9ca49aa0f..fca3c23c7 100644 --- a/lib/src/phy/utils/vector_simd.c +++ b/lib/src/phy/utils/vector_simd.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -84,7 +85,7 @@ int srslte_vec_dot_prod_sss_simd(const int16_t* x, const int16_t* y, const int l simd_dotProdVal = srslte_simd_s_add(simd_dotProdVal, z); } } - __attribute__((aligned(SRSLTE_SIMD_S_SIZE * 2))) short dotProdVector[SRSLTE_SIMD_S_SIZE]; + srslte_simd_aligned short dotProdVector[SRSLTE_SIMD_S_SIZE]; srslte_simd_s_store(dotProdVector, simd_dotProdVal); for (int k = 0; k < SRSLTE_SIMD_S_SIZE; k++) { result += dotProdVector[k]; @@ -284,9 +285,11 @@ void srslte_vec_neg_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, const } #define SAVE_OUTPUT_16_SSE(j) \ - x = (int16_t)_mm_extract_epi16(xVal, j); \ - l = (uint16_t)_mm_extract_epi16(lutVal, j); \ - y[l] = (short)x; + do { \ + int16_t temp = (int16_t)_mm_extract_epi16(xVal, j); \ + uint16_t l = (uint16_t)_mm_extract_epi16(lutVal, j); \ + y[l] = temp; \ + } while (false) /* No improvement with AVX */ void srslte_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y, const int len) @@ -298,9 +301,6 @@ void srslte_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y __m128i xVal = _mm_load_si128((__m128i*)&x[i]); __m128i lutVal = _mm_load_si128((__m128i*)&lut[i]); - int16_t x; - uint16_t l; - SAVE_OUTPUT_16_SSE(0); SAVE_OUTPUT_16_SSE(1); SAVE_OUTPUT_16_SSE(2); @@ -315,9 +315,6 @@ void srslte_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y __m128i xVal = _mm_loadu_si128((__m128i*)&x[i]); __m128i lutVal = _mm_loadu_si128((__m128i*)&lut[i]); - int16_t x; - uint16_t l; - SAVE_OUTPUT_16_SSE(0); SAVE_OUTPUT_16_SSE(1); SAVE_OUTPUT_16_SSE(2); @@ -336,14 +333,18 @@ void srslte_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y } #define SAVE_OUTPUT_SSE_8(j) \ - x = (int8_t)_mm_extract_epi8(xVal, j); \ - l = (uint16_t)_mm_extract_epi16(lutVal1, j); \ - y[l] = (char)x; + do { \ + int8_t temp = (int8_t)_mm_extract_epi8(xVal, j); \ + uint16_t idx = (uint16_t)_mm_extract_epi16(lutVal1, j); \ + y[idx] = (char)temp; \ + } while (false) #define SAVE_OUTPUT_SSE_8_2(j) \ - x = (int8_t)_mm_extract_epi8(xVal, j + 8); \ - l = (uint16_t)_mm_extract_epi16(lutVal2, j); \ - y[l] = (char)x; + do { \ + int8_t temp = (int8_t)_mm_extract_epi8(xVal, j + 8); \ + uint16_t idx = (uint16_t)_mm_extract_epi16(lutVal2, j); \ + y[idx] = (char)temp; \ + } while (false) void srslte_vec_lut_bbb_simd(const int8_t* x, const unsigned short* lut, int8_t* y, const int len) { @@ -355,9 +356,6 @@ void srslte_vec_lut_bbb_simd(const int8_t* x, const unsigned short* lut, int8_t* __m128i lutVal1 = _mm_load_si128((__m128i*)&lut[i]); __m128i lutVal2 = _mm_load_si128((__m128i*)&lut[i + 8]); - int8_t x; - uint16_t l; - SAVE_OUTPUT_SSE_8(0); SAVE_OUTPUT_SSE_8(1); SAVE_OUTPUT_SSE_8(2); @@ -382,9 +380,6 @@ void srslte_vec_lut_bbb_simd(const int8_t* x, const unsigned short* lut, int8_t* __m128i lutVal1 = _mm_loadu_si128((__m128i*)&lut[i]); __m128i lutVal2 = _mm_loadu_si128((__m128i*)&lut[i + 8]); - int8_t x; - uint16_t l; - SAVE_OUTPUT_SSE_8(0); SAVE_OUTPUT_SSE_8(1); SAVE_OUTPUT_SSE_8(2); @@ -571,7 +566,7 @@ float srslte_vec_acc_ff_simd(const float* x, const int len) } } - __attribute__((aligned(SRSLTE_SIMD_F_SIZE * 4))) float sum[SRSLTE_SIMD_F_SIZE]; + srslte_simd_aligned float sum[SRSLTE_SIMD_F_SIZE]; srslte_simd_f_store(sum, simd_sum); for (int k = 0; k < SRSLTE_SIMD_F_SIZE; k++) { acc_sum += sum[k]; @@ -1322,8 +1317,8 @@ uint32_t srslte_vec_max_fi_simd(const float* x, const int len) uint32_t max_index = 0; #if SRSLTE_SIMD_I_SIZE - __attribute__((aligned(SRSLTE_SIMD_I_SIZE * sizeof(int)))) int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; - __attribute__((aligned(SRSLTE_SIMD_I_SIZE * sizeof(float)))) float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; + srslte_simd_aligned int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; + srslte_simd_aligned float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) indexes_buffer[k] = k; @@ -1380,8 +1375,8 @@ uint32_t srslte_vec_max_abs_fi_simd(const float* x, const int len) uint32_t max_index = 0; #if SRSLTE_SIMD_I_SIZE - __attribute__((aligned(SRSLTE_SIMD_I_SIZE * sizeof(int)))) int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; - __attribute__((aligned(SRSLTE_SIMD_I_SIZE * sizeof(float)))) float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; + srslte_simd_aligned int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; + srslte_simd_aligned float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) indexes_buffer[k] = k; @@ -1439,8 +1434,8 @@ uint32_t srslte_vec_max_ci_simd(const cf_t* x, const int len) uint32_t max_index = 0; #if SRSLTE_SIMD_I_SIZE - __attribute__((aligned(SRSLTE_SIMD_I_SIZE * sizeof(int)))) int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; - __attribute__((aligned(SRSLTE_SIMD_I_SIZE * sizeof(float)))) float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; + srslte_simd_aligned int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; + srslte_simd_aligned float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) indexes_buffer[k] = k; @@ -1647,8 +1642,8 @@ void srslte_vec_apply_cfo_simd(const cf_t* x, float cfo, cf_t* z, int len) int i = 0; #if SRSLTE_SIMD_CF_SIZE - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t _osc[SRSLTE_SIMD_CF_SIZE]; - __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) cf_t _phase[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t _osc[SRSLTE_SIMD_CF_SIZE]; + srslte_simd_aligned cf_t _phase[SRSLTE_SIMD_CF_SIZE]; if (i < len - SRSLTE_SIMD_CF_SIZE + 1) { for (int k = 0; k < SRSLTE_SIMD_CF_SIZE; k++) { diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index f1a182305..e7d28ab5b 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -356,7 +356,7 @@ void rlc::write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) RRC interface *******************************************************************************/ -void rlc::add_bearer(uint32_t lcid, rlc_config_t cnfg) +void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg) { rwlock_write_guard lock(rwlock); diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index a039b06a5..86664c6b5 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -48,7 +48,7 @@ rlc_am_lte::rlc_am_lte(srslte::log_ref log_, } // Applies new configuration. Must be just reestablished or initiated -bool rlc_am_lte::configure(rlc_config_t cfg_) +bool rlc_am_lte::configure(const rlc_config_t& cfg_) { // determine bearer name and configure Rx/Tx objects rb_name = rrc->get_rb_name(lcid); @@ -176,7 +176,7 @@ rlc_am_lte::rlc_am_lte_tx::~rlc_am_lte_tx() pthread_mutex_destroy(&mutex); } -bool rlc_am_lte::rlc_am_lte_tx::configure(rlc_config_t cfg_) +bool rlc_am_lte::rlc_am_lte_tx::configure(const rlc_config_t& cfg_) { // TODO: add config checks cfg = cfg_.am; diff --git a/lib/src/upper/rlc_tm.cc b/lib/src/upper/rlc_tm.cc index a625923d7..d50ffec5a 100644 --- a/lib/src/upper/rlc_tm.cc +++ b/lib/src/upper/rlc_tm.cc @@ -44,7 +44,7 @@ rlc_tm::~rlc_tm() pool = NULL; } -bool rlc_tm::configure(rlc_config_t cnfg) +bool rlc_tm::configure(const rlc_config_t& cnfg) { log->error("Attempted to configure TM RLC entity\n"); return true; diff --git a/lib/src/upper/rlc_um_lte.cc b/lib/src/upper/rlc_um_lte.cc index 52bf0e58d..fb07cad13 100644 --- a/lib/src/upper/rlc_um_lte.cc +++ b/lib/src/upper/rlc_um_lte.cc @@ -41,7 +41,7 @@ rlc_um_lte::~rlc_um_lte() stop(); } -bool rlc_um_lte::configure(rlc_config_t cnfg_) +bool rlc_um_lte::configure(const rlc_config_t& cnfg_) { // determine bearer name and configure Rx/Tx objects rb_name = get_rb_name(rrc, lcid, cnfg_.um.is_mrb); @@ -102,7 +102,7 @@ uint32_t rlc_um_lte::rlc_um_lte_tx::get_buffer_state() return n_bytes; } -bool rlc_um_lte::rlc_um_lte_tx::configure(rlc_config_t cnfg_, std::string rb_name_) +bool rlc_um_lte::rlc_um_lte_tx::configure(const rlc_config_t& cnfg_, std::string rb_name_) { cfg = cnfg_; diff --git a/srsenb/hdr/phy/phy.h b/srsenb/hdr/phy/phy.h index a7dff474b..0164f1845 100644 --- a/srsenb/hdr/phy/phy.h +++ b/srsenb/hdr/phy/phy.h @@ -58,8 +58,9 @@ public: const std::array& activation) override; /*RRC-PHY interface*/ - void - configure_mbsfn(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s mcch) override; + void configure_mbsfn(asn1::rrc::sib_type2_s* sib2, + asn1::rrc::sib_type13_r9_s* sib13, + const asn1::rrc::mcch_msg_s& mcch) override; void start_plot() override; void set_config_dedicated(uint16_t rnti, const phy_rrc_dedicated_list_t& dedicated_list) override; diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 36a60054e..21d305472 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -247,7 +247,7 @@ void phy::set_config_dedicated(uint16_t rnti, const phy_rrc_dedicated_list_t& de } } -void phy::configure_mbsfn(sib_type2_s* sib2, sib_type13_r9_s* sib13, mcch_msg_s mcch) +void phy::configure_mbsfn(sib_type2_s* sib2, sib_type13_r9_s* sib13, const mcch_msg_s& mcch) { if (sib2->mbsfn_sf_cfg_list_present) { if (sib2->mbsfn_sf_cfg_list.size() == 0) { diff --git a/srsenb/test/common/dummy_classes.h b/srsenb/test/common/dummy_classes.h index 4f07062ce..5d09e5e5d 100644 --- a/srsenb/test/common/dummy_classes.h +++ b/srsenb/test/common/dummy_classes.h @@ -33,15 +33,12 @@ public: void reset() override {} int ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg) override { return 0; } int ue_rem(uint16_t rnti) override { return 0; } - int ue_set_crnti(uint16_t temp_crnti, uint16_t crnti, sched_interface::ue_cfg_t* cfg) override { return 0; } int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) override { return 0; } int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) override { return 0; } void phy_config_enabled(uint16_t rnti, bool enabled) override {} void write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch) override - {} - uint16_t allocate_rnti() override { return last_rnti++; } - - uint16_t last_rnti = 70; + { + } }; class rlc_dummy : public rlc_interface_rrc @@ -110,8 +107,9 @@ public: class phy_dummy : public phy_interface_rrc_lte { public: - void - configure_mbsfn(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s mcch) override + void configure_mbsfn(asn1::rrc::sib_type2_s* sib2, + asn1::rrc::sib_type13_r9_s* sib13, + const asn1::rrc::mcch_msg_s& mcch) override {} void set_config_dedicated(uint16_t rnti, const phy_rrc_dedicated_list_t& dedicated_list) override {} }; diff --git a/srsepc/hdr/mme/nas.h b/srsepc/hdr/mme/nas.h index e1980f27d..43cb75110 100644 --- a/srsepc/hdr/mme/nas.h +++ b/srsepc/hdr/mme/nas.h @@ -150,7 +150,7 @@ typedef struct { class nas { public: - nas(nas_init_t args, nas_if_t itf, srslte::log* nas_log); + nas(const nas_init_t& args, const nas_if_t& itf, srslte::log* nas_log); void reset(); /*********************** @@ -160,16 +160,16 @@ public: static bool handle_attach_request(uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log); static bool handle_imsi_attach_request_unknown_ue(uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log); static bool handle_imsi_attach_request_known_ue(nas* nas_ctx, @@ -178,16 +178,16 @@ public: const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log); static bool handle_guti_attach_request_unknown_ue(uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log); static bool handle_guti_attach_request_known_ue(nas* nas_ctx, @@ -196,8 +196,8 @@ public: const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log); // Service request messages @@ -205,8 +205,8 @@ public: uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log); // Dettach request messages @@ -214,8 +214,8 @@ public: uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log); // Tracking area update request messages @@ -223,8 +223,8 @@ public: uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log); /* Uplink NAS messages handling */ diff --git a/srsepc/src/mme/nas.cc b/srsepc/src/mme/nas.cc index 2afe02eb8..d4ebc0255 100644 --- a/srsepc/src/mme/nas.cc +++ b/srsepc/src/mme/nas.cc @@ -28,7 +28,7 @@ namespace srsepc { -nas::nas(nas_init_t args, nas_if_t itf, srslte::log* nas_log) : +nas::nas(const nas_init_t& args, const nas_if_t& itf, srslte::log* nas_log) : m_pool(srslte::byte_buffer_pool::get_instance()), m_nas_log(nas_log), m_gtpc(itf.gtpc), @@ -72,8 +72,8 @@ void nas::reset() bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log) { uint32_t m_tmsi = 0; @@ -201,8 +201,8 @@ bool nas::handle_imsi_attach_request_unknown_ue(uint32_t struct sctp_sndrcvinfo* enb_sri, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log) { nas* nas_ctx; @@ -302,8 +302,8 @@ bool nas::handle_imsi_attach_request_known_ue(nas* const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log) { bool err; @@ -333,8 +333,8 @@ bool nas::handle_guti_attach_request_unknown_ue(uint32_t struct sctp_sndrcvinfo* enb_sri, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log) { @@ -411,8 +411,8 @@ bool nas::handle_guti_attach_request_known_ue(nas* const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log) { bool msg_valid = false; @@ -565,8 +565,8 @@ bool nas::handle_service_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log) { nas_log->info("Service request -- S-TMSI 0x%x\n", m_tmsi); @@ -714,8 +714,8 @@ bool nas::handle_detach_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log) { nas_log->info("Detach Request -- S-TMSI 0x%x\n", m_tmsi); @@ -772,8 +772,8 @@ bool nas::handle_tracking_area_update_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, srslte::byte_buffer_t* nas_rx, - nas_init_t args, - nas_if_t itf, + const nas_init_t& args, + const nas_if_t& itf, srslte::log* nas_log) { srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance(); diff --git a/srsue/hdr/stack/mac/mac.h b/srsue/hdr/stack/mac/mac.h index b12b929c0..4f6c8cc28 100644 --- a/srsue/hdr/stack/mac/mac.h +++ b/srsue/hdr/stack/mac/mac.h @@ -62,7 +62,7 @@ public: /* see mac_interface.h for comments */ void new_grant_ul(uint32_t cc_idx, mac_grant_ul_t grant, tb_action_ul_t* action); void new_grant_dl(uint32_t cc_idx, mac_grant_dl_t grant, tb_action_dl_t* action); - void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action); + void new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action); void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]); void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len); uint16_t get_dl_sched_rnti(uint32_t tti); diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index cc3b287c0..8f311c8ba 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -105,7 +105,10 @@ public: void mch_decoded(uint32_t len, bool crc) final { mac.mch_decoded(len, crc); } - void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action) final { mac.new_mch_dl(phy_grant, action); } + void new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action) final + { + mac.new_mch_dl(phy_grant, action); + } void set_mbsfn_config(uint32_t nof_mbsfn_services) final { mac.set_mbsfn_config(nof_mbsfn_services); } diff --git a/srsue/src/phy/prach.cc b/srsue/src/phy/prach.cc index ab520c0e3..9febde739 100644 --- a/srsue/src/phy/prach.cc +++ b/srsue/src/phy/prach.cc @@ -230,8 +230,6 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power) f_idx = prach_obj.current_prach_idx; // For format4, choose odd or even position if (prach_obj.config_idx >= 48) { - if ((transmitted_tti / 10) % 2) { - } f_idx += 6; } if (f_idx >= 12) { diff --git a/srsue/src/stack/mac/mac.cc b/srsue/src/stack/mac/mac.cc index 42d5b8f2f..26dd6b552 100644 --- a/srsue/src/stack/mac/mac.cc +++ b/srsue/src/stack/mac/mac.cc @@ -549,7 +549,7 @@ void mac::new_grant_ul(uint32_t cc_idx, } } -void mac::new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action) +void mac::new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action) { action->generate_ack = false; action->tb[0].enabled = true; diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 729d9405d..dd27ed5ba 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -1040,24 +1040,34 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) rrc->set_ue_identity(s_tmsi); } if (attach_accept.lai_present) { + ; // Do nothing; } if (attach_accept.ms_id_present) { + ; // Do nothing; } if (attach_accept.emm_cause_present) { + ; // Do nothing; } if (attach_accept.t3402_present) { + ; // Do nothing; } if (attach_accept.t3412_ext_present) { + ; // Do nothing; } if (attach_accept.t3423_present) { + ; // Do nothing; } if (attach_accept.equivalent_plmns_present) { + ; // Do nothing; } if (attach_accept.emerg_num_list_present) { + ; // Do nothing; } if (attach_accept.eps_network_feature_support_present) { + ; // Do nothing; } if (attach_accept.additional_update_result_present) { + ; // Do nothing; } LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req = {}; diff --git a/srsue/test/phy/ue_phy_test.cc b/srsue/test/phy/ue_phy_test.cc index 7ee96a9ff..63b7d9e9d 100644 --- a/srsue/test/phy/ue_phy_test.cc +++ b/srsue/test/phy/ue_phy_test.cc @@ -106,7 +106,7 @@ private: void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool* ack) override {} void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) override {} void mch_decoded(uint32_t len, bool crc) override {} - void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action) override {} + void new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action) override {} void set_mbsfn_config(uint32_t nof_mbsfn_services) override {} void run_tti(const uint32_t tti, const uint32_t tti_jump) override {