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 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 ## 21.04
* Rename project from srsLTE to srsRAN * Rename project from srsLTE to srsRAN
* Add initial 5G NSA support to srsUE (including x86-optimized FEC and PHY layer) * 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_MAJOR 21)
SET(SRSRAN_VERSION_MINOR 04) SET(SRSRAN_VERSION_MINOR 10)
SET(SRSRAN_VERSION_PATCH 0) SET(SRSRAN_VERSION_PATCH 0)
SET(SRSRAN_VERSION_STRING "${SRSRAN_VERSION_MAJOR}.${SRSRAN_VERSION_MINOR}.${SRSRAN_VERSION_PATCH}") SET(SRSRAN_VERSION_STRING "${SRSRAN_VERSION_MAJOR}.${SRSRAN_VERSION_MINOR}.${SRSRAN_VERSION_PATCH}")
SET(SRSRAN_SOVERSION 0) SET(SRSRAN_SOVERSION 0)

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

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

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

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

@ -198,7 +198,7 @@ static void parse_args(int argc, char** argv)
mbsfn_area_id = (int)strtol(argv[optind], NULL, 10); mbsfn_area_id = (int)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
case 's': case 's':
output_file_snr = strtof(argv[optind], NULL); 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; args->disable_plots_except_constellation = true;
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
args->verbose = srsran_verbose; args->verbose = get_srsran_verbose_level();
break; break;
case 'Z': case 'Z':
args->decimate = (int)strtol(argv[optind], NULL, 10); args->decimate = (int)strtol(argv[optind], NULL, 10);
@ -699,12 +699,12 @@ int main(int argc, char** argv)
to.tv_usec = 0; to.tv_usec = 0;
/* Set default verbose level */ /* Set default verbose level */
srsran_verbose = prog_args.verbose; set_srsran_verbose_level(prog_args.verbose);
int n = select(1, &set, NULL, NULL, &to); int n = select(1, &set, NULL, NULL, &to);
if (n == 1) { if (n == 1) {
/* If a new line is detected set verbose level to Debug */ /* If a new line is detected set verbose level to Debug */
if (fgets(input, sizeof(input), stdin)) { if (fgets(input, sizeof(input), stdin)) {
srsran_verbose = SRSRAN_VERBOSE_DEBUG; set_srsran_verbose_level(SRSRAN_VERBOSE_DEBUG);
pkt_errors = 0; pkt_errors = 0;
pkt_total = 0; pkt_total = 0;
nof_detected = 0; nof_detected = 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); args->nof_rx_antennas = (int32_t)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
case 'w': case 'w':
args->disable_plots = true; args->disable_plots = true;
@ -341,7 +341,7 @@ int main(int argc, char** argv)
// PSCCH Channel estimation // PSCCH Channel estimation
srsran_chest_sl_cfg_t pscch_chest_sl_cfg = {}; srsran_chest_sl_cfg_t pscch_chest_sl_cfg = {};
srsran_chest_sl_t pscch_chest = {}; 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"); ERROR("Error in chest PSCCH init");
return SRSRAN_ERROR; 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_cfg_t pssch_chest_sl_cfg = {};
srsran_chest_sl_t pssch_chest = {}; 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"); ERROR("Error in chest PSSCH init");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }

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

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

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

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

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

@ -932,6 +932,17 @@ public:
return *this; 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 // packers / unpackers
SRSASN_CODE pack(bit_ref& bref) const SRSASN_CODE pack(bit_ref& bref) const
{ {

@ -58,6 +58,11 @@ struct phy_cfg_nr_t {
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 * @brief Computes the DCI configuration for the current UE configuration
*/ */

@ -33,7 +33,7 @@ class rlc_pcap
public: public:
rlc_pcap() {} rlc_pcap() {}
void enable(bool en); 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 close();
void set_ue_id(uint16_t ue_id); void set_ue_id(uint16_t ue_id);

@ -45,9 +45,9 @@ public:
virtual void add_user(uint16_t rnti) = 0; virtual void add_user(uint16_t rnti) = 0;
virtual void rem_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 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 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_integrity(uint16_t rnti, uint32_t lcid) = 0;
virtual void enable_encryption(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; 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; 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 * @brief Signal release of all UE resources on the NR cell
* *

@ -93,7 +93,7 @@ public:
virtual void rem_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 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 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 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_integrity(uint16_t rnti, uint32_t lcid) = 0;
virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0; virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0;
}; };
@ -203,7 +203,7 @@ class mac_interface_phy_nr
{ {
public: public:
const static int MAX_SSB = 4; 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_MSG = 64;
const static int MAX_PUCCH_CANDIDATES = 2; const static int MAX_PUCCH_CANDIDATES = 2;
const static int MAX_NZP_CSI_RS = 4; 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 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 user_release(uint16_t rnti, asn1::ngap_nr::cause_radio_network_e cause_radio) = 0;
virtual bool is_amf_connected() = 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; virtual void ue_notify_rrc_reconf_complete(uint16_t rnti, bool outcome) = 0;
}; };

@ -37,6 +37,7 @@ public:
virtual void in_sync() = 0; virtual void in_sync() = 0;
virtual void out_of_sync() = 0; virtual void out_of_sync() = 0;
virtual void run_tti(const uint32_t tti) = 0; virtual void run_tti(const uint32_t tti) = 0;
virtual void set_phy_config_complete(bool status) = 0;
}; };
class mac_interface_phy_nr class mac_interface_phy_nr

@ -35,7 +35,7 @@ public:
virtual void reset() = 0; virtual void reset() = 0;
virtual void set_enabled(uint32_t lcid, bool enabled) = 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 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 del_bearer(uint32_t lcid) = 0;
virtual void change_lcid(uint32_t old_lcid, uint32_t new_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; virtual void config_security(uint32_t lcid, const srsran::as_security_config_t& sec_cfg) = 0;

@ -88,7 +88,7 @@ typedef struct SRSRAN_API {
SRSRAN_API int srsran_chest_sl_init(srsran_chest_sl_t* q, SRSRAN_API int srsran_chest_sl_init(srsran_chest_sl_t* q,
srsran_sl_channels_t channel, srsran_sl_channels_t channel,
srsran_cell_sl_t cell, srsran_cell_sl_t cell,
srsran_sl_comm_resource_pool_t sl_comm_resource_pool); 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); 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); 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 #ifdef __cplusplus
} }
#endif #endif

@ -45,7 +45,7 @@ typedef struct SRSRAN_API {
srsran_datatype_t type; srsran_datatype_t type;
} srsran_filesink_t; } 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); SRSRAN_API void srsran_filesink_free(srsran_filesink_t* q);

