Commit fb465455 authored by frtabu's avatar frtabu

Fix corrupted LOGs in L1L2simulator, introducing two new components NFAPI_VNF...

Fix corrupted LOGs in L1L2simulator, introducing two new components NFAPI_VNF and NFAPI_pnf. Integrate Fujitsu fix for up to 50 UEs. Apply astyle to all modified files in the branch
parent f3dc8d44
......@@ -303,8 +303,8 @@ void log_getconfig(log_t *g_log) {
logparams_dump[i].numelt = 0;
}
config_get( logparams_debug,(sizeof(log_maskmap)/sizeof(mapping)) - 1 ,CONFIG_STRING_LOG_PREFIX);
config_get( logparams_dump,(sizeof(log_maskmap)/sizeof(mapping)) - 1 ,CONFIG_STRING_LOG_PREFIX);
config_get( logparams_debug,(sizeof(log_maskmap)/sizeof(mapping)) - 1,CONFIG_STRING_LOG_PREFIX);
config_get( logparams_dump,(sizeof(log_maskmap)/sizeof(mapping)) - 1,CONFIG_STRING_LOG_PREFIX);
config_check_unknown_cmdlineopt(CONFIG_STRING_LOG_PREFIX);
/* set the debug mask according to the debug parameters values */
......@@ -385,7 +385,6 @@ int logInit (void) {
register_log_component("OCG","",OCG);
register_log_component("PERF","",PERF);
register_log_component("OIP","",OIP);
register_log_component("CLI","",CLI);
register_log_component("MSC","log",MSC);
register_log_component("OCM","log",OCM);
register_log_component("HW","",HW);
......@@ -408,6 +407,8 @@ int logInit (void) {
register_log_component("X2AP","",X2AP);
register_log_component("LOADER","log",LOADER);
register_log_component("ASN","log",ASN);
register_log_component("NFAPI_PNF","log",NFAPI_PNF);
register_log_component("NFAPI_VNF","log",NFAPI_VNF);
for (int i=0 ; log_level_names[i].name != NULL ; i++)
g_log->level2string[i] = toupper(log_level_names[i].name[0]); // uppercased first letter of level name
......@@ -438,7 +439,7 @@ char *log_getthreadname(char *threadname, int bufsize) {
static int log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) {
char threadname[PR_SET_NAME];
return snprintf(log_buffer, buffsize , "%s%s[%s]%c %s %s%s",
return snprintf(log_buffer, buffsize, "%s%s[%s]%c %s %s%s",
log_level_highlight_end[level],
( (g_log->flag & FLAG_NOCOLOR)?"":log_level_highlight_start[level]),
g_log->log_component[comp].name,
......@@ -452,11 +453,17 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, int le
char log_buffer[MAX_LOG_TOTAL];
va_list args;
va_start(args, format);
log_header(log_buffer,MAX_LOG_TOTAL ,comp, level,format);
log_header(log_buffer,MAX_LOG_TOTAL,comp, level,format);
g_log->log_component[comp].vprint(g_log->log_component[comp].stream,log_buffer, args);
va_end(args);
}
void vlogRecord_mt(const char *file, const char *func, int line, int comp, int level, const char *format, va_list args ) {
char log_buffer[MAX_LOG_TOTAL];
log_header(log_buffer,MAX_LOG_TOTAL,comp, level,format);
g_log->log_component[comp].vprint(g_log->log_component[comp].stream,log_buffer, args);
}
void log_dump(int component, void *buffer, int buffsize,int datatype, const char *format, ... ) {
va_list args;
char *wbuf;
......@@ -474,7 +481,7 @@ void log_dump(int component, void *buffer, int buffsize,int datatype, const char
if (wbuf != NULL) {
va_start(args, format);
int pos=log_header(wbuf,MAX_LOG_TOTAL ,component, OAILOG_INFO,"");
int pos=log_header(wbuf,MAX_LOG_TOTAL,component, OAILOG_INFO,"");
int pos2=vsprintf(wbuf+pos,format, args);
pos=pos+pos2;
va_end(args);
......
......@@ -198,7 +198,6 @@ typedef enum {
NAS,
PERF,
OIP,
CLI,
MSC,
OCM,
UDP_,
......@@ -218,6 +217,8 @@ typedef enum {
X2AP,
LOADER,
ASN,
NFAPI_VNF,
NFAPI_PNF,
MAX_LOG_PREDEF_COMPONENTS,
}
comp_name_t;
......@@ -286,6 +287,7 @@ extern "C" {
int logInit (void);
int isLogInitDone (void);
void logRecord_mt(const char *file, const char *func, int line,int comp, int level, const char *format, ...) __attribute__ ((format (printf, 6, 7)));
void vlogRecord_mt(const char *file, const char *func, int line, int comp, int level, const char *format, va_list args );
void log_dump(int component, void *buffer, int buffsize,int datatype, const char *format, ... );
int set_log(int component, int level);
void set_glog(int level);
......@@ -365,9 +367,9 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
# define LOG_I(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} else { T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) ;}} while (0)
# define LOG_D(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} else { T(T_LEGACY_ ## c ## _DEBUG, T_PRINTF(x)) ;}} while (0)
# define LOG_T(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} else { T(T_LEGACY_ ## c ## _TRACE, T_PRINTF(x)) ;}} while (0)
# define VLOG(c,l, f, args) do { if (T_stdout) { if( g_log->log_component[c].level >= l ) vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, l, f, args) ;} } while (0)
/* macro used to dump a buffer or a message as in openair2/RRC/LTE/RRC_eNB.c, replaces LOG_F macro */
# define LOG_DUMPMSG(c, f, b, s, x...) do { if(g_log->dump_mask & f) log_dump(c, b, s, LOG_DUMP_CHAR, x) ;} while (0) /* */
# define nfapi_log(FILE, FNC, LN, COMP, LVL, F...) do { if (T_stdout) { logRecord_mt(__FILE__, __FUNCTION__, __LINE__,COMP, LVL, F) ;}} while (0) /* */
/* bitmask dependant macros, to isolate debugging code */
# define LOG_DEBUGFLAG(D) (g_log->debug_mask & D)
......
......@@ -800,6 +800,47 @@ ID = LEGACY_SIM_TRACE
GROUP = ALL:LEGACY_SIM:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_INFO
DESC = NFAPI_VNF legacy logs - info level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_ERROR
DESC = NFAPI_VNF legacy logs - error level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_WARNING
DESC = NFAPI_VNF legacy logs - warning level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_WARNING:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_DEBUG
DESC = NFAPI_VNF legacy logs - debug level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_VNF_TRACE
DESC = NFAPI_VNF legacy logs - trace level
GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_INFO
DESC = NFAPI_PNF legacy logs - info level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_ERROR
DESC = NFAPI_PNF legacy logs - error level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_WARNING
DESC = NFAPI_PNF legacy logs - warning level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_WARNING:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_DEBUG
DESC = NFAPI_PNF legacy logs - debug level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_NFAPI_PNF_TRACE
DESC = NFAPI_PNF legacy logs - trace level
GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
# this is a bad hack but I won't fix (function util_print_hex_octets
# in openairinterface5g/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c
# does funky things with the LOG_x macros but we work on the C pre-processor
......@@ -845,27 +886,7 @@ ID = LEGACY_componentP_TRACE
GROUP = ALL:LEGACY_componentP:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
#needed?
ID = LEGACY_CLI_INFO
DESC = CLI legacy logs - info level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_CLI_ERROR
DESC = CLI legacy logs - error level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
ID = LEGACY_CLI_WARNING
DESC = CLI legacy logs - warning level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_WARNING:LEGACY
FORMAT = string,log
ID = LEGACY_CLI_DEBUG
DESC = CLI legacy logs - debug level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_CLI_TRACE
DESC = CLI legacy logs - trace level
GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
#################
#### UE LOGS ####
......
......@@ -57,7 +57,7 @@ extern RAN_CONTEXT_t RC;
#define _GNU_SOURCE
extern void phy_init_RU(RU_t*);
extern void phy_init_RU(RU_t *);
extern int config_sync_var;
extern pthread_cond_t nfapi_sync_cond;
......@@ -78,7 +78,7 @@ extern void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, nfapi_d
extern uint8_t nfapi_mode;
nfapi_tx_request_pdu_t* tx_request_pdu[1023][10][10]; // [frame][subframe][max_num_pdus]
nfapi_tx_request_pdu_t *tx_request_pdu[1023][10][10]; // [frame][subframe][max_num_pdus]
uint8_t tx_pdus[32][8][4096];
......@@ -90,11 +90,11 @@ nfapi_pnf_param_response_t g_pnf_param_resp;
nfapi_pnf_p7_config_t *p7_config_g = NULL;
void* pnf_allocate(size_t size) {
void *pnf_allocate(size_t size) {
return malloc(size);
}
void pnf_deallocate(void* ptr) {
void pnf_deallocate(void *ptr) {
free(ptr);
}
......@@ -109,36 +109,36 @@ typedef struct {
} udp_data;
typedef struct {
uint16_t index;
uint16_t id;
uint8_t rfs[2];
uint8_t excluded_rfs[2];
uint16_t index;
uint16_t id;
uint8_t rfs[2];
uint8_t excluded_rfs[2];
udp_data udp;
udp_data udp;
char local_addr[80];
int local_port;
char local_addr[80];
int local_port;
char* remote_addr;
int remote_port;
char *remote_addr;
int remote_port;
uint8_t duplex_mode;
uint16_t dl_channel_bw_support;
uint16_t ul_channel_bw_support;
uint8_t num_dl_layers_supported;
uint8_t num_ul_layers_supported;
uint16_t release_supported;
uint8_t nmm_modes_supported;
uint8_t duplex_mode;
uint16_t dl_channel_bw_support;
uint16_t ul_channel_bw_support;
uint8_t num_dl_layers_supported;
uint8_t num_ul_layers_supported;
uint16_t release_supported;
uint8_t nmm_modes_supported;
uint8_t dl_ues_per_subframe;
uint8_t ul_ues_per_subframe;
uint8_t dl_ues_per_subframe;
uint8_t ul_ues_per_subframe;
uint8_t first_subframe_ind;
uint8_t first_subframe_ind;
// timing information recevied from the vnf
uint8_t timing_window;
uint8_t timing_info_mode;
uint8_t timing_info_period;
// timing information recevied from the vnf
uint8_t timing_window;
uint8_t timing_info_mode;
uint8_t timing_info_period;
} phy_info;
......@@ -158,36 +158,36 @@ typedef struct {
typedef struct {
int release;
phy_info phys[2];
rf_info rfs[2];
uint8_t sync_mode;
uint8_t location_mode;
uint8_t location_coordinates[6];
uint32_t dl_config_timing;
uint32_t ul_config_timing;
uint32_t tx_timing;
uint32_t hi_dci0_timing;
uint16_t max_phys;
uint16_t max_total_bw;
uint16_t max_total_dl_layers;
uint16_t max_total_ul_layers;
uint8_t shared_bands;
uint8_t shared_pa;
int16_t max_total_power;
uint8_t oui;
uint8_t wireshark_test_mode;
int release;
phy_info phys[2];
rf_info rfs[2];
uint8_t sync_mode;
uint8_t location_mode;
uint8_t location_coordinates[6];
uint32_t dl_config_timing;
uint32_t ul_config_timing;
uint32_t tx_timing;
uint32_t hi_dci0_timing;
uint16_t max_phys;
uint16_t max_total_bw;
uint16_t max_total_dl_layers;
uint16_t max_total_ul_layers;
uint8_t shared_bands;
uint8_t shared_pa;
int16_t max_total_power;
uint8_t oui;
uint8_t wireshark_test_mode;
} pnf_info;
typedef struct {
uint16_t phy_id;
nfapi_pnf_config_t* config;
phy_info* phy;
nfapi_pnf_p7_config_t* p7_config;
nfapi_pnf_config_t *config;
phy_info *phy;
nfapi_pnf_p7_config_t *p7_config;
} pnf_phy_user_data_t;
static pnf_info pnf;
......@@ -195,32 +195,34 @@ static pthread_t pnf_start_pthread;
int nfapitooai_level(int nfapi_level) {
switch(nfapi_level) {
case NFAPI_TRACE_ERROR:
return LOG_ERR;
case NFAPI_TRACE_WARN:
return LOG_WARNING;
case NFAPI_TRACE_ERROR:
return LOG_ERR;
case NFAPI_TRACE_WARN:
return LOG_WARNING;
case NFAPI_TRACE_NOTE:
return LOG_INFO;
case NFAPI_TRACE_INFO:
return LOG_DEBUG;
}
return LOG_INFO;
case NFAPI_TRACE_INFO:
return LOG_DEBUG;
}
return LOG_ERR;
}
void pnf_nfapi_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) {
void pnf_nfapi_trace(nfapi_trace_level_t nfapi_level, const char *message, ...) {
va_list args;
va_start(args, message);
nfapi_log("FILE>", "FUNC", 999, PHY, nfapitooai_level(nfapi_level), message, args);
VLOG( NFAPI_PNF, nfapitooai_level(nfapi_level), message, args);
va_end(args);
}
void pnf_set_thread_priority(int priority) {
pthread_attr_t ptAttr;
struct sched_param schedParam;
schedParam.__sched_priority = priority;
if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) {
printf("failed to set SCHED_RR\n");
}
......@@ -230,36 +232,29 @@ void pnf_set_thread_priority(int priority) {
}
pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED);
struct sched_param thread_params;
thread_params.sched_priority = 20;
if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0) {
printf("failed to set sched param\n");
}
}
void* pnf_p7_thread_start(void* ptr) {
void *pnf_p7_thread_start(void *ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P7 THREAD %s\n", __FUNCTION__);
pnf_set_thread_priority(79);
nfapi_pnf_p7_config_t* config = (nfapi_pnf_p7_config_t*)ptr;
nfapi_pnf_p7_config_t *config = (nfapi_pnf_p7_config_t *)ptr;
nfapi_pnf_p7_start(config);
return 0;
}
int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req) {
int pnf_param_request(nfapi_pnf_config_t *config, nfapi_pnf_param_request_t *req) {
printf("[PNF] pnf param request\n");
nfapi_pnf_param_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_PARAM_RESPONSE;
resp.error_code = NFAPI_MSG_OK;
pnf_info* pnf = (pnf_info*)(config->user_data);
pnf_info *pnf = (pnf_info *)(config->user_data);
resp.pnf_param_general.tl.tag = NFAPI_PNF_PARAM_GENERAL_TAG;
resp.pnf_param_general.nfapi_sync_mode = pnf->sync_mode;
resp.pnf_param_general.location_mode = pnf->location_mode;
......@@ -274,25 +269,25 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req
resp.pnf_param_general.shared_bands = pnf->shared_bands;
resp.pnf_param_general.shared_pa = pnf->shared_pa;
resp.pnf_param_general.maximum_total_power = pnf->max_total_power;
resp.pnf_phy.tl.tag = NFAPI_PNF_PHY_TAG;
resp.pnf_phy.number_of_phys = 1;
for(int i = 0; i < 1; ++i) {
resp.pnf_phy.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy.phy[i].downlink_channel_bandwidth_supported = pnf->phys[i].dl_channel_bw_support;
resp.pnf_phy.phy[i].uplink_channel_bandwidth_supported = pnf->phys[i].ul_channel_bw_support;
resp.pnf_phy.phy[i].number_of_dl_layers_supported = pnf->phys[i].num_dl_layers_supported;
resp.pnf_phy.phy[i].number_of_ul_layers_supported = pnf->phys[i].num_ul_layers_supported;
resp.pnf_phy.phy[i].maximum_3gpp_release_supported = pnf->phys[i].release_supported;
resp.pnf_phy.phy[i].nmm_modes_supported = pnf->phys[i].nmm_modes_supported;
resp.pnf_phy.phy[i].number_of_rfs = 2;
for(int j = 0; j < 1; ++j) {
resp.pnf_phy.phy[i].rf_config[j].rf_config_index = pnf->phys[i].rfs[j];
}
resp.pnf_phy.phy[i].number_of_rf_exclusions = 0;
for(int j = 0; j < 0; ++j) {
resp.pnf_phy.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j];
}
......@@ -302,9 +297,9 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req
resp.pnf_rf.number_of_rfs = 2;
for(int i = 0; i < 2; ++i) {
resp.pnf_rf.rf[i].rf_config_index = pnf->rfs[i].index;
resp.pnf_rf.rf[i].rf_config_index = pnf->rfs[i].index;
resp.pnf_rf.rf[i].band = pnf->rfs[i].band;
resp.pnf_rf.rf[i].maximum_transmit_power = pnf->rfs[i].max_transmit_power;
resp.pnf_rf.rf[i].maximum_transmit_power = pnf->rfs[i].max_transmit_power;
resp.pnf_rf.rf[i].minimum_transmit_power = pnf->rfs[i].min_transmit_power;
resp.pnf_rf.rf[i].number_of_antennas_suppported = pnf->rfs[i].num_antennas_supported;
resp.pnf_rf.rf[i].minimum_downlink_frequency = pnf->rfs[i].min_downlink_frequency;
......@@ -317,9 +312,8 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req
resp.pnf_phy_rel10.tl.tag = NFAPI_PNF_PHY_REL10_TAG;
resp.pnf_phy_rel10.number_of_phys = 1;
for(int i = 0; i < 1; ++i)
{
resp.pnf_phy_rel10.phy[i].phy_config_index = pnf->phys[i].index;
for(int i = 0; i < 1; ++i) {
resp.pnf_phy_rel10.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel10.phy[i].transmission_mode_7_supported = 0;
resp.pnf_phy_rel10.phy[i].transmission_mode_8_supported = 1;
resp.pnf_phy_rel10.phy[i].two_antenna_ports_for_pucch = 0;
......@@ -334,7 +328,7 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req
resp.pnf_phy_rel11.number_of_phys = 1;
for(int i = 0; i < 1; ++i) {
resp.pnf_phy_rel11.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel11.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel11.phy[i].edpcch_supported = 0;
resp.pnf_phy_rel11.phy[i].multi_ack_csi_reporting = 1;
resp.pnf_phy_rel11.phy[i].pucch_tx_diversity = 0;
......@@ -348,7 +342,7 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req
resp.pnf_phy_rel12.number_of_phys = 1;
for(int i = 0; i < 1; ++i) {
resp.pnf_phy_rel12.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel12.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel12.phy[i].csi_subframe_set = 0;
resp.pnf_phy_rel12.phy[i].enhanced_4tx_codebook = 2;
resp.pnf_phy_rel12.phy[i].drs_supported = 0;
......@@ -363,7 +357,7 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req
resp.pnf_phy_rel13.number_of_phys = 1;
for(int i = 0; i < 1; ++i) {
resp.pnf_phy_rel13.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel13.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel13.phy[i].pucch_format4_supported = 0;
resp.pnf_phy_rel13.phy[i].pucch_format5_supported = 1;
resp.pnf_phy_rel13.phy[i].more_than_5_ca_support = 0;
......@@ -380,14 +374,15 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req
resp.pnf_phy_rel13_nb_iot.number_of_phys = 1;
for(int i = 0; i < 1; ++i) {
resp.pnf_phy_rel13_nb_iot.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel13_nb_iot.phy[i].phy_config_index = pnf->phys[i].index;
resp.pnf_phy_rel13_nb_iot.phy[i].number_of_rfs = 1;
for(int j = 0; j < 1; ++j) {
resp.pnf_phy_rel13_nb_iot.phy[i].rf_config[j].rf_config_index = pnf->phys[i].rfs[j];
}
resp.pnf_phy_rel13_nb_iot.phy[i].number_of_rf_exclusions = 1;
for(int j = 0; j < 1; ++j) {
resp.pnf_phy_rel13_nb_iot.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j];
}
......@@ -400,51 +395,39 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req
}
nfapi_pnf_pnf_param_resp(config, &resp);
return 0;
}
int pnf_config_request(nfapi_pnf_config_t* config, nfapi_pnf_config_request_t* req) {
int pnf_config_request(nfapi_pnf_config_t *config, nfapi_pnf_config_request_t *req) {
printf("[PNF] pnf config request\n");
pnf_info* pnf = (pnf_info*)(config->user_data);
pnf_info *pnf = (pnf_info *)(config->user_data);
phy_info *phy = pnf->phys;
phy->id = req->pnf_phy_rf_config.phy_rf_config[0].phy_id;
printf("[PNF] pnf config request assigned phy_id %d to phy_config_index %d\n", phy->id, req->pnf_phy_rf_config.phy_rf_config[0].phy_config_index);
nfapi_pnf_config_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE;
resp.error_code = NFAPI_MSG_OK;
nfapi_pnf_pnf_config_resp(config, &resp);
printf("[PNF] Sent pnf_config_resp\n");
return 0;
}
void nfapi_send_pnf_start_resp(nfapi_pnf_config_t* config, uint16_t phy_id) {
void nfapi_send_pnf_start_resp(nfapi_pnf_config_t *config, uint16_t phy_id) {
printf("Sending NFAPI_START_RESPONSE config:%p phy_id:%d\n", config, phy_id);
nfapi_start_response_t start_resp;
memset(&start_resp, 0, sizeof(start_resp));
start_resp.header.message_id = NFAPI_START_RESPONSE;
start_resp.header.phy_id = phy_id;
start_resp.error_code = NFAPI_MSG_OK;
nfapi_pnf_start_resp(config, &start_resp);
}
int pnf_start_request(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req) {
int pnf_start_request(nfapi_pnf_config_t *config, nfapi_pnf_start_request_t *req) {
printf("Received NFAPI_PNF_START_REQUEST\n");
pnf_info* pnf = (pnf_info*)(config->user_data);
pnf_info *pnf = (pnf_info *)(config->user_data);
// start all phys that have been configured
phy_info* phy = pnf->phys;
phy_info *phy = pnf->phys;
if(phy->id != 0) {
nfapi_pnf_start_response_t resp;
......@@ -454,79 +437,62 @@ int pnf_start_request(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req
nfapi_pnf_pnf_start_resp(config, &resp);
printf("[PNF] Sent NFAPI_PNF_START_RESP\n");
}
return 0;
}
int pnf_stop_request(nfapi_pnf_config_t* config, nfapi_pnf_stop_request_t* req) {
int pnf_stop_request(nfapi_pnf_config_t *config, nfapi_pnf_stop_request_t *req) {
printf("[PNF] Received NFAPI_PNF_STOP_REQ\n");
nfapi_pnf_stop_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_STOP_RESPONSE;
resp.error_code = NFAPI_MSG_OK;
nfapi_pnf_pnf_stop_resp(config, &resp);
printf("[PNF] Sent NFAPI_PNF_STOP_REQ\n");
return 0;
}
int param_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_param_request_t* req) {
int param_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_param_request_t *req) {
printf("[PNF] Received NFAPI_PARAM_REQUEST phy_id:%d\n", req->header.phy_id);
//pnf_info* pnf = (pnf_info*)(config->user_data);
nfapi_param_response_t nfapi_resp;
pnf_info* pnf = (pnf_info*)(config->user_data);
pnf_info *pnf = (pnf_info *)(config->user_data);
memset(&nfapi_resp, 0, sizeof(nfapi_resp));
nfapi_resp.header.message_id = NFAPI_PARAM_RESPONSE;
nfapi_resp.header.phy_id = req->header.phy_id;
nfapi_resp.error_code = 0; // DJP - what value???
struct sockaddr_in pnf_p7_sockaddr;
pnf_p7_sockaddr.sin_addr.s_addr = inet_addr(pnf->phys[0].local_addr);
nfapi_resp.nfapi_config.p7_pnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG;
memcpy(nfapi_resp.nfapi_config.p7_pnf_address_ipv4.address, &pnf_p7_sockaddr.sin_addr.s_addr, 4);
nfapi_resp.num_tlv++;
// P7 PNF Port
nfapi_resp.nfapi_config.p7_pnf_port.tl.tag = NFAPI_NFAPI_P7_PNF_PORT_TAG;
nfapi_resp.nfapi_config.p7_pnf_port.value = 32123; // DJP - hard code alert!!!! FIXME TODO
nfapi_resp.num_tlv++;
nfapi_pnf_param_resp(config, &nfapi_resp);
printf("[PNF] Sent NFAPI_PARAM_RESPONSE phy_id:%d number_of_tlvs:%u\n", req->header.phy_id, nfapi_resp.num_tlv);
printf("[PNF] param request .. exit\n");
return 0;
}
int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_config_request_t* req) {
int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_config_request_t *req) {
printf("[PNF] Received NFAPI_CONFIG_REQ phy_id:%d\n", req->header.phy_id);
pnf_info* pnf = (pnf_info*)(config->user_data);
pnf_info *pnf = (pnf_info *)(config->user_data);
uint8_t num_tlv = 0;
//struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
// In the case of nfapi_mode = 3 (UE = PNF) we should not have dependency on any eNB var. So we aim
// to keep only the necessary just to keep the nfapi FSM rolling by sending a dummy response.
LTE_DL_FRAME_PARMS *fp;
if (nfapi_mode!=3) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
fp = &eNB->frame_parms;
}
else{
fp = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS));
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
fp = &eNB->frame_parms;
} else {
fp = (LTE_DL_FRAME_PARMS *) malloc(sizeof(LTE_DL_FRAME_PARMS));
}
phy_info* phy_info = pnf->phys;
phy_info *phy_info = pnf->phys;
if(req->nfapi_config.timing_window.tl.tag == NFAPI_NFAPI_TIMING_WINDOW_TAG) {
phy_info->timing_window = req->nfapi_config.timing_window.value;
......@@ -576,9 +542,8 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap
fp->dl_CarrierFreq = from_earfcn(fp->eutra_band, req->nfapi_config.earfcn.value);
fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_uldl_offset(fp->eutra_band) * 1e5);
num_tlv++;
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() earfcn:%u dl_carrierFreq:%u ul_CarrierFreq:%u band:%u N_RB_DL:%u\n",
__FUNCTION__, req->nfapi_config.earfcn.value, fp->dl_CarrierFreq, fp->ul_CarrierFreq, pnf->rfs[0].band, fp->N_RB_DL);
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() earfcn:%u dl_carrierFreq:%u ul_CarrierFreq:%u band:%u N_RB_DL:%u\n",
__FUNCTION__, req->nfapi_config.earfcn.value, fp->dl_CarrierFreq, fp->ul_CarrierFreq, pnf->rfs[0].band, fp->N_RB_DL);
}
if (req->subframe_config.duplex_mode.tl.tag == NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG) {
......@@ -683,28 +648,22 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap
}
if(nfapi_mode!=3) {
printf("[PNF] CONFIG_REQUEST[num_tlv:%d] TLVs processed:%d\n", req->num_tlv, num_tlv);
printf("[PNF] Simulating PHY CONFIG - DJP\n");
PHY_Config_t phy_config;
phy_config.Mod_id = 0;
phy_config.CC_id=0;
phy_config.cfg = req;
phy_config_request(&phy_config);
dump_frame_parms(fp);
printf("[PNF] CONFIG_REQUEST[num_tlv:%d] TLVs processed:%d\n", req->num_tlv, num_tlv);
printf("[PNF] Simulating PHY CONFIG - DJP\n");
PHY_Config_t phy_config;
phy_config.Mod_id = 0;
phy_config.CC_id=0;
phy_config.cfg = req;
phy_config_request(&phy_config);