cleaning after big merge
This commit is contained in:
@@ -2767,7 +2767,6 @@ target_link_libraries (test5Gnas LIB_5GNAS_GNB CONFIG_LIB minimal_lib )
|
||||
###################################################
|
||||
|
||||
add_executable(lte-softmodem
|
||||
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
|
||||
${OPENAIR_TARGETS}/RT/USER/lte-enb.c
|
||||
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
|
||||
${OPENAIR_TARGETS}/RT/USER/ru_control.c
|
||||
@@ -2882,7 +2881,6 @@ target_link_libraries(du_test
|
||||
add_executable(oairu
|
||||
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
|
||||
${OPENAIR_TARGETS}/RT/USER/ru_control.c
|
||||
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
|
||||
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
|
||||
${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c
|
||||
${OPENAIR_DIR}/executables/softmodem-common.c
|
||||
@@ -2910,7 +2908,6 @@ target_link_libraries (oairu pthread m ${CONFIG_LIB} rt ${CMAKE_DL_LIBS} ${T_LIB
|
||||
#######################################
|
||||
|
||||
add_executable(lte-uesoftmodem
|
||||
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
|
||||
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
|
||||
${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c
|
||||
${OPENAIR_DIR}/executables/softmodem-common.c
|
||||
|
||||
+131
-1
@@ -211,6 +211,19 @@ void start_background_system(void) {
|
||||
background_system_process();
|
||||
}
|
||||
|
||||
int rt_sleep_ns (uint64_t x)
|
||||
{
|
||||
struct timespec myTime;
|
||||
clock_gettime(CLOCK_MONOTONIC, &myTime);
|
||||
myTime.tv_sec += x/1000000000ULL;
|
||||
myTime.tv_nsec = x%1000000000ULL;
|
||||
if (myTime.tv_nsec>=1000000000) {
|
||||
myTime.tv_nsec -= 1000000000;
|
||||
myTime.tv_sec++;
|
||||
}
|
||||
|
||||
return clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &myTime, NULL);
|
||||
}
|
||||
|
||||
void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){
|
||||
pthread_attr_t attr;
|
||||
@@ -260,11 +273,128 @@ void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name,
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
|
||||
// Legacy, pthread_create + thread_top_init() should be replaced by threadCreate
|
||||
// threadCreate encapsulates the posix pthread api
|
||||
void thread_top_init(char *thread_name,
|
||||
int affinity,
|
||||
uint64_t runtime,
|
||||
uint64_t deadline,
|
||||
uint64_t period) {
|
||||
|
||||
#ifdef DEADLINE_SCHEDULER
|
||||
struct sched_attr attr;
|
||||
|
||||
unsigned int flags = 0;
|
||||
|
||||
attr.size = sizeof(attr);
|
||||
attr.sched_flags = 0;
|
||||
attr.sched_nice = 0;
|
||||
attr.sched_priority = 0;
|
||||
|
||||
attr.sched_policy = SCHED_DEADLINE;
|
||||
attr.sched_runtime = runtime;
|
||||
attr.sched_deadline = deadline;
|
||||
attr.sched_period = period;
|
||||
|
||||
if (sched_setattr(0, &attr, flags) < 0 ) {
|
||||
perror("[SCHED] eNB tx thread: sched_setattr failed\n");
|
||||
fprintf(stderr,"sched_setattr Error = %s",strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#else //LOW_LATENCY
|
||||
int policy, s, j;
|
||||
struct sched_param sparam;
|
||||
char cpu_affinity[1024];
|
||||
cpu_set_t cpuset;
|
||||
int settingPriority = 1;
|
||||
|
||||
/* Set affinity mask to include CPUs 2 to MAX_CPUS */
|
||||
/* CPU 0 is reserved for UHD threads */
|
||||
/* CPU 1 is reserved for all RX_TX threads */
|
||||
/* Enable CPU Affinity only if number of CPUs > 2 */
|
||||
CPU_ZERO(&cpuset);
|
||||
|
||||
#ifdef CPU_AFFINITY
|
||||
if (affinity == 0) {
|
||||
LOG_W(HW,"thread_top_init() called with affinity==0, but overruled by #ifdef CPU_AFFINITY\n");
|
||||
}
|
||||
else if (get_nprocs() > 2)
|
||||
{
|
||||
for (j = 2; j < get_nprocs(); j++)
|
||||
CPU_SET(j, &cpuset);
|
||||
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
if (s != 0)
|
||||
{
|
||||
perror( "pthread_setaffinity_np");
|
||||
exit_fun("Error setting processor affinity");
|
||||
}
|
||||
}
|
||||
#else //CPU_AFFINITY
|
||||
if (affinity) {
|
||||
LOG_W(HW,"thread_top_init() called with affinity>0, but overruled by #ifndef CPU_AFFINITY.\n");
|
||||
}
|
||||
#endif //CPU_AFFINITY
|
||||
|
||||
/* Check the actual affinity mask assigned to the thread */
|
||||
s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
if (s != 0)
|
||||
{
|
||||
perror( "pthread_getaffinity_np");
|
||||
exit_fun("Error getting processor affinity ");
|
||||
}
|
||||
memset(cpu_affinity,0,sizeof(cpu_affinity));
|
||||
for (j = 0; j < 1024; j++)
|
||||
{
|
||||
if (CPU_ISSET(j, &cpuset))
|
||||
{
|
||||
char temp[1024];
|
||||
sprintf (temp, " CPU_%d", j);
|
||||
strcat(cpu_affinity, temp);
|
||||
}
|
||||
}
|
||||
|
||||
if (checkIfFedoraDistribution())
|
||||
if (checkIfGenericKernelOnFedora())
|
||||
if (checkIfInsideContainer())
|
||||
settingPriority = 0;
|
||||
|
||||
if (settingPriority) {
|
||||
memset(&sparam, 0, sizeof(sparam));
|
||||
sparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||
policy = SCHED_FIFO;
|
||||
|
||||
s = pthread_setschedparam(pthread_self(), policy, &sparam);
|
||||
if (s != 0) {
|
||||
perror("pthread_setschedparam : ");
|
||||
exit_fun("Error setting thread priority");
|
||||
}
|
||||
|
||||
s = pthread_getschedparam(pthread_self(), &policy, &sparam);
|
||||
if (s != 0) {
|
||||
perror("pthread_getschedparam : ");
|
||||
exit_fun("Error getting thread priority");
|
||||
}
|
||||
|
||||
pthread_setname_np(pthread_self(), thread_name);
|
||||
|
||||
LOG_I(HW, "[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(),
|
||||
(policy == SCHED_FIFO) ? "SCHED_FIFO" :
|
||||
(policy == SCHED_RR) ? "SCHED_RR" :
|
||||
(policy == SCHED_OTHER) ? "SCHED_OTHER" :
|
||||
"???",
|
||||
sparam.sched_priority, cpu_affinity );
|
||||
}
|
||||
|
||||
#endif //LOW_LATENCY
|
||||
}
|
||||
|
||||
|
||||
// Block CPU C-states deep sleep
|
||||
void configure_linux(void) {
|
||||
int ret;
|
||||
static int latency_target_fd=-1;
|
||||
uint32_t latency_target_value=10; // in microseconds
|
||||
uint32_t latency_target_value=2; // in microseconds
|
||||
if (latency_target_fd == -1) {
|
||||
if ( (latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR)) != -1 ) {
|
||||
ret = write(latency_target_fd, &latency_target_value, sizeof(latency_target_value));
|
||||
|
||||
@@ -65,7 +65,7 @@ void thread_top_init(char *thread_name,
|
||||
int checkIfFedoraDistribution(void);
|
||||
int checkIfGenericKernelOnFedora(void);
|
||||
int checkIfInsideContainer(void);
|
||||
|
||||
int rt_sleep_ns (uint64_t x);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
+15
-16
@@ -77,6 +77,7 @@ static int DEFBFW[] = {0x00007fff};
|
||||
|
||||
#include "T.h"
|
||||
#include "nfapi_interface.h"
|
||||
#include <nfapi/oai_integration/vendor_ext.h>
|
||||
|
||||
extern volatile int oai_exit;
|
||||
|
||||
@@ -1335,24 +1336,22 @@ void *ru_thread( void *param ) {
|
||||
|
||||
|
||||
while (!oai_exit) {
|
||||
// these are local subframe/frame counters to check that we are in synch with the fronthaul timing.
|
||||
// They are set on the first rx/tx in the underly FH routines.
|
||||
slot_start = timespec_add(slot_start,slot_duration);
|
||||
struct timespec curr_time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &curr_time);
|
||||
|
||||
struct timespec sleep_time;
|
||||
|
||||
if((slot_start.tv_sec > curr_time.tv_sec) || (slot_start.tv_sec == curr_time.tv_sec && slot_start.tv_nsec > curr_time.tv_nsec)){
|
||||
sleep_time = timespec_sub(slot_start,curr_time);
|
||||
|
||||
if (NFAPI_MODE==NFAPI_MODE_VNF) {
|
||||
// We should make a VNF main loop with proper tasks calls in case of VNF
|
||||
slot_start = timespec_add(slot_start,slot_duration);
|
||||
struct timespec curr_time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &curr_time);
|
||||
|
||||
usleep(sleep_time.tv_nsec * 1e-3);
|
||||
struct timespec sleep_time;
|
||||
|
||||
if((slot_start.tv_sec > curr_time.tv_sec) || (slot_start.tv_sec == curr_time.tv_sec && slot_start.tv_nsec > curr_time.tv_nsec)){
|
||||
sleep_time = timespec_sub(slot_start,curr_time);
|
||||
|
||||
usleep(sleep_time.tv_nsec * 1e-3);
|
||||
}
|
||||
}
|
||||
else{//continue
|
||||
}
|
||||
|
||||
// clock_gettime(CLOCK_MONOTONIC, &curr_time);
|
||||
//printf("sfn:%d, slot:%d, start time %d.%d slot start %d.%d \n",frame,slot,curr_time.tv_sec,curr_time.tv_nsec,slot_start.tv_sec,slot_start.tv_nsec);
|
||||
|
||||
if (slot==(fp->slots_per_frame-1)) {
|
||||
slot=0;
|
||||
frame++;
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "targets/RT/USER/lte-softmodem.h"
|
||||
#include <syscall.h>
|
||||
#include "targets/RT/USER/rt_wrapper.h"
|
||||
#include <common/utils/threadPool/thread-pool.h>
|
||||
|
||||
//#define DEBUG_DLSCH_CODING
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include "thread_ipc.h"
|
||||
|
||||
g_thread_ipc_t thread_ipc = {0};
|
||||
|
||||
void loop_buffer_reset(buffer_t *loop_buf)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BUFFERMAX; i++) {
|
||||
loop_buf[i].subframe_num = -1;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void loop_buffer_init(loop_buffer_op_t *loop_buffer)
|
||||
{
|
||||
loop_buffer->packet_num = 0;
|
||||
loop_buffer->isfull = 0;
|
||||
loop_buffer->isempty = 1;
|
||||
|
||||
pthread_mutex_init(&loop_buffer->buffer_mutex, NULL);
|
||||
|
||||
pthread_cond_init(&loop_buffer->full_cond, NULL);
|
||||
pthread_cond_init(&loop_buffer->empty_cond, NULL);
|
||||
|
||||
loop_buffer_reset(loop_buffer->loop_buf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void sync_buffer_init(sync_buffer_t *sync_buffer)
|
||||
{
|
||||
sync_buffer->decoding_subframe_num = 0;
|
||||
pthread_mutex_init(&sync_buffer->buffer_mutex, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int thread_ipc_init(void)
|
||||
{
|
||||
//printf("recv %d\n", thread_ipc.sync_buffer.decoding_subframe_num);
|
||||
thread_ipc.ue_sync_state = 0;
|
||||
thread_ipc.rx_timestamp = 0;
|
||||
thread_ipc.tx_timestamp = 0;
|
||||
thread_ipc.current_subframe = 0;
|
||||
|
||||
pthread_mutex_init(&thread_ipc.dl_decode_mutex, NULL);
|
||||
pthread_mutex_lock(&thread_ipc.dl_decode_mutex);
|
||||
|
||||
pthread_mutex_init(&thread_ipc.ul_send_mutex, NULL);
|
||||
pthread_mutex_lock(&thread_ipc.ul_send_mutex);
|
||||
|
||||
pthread_mutex_init(&thread_ipc.sync_mutex, NULL);
|
||||
pthread_mutex_lock(&thread_ipc.sync_mutex);
|
||||
|
||||
loop_buffer_init(&thread_ipc.loop_buffer);
|
||||
sync_buffer_init(&thread_ipc.sync_buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int thread_ipc_deinit(void)
|
||||
{
|
||||
pthread_mutex_destroy(&thread_ipc.ul_send_mutex);
|
||||
pthread_mutex_destroy(&thread_ipc.sync_mutex);
|
||||
pthread_mutex_destroy(&thread_ipc.dl_decode_mutex);
|
||||
|
||||
pthread_mutex_destroy(&thread_ipc.loop_buffer.buffer_mutex);
|
||||
pthread_cond_destroy(&thread_ipc.loop_buffer.full_cond);
|
||||
pthread_cond_destroy(&thread_ipc.loop_buffer.empty_cond);
|
||||
|
||||
pthread_mutex_destroy(&thread_ipc.sync_buffer.buffer_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_thread_attr(pthread_attr_t *attr, int policy, int priority, int cpuid)
|
||||
{
|
||||
struct sched_param param;
|
||||
cpu_set_t cpu_info;
|
||||
|
||||
pthread_attr_init(attr);
|
||||
|
||||
if (pthread_attr_setschedpolicy(attr, policy) != 0) {
|
||||
perror("pthread_attr_setschedpolicy");
|
||||
return -1;
|
||||
}
|
||||
|
||||
param.sched_priority = priority;
|
||||
|
||||
if (pthread_attr_setschedparam(attr, ¶m) != 0) {
|
||||
perror("pthread_attr_setschedparam");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_ZERO(&cpu_info);
|
||||
CPU_SET(cpuid, &cpu_info);
|
||||
|
||||
if (pthread_attr_setaffinity_np(attr,sizeof(cpu_set_t),&cpu_info)) {
|
||||
perror("pthread_attr_setaffinity_np");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED) != 0) {
|
||||
perror("pthread_attr_setinheritsched");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int find_subframe_num(unsigned long long current_subframe_num, buffer_t *buf, int *flag)
|
||||
{
|
||||
long long tmp;
|
||||
int i;
|
||||
|
||||
tmp = current_subframe_num;
|
||||
|
||||
for ( i = 0; i < HIGHBUFFER + 1; i++) {
|
||||
if(tmp == buf[i].subframe_num) {
|
||||
return i;
|
||||
} else if (tmp < buf[i].subframe_num) {
|
||||
*flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ue_unsync_thread_ipc_reset(void)
|
||||
{
|
||||
thread_ipc.ue_sync_state = 0;
|
||||
|
||||
pthread_mutex_lock(&thread_ipc.loop_buffer.buffer_mutex);
|
||||
|
||||
if (thread_ipc.loop_buffer.isempty) {
|
||||
pthread_cond_signal(&thread_ipc.loop_buffer.empty_cond);
|
||||
}
|
||||
|
||||
if (thread_ipc.loop_buffer.isfull) {
|
||||
pthread_cond_signal(&thread_ipc.loop_buffer.full_cond);
|
||||
}
|
||||
|
||||
thread_ipc.loop_buffer.packet_num = 0;
|
||||
thread_ipc.loop_buffer.isfull = 0;
|
||||
thread_ipc.loop_buffer.isempty = 1;
|
||||
|
||||
loop_buffer_reset(thread_ipc.loop_buffer.loop_buf);
|
||||
pthread_mutex_unlock(&thread_ipc.loop_buffer.buffer_mutex);
|
||||
|
||||
thread_ipc.current_subframe = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
void bind_thread2kernel(int cpu_id)
|
||||
{
|
||||
cpu_set_t mask;
|
||||
cpu_set_t get;
|
||||
int i;
|
||||
int num = sysconf(_SC_NPROCESSORS_CONF);
|
||||
//printf("system has %d processor(s) by super\n", num);
|
||||
CPU_ZERO(&mask);
|
||||
CPU_SET(cpu_id, &mask);
|
||||
|
||||
if (pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) < 0) {
|
||||
fprintf(stderr, "set thread affinity failed\n");
|
||||
}
|
||||
|
||||
/*CPU_ZERO(&get);
|
||||
if (pthread_getaffinity_np(pthread_self(), sizeof(get), &get) < 0) {
|
||||
fprintf(stderr, "get thread affinity failed\n");
|
||||
}
|
||||
for (i = 0; i < num; i++) {
|
||||
if (CPU_ISSET(i, &get)) {
|
||||
printf("thread %d is running in processor %d\n", (int)pthread_self(), i);
|
||||
}
|
||||
}
|
||||
if (CPU_ISSET(cpu_id, &get)) {
|
||||
printf("thread %d is running in processor %d by super\n", (int)pthread_self(), cpu_id);
|
||||
}*/
|
||||
}
|
||||
void get_thread2kernel(void)
|
||||
{
|
||||
cpu_set_t get;
|
||||
int i;
|
||||
int num = sysconf(_SC_NPROCESSORS_CONF);
|
||||
printf("system has %d processor(s) by super\n", num);
|
||||
CPU_ZERO(&get);
|
||||
|
||||
if (pthread_getaffinity_np(pthread_self(), sizeof(get), &get) < 0) {
|
||||
fprintf(stderr, "get thread affinity failed\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
if (CPU_ISSET(i, &get)) {
|
||||
printf("The thread %d is running in processor %d by super\n", (int)pthread_self(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@
|
||||
|
||||
#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
|
||||
|
||||
#include "rt_wrapper.h"
|
||||
|
||||
#include "assertions.h"
|
||||
|
||||
|
||||
@@ -101,7 +99,6 @@ extern RAN_CONTEXT_t RC;
|
||||
//#define USRP_DEBUG 1
|
||||
struct timing_info_t {
|
||||
//unsigned int frame, hw_slot, last_slot, next_slot;
|
||||
RTIME time_min, time_max, time_avg, time_last, time_now;
|
||||
//unsigned int mbox0, mbox1, mbox2, mbox_target;
|
||||
unsigned int n_samples;
|
||||
} timing_info;
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <execinfo.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include "rt_wrapper.h"
|
||||
|
||||
#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <sched.h>
|
||||
|
||||
#include "rt_wrapper.h"
|
||||
#include <common/utils/msc/msc.h>
|
||||
|
||||
|
||||
@@ -518,13 +517,6 @@ static void wait_nfapi_init(char *thread_name) {
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
set_priority(79);
|
||||
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1)
|
||||
{
|
||||
fprintf(stderr, "mlockall: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int i;
|
||||
int CC_id = 0;
|
||||
int ru_id;
|
||||
@@ -537,8 +529,8 @@ int main ( int argc, char **argv )
|
||||
}
|
||||
|
||||
mode = normal_txrx;
|
||||
set_latency_target();
|
||||
logInit();
|
||||
configure_linux();
|
||||
printf("Reading in command-line options\n");
|
||||
get_options ();
|
||||
|
||||
@@ -573,13 +565,10 @@ int main ( int argc, char **argv )
|
||||
init_opt();
|
||||
// to make a graceful exit when ctrl-c is pressed
|
||||
set_softmodem_sighandler();
|
||||
check_clock();
|
||||
#ifndef PACKAGE_VERSION
|
||||
# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
|
||||
#endif
|
||||
LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
|
||||
printf("Runtime table\n");
|
||||
fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx);
|
||||
|
||||
/* Read configuration */
|
||||
if (RC.nb_inst > 0) {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <linux/sched.h>
|
||||
#include "rt_wrapper.h"
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
@@ -21,7 +20,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "threads_t.h"
|
||||
#include "rt_wrapper.h"
|
||||
#include "../../ARCH/COMMON/common_lib.h"
|
||||
//#undef MALLOC
|
||||
#include "assertions.h"
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
*/
|
||||
#include "lte-softmodem.h"
|
||||
|
||||
#include "rt_wrapper.h"
|
||||
#include "system.h"
|
||||
|
||||
#include "LAYER2/MAC/mac.h"
|
||||
|
||||
@@ -34,9 +34,6 @@
|
||||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <sched.h>
|
||||
|
||||
#include "rt_wrapper.h"
|
||||
|
||||
|
||||
#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
|
||||
|
||||
#include "assertions.h"
|
||||
@@ -542,12 +539,6 @@ AssertFatal(false,"");
|
||||
}
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
set_priority(79);
|
||||
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1)
|
||||
{
|
||||
fprintf(stderr, "mlockall: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int CC_id;
|
||||
uint8_t abstraction_flag=0;
|
||||
@@ -565,8 +556,8 @@ int main( int argc, char **argv ) {
|
||||
|
||||
mode = normal_txrx;
|
||||
memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
|
||||
set_latency_target();
|
||||
logInit();
|
||||
configure_linux();
|
||||
printf("Reading in command-line options\n");
|
||||
|
||||
for (int i=0; i<MAX_NUM_CCs; i++) tx_max_power[i]=23;
|
||||
@@ -629,7 +620,6 @@ int main( int argc, char **argv ) {
|
||||
pdcp_pc5_socket_init();
|
||||
// to make a graceful exit when ctrl-c is pressed
|
||||
set_softmodem_sighandler();
|
||||
check_clock();
|
||||
#ifndef PACKAGE_VERSION
|
||||
# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
|
||||
#endif
|
||||
@@ -663,52 +653,6 @@ int main( int argc, char **argv ) {
|
||||
|
||||
cpuf=get_cpu_freq_GHz();
|
||||
|
||||
|
||||
#if 0 // #ifndef DEADLINE_SCHEDULER
|
||||
|
||||
printf("NO deadline scheduler\n");
|
||||
/* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */
|
||||
cpu_set_t cpuset;
|
||||
int s;
|
||||
char cpu_affinity[1024];
|
||||
CPU_ZERO(&cpuset);
|
||||
#ifdef CPU_AFFINITY
|
||||
int j;
|
||||
if (get_nprocs() > 2) {
|
||||
for (j = 2; j < get_nprocs(); j++)
|
||||
CPU_SET(j, &cpuset);
|
||||
|
||||
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
|
||||
if (s != 0) {
|
||||
perror( "pthread_setaffinity_np");
|
||||
exit_fun("Error setting processor affinity");
|
||||
}
|
||||
LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Check the actual affinity mask assigned to the thread */
|
||||
s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
|
||||
if (s != 0) {
|
||||
perror( "pthread_getaffinity_np");
|
||||
exit_fun("Error getting processor affinity ");
|
||||
}
|
||||
|
||||
memset(cpu_affinity, 0, sizeof(cpu_affinity));
|
||||
|
||||
for (int j = 0; j < CPU_SETSIZE; j++) {
|
||||
if (CPU_ISSET(j, &cpuset)) {
|
||||
char temp[1024];
|
||||
sprintf(temp, " CPU_%d ", j);
|
||||
strcat(cpu_affinity, temp);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity);
|
||||
#endif
|
||||
|
||||
if (create_tasks_ue(NB_UE_INST) < 0) {
|
||||
printf("cannot create ITTI tasks\n");
|
||||
exit(-1); // need a softer mode
|
||||
|
||||
@@ -1,383 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file rt_wrapper.h
|
||||
* \brief provides a wrapper for the timing function, runtime calculations for real-time opeartions depending on weather RTAI or DEADLINE_SCHEDULER kernels are used or not
|
||||
* \author F. Kaltenberger and Navid Nikaein
|
||||
* \date 2013
|
||||
* \version 0.1
|
||||
* \company Eurecom
|
||||
* \email: florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr
|
||||
* \note
|
||||
* \warning
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sched.h>
|
||||
#include <linux/sched.h>
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include "rt_wrapper.h"
|
||||
#include "system.h"
|
||||
#include <errno.h>
|
||||
#include <common/utils/msc/msc.h>
|
||||
|
||||
#include "openair1/PHY/defs_common.h"
|
||||
|
||||
static int latency_target_fd = -1;
|
||||
static int32_t latency_target_value = 0;
|
||||
/* Latency trick - taken from cyclictest.c
|
||||
* if the file /dev/cpu_dma_latency exists,
|
||||
* open it and write a zero into it. This will tell
|
||||
* the power management system not to transition to
|
||||
* a high cstate (in fact, the system acts like idle=poll)
|
||||
* When the fd to /dev/cpu_dma_latency is closed, the behavior
|
||||
* goes back to the system default.
|
||||
*
|
||||
* Documentation/power/pm_qos_interface.txt
|
||||
*/
|
||||
void set_latency_target(void) {
|
||||
struct stat s;
|
||||
int ret;
|
||||
|
||||
if (stat("/dev/cpu_dma_latency", &s) == 0) {
|
||||
latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR);
|
||||
|
||||
if (latency_target_fd == -1)
|
||||
return;
|
||||
|
||||
ret = write(latency_target_fd, &latency_target_value, 4);
|
||||
|
||||
if (ret == 0) {
|
||||
printf("# error setting cpu_dma_latency to %d!: %s\n", latency_target_value, strerror(errno));
|
||||
close(latency_target_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("# /dev/cpu_dma_latency set to %dus\n", latency_target_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct timespec interval, next, now, res;
|
||||
clockid_t clock_id = CLOCK_MONOTONIC; //other options are CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID
|
||||
RTIME rt_get_time_ns (void)
|
||||
{
|
||||
clock_gettime(clock_id, &now);
|
||||
return(now.tv_sec*1e9+now.tv_nsec);
|
||||
}
|
||||
|
||||
int rt_sleep_ns (RTIME x)
|
||||
{
|
||||
int ret;
|
||||
clock_gettime(clock_id, &now);
|
||||
interval.tv_sec = x/((RTIME)1000000000);
|
||||
interval.tv_nsec = x%((RTIME)1000000000);
|
||||
//rt_printk("sleeping for %d sec and %d ns\n",interval.tv_sec,interval.tv_nsec);
|
||||
next = now;
|
||||
next.tv_sec += interval.tv_sec;
|
||||
next.tv_nsec += interval.tv_nsec;
|
||||
|
||||
if (next.tv_nsec>=1000000000) {
|
||||
next.tv_nsec -= 1000000000;
|
||||
next.tv_sec++;
|
||||
}
|
||||
|
||||
ret = clock_nanosleep(clock_id, TIMER_ABSTIME, &next, NULL);
|
||||
|
||||
/*
|
||||
if (ret==EFAULT)
|
||||
rt_printk("rt_sleep_ns returned EFAULT (%d), reqested %d sec and %d ns\n",ret,next.tv_sec,next.tv_nsec);
|
||||
if (ret==EINVAL)
|
||||
rt_printk("rt_sleep_ns returned EINVAL (%d), reqested %d sec and %d ns\n",ret,next.tv_sec,next.tv_nsec);
|
||||
if (ret==EINTR)
|
||||
rt_printk("rt_sleep_ns returned EINTR (%d), reqested %d sec and %d ns\n",ret,next.tv_sec,next.tv_nsec);
|
||||
*/
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void check_clock(void)
|
||||
{
|
||||
if (clock_getres(clock_id, &res)) {
|
||||
printf("clock_getres failed");
|
||||
} else {
|
||||
printf("reported resolution = %lld ns\n", (long long int) ((int) 1e9 * res.tv_sec) + (long long int) res.tv_nsec);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t cell_processing_dl[6]={10,15,24,42,80,112};
|
||||
uint16_t platform_processing_dl=20; // upperbound for GPP, LXC, DOCKER and KVM
|
||||
uint16_t user_processing_dl_a[6]={2,4,5,7,10,12};
|
||||
uint16_t user_processing_dl_b[6]={10, 15, 25, 70, 110, 150};
|
||||
uint16_t user_processing_dl_err[6]={20, 40, 60, 90, 120, 160};
|
||||
uint16_t protocol_processing_dl[6]={150, 250, 350, 450, 650, 800}; // assumption: max MCS 27 --> gives an upper bound for the transport block size : to be measured
|
||||
|
||||
uint16_t cell_processing_ul[6]={10,15,24,42,80,112};
|
||||
uint16_t platform_processing_ul=30; // upperbound for GPP, LXC, DOCKER and KVM
|
||||
uint16_t user_processing_ul_a[6]={5, 9, 12, 24, 33, 42};
|
||||
uint16_t user_processing_ul_b[6]={20, 30, 40, 76, 140, 200};
|
||||
uint16_t user_processing_ul_err[6]={15, 25, 32, 60, 80, 95};
|
||||
uint16_t protocol_processing_ul[6]={100, 200, 300, 400, 550, 700}; // assumption: max MCS 16 --> gives an upper bound for the transport block size
|
||||
|
||||
int fill_modeled_runtime_table(uint16_t runtime_phy_rx[29][6],
|
||||
uint16_t runtime_phy_tx[29][6]){
|
||||
//double cpu_freq;
|
||||
//cpu_freq = get_cpu_freq_GHz();
|
||||
// target_dl_mcs
|
||||
// target_ul_mcs
|
||||
// frame_parms[0]->N_RB_DL
|
||||
int i,j;
|
||||
memset(runtime_phy_rx,0,sizeof(uint16_t)*29*6);
|
||||
memset(runtime_phy_tx,0,sizeof(uint16_t)*29*6);
|
||||
/* only the BBU/PHY procesing time */
|
||||
for (i=0;i<29;i++){
|
||||
for (j=0;j<6;j++){
|
||||
runtime_phy_rx[i][j] = cell_processing_ul[j] + platform_processing_ul + user_processing_ul_err[j] + user_processing_ul_a[j]*i+ user_processing_ul_b[j];
|
||||
runtime_phy_tx[i][j] = cell_processing_dl[j] + platform_processing_dl + user_processing_dl_err[j] + user_processing_dl_a[j]*i+ user_processing_dl_b[j];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int runtime_upper_layers[6]; // values for different RBs
|
||||
// int runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
|
||||
// int runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
|
||||
|
||||
// target_dl_mcs
|
||||
// target_ul_mcs
|
||||
// frame_parms[0]->N_RB_DL
|
||||
//runtime_upper_layers[6]; // values for different RBs
|
||||
// int runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
|
||||
// int runtime_phy_tx[29][6]
|
||||
|
||||
double get_runtime_tx(int tx_subframe, uint16_t runtime_phy_tx[29][6], uint32_t mcs, int N_RB_DL,double cpuf,int nb_tx_antenna){
|
||||
int i;
|
||||
double runtime;
|
||||
//printf("cpuf =%lf \n",cpuf);
|
||||
switch(N_RB_DL){
|
||||
case 6:
|
||||
i = 0;
|
||||
break;
|
||||
case 15:
|
||||
i = 1;
|
||||
break;
|
||||
case 25:
|
||||
i = 2;
|
||||
break;
|
||||
case 50:
|
||||
i = 3;
|
||||
break;
|
||||
case 75:
|
||||
i = 4;
|
||||
break;
|
||||
case 100:
|
||||
i = 5;
|
||||
break;
|
||||
default:
|
||||
i = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
runtime = ( (3.2/cpuf)*(double)runtime_phy_tx[mcs][i] + (3.2/cpuf)*(double)protocol_processing_dl[i])/1000 ;
|
||||
printf("Setting tx %d runtime value (ms) = %lf\n",tx_subframe,runtime);
|
||||
|
||||
return runtime;
|
||||
}
|
||||
|
||||
double get_runtime_rx(int rx_subframe, uint16_t runtime_phy_rx[29][6], uint32_t mcs, int N_RB_DL,double cpuf,int nb_rx_antenna){
|
||||
int i;
|
||||
double runtime;
|
||||
|
||||
//printf("N_RB_DL=%d cpuf =%lf \n",N_RB_DL, cpuf);
|
||||
switch(N_RB_DL){
|
||||
case 6:
|
||||
i = 0;
|
||||
break;
|
||||
case 15:
|
||||
i = 1;
|
||||
break;
|
||||
case 25:
|
||||
i = 2;
|
||||
break;
|
||||
case 50:
|
||||
i = 3;
|
||||
break;
|
||||
case 75:
|
||||
i = 4;
|
||||
break;
|
||||
case 100:
|
||||
i = 5;
|
||||
break;
|
||||
default:
|
||||
i = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
runtime = ((3.2/cpuf)*(double)runtime_phy_rx[mcs][i] + (3.2/cpuf)*(double)protocol_processing_ul[i])/1000 ;
|
||||
printf("Setting rx %d runtime value (ms) = %lf \n",rx_subframe, runtime);
|
||||
|
||||
return runtime;
|
||||
}
|
||||
|
||||
#ifdef DEADLINE_SCHEDULER
|
||||
int sched_setattr(pid_t pid, const struct sched_attr *attr, unsigned int flags)
|
||||
{
|
||||
|
||||
return syscall(__NR_sched_setattr, pid, attr, flags);
|
||||
}
|
||||
|
||||
|
||||
int sched_getattr(pid_t pid,struct sched_attr *attr,unsigned int size, unsigned int flags)
|
||||
{
|
||||
|
||||
return syscall(__NR_sched_getattr, pid, attr, size, flags);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void thread_top_init(char *thread_name,
|
||||
int affinity,
|
||||
uint64_t runtime,
|
||||
uint64_t deadline,
|
||||
uint64_t period) {
|
||||
|
||||
MSC_START_USE();
|
||||
|
||||
#ifdef DEADLINE_SCHEDULER
|
||||
struct sched_attr attr;
|
||||
|
||||
unsigned int flags = 0;
|
||||
|
||||
attr.size = sizeof(attr);
|
||||
attr.sched_flags = 0;
|
||||
attr.sched_nice = 0;
|
||||
attr.sched_priority = 0;
|
||||
|
||||
attr.sched_policy = SCHED_DEADLINE;
|
||||
attr.sched_runtime = runtime;
|
||||
attr.sched_deadline = deadline;
|
||||
attr.sched_period = period;
|
||||
|
||||
if (sched_setattr(0, &attr, flags) < 0 ) {
|
||||
perror("[SCHED] eNB tx thread: sched_setattr failed\n");
|
||||
fprintf(stderr,"sched_setattr Error = %s",strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#else //LOW_LATENCY
|
||||
int policy, s, j;
|
||||
struct sched_param sparam;
|
||||
char cpu_affinity[1024];
|
||||
cpu_set_t cpuset;
|
||||
int settingPriority = 1;
|
||||
|
||||
/* Set affinity mask to include CPUs 2 to MAX_CPUS */
|
||||
/* CPU 0 is reserved for UHD threads */
|
||||
/* CPU 1 is reserved for all RX_TX threads */
|
||||
/* Enable CPU Affinity only if number of CPUs > 2 */
|
||||
CPU_ZERO(&cpuset);
|
||||
|
||||
#ifdef CPU_AFFINITY
|
||||
if (affinity == 0) {
|
||||
LOG_W(HW,"thread_top_init() called with affinity==0, but overruled by #ifdef CPU_AFFINITY\n");
|
||||
}
|
||||
else if (get_nprocs() > 2)
|
||||
{
|
||||
for (j = 2; j < get_nprocs(); j++)
|
||||
CPU_SET(j, &cpuset);
|
||||
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
if (s != 0)
|
||||
{
|
||||
perror( "pthread_setaffinity_np");
|
||||
exit_fun("Error setting processor affinity");
|
||||
}
|
||||
}
|
||||
#else //CPU_AFFINITY
|
||||
if (affinity) {
|
||||
LOG_W(HW,"thread_top_init() called with affinity>0, but overruled by #ifndef CPU_AFFINITY.\n");
|
||||
}
|
||||
#endif //CPU_AFFINITY
|
||||
|
||||
/* Check the actual affinity mask assigned to the thread */
|
||||
s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
if (s != 0)
|
||||
{
|
||||
perror( "pthread_getaffinity_np");
|
||||
exit_fun("Error getting processor affinity ");
|
||||
}
|
||||
memset(cpu_affinity,0,sizeof(cpu_affinity));
|
||||
for (j = 0; j < 1024; j++)
|
||||
{
|
||||
if (CPU_ISSET(j, &cpuset))
|
||||
{
|
||||
char temp[1024];
|
||||
sprintf (temp, " CPU_%d", j);
|
||||
strcat(cpu_affinity, temp);
|
||||
}
|
||||
}
|
||||
|
||||
if (checkIfFedoraDistribution())
|
||||
if (checkIfGenericKernelOnFedora())
|
||||
if (checkIfInsideContainer())
|
||||
settingPriority = 0;
|
||||
|
||||
if (settingPriority) {
|
||||
memset(&sparam, 0, sizeof(sparam));
|
||||
sparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||
policy = SCHED_FIFO;
|
||||
|
||||
s = pthread_setschedparam(pthread_self(), policy, &sparam);
|
||||
if (s != 0) {
|
||||
perror("pthread_setschedparam : ");
|
||||
exit_fun("Error setting thread priority");
|
||||
}
|
||||
|
||||
s = pthread_getschedparam(pthread_self(), &policy, &sparam);
|
||||
if (s != 0) {
|
||||
perror("pthread_getschedparam : ");
|
||||
exit_fun("Error getting thread priority");
|
||||
}
|
||||
|
||||
pthread_setname_np(pthread_self(), thread_name);
|
||||
|
||||
LOG_I(HW, "[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(),
|
||||
(policy == SCHED_FIFO) ? "SCHED_FIFO" :
|
||||
(policy == SCHED_RR) ? "SCHED_RR" :
|
||||
(policy == SCHED_OTHER) ? "SCHED_OTHER" :
|
||||
"???",
|
||||
sparam.sched_priority, cpu_affinity );
|
||||
}
|
||||
|
||||
#endif //LOW_LATENCY
|
||||
|
||||
mlockall(MCL_CURRENT | MCL_FUTURE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file rt_wrapper.h
|
||||
* \brief provides a wrapper for the timing function for real-time opeartions. It also implements an API for the SCHED_DEADLINE kernel scheduler.
|
||||
* \author F. Kaltenberger and Navid Nikaein
|
||||
* \date 2013
|
||||
* \version 0.1
|
||||
* \company Eurecom
|
||||
* \email: florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr
|
||||
* \note
|
||||
* \warning This code will be removed when a legacy libc API becomes available.
|
||||
*/
|
||||
|
||||
#ifndef _RT_WRAPPER_H_
|
||||
#define _RT_WRAPPER_H_
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <syscall.h>
|
||||
#include <math.h>
|
||||
#include <sched.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sched.h>
|
||||
#include <linux/sched.h>
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#include "common/utils/LOG/log_extern.h"
|
||||
#include "msc.h"
|
||||
|
||||
#define RTIME long long int
|
||||
|
||||
#define rt_printk printf
|
||||
|
||||
void set_latency_target(void);
|
||||
|
||||
RTIME rt_get_time_ns (void);
|
||||
|
||||
int rt_sleep_ns (RTIME x);
|
||||
|
||||
void check_clock(void);
|
||||
|
||||
int fill_modeled_runtime_table(uint16_t runtime_phy_rx[29][6],uint16_t runtime_phy_tx[29][6]);
|
||||
|
||||
double get_runtime_tx(int tx_subframe, uint16_t runtime_phy_tx[29][6],uint32_t mcs, int N_RB_DL,double cpuf,int nb_tx_antenna);
|
||||
|
||||
double get_runtime_rx(int rx_subframe, uint16_t runtime_phy_rx[29][6], uint32_t mcs, int N_RB_DL,double cpuf,int nb_rx_antenna);
|
||||
/**
|
||||
* see https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.txt or
|
||||
* http://www.blaess.fr/christophe/2014/04/05/utiliser-un-appel-systeme-inconnu-de-la-libc/
|
||||
*/
|
||||
#ifdef DEADLINE_SCHEDULER
|
||||
|
||||
#define gettid() syscall(__NR_gettid)
|
||||
|
||||
#define SCHED_DEADLINE 6
|
||||
|
||||
/* XXX use the proper syscall numbers */
|
||||
#ifdef __x86_64__
|
||||
#define __NR_sched_setattr 314
|
||||
#define __NR_sched_getattr 315
|
||||
#endif
|
||||
|
||||
#ifdef __i386__
|
||||
#define __NR_sched_setattr 351
|
||||
#define __NR_sched_getattr 352
|
||||
#endif
|
||||
|
||||
struct sched_attr {
|
||||
__u32 size;
|
||||
|
||||
__u32 sched_policy;
|
||||
__u64 sched_flags;
|
||||
|
||||
/* SCHED_NORMAL, SCHED_BATCH */
|
||||
__s32 sched_nice;
|
||||
|
||||
/* SCHED_FIFO, SCHED_RR */
|
||||
__u32 sched_priority;
|
||||
|
||||
/* SCHED_DEADLINE (nsec) */
|
||||
__u64 sched_runtime;
|
||||
__u64 sched_deadline;
|
||||
__u64 sched_period;
|
||||
};
|
||||
|
||||
int sched_setattr(pid_t pid, const struct sched_attr *attr, unsigned int flags);
|
||||
|
||||
int sched_getattr(pid_t pid,struct sched_attr *attr,unsigned int size, unsigned int flags);
|
||||
|
||||
#endif
|
||||
|
||||
#define gettid() syscall(__NR_gettid) // for gettid
|
||||
|
||||
|
||||
void thread_top_init(char *thread_name,
|
||||
int affinity,
|
||||
uint64_t runtime,
|
||||
uint64_t deadline,
|
||||
uint64_t period);
|
||||
|
||||
#endif
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <execinfo.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include "rt_wrapper.h"
|
||||
|
||||
#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
|
||||
|
||||
|
||||
Reference in New Issue
Block a user