Commit 1112dec9 authored by wujing's avatar wujing

Merge branch 'develop_core_nfapi' into develop

parents 8513035a fbf50396
......@@ -243,7 +243,91 @@ void* pnf_p7_thread_start(void* ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P7 THREAD %s\n", __FUNCTION__);
pnf_set_thread_priority(79);
#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 = 870000L;
attr.sched_deadline = 1000000L;
attr.sched_period = 1000000L;
if (sched_setattr(0, &attr, flags) < 0 ) {
fprintf(stderr,"sched_setattr Error = %s",strerror(errno));
exit(1);
}
#else
int policy, s, j;
struct sched_param sparam;
char cpu_affinity[1024];
cpu_set_t cpuset;
/* Set affinity mask to include CPUs 1 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 (get_nprocs() >= 8)
{
for (j = 5; j < 9; j++) {
CPU_SET(j, &cpuset);
}
} else if (get_nprocs() > 2) {
for (j = 1; j < get_nprocs(); j++) {
CPU_SET(j, &cpuset);
}
}
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0)
{
printf("Error setting processor affinity");
exit(1);
}
#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) {
printf("Error getting processor affinity ");
exit(1);
}
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);
}
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) {
printf("Error setting thread priority");
exit(1);
}
s = pthread_getschedparam(pthread_self(), &policy, &sparam);
if (s != 0) {
printf("Error getting thread priority");
exit(1);
}
pthread_setname_np(pthread_self(), "pnf_p7_thread_start");
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n", __FUNCTION__, "pnf_p7_thread_start", 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
nfapi_pnf_p7_config_t* config = (nfapi_pnf_p7_config_t*)ptr;
nfapi_pnf_p7_start(config);
......@@ -1521,7 +1605,91 @@ void* pnf_start_thread(void* ptr) {
struct sched_param sp;
sp.sched_priority = 20;
pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp);
#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 = 870000L;
attr.sched_deadline = 1000000L;
attr.sched_period = 1000000L;
if (sched_setattr(0, &attr, flags) < 0 ) {
fprintf(stderr,"sched_setattr Error = %s",strerror(errno));
exit(1);
}
#else
int policy, s, j;
struct sched_param sparam;
char cpu_affinity[1024];
cpu_set_t cpuset;
/* Set affinity mask to include CPUs 1 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 (get_nprocs() >= 8)
{
for (j = 5; j < 9; j++) {
CPU_SET(j, &cpuset);
}
} else if (get_nprocs() > 2) {
for (j = 1; j < get_nprocs(); j++) {
CPU_SET(j, &cpuset);
}
}
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0)
{
printf("Error setting processor affinity");
exit(1);
}
#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) {
printf("Error getting processor affinity ");
exit(1);
}
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);
}
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) {
printf("Error setting thread priority");
exit(1);
}
s = pthread_getschedparam(pthread_self(), &policy, &sparam);
if (s != 0) {
printf("Error getting thread priority");
exit(1);
}
pthread_setname_np(pthread_self(), "pnf_start_thread");
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n", __FUNCTION__, "pnf_start_thread", 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
nfapi_pnf_start(config);
return (void*)0;
......
......@@ -1004,7 +1004,91 @@ void* vnf_p7_start_thread(void *ptr) {
printf("%s()\n", __FUNCTION__);
pthread_setname_np(pthread_self(), "VNF_P7");
#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 = 870000L;
attr.sched_deadline = 1000000L;
attr.sched_period = 1000000L;
if (sched_setattr(0, &attr, flags) < 0 ) {
fprintf(stderr,"sched_setattr Error = %s",strerror(errno));
exit(1);
}
#else
int policy, s, j;
struct sched_param sparam;
char cpu_affinity[1024];
cpu_set_t cpuset;
/* Set affinity mask to include CPUs 1 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 (get_nprocs() >= 8)
{
for (j = 1; j < 4; j++) {
CPU_SET(j, &cpuset);
}
} else if (get_nprocs() > 2) {
for (j = 1; j < get_nprocs(); j++) {
CPU_SET(j, &cpuset);
}
}
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0)
{
printf("Error setting processor affinity");
exit(1);
}
#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) {
printf("Error getting processor affinity ");
exit(1);
}
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);
}
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) {
printf("Error setting thread priority");
exit(1);
}
s = pthread_getschedparam(pthread_self(), &policy, &sparam);
if (s != 0) {
printf("Error getting thread priority");
exit(1);
}
pthread_setname_np(pthread_self(), "vnf_p7_start_thread");
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n", __FUNCTION__, "vnf_p7_start_thread", 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
nfapi_vnf_p7_config_t* config = (nfapi_vnf_p7_config_t*)ptr;
nfapi_vnf_p7_start(config);
......@@ -1260,7 +1344,91 @@ void vnf_start_thread(void* ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] VNF NFAPI thread - nfapi_vnf_start()%s\n", __FUNCTION__);
pthread_setname_np(pthread_self(), "VNF");
#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 = 870000L;
attr.sched_deadline = 1000000L;
attr.sched_period = 1000000L;
if (sched_setattr(0, &attr, flags) < 0 ) {
fprintf(stderr,"sched_setattr Error = %s",strerror(errno));
exit(1);
}
#else
int policy, s, j;
struct sched_param sparam;
char cpu_affinity[1024];
cpu_set_t cpuset;
/* Set affinity mask to include CPUs 1 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 (get_nprocs() >= 8)
{
for (j = 1; j < 4; j++) {
CPU_SET(j, &cpuset);
}
} else if (get_nprocs() > 2) {
for (j = 1; j < get_nprocs(); j++) {
CPU_SET(j, &cpuset);
}
}
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0)
{
printf("Error setting processor affinity");
exit(1);
}
#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) {
printf("Error getting processor affinity ");
exit(1);
}
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);
}
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) {
printf("Error setting thread priority");
exit(1);
}
s = pthread_getschedparam(pthread_self(), &policy, &sparam);
if (s != 0) {
printf("Error getting thread priority");
exit(1);
}
pthread_setname_np(pthread_self(), "vnf_start_thread");
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n", __FUNCTION__, "vnf_start_thread", 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
config = (nfapi_vnf_config_t*)ptr;
nfapi_vnf_start(config);
......
......@@ -191,7 +191,7 @@ void *eNB_app_task(void *args_p)
int result;
/* for no gcc warnings */
(void)instance;
thread_top_init("eNB_app_task",1,500000,1000000,20000000);
itti_mark_task_ready (TASK_ENB_APP);
LOG_I(PHY, "%s() Task ready initialise structures\n", __FUNCTION__);
......
......@@ -6874,6 +6874,7 @@ rrc_enb_task(
)
//-----------------------------------------------------------------------------
{
thread_top_init("rrc_enb_task",1,500000,1000000,20000000);
rrc_enb_init();
itti_mark_task_ready(TASK_RRC_ENB);
LOG_I(RRC,"Entering main loop of RRC message task\n");
......
......@@ -359,7 +359,7 @@ void *x2ap_task(void *arg) {
X2AP_DEBUG("Starting X2AP layer\n");
x2ap_eNB_prepare_internal_data();
itti_mark_task_ready(TASK_X2AP);
thread_top_init("x2ap_task",1,500000,1000000,20000000);
while (1) {
itti_receive_msg(TASK_X2AP, &received_msg);
......
......@@ -1149,7 +1149,7 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
void *gtpv1u_eNB_task(void *args)
{
int rc = 0;
thread_top_init("gtpv1u_eNB_task",1,500000,1000000,20000000);
rc = gtpv1u_eNB_init();
AssertFatal(rc == 0, "gtpv1u_eNB_init Failed");
itti_mark_task_ready(TASK_GTPV1_U);
......
......@@ -393,7 +393,7 @@ void *s1ap_eNB_process_itti_msg(void *notUsed) {
void *s1ap_eNB_task(void *arg) {
s1ap_eNB_init();
thread_top_init("s1ap_eNB_task",1,500000,1000000,20000000);
while (1) {
(void) s1ap_eNB_process_itti_msg(NULL);
}
......
......@@ -1153,7 +1153,7 @@ void *sctp_eNB_process_itti_msg(void *notUsed)
void *sctp_eNB_task(void *arg)
{
sctp_eNB_init();
thread_top_init("sctp_eNB_task",1,500000,1000000,20000000);
while (1) {
(void) sctp_eNB_process_itti_msg(NULL);
}
......
......@@ -304,7 +304,7 @@ void *udp_eNB_task(void *args_p)
//const char *msg_name = NULL;
//instance_t instance = 0;
udp_enb_init();
thread_top_init("udp_eNB_task",1,500000,1000000,20000000);
itti_mark_task_ready(TASK_UDP);
MSC_START_USE();
......
......@@ -949,7 +949,9 @@ void init_eNB_proc(int inst) {
LOG_I(PHY,"eNB->single_thread_flag:%d\n", eNB->single_thread_flag);
if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) {
if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) && nfapi_mode!=2) {
pthread_create( &L1_proc->pthread, attr0, L1_thread, proc );
} else if ((get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) {
pthread_create( &L1_proc->pthread, attr0, L1_thread, proc );
pthread_create( &L1_proc_tx->pthread, attr1, L1_thread_tx, proc);
} else if (nfapi_mode == 2) { // this is neccesary in VNF or L2 FAPI simulator.
......
......@@ -308,9 +308,9 @@ void thread_top_init(char *thread_name,
else {
if (nfapi_mode == 2) {
if (get_nprocs() >= 8) {
for (j = 2; j < 4; j++) {
CPU_SET(j, &cpuset);
}
for (j = 1; j < 4; j++) {
CPU_SET(j, &cpuset);
}
} else {
for (j = 0; j < 2; j++) {
CPU_SET(j, &cpuset);
......
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