@ -33,30 +33,38 @@
#include "phy_logger.h" #include "phy_logger.h"
#include "srsran/config.h" #include "srsran/config.h"
#include <stdio.h> #include <stdio.h>
#include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define SRSRAN_VERBOSE_DEBUG 2 #define SRSRAN_VERBOSE_DEBUG 2
#define SRSRAN_VERBOSE_INFO 1 #define SRSRAN_VERBOSE_INFO 1
#define SRSRAN_VERBOSE_NONE 0 #define SRSRAN_VERBOSE_NONE 0
#include <sys/time.h>
SRSRAN_API void get_time_interval(struct timeval* tdata); SRSRAN_API void get_time_interval(struct timeval* tdata);
#define SRSRAN_DEBUG_ENABLED 1 #define SRSRAN_DEBUG_ENABLED 1
SRSRAN_API extern int srsran_verbose; SRSRAN_API int get_srsran_verbose_level(void);
SRSRAN_API extern int handler_registered; 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) SRSRAN_API bool is_handler_registered(void);
#define SRSRAN_VERBOSE_ISDEBUG() (srsran_verbose >= SRSRAN_VERBOSE_DEBUG) SRSRAN_API void set_handler_enabled(bool enable);
#define SRSRAN_VERBOSE_ISNONE() (srsran_verbose == SRSRAN_VERBOSE_NONE)
#define PRINT_DEBUG srsran_verbose = SRSRAN_VERBOSE_DEBUG #define SRSRAN_VERBOSE_ISINFO() (get_srsran_verbose_level() >= SRSRAN_VERBOSE_INFO)
#define PRINT_INFO srsran_verbose = SRSRAN_VERBOSE_INFO #define SRSRAN_VERBOSE_ISDEBUG() (get_srsran_verbose_level() >= SRSRAN_VERBOSE_DEBUG)
#define PRINT_NONE srsran_verbose = SRSRAN_VERBOSE_NONE #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, ...) \ #define DEBUG(_fmt, ...) \
do { \ 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__); \ fprintf(stdout, "[DEBUG]: " _fmt "\n", ##__VA_ARGS__); \
} else { \ } else { \
srsran_phy_log_print(LOG_LEVEL_DEBUG_S, _fmt, ##__VA_ARGS__); \ srsran_phy_log_print(LOG_LEVEL_DEBUG_S, _fmt, ##__VA_ARGS__); \
@ -65,7 +73,7 @@ SRSRAN_API extern int handler_registered;
#define INFO(_fmt, ...) \ #define INFO(_fmt, ...) \
do { \ 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__); \ fprintf(stdout, "[INFO]: " _fmt "\n", ##__VA_ARGS__); \
} else { \ } else { \
srsran_phy_log_print(LOG_LEVEL_INFO_S, _fmt, ##__VA_ARGS__); \ 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 */ /* In debug mode, it prints out the */
#define ERROR(_fmt, ...) \ #define ERROR(_fmt, ...) \
do { \ do { \
if (!handler_registered) { \ if (!is_handler_registered()) { \
fprintf(stderr, "\e[31m%s:%d: " _fmt "\e[0m\n", __FILE__, __LINE__, ##__VA_ARGS__); \ fprintf(stderr, "\e[31m%s:%d: " _fmt "\e[0m\n", __FILE__, __LINE__, ##__VA_ARGS__); \
} else { \ } else { \
srsran_phy_log_print(LOG_LEVEL_ERROR_S, _fmt, ##__VA_ARGS__); \ srsran_phy_log_print(LOG_LEVEL_ERROR_S, _fmt, ##__VA_ARGS__); \
@ -84,11 +92,15 @@ SRSRAN_API extern int handler_registered;
} while (0) } while (0)
#else #else
#define ERROR(_fmt, ...) \ #define ERROR(_fmt, ...) \
if (!handler_registered) { \ if (!is_handler_registered()) { \
fprintf(stderr, "[ERROR in %s]:" _fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ fprintf(stderr, "[ERROR in %s]:" _fmt "\n", __FUNCTION__, ##__VA_ARGS__); \
} else { \ } else { \
srsran_phy_log_print(LOG_LEVEL_ERROR, _fmt, ##__VA_ARGS__); \ srsran_phy_log_print(LOG_LEVEL_ERROR, _fmt, ##__VA_ARGS__); \
} // } //
#endif /* CMAKE_BUILD_TYPE==Debug */ #endif /* CMAKE_BUILD_TYPE==Debug */
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // SRSRAN_DEBUG_H #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_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); 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_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); 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; std::mutex metrics_mutex;
srslog::basic_logger& logger = srslog::fetch_basic_logger("RF", false); srslog::basic_logger& logger = srslog::fetch_basic_logger("RF", false);
phy_interface_radio* phy = nullptr; phy_interface_radio* phy = nullptr;
cf_t* zeros = nullptr; std::vector<cf_t> zeros;
std::array<cf_t*, SRSRAN_MAX_CHANNELS> dummy_buffers; std::array<std::vector<cf_t>, SRSRAN_MAX_CHANNELS> dummy_buffers;
std::mutex tx_mutex; std::mutex tx_mutex;
std::mutex rx_mutex; std::mutex rx_mutex;
std::array<std::vector<cf_t>, SRSRAN_MAX_CHANNELS> tx_buffer; std::array<std::vector<cf_t>, SRSRAN_MAX_CHANNELS> tx_buffer;

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

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

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

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

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

@ -48,8 +48,8 @@ public:
void set_enabled(uint32_t lcid, bool enabled) override; 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(uint32_t lcid, unique_byte_buffer_t sdu, int sn = -1) override;
void write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu); void write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu);
int add_bearer(uint32_t lcid, pdcp_config_t cnfg) override; int add_bearer(uint32_t lcid, const pdcp_config_t& cnfg) override;
void add_bearer_mrb(uint32_t lcid, pdcp_config_t cnfg); void add_bearer_mrb(uint32_t lcid, const pdcp_config_t& cnfg);
void del_bearer(uint32_t lcid) override; void del_bearer(uint32_t lcid) override;
void change_lcid(uint32_t old_lcid, uint32_t new_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; void config_security(uint32_t lcid, const as_security_config_t& sec_cfg) override;

@ -2092,12 +2092,10 @@ 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) || 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)) { (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; net_name->name[str_cnt] = tmp_char;
str_cnt++; str_cnt++;
} }
} }
}
if (0 == bit_offset || (1 == bit_offset && 0 == spare_field)) { if (0 == bit_offset || (1 == bit_offset && 0 == spare_field)) {
if (0 == bit_offset) { if (0 == bit_offset) {
@ -5027,7 +5025,6 @@ LIBLTE_ERROR_ENUM liblte_mme_pack_attach_request_msg(LIBLTE_MME_ATTACH_REQUEST_M
if (attach_req->ms_cm3_present) { if (attach_req->ms_cm3_present) {
*msg_ptr = LIBLTE_MME_MS_CLASSMARK_3_IEI; *msg_ptr = LIBLTE_MME_MS_CLASSMARK_3_IEI;
msg_ptr++; msg_ptr++;
liblte_mme_pack_mobile_station_classmark_3_ie(&attach_req->ms_cm3, &msg_ptr);
} }
// Supported Codecs // Supported Codecs
@ -5219,7 +5216,6 @@ LIBLTE_ERROR_ENUM liblte_mme_unpack_attach_request_msg(LIBLTE_BYTE_MSG_STRUCT*
// Mobile Station Classmark 3 // Mobile Station Classmark 3
if (LIBLTE_MME_MS_CLASSMARK_3_IEI == *msg_ptr) { if (LIBLTE_MME_MS_CLASSMARK_3_IEI == *msg_ptr) {
msg_ptr++; msg_ptr++;
liblte_mme_unpack_mobile_station_classmark_3_ie(&msg_ptr, &attach_req->ms_cm3);
attach_req->ms_cm3_present = true; attach_req->ms_cm3_present = true;
} else { } else {
attach_req->ms_cm3_present = false; attach_req->ms_cm3_present = false;
@ -5909,12 +5905,14 @@ 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_ERROR_ENUM liblte_mme_unpack_emm_information_msg(LIBLTE_BYTE_MSG_STRUCT* msg,
LIBLTE_MME_EMM_INFORMATION_MSG_STRUCT* emm_info) LIBLTE_MME_EMM_INFORMATION_MSG_STRUCT* emm_info)
{ {
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; if (!msg || !emm_info) {
return LIBLTE_ERROR_INVALID_INPUTS;
}
uint8* msg_ptr = msg->msg; uint8* msg_ptr = msg->msg;
uint8* msg_end = msg->msg + msg->N_bytes; uint8* msg_end = msg->msg + msg->N_bytes;
uint8 sec_hdr_type; uint8 sec_hdr_type;
if (msg != NULL && emm_info != NULL) {
// Security Header Type // Security Header Type
sec_hdr_type = (msg->msg[0] & 0xF0) >> 4; sec_hdr_type = (msg->msg[0] & 0xF0) >> 4;
if (LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS == sec_hdr_type) { if (LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS == sec_hdr_type) {
@ -5971,10 +5969,7 @@ LIBLTE_ERROR_ENUM liblte_mme_unpack_emm_information_msg(LIBLTE_BYTE_MSG_STRUCT*
emm_info->net_dst_present = false; emm_info->net_dst_present = false;
} }
err = LIBLTE_SUCCESS; return LIBLTE_SUCCESS;
}
return (err);
} }
/********************************************************************* /*********************************************************************

@ -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 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; LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
uint8 s[5]; uint8 s[5];
@ -627,7 +626,10 @@ LIBLTE_ERROR_ENUM liblte_security_128_eia2(const uint8* key,
LIBLTE_BIT_MSG_STRUCT* msg, LIBLTE_BIT_MSG_STRUCT* msg,
uint8* mac) uint8* mac)
{ {
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; if (!key || !msg || !mac) {
return LIBLTE_ERROR_INVALID_INPUTS;
}
uint8 M[msg->N_bits * 8 + 8 + 16]; uint8 M[msg->N_bits * 8 + 8 + 16];
aes_context ctx; aes_context ctx;
uint32 i; uint32 i;
@ -641,7 +643,6 @@ LIBLTE_ERROR_ENUM liblte_security_128_eia2(const uint8* key,
uint8 T[16]; uint8 T[16];
uint8 tmp[16]; uint8 tmp[16];
if (key != NULL && msg != NULL && mac != NULL) {
// Subkey L generation // Subkey L generation
aes_setkey_enc(&ctx, key, 128); aes_setkey_enc(&ctx, key, 128);
aes_crypt_ecb(&ctx, AES_ENCRYPT, const_zero, L); aes_crypt_ecb(&ctx, AES_ENCRYPT, const_zero, L);
@ -714,10 +715,7 @@ LIBLTE_ERROR_ENUM liblte_security_128_eia2(const uint8* key,
mac[i] = T[i]; mac[i] = T[i];
} }
err = LIBLTE_SUCCESS; return LIBLTE_SUCCESS;
}
return (err);
} }
uint32_t GET_WORD(uint32_t* DATA, uint32_t i) 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 bool phy_cfg_nr_t::assert_ss_id(uint32_t ss_id) const
{ {
// Make sure SS access if bounded // 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; 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) void phy_cfg_nr_default_t::make_prach_default_lte(srsran_prach_cfg_t& prach)
{ {
prach.is_nr = true; prach.is_nr = true;
prach.config_idx = 0; prach.config_idx = 8;
prach.root_seq_idx = 0; prach.root_seq_idx = 0;
prach.zero_corr_zone = 0; prach.zero_corr_zone = 0;
prach.freq_offset = 4; prach.freq_offset = 4;

@ -31,7 +31,7 @@ void rlc_pcap::enable(bool en)
enable_write = true; 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); fprintf(stdout, "Opening RLC PCAP with DLT=%d\n", UDP_DLT);
pcap_file = DLT_PCAP_Open(UDP_DLT, filename); pcap_file = DLT_PCAP_Open(UDP_DLT, filename);

@ -37,7 +37,7 @@
#define ROT(a, k) (((a) << k) | ((a) >> (32 - k))) #define ROT(a, k) (((a) << k) | ((a) >> (32 - k)))
/* the s-boxes */ /* 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, 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, 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, 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, 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}; 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, 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, 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, 0x45, 0x3e, 0x10, 0x76, 0xc6, 0xa7, 0x8b, 0x39, 0x43, 0xe1, 0x3a, 0xb5, 0x56, 0x2a, 0xc0, 0x6d, 0xb3, 0x05, 0x22,
@ -70,7 +70,7 @@ u8 S1[256] = {
0xd7, 0xb0, 0x25, 0xac, 0xaf, 0x12, 0x03, 0xe2, 0xf2}; 0xd7, 0xb0, 0x25, 0xac, 0xaf, 0x12, 0x03, 0xe2, 0xf2};
/* the constants D */ /* the constants D */
u32 EK_d[16] = {0x44D7, static const u32 EK_d[16] = {0x44D7,
0x26BC, 0x26BC,
0x626B, 0x626B,
0x135E, 0x135E,

@ -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)) { if (valid_lcid(lcid)) {
return pdcp_array[lcid]->configure(cfg) ? SRSRAN_SUCCESS : SRSRAN_ERROR; 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; 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)) { if (not valid_mch_lcid(lcid)) {
std::unique_ptr<pdcp_entity_lte> entity; std::unique_ptr<pdcp_entity_lte> entity;

@ -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++) { 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)); 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++) { for (uint32_t a = 0; a < q->nof_rx_antennas; a++) {
if (q->noise_estimate[a]) {
res->snr_ant_port_db[a][port_id] = res->snr_ant_port_db[a][port_id] =
srsran_convert_power_to_dB(q->rsrp[a][port_id] / q->noise_estimate[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->rsrp_ant_port_dbm[a][port_id] = srsran_convert_power_to_dBm(q->rsrp[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] = 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]); 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: clean_exit:
if (ret != SRSRAN_SUCCESS) { if (ret != SRSRAN_SUCCESS && q != NULL) {
srsran_chest_dl_nbiot_free(q); srsran_chest_dl_nbiot_free(q);
} }
return ret; return ret;

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

@ -769,6 +769,8 @@ int srsran_csi_rs_nzp_measure_trs(const srsran_carrier_nr_t* carrier,
// Perform Measurements // Perform Measurements
csi_rs_nzp_resource_measure_t measurements[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET]; 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); 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) { if (ret < SRSRAN_SUCCESS) {
ERROR("Error performing measurements"); ERROR("Error performing measurements");
return SRSRAN_ERROR; return SRSRAN_ERROR;
@ -865,6 +867,8 @@ int srsran_csi_rs_nzp_measure_channel(const srsran_carrier_nr_t* carrier
// Perform Measurements // Perform Measurements
csi_rs_nzp_resource_measure_t measurements[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET]; 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); 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) { if (ret < SRSRAN_SUCCESS) {
ERROR("Error performing measurements"); ERROR("Error performing measurements");
return SRSRAN_ERROR; return SRSRAN_ERROR;
@ -1041,8 +1045,11 @@ int srsran_csi_rs_zp_measure_channel(const srsran_carrier_nr_t* carrier,
// Perform Measurements // Perform Measurements
csi_rs_zp_resource_measure_t measurements[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET]; 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); 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) { if (ret < SRSRAN_SUCCESS) {
ERROR("Error performing measurements"); ERROR("Error performing measurements");
return SRSRAN_ERROR;
} }
uint32_t count = (uint32_t)ret; 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; 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); DMRS_PDCCH_DEBUG_RX("Measuring PDCCH l=%d; lse=", l);
srsran_vec_fprint_c(stdout, tmp, nof_pilots); 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); srsran_vec_apply_cfo(tmp, tmp_sync_err, tmp, nof_pilots);
#endif // DMRS_PDCCH_SYNC_PRECOMPENSATE_MEAS #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 // Correlate DMRS
corr[l] = srsran_vec_acc_cc(tmp, nof_pilots) / (float)nof_pilots; 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/common/sequence.h"
#include "srsran/phy/utils/debug.h" #include "srsran/phy/utils/debug.h"
#include "srsran/phy/utils/vector.h" #include "srsran/phy/utils/vector.h"
#include <assert.h>
#include <complex.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... // Implements TS 38.211 table 6.4.1.3.1.1-1: Number of DM-RS symbols and the corresponding N_PUCCH...
@ -192,6 +193,10 @@ int srsran_dmrs_pucch_format1_estimate(const srsran_pucch_nr_t* q,
} }
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; uint32_t l_prime = resource->start_symbol_idx;
for (uint32_t m = 0; m < n_pucch; m++) { for (uint32_t m = 0; m < n_pucch; m++) {
// Clause 6.4.1.3.1.2 specifies l=0,2,4... // 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]; cf_t z[SRSRAN_NRE];
srsran_vec_sc_prod_ccc(r_uv, w_i_m, 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 // Calculate least square estimates for this symbol
srsran_vec_prod_conj_ccc(slot_symbols_ptr, z, ce[m], SRSRAN_NRE); 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 srsran_refsignal_cs_init(srsran_refsignal_t* q, uint32_t max_prb)
{ {
int ret = SRSRAN_ERROR_INVALID_INPUTS; int ret = SRSRAN_ERROR_INVALID_INPUTS;
if (q != NULL) { if (q != NULL) {
@ -65,7 +64,6 @@ free_and_exit:
*/ */
int srsran_refsignal_cs_set_cell(srsran_refsignal_t* q, srsran_cell_t cell) int srsran_refsignal_cs_set_cell(srsran_refsignal_t* q, srsran_cell_t cell)
{ {
uint32_t c_init; uint32_t c_init;
uint32_t N_cp, mp; uint32_t N_cp, mp;
srsran_sequence_t seq; 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) inline uint32_t srsran_refsignal_mbsfn_fidx(uint32_t l)
{ {
uint32_t ret = 0; uint32_t ret = 0;
if (l == 0) { if (l == 0) {
ret = 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 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; if (q == NULL) {
q->cell = cell; ret = SRSRAN_ERROR_INVALID_INPUTS;
goto exit;
}
q->cell = cell;
q->mbsfn_area_id = mbsfn_area_id; q->mbsfn_area_id = mbsfn_area_id;
if (srsran_refsignal_mbsfn_gen_seq(q, q->cell, q->mbsfn_area_id)) { if (srsran_refsignal_mbsfn_gen_seq(q, q->cell, q->mbsfn_area_id) < SRSRAN_SUCCESS) {
goto free_and_exit; ret = SRSRAN_ERROR;
goto exit;
} }
ret = SRSRAN_SUCCESS; exit:
free_and_exit:
if (ret == SRSRAN_ERROR) {
srsran_refsignal_free(q);
}
return ret; return ret;
} }

@ -36,31 +36,33 @@
#include "srsran/phy/utils/vector.h" #include "srsran/phy/utils/vector.h"
// n_dmrs_2 table 5.5.2.1.1-1 from 36.211 // 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 // 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 /* 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}; static const float w_arg_pucch_format2_cpnorm[2] = {0, 0};
float w_arg_pucch_format2_cpext[1] = {0}; static const float w_arg_pucch_format2_cpext[1] = {0};
uint32_t pucch_dmrs_symbol_format1_cpnorm[3] = {2, 3, 4}; static const uint32_t pucch_dmrs_symbol_format1_cpnorm[3] = {2, 3, 4};
uint32_t pucch_dmrs_symbol_format1_cpext[2] = {2, 3}; static const uint32_t pucch_dmrs_symbol_format1_cpext[2] = {2, 3};
uint32_t pucch_dmrs_symbol_format2_cpnorm[2] = {1, 5}; static const 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_format2_cpext[1] = {3};
/* Table 5.5.3.3-1: Frame structure type 1 sounding reference signal subframe configuration. */ /* 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}; static const 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}; static const uint32_t Delta_sfc1[7] = {0, 0, 1, 0, 1, 2, 3};
uint32_t Delta_sfc2[4] = {0, 1, 2, 3}; static const 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 */ 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}, {36, 32, 24, 20, 16, 12, 8, 4},
{12, 16, 4, 4, 4, 4, 4, 4}, {12, 16, 4, 4, 4, 4, 4, 4},
{4, 8, 4, 4, 4, 4, 4, 4}, {4, 8, 4, 4, 4, 4, 4, 4},
@ -83,7 +85,7 @@ uint32_t m_srs_b[4][4][8] = {{/* m_srs for 6<n_rb<40. Table 5.5.3.2-1 */
{4, 4, 4, 4, 4, 4, 4, 4}}}; {4, 4, 4, 4, 4, 4, 4, 4}}};
/* Same tables for Nb */ /* 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}, {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}, {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}}, {{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; 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 && if (srsran_dft_precoding_valid_prb(pusch_cfg->grant.L_prb) && pusch_cfg->grant.n_dmrs < SRSRAN_NOF_CSHIFT) {
pusch_cfg->grant.n_dmrs < SRSRAN_NOF_CSHIFT) {
srsran_refsignal_dmrs_pusch_put( srsran_refsignal_dmrs_pusch_put(
q, pusch_cfg, pregen->r[pusch_cfg->grant.n_dmrs][sf_idx][pusch_cfg->grant.L_prb], sf_symbols); q, pusch_cfg, pregen->r[pusch_cfg->grant.n_dmrs][sf_idx][pusch_cfg->grant.L_prb], sf_symbols);
return SRSRAN_SUCCESS; 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 // 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) { switch (cfg->format) {
case SRSRAN_PUCCH_FORMAT_1: case SRSRAN_PUCCH_FORMAT_1:
case SRSRAN_PUCCH_FORMAT_1A: case SRSRAN_PUCCH_FORMAT_1A:
@ -733,14 +734,14 @@ int srsran_refsignal_srs_send_cs(uint32_t subframe_config, uint32_t sf_idx)
} else { } else {
return 1; return 1;
} }
} else if (subframe_config == 14) { }
// subframe_config == 14
else {
if (((sf_idx % tsfc) == 7) || ((sf_idx % tsfc) == 9)) { if (((sf_idx % tsfc) == 7) || ((sf_idx % tsfc) == 9)) {
return 0; return 0;
} else { } else {
return 1; return 1;
} }
} else {
return 0;
} }
} else { } else {
return SRSRAN_ERROR_INVALID_INPUTS; return SRSRAN_ERROR_INVALID_INPUTS;

@ -88,7 +88,7 @@ void parse_args(int argc, char** argv)
snr_db = strtof(argv[optind], NULL); snr_db = strtof(argv[optind], NULL);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); 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++) { for (int n_port = 0; n_port < cell.base.nof_ports; n_port++) {
srsran_vec_cf_zero(input, num_re); srsran_vec_cf_zero(input, num_re);
for (int i = 0; i < num_re; i++) { 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); srsran_vec_cf_zero(ce, num_re);

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

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

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

@ -71,7 +71,7 @@ void parse_args(int argc, char** argv)
output_matlab = argv[optind]; output_matlab = argv[optind];
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -167,7 +167,7 @@ int main(int argc, char** argv)
// Loop through subframe idx and cyclic shifts // 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) { for (int cshift_dmrs = 0; cshift_dmrs < SRSRAN_NOF_CSHIFT; cshift_dmrs += 5) {
if (SRSRAN_VERBOSE_ISINFO()) { if (SRSRAN_VERBOSE_ISINFO()) {
printf("nof_prb: %d, ", nof_prb); 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); 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); 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] = {}; char str[128] = {};
srsran_csi_rs_measure_info(&measure, str, sizeof(str)); srsran_csi_rs_measure_info(&measure, str, sizeof(str));
INFO("Measure: %s", 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); first_symbol = (uint32_t)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); usage(argv[0]);

@ -58,7 +58,7 @@ static void parse_args(int argc, char** argv)
interleaved ^= true; interleaved ^= true;
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); 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]); 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++) { for (uint32_t candidate = 0; candidate < nof_locations; candidate++) {
dci_location.ncce = 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); carrier.pci = (uint32_t)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); usage(argv[0]);

@ -66,7 +66,7 @@ void parse_args(int argc, char** argv)
cell.id = (uint32_t)strtol(argv[optind], NULL, 10); cell.id = (uint32_t)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); 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); q->table_log = srsran_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE);
if (!q->table_cos || !q->table_log) { if (!q->table_cos || !q->table_log) {
ERROR("Malloc"); ERROR("Malloc");
return SRSRAN_ERROR;
} }
// Fill tables // Fill tables

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

@ -46,7 +46,7 @@ static void usage(char* prog)
printf("\t-T Simulation Time in periods: [Default %d]\n", sim_time_periods); 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; int opt;
while ((opt = getopt(argc, argv, "mMtsT")) != -1) { while ((opt = getopt(argc, argv, "mMtsT")) != -1) {
@ -68,14 +68,15 @@ static void parse_args(int argc, char** argv)
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
exit(-1); return SRSRAN_ERROR;
} }
} }
return SRSRAN_SUCCESS;
} }
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int ret = SRSRAN_SUCCESS; int ret = SRSRAN_ERROR;
cf_t* input_buffer = NULL; cf_t* input_buffer = NULL;
cf_t* output_buffer = NULL; cf_t* output_buffer = NULL;
srsran_timestamp_t ts = {}; // Initialised to zero srsran_timestamp_t ts = {}; // Initialised to zero
@ -83,28 +84,32 @@ int main(int argc, char** argv)
struct timeval t[3] = {}; struct timeval t[3] = {};
// Parse arguments // Parse arguments
parse_args(argc, argv); if (parse_args(argc, argv) < SRSRAN_SUCCESS) {
goto clean_exit;
}
// Initialise buffers // Initialise buffers
uint32_t size = srate_hz / 1000; uint32_t size = srate_hz / 1000;
input_buffer = srsran_vec_cf_malloc(size); input_buffer = srsran_vec_cf_malloc(size);
output_buffer = srsran_vec_cf_malloc(size); output_buffer = srsran_vec_cf_malloc(size);
if (!input_buffer || !output_buffer) { if (!input_buffer || !output_buffer) {
fprintf(stderr, "Error: Allocating memory\n"); ERROR("Error: Allocating memory");
ret = SRSRAN_ERROR; goto clean_exit;
} }
// Generate random samples // Generate random samples
srsran_random_uniform_complex_dist_vector(random_gen, input_buffer, size, -1.0f, +1.0f); srsran_random_uniform_complex_dist_vector(random_gen, input_buffer, size, -1.0f, +1.0f);
// Initialise delay channel // Initialise delay channel
if (ret == SRSRAN_SUCCESS) { if (srsran_channel_delay_init(&delay, delay_min_us, delay_max_us, delay_period_s, delay_init_time_s, srate_hz) <
ret = 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 // Run actual test
gettimeofday(&t[1], NULL); 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++) { for (int j = 0; j < 1000 * delay_period_s; j++) {
// Run delay channel // Run delay channel
srsran_channel_delay_execute(&delay, input_buffer, output_buffer, size, &ts); 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); gettimeofday(&t[2], NULL);
get_time_interval(t); 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; 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 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 // 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", 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, delay_min_us,
@ -139,6 +140,19 @@ int main(int argc, char** argv)
srate_hz, srate_hz,
sim_time_periods, sim_time_periods,
(ret == SRSRAN_SUCCESS) ? "Passed" : "Failed", (ret == SRSRAN_SUCCESS) ? "Passed" : "Failed",
(double)nof_samples / elapsed_us); msps);
exit(ret);
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 */ #endif /* ENABLE_GUI */
} }
static void parse_args(int argc, char** argv) static int parse_args(int argc, char** argv)
{ {
int opt; int opt;
while ((opt = getopt(argc, argv, "mtsrg")) != -1) { while ((opt = getopt(argc, argv, "mtsrg")) != -1) {
@ -82,9 +82,10 @@ static void parse_args(int argc, char** argv)
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
exit(-1); return SRSRAN_ERROR;
} }
} }
return SRSRAN_SUCCESS;
} }
int main(int argc, char** argv) int main(int argc, char** argv)
@ -95,7 +96,16 @@ int main(int argc, char** argv)
struct timeval t[3] = {}; struct timeval t[3] = {};
uint64_t time_usec = 0; 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_t ifft;
srsran_dft_plan_c(&ifft, srate / 1000, SRSRAN_DFT_BACKWARD); srsran_dft_plan_c(&ifft, srate / 1000, SRSRAN_DFT_BACKWARD);
@ -106,9 +116,6 @@ int main(int argc, char** argv)
plot_real_t plot_imp = NULL; plot_real_t plot_imp = NULL;
srsran_dft_plan_t fft = {}; srsran_dft_plan_t fft = {};
cf_t* fft_buffer = NULL;
float* fft_mag = NULL;
float* imp = NULL;
if (enable_gui) { if (enable_gui) {
sdrgui_init(); sdrgui_init();
@ -216,15 +223,17 @@ int main(int argc, char** argv)
#endif /* ENABLE_GUI */ #endif /* ENABLE_GUI */
} }
// 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; ret = SRSRAN_SUCCESS;
clean_exit:
if (ret) {
printf("Error\n");
} else { } 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); srsran_dft_plan_free(&ifft);
#ifdef ENABLE_GUI #ifdef ENABLE_GUI

@ -739,3 +739,22 @@ srsran_ssb_patern_t srsran_ssb_pattern_fom_str(const char* str)
return SRSRAN_SSB_PATTERN_INVALID; 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/common/test_common.h"
#include "srsran/phy/common/sliv.h" #include "srsran/phy/common/sliv.h"
#include <srsran/phy/utils/debug.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -47,34 +48,52 @@ static int test()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int ret = SRSRAN_ERROR;
// Parse N // Parse N
if (argc >= 2) { if (argc >= 2) {
N = (uint32_t)strtol(argv[1], NULL, 10); 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 two arguments, run brute force test
if (argc == 2) { else if (argc == 2) {
return test(); ret = test();
} }
// if three arguments, calculate start and length from sliv // 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 sliv = (uint32_t)strtol(argv[2], NULL, 10);
uint32_t S = 0; uint32_t S = 0;
uint32_t L = 0; uint32_t L = 0;
srsran_sliv_to_s_and_l(N, sliv, &S, &L);
// 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); printf("SLIV=%d; Start: %d; Length: %d;\n", sliv, S, L);
return SRSRAN_SUCCESS; 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 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 s = (uint32_t)strtol(argv[2], NULL, 10);
uint32_t l = (uint32_t)strtol(argv[3], NULL, 10); uint32_t l = (uint32_t)strtol(argv[3], NULL, 10);
uint32_t sliv = srsran_sliv_from_s_and_l(N, s, l); uint32_t sliv = srsran_sliv_from_s_and_l(N, s, l);
printf("SLIV=%d; Start: %d; Length: %d;\n", sliv, 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/debug.h"
#include "srsran/phy/utils/primes.h" #include "srsran/phy/utils/primes.h"
#include "srsran/phy/utils/vector.h" #include "srsran/phy/utils/vector.h"
#include <assert.h>
#include <complex.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 // 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, 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, 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}, {-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}}; {-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 // 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}, {-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, 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}, {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}}; {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 // 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}, {-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}, {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}, {-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}}; {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 // 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, 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, 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}, {-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}}; {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 // 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}, {-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, 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}, {-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}}; {-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 // 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, 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, -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}, {-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) 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); 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) 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); 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) 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); 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) 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); 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) 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); 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) 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); 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) 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++) { 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) { if (lockf(fileno(fd), F_LOCK, 0) == -1) {
perror("lockf()"); perror("lockf()");
fclose(fd);
return; return;
} }
fftwf_import_wisdom_from_file(fd); fftwf_import_wisdom_from_file(fd);
if (lockf(fileno(fd), F_ULOCK, 0) == -1) { if (lockf(fileno(fd), F_ULOCK, 0) == -1) {
perror("u-lockf()"); perror("u-lockf()");
fclose(fd);
return; return;
} }
fclose(fd); fclose(fd);
@ -91,11 +93,13 @@ __attribute__((destructor)) void srsran_dft_exit()
} }
if (lockf(fileno(fd), F_LOCK, 0) == -1) { if (lockf(fileno(fd), F_LOCK, 0) == -1) {
perror("lockf()"); perror("lockf()");
fclose(fd);
return; return;
} }
fftwf_export_wisdom_to_file(fd); fftwf_export_wisdom_to_file(fd);
if (lockf(fileno(fd), F_ULOCK, 0) == -1) { if (lockf(fileno(fd), F_ULOCK, 0) == -1) {
perror("u-lockf()"); perror("u-lockf()");
fclose(fd);
return; return;
} }
fclose(fd); fclose(fd);
@ -213,10 +217,11 @@ int srsran_dft_plan_guru_c(srsran_dft_plan_t* plan,
pthread_mutex_lock(&fft_mutex); pthread_mutex_lock(&fft_mutex);
plan->p = fftwf_plan_guru_dft(1, &iodim, 1, &howmany_dims, in_buffer, out_buffer, sign, FFTW_TYPE); 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) { if (!plan->p) {
return -1; return -1;
} }
pthread_mutex_unlock(&fft_mutex);
plan->size = dft_points; plan->size = dft_points;
plan->init_size = plan->size; plan->init_size = plan->size;

@ -41,7 +41,7 @@ void usage(char* prog)
printf("Usage: %s [Rv]\n", prog); printf("Usage: %s [Rv]\n", prog);
printf("\t-R Number of repetitions [Default %d]\n", nof_repetitions); printf("\t-R Number of repetitions [Default %d]\n", nof_repetitions);
printf("\t-E Number of encoded bits [Default %d]\n", E); 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) 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); E = (uint32_t)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); 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++) { for (i_layer = 0; i_layer < vp->bgM; i_layer++) {
current_var_index = these_var_indices[i_layer][0]; current_var_index = these_var_indices[i_layer][0];
this_check_to_var = vp->check_to_var + i_layer * (vp->hrr + 1); 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; 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]); 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); 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); 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]; 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; 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; current_var_index_subnode = current_var_index * vp->n_subnodes;
for (j = 0; j < vp->n_subnodes; j++) { for (j = 0; j < vp->n_subnodes; j++) {
i_bit_tmp_base = (current_var_index <= vp->hrr) ? current_var_index : vp->hrr; 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); 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++) { for (i_layer = 0; i_layer < vp->bgM; i_layer++) {
current_var_index = these_var_indices[i_layer][0]; current_var_index = these_var_indices[i_layer][0];
this_check_to_var = vp->check_to_var + i_layer * (vp->hrrN + vp->ls); 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! // recall that current_var_index depends on i!
current_var_index_ext = current_var_index * vp->ls; current_var_index_ext = current_var_index * vp->ls;
for (j = 0; j < vp->ls; j++) { 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; 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];
} }
} }

@ -102,7 +102,7 @@ void usage(char* prog)
/*! /*!
* \brief Parses the input line. * \brief Parses the input line.
*/ */
void parse_args(int argc, char** argv) int parse_args(int argc, char** argv)
{ {
int opt = 0; int opt = 0;
while ((opt = getopt(argc, argv, "b:l:e:f:r:m:w:M:s:B:N:E:")) != -1) { 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; break;
default: default:
usage(argv[0]); usage(argv[0]);
exit(-1); return SRSRAN_ERROR;
} }
} }
return SRSRAN_SUCCESS;
} }
/*! /*!
* \brief Prints decoder statistics. * \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. * \brief Main test function.
*/ */
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int ret = SRSRAN_ERROR;
uint8_t* messages_true = NULL; uint8_t* messages_true = NULL;
uint8_t* messages_sim_f = NULL; uint8_t* messages_sim_f = NULL;
uint8_t* messages_sim_s = NULL; uint8_t* messages_sim_s = NULL;
@ -178,29 +181,68 @@ int main(int argc, char** argv)
int16_t* symbols_s = NULL; // unrm_symbols int16_t* symbols_s = NULL; // unrm_symbols
int8_t* symbols_c = 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 i = 0;
int j = 0; int j = 0;
parse_args(argc, argv); if (parse_args(argc, argv) < SRSRAN_SUCCESS) {
goto clean_exit;
// create an LDPC encoder }
srsran_ldpc_encoder_t encoder;
#ifdef LV_HAVE_AVX512 #ifdef LV_HAVE_AVX512
if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) { if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) {
perror("encoder init"); perror("encoder init");
exit(-1); goto clean_exit;
} }
#else // no AVX512 #else // no AVX512
#ifdef LV_HAVE_AVX2 #ifdef LV_HAVE_AVX2
if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) { if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) {
perror("encoder init"); 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) { if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_C, base_graph, lift_size) != 0) {
perror("encoder init"); perror("encoder init");
exit(-1); goto clean_exit;
} }
#endif // LV_HAVE_AVX2 #endif // LV_HAVE_AVX2
#endif // LV_HAVE_AVX512 #endif // LV_HAVE_AVX512
@ -215,32 +257,28 @@ int main(int argc, char** argv)
Nref = finalN; Nref = finalN;
} }
// create a LDPC rate Matcher // Init the LDPC rate Matcher
srsran_ldpc_rm_t rm_tx;
if (srsran_ldpc_rm_tx_init(&rm_tx) != 0) { if (srsran_ldpc_rm_tx_init(&rm_tx) != 0) {
perror("rate matcher init"); perror("rate matcher init");
exit(-1); goto clean_exit;
} }
// create a LDPC rate DeMatcher // Init LDPC rate DeMatcher
srsran_ldpc_rm_t rm_rx;
if (srsran_ldpc_rm_rx_init_f(&rm_rx) != 0) { if (srsran_ldpc_rm_rx_init_f(&rm_rx) != 0) {
perror("rate dematcher init"); perror("rate dematcher init");
exit(-1); goto clean_exit;
} }
// create a LDPC rate DeMatcher (int16_t) // Init LDPC rate DeMatcher (int16_t)
srsran_ldpc_rm_t rm_rx_s;
if (srsran_ldpc_rm_rx_init_s(&rm_rx_s) != 0) { if (srsran_ldpc_rm_rx_init_s(&rm_rx_s) != 0) {
perror("rate dematcher init (int16_t)"); perror("rate dematcher init (int16_t)");
exit(-1); goto clean_exit;
} }
// create a LDPC rate DeMatcher (int8_t) // Init LDPC rate DeMatcher (int8_t)
srsran_ldpc_rm_t rm_rx_c;
if (srsran_ldpc_rm_rx_init_c(&rm_rx_c) != 0) { if (srsran_ldpc_rm_rx_init_c(&rm_rx_c) != 0) {
perror("rate dematcher init (int8_t)"); perror("rate dematcher init (int8_t)");
exit(-1); goto clean_exit;
} }
// Create LDPC configuration arguments // Create LDPC configuration arguments
@ -249,73 +287,62 @@ int main(int argc, char** argv)
decoder_args.ls = lift_size; decoder_args.ls = lift_size;
decoder_args.scaling_fctr = MS_SF; decoder_args.scaling_fctr = MS_SF;
// create an LDPC decoder (float) // Init the LDPC decoder (float)
srsran_ldpc_decoder_t decoder_f;
decoder_args.type = SRSRAN_LDPC_DECODER_F; decoder_args.type = SRSRAN_LDPC_DECODER_F;
if (srsran_ldpc_decoder_init(&decoder_f, &decoder_args) != 0) { if (srsran_ldpc_decoder_init(&decoder_f, &decoder_args) != 0) {
perror("decoder init"); perror("decoder init");
exit(-1); goto clean_exit;
} }
// create an LDPC decoder (16 bit) // Init the LDPC decoder (16 bit)
srsran_ldpc_decoder_t decoder_s;
decoder_args.type = SRSRAN_LDPC_DECODER_S; decoder_args.type = SRSRAN_LDPC_DECODER_S;
if (srsran_ldpc_decoder_init(&decoder_s, &decoder_args) != 0) { if (srsran_ldpc_decoder_init(&decoder_s, &decoder_args) != 0) {
perror("decoder init (int16_t)"); perror("decoder init (int16_t)");
exit(-1); goto clean_exit;
} }
// create an LDPC decoder (8 bit) // Init the LDPC decoder (8 bit)
srsran_ldpc_decoder_t decoder_c;
decoder_args.type = SRSRAN_LDPC_DECODER_C; decoder_args.type = SRSRAN_LDPC_DECODER_C;
if (srsran_ldpc_decoder_init(&decoder_c, &decoder_args) != 0) { if (srsran_ldpc_decoder_init(&decoder_c, &decoder_args) != 0) {
perror("decoder init (int8_t)"); perror("decoder init (int8_t)");
exit(-1); goto clean_exit;
} }
// create an LDPC decoder (8 bit, flooded) // Init the LDPC decoder (8 bit, flooded)
srsran_ldpc_decoder_t decoder_c_flood;
decoder_args.type = SRSRAN_LDPC_DECODER_C_FLOOD; decoder_args.type = SRSRAN_LDPC_DECODER_C_FLOOD;
if (srsran_ldpc_decoder_init(&decoder_c_flood, &decoder_args) != 0) { if (srsran_ldpc_decoder_init(&decoder_c_flood, &decoder_args) != 0) {
perror("decoder init"); perror("decoder init");
exit(-1); goto clean_exit;
} }
#ifdef LV_HAVE_AVX2 #ifdef LV_HAVE_AVX2
// create an LDPC decoder (8 bit, AVX2 version) // Init the LDPC decoder (8 bit, AVX2 version)
srsran_ldpc_decoder_t decoder_avx;
decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX2; decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX2;
if (srsran_ldpc_decoder_init(&decoder_avx, &decoder_args) != 0) { if (srsran_ldpc_decoder_init(&decoder_avx, &decoder_args) != 0) {
perror("decoder init"); perror("decoder init");
exit(-1); goto clean_exit;
} }
// create an LDPC decoder (8 bit, flooded scheduling, AVX2 version) // Init the LDPC decoder (8 bit, flooded scheduling, AVX2 version)
srsran_ldpc_decoder_t decoder_avx_flood;
decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX2_FLOOD; decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX2_FLOOD;
if (srsran_ldpc_decoder_init(&decoder_avx_flood, &decoder_args) != 0) { if (srsran_ldpc_decoder_init(&decoder_avx_flood, &decoder_args) != 0) {
perror("decoder init"); perror("decoder init");
exit(-1); goto clean_exit;
} }
#endif // LV_HAVE_AVX2 #endif // LV_HAVE_AVX2
#ifdef LV_HAVE_AVX512 #ifdef LV_HAVE_AVX512
// create an LDPC decoder (8 bit, AVX2 version) // Init the LDPC decoder (8 bit, AVX512 version)
srsran_ldpc_decoder_t decoder_avx512;
decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX512; decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX512;
if (srsran_ldpc_decoder_init(&decoder_avx512, &decoder_args) != 0) { if (srsran_ldpc_decoder_init(&decoder_avx512, &decoder_args) != 0) {
perror("decoder init"); perror("decoder init");
exit(-1); goto clean_exit;
} }
// create an LDPC decoder (8 bit, flooded scheduling, AVX512 version) // Init LDPC decoder (8 bit, flooded scheduling, AVX512 version)
srsran_ldpc_decoder_t decoder_avx512_flood;
decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX512_FLOOD; decoder_args.type = SRSRAN_LDPC_DECODER_C_AVX512_FLOOD;
if (srsran_ldpc_decoder_init(&decoder_avx512_flood, &decoder_args) != 0) { if (srsran_ldpc_decoder_init(&decoder_avx512_flood, &decoder_args) != 0) {
perror("decoder init"); perror("decoder init");
exit(-1); goto clean_exit;
} }
#endif // LV_HAVE_AVX512 #endif // LV_HAVE_AVX512
// create a random generator
srsran_random_t random_gen = srsran_random_init(0);
printf("Test LDPC chain:\n"); printf("Test LDPC chain:\n");
printf(" Base Graph -> BG%d\n", encoder.bg + 1); printf(" Base Graph -> BG%d\n", encoder.bg + 1);
printf(" Lifting Size -> %d\n", encoder.ls); 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 || !messages_sim_avx512_flood || !codewords || !rm_codewords || !rm_symbols || !rm_symbols_s || !rm_symbols_c ||
!symbols || !symbols_s || !symbols_c) { !symbols || !symbols_s || !symbols_c) {
perror("malloc"); perror("malloc");
exit(-1); goto clean_exit;
} }
int i_bit = 0; int i_bit = 0;
@ -488,7 +515,7 @@ int main(int argc, char** argv)
rv, rv,
mod_type, mod_type,
Nref)) { Nref)) {
exit(-1); goto clean_exit;
} }
} }
@ -528,7 +555,7 @@ int main(int argc, char** argv)
rv, rv,
mod_type, mod_type,
Nref)) { Nref)) {
exit(-1); goto clean_exit;
} }
} }
@ -568,7 +595,7 @@ int main(int argc, char** argv)
rv, rv,
mod_type, mod_type,
Nref) < 0) { 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 * finalK / elapsed_time_enc,
i_batch * batch_size * finalN / 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); if (print_decoder("FLOATING POINT", i_batch, n_error_words_f, elapsed_time_dec_f) < SRSRAN_SUCCESS) {
print_decoder("FIXED POINT (16 bits)", i_batch, n_error_words_s, elapsed_time_dec_s); goto clean_exit;
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("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 #ifdef LV_HAVE_AVX2
print_decoder("FIXED POINT (8 bits - AVX2)", i_batch, n_error_words_avx, elapsed_time_dec_avx); if (print_decoder("FIXED POINT (8 bits - AVX2)", i_batch, n_error_words_avx, elapsed_time_dec_avx) < SRSRAN_SUCCESS) {
print_decoder( goto clean_exit;
"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, flooded scheduling - AVX2)",
i_batch,
n_error_words_avx_flood,
elapsed_time_dec_avx_flood) < SRSRAN_SUCCESS) {
goto clean_exit;
}
#endif // LV_HAVE_AVX2 #endif // LV_HAVE_AVX2
#ifdef LV_HAVE_AVX512 #ifdef LV_HAVE_AVX512
print_decoder("FIXED POINT (8 bits - AVX512)", i_batch, n_error_words_avx512, elapsed_time_dec_avx512); if (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)", SRSRAN_SUCCESS) {
goto clean_exit;
}
if (print_decoder("FIXED POINT (8 bits, flooded scheduling - AVX512)",
i_batch, i_batch,
n_error_words_avx512_flood, n_error_words_avx512_flood,
elapsed_time_dec_avx512_flood); elapsed_time_dec_avx512_flood) < SRSRAN_SUCCESS) {
goto clean_exit;
}
#endif // LV_HAVE_AVX512 #endif // LV_HAVE_AVX512
if (n_error_words_s > 10 * n_error_words_f) { if (n_error_words_s > 10 * n_error_words_f) {
perror("16-bit performance too low!"); perror("16-bit performance too low!");
exit(-1); goto clean_exit;
} }
if (n_error_words_c > 10 * n_error_words_f) { if (n_error_words_c > 10 * n_error_words_f) {
perror("8-bit performance too low!"); perror("8-bit performance too low!");
exit(-1); goto clean_exit;
} }
#ifdef LV_HAVE_AVX512 #ifdef LV_HAVE_AVX512
if (n_error_words_avx512 != n_error_words_avx) { if (n_error_words_avx512 != n_error_words_avx) {
perror("The number of errors AVX512 and AVX2 differs !"); 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) { if (n_error_words_avx512_flood != n_error_words_avx_flood) {
perror("The number of errors of flooded AVX512 and AVX2 differs !"); perror("The number of errors of flooded AVX512 and AVX2 differs !");
exit(-1); goto clean_exit;
} }
#endif // LV_HAVE_AVX512 #endif // LV_HAVE_AVX512
printf("\nTest completed successfully!\n\n"); printf("\nTest completed successfully!\n\n");
ret = SRSRAN_SUCCESS;
clean_exit:
if (symbols != NULL) {
free(symbols); free(symbols);
}
if (symbols_s != NULL) {
free(symbols_s); free(symbols_s);
}
if (symbols_c != NULL) {
free(symbols_c); free(symbols_c);
}
if (rm_symbols != NULL) {
free(rm_symbols); free(rm_symbols);
}
if (rm_symbols_s != NULL) {
free(rm_symbols_s); free(rm_symbols_s);
}
if (rm_symbols_c != NULL) {
free(rm_symbols_c); free(rm_symbols_c);
}
if (rm_codewords != NULL) {
free(rm_codewords); free(rm_codewords);
}
if (codewords != NULL) {
free(codewords); free(codewords);
}
if (messages_sim_avx != NULL) {
free(messages_sim_avx); free(messages_sim_avx);
}
if (messages_sim_avx_flood != NULL) {
free(messages_sim_avx_flood); free(messages_sim_avx_flood);
}
if (messages_sim_avx512 != NULL) {
free(messages_sim_avx512); free(messages_sim_avx512);
}
if (messages_sim_avx512_flood != NULL) {
free(messages_sim_avx512_flood); free(messages_sim_avx512_flood);
}
if (messages_sim_c_flood != NULL) {
free(messages_sim_c_flood); free(messages_sim_c_flood);
}
if (messages_sim_c != NULL) {
free(messages_sim_c); free(messages_sim_c);
}
if (messages_sim_s != NULL) {
free(messages_sim_s); free(messages_sim_s);
}
if (messages_sim_f != NULL) {
free(messages_sim_f); free(messages_sim_f);
}
if (messages_true != NULL) {
free(messages_true); free(messages_true);
}
srsran_random_free(random_gen); srsran_random_free(random_gen);
#ifdef LV_HAVE_AVX2 #ifdef LV_HAVE_AVX2
srsran_ldpc_decoder_free(&decoder_avx); 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_f(&rm_rx);
srsran_ldpc_rm_rx_free_s(&rm_rx_s); srsran_ldpc_rm_rx_free_s(&rm_rx_s);
srsran_ldpc_rm_rx_free_c(&rm_rx_c); 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("\n**** %s ****", title);
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("\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", 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 / elapsed_time,
n_batches * batch_size * finalK / elapsed_time, n_batches * batch_size * finalK / elapsed_time,
n_batches * batch_size * finalN / 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 i_o = 0;
uint16_t iPC = 0; uint16_t iPC = 0;
uint16_t iK = 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 i_o = K_set[iKPC]; // includes parity bits
if (i_o == PC_set[iPC]) { // skip if (i_o == PC_set[iPC]) { // skip
iPC = iPC + 1; 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 // number of parity check bits (nPC) and parity check bits of minimum bandwidth nWmPC
uint8_t nPC = 0; uint8_t nPC = 0;
uint8_t nWmPC = 0; uint8_t nWmPC = 0;
if (K >= 18 && K <= 25) { if (K <= 25) {
nPC = 3; nPC = 3;
if (E > K + 189) { if (E > K + 189) {
nWmPC = 1; nWmPC = 1;

@ -140,7 +140,7 @@ int compute_node_type(void* p,
} }
uint16_t code_stage_size = 0; uint16_t code_stage_size = 0;
uint16_t code_size_log_s = 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_size_log_s = code_size_log - s;
code_stage_size = (1U << code_size_log_s); code_stage_size = (1U << code_size_log_s);
for (uint16_t j = 0; j < code_stage_size; j++) { 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); seed = (uint32_t)strtoul(argv[optind], NULL, 0);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -96,7 +96,7 @@ int main(int argc, char** argv)
data[i] = rand() % 2; 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="); INFO("data=");
srsran_vec_fprint_b(stdout, data, num_bits); 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); long_cb = (uint32_t)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); usage(argv[0]);

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

@ -26,7 +26,7 @@
#include "srsran/phy/io/filesink.h" #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)); bzero(q, sizeof(srsran_filesink_t));
q->f = fopen(filename, "w"); 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); nof_frames = (uint32_t)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
case 'm': case 'm':
switch (strtol(argv[optind], NULL, 10)) { switch (strtol(argv[optind], NULL, 10)) {

@ -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) static int cqi_hl_get_subband_size(int nof_prb)
{ {
if (nof_prb < 7) { if (nof_prb < 7) {
return 0; ERROR("Error: nof_prb is invalid (< 7)");
return SRSRAN_ERROR;
} else if (nof_prb <= 26) { } else if (nof_prb <= 26) {
return 4; return 4;
} else if (nof_prb <= 63) { } else if (nof_prb <= 63) {
@ -540,7 +541,8 @@ static int cqi_hl_get_subband_size(int nof_prb)
} else if (nof_prb <= 110) { } else if (nof_prb <= 110) {
return 8; return 8;
} else { } 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) static int cqi_hl_get_bwp_J(int nof_prb)
{ {
if (nof_prb < 7) { if (nof_prb < 7) {
return 0; ERROR("Error: nof_prb is not valid (< 7)");
return SRSRAN_ERROR;
} else if (nof_prb <= 10) { } else if (nof_prb <= 10) {
return 1; return 1;
} else if (nof_prb <= 26) { } else if (nof_prb <= 26) {
@ -560,7 +563,8 @@ static int cqi_hl_get_bwp_J(int nof_prb)
} else if (nof_prb <= 110) { } else if (nof_prb <= 110) {
return 4; return 4;
} else { } 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) 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) { 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 { } else {
// all bw parts have the same number of subbands except the last one // 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) { if (j < J - 1) {
return Nj; return Nj;
} else { } 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 K = cfg->subband_wideband_ratio;
uint32_t J = cqi_hl_get_bwp_J(nof_prb); 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; uint32_t H = J * K + 1;
return H; 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; uint32_t x = ((tti - N_offset) / N_p) % H;
if (x > 0) { 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 { } else {
return 0; 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 // Frequency domain resource assignment
uint32_t N = dci_nr_freq_resource_size_type1(N_UL_BWP_RB); 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); dci->freq_domain_assigment = srsran_bit_pack(&y, N - N_UL_hop - trim);
// Time domain resource assignment 4 bits // Time domain resource assignment 4 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 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: "); PBCH_NR_DEBUG_TX("Packed PBCH bits: ");
srsran_vec_fprint_byte(stdout, a, PBCH_NR_A); 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 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) 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: "); PBCH_NR_DEBUG_RX("Packed PBCH bits: ");
srsran_vec_fprint_byte(stdout, a, PBCH_NR_A); 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; 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: "); PBCH_NR_DEBUG_TX("Allocated: ");
srsran_vec_fprint_byte(stdout, allocated, PBCH_NR_N); 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; 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: "); PBCH_NR_DEBUG_RX("Allocated: ");
srsran_vec_fprint_byte(stdout, allocated, PBCH_NR_N); 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; 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: "); PBCH_NR_DEBUG_TX("d: ");
srsran_vec_fprint_byte(stdout, d, PBCH_NR_N); 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; 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: "); PBCH_NR_DEBUG_RX("d: ");
srsran_vec_fprint_bs(stdout, d, PBCH_NR_N); 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++]; 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: "); // PBCH_NR_DEBUG_TX("Symbols: ");
// srsran_vec_fprint_c(stdout, symbols, PBCH_NR_M); // 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]; 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: "); // PBCH_NR_DEBUG_RX("Symbols: ");
// srsran_vec_fprint_c(stdout, symbols, PBCH_NR_M); // srsran_vec_fprint_c(stdout, symbols, PBCH_NR_M);
// } // }

@ -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); srsran_polar_interleaver_run_u8(c, c_prime, q->K, true);
// Print c and c_prime (after interleaving) // 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="); PDCCH_INFO_TX("c=");
srsran_vec_fprint_hex(stdout, c, q->K); srsran_vec_fprint_hex(stdout, c, q->K);
PDCCH_INFO_TX("c_prime="); 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 // 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="); PDCCH_INFO_TX("d=");
srsran_vec_fprint_byte(stdout, q->d, q->code.N); 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; 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] = {}; char str[128] = {};
srsran_pdcch_nr_info(q, NULL, str, sizeof(str)); srsran_pdcch_nr_info(q, NULL, str, sizeof(str));
PDCCH_INFO_TX("%s", 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 // 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="); PDCCH_DEBUG_RX("ce=");
srsran_vec_fprint_c(stdout, ce->ce, q->M); 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); srsran_predecoding_single(q->symbols, ce->ce, q->symbols, NULL, q->M, 1.0f, ce->noise_var);
// Print symbols if enabled // 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="); PDCCH_DEBUG_RX("symbols=");
srsran_vec_fprint_c(stdout, q->symbols, q->M); 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 // 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="); PDCCH_DEBUG_RX("d=");
srsran_vec_fprint_bs(stdout, d, q->K); 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); srsran_polar_interleaver_run_u8(c_prime, c, q->K, false);
// Print c // 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="); PDCCH_INFO_RX("c_prime=");
srsran_vec_fprint_hex(stdout, c_prime, q->K); srsran_vec_fprint_hex(stdout, c_prime, q->K);
PDCCH_INFO_RX("c="); 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); uint32_t checksum2 = srsran_bit_pack(&ptr, 24);
res->crc = checksum1 == checksum2; 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); PDCCH_INFO_RX("CRC={%06x, %06x}; msg=", checksum1, checksum2);
srsran_vec_fprint_hex(stdout, c, dci_msg->nof_bits); 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; 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] = {}; char str[128] = {};
srsran_pdcch_nr_info(q, res, str, sizeof(str)); srsran_pdcch_nr_info(q, res, str, sizeof(str));
PDCCH_INFO_RX("%s", 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; 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="); DEBUG("b=");
srsran_vec_fprint_b(stdout, q->b[tb->cw_idx], tb->nof_bits); 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 // 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); 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="); DEBUG("d=");
srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); 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; 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="); DEBUG("d=");
srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); 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 // Descrambling
srsran_sequence_apply_c(llr, llr, tb->nof_bits, pdsch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx)); 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="); DEBUG("b=");
srsran_vec_fprint_b(stdout, q->b[tb->cw_idx], tb->nof_bits); 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; 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="); DEBUG("ce=");
srsran_vec_fprint_c(stdout, channel->ce[0][0], nof_re); srsran_vec_fprint_c(stdout, channel->ce[0][0], nof_re);
DEBUG("x="); DEBUG("x=");

