Commit e2c32228 authored by knopp's avatar knopp

removal of EXPRESSMIMO #ifdef's in lte-ue. move UE-specific code from lte-softmodem.c to lte-ue.c

parent 58ba0089
......@@ -259,15 +259,6 @@ if (${ENABLE_ITTI})
endif (${ENABLE_ITTI})
add_boolean_option(RTAI False "Use RTAI")
if (${RTAI})
set(LOWLATENCY False)
set(CPU_AFFINITY False)
add_definitions("-DENABLE_RTAI_CLOCK")
add_definitions("-DCONFIG_RTAI_LXRT_INLINE")
include_directories ("/usr/realtime/include")
include_directories ("/usr/realtime/include/asm")
set(RTAI_SOURCE sched_dlsch.c sched_rx_pdsch.c rt_wrapper.c vcd_signal_dumper.c log.c)
endif (${RTAI})
#############################
# ASN.1 grammar C code generation & dependancies
......@@ -1574,8 +1565,6 @@ add_executable(lte-softmodem
${rrc_h}
${s1ap_h}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/sched_dlsch.c
${OPENAIR_TARGETS}/RT/USER/sched_rx_pdsch.c
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c
......@@ -1611,8 +1600,6 @@ add_executable(lte-softmodem-nos1
${rrc_h}
${s1ap_h}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/sched_dlsch.c
${OPENAIR_TARGETS}/RT/USER/sched_rx_pdsch.c
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c
......
......@@ -113,12 +113,18 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "stats.h"
#endif
// In lte-enb.c
int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg, openair0_rf_map rf_map[MAX_NUM_CCs]);
int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg, openair0_rf_map rf_map[MAX_NUM_CCs]);
extern void init_eNB(void);
extern void stop_eNB(void);
extern void kill_eNB_proc(void);
// In lte-ue.c
int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg, openair0_rf_map rf_map[MAX_NUM_CCs]);
void fill_ue_band_info(void);
extern void init_UE(void);
#ifdef XFORMS
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
// at eNB 0, an UL scope for every UE
......@@ -130,9 +136,6 @@ unsigned char scope_enb_num_ue = 2;
#endif //XFORMS
pthread_t main_ue_thread;
pthread_attr_t attr_UE_thread;
......@@ -144,7 +147,6 @@ int sync_var=-1; //!< protected by mutex \ref sync_mutex.
struct sched_param sched_param_UE_thread;
#ifdef XFORMS
......@@ -284,9 +286,8 @@ openair0_config_t openair0_cfg[MAX_CARDS];
double cpuf;
char uecap_xer[1024],uecap_xer_in=0;
extern void *UE_thread(void *arg);
extern void init_UE_threads(void);
extern void kill_eNB_proc(void);
/*---------------------BMC: timespec helpers -----------------------------*/
......@@ -1120,7 +1121,6 @@ int main( int argc, char **argv )
uint16_t Nid_cell = 0;
uint8_t cooperation_flag=0, abstraction_flag=0;
uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2;
int error_code;
#if defined (XFORMS)
int ret;
......@@ -1752,43 +1752,11 @@ int main( int argc, char **argv )
rt_sleep_ns(10*100000000ULL);
pthread_attr_init (&attr_UE_thread);
pthread_attr_setstacksize(&attr_UE_thread,8192);//5*PTHREAD_STACK_MIN);
#ifndef LOWLATENCY
sched_param_UE_thread.sched_priority = sched_get_priority_max(SCHED_FIFO);
pthread_attr_setschedparam(&attr_UE_thread,&sched_param_UE_thread);
#endif
// start the main thread
if (UE_flag == 1) {
printf("Intializing UE Threads ...\n");
init_UE_threads();
sleep(1);
error_code = pthread_create(&main_ue_thread, &attr_UE_thread, UE_thread, NULL);
if (error_code!= 0) {
LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code);
return(error_code);
} else {
LOG_D( HW, "[lte-softmodem.c] Allocate UE_thread successful\n" );
pthread_setname_np( main_ue_thread, "main UE" );
}
printf("UE threads created\n");
#ifdef USE_MME
while (start_UE == 0) {
sleep(1);
}
#endif
} else {
init_eNB();
}
if (UE_flag == 1) init_UE();
else init_eNB();
// Sleep to allow all threads to setup
sleep(1);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*! \file sched_ulsch.c
* \brief ULSCH decoding thread (RTAI)
* \author R. Knopp, F. Kaltenberger
* \date 2011
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr
* \note
* \warning
*/
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include "rt_wrapper.h"
#include <sys/mman.h>
#include "PHY/types.h"
#include "PHY/defs.h"
#include "PHY/extern.h"
#include "SCHED/defs.h"
#include "MAC_INTERFACE/extern.h"
#ifdef CBMIMO1
#include "ARCH/CBMIMO1/DEVICE_DRIVER/cbmimo1_device.h"
#include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h"
#include "ARCH/CBMIMO1/DEVICE_DRIVER/defs.h"
#endif // CBMIMO1
#define DEBUG_PHY
/// Mutex for instance count on ulsch scheduling
pthread_mutex_t ulsch_mutex[NUMBER_OF_UE_MAX];
/// Condition variable for ulsch thread
pthread_cond_t ulsch_cond[NUMBER_OF_UE_MAX];
pthread_t ulsch_threads[NUMBER_OF_UE_MAX];
pthread_attr_t attr_ulsch_threads;
// activity indicators for harq_pid's
int ulsch_instance_cnt[NUMBER_OF_UE_MAX];
// process ids for cpu
int ulsch_cpuid[NUMBER_OF_UE_MAX];
// subframe number for each harq_pid (needed to store ack in right place for UL)
int ulsch_subframe[NUMBER_OF_UE_MAX];
extern int oai_exit;
/*
extern int ulsch_errors;
extern int ulsch_received;
extern int ulsch_errors_last;
extern int ulsch_received_last;
extern int ulsch_fer;
extern int current_ulsch_cqi;
*/
/** ULSCH Decoding Thread */
static void * ulsch_thread(void *param)
{
//unsigned long cpuid;
unsigned int ulsch_thread_index = (unsigned int)param;
RTIME time_in,time_out;
#ifdef RTAI
RT_TASK *task;
char ulsch_thread_name[64];
#endif
int eNB_id = 0, UE_id = 0;
PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[eNB_id];
if ((ulsch_thread_index <0) || (ulsch_thread_index>NUMBER_OF_UE_MAX)) {
LOG_E(PHY,"[SCHED][ULSCH] Illegal ulsch_thread_index %d!!!!\n",ulsch_thread_index);
return 0;
}
#ifdef RTAI
sprintf(ulsch_thread_name,"ULSCH_THREAD%d",ulsch_thread_index);
LOG_I(PHY,"[SCHED][ULSCH] starting ulsch_thread %s for process %d\n",
ulsch_thread_name,
ulsch_thread_index);
task = rt_task_init_schmod(nam2num(ulsch_thread_name), 0, 0, 0, SCHED_FIFO, 0xF);
if (task==NULL) {
LOG_E(PHY,"[SCHED][ULSCH] Problem starting ulsch_thread_index %d!!!!\n",ulsch_thread_index);
return 0;
} else {
LOG_I(PHY,"[SCHED][ULSCH] ulsch_thread for process %d started with id %p\n",
ulsch_thread_index,
task);
}
#endif
mlockall(MCL_CURRENT | MCL_FUTURE);
//rt_set_runnable_on_cpuid(task,1);
//cpuid = rtai_cpuid();
#ifdef HARD_RT
rt_make_hard_real_time();
#endif
//ulsch_cpuid[ulsch_thread_index] = cpuid;
while (!oai_exit) {
if (pthread_mutex_lock(&ulsch_mutex[ulsch_thread_index]) != 0) {
LOG_E(PHY,"[SCHED][ULSCH] error locking mutex.\n");
} else {
while (ulsch_instance_cnt[ulsch_thread_index] < 0) {
pthread_cond_wait(&ulsch_cond[ulsch_thread_index],&ulsch_mutex[ulsch_thread_index]);
}
if (pthread_mutex_unlock(&ulsch_mutex[ulsch_thread_index]) != 0) {
LOG_E(PHY,"[SCHED][ULSCH] error unlocking mutex.\n");
}
}
if (oai_exit) break;
LOG_D(PHY,"[SCHED][ULSCH] Frame %d: Calling ulsch_decoding with ulsch_thread_index = %d\n",phy_vars_eNB->proc[0].frame_tx,ulsch_thread_index);
time_in = rt_get_time_ns();
ulsch_decoding_procedures(ulsch_subframe[ulsch_thread_index]<<1,ulsch_thread_index,phy_vars_eNB,0);
time_out = rt_get_time_ns();
if (pthread_mutex_lock(&ulsch_mutex[ulsch_thread_index]) != 0) {
msg("[openair][SCHED][ULSCH] error locking mutex.\n");
} else {
ulsch_instance_cnt[ulsch_thread_index]--;
if (pthread_mutex_unlock(&ulsch_mutex[ulsch_thread_index]) != 0) {
msg("[openair][SCHED][ULSCH] error unlocking mutex.\n");
}
}
}
#ifdef HARD_RT
rt_make_soft_real_time();
#endif
msg("[openair][SCHED][ULSCH] ULSCH thread %d exiting\n",ulsch_thread_index);
return 0;
}
int init_ulsch_threads(void)
{
int error_code, return_code=0;
struct sched_param p;
int ulsch_thread_index;
// later loop on all harq_pids, do 0 for now
for (ulsch_thread_index=0; ulsch_thread_index<NUMBER_OF_UE_MAX; ulsch_thread_index++) {
pthread_mutex_init(&ulsch_mutex[ulsch_thread_index],NULL);
pthread_cond_init(&ulsch_cond[ulsch_thread_index],NULL);
pthread_attr_init (&attr_ulsch_threads);
pthread_attr_setstacksize(&attr_ulsch_threads,OPENAIR_THREAD_STACK_SIZE);
//attr_ulsch_threads.priority = 1;
p.sched_priority = OPENAIR_THREAD_PRIORITY;
pthread_attr_setschedparam (&attr_ulsch_threads, &p);
#ifndef RTAI_ISNT_POSIX
pthread_attr_setschedpolicy (&attr_ulsch_threads, SCHED_FIFO);
#endif
ulsch_instance_cnt[ulsch_thread_index] = -1;
rt_printk("[openair][SCHED][ULSCH][INIT] Allocating ULSCH thread for ulsch_thread_index %d\n",ulsch_thread_index);
error_code = pthread_create(&ulsch_threads[ulsch_thread_index],
&attr_ulsch_threads,
ulsch_thread,
(void *)ulsch_thread_index);
if (error_code!= 0) {
rt_printk("[openair][SCHED][ULSCH][INIT] Could not allocate ulsch_thread %d, error %d\n",ulsch_thread_index,error_code);
return_code+=error_code;
//return(error_code);
} else {
rt_printk("[openair][SCHED][ULSCH][INIT] Allocate ulsch_thread %d successful\n",ulsch_thread_index);
//return(0);
}
}
return(return_code);
}
void cleanup_ulsch_threads(void)
{
int ulsch_thread_index;
for (ulsch_thread_index=0; ulsch_thread_index<NUMBER_OF_UE_MAX; ulsch_thread_index++) {
// pthread_exit(&ulsch_threads[ulsch_thread_index]);
rt_printk("[openair][SCHED][ULSCH] Scheduling ulsch_thread %d to exit\n",ulsch_thread_index);
ulsch_instance_cnt[ulsch_thread_index] = 0;
if (pthread_cond_signal(&ulsch_cond[ulsch_thread_index]) != 0)
rt_printk("[openair][SCHED][ULSCH] ERROR pthread_cond_signal\n");
else
rt_printk("[openair][SCHED][ULSCH] Signalled ulsch_thread %d to exit\n",ulsch_thread_index);
rt_printk("[openair][SCHED][ULSCH] Exiting ...\n");
pthread_cond_destroy(&ulsch_cond[ulsch_thread_index]);
pthread_mutex_destroy(&ulsch_mutex[ulsch_thread_index]);
}
}
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