LTE and NR NFAPI integration

This commit is contained in:
Mahesh
2020-11-11 15:10:32 +05:30
parent 643fc632d6
commit e6bf90e2dd
35 changed files with 5371 additions and 454 deletions
+19 -3
View File
@@ -1949,7 +1949,23 @@ set (MCE_APP_SRC
${OPENAIR2_DIR}/MCE_APP/mce_app.c
${OPENAIR2_DIR}/MCE_APP/mce_config.c
)
set (MISC_NFAPI_LTE
${OPENAIR1_DIR}/SCHED/nfapi_lte_dummy.c
)
add_library(MISC_NFAPI_LTE_LIB
${MISC_NFAPI_LTE}
)
set (MISC_NFAPI_NR
${OPENAIR1_DIR}/SCHED/nfapi_nr_dummy.c
)
add_library(MISC_NFAPI_NR_LIB
${MISC_NFAPI_NR}
)
add_library(L2
${L2_SRC}
${MAC_SRC}
@@ -2662,7 +2678,7 @@ add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer)
target_link_libraries (lte-softmodem
-Wl,--start-group
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB
PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7
PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB LFDS7
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB}
-Wl,--end-group z dl)
@@ -2773,7 +2789,7 @@ target_link_libraries (lte-uesoftmodem
-Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP F1AP_LIB
GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON
PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU_COMMON SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU_COMMON SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${ATLAS_LIBRARIES}
-Wl,--end-group z dl)
@@ -2858,7 +2874,7 @@ target_link_libraries (nr-uesoftmodem
-Wl,--start-group
RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB
PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB
NFAPI_USER_LIB S1AP_LIB S1AP_ENB
NFAPI_USER_LIB MISC_NFAPI_NR_LIB S1AP_LIB S1AP_ENB
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES}
-Wl,--end-group z dl)
+2 -2
View File
@@ -89,8 +89,8 @@ unsigned short config_frames[4] = {2,9,11,13};
pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex;
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
uint16_t sf_ahead=6; //??? value ???
uint16_t slot_ahead = 6;
uint16_t sf_ahead=4; //??? value ???
// uint16_t slot_ahead = 6;
pthread_cond_t sync_cond;
pthread_mutex_t sync_mutex;
int sync_var=-1; //!< protected by mutex \ref sync_mutex.
+485 -19
View File
@@ -83,17 +83,28 @@ extern void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame, int subframe, L1
extern void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame, int subframe, L1_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu);
extern void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame, int subframe, L1_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu);
extern void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t *sdu);
extern void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu);
extern void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu);
extern void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
uint8_t *sdu);
extern void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu);
nfapi_tx_request_pdu_t *tx_request_pdu[1023][10][10]; // [frame][subframe][max_num_pdus]
nfapi_nr_pdu_t *tx_data_request[1023][20][10]; //[frame][slot][max_num_pdus]
uint8_t tx_pdus[32][8][4096];
nfapi_ue_release_request_body_t release_rntis;
uint16_t phy_antenna_capability_values[] = { 1, 2, 4, 8, 16 };
nfapi_pnf_param_response_t g_pnf_param_resp;
nfapi_nr_pnf_param_response_t g_pnf_param_resp;
nfapi_pnf_p7_config_t *p7_config_g = NULL;
@@ -256,7 +267,14 @@ void *pnf_p7_thread_start(void *ptr) {
return 0;
}
/*
void *pnf_nr_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_nr_pnf_p7_start(config);
return 0;
}
int pnf_nr_param_request(nfapi_pnf_config_t *config, nfapi_nr_pnf_param_request_t *req) {
printf("[PNF] pnf param request\n");
nfapi_nr_pnf_param_response_t resp;
@@ -301,10 +319,10 @@ int pnf_nr_param_request(nfapi_pnf_config_t *config, nfapi_nr_pnf_param_request_
resp.pnf_phy.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j];
}
}
nfapi_pnf_pnf_param_resp(config, &resp);
nfapi_nr_pnf_pnf_param_resp(config, &resp);
return 0;
}
*/
int pnf_param_request(nfapi_pnf_config_t *config, nfapi_pnf_param_request_t *req) {
printf("[PNF] pnf param request\n");
@@ -350,7 +368,7 @@ int pnf_param_request(nfapi_pnf_config_t *config, nfapi_pnf_param_request_t *req
resp.pnf_phy.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j];
}
}
/*
resp.pnf_rf.tl.tag = NFAPI_PNF_RF_TAG;
resp.pnf_rf.number_of_rfs = 2;
@@ -451,7 +469,7 @@ int pnf_param_request(nfapi_pnf_config_t *config, nfapi_pnf_param_request_t *req
resp.pnf_phy_rel13_nb_iot.phy[i].nmm_modes_supported = pnf->phys[i].nmm_modes_supported;
}
}
*/
nfapi_pnf_pnf_param_resp(config, &resp);
return 0;
}
@@ -471,14 +489,39 @@ int pnf_config_request(nfapi_pnf_config_t *config, nfapi_pnf_config_request_t *r
return 0;
}
int pnf_nr_config_request(nfapi_pnf_config_t *config, nfapi_nr_pnf_config_request_t *req) {
printf("[PNF] pnf config request\n");
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_nr_pnf_config_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_RESPONSE;
resp.error_code = NFAPI_MSG_OK;
nfapi_nr_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) {
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);
}
void nfapi_nr_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_nr_start_response_scf_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);
nfapi_nr_pnf_start_resp(config, &start_resp);
}
int pnf_start_request(nfapi_pnf_config_t *config, nfapi_pnf_start_request_t *req) {
@@ -499,6 +542,24 @@ int pnf_start_request(nfapi_pnf_config_t *config, nfapi_pnf_start_request_t *req
return 0;
}
int pnf_nr_start_request(nfapi_pnf_config_t *config, nfapi_nr_pnf_start_request_t *req) {
printf("Received NFAPI_PNF_START_REQUEST\n");
pnf_info *pnf = (pnf_info *)(config->user_data);
// start all phys that have been configured
phy_info *phy = pnf->phys;
if(phy->id != 0) {
nfapi_nr_pnf_start_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PNF_START_RESPONSE;
resp.error_code = NFAPI_MSG_OK;
nfapi_nr_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) {
printf("[PNF] Received NFAPI_PNF_STOP_REQ\n");
nfapi_pnf_stop_response_t resp;
@@ -510,13 +571,37 @@ int pnf_stop_request(nfapi_pnf_config_t *config, nfapi_pnf_stop_request_t *req)
return 0;
}
int param_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_nr_param_request_scf_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);
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 nr_param_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_nr_param_request_scf_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_nr_param_response_scf_t nfapi_resp;
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.message_id = NFAPI_NR_PHY_MSG_TYPE_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;
@@ -723,14 +808,217 @@ int param_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi
nfapi_resp.num_tlv++;
// P7 PNF Port
printf("TAG value :%d",nfapi_resp.cell_param.phy_state.tl.tag);
nfapi_pnf_param_resp(config, &nfapi_resp);
nfapi_nr_pnf_param_resp(config, &nfapi_resp);
printf("[PNF] Sent NFAPI_PNF_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_nr_config_request_scf_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);
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!=NFAPI_UE_STUB_PNF) {
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;
if(req->nfapi_config.timing_window.tl.tag == NFAPI_NFAPI_TIMING_WINDOW_TAG) {
phy_info->timing_window = req->nfapi_config.timing_window.value;
printf("Phy_info:Timing window:%u NFAPI_CONFIG:timing_window:%u\n", phy_info->timing_window, req->nfapi_config.timing_window.value);
num_tlv++;
}
if(req->nfapi_config.timing_info_mode.tl.tag == NFAPI_NFAPI_TIMING_INFO_MODE_TAG) {
printf("timing info mode:%d\n", req->nfapi_config.timing_info_mode.value);
phy_info->timing_info_mode = req->nfapi_config.timing_info_mode.value;
num_tlv++;
} else {
phy_info->timing_info_mode = 0;
printf("NO timing info mode provided\n");
}
if(req->nfapi_config.timing_info_period.tl.tag == NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG) {
printf("timing info period provided value:%d\n", req->nfapi_config.timing_info_period.value);
phy_info->timing_info_period = req->nfapi_config.timing_info_period.value;
num_tlv++;
} else {
phy_info->timing_info_period = 0;
}
if(req->rf_config.dl_channel_bandwidth.tl.tag == NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG) {
phy_info->dl_channel_bw_support = req->rf_config.dl_channel_bandwidth.value;
fp->N_RB_DL = req->rf_config.dl_channel_bandwidth.value;
num_tlv++;
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG N_RB_DL:%u\n", __FUNCTION__, fp->N_RB_DL);
} else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() Missing NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG\n", __FUNCTION__);
}
if(req->rf_config.ul_channel_bandwidth.tl.tag == NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG) {
phy_info->ul_channel_bw_support = req->rf_config.ul_channel_bandwidth.value;
fp->N_RB_UL = req->rf_config.ul_channel_bandwidth.value;
num_tlv++;
}
if(req->nfapi_config.rf_bands.tl.tag == NFAPI_NFAPI_RF_BANDS_TAG) {
pnf->rfs[0].band = req->nfapi_config.rf_bands.rf_band[0];
fp->eutra_band = req->nfapi_config.rf_bands.rf_band[0];
num_tlv++;
}
if(req->nfapi_config.earfcn.tl.tag == NFAPI_NFAPI_EARFCN_TAG) {
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);
}
if (req->subframe_config.duplex_mode.tl.tag == NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG) {
fp->frame_type = req->subframe_config.duplex_mode.value==0 ? TDD : FDD;
num_tlv++;
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() frame_type:%d\n", __FUNCTION__, fp->frame_type);
}
if (req->subframe_config.dl_cyclic_prefix_type.tl.tag == NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG) {
fp->Ncp = req->subframe_config.dl_cyclic_prefix_type.value;
num_tlv++;
}
if (req->subframe_config.ul_cyclic_prefix_type.tl.tag == NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG) {
fp->Ncp_UL = req->subframe_config.ul_cyclic_prefix_type.value;
num_tlv++;
}
fp->num_MBSFN_config = 0; // DJP - hard code alert
if (req->sch_config.physical_cell_id.tl.tag == NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG) {
fp->Nid_cell = req->sch_config.physical_cell_id.value;
fp->nushift = fp->Nid_cell%6;
num_tlv++;
}
if (req->rf_config.tx_antenna_ports.tl.tag == NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG) {
fp->nb_antennas_tx = req->rf_config.tx_antenna_ports.value;
fp->nb_antenna_ports_eNB = 1;
num_tlv++;
}
if (req->rf_config.rx_antenna_ports.tl.tag == NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG) {
fp->nb_antennas_rx = req->rf_config.rx_antenna_ports.value;
num_tlv++;
}
if (req->phich_config.phich_resource.tl.tag == NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG) {
fp->phich_config_common.phich_resource = req->phich_config.phich_resource.value;
num_tlv++;
}
if (req->phich_config.phich_duration.tl.tag == NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG) {
fp->phich_config_common.phich_duration = req->phich_config.phich_duration.value;
num_tlv++;
}
if (req->phich_config.phich_power_offset.tl.tag == NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG) {
LOG_E(PHY, "%s() NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG tag:%d not supported\n", __FUNCTION__, req->phich_config.phich_power_offset.tl.tag);
//fp->phich_config_common.phich_power_offset = req->phich_config.
num_tlv++;
}
// UL RS Config
if (req->uplink_reference_signal_config.cyclic_shift_1_for_drms.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG) {
fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = req->uplink_reference_signal_config.cyclic_shift_1_for_drms.value;
num_tlv++;
}
if (req->uplink_reference_signal_config.uplink_rs_hopping.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG) {
fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = req->uplink_reference_signal_config.uplink_rs_hopping.value;
num_tlv++;
}
if (req->uplink_reference_signal_config.group_assignment.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG) {
fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = req->uplink_reference_signal_config.group_assignment.value;
num_tlv++;
}
if (req->pusch_config.hopping_mode.tl.tag == NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG) {
} // DJP - not being handled?
if (req->pusch_config.hopping_offset.tl.tag == NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG) {
} // DJP - not being handled?
if (req->pusch_config.number_of_subbands.tl.tag == NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG) {
} // DJP - not being handled?
if (req->prach_config.configuration_index.tl.tag == NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG) {
fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=req->prach_config.configuration_index.value;
num_tlv++;
}
if (req->prach_config.root_sequence_index.tl.tag == NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG) {
fp->prach_config_common.rootSequenceIndex=req->prach_config.root_sequence_index.value;
num_tlv++;
}
if (req->prach_config.zero_correlation_zone_configuration.tl.tag == NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG) {
fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=req->prach_config.zero_correlation_zone_configuration.value;
num_tlv++;
}
if (req->prach_config.high_speed_flag.tl.tag == NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG) {
fp->prach_config_common.prach_ConfigInfo.highSpeedFlag=req->prach_config.high_speed_flag.value;
num_tlv++;
}
if (req->prach_config.frequency_offset.tl.tag == NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG) {
fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset=req->prach_config.frequency_offset.value;
num_tlv++;
}
if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
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);
}
phy_info->remote_port = req->nfapi_config.p7_vnf_port.value;
struct sockaddr_in vnf_p7_sockaddr;
memcpy(&vnf_p7_sockaddr.sin_addr.s_addr, &(req->nfapi_config.p7_vnf_address_ipv4.address[0]), 4);
phy_info->remote_addr = inet_ntoa(vnf_p7_sockaddr.sin_addr);
printf("[PNF] %d vnf p7 %s:%d timing %d %d %d\n", phy_info->id, phy_info->remote_addr, phy_info->remote_port,
phy_info->timing_window, phy_info->timing_info_mode, phy_info->timing_info_period);
nfapi_config_response_t nfapi_resp;
memset(&nfapi_resp, 0, sizeof(nfapi_resp));
nfapi_resp.header.message_id = NFAPI_CONFIG_RESPONSE;
nfapi_resp.header.phy_id = phy_info->id;
nfapi_resp.error_code = 0; // DJP - some value resp->error_code;
nfapi_pnf_config_resp(config, &nfapi_resp);
printf("[PNF] Sent NFAPI_CONFIG_RESPONSE phy_id:%d\n", phy_info->id);
if(NFAPI_MODE==NFAPI_UE_STUB_PNF)
free(fp);
return 0;
}
int nr_config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_nr_config_request_scf_t *req)
{
printf("[PNF] Received NFAPI_CONFIG_REQ phy_id:%d\n", req->header.phy_id);
pnf_info *pnf = (pnf_info *)(config->user_data);
uint8_t num_tlv = 0;
@@ -927,10 +1215,10 @@ req->tdd_table.
phy_info->timing_window, phy_info->timing_info_mode, phy_info->timing_info_period);
nfapi_nr_config_response_scf_t nfapi_resp;
memset(&nfapi_resp, 0, sizeof(nfapi_resp));
nfapi_resp.header.message_id = NFAPI_CONFIG_RESPONSE;
nfapi_resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE;
nfapi_resp.header.phy_id = phy_info->id;
nfapi_resp.error_code = 0; // DJP - some value resp->error_code;
nfapi_pnf_config_resp(config, &nfapi_resp);
nfapi_nr_pnf_config_resp(config, &nfapi_resp);
printf("[PNF] Sent NFAPI_PNF_CONFIG_RESPONSE phy_id:%d\n", phy_info->id);
if(NFAPI_MODE==NFAPI_UE_STUB_PNF)
@@ -1487,7 +1775,127 @@ nfapi_tx_request_t dummy_tx_req;
nfapi_pnf_p7_subframe_buffer_t dummy_subframe;
int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_nr_start_request_scf_t *req) {
int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_start_request_t *req) {
printf("[PNF] Received NFAPI_START_REQ phy_id:%d\n", req->header.phy_id);
nfapi_set_trace_level(NFAPI_TRACE_INFO);
pnf_info *pnf = (pnf_info *)(config->user_data);
phy_info *phy_info = pnf->phys;
nfapi_pnf_p7_config_t *p7_config = nfapi_pnf_p7_config_create();
p7_config->phy_id = phy->phy_id;
p7_config->remote_p7_port = phy_info->remote_port;
p7_config->remote_p7_addr = phy_info->remote_addr;
p7_config->local_p7_port = 50010; // DJP - good grief cannot seem to get the right answer phy_info->local_port;
//DJP p7_config->local_p7_addr = (char*)phy_info->local_addr.c_str();
p7_config->local_p7_addr = phy_info->local_addr;
printf("[PNF] P7 remote:%s:%d local:%s:%d\n", p7_config->remote_p7_addr, p7_config->remote_p7_port, p7_config->local_p7_addr, p7_config->local_p7_port);
p7_config->user_data = phy_info;
p7_config->malloc = &pnf_allocate;
p7_config->free = &pnf_deallocate;
p7_config->codec_config.allocate = &pnf_allocate;
p7_config->codec_config.deallocate = &pnf_deallocate;
p7_config->trace = &pnf_nfapi_trace;
phy->user_data = p7_config;
p7_config->subframe_buffer_size = phy_info->timing_window;
printf("subframe_buffer_size configured using phy_info->timing_window:%d\n", phy_info->timing_window);
if(phy_info->timing_info_mode & 0x1) {
p7_config->timing_info_mode_periodic = 1;
p7_config->timing_info_period = phy_info->timing_info_period;
}
if(phy_info->timing_info_mode & 0x2) {
p7_config->timing_info_mode_aperiodic = 1;
}
p7_config->dl_config_req = &pnf_phy_dl_config_req;
p7_config->ul_config_req = &pnf_phy_ul_config_req;
p7_config->hi_dci0_req = &pnf_phy_hi_dci0_req;
p7_config->tx_req = &pnf_phy_tx_req;
p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req;
p7_config->ue_release_req = &pnf_phy_ue_release_req;
if (NFAPI_MODE==NFAPI_UE_STUB_PNF) {
p7_config->dl_config_req = &memcpy_dl_config_req;
p7_config->ul_config_req = &memcpy_ul_config_req;
p7_config->hi_dci0_req = &memcpy_hi_dci0_req;
p7_config->tx_req = &memcpy_tx_req;
} else {
p7_config->dl_config_req = &pnf_phy_dl_config_req;
p7_config->ul_config_req = &pnf_phy_ul_config_req;
p7_config->hi_dci0_req = &pnf_phy_hi_dci0_req;
p7_config->tx_req = &pnf_phy_tx_req;
}
p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req;
memset(&dummy_dl_config_req, 0, sizeof(dummy_dl_config_req));
dummy_dl_config_req.dl_config_request_body.tl.tag=NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
dummy_dl_config_req.dl_config_request_body.number_pdcch_ofdm_symbols=1;
dummy_dl_config_req.dl_config_request_body.number_dci=0;
dummy_dl_config_req.dl_config_request_body.number_pdu=0;
dummy_dl_config_req.dl_config_request_body.number_pdsch_rnti=0;
dummy_dl_config_req.dl_config_request_body.transmission_power_pcfich=6000;
dummy_dl_config_req.dl_config_request_body.dl_config_pdu_list=0;
memset(&dummy_tx_req, 0, sizeof(dummy_tx_req));
dummy_tx_req.tx_request_body.number_of_pdus=0;
dummy_tx_req.tx_request_body.tl.tag=NFAPI_TX_REQUEST_BODY_TAG;
dummy_subframe.dl_config_req = &dummy_dl_config_req;
dummy_subframe.tx_req = 0;//&dummy_tx_req;
dummy_subframe.ul_config_req=0;
dummy_subframe.hi_dci0_req=0;
dummy_subframe.lbt_dl_config_req=0;
p7_config->dummy_subframe = dummy_subframe;
p7_config->vendor_ext = &pnf_phy_vendor_ext;
p7_config->allocate_p7_vendor_ext = &pnf_phy_allocate_p7_vendor_ext;
p7_config->deallocate_p7_vendor_ext = &pnf_phy_deallocate_p7_vendor_ext;
p7_config->codec_config.unpack_p7_vendor_extension = &pnf_phy_unpack_p7_vendor_extension;
p7_config->codec_config.pack_p7_vendor_extension = &pnf_phy_pack_p7_vendor_extension;
p7_config->codec_config.unpack_vendor_extension_tlv = &pnf_phy_unpack_vendor_extension_tlv;
p7_config->codec_config.pack_vendor_extension_tlv = &pnf_phy_pack_vendor_extention_tlv;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating P7 thread %s\n", __FUNCTION__);
pthread_t p7_thread;
pthread_create(&p7_thread, NULL, &pnf_p7_thread_start, p7_config);
//((pnf_phy_user_data_t*)(phy_info->fapi->user_data))->p7_config = p7_config;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Calling l1_north_init_eNB() %s\n", __FUNCTION__);
l1_north_init_eNB();
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] DJP - HACK - Set p7_config global ready for subframe ind%s\n", __FUNCTION__);
p7_config_g = p7_config;
// Need to wait for main thread to create RU structures
while(config_sync_var<0) {
usleep(5000000);
printf("[PNF] waiting for OAI to be configured (eNB/RU)\n");
}
printf("[PNF] OAI eNB/RU configured\n");
//printf("[PNF] About to call phy_init_RU() for RC.ru[0]:%p\n", RC.ru[0]);
//phy_init_RU(RC.ru[0]);
printf("[PNF] About to call init_eNB_afterRU()\n");
if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
init_eNB_afterRU();
}
// Signal to main thread that it can carry on - otherwise RU will startup too quickly and it is not initialised
{
pthread_mutex_lock(&nfapi_sync_mutex);
nfapi_sync_var=0;
pthread_cond_broadcast(&nfapi_sync_cond);
pthread_mutex_unlock(&nfapi_sync_mutex);
}
while(sync_var<0) {
usleep(5000000);
printf("[PNF] waiting for OAI to be started\n");
}
printf("[PNF] Sending PNF_START_RESP\n");
nfapi_send_pnf_start_resp(config, p7_config->phy_id);
printf("[PNF] Sending first P7 subframe ind\n");
nfapi_pnf_p7_subframe_ind(p7_config, p7_config->phy_id, 0); // DJP - SFN_SF set to zero - correct???
printf("[PNF] Sent first P7 subframe ind\n");
return 0;
}
int nr_start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_nr_start_request_scf_t *req) {
printf("[PNF] Received NFAPI_START_REQ phy_id:%d\n", req->header.phy_id);
nfapi_set_trace_level(NFAPI_TRACE_INFO);
pnf_info *pnf = (pnf_info *)(config->user_data);
@@ -1573,7 +1981,7 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap
p7_config->codec_config.pack_vendor_extension_tlv = &pnf_phy_pack_vendor_extention_tlv;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating P7 thread %s\n", __FUNCTION__);
pthread_t p7_thread;
pthread_create(&p7_thread, NULL, &pnf_p7_thread_start, p7_config);
pthread_create(&p7_thread, NULL, &pnf_nr_p7_thread_start, p7_config);
//((pnf_phy_user_data_t*)(phy_info->fapi->user_data))->p7_config = p7_config;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Calling l1_north_init_eNB() %s\n", __FUNCTION__);
l1_north_init_gNB();
@@ -1609,7 +2017,7 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap
}
printf("[PNF] Sending PNF_START_RESP\n");
nfapi_send_pnf_start_resp(config, p7_config->phy_id);
nfapi_nr_send_pnf_start_resp(config, p7_config->phy_id);
printf("[PNF] Sending first P7 slot indication\n");
#if 1
nfapi_pnf_p7_slot_ind(p7_config, p7_config->phy_id, 0, 0);
@@ -1868,7 +2276,6 @@ int pnf_sim_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header,
}
/*------------------------------------------------------------------------------*/
void *pnf_start_thread(void *ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] IN PNF NFAPI start thread %s\n", __FUNCTION__);
nfapi_pnf_config_t *config = (nfapi_pnf_config_t *)ptr;
@@ -1879,7 +2286,17 @@ void *pnf_start_thread(void *ptr) {
return (void *)0;
}
void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) {
void *pnf_nr_start_thread(void *ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] IN PNF NFAPI start thread %s\n", __FUNCTION__);
nfapi_pnf_config_t *config = (nfapi_pnf_config_t *)ptr;
struct sched_param sp;
sp.sched_priority = 20;
pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp);
nfapi_nr_pnf_start(config);
return (void *)0;
}
void configure_nr_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) {
printf("%s() PNF\n\n\n\n\n\n", __FUNCTION__);
if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
@@ -1903,6 +2320,54 @@ void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr,
//config->pnf_nr_param_req = &pnf_nr_param_request;
config->pnf_nr_param_req = &pnf_nr_param_request;
config->pnf_nr_config_req = &pnf_nr_config_request;
config->pnf_nr_start_req = &pnf_nr_start_request;
config->pnf_stop_req = &pnf_stop_request;
config->nr_param_req = &nr_param_request;
config->nr_config_req = &nr_config_request;
config->nr_start_req = &nr_start_request;
config->measurement_req = &measurement_request;
config->rssi_req = &rssi_request;
config->broadcast_detect_req = &broadcast_detect_request;
config->system_information_schedule_req = &system_information_schedule_request;
config->system_information_req = &system_information_request;
config->nmm_stop_req = &nmm_stop_request;
config->vendor_ext = &vendor_ext;
config->trace = &pnf_nfapi_trace;
config->user_data = &pnf;
// To allow custom vendor extentions to be added to nfapi
config->codec_config.unpack_vendor_extension_tlv = &pnf_sim_unpack_vendor_extension_tlv;
config->codec_config.pack_vendor_extension_tlv = &pnf_sim_pack_vendor_extention_tlv;
config->allocate_p4_p5_vendor_ext = &pnf_sim_allocate_p4_p5_vendor_ext;
config->deallocate_p4_p5_vendor_ext = &pnf_sim_deallocate_p4_p5_vendor_ext;
config->codec_config.unpack_p4_p5_vendor_extension = &pnf_sim_unpack_p4_p5_vendor_extension;
config->codec_config.pack_p4_p5_vendor_extension = &pnf_sim_pack_p4_p5_vendor_extension;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating PNF NFAPI start thread %s\n", __FUNCTION__);
pthread_create(&pnf_start_pthread, NULL, &pnf_nr_start_thread, config);
pthread_setname_np(pnf_start_pthread, "NFAPI_PNF");
}
void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) {
printf("%s() PNF\n\n\n\n\n\n", __FUNCTION__);
if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
nfapi_setmode(NFAPI_MODE_PNF); // PNF!
}
nfapi_pnf_config_t *config = nfapi_pnf_config_create();
config->vnf_ip_addr = vnf_ip_addr;
config->vnf_p5_port = vnf_p5_port;
pnf.phys[0].udp.enabled = 1;
pnf.phys[0].udp.rx_port = pnf_p7_port;
pnf.phys[0].udp.tx_port = vnf_p7_port;
strcpy(pnf.phys[0].udp.tx_addr, vnf_ip_addr);
strcpy(pnf.phys[0].local_addr, pnf_ip_addr);
printf("%s() VNF:%s:%d PNF_PHY[addr:%s UDP:tx_addr:%s:%d rx:%d]\n",
__FUNCTION__,
config->vnf_ip_addr, config->vnf_p5_port,
pnf.phys[0].local_addr,
pnf.phys[0].udp.tx_addr, pnf.phys[0].udp.tx_port,
pnf.phys[0].udp.rx_port);
config->pnf_param_req = &pnf_param_request;
config->pnf_config_req = &pnf_config_request;
config->pnf_start_req = &pnf_start_request;
@@ -1912,6 +2377,7 @@ void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr,
config->start_req = &start_request;
config->measurement_req = &measurement_request;
config->rssi_req = &rssi_request;
config->cell_search_req = &cell_search_request;
config->broadcast_detect_req = &broadcast_detect_request;
config->system_information_schedule_req = &system_information_schedule_request;
config->system_information_req = &system_information_request;
+2
View File
@@ -23,6 +23,8 @@
#define NFAPI_PNF_H__
int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind);
void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port);
void configure_nr_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port);
void oai_subframe_ind(uint16_t sfn, uint16_t sf);
void oai_slot_ind(uint16_t sfn, uint16_t slot);
#endif
+199 -32
View File
@@ -274,7 +274,7 @@ void oai_create_gnb(void) {
int pnf_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
printf("[VNF] pnf connection indication idx:%d\n", p5_idx);
oai_create_gnb();
oai_create_enb();
nfapi_pnf_param_request_t req;
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_PARAM_REQUEST;
@@ -282,7 +282,6 @@ int pnf_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
return 0;
}
/*
int pnf_nr_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
printf("[VNF] pnf connection indication idx:%d\n", p5_idx);
oai_create_gnb();
@@ -292,7 +291,7 @@ int pnf_nr_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
nfapi_nr_vnf_pnf_param_req(config, p5_idx, &req);
return 0;
}
*/
int pnf_disconnection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
printf("[VNF] pnf disconnection indication idx:%d\n", p5_idx);
vnf_info *vnf = (vnf_info *)(config->user_data);
@@ -302,7 +301,7 @@ int pnf_disconnection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
nfapi_vnf_p7_del_pnf((p7_vnf->config), phy->id);
return 0;
}
/*
int pnf_nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_param_response_t *resp) {
printf("[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code);
vnf_info *vnf = (vnf_info *)(config->user_data);
@@ -322,7 +321,7 @@ int pnf_nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_pa
pnf->phys[0] = phy;
}
nfapi_pnf_config_request_t req;
nfapi_nr_pnf_config_request_t req;
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_CONFIG_REQUEST;
req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG;
@@ -335,10 +334,10 @@ int pnf_nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_pa
req.pnf_phy_rf_config.phy_rf_config[i].rf_config_index = pnf->phys[i].rfs[0];
}
nfapi_vnf_pnf_config_req(config, p5_idx, &req);
nfapi_nr_vnf_pnf_config_req(config, p5_idx, &req);
return 0;
}
*/
int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_response_t *resp) {
printf("[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code);
vnf_info *vnf = (vnf_info *)(config->user_data);
@@ -358,13 +357,13 @@ int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_re
pnf->phys[0] = phy;
}
// for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) {
// rf_info rf;
// memset(&rf,0,sizeof(rf));
// rf.index = resp->pnf_rf.rf[i].rf_config_index;
// printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index);
// pnf->rfs[0] = rf;
// }
for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) {
rf_info rf;
memset(&rf,0,sizeof(rf));
rf.index = resp->pnf_rf.rf[i].rf_config_index;
printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index);
pnf->rfs[0] = rf;
}
nfapi_pnf_config_request_t req;
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_CONFIG_REQUEST;
@@ -382,6 +381,31 @@ int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_re
return 0;
}
int pnf_nr_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_config_response_t *resp) {
printf("[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length);
if(1) {
nfapi_nr_pnf_start_request_t req;
memset(&req, 0, sizeof(req));
req.header.phy_id = resp->header.phy_id;
req.header.message_id = NFAPI_PNF_START_REQUEST;
nfapi_nr_vnf_pnf_start_req(config, p5_idx, &req);
} else {
// Rather than send the pnf_start_request we will demonstrate
// sending a vendor extention message. The start request will be
// send when the vendor extension response is received
//vnf_info* vnf = (vnf_info*)(config->user_data);
vendor_ext_p5_req req;
memset(&req, 0, sizeof(req));
req.header.message_id = P5_VENDOR_EXT_REQ;
req.dummy1 = 45;
req.dummy2 = 1977;
nfapi_vnf_vendor_extension(config, p5_idx, &req.header);
}
return 0;
}
int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_response_t *resp) {
printf("[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length);
@@ -1077,6 +1101,14 @@ int vnf_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_
static pthread_t vnf_start_pthread;
static pthread_t vnf_p7_start_pthread;
void *vnf_nr_p7_start_thread(void *ptr) {
printf("%s()\n", __FUNCTION__);
pthread_setname_np(pthread_self(), "VNF_P7");
nfapi_vnf_p7_config_t *config = (nfapi_vnf_p7_config_t *)ptr;
nfapi_nr_vnf_p7_start(config);
return config;
}
void *vnf_p7_start_thread(void *ptr) {
printf("%s()\n", __FUNCTION__);
pthread_setname_np(pthread_self(), "VNF_P7");
@@ -1087,6 +1119,42 @@ void *vnf_p7_start_thread(void *ptr) {
void set_thread_priority(int priority);
void *vnf_nr_p7_thread_start(void *ptr) {
set_thread_priority(79);
vnf_p7_info *p7_vnf = (vnf_p7_info *)ptr;
p7_vnf->config->port = p7_vnf->local_port;
p7_vnf->config->sync_indication = &phy_sync_indication;
p7_vnf->config->slot_indication = &phy_slot_indication;
p7_vnf->config->harq_indication = &phy_harq_indication;
p7_vnf->config->crc_indication = &phy_crc_indication;
p7_vnf->config->rx_indication = &phy_rx_indication;
p7_vnf->config->rach_indication = &phy_rach_indication;
p7_vnf->config->srs_indication = &phy_srs_indication;
p7_vnf->config->sr_indication = &phy_sr_indication;
p7_vnf->config->cqi_indication = &phy_cqi_indication;
p7_vnf->config->lbt_dl_indication = &phy_lbt_dl_indication;
p7_vnf->config->nb_harq_indication = &phy_nb_harq_indication;
p7_vnf->config->nrach_indication = &phy_nrach_indication;
p7_vnf->config->malloc = &vnf_allocate;
p7_vnf->config->free = &vnf_deallocate;
p7_vnf->config->trace = &vnf_trace;
p7_vnf->config->vendor_ext = &phy_vendor_ext;
p7_vnf->config->user_data = p7_vnf;
p7_vnf->mac->user_data = p7_vnf;
p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension;
p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension;
p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv;
p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv;
p7_vnf->config->codec_config.allocate = &vnf_allocate;
p7_vnf->config->codec_config.deallocate = &vnf_deallocate;
p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext;
p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI P7 start thread %s\n", __FUNCTION__);
pthread_create(&vnf_p7_start_pthread, NULL, &vnf_nr_p7_start_thread, p7_vnf->config);
return 0;
}
void *vnf_p7_thread_start(void *ptr) {
set_thread_priority(79);
vnf_p7_info *p7_vnf = (vnf_p7_info *)ptr;
@@ -1124,6 +1192,30 @@ void *vnf_p7_thread_start(void *ptr) {
return 0;
}
int pnf_nr_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_start_response_t *resp) {
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
pnf_info *pnf = vnf->pnfs;
nfapi_nr_param_request_scf_t req;
printf("[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started);
if(p7_vnf->thread_started == 0) {
pthread_t vnf_p7_thread;
pthread_create(&vnf_p7_thread, NULL, &vnf_nr_p7_thread_start, p7_vnf);
p7_vnf->thread_started = 1;
} else {
// P7 thread already running.
}
// start all the phys in the pnf.
printf("[VNF] Sending NFAPI_VNF_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id);
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST;
req.header.phy_id = pnf->phys[0].id;
nfapi_nr_vnf_param_req(config, p5_idx, &req);
return 0;
}
int pnf_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_start_response_t *resp) {
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
@@ -1150,7 +1242,7 @@ int pnf_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_start_re
extern uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq,uint32_t bw);
int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_param_response_scf_t *resp) {
int nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_param_response_scf_t *resp) {
printf("[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
vnf_info *vnf = (vnf_info *)(config->user_data);
@@ -1165,7 +1257,7 @@ int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_param_respons
// for now just 1
printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled,
p7_vnf->periodic_timing_period);
req->header.message_id = NFAPI_CONFIG_REQUEST;
req->header.message_id = NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST;
req->header.phy_id = phy->id;
printf("[VNF] Send NFAPI_CONFIG_REQUEST\n");
//printf("\n NR bandP =%d\n",req->nfapi_config.rf_bands.rf_band[0]);
@@ -1207,25 +1299,103 @@ req->nfapi_config.tx_data_timing_offset.tl.tag = NFAPI_NR_NFAPI_TX_DATA_TIMING_O
ve2.tl.tag = VENDOR_EXT_TLV_2_TAG;
ve2.dummy = 2016;
req->vendor_extension = &ve2.tl;
nfapi_vnf_config_req(config, p5_idx, req);
nfapi_nr_vnf_config_req(config, p5_idx, req);
printf("[VNF] Sent NFAPI_VNF_CONFIG_REQ num_tlv:%u\n",req->num_tlv);
return 0;
}
int config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_config_response_scf_t *resp) {
int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_param_response_t *resp) {
printf("[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys;
struct sockaddr_in pnf_p7_sockaddr;
nfapi_config_request_t *req = &RC.mac[0]->config[0];
phy->remote_port = 50010;//resp->nfapi_config.p7_pnf_port.value;
memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4);
phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr);
// for now just 1
printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled,
p7_vnf->periodic_timing_period);
req->header.message_id = NFAPI_CONFIG_REQUEST;
req->header.phy_id = phy->id;
printf("[VNF] Send NFAPI_CONFIG_REQUEST\n");
req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG;
req->nfapi_config.p7_vnf_port.value = 50011;//p7_vnf->local_port;
req->num_tlv++;
printf("[VNF] DJP local_port:%d\n", p7_vnf->local_port);
req->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG;
struct sockaddr_in vnf_p7_sockaddr;
vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf->local_addr);
memcpy(&(req->nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4);
req->num_tlv++;
printf("[VNF] DJP local_addr:%s\n", p7_vnf->local_addr);
req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG;
req->nfapi_config.timing_window.value = p7_vnf->timing_window;
printf("[VNF] Timing window:%u\n", p7_vnf->timing_window);
req->num_tlv++;
if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) {
req->nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG;
req->nfapi_config.timing_info_mode.value = (p7_vnf->aperiodic_timing_enabled << 1) | (p7_vnf->periodic_timing_enabled);
req->num_tlv++;
if(p7_vnf->periodic_timing_enabled) {
req->nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG;
req->nfapi_config.timing_info_period.value = p7_vnf->periodic_timing_period;
req->num_tlv++;
}
}
vendor_ext_tlv_2 ve2;
memset(&ve2, 0, sizeof(ve2));
ve2.tl.tag = VENDOR_EXT_TLV_2_TAG;
ve2.dummy = 2016;
req->vendor_extension = &ve2.tl;
nfapi_vnf_config_req(config, p5_idx, req);
printf("[VNF] Sent NFAPI_CONFIG_REQ num_tlv:%u\n",req->num_tlv);
return 0;
}
int nr_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_config_response_scf_t *resp) {
nfapi_nr_start_request_scf_t req;
printf("[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
printf("[VNF] Calling oai_enb_init()\n");
oai_enb_init(); // TODO: change to gnb
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_START_REQUEST;
req.header.message_id = NFAPI_NR_PHY_MSG_TYPE_START_REQUEST;
req.header.phy_id = resp->header.phy_id;
nfapi_vnf_start_req(config, p5_idx, &req);
nfapi_nr_vnf_start_req(config, p5_idx, &req);
printf("[VNF] Send NFAPI_VNF_START_REQUEST idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
return 0;
}
int start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_start_response_scf_t *resp) {
int config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_config_response_t *resp) {
nfapi_start_request_t req;
printf("[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
printf("[VNF] Calling oai_enb_init()\n");
oai_enb_init();
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_START_REQUEST;
req.header.phy_id = resp->header.phy_id;
nfapi_vnf_start_req(config, p5_idx, &req);
printf("[VNF] Send NFAPI_START_REQUEST idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
return 0;
}
int start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_start_response_t *resp) {
printf("[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
vnf_info *vnf = (vnf_info *)(config->user_data);
pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys;
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, phy->remote_port, phy->id);
return 0;
}
int nr_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_start_response_scf_t *resp) {
printf("[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
vnf_info *vnf = (vnf_info *)(config->user_data);
pnf_info *pnf = vnf->pnfs;
@@ -1281,14 +1451,14 @@ void vnf_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t *header) {
}
nfapi_vnf_config_t *config = 0;
/*
void vnf_nr_start_thread(void *ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] VNF NFAPI thread - nfapi_vnf_start()%s\n", __FUNCTION__);
pthread_setname_np(pthread_self(), "VNF");
config = (nfapi_vnf_config_t *)ptr;
nfapi_nr_vnf_start(config);
}
*/
void vnf_start_thread(void *ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] VNF NFAPI thread - nfapi_vnf_start()%s\n", __FUNCTION__);
pthread_setname_np(pthread_self(), "VNF");
@@ -1298,7 +1468,6 @@ void vnf_start_thread(void *ptr) {
static vnf_info vnf;
/*
void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port) {
nfapi_setmode(NFAPI_MODE_VNF);
memset(&vnf, 0, sizeof(vnf));
@@ -1324,16 +1493,14 @@ void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port) {
config->phy_list = 0;
config->pnf_nr_connection_indication = &pnf_nr_connection_indication_cb;
config->pnf_connection_indication = &pnf_connection_indication_cb;
config->pnf_disconnect_indication = &pnf_disconnection_indication_cb;
config->pnf_nr_param_resp = &pnf_nr_param_resp_cb;
config->pnf_param_resp = &pnf_param_resp_cb;
config->pnf_config_resp = &pnf_config_resp_cb;
config->pnf_start_resp = &pnf_start_resp_cb;
config->param_resp = &param_resp_cb;
config->config_resp = &config_resp_cb;
config->start_resp = &start_resp_cb;
config->pnf_nr_config_resp = &pnf_nr_config_resp_cb;
config->pnf_nr_start_resp = &pnf_nr_start_resp_cb;
config->nr_param_resp = &nr_param_resp_cb;
config->nr_config_resp = &nr_config_resp_cb;
config->nr_start_resp = &nr_start_resp_cb;
config->vendor_ext = &vendor_ext_cb;
config->user_data = &vnf;
// To allow custom vendor extentions to be added to nfapi
@@ -1350,7 +1517,7 @@ void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port) {
pthread_create(&vnf_start_pthread, NULL, (void *)&vnf_nr_start_thread, config);
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Created VNF NFAPI start thread %s\n", __FUNCTION__);
}
*/
void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) {
nfapi_setmode(NFAPI_MODE_VNF);
@@ -187,7 +187,6 @@ typedef enum {
NFAPI_DL_NODE_SYNC,
NFAPI_TIMING_INFO,
NFAPI_RSSI_REQUEST = 0x0200,
NFAPI_RSSI_RESPONSE,
NFAPI_RSSI_INDICATION,
@@ -1125,12 +1124,12 @@ typedef struct {
uint32_t error_code;
nfapi_pnf_param_general_t pnf_param_general;
nfapi_pnf_phy_t pnf_phy;
// nfapi_pnf_rf_t pnf_rf;
// nfapi_pnf_phy_rel10_t pnf_phy_rel10;
// nfapi_pnf_phy_rel11_t pnf_phy_rel11;
// nfapi_pnf_phy_rel12_t pnf_phy_rel12;
// nfapi_pnf_phy_rel13_t pnf_phy_rel13;
// nfapi_pnf_phy_rel13_nb_iot_t pnf_phy_rel13_nb_iot;
nfapi_pnf_rf_t pnf_rf;
nfapi_pnf_phy_rel10_t pnf_phy_rel10;
nfapi_pnf_phy_rel11_t pnf_phy_rel11;
nfapi_pnf_phy_rel12_t pnf_phy_rel12;
nfapi_pnf_phy_rel13_t pnf_phy_rel13;
nfapi_pnf_phy_rel13_nb_iot_t pnf_phy_rel13_nb_iot;
nfapi_pnf_phy_rel15_t pnf_phy_rel15;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_pnf_param_response_t;
@@ -2498,8 +2497,7 @@ typedef struct {
typedef struct {
nfapi_p7_message_header_t header;
uint32_t t1;
//int32_t delta_sfn_sf;
int32_t delta_sfn_slot;
int32_t delta_sfn_sf;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_dl_node_sync_t;
@@ -2514,35 +2512,49 @@ typedef struct {
typedef struct {
nfapi_p7_message_header_t header;
uint32_t last_sfn_sf;
uint32_t last_sfn;
uint32_t last_slot;
uint32_t time_since_last_timing_info;
uint32_t dl_config_jitter;
uint32_t tx_request_jitter;
uint32_t ul_config_jitter;
uint32_t hi_dci0_jitter;
uint32_t dl_tti_jitter;
uint32_t tx_data_request_jitter;
uint32_t ul_tti_jitter;
uint32_t ul_dci_jitter;
int32_t dl_config_latest_delay;
int32_t tx_request_latest_delay;
int32_t ul_config_latest_delay;
int32_t hi_dci0_latest_delay;
int32_t dl_tti_latest_delay;
int32_t tx_data_request_latest_delay;
int32_t ul_tti_latest_delay;
int32_t ul_dci_latest_delay;
int32_t dl_config_earliest_arrival;
int32_t tx_request_earliest_arrival;
int32_t ul_config_earliest_arrival;
int32_t hi_dci0_earliest_arrival;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_timing_info_t;
typedef struct {
nfapi_p7_message_header_t header;
uint32_t last_sfn;
uint32_t last_slot;
uint32_t time_since_last_timing_info;
uint32_t dl_tti_jitter;
uint32_t tx_data_request_jitter;
uint32_t ul_tti_jitter;
uint32_t ul_dci_jitter;
int32_t dl_tti_latest_delay;
int32_t tx_data_request_latest_delay;
int32_t ul_tti_latest_delay;
int32_t ul_dci_latest_delay;
int32_t dl_tti_earliest_arrival;
int32_t tx_data_request_earliest_arrival;
int32_t ul_tti_earliest_arrival;
int32_t ul_dci_earliest_arrival;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_timing_info_t;
} nfapi_nr_timing_info_t;
typedef struct {
nfapi_tl_t tl;
@@ -3955,7 +3967,7 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
*
*/
int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
//int nfapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
int nfapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
/*! \brief Decodes an NFAPI P5 message header
* \param pMessageBuf A pointer to an encoded P5 message header
@@ -3979,7 +3991,7 @@ int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, vo
*
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf
*/
//int nfapi_nr_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
int nfapi_nr_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
/*! \brief Encodes an NFAPI P7 message to a buffer
@@ -3993,6 +4005,7 @@ int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
*
*/
int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config);
int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config);
/*! \brief Decodes an NFAPI P7 message header
* \param pMessageBuf A pointer to an encoded P7 message header
@@ -4018,6 +4031,7 @@ int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, vo
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p7 message structure pointer to by pUnpackedBuf
*/
int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config);
int nfapi_nr_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config);
/*! \brief Calculates the checksum of a message
*
@@ -78,7 +78,11 @@ typedef enum {
NFAPI_NR_PHY_MSG_TYPE_PNF_START_REQUEST= 0x0104,
NFAPI_NR_PHY_MSG_TYPE_PNF_START_RESPONSE= 0x0105,
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_REQUEST= 0x0106,
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_RESPONSE= 0x0107
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_RESPONSE= 0x0107,
NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC = 0x0180,
NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC,
NFAPI_NR_PHY_MSG_TYPE_TIMING_INFO
} nfapi_nr_phy_msg_type_e;
// SCF222_5G-FAPI_PHY_SPI_Specificayion.pdf Section 3.3
@@ -88,10 +92,6 @@ typedef enum {
//same with nfapi_param_request_t
typedef struct {
nfapi_p4_p5_message_header_t header;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_param_request_t;
/*typedef struct {
@@ -1049,6 +1049,22 @@ typedef struct {
} nfapi_nr_dl_tti_request_body_t;
*/
typedef struct {
nfapi_p7_message_header_t header;
uint32_t t1;
int32_t delta_sfn_slot;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_dl_node_sync_t;
typedef struct {
nfapi_p7_message_header_t header;
uint32_t t1;
uint32_t t2;
uint32_t t3;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_ul_node_sync_t;
typedef struct {
nfapi_p7_message_header_t header;
/// System Frame Number (0-1023)
File diff suppressed because it is too large Load Diff
+612 -72
View File
@@ -3260,15 +3260,34 @@ static uint8_t pack_nrach_indication(void *msg, uint8_t **ppWritePackedMsg, uint
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
static uint8_t pack_nr_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
{
nfapi_nr_dl_node_sync_t *pNfapiMsg = (nfapi_nr_dl_node_sync_t*)msg;
return ( push32(pNfapiMsg->t1, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->delta_sfn_slot, ppWritePackedMsg, end) &&
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
static uint8_t pack_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
{
nfapi_dl_node_sync_t *pNfapiMsg = (nfapi_dl_node_sync_t*)msg;
return ( push32(pNfapiMsg->t1, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->delta_sfn_slot, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->delta_sfn_sf, ppWritePackedMsg, end) &&
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
static uint8_t pack_nr_ul_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
{
nfapi_nr_ul_node_sync_t *pNfapiMsg = (nfapi_nr_ul_node_sync_t*)msg;
return (push32(pNfapiMsg->t1, ppWritePackedMsg, end) &&
push32(pNfapiMsg->t2, ppWritePackedMsg, end) &&
push32(pNfapiMsg->t3, ppWritePackedMsg, end) &&
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
static uint8_t pack_ul_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
{
nfapi_ul_node_sync_t *pNfapiMsg = (nfapi_ul_node_sync_t*)msg;
@@ -3283,6 +3302,27 @@ static uint8_t pack_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *
{
nfapi_timing_info_t *pNfapiMsg = (nfapi_timing_info_t*)msg;
return (push32(pNfapiMsg->last_sfn_sf, ppWritePackedMsg, end) &&
push32(pNfapiMsg->time_since_last_timing_info, ppWritePackedMsg, end) &&
push32(pNfapiMsg->dl_config_jitter, ppWritePackedMsg, end) &&
push32(pNfapiMsg->tx_request_jitter, ppWritePackedMsg, end) &&
push32(pNfapiMsg->ul_config_jitter, ppWritePackedMsg, end) &&
push32(pNfapiMsg->hi_dci0_jitter, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->dl_config_latest_delay, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->tx_request_latest_delay, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->ul_config_latest_delay, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->hi_dci0_latest_delay, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->dl_config_earliest_arrival, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->tx_request_earliest_arrival, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->ul_config_earliest_arrival, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->hi_dci0_earliest_arrival, ppWritePackedMsg, end) &&
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
static uint8_t pack_nr_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
{
nfapi_nr_timing_info_t *pNfapiMsg = (nfapi_nr_timing_info_t*)msg;
return (push32(pNfapiMsg->last_sfn, ppWritePackedMsg, end) &&
push32(pNfapiMsg->last_slot, ppWritePackedMsg, end) &&
push32(pNfapiMsg->time_since_last_timing_info, ppWritePackedMsg, end) &&
@@ -3299,30 +3339,13 @@ static uint8_t pack_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *
pushs32(pNfapiMsg->ul_tti_earliest_arrival, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->ul_dci_earliest_arrival, ppWritePackedMsg, end) &&
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
#if LTE
return (push32(pNfapiMsg->last_sfn_sf, ppWritePackedMsg, end) &&
push32(pNfapiMsg->time_since_last_timing_info, ppWritePackedMsg, end) &&
push32(pNfapiMsg->dl_config_jitter, ppWritePackedMsg, end) &&
push32(pNfapiMsg->tx_request_jitter, ppWritePackedMsg, end) &&
push32(pNfapiMsg->ul_config_jitter, ppWritePackedMsg, end) &&
push32(pNfapiMsg->hi_dci0_jitter, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->dl_config_latest_delay, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->tx_request_latest_delay, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->ul_config_latest_delay, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->hi_dci0_latest_delay, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->dl_config_earliest_arrival, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->tx_request_earliest_arrival, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->ul_config_earliest_arrival, ppWritePackedMsg, end) &&
pushs32(pNfapiMsg->hi_dci0_earliest_arrival, ppWritePackedMsg, end) &&
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
#endif
}
// Main pack function - public
int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config)
int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config)
{
nfapi_p7_message_header_t *pMessageHeader = pMessageBuf;
uint8_t *pWritePackedMessage = pPackedBuf;
@@ -3374,7 +3397,172 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
result = pack_ul_dci_request(pMessageHeader, &pWritePackedMessage, end, config);
break;
#if 0
case NFAPI_UE_RELEASE_REQUEST:
result =pack_ue_release_request(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_UE_RELEASE_RESPONSE:
result =pack_ue_release_response(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_HARQ_INDICATION:
result = pack_harq_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_CRC_INDICATION:
result = pack_crc_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_RX_ULSCH_INDICATION:
//printf("RX ULSCH\n");
result = pack_rx_ulsch_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_RACH_INDICATION:
result = pack_rach_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_SRS_INDICATION:
result = pack_srs_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_RX_SR_INDICATION:
result = pack_sr_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_RX_CQI_INDICATION:
result = pack_cqi_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_LBT_DL_CONFIG_REQUEST:
result = pack_lbt_dl_config_request(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_LBT_DL_INDICATION:
result = pack_lbt_dl_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_NB_HARQ_INDICATION:
result = pack_nb_harq_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_NRACH_INDICATION:
result = pack_nrach_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
result = pack_nr_dl_node_sync(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC:
result = pack_nr_ul_node_sync(pMessageHeader, &pWritePackedMessage, end, config);
break;
case NFAPI_TIMING_INFO:
result = pack_nr_timing_info(pMessageHeader, &pWritePackedMessage, end, config);
break;
default:
{
if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX)
{
if(config && config->pack_p7_vendor_extension)
{
result = (config->pack_p7_vendor_extension)(pMessageHeader, &pWritePackedMessage, end, config);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve ecoder provided\n", __FUNCTION__, pMessageHeader->message_id);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
}
}
break;
}
if(result == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack failed to pack message\n");
return -1;
}
// check for a valid message length
uintptr_t msgHead = (uintptr_t)pPackedBuf;
uintptr_t msgEnd = (uintptr_t)pWritePackedMessage;
uint32_t packedMsgLen = msgEnd - msgHead;
uint16_t packedMsgLen16;
if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen);
return -1;
}
else
{
packedMsgLen16 = (uint16_t)packedMsgLen;
}
// Update the message length in the header
pMessageHeader->message_length = packedMsgLen16;
if(!push16(packedMsgLen16, &pPackedLengthField, end))
return -1;
if(1)
{
//quick test
if(pMessageHeader->message_length != packedMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi packedMsgLen(%d) != message_length(%d) id %d\n", packedMsgLen, pMessageHeader->message_length, pMessageHeader->message_id);
}
}
return (packedMsgLen);
}
int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config)
{
nfapi_p7_message_header_t *pMessageHeader = pMessageBuf;
uint8_t *pWritePackedMessage = pPackedBuf;
uint8_t *pPackedLengthField = &pWritePackedMessage[4];
uint8_t *end = pPackedBuf + packedBufLen;
if (pMessageBuf == NULL || pPackedBuf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack supplied pointers are null\n");
return -1;
}
/*
printf("\n P7 MESSAGE SENT: \n");
for(int i=0; i< packedBufLen; i++){
printf("%d", *(uint8_t *)(pMessageBuf + i));
}
printf("\n");
*/
// process the header
if(!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) &&
push16(pMessageHeader->message_id, &pWritePackedMessage, end) &&
push16(0/*pMessageHeader->message_length*/, &pWritePackedMessage, end) &&
push16(pMessageHeader->m_segment_sequence, &pWritePackedMessage, end) &&
push32(0/*pMessageHeader->checksum*/, &pWritePackedMessage, end) &&
push32(pMessageHeader->transmit_timestamp, &pWritePackedMessage, end)))
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack header failed\n");
return -1;
}
if (pMessageHeader->message_id != NFAPI_TIMING_INFO)
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() message_id:0x%04x phy_id:%u m_segment_sequence:%u timestamp:%u\n", __FUNCTION__, pMessageHeader->message_id, pMessageHeader->phy_id, pMessageHeader->m_segment_sequence, pMessageHeader->transmit_timestamp);
}
// look for the specific message
uint8_t result = 0;
switch (pMessageHeader->message_id)
{
case NFAPI_DL_CONFIG_REQUEST:
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() NFAPI_DL_CONFIG_REQUEST\n", __FUNCTION__);
result = pack_dl_config_request(pMessageHeader, &pWritePackedMessage, end, config);
@@ -3390,7 +3578,6 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu
case NFAPI_HI_DCI0_REQUEST:
result = pack_hi_dci0_request(pMessageHeader, &pWritePackedMessage, end, config);
break;
#endif
case NFAPI_UE_RELEASE_REQUEST:
result =pack_ue_release_request(pMessageHeader, &pWritePackedMessage, end, config);
@@ -3518,8 +3705,6 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu
return (packedMsgLen);
}
// Unpack routines
// NR:
static uint8_t unpack_dl_tti_csi_rs_pdu_rel15_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
@@ -7228,9 +7413,9 @@ static uint8_t unpack_nrach_indication(uint8_t **ppReadPackedMsg, uint8_t *end,
unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
}
static uint8_t unpack_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config)
static uint8_t unpack_nr_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config)
{
nfapi_dl_node_sync_t *pNfapiMsg = (nfapi_dl_node_sync_t*)msg;
nfapi_nr_dl_node_sync_t *pNfapiMsg = (nfapi_nr_dl_node_sync_t*)msg;
unpack_p7_tlv_t unpack_fns[] =
{
@@ -7241,6 +7426,35 @@ static uint8_t unpack_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void
unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
}
static uint8_t unpack_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config)
{
nfapi_dl_node_sync_t *pNfapiMsg = (nfapi_dl_node_sync_t*)msg;
unpack_p7_tlv_t unpack_fns[] =
{
};
return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->delta_sfn_sf, end) &&
unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
}
static uint8_t unpack_nr_ul_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config)
{
nfapi_nr_ul_node_sync_t *pNfapiMsg = (nfapi_nr_ul_node_sync_t*)msg;
unpack_p7_tlv_t unpack_fns[] =
{
};
return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->t2, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->t3, end) &&
unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
}
static uint8_t unpack_ul_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config)
{
nfapi_ul_node_sync_t *pNfapiMsg = (nfapi_ul_node_sync_t*)msg;
@@ -7263,6 +7477,32 @@ static uint8_t unpack_timing_info(uint8_t **ppReadPackedMsg, uint8_t *end, void
{
};
return (pull32(ppReadPackedMsg, &pNfapiMsg->last_sfn_sf, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->time_since_last_timing_info, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->dl_config_jitter, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->tx_request_jitter, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->ul_config_jitter, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_jitter, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->dl_config_latest_delay, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->tx_request_latest_delay, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_config_latest_delay, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_latest_delay, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->dl_config_earliest_arrival, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->tx_request_earliest_arrival, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_config_earliest_arrival, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_earliest_arrival, end) &&
unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
}
static uint8_t unpack_nr_timing_info(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config)
{
nfapi_nr_timing_info_t *pNfapiMsg = (nfapi_nr_timing_info_t*)msg;
unpack_p7_tlv_t unpack_fns[] =
{
};
return (pull32(ppReadPackedMsg, &pNfapiMsg->last_sfn, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->last_slot, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->time_since_last_timing_info, end) &&
@@ -7279,27 +7519,10 @@ static uint8_t unpack_timing_info(uint8_t **ppReadPackedMsg, uint8_t *end, void
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_tti_earliest_arrival, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_dci_earliest_arrival, end) &&
unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
#if LTE
return (pull32(ppReadPackedMsg, &pNfapiMsg->last_sfn_sf, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->time_since_last_timing_info, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->dl_config_jitter, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->tx_request_jitter, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->ul_config_jitter, end) &&
pull32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_jitter, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->dl_config_latest_delay, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->tx_request_latest_delay, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_config_latest_delay, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_latest_delay, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->dl_config_earliest_arrival, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->tx_request_earliest_arrival, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_config_earliest_arrival, end) &&
pulls32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_earliest_arrival, end) &&
unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
#endif
}
// unpack length check
static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen)
@@ -7421,6 +7644,126 @@ static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen
return retLen;
}
static int check_nr_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen)
{
int retLen = 0;
switch (msgId)
{
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_dl_tti_request_t))
retLen = sizeof(nfapi_nr_dl_tti_request_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_ul_tti_request_t))
retLen = sizeof(nfapi_nr_ul_tti_request_t);
break;
case NFAPI_SUBFRAME_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_subframe_indication_t))
retLen = sizeof(nfapi_subframe_indication_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_ul_dci_request_t))
retLen = sizeof(nfapi_nr_ul_dci_request_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_tx_data_request_t))
retLen = sizeof(nfapi_nr_tx_data_request_t);
break;
case NFAPI_HARQ_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_harq_indication_t))
retLen = sizeof(nfapi_harq_indication_t);
break;
case NFAPI_CRC_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_crc_indication_t))
retLen = sizeof(nfapi_crc_indication_t);
break;
case NFAPI_RX_ULSCH_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_rx_indication_t))
retLen = sizeof(nfapi_rx_indication_t);
break;
case NFAPI_RACH_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_rach_indication_t))
retLen = sizeof(nfapi_rach_indication_t);
break;
case NFAPI_SRS_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_srs_indication_t))
retLen = sizeof(nfapi_srs_indication_t);
break;
case NFAPI_RX_SR_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_sr_indication_t))
retLen = sizeof(nfapi_sr_indication_t);
break;
case NFAPI_RX_CQI_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_cqi_indication_t))
retLen = sizeof(nfapi_cqi_indication_t);
break;
case NFAPI_LBT_DL_CONFIG_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_lbt_dl_config_request_t))
retLen = sizeof(nfapi_lbt_dl_config_request_t);
break;
case NFAPI_LBT_DL_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_lbt_dl_indication_t))
retLen = sizeof(nfapi_lbt_dl_indication_t);
break;
case NFAPI_NB_HARQ_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_nb_harq_indication_t))
retLen = sizeof(nfapi_nb_harq_indication_t);
break;
case NFAPI_NRACH_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_nrach_indication_t))
retLen = sizeof(nfapi_nrach_indication_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
if (unpackedBufLen >= sizeof(nfapi_nr_dl_node_sync_t))
retLen = sizeof(nfapi_nr_dl_node_sync_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC:
if (unpackedBufLen >= sizeof(nfapi_nr_ul_node_sync_t))
retLen = sizeof(nfapi_nr_ul_node_sync_t);
break;
case NFAPI_TIMING_INFO:
if (unpackedBufLen >= sizeof(nfapi_timing_info_t))
retLen = sizeof(nfapi_timing_info_t);
break;
case NFAPI_UE_RELEASE_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_ue_release_request_t))
retLen = sizeof(nfapi_ue_release_request_t);
break;
case NFAPI_UE_RELEASE_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_ue_release_response_t))
retLen = sizeof(nfapi_ue_release_response_t);
break;
default:
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown message ID %d\n", msgId);
break;
}
return retLen;
}
// Main unpack functions - public
@@ -7513,32 +7856,6 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
// look for the specific message
switch (pMessageHeader->message_id)
{
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
if (check_unpack_length(NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST, unpackedBufLen))
result = unpack_dl_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
if (check_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST, unpackedBufLen))
result = unpack_ul_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
if (check_unpack_length(NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST, unpackedBufLen))
result = unpack_tx_data_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
if (check_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST, unpackedBufLen))
result = unpack_ul_dci_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
#if 0
case NFAPI_DL_CONFIG_REQUEST:
if (check_unpack_length(NFAPI_DL_CONFIG_REQUEST, unpackedBufLen))
result = unpack_dl_config_request(&pReadPackedMessage, end, pMessageHeader, config);
@@ -7564,8 +7881,6 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
else
return -1;
break;
#endif
case NFAPI_UE_RELEASE_REQUEST:
if (check_unpack_length(NFAPI_UE_RELEASE_REQUEST, unpackedBufLen))
@@ -7706,3 +8021,228 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
return 0;
}
int nfapi_nr_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config)
{
int result = 0;
nfapi_p7_message_header_t *pMessageHeader = (nfapi_p7_message_header_t*)pUnpackedBuf;
uint8_t *pReadPackedMessage = pMessageBuf;
uint8_t *end = pMessageBuf + messageBufLen;
if (pMessageBuf == NULL || pUnpackedBuf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied pointers are null\n");
return -1;
}
if (messageBufLen < NFAPI_P7_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p7_message_header_t))
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen);
return -1;
}
/*
uint8_t *ptr = pMessageBuf;
printf("\n Read P7 message unpack: ");
while(ptr < end){
printf(" %d ", *ptr);
ptr++;
}
printf("\n");
*/
// clean the supplied buffer for - tag value blanking
(void)memset(pUnpackedBuf, 0, unpackedBufLen);
// process the header
if(!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) &&
pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) &&
pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) &&
pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end) &&
pull32(&pReadPackedMessage, &pMessageHeader->checksum, end) &&
pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end)))
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack header failed\n");
return -1;
}
if((uint8_t*)(pMessageBuf + pMessageHeader->message_length) > end)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack message length is greater than the message buffer \n");
return -1;
}
/*
if(check_unpack_length(pMessageHeader->message_id, unpackedBufLen) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack unpack buffer is not large enough \n");
return -1;
}
*/
// look for the specific message
switch (pMessageHeader->message_id)
{
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST, unpackedBufLen))
result = unpack_dl_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST, unpackedBufLen))
result = unpack_ul_tti_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST, unpackedBufLen))
result = unpack_tx_data_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST, unpackedBufLen))
result = unpack_ul_dci_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_UE_RELEASE_REQUEST:
if (check_nr_unpack_length(NFAPI_UE_RELEASE_REQUEST, unpackedBufLen))
result = unpack_ue_release_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_HARQ_INDICATION:
if (check_nr_unpack_length(NFAPI_HARQ_INDICATION, unpackedBufLen))
result = unpack_harq_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_CRC_INDICATION:
if (check_nr_unpack_length(NFAPI_CRC_INDICATION, unpackedBufLen))
result = unpack_crc_indication(&pReadPackedMessage,end , pMessageHeader, config);
else
return -1;
break;
case NFAPI_RX_ULSCH_INDICATION:
if (check_nr_unpack_length(NFAPI_RX_ULSCH_INDICATION, unpackedBufLen))
result = unpack_rx_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_RACH_INDICATION:
if (check_nr_unpack_length(NFAPI_RACH_INDICATION, unpackedBufLen))
result = unpack_rach_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_SRS_INDICATION:
if (check_nr_unpack_length(NFAPI_SRS_INDICATION, unpackedBufLen))
result = unpack_srs_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_RX_SR_INDICATION:
if (check_nr_unpack_length(NFAPI_RX_SR_INDICATION, unpackedBufLen))
result = unpack_sr_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_RX_CQI_INDICATION:
if (check_nr_unpack_length(NFAPI_RX_CQI_INDICATION, unpackedBufLen))
result = unpack_cqi_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_LBT_DL_CONFIG_REQUEST:
if (check_nr_unpack_length(NFAPI_LBT_DL_CONFIG_REQUEST, unpackedBufLen))
result = unpack_lbt_dl_config_request(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_LBT_DL_INDICATION:
if (check_nr_unpack_length(NFAPI_LBT_DL_INDICATION, unpackedBufLen))
result = unpack_lbt_dl_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NB_HARQ_INDICATION:
if (check_nr_unpack_length(NFAPI_NB_HARQ_INDICATION, unpackedBufLen))
result = unpack_nb_harq_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NRACH_INDICATION:
if (check_nr_unpack_length(NFAPI_NRACH_INDICATION, unpackedBufLen))
result = unpack_nrach_indication(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC, unpackedBufLen))
result = unpack_nr_dl_node_sync(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC:
if (check_nr_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC, unpackedBufLen))
result = unpack_nr_ul_node_sync(&pReadPackedMessage, end , pMessageHeader, config);
else
return -1;
break;
case NFAPI_TIMING_INFO:
if (check_nr_unpack_length(NFAPI_TIMING_INFO, unpackedBufLen))
result = unpack_nr_timing_info(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
case NFAPI_UE_RELEASE_RESPONSE:
if (check_nr_unpack_length(NFAPI_UE_RELEASE_RESPONSE, unpackedBufLen))
result = unpack_ue_release_resp(&pReadPackedMessage, end, pMessageHeader, config);
else
return -1;
break;
default:
if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX)
{
if(config && config->unpack_p7_vendor_extension)
{
result = (config->unpack_p7_vendor_extension)(pMessageHeader, &pReadPackedMessage, end, config);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve decoder provided\n", __FUNCTION__, pMessageHeader->message_id);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
}
break;
}
if(result == 0)
return -1;
else
return 0;
}
+2 -1
View File
@@ -38,8 +38,9 @@ typedef struct {
int pnf_connect(pnf_t *pnf);
int pnf_message_pump(pnf_t *pnf);
int pnf_nr_message_pump(pnf_t *pnf);
//int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len);
int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len);
int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len);
int pnf_pack_and_send_p4_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len);
int pnf_send_message(pnf_t* pnf, uint8_t* msg, uint32_t msg_len, uint16_t stream_id);
+1 -1
View File
@@ -146,7 +146,7 @@ typedef struct {
} pnf_p7_t;
int pnf_p7_message_pump(pnf_p7_t* pnf_p7);
int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7);
int pnf_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* msg, uint32_t msg_len);
int pnf_p7_send_message(pnf_p7_t* pnf_p7, uint8_t* msg, uint32_t msg_len);
@@ -127,7 +127,7 @@ typedef struct nfapi_pnf_config
* The client is expected to send the PNF_PARAM.response after receiving the
* PNF_PARAM.request. This can be done in the call back.
*/
//int (*pnf_nr_param_req)(nfapi_pnf_config_t* config, nfapi_nr_pnf_param_request_t* req);
int (*pnf_nr_param_req)(nfapi_pnf_config_t* config, nfapi_nr_pnf_param_request_t* req);
int (*pnf_param_req)(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req);
/*! A callback for the PNF_CONFIG.request
@@ -140,7 +140,8 @@ typedef struct nfapi_pnf_config
* PNF_CONFIG.request. This can be done in the call back.
*/
int (*pnf_config_req)(nfapi_pnf_config_t* config, nfapi_pnf_config_request_t* req);
int (*pnf_nr_config_req)(nfapi_pnf_config_t* config, nfapi_nr_pnf_config_request_t* req);
/*! A callback for the PNF_START.request
* \param config A pointer to the pnf configuration
* \param req A data structure for the decoded PNF_CONFIG.request. This will have
@@ -151,7 +152,8 @@ typedef struct nfapi_pnf_config
* PNF_START.request. This can be done in the call back.
*/
int (*pnf_start_req)(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req);
int (*pnf_nr_start_req)(nfapi_pnf_config_t* config, nfapi_nr_pnf_start_request_t* req);
/*! A callback for the PNF_STOP.request
* \param config A pointer to the pnf configuration
* \param req A data structure for the decoded PNF_STOP.request. This will have
@@ -173,8 +175,9 @@ typedef struct nfapi_pnf_config
* The client is expected to send the PARAM.response after receiving the
* PARAM.request. This can be done in the call back.
*/
int (*param_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nr_param_request_scf_t* req);
int (*param_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_param_request_t* req);
int (*nr_param_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nr_param_request_scf_t* req);
/*! A callback for the CONFIG.request
* \param config A pointer to the pnf configuration
* \param phy A pointer to the pnf phy configuration
@@ -185,7 +188,8 @@ typedef struct nfapi_pnf_config
* The client is expected to send the CONFIG.response after receiving the
* CONFIG.request. This can be done in the call back.
*/
int (*config_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nr_config_request_scf_t* req);
int (*config_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_config_request_t* req);
int (*nr_config_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nr_config_request_scf_t* req);
/*! A callback for the START.request
* \param config A pointer to the pnf configuration
@@ -197,8 +201,8 @@ typedef struct nfapi_pnf_config
* The client is expected to send the START.response after the client has received the
* first subframe indication from FAPI.
*/
int (*start_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nr_start_request_scf_t* req);
int (*start_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_start_request_t* req);
int (*nr_start_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nr_start_request_scf_t* req);
/*! A callback for the STOP.request
* \param config A pointer to the pnf configuration
* \param phy A pointer to the pnf phy configuration
@@ -362,6 +366,7 @@ int nfapi_pnf_config_destroy(nfapi_pnf_config_t* config);
* \endcode
*/
int nfapi_pnf_start(nfapi_pnf_config_t* config);
int nfapi_nr_pnf_start(nfapi_pnf_config_t* config);
/*! Stop the PNF library.
* \param config A pointer to the pnf configuration
@@ -378,6 +383,8 @@ int nfapi_pnf_stop(nfapi_pnf_config_t* config);
*
*/
int nfapi_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_pnf_param_response_t* resp);
int nfapi_nr_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_param_response_t* resp);
/*! Send the PNF_CONFIG.response
* \param config A pointer to a pnf configuraiton
@@ -386,6 +393,7 @@ int nfapi_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_pnf_param_respons
*
*/
int nfapi_pnf_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_pnf_config_response_t* resp);
int nfapi_nr_pnf_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_config_response_t* resp);
/*! Send the PNF_START.response
* \param config A pointer to a pnf configuraiton
@@ -394,7 +402,7 @@ int nfapi_pnf_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_pnf_config_respo
*
*/
int nfapi_pnf_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_pnf_start_response_t* resp);
int nfapi_nr_pnf_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_start_response_t* resp);
/*! Send the PNF_STOP.response
* \param config A pointer to a pnf configuraiton
* \param resp A pointer to the message structure
@@ -409,7 +417,8 @@ int nfapi_pnf_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_pnf_stop_response_
* \return 0 for success, -1 for failure
*
*/
int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_scf_t* resp);
int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_param_response_t* resp);
int nfapi_nr_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_scf_t* resp);
/*! Send the CONFIG.response
* \param config A pointer to a pnf configuraiton
@@ -417,15 +426,16 @@ int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_scf
* \return 0 for success, -1 for failure
*
*/
int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_config_response_scf_t* resp);
int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_config_response_t* resp);
int nfapi_nr_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_config_response_scf_t* resp);
/*! Send the START.response
* \param config A pointer to a pnf configuraiton
* \param resp A pointer to the message structure
* \return 0 for success, -1 for failure
*
*/
int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_start_response_scf_t* resp);
int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_start_response_t* resp);
int nfapi_nr_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_start_response_scf_t* resp);
/*! Send the STOP.response
* \param config A pointer to a pnf configuraiton
@@ -738,6 +748,7 @@ int nfapi_pnf_p7_config_destroy(nfapi_pnf_p7_config_t* config);
* This function will not return until nfapi_pnf_p7_stop is called.
*/
int nfapi_pnf_p7_start(nfapi_pnf_p7_config_t* config);
int nfapi_nr_pnf_p7_start(nfapi_pnf_p7_config_t* config);
/*! Stop the PNF P7 library.
* \param config A pointer to a PNF P7 config
+670 -45
View File
@@ -82,7 +82,7 @@ nfapi_pnf_phy_config_t* nfapi_pnf_phy_config_find(nfapi_pnf_config_t* config, ui
}
return 0;
}
/*
void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
@@ -110,11 +110,11 @@ void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in IDLE state\n", __FUNCTION__);
nfapi_pnf_param_response_t resp;
nfapi_nr_pnf_param_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_PARAM_RESPONSE;
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_RESPONSE;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_pnf_pnf_param_resp(&pnf->_public, &resp);
nfapi_nr_pnf_pnf_param_resp(&pnf->_public, &resp);
}
}
else
@@ -126,7 +126,7 @@ void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
*/
void pnf_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
@@ -237,6 +237,72 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
}
void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
if (pRecvMsg == NULL || pnf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
nfapi_nr_pnf_config_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_CONFIG.request received\n");
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0)
{
// ensure correct state
if(pnf->_public.state != NFAPI_PNF_RUNNING)
{
// delete the phy records
nfapi_pnf_phy_config_delete_all(&pnf->_public);
// create the phy records
if (req.pnf_phy_rf_config.tl.tag == NFAPI_PNF_PHY_RF_TAG)
{
int i = 0;
for(i = 0; i < req.pnf_phy_rf_config.number_phy_rf_config_info; ++i)
{
nfapi_pnf_phy_config_t* phy = (nfapi_pnf_phy_config_t*)malloc(sizeof(nfapi_pnf_phy_config_t));
memset(phy, 0, sizeof(nfapi_pnf_phy_config_t));
phy->state = NFAPI_PNF_PHY_IDLE;
phy->phy_id = req.pnf_phy_rf_config.phy_rf_config[i].phy_id;
nfapi_pnf_phy_config_add(&(pnf->_public), phy);
}
}
if(pnf->_public.pnf_nr_config_req)
{
(pnf->_public.pnf_nr_config_req)(&(pnf->_public), &req);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in correct state: %d\n", __FUNCTION__, pnf->_public.state);
nfapi_nr_pnf_config_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_nr_pnf_pnf_config_resp(&(pnf->_public), &resp);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
void pnf_handle_pnf_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
@@ -279,6 +345,48 @@ void pnf_handle_pnf_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
}
void pnf_nr_handle_pnf_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
if (pRecvMsg == NULL || pnf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
nfapi_nr_pnf_start_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_START.request Received\n");
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0)
{
if(pnf->_public.state == NFAPI_PNF_CONFIGURED)
{
if(pnf->_public.pnf_nr_start_req)
{
(pnf->_public.pnf_nr_start_req)(&(pnf->_public), &req);
}
}
else
{
nfapi_nr_pnf_start_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_START_RESPONSE;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_nr_pnf_pnf_start_resp(&(pnf->_public), &resp);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
void pnf_handle_pnf_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
@@ -322,6 +430,49 @@ void pnf_handle_pnf_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
}
void pnf_nr_handle_pnf_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
if (pRecvMsg == NULL || pnf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
nfapi_nr_pnf_stop_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_STOP.request Received\n");
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0)
{
if(pnf->_public.state == NFAPI_PNF_RUNNING)
{
if(pnf->_public.pnf_stop_req)
{
(pnf->_public.pnf_stop_req)(&(pnf->_public), &req);
}
}
else
{
nfapi_pnf_stop_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_PNF_STOP_RESPONSE;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_pnf_pnf_stop_resp(&(pnf->_public), &resp);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
@@ -331,7 +482,7 @@ void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
else
{
nfapi_nr_param_request_scf_t req;
nfapi_param_request_t req;
nfapi_pnf_config_t* config = &(pnf->_public);
@@ -394,6 +545,78 @@ void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
}
void pnf_nr_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
if (pRecvMsg == NULL || pnf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
nfapi_nr_param_request_scf_t req;
nfapi_pnf_config_t* config = &(pnf->_public);
NFAPI_TRACE(NFAPI_TRACE_INFO, "PARAM.request received\n");
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
{
nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id);
if(phy)
{
if(phy->state == NFAPI_PNF_PHY_IDLE)
{
if(config->nr_param_req)
{
(config->nr_param_req)(config, phy, &req);
}
}
else
{
nfapi_nr_param_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_nr_pnf_param_resp(config, &resp);
}
}
else
{
nfapi_nr_param_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_CONFIG;
nfapi_nr_pnf_param_resp(config, &resp);
}
}
else
{
nfapi_nr_param_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_nr_pnf_param_resp(config, &resp);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
@@ -404,7 +627,7 @@ void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
else
{
nfapi_nr_config_request_scf_t req;
nfapi_config_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "CONFIG.request received\n");
@@ -416,11 +639,6 @@ void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
if(config->state == NFAPI_PNF_RUNNING)
{
nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id);
#if 0 // emulate set_config TLV reception (hard-code)
int tdd_return = set_tdd_config_nr(&req, 1, 7, 6, 2, 4);
#endif
if(phy)
{
if(phy->state != NFAPI_PNF_PHY_RUNNING)
@@ -428,8 +646,6 @@ void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
if(config->config_req)
{
(config->config_req)(config, phy, &req);
}
}
else
@@ -472,6 +688,85 @@ void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
}
void pnf_nr_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
if (pRecvMsg == NULL || pnf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
nfapi_nr_config_request_scf_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "CONFIG.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
{
nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id);
#if 0 // emulate set_config TLV reception (hard-code)
int tdd_return = set_tdd_config_nr(&req, 1, 7, 6, 2, 4);
#endif
if(phy)
{
if(phy->state != NFAPI_PNF_PHY_RUNNING)
{
if(config->nr_config_req)
{
(config->nr_config_req)(config, phy, &req);
}
}
else
{
nfapi_nr_config_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_CONFIG_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_nr_pnf_config_resp(config, &resp);
}
}
else
{
nfapi_nr_config_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_CONFIG_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_CONFIG;
nfapi_nr_pnf_config_resp(config, &resp);
}
}
else
{
nfapi_nr_config_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_CONFIG_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_nr_pnf_config_resp(config, &resp);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
void pnf_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
@@ -481,7 +776,7 @@ void pnf_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
else
{
nfapi_nr_start_request_scf_t req;
nfapi_start_request_t req;
nfapi_pnf_config_t* config = &(pnf->_public);
@@ -543,6 +838,77 @@ void pnf_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
}
void pnf_nr_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
if (pRecvMsg == NULL || pnf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
nfapi_nr_start_request_scf_t req;
nfapi_pnf_config_t* config = &(pnf->_public);
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() START.request received state:%d\n", __FUNCTION__, config->state);
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
{
nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id);
if(phy)
{
if(phy->state != NFAPI_PNF_PHY_RUNNING)
{
if(config->nr_start_req)
{
(config->nr_start_req)(config, phy, &req);
}
}
else
{
nfapi_nr_start_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_START_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_nr_pnf_start_resp(config, &resp);
}
}
else
{
nfapi_nr_start_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_START_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_CONFIG;
nfapi_nr_pnf_start_resp(config, &resp);
}
}
else
{
nfapi_nr_start_response_scf_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_START_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_nr_pnf_start_resp(config, &resp);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
@@ -614,6 +980,77 @@ void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
}
void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
if (pRecvMsg == NULL || pnf == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
nfapi_nr_stop_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "STOP.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0)
{
if(config->state == NFAPI_PNF_RUNNING)
{
nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id);
if(phy)
{
if(phy->state != NFAPI_PNF_PHY_RUNNING)
{
if(config->stop_req)
{
(config->stop_req)(config, phy, &req);
}
}
else
{
nfapi_stop_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_STOP_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_pnf_stop_resp(config, &resp);
}
}
else
{
nfapi_stop_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_STOP_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_CONFIG;
nfapi_pnf_stop_resp(config, &resp);
}
}
else
{
nfapi_stop_response_t resp;
memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_STOP_RESPONSE;
resp.header.phy_id = req.header.phy_id;
resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_pnf_stop_resp(config, &resp);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
if(req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension);
}
}
void pnf_handle_measurement_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
// ensure it's valid
@@ -1142,7 +1579,6 @@ void pnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_t* pnf, uin
}
}
/*
void pnf_nr_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
nfapi_p4_p5_message_header_t messageHeader;
@@ -1167,32 +1603,32 @@ void pnf_nr_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
pnf_nr_handle_pnf_param_request(pnf, pRecvMsg, recvMsgLen);
break;
case NFAPI_PNF_CONFIG_REQUEST:
pnf_handle_pnf_config_request(pnf, pRecvMsg, recvMsgLen);
case NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_REQUEST:
pnf_nr_handle_pnf_config_request(pnf, pRecvMsg, recvMsgLen);
break;
case NFAPI_PNF_START_REQUEST:
pnf_handle_pnf_start_request(pnf, pRecvMsg, recvMsgLen);
case NFAPI_NR_PHY_MSG_TYPE_PNF_START_REQUEST:
pnf_nr_handle_pnf_start_request(pnf, pRecvMsg, recvMsgLen);
break;
case NFAPI_PNF_STOP_REQUEST:
pnf_handle_pnf_stop_request(pnf, pRecvMsg, recvMsgLen);
case NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_REQUEST:
pnf_nr_handle_pnf_stop_request(pnf, pRecvMsg, recvMsgLen);
break;
case NFAPI_PARAM_REQUEST:
pnf_handle_param_request(pnf, pRecvMsg, recvMsgLen);
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
pnf_nr_handle_param_request(pnf, pRecvMsg, recvMsgLen);
break;
case NFAPI_CONFIG_REQUEST:
pnf_handle_config_request(pnf, pRecvMsg, recvMsgLen);
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
pnf_nr_handle_config_request(pnf, pRecvMsg, recvMsgLen);
break;
case NFAPI_START_REQUEST:
pnf_handle_start_request(pnf, pRecvMsg, recvMsgLen);
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
pnf_nr_handle_start_request(pnf, pRecvMsg, recvMsgLen);
break;
case NFAPI_STOP_REQUEST:
pnf_handle_stop_request(pnf, pRecvMsg, recvMsgLen);
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
pnf_nr_handle_stop_request(pnf, pRecvMsg, recvMsgLen);
break;
case NFAPI_MEASUREMENT_REQUEST:
@@ -1238,7 +1674,7 @@ void pnf_nr_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
break;
}
}
*/
void pnf_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
{
nfapi_p4_p5_message_header_t messageHeader;
@@ -1336,21 +1772,21 @@ void pnf_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
}
// int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len)
// {
// int packed_len = nfapi_nr_p5_message_pack(msg, msg_len,
// pnf->tx_message_buffer,
// sizeof(pnf->tx_message_buffer),
// &pnf->_public.codec_config);
int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len)
{
int packed_len = nfapi_nr_p5_message_pack(msg, msg_len,
pnf->tx_message_buffer,
sizeof(pnf->tx_message_buffer),
&pnf->_public.codec_config);
// if (packed_len < 0)
// {
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p5_message_pack failed (%d)\n", packed_len);
// return -1;
// }
if (packed_len < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p5_message_pack failed (%d)\n", packed_len);
return -1;
}
// return pnf_send_message(pnf, pnf->tx_message_buffer, packed_len, 0/*msg->stream_id*/);
// }
return pnf_send_message(pnf, pnf->tx_message_buffer, packed_len, 0/*msg->stream_id*/);
}
int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len)
@@ -1603,7 +2039,6 @@ int pnf_send_message(pnf_t* pnf, uint8_t *msg, uint32_t len, uint16_t stream)
return 0;
}
int pnf_read_dispatch_message(pnf_t* pnf)
{
int socket_connected = 1;
@@ -1731,6 +2166,135 @@ int pnf_read_dispatch_message(pnf_t* pnf)
return socket_connected;
}
int pnf_nr_read_dispatch_message(pnf_t* pnf)
{
int socket_connected = 1;
// 1. Peek the message header
// 2. If the message is larger than the stack buffer then create a dynamic buffer
// 3. Read the buffer
// 4. Handle the p5 message
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
uint8_t header_buffer[header_buffer_size];
uint32_t stack_buffer_size = 32; //should it be the size of then sctp_notificatoin structure
uint8_t stack_buffer[stack_buffer_size];
uint8_t* dynamic_buffer = 0;
uint8_t* read_buffer = &stack_buffer[0];
uint32_t message_size = 0;
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
struct sctp_sndrcvinfo sndrcvinfo;
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
{
int flags = MSG_PEEK;
message_size = sctp_recvmsg(pnf->p5_sock, header_buffer, header_buffer_size, /*(struct sockaddr*)&addr, &addr_len*/ 0, 0, &sndrcvinfo, &flags);
if(message_size == -1)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to peek sctp message size errno:%d\n", errno);
return 0;
}
nfapi_p4_p5_message_header_t header;
int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
if(unpack_result < 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to unpack p5 message header\n");
return 0;
}
message_size = header.message_length;
// now have the size of the mesage
}
if(message_size > stack_buffer_size)
{
dynamic_buffer = (uint8_t*)malloc(message_size);
if(dynamic_buffer == NULL)
{
// todo : add error mesage
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to allocate dynamic buffer for sctp_recvmsg size:%d\n", message_size);
return -1;
}
read_buffer = dynamic_buffer;
}
{
int flags = 0;
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
int recvmsg_result = sctp_recvmsg(pnf->p5_sock, read_buffer, message_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
if(recvmsg_result == -1)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Failed to read sctp message size errno:%d\n", errno);
}
else
{
// print the received message
printf("\n MESSAGE RECEIVED: \n");
for(int i=0; i<message_size; i++){
printf("%d", read_buffer[i]);
}
printf("\n");
if (flags & MSG_NOTIFICATION)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Notification received from %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
// todo - handle the events
}
else
{
/*
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received message fd:%d from %s:%u assoc:%d on stream %d, PPID %d, length %d, flags 0x%x\n",
pnf->p5_sock,
inet_ntoa(addr.sin_addr),
ntohs(addr.sin_port),
sndrcvinfo.sinfo_assoc_id,
sndrcvinfo.sinfo_stream,
ntohl(sndrcvinfo.sinfo_ppid),
message_size,
flags);
*/
// handle now if complete message in one or more segments
if ((flags & 0x80) == 0x80)
{
pnf_nr_handle_p5_message(pnf, read_buffer, message_size);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "sctp_recvmsg: unhandled mode with flags 0x%x\n", flags);
// assume socket disconnected
NFAPI_TRACE(NFAPI_TRACE_WARN, "Disconnected socket\n");
socket_connected = 0;
}
}
}
}
if(dynamic_buffer)
{
free(dynamic_buffer);
}
return socket_connected;
}
@@ -1795,3 +2359,64 @@ int pnf_message_pump(pnf_t* pnf)
}
int pnf_nr_message_pump(pnf_t* pnf)
{
uint8_t socketConnected = 1;
while(socketConnected && pnf->terminate == 0)
{
fd_set rfds;
int selectRetval = 0;
// select on a timeout and then get the message
FD_ZERO(&rfds);
FD_SET(pnf->p5_sock, &rfds);
struct timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
selectRetval = select(pnf->p5_sock+1, &rfds, NULL, NULL, &timeout);
if(selectRetval == 0)
{
// timeout
continue;
}
else if (selectRetval == -1 && (errno == EINTR))
{
// interrupted by signal
NFAPI_TRACE(NFAPI_TRACE_WARN, "P5 Signal Interrupt %d\n", errno);
continue;
}
else if (selectRetval == -1)
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "P5 select() failed\n");
sleep(1);
continue;
}
if(FD_ISSET(pnf->p5_sock, &rfds))
{
socketConnected = pnf_nr_read_dispatch_message(pnf);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "Why are we here\n");
}
}
// Drop back to idle if we have lost connection
pnf->_public.state = NFAPI_PNF_PHY_IDLE;
// close the connection and socket
if (close(pnf->p5_sock) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "close(sctpSock) failed errno: %d\n", errno);
}
return 0;
}
+154 -9
View File
@@ -83,6 +83,40 @@ int nfapi_pnf_start(nfapi_pnf_config_t* config)
return 0;
}
int nfapi_nr_pnf_start(nfapi_pnf_config_t* config)
{
// Verify that config is not null
if(config == 0)
return -1;
// Make sure to set the defined trace function before using NFAPI_TRACE
if(config->trace)
nfapi_trace_g = config->trace;
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
pnf_t* _this = (pnf_t*)(config);
while (_this->terminate == 0)
{
int connect_result = pnf_connect(_this);
if(connect_result > 0)
{
pnf_nr_message_pump(_this);
}
else if(connect_result < 0)
{
return connect_result;
}
sleep(1);
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() terminate=1 - EXITTING............\n", __FUNCTION__);
return 0;
}
int nfapi_pnf_stop(nfapi_pnf_config_t* config)
{
// Verify that config is not null
@@ -98,7 +132,7 @@ int nfapi_pnf_stop(nfapi_pnf_config_t* config)
return 0;
}
/*
int nfapi_nr_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_param_response_t* resp)
{
// ensure it's valid
@@ -112,7 +146,7 @@ int nfapi_nr_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_param_r
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_pnf_param_response_t));
}
*/
int nfapi_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_pnf_param_response_t* resp)
{
// ensure it's valid
@@ -146,6 +180,27 @@ int nfapi_pnf_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_pnf_config_respo
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_pnf_config_response_t));
}
int nfapi_nr_pnf_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_config_response_t* resp)
{
// ensure it's valid
if (config == NULL || resp == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
return -1;
}
if(resp->error_code == NFAPI_MSG_OK)
{
config->state = NFAPI_PNF_CONFIGURED;
}
pnf_t* _this = (pnf_t*)(config);
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_pnf_config_response_t));
}
int nfapi_pnf_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_pnf_start_response_t* resp)
{
// ensure it's valid
@@ -165,6 +220,26 @@ int nfapi_pnf_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_pnf_start_respons
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_pnf_start_response_t));
}
int nfapi_nr_pnf_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_start_response_t* resp)
{
// ensure it's valid
if (config == NULL || resp == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
return -1;
}
if(resp->error_code == NFAPI_MSG_OK)
{
config->state = NFAPI_PNF_RUNNING;
}
pnf_t* _this = (pnf_t*)(config);
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_pnf_start_response_t));
}
int nfapi_pnf_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_pnf_stop_response_t* resp)
{
// ensure it's valid
@@ -183,8 +258,7 @@ int nfapi_pnf_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_pnf_stop_response_
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_pnf_stop_response_t));
}
int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_scf_t* resp)
int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_param_response_t* resp)
{
if (config == NULL || resp == NULL)
{
@@ -194,10 +268,24 @@ int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_scf
pnf_t* _this = (pnf_t*)(config);
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_param_response_scf_t));
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_param_response_t));
}
int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_config_response_scf_t* resp)
int nfapi_nr_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_scf_t* resp)
{
if (config == NULL || resp == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
return -1;
}
pnf_t* _this = (pnf_t*)(config);
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_param_response_scf_t));
}
int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_config_response_t* resp)
{
if (config == NULL || resp == NULL)
{
@@ -222,10 +310,39 @@ int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_config_response_s
return -1;
}
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_config_response_scf_t));
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_config_response_t));
}
int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_start_response_scf_t* resp)
int nfapi_nr_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_config_response_scf_t* resp)
{
if (config == NULL || resp == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
return -1;
}
pnf_t* _this = (pnf_t*)(config);
nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, resp->header.phy_id);
if(phy)
{
if(resp->error_code == NFAPI_MSG_OK)
{
phy->state = NFAPI_PNF_PHY_CONFIGURED;
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: unknow phy id %d\n", __FUNCTION__, resp->header.phy_id);
return -1;
}
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_config_response_scf_t));
}
int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_start_response_t* resp)
{
if (config == NULL || resp == NULL)
{
@@ -249,9 +366,37 @@ int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_start_response_scf
return -1;
}
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_start_response_scf_t));
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_start_response_t));
}
int nfapi_nr_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_start_response_scf_t* resp)
{
if (config == NULL || resp == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
return -1;
}
pnf_t* _this = (pnf_t*)(config);
nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, resp->header.phy_id);
if(phy)
{
if(resp->error_code == NFAPI_MSG_OK)
{
phy->state = NFAPI_PNF_PHY_RUNNING;
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: unknown phy id %d\n", __FUNCTION__, resp->header.phy_id);
return -1;
}
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_start_response_scf_t));
}
int nfapi_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_stop_response_t* resp)
{
if (config == NULL || resp == NULL)
+594 -24
View File
@@ -521,6 +521,30 @@ static uint32_t get_slot_time(uint32_t now_hr, uint32_t slot_start_hr)
}
}
static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr)
{
if(now_hr < sf_start_hr)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "now is earlier than start of subframe\n");
return 0;
}
else
{
uint32_t now_us = TIMEHR_USEC(now_hr);
uint32_t sf_start_us = TIMEHR_USEC(sf_start_hr);
// if the us have wrapped adjust for it
if(now_hr < sf_start_us)
{
now_us += 1000000;
}
return now_us - sf_start_us;
}
}
int pnf_p7_send_message(pnf_p7_t* pnf_p7, uint8_t* msg, uint32_t len)
{
// todo : consider how to do this only once
@@ -645,6 +669,97 @@ int pnf_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t*
return 0;
}
int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* header, uint32_t msg_len)
{
header->m_segment_sequence = NFAPI_P7_SET_MSS(0, 0, pnf_p7->sequence_number);
// Need to guard against different threads calling the encode function at the same time
if(pthread_mutex_lock(&(pnf_p7->pack_mutex)) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n");
return -1;
}
int len = nfapi_nr_p7_message_pack(header, pnf_p7->tx_message_buffer, sizeof(pnf_p7->tx_message_buffer), &pnf_p7->_public.codec_config);
if (len < 0)
{
if(pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
return -1;
}
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p7_message_pack failed with return %d\n", len );
return -1;
}
if(len > pnf_p7->_public.segment_size)
{
int msg_body_len = len - NFAPI_P7_HEADER_LENGTH ;
int seg_body_len = pnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH ;
int segment_count = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0);
int segment = 0;
int offset = NFAPI_P7_HEADER_LENGTH;
uint8_t buffer[pnf_p7->_public.segment_size];
for(segment = 0; segment < segment_count; ++segment)
{
uint8_t last = 0;
uint16_t size = pnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH;
if(segment + 1 == segment_count)
{
last = 1;
size = (msg_body_len) - (seg_body_len * segment);
}
uint16_t segment_size = size + NFAPI_P7_HEADER_LENGTH;
// Update the header with the m and segement
memcpy(&buffer[0], pnf_p7->tx_message_buffer, NFAPI_P7_HEADER_LENGTH);
// set the segment length
buffer[4] = (segment_size & 0xFF00) >> 8;
buffer[5] = (segment_size & 0xFF);
// set the m & segment number
buffer[6] = ((!last) << 7) + segment;
memcpy(&buffer[NFAPI_P7_HEADER_LENGTH], pnf_p7->tx_message_buffer + offset, size);
offset += size;
if(pnf_p7->_public.checksum_enabled)
{
nfapi_p7_update_checksum(buffer, segment_size);
}
pnf_p7_send_message(pnf_p7, &buffer[0], segment_size);
}
}
else
{
if(pnf_p7->_public.checksum_enabled)
{
nfapi_p7_update_checksum(pnf_p7->tx_message_buffer, len);
}
// simple case that the message fits in a single segment
pnf_p7_send_message(pnf_p7, pnf_p7->tx_message_buffer, len);
}
pnf_p7->sequence_number++;
if(pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
return -1;
}
return 0;
}
void pnf_pack_and_send_timing_info(pnf_p7_t* pnf_p7)
{
nfapi_timing_info_t timing_info;
@@ -652,7 +767,6 @@ void pnf_pack_and_send_timing_info(pnf_p7_t* pnf_p7)
timing_info.header.message_id = NFAPI_TIMING_INFO;
timing_info.header.phy_id = pnf_p7->_public.phy_id;
#if 0
timing_info.last_sfn_sf = pnf_p7->sfn_sf;
timing_info.time_since_last_timing_info = pnf_p7->timing_info_ms_counter;
@@ -670,7 +784,20 @@ void pnf_pack_and_send_timing_info(pnf_p7_t* pnf_p7)
timing_info.tx_request_earliest_arrival = 0;
timing_info.ul_config_earliest_arrival = 0;
timing_info.hi_dci0_earliest_arrival = 0;
#endif
pnf_p7_pack_and_send_p7_message(pnf_p7, &(timing_info.header), sizeof(timing_info));
pnf_p7->timing_info_ms_counter = 0;
}
void pnf_nr_pack_and_send_timing_info(pnf_p7_t* pnf_p7)
{
nfapi_nr_timing_info_t timing_info;
memset(&timing_info, 0, sizeof(timing_info));
timing_info.header.message_id = NFAPI_TIMING_INFO;
timing_info.header.phy_id = pnf_p7->_public.phy_id;
timing_info.last_sfn = pnf_p7->sfn;
timing_info.last_slot = pnf_p7->slot;
@@ -692,7 +819,7 @@ void pnf_pack_and_send_timing_info(pnf_p7_t* pnf_p7)
timing_info.ul_dci_earliest_arrival = 0;
pnf_p7_pack_and_send_p7_message(pnf_p7, &(timing_info.header), sizeof(timing_info));
pnf_nr_p7_pack_and_send_p7_message(pnf_p7, &(timing_info.header), sizeof(timing_info));
pnf_p7->timing_info_ms_counter = 0;
}
@@ -1074,13 +1201,13 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
// send the periodic timing info if configured
if(pnf_p7->_public.timing_info_mode_periodic && (pnf_p7->timing_info_period_counter++) == pnf_p7->_public.timing_info_period)
{
pnf_pack_and_send_timing_info(pnf_p7);
pnf_nr_pack_and_send_timing_info(pnf_p7);
pnf_p7->timing_info_period_counter = 0;
}
else if(pnf_p7->_public.timing_info_mode_aperiodic && pnf_p7->timing_info_aperiodic_send)
{
pnf_pack_and_send_timing_info(pnf_p7);
pnf_nr_pack_and_send_timing_info(pnf_p7);
pnf_p7->timing_info_aperiodic_send = 0;
}
@@ -1552,7 +1679,7 @@ void pnf_handle_dl_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7)
return;
}
int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_dl_tti_request_t), &(pnf_p7->_public.codec_config));
int unpack_result = nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_dl_tti_request_t), &(pnf_p7->_public.codec_config));
if(unpack_result == 0)
{
@@ -1734,7 +1861,7 @@ void pnf_handle_ul_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7)
return;
}
int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_ul_tti_request_t), &(pnf_p7->_public.codec_config));
int unpack_result = nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_ul_tti_request_t), &(pnf_p7->_public.codec_config));
if(unpack_result == 0)
{
@@ -1880,7 +2007,7 @@ void pnf_handle_ul_dci_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7)
return;
}
int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_ul_dci_request_t), &pnf_p7->_public.codec_config);
int unpack_result = nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_ul_dci_request_t), &pnf_p7->_public.codec_config);
if(unpack_result == 0)
{
@@ -2020,7 +2147,7 @@ void pnf_handle_tx_data_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7
return;
}
int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_tx_data_request_t), &pnf_p7->_public.codec_config);
int unpack_result = nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_tx_data_request_t), &pnf_p7->_public.codec_config);
if(unpack_result == 0)
{
if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0)
@@ -2326,8 +2453,7 @@ void pnf_handle_ue_release_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf
deallocate_nfapi_ue_release_request(req, pnf_p7);
}
}
/*
#if 0
uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr)
{
uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr);
@@ -2350,9 +2476,8 @@ uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_t
return t2;
}
#endif
*/
uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn,uint16_t slot, uint32_t slot_start_time_hr)
uint32_t calculate_nr_t2(uint32_t now_time_hr, uint16_t sfn,uint16_t slot, uint32_t slot_start_time_hr)
{
uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr);
uint32_t t2 = (NFAPI_SFNSLOT2DEC(sfn, slot) * 500) + slot_time_us;
@@ -2375,7 +2500,18 @@ uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn,uint16_t slot, uint32_t
return t2;
}
uint32_t calculate_t3(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
uint32_t calculate_t3(uint16_t sfn_sf, uint32_t sf_start_time_hr)
{
uint32_t now_time_hr = pnf_get_current_time_hr();
uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr);
uint32_t t3 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us;
return t3;
}
uint32_t calculate_nr_t3(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
{
uint32_t now_time_hr = pnf_get_current_time_hr();
@@ -2387,9 +2523,7 @@ uint32_t calculate_t3(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
}
void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
{
//printf("Received DL node sync");
{
nfapi_dl_node_sync_t dl_node_sync;
//NFAPI_TRACE(NFAPI_TRACE_INFO, "DL_NODE_SYNC Received\n");
@@ -2414,11 +2548,11 @@ void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, u
}
if (dl_node_sync.delta_sfn_slot != 0)
if (dl_node_sync.delta_sfn_sf != 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Will shift Slot timing by %d on next slot\n", dl_node_sync.delta_sfn_slot);
NFAPI_TRACE(NFAPI_TRACE_INFO, "Will shift SF timing by %d on next subframe\n", dl_node_sync.delta_sfn_sf);
pnf_p7->slot_shift = dl_node_sync.delta_sfn_slot;
pnf_p7->sfn_sf_shift = dl_node_sync.delta_sfn_sf;
}
nfapi_ul_node_sync_t ul_node_sync;
@@ -2426,8 +2560,61 @@ void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, u
ul_node_sync.header.message_id = NFAPI_UL_NODE_SYNC;
ul_node_sync.header.phy_id = dl_node_sync.header.phy_id;
ul_node_sync.t1 = dl_node_sync.t1;
ul_node_sync.t2 = calculate_t2(rx_hr_time, pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr);
ul_node_sync.t3 = calculate_t3(pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr);
ul_node_sync.t2 = calculate_t2(rx_hr_time, pnf_p7->sfn_sf, pnf_p7->sf_start_time_hr);
ul_node_sync.t3 = calculate_t3(pnf_p7->sfn_sf, pnf_p7->sf_start_time_hr);
if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
return;
}
pnf_p7_pack_and_send_p7_message(pnf_p7, &(ul_node_sync.header), sizeof(ul_node_sync));
}
void pnf_nr_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
{
//printf("Received DL node sync");
nfapi_nr_dl_node_sync_t dl_node_sync;
//NFAPI_TRACE(NFAPI_TRACE_INFO, "DL_NODE_SYNC Received\n");
if (pRecvMsg == NULL || pnf_p7 == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
return;
}
// unpack the message
if (nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &dl_node_sync, sizeof(dl_node_sync), &pnf_p7->_public.codec_config) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
return;
}
if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n");
return;
}
if (dl_node_sync.delta_sfn_slot != 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Will shift Slot timing by %d on next slot\n", dl_node_sync.delta_sfn_slot);
pnf_p7->slot_shift = dl_node_sync.delta_sfn_slot;
}
nfapi_nr_ul_node_sync_t ul_node_sync;
memset(&ul_node_sync, 0, sizeof(ul_node_sync));
ul_node_sync.header.message_id = NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC;
ul_node_sync.header.phy_id = dl_node_sync.header.phy_id;
ul_node_sync.t1 = dl_node_sync.t1;
ul_node_sync.t2 = calculate_nr_t2(rx_hr_time, pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr);
ul_node_sync.t3 = calculate_nr_t3(pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr);
// ul_node_sync.t2 = ul_node_sync.t1 + 10;
// ul_node_sync.t3 = ul_node_sync.t2 + 10; // hardcoded - gokul
@@ -2437,7 +2624,7 @@ void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, u
return;
}
pnf_p7_pack_and_send_p7_message(pnf_p7, &(ul_node_sync.header), sizeof(ul_node_sync));
pnf_nr_p7_pack_and_send_p7_message(pnf_p7, &(ul_node_sync.header), sizeof(ul_node_sync));
//printf("\nSSent UL Node Sync sfn:%d,slot:%d\n",pnf_p7->sfn,pnf_p7->slot);
}
@@ -2471,6 +2658,76 @@ void pnf_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7,
case NFAPI_DL_NODE_SYNC:
pnf_handle_dl_node_sync(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time);
break;
case NFAPI_DL_CONFIG_REQUEST:
pnf_handle_dl_config_request(pRecvMsg, recvMsgLen, pnf_p7);
break;
case NFAPI_UL_CONFIG_REQUEST:
pnf_handle_ul_config_request(pRecvMsg, recvMsgLen, pnf_p7);
break;
case NFAPI_HI_DCI0_REQUEST:
pnf_handle_hi_dci0_request(pRecvMsg, recvMsgLen, pnf_p7);
break;
case NFAPI_TX_REQUEST:
pnf_handle_tx_request(pRecvMsg, recvMsgLen, pnf_p7);
break;
case NFAPI_LBT_DL_CONFIG_REQUEST:
pnf_handle_lbt_dl_config_request(pRecvMsg, recvMsgLen, pnf_p7);
break;
case NFAPI_UE_RELEASE_REQUEST:
pnf_handle_ue_release_request(pRecvMsg, recvMsgLen, pnf_p7);
break;
default:
{
if(header.message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
header.message_id <= NFAPI_VENDOR_EXT_MSG_MAX)
{
pnf_handle_p7_vendor_extension(pRecvMsg, recvMsgLen, pnf_p7, header.message_id);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P7 Unknown message ID %d\n", __FUNCTION__, header.message_id);
}
}
break;
}
}
void pnf_nr_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
{
nfapi_p7_message_header_t header;
// validate the input params
if(pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__);
return;
}
// unpack the message header
if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &header, sizeof(header), &pnf_p7->_public.codec_config) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
return;
}
// ensure the message is sensible
if (recvMsgLen < 8 || pRecvMsg == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen);
return;
}
switch (header.message_id)
{
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
pnf_nr_handle_dl_node_sync(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time);
break;
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
//printf("\nEntering pnf_handle_dl_tti_request sfn=%d,slot=%d \n",pnf_p7->sfn,pnf_p7->slot);
@@ -2631,6 +2888,114 @@ void pnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, ui
pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7, &(pnf_p7->reassembly_queue), rx_hr_time, 1000);
}
void pnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time)
{
nfapi_p7_message_header_t messageHeader;
// validate the input params
if(pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "pnf_handle_p7_message: invalid input params (%d %d %d)\n", pRecvMsg, recvMsgLen, pnf_p7);
return;
}
// unpack the message header
if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p7_message_header_t), &pnf_p7->_public.codec_config) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
return;
}
uint8_t m = NFAPI_P7_GET_MORE(messageHeader.m_segment_sequence);
uint8_t sequence_num = NFAPI_P7_GET_SEQUENCE(messageHeader.m_segment_sequence);
uint8_t segment_num = NFAPI_P7_GET_SEGMENT(messageHeader.m_segment_sequence);
if(pnf_p7->_public.checksum_enabled)
{
uint32_t checksum = nfapi_p7_calculate_checksum(pRecvMsg, recvMsgLen);
if(checksum != messageHeader.checksum)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Checksum verification failed %d %d\n", checksum, messageHeader.checksum);
return;
}
}
if(m == 0 && segment_num == 0)
{
// we have a complete message
// ensure the message is sensible
if (recvMsgLen < 8 || pRecvMsg == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen);
return;
}
pnf_nr_dispatch_p7_message(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time);
}
else
{
pnf_p7_rx_message_t* rx_msg = pnf_p7_rx_reassembly_queue_add_segment(pnf_p7, &(pnf_p7->reassembly_queue), rx_hr_time, sequence_num, segment_num, m, pRecvMsg, recvMsgLen);
if(rx_msg->num_segments_received == rx_msg->num_segments_expected)
{
// send the buffer on
uint16_t i = 0;
uint16_t length = 0;
for(i = 0; i < rx_msg->num_segments_expected; ++i)
{
length += rx_msg->segments[i].length - (i > 0 ? NFAPI_P7_HEADER_LENGTH : 0);
}
if(pnf_p7->reassemby_buffer_size < length)
{
pnf_p7_free(pnf_p7, pnf_p7->reassemby_buffer);
pnf_p7->reassemby_buffer = 0;
}
if(pnf_p7->reassemby_buffer == 0)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "Resizing PNF_P7 Reassembly buffer %d->%d\n", pnf_p7->reassemby_buffer_size, length);
pnf_p7->reassemby_buffer = (uint8_t*)pnf_p7_malloc(pnf_p7, length);
if(pnf_p7->reassemby_buffer == 0)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "Failed to allocate PNF_P7 reassemby buffer len:%d\n", length);
return;
}
memset(pnf_p7->reassemby_buffer, 0, length);
pnf_p7->reassemby_buffer_size = length;
}
uint16_t offset = 0;
for(i = 0; i < rx_msg->num_segments_expected; ++i)
{
if(i == 0)
{
memcpy(pnf_p7->reassemby_buffer, rx_msg->segments[i].buffer, rx_msg->segments[i].length);
offset += rx_msg->segments[i].length;
}
else
{
memcpy(pnf_p7->reassemby_buffer + offset, rx_msg->segments[i].buffer + NFAPI_P7_HEADER_LENGTH, rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH);
offset += rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH;
}
}
pnf_nr_dispatch_p7_message(pnf_p7->reassemby_buffer, length, pnf_p7, rx_msg->rx_hr_time);
// delete the structure
pnf_p7_rx_reassembly_queue_remove_msg(pnf_p7, &(pnf_p7->reassembly_queue), rx_msg);
}
}
pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7, &(pnf_p7->reassembly_queue), rx_hr_time, 1000);
}
void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time)
{
int recvfrom_result = 0;
@@ -2694,6 +3059,70 @@ void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time)
while(recvfrom_result > 0);
}
void pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time)
{
int recvfrom_result = 0;
struct sockaddr_in remote_addr;
socklen_t remote_addr_size = sizeof(remote_addr);
remote_addr.sin_family = 2; // Gokul - hardcoded
do
{
// peek the header
uint8_t header_buffer[NFAPI_P7_HEADER_LENGTH];
recvfrom_result = recvfrom(pnf_p7->p7_sock, header_buffer, NFAPI_P7_HEADER_LENGTH, MSG_DONTWAIT | MSG_PEEK, (struct sockaddr*)&remote_addr, &remote_addr_size);
if(recvfrom_result > 0)
{
// get the segment size
nfapi_p7_message_header_t header;
nfapi_p7_message_header_unpack(header_buffer, NFAPI_P7_HEADER_LENGTH, &header, 34, 0);
// resize the buffer if we have a large segment
if(header.message_length > pnf_p7->rx_message_buffer_size)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length);
pnf_p7->rx_message_buffer = realloc(pnf_p7->rx_message_buffer, header.message_length);
pnf_p7->rx_message_buffer_size = header.message_length;
}
// read the segment
recvfrom_result = recvfrom(pnf_p7->p7_sock, pnf_p7->rx_message_buffer, header.message_length, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size);
now_hr_time = pnf_get_current_time_hr(); //DJP - moved to here - get closer timestamp???
if(recvfrom_result > 0)
{
pnf_nr_handle_p7_message(pnf_p7->rx_message_buffer, recvfrom_result, pnf_p7, now_hr_time);
//printf("\npnf_handle_p7_message sfn=%d,slot=%d\n",pnf_p7->sfn,pnf_p7->slot);
}
}
else if(recvfrom_result == 0)
{
// recv zero length message
recvfrom_result = recvfrom(pnf_p7->p7_sock, header_buffer, 0, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size);
}
if(recvfrom_result == -1)
{
if(errno == EAGAIN || errno == EWOULDBLOCK)
{
// return to the select
//NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom would block :%d\n", __FUNCTION__, errno);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom failed errno:%d\n", __FUNCTION__, errno);
}
}
// need to update the time as we would only use the value from the
// select
}
while(recvfrom_result > 0);
}
int pnf_p7_message_pump(pnf_p7_t* pnf_p7)
{
@@ -2834,3 +3263,144 @@ int pnf_p7_message_pump(pnf_p7_t* pnf_p7)
return 0;
}
int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
{
// initialize the mutex lock
if(pthread_mutex_init(&(pnf_p7->mutex), NULL) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P7 mutex init: %d\n", errno);
return -1;
}
if(pthread_mutex_init(&(pnf_p7->pack_mutex), NULL) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P7 mutex init: %d\n", errno);
return -1;
}
// create the pnf p7 socket
if ((pnf_p7->p7_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P7 socket errno: %d\n", errno);
return -1;
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 socket created (%d)...\n", pnf_p7->p7_sock);
// configure the UDP socket options
int reuseaddr_enable = 1;
if (setsockopt(pnf_p7->p7_sock, SOL_SOCKET, SO_REUSEADDR, &reuseaddr_enable, sizeof(int)) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF P7 setsockopt (SOL_SOCKET, SO_REUSEADDR) failed errno: %d\n", errno);
return -1;
}
/*
int reuseport_enable = 1;
if (setsockopt(pnf_p7->p7_sock, SOL_SOCKET, SO_REUSEPORT, &reuseport_enable, sizeof(int)) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF P7 setsockopt (SOL_SOCKET, SO_REUSEPORT) failed errno: %d\n", errno);
return -1;
}
*/
int iptos_value = FAPI2_IP_DSCP << 2;
if (setsockopt(pnf_p7->p7_sock, IPPROTO_IP, IP_TOS, &iptos_value, sizeof(iptos_value)) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF P7 setsockopt (IPPROTO_IP, IP_TOS) failed errno: %d\n", errno);
return -1;
}
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
//addr.sin_port = htons(pnf_p7->_public.local_p7_port); Gokul
addr.sin_port = pnf_p7->_public.local_p7_port;
if(pnf_p7->_public.local_p7_addr == 0)
{
addr.sin_addr.s_addr = INADDR_ANY;
}
else
{
//addr.sin_addr.s_addr = inet_addr(pnf_p7->_public.local_p7_addr);
if(inet_aton(pnf_p7->_public.local_p7_addr, &addr.sin_addr) == -1)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "inet_aton failed\n");
}
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 binding %d too %s:%d\n", pnf_p7->p7_sock, inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
if (bind(pnf_p7->p7_sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF_P7 bind error fd:%d errno: %d\n", pnf_p7->p7_sock, errno);
return -1;
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 bind succeeded...\n");
while(pnf_p7->terminate == 0)
{
fd_set rfds;
int selectRetval = 0;
// select on a timeout and then get the message
FD_ZERO(&rfds);
FD_SET(pnf_p7->p7_sock, &rfds);
struct timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
selectRetval = select(pnf_p7->p7_sock+1, &rfds, NULL, NULL, &timeout);
uint32_t now_hr_time = pnf_get_current_time_hr();
if(selectRetval == 0)
{
// timeout
continue;
}
else if (selectRetval == -1 && (errno == EINTR))
{
// interrupted by signal
NFAPI_TRACE(NFAPI_TRACE_WARN, "PNF P7 Signal Interrupt %d\n", errno);
continue;
}
else if (selectRetval == -1)
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "PNF P7 select() failed\n");
sleep(1);
continue;
}
if(FD_ISSET(pnf_p7->p7_sock, &rfds))
{
pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time);
}
}
NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF_P7 Terminating..\n");
// close the connection and socket
if (close(pnf_p7->p7_sock) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "close failed errno: %d\n", errno);
}
if(pthread_mutex_destroy(&(pnf_p7->pack_mutex)) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "mutex destroy failed errno: %d\n", errno);
}
if(pthread_mutex_destroy(&(pnf_p7->mutex)) != 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "mutex destroy failed errno: %d\n", errno);
}
return 0;
}
@@ -76,6 +76,26 @@ int nfapi_pnf_p7_start(nfapi_pnf_p7_config_t* config)
return 0;
}
int nfapi_nr_pnf_p7_start(nfapi_pnf_p7_config_t* config)
{
// Verify that config is not null
if(config == 0)
return -1;
// Make sure to set the defined trace function before using NFAPI_TRACE
if(config->trace)
nfapi_trace_g = config->trace;
pnf_p7_t* _this = (pnf_p7_t*)(config);
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
pnf_nr_p7_message_pump(_this);
return 0;
}
int nfapi_pnf_p7_stop(nfapi_pnf_p7_config_t* config)
{
// Verify that config is not null
+2
View File
@@ -40,6 +40,8 @@ int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_mes
int vnf_pack_and_send_p4_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len);
int vnf_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* pnf);
int vnf_nr_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* pnf);
void nfapi_vnf_phy_info_list_add(nfapi_vnf_config_t* config, nfapi_vnf_phy_info_t* info);
nfapi_vnf_phy_info_t* nfapi_vnf_phy_info_list_find(nfapi_vnf_config_t* config, uint16_t phy_id);
+8 -5
View File
@@ -74,9 +74,9 @@ typedef struct nfapi_vnf_p7_connection_info {
uint16_t min_sync_cycle_count;
uint32_t latency[8];
uint32_t average_latency;
//int32_t sf_offset_filtered;
//int32_t sf_offset_trend;
//int32_t sf_offset;
int32_t sf_offset_filtered;
int32_t sf_offset_trend;
int32_t sf_offset;
int32_t slot_offset;
int32_t slot_offset_trend;
int32_t slot_offset_filtered;
@@ -87,7 +87,7 @@ typedef struct nfapi_vnf_p7_connection_info {
uint32_t previous_t1;
uint32_t previous_t2;
//int32_t previous_sf_offset_filtered;
int32_t previous_sf_offset_filtered;
int32_t previous_slot_offset_filtered;
int sfn_sf;
int sfn;
@@ -115,7 +115,7 @@ typedef struct {
uint8_t terminate;
nfapi_vnf_p7_connection_info_t* p7_connections;
int socket;
// uint32_t sf_start_time_hr;
uint32_t sf_start_time_hr;
uint32_t slot_start_time_hr;
uint8_t* rx_message_buffer; // would this be better put in the p7 conenction info?
uint16_t rx_message_buffer_size;
@@ -126,9 +126,12 @@ uint32_t vnf_get_current_time_hr(void);
uint16_t increment_sfn_sf(uint16_t sfn_sf);
int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info);
int vnf_nr_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info);
int send_mac_subframe_indications(vnf_p7_t* config);
int send_mac_slot_indications(vnf_p7_t* config);
int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7 );
int vnf_nr_p7_read_dispatch_message(vnf_p7_t* vnf_p7 );
void vnf_p7_connection_info_list_add(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* node);
nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_find(vnf_p7_t* vnf_p7, uint16_t phy_id);
@@ -185,7 +185,8 @@ typedef struct nfapi_vnf_config
* use the codec_config.deallocate function to release it at a future point
*/
int (*pnf_config_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* resp);
int (*pnf_nr_config_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_config_response_t* resp);
/*! A callback for the PNF_START.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
@@ -206,7 +207,8 @@ typedef struct nfapi_vnf_config
* use the codec_config.deallocate function to release it at a future point
*/
int (*pnf_start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* resp);
int (*pnf_nr_start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_start_response_t* resp);
/*! A callback for the PNF_STOP.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
@@ -252,6 +254,7 @@ typedef struct nfapi_vnf_config
* use the codec_config.deallocate function to release it at a future point
*/
int (*param_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_param_response_scf_t* resp);
int (*nr_param_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_param_response_scf_t* resp);
/*! A callback for the CONFIG.response
* \param config A pointer to the vnf configuration
@@ -269,9 +272,9 @@ typedef struct nfapi_vnf_config
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
//TODO: Add nfapi_nr_config_response_scf_t struct
int (*config_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_config_response_scf_t* resp);
int (*nr_config_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_config_response_scf_t* resp);
int (*config_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* resp);
/*! A callback for the START.resp
* \param config A pointer to the vnf configuration
* \param p5_idx The p5 index used to indicate a particular pnf p5 connection
@@ -288,7 +291,8 @@ typedef struct nfapi_vnf_config
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
int (*start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_start_response_scf_t* resp);
int (*start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp);
int (*nr_start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_start_response_scf_t* resp);
/*! A callback for the STOP.resp
* \param config A pointer to the vnf configuration
@@ -506,7 +510,7 @@ int nfapi_vnf_allocate_phy(nfapi_vnf_config_t* config, int p5_idx, uint16_t* phy
* \return 0 means success, -1 failure
*/
int nfapi_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_request_t* req);
//int nfapi_nr_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_param_request_t* req);
int nfapi_nr_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_param_request_t* req);
/*! Send the PNF_CONFIG.request
* \param config A pointer to a vnf config
@@ -515,6 +519,7 @@ int nfapi_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_pa
* \return 0 means success, -1 failure
*/
int nfapi_vnf_pnf_config_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_pnf_config_request_t* req);
int nfapi_nr_vnf_pnf_config_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_nr_pnf_config_request_t* req);
/*! Send the PNF_START.request
* \param config A pointer to a vnf config
@@ -523,6 +528,7 @@ int nfapi_vnf_pnf_config_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_pnf_co
* \return 0 means success, -1 failure
*/
int nfapi_vnf_pnf_start_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_pnf_start_request_t* req);
int nfapi_nr_vnf_pnf_start_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_nr_pnf_start_request_t* req);
/*! Send the PNF_STOP.request
* \param config A pointer to a vnf config
@@ -539,6 +545,7 @@ int nfapi_vnf_pnf_stop_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_pnf_stop
* \return 0 means success, -1 failure
*/
int nfapi_vnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_request_t* req);
int nfapi_nr_vnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_param_request_scf_t* req);
/*! Send the CONFIG.request
* \param config A pointer to a vnf config
@@ -546,7 +553,8 @@ int nfapi_vnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_requ
* \param req A pointer to a CONFIG.request message structure
* \return 0 means success, -1 failure
*/
int nfapi_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_config_request_scf_t* req);
int nfapi_nr_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_config_request_scf_t* req);
int nfapi_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_request_t* req);
/*! Send the START.request
* \param config A pointer to a vnf config
@@ -554,7 +562,8 @@ int nfapi_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_config
* \param req A pointer to a START.request message structure
* \return 0 means success, -1 failure
*/
int nfapi_vnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_start_request_scf_t* req);
int nfapi_vnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_request_t* req);
int nfapi_nr_vnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_start_request_scf_t* req);
/*! Send the STOP.request
* \param config A pointer to a vnf config
@@ -893,6 +902,8 @@ void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config);
*/
int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config);
int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config);
/*! Stop the VNF P7 library.
* \param config A pointer to an vnf p7 configuration structure
+349 -20
View File
@@ -102,7 +102,7 @@ nfapi_vnf_pnf_info_t* nfapi_vnf_pnf_list_find(nfapi_vnf_config_t* config, int p5
return 0;
}
/*
void vnf_nr_handle_pnf_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
@@ -135,7 +135,7 @@ void vnf_nr_handle_pnf_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_
config->codec_config.deallocate(msg.vendor_extension);
}
}
*/
void vnf_handle_pnf_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
@@ -169,6 +169,40 @@ void vnf_handle_pnf_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_con
}
}
void vnf_nr_handle_pnf_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
if (pRecvMsg == NULL || config == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PNF_CONFIG_RESPONSE\n");
nfapi_nr_pnf_config_response_t msg;
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0)
{
// Invoke the call back
if(config->pnf_nr_config_resp)
{
(config->pnf_nr_config_resp)(config, p5_idx, &msg);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
// make sure to release any dyanmic part of the message
if(msg.vendor_extension)
config->codec_config.deallocate(msg.vendor_extension);
}
}
void vnf_handle_pnf_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
@@ -202,6 +236,38 @@ void vnf_handle_pnf_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_co
}
}
void vnf_nr_handle_pnf_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
if (pRecvMsg == NULL || config == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PNF_START_RESPONSE\n");
nfapi_nr_pnf_start_response_t msg;
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0)
{
if(config->pnf_nr_start_resp)
{
(config->pnf_nr_start_resp)(config, p5_idx, &msg);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
// make sure to release any dyanmic part of the message
if(msg.vendor_extension)
config->codec_config.deallocate(msg.vendor_extension);
}
}
void vnf_handle_pnf_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
@@ -279,7 +345,7 @@ void vnf_handle_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PARAM_RESPONSE\n");
nfapi_nr_param_response_scf_t msg;
nfapi_param_response_t msg;
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0)
@@ -333,6 +399,110 @@ void vnf_handle_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_
}
}
void vnf_nr_handle_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
if (pRecvMsg == NULL || config == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PARAM_RESPONSE\n");
nfapi_nr_param_response_scf_t msg;
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0)
{
if (msg.error_code == NFAPI_MSG_OK)
{
nfapi_vnf_phy_info_t* phy_info = nfapi_vnf_phy_info_list_find(config, msg.header.phy_id);
if(msg.nfapi_config.p7_pnf_address_ipv4.tl.tag)
{
struct sockaddr_in sockAddr;
(void)memcpy(&sockAddr.sin_addr.s_addr, msg.nfapi_config.p7_pnf_address_ipv4.address, NFAPI_IPV4_ADDRESS_LENGTH);
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 IPv4 address: %s\n", inet_ntoa(sockAddr.sin_addr));
// store address
phy_info->p7_pnf_address.sin_addr = sockAddr.sin_addr;
}
if(msg.nfapi_config.p7_pnf_address_ipv6.tl.tag)
{
struct sockaddr_in6 sockAddr6;
char addr6[64];
(void)memcpy(&sockAddr6.sin6_addr, msg.nfapi_config.p7_pnf_address_ipv6.address, NFAPI_IPV6_ADDRESS_LENGTH);
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 IPv6 address: %s\n", inet_ntop(AF_INET6, &sockAddr6.sin6_addr, addr6, sizeof(addr6)));
}
if (msg.nfapi_config.p7_pnf_port.tl.tag)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 Port: %d\n", msg.nfapi_config.p7_pnf_port.value);
// store port
phy_info->p7_pnf_address.sin_port = htons(msg.nfapi_config.p7_pnf_port.value);
}
}
if(config->nr_param_resp)
{
(config->nr_param_resp)(config, p5_idx, &msg);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
// make sure to release any dyanmic part of the message
if(msg.vendor_extension)
config->codec_config.deallocate(msg.vendor_extension);
}
}
void vnf_nr_handle_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
if (pRecvMsg == NULL || config == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received CONFIG_RESPONSE\n");
nfapi_nr_config_response_scf_t msg;
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >=0 )
{
// check the error code:
if (msg.error_code == NFAPI_MSG_OK){
if(config->nr_config_resp)
{
(config->nr_config_resp)(config, p5_idx, &msg);
}
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
// make sure to release any dyanmic part of the message
if(msg.vendor_extension)
config->codec_config.deallocate(msg.vendor_extension);
}
}
void vnf_handle_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
@@ -381,15 +551,47 @@ void vnf_handle_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received START_RESPONSE\n");
nfapi_nr_start_response_scf_t msg;
nfapi_start_response_t msg;
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0)
{
if(config->start_resp)
{
(config->start_resp)(config, p5_idx, &msg);
}
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
}
// make sure to release any dyanmic part of the message
if(msg.vendor_extension)
config->codec_config.deallocate(msg.vendor_extension);
}
}
void vnf_nr_handle_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
if (pRecvMsg == NULL || config == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received START_RESPONSE\n");
nfapi_nr_start_response_scf_t msg;
// unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0)
{ // check the error code
if (msg.error_code == NFAPI_MSG_OK){
if(config->start_resp)
if(config->nr_start_resp)
{
(config->start_resp)(config, p5_idx, &msg);
(config->nr_start_resp)(config, p5_idx, &msg);
}
}
}
@@ -853,7 +1055,6 @@ void vnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, nfapi_vnf_confi
}
}
#if 0
void vnf_nr_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfapi_vnf_config_t* config)
{
nfapi_p4_p5_message_header_t messageHeader;
@@ -874,32 +1075,32 @@ void vnf_nr_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfa
switch (messageHeader.message_id)
{
case NFAPI_PNF_PARAM_RESPONSE:
case NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_RESPONSE:
vnf_nr_handle_pnf_param_response(pRecvMsg, recvMsgLen, config, p5_idx);
break;
case NFAPI_PNF_CONFIG_RESPONSE:
vnf_handle_pnf_config_response(pRecvMsg, recvMsgLen, config, p5_idx);
case NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_RESPONSE:
vnf_nr_handle_pnf_config_response(pRecvMsg, recvMsgLen, config, p5_idx);
break;
case NFAPI_PNF_START_RESPONSE:
vnf_handle_pnf_start_response(pRecvMsg, recvMsgLen, config, p5_idx);
case NFAPI_NR_PHY_MSG_TYPE_PNF_START_RESPONSE:
vnf_nr_handle_pnf_start_response(pRecvMsg, recvMsgLen, config, p5_idx);
break;
case NFAPI_PNF_STOP_RESPONSE:
vnf_handle_pnf_stop_response(pRecvMsg, recvMsgLen, config, p5_idx);
break;
case NFAPI_PARAM_RESPONSE:
vnf_handle_param_response(pRecvMsg, recvMsgLen, config, p5_idx);
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE:
vnf_nr_handle_param_response(pRecvMsg, recvMsgLen, config, p5_idx);
break;
case NFAPI_CONFIG_RESPONSE:
vnf_handle_config_response(pRecvMsg, recvMsgLen, config, p5_idx);
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE:
vnf_nr_handle_config_response(pRecvMsg, recvMsgLen, config, p5_idx);
break;
case NFAPI_START_RESPONSE:
vnf_handle_start_response(pRecvMsg, recvMsgLen, config, p5_idx);
vnf_nr_handle_start_response(pRecvMsg, recvMsgLen, config, p5_idx);
break;
case NFAPI_STOP_RESPONSE:
@@ -969,7 +1170,7 @@ void vnf_nr_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfa
break;
}
}
#endif
void vnf_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfapi_vnf_config_t* config)
{
nfapi_p4_p5_message_header_t messageHeader;
@@ -1086,6 +1287,136 @@ void vnf_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfapi_
}
}
int vnf_nr_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* pnf)
{
if(1)
{
int socket_connected = 1;
// 1. Peek the message header
// 2. If the message is larger than the stack buffer then create a dynamic buffer
// 3. Read the buffer
// 4. Handle the p5 message
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
uint8_t header_buffer[header_buffer_size];
uint32_t stack_buffer_size = 32; //should it be the size of then sctp_notificatoin structure
uint8_t stack_buffer[stack_buffer_size];
uint8_t* dynamic_buffer = 0;
uint8_t* read_buffer = &stack_buffer[0];
uint32_t message_size = 0;
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
struct sctp_sndrcvinfo sndrcvinfo;
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
{
int flags = MSG_PEEK;
message_size = sctp_recvmsg(pnf->p5_sock, header_buffer, header_buffer_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
if(message_size == -1)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to peek sctp message size errno:%d\n", errno);
return 0;
}
nfapi_p4_p5_message_header_t header;
int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
if(unpack_result < 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to decode message header %d\n", unpack_result);
return 0;
}
message_size = header.message_length;
// now have the size of the mesage
}
if(message_size > stack_buffer_size)
{
dynamic_buffer = (uint8_t*)malloc(message_size);
if(dynamic_buffer == NULL)
{
// todo : add error mesage
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to allocate dynamic buffer for sctp_recvmsg size:%d\n", message_size);
return -1;
}
read_buffer = dynamic_buffer;
}
{
int flags = 0;
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
int recvmsg_result = sctp_recvmsg(pnf->p5_sock, read_buffer, message_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
if(recvmsg_result == -1)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Failed to read sctp message size errno:%d\n", errno);
}
else
{
if (flags & MSG_NOTIFICATION)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Notification received from %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
// todo - handle the events
}
else
{
/*
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received message fd:%d from %s:%u assoc:%d on stream %d, PPID %d, length %d, flags 0x%x\n",
pnf->p5_sock,
inet_ntoa(addr.sin_addr),
ntohs(addr.sin_port),
sndrcvinfo.sinfo_assoc_id,
sndrcvinfo.sinfo_stream,
ntohl(sndrcvinfo.sinfo_ppid),
message_size,
flags);
*/
// handle now if complete message in one or more segments
if ((flags & 0x80) == 0x80)
{
printf("\nVNF RECEIVES:\n");
for(int i=0; i<message_size; i++){
printf("%d", read_buffer[i]);
}
printf("\n");
vnf_nr_handle_p4_p5_message(read_buffer, message_size, pnf->p5_idx, config);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "sctp_recvmsg: unhandled mode with flags 0x%x\n", flags);
// assume socket disconnected
NFAPI_TRACE(NFAPI_TRACE_WARN, "Disconnected socket\n");
socket_connected = 0;
}
}
}
}
if(dynamic_buffer)
{
free(dynamic_buffer);
}
return socket_connected;
}
}
int vnf_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* pnf)
{
if(1)
@@ -1243,7 +1574,6 @@ static int vnf_send_p5_msg(nfapi_vnf_pnf_info_t* pnf, const void *msg, int len,
return 0;
}
/*
int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len)
{
nfapi_vnf_pnf_info_t* pnf = nfapi_vnf_pnf_list_find(&(vnf->_public), p5_idx);
@@ -1266,7 +1596,6 @@ int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_mes
return -1;
}
}
*/
int vnf_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len)
+90 -14
View File
@@ -62,7 +62,7 @@ void nfapi_vnf_config_destory(nfapi_vnf_config_t* config)
{
free(config);
}
#if 0
int nfapi_nr_vnf_start(nfapi_vnf_config_t* config)
{
// Verify that config is not null
@@ -390,7 +390,7 @@ int nfapi_nr_vnf_start(nfapi_vnf_config_t* config)
{
if(FD_ISSET(pnf->p5_sock, &read_fd_set))
{
if(vnf_read_dispatch_message(config, pnf) == 0)
if(vnf_nr_read_dispatch_message(config, pnf) == 0)
{
if(config->pnf_disconnect_indication != 0)
{
@@ -474,7 +474,7 @@ int nfapi_nr_vnf_start(nfapi_vnf_config_t* config)
return 0;
}
#endif
int nfapi_vnf_start(nfapi_vnf_config_t* config)
{
// Verify that config is not null
@@ -898,15 +898,15 @@ int nfapi_vnf_stop(nfapi_vnf_config_t* config)
return 0;
}
// int nfapi_nr_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_param_request_t* req)
// {
// if(config == 0 || req == 0)
// return -1;
int nfapi_nr_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_param_request_t* req)
{
if(config == 0 || req == 0)
return -1;
// vnf_t* _this = (vnf_t*)(config);
vnf_t* _this = (vnf_t*)(config);
// return vnf_nr_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_pnf_param_request_t));
// }
return vnf_nr_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_pnf_param_request_t));
}
int nfapi_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_request_t* req)
{
@@ -918,6 +918,17 @@ int nfapi_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_pa
return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_pnf_param_request_t));
}
int nfapi_nr_vnf_pnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_config_request_t* req)
{
if(config == 0 || req == 0)
return -1;
vnf_t* _this = (vnf_t*)(config);
return vnf_nr_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_pnf_config_request_t));
}
int nfapi_vnf_pnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_request_t* req)
{
if(config == 0 || req == 0)
@@ -938,6 +949,16 @@ int nfapi_vnf_pnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_st
return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_pnf_start_request_t));
}
int nfapi_nr_vnf_pnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_pnf_start_request_t* req)
{
if(config == 0 || req == 0)
return -1;
vnf_t* _this = (vnf_t*)(config);
return vnf_nr_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_pnf_start_request_t));
}
int nfapi_vnf_pnf_stop_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_stop_request_t* req)
{
if(config == 0 || req == 0)
@@ -948,6 +969,16 @@ int nfapi_vnf_pnf_stop_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_sto
return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_pnf_stop_request_t));
}
int nfapi_nr_vnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_param_request_scf_t* req)
{
if(config == 0 || req == 0)
return -1;
vnf_t* _this = (vnf_t*)(config);
return vnf_nr_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_param_request_scf_t));
}
int nfapi_vnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_request_t* req)
{
if(config == 0 || req == 0)
@@ -957,7 +988,8 @@ int nfapi_vnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_requ
return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_param_request_t));
}
int nfapi_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_config_request_scf_t* req)
int nfapi_nr_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_config_request_scf_t* req)
{
if(config == 0 || req == 0)
return -1;
@@ -985,17 +1017,61 @@ int nfapi_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_config
req->nfapi_config.timing_info_period.value = phy->timing_info_period;
req->num_tlv++;
return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_config_request_scf_t));
return vnf_nr_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_config_request_scf_t));
}
int nfapi_vnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_start_request_scf_t * req)
int nfapi_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_request_t* req)
{
if(config == 0 || req == 0)
return -1;
vnf_t* _this = (vnf_t*)(config);
return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_start_request_scf_t));
nfapi_vnf_phy_info_t* phy = nfapi_vnf_phy_info_list_find(config, req->header.phy_id);
if(phy == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "%s failed to find phy inforation phy_id:%d\n", __FUNCTION__, req->header.phy_id);
return -1;
}
// set the timing parameters
req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG;
req->nfapi_config.timing_window.value = phy->timing_window;
req->num_tlv++;
req->nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG;
req->nfapi_config.timing_info_mode.value = phy->timing_info_mode;
req->num_tlv++;
req->nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG;
req->nfapi_config.timing_info_period.value = phy->timing_info_period;
req->num_tlv++;
return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_config_request_t));
}
int nfapi_vnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_request_t * req)
{
if(config == 0 || req == 0)
return -1;
vnf_t* _this = (vnf_t*)(config);
return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_start_request_t));
}
int nfapi_nr_vnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_start_request_scf_t * req)
{
if(config == 0 || req == 0)
return -1;
vnf_t* _this = (vnf_t*)(config);
return vnf_nr_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_nr_start_request_scf_t));
}
int nfapi_vnf_stop_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_stop_request_t* req)
{
if(config == 0 || req == 0)
+848 -20
View File
@@ -299,7 +299,7 @@ struct timespec timespec_delta(struct timespec start, struct timespec end)
return temp;
}
/*static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr)
static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr)
{
if(now_hr < sf_start_hr)
{
@@ -319,7 +319,7 @@ struct timespec timespec_delta(struct timespec start, struct timespec end)
return now_us - sf_start_us;
}
}*/
}
static uint32_t get_slot_time(uint32_t now_hr, uint32_t slot_start_hr)
{
@@ -343,7 +343,7 @@ static uint32_t get_slot_time(uint32_t now_hr, uint32_t slot_start_hr)
}
}
/*uint32_t calculate_t1(uint16_t sfn_sf, uint32_t sf_start_time_hr)
uint32_t calculate_t1(uint16_t sfn_sf, uint32_t sf_start_time_hr)
{
uint32_t now_time_hr = vnf_get_current_time_hr();
@@ -352,9 +352,9 @@ static uint32_t get_slot_time(uint32_t now_hr, uint32_t slot_start_hr)
uint32_t t1 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us;
return t1;
}*/
}
uint32_t calculate_t1(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
uint32_t calculate_nr_t1(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
{
uint32_t now_time_hr = vnf_get_current_time_hr();
@@ -366,7 +366,7 @@ uint32_t calculate_t1(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
}
/*uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr)
uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr)
{
uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr);
@@ -374,9 +374,9 @@ uint32_t calculate_t1(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
return t4;
}*/
}
uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
uint32_t calculate_nr_t4(uint32_t now_time_hr, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
{
uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr);
@@ -465,6 +465,100 @@ int vnf_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info, u
return 0;
}
int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header)
{
nfapi_vnf_p7_connection_info_t* p7_connection = vnf_p7_connection_info_list_find(vnf_p7, header->phy_id);
if(p7_connection)
{
int send_result = 0;
uint8_t buffer[1024 * 32];
header->m_segment_sequence = NFAPI_P7_SET_MSS(0, 0, p7_connection->sequence_number);
int len = nfapi_nr_p7_message_pack(header, buffer, sizeof(buffer), &vnf_p7->_public.codec_config);
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() phy_id:%d nfapi_p7_message_pack()=len=%d vnf_p7->_public.segment_size:%u\n", __FUNCTION__, header->phy_id, len, vnf_p7->_public.segment_size);
if(len < 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() failed to pack p7 message phy_id:%d\n", __FUNCTION__, header->phy_id);
return -1;
}
if(len > vnf_p7->_public.segment_size)
{
// todo : consider replacing with the sendmmsg call
// todo : worry about blocking writes?
// segmenting the transmit
int msg_body_len = len - NFAPI_P7_HEADER_LENGTH ;
int seg_body_len = vnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH ;
int segment_count = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0);
int segment = 0;
int offset = NFAPI_P7_HEADER_LENGTH;
uint8_t tx_buffer[vnf_p7->_public.segment_size];
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() MORE THAN ONE SEGMENT phy_id:%d nfapi_p7_message_pack()=len=%d vnf_p7->_public.segment_size:%u\n", __FUNCTION__, header->phy_id, len, vnf_p7->_public.segment_size);
for(segment = 0; segment < segment_count; ++segment)
{
uint8_t last = 0;
uint16_t size = vnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH;
if(segment + 1 == segment_count)
{
last = 1;
size = (msg_body_len) - (seg_body_len * segment);
}
uint16_t segment_size = size + NFAPI_P7_HEADER_LENGTH;
// Update the header with the m and segement
memcpy(&tx_buffer[0], buffer, NFAPI_P7_HEADER_LENGTH);
// set the segment length
tx_buffer[4] = (segment_size & 0xFF00) >> 8;
tx_buffer[5] = (segment_size & 0xFF);
// set the m & segment number
tx_buffer[6] = ((!last) << 7) + segment;
memcpy(&tx_buffer[NFAPI_P7_HEADER_LENGTH], &buffer[0] + offset, size);
offset += size;
if(vnf_p7->_public.checksum_enabled)
{
nfapi_p7_update_checksum(tx_buffer, segment_size);
}
nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &tx_buffer[0], segment_size);
}
}
else
{
if(vnf_p7->_public.checksum_enabled)
{
nfapi_p7_update_checksum(buffer, len);
}
nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
// simple case that the message fits in a single segement
send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &buffer[0], len);
}
p7_connection->sequence_number++;
return send_result;
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() cannot find p7 connection info for phy_id:%d\n", __FUNCTION__, header->phy_id);
return -1;
}
}
int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header)
{
@@ -558,23 +652,35 @@ int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* hea
return -1;
}
}
int vnf_build_send_dl_node_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
{
{
nfapi_dl_node_sync_t dl_node_sync;
memset(&dl_node_sync, 0, sizeof(dl_node_sync));
dl_node_sync.header.phy_id = p7_info->phy_id;
dl_node_sync.header.message_id = NFAPI_DL_NODE_SYNC;
//dl_node_sync.t1 = calculate_t1(p7_info->sfn_sf, vnf_p7->sf_start_time_hr);
dl_node_sync.t1 = calculate_t1(p7_info->sfn,p7_info->slot, vnf_p7->slot_start_time_hr);
dl_node_sync.delta_sfn_slot = 0;
dl_node_sync.t1 = calculate_t1(p7_info->sfn_sf, vnf_p7->sf_start_time_hr);
dl_node_sync.delta_sfn_sf = 0;
return vnf_p7_pack_and_send_p7_msg(vnf_p7, &dl_node_sync.header);
}
int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
int vnf_nr_build_send_dl_node_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
{
nfapi_nr_dl_node_sync_t dl_node_sync;
memset(&dl_node_sync, 0, sizeof(dl_node_sync));
dl_node_sync.header.phy_id = p7_info->phy_id;
dl_node_sync.header.message_id = NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC;
//dl_node_sync.t1 = calculate_t1(p7_info->sfn_sf, vnf_p7->sf_start_time_hr);
dl_node_sync.t1 = calculate_nr_t1(p7_info->sfn,p7_info->slot, vnf_p7->slot_start_time_hr);
dl_node_sync.delta_sfn_slot = 0;
return vnf_nr_p7_pack_and_send_p7_msg(vnf_p7, &dl_node_sync.header);
}
int vnf_nr_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
{
if(p7_info->in_sync == 1)
@@ -586,7 +692,7 @@ int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
//if ((((sfn_sf_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0)
if ((((sfn_slot_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSLOTDEC) & dl_sync_period_mask) == 0)
{
vnf_build_send_dl_node_sync(vnf_p7, p7_info);
vnf_nr_build_send_dl_node_sync(vnf_p7, p7_info);
}
}
else
@@ -597,6 +703,33 @@ int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
//if ((((sfn_sf_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0)
if ((((sfn_slot_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSLOTDEC) & dl_sync_period_mask) == 0)
{
vnf_nr_build_send_dl_node_sync(vnf_p7, p7_info);
}
}
return 0;
}
int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
{
if(p7_info->in_sync == 1)
{
uint16_t dl_sync_period_mask = p7_info->dl_in_sync_period-1;
uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf);
if ((((sfn_sf_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0)
{
vnf_build_send_dl_node_sync(vnf_p7, p7_info);
}
}
else
{
uint16_t dl_sync_period_mask = p7_info->dl_out_sync_period-1;
uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf);
if ((((sfn_sf_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0)
{
vnf_build_send_dl_node_sync(vnf_p7, p7_info);
}
@@ -949,9 +1082,7 @@ void vnf_handle_p7_vendor_extension(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vn
void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
{
//printf("received UL Node sync");
{
uint32_t now_time_hr = vnf_get_current_time_hr();
if (pRecvMsg == NULL || vnf_p7 == NULL)
@@ -970,7 +1101,382 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Received UL_NODE_SYNC phy_id:%d t1:%d t2:%d t3:%d\n", ind.header.phy_id, ind.t1, ind.t2, ind.t3);
nfapi_vnf_p7_connection_info_t* phy = vnf_p7_connection_info_list_find(vnf_p7, ind.header.phy_id);
uint32_t t4 = calculate_t4(now_time_hr, phy->sfn, phy->slot, vnf_p7->slot_start_time_hr);
uint32_t t4 = calculate_t4(now_time_hr, phy->sfn_sf, vnf_p7->sf_start_time_hr);
uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSFDEC - ind.t1 ;
uint32_t pnf_proc_time = ind.t3 - ind.t2;
// divide by 2 using shift operator
uint32_t latency = (tx_2_rx - pnf_proc_time) >> 1;
if(!(phy->filtered_adjust))
{
phy->latency[phy->min_sync_cycle_count] = latency;
NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) PNF to VNF !sync phy_id:%d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d\n",
NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, ind.t1, ind.t2, ind.t3, t4,
tx_2_rx, pnf_proc_time, latency);
}
else
{
phy->latency[phy->min_sync_cycle_count] = latency;
//if(phy->min_sync_cycle_count != SYNC_CYCLE_COUNT)
{
if (ind.t2 < phy->previous_t2 && ind.t1 > phy->previous_t1)
{
// Only t2 wrap has occurred!!!
phy->sf_offset = (NFAPI_MAX_SFNSFDEC + ind.t2) - ind.t1 - latency;
}
else if (ind.t2 > phy->previous_t2 && ind.t1 < phy->previous_t1)
{
// Only t1 wrap has occurred
phy->sf_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSFDEC) - latency;
}
else
{
// Either no wrap or both have wrapped
phy->sf_offset = ind.t2 - ind.t1 - latency;
}
if (phy->sf_offset_filtered == 0)
{
phy->sf_offset_filtered = phy->sf_offset;
}
else
{
int32_t oldFilteredValueShifted = phy->sf_offset_filtered << 5;
int32_t newOffsetShifted = phy->sf_offset << 5;
// 1/8 of new and 7/8 of old
phy->sf_offset_filtered = ((newOffsetShifted >> 3) + ((oldFilteredValueShifted * 7) >> 3)) >> 5;
}
}
if(1)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%1d) %d.%d PNF to VNF phy_id:%2d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d(avg:%4d) offset(us):%8d filtered(us):%8d wrap[t1:%u t2:%u]\n",
NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ts.tv_sec, ts.tv_nsec, ind.header.phy_id,
ind.t1, ind.t2, ind.t3, t4,
tx_2_rx, pnf_proc_time, latency, phy->average_latency, phy->sf_offset, phy->sf_offset_filtered,
(ind.t1<phy->previous_t1), (ind.t2<phy->previous_t2));
}
}
if (phy->filtered_adjust && (phy->sf_offset_filtered > 1e6 || phy->sf_offset_filtered < -1e6))
{
phy->filtered_adjust = 0;
phy->zero_count=0;
phy->min_sync_cycle_count = 2;
phy->in_sync = 0;
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s - ADJUST TOO BAD - go out of filtered phy->sf_offset_filtered:%d\n", __FUNCTION__, phy->sf_offset_filtered);
}
if(phy->min_sync_cycle_count)
phy->min_sync_cycle_count--;
if(phy->min_sync_cycle_count == 0)
{
uint32_t curr_sfn_sf = phy->sfn_sf;
int32_t sfn_sf_dec = NFAPI_SFNSF2DEC(phy->sfn_sf);
if(!phy->filtered_adjust)
{
int i = 0;
//phy->average_latency = 0;
for(i = 0; i < SYNC_CYCLE_COUNT; ++i)
{
phy->average_latency += phy->latency[i];
}
phy->average_latency /= SYNC_CYCLE_COUNT;
phy->sf_offset = ind.t2 - (ind.t1 - phy->average_latency);
sfn_sf_dec += (phy->sf_offset / 1000);
}
else
{
sfn_sf_dec += ((phy->sf_offset_filtered + 500) / 1000); //Round up go from microsecond to subframe(1ms)
}
if(sfn_sf_dec < 0)
{
sfn_sf_dec += NFAPI_MAX_SFNSFDEC;
}
else if( sfn_sf_dec >= NFAPI_MAX_SFNSFDEC)
{
sfn_sf_dec -= NFAPI_MAX_SFNSFDEC;
}
uint16_t new_sfn_sf = NFAPI_SFNSFDEC2SFNSF(sfn_sf_dec);
{
phy->adjustment = NFAPI_SFNSF2DEC(new_sfn_sf) - NFAPI_SFNSF2DEC(curr_sfn_sf);
NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF phy_id:%d adjustment%d phy->previous_sf_offset_filtered:%d phy->previous_sf_offset_filtered:%d phy->sf_offset_trend:%d\n", ind.header.phy_id, phy->adjustment, phy->previous_sf_offset_filtered, phy->previous_sf_offset_filtered, phy->sf_offset_trend);
phy->previous_t1 = 0;
phy->previous_t2 = 0;
if(phy->previous_sf_offset_filtered > 0)
{
if( phy->sf_offset_filtered > phy->previous_sf_offset_filtered)
{
// pnf is getting futher ahead of vnf
//phy->sf_offset_trend = phy->sf_offset_filtered - phy->previous_sf_offset_filtered;
phy->sf_offset_trend = (phy->sf_offset_filtered + phy->previous_sf_offset_filtered)/2;
}
else
{
// pnf is getting back in sync
}
}
else if(phy->previous_sf_offset_filtered < 0)
{
if(phy->sf_offset_filtered < phy->previous_sf_offset_filtered)
{
// vnf is getting future ahead of pnf
//phy->sf_offset_trend = -(phy->sf_offset_filtered - phy->previous_sf_offset_filtered);
phy->sf_offset_trend = (-(phy->sf_offset_filtered + phy->previous_sf_offset_filtered)) /2;
}
else
{
// vnf is getting back in sync
}
}
int insync_minor_adjustment_1 = phy->sf_offset_trend / 6;
int insync_minor_adjustment_2 = phy->sf_offset_trend / 2;
if(insync_minor_adjustment_1 == 0)
insync_minor_adjustment_1 = 2;
if(insync_minor_adjustment_2 == 0)
insync_minor_adjustment_2 = 10;
if(!phy->filtered_adjust)
{
if(phy->adjustment < 10)
{
phy->zero_count++;
if(phy->zero_count >= 10)
{
phy->filtered_adjust = 1;
phy->zero_count = 0;
NFAPI_TRACE(NFAPI_TRACE_NOTE, "***** Adjusting VNF SFN/SF switching to filtered mode\n");
}
}
else
{
phy->zero_count = 0;
}
}
else
{
// Fine level of adjustment
if (phy->adjustment == 0)
{
if (phy->zero_count >= 10)
{
if(phy->in_sync == 0)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "VNF P7 In Sync with phy (phy_id:%d)\n", phy->phy_id);
if(vnf_p7->_public.sync_indication)
(vnf_p7->_public.sync_indication)(&(vnf_p7->_public), 1);
}
phy->in_sync = 1;
}
else
{
phy->zero_count++;
}
if(phy->in_sync)
{
// in sync
if(phy->sf_offset_filtered > 250)
{
// VNF is slow
phy->insync_minor_adjustment = insync_minor_adjustment_1; //25;
phy->insync_minor_adjustment_duration = ((phy->sf_offset_filtered) / insync_minor_adjustment_1);
}
else if(phy->sf_offset_filtered < -250)
{
// VNF is fast
phy->insync_minor_adjustment = -(insync_minor_adjustment_1); //25;
phy->insync_minor_adjustment_duration = (((phy->sf_offset_filtered) / -(insync_minor_adjustment_1)));
}
else
{
phy->insync_minor_adjustment = 0;
}
if(phy->insync_minor_adjustment != 0)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (sf_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adjustment:%d\n",
NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id,
phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration,
phy->sf_offset_filtered,
insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend,
NFAPI_SFNSF2DEC(new_sfn_sf),
NFAPI_SFNSF2DEC(curr_sfn_sf),
phy->adjustment);
}
}
}
else
{
if (phy->in_sync)
{
if(phy->adjustment == 0)
{
}
else if(phy->adjustment > 0)
{
// VNF is slow
//if(phy->adjustment == 1)
{
//
if(phy->sf_offset_filtered > 250)
{
// VNF is slow
phy->insync_minor_adjustment = insync_minor_adjustment_2;
phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered - 250) / insync_minor_adjustment_2);
}
else if(phy->sf_offset_filtered < -250)
{
// VNF is fast
phy->insync_minor_adjustment = -(insync_minor_adjustment_2);
phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered + 250) / -(insync_minor_adjustment_2));
}
}
//else
{
// out of sync?
}
NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (adjustment:%d sf_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adj:%d\n",
NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id,
phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->sf_offset_filtered,
insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend,
NFAPI_SFNSF2DEC(new_sfn_sf),
NFAPI_SFNSF2DEC(curr_sfn_sf),
phy->adjustment);
}
else if(phy->adjustment < 0)
{
// VNF is fast
//if(phy->adjustment == -1)
{
//
if(phy->sf_offset_filtered > 250)
{
// VNF is slow
phy->insync_minor_adjustment = insync_minor_adjustment_2;
phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered - 250) / insync_minor_adjustment_2);
}
else if(phy->sf_offset_filtered < -250)
{
// VNF is fast
phy->insync_minor_adjustment = -(insync_minor_adjustment_2);
phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered + 250) / -(insync_minor_adjustment_2));
}
}
//else
{
// out of sync?
}
NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (adjustment:%d sf_offset_filtered:%d) %d %d %d\n",
NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id,
phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->sf_offset_filtered,
insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend);
}
/*
if (phy->adjustment > 10 || phy->adjustment < -10)
{
phy->zero_count++; // Add one to the getting out of sync counter
}
else
{
phy->zero_count = 0; // Small error - zero the out of sync counter
}
if (phy->zero_count >= 10) // If we have had 10 consecutive large errors - drop out of sync
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "we have fallen out of sync...\n");
//pP7SockInfo->syncAchieved = 0;
}
*/
}
}
}
if(phy->in_sync == 0)
{
/*NFAPI_TRACE(NFAPI_TRACE_NOTE, "***** Adjusting VNF phy_id:%d SFN/SF (%s) from %d to %d (%d) mode:%s zeroCount:%u sync:%s\n",
ind.header.phy_id, (phy->in_sync ? "via sfn" : "now"),
NFAPI_SFNSF2DEC(curr_sfn_sf), NFAPI_SFNSF2DEC(new_sfn_sf), phy->adjustment,
phy->filtered_adjust ? "FILTERED" : "ABSOLUTE",
phy->zero_count,
phy->in_sync ? "IN_SYNC" : "OUT_OF_SYNC");*/
phy->sfn_sf = new_sfn_sf;
}
}
// reset for next cycle
phy->previous_sf_offset_filtered = phy->sf_offset_filtered;
phy->min_sync_cycle_count = 2;
phy->sf_offset_filtered = 0;
phy->sf_offset = 0;
}
else
{
phy->previous_t1 = ind.t1;
phy->previous_t2 = ind.t2;
}
}
void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
{
//printf("received UL Node sync");
uint32_t now_time_hr = vnf_get_current_time_hr();
if (pRecvMsg == NULL || vnf_p7 == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_ul_node_sync: NULL parameters\n");
return;
}
nfapi_nr_ul_node_sync_t ind;
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(nfapi_nr_ul_node_sync_t), &vnf_p7->_public.codec_config) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack ul_node_sync\n");
return;
}
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Received UL_NODE_SYNC phy_id:%d t1:%d t2:%d t3:%d\n", ind.header.phy_id, ind.t1, ind.t2, ind.t3);
nfapi_vnf_p7_connection_info_t* phy = vnf_p7_connection_info_list_find(vnf_p7, ind.header.phy_id);
uint32_t t4 = calculate_nr_t4(now_time_hr, phy->sfn, phy->slot, vnf_p7->slot_start_time_hr);
uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSLOTDEC - ind.t1 ; //time taken to receive ul node sync - time taken to send dl node sync
uint32_t pnf_proc_time = ind.t3 - ind.t2;
@@ -1346,6 +1852,39 @@ void vnf_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
return;
}
if (vnf_p7 && vnf_p7->p7_connections)
{
int16_t vnf_pnf_sfnsf_delta = NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf) - NFAPI_SFNSF2DEC(ind.last_sfn_sf);
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PNF:SFN/SF:%d VNF:SFN/SF:%d deltaSFNSF:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind.last_sfn_sf), NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), vnf_pnf_sfnsf_delta);
// Panos: Careful here!!! Modification of the original nfapi-code
//if (vnf_pnf_sfnsf_delta>1 || vnf_pnf_sfnsf_delta < -1)
if (vnf_pnf_sfnsf_delta>0 || vnf_pnf_sfnsf_delta < 0)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() LARGE SFN/SF DELTA between PNF and VNF delta:%d VNF:%d PNF:%d\n\n\n\n\n\n\n\n\n", __FUNCTION__, vnf_pnf_sfnsf_delta, NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), NFAPI_SFNSF2DEC(ind.last_sfn_sf));
// Panos: Careful here!!! Modification of the original nfapi-code
vnf_p7->p7_connections[0].sfn_sf = ind.last_sfn_sf;
}
}
}
void vnf_nr_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
{
if (pRecvMsg == NULL || vnf_p7 == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_timing_info: NULL parameters\n");
return;
}
nfapi_nr_timing_info_t ind;
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(nfapi_timing_info_t), &vnf_p7->_public.codec_config) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack timing_info\n");
return;
}
if (vnf_p7 && vnf_p7->p7_connections)
{
//int16_t vnf_pnf_sfnsf_delta = NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf) - NFAPI_SFNSF2DEC(ind.last_sfn_sf);
@@ -1460,6 +1999,101 @@ void vnf_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
}
}
void vnf_nr_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
{
nfapi_p7_message_header_t header;
// validate the input params
if(pRecvMsg == NULL || recvMsgLen < 4 || vnf_p7 == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__);
return;
}
// unpack the message header
if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &header, sizeof(header), &vnf_p7->_public.codec_config) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
return;
}
// ensure the message is sensible
if (recvMsgLen < 8 || pRecvMsg == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen);
return;
}
switch (header.message_id)
{
case NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC:
vnf_nr_handle_ul_node_sync(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_TIMING_INFO:
vnf_nr_handle_timing_info(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_HARQ_INDICATION:
vnf_handle_harq_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_CRC_INDICATION:
vnf_handle_crc_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_RX_ULSCH_INDICATION:
vnf_handle_rx_ulsch_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_RACH_INDICATION:
vnf_handle_rach_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_SRS_INDICATION:
vnf_handle_srs_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_RX_SR_INDICATION:
vnf_handle_rx_sr_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_RX_CQI_INDICATION:
vnf_handle_rx_cqi_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_LBT_DL_INDICATION:
vnf_handle_lbt_dl_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_NB_HARQ_INDICATION:
vnf_handle_nb_harq_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_NRACH_INDICATION:
vnf_handle_nrach_indication(pRecvMsg, recvMsgLen, vnf_p7);
break;
case NFAPI_UE_RELEASE_RESPONSE:
vnf_handle_ue_release_resp(pRecvMsg, recvMsgLen, vnf_p7);
break;
default:
{
if(header.message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
header.message_id <= NFAPI_VENDOR_EXT_MSG_MAX)
{
vnf_handle_p7_vendor_extension(pRecvMsg, recvMsgLen, vnf_p7, header.message_id);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Unknown message ID %d\n", header.message_id);
}
}
break;
}
}
void vnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
{
nfapi_p7_message_header_t messageHeader;
@@ -1578,6 +2212,200 @@ void vnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
}
}
void vnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
{
nfapi_p7_message_header_t messageHeader;
// validate the input params
if(pRecvMsg == NULL || recvMsgLen < 4 || vnf_p7 == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_p7_message: invalid input params (%d %d %d)\n", pRecvMsg, recvMsgLen, vnf_p7);
return;
}
// unpack the message header
if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p7_message_header_t), &vnf_p7->_public.codec_config) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
return;
}
if(vnf_p7->_public.checksum_enabled)
{
uint32_t checksum = nfapi_p7_calculate_checksum(pRecvMsg, recvMsgLen);
if(checksum != messageHeader.checksum)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Checksum verification failed %d %d msg:%d len:%d\n", checksum, messageHeader.checksum, messageHeader.message_id, recvMsgLen);
return;
}
}
uint8_t m = NFAPI_P7_GET_MORE(messageHeader.m_segment_sequence);
uint8_t segment_num = NFAPI_P7_GET_SEGMENT(messageHeader.m_segment_sequence);
uint8_t sequence_num = NFAPI_P7_GET_SEQUENCE(messageHeader.m_segment_sequence);
if(m == 0 && segment_num == 0)
{
// we have a complete message
// ensure the message is sensible
if (recvMsgLen < 8 || pRecvMsg == NULL)
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen);
return;
}
//vnf_dispatch_p7_message(&messageHeader, pRecvMsg, recvMsgLen, vnf_p7);
vnf_nr_dispatch_p7_message(pRecvMsg, recvMsgLen, vnf_p7);
}
else
{
nfapi_vnf_p7_connection_info_t* phy = vnf_p7_connection_info_list_find(vnf_p7, messageHeader.phy_id);
if(phy)
{
vnf_p7_rx_message_t* rx_msg = vnf_p7_rx_reassembly_queue_add_segment(vnf_p7, &(phy->reassembly_queue), sequence_num, segment_num, m, pRecvMsg, recvMsgLen);
if(rx_msg->num_segments_received == rx_msg->num_segments_expected)
{
// send the buffer on
uint16_t i = 0;
uint16_t length = 0;
for(i = 0; i < rx_msg->num_segments_expected; ++i)
{
length += rx_msg->segments[i].length - (i > 0 ? NFAPI_P7_HEADER_LENGTH : 0);
}
if(phy->reassembly_buffer_size < length)
{
vnf_p7_free(vnf_p7, phy->reassembly_buffer);
phy->reassembly_buffer = 0;
}
if(phy->reassembly_buffer == 0)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "Resizing VNF_P7 Reassembly buffer %d->%d\n", phy->reassembly_buffer_size, length);
phy->reassembly_buffer = (uint8_t*)vnf_p7_malloc(vnf_p7, length);
if(phy->reassembly_buffer == 0)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "Failed to allocate VNF_P7 reassemby buffer len:%d\n", length);
return;
}
memset(phy->reassembly_buffer, 0, length);
phy->reassembly_buffer_size = length;
}
uint16_t offset = 0;
for(i = 0; i < rx_msg->num_segments_expected; ++i)
{
if(i == 0)
{
memcpy(phy->reassembly_buffer, rx_msg->segments[i].buffer, rx_msg->segments[i].length);
offset += rx_msg->segments[i].length;
}
else
{
memcpy(phy->reassembly_buffer + offset, rx_msg->segments[i].buffer + NFAPI_P7_HEADER_LENGTH, rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH);
offset += rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH;
}
}
//pnf_dispatch_p7_message(pnf_p7->reassemby_buffer, length, pnf_p7, rx_msg->rx_hr_time);
vnf_nr_dispatch_p7_message(phy->reassembly_buffer, length , vnf_p7);
// delete the structure
vnf_p7_rx_reassembly_queue_remove_msg(vnf_p7, &(phy->reassembly_queue), rx_msg);
}
vnf_p7_rx_reassembly_queue_remove_old_msgs(vnf_p7, &(phy->reassembly_queue), 1000);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Unknown phy id %d\n", messageHeader.phy_id);
}
}
}
int vnf_nr_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
{
int recvfrom_result = 0;
struct sockaddr_in remote_addr;
socklen_t remote_addr_size = sizeof(remote_addr);
do
{
// peek the header
uint8_t header_buffer[NFAPI_P7_HEADER_LENGTH];
recvfrom_result = recvfrom(vnf_p7->socket, header_buffer, NFAPI_P7_HEADER_LENGTH, MSG_DONTWAIT | MSG_PEEK, (struct sockaddr*)&remote_addr, &remote_addr_size);
if(recvfrom_result > 0)
{
// get the segment size
nfapi_p7_message_header_t header;
if(nfapi_p7_message_header_unpack(header_buffer, NFAPI_P7_HEADER_LENGTH, &header, sizeof(header), 0) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
return -1;
}
// resize the buffer if we have a large segment
if(header.message_length > vnf_p7->rx_message_buffer_size)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length);
vnf_p7->rx_message_buffer = realloc(vnf_p7->rx_message_buffer, header.message_length);
vnf_p7->rx_message_buffer_size = header.message_length;
}
// read the segment
recvfrom_result = recvfrom(vnf_p7->socket, vnf_p7->rx_message_buffer, header.message_length, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size);
// todo : how to handle incomplete readfroms, need some sort of buffer/select
if(recvfrom_result == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom returned 0\n");
}
else if(recvfrom_result != header.message_length)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "did not receive the entire message %d %d\n", recvfrom_result, header.message_length);
recvfrom_result += recvfrom(vnf_p7->socket, &vnf_p7->rx_message_buffer[recvfrom_result], header.message_length - recvfrom_result, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size);
}
if(recvfrom_result > 0)
{
vnf_nr_handle_p7_message(vnf_p7->rx_message_buffer, recvfrom_result, vnf_p7);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom failed %d %d\n", recvfrom_result, errno);
}
}
if(recvfrom_result == -1)
{
if(errno == EAGAIN || errno == EWOULDBLOCK)
{
// return to the select
//NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom would block :%d\n", __FUNCTION__, errno);
}
else
{
NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom failed errno:%d\n", __FUNCTION__, errno);
}
}
}
while(recvfrom_result > 0);
return 0;
}
int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
{
int recvfrom_result = 0;
+327 -7
View File
@@ -91,7 +91,7 @@ struct timespec timespec_sub(struct timespec lhs, struct timespec rhs)
// monitor the p7 endpoints and the timing loop and
// send indications to mac
int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config)
int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config)
{
if(config == 0)
return -1;
@@ -410,7 +410,7 @@ struct timespec current_time;
{
curr->slot++;
}
vnf_sync(vnf_p7, curr);
vnf_nr_sync(vnf_p7, curr);
//printf("\nsfn:%d, slot:%d\n current time:%d.%d",curr->sfn,curr->slot,current_time.tv_sec, current_time.tv_nsec); //remove later - gokul
//printf("next slot will start at %d.%d\n",current_time.tv_sec, current_time.tv_nsec);
curr = curr->next;
@@ -423,7 +423,7 @@ struct timespec current_time;
// have a p7 message
if(FD_ISSET(vnf_p7->socket, &rfds))
{
vnf_p7_read_dispatch_message(vnf_p7);
vnf_nr_p7_read_dispatch_message(vnf_p7);
}
}
else
@@ -455,6 +455,326 @@ struct timespec current_time;
return 0;
}
int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config)
{
if(config == 0)
return -1;
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()\n", __FUNCTION__);
vnf_p7_t* vnf_p7 = (vnf_p7_t*)config;
// Create p7 receive udp port
// todo : this needs updating for Ipv6
NFAPI_TRACE(NFAPI_TRACE_INFO, "Initialising VNF P7 port:%u\n", config->port);
// open the UDP socket
if ((vnf_p7->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P7 socket errno: %d\n", errno);
return -1;
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 socket created...\n");
// configure the UDP socket options
int iptos_value = FAPI2_IP_DSCP << 2;
if (setsockopt(vnf_p7->socket, IPPROTO_IP, IP_TOS, &iptos_value, sizeof(iptos_value)) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (IP_TOS) errno: %d\n", errno);
return -1;
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 setsockopt succeeded...\n");
// Create the address structure
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(config->port);
addr.sin_addr.s_addr = INADDR_ANY;
// bind to the configured port
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 binding too %s:%d\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
if (bind(vnf_p7->socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0)
//if (sctp_bindx(config->socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in), 0) < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "After bind errno: %d\n", errno);
return -1;
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 bind succeeded...\n");
//struct timespec original_pselect_timeout;
struct timespec pselect_timeout;
pselect_timeout.tv_sec = 0;
pselect_timeout.tv_nsec = 1000000; // ns in a 1 us
struct timespec pselect_start;
struct timespec pselect_stop;
//struct timespec sf_end;
long last_millisecond = -1;
struct timespec sf_duration;
sf_duration.tv_sec = 0;
sf_duration.tv_nsec = 1e6; // We want 1ms pause
struct timespec sf_start;
clock_gettime(CLOCK_MONOTONIC, &sf_start);
long millisecond = sf_start.tv_nsec / 1e6;
sf_start = timespec_add(sf_start, sf_duration);
NFAPI_TRACE(NFAPI_TRACE_INFO, "next subframe will start at %d.%d\n", sf_start.tv_sec, sf_start.tv_nsec);
while(vnf_p7->terminate == 0)
{
fd_set rfds;
int maxSock = 0;
FD_ZERO(&rfds);
int selectRetval = 0;
// Add the p7 socket
FD_SET(vnf_p7->socket, &rfds);
maxSock = vnf_p7->socket;
clock_gettime(CLOCK_MONOTONIC, &pselect_start);
//long millisecond = pselect_start.tv_nsec / 1e6;
if((last_millisecond == -1) || (millisecond == last_millisecond) || (millisecond == (last_millisecond + 1) % 1000) )
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "pselect_start:%d.%d sf_start:%d.%d\n", pselect_start.tv_sec, pselect_start.tv_nsec, sf_start.tv_sec, sf_start.tv_nsec);
if((pselect_start.tv_sec > sf_start.tv_sec) ||
((pselect_start.tv_sec == sf_start.tv_sec) && (pselect_start.tv_nsec > sf_start.tv_nsec)))
{
// overran the end of the subframe we do not want to wait
pselect_timeout.tv_sec = 0;
pselect_timeout.tv_nsec = 0;
//struct timespec overrun = timespec_sub(pselect_start, sf_start);
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Subframe overrun detected of %d.%d running to catchup\n", overrun.tv_sec, overrun.tv_nsec);
}
else
{
// still time before the end of the subframe wait
pselect_timeout = timespec_sub(sf_start, pselect_start);
}
//original_pselect_timeout = pselect_timeout;
// detemine how long to sleep in ns before the start of the next 1ms
//pselect_timeout.tv_nsec = 1e6 - (pselect_start.tv_nsec % 1000000);
//uint8_t underrun_possible =0;
// if we are not sleeping until the next milisecond due to the
// insycn minor adjment flag it so we don't consider it an error
//uint8_t underrun_possible =0;
/*
{
nfapi_vnf_p7_connection_info_t* phy = vnf_p7->p7_connections;
if(phy && phy->in_sync && phy->insync_minor_adjustment != 0 && phy->insync_minor_adjustment_duration > 0 && pselect_start.tv_nsec != 0)
{
NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] Subframe minor adjustment %d (%d->%d)\n", phy->insync_minor_adjustment,
pselect_timeout.tv_nsec, pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000))
if(phy->insync_minor_adjustment > 0)
{
// todo check we don't go below 0
if((phy->insync_minor_adjustment * 1000) > pselect_timeout.tv_nsec)
pselect_timeout.tv_nsec = 0;
else
pselect_timeout.tv_nsec = pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000);
//underrun_possible = 1;
}
else if(phy->insync_minor_adjustment < 0)
{
// todo check we don't go below 0
pselect_timeout.tv_nsec = pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000);
}
//phy->insync_minor_adjustment = 0;
phy->insync_minor_adjustment_duration--;
}
}
*/
//long wraps = pselect_timeout.tv_nsec % 1e9;
selectRetval = pselect(maxSock+1, &rfds, NULL, NULL, &pselect_timeout, NULL);
clock_gettime(CLOCK_MONOTONIC, &pselect_stop);
nfapi_vnf_p7_connection_info_t* phy = vnf_p7->p7_connections;
if (selectRetval==-1 && errno == 22)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n",
pselect_timeout.tv_sec, pselect_timeout.tv_nsec,
phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment,
sf_duration.tv_sec, sf_duration.tv_nsec);
}
if(selectRetval == 0)
{
// calculate the start of the next subframe
sf_start = timespec_add(sf_start, sf_duration);
//NFAPI_TRACE(NFAPI_TRACE_INFO, "next subframe will start at %d.%d\n", sf_start.tv_sec, sf_start.tv_nsec);
if(phy && phy->in_sync && phy->insync_minor_adjustment != 0 && phy->insync_minor_adjustment_duration > 0)
{
long insync_minor_adjustment_ns = (phy->insync_minor_adjustment * 1000);
sf_start.tv_nsec -= insync_minor_adjustment_ns;
#if 1
if (sf_start.tv_nsec > 1e9)
{
sf_start.tv_sec++;
sf_start.tv_nsec-=1e9;
}
else if (sf_start.tv_nsec < 0)
{
sf_start.tv_sec--;
sf_start.tv_nsec+=1e9;
}
#else
//NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] BEFORE adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d\n", phy->insync_minor_adjustment, sf_start.tv_nsec);
if(phy->insync_minor_adjustment > 0)
{
// decrease the subframe duration a little
if (sf_start.tv_nsec > insync_minor_adjustment_ns)
sf_start.tv_nsec -= insync_minor_adjustment_ns;
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "[VNF] Adjustment would make it negative sf:%d.%ld adjust:%ld\n\n\n", sf_start.tv_sec, sf_start.tv_nsec, insync_minor_adjustment_ns);
sf_start.tv_sec--;
sf_start.tv_nsec += 1e9 - insync_minor_adjustment_ns;
}
}
else if(phy->insync_minor_adjustment < 0)
{
// todo check we don't go below 0
// increase the subframe duration a little
sf_start.tv_nsec += insync_minor_adjustment_ns;
if (sf_start.tv_nsec < 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "[VNF] OVERFLOW %d.%ld\n\n\n\n", sf_start.tv_sec, sf_start.tv_nsec);
sf_start.tv_sec++;
sf_start.tv_nsec += 1e9;
}
}
#endif
//phy->insync_minor_adjustment = 0;
phy->insync_minor_adjustment_duration--;
NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d duration:%u\n",
phy->insync_minor_adjustment, sf_start.tv_nsec, phy->insync_minor_adjustment_duration);
if (phy->insync_minor_adjustment_duration==0)
{
phy->insync_minor_adjustment = 0;
}
}
/*
long pselect_stop_millisecond = pselect_stop.tv_nsec / 1e6;
if(millisecond == pselect_stop_millisecond)
{
// we have woke up in the same subframe
if(underrun_possible == 0)
NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe pselect underrun %ld (%d.%d)\n", millisecond, pselect_stop.tv_sec, pselect_stop.tv_nsec);
}
else if(((millisecond + 1) % 1000) != pselect_stop_millisecond)
{
// we have overrun the subframe
NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe pselect overrun %ld %ld\n", millisecond, pselect_stop_millisecond);
NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe underrun %ld\n", millisecond);
}
last_millisecond = millisecond;
*/
millisecond ++;
}
}
else
{
// we have overrun the subframe advance to go and collect $200
if((millisecond - last_millisecond) > 3)
NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe overrun %ld %ld (%ld)\n", millisecond, last_millisecond, millisecond - last_millisecond + 1);
last_millisecond = ( last_millisecond + 1 ) % 1000;
selectRetval = 0;
}
if(selectRetval == 0)
{
vnf_p7->sf_start_time_hr = vnf_get_current_time_hr();
// pselect timed out
nfapi_vnf_p7_connection_info_t* curr = vnf_p7->p7_connections;
while(curr != 0)
{
curr->sfn_sf = increment_sfn_sf(curr->sfn_sf);
vnf_sync(vnf_p7, curr);
curr = curr->next;
}
send_mac_subframe_indications(vnf_p7);
}
else if(selectRetval > 0)
{
// have a p7 message
if(FD_ISSET(vnf_p7->socket, &rfds))
{
vnf_p7_read_dispatch_message(vnf_p7);
}
}
else
{
// pselect error
if(selectRetval == -1 && errno == EINTR)
{
// a sigal was received.
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "P7 select failed result %d errno %d timeout:%d.%d orginal:%d.%d last_ms:%ld ms:%ld\n", selectRetval, errno, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, last_millisecond, millisecond);
// should we exit now?
if (selectRetval == -1 && errno == 22) // invalid argument??? not sure about timeout duration
{
usleep(100000);
}
}
}
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "Closing p7 socket\n");
close(vnf_p7->socket);
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() returning\n", __FUNCTION__);
return 0;
}
int nfapi_vnf_p7_stop(nfapi_vnf_p7_config_t* config)
{
if(config == 0)
@@ -538,7 +858,7 @@ int nfapi_vnf_p7_nr_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_nr_dl_tti
return -1;
vnf_p7_t* vnf_p7 = (vnf_p7_t*)config;
return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
return vnf_nr_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
}
int nfapi_vnf_p7_ul_tti_req(nfapi_vnf_p7_config_t* config, nfapi_nr_ul_tti_request_t* req)
@@ -547,7 +867,7 @@ int nfapi_vnf_p7_ul_tti_req(nfapi_vnf_p7_config_t* config, nfapi_nr_ul_tti_reque
return -1;
vnf_p7_t* vnf_p7 = (vnf_p7_t*)config;
return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
return vnf_nr_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
}
int nfapi_vnf_p7_ul_config_req(nfapi_vnf_p7_config_t* config, nfapi_ul_config_request_t* req)
@@ -564,7 +884,7 @@ int nfapi_vnf_p7_ul_dci_req(nfapi_vnf_p7_config_t* config, nfapi_nr_ul_dci_reque
return -1;
vnf_p7_t* vnf_p7 = (vnf_p7_t*)config;
return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
return vnf_nr_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
}
int nfapi_vnf_p7_hi_dci0_req(nfapi_vnf_p7_config_t* config, nfapi_hi_dci0_request_t* req)
{
@@ -580,7 +900,7 @@ int nfapi_vnf_p7_tx_data_req(nfapi_vnf_p7_config_t* config, nfapi_nr_tx_data_req
return -1;
vnf_p7_t* vnf_p7 = (vnf_p7_t*)config;
return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
return vnf_nr_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
}
int nfapi_vnf_p7_tx_req(nfapi_vnf_p7_config_t* config, nfapi_tx_request_t* req)
{
+1 -1
View File
@@ -81,7 +81,6 @@ l1_north_init_eNB () {
return(0);
}
void phy_config_request(PHY_Config_t *phy_config) {
uint8_t Mod_id = phy_config->Mod_id;
int CC_id = phy_config->CC_id;
@@ -573,6 +572,7 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) {
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) eNB->UE_stats_ptr[UE_id] = NULL;
}
void install_schedule_handlers(IF_Module_t *if_inst) {
if_inst->PHY_config_req = phy_config_request;
if_inst->schedule_response = schedule_response;
+1
View File
@@ -183,6 +183,7 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,
}
void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms) {
LOG_I(PHY,"frame_parms->N_RB_DL=%d\n",frame_parms->N_RB_DL);
LOG_I(PHY,"frame_parms->N_RB_UL=%d\n",frame_parms->N_RB_UL);
-2
View File
@@ -101,8 +101,6 @@ void handle_nfapi_hi_dci0_mpdcch_dci_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
// copy dci configuration in to eNB structure
fill_mpdcch_dci0(eNB,proc,&pdcch_vars->mdci_alloc[pdcch_vars->num_dci], &hi_dci0_config_pdu->mpdcch_dci_pdu);
}
void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) {
LTE_eNB_PHICH *phich = &eNB->phich_vars[subframe&1];
+1
View File
@@ -31,6 +31,7 @@
*/
#include "PHY/defs_eNB.h"
#include "PHY/defs_gNB.h"
#include "PHY/phy_extern.h"
#include "PHY/LTE_TRANSPORT/transport_proto.h"
#include "SCHED/sched_eNB.h"
+34
View File
@@ -0,0 +1,34 @@
//Dummy NR defs to avoid linking errors
#include "PHY/defs_gNB.h"
#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h"
#include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h"
#include "openair1/PHY/LTE_TRANSPORT/transport_common.h"
void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu){}
void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu){}
int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type){}
void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
uint8_t *sdu){
}
int l1_north_init_gNB(void){}
uint8_t slot_ahead=6;
uint8_t nfapi_mode=0;
NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {}
void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu){}
void nr_phy_config_request(NR_PHY_Config_t *gNB){}
void install_nr_schedule_handlers(NR_IF_Module_t *if_inst){}
void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp){}
+36
View File
@@ -0,0 +1,36 @@
//Dummy NR defs to avoid linking errors
#include "PHY/defs_gNB.h"
#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h"
#include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h"
#include "openair1/PHY/LTE_TRANSPORT/transport_common.h"
void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu){}
void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu){}
int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type){}
void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
uint8_t *sdu){
}
int l1_north_init_gNB(void){}
uint8_t slot_ahead=6;
uint8_t nfapi_mode=0;
NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {}
void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu){}
void nr_phy_config_request(NR_PHY_Config_t *gNB){}
void install_nr_schedule_handlers(NR_IF_Module_t *if_inst){}
//void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp){}
+36
View File
@@ -0,0 +1,36 @@
//Dummy NR defs to avoid linking errors
#include "PHY/defs_gNB.h"
#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h"
#include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h"
#include "openair1/PHY/LTE_TRANSPORT/transport_common.h"
void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu){}
void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu){}
int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type){}
void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
uint8_t *sdu){
}
int l1_north_init_gNB(void){}
uint8_t slot_ahead=0;
uint8_t nfapi_mode=0;
NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {}
void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu){}
void nr_phy_config_request(NR_PHY_Config_t *gNB){}
void install_nr_schedule_handlers(NR_IF_Module_t *if_inst){}
//void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp){}
+2 -2
View File
@@ -425,7 +425,7 @@ void RCconfig_NR_L1(void) {
mac_top_init_gNB();
configure_nfapi_pnf(RC.gNB[j]->eth_params_n.remote_addr, RC.gNB[j]->eth_params_n.remote_portc, RC.gNB[j]->eth_params_n.my_addr, RC.gNB[j]->eth_params_n.my_portd, RC.gNB[j]->eth_params_n .remote_portd);
configure_nr_nfapi_pnf(RC.gNB[j]->eth_params_n.remote_addr, RC.gNB[j]->eth_params_n.remote_portc, RC.gNB[j]->eth_params_n.my_addr, RC.gNB[j]->eth_params_n.my_portd, RC.gNB[j]->eth_params_n .remote_portd);
}else { // other midhaul
}
}// for (j = 0; j < RC.nb_nr_L1_inst; j++)
@@ -496,7 +496,7 @@ void RCconfig_nr_macrlc() {
//sf_ahead = 2; // Cannot cope with 4 subframes between RX and TX - set it to 2
printf("**************** vnf_port:%d\n", RC.nrmac[j]->eth_params_s.my_portc);
configure_nfapi_vnf(RC.nrmac[j]->eth_params_s.my_addr, RC.nrmac[j]->eth_params_s.my_portc);
configure_nr_nfapi_vnf(RC.nrmac[j]->eth_params_s.my_addr, RC.nrmac[j]->eth_params_s.my_portc);
printf("**************** RETURNED FROM configure_nfapi_vnf() vnf_port:%d\n", RC.nrmac[j]->eth_params_s.my_portc);
}else { // other midhaul
AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr));
+1 -2
View File
@@ -2117,8 +2117,7 @@ pdcp_config_set_security(
}
//-----------------------------------------------------------------------------
void
rrc_pdcp_config_req (
void rrc_pdcp_config_req (
const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const uint32_t actionP,
+1
View File
@@ -775,6 +775,7 @@ void UL_indication(UL_IND_t *UL_info, L1_rxtx_proc_t *proc) {
}
}
IF_Module_t *IF_Module_init(int Mod_id) {
AssertFatal(Mod_id<MAX_MODULES,"Asking for Module %d > %d\n",Mod_id,MAX_IF_MODULES);
LOG_D(PHY,"Installing callbacks for IF_Module - UL_indication\n");
-27
View File
@@ -1096,13 +1096,6 @@ void handle_nfapi_hi_dci0_hi_pdu(
nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) {
}
void rrc_pdcp_config_req (
const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const uint32_t actionP,
const rb_id_t rb_idP,
const uint8_t security_modeP){
}
void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,
int frame,
@@ -1163,23 +1156,3 @@ int l1_north_init_eNB(void) {
void init_eNB_afterRU(void) {
}
void nr_phy_config_request(NR_PHY_Config_t *gNB){}
void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu){}
void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB,
int frame, int slot,
nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu){}
void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu){}
int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type){}
void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
uint8_t *sdu){
}
int l1_north_init_gNB(void){}
uint8_t nfapi_mode;
+20 -19
View File
@@ -566,6 +566,19 @@ int main ( int argc, char **argv )
/* Read configuration */
if (RC.nb_inst > 0) {
read_config_and_init();
init_pdcp();
if (create_tasks(1) < 0) {
printf("cannot create ITTI tasks\n");
exit(-1);
}
for (int enb_id = 0; enb_id < RC.nb_inst; enb_id++) {
MessageDef *msg_p = itti_alloc_new_message (TASK_ENB_APP, RRC_CONFIGURATION_REQ);
RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration;
itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
}
node_type = RC.rrc[0]->node_type;
} else {
printf("RC.nb_inst = 0, Initializing L1\n");
RCconfig_L1();
@@ -580,28 +593,16 @@ int main ( int argc, char **argv )
RC.nb_L1_inst, RC.nb_RU, get_nprocs());
}
if (RC.nb_inst > 0) {
/* Start the agent. If it is turned off in the configuration, it won't start */
for (i = 0; i < RC.nb_inst; i++) {
flexran_agent_start(i);
}
// if (RC.nb_inst > 0) {
// /* Start the agent. If it is turned off in the configuration, it won't start */
// for (i = 0; i < RC.nb_inst; i++) {
// flexran_agent_start(i);
// }
/* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks
* for monolithic/F1 modes */
init_pdcp();
if (create_tasks(1) < 0) {
printf("cannot create ITTI tasks\n");
exit(-1);
}
for (int enb_id = 0; enb_id < RC.nb_inst; enb_id++) {
MessageDef *msg_p = itti_alloc_new_message (TASK_ENB_APP, RRC_CONFIGURATION_REQ);
RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration;
itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
}
node_type = RC.rrc[0]->node_type;
}
//}
if (RC.nb_inst > 0 && NODE_IS_CU(node_type)) {
protocol_ctxt_t ctxt;