Commit ab092a57 authored by Y_Tomita's avatar Y_Tomita

Modified for multiple threads of UEs in L2 FAPI simulator.

parent 178e1f7b
......@@ -204,6 +204,9 @@ typedef struct {
/// condition variable for timer_thread;
pthread_cond_t cond_ticking;
//time_stats_t timer_stats;
pthread_mutex_t mutex_single_thread;
pthread_cond_t cond_single_thread;
int num_single_thread[NUMBER_OF_UE_MAX];
} SF_ticking;
typedef struct {
......@@ -889,6 +892,7 @@ typedef struct {
struct rx_tx_thread_data {
PHY_VARS_UE *UE;
UE_rxtx_proc_t *proc;
uint16_t thread_id;
};
......
......@@ -1009,7 +1009,7 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP,
{
// This is normal LTE case
LOG_D(MAC, "generate_Msg4 1 ra->Msg4_frame SFN/SF: %d.%d, frameP SFN/SF: %d.%d FOR eNB_Mod: %d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP, module_idP);
if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) {
if (((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP))||((nfapi_mode == 2)&&(cc->tdd_Config == NULL))) {
// Get RRCConnectionSetup for Piggyback
/*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block
......@@ -1419,7 +1419,8 @@ schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
if (ra->state == MSG2)
generate_Msg2(module_idP, CC_id, frameP, subframeP, ra);
else if (ra->state == MSG4 && ra->Msg4_frame == frameP && ra->Msg4_subframe == subframeP )
//else if (ra->state == MSG4 && ra->Msg4_frame == frameP && ra->Msg4_subframe == subframeP )
else if (ra->state == MSG4)
generate_Msg4(module_idP, CC_id, frameP, subframeP, ra);
else if (ra->state == WAITMSG4ACK)
check_Msg4_retransmission(module_idP, CC_id, frameP,
......
......@@ -3635,6 +3635,7 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id,
// "Got ACK/NAK for inactive harq_pid %d for UE %d/%x\n",
// harq_pid, UE_id, rnti);
if(sched_ctl->round[CC_idP][harq_pid] == 8){
LOG_E(MAC,"Got ACK/NAK for inactive harq_pid %d for UE %d/%x\n",harq_pid, UE_id, rnti);
return;
}
......
......@@ -64,7 +64,8 @@ extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES
extern unsigned char NB_INST;
#endif
extern unsigned char NB_eNB_INST;
extern unsigned char NB_UE_INST;
extern uint16_t NB_UE_INST;
extern uint16_t NB_THREAD_INST;
extern unsigned char NB_RN_INST;
extern unsigned short NODE_ID[1];
......
......@@ -109,7 +109,8 @@ eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_EN
#ifdef OPENAIR2
unsigned char NB_eNB_INST = 0;
unsigned char NB_UE_INST = 0;
uint16_t NB_UE_INST = 0;
uint16_t NB_THREAD_INST = 0;
unsigned char NB_RN_INST = 0;
unsigned char NB_INST = 0;
#endif
......
......@@ -43,7 +43,7 @@
#include "common/ran_context.h"
extern FILL_UL_INFO_MUTEX fill_ul_mutex;
extern void openair_rrc_top_init_ue( int eMBMS_active, char* uecap_xer, uint8_t cba_group_active, uint8_t HO_active);
void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char eNB_index, uint8_t first_sync) //init as MR
......@@ -103,6 +103,12 @@ mac_top_init_ue(int eMBMS_active, char *uecap_xer,
UE_mac_inst = NULL;
}
pthread_mutex_init(&fill_ul_mutex.rx_mutex,NULL);
pthread_mutex_init(&fill_ul_mutex.crc_mutex,NULL);
pthread_mutex_init(&fill_ul_mutex.sr_mutex,NULL);
pthread_mutex_init(&fill_ul_mutex.harq_mutex,NULL);
pthread_mutex_init(&fill_ul_mutex.cqi_mutex,NULL);
pthread_mutex_init(&fill_ul_mutex.rach_mutex,NULL);
LOG_I(MAC, "[MAIN] calling RRC\n");
openair_rrc_top_init_ue(eMBMS_active, uecap_xer, cba_group_active,
......
......@@ -2312,7 +2312,7 @@ ue_scheduler(const module_id_t module_idP,
UE_mac_inst[module_idP].crnti, txFrameP,
txSubframeP, eNB_indexP);
#if defined(ENABLE_ITTI)
if(module_idP == 0){
do {
// Checks if a message has been sent to MAC sub-task
itti_poll_msg(TASK_MAC_UE, &msg_p);
......@@ -2342,7 +2342,7 @@ ue_scheduler(const module_id_t module_idP,
}
}
while (msg_p != NULL);
}
#endif
//Mac_rlc_xface->frameP=frameP;
......
......@@ -932,6 +932,7 @@ pdcp_run (
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN);
#if defined(ENABLE_ITTI)
if(ctxt_pP->module_id == 0){
MessageDef *msg_p;
int result;
protocol_ctxt_t ctxt;
......@@ -1034,7 +1035,7 @@ pdcp_run (
} else {
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip);
}
}
if (ctxt_pP->enb_flag) {
stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run);
} else {
......
......@@ -34,7 +34,7 @@
#include "common/utils/LOG/log.h"
#include "UTIL/OCG/OCG_vars.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "targets/COMMON/openairinterface5g_limits.h"
#include "assertions.h"
extern boolean_t pdcp_data_ind(
......@@ -649,7 +649,7 @@ rlc_module_init (void)
rlc_rrc_data_ind = NULL;
rlc_rrc_data_conf = NULL;
rlc_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, rb_free_rlc_union);
rlc_coll_p = hashtable_create ((maxDRB + 2) * NUMBER_OF_UE_MAX, NULL, rb_free_rlc_union);
//AssertFatal(rlc_coll_p != NULL, "UNRECOVERABLE error, RLC hashtable_create failed");
if(rlc_coll_p == NULL) {
LOG_E(RLC, "UNRECOVERABLE error, RLC hashtable_create failed\n");
......
......@@ -128,6 +128,15 @@ typedef struct IF_Module_s{
pthread_mutex_t if_mutex;
}IF_Module_t;
typedef struct {
pthread_mutex_t rx_mutex;
pthread_mutex_t crc_mutex;
pthread_mutex_t sr_mutex;
pthread_mutex_t harq_mutex;
pthread_mutex_t cqi_mutex;
pthread_mutex_t rach_mutex;
}FILL_UL_INFO_MUTEX;
/*Initial */
IF_Module_t *IF_Module_init(int Mod_id);
void IF_Module_kill(int Mod_id);
......
......@@ -47,7 +47,7 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND
int timing_advance_update;
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_lock(&fill_ul_mutex.rx_mutex);
UL_INFO->rx_ind.sfn_sf = frame<<4| subframe;
......@@ -82,7 +82,7 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND
UL_INFO->rx_ind.rx_indication_body.number_of_pdus++;
UL_INFO->rx_ind.sfn_sf = frame<<4 | subframe;
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_unlock(&fill_ul_mutex.rx_mutex);
}
......@@ -90,7 +90,7 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND
void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti) {
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_lock(&fill_ul_mutex.sr_mutex);
nfapi_sr_indication_t *sr_ind = &UL_INFO->sr_ind;
nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body;
......@@ -124,13 +124,13 @@ void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_I
//UL_INFO->rx_ind.rx_indication_body.number_of_pdus++;
sr_ind_body->number_of_srs++;
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_unlock(&fill_ul_mutex.sr_mutex);
}
void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti) {
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_lock(&fill_ul_mutex.crc_mutex);
// REMEMBER HAVE EXCHANGED THE FOLLOWING TWO LINES HERE!
nfapi_crc_indication_pdu_t *pdu = &UL_INFO->crc_ind.crc_indication_body.crc_pdu_list[UL_INFO->crc_ind.crc_indication_body.number_of_crcs];
......@@ -153,13 +153,13 @@ void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_
LOG_D(PHY, "%s() rnti:%04x pdus:%d\n", __FUNCTION__, pdu->rx_ue_information.rnti, UL_INFO->crc_ind.crc_indication_body.number_of_crcs);
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_unlock(&fill_ul_mutex.crc_mutex);
}
void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI) {
LOG_D(MAC, "fill_rach_indication_UE_MAC 1 \n");
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_lock(&fill_ul_mutex.rach_mutex);
// UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
UL_INFO->rach_ind.rach_indication_body.number_of_preambles = 1;
......@@ -200,13 +200,13 @@ void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL
// free(UL_INFO);
//}
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_unlock(&fill_ul_mutex.rach_mutex);
}
void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti) {
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_lock(&fill_ul_mutex.cqi_mutex);
nfapi_cqi_indication_pdu_t *pdu = &UL_INFO->cqi_ind.cqi_pdu_list[UL_INFO->cqi_ind.number_of_cqis];
nfapi_cqi_indication_raw_pdu_t *raw_pdu = &UL_INFO->cqi_ind.cqi_raw_pdu_list[UL_INFO->cqi_ind.number_of_cqis];
......@@ -235,14 +235,14 @@ void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subfram
UL_INFO->cqi_ind.number_of_cqis++;
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_unlock(&fill_ul_mutex.cqi_mutex);
}
void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti)
{
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_lock(&fill_ul_mutex.harq_mutex);
nfapi_harq_indication_pdu_t *pdu = &UL_INFO->harq_ind.harq_indication_body.harq_pdu_list[UL_INFO->harq_ind.harq_indication_body.number_of_harqs];
int i;
......@@ -273,7 +273,7 @@ void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IN
}
UL_INFO->harq_ind.harq_indication_body.number_of_harqs++;
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_unlock(&fill_ul_mutex.harq_mutex);
}
......@@ -287,7 +287,7 @@ void fill_uci_harq_indication_UE_MAC(int Mod_id,
uint16_t tdd_multiplexing_mask*/) {
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_lock(&fill_ul_mutex.harq_mutex);
nfapi_harq_indication_t *ind = &UL_INFO->harq_ind;
nfapi_harq_indication_body_t *body = &ind->harq_indication_body;
nfapi_harq_indication_pdu_t *pdu = &body->harq_pdu_list[UL_INFO->harq_ind.harq_indication_body.number_of_harqs];
......@@ -357,7 +357,7 @@ void fill_uci_harq_indication_UE_MAC(int Mod_id,
UL_INFO->harq_ind.harq_indication_body.number_of_harqs++;
LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n", UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
pthread_mutex_unlock(&fill_ul_mutex.harq_mutex);
}
......@@ -659,7 +659,7 @@ int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //,
}
}
else {
LOG_E(MAC,"[UE %d] Frame %d, subframe %d : DLSCH PDU from NFAPI not for this UE \n",Mod_id, sfn,sf);
LOG_D(MAC,"[UE %d] Frame %d, subframe %d : DLSCH PDU from NFAPI not for this UE \n",Mod_id, sfn,sf);
i++;
}
}
......@@ -697,7 +697,7 @@ int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //,
}
else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) {
// RA-RNTI case
LOG_E(MAC,"dl_config_req_UE_MAC 4 Received RAR? \n");
LOG_D(MAC,"dl_config_req_UE_MAC 4 Received RAR? \n");
// RNTI parameter not actually used. Provided only to comply with existing function definition.
// Not sure about parameters to fill the preamble index.
//rnti_t c_rnti = UE_mac_inst[Mod_id].crnti;
......
......@@ -18,7 +18,7 @@
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
UL_IND_t *UL_INFO;
FILL_UL_INFO_MUTEX fill_ul_mutex;
nfapi_tx_request_pdu_t* tx_request_pdu_list;
// New
/// Pointers to config_request types. Used from nfapi callback functions.
......
......@@ -51,7 +51,7 @@ extern LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue;
extern unsigned char NB_INST;
#endif
extern unsigned char NB_eNB_INST;
extern unsigned char NB_UE_INST;
extern uint16_t NB_UE_INST;
extern unsigned short NODE_ID[1];
extern void* bigphys_malloc(int);
#endif
......
......@@ -40,7 +40,7 @@
// FIXME review these externs
extern unsigned char NB_eNB_INST;
extern unsigned char NB_UE_INST;
extern uint16_t NB_UE_INST;
char *make_port_str_from_ueid(const char *base_port_str, int ueid);
......
......@@ -144,9 +144,10 @@
{"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:23, TYPE_INT, 0}, \
{"emul-iface", CONFIG_HLP_EMULIFACE, 0, strptr:&emul_iface, defstrval:"lo", TYPE_STRING, 100}, \
{"L2-emul", NULL, 0, u8ptr:&nfapi_mode, defuintval:3, TYPE_UINT8, 0}, \
{"num-ues", NULL, 0, u8ptr:&(NB_UE_INST), defuintval:1, TYPE_UINT8, 0}, \
{"num-ues", NULL, 0, u16ptr:&(NB_UE_INST), defuintval:1, TYPE_UINT16, 0}, \
{"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \
{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
{"nums_ue_thread" , NULL, 0, u16ptr:&(NB_THREAD_INST), defuintval:1, TYPE_UINT16, 0} \
}
#define DEFAULT_DLF 2680000000
......
This diff is collapsed.
......@@ -774,7 +774,7 @@ int main( int argc, char **argv )
// Default value for the number of UEs. It will hold,
// if not changed from the command line option --num-ues
NB_UE_INST=1;
NB_THREAD_INST=1;
#if defined (XFORMS)
int ret;
#endif
......@@ -807,7 +807,14 @@ int main( int argc, char **argv )
}
printf("NFAPI_MODE value: %d \n", nfapi_mode);
if(NB_THREAD_INST < 1){
printf("Running with 0 UE rxtx thread, exiting.\n");
abort();
}
if(NB_UE_INST <NB_THREAD_INST ){
printf("Number of UEs < number of UE rxtx threads, exiting.\n");
abort();
}
// Not sure if the following is needed here
/*if (CONFIG_ISFLAGSET(CONFIG_ABORT)) {
if (UE_flag == 0) {
......@@ -1154,12 +1161,14 @@ int main( int argc, char **argv )
}
#endif
while(sync_var == -1){
usleep(1000);
}
printf("Sending sync to all threads (%p,%p,%p)\n",&sync_var,&sync_cond,&sync_mutex);
pthread_mutex_lock(&sync_mutex);
sync_var=0;
// sync_var=0;
pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex);
......
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