Commit 45b5d75f authored by Raymond Knopp's avatar Raymond Knopp

integration of L1/L2 sidelink synchronization. USRP interfaces and threading...

integration of L1/L2 sidelink synchronization. USRP interfaces and threading for sidelink. Currently only HW support for off-network case.
parent bd4d8164
......@@ -884,7 +884,7 @@ typedef struct {
uint16_t slss_id;
uint8_t slmib_length;
uint8_t *slmib;
uint8_t slmib[5];
} SLSS_t;
......
......@@ -43,10 +43,12 @@ void check_and_generate_slss(PHY_VARS_UE *ue,int frame_tx,int subframe_tx) {
int tx_amp;
if (slss->slmib == NULL) return;
if ((((10*frame_tx) + subframe_tx)%40) != slss->SL_OffsetIndicator) return;
if (slss->slmib_length == 0) return;
// here we have a transmission opportunity for SLSS
ue->frame_parms.Nid_SL = slss->slss_id;
......
......@@ -639,6 +639,7 @@ typedef struct {
struct sched_param sched_param_ue;
/// pthread descriptor main UE thread
pthread_t pthread_ue;
/// \brief Instance count for synch thread.
/// \internal This variable is protected by \ref mutex_synch.
int instance_cnt_synch;
......@@ -652,6 +653,34 @@ typedef struct {
pthread_cond_t cond_synch;
/// mutex for UE synch thread
pthread_mutex_t mutex_synch;
/// pthread attributes for main UE thread
pthread_attr_t attr_ueSL;
/// scheduling parameters for main UE thread
struct sched_param sched_param_ueSL;
/// pthread descriptor main UE thread
pthread_t pthread_ueSL;
/// \brief Instance count for SL synch thread.
/// \internal This variable is protected by \ref mutex_synch.
int instance_cnt_synchSL;
/// pthread attributes for SL synch processing thread
pthread_attr_t attr_synchSL;
/// scheduling parameters for sL synch thread
struct sched_param sched_param_synchSL;
/// pthread descriptor SL synch thread
pthread_t pthread_synchSL;
/// condition variable for UE SL synch thread;
pthread_cond_t cond_synchSL;
/// mutex for UE sL synch thread
pthread_mutex_t mutex_synchSL;
/// instance count for synchronizing UE_thread (DL/UL) with UE_threadSL
int instance_cnt_SL;
/// condition variable for synchronizing UE_thread (DL/UL) with UE_threadSL
pthread_cond_t cond_SL;
/// mutex for synchronizing UE_thread (DL/UL) with UE_threadSL
pthread_mutex_t mutex_SL;
/// instance count for eNBs
int instance_cnt_eNBs;
/// set of scheduling variables RXn-TXnp4 threads
......@@ -1210,6 +1239,10 @@ typedef struct {
int UE_scan_carrier;
/// \brief Indicator that UE is synchronized to an eNB
int is_synchronized;
/// \brief Indicator that UE is synchronized to a SyncRef UE on SL
int is_synchronizedSL;
/// \brief Indicator that UE is an SynchRef UE
int is_SynchRef;
/// Data structure for UE process scheduling
UE_proc_t proc;
/// Flag to indicate the UE shouldn't do timing correction at all
......@@ -1370,9 +1403,10 @@ typedef struct {
int dlsch_mtch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mcch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mtch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX];
int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX];
unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX];
uint8_t sidelink_active;
uint8_t SLonly;
uint8_t destination_id;
// DMRS group-hopping sequences for PSBCH (index 0) and 256 possible PSSCH (indices 1...256)
uint32_t gh[257][20];
......@@ -1387,6 +1421,8 @@ typedef struct {
uint8_t decode_SIB;
uint8_t decode_MIB;
int rx_offset; /// Timing offset
/// timing offset for SL
int rx_offsetSL;
int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP
int time_sync_cell;
int timing_advance; ///timing advance signalled from eNB
......@@ -1516,7 +1552,6 @@ typedef struct {
int instance_cnt_timer;
/// RF and Interface devices per CC
openair0_device rfdevice;
} PHY_VARS_UE;
......
......@@ -3143,8 +3143,15 @@ SLSS_t *ue_get_slss(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t su
SLSS_t *slss = &UE_mac_inst[Mod_id].slss;
// call RRC get check for SL-MIB
return((SLSS_t*)slss);
slss->slmib_length = mac_rrc_data_req_ue(Mod_id,
CC_id,
(frame_tx*10)+subframe_tx,
MIBCH, 1,
slss->slmib,
0,
0);
return(slss);
}
SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) {
......
......@@ -40,7 +40,7 @@
#include "rrc_eNB_UE_context.h"
#include "pdcp.h"
#include "msc.h"
#include "asn1_msg.h"
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
......@@ -55,31 +55,39 @@
int8_t
mac_rrc_data_req_ue(
const module_id_t Mod_idP,
const int CC_id,
const int CC_idP,
const frame_t frameP,
const rb_id_t Srb_id,
const uint8_t Nb_tb,
const rb_id_t Srb_idP,
const uint8_t Nb_tbP,
uint8_t* const buffer_pP,
const uint8_t eNB_index,
const uint8_t mbsfn_sync_area
const uint8_t eNB_indexP,
const uint8_t mbsfn_sync_areaP
)
//--------------------------------------------------------------------------
{
protocol_ctxt_t ctxt;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, Mod_idP, 0, 0, frameP/10, frameP%10,eNB_indexP);
#ifdef DEBUG_RRC
int i;
LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id);
LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_idP);
#endif
LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_id);
LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size);
LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_idP);
LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.payload_size);
AssertFatal(Srb_idP==MIBCH || Srb_idP==CCCH,"SRB_id %d is not possible should be (MIBCH %d or CCCH %d)\n",
Srb_idP,MIBCH,CCCH);
if( (UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size > 0) ) {
if( Srb_idP == CCCH && UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.payload_size > 0 ) {
// Note the bottom code is not used
#if defined(ENABLE_ITTI)
{
MessageDef *message_p;
int ccch_size = UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size;
int ccch_size = UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.payload_size;
int sdu_size = sizeof(RRC_MAC_CCCH_DATA_REQ (message_p).sdu);
if (ccch_size > sdu_size) {
......@@ -91,24 +99,29 @@ mac_rrc_data_req_ue(
RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP;
RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size;
memset (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, 0, CCCH_SDU_SIZE);
memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload, ccch_size);
RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index;
memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.Payload, ccch_size);
RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_indexP;
itti_send_msg_to_task (TASK_MAC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p);
}
#endif
memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size);
uint8_t Ret_size=UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size;
memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.payload_size);
uint8_t Ret_size=UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.payload_size;
// UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size=0;
UE_rrc_inst[Mod_idP].Info[eNB_index].T300_active = 1;
UE_rrc_inst[Mod_idP].Info[eNB_index].T300_cnt = 0;
UE_rrc_inst[Mod_idP].Info[eNB_indexP].T300_active = 1;
UE_rrc_inst[Mod_idP].Info[eNB_indexP].T300_cnt = 0;
// msg("[RRC][UE %d] Sending rach\n",Mod_id);
return(Ret_size);
} else {
return 0;
}
}
else if (Srb_idP == MIBCH) {
int Ret_size = do_MIB_SL(&ctxt,eNB_indexP,frameP,0);
memcpy((void*)buffer_pP,(void*)UE_rrc_inst[Mod_idP].SL_MIB,Ret_size);
return(Ret_size);
}
AssertFatal(1==0,"Should never be here!\n");
return(0);
}
......
......@@ -276,61 +276,70 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich
//TTN for D2D
// 3GPP 36.331 (Section 5.10.7.4)
uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, uint32_t frame, uint8_t subframe, uint8_t in_coverage, uint8_t mode)
uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, int absSF, uint8_t in_coverage)
{
asn_enc_rval_t enc_rval;
SBCCH_SL_BCH_MessageType_t *mib_sl = &UE_rrc_inst[ctxt_pP->module_id].mib_sl[eNB_index];
uint8_t sfn = (uint8_t)((frame>>2)&0xff);
UE_rrc_inst[ctxt_pP->module_id].MIB = (uint8_t*) malloc16(4);
uint16_t frame = absSF/10;
uint8_t subframe = absSF%10;
uint32_t reserved = 0;
UE_RRC_INST *UE = &UE_rrc_inst[ctxt_pP->module_id];
SBCCH_SL_BCH_Message_t *sl_mib = &UE->SL_mib[eNB_index];
AssertFatal(eNB_index==0,"eNB_index needs to be 0\n");
if (UE->SL_MIB == NULL) UE->SL_MIB = (uint8_t*) CALLOC(1,5);
if (in_coverage > 0 ){
//in coverage
mib_sl->inCoverage_r12 = TRUE;
mib_sl->sl_Bandwidth_r12 = UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth;
if (UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config) {
mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config->subframeAssignment;
sl_mib->message.inCoverage_r12 = TRUE;
sl_mib->message.sl_Bandwidth_r12 = UE->sib2[eNB_index]->freqInfo.ul_Bandwidth;
if (UE->sib1[eNB_index]->tdd_Config) {
sl_mib->message.tdd_ConfigSL_r12.subframeAssignmentSL_r12 = UE->sib1[eNB_index]->tdd_Config->subframeAssignment;
} else {
mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = TDD_ConfigSL_r12__subframeAssignmentSL_r12_none;
sl_mib->message.tdd_ConfigSL_r12.subframeAssignmentSL_r12 = TDD_ConfigSL_r12__subframeAssignmentSL_r12_none;
}
//if triggered by sl communication
if (UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){
mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12;
if (UE->sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){
sl_mib->message.reserved_r12 = *UE->sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12;
}
//if triggered by sl discovery
if (UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){
mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12;
if (UE->sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){
sl_mib->message.reserved_r12 = *UE->sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12;
}
//Todo - if triggered by v2x
} else {
//Todo - out of coverage for V2X
// Todo - UE has a selected SyncRef UE
mib_sl->inCoverage_r12 = FALSE;
//set sl-Bandwidth, subframeAssignmentSL and reserved from the pre-configured parameters
//Todo - out of coverage for V2X
// Todo - UE has a selected SyncRef UE
sl_mib->message.inCoverage_r12 = FALSE;
sl_mib->message.sl_Bandwidth_r12 = UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.sl_bandwidth_r12;
sl_mib->message.tdd_ConfigSL_r12.subframeAssignmentSL_r12 = UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.tdd_ConfigSL_r12.subframeAssignmentSL_r12;
//set sl-Bandwidth, subframeAssignmentSL and reserved from the pre-configured parameters
sl_mib->message.reserved_r12.buf = &reserved;
sl_mib->message.reserved_r12.size = 3;
sl_mib->message.reserved_r12.bits_unused = 5;
}
//set FrameNumber, subFrameNumber
mib_sl->directFrameNumber_r12.buf = &sfn;
mib_sl->directFrameNumber_r12.size = 1;
mib_sl->directFrameNumber_r12.bits_unused=0;
mib_sl->directSubframeNumber_r12 = subframe;
sl_mib->message.directFrameNumber_r12.buf = &frame;
sl_mib->message.directFrameNumber_r12.size = 1;
sl_mib->message.directFrameNumber_r12.bits_unused=0;
sl_mib->message.directSubframeNumber_r12 = subframe;
LOG_I(RRC,"[MIB-SL] sfn %x, subframe %x\n", (uint32_t)sfn, (uint8_t)subframe);
LOG_I(RRC,"[MIB-SL] sfn %x, subframe %x\n", (uint32_t)frame, (uint8_t)subframe);
enc_rval = uper_encode_to_buffer(&asn_DEF_SBCCH_SL_BCH_Message,
(void*)mib_sl,
UE_rrc_inst[ctxt_pP->module_id].MIB,
(void*)sl_mib,
UE->SL_MIB,
24);
AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
if (enc_rval.encoded==-1) {
return(-1);
}
return((enc_rval.encoded+7)/8);
}
......
......@@ -297,3 +297,6 @@ uint8_t do_SecurityModeCommand(
const uint8_t Transaction_id,
const uint8_t cipheringAlgorithm,
const uint8_t integrityProtAlgorithm);
uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, int absSF, uint8_t in_coverage);
......@@ -174,7 +174,7 @@ void *send_UE_status_notification(void *);
#include "RRCConnectionRequest.h"
#include "RRCConnectionReestablishmentRequest.h"
#include "BCCH-DL-SCH-Message.h"
#include "SBCCH-SL-BCH-MessageType.h"
#include "SBCCH-SL-BCH-Message.h"
#include "BCCH-BCH-Message.h"
#if defined(Rel10) || defined(Rel14)
#include "MCCH-Message.h"
......@@ -758,7 +758,8 @@ typedef struct UE_RRC_INST_s {
SystemInformationBlockType18_r12_t *sib18[NB_CNX_UE];
SystemInformationBlockType19_r12_t *sib19[NB_CNX_UE];
SBCCH_SL_BCH_MessageType_t mib_sl[NB_CNX_UE];
SBCCH_SL_BCH_Message_t SL_mib[NB_CNX_UE];
uint8_t *SL_MIB;
/// Preconfiguration for Sidelink
struct SL_Preconfiguration_r12 *SL_Preconfiguration[NB_CNX_UE];
//source L2 Id
......
......@@ -76,6 +76,9 @@
#define CONFIG_HLP_PRB "Set the PRB, valid values: 6, 25, 50, 100 \n"
#define CONFIG_HLP_EMULIFACE "Set the interface name for the multicast transport for emulation mode (e.g. eth0, lo, etc.) \n"
#define CONFIG_HLP_SIML1 "Turn on simulation interface for L1"
#define CONFIG_HLP_ENABLESL "Enable SL functionality"
#define CONFIG_HLP_SLONLY "Use SL only (i.e. wire UE to off-network state)"
#define CONFIG_HLP_SYNCHREF "Hard-wire UE as SynchRef UE for SL"
#define CONFIG_HLP_MSLOTS "Skip the missed slots/subframes \n"
#define CONFIG_HLP_ULMCS "Set the maximum uplink MCS\n"
#define CONFIG_HLP_TDD "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n"
......@@ -133,6 +136,9 @@
{"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:90, TYPE_INT, 0}, \
{"emul-iface", CONFIG_HLP_EMULIFACE, 0, strptr:&emul_iface, defstrval:"lo", TYPE_STRING, 100},\
{"sim-L1", CONFIG_HLP_SIML1, 0, iptr:&simL1, defintval:0, TYPE_INT, 0}, \
{"ue-enable-sl", CONFIG_HLP_ENABLESL, PARAMFLAG_BOOL, iptr:&sidelink_active, defintval:0, TYPE_INT, 0}, \
{"ue-sl-only", CONFIG_HLP_SLONLY, PARAMFLAG_BOOL, iptr:&SLonly, defintval:0, TYPE_INT, 0}, \
{"ue-synchref", CONFIG_HLP_SYNCHREF, PARAMFLAG_BOOL, iptr:&synchRef, defintval:0, TYPE_INT, 0}, \
{"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \
}
......@@ -259,7 +265,7 @@ extern void set_function_spec_param(RU_t *ru);
extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
extern void fill_ue_band_info(void);
extern void init_UE(int,int,int,int);
extern void init_UE(int,int,int,int,int,int);
extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name);
extern void reset_opp_meas(void);
......
This diff is collapsed.
......@@ -157,6 +157,9 @@ FILE *input_fd=NULL;
int simL1=0;
char emul_iface[100];
int sidelink_active=0;
int SLonly=0;
int synchRef=0;
#if MAX_NUM_CCs == 1
rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}};
......@@ -1035,7 +1038,7 @@ int main( int argc, char **argv )
// start the main threads
int eMBMS_active = 0;
init_UE(1,eMBMS_active,uecap_xer_in,0);
init_UE(1,eMBMS_active,uecap_xer_in,0,sidelink_active,SLonly);
if (phy_test==0) {
printf("Filling UE band info\n");
......
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