Commit b60f1122 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

update code to support multiple flows

parent dad40182
......@@ -1384,58 +1384,92 @@ rrc_mac_config_req_ue(
UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id;
LOG_I(MAC,"[UE %d] Configure source L2Id 0x%08x \n", Mod_idP, *sourceL2Id );
}
if (destinationL2Id) {
//store list of (S,D,G,LCID) for SL
if ((logicalChannelIdentity > 0) && (logicalChannelIdentity < MAX_NUM_LCID_DATA)) {
if (groupL2Id){
LOG_I(MAC,"[UE %d] Configure group L2Id 0x%08x\n", Mod_idP, *groupL2Id );
j = 0;
k = 0;
LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x\n", Mod_idP, *destinationL2Id );
for (k=0; k< MAX_NUM_DEST; k++) {
if ((UE_mac_inst[Mod_idP].destinationList[k] == 0) && (j == 0)) j = k+1;
if (UE_mac_inst[Mod_idP].destinationList[k] == *destinationL2Id) break; //destination already exists!
for (k=0; k< MAX_NUM_LCID_DATA; k++) {
if ((UE_mac_inst[Mod_idP].sl_info[k].LCID == 0) && (j == 0)) j = k+1;
if ((UE_mac_inst[Mod_idP].sl_info[k].LCID == logicalChannelIdentity) && (UE_mac_inst[Mod_idP].sl_info[k].groupL2Id == *groupL2Id)) break; //(LCID, G) already exists!
}
if ((k == MAX_NUM_DEST) && (j > 0)) {
UE_mac_inst[Mod_idP].destinationList[j-1] = *destinationL2Id;
// UE_mac_inst[Mod_idP].numCommFlows++;
if ((k == MAX_NUM_LCID_DATA) && (j > 0)) {
UE_mac_inst[Mod_idP].sl_info[j-1].LCID = logicalChannelIdentity;
UE_mac_inst[Mod_idP].sl_info[j-1].groupL2Id = *groupL2Id;
UE_mac_inst[Mod_idP].numCommFlows++;
}
for (k=0; k< MAX_NUM_DEST; k++) {
LOG_I(MAC,"[UE %d] destination %d L2Id 0x%08x\n", Mod_idP,k,UE_mac_inst[Mod_idP].destinationList[k] );
for (k=0; k< MAX_NUM_LCID_DATA; k++) {
LOG_I(MAC,"[UE %d] logical channel %d channel id %d, groupL2Id %d\n", Mod_idP,k,UE_mac_inst[Mod_idP].sl_info[k].LCID, UE_mac_inst[Mod_idP].sl_info[k].groupL2Id );
}
}
if (groupL2Id) {
if (destinationL2Id){
LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x\n", Mod_idP, *destinationL2Id );
j = 0;
k = 0;
LOG_I(MAC,"[UE %d] Configure group L2Id 0x%08x\n", Mod_idP, *groupL2Id );
for (k=0; k< MAX_NUM_DEST; k++) {
if ((UE_mac_inst[Mod_idP].groupList[k] == 0) && (j == 0)) j = k+1;
if (UE_mac_inst[Mod_idP].groupList[k] == *groupL2Id) break; //group already exists!
for (k=0; k< MAX_NUM_LCID_DATA; k++) {
if ((UE_mac_inst[Mod_idP].sl_info[k].LCID == 0) && (j == 0)) j = k+1;
if ((UE_mac_inst[Mod_idP].sl_info[k].LCID == logicalChannelIdentity) && (UE_mac_inst[Mod_idP].sl_info[k].destinationL2Id == *destinationL2Id)) break; //(LCID, D) already exists!
}
if ((k == MAX_NUM_DEST) && (j > 0)) {
UE_mac_inst[Mod_idP].groupList[j-1] = *groupL2Id;
// UE_mac_inst[Mod_idP].numCommFlows++;
if ((k == MAX_NUM_LCID_DATA) && (j > 0)) {
UE_mac_inst[Mod_idP].sl_info[j-1].LCID = logicalChannelIdentity;
UE_mac_inst[Mod_idP].sl_info[j-1].destinationL2Id = *destinationL2Id;
UE_mac_inst[Mod_idP].numCommFlows++;
}
for (k=0; k< MAX_NUM_DEST; k++) {
LOG_I(MAC,"[UE %d] group %d L2Id 0x%08x\n", Mod_idP,k,UE_mac_inst[Mod_idP].groupList[k] );
for (k=0; k< MAX_NUM_LCID_DATA; k++) {
LOG_I(MAC,"[UE %d] logical channel %d channel id %d, destinationL2Id %d\n", Mod_idP,k,UE_mac_inst[Mod_idP].sl_info[k].LCID, UE_mac_inst[Mod_idP].sl_info[k].destinationL2Id);
}
}
//store list of LCIDs for SL
if (logicalChannelIdentity >0 ){
} else if ((logicalChannelIdentity >= MAX_NUM_LCID_DATA) && (logicalChannelIdentity < MAX_NUM_LCID)) {
if (destinationL2Id){
LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x for PC5S\n", Mod_idP, *destinationL2Id );
j = 0;
k = 0;
for (k=0; k< MAX_NUM_LCID; k++) {
if ((UE_mac_inst[Mod_idP].SL_LCID[k] == 0) && (j == 0)) j = k+1;
if (UE_mac_inst[Mod_idP].SL_LCID[k] == logicalChannelIdentity) break; //LCID already exists!
for (k=MAX_NUM_LCID_DATA; k< MAX_NUM_LCID; k++) {
if ((UE_mac_inst[Mod_idP].sl_info[k].LCID == 0) && (j == 0)) j = k+1;
if ((UE_mac_inst[Mod_idP].sl_info[k].LCID == logicalChannelIdentity) && (UE_mac_inst[Mod_idP].sl_info[k].destinationL2Id == *destinationL2Id)) break; //(LCID, D) already exists!
}
if ((k == MAX_NUM_LCID) && (j > 0)) {
UE_mac_inst[Mod_idP].SL_LCID[j-1] = logicalChannelIdentity;
UE_mac_inst[Mod_idP].sl_info[j-1].LCID = logicalChannelIdentity;
UE_mac_inst[Mod_idP].sl_info[j-1].destinationL2Id = *destinationL2Id;
UE_mac_inst[Mod_idP].numCommFlows++;
}
for (k=MAX_NUM_LCID_DATA; k< MAX_NUM_LCID; k++) {
LOG_I(MAC,"[UE %d] logical channel %d channel id %d, destinationL2Id %d\n", Mod_idP,k,UE_mac_inst[Mod_idP].sl_info[k].LCID, UE_mac_inst[Mod_idP].sl_info[k].destinationL2Id);
}
for (k=0; k< MAX_NUM_LCID; k++) {
LOG_I(MAC,"[UE %d] logical channel %d channel id %d\n", Mod_idP,k,UE_mac_inst[Mod_idP].SL_LCID[k] );
}
}
break;
case CONFIG_ACTION_REMOVE:
//TODO
// OK for the moment since LCID is unique per flow
if ((logicalChannelIdentity > 0) && (logicalChannelIdentity < MAX_NUM_LCID_DATA)) {
LOG_I(MAC,"[UE %d] Remove (logicalChannelIdentity %d)\n", Mod_idP, logicalChannelIdentity );
k = 0;
for (k = 0; k < MAX_NUM_LCID_DATA; k++) {
if (UE_mac_inst[Mod_idP].sl_info[k].LCID == logicalChannelIdentity) {
UE_mac_inst[Mod_idP].sl_info[k].LCID = 0;
UE_mac_inst[Mod_idP].sl_info[k].destinationL2Id = 0;
UE_mac_inst[Mod_idP].sl_info[k].groupL2Id = 0;
UE_mac_inst[Mod_idP].numCommFlows--;
break;
}
}
for (k = 0; k < MAX_NUM_LCID_DATA; k++) {
LOG_I(MAC,"[UE %d] channel id %d, destinationL2Id %d, groupL2Id %d\n", Mod_idP, UE_mac_inst[Mod_idP].sl_info[k].LCID, UE_mac_inst[Mod_idP].sl_info[k].destinationL2Id, UE_mac_inst[Mod_idP].sl_info[k].groupL2Id);
}
} else if ((logicalChannelIdentity >= MAX_NUM_LCID_DATA) && (logicalChannelIdentity < MAX_NUM_LCID)) {
//Todo - remove RBID for PCS5
}
break;
default:
break;
}
......
......@@ -127,6 +127,7 @@
#define LCGID3 3
/*!\brief Maximum number of logical chanels */
#define MAX_NUM_LCID 11
#define MAX_NUM_LCID_DATA 8
/*!\brief Maximum number od control elemenets */
#define MAX_NUM_CE 5
/*!\brief Maximum number of random access process */
......@@ -1294,6 +1295,16 @@ typedef struct {
// Bucket size per lcid
int16_t bucket_size[MAX_NUM_LCID];
} UE_SCHEDULING_INFO;
typedef struct {
//SL groupL2Id
uint32_t groupL2Id;
//SL destinationL2Id
uint32_t destinationL2Id;
//LCID
uint32_t LCID;
} SL_INFO;
/*!\brief Top level UE MAC structure */
typedef struct {
uint16_t Node_id;
......@@ -1342,12 +1353,9 @@ typedef struct {
uint32_t groupL2Id;
//SL destinationL2Id
uint32_t destinationL2Id;
//List of destinations (unicast)
uint32_t destinationList[MAX_NUM_DEST];
//List of group (multicast)
uint32_t groupList[MAX_NUM_DEST];
uint8_t numCommFlows;
uint32_t SL_LCID[MAX_NUM_LCID];
//list of (SLID, G, D)s
SL_INFO sl_info[MAX_NUM_LCID];
#endif
/// pointer to TDD Configuration (NULL for FDD)
......
......@@ -773,14 +773,14 @@ void ue_send_sl_sdu(module_id_t module_idP,
LOG_D( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id );
//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].groupList[i] == destinationL2Id) break;
for (i=0; i< MAX_NUM_LCID; i++)
if (UE_mac_inst[module_idP].sl_info[i].groupL2Id == destinationL2Id) break;
int j = 0;
for (j=0; j< MAX_NUM_DEST; j++)
if (UE_mac_inst[module_idP].destinationList[j] == sourceL2Id) break;
for (j=0; j< MAX_NUM_LCID; j++)
if (UE_mac_inst[module_idP].sl_info[j].destinationL2Id == sourceL2Id) break;
//match the destinationL2Id with UE L2Id or groupL2ID
if (!(((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) && (j < MAX_NUM_DEST)) | ((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) && (longh->LCID == 10)) | (i < MAX_NUM_DEST))){
if (!(((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) && (j < MAX_NUM_LCID)) | ((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) && (longh->LCID >= MAX_NUM_LCID_DATA)) | (i < MAX_NUM_LCID))){
LOG_D( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
return;
}
......@@ -2807,7 +2807,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
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;
/*
for (i = 0; i < MAX_NUM_LCID; i++){
if (ue->SL_LCID[i] > 0) {
for (int j = 0; j < ue->numCommFlows; j++){
......@@ -2843,6 +2843,42 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
}
if ( ue->sltx_active == 1) break;
}
*/
for (i = 0; i < MAX_NUM_LCID; i++){
if (ue->sl_info[i].LCID > 0) {
for (int j = 0; j < ue->numCommFlows; j++){
if ((ue->sourceL2Id > 0) && (ue->sl_info[j].destinationL2Id >0) ){
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
ue->sl_info[i].LCID, 0xFFFF, ue->sourceL2Id, ue->sl_info[j].destinationL2Id );
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_info[i].LCID;
ue->destinationL2Id = ue->sl_info[j].destinationL2Id;
break;
}
}
if ((ue->sourceL2Id > 0) && (ue->sl_info[j].groupL2Id >0) ){
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
ue->sl_info[i].LCID, 0xFFFF, ue->sourceL2Id, ue->sl_info[j].groupL2Id);
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_info[i].LCID;
ue->destinationL2Id = ue->sl_info[j].groupL2Id;
break;
}
}
}
}
if ( ue->sltx_active == 1) break;
}
} // 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
......
......@@ -84,14 +84,14 @@
#define DIRECT_COMMUNICATION_ESTABLISH_RSP 6
#define GROUP_COMMUNICATION_RELEASE_REQ 7
#define GROUP_COMMUNICATION_RELEASE_RSP 8
#define PC5S_ESTABLISH_REQ 9
#define PC5S_ESTABLISH_RSP 10
#define PC5_DISCOVERY_MESSAGE 11
#define DIRECT_COMMUNICATION_RELEASE_REQ 9
#define DIRECT_COMMUNICATION_RELEASE_RSP 10
#define PC5S_ESTABLISH_REQ 11
#define PC5S_ESTABLISH_RSP 12
#define PC5_DISCOVERY_MESSAGE 13
#define PC5_DISCOVERY_PAYLOAD_SIZE 29
typedef enum {
UE_STATE_OFF_NETWORK,
UE_STATE_ON_NETWORK
......@@ -140,6 +140,10 @@ typedef struct {
uint32_t measuredPower;
} __attribute__((__packed__)) PC5DiscoveryMessage ;
typedef enum {
DIRECT_COMMUNICATION_RELEASE_OK = 0,
DIRECT_COMMUNICATION_RELEASE_FAILURE
} Direct_Communication_Status_t;
struct sidelink_ctrl_element {
unsigned short type;
......@@ -147,7 +151,7 @@ struct sidelink_ctrl_element {
struct GroupCommunicationEstablishReq group_comm_establish_req;
struct DirectCommunicationEstablishReq direct_comm_establish_req;
Group_Communication_Status_t group_comm_release_rsp;
//struct DirectCommunicationReleaseReq direct_comm_release_req;
Direct_Communication_Status_t direct_comm_release_rsp;
SL_UE_STATE_t ue_state;
int slrb_id;
struct PC5SEstablishReq pc5s_establish_req;
......@@ -741,10 +745,7 @@ typedef struct UE_RRC_INST_s {
uint32_t groupL2Id;
//current destination
uint32_t destinationL2Id;
//List of destinations (unicast)
uint32_t destinationList[MAX_NUM_DEST];
//List of groups (multicast)
uint32_t groupList[MAX_NUM_DEST];
SL_INFO sl_info[MAX_NUM_LCID];
//sl_discovery..
SRB_INFO SL_Discovery[NB_CNX_UE];
#endif
......
......@@ -5478,6 +5478,7 @@ void *rrc_control_socket_thread_fct(void *arg)
long *logicalchannelgroup_drb = NULL;
int j = 0;
int i = 0;
int slrb_id =0;
//from the main program, listen for the incoming messages from control socket (ProSe App)
prose_addr_len = sizeof(prose_app_addr);
......@@ -5543,7 +5544,7 @@ void *rrc_control_socket_thread_fct(void *arg)
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;
int group_comm_rbid = 4;
int group_comm_rbid = 0;
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[GroupCommunicationEstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
......@@ -5557,11 +5558,24 @@ void *rrc_control_socket_thread_fct(void *arg)
UE_rrc_inst[module_id].groupL2Id = groupL2Id;
j = 0;
i = 0;
for (i=0; i< MAX_NUM_DEST; i++) {
if ((UE_rrc_inst[module_id].groupList[i] == 0) && (j == 0)) j = i+1;
if (UE_rrc_inst[module_id].groupList[i] == groupL2Id) break; //group already exists!
//get available rbid for this communication and store (LCID, G)
if (groupL2Id > 0){
for (i=0; i< MAX_NUM_LCID_DATA; i++) {
if ((UE_rrc_inst[module_id].sl_info[i].LCID == 0) && (j == 0)) j = i+1;
if (UE_rrc_inst[module_id].sl_info[i].groupL2Id == groupL2Id) {
group_comm_rbid = UE_rrc_inst[module_id].sl_info[i].LCID;
LOG_I(RRC,"[GroupCommunicationEstablishReq] rbid %d for group Id: 0x%08x\n already exists",group_comm_rbid, UE_rrc_inst[module_id].sl_info[i].groupL2Id );
break; //(LCID, G) already exists!
}
}
if ((i == MAX_NUM_LCID_DATA) && (j > 0)) {
UE_rrc_inst[module_id].sl_info[j-1].LCID = (j-1)+3;
group_comm_rbid = UE_rrc_inst[module_id].sl_info[j-1].LCID;
UE_rrc_inst[module_id].sl_info[j-1].groupL2Id = groupL2Id;
LOG_I(RRC,"[GroupCommunicationEstablishReq] establish rbid %d for group Id: 0x%08x\n",group_comm_rbid, UE_rrc_inst[module_id].sl_info[j-1].groupL2Id );
}
}
if ((i == MAX_NUM_DEST) && (j > 0)) UE_rrc_inst[module_id].groupList[j-1] = groupL2Id;
// configure lower layers PDCP/MAC/PHY for this communication
//Establish a new RBID/LCID for this communication
......@@ -5725,10 +5739,24 @@ void *rrc_control_socket_thread_fct(void *arg)
LOG_I(RRC,"[GroupCommunicationReleaseRequest] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[GroupCommunicationReleaseRequest] Slrb Id: %i\n",sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id);
#endif
slrb_id = sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id;
//reset groupL2ID from MAC LAYER
UE_rrc_inst[module_id].groupL2Id = 0x00000000;
sourceL2Id = UE_rrc_inst[module_id].sourceL2Id;
//find the corresponding record and reset the values
if (slrb_id > 0){
for (i=0; i< MAX_NUM_LCID_DATA; i++) {
if (UE_rrc_inst[module_id].sl_info[i].LCID == slrb_id) {
UE_rrc_inst[module_id].sl_info[i].LCID = 0;
LOG_I(RRC,"[GroupCommunicationReleaseRequest] rbid %d for group Id: 0x%08x\n has been removed",slrb_id, UE_rrc_inst[module_id].sl_info[i].groupL2Id );
UE_rrc_inst[module_id].sl_info[i].groupL2Id = 0x00;
break;
}
}
}
rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0
(RadioResourceConfigCommonSIB_t *)NULL,
(struct PhysicalConfigDedicated *)NULL,
......@@ -5738,7 +5766,7 @@ void *rrc_control_socket_thread_fct(void *arg)
#endif
(MeasObjectToAddMod_t **)NULL,
(MAC_MainConfig_t *)NULL,
0,
slrb_id,
(struct LogicalChannelConfig *)NULL,
(MeasGapConfig_t *)NULL,
(TDD_Config_t *)NULL,
......@@ -5763,7 +5791,7 @@ void *rrc_control_socket_thread_fct(void *arg)
#if defined(Rel10) || defined(Rel14)
,CONFIG_ACTION_REMOVE,
&sourceL2Id,
&destinationL2Id,
NULL,
NULL
#endif
);
......@@ -5774,15 +5802,8 @@ void *rrc_control_socket_thread_fct(void *arg)
sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element));
sl_ctrl_msg_send->type = GROUP_COMMUNICATION_RELEASE_RSP;
//if the requested id exists -> release this ID
if (sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id == slrb_id) {
sl_ctrl_msg_send->sidelinkPrimitive.group_comm_release_rsp = GROUP_COMMUNICATION_RELEASE_OK;
// pthread_mutex_lock(&slrb_mutex);
slrb_id = 0; //Reset slrb_id
//pthread_mutex_unlock(&slrb_mutex);
} else {
sl_ctrl_msg_send->sidelinkPrimitive.group_comm_release_rsp = GROUP_COMMUNICATION_RELEASE_FAILURE;
}
memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element));
free(sl_ctrl_msg_send);
......@@ -5798,7 +5819,7 @@ void *rrc_control_socket_thread_fct(void *arg)
case DIRECT_COMMUNICATION_ESTABLISH_REQ:
sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.direct_comm_establish_req.sourceL2Id;
destinationL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.direct_comm_establish_req.destinationL2Id;
int direct_comm_rbid = 3;
int direct_comm_rbid = 0;
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[DirectCommunicationEstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
......@@ -5810,11 +5831,25 @@ void *rrc_control_socket_thread_fct(void *arg)
UE_rrc_inst[module_id].sourceL2Id = sourceL2Id;
i = 0;
j = 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; //destination already exists!
//get available rbid for this communication and store (LCID, D)
if (destinationL2Id >0){
for (i=0; i< MAX_NUM_LCID_DATA; i++) {
if ((UE_rrc_inst[module_id].sl_info[i].LCID == 0) && (j == 0)) j = i+1;
if (UE_rrc_inst[module_id].sl_info[i].destinationL2Id == destinationL2Id) {
direct_comm_rbid = UE_rrc_inst[module_id].sl_info[i].LCID;
LOG_I(RRC,"[DirectCommunicationEstablishReq] rbid %d for destination Id: 0x%08x already exists!\n",direct_comm_rbid, UE_rrc_inst[module_id].sl_info[i].destinationL2Id );
break; //(LCID, D) already exists!
}
}
if ((i == MAX_NUM_DEST) && (j > 0)) UE_rrc_inst[module_id].destinationList[j-1] = destinationL2Id;
if ((i == MAX_NUM_LCID_DATA) && (j > 0)) {
UE_rrc_inst[module_id].sl_info[j-1].LCID = (j-1)+3;
direct_comm_rbid = UE_rrc_inst[module_id].sl_info[j-1].LCID;
UE_rrc_inst[module_id].sl_info[j-1].destinationL2Id = destinationL2Id;
LOG_I(RRC,"[DirectCommunicationEstablishReq] establish rbid %d for destination Id: 0x%08x\n",direct_comm_rbid, UE_rrc_inst[module_id].sl_info[j-1].destinationL2Id );
}
}
// configure lower layers PDCP/MAC/PHY for this communication
//Establish a new RBID/LCID for this communication
......@@ -5972,10 +6007,92 @@ void *rrc_control_socket_thread_fct(void *arg)
#endif
break;
case DIRECT_COMMUNICATION_RELEASE_REQ:
printf("-----------------------------------\n");
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[DirectCommunicationReleaseRequest] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[DirectCommunicationReleaseRequest] Slrb Id: %i\n",sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id);
#endif
slrb_id = sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id;
//reset groupL2ID from MAC LAYER
UE_rrc_inst[module_id].destinationL2Id = 0x00000000;
sourceL2Id = UE_rrc_inst[module_id].sourceL2Id;
//find the corresponding record and reset the values
if (slrb_id > 0){
for (i=0; i< MAX_NUM_LCID_DATA; i++) {
if (UE_rrc_inst[module_id].sl_info[i].LCID == slrb_id) {
UE_rrc_inst[module_id].sl_info[i].LCID = 0;
LOG_I(RRC,"[GroupCommunicationReleaseRequest] rbid %d for destination Id: 0x%08x\n has been removed",slrb_id, UE_rrc_inst[module_id].sl_info[i].destinationL2Id );
UE_rrc_inst[module_id].sl_info[i].destinationL2Id = 0x00;
break;
}
}
}
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,
slrb_id,
(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_REMOVE,
&sourceL2Id,
NULL,
NULL
#endif
);
LOG_I(RRC,"Send DirectCommunicationReleaseResponse to ProSe App \n");
memset(send_buf, 0, BUFSIZE);
sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element));
sl_ctrl_msg_send->type = DIRECT_COMMUNICATION_RELEASE_RSP;
sl_ctrl_msg_send->sidelinkPrimitive.direct_comm_release_rsp = DIRECT_COMMUNICATION_RELEASE_OK;
memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element));
free(sl_ctrl_msg_send);
prose_addr_len = sizeof(prose_app_addr);
n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len);
if (n < 0){
LOG_E(RRC, "ERROR: Failed to send to ProSe App\n");
exit(EXIT_FAILURE);
}
break;
case PC5S_ESTABLISH_REQ:
type = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.type;
sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.sourceL2Id;
int pc5s_rbid = 10;
int pc5s_rbid = 0;
#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
......@@ -5993,18 +6110,32 @@ void *rrc_control_socket_thread_fct(void *arg)
UE_rrc_inst[module_id].sourceL2Id = sourceL2Id;
j = 0;
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; //destination already exists!
if (destinationL2Id > 0){
for (i = MAX_NUM_LCID_DATA; i < MAX_NUM_LCID; i++) {
if ((UE_rrc_inst[module_id].sl_info[i].LCID == 0) && (j == 0)) j = i+1;
if (UE_rrc_inst[module_id].sl_info[i].destinationL2Id == destinationL2Id) {
pc5s_rbid = UE_rrc_inst[module_id].sl_info[i].LCID;
LOG_I(RRC,"[PC5EstablishReq] rbid %d for destination Id: 0x%08x\n ",pc5s_rbid, UE_rrc_inst[module_id].sl_info[i].destinationL2Id );
break; //(LCID, D) already exists!
}
}
if ((i == MAX_NUM_DEST) && (j > 0)) UE_rrc_inst[module_id].destinationList[j-1] = destinationL2Id;
if ((i == MAX_NUM_LCID) && (j > 0)) {
UE_rrc_inst[module_id].sl_info[j-1].LCID = (j-1);
pc5s_rbid = UE_rrc_inst[module_id].sl_info[j-1].LCID;
UE_rrc_inst[module_id].sl_info[j-1].destinationL2Id = destinationL2Id;
LOG_I(RRC,"[PC5EstablishReq] establish rbid %d for destinationL2Id Id: 0x%08x\n",pc5s_rbid, UE_rrc_inst[module_id].sl_info[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)
// Establish a SLRB (starting from 8 for now)
UE = &UE_rrc_inst[module_id];
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,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