Hardcodings removed fully, system runs but unstable
This commit is contained in:
@@ -4126,7 +4126,7 @@ static uint8_t unpack_dl_tti_pdsch_pdu_rel15_value(void* tlv, uint8_t **ppReadPa
|
||||
|
||||
static uint8_t unpack_dl_tti_ssb_pdu_rel15_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
|
||||
{
|
||||
printf("ssb received and unpacked. \n");
|
||||
//printf("ssb received and unpacked. \n");
|
||||
nfapi_nr_dl_tti_ssb_pdu_rel15_t* value = (nfapi_nr_dl_tti_ssb_pdu_rel15_t*)tlv;
|
||||
|
||||
return(
|
||||
@@ -6429,7 +6429,6 @@ static uint8_t unpack_nr_crc_indication(uint8_t **ppReadPackedMsg, uint8_t *end,
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Done \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -935,9 +935,9 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
|
||||
// save the curren time, sfn and slot
|
||||
pnf_p7->slot_start_time_hr = pnf_get_current_time_hr();
|
||||
// pnf_p7->sfn = sfn;
|
||||
pnf_p7->sfn = sfn;
|
||||
|
||||
// pnf_p7->slot = slot;
|
||||
pnf_p7->slot = slot;
|
||||
|
||||
|
||||
|
||||
@@ -1559,26 +1559,23 @@ uint8_t is_nr_p7_request_in_window(uint16_t sfn,uint16_t slot, const char* name,
|
||||
// }
|
||||
|
||||
// }
|
||||
struct timespec curr_time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &curr_time);
|
||||
printf("PNF SFN:%d, PNF slot:%d, VNF SFN:%d, VNF slot:%d, SFN offset:%d, Curr time;%d.%d. \n",phy->sfn,phy->slot,sfn,slot, phy->sfn - sfn,curr_time.tv_sec,curr_time.tv_nsec);
|
||||
if(current_sfn_slot_dec <= recv_sfn_slot_dec + timing_window){
|
||||
in_window = 1;
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is in window %d\n", current_sfn_slot_dec, name, recv_sfn_slot_dec);
|
||||
//NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is in window %d\n", current_sfn_slot_dec, name, recv_sfn_slot_dec);
|
||||
}
|
||||
else if(current_sfn_slot_dec + NFAPI_MAX_SFNSLOTDEC <= recv_sfn_slot_dec + timing_window){ //checking for wrap
|
||||
in_window = 1;
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is in window %d\n", current_sfn_slot_dec, name, recv_sfn_slot_dec);
|
||||
//NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is in window %d\n", current_sfn_slot_dec, name, recv_sfn_slot_dec);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
//NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is out of window %d (delta:%d) [max:%d]\n", current_sfn_slot_dec, name, recv_sfn_slot_dec, (current_sfn_slot_dec - recv_sfn_slot_dec), timing_window);
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is out of window %d (delta:%d) [max:%d]\n", current_sfn_slot_dec, name, recv_sfn_slot_dec, (current_sfn_slot_dec - recv_sfn_slot_dec), timing_window);
|
||||
|
||||
}//Need to add more cases
|
||||
|
||||
in_window = 0; // gokul
|
||||
|
||||
return in_window;
|
||||
}
|
||||
|
||||
@@ -1848,7 +1845,7 @@ void pnf_handle_ul_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7)
|
||||
struct timespec t;
|
||||
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE UL_TTI_REQ sfn_slot:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_slot_dec, buffer_index);
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE UL_TTI_REQ sfn_slot:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_slot_dec, buffer_index);
|
||||
|
||||
if(pnf_p7->slot_buffer[buffer_index].ul_tti_req != 0)
|
||||
{
|
||||
@@ -2133,7 +2130,7 @@ void pnf_handle_tx_data_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7
|
||||
struct timespec t;
|
||||
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE TX_DATA_REQ sfn_sf:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_slot_dec, buffer_index);
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE TX_DATA_REQ sfn_sf:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_slot_dec, buffer_index);
|
||||
#if 0
|
||||
if (0 && NFAPI_SFNSF2DEC(req->sfn_sf)%100==0) NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX_REQ.req sfn_sf:%d pdus:%d - TX_REQ is within window\n",
|
||||
__FUNCTION__,
|
||||
@@ -3202,43 +3199,9 @@ int pnf_p7_message_pump(pnf_p7_t* pnf_p7)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct timespec pnf_timespec_add(struct timespec lhs, struct timespec rhs)
|
||||
{
|
||||
struct timespec result;
|
||||
|
||||
result.tv_sec = lhs.tv_sec + rhs.tv_sec;
|
||||
result.tv_nsec = lhs.tv_nsec + rhs.tv_nsec;
|
||||
|
||||
if(result.tv_nsec > 1e9)
|
||||
{
|
||||
result.tv_sec++;
|
||||
result.tv_nsec-= 1e9;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
struct timespec pnf_timespec_sub(struct timespec lhs, struct timespec rhs)
|
||||
{
|
||||
struct timespec result;
|
||||
if ((lhs.tv_nsec-rhs.tv_nsec)<0)
|
||||
{
|
||||
result.tv_sec = lhs.tv_sec-rhs.tv_sec-1;
|
||||
result.tv_nsec = 1000000000+lhs.tv_nsec-rhs.tv_nsec;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.tv_sec = lhs.tv_sec-rhs.tv_sec;
|
||||
result.tv_nsec = lhs.tv_nsec-rhs.tv_nsec;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
|
||||
{
|
||||
|
||||
uint16_t pnf_frame = 0;
|
||||
uint8_t pnf_slot = 0;
|
||||
// initialize the mutex lock
|
||||
if(pthread_mutex_init(&(pnf_p7->mutex), NULL) != 0)
|
||||
{
|
||||
@@ -3311,23 +3274,6 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
|
||||
}
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 bind succeeded...\n");
|
||||
|
||||
//Initializaing timing structures needed for slot ticking
|
||||
|
||||
struct timespec slot_start;
|
||||
clock_gettime(CLOCK_MONOTONIC, &slot_start);
|
||||
|
||||
struct timespec pselect_start;
|
||||
|
||||
struct timespec timeout;
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_nsec = 500000;
|
||||
|
||||
struct timespec slot_duration;
|
||||
slot_duration.tv_sec = 0;
|
||||
slot_duration.tv_nsec = 0.5e6;
|
||||
|
||||
//Infinite loop
|
||||
|
||||
while(pnf_p7->terminate == 0)
|
||||
{
|
||||
fd_set rfds;
|
||||
@@ -3337,26 +3283,11 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(pnf_p7->p7_sock, &rfds);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &pselect_start);
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 100;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
//setting the timeout
|
||||
|
||||
if((pselect_start.tv_sec > slot_start.tv_sec) || ((pselect_start.tv_sec == slot_start.tv_sec) && (pselect_start.tv_nsec > slot_start.tv_nsec)))
|
||||
{
|
||||
// overran the end of the subframe we do not want to wait
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_nsec = 0;
|
||||
|
||||
//struct timespec overrun = pnf_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
|
||||
timeout = pnf_timespec_sub(slot_start, pselect_start);
|
||||
}
|
||||
|
||||
selectRetval = pselect(pnf_p7->p7_sock+1, &rfds, NULL, NULL, &timeout, NULL);
|
||||
selectRetval = select(pnf_p7->p7_sock+1, &rfds, NULL, NULL, &timeout);
|
||||
|
||||
uint32_t now_hr_time = pnf_get_current_time_hr();
|
||||
|
||||
@@ -3366,19 +3297,7 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
|
||||
if(selectRetval == 0)
|
||||
{
|
||||
// timeout
|
||||
|
||||
//update slot start timing
|
||||
slot_start = pnf_timespec_add(slot_start, slot_duration);
|
||||
|
||||
//increment sfn/slot
|
||||
if (pnf_slot == 19)
|
||||
pnf_frame = (pnf_frame + 1) % 1024;
|
||||
pnf_slot = (pnf_slot + 1) % 20;
|
||||
pnf_p7->sfn = pnf_frame;
|
||||
pnf_p7->slot = pnf_slot;
|
||||
|
||||
struct timespec curr_time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &curr_time);
|
||||
continue;
|
||||
}
|
||||
else if (selectRetval == -1 && (errno == EINTR))
|
||||
{
|
||||
@@ -3396,7 +3315,7 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
|
||||
if(FD_ISSET(pnf_p7->p7_sock, &rfds))
|
||||
|
||||
{
|
||||
pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time);
|
||||
pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time);
|
||||
}
|
||||
}
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF_P7 Terminating..\n");
|
||||
|
||||
@@ -457,7 +457,7 @@ int send_mac_subframe_indications(vnf_p7_t* vnf_p7)
|
||||
int vnf_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info, uint8_t* msg, const uint32_t len)
|
||||
{
|
||||
int sendto_result = sendto(vnf_p7->socket, msg, len, 0, (struct sockaddr*)&(p7_info->remote_addr), sizeof(p7_info->remote_addr));
|
||||
//printf("\nSending p7 message sfn=%d,slot=%d\n",vnf_p7->p7_connections->sfn,vnf_p7->p7_connections->slot);
|
||||
//printf("P7 msg sent \n");
|
||||
if(sendto_result != len)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sendto_result %d %d\n", __FUNCTION__, sendto_result, errno);
|
||||
@@ -534,7 +534,7 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t*
|
||||
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);
|
||||
//printf("segment %d \n", segment);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -551,7 +551,6 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t*
|
||||
}
|
||||
|
||||
p7_connection->sequence_number++;
|
||||
|
||||
return send_result;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -97,7 +97,7 @@ struct timespec timespec_sub(struct timespec lhs, struct timespec rhs)
|
||||
// send indications to mac
|
||||
int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config)
|
||||
{
|
||||
uint16_t vnf_frame; uint8_t vnf_slot;
|
||||
uint16_t vnf_frame; uint8_t vnf_slot; uint16_t slot_scheduled;
|
||||
if(config == 0)
|
||||
return -1;
|
||||
|
||||
@@ -265,6 +265,21 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config)
|
||||
}
|
||||
*/
|
||||
|
||||
if(setup_time > 10 && slot_scheduled == 0){
|
||||
|
||||
// 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);
|
||||
//printf("Scheduler called at SFN/slot %d.%d. \n",vnf_frame,vnf_slot);
|
||||
slot_scheduled = 1;
|
||||
}
|
||||
|
||||
//long wraps = pselect_timeout.tv_nsec % 1e9;
|
||||
|
||||
@@ -410,18 +425,18 @@ struct timespec current_time;
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||
// pselect timed out
|
||||
|
||||
if(setup_time > 10){
|
||||
// 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;
|
||||
// if(setup_time > 10){
|
||||
// // 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);
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
|
||||
while(curr != 0)
|
||||
{
|
||||
@@ -437,7 +452,7 @@ struct timespec current_time;
|
||||
{
|
||||
curr->slot++;
|
||||
}
|
||||
printf("Frame = %d, slot = %d in VNF main loop. \n",curr->sfn,curr->slot);
|
||||
//printf("Frame = %d, slot = %d in VNF main loop. \n",curr->sfn,curr->slot);
|
||||
vnf_frame = curr->sfn; vnf_slot = curr->slot;
|
||||
|
||||
struct timespec curr_time;
|
||||
@@ -450,17 +465,14 @@ struct timespec current_time;
|
||||
curr = curr->next;
|
||||
}
|
||||
send_mac_slot_indications(vnf_p7);
|
||||
|
||||
slot_scheduled = 0;
|
||||
}
|
||||
else if(selectRetval > 0)
|
||||
{
|
||||
// have a p7 message
|
||||
if(FD_ISSET(vnf_p7->socket, &rfds))
|
||||
{
|
||||
printf("P7 message received \n");
|
||||
vnf_nr_p7_read_dispatch_message(vnf_p7);
|
||||
|
||||
|
||||
vnf_nr_p7_read_dispatch_message(vnf_p7);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -902,7 +914,6 @@ int nfapi_vnf_p7_ul_tti_req(nfapi_vnf_p7_config_t* config, nfapi_nr_ul_tti_reque
|
||||
{
|
||||
if(config == 0 || req == 0)
|
||||
return -1;
|
||||
|
||||
vnf_p7_t* vnf_p7 = (vnf_p7_t*)config;
|
||||
return vnf_nr_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user