mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
258 lines
7.0 KiB
C
258 lines
7.0 KiB
C
/*
|
|
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
|
*/
|
|
|
|
#include <sched.h>
|
|
#include "assertions.h"
|
|
#include "PHY/types.h"
|
|
#include "PHY/defs_RU.h"
|
|
#include "common/oai_version.h"
|
|
#include "common/config/config_userapi.h"
|
|
#include "common/utils/load_module_shlib.h"
|
|
#include "common/ran_context.h"
|
|
#include "radio/ETHERNET/if_defs.h"
|
|
#include "PHY/phy_vars.h"
|
|
#include "PHY/phy_extern.h"
|
|
#include "PHY/TOOLS/phy_scope_interface.h"
|
|
#include "common/utils/LOG/log.h"
|
|
#include "openair2/ENB_APP/enb_paramdef.h"
|
|
#include "system.h"
|
|
#include "nfapi/oai_integration/vendor_ext.h"
|
|
#include <executables/softmodem-common.h>
|
|
#include <executables/thread-common.h>
|
|
#include "executables/nr-softmodem.h"
|
|
#include "nr-oru.h"
|
|
#include "openair1/PHY/INIT/nr_phy_init.h"
|
|
#include "openair1/SCHED_NR/sched_nr.h"
|
|
|
|
pthread_cond_t sync_cond;
|
|
pthread_mutex_t sync_mutex;
|
|
int sync_var = -1; //!< protected by mutex \ref sync_mutex.
|
|
int config_sync_var = -1;
|
|
|
|
int oai_exit = 0;
|
|
int sf_ahead = 4;
|
|
int emulate_rf = 0;
|
|
|
|
RAN_CONTEXT_t RC;
|
|
|
|
|
|
|
|
int64_t uplink_frequency_offset[MAX_NUM_CCs][4];
|
|
|
|
void nfapi_setmode(nfapi_mode_t nfapi_mode)
|
|
{
|
|
return;
|
|
}
|
|
void exit_function(const char *file, const char *function, const int line, const char *s, const int assert)
|
|
{
|
|
if (s != NULL) {
|
|
printf("%s:%d %s() Exiting OAI softmodem: %s\n", file, line, function, s);
|
|
}
|
|
close_log_mem();
|
|
oai_exit = 1;
|
|
RU_t *ru = RC.ru[0];
|
|
|
|
if (ru->rfdevice.trx_end_func) {
|
|
ru->rfdevice.trx_end_func(&ru->rfdevice);
|
|
ru->rfdevice.trx_end_func = NULL;
|
|
}
|
|
|
|
if (ru->ifdevice.trx_end_func) {
|
|
ru->ifdevice.trx_end_func(&ru->ifdevice);
|
|
ru->ifdevice.trx_end_func = NULL;
|
|
}
|
|
|
|
pthread_mutex_destroy(ru->ru_mutex);
|
|
pthread_cond_destroy(ru->ru_cond);
|
|
if (assert) {
|
|
abort();
|
|
} else {
|
|
sleep(1); // allow lte-softmodem threads to exit first
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
}
|
|
|
|
static void get_options(configmodule_interface_t *cfg)
|
|
{
|
|
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
|
|
get_common_options(cfg);
|
|
CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
|
|
|
|
// NRCConfig();
|
|
}
|
|
|
|
nfapi_mode_t nfapi_getmode(void)
|
|
{
|
|
return (NFAPI_MODE_PNF);
|
|
}
|
|
|
|
void oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind)
|
|
{
|
|
AssertFatal(1 == 0, "This is bad ... please check why we get here\n");
|
|
}
|
|
|
|
void wait_eNBs(void)
|
|
{
|
|
return;
|
|
}
|
|
void wait_gNBs(void)
|
|
{
|
|
return;
|
|
}
|
|
|
|
struct timespec timespec_add(struct timespec, struct timespec)
|
|
{
|
|
struct timespec t = {0};
|
|
return t;
|
|
};
|
|
struct timespec timespec_sub(struct timespec, struct timespec)
|
|
{
|
|
struct timespec t = {0};
|
|
return t;
|
|
};
|
|
void beam_index_allocation(uint16_t fapi_beam_index,
|
|
int ant,
|
|
int num_ports,
|
|
int symbols_per_slot,
|
|
int slot,
|
|
uint16_t bitmap_symbols,
|
|
int num_ant_max,
|
|
uint16_t **ant_beam_id_list)
|
|
{
|
|
}
|
|
uint16_t get_first_ant_idx(bool das, uint16_t num_ports_beams, uint16_t beam_id, uint16_t fapi_start_port)
|
|
{
|
|
return 0;
|
|
};
|
|
void nr_fill_du(uint16_t N_ZC, const uint16_t *prach_root_sequence_map, uint16_t nr_du[NR_PRACH_SEQ_LEN_L - 1])
|
|
{
|
|
return;
|
|
};
|
|
|
|
static void sig_handler(int sig_num)
|
|
{
|
|
oai_exit = 1;
|
|
}
|
|
|
|
uint16_t nr_du[838];
|
|
|
|
uint64_t downlink_frequency[MAX_NUM_CCs][4];
|
|
|
|
configmodule_interface_t *uniqCfg = NULL;
|
|
THREAD_STRUCT thread_struct;
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
memset(&RC, 0, sizeof(RC));
|
|
if ((uniqCfg = load_configmodule(argc, argv, 0)) == NULL) {
|
|
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
|
|
}
|
|
|
|
logInit();
|
|
LOG_W(PHY, "%s is experimental software and at this point is not an implementation of a 7.2 O-RAN RU\n", argv[0]);
|
|
printf("Reading in command-line options\n");
|
|
get_options(uniqCfg);
|
|
|
|
if (CONFIG_ISFLAGSET(CONFIG_ABORT)) {
|
|
fprintf(stderr, "Getting configuration failed\n");
|
|
exit(-1);
|
|
}
|
|
|
|
#if T_TRACER
|
|
T_Config_Init();
|
|
#endif
|
|
printf("configuring for RRU\n");
|
|
// strdup to put the sring in the core file for post mortem identification
|
|
LOG_I(HW, "Version: %s\n", strdup(OAI_PACKAGE_VERSION));
|
|
|
|
/* Read configuration */
|
|
|
|
printf("About to Init RU threads\n");
|
|
|
|
lock_memory_to_ram();
|
|
load_dftslib();
|
|
|
|
RC.nb_RU = 1;
|
|
RC.ru = malloc(sizeof(RC.ru));
|
|
|
|
init_NR_RU(config_get_if(), NULL);
|
|
|
|
RU_t *ru = RC.ru[0];
|
|
ORU_t oru = {0};
|
|
oru.ru = ru;
|
|
int ret = get_oru_options(&oru);
|
|
AssertFatal(ret == 0, "Cannot configure oru, check your config file/cmdline");
|
|
ru->numerology = oru.numerology;
|
|
oru_init_frame_parms(&oru);
|
|
NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
|
|
nr_dump_frame_parms(fp);
|
|
init_symbol_rotation(fp);
|
|
init_timeshift_rotation(fp->ofdm_symbol_size, fp->nb_prefix_samples, fp->ofdm_offset_divisor, fp->timeshift_symbol_rotation);
|
|
ru->if_south = LOCAL_RF;
|
|
nr_phy_init_RU(oru.ru);
|
|
fill_rf_config(ru, ru->rf_config_file);
|
|
ru->N_TA_offset = set_default_nta_offset(fp->freq_range, fp->samples_per_subframe);
|
|
|
|
/* set PRACH configuration */
|
|
nfapi_nr_prach_config_t *prach_config = &ru->config.prach_config;
|
|
prach_config->prach_ConfigurationIndex.value = oru.prach_config_index;
|
|
prach_config->num_prach_fd_occasions_list[0].k1.value = oru.prach_msg1_freq;
|
|
prach_config->prach_sequence_length.value = 1;
|
|
prach_config->prach_sub_c_spacing.value = 1;
|
|
prach_config->num_prach_fd_occasions.value = 1;
|
|
|
|
reset_meas(&oru.rx_prach);
|
|
oru.prach_info = get_nr_prach_occasion_info_from_index(oru.prach_config_index, FR1, fp->frame_type);
|
|
LOG_A(PHY, "PRACH configuration index %d\n", oru.prach_config_index);
|
|
LOG_A(PHY,
|
|
"PRACH format %d start_symbol %d duration %d\n",
|
|
oru.prach_info.format,
|
|
oru.prach_info.start_symbol,
|
|
oru.prach_info.N_dur);
|
|
prepare_prach_item(&oru);
|
|
|
|
oru.fronthaul = oru_fh_init(&oru.fh_config);
|
|
AssertFatal(oru.fronthaul != NULL, "Cannot configure oru fronthaul, check your config file/cmdline");
|
|
|
|
LOG_I(PHY, "starting rfdevice\n");
|
|
ret = openair0_device_load(&ru->rfdevice, &ru->openair0_cfg);
|
|
AssertFatal(ret == 0, "RU %u: openair0_device_load() ret %d: cannot initialize rfdevice\n", ru->idx, ret);
|
|
ret = ru->rfdevice.trx_start_func(&ru->rfdevice);
|
|
AssertFatal(ret == 0, "RU %u: trx_start_func() ret %d: cannot start rfdevice\n", ru->idx, ret);
|
|
|
|
threadCreate(&oru.north_read_thread, oru_north_read_thread, (void *)&oru, "north_read_thread", -1, OAI_PRIORITY_RT_MAX);
|
|
threadCreate(&oru.south_read_thread, oru_south_read_thread, (void *)&oru, "south_read_thread", -1, OAI_PRIORITY_RT_MAX);
|
|
usleep(1000);
|
|
oru_fh_start(oru.fronthaul);
|
|
|
|
// Signal handler
|
|
signal(SIGINT, sig_handler);
|
|
|
|
while (oai_exit == 0) {
|
|
oru_fh_print_stats(oru.fronthaul);
|
|
sleep(1);
|
|
}
|
|
|
|
pthread_join(oru.north_read_thread, NULL);
|
|
pthread_join(oru.south_read_thread, NULL);
|
|
|
|
oru_fh_stop(oru.fronthaul);
|
|
|
|
if (ru->rfdevice.trx_stop_func) {
|
|
ru->rfdevice.trx_stop_func(&ru->rfdevice);
|
|
ru->rfdevice.trx_stop_func = NULL;
|
|
}
|
|
|
|
if (ru->rfdevice.trx_end_func) {
|
|
ru->rfdevice.trx_end_func(&ru->rfdevice);
|
|
ru->rfdevice.trx_end_func = NULL;
|
|
}
|
|
|
|
end_configmodule(uniqCfg);
|
|
|
|
logClean();
|
|
printf("Bye.\n");
|
|
return 0;
|
|
}
|