LTE and NR NFAPI integration
This commit is contained in:
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user