@ -195,11 +195,6 @@ int srsran_phich_decode(srsran_phich_t* q,
uint32_t sf_idx = sf->tti % 10; 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 (SRSRAN_CP_ISEXT(q->cell.cp)) {
if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) { if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) {
ERROR("Invalid nseq %d", n_phich.nseq); 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; 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 (SRSRAN_CP_ISEXT(q->cell.cp)) {
if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) { if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) {
ERROR("Invalid nseq %d", n_phich.nseq); 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], cf_t* sf_symbols[SRSRAN_MAX_PORTS],
srsran_pdsch_res_t* out) srsran_pdsch_res_t* out)
{ {
/* Set pointers for layermapping & precoding */
uint32_t i, n; uint32_t i, n;
cf_t* x[SRSRAN_MAX_LAYERS];
if (q != NULL && sf_symbols != NULL && out != NULL && cfg != NULL) { 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, " 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, cfg->pdsch_cfg.grant.nof_prb,
sf->cfi); 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); uint32_t lstart = SRSRAN_NOF_CTRL_SYMBOLS(q->cell, sf->cfi);
for (int j = 0; j < q->nof_rx_antennas; j++) { for (int j = 0; j < q->nof_rx_antennas; j++) {
/* extract symbols */ /* 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) 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->area_id = 1;
pmch_cfg->pdsch_cfg.rnti = SRSRAN_MRNTI;
pmch_cfg->pdsch_cfg.grant.nof_layers = 1; pmch_cfg->pdsch_cfg.grant.nof_layers = 1;
pmch_cfg->pdsch_cfg.grant.nof_prb = cell->nof_prb; pmch_cfg->pdsch_cfg.grant.nof_prb = cell->nof_prb;
pmch_cfg->pdsch_cfg.grant.tb[0].mcs_idx = mbsfn_cfg->mbsfn_mcs; pmch_cfg->pdsch_cfg.grant.tb[0].mcs_idx = mbsfn_cfg->mbsfn_mcs;
@ -410,8 +403,6 @@ int srsran_pmch_encode(srsran_pmch_t* q,
cf_t* sf_symbols[SRSRAN_MAX_PORTS]) cf_t* sf_symbols[SRSRAN_MAX_PORTS])
{ {
int i; 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) { if (q != NULL && cfg != NULL) {
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
@ -440,12 +431,6 @@ int srsran_pmch_encode(srsran_pmch_t* q,
cfg->pdsch_cfg.grant.tb[0].nof_bits, cfg->pdsch_cfg.grant.tb[0].nof_bits,
0); 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 // TODO: use tb_encode directly
if (srsran_dlsch_encode(&q->dl_sch, &cfg->pdsch_cfg, data, q->e)) { if (srsran_dlsch_encode(&q->dl_sch, &cfg->pdsch_cfg, data, q->e)) {
ERROR("Error encoding TB"); 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="); INFO("d=");
srsran_vec_fprint_c(stdout, q->d, resource->nof_symbols * resource->nof_prb * (SRSRAN_NRE - 4)); srsran_vec_fprint_c(stdout, q->d, resource->nof_symbols * resource->nof_prb * (SRSRAN_NRE - 4));
INFO("ce="); 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 // 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) { if (m_ulsch_count != 0) {
DEBUG("UL-SCH bit positions:"); DEBUG("UL-SCH bit positions:");
srsran_vec_fprint_i(stdout, (int*)pos_ulsch, m_ulsch_count); 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="); DEBUG("b=");
srsran_vec_fprint_b(stdout, b, nof_bits); 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 // 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); 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="); DEBUG("d=");
srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); 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; 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="); DEBUG("d=");
srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); 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 // Descrambling
srsran_sequence_apply_c(llr, llr, nof_bits, pusch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx)); 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="); DEBUG("b=");
srsran_vec_fprint_bs(stdout, llr, nof_bits); 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; 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="); DEBUG("ce=");
srsran_vec_fprint_c(stdout, channel->ce[0][0], nof_re); srsran_vec_fprint_c(stdout, channel->ce[0][0], nof_re);
DEBUG("x="); DEBUG("x=");

@ -152,7 +152,7 @@ int srsran_ra_ul_nr_time(const srsran_sch_hl_cfg_nr_t* cfg,
// Row 1 // Row 1
if (cfg->nof_common_time_ra == 0) { if (cfg->nof_common_time_ra == 0) {
srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant); 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); ra_ul_nr_time_hl(&cfg->common_time_ra[m], grant);
} else { } else {
ERROR("Time domain resource selection (m=%d) exceeds the maximum value (%d)", 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 // Row 2
if (cfg->nof_common_time_ra == 0) { if (cfg->nof_common_time_ra == 0) {
srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant); 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); 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 || } 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 // Calculate TB CRC
uint32_t checksum_tb = srsran_crc_checksum_byte(crc_tb, data, tb->tbs); 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="); DEBUG("tb=");
srsran_vec_fprint_byte(stdout, data, tb->tbs / 8); 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); 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); DEBUG("cb%d=", r);
srsran_vec_fprint_byte(stdout, input_ptr, cb_len / 8); 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 // Encode code block
srsran_ldpc_encoder_encode(encoder, q->temp_cb, rm_buffer, cfg.Kr); 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="); DEBUG("encoded=");
srsran_vec_fprint_b(stdout, rm_buffer, encoder->liftN - 2 * encoder->ls); 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"); 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 // 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); DEBUG("CB %d/%d:", r, cfg.C);
srsran_vec_fprint_hex(stdout, q->temp_cb, cb_len); 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); 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: "); DEBUG("Decode: ");
srsran_vec_fprint_byte(stdout, res->payload, tb->tbs / 8); 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) { while ((opt = getopt(argc, argv, "cpndv")) != -1) {
switch (opt) { switch (opt) {
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); usage(argv[0]);

@ -374,7 +374,7 @@ static void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "vR")) != -1) { while ((opt = getopt(argc, argv, "vR")) != -1) {
switch (opt) { switch (opt) {
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
case 'R': case 'R':
nof_repetitions = (uint32_t)strtol(argv[optind], NULL, 10); 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) { while ((opt = getopt(argc, argv, "vR")) != -1) {
switch (opt) { switch (opt) {
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
case 'R': case 'R':
nof_repetitions = (uint32_t)strtol(argv[optind], NULL, 10); 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); sf_idx = (int)(strtol(argv[optind], NULL, 10) % 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
case 'r': case 'r':
nf = (int)strtol(argv[optind], NULL, 10); 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); cell.base.id = (uint32_t)strtol(argv[optind], NULL, 10);
break; break;
case 'v': case 'v':
srsran_verbose++; increase_srsran_verbose_level();
break; break;
default: default:
usage(argv[0]); usage(argv[0]);

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

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

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

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

Loading…
Cancel
Save