Merge branch 'next' into agpl_next

master
Codebot 3 years ago committed by Your Name
commit 1cd26af06b

@ -1,6 +1,14 @@
Change Log for Releases
=======================
## 21.10
* Add initial 5G NSA support to srsENB (tested with OnePlus 5G Nord)
* Improved interoperability of srsUE in NSA mode
* Added enhanced instrumentation to file using JSON format
* Fixed stability issues with Ettus N310
* Added BLER-adaptive MCS scheduling to srsENB
* Other bug-fixes and improved stability and performance in all parts
## 21.04
* Rename project from srsLTE to srsRAN
* Add initial 5G NSA support to srsUE (including x86-optimized FEC and PHY layer)

@ -19,7 +19,7 @@
#
SET(SRSRAN_VERSION_MAJOR 21)
SET(SRSRAN_VERSION_MINOR 04)
SET(SRSRAN_VERSION_MINOR 10)
SET(SRSRAN_VERSION_PATCH 0)
SET(SRSRAN_VERSION_STRING "${SRSRAN_VERSION_MAJOR}.${SRSRAN_VERSION_MINOR}.${SRSRAN_VERSION_PATCH}")
SET(SRSRAN_SOVERSION 0)

@ -106,7 +106,7 @@ void parse_args(int argc, char** argv)
rf_gain = strtof(argv[optind], NULL);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -106,7 +106,7 @@ void parse_args(int argc, char** argv)
scan_raster_offset = true;
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -170,7 +170,7 @@ void parse_args(int argc, char** argv)
cell.nbiot_prb = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -228,7 +228,7 @@ void parse_args(prog_args_t* args, int argc, char** argv)
args->disable_plots_except_constellation = true;
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(args, argv[0]);

@ -66,7 +66,7 @@ static int net_port = -1; // -1 generates random dataThat means there is so
static uint32_t cfi = 2;
static uint32_t mcs_idx = 1, last_mcs_idx = 1;
static int nof_frames = -1;
static srsran_tm_t transmission_mode = SRSRAN_TM1;
static srsran_tm_t transmission_mode = SRSRAN_TM1;
static uint32_t nof_tb = 1;
static uint32_t multiplex_pmi = 0;
static uint32_t multiplex_nof_layers = 1;
@ -198,7 +198,7 @@ static void parse_args(int argc, char** argv)
mbsfn_area_id = (int)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
case 's':
output_file_snr = strtof(argv[optind], NULL);

@ -286,8 +286,8 @@ void parse_args(prog_args_t* args, int argc, char** argv)
args->disable_plots_except_constellation = true;
break;
case 'v':
srsran_verbose++;
args->verbose = srsran_verbose;
increase_srsran_verbose_level();
args->verbose = get_srsran_verbose_level();
break;
case 'Z':
args->decimate = (int)strtol(argv[optind], NULL, 10);
@ -699,16 +699,16 @@ int main(int argc, char** argv)
to.tv_usec = 0;
/* Set default verbose level */
srsran_verbose = prog_args.verbose;
int n = select(1, &set, NULL, NULL, &to);
set_srsran_verbose_level(prog_args.verbose);
int n = select(1, &set, NULL, NULL, &to);
if (n == 1) {
/* If a new line is detected set verbose level to Debug */
if (fgets(input, sizeof(input), stdin)) {
srsran_verbose = SRSRAN_VERBOSE_DEBUG;
pkt_errors = 0;
pkt_total = 0;
nof_detected = 0;
nof_trials = 0;
set_srsran_verbose_level(SRSRAN_VERBOSE_DEBUG);
pkt_errors = 0;
pkt_total = 0;
nof_detected = 0;
nof_trials = 0;
}
}

@ -188,7 +188,7 @@ void parse_args(prog_args_t* args, int argc, char** argv)
args->nof_rx_antennas = (int32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
case 'w':
args->disable_plots = true;
@ -341,7 +341,7 @@ int main(int argc, char** argv)
// PSCCH Channel estimation
srsran_chest_sl_cfg_t pscch_chest_sl_cfg = {};
srsran_chest_sl_t pscch_chest = {};
if (srsran_chest_sl_init(&pscch_chest, SRSRAN_SIDELINK_PSCCH, cell_sl, sl_comm_resource_pool) != SRSRAN_SUCCESS) {
if (srsran_chest_sl_init(&pscch_chest, SRSRAN_SIDELINK_PSCCH, cell_sl, &sl_comm_resource_pool) != SRSRAN_SUCCESS) {
ERROR("Error in chest PSCCH init");
return SRSRAN_ERROR;
}
@ -353,7 +353,7 @@ int main(int argc, char** argv)
srsran_chest_sl_cfg_t pssch_chest_sl_cfg = {};
srsran_chest_sl_t pssch_chest = {};
if (srsran_chest_sl_init(&pssch_chest, SRSRAN_SIDELINK_PSSCH, cell_sl, sl_comm_resource_pool) != SRSRAN_SUCCESS) {
if (srsran_chest_sl_init(&pssch_chest, SRSRAN_SIDELINK_PSSCH, cell_sl, &sl_comm_resource_pool) != SRSRAN_SUCCESS) {
ERROR("Error in chest PSSCH init");
return SRSRAN_ERROR;
}

@ -83,7 +83,7 @@ void parse_args(int argc, char** argv)
force_cfo = strtof(argv[optind], NULL);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -84,7 +84,7 @@ void parse_args(int argc, char** argv)
nof_rx_antennas = (int)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -105,7 +105,7 @@ void parse_args(int argc, char** argv)
nof_rx_antennas = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -77,7 +77,7 @@ void parse_args(int argc, char** argv)
nof_subframes = (int)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -123,7 +123,7 @@ int main(int argc, char** argv)
ERROR("Error receiving samples");
exit(-1);
}
if (srsran_verbose == SRSRAN_VERBOSE_INFO) {
if (get_srsran_verbose_level() == SRSRAN_VERBOSE_INFO) {
printf("Received %d samples from radio\n", n);
}
@ -136,7 +136,7 @@ int main(int argc, char** argv)
print_cnt = 0;
}
} else {
if (srsran_verbose == SRSRAN_VERBOSE_INFO) {
if (get_srsran_verbose_level() == SRSRAN_VERBOSE_INFO) {
printf("Transmitted %d bytes to ZMQ\n", n);
}
}
@ -239,7 +239,7 @@ static void parse_args(int argc, char** argv)
rf_freq = strtof(argv[optind], NULL);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
case 'z':
zmq_args = argv[optind];

@ -932,6 +932,17 @@ public:
return *this;
}
this_type& from_number(uint64_t val, uint32_t nof_bits)
{
if (nof_bits > UB) {
log_error("The provided bitstring value %ld does not fit the bounds [%d, %d]", val, uint32_t(lb), uint32_t(ub));
return *this;
}
resize(nof_bits);
bitstring_utils::from_number(data(), val, length());
return *this;
}
// packers / unpackers
SRSASN_CODE pack(bit_ref& bref) const
{

@ -58,6 +58,11 @@ struct phy_cfg_nr_t {
phy_cfg_nr_t() {}
bool carrier_is_equal(const srsran::phy_cfg_nr_t& other) const
{
return srsran_carrier_nr_equal(&carrier, &other.carrier);
}
/**
* @brief Computes the DCI configuration for the current UE configuration
*/

@ -33,7 +33,7 @@ class rlc_pcap
public:
rlc_pcap() {}
void enable(bool en);
void open(const char* filename, rlc_config_t config);
void open(const char* filename, const rlc_config_t& config);
void close();
void set_ue_id(uint16_t ue_id);

@ -45,9 +45,9 @@ public:
virtual void add_user(uint16_t rnti) = 0;
virtual void rem_user(uint16_t rnti) = 0;
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) = 0;
virtual void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) = 0;
virtual void add_bearer(uint16_t rnti, uint32_t lcid, const srsran::pdcp_config_t& cnfg) = 0;
virtual void del_bearer(uint16_t rnti, uint32_t lcid) = 0;
virtual void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) = 0;
virtual void config_security(uint16_t rnti, uint32_t lcid, const srsran::as_security_config_t& sec_cfg) = 0;
virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0;
virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0;
virtual void send_status_report(uint16_t rnti) = 0;

@ -94,6 +94,13 @@ public:
*/
virtual void sgnb_addition_complete(uint16_t eutra_rnti, uint16_t nr_rnti) = 0;
/**
* @brief Signal timeout for inactivity or MSG5 timers
*
* @param eutra_rnti The RNTI that the EUTRA RRC used to request the SgNB addition
*/
virtual void sgnb_inactivity_timeout(uint16_t eutra_rnti) = 0;
/**
* @brief Signal release of all UE resources on the NR cell
*

@ -88,14 +88,14 @@ public:
class pdcp_interface_rrc_nr
{
public:
virtual void reset(uint16_t rnti) = 0;
virtual void add_user(uint16_t rnti) = 0;
virtual void rem_user(uint16_t rnti) = 0;
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0;
virtual void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) = 0;
virtual void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) = 0;
virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0;
virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0;
virtual void reset(uint16_t rnti) = 0;
virtual void add_user(uint16_t rnti) = 0;
virtual void rem_user(uint16_t rnti) = 0;
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0;
virtual void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) = 0;
virtual void config_security(uint16_t rnti, uint32_t lcid, const srsran::as_security_config_t& sec_cfg) = 0;
virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0;
virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0;
};
class pdcp_interface_sdap_nr
@ -203,7 +203,7 @@ class mac_interface_phy_nr
{
public:
const static int MAX_SSB = 4;
const static int MAX_GRANTS = 32;
const static int MAX_GRANTS = 4;
const static int MAX_PUCCH_MSG = 64;
const static int MAX_PUCCH_CANDIDATES = 2;
const static int MAX_NZP_CSI_RS = 4;

@ -58,7 +58,6 @@ public:
virtual void user_mod(uint16_t old_rnti, uint16_t new_rnti) = 0;
virtual bool user_release(uint16_t rnti, asn1::ngap_nr::cause_radio_network_e cause_radio) = 0;
virtual bool is_amf_connected() = 0;
virtual void ue_ctxt_setup_complete(uint16_t rnti) = 0;
virtual void ue_notify_rrc_reconf_complete(uint16_t rnti, bool outcome) = 0;
};

@ -34,9 +34,10 @@ namespace srsue {
class rrc_interface_phy_nr
{
public:
virtual void in_sync() = 0;
virtual void out_of_sync() = 0;
virtual void run_tti(const uint32_t tti) = 0;
virtual void in_sync() = 0;
virtual void out_of_sync() = 0;
virtual void run_tti(const uint32_t tti) = 0;
virtual void set_phy_config_complete(bool status) = 0;
};
class mac_interface_phy_nr

@ -35,7 +35,7 @@ public:
virtual void reset() = 0;
virtual void set_enabled(uint32_t lcid, bool enabled) = 0;
virtual void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu, int sn = -1) = 0;
virtual int add_bearer(uint32_t lcid, srsran::pdcp_config_t cnfg) = 0;
virtual int add_bearer(uint32_t lcid, const srsran::pdcp_config_t& cnfg) = 0;
virtual void del_bearer(uint32_t lcid) = 0;
virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0;
virtual void config_security(uint32_t lcid, const srsran::as_security_config_t& sec_cfg) = 0;

@ -85,10 +85,10 @@ typedef struct SRSRAN_API {
} srsran_chest_sl_t;
SRSRAN_API int srsran_chest_sl_init(srsran_chest_sl_t* q,
srsran_sl_channels_t channel,
srsran_cell_sl_t cell,
srsran_sl_comm_resource_pool_t sl_comm_resource_pool);
SRSRAN_API int srsran_chest_sl_init(srsran_chest_sl_t* q,
srsran_sl_channels_t channel,
srsran_cell_sl_t cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool);
SRSRAN_API int srsran_chest_sl_set_cell(srsran_chest_sl_t* q, srsran_cell_sl_t cell);

@ -727,6 +727,14 @@ SRSRAN_API const char* srsran_ssb_pattern_to_str(srsran_ssb_patern_t pattern);
*/
SRSRAN_API srsran_ssb_patern_t srsran_ssb_pattern_fom_str(const char* str);
/**
* @brief Compares if two NR carrier structures are equal
* @param a First carrier to compare
* @param b Second carrier to compare
* @return True if all the carrier structure fields are equal, otherwise false
*/
SRSRAN_API bool srsran_carrier_nr_equal(const srsran_carrier_nr_t* a, const srsran_carrier_nr_t* b);
#ifdef __cplusplus
}
#endif

@ -45,7 +45,7 @@ typedef struct SRSRAN_API {
srsran_datatype_t type;
} srsran_filesink_t;
SRSRAN_API int srsran_filesink_init(srsran_filesink_t* q, char* filename, srsran_datatype_t type);
SRSRAN_API int srsran_filesink_init(srsran_filesink_t* q, const char* filename, srsran_datatype_t type);
SRSRAN_API void srsran_filesink_free(srsran_filesink_t* q);

