Commit a3380204 authored by Raymond Knopp's avatar Raymond Knopp

addition of Sidelink UE-UE stub and initial MAC scheduling for Sidelink for off-network scenario

parent d34ac165
...@@ -1096,6 +1096,9 @@ set(PHY_SRC ...@@ -1096,6 +1096,9 @@ set(PHY_SRC
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pch.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pch.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/slss.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sldch.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/slsch.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/group_hopping.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/group_hopping.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/srs_modulation.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/srs_modulation.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/drs_modulation.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/drs_modulation.c
...@@ -1946,7 +1949,7 @@ add_executable(lte-softmodem-stub ...@@ -1946,7 +1949,7 @@ add_executable(lte-softmodem-stub
${OPENAIR_TARGETS}/COMMON/create_tasks.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
#${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/system.c
${GTPU_need_ITTI} ${GTPU_need_ITTI}
......
...@@ -864,11 +864,80 @@ typedef enum { ...@@ -864,11 +864,80 @@ typedef enum {
} RX_type_t; } RX_type_t;
#ifdef Rel14
typedef enum { typedef enum {
DCI_COMMON_SPACE, DCI_COMMON_SPACE,
DCI_UE_SPACE DCI_UE_SPACE
} dci_space_t; } dci_space_t;
typedef struct {
uint16_t slss_id;
uint8_t *slmib;
} SLSS_t;
typedef struct {
// SL Configuration
/// Number of SL resource blocks (1-100)
uint32_t N_SL_RB;
/// prb-start (0-99)
uint32_t prb_Start;
/// prb-End (0-99)
uint32_t prb_End;
/// SL-OffsetIndicator (0-10239)
uint32_t SL_OffsetIndicator;
/// PSCCH subframe bitmap, first 64-bits (up to 40 bits for Rel 12)
uint64_t bitmap1;
/// PSCCH subframe bitmap, 2nd 64-bits (up to 100 bits for Rel 14)
uint64_t bitmap2;
// SCI parameters
/// npscch resource index
uint32_t n_pscch;
/// format of SCI (0,1)
uint32_t format;
/// SCI0 frequency hopping flag
uint32_t freq_hopping_flag;
/// SCI0 Resource Block Coding
uint32_t resource_block_coding;
/// SCI0 Time Resource Pattern for SLSCH
uint32_t time_resource_pattern;
/// SCI0 MCS for SLSCH
uint32_t mcs;
/// SCI0 Timing advance indication for SLSCH
uint32_t timing_advance_indication;
/// SCI0 Group Destination ID for SLSCH
uint32_t group_destination_id;
// SLSCH Parameters
/// Number of Subbands (36.213 14.1.1.2)
uint32_t Nsb;
/// N_RB_HO (36.213 14.1.1.2)
uint32_t N_RB_HO;
/// n_ss_PSSCH (36.211 9.2.4)
uint32_t n_ss_PSSCH;
/// n_ssf_PSSCH
uint32_t n_ssf_PSSCH;
/// cinit (36.331 hoppingParameter-r12)
uint32_t cinit;
/// redundancy version
uint32_t rvidx;
/// n_prime_VRB (36.213 14.1.1.2.1)
uint32_t n_prime_VRB;
/// M_RB_PSSCH_RP (36.213 14.1.3
uint32_t M_RB_PSSCH_RP;
/// n_prime_PRB (36.213 14.1.1.4
uint32_t n_prime_PRB;
/// m_nprime_PRB_PSSCH (36.213 14.1.3)
uint32_t m_nprime_PRB_PSCCH;
uint8_t *payload;
} SLSCH_t;
typedef struct {
} SLDCH_t;
#endif
/**@}*/ /**@}*/
#endif #endif
...@@ -1479,6 +1479,23 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, ...@@ -1479,6 +1479,23 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB,
DCI_ALLOC_t *dci_alloc, DCI_ALLOC_t *dci_alloc,
uint8_t subframe); uint8_t subframe);
/*! \brief Top-level generation route for Sidelink BCH,PSS and SSS
\param ue pointer to UE descriptor
\param slss pointer to SLSS configuration and payload
*/
void generate_slss(PHY_VARS_UE *ue,SLSS_t *slss);
/*! \brief Top-level generation route for Sidelink Discovery Channel
\param ue pointer to UE descriptor
\param sldch pointer to SLDCH configuration and payload
*/
void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch);
/*! \brief Top-level generation route for Sidelink Shared Channel
\param ue pointer to UE descriptor
\param slsch pointer to SLSCH configuration and payload
*/
void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slss);
void generate_64qam_table(void); void generate_64qam_table(void);
void generate_16qam_table(void); void generate_16qam_table(void);
......
...@@ -137,6 +137,8 @@ static inline void* malloc16_clear( size_t size ) ...@@ -137,6 +137,8 @@ static inline void* malloc16_clear( size_t size )
#include "targets/ARCH/COMMON/common_lib.h" #include "targets/ARCH/COMMON/common_lib.h"
#include "targets/COMMON/openairinterface5g_limits.h" #include "targets/COMMON/openairinterface5g_limits.h"
#include "openair2/LAYER2/MAC/defs.h"
#if defined(EXMIMO) || defined(OAI_USRP) #if defined(EXMIMO) || defined(OAI_USRP)
//#define NUMBER_OF_eNB_MAX 1 //#define NUMBER_OF_eNB_MAX 1
//#define NUMBER_OF_UE_MAX 16 //#define NUMBER_OF_UE_MAX 16
......
...@@ -140,6 +140,19 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t ...@@ -140,6 +140,19 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t
@param phy_vars_rn pointer to RN variables @param phy_vars_rn pointer to RN variables
*/ */
int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn);
/*! \brief Scheduling for UE Sidelink RX procedures in normal subframes.
@param ue Pointer to UE variables on which to act
@param proc Pointer to RXn_TXnp4 proc information
*/
void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc);
/*! \brief Scheduling for UE Sidelink TX procedures in normal subframes.
@param ue Pointer to UE variables on which to act
@param proc Pointer to RXn_TXnp4 proc information
*/
void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc);
int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,
uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,
relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn);
......
...@@ -2368,6 +2368,27 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ...@@ -2368,6 +2368,27 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin
} }
void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) {
int subframe_tx = proc->subframe_tx;
int frame_tx = proc->frame_tx;
SLSS_t *slss;
SLDCH_t *sldch;
SLSCH_t *slsch;
LOG_D(PHY,"****** start Sidelink TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, subframe_tx);
// check for SLBCH/SLSS
if ((slss = ue_get_slss(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slss(ue,slss);
// check for SLDCH
if ((sldch = ue_get_sldch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_sldch(ue,sldch);
// check for SLSCH
if ((slsch = ue_get_slsch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slsch(ue,slsch);
}
void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type) { void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type) {
...@@ -4757,6 +4778,11 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *pr ...@@ -4757,6 +4778,11 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *pr
#endif #endif
void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) {
}
int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,
uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,
relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) {
......
...@@ -69,8 +69,9 @@ ...@@ -69,8 +69,9 @@
#endif #endif
#ifdef Rel14 #ifdef Rel14
#include "SystemInformationBlockType1-v1310-IEs.h" #include "SystemInformationBlockType1-v1310-IEs.h"
#include "SystemInformationBlockType18-r12.h"
#endif #endif
#include "RadioResourceConfigCommonSIB.h"
#include "nfapi_interface.h" #include "nfapi_interface.h"
#include "PHY_INTERFACE/IF_Module.h" #include "PHY_INTERFACE/IF_Module.h"
...@@ -978,7 +979,7 @@ typedef struct { ...@@ -978,7 +979,7 @@ typedef struct {
/*! \brief subband bitmap confguration (for ALU icic algo purpose), in test phase */ /*! \brief subband bitmap confguration (for ALU icic algo purpose), in test phase */
typedef struct { typedef struct {
uint8_t sbmap[NUMBER_OF_SUBBANDS_MAX]; //13 = number of SB MAX for 100 PRB uint8_t sbmap[13];
uint8_t periodicity; uint8_t periodicity;
uint8_t first_subframe; uint8_t first_subframe;
uint8_t sb_size; uint8_t sb_size;
...@@ -1266,6 +1267,22 @@ typedef struct { ...@@ -1266,6 +1267,22 @@ typedef struct {
#if defined(Rel10) || defined(Rel14) #if defined(Rel10) || defined(Rel14)
/// pointer to RRC PHY configuration SCEll /// pointer to RRC PHY configuration SCEll
struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10; struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10;
/// Preconfiguration for Sidelink
struct SL_Preconfiguration_r12 *SL_Preconfiguration;
/// RX Pool for Sidelink from SIB18
SL_CommRxPoolList_r12_t commRxPool_r12;
/// TX Pool Normal for Sidelink from SIB18
struct SL_CommTxPoolList_r12 *commTxPoolNormalCommon_r12;
/// TX Pool Exceptional for Sidelink from SIB18
struct SL_CommTxPoolList_r12 *commTxPoolExceptional_r12;
/// Common Sync Config for Sidelink from SIB18
struct SL_SyncConfigList_r12 *commSyncConfig_r12;
/// Dedicated Sync TX control for Sidelink
struct SL_SyncTxControl_r12 *sl_SyncTxControl_r12;
/// Dedicated Discovery TX control for Sidelink
struct SL_DiscConfig_r12 *sl_DiscConfig_r12;
/// Dedicated TX config for Sidelink
struct SL_CommConfig_r12 *sl_CommConfig_r12;
#endif #endif
/// pointer to TDD Configuration (NULL for FDD) /// pointer to TDD Configuration (NULL for FDD)
TDD_Config_t *tdd_Config; TDD_Config_t *tdd_Config;
...@@ -1298,6 +1315,11 @@ typedef struct { ...@@ -1298,6 +1315,11 @@ typedef struct {
RAR_PDU RAR_pdu; RAR_PDU RAR_pdu;
/// Incoming DLSCH pdu for PHY /// Incoming DLSCH pdu for PHY
DLSCH_PDU DLSCH_pdu[NUMBER_OF_UE_MAX][2]; DLSCH_PDU DLSCH_pdu[NUMBER_OF_UE_MAX][2];
#ifdef Rel14
int sltx_active;
SLSCH_t slsch;
ULSCH_PDU slsch_pdu;
#endif
/// number of attempt for rach /// number of attempt for rach
uint8_t RA_attempt_number; uint8_t RA_attempt_number;
/// Random-access procedure flag /// Random-access procedure flag
...@@ -1409,6 +1431,8 @@ typedef struct { ...@@ -1409,6 +1431,8 @@ typedef struct {
uint8_t n_adj_cells; uint8_t n_adj_cells;
} neigh_cell_id_t; } neigh_cell_id_t;
#include "proto.h" #include "proto.h"
/*@}*/ /*@}*/
#endif /*__LAYER2_MAC_DEFS_H__ */ #endif /*__LAYER2_MAC_DEFS_H__ */
......
...@@ -476,10 +476,33 @@ int ue_query_mch(uint8_t Mod_id,uint8_t CC_id, uint32_t frame,sub_frame_t subfra ...@@ -476,10 +476,33 @@ int ue_query_mch(uint8_t Mod_id,uint8_t CC_id, uint32_t frame,sub_frame_t subfra
@param eNB_id Index of eNB that UE is attached to @param eNB_id Index of eNB that UE is attached to
@param rnti C_RNTI of UE @param rnti C_RNTI of UE
@param subframe subframe number @param subframe subframe number
@returns 0 for no SR, 1 for SR
*/ */
void ue_get_sdu(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe, uint8_t eNB_index,uint8_t *ulsch_buffer,uint16_t buflen,uint8_t *access_mode); void ue_get_sdu(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe, uint8_t eNB_index,uint8_t *ulsch_buffer,uint16_t buflen,uint8_t *access_mode);
/* \brief Called by PHY to get sdu for PSBCH/SSS/PSS transmission.
@param Mod_id Instance id of UE in machine
@param frame_tx TX frame index
@param subframe_tx TX subframe index
@returns pointer to SLSS_t descriptor
*/
SLSS_t *ue_get_slss(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe);
/* \brief Called by PHY to get sdu for PSDCH transmission.
@param Mod_id Instance id of UE in machine
@param frame_tx TX frame index
@param subframe_tx TX subframe index
@returns pointer to SLDCH_t descriptor
*/
SLDCH_t *ue_get_sldch(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe);
/* \brief Called by PHY to get sdu for PSSCH transmission.
@param Mod_id Instance id of UE in machine
@param frame_tx TX frame index
@param subframe_tx TX subframe index
@returns pointer to SLSCH_t descriptor
*/
SLSCH_t *ue_get_slsch(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe);
/* \brief Function called by PHY to retrieve information to be transmitted using the RA procedure. If the UE is not in PUSCH mode for a particular eNB index, this is assumed to be an Msg3 and MAC attempts to retrieves the CCCH message from RRC. If the UE is in PUSCH mode for a particular eNB index and PUCCH format 0 (Scheduling Request) is not activated, the MAC may use this resource for random-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321) /* \brief Function called by PHY to retrieve information to be transmitted using the RA procedure. If the UE is not in PUSCH mode for a particular eNB index, this is assumed to be an Msg3 and MAC attempts to retrieves the CCCH message from RRC. If the UE is in PUSCH mode for a particular eNB index and PUCCH format 0 (Scheduling Request) is not activated, the MAC may use this resource for random-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321)
@param Mod_id Index of UE instance @param Mod_id Index of UE instance
@param Mod_id Component Carrier Index @param Mod_id Component Carrier Index
......
/* /*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * Licensed to the OpenAirInterface (OAI) Software Alliance under one
* contributor license agreements. See the NOTICE file distributed with * or more contributor license agreements. See the NOTICE file
* this work for additional information regarding copyright ownership. * distributed with this work for additional information regarding
* The OpenAirInterface Software Alliance licenses this file to You under * copyright ownership. The OpenAirInterface Software Alliance
* the OAI Public License, Version 1.1 (the "License"); you may not use this file * licenses this file to You under the OAI Public License, Version 1.1
* except in compliance with the License. * (the "License"); you may not use this file except in compliance
* You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -1493,14 +1493,14 @@ for (lcid=DCCH; (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE) ; lcid ...@@ -1493,14 +1493,14 @@ for (lcid=DCCH; (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE) ; lcid
sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].crnti,
eNB_index, eNB_index,
frameP, frameP,
ENB_FLAG_NO, ENB_FLAG_NO,
MBMS_FLAG_NO, MBMS_FLAG_NO,
lcid, lcid,
buflen_remain, buflen_remain,
(char *)&ulsch_buff[sdu_length_total]); (char *)&ulsch_buff[sdu_length_total]);
AssertFatal (buflen_remain >= sdu_lengths[num_sdus], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", AssertFatal (buflen_remain >= sdu_lengths[num_sdus], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n",
...@@ -2666,3 +2666,75 @@ int get_db_dl_PathlossChange(uint8_t dl_PathlossChange) ...@@ -2666,3 +2666,75 @@ int get_db_dl_PathlossChange(uint8_t dl_PathlossChange)
break; break;
} }
} }
SLSS_t *ue_get_slss(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) {
return((SLSS_t*)NULL);
}
SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) {
return((SLDCH_t*)NULL);
}
SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframeP) {
mac_rlc_status_resp_t rlc_status;
uint32_t absSF = (frameP*10)+subframeP;
UE_MAC_INST *ue = &UE_mac_inst[module_idP];
int rvtab[4] = {0,2,3,1};
int sdu_length;
// Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH)
SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch;
LOG_D(MAC,"Checking SLSCH for absSF %d\n",absSF);
if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period
ue->sltx_active = 0;
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3,
0xFFFF);
if (rlc_status.bytes_in_buffer > 0) {
LOG_I(MAC,"Scheduling for %d bytes in Sidelink buffer\n",rlc_status.bytes_in_buffer);
// Fill in group id for off-network communications
ue->sltx_active = 1;
}
} // we're not in the SCCH period
else if (((absSF & 3) == 0 ) &&
(ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC
// 10 PRBs, mcs 19
int TBS = 4584/8;
int req;
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3,
0xFFFF);
if (TBS<=rlc_status.bytes_in_buffer) req=TBS;
else req = rlc_status.bytes_in_buffer;
sdu_length = mac_rlc_data_req(module_idP,
0x1234,
0,
frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
3,
req,
(char*)ue->slsch_pdu.payload);
LOG_I(MAC,"got %d bytes from Sidelink buffer (%d requested)\n",sdu_length,req);
if (sdu_length > 0) {
slsch->payload = (unsigned char*)ue->slsch_pdu.payload;
slsch->rvidx = 0;
// fill in SLSCH configuration
return(&ue->slsch);
}
else { // handle retransmission of SDU
slsch->rvidx = rvtab[absSF&3];
return(&ue->slsch);
}
}
return(NULL);
}
...@@ -1701,6 +1701,7 @@ rrc_pdcp_config_req ( ...@@ -1701,6 +1701,7 @@ rrc_pdcp_config_req (
if (ctxt_pP->enb_flag == ENB_FLAG_NO) { if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
pdcp_p->is_ue = TRUE; pdcp_p->is_ue = TRUE;
pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti;
} else { } else {
pdcp_p->is_ue = FALSE; pdcp_p->is_ue = FALSE;
} }
...@@ -1719,9 +1720,9 @@ rrc_pdcp_config_req ( ...@@ -1719,9 +1720,9 @@ rrc_pdcp_config_req (
} }
pdcp_p->first_missing_pdu = -1; pdcp_p->first_missing_pdu = -1;
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n", LOG_I(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP); rb_idP);
break; break;
case CONFIG_ACTION_MODIFY: case CONFIG_ACTION_MODIFY:
...@@ -1778,10 +1779,10 @@ rrc_pdcp_config_req ( ...@@ -1778,10 +1779,10 @@ rrc_pdcp_config_req (
if (ctxt_pP->enb_flag == ENB_FLAG_NO) { if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
pdcp_p->is_ue = TRUE; pdcp_p->is_ue = TRUE;
pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti;
} else { } else {
pdcp_p->is_ue = FALSE; pdcp_p->is_ue = FALSE;
} }
pdcp_p->next_pdcp_tx_sn = 0; pdcp_p->next_pdcp_tx_sn = 0;
pdcp_p->next_pdcp_rx_sn = 0; pdcp_p->next_pdcp_rx_sn = 0;
...@@ -1798,9 +1799,9 @@ rrc_pdcp_config_req ( ...@@ -1798,9 +1799,9 @@ rrc_pdcp_config_req (
} }
pdcp_p->first_missing_pdu = -1; pdcp_p->first_missing_pdu = -1;
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Inserting PDCP instance in collection key 0x%"PRIx64"\n", LOG_I(PDCP,PROTOCOL_PDCP_CTXT_FMT" Inserting PDCP instance in collection key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), key); PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), key);
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d configured\n", LOG_I(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP); rb_idP);
} }
......
...@@ -421,7 +421,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -421,7 +421,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB);
if (rab_id != 0) { if (rab_id != 0) {
LOG_D(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ " LOG_I(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ "
"/ %d Bytes --->][PDCP][MOD %u][RB %u]\n", "/ %d Bytes --->][PDCP][MOD %u][RB %u]\n",
ctxt_cpy.frame, ctxt_cpy.frame,
(ctxt_cpy.enb_flag) ? "eNB" : "UE", (ctxt_cpy.enb_flag) ? "eNB" : "UE",
...@@ -583,7 +583,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -583,7 +583,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
ctxt.enb_flag = ctxt_cpy.enb_flag; ctxt.enb_flag = ctxt_cpy.enb_flag;
#ifdef PDCP_DEBUG #ifdef PDCP_DEBUG
LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d\n", pdcp_read_header_g.rb_id); LOG_I(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d\n", pdcp_read_header_g.rb_id);
#endif #endif
if (ctxt_cpy.enb_flag) { if (ctxt_cpy.enb_flag) {
...@@ -682,13 +682,13 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -682,13 +682,13 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
} else { // enb_flag } else { // enb_flag
if (rab_id != 0) { if (rab_id != 0) {
if (rab_id == UE_IP_DEFAULT_RAB_ID) { if (rab_id == UE_IP_DEFAULT_RAB_ID) {
LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", LOG_I(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
ctxt.module_id, ctxt.rnti, ctxt.enb_flag); ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
} else { } else {
rab_id = rab_id % maxDRB; rab_id = rab_id % maxDRB;
LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n",
ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
...@@ -697,14 +697,14 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -697,14 +697,14 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
if (h_rc == HASH_TABLE_OK) { if (h_rc == HASH_TABLE_OK) {
rab_id = pdcp_p->rb_id; rab_id = pdcp_p->rb_id;
#ifdef PDCP_DEBUG #ifdef PDCP_DEBUG
LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n",
ctxt.frame, ctxt.frame,
pdcp_read_header_g.inst, pdcp_read_header_g.inst,
len, len,
nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr),
pdcp_read_header_g.rb_id); pdcp_read_header_g.rb_id);
LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n",
ctxt.frame, ctxt.frame,
pdcp_read_header_g.inst, pdcp_read_header_g.inst,
pdcp_read_header_g.rb_id, pdcp_read_header_g.rb_id,
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "assertions.h" #include "assertions.h"
#include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/LOG/vcd_signal_dumper.h"
//#define DEBUG_MAC_INTERFACE 1 #define DEBUG_MAC_INTERFACE 1
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct mac_data_ind mac_rlc_deserialize_tb ( struct mac_data_ind mac_rlc_deserialize_tb (
...@@ -143,7 +143,7 @@ tbs_size_t mac_rlc_data_req( ...@@ -143,7 +143,7 @@ tbs_size_t mac_rlc_data_req(
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_REQ,VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_REQ,VCD_FUNCTION_IN);
#ifdef DEBUG_MAC_INTERFACE #ifdef DEBUG_MAC_INTERFACE
LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d, Num_tb %d\n", LOG_I(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d, Num_tb %d\n",
PROTOCOL_CTXT_ARGS((&ctxt)), PROTOCOL_CTXT_ARGS((&ctxt)),
channel_idP, channel_idP,
RLC_MAX_LC, RLC_MAX_LC,
...@@ -196,7 +196,7 @@ tbs_size_t mac_rlc_data_req( ...@@ -196,7 +196,7 @@ tbs_size_t mac_rlc_data_req(
break; break;
case RLC_MODE_UM: case RLC_MODE_UM:
if (!enb_flagP) rlc_um_set_nb_bytes_requested_by_mac(&rlc_union_p->rlc.um,tb_sizeP); if (!enb_flagP) rlc_um_set_nb_bytes_requested_by_mac(&rlc_union_p->rlc.um,tb_sizeP);
data_request = rlc_um_mac_data_request(&ctxt, &rlc_union_p->rlc.um,enb_flagP); data_request = rlc_um_mac_data_request(&ctxt, &rlc_union_p->rlc.um,enb_flagP);
ret_tb_size = mac_rlc_serialize_tb(buffer_pP, data_request.data); ret_tb_size = mac_rlc_serialize_tb(buffer_pP, data_request.data);
break; break;
...@@ -390,7 +390,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( ...@@ -390,7 +390,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind(
rlc_mode = rlc_union_p->mode; rlc_mode = rlc_union_p->mode;
} else { } else {
rlc_mode = RLC_MODE_NONE; rlc_mode = RLC_MODE_NONE;
//LOG_W(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); LOG_W(RLC , "[%s] RLC not configured lcid %u module %u!\n", __FUNCTION__, channel_idP, module_idP);
//LOG_D(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); //LOG_D(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP);
} }
......
...@@ -691,11 +691,16 @@ typedef struct UE_RRC_INST_s { ...@@ -691,11 +691,16 @@ typedef struct UE_RRC_INST_s {
SystemInformationBlockType9_t *sib9[NB_CNX_UE]; SystemInformationBlockType9_t *sib9[NB_CNX_UE];
SystemInformationBlockType10_t *sib10[NB_CNX_UE]; SystemInformationBlockType10_t *sib10[NB_CNX_UE];
SystemInformationBlockType11_t *sib11[NB_CNX_UE]; SystemInformationBlockType11_t *sib11[NB_CNX_UE];
uint8_t *MIB;
#ifdef Rel14
//TTN - SIB18 //TTN - SIB18
SystemInformationBlockType18_r12_t *sib18[NB_CNX_UE]; SystemInformationBlockType18_r12_t *sib18[NB_CNX_UE];
SystemInformationBlockType19_r12_t *sib19[NB_CNX_UE]; SystemInformationBlockType19_r12_t *sib19[NB_CNX_UE];
uint8_t *MIB;
SBCCH_SL_BCH_MessageType_t mib_sl[NB_CNX_UE]; SBCCH_SL_BCH_MessageType_t mib_sl[NB_CNX_UE];
/// Preconfiguration for Sidelink
struct SL_Preconfiguration_r12 *SL_Preconfiguration[NB_CNX_UE];
#endif
#if defined(Rel10) || defined(Rel14) #if defined(Rel10) || defined(Rel14)
uint8_t MBMS_flag; uint8_t MBMS_flag;
......
...@@ -183,8 +183,7 @@ void rrc_ue_process_sidelink_radioResourceConfig( ...@@ -183,8 +183,7 @@ void rrc_ue_process_sidelink_radioResourceConfig(
/** \brief Init control socket to listen to incoming packets from ProSe App /** \brief Init control socket to listen to incoming packets from ProSe App
* *
*/ */
void void rrc_control_socket_init(void);
rrc_control_socket_init();
// eNB/CH RRC Procedures // eNB/CH RRC Procedures
......
...@@ -88,6 +88,11 @@ ...@@ -88,6 +88,11 @@
#include "SIMULATION/TOOLS/defs.h" // for taus #include "SIMULATION/TOOLS/defs.h" // for taus
#ifdef Rel14
#include "SL-Preconfiguration-r12.h"
#endif
//TTN - for D2D //TTN - for D2D
#define D2D_MODE //enable d2d #define D2D_MODE //enable d2d
int ctrl_sock_fd; int ctrl_sock_fd;
...@@ -249,7 +254,7 @@ static int rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_t subState ) ...@@ -249,7 +254,7 @@ static int rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_t subState )
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index ) void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index )
{ {
UE_rrc_inst[ctxt_pP->module_id].sizeof_SIB1[eNB_index] = 0; UE_rrc_inst[ctxt_pP->module_id].sizeof_SIB1[eNB_index] = 0;
UE_rrc_inst[ctxt_pP->module_id].sizeof_SI[eNB_index] = 0; UE_rrc_inst[ctxt_pP->module_id].sizeof_SI[eNB_index] = 0;
...@@ -277,10 +282,109 @@ static void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ ...@@ -277,10 +282,109 @@ static void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt = 0; UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt = 0;
} }
#ifdef Rel14
void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
{
LOG_I(RRC,"Initializing Sidelink Pre-configuration for UE\n");
UE->SL_Preconfiguration[eNB_index] = malloc16_clear( sizeof(struct SL_Preconfiguration_r12) );
UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.rohc_Profiles_r12.profile0x0001_r12 = true;
UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.carrierFreq_r12 = 3350;
UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.maxTxPower_r12 = 0;
UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.additionalSpectrumEmission_r12 = 0;
UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.sl_bandwidth_r12 = SL_PreconfigGeneral_r12__sl_bandwidth_r12_n50;
UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.tdd_ConfigSL_r12.subframeAssignmentSL_r12 = TDD_ConfigSL_r12__subframeAssignmentSL_r12_none;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncCP_Len_r12 = SL_CP_Len_r12_normal;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncOffsetIndicator1_r12 = 0;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncOffsetIndicator2_r12 = 0;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncTxParameters_r12 = 0;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncTxThreshOoC_r12 = 0;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.filterCoefficient_r12 = FilterCoefficient_fc0;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncRefMinHyst_r12 = SL_PreconfigSync_r12__syncRefMinHyst_r12_dB0;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncRefDiffHyst_r12 = SL_PreconfigSync_r12__syncRefDiffHyst_r12_dB0;
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.ext1 = malloc16_clear(sizeof(struct SL_PreconfigSync_r12__ext1));
UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.ext1->syncTxPeriodic_r13 = NULL;
struct SL_PreconfigCommPool_r12 *preconfigpool = malloc16_clear(sizeof(struct SL_PreconfigCommPool_r12));
preconfigpool->sc_CP_Len_r12 = SL_CP_Len_r12_normal;
preconfigpool->sc_Period_r12 = SL_PeriodComm_r12_sf40;
// 20 PRBs for SL communications
preconfigpool->sc_TF_ResourceConfig_r12.prb_Num_r12 = 20;
preconfigpool->sc_TF_ResourceConfig_r12.prb_Start_r12 = 5;
preconfigpool->sc_TF_ResourceConfig_r12.prb_End_r12 = 44;
// Offset set to 0 subframes
preconfigpool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = SL_OffsetIndicator_r12_PR_small_r12;
preconfigpool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0;
// 40 ms SL Period
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = SubframeBitmapSL_r12_PR_bs40_r12;
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = CALLOC(1,5);
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = 5;
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = 0;
// 1st 4 subframes for PSCCH
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[0] = 0xF;
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[1] = 0;
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[2] = 0;
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[3] = 0;
preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[4] = 0;
preconfigpool->sc_TxParameters_r12 = 0;
preconfigpool->data_CP_Len_r12 = SL_CP_Len_r12_normal;
// 20 PRBs for SL communications
preconfigpool->data_TF_ResourceConfig_r12.prb_Num_r12 = 20;
preconfigpool->data_TF_ResourceConfig_r12.prb_Start_r12 = 5;
preconfigpool->data_TF_ResourceConfig_r12.prb_End_r12 = 44;
// Offset set to 0 subframes
preconfigpool->data_TF_ResourceConfig_r12.offsetIndicator_r12.present = SL_OffsetIndicator_r12_PR_small_r12;
preconfigpool->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0;
// 40 ms SL Period
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.present = SubframeBitmapSL_r12_PR_bs40_r12;
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = CALLOC(1,5);
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = 5;
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = 0;
// last 36 subframes for PSCCH
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[0] = 0xF0;
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[1] = 0xFF;
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[2] = 0xFF;
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[3] = 0xFF;
preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[5] = 0xFF;
preconfigpool->dataHoppingConfig_r12.hoppingParameter_r12 = 0;
preconfigpool->dataHoppingConfig_r12.numSubbands_r12 = SL_HoppingConfigComm_r12__numSubbands_r12_ns1;
preconfigpool->dataHoppingConfig_r12.rb_Offset_r12 = 0;
preconfigpool->dataTxParameters_r12 = 0;
ASN_SEQUENCE_ADD(&UE->SL_Preconfiguration[eNB_index]->preconfigComm_r12.list,preconfigpool);
// Rel13 extensions
UE->SL_Preconfiguration[eNB_index]->ext1 = NULL;
// Establish a SLRB (using DRB for now)
protocol_ctxt_t ctxt;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,0);
rrc_pdcp_config_req (&ctxt,SRB_FLAG_NO, CONFIG_ACTION_ADD,
3, UNDEF_SECURITY_MODE);
rlc_info_t rlc_info;
rlc_info.rlc_mode = RLC_MODE_UM;
rlc_info.rlc.rlc_um_info.timer_reordering = 5;
rlc_info.rlc.rlc_um_info.sn_field_length = 10;
rlc_info.rlc.rlc_um_info.is_mXch = 0;
rrc_rlc_config_req(&ctxt,SRB_FLAG_NO,MBMS_FLAG_NO,CONFIG_ACTION_ADD,
3,
rlc_info);
}
#endif
#if defined(Rel10) || defined(Rel14) #if defined(Rel10) || defined(Rel14)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if 0 #if 0
static void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index) void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index)
{ {
int i; int i;
UE_rrc_inst[ue_mod_idP].sizeof_MCCH_MESSAGE[eNB_index] = 0; UE_rrc_inst[ue_mod_idP].sizeof_MCCH_MESSAGE[eNB_index] = 0;
...@@ -296,7 +400,7 @@ static void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index) ...@@ -296,7 +400,7 @@ static void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index)
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void openair_rrc_ue_init_security( const protocol_ctxt_t* const ctxt_pP ) void openair_rrc_ue_init_security( const protocol_ctxt_t* const ctxt_pP )
{ {
#if defined(ENABLE_SECURITY) #if defined(ENABLE_SECURITY)
// uint8_t *kRRCenc; // uint8_t *kRRCenc;
...@@ -349,6 +453,12 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_ ...@@ -349,6 +453,12 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_
LOG_D(RRC,PROTOCOL_RRC_CTXT_FMT" INIT: phy_sync_2_ch_ind\n", LOG_D(RRC,PROTOCOL_RRC_CTXT_FMT" INIT: phy_sync_2_ch_ind\n",
PROTOCOL_RRC_CTXT_ARGS(&ctxt)); PROTOCOL_RRC_CTXT_ARGS(&ctxt));
#ifndef NO_RRM
send_msg(&S_rrc,msg_rrc_phy_synch_to_CH_ind(ctxt.module_id,eNB_index,UE_rrc_inst[ctxt.module_id].Mac_id));
#endif
#ifndef NO_RRM #ifndef NO_RRM
send_msg(&S_rrc,msg_rrc_phy_synch_to_CH_ind(ctxt.module_id,eNB_index,UE_rrc_inst[ctxt.module_id].Mac_id)); send_msg(&S_rrc,msg_rrc_phy_synch_to_CH_ind(ctxt.module_id,eNB_index,UE_rrc_inst[ctxt.module_id].Mac_id));
#endif #endif
...@@ -446,7 +556,7 @@ static const char const nas_attach_req_guti[] = { ...@@ -446,7 +556,7 @@ static const char const nas_attach_req_guti[] = {
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id ) void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id )
{ {
uint8_t buffer[100]; uint8_t buffer[100];
...@@ -480,7 +590,7 @@ static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* c ...@@ -480,7 +590,7 @@ static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* c
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id ) void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id )
{ {
uint8_t buffer[32], size; uint8_t buffer[32], size;
...@@ -2506,7 +2616,7 @@ const char SIBType[12][6] = {"SIB3","SIB4","SIB5","SIB6","SIB7","SIB8","SIB9","S ...@@ -2506,7 +2616,7 @@ const char SIBType[12][6] = {"SIB3","SIB4","SIB5","SIB6","SIB7","SIB8","SIB9","S
const char SIBPeriod[8][6]= {"rf8","rf16","rf32","rf64","rf128","rf256","rf512","ERR"}; const char SIBPeriod[8][6]= {"rf8","rf16","rf32","rf64","rf128","rf256","rf512","ERR"};
int siPeriod_int[7] = {80,160,320,640,1280,2560,5120}; int siPeriod_int[7] = {80,160,320,640,1280,2560,5120};
static const char* SIBreserved( long value ) const char* SIBreserved( long value )
{ {
if (value < 0 || value > 1) if (value < 0 || value > 1)
return "ERR"; return "ERR";
...@@ -2516,7 +2626,7 @@ static const char* SIBreserved( long value ) ...@@ -2516,7 +2626,7 @@ static const char* SIBreserved( long value )
return "reserved"; return "reserved";
} }
static const char* SIBbarred( long value ) const char* SIBbarred( long value )
{ {
if (value < 0 || value > 1) if (value < 0 || value > 1)
return "ERR"; return "ERR";
...@@ -2526,7 +2636,7 @@ static const char* SIBbarred( long value ) ...@@ -2526,7 +2636,7 @@ static const char* SIBbarred( long value )
return "barred"; return "barred";
} }
static const char* SIBallowed( long value ) const char* SIBallowed( long value )
{ {
if (value < 0 || value > 1) if (value < 0 || value > 1)
return "ERR"; return "ERR";
...@@ -2536,7 +2646,7 @@ static const char* SIBallowed( long value ) ...@@ -2536,7 +2646,7 @@ static const char* SIBallowed( long value )
return "allowed"; return "allowed";
} }
static const char* SIB2SoundingPresent( int value ) const char* SIB2SoundingPresent( int value )
{ {
switch (value) { switch (value) {
case SoundingRS_UL_ConfigCommon_PR_NOTHING: case SoundingRS_UL_ConfigCommon_PR_NOTHING:
...@@ -2551,7 +2661,7 @@ static const char* SIB2SoundingPresent( int value ) ...@@ -2551,7 +2661,7 @@ static const char* SIB2SoundingPresent( int value )
return "ERR"; return "ERR";
} }
static const char* SIB2numberOfRA_Preambles( long value ) const char* SIB2numberOfRA_Preambles( long value )
{ {
static char temp[4] = {0}; static char temp[4] = {0};
...@@ -2562,7 +2672,7 @@ static const char* SIB2numberOfRA_Preambles( long value ) ...@@ -2562,7 +2672,7 @@ static const char* SIB2numberOfRA_Preambles( long value )
temp[3] = 0; // terminate string temp[3] = 0; // terminate string
return temp; return temp;
} }
static const char* SIB2powerRampingStep( long value ) const char* SIB2powerRampingStep( long value )
{ {
if (value < 0 || value > 3) if (value < 0 || value > 3)
return "ERR"; return "ERR";
...@@ -2570,7 +2680,7 @@ static const char* SIB2powerRampingStep( long value ) ...@@ -2570,7 +2680,7 @@ static const char* SIB2powerRampingStep( long value )
static const char str[4][4] = {"dB0","dB2","dB4","dB6"}; static const char str[4][4] = {"dB0","dB2","dB4","dB6"};
return str[value]; return str[value];
} }
static const char* SIB2preambleInitialReceivedTargetPower( long value ) const char* SIB2preambleInitialReceivedTargetPower( long value )
{ {
static char temp[8] = {0}; static char temp[8] = {0};
...@@ -2581,7 +2691,7 @@ static const char* SIB2preambleInitialReceivedTargetPower( long value ) ...@@ -2581,7 +2691,7 @@ static const char* SIB2preambleInitialReceivedTargetPower( long value )
temp[7] = 0; // terminate string temp[7] = 0; // terminate string
return temp; return temp;
} }
static const char* SIB2preambleTransMax( long value ) const char* SIB2preambleTransMax( long value )
{ {
static char temp[5] = {0}; static char temp[5] = {0};
...@@ -2613,7 +2723,7 @@ static const char* SIB2preambleTransMax( long value ) ...@@ -2613,7 +2723,7 @@ static const char* SIB2preambleTransMax( long value )
/* unreachable but gcc warns... */ /* unreachable but gcc warns... */
return "ERR"; return "ERR";
} }
static const char* SIB2ra_ResponseWindowSize( long value ) const char* SIB2ra_ResponseWindowSize( long value )
{ {
static char temp[4] = {0}; static char temp[4] = {0};
...@@ -2626,7 +2736,7 @@ static const char* SIB2ra_ResponseWindowSize( long value ) ...@@ -2626,7 +2736,7 @@ static const char* SIB2ra_ResponseWindowSize( long value )
snprintf( temp, sizeof(temp), "sf%ld", value+2 ); snprintf( temp, sizeof(temp), "sf%ld", value+2 );
return temp; return temp;
} }
static const char* SIB2mac_ContentionResolutionTimer( long value ) const char* SIB2mac_ContentionResolutionTimer( long value )
{ {
static char temp[5] = {0}; static char temp[5] = {0};
...@@ -2636,7 +2746,7 @@ static const char* SIB2mac_ContentionResolutionTimer( long value ) ...@@ -2636,7 +2746,7 @@ static const char* SIB2mac_ContentionResolutionTimer( long value )
snprintf( temp, sizeof(temp), "sf%ld", 8 + value*8 ); snprintf( temp, sizeof(temp), "sf%ld", 8 + value*8 );
return temp; return temp;
} }
static const char* SIB2modificationPeriodCoeff( long value ) const char* SIB2modificationPeriodCoeff( long value )
{ {
static char temp[32] = {0}; static char temp[32] = {0};
...@@ -2646,7 +2756,7 @@ static const char* SIB2modificationPeriodCoeff( long value ) ...@@ -2646,7 +2756,7 @@ static const char* SIB2modificationPeriodCoeff( long value )
snprintf( temp, sizeof(temp), "n%d", (int)pow(2,value+1) ); snprintf( temp, sizeof(temp), "n%d", (int)pow(2,value+1) );
return temp; return temp;
} }
static const char* SIB2defaultPagingCycle( long value ) const char* SIB2defaultPagingCycle( long value )
{ {
static char temp[32] = {0}; static char temp[32] = {0};
...@@ -2656,7 +2766,7 @@ static const char* SIB2defaultPagingCycle( long value ) ...@@ -2656,7 +2766,7 @@ static const char* SIB2defaultPagingCycle( long value )
snprintf( temp, sizeof(temp), "rf%d", (int)pow(2,value+4) ); snprintf( temp, sizeof(temp), "rf%d", (int)pow(2,value+4) );
return temp; return temp;
} }
static const char* SIB2nB( long value ) const char* SIB2nB( long value )
{ {
if (value < 0 || value > 7) if (value < 0 || value > 7)
return "ERR"; return "ERR";
...@@ -2834,7 +2944,7 @@ int decode_PCCH_DLSCH_Message( ...@@ -2834,7 +2944,7 @@ int decode_PCCH_DLSCH_Message(
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp ) int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp )
{ {
SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]; SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
...@@ -3065,7 +3175,7 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ ...@@ -3065,7 +3175,7 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void dump_sib2( SystemInformationBlockType2_t *sib2 ) void dump_sib2( SystemInformationBlockType2_t *sib2 )
{ {
// ac_BarringInfo // ac_BarringInfo
if (sib2->ac_BarringInfo) { if (sib2->ac_BarringInfo) {
...@@ -3306,7 +3416,7 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 ) ...@@ -3306,7 +3416,7 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 )
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void dump_sib3( SystemInformationBlockType3_t *sib3 ) void dump_sib3( SystemInformationBlockType3_t *sib3 )
{ {
LOG_I( RRC, "Dumping SIB3 (see TS36.331 V8.21.0)\n" ); LOG_I( RRC, "Dumping SIB3 (see TS36.331 V8.21.0)\n" );
...@@ -3455,7 +3565,7 @@ uint64_t arfcn_to_freq(long arfcn) { ...@@ -3455,7 +3565,7 @@ uint64_t arfcn_to_freq(long arfcn) {
exit(1); exit(1);
} }
} }
static void dump_sib5( SystemInformationBlockType5_t *sib5 ) void dump_sib5( SystemInformationBlockType5_t *sib5 )
{ {
InterFreqCarrierFreqList_t interFreqCarrierFreqList = sib5->interFreqCarrierFreqList; InterFreqCarrierFreqList_t interFreqCarrierFreqList = sib5->interFreqCarrierFreqList;
int i,j; int i,j;
...@@ -3548,7 +3658,7 @@ static void dump_sib5( SystemInformationBlockType5_t *sib5 ) ...@@ -3548,7 +3658,7 @@ static void dump_sib5( SystemInformationBlockType5_t *sib5 )
} }
#if defined(Rel10) || defined(Rel14) #if defined(Rel10) || defined(Rel14)
static void dump_sib13( SystemInformationBlockType13_r9_t *sib13 ) void dump_sib13( SystemInformationBlockType13_r9_t *sib13 )
{ {
LOG_I( RRC, "[UE] Dumping SIB13\n" ); LOG_I( RRC, "[UE] Dumping SIB13\n" );
LOG_I( RRC, "[UE] dumping sib13 second time\n" ); LOG_I( RRC, "[UE] dumping sib13 second time\n" );
...@@ -3560,7 +3670,7 @@ static void dump_sib13( SystemInformationBlockType13_r9_t *sib13 ) ...@@ -3560,7 +3670,7 @@ static void dump_sib13( SystemInformationBlockType13_r9_t *sib13 )
//TTN - SIB18 //TTN - SIB18
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void dump_sib18(SystemInformationBlockType18_r12_t *sib18){ void dump_sib18(SystemInformationBlockType18_r12_t *sib18){
LOG_I( RRC, "[UE] Dumping SIB18\n" ); LOG_I( RRC, "[UE] Dumping SIB18\n" );
for (int i = 0; i < sib18->commConfig_r12->commRxPool_r12.list.count; i++) { for (int i = 0; i < sib18->commConfig_r12->commRxPool_r12.list.count; i++) {
LOG_I(RRC, " Contents of SIB18 %d/%d \n", i+1, sib18->commConfig_r12->commRxPool_r12.list.count); LOG_I(RRC, " Contents of SIB18 %d/%d \n", i+1, sib18->commConfig_r12->commRxPool_r12.list.count);
...@@ -3576,7 +3686,7 @@ static void dump_sib18(SystemInformationBlockType18_r12_t *sib18){ ...@@ -3576,7 +3686,7 @@ static void dump_sib18(SystemInformationBlockType18_r12_t *sib18){
//TTN - SIB19 //TTN - SIB19
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void dump_sib19(SystemInformationBlockType19_r12_t *sib19){ void dump_sib19(SystemInformationBlockType19_r12_t *sib19){
LOG_I( RRC, "[UE] Dumping SIB19\n" ); LOG_I( RRC, "[UE] Dumping SIB19\n" );
for (int i = 0; i < sib19->discConfig_r12->discRxPool_r12.list.count; i++) { for (int i = 0; i < sib19->discConfig_r12->discRxPool_r12.list.count; i++) {
LOG_I(RRC, " Contents of SIB18 %d/%d \n", i+1, sib19->discConfig_r12->discRxPool_r12.list.count); LOG_I(RRC, " Contents of SIB18 %d/%d \n", i+1, sib19->discConfig_r12->discRxPool_r12.list.count);
...@@ -3592,7 +3702,7 @@ static void dump_sib19(SystemInformationBlockType19_r12_t *sib19){ ...@@ -3592,7 +3702,7 @@ static void dump_sib19(SystemInformationBlockType19_r12_t *sib19){
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index ) int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index )
{ {
LOG_I( RRC, "Panos-D: decode_SI 1 \n"); LOG_I( RRC, "Panos-D: decode_SI 1 \n");
//printf("Panos-D: decode_SI 1 \n"); //printf("Panos-D: decode_SI 1 \n");
...@@ -3980,7 +4090,7 @@ void ue_meas_filtering( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ ...@@ -3980,7 +4090,7 @@ void ue_meas_filtering( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
//Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5 //Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, uint8_t eNB_index ) void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, uint8_t eNB_index )
{ {
uint8_t buffer[32], size; uint8_t buffer[32], size;
...@@ -4174,7 +4284,7 @@ void ue_measurement_report_triggering(protocol_ctxt_t* const ctxt_pP, const uint ...@@ -4174,7 +4284,7 @@ void ue_measurement_report_triggering(protocol_ctxt_t* const ctxt_pP, const uint
//check_trigger_meas_event(ue_mod_idP, frameP, eNB_index, i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms) //check_trigger_meas_event(ue_mod_idP, frameP, eNB_index, i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static uint8_t check_trigger_meas_event( uint8_t check_trigger_meas_event(
module_id_t ue_mod_idP, module_id_t ue_mod_idP,
frame_t frameP, frame_t frameP,
uint8_t eNB_index, uint8_t eNB_index,
...@@ -4301,7 +4411,7 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB ...@@ -4301,7 +4411,7 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_index, frame_t frameP, uint8_t mbsfn_sync_area ) void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_index, frame_t frameP, uint8_t mbsfn_sync_area )
{ {
protocol_ctxt_t ctxt; protocol_ctxt_t ctxt;
...@@ -4903,6 +5013,11 @@ openair_rrc_top_init_ue( ...@@ -4903,6 +5013,11 @@ openair_rrc_top_init_ue(
} }
#endif #endif
#ifdef Rel14
init_SL_preconfig(&UE_rrc_inst[module_id],0);
#endif
} else { } else {
UE_rrc_inst = NULL; UE_rrc_inst = NULL;
} }
...@@ -5189,7 +5304,7 @@ rrc_control_socket_init(){ ...@@ -5189,7 +5304,7 @@ rrc_control_socket_init(){
} }
//-------------------------------------------------------- //--------------------------------------------------------
static void *rrc_control_socket_thread_fct(void *arg) void *rrc_control_socket_thread_fct(void *arg)
{ {
int prose_addr_len; int prose_addr_len;
......
...@@ -639,6 +639,7 @@ static void get_options(void) { ...@@ -639,6 +639,7 @@ static void get_options(void) {
paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ;
paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ;
config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
printf("get_options 0, UE_flag: %d", UE_flag); printf("get_options 0, UE_flag: %d", UE_flag);
...@@ -667,11 +668,13 @@ static void get_options(void) { ...@@ -667,11 +668,13 @@ static void get_options(void) {
} }
if (UE_flag > 0) { if (UE_flag > 0) {
// set default parameters
set_default_frame_parms(frame_parms); uint8_t n_rb_dl;
paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC; paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC;
paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC;
set_default_frame_parms(frame_parms);
config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL);
config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
...@@ -687,67 +690,55 @@ static void get_options(void) { ...@@ -687,67 +690,55 @@ static void get_options(void) {
printf("Panos: get_options 9 \n"); printf("Panos: get_options 9 \n");
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp;
printf("Panos: get_options 10 \n"); printf("Panos: get_options 10 \n");
if ( cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr != NULL) { if ( (cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = debug_prach;
if ( *(cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) > 0) mode = debug_prach; if ( (cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = no_L2_connect;
if ( *(cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) > 0) mode = no_L2_connect; if ( (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = calib_prach_tx;
if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx;
}
printf("Panos: get_options 11 \n"); printf("Panos: get_options 11 \n");
if (dumpframe > 0) mode = rx_dump_frame; if (dumpframe > 0) mode = rx_dump_frame;
if ( downlink_frequency[0][0] > 0) { if ( downlink_frequency[0][0] > 0) {
printf("Panos: get_options 8 \n"); printf("Downlink frequency set to %u\n", downlink_frequency[0][0]);
for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
downlink_frequency[CC_id][1] = downlink_frequency[0][0]; frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0];
downlink_frequency[CC_id][2] = downlink_frequency[0][0]; }
downlink_frequency[CC_id][3] = downlink_frequency[0][0]; UE_scan=0;
printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); }
}
UE_scan=0;
}
printf("Panos: get_options 15 \n");
if (tddflag > 0) { if (tddflag > 0) {
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++)
frame_parms[CC_id]->frame_type = TDD; frame_parms[CC_id]->frame_type = TDD;
}
printf("Panos: get_options 16 \n");
if (frame_parms != NULL){
printf("Panos: get_options 17 \n");
if (frame_parms[0]->N_RB_DL !=0) {
printf("Panos: get_options 17 \n");
if ( frame_parms[0]->N_RB_DL < 6 ) {
frame_parms[0]->N_RB_DL = 6;
printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",frame_parms[0]->N_RB_DL);
}
if ( frame_parms[0]->N_RB_DL > 100 ) {
frame_parms[0]->N_RB_DL = 100;
printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",frame_parms[0]->N_RB_DL);
}
if ( frame_parms[0]->N_RB_DL > 50 && frame_parms[0]->N_RB_DL < 100 ) {
frame_parms[0]->N_RB_DL = 50;
printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",frame_parms[0]->N_RB_DL);
}
if ( frame_parms[0]->N_RB_DL > 25 && frame_parms[0]->N_RB_DL < 50 ) {
frame_parms[0]->N_RB_DL = 25;
printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",frame_parms[0]->N_RB_DL);
}
UE_scan = 0;
frame_parms[0]->N_RB_UL=frame_parms[0]->N_RB_DL;
for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) {
frame_parms[CC_id]->N_RB_DL=frame_parms[0]->N_RB_DL;
frame_parms[CC_id]->N_RB_UL=frame_parms[0]->N_RB_UL;
}
} }
if (n_rb_dl !=0) {
printf("NB_RB set to %d\n",n_rb_dl);
if ( n_rb_dl < 6 ) {
n_rb_dl = 6;
printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",n_rb_dl);
}
if ( n_rb_dl > 100 ) {
n_rb_dl = 100;
printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",n_rb_dl);
}
if ( n_rb_dl > 50 && n_rb_dl < 100 ) {
n_rb_dl = 50;
printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",n_rb_dl);
}
if ( n_rb_dl > 25 && n_rb_dl < 50 ) {
n_rb_dl = 25;
printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",n_rb_dl);
}
UE_scan = 0;
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
frame_parms[CC_id]->N_RB_DL=n_rb_dl;
frame_parms[CC_id]->N_RB_UL=n_rb_dl;
}
} }
printf("Panos: get_options 17 \n");
for (CC_id=1;CC_id<MAX_NUM_CCs;CC_id++) { for (CC_id=1;CC_id<MAX_NUM_CCs;CC_id++) {
tx_max_power[CC_id]=tx_max_power[0]; tx_max_power[CC_id]=tx_max_power[0];
rx_gain[0][CC_id] = rx_gain[0][0]; rx_gain[0][CC_id] = rx_gain[0][0];
tx_gain[0][CC_id] = tx_gain[0][0]; tx_gain[0][CC_id] = tx_gain[0][0];
} }
printf("Panos: get_options 6 \n");
} /* UE_flag > 0 */ } /* UE_flag > 0 */
#if T_TRACER #if T_TRACER
paramdef_t cmdline_ttraceparams[] =CMDLINE_TTRACEPARAMS_DESC ; paramdef_t cmdline_ttraceparams[] =CMDLINE_TTRACEPARAMS_DESC ;
...@@ -767,7 +758,7 @@ static void get_options(void) { ...@@ -767,7 +758,7 @@ static void get_options(void) {
// Here the configuration file is the XER encoded UE capabilities // Here the configuration file is the XER encoded UE capabilities
// Read it in and store in asn1c data structures // Read it in and store in asn1c data structures
strcpy(uecap_xer,CONFIG_GETCONFFILE); strcpy(uecap_xer,CONFIG_GETCONFFILE);
uecap_xer_in=1; uecap_xer_in=0;
printf("Panos: get_options 7 \n"); printf("Panos: get_options 7 \n");
} /* UE with config file */ } /* UE with config file */
} }
...@@ -976,10 +967,16 @@ int main( int argc, char **argv ) ...@@ -976,10 +967,16 @@ int main( int argc, char **argv )
get_options (); get_options ();
if (CONFIG_ISFLAGSET(CONFIG_ABORT)) { if (CONFIG_ISFLAGSET(CONFIG_ABORT)) {
if (UE_flag == 0) {
fprintf(stderr,"Getting configuration failed\n"); fprintf(stderr,"Getting configuration failed\n");
exit(-1); exit(-1);
}
else {
printf("Setting nfapi mode to UE_STUB_OFFNET\n");
nfapi_mode = 4;
}
} }
#if T_TRACER #if T_TRACER
T_init(T_port, 1-T_nowait, T_dont_fork); T_init(T_port, 1-T_nowait, T_dont_fork);
...@@ -993,10 +990,10 @@ int main( int argc, char **argv ) ...@@ -993,10 +990,10 @@ int main( int argc, char **argv )
if (UE_flag==1) { if (UE_flag==1) {
printf("configuring for UE\n"); printf("configuring for UE\n");
set_comp_log(HW, LOG_DEBUG, LOG_HIGH, 1); set_comp_log(HW, LOG_INFO, LOG_HIGH, 1);
set_comp_log(PHY, LOG_DEBUG, LOG_HIGH, 1); set_comp_log(PHY, LOG_INFO, LOG_HIGH, 1);
set_comp_log(MAC, LOG_INFO, LOG_HIGH, 1); set_comp_log(MAC, LOG_TRACE, LOG_HIGH, 1);
set_comp_log(RLC, LOG_INFO, LOG_HIGH | FLAG_THREAD, 1); set_comp_log(RLC, LOG_TRACE, LOG_HIGH | FLAG_THREAD, 1);
set_comp_log(PDCP, LOG_INFO, LOG_HIGH, 1); set_comp_log(PDCP, LOG_INFO, LOG_HIGH, 1);
set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1); set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1);
set_comp_log(RRC, LOG_INFO, LOG_HIGH, 1); set_comp_log(RRC, LOG_INFO, LOG_HIGH, 1);
...@@ -1223,7 +1220,7 @@ int main( int argc, char **argv ) ...@@ -1223,7 +1220,7 @@ int main( int argc, char **argv )
printf("cannot create ITTI tasks\n"); printf("cannot create ITTI tasks\n");
exit(-1); // need a softer mode exit(-1); // need a softer mode
} }
UE_config_stub_pnf(); // UE_config_stub_pnf();
printf("ITTI tasks created\n"); printf("ITTI tasks created\n");
} }
else { else {
...@@ -1331,14 +1328,17 @@ int main( int argc, char **argv ) ...@@ -1331,14 +1328,17 @@ int main( int argc, char **argv )
case 3: case 3:
nfapi_mode_str = "UE_STUB_PNF"; nfapi_mode_str = "UE_STUB_PNF";
break; break;
case 4:
nfapi_mode_str = "UE_STUB_OFFNET";
break;
default: default:
nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; nfapi_mode_str = "<UNKNOWN NFAPI MODE>";
break; break;
} }
printf("NFAPI MODE:%s\n", nfapi_mode_str); printf("NFAPI MODE:%s\n", nfapi_mode_str);
// Panos: We should never enter here since we are always going to run with nfapi_mode=3
if (nfapi_mode==2) // VNF if (nfapi_mode<3) // VNF
wait_nfapi_init("main?"); wait_nfapi_init("main?");
printf("START MAIN THREADS\n"); printf("START MAIN THREADS\n");
......
...@@ -607,9 +607,12 @@ static void get_options(void) { ...@@ -607,9 +607,12 @@ static void get_options(void) {
if (UE_flag > 0) { if (UE_flag > 0) {
uint8_t n_rb_dl;
nfapi_mode=0;
paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC; paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC;
paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC;
set_default_frame_parms(frame_parms);
config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL);
...@@ -623,19 +626,17 @@ static void get_options(void) { ...@@ -623,19 +626,17 @@ static void get_options(void) {
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue;
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med;
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp;
if ( *(cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) > 0) mode = debug_prach; if ( (cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = debug_prach;
if ( *(cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) > 0) mode = no_L2_connect; if ( (cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = no_L2_connect;
if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx; if ( (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = calib_prach_tx;
if (dumpframe > 0) mode = rx_dump_frame; if (dumpframe > 0) mode = rx_dump_frame;
if ( downlink_frequency[0][0] > 0) { if ( downlink_frequency[0][0] > 0) {
for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) { printf("Downlink frequency set to %u\n", downlink_frequency[0][0]);
downlink_frequency[CC_id][1] = downlink_frequency[0][0]; for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
downlink_frequency[CC_id][2] = downlink_frequency[0][0]; frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0];
downlink_frequency[CC_id][3] = downlink_frequency[0][0]; }
printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); UE_scan=0;
}
UE_scan=0;
} }
if (tddflag > 0) { if (tddflag > 0) {
...@@ -643,29 +644,29 @@ static void get_options(void) { ...@@ -643,29 +644,29 @@ static void get_options(void) {
frame_parms[CC_id]->frame_type = TDD; frame_parms[CC_id]->frame_type = TDD;
} }
if (frame_parms[0]->N_RB_DL !=0) { if (n_rb_dl !=0) {
if ( frame_parms[0]->N_RB_DL < 6 ) { printf("NB_RB set to %d\n",n_rb_dl);
frame_parms[0]->N_RB_DL = 6; if ( n_rb_dl < 6 ) {
printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",frame_parms[0]->N_RB_DL); n_rb_dl = 6;
} printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",n_rb_dl);
if ( frame_parms[0]->N_RB_DL > 100 ) { }
frame_parms[0]->N_RB_DL = 100; if ( n_rb_dl > 100 ) {
printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",frame_parms[0]->N_RB_DL); n_rb_dl = 100;
} printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",n_rb_dl);
if ( frame_parms[0]->N_RB_DL > 50 && frame_parms[0]->N_RB_DL < 100 ) { }
frame_parms[0]->N_RB_DL = 50; if ( n_rb_dl > 50 && n_rb_dl < 100 ) {
printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",frame_parms[0]->N_RB_DL); n_rb_dl = 50;
} printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",n_rb_dl);
if ( frame_parms[0]->N_RB_DL > 25 && frame_parms[0]->N_RB_DL < 50 ) { }
frame_parms[0]->N_RB_DL = 25; if ( n_rb_dl > 25 && n_rb_dl < 50 ) {
printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",frame_parms[0]->N_RB_DL); n_rb_dl = 25;
} printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",n_rb_dl);
UE_scan = 0; }
frame_parms[0]->N_RB_UL=frame_parms[0]->N_RB_DL; UE_scan = 0;
for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
frame_parms[CC_id]->N_RB_DL=frame_parms[0]->N_RB_DL; frame_parms[CC_id]->N_RB_DL=n_rb_dl;
frame_parms[CC_id]->N_RB_UL=frame_parms[0]->N_RB_UL; frame_parms[CC_id]->N_RB_UL=n_rb_dl;
} }
} }
...@@ -693,7 +694,7 @@ static void get_options(void) { ...@@ -693,7 +694,7 @@ static void get_options(void) {
// Here the configuration file is the XER encoded UE capabilities // Here the configuration file is the XER encoded UE capabilities
// Read it in and store in asn1c data structures // Read it in and store in asn1c data structures
strcpy(uecap_xer,CONFIG_GETCONFFILE); strcpy(uecap_xer,CONFIG_GETCONFFILE);
uecap_xer_in=1; // uecap_xer_in=1;
} /* UE with config file */ } /* UE with config file */
} }
...@@ -938,13 +939,13 @@ int main( int argc, char **argv ) ...@@ -938,13 +939,13 @@ int main( int argc, char **argv )
// set default parameters // set default parameters
if (UE_flag == 1) set_default_frame_parms(frame_parms); //if (UE_flag == 1) set_default_frame_parms(frame_parms);
logInit(); logInit();
printf("Reading in command-line options\n"); printf("Reading in command-line options\n");
get_options (); get_options ();
if (CONFIG_ISFLAGSET(CONFIG_ABORT)) { if (CONFIG_ISFLAGSET(CONFIG_ABORT) && UE_flag == 0) {
fprintf(stderr,"Getting configuration failed\n"); fprintf(stderr,"Getting configuration failed\n");
exit(-1); exit(-1);
} }
...@@ -1055,7 +1056,6 @@ int main( int argc, char **argv ) ...@@ -1055,7 +1056,6 @@ int main( int argc, char **argv )
printf("Before CC \n");
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
...@@ -1115,11 +1115,10 @@ int main( int argc, char **argv ) ...@@ -1115,11 +1115,10 @@ int main( int argc, char **argv )
else if (frame_parms[CC_id]->N_RB_DL == 25) else if (frame_parms[CC_id]->N_RB_DL == 25)
UE[CC_id]->N_TA_offset = 624/4; UE[CC_id]->N_TA_offset = 624/4;
} }
init_openair0();
} }
} }
printf("Runtime table\n");
fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx);
cpuf=get_cpu_freq_GHz(); cpuf=get_cpu_freq_GHz();
...@@ -1168,10 +1167,6 @@ int main( int argc, char **argv ) ...@@ -1168,10 +1167,6 @@ int main( int argc, char **argv )
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
printf("ITTI enabled\n");
printf("UE_flag:%d\n", UE_flag);
printf("RC.nb_inst:%d\n", RC.nb_inst);
if ((UE_flag == 1)|| if ((UE_flag == 1)||
(RC.nb_inst > 0)) { (RC.nb_inst > 0)) {
...@@ -1189,14 +1184,6 @@ int main( int argc, char **argv ) ...@@ -1189,14 +1184,6 @@ int main( int argc, char **argv )
} }
#endif #endif
if (phy_test==0) {
if (UE_flag==1) {
printf("Filling UE band info\n");
fill_ue_band_info();
dl_phy_sync_success (0, 0, 0, 1);
}
}
mlockall(MCL_CURRENT | MCL_FUTURE); mlockall(MCL_CURRENT | MCL_FUTURE);
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
...@@ -1298,6 +1285,12 @@ int main( int argc, char **argv ) ...@@ -1298,6 +1285,12 @@ int main( int argc, char **argv )
if (UE_flag == 1) { if (UE_flag == 1) {
int eMBMS_active = 0; int eMBMS_active = 0;
init_UE(1,eMBMS_active,uecap_xer_in); init_UE(1,eMBMS_active,uecap_xer_in);
if (phy_test==0) {
printf("Filling UE band info\n");
fill_ue_band_info();
dl_phy_sync_success (0, 0, 0, 1);
}
number_of_cards = 1; number_of_cards = 1;
for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
...@@ -1315,10 +1308,8 @@ int main( int argc, char **argv ) ...@@ -1315,10 +1308,8 @@ int main( int argc, char **argv )
// for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0); // for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0);
} }
printf("wait_eNBs()\n");
wait_eNBs(); wait_eNBs();
printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU);
if (RC.nb_RU >0) { if (RC.nb_RU >0) {
printf("Initializing RU threads\n"); printf("Initializing RU threads\n");
init_RU(rf_config_file); init_RU(rf_config_file);
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
{"ue-nb-ant-tx", CONFIG_HLP_UENANTT, 0, u8ptr:&nb_antenna_tx, defuintval:1, TYPE_UINT8, 0}, \ {"ue-nb-ant-tx", CONFIG_HLP_UENANTT, 0, u8ptr:&nb_antenna_tx, defuintval:1, TYPE_UINT8, 0}, \
{"ue-scan-carrier", CONFIG_HLP_UESCAN, PARAMFLAG_BOOL, iptr:&UE_scan_carrier, defintval:0, TYPE_INT, 0}, \ {"ue-scan-carrier", CONFIG_HLP_UESCAN, PARAMFLAG_BOOL, iptr:&UE_scan_carrier, defintval:0, TYPE_INT, 0}, \
{"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:90, TYPE_INT, 0}, \ {"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:90, TYPE_INT, 0}, \
{"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:0, TYPE_UINT8, 0}, \ {"r" , CONFIG_HLP_PRB, 0, u8ptr:&n_rb_dl, defintval:0, TYPE_UINT8, 0}, \
} }
......
...@@ -68,9 +68,9 @@ extern uint8_t nfapi_mode; ...@@ -68,9 +68,9 @@ extern uint8_t nfapi_mode;
#define FIFO_PRIORITY 40 #define FIFO_PRIORITY 40
typedef enum { typedef enum {
pss=0, pss=0,
pbch=1, pbch=1,
si=2 si=2
} sync_mode_t; } sync_mode_t;
void init_UE_threads(int); void init_UE_threads(int);
...@@ -92,51 +92,51 @@ SF_ticking *phy_stub_ticking; ...@@ -92,51 +92,51 @@ SF_ticking *phy_stub_ticking;
#define MHz (1000*KHz) #define MHz (1000*KHz)
typedef struct eutra_band_s { typedef struct eutra_band_s {
int16_t band; int16_t band;
uint32_t ul_min; uint32_t ul_min;
uint32_t ul_max; uint32_t ul_max;
uint32_t dl_min; uint32_t dl_min;
uint32_t dl_max; uint32_t dl_max;
lte_frame_type_t frame_type; lte_frame_type_t frame_type;
} eutra_band_t; } eutra_band_t;
typedef struct band_info_s { typedef struct band_info_s {
int nbands; int nbands;
eutra_band_t band_info[100]; eutra_band_t band_info[100];
} band_info_t; } band_info_t;
band_info_t bands_to_scan; band_info_t bands_to_scan;
static const eutra_band_t eutra_bands[] = { static const eutra_band_t eutra_bands[] = {
{ 1, 1920 * MHz, 1980 * MHz, 2110 * MHz, 2170 * MHz, FDD}, { 1, 1920 * MHz, 1980 * MHz, 2110 * MHz, 2170 * MHz, FDD},
{ 2, 1850 * MHz, 1910 * MHz, 1930 * MHz, 1990 * MHz, FDD}, { 2, 1850 * MHz, 1910 * MHz, 1930 * MHz, 1990 * MHz, FDD},
{ 3, 1710 * MHz, 1785 * MHz, 1805 * MHz, 1880 * MHz, FDD}, { 3, 1710 * MHz, 1785 * MHz, 1805 * MHz, 1880 * MHz, FDD},
{ 4, 1710 * MHz, 1755 * MHz, 2110 * MHz, 2155 * MHz, FDD}, { 4, 1710 * MHz, 1755 * MHz, 2110 * MHz, 2155 * MHz, FDD},
{ 5, 824 * MHz, 849 * MHz, 869 * MHz, 894 * MHz, FDD}, { 5, 824 * MHz, 849 * MHz, 869 * MHz, 894 * MHz, FDD},
{ 6, 830 * MHz, 840 * MHz, 875 * MHz, 885 * MHz, FDD}, { 6, 830 * MHz, 840 * MHz, 875 * MHz, 885 * MHz, FDD},
{ 7, 2500 * MHz, 2570 * MHz, 2620 * MHz, 2690 * MHz, FDD}, { 7, 2500 * MHz, 2570 * MHz, 2620 * MHz, 2690 * MHz, FDD},
{ 8, 880 * MHz, 915 * MHz, 925 * MHz, 960 * MHz, FDD}, { 8, 880 * MHz, 915 * MHz, 925 * MHz, 960 * MHz, FDD},
{ 9, 1749900 * KHz, 1784900 * KHz, 1844900 * KHz, 1879900 * KHz, FDD}, { 9, 1749900 * KHz, 1784900 * KHz, 1844900 * KHz, 1879900 * KHz, FDD},
{10, 1710 * MHz, 1770 * MHz, 2110 * MHz, 2170 * MHz, FDD}, {10, 1710 * MHz, 1770 * MHz, 2110 * MHz, 2170 * MHz, FDD},
{11, 1427900 * KHz, 1452900 * KHz, 1475900 * KHz, 1500900 * KHz, FDD}, {11, 1427900 * KHz, 1452900 * KHz, 1475900 * KHz, 1500900 * KHz, FDD},
{12, 698 * MHz, 716 * MHz, 728 * MHz, 746 * MHz, FDD}, {12, 698 * MHz, 716 * MHz, 728 * MHz, 746 * MHz, FDD},
{13, 777 * MHz, 787 * MHz, 746 * MHz, 756 * MHz, FDD}, {13, 777 * MHz, 787 * MHz, 746 * MHz, 756 * MHz, FDD},
{14, 788 * MHz, 798 * MHz, 758 * MHz, 768 * MHz, FDD}, {14, 788 * MHz, 798 * MHz, 758 * MHz, 768 * MHz, FDD},
{17, 704 * MHz, 716 * MHz, 734 * MHz, 746 * MHz, FDD}, {17, 704 * MHz, 716 * MHz, 734 * MHz, 746 * MHz, FDD},
{20, 832 * MHz, 862 * MHz, 791 * MHz, 821 * MHz, FDD}, {20, 832 * MHz, 862 * MHz, 791 * MHz, 821 * MHz, FDD},
{22, 3510 * MHz, 3590 * MHz, 3410 * MHz, 3490 * MHz, FDD}, {22, 3510 * MHz, 3590 * MHz, 3410 * MHz, 3490 * MHz, FDD},
{33, 1900 * MHz, 1920 * MHz, 1900 * MHz, 1920 * MHz, TDD}, {33, 1900 * MHz, 1920 * MHz, 1900 * MHz, 1920 * MHz, TDD},
{34, 2010 * MHz, 2025 * MHz, 2010 * MHz, 2025 * MHz, TDD}, {34, 2010 * MHz, 2025 * MHz, 2010 * MHz, 2025 * MHz, TDD},
{35, 1850 * MHz, 1910 * MHz, 1850 * MHz, 1910 * MHz, TDD}, {35, 1850 * MHz, 1910 * MHz, 1850 * MHz, 1910 * MHz, TDD},
{36, 1930 * MHz, 1990 * MHz, 1930 * MHz, 1990 * MHz, TDD}, {36, 1930 * MHz, 1990 * MHz, 1930 * MHz, 1990 * MHz, TDD},
{37, 1910 * MHz, 1930 * MHz, 1910 * MHz, 1930 * MHz, TDD}, {37, 1910 * MHz, 1930 * MHz, 1910 * MHz, 1930 * MHz, TDD},
{38, 2570 * MHz, 2620 * MHz, 2570 * MHz, 2630 * MHz, TDD}, {38, 2570 * MHz, 2620 * MHz, 2570 * MHz, 2630 * MHz, TDD},
{39, 1880 * MHz, 1920 * MHz, 1880 * MHz, 1920 * MHz, TDD}, {39, 1880 * MHz, 1920 * MHz, 1880 * MHz, 1920 * MHz, TDD},
{40, 2300 * MHz, 2400 * MHz, 2300 * MHz, 2400 * MHz, TDD}, {40, 2300 * MHz, 2400 * MHz, 2300 * MHz, 2400 * MHz, TDD},
{41, 2496 * MHz, 2690 * MHz, 2496 * MHz, 2690 * MHz, TDD}, {41, 2496 * MHz, 2690 * MHz, 2496 * MHz, 2690 * MHz, TDD},
{42, 3400 * MHz, 3600 * MHz, 3400 * MHz, 3600 * MHz, TDD}, {42, 3400 * MHz, 3600 * MHz, 3400 * MHz, 3600 * MHz, TDD},
{43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD}, {43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD},
{44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD}, {44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD},
}; };
...@@ -169,12 +169,12 @@ PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, ...@@ -169,12 +169,12 @@ PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
// Panos: In phy_stub_UE (MAC-to-MAC) mode these init functions don't need to get called. Is this correct? // Panos: In phy_stub_UE (MAC-to-MAC) mode these init functions don't need to get called. Is this correct?
if (nfapi_mode!=3) if (nfapi_mode!=3)
{ {
// initialize all signal buffers // initialize all signal buffers
init_lte_ue_signal(ue,1,abstraction_flag); init_lte_ue_signal(ue,1,abstraction_flag);
// intialize transport // intialize transport
init_lte_ue_transport(ue,abstraction_flag); init_lte_ue_transport(ue,abstraction_flag);
} }
return(ue); return(ue);
} }
...@@ -187,35 +187,35 @@ char uecap_xer[1024]; ...@@ -187,35 +187,35 @@ char uecap_xer[1024];
void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name) { void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name) {
#ifdef DEADLINE_SCHEDULER #ifdef DEADLINE_SCHEDULER
if (sched_runtime!=0) { if (sched_runtime!=0) {
struct sched_attr attr= {0}; struct sched_attr attr= {0};
attr.size = sizeof(attr); attr.size = sizeof(attr);
attr.sched_policy = SCHED_DEADLINE; attr.sched_policy = SCHED_DEADLINE;
attr.sched_runtime = sched_runtime; attr.sched_runtime = sched_runtime;
attr.sched_deadline = sched_deadline; attr.sched_deadline = sched_deadline;
attr.sched_period = 0; attr.sched_period = 0;
AssertFatal(sched_setattr(0, &attr, 0) == 0, AssertFatal(sched_setattr(0, &attr, 0) == 0,
"[SCHED] %s thread: sched_setattr failed %s \n", name, strerror(errno)); "[SCHED] %s thread: sched_setattr failed %s \n", name, strerror(errno));
LOG_I(HW,"[SCHED][eNB] %s deadline thread %lu started on CPU %d\n", LOG_I(HW,"[SCHED][eNB] %s deadline thread %lu started on CPU %d\n",
name, (unsigned long)gettid(), sched_getcpu()); name, (unsigned long)gettid(), sched_getcpu());
} }
#else #else
if (CPU_COUNT(cpuset) > 0) if (CPU_COUNT(cpuset) > 0)
AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), ""); AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), "");
struct sched_param sp; struct sched_param sp;
sp.sched_priority = sched_fifo; sp.sched_priority = sched_fifo;
AssertFatal(pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp)==0, AssertFatal(pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp)==0,
"Can't set thread priority, Are you root?\n"); "Can't set thread priority, Are you root?\n");
/* Check the actual affinity mask assigned to the thread */ /* Check the actual affinity mask assigned to the thread */
cpu_set_t *cset=CPU_ALLOC(CPU_SETSIZE); cpu_set_t *cset=CPU_ALLOC(CPU_SETSIZE);
if (0 == pthread_getaffinity_np(pthread_self(), CPU_ALLOC_SIZE(CPU_SETSIZE), cset)) { if (0 == pthread_getaffinity_np(pthread_self(), CPU_ALLOC_SIZE(CPU_SETSIZE), cset)) {
char txt[512]={0}; char txt[512]={0};
for (int j = 0; j < CPU_SETSIZE; j++) for (int j = 0; j < CPU_SETSIZE; j++)
if (CPU_ISSET(j, cset)) if (CPU_ISSET(j, cset))
sprintf(txt+strlen(txt), " %d ", j); sprintf(txt+strlen(txt), " %d ", j);
printf("CPU Affinity of thread %s is %s\n", name, txt); printf("CPU Affinity of thread %s is %s\n", name, txt);
} }
CPU_FREE(cset); CPU_FREE(cset);
#endif #endif
} }
...@@ -292,17 +292,17 @@ void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in) { ...@@ -292,17 +292,17 @@ void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in) {
/*if (oaisim_flag == 0) { /*if (oaisim_flag == 0) {
ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]); ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
if (ret !=0){ if (ret !=0){
exit_fun("Error loading device library"); exit_fun("Error loading device library");
} }
}*/ }*/
//UE->rfdevice.host_type = RAU_HOST; //UE->rfdevice.host_type = RAU_HOST;
// UE->rfdevice.type = NONE_DEV; // UE->rfdevice.type = NONE_DEV;
/*PHY_VARS_UE *UE = PHY_vars_UE_g[inst][0]; /*PHY_VARS_UE *UE = PHY_vars_UE_g[inst][0];
AssertFatal(0 == pthread_create(&UE->proc.pthread_ue, AssertFatal(0 == pthread_create(&UE->proc.pthread_ue,
&UE->proc.attr_ue, &UE->proc.attr_ue,
UE_thread, UE_thread,
(void*)UE), "");*/ (void*)UE), "");*/
} }
printf("UE threads created \n"); printf("UE threads created \n");
...@@ -343,7 +343,7 @@ static void *UE_thread_synch(void *arg) ...@@ -343,7 +343,7 @@ static void *UE_thread_synch(void *arg)
UE->is_synchronized = 0; UE->is_synchronized = 0;
printf("UE_thread_sync in with PHY_vars_UE %p\n",arg); printf("UE_thread_sync in with PHY_vars_UE %p\n",arg);
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
if ( threads.iq != -1 ) if ( threads.iq != -1 )
CPU_SET(threads.iq, &cpuset); CPU_SET(threads.iq, &cpuset);
...@@ -432,193 +432,193 @@ static void *UE_thread_synch(void *arg) ...@@ -432,193 +432,193 @@ static void *UE_thread_synch(void *arg)
if (current_offset > bands_to_scan.band_info[current_band].dl_max-bands_to_scan.band_info[current_band].dl_min) { if (current_offset > bands_to_scan.band_info[current_band].dl_max-bands_to_scan.band_info[current_band].dl_min) {
current_band++; current_band++;
current_offset=0; current_offset=0;
} }
if (current_band==bands_to_scan.nbands) { if (current_band==bands_to_scan.nbands) {
current_band=0; current_band=0;
oai_exit=1; oai_exit=1;
} }
for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].dl_min+current_offset; downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].dl_min+current_offset;
uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].ul_min-bands_to_scan.band_info[0].dl_min + current_offset; uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].ul_min-bands_to_scan.band_info[0].dl_min + current_offset;
openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]; openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i];
openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]; openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i];
openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB; openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;
if (UE->UE_scan_carrier) { if (UE->UE_scan_carrier) {
openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
} }
} }
break; break;
case pbch: case pbch:
#if DISABLE_LOG_X #if DISABLE_LOG_X
printf("[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); printf("[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode);
#else #else
LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode);
#endif #endif
if (initial_sync( UE, UE->mode ) == 0) { if (initial_sync( UE, UE->mode ) == 0) {
hw_slot_offset = (UE->rx_offset<<1) / UE->frame_parms.samples_per_tti; hw_slot_offset = (UE->rx_offset<<1) / UE->frame_parms.samples_per_tti;
LOG_I( HW, "Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n", LOG_I( HW, "Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n",
hw_slot_offset, hw_slot_offset,
freq_offset, freq_offset,
UE->rx_total_gain_dB, UE->rx_total_gain_dB,
downlink_frequency[0][0]+freq_offset, downlink_frequency[0][0]+freq_offset,
downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset, downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset,
UE->UE_scan_carrier ); UE->UE_scan_carrier );
// rerun with new cell parameters and frequency-offset // rerun with new cell parameters and frequency-offset
for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET;
if (UE->UE_scan_carrier == 1) { if (UE->UE_scan_carrier == 1) {
if (freq_offset >= 0) if (freq_offset >= 0)
openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] += abs(UE->common_vars.freq_offset); openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] += abs(UE->common_vars.freq_offset);
else else
openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(UE->common_vars.freq_offset); openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(UE->common_vars.freq_offset);
openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] =
openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+uplink_frequency_offset[CC_id][i]; openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+uplink_frequency_offset[CC_id][i];
downlink_frequency[CC_id][i] = openair0_cfg[CC_id].rx_freq[i]; downlink_frequency[CC_id][i] = openair0_cfg[CC_id].rx_freq[i];
freq_offset=0; freq_offset=0;
}
} }
}
// reconfigure for potentially different bandwidth
switch(UE->frame_parms.N_RB_DL) {
case 6:
openair0_cfg[UE->rf_map.card].sample_rate =1.92e6;
openair0_cfg[UE->rf_map.card].rx_bw =.96e6;
openair0_cfg[UE->rf_map.card].tx_bw =.96e6;
// openair0_cfg[0].rx_gain[0] -= 12;
break;
case 25:
openair0_cfg[UE->rf_map.card].sample_rate =7.68e6;
openair0_cfg[UE->rf_map.card].rx_bw =2.5e6;
openair0_cfg[UE->rf_map.card].tx_bw =2.5e6;
// openair0_cfg[0].rx_gain[0] -= 6;
break;
case 50:
openair0_cfg[UE->rf_map.card].sample_rate =15.36e6;
openair0_cfg[UE->rf_map.card].rx_bw =5.0e6;
openair0_cfg[UE->rf_map.card].tx_bw =5.0e6;
// openair0_cfg[0].rx_gain[0] -= 3;
break;
case 100:
openair0_cfg[UE->rf_map.card].sample_rate=30.72e6;
openair0_cfg[UE->rf_map.card].rx_bw=10.0e6;
openair0_cfg[UE->rf_map.card].tx_bw=10.0e6;
// openair0_cfg[0].rx_gain[0] -= 0;
break;
}
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
//UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]);
//UE->rfdevice.trx_stop_func(&UE->rfdevice);
sleep(1);
init_frame_parms(&UE->frame_parms,1);
/*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
LOG_E(HW,"Could not start the device\n");
oai_exit=1;
}*/
if (UE->UE_scan_carrier == 1) {
UE->UE_scan_carrier = 0;
} else {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
UE->is_synchronized = 1;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if( UE->mode == rx_dump_frame ) {
FILE *fd;
if ((UE->proc.proc_rxtx[0].frame_rx&1) == 0) { // this guarantees SIB1 is present
if ((fd = fopen("rxsig_frame0.dat","w")) != NULL) {
fwrite((void*)&UE->common_vars.rxdata[0][0],
sizeof(int32_t),
10*UE->frame_parms.samples_per_tti,
fd);
LOG_I(PHY,"Dummping Frame ... bye bye \n");
fclose(fd);
exit(0);
} else {
LOG_E(PHY,"Cannot open file for writing\n");
exit(0);
}
} else {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
UE->is_synchronized = 0;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
// reconfigure for potentially different bandwidth }
switch(UE->frame_parms.N_RB_DL) { }
case 6: }
openair0_cfg[UE->rf_map.card].sample_rate =1.92e6; } else {
openair0_cfg[UE->rf_map.card].rx_bw =.96e6; // initial sync failed
openair0_cfg[UE->rf_map.card].tx_bw =.96e6; // calculate new offset and try again
// openair0_cfg[0].rx_gain[0] -= 12; if (UE->UE_scan_carrier == 1) {
break; if (freq_offset >= 0)
case 25: freq_offset += 100;
openair0_cfg[UE->rf_map.card].sample_rate =7.68e6; freq_offset *= -1;
openair0_cfg[UE->rf_map.card].rx_bw =2.5e6;
openair0_cfg[UE->rf_map.card].tx_bw =2.5e6; if (abs(freq_offset) > 7500) {
// openair0_cfg[0].rx_gain[0] -= 6; LOG_I( PHY, "[initial_sync] No cell synchronization found, abandoning\n" );
break; FILE *fd;
case 50: if ((fd = fopen("rxsig_frame0.dat","w"))!=NULL) {
openair0_cfg[UE->rf_map.card].sample_rate =15.36e6; fwrite((void*)&UE->common_vars.rxdata[0][0],
openair0_cfg[UE->rf_map.card].rx_bw =5.0e6; sizeof(int32_t),
openair0_cfg[UE->rf_map.card].tx_bw =5.0e6; 10*UE->frame_parms.samples_per_tti,
// openair0_cfg[0].rx_gain[0] -= 3; fd);
break; LOG_I(PHY,"Dummping Frame ... bye bye \n");
case 100: fclose(fd);
openair0_cfg[UE->rf_map.card].sample_rate=30.72e6; exit(0);
openair0_cfg[UE->rf_map.card].rx_bw=10.0e6; }
openair0_cfg[UE->rf_map.card].tx_bw=10.0e6; AssertFatal(1==0,"No cell synchronization found, abandoning");
// openair0_cfg[0].rx_gain[0] -= 0; return &UE_thread_synch_retval; // not reached
break; }
} }
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
//UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]);
//UE->rfdevice.trx_stop_func(&UE->rfdevice);
sleep(1);
init_frame_parms(&UE->frame_parms,1);
/*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
LOG_E(HW,"Could not start the device\n");
oai_exit=1;
}*/
if (UE->UE_scan_carrier == 1) {
UE->UE_scan_carrier = 0;
} else {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
UE->is_synchronized = 1;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if( UE->mode == rx_dump_frame ) {
FILE *fd;
if ((UE->proc.proc_rxtx[0].frame_rx&1) == 0) { // this guarantees SIB1 is present
if ((fd = fopen("rxsig_frame0.dat","w")) != NULL) {
fwrite((void*)&UE->common_vars.rxdata[0][0],
sizeof(int32_t),
10*UE->frame_parms.samples_per_tti,
fd);
LOG_I(PHY,"Dummping Frame ... bye bye \n");
fclose(fd);
exit(0);
} else {
LOG_E(PHY,"Cannot open file for writing\n");
exit(0);
}
} else {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
UE->is_synchronized = 0;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
}
}
}
} else {
// initial sync failed
// calculate new offset and try again
if (UE->UE_scan_carrier == 1) {
if (freq_offset >= 0)
freq_offset += 100;
freq_offset *= -1;
if (abs(freq_offset) > 7500) {
LOG_I( PHY, "[initial_sync] No cell synchronization found, abandoning\n" );
FILE *fd;
if ((fd = fopen("rxsig_frame0.dat","w"))!=NULL) {
fwrite((void*)&UE->common_vars.rxdata[0][0],
sizeof(int32_t),
10*UE->frame_parms.samples_per_tti,
fd);
LOG_I(PHY,"Dummping Frame ... bye bye \n");
fclose(fd);
exit(0);
}
AssertFatal(1==0,"No cell synchronization found, abandoning");
return &UE_thread_synch_retval; // not reached
}
}
#if DISABLE_LOG_X #if DISABLE_LOG_X
printf("[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n", printf("[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n",
freq_offset, freq_offset,
UE->rx_total_gain_dB, UE->rx_total_gain_dB,
downlink_frequency[0][0]+freq_offset, downlink_frequency[0][0]+freq_offset,
downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset ); downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset );
#else #else
LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n", LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n",
freq_offset, freq_offset,
UE->rx_total_gain_dB, UE->rx_total_gain_dB,
downlink_frequency[0][0]+freq_offset, downlink_frequency[0][0]+freq_offset,
downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset ); downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset );
#endif #endif
for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+freq_offset; openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+freq_offset;
openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]+freq_offset; openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]+freq_offset;
openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET;
if (UE->UE_scan_carrier==1) if (UE->UE_scan_carrier==1)
openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
} }
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
}// initial_sync=0 }// initial_sync=0
break; break;
case si: case si:
default: default:
break; break;
} }
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
// indicate readiness // indicate readiness
UE->proc.instance_cnt_synch--; UE->proc.instance_cnt_synch--;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_THREAD_SYNCH, 0 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_THREAD_SYNCH, 0 );
} // while !oai_exit } // while !oai_exit
return &UE_thread_synch_retval; return &UE_thread_synch_retval;
} }
/*! /*!
...@@ -630,144 +630,144 @@ static void *UE_thread_synch(void *arg) ...@@ -630,144 +630,144 @@ static void *UE_thread_synch(void *arg)
*/ */
static void *UE_thread_rxn_txnp4(void *arg) { static void *UE_thread_rxn_txnp4(void *arg) {
static __thread int UE_thread_rxtx_retval; static __thread int UE_thread_rxtx_retval;
struct rx_tx_thread_data *rtd = arg; struct rx_tx_thread_data *rtd = arg;
UE_rxtx_proc_t *proc = rtd->proc; UE_rxtx_proc_t *proc = rtd->proc;
PHY_VARS_UE *UE = rtd->UE; PHY_VARS_UE *UE = rtd->UE;
int ret; int ret;
proc->instance_cnt_rxtx=-1; proc->instance_cnt_rxtx=-1;
proc->subframe_rx=proc->sub_frame_start; proc->subframe_rx=proc->sub_frame_start;
char threadname[256]; char threadname[256];
sprintf(threadname,"UE_%d_proc_%d", UE->Mod_id, proc->sub_frame_start); sprintf(threadname,"UE_%d_proc_%d", UE->Mod_id, proc->sub_frame_start);
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 )
CPU_SET(threads.one, &cpuset);
if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 )
CPU_SET(threads.two, &cpuset);
if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 )
CPU_SET(threads.three, &cpuset);
//CPU_SET(threads.three, &cpuset);
init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset,
threadname);
while (!oai_exit) { if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 )
if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { CPU_SET(threads.one, &cpuset);
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 )
exit_fun("nothing to add"); CPU_SET(threads.two, &cpuset);
} if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 )
while (proc->instance_cnt_rxtx < 0) { CPU_SET(threads.three, &cpuset);
// most of the time, the thread is waiting here //CPU_SET(threads.three, &cpuset);
pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx ); init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset,
} threadname);
if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" ); while (!oai_exit) {
exit_fun("nothing to add"); if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) {
} LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
exit_fun("nothing to add");
initRefTimes(t2); }
initRefTimes(t3); while (proc->instance_cnt_rxtx < 0) {
pickTime(current); // most of the time, the thread is waiting here
updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)"); pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx );
}
// Process Rx data for one sub-frame if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx); LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" );
if ((sf_type == SF_DL) || exit_fun("nothing to add");
(UE->frame_parms.frame_type == FDD) || }
(sf_type == SF_S)) {
initRefTimes(t2);
if (UE->frame_parms.frame_type == TDD) { initRefTimes(t3);
LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n", pickTime(current);
threadname, updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)");
UE->frame_parms.tdd_config,
(sf_type==SF_DL? "SF_DL" : // Process Rx data for one sub-frame
(sf_type==SF_UL? "SF_UL" : lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx);
(sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); if ((sf_type == SF_DL) ||
} else { (UE->frame_parms.frame_type == FDD) ||
LOG_D(PHY, "%s,%s,%s: calling UE_RX\n", (sf_type == SF_S)) {
threadname,
(UE->frame_parms.frame_type==FDD? "FDD": if (UE->frame_parms.frame_type == TDD) {
(UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")), LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n",
(sf_type==SF_DL? "SF_DL" : threadname,
(sf_type==SF_UL? "SF_UL" : UE->frame_parms.tdd_config,
(sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); (sf_type==SF_DL? "SF_DL" :
} (sf_type==SF_UL? "SF_UL" :
(sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE"))));
} else {
LOG_D(PHY, "%s,%s,%s: calling UE_RX\n",
threadname,
(UE->frame_parms.frame_type==FDD? "FDD":
(UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")),
(sf_type==SF_DL? "SF_DL" :
(sf_type==SF_UL? "SF_UL" :
(sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE"))));
}
#ifdef UE_SLOT_PARALLELISATION #ifdef UE_SLOT_PARALLELISATION
phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL );
#else #else
phy_procedures_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); phy_procedures_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL );
#endif #endif
} }
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&UE->generic_stat); start_meas(&UE->generic_stat);
#endif #endif
if (UE->mac_enabled==1) { if (UE->mac_enabled==1) {
ret = ue_scheduler(UE->Mod_id, ret = ue_scheduler(UE->Mod_id,
proc->frame_rx, proc->frame_rx,
proc->subframe_rx, proc->subframe_rx,
proc->frame_tx, proc->frame_tx,
proc->subframe_tx, proc->subframe_tx,
subframe_select(&UE->frame_parms,proc->subframe_tx), subframe_select(&UE->frame_parms,proc->subframe_tx),
0, 0,
0/*FIXME CC_id*/); 0/*FIXME CC_id*/);
if ( ret != CONNECTION_OK) { if ( ret != CONNECTION_OK) {
char *txt; char *txt;
switch (ret) { switch (ret) {
case CONNECTION_LOST: case CONNECTION_LOST:
txt="RRC Connection lost, returning to PRACH"; txt="RRC Connection lost, returning to PRACH";
break; break;
case PHY_RESYNCH: case PHY_RESYNCH:
txt="RRC Connection lost, trying to resynch"; txt="RRC Connection lost, trying to resynch";
break; break;
case RESYNCH: case RESYNCH:
txt="return to PRACH and perform a contention-free access"; txt="return to PRACH and perform a contention-free access";
break; break;
default: default:
txt="UNKNOWN RETURN CODE"; txt="UNKNOWN RETURN CODE";
}; };
LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n", LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n",
UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt ); UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt );
} }
} }
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
stop_meas(&UE->generic_stat); stop_meas(&UE->generic_stat);
#endif #endif
// Prepare the future Tx data // Prepare the future Tx data
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) ) (UE->frame_parms.frame_type == FDD) )
if (UE->mode != loop_through_memory) if (UE->mode != loop_through_memory)
phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay); phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay);
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) && if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) &&
(UE->frame_parms.frame_type == TDD)) (UE->frame_parms.frame_type == TDD))
if (UE->mode != loop_through_memory) if (UE->mode != loop_through_memory)
phy_procedures_UE_S_TX(UE,0,0,no_relay); phy_procedures_UE_S_TX(UE,0,0,no_relay);
updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)"); updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)");
if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
exit_fun("noting to add"); exit_fun("noting to add");
}
proc->instance_cnt_rxtx--;
if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
exit_fun("noting to add");
}
} }
proc->instance_cnt_rxtx--;
if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
exit_fun("noting to add");
}
}
// thread finished // thread finished
free(arg); free(arg);
return &UE_thread_rxtx_retval; return &UE_thread_rxtx_retval;
} }
...@@ -783,196 +783,198 @@ static void *UE_thread_rxn_txnp4(void *arg) { ...@@ -783,196 +783,198 @@ static void *UE_thread_rxn_txnp4(void *arg) {
*/ */
static void *UE_phy_stub_thread_rxn_txnp4(void *arg) { static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
module_id_t Mod_id = 0; module_id_t Mod_id = 0;
static __thread int UE_thread_rxtx_retval; static __thread int UE_thread_rxtx_retval;
struct rx_tx_thread_data *rtd = arg; struct rx_tx_thread_data *rtd = arg;
UE_rxtx_proc_t *proc = rtd->proc; UE_rxtx_proc_t *proc = rtd->proc;
PHY_VARS_UE *UE = rtd->UE; PHY_VARS_UE *UE = rtd->UE;
int ret; int ret;
// Panos: Call (Sched_Rsp_t) get_nfapi_sched_response(UE->Mod_ID) to get all // Panos: Call (Sched_Rsp_t) get_nfapi_sched_response(UE->Mod_ID) to get all
//sched_response config messages which concern the specific UE. Inside this //sched_response config messages which concern the specific UE. Inside this
//function we should somehow make the translation of rnti to Mod_ID. //function we should somehow make the translation of rnti to Mod_ID.
//proc->instance_cnt_rxtx=-1; //proc->instance_cnt_rxtx=-1;
phy_stub_ticking->ticking_var = -1; phy_stub_ticking->ticking_var = -1;
proc->subframe_rx=proc->sub_frame_start; proc->subframe_rx=proc->sub_frame_start;
char threadname[256];
sprintf(threadname,"UE_%d_proc_%d", UE->Mod_id, proc->sub_frame_start);
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 )
CPU_SET(threads.one, &cpuset);
if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 )
CPU_SET(threads.two, &cpuset);
if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 )
CPU_SET(threads.three, &cpuset);
//CPU_SET(threads.three, &cpuset);
init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset,
threadname);
wait_sync("UE_phy_stub_thread_rxn_txnp4");
while (!oai_exit) { char threadname[256];
if (pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) != 0) { sprintf(threadname,"UE_%d_proc_%d", UE->Mod_id, proc->sub_frame_start);
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); cpu_set_t cpuset;
exit_fun("nothing to add"); CPU_ZERO(&cpuset);
}
while (phy_stub_ticking->ticking_var < 0) {
// most of the time, the thread is waiting here
//pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx );
pthread_cond_wait( &phy_stub_ticking->cond_ticking, &phy_stub_ticking->mutex_ticking);
}
if (pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" );
exit_fun("nothing to add");
}
proc->subframe_rx=timer_subframe;
proc->frame_rx = timer_frame;
proc->subframe_tx=(timer_subframe+2)%10;
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
// Panos: Guessing that the next 4 lines are not needed for the phy_stub mode.
/*initRefTimes(t2);
initRefTimes(t3);
pickTime(current);
updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)");*/
// Process Rx data for one sub-frame
lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx);
if ((sf_type == SF_DL) ||
(UE->frame_parms.frame_type == FDD) ||
(sf_type == SF_S)) {
if (UE->frame_parms.frame_type == TDD) {
LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n",
threadname,
UE->frame_parms.tdd_config,
(sf_type==SF_DL? "SF_DL" :
(sf_type==SF_UL? "SF_UL" :
(sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE"))));
} else {
LOG_D(PHY, "%s,%s,%s: calling UE_RX\n",
threadname,
(UE->frame_parms.frame_type==FDD? "FDD":
(UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")),
(sf_type==SF_DL? "SF_DL" :
(sf_type==SF_UL? "SF_UL" :
(sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE"))));
}
/* if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 )
#ifdef UE_SLOT_PARALLELISATION CPU_SET(threads.one, &cpuset);
phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 )
#else CPU_SET(threads.two, &cpuset);
*/ if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 )
// Panos: Substitute call to phy_procedures Rx with call to phy_stub functions in order to trigger CPU_SET(threads.three, &cpuset);
// UE Rx procedures directly at the MAC layer, based on the received nfapi requests from the vnf (eNB). //CPU_SET(threads.three, &cpuset);
// Hardcode Mod_id for now. Will be changed later. init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset,
threadname);
// Panos: is this the right place to call oai_subframe_indication to invoke p7 nfapi callbacks here? wait_sync("UE_phy_stub_thread_rxn_txnp4");
oai_subframe_ind(proc->frame_rx, proc->subframe_rx);
LOG_I( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind \n"); while (!oai_exit) {
//printf("Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind \n"); if (pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) != 0) {
/*if(UE_mac_inst[Mod_id].tx_req!= NULL){ LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
printf("Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 2\n"); exit_fun("nothing to add");
tx_req_UE_MAC(UE_mac_inst[Mod_id].tx_req); }
}*/ while (phy_stub_ticking->ticking_var < 0) {
if(UE_mac_inst[Mod_id].dl_config_req!= NULL) { // most of the time, the thread is waiting here
LOG_I( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 3 \n"); //pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx );
dl_config_req_UE_MAC(UE_mac_inst[Mod_id].dl_config_req); pthread_cond_wait( &phy_stub_ticking->cond_ticking, &phy_stub_ticking->mutex_ticking);
} }
if(UE_mac_inst[Mod_id].hi_dci0_req!= NULL){ if (pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) != 0) {
LOG_I( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 4 \n"); LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" );
hi_dci0_req_UE_MAC(UE_mac_inst[Mod_id].hi_dci0_req); exit_fun("nothing to add");
} }
//#endif proc->subframe_rx=timer_subframe;
} proc->frame_rx = timer_frame;
proc->subframe_tx=(timer_subframe+2)%10;
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
// Panos: Guessing that the next 4 lines are not needed for the phy_stub mode.
/*initRefTimes(t2);
initRefTimes(t3);
pickTime(current);
updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)");*/
// Process Rx data for one sub-frame
lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx);
if ((sf_type == SF_DL) ||
(UE->frame_parms.frame_type == FDD) ||
(sf_type == SF_S)) {
if (UE->frame_parms.frame_type == TDD) {
LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n",
threadname,
UE->frame_parms.tdd_config,
(sf_type==SF_DL? "SF_DL" :
(sf_type==SF_UL? "SF_UL" :
(sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE"))));
} else {
LOG_D(PHY, "%s,%s,%s: calling UE_RX\n",
threadname,
(UE->frame_parms.frame_type==FDD? "FDD":
(UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")),
(sf_type==SF_DL? "SF_DL" :
(sf_type==SF_UL? "SF_UL" :
(sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE"))));
}
phy_procedures_UE_SL_RX(UE,proc);
/*
#ifdef UE_SLOT_PARALLELISATION
phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL );
#else
*/
// Panos: Substitute call to phy_procedures Rx with call to phy_stub functions in order to trigger
// UE Rx procedures directly at the MAC layer, based on the received nfapi requests from the vnf (eNB).
// Hardcode Mod_id for now. Will be changed later.
// Panos: is this the right place to call oai_subframe_indication to invoke p7 nfapi callbacks here?
oai_subframe_ind(proc->frame_rx, proc->subframe_rx);
LOG_D( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind \n");
//printf("Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind \n");
/*if(UE_mac_inst[Mod_id].tx_req!= NULL){
printf("Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 2\n");
tx_req_UE_MAC(UE_mac_inst[Mod_id].tx_req);
}*/
if(UE_mac_inst[Mod_id].dl_config_req!= NULL) {
LOG_D( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 3 \n");
dl_config_req_UE_MAC(UE_mac_inst[Mod_id].dl_config_req);
}
if(UE_mac_inst[Mod_id].hi_dci0_req!= NULL){
LOG_D( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 4 \n");
hi_dci0_req_UE_MAC(UE_mac_inst[Mod_id].hi_dci0_req);
}
phy_procedures_UE_SL_TX(UE,proc);
//#endif
}
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&UE->generic_stat); start_meas(&UE->generic_stat);
#endif #endif
if (UE->mac_enabled==1) { if (UE->mac_enabled==1) {
ret = ue_scheduler(UE->Mod_id, ret = ue_scheduler(UE->Mod_id,
proc->frame_rx, proc->frame_rx,
proc->subframe_rx, proc->subframe_rx,
proc->frame_tx, proc->frame_tx,
proc->subframe_tx, proc->subframe_tx,
subframe_select(&UE->frame_parms,proc->subframe_tx), subframe_select(&UE->frame_parms,proc->subframe_tx),
0, 0,
0/*FIXME CC_id*/); 0/*FIXME CC_id*/);
if ( ret != CONNECTION_OK) { if ( ret != CONNECTION_OK) {
char *txt; char *txt;
switch (ret) { switch (ret) {
case CONNECTION_LOST: case CONNECTION_LOST:
txt="RRC Connection lost, returning to PRACH"; txt="RRC Connection lost, returning to PRACH";
break; break;
case PHY_RESYNCH: case PHY_RESYNCH:
txt="RRC Connection lost, trying to resynch"; txt="RRC Connection lost, trying to resynch";
break; break;
case RESYNCH: case RESYNCH:
txt="return to PRACH and perform a contention-free access"; txt="return to PRACH and perform a contention-free access";
break; break;
default: default:
txt="UNKNOWN RETURN CODE"; txt="UNKNOWN RETURN CODE";
}; };
LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n", LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n",
UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt ); UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt );
} }
} }
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
stop_meas(&UE->generic_stat); stop_meas(&UE->generic_stat);
#endif #endif
// Prepare the future Tx data // Prepare the future Tx data
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) )
if (UE->mode != loop_through_memory){
// Panos: Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
// UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
// Generate UL_indications which corresponf to UL traffic.
if(UE_mac_inst[Mod_id].ul_config_req!= NULL){
ul_config_req_UE_MAC(UE_mac_inst[Mod_id].ul_config_req);
UL_indication(UL_INFO);
}
}
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) )
if (UE->mode != loop_through_memory){
// Panos: Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
// UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
// Generate UL_indications which corresponf to UL traffic.
if(UE_mac_inst[Mod_id].ul_config_req!= NULL){
ul_config_req_UE_MAC(UE_mac_inst[Mod_id].ul_config_req);
UL_indication(UL_INFO);
}
}
phy_procedures_UE_SL_RX(UE,proc);
/*if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) && /*if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) &&
(UE->frame_parms.frame_type == TDD)) (UE->frame_parms.frame_type == TDD))
if (UE->mode != loop_through_memory) if (UE->mode != loop_through_memory)
phy_procedures_UE_S_TX(UE,0,0,no_relay); phy_procedures_UE_S_TX(UE,0,0,no_relay);
updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)");*/ updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)");*/
//if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { //if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) {
if (pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) != 0) { if (pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) != 0) {
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
exit_fun("noting to add"); exit_fun("noting to add");
} }
//proc->instance_cnt_rxtx--; //proc->instance_cnt_rxtx--;
phy_stub_ticking->ticking_var--; phy_stub_ticking->ticking_var--;
//if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) { //if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
if (pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) != 0) { if (pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" ); LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
exit_fun("noting to add"); exit_fun("noting to add");
}
} }
}
// thread finished // thread finished
free(arg); free(arg);
return &UE_thread_rxtx_retval; return &UE_thread_rxtx_retval;
} }
...@@ -990,242 +992,242 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) { ...@@ -990,242 +992,242 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
void *UE_thread(void *arg) { void *UE_thread(void *arg) {
PHY_VARS_UE *UE = (PHY_VARS_UE *) arg; PHY_VARS_UE *UE = (PHY_VARS_UE *) arg;
// int tx_enabled = 0; // int tx_enabled = 0;
int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32))); int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32)));
openair0_timestamp timestamp,timestamp1; openair0_timestamp timestamp,timestamp1;
void* rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX]; void* rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX];
int start_rx_stream = 0; int start_rx_stream = 0;
int i; int i;
int th_id; int th_id;
static uint8_t thread_idx = 0; static uint8_t thread_idx = 0;
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
if ( threads.iq != -1 ) if ( threads.iq != -1 )
CPU_SET(threads.iq, &cpuset); CPU_SET(threads.iq, &cpuset);
init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, init_thread(100000, 500000, FIFO_PRIORITY, &cpuset,
"UHD Threads"); "UHD Threads");
#ifdef NAS_UE #ifdef NAS_UE
MessageDef *message_p; MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE); message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE);
itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p); itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p);
#endif #endif
int sub_frame=-1; int sub_frame=-1;
//int cumulated_shift=0; //int cumulated_shift=0;
while (!oai_exit) { while (!oai_exit) {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
int instance_cnt_synch = UE->proc.instance_cnt_synch; int instance_cnt_synch = UE->proc.instance_cnt_synch;
int is_synchronized = UE->is_synchronized; int is_synchronized = UE->is_synchronized;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if (is_synchronized == 0) { if (is_synchronized == 0) {
if (instance_cnt_synch < 0) { // we can invoke the synch if (instance_cnt_synch < 0) { // we can invoke the synch
// grab 10 ms of signal and wakeup synch thread // grab 10 ms of signal and wakeup synch thread
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void*)&UE->common_vars.rxdata[i][0]; rxp[i] = (void*)&UE->common_vars.rxdata[i][0];
if (UE->mode != loop_through_memory) if (UE->mode != loop_through_memory)
AssertFatal( UE->frame_parms.samples_per_tti*10 == AssertFatal( UE->frame_parms.samples_per_tti*10 ==
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
rxp, rxp,
UE->frame_parms.samples_per_tti*10, UE->frame_parms.samples_per_tti*10,
UE->frame_parms.nb_antennas_rx), ""); UE->frame_parms.nb_antennas_rx), "");
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
instance_cnt_synch = ++UE->proc.instance_cnt_synch; instance_cnt_synch = ++UE->proc.instance_cnt_synch;
if (instance_cnt_synch == 0) { if (instance_cnt_synch == 0) {
AssertFatal( 0 == pthread_cond_signal(&UE->proc.cond_synch), ""); AssertFatal( 0 == pthread_cond_signal(&UE->proc.cond_synch), "");
} else { } else {
LOG_E( PHY, "[SCHED][UE] UE sync thread busy!!\n" ); LOG_E( PHY, "[SCHED][UE] UE sync thread busy!!\n" );
exit_fun("nothing to add"); exit_fun("nothing to add");
} }
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
} else { } else {
#if OAISIM #if OAISIM
(void)dummy_rx; /* avoid gcc warnings */ (void)dummy_rx; /* avoid gcc warnings */
usleep(500); usleep(500);
#else #else
// grab 10 ms of signal into dummy buffer // grab 10 ms of signal into dummy buffer
if (UE->mode != loop_through_memory) { if (UE->mode != loop_through_memory) {
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void*)&dummy_rx[i][0]; rxp[i] = (void*)&dummy_rx[i][0];
for (int sf=0; sf<10; sf++) for (int sf=0; sf<10; sf++)
// printf("Reading dummy sf %d\n",sf); // printf("Reading dummy sf %d\n",sf);
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
rxp, rxp,
UE->frame_parms.samples_per_tti, UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx); UE->frame_parms.nb_antennas_rx);
} }
#endif #endif
} }
} // UE->is_synchronized==0 } // UE->is_synchronized==0
else { else {
if (start_rx_stream==0) { if (start_rx_stream==0) {
start_rx_stream=1; start_rx_stream=1;
if (UE->mode != loop_through_memory) { if (UE->mode != loop_through_memory) {
if (UE->no_timing_correction==0) { if (UE->no_timing_correction==0) {
LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
AssertFatal(UE->rx_offset == AssertFatal(UE->rx_offset ==
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
(void**)UE->common_vars.rxdata, (void**)UE->common_vars.rxdata,
UE->rx_offset, UE->rx_offset,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
} }
UE->rx_offset=0; UE->rx_offset=0;
UE->time_sync_cell=0; UE->time_sync_cell=0;
//UE->proc.proc_rxtx[0].frame_rx++; //UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++; //UE->proc.proc_rxtx[1].frame_rx++;
for (th_id=0; th_id < RX_NB_TH; th_id++) { for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].frame_rx++; UE->proc.proc_rxtx[th_id].frame_rx++;
} }
// read in first symbol // read in first symbol
AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 == AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 ==
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
(void**)UE->common_vars.rxdata, (void**)UE->common_vars.rxdata,
UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
slot_fep(UE,0, 0, 0, 0, 0); slot_fep(UE,0, 0, 0, 0, 0);
} //UE->mode != loop_through_memory } //UE->mode != loop_through_memory
else else
rt_sleep_ns(1000*1000); rt_sleep_ns(1000*1000);
} else { } else {
sub_frame++; sub_frame++;
sub_frame%=10; sub_frame%=10;
UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[thread_idx]; UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[thread_idx];
// update thread index for received subframe // update thread index for received subframe
UE->current_thread_id[sub_frame] = thread_idx; UE->current_thread_id[sub_frame] = thread_idx;
LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]);
thread_idx++; thread_idx++;
if(thread_idx>=RX_NB_TH) if(thread_idx>=RX_NB_TH)
thread_idx = 0; thread_idx = 0;
if (UE->mode != loop_through_memory) { if (UE->mode != loop_through_memory) {
for (i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void*)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+ rxp[i] = (void*)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+
UE->frame_parms.nb_prefix_samples0+ UE->frame_parms.nb_prefix_samples0+
sub_frame*UE->frame_parms.samples_per_tti]; sub_frame*UE->frame_parms.samples_per_tti];
for (i=0; i<UE->frame_parms.nb_antennas_tx; i++) for (i=0; i<UE->frame_parms.nb_antennas_tx; i++)
txp[i] = (void*)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti]; txp[i] = (void*)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti];
int readBlockSize, writeBlockSize; int readBlockSize, writeBlockSize;
if (sub_frame<9) { if (sub_frame<9) {
readBlockSize=UE->frame_parms.samples_per_tti; readBlockSize=UE->frame_parms.samples_per_tti;
writeBlockSize=UE->frame_parms.samples_per_tti; writeBlockSize=UE->frame_parms.samples_per_tti;
} else { } else {
// set TO compensation to zero // set TO compensation to zero
UE->rx_offset_diff = 0; UE->rx_offset_diff = 0;
// compute TO compensation that should be applied for this frame // compute TO compensation that should be applied for this frame
if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti && if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti &&
UE->rx_offset > 0 ) UE->rx_offset > 0 )
UE->rx_offset_diff = -1 ; UE->rx_offset_diff = -1 ;
if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti && if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti &&
UE->rx_offset < 10*UE->frame_parms.samples_per_tti ) UE->rx_offset < 10*UE->frame_parms.samples_per_tti )
UE->rx_offset_diff = 1; UE->rx_offset_diff = 1;
LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset); LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset);
readBlockSize=UE->frame_parms.samples_per_tti - readBlockSize=UE->frame_parms.samples_per_tti -
UE->frame_parms.ofdm_symbol_size - UE->frame_parms.ofdm_symbol_size -
UE->frame_parms.nb_prefix_samples0 - UE->frame_parms.nb_prefix_samples0 -
UE->rx_offset_diff; UE->rx_offset_diff;
writeBlockSize=UE->frame_parms.samples_per_tti - writeBlockSize=UE->frame_parms.samples_per_tti -
UE->rx_offset_diff; UE->rx_offset_diff;
} }
AssertFatal(readBlockSize == AssertFatal(readBlockSize ==
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
rxp, rxp,
readBlockSize, readBlockSize,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
AssertFatal( writeBlockSize == AssertFatal( writeBlockSize ==
UE->rfdevice.trx_write_func(&UE->rfdevice, UE->rfdevice.trx_write_func(&UE->rfdevice,
timestamp+ timestamp+
(2*UE->frame_parms.samples_per_tti) - (2*UE->frame_parms.samples_per_tti) -
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
openair0_cfg[0].tx_sample_advance, openair0_cfg[0].tx_sample_advance,
txp, txp,
writeBlockSize, writeBlockSize,
UE->frame_parms.nb_antennas_tx, UE->frame_parms.nb_antennas_tx,
1),""); 1),"");
if( sub_frame==9) { if( sub_frame==9) {
// read in first symbol of next frame and adjust for timing drift // read in first symbol of next frame and adjust for timing drift
int first_symbols=writeBlockSize-readBlockSize; int first_symbols=writeBlockSize-readBlockSize;
if ( first_symbols > 0 ) if ( first_symbols > 0 )
AssertFatal(first_symbols == AssertFatal(first_symbols ==
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp1, &timestamp1,
(void**)UE->common_vars.rxdata, (void**)UE->common_vars.rxdata,
first_symbols, first_symbols,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
if ( first_symbols <0 ) if ( first_symbols <0 )
LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
} }
pickTime(gotIQs); pickTime(gotIQs);
// operate on thread sf mod 2 // operate on thread sf mod 2
AssertFatal(pthread_mutex_lock(&proc->mutex_rxtx) ==0,""); AssertFatal(pthread_mutex_lock(&proc->mutex_rxtx) ==0,"");
if(sub_frame == 0) { if(sub_frame == 0) {
//UE->proc.proc_rxtx[0].frame_rx++; //UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++; //UE->proc.proc_rxtx[1].frame_rx++;
for (th_id=0; th_id < RX_NB_TH; th_id++) { for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].frame_rx++; UE->proc.proc_rxtx[th_id].frame_rx++;
} }
} }
//UE->proc.proc_rxtx[0].gotIQs=readTime(gotIQs); //UE->proc.proc_rxtx[0].gotIQs=readTime(gotIQs);
//UE->proc.proc_rxtx[1].gotIQs=readTime(gotIQs); //UE->proc.proc_rxtx[1].gotIQs=readTime(gotIQs);
for (th_id=0; th_id < RX_NB_TH; th_id++) { for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].gotIQs=readTime(gotIQs); UE->proc.proc_rxtx[th_id].gotIQs=readTime(gotIQs);
} }
proc->subframe_rx=sub_frame; proc->subframe_rx=sub_frame;
proc->subframe_tx=(sub_frame+4)%10; proc->subframe_tx=(sub_frame+4)%10;
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
proc->timestamp_tx = timestamp+ proc->timestamp_tx = timestamp+
(4*UE->frame_parms.samples_per_tti)- (4*UE->frame_parms.samples_per_tti)-
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0; UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0;
proc->instance_cnt_rxtx++; proc->instance_cnt_rxtx++;
LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx); LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx);
if (proc->instance_cnt_rxtx == 0) { if (proc->instance_cnt_rxtx == 0) {
if (pthread_cond_signal(&proc->cond_rxtx) != 0) { if (pthread_cond_signal(&proc->cond_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id); LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id);
exit_fun("nothing to add"); exit_fun("nothing to add");
} }
} else { } else {
LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", UE->Mod_id, proc->instance_cnt_rxtx); LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", UE->Mod_id, proc->instance_cnt_rxtx);
if (proc->instance_cnt_rxtx > 2) if (proc->instance_cnt_rxtx > 2)
exit_fun("instance_cnt_rxtx > 2"); exit_fun("instance_cnt_rxtx > 2");
} }
AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0 ,""); AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0 ,"");
AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,""); AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,"");
initRefTimes(t1); initRefTimes(t1);
initStaticTime(lastTime); initStaticTime(lastTime);
updateTimes(lastTime, &t1, 20000, "Delay between two IQ acquisitions (case 1)"); updateTimes(lastTime, &t1, 20000, "Delay between two IQ acquisitions (case 1)");
pickStaticTime(lastTime); pickStaticTime(lastTime);
} else { } else {
printf("Processing subframe %d",proc->subframe_rx); printf("Processing subframe %d",proc->subframe_rx);
getchar(); getchar();
} }
} // start_rx_stream==1 } // start_rx_stream==1
} // UE->is_synchronized==1 } // UE->is_synchronized==1
} // while !oai_exit } // while !oai_exit
return NULL; return NULL;
} }
...@@ -1242,47 +1244,47 @@ void *UE_thread(void *arg) { ...@@ -1242,47 +1244,47 @@ void *UE_thread(void *arg) {
* and the locking between them. * and the locking between them.
*/ */
void init_UE_threads(int inst) { void init_UE_threads(int inst) {
struct rx_tx_thread_data *rtd; struct rx_tx_thread_data *rtd;
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n"); AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
AssertFatal(PHY_vars_UE_g[inst]!=NULL,"PHY_vars_UE_g[inst] is NULL\n"); AssertFatal(PHY_vars_UE_g[inst]!=NULL,"PHY_vars_UE_g[inst] is NULL\n");
AssertFatal(PHY_vars_UE_g[inst][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n"); AssertFatal(PHY_vars_UE_g[inst][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n");
UE = PHY_vars_UE_g[inst][0]; UE = PHY_vars_UE_g[inst][0];
pthread_attr_init (&UE->proc.attr_ue); pthread_attr_init (&UE->proc.attr_ue);
pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN); pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN);
pthread_mutex_init(&UE->proc.mutex_synch,NULL); pthread_mutex_init(&UE->proc.mutex_synch,NULL);
pthread_cond_init(&UE->proc.cond_synch,NULL); pthread_cond_init(&UE->proc.cond_synch,NULL);
// the threads are not yet active, therefore access is allowed without locking // the threads are not yet active, therefore access is allowed without locking
int nb_threads=RX_NB_TH; int nb_threads=RX_NB_TH;
for (int i=0; i<nb_threads; i++) { for (int i=0; i<nb_threads; i++) {
rtd = calloc(1, sizeof(struct rx_tx_thread_data)); rtd = calloc(1, sizeof(struct rx_tx_thread_data));
if (rtd == NULL) abort(); if (rtd == NULL) abort();
rtd->UE = UE; rtd->UE = UE;
rtd->proc = &UE->proc.proc_rxtx[i]; rtd->proc = &UE->proc.proc_rxtx[i];
pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL); pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL);
pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL); pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL);
UE->proc.proc_rxtx[i].sub_frame_start=i; UE->proc.proc_rxtx[i].sub_frame_start=i;
UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; UE->proc.proc_rxtx[i].sub_frame_step=nb_threads;
printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i); printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i);
pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_thread_rxn_txnp4, rtd); pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_thread_rxn_txnp4, rtd);
#ifdef UE_SLOT_PARALLELISATION #ifdef UE_SLOT_PARALLELISATION
//pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot0_dl_processing,NULL); //pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot0_dl_processing,NULL);
//pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot0_dl_processing,NULL); //pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot0_dl_processing,NULL);
//pthread_create(&UE->proc.proc_rxtx[i].pthread_slot0_dl_processing,NULL,UE_thread_slot0_dl_processing, rtd); //pthread_create(&UE->proc.proc_rxtx[i].pthread_slot0_dl_processing,NULL,UE_thread_slot0_dl_processing, rtd);
pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot1_dl_processing,NULL); pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot1_dl_processing,NULL);
pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot1_dl_processing,NULL); pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot1_dl_processing,NULL);
pthread_create(&UE->proc.proc_rxtx[i].pthread_slot1_dl_processing,NULL,UE_thread_slot1_dl_processing, rtd); pthread_create(&UE->proc.proc_rxtx[i].pthread_slot1_dl_processing,NULL,UE_thread_slot1_dl_processing, rtd);
#endif #endif
} }
pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE);
} }
...@@ -1299,58 +1301,58 @@ void init_UE_threads(int inst) { ...@@ -1299,58 +1301,58 @@ void init_UE_threads(int inst) {
* and the locking between them. * and the locking between them.
*/ */
void init_UE_threads_stub(int inst) { void init_UE_threads_stub(int inst) {
struct rx_tx_thread_data *rtd; struct rx_tx_thread_data *rtd;
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
AssertFatal(PHY_vars_UE_g[inst]!=NULL,"PHY_vars_UE_g[inst] is NULL\n");
AssertFatal(PHY_vars_UE_g[inst][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n");
UE = PHY_vars_UE_g[inst][0];
pthread_attr_init (&UE->proc.attr_ue);
pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN);
// Panos: Don't need synch for phy_stub mode
//pthread_mutex_init(&UE->proc.mutex_synch,NULL);
//pthread_cond_init(&UE->proc.cond_synch,NULL);
// the threads are not yet active, therefore access is allowed without locking
// Panos: In phy_stub_UE mode due to less heavy processing operations we don't need two threads
//int nb_threads=RX_NB_TH;
int nb_threads=1;
for (int i=0; i<nb_threads; i++) {
rtd = calloc(1, sizeof(struct rx_tx_thread_data));
if (rtd == NULL) abort();
rtd->UE = UE;
rtd->proc = &UE->proc.proc_rxtx[i];
pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL);
pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL);
UE->proc.proc_rxtx[i].sub_frame_start=i;
UE->proc.proc_rxtx[i].sub_frame_step=nb_threads;
printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i);
pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_phy_stub_thread_rxn_txnp4, rtd);
/*
#ifdef UE_SLOT_PARALLELISATION
//pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot0_dl_processing,NULL);
//pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot0_dl_processing,NULL);
//pthread_create(&UE->proc.proc_rxtx[i].pthread_slot0_dl_processing,NULL,UE_thread_slot0_dl_processing, rtd);
pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot1_dl_processing,NULL); AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot1_dl_processing,NULL); AssertFatal(PHY_vars_UE_g[inst]!=NULL,"PHY_vars_UE_g[inst] is NULL\n");
pthread_create(&UE->proc.proc_rxtx[i].pthread_slot1_dl_processing,NULL,UE_thread_slot1_dl_processing, rtd); AssertFatal(PHY_vars_UE_g[inst][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n");
#endif*/ UE = PHY_vars_UE_g[inst][0];
pthread_attr_init (&UE->proc.attr_ue);
pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN);
// Panos: Don't need synch for phy_stub mode
//pthread_mutex_init(&UE->proc.mutex_synch,NULL);
//pthread_cond_init(&UE->proc.cond_synch,NULL);
// the threads are not yet active, therefore access is allowed without locking
// Panos: In phy_stub_UE mode due to less heavy processing operations we don't need two threads
//int nb_threads=RX_NB_TH;
int nb_threads=1;
for (int i=0; i<nb_threads; i++) {
rtd = calloc(1, sizeof(struct rx_tx_thread_data));
if (rtd == NULL) abort();
rtd->UE = UE;
rtd->proc = &UE->proc.proc_rxtx[i];
pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL);
pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL);
UE->proc.proc_rxtx[i].sub_frame_start=i;
UE->proc.proc_rxtx[i].sub_frame_step=nb_threads;
printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i);
pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_phy_stub_thread_rxn_txnp4, rtd);
/*
#ifdef UE_SLOT_PARALLELISATION
//pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot0_dl_processing,NULL);
//pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot0_dl_processing,NULL);
//pthread_create(&UE->proc.proc_rxtx[i].pthread_slot0_dl_processing,NULL,UE_thread_slot0_dl_processing, rtd);
pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot1_dl_processing,NULL);
pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot1_dl_processing,NULL);
pthread_create(&UE->proc.proc_rxtx[i].pthread_slot1_dl_processing,NULL,UE_thread_slot1_dl_processing, rtd);
#endif*/
} }
// Panos: Remove thread for UE_sync in phy_stub_UE mode. // Panos: Remove thread for UE_sync in phy_stub_UE mode.
//pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); //pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE);
} }
#ifdef OPENAIR2 #ifdef OPENAIR2
void fill_ue_band_info(void) { void fill_ue_band_info(void) {
UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability; UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability;
int i,j; int i,j;
...@@ -1359,155 +1361,155 @@ void fill_ue_band_info(void) { ...@@ -1359,155 +1361,155 @@ void fill_ue_band_info(void) {
for (i=0; i<bands_to_scan.nbands; i++) { for (i=0; i<bands_to_scan.nbands; i++) {
for (j=0; j<sizeof (eutra_bands) / sizeof (eutra_bands[0]); j++) for (j=0; j<sizeof (eutra_bands) / sizeof (eutra_bands[0]); j++)
if (eutra_bands[j].band == UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA) { if (eutra_bands[j].band == UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA) {
memcpy(&bands_to_scan.band_info[i], memcpy(&bands_to_scan.band_info[i],
&eutra_bands[j], &eutra_bands[j],
sizeof(eutra_band_t)); sizeof(eutra_band_t));
printf("Band %d (%lu) : DL %u..%u Hz, UL %u..%u Hz, Duplex %s \n", printf("Band %d (%lu) : DL %u..%u Hz, UL %u..%u Hz, Duplex %s \n",
bands_to_scan.band_info[i].band, bands_to_scan.band_info[i].band,
UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA, UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA,
bands_to_scan.band_info[i].dl_min, bands_to_scan.band_info[i].dl_min,
bands_to_scan.band_info[i].dl_max, bands_to_scan.band_info[i].dl_max,
bands_to_scan.band_info[i].ul_min, bands_to_scan.band_info[i].ul_min,
bands_to_scan.band_info[i].ul_max, bands_to_scan.band_info[i].ul_max,
(bands_to_scan.band_info[i].frame_type==FDD) ? "FDD" : "TDD"); (bands_to_scan.band_info[i].frame_type==FDD) ? "FDD" : "TDD");
break; break;
} }
} }
} }
#endif #endif
int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg) { int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg) {
int i, CC_id; int i, CC_id;
LTE_DL_FRAME_PARMS *frame_parms; LTE_DL_FRAME_PARMS *frame_parms;
openair0_rf_map *rf_map; openair0_rf_map *rf_map;
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
rf_map = &phy_vars_ue[CC_id]->rf_map; rf_map = &phy_vars_ue[CC_id]->rf_map;
AssertFatal( phy_vars_ue[CC_id] !=0, ""); AssertFatal( phy_vars_ue[CC_id] !=0, "");
frame_parms = &(phy_vars_ue[CC_id]->frame_parms); frame_parms = &(phy_vars_ue[CC_id]->frame_parms);
// replace RX signal buffers with mmaped HW versions // replace RX signal buffers with mmaped HW versions
rxdata = (int32_t**)malloc16( frame_parms->nb_antennas_rx*sizeof(int32_t*) ); rxdata = (int32_t**)malloc16( frame_parms->nb_antennas_rx*sizeof(int32_t*) );
txdata = (int32_t**)malloc16( frame_parms->nb_antennas_tx*sizeof(int32_t*) ); txdata = (int32_t**)malloc16( frame_parms->nb_antennas_tx*sizeof(int32_t*) );
for (i=0; i<frame_parms->nb_antennas_rx; i++) { for (i=0; i<frame_parms->nb_antennas_rx; i++) {
LOG_I(PHY, "Mapping UE CC_id %d, rx_ant %d, freq %u on card %d, chain %d\n", LOG_I(PHY, "Mapping UE CC_id %d, rx_ant %d, freq %u on card %d, chain %d\n",
CC_id, i, downlink_frequency[CC_id][i], rf_map->card, rf_map->chain+i ); CC_id, i, downlink_frequency[CC_id][i], rf_map->card, rf_map->chain+i );
free( phy_vars_ue[CC_id]->common_vars.rxdata[i] ); free( phy_vars_ue[CC_id]->common_vars.rxdata[i] );
rxdata[i] = (int32_t*)malloc16_clear( 307200*sizeof(int32_t) ); rxdata[i] = (int32_t*)malloc16_clear( 307200*sizeof(int32_t) );
phy_vars_ue[CC_id]->common_vars.rxdata[i] = rxdata[i]; // what about the "-N_TA_offset" ? // N_TA offset for TDD phy_vars_ue[CC_id]->common_vars.rxdata[i] = rxdata[i]; // what about the "-N_TA_offset" ? // N_TA offset for TDD
} }
for (i=0; i<frame_parms->nb_antennas_tx; i++) { for (i=0; i<frame_parms->nb_antennas_tx; i++) {
LOG_I(PHY, "Mapping UE CC_id %d, tx_ant %d, freq %u on card %d, chain %d\n", LOG_I(PHY, "Mapping UE CC_id %d, tx_ant %d, freq %u on card %d, chain %d\n",
CC_id, i, downlink_frequency[CC_id][i], rf_map->card, rf_map->chain+i ); CC_id, i, downlink_frequency[CC_id][i], rf_map->card, rf_map->chain+i );
free( phy_vars_ue[CC_id]->common_vars.txdata[i] ); free( phy_vars_ue[CC_id]->common_vars.txdata[i] );
txdata[i] = (int32_t*)malloc16_clear( 307200*sizeof(int32_t) ); txdata[i] = (int32_t*)malloc16_clear( 307200*sizeof(int32_t) );
phy_vars_ue[CC_id]->common_vars.txdata[i] = txdata[i]; phy_vars_ue[CC_id]->common_vars.txdata[i] = txdata[i];
} }
// rxdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.rxdata[x] // rxdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.rxdata[x]
// txdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.txdata[x] // txdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.txdata[x]
// be careful when releasing memory! // be careful when releasing memory!
// because no "release_ue_buffers"-function is available, at least rxdata and txdata memory will leak (only some bytes) // because no "release_ue_buffers"-function is available, at least rxdata and txdata memory will leak (only some bytes)
} }
return 0; return 0;
} }
// Panos: This timer thread is used only in the phy_sub mode as an independent timer // Panos: This timer thread is used only in the phy_sub mode as an independent timer
// which will be ticking and provide the SFN/SF values that will be used from the UE threads // which will be ticking and provide the SFN/SF values that will be used from the UE threads
// playing the role of nfapi-pnf. // playing the role of nfapi-pnf.
static void* timer_thread( void* param ) { static void* timer_thread( void* param ) {
thread_top_init("timer_thread",1,870000L,1000000L,1000000L); thread_top_init("timer_thread",1,870000L,1000000L,1000000L);
timer_subframe =9; timer_subframe =9;
timer_frame =1023; timer_frame =1023;
//phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking)); //phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking));
phy_stub_ticking->ticking_var = -1; phy_stub_ticking->ticking_var = -1;
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
UE = PHY_vars_UE_g[0][0]; UE = PHY_vars_UE_g[0][0];
double t_diff; double t_diff;
wait_sync("timer_thread"); wait_sync("timer_thread");
//pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL); //pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL);
//pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL); //pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL);
struct timespec start = {0}; struct timespec start = {0};
struct timespec end = {0}; struct timespec end = {0};
//sleepValue.tv_nsec = 1000000; //sleepValue.tv_nsec = 1000000;
opp_enabled = 1; opp_enabled = 1;
while (!oai_exit) { 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.
if (timer_subframe==9) {
timer_subframe=0;
timer_frame++;
timer_frame&=1023;
} else {
timer_subframe++;
}
//printf("[timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe);
LOG_I(MAC," Panos-D [timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe);
//AssertFatal( 0 == pthread_cond_signal(&phy_stub_ticking->cond_ticking), "");
AssertFatal(pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) ==0,"");
phy_stub_ticking->ticking_var++;
// This should probably be a call to pthread_cond_broadcast when we introduce support for multiple UEs (threads)
if(phy_stub_ticking->ticking_var == 0){
//AssertFatal(phy_stub_ticking->ticking_var == 0,"phy_stub_ticking->ticking_var = %d",
// phy_stub_ticking->ticking_var);
if (pthread_cond_signal(&phy_stub_ticking->cond_ticking) != 0) {
//LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id);
LOG_E( PHY, "timer_thread ERROR pthread_cond_signal for UE_thread\n");
exit_fun("nothing to add");
}
}
AssertFatal(pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) ==0,""); // these are local subframe/frame counters to check that we are in synch with the fronthaul timing.
start_meas(&UE->timer_stats); // They are set on the first rx/tx in the underly FH routines.
if (timer_subframe==9) {
timer_subframe=0;
timer_frame++;
timer_frame&=1023;
} else {
timer_subframe++;
}
//printf("[timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe);
LOG_D(MAC," Panos-D [timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe);
//AssertFatal( 0 == pthread_cond_signal(&phy_stub_ticking->cond_ticking), "");
AssertFatal(pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) ==0,"");
phy_stub_ticking->ticking_var++;
// This should probably be a call to pthread_cond_broadcast when we introduce support for multiple UEs (threads)
if(phy_stub_ticking->ticking_var == 0){
//AssertFatal(phy_stub_ticking->ticking_var == 0,"phy_stub_ticking->ticking_var = %d",
// phy_stub_ticking->ticking_var);
if (pthread_cond_signal(&phy_stub_ticking->cond_ticking) != 0) {
//LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id);
LOG_E( PHY, "timer_thread ERROR pthread_cond_signal for UE_thread\n");
exit_fun("nothing to add");
}
}
AssertFatal(pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) ==0,"");
start_meas(&UE->timer_stats);
//clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); // get initial time-stamp
usleep(1000);
//clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); // get final time-stamp //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); // get initial time-stamp
usleep(1000);
//double t_ns = (double)(end.tv_sec - start.tv_sec) * 1.0e9 + //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); // get final time-stamp
// (double)(end.tv_nsec - start.tv_nsec);
//printf("Panos-D: [timer_thread] REAL TIME difference: %f", t_ns);
//double t_ns = (double)(end.tv_sec - start.tv_sec) * 1.0e9 +
// (double)(end.tv_nsec - start.tv_nsec);
//printf("Panos-D: [timer_thread] REAL TIME difference: %f", t_ns);
//nanosleep(&sleepValue, NULL);
stop_meas(&UE->timer_stats); //nanosleep(&sleepValue, NULL);
t_diff = get_time_meas_us(&UE->timer_stats);
//printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now);
//LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP);
if (t_diff > 1100) LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff);
//printf("Panos-D: Absolute time: %f", t_diff);
//UE->proc.ticking_var++; stop_meas(&UE->timer_stats);
// pthread_cond_signal() //Send signal to ue_thread()? t_diff = get_time_meas_us(&UE->timer_stats);
// We also need to somehow pass the information of SFN/SF //printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now);
} //LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP);
free(phy_stub_ticking); //if (t_diff > 1100) LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff);
pthread_cond_destroy(&phy_stub_ticking->cond_ticking); //printf("Panos-D: Absolute time: %f", t_diff);
pthread_mutex_destroy(&phy_stub_ticking->mutex_ticking);
return 0;
} //UE->proc.ticking_var++;
// pthread_cond_signal() //Send signal to ue_thread()?
// We also need to somehow pass the information of SFN/SF
}
free(phy_stub_ticking);
pthread_cond_destroy(&phy_stub_ticking->cond_ticking);
pthread_mutex_destroy(&phy_stub_ticking->mutex_ticking);
return 0;
int init_timer_thread(void) { }
phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking));
pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL); int init_timer_thread(void) {
pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL); phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking));
pthread_create(phy_stub_ticking->pthread_timer, NULL, &timer_thread, NULL); pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL);
return 0; pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL);
} pthread_create(phy_stub_ticking->pthread_timer, NULL, &timer_thread, NULL);
return 0;
}
......
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