Commit 7781cd58 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Configure MAC with Source/groupL2Id, add possiblility to filter at MAC layer

parent 2e5af5a9
......@@ -10,8 +10,6 @@ auto eth0
netmask 255.255.255.0
gateway 10.10.10.1
Prepare the environment:
- git clone https://gitlab.eurecom.fr/matzakos/LTE-D2D.git
This branch contains all the current development for DDPS
......
......@@ -65,6 +65,7 @@ extern void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
extern uint8_t nfapi_mode;
/* sec 5.9, 36.321: MAC Reset Procedure */
void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index)
{
......@@ -1046,6 +1047,11 @@ rrc_mac_config_req_ue(
,uint8_t num_active_cba_groups,
uint16_t cba_rnti
#endif
#if defined(Rel14)
,uint32_t *sourceL2Id,
uint32_t *groupL2Id
#endif
)
{
......@@ -1363,6 +1369,13 @@ rrc_mac_config_req_ue(
// Panos: Call to the phy_config_request_ue() function of the interface to copy the UE_PHY_Config_t interface
// configuration to the PHY common and dedicated configuration originating from RRC.
//for D2D
#if defined(Rel10) || defined(Rel14)
if ( sourceL2Id && groupL2Id) {
UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id;
UE_mac_inst[Mod_idP].groupL2Id = *groupL2Id;
}
#endif
return(0);
}
......
......@@ -1325,6 +1325,13 @@ typedef struct {
struct SL_DiscConfig_r12 *sl_DiscConfig_r12;
/// Dedicated TX config for Sidelink
struct SL_CommConfig_r12 *sl_CommConfig_r12;
//SL sourceL2ID
uint32_t sourceL2Id;
//SL groupL2Id
uint32_t groupL2Id;
//SL destinationL2Id
uint32_t destinationL2Id;
#endif
/// pointer to TDD Configuration (NULL for FDD)
TDD_Config_t *tdd_Config;
......
......@@ -928,6 +928,11 @@ int rrc_mac_config_req_ue(module_id_t module_idP,
,
uint8_t num_active_cba_groups,
uint16_t cba_rnti
#endif
#if defined(Rel14)
,
uint32_t *sourceL2Id,
uint32_t *groupL2Id
#endif
);
......
......@@ -753,6 +753,8 @@ void ue_send_sl_sdu(module_id_t module_idP,
int rlc_sdu_len;
char *rlc_sdu;
uint32_t sourceL2Id;
uint32_t destinationL2Id =0x00000000;
// Notes: 1. no control elements are supported yet
// 2. we exit with error if LCID != 3
......@@ -761,6 +763,16 @@ void ue_send_sl_sdu(module_id_t module_idP,
SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu;
AssertFatal(longh->E==0,"E is non-zero\n");
AssertFatal(longh->LCID==3,"LCID is %d (not 3)\n",longh->LCID);
//filter incoming packet based on destination address
destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623);
LOG_I( MAC, "[DestinationL2Id: %"PRIu32"] \n", destinationL2Id );
//match the destinationL2Id with UE L2Id or groupL2ID
if (!((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (destinationL2Id == UE_mac_inst[module_idP].groupL2Id))){
LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
return;
}
//AssertFatal(((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (destinationL2Id == UE_mac_inst[module_idP].groupL2Id)), "Destination Id is neither matched with Source Id nor with Group Id \n")
if (longh->F==1) {
rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF);
rlc_sdu = sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG);
......@@ -2773,7 +2785,11 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
// 2. LCID hard-coded to 3
// 3. SRC/DST IDs with debug values
if (sdu_length > 0) {
LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req);
LOG_I(MAC,"sourceL2Id %d: \n",ue->sourceL2Id);
LOG_I(MAC,"groupL2Id %d: \n",ue->groupL2Id);
slsch->payload = (unsigned char*)ue->slsch_pdu.payload;
if (sdu_length < 128) {
slsch->payload++;
......@@ -2782,12 +2798,20 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
shorth->L=sdu_length;
shorth->E=0;
shorth->LCID=3;
shorth->SRC07=0x12;
shorth->SRC815=0x34;
/* shorth->SRC07=0x12;
shorth->SRC1623=0x56;
shorth->SRC815=0x34;
shorth->DST07=0x78;
shorth->DST815=0x9A;
shorth->DST1623=0xBC;
shorth->DST1623=0xBC;*/
shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff;
shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
shorth->SRC1623 = ue->sourceL2Id & 0x000000ff;
shorth->DST07 = (ue->groupL2Id >>16) & 0x000000ff;
shorth->DST815 = (ue->groupL2Id>>8) & 0x000000ff;
shorth->DST1623 = ue->groupL2Id & 0x000000ff;
shorth->V=0x1;
}
else {
......@@ -2797,12 +2821,21 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
longh->L_MSB=(sdu_length>>8)&0x7f;
longh->E=0;
longh->LCID=3;
/*
longh->SRC07=0x12;
longh->SRC815=0x34;
longh->SRC1623=0x56;
longh->DST07=0x78;
longh->DST815=0x9A;
longh->DST1623=0xBC;
*/
longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff;
longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
longh->SRC1623 = ue->sourceL2Id & 0x000000ff;
longh->DST07 = (ue->groupL2Id >>16) & 0x000000ff;
longh->DST815 = (ue->groupL2Id>>8) & 0x000000ff;
longh->DST1623 = ue->groupL2Id & 0x000000ff;
longh->V=0x1;
}
slsch->rvidx = 0;
......
......@@ -1031,6 +1031,11 @@ rrc_ue_process_measConfig(
,
0,
0
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
}
......@@ -1543,6 +1548,11 @@ rrc_ue_process_radioResourceConfigDedicated(
,
0,
0
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
}
......@@ -1602,6 +1612,11 @@ rrc_ue_process_radioResourceConfigDedicated(
,
0,
0
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
}
......@@ -1709,6 +1724,11 @@ rrc_ue_process_radioResourceConfigDedicated(
,
UE_rrc_inst[ue_mod_idP].num_active_cba_groups, //
UE_rrc_inst[ue_mod_idP].cba_rnti[0]
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
......@@ -2292,6 +2312,11 @@ rrc_ue_process_mobilityControlInfo(
#ifdef CBA
,0,
0
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
......@@ -3154,6 +3179,11 @@ int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index,
,
0,
0
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
......@@ -3833,6 +3863,11 @@ uint64_t arfcn_to_freq(long arfcn) {
#ifdef CBA
,0,
0
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
// After SI is received, prepare RRCConnectionRequest
......@@ -4013,6 +4048,11 @@ uint64_t arfcn_to_freq(long arfcn) {
#ifdef CBA
,0,
0
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
break;
......@@ -4509,6 +4549,11 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB
,
0,
0
#endif
#if defined(Rel14)
,
NULL,
NULL
#endif
);
......@@ -5373,6 +5418,9 @@ void *rrc_control_socket_thread_fct(void *arg)
int n; // message byte size
struct sidelink_ctrl_element *sl_ctrl_msg_recv = NULL;
struct sidelink_ctrl_element *sl_ctrl_msg_send = NULL;
uint32_t sourceL2Id;
uint32_t groupL2Id;
module_id_t module_id;
//from the main program, listen for the incoming messages from control socket (ProSe App)
......@@ -5438,6 +5486,10 @@ void *rrc_control_socket_thread_fct(void *arg)
break;
case GROUP_COMMUNICATION_ESTABLISH_REQ:
sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.sourceL2Id;
groupL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id;
//sourceL2Id = 0x123456;
//groupL2Id = 0x789ABC;
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.type);
......@@ -5447,6 +5499,45 @@ void *rrc_control_socket_thread_fct(void *arg)
#endif
// configure lower layers PDCP/MAC/PHY for this communication
//init_SL_preconfig()
//configure MAC with sourceL2Id/groupL2ID (to be used in MAC/ue_procedures.c)
module_id = 0 ; //hardcoded for testing only
rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0
(RadioResourceConfigCommonSIB_t *)NULL,
(struct PhysicalConfigDedicated *)NULL,
#if defined(Rel10) || defined(Rel14)
(SCellToAddMod_r10_t *)NULL,
//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
#endif
(MeasObjectToAddMod_t **)NULL,
(MAC_MainConfig_t *)NULL,
0,
(struct LogicalChannelConfig *)NULL,
(MeasGapConfig_t *)NULL,
(TDD_Config_t *)NULL,
(MobilityControlInfo_t *)NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
#if defined(Rel10) || defined(Rel14)
,0,
(MBSFN_AreaInfoList_r9_t *)NULL,
(PMCH_InfoList_r9_t *)NULL
#endif
#ifdef CBA
,
0,
0
#endif
#if defined(Rel10) || defined(Rel14)
,
&sourceL2Id,
&groupL2Id
#endif
);
LOG_I(RRC,"[rrc_control_socket_thread_fct]Send GroupCommunicationEstablishResp to ProSe App\n");
memset(send_buf, 0, BUFSIZE);
......
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