Commit ff8d9a81 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

separation of SLRB establishment PC5-U/PC5-S

parent 97c2aff9
......@@ -1391,6 +1391,16 @@ rrc_mac_config_req_ue(
if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[Mod_idP].destinationList[j-1] = *destinationL2Id;
UE_mac_inst[Mod_idP].numCommFlows++;
}
//store list of LCIDs for SL
if (logicalChannelIdentity >0 ){
int j = 0;
int i = 0;
for (i=0; i< MAX_NUM_LCID; i++) {
if ((UE_mac_inst[Mod_idP].SL_LCID[i] == 0) && (j == 0)) j = i+1;
if (UE_mac_inst[Mod_idP].SL_LCID[i] == logicalChannelIdentity) break; //LCID already exists!
}
if ((i == MAX_NUM_LCID) && (j > 0)) UE_mac_inst[Mod_idP].SL_LCID[j-1] = logicalChannelIdentity;
}
break;
case CONFIG_ACTION_REMOVE:
//TODO
......
......@@ -1345,6 +1345,7 @@ typedef struct {
//List of destinations
uint32_t destinationList[MAX_NUM_DEST];
uint8_t numCommFlows;
uint32_t SL_LCID[MAX_NUM_LCID];
#endif
/// pointer to TDD Configuration (NULL for FDD)
......
......@@ -770,10 +770,21 @@ void ue_send_sl_sdu(module_id_t module_idP,
destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623);
LOG_I( MAC, "[DestinationL2Id: 0x%08x] \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))){
/* 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;
}
*/
//in case of 1-n communication, verify that UE belongs to that group
int i=0;
for (i=0; i< MAX_NUM_DEST; i++)
if (UE_mac_inst[module_idP].destinationList[i] == destinationL2Id) break;
//match the destinationL2Id with UE L2Id or groupL2ID
if (!((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (i < MAX_NUM_DEST))){
LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
return;
}
if (longh->F==1) {
rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF);
......@@ -2787,7 +2798,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
UE_MAC_INST *ue = &UE_mac_inst[module_idP];
int rvtab[4] = {0,2,3,1};
int sdu_length;
uint8_t sl_lcids[2] = {3, 10}; //list of lcids for SL - hardcoded
//uint8_t sl_lcids[2] = {3, 10}; //list of lcids for SL - hardcoded
int i = 0;
// Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH)
......@@ -2797,19 +2808,21 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period
ue->sltx_active = 0;
for (i = 0; i < 2; i++){
for (int j = 0; j < ue->numCommFlows; j++){
if ((ue->sourceL2Id > 0) && (ue->destinationList[j] >0) ){
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
sl_lcids[i], 0xFFFF, ue->sourceL2Id, ue->destinationList[j]);
if (rlc_status.bytes_in_buffer > 2){
LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer);
// Fill in group id for off-network communications
ue->sltx_active = 1;
//store LCID, destinationL2Id
ue->slsch_lcid = sl_lcids[i];
ue->destinationL2Id = ue->destinationList[j];
break;
for (i = 0; i < MAX_NUM_LCID; i++){
if (ue->SL_LCID[i] > 0) {
for (int j = 0; j < ue->numCommFlows; j++){
if ((ue->sourceL2Id > 0) && (ue->destinationList[j] >0) ){
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
ue->SL_LCID[i], 0xFFFF, ue->sourceL2Id, ue->destinationList[j]);
if (rlc_status.bytes_in_buffer > 2){
LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer);
// Fill in group id for off-network communications
ue->sltx_active = 1;
//store LCID, destinationL2Id
ue->slsch_lcid = ue->SL_LCID[i];
ue->destinationL2Id = ue->destinationList[j];
break;
}
}
}
}
......
......@@ -5459,6 +5459,15 @@ void *rrc_control_socket_thread_fct(void *arg)
uint32_t sourceL2Id, groupL2Id, destinationL2Id;
module_id_t module_id = 0; //hardcoded for testing only
uint8_t type;
UE_RRC_INST *UE = NULL;
protocol_ctxt_t ctxt;
struct RLC_Config *DRB_rlc_config = NULL;
struct PDCP_Config *DRB_pdcp_config = NULL;
struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL;
struct LogicalChannelConfig *DRB_lchan_config = NULL;
struct LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters = NULL;
long *logicalchannelgroup_drb = NULL;
//from the main program, listen for the incoming messages from control socket (ProSe App)
prose_addr_len = sizeof(prose_app_addr);
......@@ -5546,9 +5555,8 @@ void *rrc_control_socket_thread_fct(void *arg)
// configure lower layers PDCP/MAC/PHY for this communication
//Establish a new RBID/LCID for this communication
UE_RRC_INST *UE = &UE_rrc_inst[module_id];
// Establish a SLRB (using DRB 3 for now)
protocol_ctxt_t ctxt;
UE = &UE_rrc_inst[module_id];
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,0);
UE->DRB_config[0][0] = CALLOC(1,sizeof(struct DRB_ToAddMod));
......@@ -5559,17 +5567,7 @@ void *rrc_control_socket_thread_fct(void *arg)
*(UE->DRB_config[0][0]->eps_BearerIdentity) = 3;
UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long));
*(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2
// TTN - Establish a new SLRB for PC5-S (using DRB 10 for now)
UE->DRB_config[0][1] = CALLOC(1,sizeof(struct DRB_ToAddMod));
UE->DRB_config[0][1]->eps_BearerIdentity = CALLOC(1, sizeof(long));
UE->DRB_config[0][1]->drb_Identity = 10;
UE->DRB_config[0][1]->eps_BearerIdentity = CALLOC(1, sizeof(long));
// allowed value 5..15, value : x+4
*(UE->DRB_config[0][1]->eps_BearerIdentity) = 10;
UE->DRB_config[0][1]->logicalChannelIdentity = CALLOC(1, sizeof(long));
*(UE->DRB_config[0][1]->logicalChannelIdentity) = UE->DRB_config[0][1]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2
/*
struct RLC_Config *DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config));
struct PDCP_Config *DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config));
struct PDCP_Config__rlc_UM *PDCP_rlc_UM = CALLOC(1,sizeof(struct PDCP_Config__rlc_UM));
......@@ -5577,17 +5575,22 @@ void *rrc_control_socket_thread_fct(void *arg)
struct LogicalChannelConfig__ul_SpecificParameters
*DRB_ul_SpecificParameters = CALLOC(1, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
long *logicalchannelgroup_drb = CALLOC(1, sizeof(long));
*/
DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config));
DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config));
PDCP_rlc_UM = CALLOC(1,sizeof(struct PDCP_Config__rlc_UM));
DRB_lchan_config = CALLOC(1,sizeof(struct LogicalChannelConfig));
DRB_ul_SpecificParameters = CALLOC(1, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
logicalchannelgroup_drb = CALLOC(1, sizeof(long));
DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional;
DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
UE->DRB_config[0][0]->rlc_Config = DRB_rlc_config;
UE->DRB_config[0][1]->rlc_Config = DRB_rlc_config;
DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config));
UE->DRB_config[0][0]->pdcp_Config = DRB_pdcp_config;
UE->DRB_config[0][1]->pdcp_Config = DRB_pdcp_config;
DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long));
*DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity;
DRB_pdcp_config->rlc_AM = NULL;
......@@ -5601,7 +5604,6 @@ void *rrc_control_socket_thread_fct(void *arg)
DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed;
UE->DRB_config[0][0]->logicalChannelConfig = DRB_lchan_config;
UE->DRB_config[0][1]->logicalChannelConfig = DRB_lchan_config;
DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters));
DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters;
......@@ -5618,7 +5620,6 @@ void *rrc_control_socket_thread_fct(void *arg)
UE->DRB_configList = CALLOC(1,sizeof(DRB_ToAddModList_t));
ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][0]);
ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][1]);
rrc_pdcp_config_asn1_req(&ctxt,
(SRB_ToAddModList_t *) NULL,
......@@ -5662,7 +5663,7 @@ void *rrc_control_socket_thread_fct(void *arg)
#endif
(MeasObjectToAddMod_t **)NULL,
(MAC_MainConfig_t *)NULL,
0,
3, //LCID
(struct LogicalChannelConfig *)NULL,
(MeasGapConfig_t *)NULL,
(TDD_Config_t *)NULL,
......@@ -5802,10 +5803,10 @@ void *rrc_control_socket_thread_fct(void *arg)
case PC5S_ESTABLISH_REQ:
type = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.type;
sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.sourceL2Id;
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[PC5EstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[PC5EstablishReq] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.type); //RX/TX
LOG_I(RRC,"[PC5EstablishReq] source Id: 0x%08x \n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.sourceL2Id);
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[PC5EstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[PC5EstablishReq] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.type); //RX/TX
LOG_I(RRC,"[PC5EstablishReq] source Id: 0x%08x \n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.sourceL2Id);
#endif
if (type > 0) {
destinationL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.destinationL2Id;
......@@ -5814,6 +5815,205 @@ void *rrc_control_socket_thread_fct(void *arg)
#endif
}
//store sourceL2Id/destinationL2Id
if (type > 0) { //TX
UE_rrc_inst[module_id].sourceL2Id = sourceL2Id;
int j = 0;
int i = 0;
for (i=0; i< MAX_NUM_DEST; i++) {
if ((UE_rrc_inst[module_id].destinationList[i] == 0) && (j == 0)) j = i+1;
if (UE_rrc_inst[module_id].destinationList[i] == destinationL2Id) break; //group already exists!
}
if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[module_id].destinationList[j-1] = destinationL2Id;
} else {//RX
UE_rrc_inst[module_id].sourceL2Id = sourceL2Id;
}
// configure lower layers PDCP/MAC/PHY for this communication
//Establish a new RBID/LCID for this communication
// Establish a SLRB (using DRB 10 for now)
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,0);
UE->DRB_config[0][0] = CALLOC(1,sizeof(struct DRB_ToAddMod));
UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long));
UE->DRB_config[0][0]->drb_Identity = 10;
UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long));
// allowed value 5..15, value : x+4
*(UE->DRB_config[0][0]->eps_BearerIdentity) = 10;
UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long));
*(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2
DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config));
DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config));
PDCP_rlc_UM = CALLOC(1,sizeof(struct PDCP_Config__rlc_UM));
DRB_lchan_config = CALLOC(1,sizeof(struct LogicalChannelConfig));
DRB_ul_SpecificParameters = CALLOC(1, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
logicalchannelgroup_drb = CALLOC(1, sizeof(long));
DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional;
DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
UE->DRB_config[0][0]->rlc_Config = DRB_rlc_config;
DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config));
UE->DRB_config[0][0]->pdcp_Config = DRB_pdcp_config;
DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long));
*DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity;
DRB_pdcp_config->rlc_AM = NULL;
DRB_pdcp_config->rlc_UM = NULL;
/* avoid gcc warnings */
(void)PDCP_rlc_UM;
DRB_pdcp_config->rlc_UM = PDCP_rlc_UM;
PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits;
DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed;
UE->DRB_config[0][0]->logicalChannelConfig = DRB_lchan_config;
DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters));
DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters;
DRB_ul_SpecificParameters->priority = 12; // lower priority than srb1, srb2 and other dedicated bearer
DRB_ul_SpecificParameters->prioritisedBitRate =LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ;
//LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
DRB_ul_SpecificParameters->bucketSizeDuration =
LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
// LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM)
*logicalchannelgroup_drb = 1;
DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb;
UE->DRB_configList = CALLOC(1,sizeof(DRB_ToAddModList_t));
ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][0]);
rrc_pdcp_config_asn1_req(&ctxt,
(SRB_ToAddModList_t *) NULL,
UE->DRB_configList,
(DRB_ToReleaseList_t*) NULL,
0xff, NULL, NULL, NULL
#if defined(Rel10) || defined(Rel14)
, (PMCH_InfoList_r9_t *) NULL
#endif
,NULL);
rrc_rlc_config_asn1_req(&ctxt,
(SRB_ToAddModList_t*)NULL,
UE->DRB_configList,
(DRB_ToReleaseList_t*)NULL
#if defined(Rel10) || defined(Rel14)
,(PMCH_InfoList_r9_t *)NULL
, 0, 0
#endif
);
//TX
if (type > 0) {
rrc_rlc_config_asn1_req(&ctxt,
(SRB_ToAddModList_t*)NULL,
UE->DRB_configList,
(DRB_ToReleaseList_t*)NULL
#ifdef Rel14
,(PMCH_InfoList_r9_t *)NULL
, sourceL2Id, groupL2Id
#endif
);
//configure MAC with sourceL2Id/groupL2ID
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,
10, //LCID
(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)
,CONFIG_ACTION_ADD,
&sourceL2Id,
&groupL2Id
#endif
);
} else {//RX
rrc_rlc_config_asn1_req(&ctxt,
(SRB_ToAddModList_t*)NULL,
UE->DRB_configList,
(DRB_ToReleaseList_t*)NULL
#ifdef Rel14
,(PMCH_InfoList_r9_t *)NULL
, sourceL2Id, 0
#endif
);
//configure MAC with sourceL2Id/groupL2ID
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)
,CONFIG_ACTION_ADD,
&sourceL2Id,
NULL
#endif
);
}
/*
//store sourceL2Id, destinationL2Id
if (type > 0) { //TX
UE_rrc_inst[module_id].sourceL2Id = sourceL2Id;
......@@ -5899,7 +6099,7 @@ void *rrc_control_socket_thread_fct(void *arg)
#endif
);
}
*/
LOG_I(RRC,"Send PC5EstablishRsp 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