Cleanup
This commit is contained in:
+425
-339
@@ -461,6 +461,7 @@ int vnf_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info, u
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sendto_result %d %d\n", __FUNCTION__, sendto_result, errno);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -676,6 +677,7 @@ int vnf_nr_build_send_dl_node_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_inf
|
||||
//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);
|
||||
}
|
||||
|
||||
@@ -1451,8 +1453,102 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
phy->previous_t1 = ind.t1;
|
||||
phy->previous_t2 = ind.t2;
|
||||
}
|
||||
}
|
||||
|
||||
//NR HANDLES FOR UPLINK MESSAGES
|
||||
|
||||
void vnf_handle_nr_rx_data_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
// ensure it's valid
|
||||
if (pRecvMsg == NULL || vnf_p7 == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
|
||||
}
|
||||
else
|
||||
{
|
||||
nfapi_nr_rx_data_indication_t ind;
|
||||
|
||||
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void vnf_handle_nr_crc_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
// ensure it's valid
|
||||
if (pRecvMsg == NULL || vnf_p7 == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
|
||||
}
|
||||
else
|
||||
{
|
||||
nfapi_nr_crc_indication_t ind;
|
||||
|
||||
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void vnf_handle_nr_srs_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
// ensure it's valid
|
||||
if (pRecvMsg == NULL || vnf_p7 == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
|
||||
}
|
||||
else
|
||||
{
|
||||
nfapi_nr_srs_indication_t ind;
|
||||
|
||||
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void vnf_handle_nr_uci_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
// ensure it's valid
|
||||
if (pRecvMsg == NULL || vnf_p7 == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
|
||||
}
|
||||
else
|
||||
{
|
||||
nfapi_nr_uci_indication_t ind;
|
||||
|
||||
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vnf_handle_nr_rach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
// ensure it's valid
|
||||
if (pRecvMsg == NULL || vnf_p7 == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
|
||||
}
|
||||
else
|
||||
{
|
||||
nfapi_nr_rach_indication_t ind;
|
||||
|
||||
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
@@ -1485,358 +1581,368 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
// divide by 2 using shift operator
|
||||
uint32_t latency = (tx_2_rx - pnf_proc_time) >> 1;
|
||||
|
||||
if(!(phy->filtered_adjust))
|
||||
if(phy->in_sync == 0)
|
||||
{
|
||||
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",
|
||||
// phy->sfn, phy->slot, 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->slot_offset = (NFAPI_MAX_SFNSLOTDEC + ind.t2) - ind.t1 - latency;
|
||||
}
|
||||
else if (ind.t2 > phy->previous_t2 && ind.t1 < phy->previous_t1)
|
||||
{
|
||||
// Only t1 wrap has occurred
|
||||
phy->slot_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSLOTDEC) - latency;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Either no wrap or both have wrapped
|
||||
phy->slot_offset = ind.t2 - ind.t1 - latency;
|
||||
}
|
||||
|
||||
if (phy->slot_offset_filtered == 0)
|
||||
{
|
||||
phy->slot_offset_filtered = phy->slot_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t oldFilteredValueShifted = phy->slot_offset_filtered << 5;
|
||||
int32_t newOffsetShifted = phy->slot_offset << 5;
|
||||
|
||||
// 1/8 of new and 7/8 of old
|
||||
phy->slot_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",
|
||||
// phy->sfn, phy->slot, 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->slot_offset, phy->slot_offset_filtered,
|
||||
// (ind.t1<phy->previous_t1), (ind.t2<phy->previous_t2));
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (phy->filtered_adjust && (phy->slot_offset_filtered > 1e6 || phy->slot_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->slot_offset_filtered:%d\n", __FUNCTION__, phy->slot_offset_filtered);
|
||||
}
|
||||
phy->in_sync = 1;
|
||||
|
||||
if(phy->min_sync_cycle_count)
|
||||
phy->min_sync_cycle_count--;
|
||||
// if(!(phy->filtered_adjust))
|
||||
// {
|
||||
// phy->latency[phy->min_sync_cycle_count] = latency;
|
||||
|
||||
if(phy->min_sync_cycle_count == 0)
|
||||
{
|
||||
uint32_t curr_sfn = phy->sfn;
|
||||
uint32_t curr_slot = phy->slot;
|
||||
int32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(phy->sfn,phy->slot);
|
||||
// //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",
|
||||
// // phy->sfn, phy->slot, 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->filtered_adjust)
|
||||
{
|
||||
int i = 0;
|
||||
//phy->average_latency = 0;
|
||||
for(i = 0; i < SYNC_CYCLE_COUNT; ++i)
|
||||
{
|
||||
phy->average_latency += phy->latency[i];
|
||||
// //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->slot_offset = (NFAPI_MAX_SFNSLOTDEC + ind.t2) - ind.t1 - latency;
|
||||
// }
|
||||
// else if (ind.t2 > phy->previous_t2 && ind.t1 < phy->previous_t1)
|
||||
// {
|
||||
// // Only t1 wrap has occurred
|
||||
// phy->slot_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSLOTDEC) - latency;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Either no wrap or both have wrapped
|
||||
// phy->slot_offset = ind.t2 - ind.t1 - latency;
|
||||
// }
|
||||
|
||||
}
|
||||
phy->average_latency /= SYNC_CYCLE_COUNT;
|
||||
// if (phy->slot_offset_filtered == 0)
|
||||
// {
|
||||
// phy->slot_offset_filtered = phy->slot_offset;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// int32_t oldFilteredValueShifted = phy->slot_offset_filtered << 5;
|
||||
// int32_t newOffsetShifted = phy->slot_offset << 5;
|
||||
|
||||
phy->slot_offset = ind.t2 - (ind.t1 - phy->average_latency);
|
||||
// // 1/8 of new and 7/8 of old
|
||||
// phy->slot_offset_filtered = ((newOffsetShifted >> 3) + ((oldFilteredValueShifted * 7) >> 3)) >> 5;
|
||||
// }
|
||||
// }
|
||||
|
||||
sfn_slot_dec += (phy->slot_offset / 500);
|
||||
// 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",
|
||||
// // phy->sfn, phy->slot, 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->slot_offset, phy->slot_offset_filtered,
|
||||
// // (ind.t1<phy->previous_t1), (ind.t2<phy->previous_t2));
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// if (phy->filtered_adjust && (phy->slot_offset_filtered > 1e6 || phy->slot_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->slot_offset_filtered:%d\n", __FUNCTION__, phy->slot_offset_filtered);
|
||||
// }
|
||||
|
||||
// if(phy->min_sync_cycle_count)
|
||||
// phy->min_sync_cycle_count--;
|
||||
|
||||
// if(phy->min_sync_cycle_count == 0)
|
||||
// {
|
||||
// uint32_t curr_sfn = phy->sfn;
|
||||
// uint32_t curr_slot = phy->slot;
|
||||
// int32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(phy->sfn,phy->slot);
|
||||
|
||||
// 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->slot_offset = ind.t2 - (ind.t1 - phy->average_latency);
|
||||
|
||||
// sfn_slot_dec += (phy->slot_offset / 500);
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF slot offset:%d sfn :%d slot:%d \n",phy->slot_offset,NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec),NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec) );
|
||||
// //NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF slot offset:%d sfn :%d slot:%d \n",phy->slot_offset,NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec),NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec) );
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sfn_slot_dec += ((phy->slot_offset_filtered + 250) / 500); //Round up to go from microsecond to slot
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sfn_slot_dec += ((phy->slot_offset_filtered + 250) / 500); //Round up to go from microsecond to slot
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
if(sfn_slot_dec < 0)
|
||||
{
|
||||
sfn_slot_dec += NFAPI_MAX_SFNSLOTDEC;
|
||||
}
|
||||
else if( sfn_slot_dec >= NFAPI_MAX_SFNSLOTDEC)
|
||||
{
|
||||
sfn_slot_dec -= NFAPI_MAX_SFNSLOTDEC;
|
||||
}
|
||||
// if(sfn_slot_dec < 0)
|
||||
// {
|
||||
// sfn_slot_dec += NFAPI_MAX_SFNSLOTDEC;
|
||||
// }
|
||||
// else if( sfn_slot_dec >= NFAPI_MAX_SFNSLOTDEC)
|
||||
// {
|
||||
// sfn_slot_dec -= NFAPI_MAX_SFNSLOTDEC;
|
||||
// }
|
||||
|
||||
|
||||
uint16_t new_sfn = NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec);
|
||||
uint16_t new_slot = NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec);
|
||||
// uint16_t new_sfn = NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec);
|
||||
// uint16_t new_slot = NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec);
|
||||
|
||||
{
|
||||
phy->adjustment = NFAPI_SFNSLOT2DEC(new_sfn, new_slot) - NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot);
|
||||
// {
|
||||
// phy->adjustment = NFAPI_SFNSLOT2DEC(new_sfn, new_slot) - NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot);
|
||||
|
||||
//NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF phy_id:%d adjustment%d phy->previous_slot_offset_filtered:%d phy->previous_slot_offset_filtered:%d phy->slot_offset_trend:%d\n", ind.header.phy_id, phy->adjustment, phy->previous_slot_offset_filtered, phy->previous_slot_offset_filtered, phy->slot_offset_trend);
|
||||
// //NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF phy_id:%d adjustment%d phy->previous_slot_offset_filtered:%d phy->previous_slot_offset_filtered:%d phy->slot_offset_trend:%d\n", ind.header.phy_id, phy->adjustment, phy->previous_slot_offset_filtered, phy->previous_slot_offset_filtered, phy->slot_offset_trend);
|
||||
|
||||
phy->previous_t1 = 0;
|
||||
phy->previous_t2 = 0;
|
||||
// phy->previous_t1 = 0;
|
||||
// phy->previous_t2 = 0;
|
||||
|
||||
if(phy->previous_slot_offset_filtered > 0)
|
||||
{
|
||||
if( phy->slot_offset_filtered > phy->previous_slot_offset_filtered)
|
||||
{
|
||||
// pnf is getting futher ahead of vnf
|
||||
//phy->sf_offset_trend = phy->sf_offset_filtered - phy->previous_sf_offset_filtered;
|
||||
phy->slot_offset_trend = (phy->slot_offset_filtered + phy->previous_slot_offset_filtered)/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// pnf is getting back in sync
|
||||
}
|
||||
}
|
||||
else if(phy->previous_slot_offset_filtered < 0)
|
||||
{
|
||||
if(phy->slot_offset_filtered < phy->previous_slot_offset_filtered)
|
||||
{
|
||||
// vnf is getting future ahead of pnf
|
||||
//phy->sf_offset_trend = -(phy->sf_offset_filtered - phy->previous_sf_offset_filtered);
|
||||
phy->slot_offset_trend = (-(phy->slot_offset_filtered + phy->previous_slot_offset_filtered)) /2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// vnf is getting back in sync
|
||||
}
|
||||
}
|
||||
// if(phy->previous_slot_offset_filtered > 0)
|
||||
// {
|
||||
// if( phy->slot_offset_filtered > phy->previous_slot_offset_filtered)
|
||||
// {
|
||||
// // pnf is getting futher ahead of vnf
|
||||
// //phy->sf_offset_trend = phy->sf_offset_filtered - phy->previous_sf_offset_filtered;
|
||||
// phy->slot_offset_trend = (phy->slot_offset_filtered + phy->previous_slot_offset_filtered)/2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // pnf is getting back in sync
|
||||
// }
|
||||
// }
|
||||
// else if(phy->previous_slot_offset_filtered < 0)
|
||||
// {
|
||||
// if(phy->slot_offset_filtered < phy->previous_slot_offset_filtered)
|
||||
// {
|
||||
// // vnf is getting future ahead of pnf
|
||||
// //phy->sf_offset_trend = -(phy->sf_offset_filtered - phy->previous_sf_offset_filtered);
|
||||
// phy->slot_offset_trend = (-(phy->slot_offset_filtered + phy->previous_slot_offset_filtered)) /2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // vnf is getting back in sync
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
int insync_minor_adjustment_1 = phy->slot_offset_trend / 6;
|
||||
int insync_minor_adjustment_2 = phy->slot_offset_trend / 2;
|
||||
// int insync_minor_adjustment_1 = phy->slot_offset_trend / 6;
|
||||
// int insync_minor_adjustment_2 = phy->slot_offset_trend / 2;
|
||||
|
||||
|
||||
if(insync_minor_adjustment_1 == 0)
|
||||
insync_minor_adjustment_1 = 2;
|
||||
// if(insync_minor_adjustment_1 == 0)
|
||||
// insync_minor_adjustment_1 = 2;
|
||||
|
||||
if(insync_minor_adjustment_2 == 0)
|
||||
insync_minor_adjustment_2 = 10;
|
||||
// if(insync_minor_adjustment_2 == 0)
|
||||
// insync_minor_adjustment_2 = 10;
|
||||
|
||||
if(!phy->filtered_adjust)
|
||||
{
|
||||
if(phy->adjustment < 10)
|
||||
{
|
||||
phy->zero_count++;
|
||||
// if(!phy->filtered_adjust)
|
||||
// {
|
||||
// if(phy->adjustment < 10)
|
||||
// {
|
||||
// phy->zero_count++;
|
||||
|
||||
if(phy->zero_count >= 10)
|
||||
{
|
||||
phy->filtered_adjust = 1;
|
||||
phy->zero_count = 0;
|
||||
// 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);
|
||||
// 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);
|
||||
}
|
||||
// if(vnf_p7->_public.sync_indication)
|
||||
// (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), 1);
|
||||
// }
|
||||
|
||||
phy->in_sync = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
phy->zero_count++;
|
||||
}
|
||||
// phy->in_sync = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// phy->zero_count++;
|
||||
// }
|
||||
|
||||
if(phy->in_sync)
|
||||
{
|
||||
// in sync
|
||||
if(phy->slot_offset_filtered > 250)
|
||||
{
|
||||
// VNF is slow
|
||||
phy->insync_minor_adjustment = insync_minor_adjustment_1; //25;
|
||||
phy->insync_minor_adjustment_duration = ((phy->slot_offset_filtered) / insync_minor_adjustment_1);
|
||||
}
|
||||
else if(phy->slot_offset_filtered < -250)
|
||||
{
|
||||
// VNF is fast
|
||||
phy->insync_minor_adjustment = -(insync_minor_adjustment_1); //25;
|
||||
phy->insync_minor_adjustment_duration = (((phy->slot_offset_filtered) / -(insync_minor_adjustment_1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
phy->insync_minor_adjustment = 0;
|
||||
}
|
||||
// if(phy->in_sync)
|
||||
// {
|
||||
// // in sync
|
||||
// if(phy->slot_offset_filtered > 250)
|
||||
// {
|
||||
// // VNF is slow
|
||||
// phy->insync_minor_adjustment = insync_minor_adjustment_1; //25;
|
||||
// phy->insync_minor_adjustment_duration = ((phy->slot_offset_filtered) / insync_minor_adjustment_1);
|
||||
// }
|
||||
// else if(phy->slot_offset_filtered < -250)
|
||||
// {
|
||||
// // VNF is fast
|
||||
// phy->insync_minor_adjustment = -(insync_minor_adjustment_1); //25;
|
||||
// phy->insync_minor_adjustment_duration = (((phy->slot_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 slots (slot_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adjustment:%d\n",
|
||||
// phy->sfn, phy->slot, ind.header.phy_id,
|
||||
// phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration,
|
||||
// phy->slot_offset_filtered,
|
||||
// insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend,
|
||||
// NFAPI_SFNSLOT2DEC(new_sfn, new_slot),
|
||||
// NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot),
|
||||
// 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->slot_offset_filtered > 250)
|
||||
{
|
||||
// VNF is slow
|
||||
phy->insync_minor_adjustment = insync_minor_adjustment_2;
|
||||
phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered - 250) / insync_minor_adjustment_2);
|
||||
}
|
||||
else if(phy->slot_offset_filtered < -250)
|
||||
{
|
||||
// VNF is fast
|
||||
phy->insync_minor_adjustment = -(insync_minor_adjustment_2);
|
||||
phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered + 250) / -(insync_minor_adjustment_2));
|
||||
}
|
||||
// if(phy->insync_minor_adjustment != 0)
|
||||
// {
|
||||
// // NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (slot_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adjustment:%d\n",
|
||||
// // phy->sfn, phy->slot, ind.header.phy_id,
|
||||
// // phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration,
|
||||
// // phy->slot_offset_filtered,
|
||||
// // insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend,
|
||||
// // NFAPI_SFNSLOT2DEC(new_sfn, new_slot),
|
||||
// // NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot),
|
||||
// // 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->slot_offset_filtered > 250)
|
||||
// {
|
||||
// // VNF is slow
|
||||
// phy->insync_minor_adjustment = insync_minor_adjustment_2;
|
||||
// phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered - 250) / insync_minor_adjustment_2);
|
||||
// }
|
||||
// else if(phy->slot_offset_filtered < -250)
|
||||
// {
|
||||
// // VNF is fast
|
||||
// phy->insync_minor_adjustment = -(insync_minor_adjustment_2);
|
||||
// phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered + 250) / -(insync_minor_adjustment_2));
|
||||
// }
|
||||
|
||||
}
|
||||
//else
|
||||
{
|
||||
// out of sync?
|
||||
}
|
||||
// }
|
||||
// //else
|
||||
// {
|
||||
// // out of sync?
|
||||
// }
|
||||
|
||||
// NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (adjustment:%d slot_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adj:%d\n",
|
||||
// phy->sfn, phy->slot, ind.header.phy_id,
|
||||
// phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->slot_offset_filtered,
|
||||
// insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend,
|
||||
// NFAPI_SFNSLOT2DEC(new_sfn, new_slot),
|
||||
// NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot),
|
||||
// phy->adjustment);
|
||||
// // NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (adjustment:%d slot_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adj:%d\n",
|
||||
// // phy->sfn, phy->slot, ind.header.phy_id,
|
||||
// // phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->slot_offset_filtered,
|
||||
// // insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend,
|
||||
// // NFAPI_SFNSLOT2DEC(new_sfn, new_slot),
|
||||
// // NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot),
|
||||
// // phy->adjustment);
|
||||
|
||||
}
|
||||
else if(phy->adjustment < 0)
|
||||
{
|
||||
// VNF is fast
|
||||
//if(phy->adjustment == -1)
|
||||
{
|
||||
//
|
||||
if(phy->slot_offset_filtered > 250)
|
||||
{
|
||||
// VNF is slow
|
||||
phy->insync_minor_adjustment = insync_minor_adjustment_2;
|
||||
phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered - 250) / insync_minor_adjustment_2);
|
||||
}
|
||||
else if(phy->slot_offset_filtered < -250)
|
||||
{
|
||||
// VNF is fast
|
||||
phy->insync_minor_adjustment = -(insync_minor_adjustment_2);
|
||||
phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered + 250) / -(insync_minor_adjustment_2));
|
||||
}
|
||||
}
|
||||
//else
|
||||
{
|
||||
// out of sync?
|
||||
}
|
||||
// }
|
||||
// else if(phy->adjustment < 0)
|
||||
// {
|
||||
// // VNF is fast
|
||||
// //if(phy->adjustment == -1)
|
||||
// {
|
||||
// //
|
||||
// if(phy->slot_offset_filtered > 250)
|
||||
// {
|
||||
// // VNF is slow
|
||||
// phy->insync_minor_adjustment = insync_minor_adjustment_2;
|
||||
// phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered - 250) / insync_minor_adjustment_2);
|
||||
// }
|
||||
// else if(phy->slot_offset_filtered < -250)
|
||||
// {
|
||||
// // VNF is fast
|
||||
// phy->insync_minor_adjustment = -(insync_minor_adjustment_2);
|
||||
// phy->insync_minor_adjustment_duration = 2 * ((phy->slot_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 slots (adjustment:%d slot_offset_filtered:%d) %d %d %d\n",
|
||||
// phy->sfn, phy->slot, ind.header.phy_id,
|
||||
// phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->slot_offset_filtered,
|
||||
// insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend);
|
||||
}
|
||||
// // NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (adjustment:%d slot_offset_filtered:%d) %d %d %d\n",
|
||||
// // phy->sfn, phy->slot, ind.header.phy_id,
|
||||
// // phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->slot_offset_filtered,
|
||||
// // insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_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->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->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");*/
|
||||
// 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 = new_sfn;
|
||||
phy->slot = new_slot;
|
||||
}
|
||||
}
|
||||
// phy->sfn = new_sfn;
|
||||
// phy->slot = new_slot;
|
||||
// }
|
||||
// }
|
||||
|
||||
// reset for next cycle
|
||||
phy->previous_slot_offset_filtered = phy->slot_offset_filtered;
|
||||
phy->min_sync_cycle_count = 2;
|
||||
phy->slot_offset_filtered = 0;
|
||||
phy->slot_offset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
phy->previous_t1 = ind.t1;
|
||||
phy->previous_t2 = ind.t2;
|
||||
}
|
||||
}
|
||||
// // reset for next cycle
|
||||
// phy->previous_slot_offset_filtered = phy->slot_offset_filtered;
|
||||
// phy->min_sync_cycle_count = 2;
|
||||
// phy->slot_offset_filtered = 0;
|
||||
// phy->slot_offset = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// phy->previous_t1 = ind.t1;
|
||||
// phy->previous_t2 = ind.t2;
|
||||
// }
|
||||
}
|
||||
|
||||
void vnf_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
{
|
||||
@@ -2035,46 +2141,26 @@ void vnf_nr_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
vnf_nr_handle_timing_info(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
break;
|
||||
|
||||
case NFAPI_HARQ_INDICATION:
|
||||
vnf_handle_harq_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION:
|
||||
vnf_handle_nr_rx_data_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
break;
|
||||
|
||||
case NFAPI_CRC_INDICATION:
|
||||
vnf_handle_crc_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION:
|
||||
vnf_handle_nr_crc_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
break;
|
||||
|
||||
case NFAPI_RX_ULSCH_INDICATION:
|
||||
vnf_handle_rx_ulsch_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION:
|
||||
vnf_handle_nr_uci_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
break;
|
||||
|
||||
case NFAPI_RACH_INDICATION:
|
||||
vnf_handle_rach_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
|
||||
vnf_handle_nr_rach_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
break;
|
||||
|
||||
case NFAPI_SRS_INDICATION:
|
||||
vnf_handle_srs_indication(pRecvMsg, recvMsgLen, vnf_p7);
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
vnf_handle_nr_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;
|
||||
|
||||
@@ -430,18 +430,6 @@ struct timespec current_time;
|
||||
}
|
||||
send_mac_slot_indications(vnf_p7);
|
||||
|
||||
|
||||
|
||||
// // Call the scheduler
|
||||
// struct PHY_VARS_gNB_s *gNB = RC.gNB[0];
|
||||
// pthread_mutex_lock(&gNB->UL_INFO_mutex);
|
||||
// gNB->UL_INFO.frame = vnf_frame;
|
||||
// gNB->UL_INFO.slot = vnf_slot;
|
||||
|
||||
// gNB->UL_INFO.module_id = gNB->Mod_id;
|
||||
// gNB->UL_INFO.CC_id = gNB->CC_id;
|
||||
// gNB->if_inst->NR_UL_indication(&gNB->UL_INFO);
|
||||
// pthread_mutex_unlock(&gNB->UL_INFO_mutex);
|
||||
}
|
||||
else if(selectRetval > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user