@ -33,30 +33,38 @@
#include "phy_logger.h"
#include "srsran/config.h"
#include <stdio.h>
#include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define SRSRAN_VERBOSE_DEBUG 2
#define SRSRAN_VERBOSE_INFO 1
#define SRSRAN_VERBOSE_NONE 0
#include <sys/time.h>
SRSRAN_API void get_time_interval(struct timeval* tdata);
#define SRSRAN_DEBUG_ENABLED 1
SRSRAN_API extern int srsran_verbose;
SRSRAN_API extern int handler_registered;
SRSRAN_API int get_srsran_verbose_level(void);
SRSRAN_API void set_srsran_verbose_level(int level);
SRSRAN_API void increase_srsran_verbose_level(void);
#define SRSRAN_VERBOSE_ISINFO() (srsran_verbose >= SRSRAN_VERBOSE_INFO)
#define SRSRAN_VERBOSE_ISDEBUG() (srsran_verbose >= SRSRAN_VERBOSE_DEBUG)
#define SRSRAN_VERBOSE_ISNONE() (srsran_verbose == SRSRAN_VERBOSE_NONE)
SRSRAN_API bool is_handler_registered(void);
SRSRAN_API void set_handler_enabled(bool enable);
#define PRINT_DEBUG srsran_verbose = SRSRAN_VERBOSE_DEBUG
#define PRINT_INFO srsran_verbose = SRSRAN_VERBOSE_INFO
#define PRINT_NONE srsran_verbose = SRSRAN_VERBOSE_NONE
#define SRSRAN_VERBOSE_ISINFO() (get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO)
#define SRSRAN_VERBOSE_ISDEBUG() (get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG)
#define SRSRAN_VERBOSE_ISNONE() (get_srsran_verbose_level() == SRSRAN_VERBOSE_NONE)
#define PRINT_DEBUG set_srsran_verbose_level(SRSRAN_VERBOSE_DEBUG)
#define PRINT_INFO set_srsran_verbose_level(SRSRAN_VERBOSE_INFO)
#define PRINT_NONE set_srsran_verbose_level(SRSRAN_VERBOSE_NONE)
#define DEBUG(_fmt, ...) \
do { \
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { \
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) { \
fprintf(stdout, "[DEBUG]: " _fmt "\n", ##__VA_ARGS__); \
} else { \
srsran_phy_log_print(LOG_LEVEL_DEBUG_S, _fmt, ##__VA_ARGS__); \
@ -65,7 +73,7 @@ SRSRAN_API extern int handler_registered;
#define INFO(_fmt, ...) \
do { \
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { \
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) { \
fprintf(stdout, "[INFO]: " _fmt "\n", ##__VA_ARGS__); \
} else { \
srsran_phy_log_print(LOG_LEVEL_INFO_S, _fmt, ##__VA_ARGS__); \
@ -76,7 +84,7 @@ SRSRAN_API extern int handler_registered;
/* In debug mode, it prints out the */
#define ERROR(_fmt, ...) \
do { \
if (!handler_registered) { \
if (!is_handler_registered()) { \
fprintf(stderr, "\e[31m%s:%d: " _fmt "\e[0m\n", __FILE__, __LINE__, ##__VA_ARGS__); \
} else { \
srsran_phy_log_print(LOG_LEVEL_ERROR_S, _fmt, ##__VA_ARGS__); \
@ -84,11 +92,15 @@ SRSRAN_API extern int handler_registered;
} while (0)
#else
#define ERROR(_fmt, ...) \
if (!handler_registered) { \
if (!is_handler_registered()) { \
fprintf(stderr, "[ERROR in %s]:" _fmt "\n", __FUNCTION__, ##__VA_ARGS__); \
} else { \
srsran_phy_log_print(LOG_LEVEL_ERROR, _fmt, ##__VA_ARGS__); \
} //
#endif /* CMAKE_BUILD_TYPE==Debug */
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // SRSRAN_DEBUG_H

@ -352,7 +352,7 @@ SRSRAN_API void srsran_vec_interleave(const cf_t* x, const cf_t* y, cf_t* z, con
SRSRAN_API void srsran_vec_interleave_add(const cf_t* x, const cf_t* y, cf_t* z, const int len);
SRSRAN_API void srsran_vec_gen_sine(cf_t amplitude, float freq, cf_t* z, int len);
SRSRAN_API cf_t srsran_vec_gen_sine(cf_t amplitude, float freq, cf_t* z, int len);
SRSRAN_API void srsran_vec_apply_cfo(const cf_t* x, float cfo, cf_t* z, int len);

@ -130,7 +130,7 @@ SRSRAN_API void srsran_vec_interleave_simd(const cf_t* x, const cf_t* y, cf_t* z
SRSRAN_API void srsran_vec_interleave_add_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len);
SRSRAN_API void srsran_vec_gen_sine_simd(cf_t amplitude, float freq, cf_t* z, int len);
SRSRAN_API cf_t srsran_vec_gen_sine_simd(cf_t amplitude, float freq, cf_t* z, int len);
SRSRAN_API void srsran_vec_apply_cfo_simd(const cf_t* x, float cfo, cf_t* z, int len);

@ -102,8 +102,8 @@ private:
std::mutex metrics_mutex;
srslog::basic_logger& logger = srslog::fetch_basic_logger("RF", false);
phy_interface_radio* phy = nullptr;
cf_t* zeros = nullptr;
std::array<cf_t*, SRSRAN_MAX_CHANNELS> dummy_buffers;
std::vector<cf_t> zeros;
std::array<std::vector<cf_t>, SRSRAN_MAX_CHANNELS> dummy_buffers;
std::mutex tx_mutex;
std::mutex rx_mutex;
std::array<std::vector<cf_t>, SRSRAN_MAX_CHANNELS> tx_buffer;

@ -68,7 +68,6 @@ public:
// MAC interface
bool has_data_locked(const uint32_t lcid);
uint32_t get_buffer_state(const uint32_t lcid);
void get_buffer_state(uint32_t lcid, uint32_t& tx_queue, uint32_t& prio_tx_queue);
uint32_t get_total_mch_buffer_state(uint32_t lcid);
uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
uint32_t read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
@ -98,6 +97,8 @@ public:
private:
void reset_metrics();
void get_buffer_state(uint32_t lcid, uint32_t& tx_queue, uint32_t& prio_tx_queue);
srslog::basic_logger& logger;
byte_buffer_pool* pool = nullptr;
srsue::pdcp_interface_rlc* pdcp = nullptr;

@ -410,6 +410,8 @@ private:
int required_buffer_size(const rlc_amd_retx_t& retx);
void retransmit_pdu(uint32_t sn);
void get_buffer_state_nolock(uint32_t& new_tx, uint32_t& prio_tx);
// Helpers
bool poll_required();
bool do_status();

@ -67,7 +67,7 @@ public:
uint32_t read_pdu(uint8_t* payload, uint32_t nof_bytes) override;
void write_pdu(uint8_t* payload, uint32_t nof_bytes) override;
void set_bsr_callback(bsr_callback_t callback) override {}
void set_bsr_callback(bsr_callback_t callback) override;
private:
byte_buffer_pool* pool = nullptr;
@ -76,6 +76,9 @@ private:
srsue::pdcp_interface_rlc* pdcp = nullptr;
srsue::rrc_interface_rlc* rrc = nullptr;
std::mutex bsr_callback_mutex;
bsr_callback_t bsr_callback;
std::atomic<bool> tx_enabled = {true};
std::mutex metrics_mutex;

@ -75,7 +75,9 @@ public:
rlc_bearer_metrics_t get_metrics();
void reset_metrics();
void set_bsr_callback(bsr_callback_t callback) {}
void set_bsr_callback(bsr_callback_t callback);
uint32_t get_lcid() const { return lcid; }
protected:
// Transmitter sub-class base
@ -97,11 +99,14 @@ protected:
bool has_data();
virtual uint32_t get_buffer_state() = 0;
void set_bsr_callback(bsr_callback_t callback);
protected:
byte_buffer_pool* pool = nullptr;
srslog::basic_logger& logger;
std::string rb_name;
rlc_um_base* parent = nullptr;
bsr_callback_t bsr_callback;
rlc_config_t cfg = {};

@ -318,7 +318,7 @@ inline null<> gmtime_s(...) { return null<>(); }
inline std::tm localtime(std::time_t time) {
struct dispatcher {
std::time_t time_;
std::tm tm_;
std::tm tm_{};
dispatcher(std::time_t t) : time_(t) {}

@ -48,8 +48,8 @@ public:
void set_enabled(uint32_t lcid, bool enabled) override;
void write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, int sn = -1) override;
void write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu);
int add_bearer(uint32_t lcid, pdcp_config_t cnfg) override;
void add_bearer_mrb(uint32_t lcid, pdcp_config_t cnfg);
int add_bearer(uint32_t lcid, const pdcp_config_t& cnfg) override;
void add_bearer_mrb(uint32_t lcid, const pdcp_config_t& cnfg);
void del_bearer(uint32_t lcid) override;
void change_lcid(uint32_t old_lcid, uint32_t new_lcid) override;
void config_security(uint32_t lcid, const as_security_config_t& sec_cfg) override;

@ -2092,10 +2092,8 @@ LIBLTE_ERROR_ENUM liblte_mme_unpack_network_name_ie(uint8** ie_ptr, LIBLTE_MME_N
if (tmp_char == 0x0A || tmp_char == 0x0D || (tmp_char >= 0x20 && tmp_char <= 0x3F) ||
(tmp_char >= 0x41 && tmp_char <= 0x5A) || (tmp_char >= 0x61 && tmp_char <= 0x7A)) {
if (str_cnt < LIBLTE_STRING_LEN) {
net_name->name[str_cnt] = tmp_char;
str_cnt++;
}
net_name->name[str_cnt] = tmp_char;
str_cnt++;
}
}
@ -5027,7 +5025,6 @@ LIBLTE_ERROR_ENUM liblte_mme_pack_attach_request_msg(LIBLTE_MME_ATTACH_REQUEST_M
if (attach_req->ms_cm3_present) {
*msg_ptr = LIBLTE_MME_MS_CLASSMARK_3_IEI;
msg_ptr++;
liblte_mme_pack_mobile_station_classmark_3_ie(&attach_req->ms_cm3, &msg_ptr);
}
// Supported Codecs
@ -5219,7 +5216,6 @@ LIBLTE_ERROR_ENUM liblte_mme_unpack_attach_request_msg(LIBLTE_BYTE_MSG_STRUCT*
// Mobile Station Classmark 3
if (LIBLTE_MME_MS_CLASSMARK_3_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_mobile_station_classmark_3_ie(&msg_ptr, &attach_req->ms_cm3);
attach_req->ms_cm3_present = true;
} else {
attach_req->ms_cm3_present = false;
@ -5909,72 +5905,71 @@ LIBLTE_ERROR_ENUM liblte_mme_pack_emm_information_msg(LIBLTE_MME_EMM_INFORMATION
LIBLTE_ERROR_ENUM liblte_mme_unpack_emm_information_msg(LIBLTE_BYTE_MSG_STRUCT* msg,
LIBLTE_MME_EMM_INFORMATION_MSG_STRUCT* emm_info)
{
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
uint8* msg_ptr = msg->msg;
uint8* msg_end = msg->msg + msg->N_bytes;
uint8 sec_hdr_type;
if (!msg || !emm_info) {
return LIBLTE_ERROR_INVALID_INPUTS;
}
if (msg != NULL && emm_info != NULL) {
// Security Header Type
sec_hdr_type = (msg->msg[0] & 0xF0) >> 4;
if (LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS == sec_hdr_type) {
msg_ptr++;
} else {
msg_ptr += 7;
}
uint8* msg_ptr = msg->msg;
uint8* msg_end = msg->msg + msg->N_bytes;
uint8 sec_hdr_type;
// Skip Message Type
// Security Header Type
sec_hdr_type = (msg->msg[0] & 0xF0) >> 4;
if (LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS == sec_hdr_type) {
msg_ptr++;
} else {
msg_ptr += 7;
}
// Full Name For Network
if (LIBLTE_MME_FULL_NAME_FOR_NETWORK_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_network_name_ie(&msg_ptr, &emm_info->full_net_name);
emm_info->full_net_name_present = true;
} else {
emm_info->full_net_name_present = false;
}
// Skip Message Type
msg_ptr++;
// Short Name For Network
if (msg_ptr < msg_end && LIBLTE_MME_SHORT_NAME_FOR_NETWORK_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_network_name_ie(&msg_ptr, &emm_info->short_net_name);
emm_info->short_net_name_present = true;
} else {
emm_info->short_net_name_present = false;
}
// Full Name For Network
if (LIBLTE_MME_FULL_NAME_FOR_NETWORK_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_network_name_ie(&msg_ptr, &emm_info->full_net_name);
emm_info->full_net_name_present = true;
} else {
emm_info->full_net_name_present = false;
}
// Local Time Zone
if (msg_ptr < msg_end && LIBLTE_MME_LOCAL_TIME_ZONE_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_time_zone_ie(&msg_ptr, &emm_info->local_time_zone);
emm_info->local_time_zone_present = true;
} else {
emm_info->local_time_zone_present = false;
}
// Short Name For Network
if (msg_ptr < msg_end && LIBLTE_MME_SHORT_NAME_FOR_NETWORK_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_network_name_ie(&msg_ptr, &emm_info->short_net_name);
emm_info->short_net_name_present = true;
} else {
emm_info->short_net_name_present = false;
}
// Universal Time And Local Time Zone
if (msg_ptr < msg_end && LIBLTE_MME_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_time_zone_and_time_ie(&msg_ptr, &emm_info->utc_and_local_time_zone);
emm_info->utc_and_local_time_zone_present = true;
} else {
emm_info->utc_and_local_time_zone_present = false;
}
// Local Time Zone
if (msg_ptr < msg_end && LIBLTE_MME_LOCAL_TIME_ZONE_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_time_zone_ie(&msg_ptr, &emm_info->local_time_zone);
emm_info->local_time_zone_present = true;
} else {
emm_info->local_time_zone_present = false;
}
// Network Daylight Saving Time
if (msg_ptr < msg_end && LIBLTE_MME_NETWORK_DAYLIGHT_SAVING_TIME_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_daylight_saving_time_ie(&msg_ptr, &emm_info->net_dst);
emm_info->net_dst_present = true;
} else {
emm_info->net_dst_present = false;
}
// Universal Time And Local Time Zone
if (msg_ptr < msg_end && LIBLTE_MME_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_time_zone_and_time_ie(&msg_ptr, &emm_info->utc_and_local_time_zone);
emm_info->utc_and_local_time_zone_present = true;
} else {
emm_info->utc_and_local_time_zone_present = false;
}
err = LIBLTE_SUCCESS;
// Network Daylight Saving Time
if (msg_ptr < msg_end && LIBLTE_MME_NETWORK_DAYLIGHT_SAVING_TIME_IEI == *msg_ptr) {
msg_ptr++;
liblte_mme_unpack_daylight_saving_time_ie(&msg_ptr, &emm_info->net_dst);
emm_info->net_dst_present = true;
} else {
emm_info->net_dst_present = false;
}
return (err);
return LIBLTE_SUCCESS;
}
/*********************************************************************

@ -428,7 +428,6 @@ LIBLTE_ERROR_ENUM liblte_security_generate_k_nr_up(uint8*
LIBLTE_ERROR_ENUM liblte_security_generate_sk_gnb(uint8_t* k_enb, uint8_t* sk_gnb, uint16_t scg_counter)
{
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
uint8 s[5];
@ -627,97 +626,96 @@ LIBLTE_ERROR_ENUM liblte_security_128_eia2(const uint8* key,
LIBLTE_BIT_MSG_STRUCT* msg,
uint8* mac)
{
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
uint8 M[msg->N_bits * 8 + 8 + 16];
aes_context ctx;
uint32 i;
uint32 j;
uint32 n;
uint32 pad_bits;
uint8 const_zero[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8 L[16];
uint8 K1[16];
uint8 K2[16];
uint8 T[16];
uint8 tmp[16];
if (key != NULL && msg != NULL && mac != NULL) {
// Subkey L generation
aes_setkey_enc(&ctx, key, 128);
aes_crypt_ecb(&ctx, AES_ENCRYPT, const_zero, L);
if (!key || !msg || !mac) {
return LIBLTE_ERROR_INVALID_INPUTS;
}
// Subkey K1 generation
for (i = 0; i < 15; i++) {
K1[i] = (L[i] << 1) | ((L[i + 1] >> 7) & 0x01);
}
K1[15] = L[15] << 1;
if (L[0] & 0x80) {
K1[15] ^= 0x87;
}
uint8 M[msg->N_bits * 8 + 8 + 16];
aes_context ctx;
uint32 i;
uint32 j;
uint32 n;
uint32 pad_bits;
uint8 const_zero[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8 L[16];
uint8 K1[16];
uint8 K2[16];
uint8 T[16];
uint8 tmp[16];
// Subkey L generation
aes_setkey_enc(&ctx, key, 128);
aes_crypt_ecb(&ctx, AES_ENCRYPT, const_zero, L);
// Subkey K1 generation
for (i = 0; i < 15; i++) {
K1[i] = (L[i] << 1) | ((L[i + 1] >> 7) & 0x01);
}
K1[15] = L[15] << 1;
if (L[0] & 0x80) {
K1[15] ^= 0x87;
}
// Subkey K2 generation
for (i = 0; i < 15; i++) {
K2[i] = (K1[i] << 1) | ((K1[i + 1] >> 7) & 0x01);
}
K2[15] = K1[15] << 1;
if (K1[0] & 0x80) {
K2[15] ^= 0x87;
}
// Subkey K2 generation
for (i = 0; i < 15; i++) {
K2[i] = (K1[i] << 1) | ((K1[i + 1] >> 7) & 0x01);
}
K2[15] = K1[15] << 1;
if (K1[0] & 0x80) {
K2[15] ^= 0x87;
}
// Construct M
memset(M, 0, msg->N_bits * 8 + 8 + 16);
M[0] = (count >> 24) & 0xFF;
M[1] = (count >> 16) & 0xFF;
M[2] = (count >> 8) & 0xFF;
M[3] = count & 0xFF;
M[4] = (bearer << 3) | (direction << 2);
for (i = 0; i < msg->N_bits / 8; i++) {
M[8 + i] = 0;
for (j = 0; j < 8; j++) {
M[8 + i] |= msg->msg[i * 8 + j] << (7 - j);
}
// Construct M
memset(M, 0, msg->N_bits * 8 + 8 + 16);
M[0] = (count >> 24) & 0xFF;
M[1] = (count >> 16) & 0xFF;
M[2] = (count >> 8) & 0xFF;
M[3] = count & 0xFF;
M[4] = (bearer << 3) | (direction << 2);
for (i = 0; i < msg->N_bits / 8; i++) {
M[8 + i] = 0;
for (j = 0; j < 8; j++) {
M[8 + i] |= msg->msg[i * 8 + j] << (7 - j);
}
if ((msg->N_bits % 8) != 0) {
M[8 + i] = 0;
for (j = 0; j < msg->N_bits % 8; j++) {
M[8 + i] |= msg->msg[i * 8 + j] << (7 - j);
}
}
if ((msg->N_bits % 8) != 0) {
M[8 + i] = 0;
for (j = 0; j < msg->N_bits % 8; j++) {
M[8 + i] |= msg->msg[i * 8 + j] << (7 - j);
}
}
// MAC generation
n = (uint32)(ceilf((float)(msg->N_bits + 64) / (float)(128)));
for (i = 0; i < 16; i++) {
T[i] = 0;
}
for (i = 0; i < n - 1; i++) {
for (j = 0; j < 16; j++) {
tmp[j] = T[j] ^ M[i * 16 + j];
}
aes_crypt_ecb(&ctx, AES_ENCRYPT, tmp, T);
// MAC generation
n = (uint32)(ceilf((float)(msg->N_bits + 64) / (float)(128)));
for (i = 0; i < 16; i++) {
T[i] = 0;
}
for (i = 0; i < n - 1; i++) {
for (j = 0; j < 16; j++) {
tmp[j] = T[j] ^ M[i * 16 + j];
}
pad_bits = (msg->N_bits + 64) % 128;
if (pad_bits == 0) {
for (j = 0; j < 16; j++) {
tmp[j] = T[j] ^ K1[j] ^ M[i * 16 + j];
}
aes_crypt_ecb(&ctx, AES_ENCRYPT, tmp, T);
} else {
pad_bits = (128 - pad_bits) - 1;
M[i * 16 + (15 - (pad_bits / 8))] |= 0x1 << (pad_bits % 8);
for (j = 0; j < 16; j++) {
tmp[j] = T[j] ^ K2[j] ^ M[i * 16 + j];
}
aes_crypt_ecb(&ctx, AES_ENCRYPT, tmp, T);
aes_crypt_ecb(&ctx, AES_ENCRYPT, tmp, T);
}
pad_bits = (msg->N_bits + 64) % 128;
if (pad_bits == 0) {
for (j = 0; j < 16; j++) {
tmp[j] = T[j] ^ K1[j] ^ M[i * 16 + j];
}
for (i = 0; i < 4; i++) {
mac[i] = T[i];
aes_crypt_ecb(&ctx, AES_ENCRYPT, tmp, T);
} else {
pad_bits = (128 - pad_bits) - 1;
M[i * 16 + (15 - (pad_bits / 8))] |= 0x1 << (pad_bits % 8);
for (j = 0; j < 16; j++) {
tmp[j] = T[j] ^ K2[j] ^ M[i * 16 + j];
}
aes_crypt_ecb(&ctx, AES_ENCRYPT, tmp, T);
}
err = LIBLTE_SUCCESS;
for (i = 0; i < 4; i++) {
mac[i] = T[i];
}
return (err);
return LIBLTE_SUCCESS;
}
uint32_t GET_WORD(uint32_t* DATA, uint32_t i)

@ -112,7 +112,7 @@ srsran_dci_cfg_nr_t phy_cfg_nr_t::get_dci_cfg() const
bool phy_cfg_nr_t::assert_ss_id(uint32_t ss_id) const
{
// Make sure SS access if bounded
if (ss_id > SRSRAN_UE_DL_NR_MAX_NOF_SEARCH_SPACE) {
if (ss_id >= SRSRAN_UE_DL_NR_MAX_NOF_SEARCH_SPACE) {
return false;
}

@ -398,7 +398,7 @@ void phy_cfg_nr_default_t::make_harq_auto(srsran_harq_ack_cfg_hl_t& harq,
void phy_cfg_nr_default_t::make_prach_default_lte(srsran_prach_cfg_t& prach)
{
prach.is_nr = true;
prach.config_idx = 0;
prach.config_idx = 8;
prach.root_seq_idx = 0;
prach.zero_corr_zone = 0;
prach.freq_offset = 4;

@ -31,7 +31,7 @@ void rlc_pcap::enable(bool en)
enable_write = true;
}
void rlc_pcap::open(const char* filename, rlc_config_t config)
void rlc_pcap::open(const char* filename, const rlc_config_t& config)
{
fprintf(stdout, "Opening RLC PCAP with DLT=%d\n", UDP_DLT);
pcap_file = DLT_PCAP_Open(UDP_DLT, filename);

@ -37,7 +37,7 @@
#define ROT(a, k) (((a) << k) | ((a) >> (32 - k)))
/* the s-boxes */
u8 S0[256] = {
static const u8 S0[256] = {
0x3e, 0x72, 0x5b, 0x47, 0xca, 0xe0, 0x00, 0x33, 0x04, 0xd1, 0x54, 0x98, 0x09, 0xb9, 0x6d, 0xcb, 0x7b, 0x1b, 0xf9,
0x32, 0xaf, 0x9d, 0x6a, 0xa5, 0xb8, 0x2d, 0xfc, 0x1d, 0x08, 0x53, 0x03, 0x90, 0x4d, 0x4e, 0x84, 0x99, 0xe4, 0xce,
0xd9, 0x91, 0xdd, 0xb6, 0x85, 0x48, 0x8b, 0x29, 0x6e, 0xac, 0xcd, 0xc1, 0xf8, 0x1e, 0x73, 0x43, 0x69, 0xc6, 0xb5,
@ -53,7 +53,7 @@ u8 S0[256] = {
0x25, 0x05, 0x3f, 0x0c, 0x30, 0xea, 0x70, 0xb7, 0xa1, 0xe8, 0xa9, 0x65, 0x8d, 0x27, 0x1a, 0xdb, 0x81, 0xb3, 0xa0,
0xf4, 0x45, 0x7a, 0x19, 0xdf, 0xee, 0x78, 0x34, 0x60};
u8 S1[256] = {
static const u8 S1[256] = {
0x55, 0xc2, 0x63, 0x71, 0x3b, 0xc8, 0x47, 0x86, 0x9f, 0x3c, 0xda, 0x5b, 0x29, 0xaa, 0xfd, 0x77, 0x8c, 0xc5, 0x94,
0x0c, 0xa6, 0x1a, 0x13, 0x00, 0xe3, 0xa8, 0x16, 0x72, 0x40, 0xf9, 0xf8, 0x42, 0x44, 0x26, 0x68, 0x96, 0x81, 0xd9,
0x45, 0x3e, 0x10, 0x76, 0xc6, 0xa7, 0x8b, 0x39, 0x43, 0xe1, 0x3a, 0xb5, 0x56, 0x2a, 0xc0, 0x6d, 0xb3, 0x05, 0x22,
@ -70,22 +70,22 @@ u8 S1[256] = {
0xd7, 0xb0, 0x25, 0xac, 0xaf, 0x12, 0x03, 0xe2, 0xf2};
/* the constants D */
u32 EK_d[16] = {0x44D7,
0x26BC,
0x626B,
0x135E,
0x5789,
0x35E2,
0x7135,
0x09AF,
0x4D78,
0x2F13,
0x6BC4,
0x1AF1,
0x5E26,
0x3C4D,
0x789A,
0x47AC};
static const u32 EK_d[16] = {0x44D7,
0x26BC,
0x626B,
0x135E,
0x5789,
0x35E2,
0x7135,
0x09AF,
0x4D78,
0x2F13,
0x6BC4,
0x1AF1,
0x5E26,
0x3C4D,
0x789A,
0x47AC};
/* ——————————————————————- */
/* c = a + b mod (2^31 1) */

@ -108,7 +108,7 @@ void pdcp::write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu)
}
}
int pdcp::add_bearer(uint32_t lcid, pdcp_config_t cfg)
int pdcp::add_bearer(uint32_t lcid, const pdcp_config_t& cfg)
{
if (valid_lcid(lcid)) {
return pdcp_array[lcid]->configure(cfg) ? SRSRAN_SUCCESS : SRSRAN_ERROR;
@ -143,7 +143,7 @@ int pdcp::add_bearer(uint32_t lcid, pdcp_config_t cfg)
return SRSRAN_SUCCESS;
}
void pdcp::add_bearer_mrb(uint32_t lcid, pdcp_config_t cfg)
void pdcp::add_bearer_mrb(uint32_t lcid, const pdcp_config_t& cfg)
{
if (not valid_mch_lcid(lcid)) {
std::unique_ptr<pdcp_entity_lte> entity;

@ -329,9 +329,9 @@ static float estimate_noise_pilots(srsran_chest_dl_t* q, srsran_dl_sf_cfg_t* sf,
float sum_power = 0.0f;
uint32_t count = 0;
uint32_t npilots = (ch_mode == SRSRAN_SF_MBSFN) ? SRSRAN_REFSIGNAL_NUM_SF_MBSFN(q->cell.nof_prb, port_id)
: srsran_refsignal_cs_nof_re(&q->csr_refs, sf, port_id);
uint32_t nsymbols = (ch_mode == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_nof_symbols()
: srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id);
: srsran_refsignal_cs_nof_re(&q->csr_refs, sf, port_id);
uint32_t nsymbols = (ch_mode == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_nof_symbols()
: srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id);
if (nsymbols == 0) {
ERROR("Invalid number of CRS symbols\n");
return SRSRAN_ERROR;
@ -442,8 +442,8 @@ static void interpolate_pilots(srsran_chest_dl_t* q,
uint32_t port_id)
{
/* interpolate the symbols with references in the freq domain */
uint32_t nsymbols = (sf->sf_type == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_nof_symbols() + 1
: srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id);
uint32_t nsymbols = (sf->sf_type == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_nof_symbols() + 1
: srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id);
uint32_t fidx_offset = 0;
/* Interpolate in the frequency domain */
@ -565,7 +565,7 @@ static void average_pilots(srsran_chest_dl_t* q,
{
uint32_t nsymbols = (sf->sf_type == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_nof_symbols()
: srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id);
uint32_t nref = (sf->sf_type == SRSRAN_SF_MBSFN) ? 6 * q->cell.nof_prb : 2 * q->cell.nof_prb;
uint32_t nref = (sf->sf_type == SRSRAN_SF_MBSFN) ? 6 * q->cell.nof_prb : 2 * q->cell.nof_prb;
// Average in the time domain if enabled
if (cfg->estimator_alg == SRSRAN_ESTIMATOR_ALG_AVERAGE && nsymbols > 1) {
@ -976,12 +976,8 @@ static void fill_res(srsran_chest_dl_t* q, srsran_chest_dl_res_t* res)
for (uint32_t port_id = 0; port_id < q->cell.nof_ports; port_id++) {
res->rsrp_port_dbm[port_id] = srsran_convert_power_to_dBm(get_rsrp_port(q, port_id));
for (uint32_t a = 0; a < q->nof_rx_antennas; a++) {
if (q->noise_estimate[a]) {
res->snr_ant_port_db[a][port_id] =
srsran_convert_power_to_dB(q->rsrp[a][port_id] / q->noise_estimate[a][port_id]);
} else {
res->snr_ant_port_db[a][port_id] = 0.0f;
}
res->snr_ant_port_db[a][port_id] =
srsran_convert_power_to_dB(q->rsrp[a][port_id] / q->noise_estimate[a][port_id]);
res->rsrp_ant_port_dbm[a][port_id] = srsran_convert_power_to_dBm(q->rsrp[a][port_id]);
res->rsrq_ant_port_db[a][port_id] =
srsran_convert_power_to_dB(q->cell.nof_prb * q->rsrp[a][port_id] / q->rssi[a][port_id]);

@ -89,7 +89,7 @@ int srsran_chest_dl_nbiot_init(srsran_chest_dl_nbiot_t* q, uint32_t max_prb)
}
clean_exit:
if (ret != SRSRAN_SUCCESS) {
if (ret != SRSRAN_SUCCESS && q != NULL) {
srsran_chest_dl_nbiot_free(q);
}
return ret;

@ -944,10 +944,10 @@ float srsran_chest_sl_estimate_noise(srsran_chest_sl_t* q)
return q->noise_estimated;
}
int srsran_chest_sl_init(srsran_chest_sl_t* q,
srsran_sl_channels_t channel,
srsran_cell_sl_t cell,
srsran_sl_comm_resource_pool_t sl_comm_resource_pool)
int srsran_chest_sl_init(srsran_chest_sl_t* q,
srsran_sl_channels_t channel,
srsran_cell_sl_t cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool)
{
int ret = SRSRAN_ERROR_INVALID_INPUTS;
if (q != NULL) {
@ -955,7 +955,7 @@ int srsran_chest_sl_init(srsran_chest_sl_t* q,
q->channel = channel;
q->cell = cell;
q->sl_comm_resource_pool = sl_comm_resource_pool;
q->sl_comm_resource_pool = *sl_comm_resource_pool;
switch (channel) {
case SRSRAN_SIDELINK_PSBCH:

@ -769,6 +769,8 @@ int srsran_csi_rs_nzp_measure_trs(const srsran_carrier_nr_t* carrier,
// Perform Measurements
csi_rs_nzp_resource_measure_t measurements[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET];
int ret = csi_rs_nzp_measure_set(carrier, slot_cfg, set, grid, measurements);
// Return to prevent assigning negative values to count
if (ret < SRSRAN_SUCCESS) {
ERROR("Error performing measurements");
return SRSRAN_ERROR;
@ -865,6 +867,8 @@ int srsran_csi_rs_nzp_measure_channel(const srsran_carrier_nr_t* carrier
// Perform Measurements
csi_rs_nzp_resource_measure_t measurements[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET];
int ret = csi_rs_nzp_measure_set(carrier, slot_cfg, set, grid, measurements);
// Return to prevent assigning negative values to count
if (ret < SRSRAN_SUCCESS) {
ERROR("Error performing measurements");
return SRSRAN_ERROR;
@ -1041,8 +1045,11 @@ int srsran_csi_rs_zp_measure_channel(const srsran_carrier_nr_t* carrier,
// Perform Measurements
csi_rs_zp_resource_measure_t measurements[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET];
int ret = csi_rs_zp_measure_set(carrier, slot_cfg, set, grid, measurements);
// Return to prevent assigning negative values to count
if (ret < SRSRAN_SUCCESS) {
ERROR("Error performing measurements");
return SRSRAN_ERROR;
}
uint32_t count = (uint32_t)ret;

@ -449,7 +449,7 @@ int srsran_dmrs_pdcch_get_measure(const srsran_dmrs_pdcch_estimator_t* q,
nof_pilots += NOF_PILOTS_X_RB;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DMRS_PDCCH_DEBUG_RX("Measuring PDCCH l=%d; lse=", l);
srsran_vec_fprint_c(stdout, tmp, nof_pilots);
}
@ -463,6 +463,11 @@ int srsran_dmrs_pdcch_get_measure(const srsran_dmrs_pdcch_estimator_t* q,
srsran_vec_apply_cfo(tmp, tmp_sync_err, tmp, nof_pilots);
#endif // DMRS_PDCCH_SYNC_PRECOMPENSATE_MEAS
// Prevent undefined division
if (!nof_pilots) {
ERROR("Error in DMRS correlation. nof_pilots cannot be zero");
return SRSRAN_ERROR;
}
// Correlate DMRS
corr[l] = srsran_vec_acc_cc(tmp, nof_pilots) / (float)nof_pilots;

@ -23,6 +23,7 @@
#include "srsran/phy/common/sequence.h"
#include "srsran/phy/utils/debug.h"
#include "srsran/phy/utils/vector.h"
#include <assert.h>
#include <complex.h>
// Implements TS 38.211 table 6.4.1.3.1.1-1: Number of DM-RS symbols and the corresponding N_PUCCH...
@ -191,7 +192,11 @@ int srsran_dmrs_pucch_format1_estimate(const srsran_pucch_nr_t* q,
return SRSRAN_ERROR;
}
cf_t ce[SRSRAN_PUCCH_NR_FORMAT1_N_MAX][SRSRAN_NRE];
cf_t ce[SRSRAN_PUCCH_NR_FORMAT1_N_MAX][SRSRAN_NRE];
// Prevent ce[m] overflow
assert(n_pucch <= SRSRAN_PUCCH_NR_FORMAT1_N_MAX);
uint32_t l_prime = resource->start_symbol_idx;
for (uint32_t m = 0; m < n_pucch; m++) {
// Clause 6.4.1.3.1.2 specifies l=0,2,4...
@ -222,6 +227,7 @@ int srsran_dmrs_pucch_format1_estimate(const srsran_pucch_nr_t* q,
cf_t z[SRSRAN_NRE];
srsran_vec_sc_prod_ccc(r_uv, w_i_m, z, SRSRAN_NRE);
// TODO: can ce[m] overflow?
// Calculate least square estimates for this symbol
srsran_vec_prod_conj_ccc(slot_symbols_ptr, z, ce[m], SRSRAN_NRE);
}

@ -36,7 +36,6 @@
*/
int srsran_refsignal_cs_init(srsran_refsignal_t* q, uint32_t max_prb)
{
int ret = SRSRAN_ERROR_INVALID_INPUTS;
if (q != NULL) {
@ -65,7 +64,6 @@ free_and_exit:
*/
int srsran_refsignal_cs_set_cell(srsran_refsignal_t* q, srsran_cell_t cell)
{
uint32_t c_init;
uint32_t N_cp, mp;
srsran_sequence_t seq;
@ -356,7 +354,6 @@ uint32_t srsran_refsignal_mbsfn_nof_symbols()
inline uint32_t srsran_refsignal_mbsfn_fidx(uint32_t l)
{
uint32_t ret = 0;
if (l == 0) {
ret = 0;
@ -456,21 +453,21 @@ free_and_exit:
int srsran_refsignal_mbsfn_set_cell(srsran_refsignal_t* q, srsran_cell_t cell, uint16_t mbsfn_area_id)
{
int ret = SRSRAN_SUCCESS;
int ret = SRSRAN_ERROR_INVALID_INPUTS;
q->cell = cell;
if (q == NULL) {
ret = SRSRAN_ERROR_INVALID_INPUTS;
goto exit;
}
q->cell = cell;
q->mbsfn_area_id = mbsfn_area_id;
if (srsran_refsignal_mbsfn_gen_seq(q, q->cell, q->mbsfn_area_id)) {
goto free_and_exit;
if (srsran_refsignal_mbsfn_gen_seq(q, q->cell, q->mbsfn_area_id) < SRSRAN_SUCCESS) {
ret = SRSRAN_ERROR;
goto exit;
}
ret = SRSRAN_SUCCESS;
free_and_exit:
if (ret == SRSRAN_ERROR) {
srsran_refsignal_free(q);
}
exit:
return ret;
}

@ -36,54 +36,56 @@
#include "srsran/phy/utils/vector.h"
// n_dmrs_2 table 5.5.2.1.1-1 from 36.211
uint32_t n_dmrs_2[8] = {0, 6, 3, 4, 2, 8, 10, 9};
static const uint32_t n_dmrs_2[8] = {0, 6, 3, 4, 2, 8, 10, 9};
// n_dmrs_1 table 5.5.2.1.1-2 from 36.211
uint32_t n_dmrs_1[8] = {0, 2, 3, 4, 6, 8, 9, 10};
static const uint32_t n_dmrs_1[8] = {0, 2, 3, 4, 6, 8, 9, 10};
/* Orthogonal sequences for PUCCH formats 1a, 1b and 1c. Table 5.5.2.2.1-2
*/
float w_arg_pucch_format1_cpnorm[3][3] = {{0, 0, 0}, {0, 2 * M_PI / 3, 4 * M_PI / 3}, {0, 4 * M_PI / 3, 2 * M_PI / 3}};
static const float w_arg_pucch_format1_cpnorm[3][3] = {{0, 0, 0},
{0, 2 * M_PI / 3, 4 * M_PI / 3},
{0, 4 * M_PI / 3, 2 * M_PI / 3}};
float w_arg_pucch_format1_cpext[3][2] = {{0, 0}, {0, M_PI}, {0, 0}};
static const float w_arg_pucch_format1_cpext[3][2] = {{0, 0}, {0, M_PI}, {0, 0}};
float w_arg_pucch_format2_cpnorm[2] = {0, 0};
float w_arg_pucch_format2_cpext[1] = {0};
static const float w_arg_pucch_format2_cpnorm[2] = {0, 0};
static const float w_arg_pucch_format2_cpext[1] = {0};
uint32_t pucch_dmrs_symbol_format1_cpnorm[3] = {2, 3, 4};
uint32_t pucch_dmrs_symbol_format1_cpext[2] = {2, 3};
uint32_t pucch_dmrs_symbol_format2_cpnorm[2] = {1, 5};
uint32_t pucch_dmrs_symbol_format2_cpext[1] = {3};
static const uint32_t pucch_dmrs_symbol_format1_cpnorm[3] = {2, 3, 4};
static const uint32_t pucch_dmrs_symbol_format1_cpext[2] = {2, 3};
static const uint32_t pucch_dmrs_symbol_format2_cpnorm[2] = {1, 5};
static const uint32_t pucch_dmrs_symbol_format2_cpext[1] = {3};
/* Table 5.5.3.3-1: Frame structure type 1 sounding reference signal subframe configuration. */
uint32_t T_sfc[15] = {1, 2, 2, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10};
uint32_t Delta_sfc1[7] = {0, 0, 1, 0, 1, 2, 3};
uint32_t Delta_sfc2[4] = {0, 1, 2, 3};
uint32_t m_srs_b[4][4][8] = {{/* m_srs for 6<n_rb<40. Table 5.5.3.2-1 */
{36, 32, 24, 20, 16, 12, 8, 4},
{12, 16, 4, 4, 4, 4, 4, 4},
{4, 8, 4, 4, 4, 4, 4, 4},
{4, 4, 4, 4, 4, 4, 4, 4}},
{/* m_srs for 40<n_rb<60. Table 5.5.3.2-2 */
{48, 48, 40, 36, 32, 24, 20, 16},
{24, 16, 20, 12, 16, 4, 4, 4},
{12, 8, 4, 4, 8, 4, 4, 4},
{4, 4, 4, 4, 4, 4, 4, 4}},
{/* m_srs for 60<n_rb<80. Table 5.5.3.2-3 */
{72, 64, 60, 48, 48, 40, 36, 32},
{24, 32, 20, 24, 16, 20, 12, 16},
{12, 16, 4, 12, 8, 4, 4, 8},
{4, 4, 4, 4, 4, 4, 4, 4}},
{/* m_srs for 80<n_rb<110. Table 5.5.3.2-4 */
{96, 96, 80, 72, 64, 60, 48, 48},
{48, 32, 40, 24, 32, 20, 24, 16},
{24, 16, 20, 12, 16, 4, 12, 8},
{4, 4, 4, 4, 4, 4, 4, 4}}};
static const uint32_t T_sfc[15] = {1, 2, 2, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10};
static const uint32_t Delta_sfc1[7] = {0, 0, 1, 0, 1, 2, 3};
static const uint32_t Delta_sfc2[4] = {0, 1, 2, 3};
static const uint32_t m_srs_b[4][4][8] = {{/* m_srs for 6<n_rb<40. Table 5.5.3.2-1 */
{36, 32, 24, 20, 16, 12, 8, 4},
{12, 16, 4, 4, 4, 4, 4, 4},
{4, 8, 4, 4, 4, 4, 4, 4},
{4, 4, 4, 4, 4, 4, 4, 4}},
{/* m_srs for 40<n_rb<60. Table 5.5.3.2-2 */
{48, 48, 40, 36, 32, 24, 20, 16},
{24, 16, 20, 12, 16, 4, 4, 4},
{12, 8, 4, 4, 8, 4, 4, 4},
{4, 4, 4, 4, 4, 4, 4, 4}},
{/* m_srs for 60<n_rb<80. Table 5.5.3.2-3 */
{72, 64, 60, 48, 48, 40, 36, 32},
{24, 32, 20, 24, 16, 20, 12, 16},
{12, 16, 4, 12, 8, 4, 4, 8},
{4, 4, 4, 4, 4, 4, 4, 4}},
{/* m_srs for 80<n_rb<110. Table 5.5.3.2-4 */
{96, 96, 80, 72, 64, 60, 48, 48},
{48, 32, 40, 24, 32, 20, 24, 16},
{24, 16, 20, 12, 16, 4, 12, 8},
{4, 4, 4, 4, 4, 4, 4, 4}}};
/* Same tables for Nb */
uint32_t Nb[4][4][8] = {
static const uint32_t Nb[4][4][8] = {
{{1, 1, 1, 1, 1, 1, 1, 1}, {3, 2, 6, 5, 4, 3, 2, 1}, {3, 2, 1, 1, 1, 1, 1, 1}, {1, 2, 1, 1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1, 1, 1, 1}, {2, 3, 2, 3, 2, 6, 5, 4}, {2, 2, 5, 3, 2, 1, 1, 1}, {3, 2, 1, 1, 2, 1, 1, 1}},
{{1, 1, 1, 1, 1, 1, 1, 1}, {3, 2, 3, 2, 3, 2, 3, 2}, {2, 2, 5, 2, 2, 5, 3, 2}, {3, 4, 1, 3, 2, 1, 1, 2}},
@ -323,8 +325,7 @@ int srsran_refsignal_dmrs_pusch_pregen_put(srsran_refsignal_ul_t* q,
{
uint32_t sf_idx = sf_cfg->tti % 10;
if (srsran_dft_precoding_valid_prb(pusch_cfg->grant.L_prb) && sf_idx < SRSRAN_NOF_SF_X_FRAME &&
pusch_cfg->grant.n_dmrs < SRSRAN_NOF_CSHIFT) {
if (srsran_dft_precoding_valid_prb(pusch_cfg->grant.L_prb) && pusch_cfg->grant.n_dmrs < SRSRAN_NOF_CSHIFT) {
srsran_refsignal_dmrs_pusch_put(
q, pusch_cfg, pregen->r[pusch_cfg->grant.n_dmrs][sf_idx][pusch_cfg->grant.L_prb], sf_symbols);
return SRSRAN_SUCCESS;
@ -467,7 +468,7 @@ int srsran_refsignal_dmrs_pucch_gen(srsran_refsignal_ul_t* q,
}
// Choose number of symbols and orthogonal sequence from Tables 5.5.2.2.1-1 to -3
float* w = NULL;
const float* w = NULL;
switch (cfg->format) {
case SRSRAN_PUCCH_FORMAT_1:
case SRSRAN_PUCCH_FORMAT_1A:
@ -733,14 +734,14 @@ int srsran_refsignal_srs_send_cs(uint32_t subframe_config, uint32_t sf_idx)
} else {
return 1;
}
} else if (subframe_config == 14) {
}
// subframe_config == 14
else {
if (((sf_idx % tsfc) == 7) || ((sf_idx % tsfc) == 9)) {
return 0;
} else {
return 1;
}
} else {
return 0;
}
} else {
return SRSRAN_ERROR_INVALID_INPUTS;

@ -88,7 +88,7 @@ void parse_args(int argc, char** argv)
snr_db = strtof(argv[optind], NULL);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);
@ -154,7 +154,7 @@ int main(int argc, char** argv)
for (int n_port = 0; n_port < cell.base.nof_ports; n_port++) {
srsran_vec_cf_zero(input, num_re);
for (int i = 0; i < num_re; i++) {
input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX);
input[i] = 0.5 - rand() / (float)RAND_MAX + I * (0.5 - rand() / (float)RAND_MAX);
}
srsran_vec_cf_zero(ce, num_re);

@ -68,7 +68,7 @@ void parse_args(int argc, char** argv)
output_matlab = argv[optind];
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);
@ -146,7 +146,7 @@ int main(int argc, char** argv)
for (uint32_t n_port = 0; n_port < cell.nof_ports; n_port++) {
srsran_vec_cf_zero(input, num_re);
for (i = 0; i < num_re; i++) {
input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX);
input[i] = 0.5 - rand() / (float)RAND_MAX + I * (0.5 - rand() / (float)RAND_MAX);
}
srsran_vec_cf_zero(ce, num_re);
@ -172,7 +172,7 @@ int main(int argc, char** argv)
struct timeval t[3];
gettimeofday(&t[1], NULL);
for (int j = 0; j < 100; j++) {
for (int k = 0; k < 100; k++) {
srsran_chest_dl_estimate(&est, &sf_cfg, input_m, &res);
}
gettimeofday(&t[2], NULL);
@ -180,7 +180,7 @@ int main(int argc, char** argv)
printf("CHEST: %f us\n", (float)t[0].tv_usec / 100);
gettimeofday(&t[1], NULL);
for (int j = 0; j < 100; j++) {
for (int k = 0; k < 100; k++) {
srsran_predecoding_single(input, ce, output, NULL, num_re, 1.0f, 0);
}
gettimeofday(&t[2], NULL);
@ -195,7 +195,7 @@ int main(int argc, char** argv)
printf("MSE: %f\n", mse);
gettimeofday(&t[1], NULL);
for (int j = 0; j < 100; j++) {
for (int k = 0; k < 100; k++) {
srsran_predecoding_single(input, ce, output, NULL, num_re, 1.0f, res.noise_estimate);
}
gettimeofday(&t[2], NULL);

@ -76,7 +76,7 @@ void parse_args(int argc, char** argv)
}
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);
@ -113,9 +113,8 @@ int main(int argc, char** argv)
srsran_chest_sl_t q = {};
if (run_psbch_test) {
// Tx
srsran_chest_sl_init(&q, SRSRAN_SIDELINK_PSBCH, cell, sl_comm_resource_pool);
srsran_chest_sl_init(&q, SRSRAN_SIDELINK_PSBCH, cell, &sl_comm_resource_pool);
srsran_chest_sl_put_dmrs(&q, sf_buffer);
// Rx

@ -185,7 +185,7 @@ void parse_args(int argc, char** argv)
cell.id = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -71,7 +71,7 @@ void parse_args(int argc, char** argv)
output_matlab = argv[optind];
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);
@ -167,7 +167,7 @@ int main(int argc, char** argv)
// Loop through subframe idx and cyclic shifts
for (int sf_idx = 0; sf_idx < 10; sf_idx += 3) {
for (sf_idx = 0; sf_idx < 10; sf_idx += 3) {
for (int cshift_dmrs = 0; cshift_dmrs < SRSRAN_NOF_CSHIFT; cshift_dmrs += 5) {
if (SRSRAN_VERBOSE_ISINFO()) {
printf("nof_prb: %d, ", nof_prb);

@ -55,7 +55,7 @@ static int nzp_test_case(const srsran_slot_cfg_t* slot_cfg,
srsran_convert_power_to_dB(srsran_convert_dB_to_power(rsrp_dB_gold) + awgn->std_dev * awgn->std_dev);
const float n0_dB_gold = srsran_convert_amplitude_to_dB(awgn->std_dev);
if (srsran_verbose >= SRSRAN_VERBOSE_INFO) {
if (get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO) {
char str[128] = {};
srsran_csi_rs_measure_info(&measure, str, sizeof(str));
INFO("Measure: %s", str);
@ -370,7 +370,7 @@ static void parse_args(int argc, char** argv)
first_symbol = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -58,7 +58,7 @@ static void parse_args(int argc, char** argv)
interleaved ^= true;
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);
@ -87,6 +87,9 @@ static int run_test(srsran_dmrs_pdcch_estimator_t* estimator,
TESTASSERT(nof_locations == search_space->nof_candidates[aggregation_level]);
// Prevent possible out of bounds read in locations
TESTASSERT(nof_locations <= SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR);
for (uint32_t candidate = 0; candidate < nof_locations; candidate++) {
dci_location.ncce = locations[candidate];

@ -150,7 +150,7 @@ static void parse_args(int argc, char** argv)
carrier.pci = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -66,7 +66,7 @@ void parse_args(int argc, char** argv)
cell.id = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -79,6 +79,7 @@ int srsran_channel_awgn_init(srsran_channel_awgn_t* q, uint32_t seed)
q->table_log = srsran_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE);
if (!q->table_cos || !q->table_log) {
ERROR("Malloc");
return SRSRAN_ERROR;
}
// Fill tables

@ -49,7 +49,7 @@ static void usage(char* prog)
printf("\t-t tolerance: [Default %.3f]\n", tolerance);
}
static void parse_args(int argc, char** argv)
static int parse_args(int argc, char** argv)
{
int opt;
while ((opt = getopt(argc, argv, "nmMst")) != -1) {
@ -71,9 +71,10 @@ static void parse_args(int argc, char** argv)
break;
default:
usage(argv[0]);
exit(-1);
return SRSRAN_ERROR;
}
}
return SRSRAN_SUCCESS;
}
int main(int argc, char** argv)
@ -84,8 +85,15 @@ int main(int argc, char** argv)
uint64_t count_samples = 0;
uint64_t count_us = 0;
#ifdef ENABLE_GUI
cf_t* fft_out = NULL;
#endif
// Parse arguments
parse_args(argc, argv);
if (parse_args(argc, argv) < SRSRAN_SUCCESS) {
ret = SRSRAN_ERROR;
goto clean_exit;
}
// Initialise buffers
input_buffer = srsran_vec_cf_malloc(nof_samples);
@ -94,6 +102,7 @@ int main(int argc, char** argv)
if (!input_buffer || !output_buffer) {
ERROR("Error: Allocating memory");
ret = SRSRAN_ERROR;
goto clean_exit;
}
// Initialise input
@ -113,24 +122,31 @@ int main(int argc, char** argv)
plot_scatter_setTitle(&plot_fft, "IQ");
plot_scatter_addToWindowGrid(&plot_fft, (char*)"IQ", 1, 0);
cf_t* fft_out = srsran_vec_cf_malloc(nof_samples);
srsran_dft_plan_t fft = {};
fft_out = srsran_vec_cf_malloc(nof_samples);
srsran_dft_plan_t fft = {};
if (srsran_dft_plan_c(&fft, nof_samples, SRSRAN_DFT_FORWARD)) {
ERROR("Error: init DFT");
ret = SRSRAN_ERROR;
goto clean_exit;
}
#endif /* ENABLE_GUI */
// Initialise AWGN channel
if (ret == SRSRAN_SUCCESS) {
ret = srsran_channel_awgn_init(&awgn, 0);
if (srsran_channel_awgn_init(&awgn, 0) < SRSRAN_SUCCESS) {
ERROR("Error initialising AWGN channel");
ret = SRSRAN_ERROR;
goto clean_exit;
}
float n0 = n0_min;
while (!isnan(n0) && !isinf(n0) && n0 < n0_max) {
struct timeval t[3] = {};
srsran_channel_awgn_set_n0(&awgn, n0);
if (srsran_channel_awgn_set_n0(&awgn, n0) < SRSRAN_SUCCESS) {
ERROR("Error setting AWGN n0");
ret = SRSRAN_ERROR;
goto clean_exit;
}
// Run actual test
gettimeofday(&t[1], NULL);
@ -175,13 +191,28 @@ int main(int argc, char** argv)
n0 += n0_step;
}
// Free
// Print result and exit
double msps = 0;
if (count_us) {
msps = (double)nof_samples / (double)count_us;
} else {
ERROR("Error in Msps calculation: undefined division");
ret = SRSRAN_ERROR;
}
printf("Test n0_min=%.3f; n0_max=%.3f; n0_step=%.3f; nof_samples=%d; %s ... %.1f MSps\n",
n0_min,
n0_max,
n0_step,
nof_samples,
(ret == SRSRAN_SUCCESS) ? "Passed" : "Failed",
msps);
clean_exit:
srsran_channel_awgn_free(&awgn);
if (input_buffer) {
free(input_buffer);
}
if (output_buffer) {
free(output_buffer);
}
@ -193,13 +224,5 @@ int main(int argc, char** argv)
srsran_dft_plan_free(&fft);
#endif /* ENABLE_GUI */
// Print result and exit
printf("Test n0_min=%.3f; n0_max=%.3f; n0_step=%.3f; nof_samples=%d; %s ... %.1f MSps\n",
n0_min,
n0_max,
n0_step,
nof_samples,
(ret == SRSRAN_SUCCESS) ? "Passed" : "Failed",
(double)nof_samples / (double)count_us);
return ret;
}

@ -46,7 +46,7 @@ static void usage(char* prog)
printf("\t-T Simulation Time in periods: [Default %d]\n", sim_time_periods);
}
static void parse_args(int argc, char** argv)
static int parse_args(int argc, char** argv)
{
int opt;
while ((opt = getopt(argc, argv, "mMtsT")) != -1) {
@ -68,14 +68,15 @@ static void parse_args(int argc, char** argv)
break;
default:
usage(argv[0]);
exit(-1);
return SRSRAN_ERROR;
}
}
return SRSRAN_SUCCESS;
}
int main(int argc, char** argv)
{
int ret = SRSRAN_SUCCESS;
int ret = SRSRAN_ERROR;
cf_t* input_buffer = NULL;
cf_t* output_buffer = NULL;
srsran_timestamp_t ts = {}; // Initialised to zero
@ -83,28 +84,32 @@ int main(int argc, char** argv)
struct timeval t[3] = {};
// Parse arguments
parse_args(argc, argv);
if (parse_args(argc, argv) < SRSRAN_SUCCESS) {
goto clean_exit;
}
// Initialise buffers
uint32_t size = srate_hz / 1000;
input_buffer = srsran_vec_cf_malloc(size);
output_buffer = srsran_vec_cf_malloc(size);
if (!input_buffer || !output_buffer) {
fprintf(stderr, "Error: Allocating memory\n");
ret = SRSRAN_ERROR;
ERROR("Error: Allocating memory");
goto clean_exit;
}
// Generate random samples
srsran_random_uniform_complex_dist_vector(random_gen, input_buffer, size, -1.0f, +1.0f);
// Initialise delay channel
if (ret == SRSRAN_SUCCESS) {
ret = srsran_channel_delay_init(&delay, delay_min_us, delay_max_us, delay_period_s, delay_init_time_s, srate_hz);
if (srsran_channel_delay_init(&delay, delay_min_us, delay_max_us, delay_period_s, delay_init_time_s, srate_hz) <
SRSRAN_SUCCESS) {
ERROR("Error initialising delay channel");
goto clean_exit;
}
// Run actual test
gettimeofday(&t[1], NULL);
for (int i = 0; i < sim_time_periods && ret == SRSRAN_SUCCESS; i++) {
for (int i = 0; i < sim_time_periods; i++) {
for (int j = 0; j < 1000 * delay_period_s; j++) {
// Run delay channel
srsran_channel_delay_execute(&delay, input_buffer, output_buffer, size, &ts);
@ -116,21 +121,17 @@ int main(int argc, char** argv)
gettimeofday(&t[2], NULL);
get_time_interval(t);
// Free
srsran_random_free(random_gen);
srsran_channel_delay_free(&delay);
if (input_buffer) {
free(input_buffer);
}
if (output_buffer) {
free(output_buffer);
}
uint64_t nof_samples = sim_time_periods * 1000 * delay_period_s * size;
double elapsed_us = t[0].tv_sec * 1e6 + t[0].tv_usec;
double msps = 0;
if (isnormal(elapsed_us)) {
msps = (double)nof_samples / elapsed_us;
ret = SRSRAN_SUCCESS;
} else {
ERROR("Error in Msps calculation: undefined division");
}
// Print result and exit
printf("Test delay_min_us=%d; delay_max_us=%d; delay_period_s=%.1f; srate_hz=%d; periods=%d; %s ... %.1f MSps\n",
delay_min_us,
@ -139,6 +140,19 @@ int main(int argc, char** argv)
srate_hz,
sim_time_periods,
(ret == SRSRAN_SUCCESS) ? "Passed" : "Failed",
(double)nof_samples / elapsed_us);
exit(ret);
msps);
clean_exit:
srsran_random_free(random_gen);
srsran_channel_delay_free(&delay);
if (input_buffer) {
free(input_buffer);
}
if (output_buffer) {
free(output_buffer);
}
return (ret);
}

@ -58,7 +58,7 @@ static void usage(char* prog)
#endif /* ENABLE_GUI */
}
static void parse_args(int argc, char** argv)
static int parse_args(int argc, char** argv)
{
int opt;
while ((opt = getopt(argc, argv, "mtsrg")) != -1) {
@ -82,9 +82,10 @@ static void parse_args(int argc, char** argv)
break;
default:
usage(argv[0]);
exit(-1);
return SRSRAN_ERROR;
}
}
return SRSRAN_SUCCESS;
}
int main(int argc, char** argv)
@ -95,7 +96,16 @@ int main(int argc, char** argv)
struct timeval t[3] = {};
uint64_t time_usec = 0;
parse_args(argc, argv);
#ifdef ENABLE_GUI
cf_t* fft_buffer = NULL;
float* fft_mag = NULL;
float* imp = NULL;
#endif
// Parse arguments
if (parse_args(argc, argv) < SRSRAN_SUCCESS) {
goto clean_exit;
}
srsran_dft_plan_t ifft;
srsran_dft_plan_c(&ifft, srate / 1000, SRSRAN_DFT_BACKWARD);
@ -105,10 +115,7 @@ int main(int argc, char** argv)
plot_real_t plot_h = NULL;
plot_real_t plot_imp = NULL;
srsran_dft_plan_t fft = {};
cf_t* fft_buffer = NULL;
float* fft_mag = NULL;
float* imp = NULL;
srsran_dft_plan_t fft = {};
if (enable_gui) {
sdrgui_init();
@ -216,15 +223,17 @@ int main(int argc, char** argv)
#endif /* ENABLE_GUI */
}
ret = SRSRAN_SUCCESS;
clean_exit:
if (ret) {
printf("Error\n");
// Print results and exit
double msps = 0;
if (time_usec) {
msps = duration_ms * (srate / 1000.0) / (double)time_usec;
printf("Ok ... %.1f MSps\n", msps);
ret = SRSRAN_SUCCESS;
} else {
printf("Ok ... %.1f MSps\n", duration_ms * (srate / 1000.0) / (double)time_usec);
printf("Error in Msps calculation: undefined division\n");
}
clean_exit:
srsran_dft_plan_free(&ifft);
#ifdef ENABLE_GUI

@ -739,3 +739,22 @@ srsran_ssb_patern_t srsran_ssb_pattern_fom_str(const char* str)
return SRSRAN_SSB_PATTERN_INVALID;
}
bool srsran_carrier_nr_equal(const srsran_carrier_nr_t* a, const srsran_carrier_nr_t* b)
{
if (a == NULL || b == NULL) {
return false;
}
bool ret = (a->pci == b->pci);
ret = ret && (a->dl_center_frequency_hz == b->dl_center_frequency_hz);
ret = ret && (a->ul_center_frequency_hz == b->ul_center_frequency_hz);
ret = ret && (a->ssb_center_freq_hz == b->ssb_center_freq_hz);
ret = ret && (a->offset_to_carrier == b->offset_to_carrier);
ret = ret && (a->scs == b->scs);
ret = ret && (a->nof_prb == b->nof_prb);
ret = ret && (a->start == b->start);
ret = ret && (a->max_mimo_layers == b->max_mimo_layers);
return ret;
}

@ -20,6 +20,7 @@
*/
#include "srsran/common/test_common.h"
#include "srsran/phy/common/sliv.h"
#include <srsran/phy/utils/debug.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -47,34 +48,52 @@ static int test()
int main(int argc, char** argv)
{
int ret = SRSRAN_ERROR;
// Parse N
if (argc >= 2) {
N = (uint32_t)strtol(argv[1], NULL, 10);
}
// No input arguments are provided
if (argc <= 1) {
ERROR("Error: too few arguments");
}
// If two arguments, run brute force test
if (argc == 2) {
return test();
else if (argc == 2) {
ret = test();
}
// if three arguments, calculate start and length from sliv
if (argc == 3) {
else if (argc == 3) {
uint32_t sliv = (uint32_t)strtol(argv[2], NULL, 10);
uint32_t S = 0;
uint32_t L = 0;
srsran_sliv_to_s_and_l(N, sliv, &S, &L);
printf("SLIV=%d; Start: %d; Length: %d;\n", sliv, S, L);
return SRSRAN_SUCCESS;
// check that N is not zero to prevent undefined division
if (N) {
srsran_sliv_to_s_and_l(N, sliv, &S, &L);
printf("SLIV=%d; Start: %d; Length: %d;\n", sliv, S, L);
ret = SRSRAN_SUCCESS;
}
else {
ERROR("Error: N cannot be 0 to prevent an undefined division");
}
}
// if four arguments, calculate sliv from start and length
if (argc == 4) {
else if (argc == 4) {
uint32_t s = (uint32_t)strtol(argv[2], NULL, 10);
uint32_t l = (uint32_t)strtol(argv[3], NULL, 10);
uint32_t sliv = srsran_sliv_from_s_and_l(N, s, l);
printf("SLIV=%d; Start: %d; Length: %d;\n", sliv, s, l);
return SRSRAN_SUCCESS;
ret = SRSRAN_SUCCESS;
}
else {
ERROR("Error: too many arguments");
}
return ret;
}

@ -24,10 +24,13 @@
#include "srsran/phy/utils/debug.h"
#include "srsran/phy/utils/primes.h"
#include "srsran/phy/utils/vector.h"
#include <assert.h>
#include <complex.h>
#define NOF_ZC_SEQ 30
// Phi values for M_sc=12 Table 5.5.1.2-1 in TS 36.211
static const float zc_sequence_lte_phi_M_sc_12[30][12] = {
static const float zc_sequence_lte_phi_M_sc_12[NOF_ZC_SEQ][12] = {
{-1, 1, 3, -3, 3, 3, 1, 1, 3, 1, -3, 3}, {1, 1, 3, 3, 3, -1, 1, -3, -3, 1, -3, 3},
{1, 1, -3, -3, -3, -1, -3, -3, 1, -3, 1, -1}, {-1, 1, 1, 1, 1, -1, -3, -3, 1, -3, 3, -1},
{-1, 3, 1, -1, 1, -1, -3, -1, 1, -1, 1, 3}, {1, -3, 3, -1, -1, 1, 1, -1, -1, 3, -3, 1},
@ -45,7 +48,7 @@ static const float zc_sequence_lte_phi_M_sc_12[30][12] = {
{-1, 3, -3, 3, -1, 3, 3, -3, 3, 3, -1, -1}, {3, -3, -3, -1, -1, -3, -1, 3, -3, 3, 1, -1}};
// Phi values for M_sc=24 Table 5.5.1.2-2 in TS 36.211
static const float zc_sequence_lte_phi_M_sc_24[30][24] = {
static const float zc_sequence_lte_phi_M_sc_24[NOF_ZC_SEQ][24] = {
{-1, 3, 1, -3, 3, -1, 1, 3, -3, 3, 1, 3, -3, 3, 1, 1, -1, 1, 3, -3, 3, -3, -1, -3},
{-3, 3, -3, -3, -3, 1, -3, -3, 3, -1, 1, 1, 1, 3, 1, -1, 3, -3, -3, 1, 3, 1, 1, -3},
{3, -1, 3, 3, 1, 1, -3, 3, 3, 3, 3, 1, -1, 3, -1, 1, 1, -1, -3, -1, -1, 1, 3, 3},
@ -78,7 +81,7 @@ static const float zc_sequence_lte_phi_M_sc_24[30][24] = {
{1, 1, -1, -1, -3, -1, 3, -1, 3, -1, 1, 3, 1, -1, 3, 1, 3, -3, -3, 1, -1, -1, 1, 3}};
// Phi values for M_sc=12 Table 5.2.2.2-1 in TS 38.211
static const float zc_sequence_nr_phi_M_sc_6[30][6] = {
static const float zc_sequence_nr_phi_M_sc_6[NOF_ZC_SEQ][6] = {
{-3, -1, 3, 3, -1, -3}, {-3, 3, -1, -1, 3, -3}, {-3, -3, -3, 3, 1, -3}, {1, 1, 1, 3, -1, -3},
{1, 1, 1, -3, -1, 3}, {-3, 1, -1, -3, -3, -3}, {-3, 1, 3, -3, -3, -3}, {-3, -1, 1, -3, 1, -1},
{-3, -1, -3, 1, -3, -3}, {-3, -3, 1, -3, 3, -3}, {-3, 1, 3, 1, -3, -3}, {-3, -1, -3, 1, 1, -3},
@ -89,7 +92,7 @@ static const float zc_sequence_nr_phi_M_sc_6[30][6] = {
{1, 1, -1, 3, -3, -1}, {1, 1, -3, 1, -1, -1}};
// Phi values for M_sc=12 Table 5.2.2.2-2 in TS 38.211
static const float zc_sequence_nr_phi_M_sc_12[30][12] = {
static const float zc_sequence_nr_phi_M_sc_12[NOF_ZC_SEQ][12] = {
{-3, 1, -3, -3, -3, 3, -3, -1, 1, 1, 1, -3}, {-3, 3, 1, -3, 1, 3, -1, -1, 1, 3, 3, 3},
{-3, 3, 3, 1, -3, 3, -1, 1, 3, -3, 3, -3}, {-3, -3, -1, 3, 3, 3, -3, 3, -3, 1, -1, -3},
{-3, -1, -1, 1, 3, 1, 1, -1, 1, -1, -3, 1}, {-3, -3, 3, 1, -3, -3, -3, -1, 3, -1, 1, 3},
@ -107,7 +110,7 @@ static const float zc_sequence_nr_phi_M_sc_12[30][12] = {
{1, -1, 3, 1, 1, -1, -1, -1, 1, 3, -3, 1}, {-3, 3, -3, 3, -3, -3, 3, -1, -1, 1, 3, -3}};
// Phi values for M_sc=18 Table 5.2.2.2-3 in TS 38.211
static const float zc_sequence_nr_phi_M_sc_18[30][18] = {
static const float zc_sequence_nr_phi_M_sc_18[NOF_ZC_SEQ][18] = {
{-1, 3, -1, -3, 3, 1, -3, -1, 3, -3, -1, -1, 1, 1, 1, -1, -1, -1},
{3, -3, 3, -1, 1, 3, -3, -1, -3, -3, -1, -3, 3, 1, -1, 3, -3, 3},
{-3, 3, 1, -1, -1, 3, -3, -1, 1, 1, 1, 1, 1, -1, 3, -1, -3, -1},
@ -140,7 +143,7 @@ static const float zc_sequence_nr_phi_M_sc_18[30][18] = {
{-3, 3, 1, -1, -1, -1, -1, 1, -1, 3, 3, -3, -1, 1, 3, -1, 3, -1}};
// Phi values for M_sc=18 Table 5.2.2.2-3 in TS 38.211
static const float zc_sequence_nr_phi_M_sc_24[30][24] = {
static const float zc_sequence_nr_phi_M_sc_24[NOF_ZC_SEQ][24] = {
{-1, -3, 3, -1, 3, 1, 3, -1, 1, -3, -1, -3, -1, 1, 3, -3, -1, -3, 3, 3, 3, -3, -3, -3},
{-1, -3, 3, 1, 1, -3, 1, -3, -3, 1, -3, -1, -1, 3, -3, 3, 3, 3, -3, 1, 3, 3, -3, -3},
{-1, -3, -3, 1, -1, -1, -3, 1, 3, -1, -3, -1, -1, -3, 1, 1, 3, 1, -3, -1, -1, 3, -3, -3},
@ -174,31 +177,37 @@ static const float zc_sequence_nr_phi_M_sc_24[30][24] = {
static void zc_sequence_lte_r_uv_arg_1prb(uint32_t u, cf_t* tmp_arg)
{
assert(u < NOF_ZC_SEQ);
srsran_vec_sc_prod_fcc(zc_sequence_lte_phi_M_sc_12[u], M_PI_4, tmp_arg, SRSRAN_NRE);
}
static void zc_sequence_lte_r_uv_arg_2prb(uint32_t u, cf_t* tmp_arg)
{
assert(u < NOF_ZC_SEQ);
srsran_vec_sc_prod_fcc(zc_sequence_lte_phi_M_sc_24[u], M_PI_4, tmp_arg, 2 * SRSRAN_NRE);
}
static void zc_sequence_nr_r_uv_arg_0dot5prb(uint32_t u, cf_t* tmp_arg)
{
assert(u < NOF_ZC_SEQ);
srsran_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_6[u], M_PI_4, tmp_arg, SRSRAN_NRE / 2);
}
static void zc_sequence_nr_r_uv_arg_1prb(uint32_t u, cf_t* tmp_arg)
{
assert(u < NOF_ZC_SEQ);
srsran_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_12[u], M_PI_4, tmp_arg, SRSRAN_NRE);
}
static void zc_sequence_nr_r_uv_arg_1dot5prb(uint32_t u, cf_t* tmp_arg)
{
assert(u < NOF_ZC_SEQ);
srsran_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_18[u], M_PI_4, tmp_arg, (3 * SRSRAN_NRE) / 2);
}
static void zc_sequence_nr_r_uv_arg_2prb(uint32_t u, cf_t* tmp_arg)
{
assert(u < NOF_ZC_SEQ);
srsran_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_24[u], M_PI_4, tmp_arg, 2 * SRSRAN_NRE);
}
@ -270,7 +279,7 @@ static int zc_sequence_nr_r_uv_arg(uint32_t M_zc, uint32_t u, uint32_t v, cf_t*
static void zc_sequence_generate(uint32_t M_zc, float alpha, const cf_t* tmp_arg, cf_t* sequence)
{
for (uint32_t i = 0; i < M_zc; i++) {
sequence[i] = cexpf(I * (tmp_arg[i] + alpha * (float)i));
sequence[i] = cexpf(I * (tmp_arg[i] + alpha * (cf_t)i));
}
}

@ -66,11 +66,13 @@ __attribute__((constructor)) static void srsran_dft_load()
}
if (lockf(fileno(fd), F_LOCK, 0) == -1) {
perror("lockf()");
fclose(fd);
return;
}
fftwf_import_wisdom_from_file(fd);
if (lockf(fileno(fd), F_ULOCK, 0) == -1) {
perror("u-lockf()");
fclose(fd);
return;
}
fclose(fd);
@ -91,11 +93,13 @@ __attribute__((destructor)) void srsran_dft_exit()
}
if (lockf(fileno(fd), F_LOCK, 0) == -1) {
perror("lockf()");
fclose(fd);
return;
}
fftwf_export_wisdom_to_file(fd);
if (lockf(fileno(fd), F_ULOCK, 0) == -1) {
perror("u-lockf()");
fclose(fd);
return;
}
fclose(fd);
@ -213,10 +217,11 @@ int srsran_dft_plan_guru_c(srsran_dft_plan_t* plan,
pthread_mutex_lock(&fft_mutex);
plan->p = fftwf_plan_guru_dft(1, &iodim, 1, &howmany_dims, in_buffer, out_buffer, sign, FFTW_TYPE);
pthread_mutex_unlock(&fft_mutex);
if (!plan->p) {
return -1;
}
pthread_mutex_unlock(&fft_mutex);
plan->size = dft_points;
plan->init_size = plan->size;

@ -41,7 +41,7 @@ void usage(char* prog)
printf("Usage: %s [Rv]\n", prog);
printf("\t-R Number of repetitions [Default %d]\n", nof_repetitions);
printf("\t-E Number of encoded bits [Default %d]\n", E);
printf("\t-v increase verbose [Default %d]\n", srsran_verbose);
printf("\t-v increase verbose [Default %d]\n", get_srsran_verbose_level());
}
void parse_args(int argc, char** argv)
@ -56,7 +56,7 @@ void parse_args(int argc, char** argv)
E = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -389,9 +389,8 @@ int update_ldpc_soft_bits_c_avx2_flood(void* p, const int8_t (*these_var_indices
for (i_layer = 0; i_layer < vp->bgM; i_layer++) {
current_var_index = these_var_indices[i_layer][0];
this_check_to_var = vp->check_to_var + i_layer * (vp->hrr + 1);
for (i = 0; (current_var_index != -1) && (i < MAX_CNCT); i++) {
for (i = 1; (current_var_index != -1) && (i < MAX_CNCT); i++) {
i_bit_tmp_base = (current_var_index <= vp->hrr) ? current_var_index : vp->hrr;
tmp_epi8 = _mm256_adds_epi8(this_check_to_var[i_bit_tmp_base], vp->soft_bits.v[current_var_index]);
@ -404,7 +403,7 @@ int update_ldpc_soft_bits_c_avx2_flood(void* p, const int8_t (*these_var_indices
mask_epi8 = _mm256_cmpgt_epi8(neg_infty7_epi8, tmp_epi8);
vp->soft_bits.v[current_var_index] = _mm256_blendv_epi8(tmp_epi8, neg_infty8_epi8, mask_epi8);
current_var_index = these_var_indices[i_layer][i + 1];
current_var_index = these_var_indices[i_layer][i];
}
}

@ -443,7 +443,7 @@ int update_ldpc_soft_bits_c_avx2long_flood(void* p, const int8_t (*these_var_ind
current_var_index = these_var_indices[i_layer][0];
this_check_to_var = vp->check_to_var + i_layer * (vp->hrr + 1) * vp->n_subnodes;
for (i = 0; (current_var_index != -1) && (i < MAX_CNCT); i++) {
for (i = 1; (current_var_index != -1) && (i < MAX_CNCT); i++) {
current_var_index_subnode = current_var_index * vp->n_subnodes;
for (j = 0; j < vp->n_subnodes; j++) {
i_bit_tmp_base = (current_var_index <= vp->hrr) ? current_var_index : vp->hrr;
@ -459,7 +459,7 @@ int update_ldpc_soft_bits_c_avx2long_flood(void* p, const int8_t (*these_var_ind
vp->soft_bits[current_var_index_subnode + j].v = _mm256_blendv_epi8(tmp_epi8, neg_infty8_epi8, mask_epi8);
}
current_var_index = these_var_indices[i_layer][i + 1];
current_var_index = these_var_indices[i_layer][i];
}
}

@ -326,7 +326,7 @@ int update_ldpc_soft_bits_c_flood(void* p, const int8_t (*these_var_indices)[MAX
for (i_layer = 0; i_layer < vp->bgM; i_layer++) {
current_var_index = these_var_indices[i_layer][0];
this_check_to_var = vp->check_to_var + i_layer * (vp->hrrN + vp->ls);
for (i = 0; (current_var_index != -1) && (i < MAX_CNCT); i++) {
for (i = 1; (current_var_index != -1) && (i < MAX_CNCT); i++) {
// recall that current_var_index depends on i!
current_var_index_ext = current_var_index * vp->ls;
for (j = 0; j < vp->ls; j++) {
@ -341,7 +341,7 @@ int update_ldpc_soft_bits_c_flood(void* p, const int8_t (*these_var_indices)[MAX
}
vp->soft_bits[i_bit] = (int8_t)tmp;
}
current_var_index = these_var_indices[i_layer][i + 1];
current_var_index = these_var_indices[i_layer][i];
}
}

@ -69,7 +69,7 @@ static uint8_t rv = 0; /*!< \brief Redundancy version {
static srsran_mod_t mod_type = SRSRAN_MOD_BPSK; /*!< \brief Modulation type: BPSK, QPSK, QAM16, QAM64, QAM256 = 4 */
static uint32_t Nref = 0; /*!< \brief Limited buffer size. */
static float snr = 0; /*!< \brief Signal-to-Noise Ratio [dB]. */
static uint8_t rm_aware = 1; /*!< \brief Flag rate matching aware encoding/decoding (1 to enable). */
static uint8_t rm_aware = 1; /*!< \brief Flag rate matching aware encoding/decoding (1 to enable). */
static int finalK = 0; /*!< \brief Number of uncoded bits (message length, including punctured and filler bits). */
static int finalN = 0; /*!< \brief Number of coded bits (codeword length). */
@ -102,7 +102,7 @@ void usage(char* prog)
/*!
* \brief Parses the input line.
*/
void parse_args(int argc, char** argv)
int parse_args(int argc, char** argv)
{
int opt = 0;
while ((opt = getopt(argc, argv, "b:l:e:f:r:m:w:M:s:B:N:E:")) != -1) {
@ -145,21 +145,24 @@ void parse_args(int argc, char** argv)
break;
default:
usage(argv[0]);
exit(-1);
return SRSRAN_ERROR;
}
}
return SRSRAN_SUCCESS;
}
/*!
* \brief Prints decoder statistics.
*/
void print_decoder(char* title, int n_batches, int n_errors, double elapsed_time);
int print_decoder(char* title, int n_batches, int n_errors, double elapsed_time);
/*!
* \brief Main test function.
*/
int main(int argc, char** argv)
{
int ret = SRSRAN_ERROR;
uint8_t* messages_true = NULL;
uint8_t* messages_sim_f = NULL;
uint8_t* messages_sim_s = NULL;
@ -178,29 +181,68 @@ int main(int argc, char** argv)
int16_t* symbols_s = NULL; // unrm_symbols
int8_t* symbols_c = NULL; // unrm_symbols
// LDPC encoder
srsran_ldpc_encoder_t encoder = {};
// LDPC decoder (8 bit)
srsran_ldpc_decoder_t decoder_c = {};
// LDPC decoder (8 bit, flooded)
srsran_ldpc_decoder_t decoder_c_flood = {};
// LDPC decoder (16 bit)
srsran_ldpc_decoder_t decoder_s = {};
// LDPC decoder (float)
srsran_ldpc_decoder_t decoder_f = {};
#ifdef LV_HAVE_AVX2
// LDPC decoder (8 bit, AVX2 version)
srsran_ldpc_decoder_t decoder_avx = {};
// LDPC decoder (8 bit, flooded scheduling, AVX2 version)
srsran_ldpc_decoder_t decoder_avx_flood = {};
#endif
#ifdef LV_HAVE_AVX512
// LDPC decoder (8 bit, AVX512 version)
srsran_ldpc_decoder_t decoder_avx512 = {};
// LDPC decoder (8 bit, flooded scheduling, AVX512 version)
srsran_ldpc_decoder_t decoder_avx512_flood = {};
#endif
// LDPC rate Matcher
srsran_ldpc_rm_t rm_tx = {};
// LDPC rate DeMatcher
srsran_ldpc_rm_t rm_rx = {};
// LDPC rate DeMatcher (int16_t)
srsran_ldpc_rm_t rm_rx_s = {};
// LDPC rate DeMatcher (int8_t)
srsran_ldpc_rm_t rm_rx_c = {};
// Create a random generator
srsran_random_t random_gen = NULL;
random_gen = srsran_random_init(0);
int i = 0;
int j = 0;
parse_args(argc, argv);
// create an LDPC encoder
srsran_ldpc_encoder_t encoder;
if (parse_args(argc, argv) < SRSRAN_SUCCESS) {
goto clean_exit;
}
#ifdef LV_HAVE_AVX512
if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) {
perror("encoder init");
exit(-1);
goto clean_exit;
}
#else // no AVX512
#ifdef LV_HAVE_AVX2
if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) {
perror("encoder init");
exit(-1);
goto clean_exit;
}
#else // no AVX2
#else // no AVX2
if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_C, base_graph, lift_size) != 0) {
perror("encoder init");
exit(-1);
goto clean_exit;
}
#endif // LV_HAVE_AVX2
#endif // LV_HAVE_AVX512
@ -215,32 +257,28 @@ int main(int argc, char** argv)
Nref = finalN;
}
// create a LDPC rate Matcher
srsran_ldpc_rm_t rm_tx;
// Init the LDPC rate Matcher
if (srsran_ldpc_rm_tx_init(&rm_tx) != 0) {
perror("rate matcher init");
exit(-1);
goto clean_exit;
}
// create a LDPC rate DeMatcher
srsran_ldpc_rm_t rm_rx;
// Init LDPC rate DeMatcher
if (srsran_ldpc_rm_rx_init_f(&rm_rx) != 0) {
perror("rate dematcher init");
exit(-1);
goto clean_exit;
}
// create a LDPC rate DeMatcher (int16_t)
srsran_ldpc_rm_t rm_rx_s;
// Init LDPC rate DeMatcher (int16_t)
if (srsran_ldpc_rm_rx_init_s(&rm_rx_s) != 0) {
perror("rate dematcher init (int16_t)");
exit(-1);
goto clean_exit;
}
// create a LDPC rate DeMatcher (int8_t)
srsran_ldpc_rm_t rm_rx_c;
// Init LDPC rate DeMatcher (int8_t)
if (srsran_ldpc_rm_rx_init_c(&rm_rx_c) != 0) {
perror("rate dematcher init (int8_t)");
exit(-1);
goto clean_exit;
}
// Create LDPC configuration arguments
@ -249,73 +287,62 @@ int main(int argc, char** argv)
decoder_args.ls = lift_size;
decoder_args.scaling_fctr = MS_SF;
// create an LDPC decoder (float)
srsran_ldpc_decoder_t decoder_f;
// Init the LDPC decoder (float)
decoder_args.type = SRSRAN_LDPC_DECODER_F;
if (srsran_ldpc_decoder_init(&decoder_f, &decoder_args) != 0) {
perror("decoder init");
exit(-1);
goto clean_exit;
}
// create an LDPC decoder (16 bit)
srsran_ldpc_decoder_t decoder_s;
// Init the LDPC decoder (16 bit)
decoder_args.type = SRSRAN_LDPC_DECODER_S;
if (srsran_ldpc_decoder_init(&decoder_s, &decoder_args) != 0) {
perror("decoder init (int16_t)");
exit(-1);
goto clean_exit;
}
// create an LDPC decoder (8 bit)
srsran_ldpc_decoder_t decoder_c;
// Init the LDPC decoder (8 bit)
decoder_args.type = SRSRAN_LDPC_DECODER_C;
if (srsran_ldpc_decoder_init(&decoder_c, &decoder_args) != 0) {
perror("decoder init (int8_t)");
exit(-1);
goto clean_exit;
}
// create an LDPC decoder (8 bit, flooded)
srsran_ldpc_decoder_t decoder_c_flood;
// Init the LDPC decoder (8 bit, flooded)
decoder_args.type = SRSRAN_LDPC_DECODER_C_FLOOD;
if (srsran_ldpc_decoder_init(&decoder_c_flood, &decoder_args) != 0) {
perror("decoder init");
exit(-1);
goto clean_exit;
}
#ifdef LV_HAVE_AVX2
// create an LDPC decoder (8 bit, AVX2 version)
srsran_ldpc_decoder_t decoder_avx;
// Init the LDPC decoder (8 bit, AVX2 version)
decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX2;
if (srsran_ldpc_decoder_init(&decoder_avx, &decoder_args) != 0) {
perror("decoder init");
exit(-1);
goto clean_exit;
}
// create an LDPC decoder (8 bit, flooded scheduling, AVX2 version)
srsran_ldpc_decoder_t decoder_avx_flood;
// Init the LDPC decoder (8 bit, flooded scheduling, AVX2 version)
decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX2_FLOOD;
if (srsran_ldpc_decoder_init(&decoder_avx_flood, &decoder_args) != 0) {
perror("decoder init");
exit(-1);
goto clean_exit;
}
#endif // LV_HAVE_AVX2
#ifdef LV_HAVE_AVX512
// create an LDPC decoder (8 bit, AVX2 version)
srsran_ldpc_decoder_t decoder_avx512;
// Init the LDPC decoder (8 bit, AVX512 version)
decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX512;
if (srsran_ldpc_decoder_init(&decoder_avx512, &decoder_args) != 0) {
perror("decoder init");
exit(-1);
goto clean_exit;
}
// create an LDPC decoder (8 bit, flooded scheduling, AVX512 version)
srsran_ldpc_decoder_t decoder_avx512_flood;
// Init LDPC decoder (8 bit, flooded scheduling, AVX512 version)
decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX512_FLOOD;
if (srsran_ldpc_decoder_init(&decoder_avx512_flood, &decoder_args) != 0) {
perror("decoder init");
exit(-1);
goto clean_exit;
}
#endif // LV_HAVE_AVX512
// create a random generator
srsran_random_t random_gen = srsran_random_init(0);
printf("Test LDPC chain:\n");
printf(" Base Graph -> BG%d\n", encoder.bg + 1);
printf(" Lifting Size -> %d\n", encoder.ls);
@ -361,7 +388,7 @@ int main(int argc, char** argv)
!messages_sim_avx512_flood || !codewords || !rm_codewords || !rm_symbols || !rm_symbols_s || !rm_symbols_c ||
!symbols || !symbols_s || !symbols_c) {
perror("malloc");
exit(-1);
goto clean_exit;
}
int i_bit = 0;
@ -488,7 +515,7 @@ int main(int argc, char** argv)
rv,
mod_type,
Nref)) {
exit(-1);
goto clean_exit;
}
}
@ -528,7 +555,7 @@ int main(int argc, char** argv)
rv,
mod_type,
Nref)) {
exit(-1);
goto clean_exit;
}
}
@ -568,7 +595,7 @@ int main(int argc, char** argv)
rv,
mod_type,
Nref) < 0) {
exit(-1);
goto clean_exit;
}
}
@ -711,63 +738,120 @@ int main(int argc, char** argv)
i_batch * batch_size * finalK / elapsed_time_enc,
i_batch * batch_size * finalN / elapsed_time_enc);
print_decoder("FLOATING POINT", i_batch, n_error_words_f, elapsed_time_dec_f);
print_decoder("FIXED POINT (16 bits)", i_batch, n_error_words_s, elapsed_time_dec_s);
print_decoder("FIXED POINT (8 bits)", i_batch, n_error_words_c, elapsed_time_dec_c);
print_decoder("FIXED POINT (8 bits, flooded scheduling)", i_batch, n_error_words_c_flood, elapsed_time_dec_c_flood);
if (print_decoder("FLOATING POINT", i_batch, n_error_words_f, elapsed_time_dec_f) < SRSRAN_SUCCESS) {
goto clean_exit;
}
if (print_decoder("FIXED POINT (16 bits)", i_batch, n_error_words_s, elapsed_time_dec_s) < SRSRAN_SUCCESS) {
goto clean_exit;
}
if (print_decoder("FIXED POINT (8 bits)", i_batch, n_error_words_c, elapsed_time_dec_c) < SRSRAN_SUCCESS) {
goto clean_exit;
}
if (print_decoder(
"FIXED POINT (8 bits, flooded scheduling)", i_batch, n_error_words_c_flood, elapsed_time_dec_c_flood) <
SRSRAN_SUCCESS) {
goto clean_exit;
}
#ifdef LV_HAVE_AVX2
print_decoder("FIXED POINT (8 bits - AVX2)", i_batch, n_error_words_avx, elapsed_time_dec_avx);
print_decoder(
"FIXED POINT (8 bits, flooded scheduling - AVX2)", i_batch, n_error_words_avx_flood, elapsed_time_dec_avx_flood);
if (print_decoder("FIXED POINT (8 bits - AVX2)", i_batch, n_error_words_avx, elapsed_time_dec_avx) < SRSRAN_SUCCESS) {
goto clean_exit;
}
if (print_decoder("FIXED POINT (8 bits, flooded scheduling - AVX2)",
i_batch,
n_error_words_avx_flood,
elapsed_time_dec_avx_flood) < SRSRAN_SUCCESS) {
goto clean_exit;
}
#endif // LV_HAVE_AVX2
#ifdef LV_HAVE_AVX512
print_decoder("FIXED POINT (8 bits - AVX512)", i_batch, n_error_words_avx512, elapsed_time_dec_avx512);
print_decoder("FIXED POINT (8 bits, flooded scheduling - AVX512)",
i_batch,
n_error_words_avx512_flood,
elapsed_time_dec_avx512_flood);
if (print_decoder("FIXED POINT (8 bits - AVX512)", i_batch, n_error_words_avx512, elapsed_time_dec_avx512) <
SRSRAN_SUCCESS) {
goto clean_exit;
}
if (print_decoder("FIXED POINT (8 bits, flooded scheduling - AVX512)",
i_batch,
n_error_words_avx512_flood,
elapsed_time_dec_avx512_flood) < SRSRAN_SUCCESS) {
goto clean_exit;
}
#endif // LV_HAVE_AVX512
if (n_error_words_s > 10 * n_error_words_f) {
perror("16-bit performance too low!");
exit(-1);
goto clean_exit;
}
if (n_error_words_c > 10 * n_error_words_f) {
perror("8-bit performance too low!");
exit(-1);
goto clean_exit;
}
#ifdef LV_HAVE_AVX512
if (n_error_words_avx512 != n_error_words_avx) {
perror("The number of errors AVX512 and AVX2 differs !");
exit(-1);
goto clean_exit;
}
if (n_error_words_avx512_flood != n_error_words_avx_flood) {
perror("The number of errors of flooded AVX512 and AVX2 differs !");
exit(-1);
goto clean_exit;
}
#endif // LV_HAVE_AVX512
printf("\nTest completed successfully!\n\n");
ret = SRSRAN_SUCCESS;
free(symbols);
free(symbols_s);
free(symbols_c);
free(rm_symbols);
free(rm_symbols_s);
free(rm_symbols_c);
free(rm_codewords);
free(codewords);
free(messages_sim_avx);
free(messages_sim_avx_flood);
free(messages_sim_avx512);
free(messages_sim_avx512_flood);
free(messages_sim_c_flood);
free(messages_sim_c);
free(messages_sim_s);
free(messages_sim_f);
free(messages_true);
clean_exit:
if (symbols != NULL) {
free(symbols);
}
if (symbols_s != NULL) {
free(symbols_s);
}
if (symbols_c != NULL) {
free(symbols_c);
}
if (rm_symbols != NULL) {
free(rm_symbols);
}
if (rm_symbols_s != NULL) {
free(rm_symbols_s);
}
if (rm_symbols_c != NULL) {
free(rm_symbols_c);
}
if (rm_codewords != NULL) {
free(rm_codewords);
}
if (codewords != NULL) {
free(codewords);
}
if (messages_sim_avx != NULL) {
free(messages_sim_avx);
}
if (messages_sim_avx_flood != NULL) {
free(messages_sim_avx_flood);
}
if (messages_sim_avx512 != NULL) {
free(messages_sim_avx512);
}
if (messages_sim_avx512_flood != NULL) {
free(messages_sim_avx512_flood);
}
if (messages_sim_c_flood != NULL) {
free(messages_sim_c_flood);
}
if (messages_sim_c != NULL) {
free(messages_sim_c);
}
if (messages_sim_s != NULL) {
free(messages_sim_s);
}
if (messages_sim_f != NULL) {
free(messages_sim_f);
}
if (messages_true != NULL) {
free(messages_true);
}
srsran_random_free(random_gen);
#ifdef LV_HAVE_AVX2
srsran_ldpc_decoder_free(&decoder_avx);
@ -786,15 +870,23 @@ int main(int argc, char** argv)
srsran_ldpc_rm_rx_free_f(&rm_rx);
srsran_ldpc_rm_rx_free_s(&rm_rx_s);
srsran_ldpc_rm_rx_free_c(&rm_rx_c);
return ret;
}
void print_decoder(char* title, int n_batches, int n_errors, double elapsed_time)
int print_decoder(char* title, int n_batches, int n_errors, double elapsed_time)
{
printf("\n**** %s ****", title);
printf("\nEstimated word error rate:\n %e (%d errors)\n", (double)n_errors / n_batches / batch_size, n_errors);
printf("Estimated throughput decoder:\n %e word/s\n %e bit/s (information)\n %e bit/s (encoded)\n",
n_batches * batch_size / elapsed_time,
n_batches * batch_size * finalK / elapsed_time,
n_batches * batch_size * finalN / elapsed_time);
if (!isnormal(elapsed_time)) {
printf("\nError: elapsed time is not a valid number\n");
return SRSRAN_ERROR;
} else {
printf("\nEstimated word error rate:\n %e (%d errors)\n", (double)n_errors / n_batches / batch_size, n_errors);
printf("Estimated throughput decoder:\n %e word/s\n %e bit/s (information)\n %e bit/s (encoded)\n",
n_batches * batch_size / elapsed_time,
n_batches * batch_size * finalK / elapsed_time,
n_batches * batch_size * finalN / elapsed_time);
return SRSRAN_SUCCESS;
}
}

@ -91,7 +91,7 @@ void srsran_polar_chanalloc_rx(const uint8_t* output_decoder,
uint16_t i_o = 0;
uint16_t iPC = 0;
uint16_t iK = 0;
for (uint16_t iKPC = 0; iKPC < K + (uint16_t)nPC; iKPC++) {
for (uint16_t iKPC = 0; iKPC < (uint16_t)(K + nPC); iKPC++) {
i_o = K_set[iKPC]; // includes parity bits
if (i_o == PC_set[iPC]) { // skip
iPC = iPC + 1;

@ -124,7 +124,7 @@ int get_code_params(srsran_polar_code_t* c, const uint16_t K, const uint16_t E,
// number of parity check bits (nPC) and parity check bits of minimum bandwidth nWmPC
uint8_t nPC = 0;
uint8_t nWmPC = 0;
if (K >= 18 && K <= 25) {
if (K <= 25) {
nPC = 3;
if (E > K + 189) {
nWmPC = 1;

@ -140,7 +140,7 @@ int compute_node_type(void* p,
}
uint16_t code_stage_size = 0;
uint16_t code_size_log_s = 0;
for (s = 1; s < code_size_log + 1; s++) {
for (s = 1; s < (uint8_t)(code_size_log + 1); s++) {
code_size_log_s = code_size_log - s;
code_stage_size = (1U << code_size_log_s);
for (uint16_t j = 0; j < code_stage_size; j++) {

@ -62,7 +62,7 @@ void parse_args(int argc, char** argv)
seed = (uint32_t)strtoul(argv[optind], NULL, 0);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);
@ -96,7 +96,7 @@ int main(int argc, char** argv)
data[i] = rand() % 2;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) {
INFO("data=");
srsran_vec_fprint_b(stdout, data, num_bits);
}

@ -44,7 +44,7 @@ void parse_args(int argc, char** argv)
long_cb = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -103,7 +103,7 @@ void parse_args(int argc, char** argv)
seed = (uint32_t)strtoul(argv[optind], NULL, 0);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -26,7 +26,7 @@
#include "srsran/phy/io/filesink.h"
int srsran_filesink_init(srsran_filesink_t* q, char* filename, srsran_datatype_t type)
int srsran_filesink_init(srsran_filesink_t* q, const char* filename, srsran_datatype_t type)
{
bzero(q, sizeof(srsran_filesink_t));
q->f = fopen(filename, "w");

@ -54,7 +54,7 @@ void parse_args(int argc, char** argv)
nof_frames = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
case 'm':
switch (strtol(argv[optind], NULL, 10)) {

@ -312,7 +312,7 @@ int srsran_cqi_value_tostring(srsran_cqi_cfg_t* cfg, srsran_cqi_value_t* value,
ret = cqi_hl_subband_tostring(cfg, &value->subband_hl, buff, buff_len);
break;
default:
/* Do nothing */;
/* Do nothing */;
}
return ret;
@ -532,7 +532,8 @@ static bool ri_send(uint32_t I_cqi_pmi, uint32_t I_ri, uint32_t tti, bool is_fdd
static int cqi_hl_get_subband_size(int nof_prb)
{
if (nof_prb < 7) {
return 0;
ERROR("Error: nof_prb is invalid (< 7)");
return SRSRAN_ERROR;
} else if (nof_prb <= 26) {
return 4;
} else if (nof_prb <= 63) {
@ -540,7 +541,8 @@ static int cqi_hl_get_subband_size(int nof_prb)
} else if (nof_prb <= 110) {
return 8;
} else {
return -1;
ERROR("Error: nof_prb is invalid (> 110)");
return SRSRAN_ERROR;
}
}
@ -550,7 +552,8 @@ static int cqi_hl_get_subband_size(int nof_prb)
static int cqi_hl_get_bwp_J(int nof_prb)
{
if (nof_prb < 7) {
return 0;
ERROR("Error: nof_prb is not valid (< 7)");
return SRSRAN_ERROR;
} else if (nof_prb <= 10) {
return 1;
} else if (nof_prb <= 26) {
@ -560,7 +563,8 @@ static int cqi_hl_get_bwp_J(int nof_prb)
} else if (nof_prb <= 110) {
return 4;
} else {
return -1;
ERROR("Error: nof_prb is not valid (> 110)");
return SRSRAN_ERROR;
}
}
@ -568,12 +572,20 @@ static int cqi_hl_get_bwp_J(int nof_prb)
*/
static int cqi_sb_get_Nj(uint32_t j, uint32_t nof_prb)
{
uint32_t J = cqi_hl_get_bwp_J(nof_prb);
// from Table 7.2.2-2 in TS 36.213
int J = cqi_hl_get_bwp_J(nof_prb);
int K = cqi_hl_get_subband_size(nof_prb);
// Catch the J and k errors, and prevent undefined modulo operations
if (J <= 0 || K <= 0) {
return 0;
}
if (J == 1) {
return (uint32_t)ceil((float)nof_prb / cqi_hl_get_subband_size(nof_prb));
return (uint32_t)ceil((float)nof_prb / K);
} else {
// all bw parts have the same number of subbands except the last one
uint32_t Nj = (uint32_t)ceil((float)nof_prb / cqi_hl_get_subband_size(nof_prb) / J);
uint32_t Nj = (uint32_t)ceil((float)nof_prb / K / J);
if (j < J - 1) {
return Nj;
} else {
@ -617,6 +629,13 @@ uint32_t cqi_sb_get_H(const srsran_cqi_report_cfg_t* cfg, uint32_t nof_prb)
{
uint32_t K = cfg->subband_wideband_ratio;
uint32_t J = cqi_hl_get_bwp_J(nof_prb);
// Catch the J errors
if (J <= 0)
{
return 0;
}
uint32_t H = J * K + 1;
return H;
}
@ -650,9 +669,15 @@ uint32_t srsran_cqi_periodic_sb_bw_part_idx(const srsran_cqi_report_cfg_t* cfg,
}
}
assert(N_p != 0);
uint32_t x = ((tti - N_offset) / N_p) % H;
if (x > 0) {
return (x - 1) % cqi_hl_get_bwp_J(nof_prb);
int J = cqi_hl_get_bwp_J(nof_prb);
// Catch the J errors and prevent undefined modulo operation
if (J <= 0) {
return 0;
}
return (x - 1) % J;
} else {
return 0;
}

@ -319,9 +319,7 @@ static int dci_nr_format_0_0_unpack(const srsran_dci_nr_t* q, srsran_dci_msg_nr_
// Frequency domain resource assignment
uint32_t N = dci_nr_freq_resource_size_type1(N_UL_BWP_RB);
if (N < N_UL_hop) {
return SRSRAN_ERROR;
}
dci->freq_domain_assigment = srsran_bit_pack(&y, N - N_UL_hop - trim);
// Time domain resource assignment 4 bits
@ -1027,8 +1025,8 @@ static int dci_nr_format_1_0_pack(const srsran_dci_nr_t* q, const srsran_dci_dl_
srsran_rnti_type_t rnti_type = msg->ctx.rnti_type;
srsran_search_space_type_t ss_type = dci->ctx.ss_type;
uint32_t N_DL_BWP_RB = SRSRAN_SEARCH_SPACE_IS_COMMON(ss_type)
? (q->cfg.coreset0_bw == 0) ? q->cfg.bwp_dl_initial_bw : q->cfg.coreset0_bw
: q->cfg.bwp_dl_active_bw;
? (q->cfg.coreset0_bw == 0) ? q->cfg.bwp_dl_initial_bw : q->cfg.coreset0_bw
: q->cfg.bwp_dl_active_bw;
// Identifier for DCI formats 1 bits
if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) {
@ -1133,8 +1131,8 @@ static int dci_nr_format_1_0_unpack(const srsran_dci_nr_t* q, srsran_dci_msg_nr_
srsran_rnti_type_t rnti_type = msg->ctx.rnti_type;
srsran_search_space_type_t ss_type = msg->ctx.ss_type;
uint32_t N_DL_BWP_RB = SRSRAN_SEARCH_SPACE_IS_COMMON(ss_type)
? (q->cfg.coreset0_bw == 0) ? q->cfg.bwp_dl_initial_bw : q->cfg.coreset0_bw
: q->cfg.bwp_dl_active_bw;
? (q->cfg.coreset0_bw == 0) ? q->cfg.bwp_dl_initial_bw : q->cfg.coreset0_bw
: q->cfg.bwp_dl_active_bw;
uint32_t nof_bits = srsran_dci_nr_size(q, ss_type, srsran_dci_format_nr_1_0);
if (msg->nof_bits != nof_bits) {

@ -231,7 +231,7 @@ pbch_nr_pbch_msg_pack(const srsran_pbch_nr_cfg_t* cfg, const srsran_pbch_msg_nr_
a[G[13]] = 0; // Reserved
}
if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PBCH_NR_DEBUG_TX("Packed PBCH bits: ");
srsran_vec_fprint_byte(stdout, a, PBCH_NR_A);
}
@ -239,7 +239,7 @@ pbch_nr_pbch_msg_pack(const srsran_pbch_nr_cfg_t* cfg, const srsran_pbch_msg_nr_
static void
pbch_nr_pbch_msg_unpack(const srsran_pbch_nr_cfg_t* cfg, const uint8_t a[PBCH_NR_A], srsran_pbch_msg_nr_t* msg)
{
if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PBCH_NR_DEBUG_RX("Packed PBCH bits: ");
srsran_vec_fprint_byte(stdout, a, PBCH_NR_A);
}
@ -339,7 +339,7 @@ static int pbch_nr_polar_encode(srsran_pbch_nr_t* q, const uint8_t c[PBCH_NR_K],
return SRSRAN_ERROR;
}
if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PBCH_NR_DEBUG_TX("Allocated: ");
srsran_vec_fprint_byte(stdout, allocated, PBCH_NR_N);
}
@ -356,7 +356,7 @@ static int pbch_nr_polar_decode(srsran_pbch_nr_t* q, const int8_t d[PBCH_NR_N],
return SRSRAN_ERROR;
}
if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PBCH_NR_DEBUG_RX("Allocated: ");
srsran_vec_fprint_byte(stdout, allocated, PBCH_NR_N);
}
@ -378,7 +378,7 @@ static int pbch_nr_polar_rm_tx(srsran_pbch_nr_t* q, const uint8_t d[PBCH_NR_N],
return SRSRAN_ERROR;
}
if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PBCH_NR_DEBUG_TX("d: ");
srsran_vec_fprint_byte(stdout, d, PBCH_NR_N);
}
@ -398,7 +398,7 @@ static int pbch_nr_polar_rm_rx(srsran_pbch_nr_t* q, const int8_t llr[PBCH_NR_E],
d[i] *= -1;
}
if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PBCH_NR_DEBUG_RX("d: ");
srsran_vec_fprint_bs(stdout, d, PBCH_NR_N);
}
@ -506,7 +506,7 @@ pbch_nr_mapping(const srsran_pbch_nr_cfg_t* cfg, const cf_t symbols[PBCH_NR_M],
ssb_grid[3 * SRSRAN_SSB_BW_SUBC + k] = symbols[count++];
}
// if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
// if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
// PBCH_NR_DEBUG_TX("Symbols: ");
// srsran_vec_fprint_c(stdout, symbols, PBCH_NR_M);
// }
@ -558,7 +558,7 @@ pbch_nr_demapping(const srsran_pbch_nr_cfg_t* cfg, const cf_t ssb_grid[SRSRAN_SS
symbols[count++] = ssb_grid[3 * SRSRAN_SSB_BW_SUBC + k];
}
// if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
// if (srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
// PBCH_NR_DEBUG_RX("Symbols: ");
// srsran_vec_fprint_c(stdout, symbols, PBCH_NR_M);
// }

@ -330,9 +330,9 @@ static int pdcch_nr_cce_to_reg_mapping_non_interleaved(const srsran_coreset_t*
const srsran_dci_location_t* dci_location,
bool rb_mask[SRSRAN_MAX_PRB_NR])
{
uint32_t nof_cce = 1U << dci_location->L;
uint32_t L = 6;
uint32_t nof_reg_bundle = 6 / L;
uint32_t nof_cce = 1U << dci_location->L;
uint32_t L = 6;
uint32_t nof_reg_bundle = 6 / L;
// For each CCE j in the PDCCH transmission
for (uint32_t j = dci_location->ncce; j < dci_location->ncce + nof_cce; j++) {
@ -373,8 +373,8 @@ static int pdcch_nr_cce_to_reg_mapping_interleaved(const srsran_coreset_t*
return 0;
}
uint32_t nof_cce = 1U << dci_location->L;
uint32_t nof_reg_bundle = 6 / L;
uint32_t nof_cce = 1U << dci_location->L;
uint32_t nof_reg_bundle = 6 / L;
// For each CCE j in the PDCCH transmission
for (uint32_t j = dci_location->ncce; j < dci_location->ncce + nof_cce; j++) {
@ -530,7 +530,7 @@ int srsran_pdcch_nr_encode(srsran_pdcch_nr_t* q, const srsran_dci_msg_nr_t* dci_
srsran_polar_interleaver_run_u8(c, c_prime, q->K, true);
// Print c and c_prime (after interleaving)
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) {
PDCCH_INFO_TX("c=");
srsran_vec_fprint_hex(stdout, c, q->K);
PDCCH_INFO_TX("c_prime=");
@ -546,7 +546,7 @@ int srsran_pdcch_nr_encode(srsran_pdcch_nr_t* q, const srsran_dci_msg_nr_t* dci_
}
// Print d
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) {
PDCCH_INFO_TX("d=");
srsran_vec_fprint_byte(stdout, q->d, q->code.N);
}
@ -573,7 +573,7 @@ int srsran_pdcch_nr_encode(srsran_pdcch_nr_t* q, const srsran_dci_msg_nr_t* dci_
q->meas_time_us = (uint32_t)t[0].tv_usec;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) {
char str[128] = {};
srsran_pdcch_nr_info(q, NULL, str, sizeof(str));
PDCCH_INFO_TX("%s", str);
@ -622,7 +622,7 @@ int srsran_pdcch_nr_decode(srsran_pdcch_nr_t* q,
}
// Print channel estimates if enabled
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PDCCH_DEBUG_RX("ce=");
srsran_vec_fprint_c(stdout, ce->ce, q->M);
}
@ -631,7 +631,7 @@ int srsran_pdcch_nr_decode(srsran_pdcch_nr_t* q,
srsran_predecoding_single(q->symbols, ce->ce, q->symbols, NULL, q->M, 1.0f, ce->noise_var);
// Print symbols if enabled
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PDCCH_DEBUG_RX("symbols=");
srsran_vec_fprint_c(stdout, q->symbols, q->M);
}
@ -662,7 +662,7 @@ int srsran_pdcch_nr_decode(srsran_pdcch_nr_t* q,
}
// Print d
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
PDCCH_DEBUG_RX("d=");
srsran_vec_fprint_bs(stdout, d, q->K);
}
@ -685,7 +685,7 @@ int srsran_pdcch_nr_decode(srsran_pdcch_nr_t* q,
srsran_polar_interleaver_run_u8(c_prime, c, q->K, false);
// Print c
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) {
PDCCH_INFO_RX("c_prime=");
srsran_vec_fprint_hex(stdout, c_prime, q->K);
PDCCH_INFO_RX("c=");
@ -706,7 +706,7 @@ int srsran_pdcch_nr_decode(srsran_pdcch_nr_t* q,
uint32_t checksum2 = srsran_bit_pack(&ptr, 24);
res->crc = checksum1 == checksum2;
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) {
PDCCH_INFO_RX("CRC={%06x, %06x}; msg=", checksum1, checksum2);
srsran_vec_fprint_hex(stdout, c, dci_msg->nof_bits);
}
@ -720,7 +720,7 @@ int srsran_pdcch_nr_decode(srsran_pdcch_nr_t* q,
q->meas_time_us = (uint32_t)t[0].tv_usec;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) {
char str[128] = {};
srsran_pdcch_nr_info(q, res, str, sizeof(str));
PDCCH_INFO_RX("%s", str);

@ -330,7 +330,7 @@ static inline int pdsch_nr_encode_codeword(srsran_pdsch_nr_t* q,
return SRSRAN_ERROR;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("b=");
srsran_vec_fprint_b(stdout, q->b[tb->cw_idx], tb->nof_bits);
}
@ -342,7 +342,7 @@ static inline int pdsch_nr_encode_codeword(srsran_pdsch_nr_t* q,
// 7.3.1.2 Modulation
srsran_mod_modulate(&q->modem_tables[tb->mod], q->b[tb->cw_idx], q->d[tb->cw_idx], tb->nof_bits);
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("d=");
srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re);
}
@ -446,7 +446,7 @@ static inline int pdsch_nr_decode_codeword(srsran_pdsch_nr_t* q,
return SRSRAN_ERROR_OUT_OF_BOUNDS;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("d=");
srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re);
}
@ -469,7 +469,7 @@ static inline int pdsch_nr_decode_codeword(srsran_pdsch_nr_t* q,
// Descrambling
srsran_sequence_apply_c(llr, llr, tb->nof_bits, pdsch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx));
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("b=");
srsran_vec_fprint_b(stdout, q->b[tb->cw_idx], tb->nof_bits);
}
@ -525,7 +525,7 @@ int srsran_pdsch_nr_decode(srsran_pdsch_nr_t* q,
return SRSRAN_ERROR;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("ce=");
srsran_vec_fprint_c(stdout, channel->ce[0][0], nof_re);
DEBUG("x=");

@ -195,11 +195,6 @@ int srsran_phich_decode(srsran_phich_t* q,
uint32_t sf_idx = sf->tti % 10;
if (sf_idx >= SRSRAN_NOF_SF_X_FRAME) {
ERROR("Invalid nslot %d", sf_idx);
return SRSRAN_ERROR_INVALID_INPUTS;
}
if (SRSRAN_CP_ISEXT(q->cell.cp)) {
if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) {
ERROR("Invalid nseq %d", n_phich.nseq);
@ -328,11 +323,6 @@ int srsran_phich_encode(srsran_phich_t* q,
uint32_t sf_idx = sf->tti % 10;
if (sf_idx >= SRSRAN_NOF_SF_X_FRAME) {
ERROR("Invalid nslot %d", sf_idx);
return SRSRAN_ERROR_INVALID_INPUTS;
}
if (SRSRAN_CP_ISEXT(q->cell.cp)) {
if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) {
ERROR("Invalid nseq %d", n_phich.nseq);

@ -291,9 +291,7 @@ int srsran_pmch_decode(srsran_pmch_t* q,
cf_t* sf_symbols[SRSRAN_MAX_PORTS],
srsran_pdsch_res_t* out)
{
/* Set pointers for layermapping & precoding */
uint32_t i, n;
cf_t* x[SRSRAN_MAX_LAYERS];
if (q != NULL && sf_symbols != NULL && out != NULL && cfg != NULL) {
INFO("Decoding PMCH SF: %d, MBSFN area ID: 0x%x, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d, "
@ -308,12 +306,6 @@ int srsran_pmch_decode(srsran_pmch_t* q,
cfg->pdsch_cfg.grant.nof_prb,
sf->cfi);
/* number of layers equals number of ports */
for (i = 0; i < q->cell.nof_ports; i++) {
x[i] = q->x[i];
}
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports));
uint32_t lstart = SRSRAN_NOF_CTRL_SYMBOLS(q->cell, sf->cfi);
for (int j = 0; j < q->nof_rx_antennas; j++) {
/* extract symbols */
@ -384,6 +376,7 @@ int srsran_pmch_decode(srsran_pmch_t* q,
void srsran_configure_pmch(srsran_pmch_cfg_t* pmch_cfg, srsran_cell_t* cell, srsran_mbsfn_cfg_t* mbsfn_cfg)
{
pmch_cfg->area_id = 1;
pmch_cfg->pdsch_cfg.rnti = SRSRAN_MRNTI;
pmch_cfg->pdsch_cfg.grant.nof_layers = 1;
pmch_cfg->pdsch_cfg.grant.nof_prb = cell->nof_prb;
pmch_cfg->pdsch_cfg.grant.tb[0].mcs_idx = mbsfn_cfg->mbsfn_mcs;
@ -410,9 +403,7 @@ int srsran_pmch_encode(srsran_pmch_t* q,
cf_t* sf_symbols[SRSRAN_MAX_PORTS])
{
int i;
/* Set pointers for layermapping & precoding */
cf_t* x[SRSRAN_MAX_LAYERS];
int ret = SRSRAN_ERROR_INVALID_INPUTS;
int ret = SRSRAN_ERROR_INVALID_INPUTS;
if (q != NULL && cfg != NULL) {
for (i = 0; i < q->cell.nof_ports; i++) {
if (sf_symbols[i] == NULL) {
@ -440,12 +431,6 @@ int srsran_pmch_encode(srsran_pmch_t* q,
cfg->pdsch_cfg.grant.tb[0].nof_bits,
0);
/* number of layers equals number of ports */
for (i = 0; i < q->cell.nof_ports; i++) {
x[i] = q->x[i];
}
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports));
// TODO: use tb_encode directly
if (srsran_dlsch_encode(&q->dl_sch, &cfg->pdsch_cfg, data, q->e)) {
ERROR("Error encoding TB");

@ -652,7 +652,7 @@ static int pucch_nr_format2_decode(srsran_pucch_nr_t* q,
}
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO && !is_handler_registered()) {
INFO("d=");
srsran_vec_fprint_c(stdout, q->d, resource->nof_symbols * resource->nof_prb * (SRSRAN_NRE - 4));
INFO("ce=");

@ -565,7 +565,7 @@ static int pusch_nr_gen_mux_uci(srsran_pusch_nr_t* q, const srsran_uci_cfg_nr_t*
}
// Print debug information if configured for ity
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
if (m_ulsch_count != 0) {
DEBUG("UL-SCH bit positions:");
srsran_vec_fprint_i(stdout, (int*)pos_ulsch, m_ulsch_count);
@ -671,7 +671,7 @@ static inline int pusch_nr_encode_codeword(srsran_pusch_nr_t* q,
}
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("b=");
srsran_vec_fprint_b(stdout, b, nof_bits);
}
@ -697,7 +697,7 @@ static inline int pusch_nr_encode_codeword(srsran_pusch_nr_t* q,
// 7.3.1.2 Modulation
srsran_mod_modulate(&q->modem_tables[tb->mod], q->b[tb->cw_idx], q->d[tb->cw_idx], nof_bits);
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("d=");
srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re);
}
@ -803,7 +803,7 @@ static inline int pusch_nr_decode_codeword(srsran_pusch_nr_t* q,
return SRSRAN_ERROR_OUT_OF_BOUNDS;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("d=");
srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re);
}
@ -851,7 +851,7 @@ static inline int pusch_nr_decode_codeword(srsran_pusch_nr_t* q,
// Descrambling
srsran_sequence_apply_c(llr, llr, nof_bits, pusch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx));
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("b=");
srsran_vec_fprint_bs(stdout, llr, nof_bits);
}
@ -977,7 +977,7 @@ int srsran_pusch_nr_decode(srsran_pusch_nr_t* q,
return SRSRAN_ERROR;
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("ce=");
srsran_vec_fprint_c(stdout, channel->ce[0][0], nof_re);
DEBUG("x=");

@ -152,7 +152,7 @@ int srsran_ra_ul_nr_time(const srsran_sch_hl_cfg_nr_t* cfg,
// Row 1
if (cfg->nof_common_time_ra == 0) {
srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant);
} else if (m < SRSRAN_MAX_NOF_TIME_RA && m < cfg->nof_common_time_ra) {
} else if (m < cfg->nof_common_time_ra) {
ra_ul_nr_time_hl(&cfg->common_time_ra[m], grant);
} else {
ERROR("Time domain resource selection (m=%d) exceeds the maximum value (%d)",
@ -165,7 +165,7 @@ int srsran_ra_ul_nr_time(const srsran_sch_hl_cfg_nr_t* cfg,
// Row 2
if (cfg->nof_common_time_ra == 0) {
srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant);
} else if (m < SRSRAN_MAX_NOF_TIME_RA) {
} else {
ra_ul_nr_time_hl(&cfg->common_time_ra[m], grant);
}
} else if ((rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_mcs_c ||

@ -463,7 +463,7 @@ static inline int sch_nr_encode(srsran_sch_nr_t* q,
// Calculate TB CRC
uint32_t checksum_tb = srsran_crc_checksum_byte(crc_tb, data, tb->tbs);
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("tb=");
srsran_vec_fprint_byte(stdout, data, tb->tbs / 8);
}
@ -498,7 +498,7 @@ static inline int sch_nr_encode(srsran_sch_nr_t* q,
srsran_bit_unpack_vector(input_ptr, q->temp_cb, (int)cb_len);
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("cb%d=", r);
srsran_vec_fprint_byte(stdout, input_ptr, cb_len / 8);
}
@ -519,7 +519,7 @@ static inline int sch_nr_encode(srsran_sch_nr_t* q,
// Encode code block
srsran_ldpc_encoder_encode(encoder, q->temp_cb, rm_buffer, cfg.Kr);
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("encoded=");
srsran_vec_fprint_b(stdout, rm_buffer, encoder->liftN - 2 * encoder->ls);
}
@ -677,7 +677,7 @@ static int sch_nr_decode(srsran_sch_nr_t* q,
SCH_INFO_RX("CB %d/%d iter=%d CRC=%s", r, cfg.C, n_iter_cb, tb->softbuffer.rx->cb_crc[r] ? "OK" : "KO");
// CB Debug trace
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("CB %d/%d:", r, cfg.C);
srsran_vec_fprint_hex(stdout, q->temp_cb, cb_len);
}
@ -740,7 +740,7 @@ static int sch_nr_decode(srsran_sch_nr_t* q,
SCH_INFO_RX("TB: TBS=%d; CRC={%06x, %06x}", tb->tbs, checksum1, checksum2);
}
if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) {
if (SRSRAN_DEBUG_ENABLED && get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG && !is_handler_registered()) {
DEBUG("Decode: ");
srsran_vec_fprint_byte(stdout, res->payload, tb->tbs / 8);
}

@ -39,7 +39,7 @@ void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "cpndv")) != -1) {
switch (opt) {
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -374,7 +374,7 @@ static void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "vR")) != -1) {
switch (opt) {
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
case 'R':
nof_repetitions = (uint32_t)strtol(argv[optind], NULL, 10);

@ -87,7 +87,7 @@ static void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "vR")) != -1) {
switch (opt) {
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
case 'R':
nof_repetitions = (uint32_t)strtol(argv[optind], NULL, 10);

@ -92,7 +92,7 @@ void parse_args(int argc, char** argv)
sf_idx = (int)(strtol(argv[optind], NULL, 10) % 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
case 'r':
nf = (int)strtol(argv[optind], NULL, 10);

@ -58,7 +58,7 @@ void parse_args(int argc, char** argv)
cell.base.id = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -92,7 +92,7 @@ void parse_args(int argc, char** argv)
tti = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -74,7 +74,7 @@ void parse_args(int argc, char** argv)
}
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

@ -126,7 +126,7 @@ void parse_args(int argc, char** argv)
snr = strtof(argv[optind], NULL);
break;
case 'v':
srsran_verbose++;
increase_srsran_verbose_level();
break;
default:
usage(argv[0]);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save