Commit bc123817 authored by wujing's avatar wujing

fix L2 FAPI Simulator by diable mimo-vnf

parent 61e60919
......@@ -920,7 +920,9 @@ int vnf_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_
static pthread_t vnf_start_pthread;
static pthread_t vnf_p7_start_pthread;
#ifdef PHY_RM
static pthread_t vnf_p7_time_pthread;
#endif
void *vnf_p7_start_thread(void *ptr) {
printf("%s()\n", __FUNCTION__);
......@@ -929,7 +931,7 @@ void *vnf_p7_start_thread(void *ptr) {
nfapi_vnf_p7_start(config);
return config;
}
#ifdef PHY_RM
void* vnf_p7_time_thread(void *ptr) {
printf("%s()\n", __FUNCTION__);
......@@ -949,7 +951,7 @@ void* vnf_p7_time_thread(void *ptr) {
nfapi_vnf_p7_time(config);
return config;
}
#endif
void set_thread_priority(int priority);
void *vnf_p7_thread_start(void *ptr) {
......@@ -984,7 +986,9 @@ void *vnf_p7_thread_start(void *ptr) {
p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__);
pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config);
#ifdef PHY_RM
pthread_create(&vnf_p7_time_pthread, NULL, &vnf_p7_time_thread, p7_vnf->config);
#endif
return 0;
}
......@@ -1279,7 +1283,7 @@ int oai_nfapi_ue_release_req(nfapi_ue_release_request_t *release_req){
}
return retval;
}
#ifdef PHY_RM
int oai_nfapi_phy_rm_start_req(nfapi_phy_rm_start_request_t *rm_start_req){
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
......@@ -1295,3 +1299,4 @@ int oai_nfapi_phy_rm_start_req(nfapi_phy_rm_start_request_t *rm_start_req){
}
return retval;
}
#endif
......@@ -148,7 +148,9 @@ typedef enum {
NFAPI_NRACH_INDICATION,
NFAPI_UE_RELEASE_REQUEST,
NFAPI_UE_RELEASE_RESPONSE,
NFAPI_PHY_RM_START_REQUEST,
#ifdef PHY_RM
NFAPI_PHY_RM_START_REQUEST,
#endif
NFAPI_PNF_PARAM_REQUEST = 0x0100,
NFAPI_PNF_PARAM_RESPONSE,
......@@ -3446,13 +3448,13 @@ typedef struct {
uint32_t error_code;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_ue_release_response_t;
#ifdef PHY_RM
typedef struct {
nfapi_p7_message_header_t header;
uint16_t sfn_sf;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_phy_rm_start_request_t;
#endif
//
// P4 Messages
//
......
......@@ -2653,7 +2653,7 @@ static uint8_t pack_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *
pushs32(pNfapiMsg->hi_dci0_earliest_arrival, ppWritePackedMsg, end) &&
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
#ifdef PHY_RM
static uint8_t pack_phy_rm_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
{
nfapi_phy_rm_start_request_t *pNfapiMsg = (nfapi_phy_rm_start_request_t*)msg;
......@@ -2661,7 +2661,7 @@ static uint8_t pack_phy_rm_start_request(void *msg, uint8_t **ppWritePackedMsg,
int y = pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
return x && y;
}
#endif
// Main pack function - public
int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config)
......@@ -2722,11 +2722,11 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu
case NFAPI_UE_RELEASE_RESPONSE:
result =pack_ue_release_response(pMessageHeader, &pWritePackedMessage, end, config);
break;
#ifdef PHY_RM
case NFAPI_PHY_RM_START_REQUEST:
result =pack_phy_rm_start_request(pMessageHeader, &pWritePackedMessage, end, config);
break;
#endif
case NFAPI_HARQ_INDICATION:
result = pack_harq_indication(pMessageHeader, &pWritePackedMessage, end, config);
break;
......@@ -5956,7 +5956,7 @@ static uint8_t unpack_timing_info(uint8_t **ppReadPackedMsg, uint8_t *end, void
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));
}
#ifdef PHY_RM
static uint8_t unpack_phy_rm_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config)
{
uint8_t proceed = 1;
......@@ -5968,7 +5968,7 @@ static uint8_t unpack_phy_rm_start_request(uint8_t **ppReadPackedMsg, uint8_t *e
return 1;
}
#endif
// unpack length check
static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen)
......@@ -6081,12 +6081,12 @@ static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen
if (unpackedBufLen >= sizeof(nfapi_ue_release_response_t))
retLen = sizeof(nfapi_ue_release_response_t);
break;
#ifdef PHY_RM
case NFAPI_PHY_RM_START_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_phy_rm_start_request_t))
retLen = sizeof(nfapi_phy_rm_start_request_t);
break;
#endif
default:
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown message ID %d\n", msgId);
break;
......@@ -6213,12 +6213,12 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
else
return -1;
break;
#ifdef PHY_RM
case NFAPI_PHY_RM_START_REQUEST:
if (check_unpack_length(NFAPI_PHY_RM_START_REQUEST, unpackedBufLen))
result = unpack_phy_rm_start_request(&pReadPackedMessage, end, pMessageHeader, config);
break;
#endif
case NFAPI_HARQ_INDICATION:
if (check_unpack_length(NFAPI_HARQ_INDICATION, unpackedBufLen))
result = unpack_harq_indication(&pReadPackedMessage, end, pMessageHeader, config);
......
......@@ -111,15 +111,19 @@ typedef struct {
nfapi_vnf_p7_connection_info_t* p7_connections;
int socket;
uint32_t sf_start_time_hr;
#ifdef PHY_RM
uint32_t sf_start_time_hr_old;
#endif
uint8_t* rx_message_buffer; // would this be better put in the p7 conenction info?
uint16_t rx_message_buffer_size;
#ifdef PHY_RM
struct timespec sf_corr_tim;
uint8_t vnf_extend_flg;
uint8_t sf_duration_correct_flg;
uint32_t fapi_1ms_fd_list[6];
fd_set watchset;
uint32_t maxfd;
#endif
} vnf_p7_t;
uint32_t vnf_get_current_time_hr(void);
......
......@@ -883,9 +883,9 @@ void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config);
*/
int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config);
#ifdef PHY_RM
int nfapi_vnf_p7_time(nfapi_vnf_p7_config_t* config);
#endif
/*! Stop the VNF P7 library.
* \param config A pointer to an vnf p7 configuration structure
* \return A status value. 0 equal success, -1 indicates failure
......@@ -999,7 +999,7 @@ int nfapi_vnf_p7_vendor_extension(nfapi_vnf_p7_config_t* config, nfapi_p7_messag
* may be released after this function call has returned or at a later pointer
*/
int nfapi_vnf_p7_ue_release_req(nfapi_vnf_p7_config_t* config, nfapi_ue_release_request_t* req);
#ifdef PHY_RM
/*! Send the PHY_RM_START.request
* \param config A pointer to the vnf p7 configuration
* \param req A data structure for the decoded PHY_RM_START.request.
......@@ -1009,6 +1009,7 @@ int nfapi_vnf_p7_ue_release_req(nfapi_vnf_p7_config_t* config, nfapi_ue_release_
* may be released after this function call has returned or at a later pointer
*/
int nfapi_vnf_p7_phy_rm_start_req(nfapi_vnf_p7_config_t* config, nfapi_phy_rm_start_request_t* req);
#endif
#if defined(__cplusplus)
}
#endif
......
......@@ -27,6 +27,7 @@
#include <errno.h>
#include <stdio.h>
#ifdef PHY_RM
#include <stdint.h>
#include <sys/un.h>
#include <sys/signalfd.h>
......@@ -35,8 +36,9 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <pthread.h>
#endif
#include "vnf.h"
#ifdef PHY_RM
#include "vnf_p7.h"
typedef struct {
......@@ -160,7 +162,7 @@ typedef struct {
vnf_p7_info p7_vnfs[2];
} vnf_info;
#endif
nfapi_vnf_config_t* nfapi_vnf_config_create()
{
......@@ -192,7 +194,7 @@ void nfapi_vnf_config_destory(nfapi_vnf_config_t* config)
{
free(config);
}
#ifdef PHY_RM
void init_server_eventfd(int *watch_fd_list, int client_num, char *path)
{
// eventfd server
......@@ -267,7 +269,7 @@ void init_server_eventfd(int *watch_fd_list, int client_num, char *path)
}
}
}
#endif
int nfapi_vnf_start(nfapi_vnf_config_t* config)
{
// Verify that config is not null
......@@ -585,7 +587,7 @@ int nfapi_vnf_start(nfapi_vnf_config_t* config)
}
}
}
#ifdef PHY_RM
int fd[6];
const char *path = "/tmp/oai_fapi_1ms";
char idx[2];
......@@ -608,6 +610,7 @@ int nfapi_vnf_start(nfapi_vnf_config_t* config)
vnf_p7->maxfd = vnf_p7->fapi_1ms_fd_list[0];
FD_SET(vnf_p7->fapi_1ms_fd_list[0], &(vnf_p7->watchset));
#endif
}
else
{
......@@ -894,8 +897,11 @@ int nfapi_vnf_allocate_phy(nfapi_vnf_config_t* config, int p5_idx, uint16_t* phy
info->timing_window = 30; // This seems to override what gets set by the user - why???
info->timing_info_mode = 0x03;
info->timing_info_period = 32;
#ifdef PHY_RM
info->timing_info_period = 32
#else;
info->timing_info_period = 128;
#endif
nfapi_vnf_phy_info_list_add(config, info);
(*phy_id) = info->phy_id;
......
......@@ -22,13 +22,13 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#ifdef PHY_RM
#include <stdio.h>
#endif
#include "vnf_p7.h"
#define SYNC_CYCLE_COUNT 2
#ifdef PHY_RM
extern uint8_t* vnf_msg_ptr;
extern uint8_t* vnf_msg_buf_ptr;
......@@ -61,7 +61,7 @@ void* vnf_get_memory_segment_ptr(uint8_t segment_num)
{
return (vnf_msg_buf_ptr + segment_num * 1024 * 16);
}
#endif
void* vnf_p7_malloc(vnf_p7_t* vnf_p7, size_t size)
{
if(vnf_p7->_public.malloc)
......@@ -177,9 +177,11 @@ vnf_p7_rx_message_t* vnf_p7_rx_reassembly_queue_add_segment(vnf_p7_t* vnf_p7, vn
// if found then copy data to message
if(msg != 0)
{
// msg->segments[segment_number].buffer = (uint8_t*)vnf_p7_malloc(vnf_p7, data_len);
#ifndef PHY_RM
msg->segments[segment_number].buffer = (uint8_t*)vnf_p7_malloc(vnf_p7, data_len);
#else
msg->segments[segment_number].buffer = (uint8_t*)vnf_get_memory_segment_ptr(segment_number);
#endif
memcpy(msg->segments[segment_number].buffer, data, data_len);
msg->segments[segment_number].length = data_len;
......@@ -193,17 +195,22 @@ vnf_p7_rx_message_t* vnf_p7_rx_reassembly_queue_add_segment(vnf_p7_t* vnf_p7, vn
else
{
// create a new message
// msg = (vnf_p7_rx_message_t*)(vnf_p7_malloc(vnf_p7, sizeof(vnf_p7_rx_message_t)));
#ifndef PHY_RM
msg = (vnf_p7_rx_message_t*)(vnf_p7_malloc(vnf_p7, sizeof(vnf_p7_rx_message_t)));
#else
msg = (vnf_p7_rx_message_t*)vnf_msg_ptr;
#endif
memset(msg, 0, sizeof(vnf_p7_rx_message_t));
msg->sequence_number = sequence_number;
msg->num_segments_expected = m ? 255 : segment_number + 1;
msg->num_segments_received = 1;
msg->rx_hr_time = vnf_get_current_time_hr();
// msg->segments[segment_number].buffer = (uint8_t*)vnf_p7_malloc(vnf_p7, data_len);
#ifndef PHY_RM
msg->segments[segment_number].buffer = (uint8_t*)vnf_p7_malloc(vnf_p7, data_len);
#else
msg->segments[segment_number].buffer = (uint8_t*)vnf_get_memory_segment_ptr(segment_number);
#endif
memcpy(msg->segments[segment_number].buffer, data, data_len);
msg->segments[segment_number].length = data_len;
......@@ -254,8 +261,9 @@ void vnf_p7_rx_reassembly_queue_remove_msg(vnf_p7_t* vnf_p7, vnf_p7_rx_reassembl
void vnf_p7_rx_reassembly_queue_remove_old_msgs(vnf_p7_t* vnf_p7, vnf_p7_rx_reassembly_queue_t* queue, uint32_t delta)
{
#ifdef PHY_RM
uint32_t diff_usec;
#endif
// remove all messages that are too old
vnf_p7_rx_message_t* iterator = queue->msg_queue;
vnf_p7_rx_message_t* previous = 0;
......@@ -264,9 +272,13 @@ void vnf_p7_rx_reassembly_queue_remove_old_msgs(vnf_p7_t* vnf_p7, vnf_p7_rx_reas
while(iterator != 0)
{
#ifdef PHY_RM
diff_usec = vnf_get_diff_time_hr(rx_hr_time, iterator->rx_hr_time);
if(diff_usec > delta)
#else
if(rx_hr_time - iterator->rx_hr_time > delta)
#endif
{
if(previous == 0)
{
......@@ -368,17 +380,25 @@ static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_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();
#ifdef PHY_RM
uint32_t t1 = get_sf_time(now_time_hr, sf_start_time_hr);
#else
uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr);
uint32_t t1 = get_sf_time(now_time_hr, sf_start_time_hr);
uint32_t t1 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us;
#endif
return t1;
}
uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr)
{
uint32_t t4 = get_sf_time(now_time_hr, sf_start_time_hr);
#ifdef PHY_RM
uint32_t t4 = get_sf_time(now_time_hr, sf_start_time_hr);
#else
uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr);
uint32_t t4 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us;
#endif
return t4;
}
......@@ -595,9 +615,10 @@ void vnf_handle_harq_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
(vnf_p7->_public.harq_indication)(&(vnf_p7->_public), &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.harq_indication_body.harq_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.harq_indication_body.harq_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
......@@ -623,9 +644,10 @@ void vnf_handle_crc_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
(vnf_p7->_public.crc_indication)(&(vnf_p7->_public), &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.crc_indication_body.crc_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.crc_indication_body.crc_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
......@@ -685,10 +707,10 @@ void vnf_handle_rach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
(vnf_p7->_public.rach_indication)(&vnf_p7->_public, &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.rach_indication_body.preamble_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.rach_indication_body.preamble_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
......@@ -714,9 +736,10 @@ void vnf_handle_srs_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
(vnf_p7->_public.srs_indication)(&(vnf_p7->_public), &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.srs_indication_body.srs_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.srs_indication_body.srs_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
......@@ -742,9 +765,10 @@ void vnf_handle_rx_sr_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p
(vnf_p7->_public.sr_indication)(&(vnf_p7->_public), &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.sr_indication_body.sr_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.sr_indication_body.sr_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
void vnf_handle_rx_cqi_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
......@@ -769,11 +793,11 @@ void vnf_handle_rx_cqi_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_
(vnf_p7->_public.cqi_indication)(&(vnf_p7->_public), &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.cqi_indication_body.cqi_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.cqi_indication_body.cqi_raw_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.cqi_indication_body.cqi_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.cqi_indication_body.cqi_raw_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
......@@ -800,9 +824,10 @@ void vnf_handle_lbt_dl_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_
(vnf_p7->_public.lbt_dl_indication)(&(vnf_p7->_public), &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.lbt_dl_indication_body.lbt_indication_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.lbt_dl_indication_body.lbt_indication_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
......@@ -828,9 +853,10 @@ void vnf_handle_nb_harq_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf
(vnf_p7->_public.nb_harq_indication)(&(vnf_p7->_public), &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.nb_harq_indication_body.nb_harq_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.nb_harq_indication_body.nb_harq_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
......@@ -856,9 +882,10 @@ void vnf_handle_nrach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p
(vnf_p7->_public.nrach_indication)(&(vnf_p7->_public), &ind);
}
}
//vnf_p7_codec_free(vnf_p7, ind.nrach_indication_body.nrach_pdu_list);
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#ifndef PHY_RM
vnf_p7_codec_free(vnf_p7, ind.nrach_indication_body.nrach_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
#endif
}
}
......@@ -946,7 +973,7 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
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;
#ifdef PHY_RM
//calculate pnf-vnf subframe boundary difference
int32_t diff = (int32_t)((int32_t)ind.t3 - (int32_t)t4);
int32_t latency_2 = (int32_t)(((int32_t)t4 - (int32_t)ind.t1) - ((int32_t)ind.t3 - (int32_t)ind.t2)) / 2;
......@@ -979,7 +1006,7 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
fclose(fp);
#endif
#endif
// divide by 2 using shift operator
uint32_t latency = (tx_2_rx - pnf_proc_time) >> 1;
......@@ -1596,15 +1623,15 @@ int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n");
return -1;
}
#ifndef PHY_RM
// 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;
//}
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;
}
#endif
// 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);
......@@ -1616,7 +1643,7 @@ int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
}
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);
NFAPI_TRACE(NFAPI_TRACE_NOTE, "did not receive the entire message %d %d %d\n", recvfrom_result, header.message_length, header.message_id);
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);
......
......@@ -29,6 +29,7 @@
#include "vnf_p7.h"
#define FAPI2_IP_DSCP 0
#ifdef PHY_RM
#define SF_BAND_CORRECT_200US 200000
#define SF_BAND_CORRECT_500US 500000
......@@ -43,7 +44,7 @@ uint8_t* vnf_msg_buf_ptr;
uint8_t vnf_reassembly_flg = 0;
//#define LOG
#endif
nfapi_vnf_p7_config_t* nfapi_vnf_p7_config_create()
{
vnf_p7_t* _this = (vnf_p7_t*)calloc(1, sizeof(vnf_p7_t));
......@@ -145,7 +146,6 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config)
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)
......@@ -162,15 +162,29 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config)
struct timespec pselect_timeout;
pselect_timeout.tv_sec = 0;
pselect_timeout.tv_nsec = 1000000; // ns in a 1 us
#ifdef PHY_RM
vnf_msg_ptr = (uint8_t *)malloc(VNF_MSG_SIZE);
vnf_msg_buf_ptr = (uint8_t *)malloc(VNF_MSG_BUF_SIZE);
vnf_p7->rx_message_buffer = (uint8_t*)malloc(VNF_RX_MESSAGE_BUF_SIZE);
vnf_p7->rx_message_buffer_size = VNF_RX_MESSAGE_BUF_SIZE;
#else
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);
#endif
while(vnf_p7->terminate == 0)
{
fd_set rfds;
......@@ -183,7 +197,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config)
maxSock = vnf_p7->socket;
//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);
#ifdef PHY_RM
selectRetval = pselect(maxSock+1, &rfds, NULL, NULL, &pselect_timeout, NULL);
nfapi_vnf_p7_connection_info_t* phy = vnf_p7->p7_connections;
......@@ -194,39 +208,142 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config)
phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment);
}
if(selectRetval > 0)
{
if((vnf_reassembly_flg == 0) && (phy != 0))
if(selectRetval > 0)
{
if((vnf_reassembly_flg == 0) && (phy != 0))
{
phy->reassembly_buffer = (uint8_t*)malloc(VNF_REASSEMBY_BUF_SIZE);
phy->reassembly_buffer_size = VNF_REASSEMBY_BUF_SIZE;
vnf_reassembly_flg = 1;
}
// have a p7 message
if(FD_ISSET(vnf_p7->socket, &rfds))
{
vnf_p7_read_dispatch_message(vnf_p7);
}
} else if(selectRetval < 0)
{
// 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\n", selectRetval, errno, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, pselect_timeout.tv_sec, pselect_timeout.tv_nsec);
// should we exit now?
if (selectRetval == -1 && errno == 22) // invalid argument??? not sure about timeout duration
{
usleep(100000);
}
}
}
#else
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) )
{
phy->reassembly_buffer = (uint8_t*)malloc(VNF_REASSEMBY_BUF_SIZE);
phy->reassembly_buffer_size = VNF_REASSEMBY_BUF_SIZE;
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;
vnf_reassembly_flg = 1;
} else {
// still time before the end of the subframe wait
pselect_timeout = timespec_sub(sf_start, pselect_start);
}
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 (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;
}
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;
}
}
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;
}
// have a p7 message
if(FD_ISSET(vnf_p7->socket, &rfds))
{
vnf_p7_read_dispatch_message(vnf_p7);
}
}
else if(selectRetval < 0)
{
// 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\n", selectRetval, errno, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, pselect_timeout.tv_sec, pselect_timeout.tv_nsec);
// should we exit now?
if (selectRetval == -1 && errno == 22) // invalid argument??? not sure about timeout duration
{
usleep(100000);
}
}
}
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);
}
}
}
#endif
}
......@@ -238,7 +355,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config)
return 0;
}
#ifdef PHY_RM
int nfapi_vnf_p7_time(nfapi_vnf_p7_config_t* config){
#ifdef LOG
......@@ -378,7 +495,7 @@ int nfapi_vnf_p7_time(nfapi_vnf_p7_config_t* config){
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() returning\n", __FUNCTION__);
return 0;
}
#endif
int nfapi_vnf_p7_stop(nfapi_vnf_p7_config_t* config)
{
if(config == 0)
......@@ -408,7 +525,11 @@ int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr,
node->dl_out_sync_offset = 30;
node->dl_out_sync_period = 10;
node->dl_in_sync_offset = 30;
node->dl_in_sync_period = 32;
#ifdef PHY_RM
node->dl_in_sync_period = 32;
#else
node->dl_in_sync_period = 512;
#endif
node->sfn_sf = 0;
node->min_sync_cycle_count = 8;
......@@ -525,7 +646,7 @@ int nfapi_vnf_p7_release_pdu(nfapi_vnf_p7_config_t* config, void* pdu)
return 0;
}
#ifdef PHY_RM
int nfapi_vnf_p7_phy_rm_start_req(nfapi_vnf_p7_config_t* config, nfapi_phy_rm_start_request_t* req)
{
if(config == 0 || req == 0)
......@@ -534,3 +655,4 @@ int nfapi_vnf_p7_phy_rm_start_req(nfapi_vnf_p7_config_t* config, nfapi_phy_rm_st
vnf_p7_t* vnf_p7 = (vnf_p7_t*)config;
return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
}
#endif
......@@ -43,7 +43,9 @@ int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req);
int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req);
int oai_nfapi_ue_release_req(nfapi_ue_release_request_t *release_req);
#ifdef PHY_RM
int oai_nfapi_phy_rm_start_req(nfapi_phy_rm_start_request_t *rm_start_req);
#endif
uint8_t dl_pdus[8][MAX_NUM_DL_PDU][9422];
void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,
int frame, int subframe,
......
......@@ -1452,9 +1452,10 @@ typedef struct eNB_MAC_INST_s {
nfapi_tx_request_t TX_req[NFAPI_CC_MAX];
/// NFAPI UE_release_req structure
nfapi_ue_release_request_t UE_release_req;
#ifdef PHY_RM
/// NFAPI phy rm start structure
nfapi_phy_rm_start_request_t PHY_rm_start_req;
#endif
/// UL handle
uint32_t ul_handle;
UE_list_t UE_list;
......
......@@ -762,7 +762,9 @@ void UL_indication(UL_IND_t *UL_info) {
sched_info->TX_req = &mac->TX_req[CC_id];
pthread_mutex_lock(&lock_ue_freelist);
sched_info->UE_release_req = &mac->UE_release_req;
#ifdef PHY_RM
sched_info->PHY_rm_start_req = &mac->PHY_rm_start_req;
#endif
pthread_mutex_unlock(&lock_ue_freelist);
#ifdef DUMP_FAPI
dump_dl(sched_info);
......
......@@ -131,8 +131,10 @@ typedef struct{
nfapi_tx_request_t *TX_req;
/// Pointers to ue_release
nfapi_ue_release_request_t *UE_release_req;
#ifdef PHY_RM
/// Pointers to phy rm
nfapi_phy_rm_start_request_t *PHY_rm_start_req;
#endif
}Sched_Rsp_t;
typedef struct {
......
......@@ -971,7 +971,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
UE = rtd->UE;
if(ue_thread_id == 0) {
phy_stub_ticking->ticking_var = -1;
// phy_stub_ticking->ticking_var = -1;
proc->subframe_rx=proc->sub_frame_start;
// Initializations for nfapi-L2-emulator mode
dl_config_req = NULL;
......@@ -1224,7 +1224,10 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
oai_nfapi_rx_ind(&UL_INFO->rx_ind);
for(uint8_t num_pdu = 0; num_pdu < UL_INFO->rx_ind.rx_indication_body.number_of_pdus; num_pdu++) {
free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[num_pdu].data);
if (UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[num_pdu].data) {
free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[num_pdu].data);
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[num_pdu].data = NULL;
}
}
//LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n");
......@@ -1246,22 +1249,22 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
}
// Free UL_INFO messages
//if(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list != NULL){
if(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list != NULL){
free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list);
UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL;
//}
//if(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list != NULL){
}
if(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list != NULL){
free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list);
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
//}
//if(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list !=NULL){
}
if(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list !=NULL){
free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list);
UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL;
//}
//if(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list!=NULL){
}
if(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list!=NULL){
free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list);
UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL;
//}
}
free(UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list);
UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = NULL;
free(UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list);
......
......@@ -691,9 +691,9 @@ int main( int argc, char **argv ) {
frame_parms[CC_id]->nb_antennas_rx = nb_antenna_rx;
frame_parms[CC_id]->nb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later
}
#ifndef OPENAIR2
NB_INST=1;
#endif
if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE **)*NB_UE_INST);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment