Add send function pointers to PNF
This commit is contained in:
@@ -1705,17 +1705,17 @@ void pnf_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
|
||||
}
|
||||
}
|
||||
|
||||
int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_nr_p4_p5_message_header_t* msg, uint32_t msg_len)
|
||||
bool pnf_nr_send_p5_message(pnf_t* pnf, nfapi_nr_p4_p5_message_header_t* msg, uint32_t msg_len)
|
||||
{
|
||||
int packed_len =
|
||||
pnf->_public.pack_func(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_nr_p5_message_pack failed (%d)\n", packed_len);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
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*/) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,8 +135,8 @@ int nfapi_nr_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_param_r
|
||||
}
|
||||
|
||||
pnf_t* _this = (pnf_t*)(config);
|
||||
|
||||
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_pnf_param_response_t));
|
||||
AssertFatal(config->send_p5_msg, "Function pointer must be configured!");
|
||||
return config->send_p5_msg(_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)
|
||||
@@ -188,8 +188,8 @@ int nfapi_nr_pnf_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_config
|
||||
}
|
||||
|
||||
pnf_t* _this = (pnf_t*)(config);
|
||||
|
||||
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_pnf_config_response_t));
|
||||
AssertFatal(config->send_p5_msg, "Function pointer must be configured|");
|
||||
return config->send_p5_msg(_this, &(resp->header), sizeof(nfapi_nr_pnf_config_response_t));
|
||||
}
|
||||
|
||||
|
||||
@@ -227,8 +227,8 @@ int nfapi_nr_pnf_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_pnf_start_r
|
||||
}
|
||||
|
||||
pnf_t* _this = (pnf_t*)(config);
|
||||
|
||||
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_pnf_start_response_t));
|
||||
AssertFatal(config->send_p5_msg, "Function pointer must be configured|");
|
||||
return config->send_p5_msg(_this, &(resp->header), sizeof(nfapi_nr_pnf_start_response_t));
|
||||
}
|
||||
|
||||
|
||||
@@ -273,8 +273,8 @@ int nfapi_nr_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_
|
||||
}
|
||||
|
||||
pnf_t* _this = (pnf_t*)(config);
|
||||
|
||||
return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_param_response_scf_t));
|
||||
AssertFatal(config->send_p5_msg, "Function pointer must be configured|");
|
||||
return config->send_p5_msg(_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)
|
||||
@@ -329,8 +329,8 @@ int nfapi_nr_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_config_respons
|
||||
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));
|
||||
AssertFatal(config->send_p5_msg, "Function pointer must be configured|");
|
||||
return config->send_p5_msg(_this, &(resp->header), sizeof(nfapi_nr_config_response_scf_t));
|
||||
}
|
||||
|
||||
|
||||
@@ -384,8 +384,8 @@ int nfapi_nr_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_start_response_
|
||||
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));
|
||||
AssertFatal(config->send_p5_msg, "Function pointer must be configured|");
|
||||
return config->send_p5_msg(_this, &(resp->header), sizeof(nfapi_nr_start_response_scf_t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -569,14 +569,14 @@ 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_nr_p7_message_header_t* header, uint32_t msg_len)
|
||||
bool pnf_nr_send_p7_message(pnf_p7_t* pnf_p7, nfapi_nr_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;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t tx_buf[131072]; // four times NFAPI_MAX_PACKED_MESSAGE_SIZE as of this commit
|
||||
@@ -585,11 +585,11 @@ int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_nr_p7_message_hea
|
||||
if (len < 0) {
|
||||
if (pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p7_message_pack failed with return %d\n", len);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (len > pnf_p7->_public.segment_size) {
|
||||
@@ -644,10 +644,10 @@ int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_nr_p7_message_hea
|
||||
|
||||
if (pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void pnf_pack_and_send_timing_info(pnf_p7_t* pnf_p7)
|
||||
@@ -707,9 +707,8 @@ void pnf_nr_pack_and_send_timing_info(pnf_p7_t* pnf_p7)
|
||||
timing_info.tx_data_request_earliest_arrival = 0;
|
||||
timing_info.ul_tti_earliest_arrival = 0;
|
||||
timing_info.ul_dci_earliest_arrival = 0;
|
||||
|
||||
|
||||
pnf_nr_p7_pack_and_send_p7_message(pnf_p7, &(timing_info.header), sizeof(timing_info));
|
||||
AssertFatal(pnf_p7->_public.send_p7_msg, "The function pointer to pack and send P7 messages must be set");
|
||||
pnf_p7->_public.send_p7_msg(pnf_p7, &(timing_info.header), sizeof(timing_info));
|
||||
|
||||
pnf_p7->timing_info_ms_counter = 0;
|
||||
}
|
||||
@@ -2097,8 +2096,8 @@ void pnf_nr_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pnf_nr_p7_pack_and_send_p7_message(pnf_p7, &(ul_node_sync.header), sizeof(ul_node_sync));
|
||||
AssertFatal(pnf_p7->_public.send_p7_msg, "Function pointer must be configured|");
|
||||
pnf_p7->_public.send_p7_msg(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);
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +260,8 @@ int nfapi_pnf_p7_nr_slot_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_slot_indica
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_slot_indication_scf_t));
|
||||
AssertFatal(_this->_public.send_p7_msg, "Function pointer must be configured|");
|
||||
return _this->_public.send_p7_msg(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_slot_indication_scf_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_rx_data_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rx_data_indication_t* ind)
|
||||
@@ -272,8 +273,8 @@ int nfapi_pnf_p7_nr_rx_data_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rx_data_
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
|
||||
int ret = pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_rx_data_indication_t));
|
||||
AssertFatal(_this->_public.send_p7_msg, "Function pointer must be configured|");
|
||||
int ret = _this->_public.send_p7_msg(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_rx_data_indication_t));
|
||||
if (ret == 0) {
|
||||
for (int i = 0; i < ind->number_of_pdus; ++i)
|
||||
_this->nr_stats.ul.bytes += ind->pdu_list[i].pdu_length;
|
||||
@@ -290,7 +291,8 @@ int nfapi_pnf_p7_nr_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_crc_indicati
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_crc_indication_t));
|
||||
AssertFatal(_this->_public.send_p7_msg, "Function pointer must be configured|");
|
||||
return _this->_public.send_p7_msg(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_crc_indication_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_srs_indication_t* ind)
|
||||
@@ -302,7 +304,8 @@ int nfapi_pnf_p7_nr_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_srs_indicati
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_srs_indication_t));
|
||||
AssertFatal(_this->_public.send_p7_msg, "Function pointer must be configured|");
|
||||
return _this->_public.send_p7_msg(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_srs_indication_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_uci_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_uci_indication_t* ind)
|
||||
@@ -314,7 +317,8 @@ int nfapi_pnf_p7_nr_uci_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_uci_indicati
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_uci_indication_t));
|
||||
AssertFatal(_this->_public.send_p7_msg, "Function pointer must be configured|");
|
||||
return _this->_public.send_p7_msg(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_uci_indication_t));
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rach_indication_t* ind)
|
||||
@@ -326,5 +330,6 @@ int nfapi_pnf_p7_nr_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rach_indica
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_rach_indication_t));
|
||||
AssertFatal(_this->_public.send_p7_msg, "Function pointer must be configured|");
|
||||
return _this->_public.send_p7_msg(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_rach_indication_t));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user