Commit 2ff12533 authored by Bartosz Podrygajlo's avatar Bartosz Podrygajlo

Move init_nr_bler_table out of nr-uesoftmodem.c

parent dc91550e
......@@ -165,10 +165,6 @@ unsigned int NTN_UE_Koffset = 0;
*/
uint8_t abstraction_flag=0;
nr_bler_struct nr_bler_data[NR_NUM_MCS];
static void init_bler_table(char*);
/*---------------------BMC: timespec helpers -----------------------------*/
struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
......@@ -421,9 +417,9 @@ static void get_channel_model_mode(configmodule_interface_t *cfg)
int num_xp_antennas = *GNBParams[GNB_PDSCH_ANTENNAPORTS_XP_IDX].iptr;
if (num_xp_antennas == 2)
init_bler_table("NR_MIMO2x2_AWGN_RESULTS_DIR");
init_nr_bler_table("NR_MIMO2x2_AWGN_RESULTS_DIR");
else
init_bler_table("NR_AWGN_RESULTS_DIR");
init_nr_bler_table("NR_AWGN_RESULTS_DIR");
}
void start_oai_nrue_threads()
......@@ -639,55 +635,3 @@ int main(int argc, char **argv)
return 0;
}
// Read in each MCS file and build BLER-SINR-TB table
static void init_bler_table(char *env_string) {
memset(nr_bler_data, 0, sizeof(nr_bler_data));
const char *awgn_results_dir = getenv(env_string);
if (!awgn_results_dir) {
LOG_W(NR_MAC, "No %s\n", env_string);
return;
}
for (unsigned int i = 0; i < NR_NUM_MCS; i++) {
char fName[1024];
snprintf(fName, sizeof(fName), "%s/mcs%u_awgn_5G.csv", awgn_results_dir, i);
FILE *pFile = fopen(fName, "r");
if (!pFile) {
LOG_E(NR_MAC, "%s: open %s: %s\n", __func__, fName, strerror(errno));
continue;
}
size_t bufSize = 1024;
char * line = NULL;
char * token;
char * temp = NULL;
int nlines = 0;
while (getline(&line, &bufSize, pFile) > 0) {
if (!strncmp(line, "SNR", 3)) {
continue;
}
if (nlines > NR_NUM_SINR) {
LOG_E(NR_MAC, "BLER FILE ERROR - num lines greater than expected - file: %s\n", fName);
abort();
}
token = strtok_r(line, ";", &temp);
int ncols = 0;
while (token != NULL) {
if (ncols > NUM_BLER_COL) {
LOG_E(NR_MAC, "BLER FILE ERROR - num of cols greater than expected\n");
abort();
}
nr_bler_data[i].bler_table[nlines][ncols] = strtof(token, NULL);
ncols++;
token = strtok_r(NULL, ";", &temp);
}
nlines++;
}
nr_bler_data[i].length = nlines;
fclose(pFile);
}
}
......@@ -119,8 +119,6 @@ void nr_derive_key(int alg_type, uint8_t alg_id, const uint8_t key[32], uint8_t
void processSlotTX(void *arg) {}
nr_bler_struct nr_bler_data[NR_NUM_MCS];
// needed for some functions
openair0_config_t openair0_cfg[MAX_CARDS];
void update_ptrs_config(NR_CellGroupConfig_t *secondaryCellGroup, uint16_t *rbSize, uint8_t *mcsIndex,int8_t *ptrs_arg);
......
......@@ -114,8 +114,6 @@ nrUE_params_t *get_nrUE_params(void) {
return &nrUE_params;
}
nr_bler_struct nr_bler_data[NR_NUM_MCS];
void processSlotTX(void *arg) {}
int NB_UE_INST = 1;
configmodule_interface_t *uniqCfg = NULL;
......
......@@ -80,7 +80,6 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
return 0;
}
nr_bler_struct nr_bler_data[NR_NUM_MCS];
void get_nrUE_params(void)
{
return;
......
......@@ -121,8 +121,6 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP,
return 0;
}
nr_bler_struct nr_bler_data[NR_NUM_MCS];
void nr_derive_key(int alg_type, uint8_t alg_id, const uint8_t key[32], uint8_t out[16])
{
(void)alg_type;
......
......@@ -23,6 +23,8 @@
#include "executables/softmodem-common.h"
#include "NR_MAC_UE/mac_proto.h"
nr_bler_struct nr_bler_data[NR_NUM_MCS];
slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT];
void read_channel_param(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t * pdu, int slot, int index)
{
......@@ -204,3 +206,57 @@ int get_mcs_from_sinr(nr_bler_struct *nr_bler_data, float sinr)
LOG_E(NR_MAC, "Unable to get an MCS value.\n");
abort();
}
// Read in each MCS file and build BLER-SINR-TB table
void init_nr_bler_table(const char *env_string)
{
memset(nr_bler_data, 0, sizeof(nr_bler_data));
const char *awgn_results_dir = getenv(env_string);
if (!awgn_results_dir) {
LOG_W(NR_MAC, "No %s\n", env_string);
return;
}
for (unsigned int i = 0; i < NR_NUM_MCS; i++) {
char fName[1024];
snprintf(fName, sizeof(fName), "%s/mcs%u_awgn_5G.csv", awgn_results_dir, i);
FILE *pFile = fopen(fName, "r");
if (!pFile) {
LOG_E(NR_MAC, "%s: open %s: %s\n", __func__, fName, strerror(errno));
continue;
}
size_t bufSize = 1024;
char *line = NULL;
char *token;
char *temp = NULL;
int nlines = 0;
while (getline(&line, &bufSize, pFile) > 0) {
if (!strncmp(line, "SNR", 3)) {
continue;
}
if (nlines > NR_NUM_SINR) {
LOG_E(NR_MAC, "BLER FILE ERROR - num lines greater than expected - file: %s\n", fName);
abort();
}
token = strtok_r(line, ";", &temp);
int ncols = 0;
while (token != NULL) {
if (ncols > NUM_BLER_COL) {
LOG_E(NR_MAC, "BLER FILE ERROR - num of cols greater than expected\n");
abort();
}
nr_bler_data[i].bler_table[nlines][ncols] = strtof(token, NULL);
ncols++;
token = strtok_r(NULL, ";", &temp);
}
nlines++;
}
nr_bler_data[i].length = nlines;
fclose(pFile);
}
}
......@@ -77,5 +77,6 @@ float get_bler_val(uint8_t mcs, int sinr);
bool should_drop_transport_block(int slot, uint16_t rnti);
bool is_channel_modeling(void);
int get_mcs_from_sinr(nr_bler_struct *nr_bler_data, float sinr);
void init_nr_bler_table(const char *env_string);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment