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( ...@@ -1384,58 +1384,92 @@ rrc_mac_config_req_ue(
UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id; UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id;
LOG_I(MAC,"[UE %d] Configure source L2Id 0x%08x \n", Mod_idP, *sourceL2Id ); LOG_I(MAC,"[UE %d] Configure source L2Id 0x%08x \n", Mod_idP, *sourceL2Id );
} }
if (destinationL2Id) {
j = 0; //store list of (S,D,G,LCID) for SL
k = 0; if ((logicalChannelIdentity > 0) && (logicalChannelIdentity < MAX_NUM_LCID_DATA)) {
LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x\n", Mod_idP, *destinationL2Id ); if (groupL2Id){
for (k=0; k< MAX_NUM_DEST; k++) { LOG_I(MAC,"[UE %d] Configure group L2Id 0x%08x\n", Mod_idP, *groupL2Id );
if ((UE_mac_inst[Mod_idP].destinationList[k] == 0) && (j == 0)) j = k+1; j = 0;
if (UE_mac_inst[Mod_idP].destinationList[k] == *destinationL2Id) break; //destination already exists! k = 0;
} for (k=0; k< MAX_NUM_LCID_DATA; k++) {
if ((k == MAX_NUM_DEST) && (j > 0)) { if ((UE_mac_inst[Mod_idP].sl_info[k].LCID == 0) && (j == 0)) j = k+1;
UE_mac_inst[Mod_idP].destinationList[j-1] = *destinationL2Id; 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!
// UE_mac_inst[Mod_idP].numCommFlows++; }
} if ((k == MAX_NUM_LCID_DATA) && (j > 0)) {
for (k=0; k< MAX_NUM_DEST; k++) { UE_mac_inst[Mod_idP].sl_info[j-1].LCID = logicalChannelIdentity;
LOG_I(MAC,"[UE %d] destination %d L2Id 0x%08x\n", Mod_idP,k,UE_mac_inst[Mod_idP].destinationList[k] ); UE_mac_inst[Mod_idP].sl_info[j-1].groupL2Id = *groupL2Id;
} UE_mac_inst[Mod_idP].numCommFlows++;
}
if (groupL2Id) { }
j = 0; for (k=0; k< MAX_NUM_LCID_DATA; k++) {
k = 0; 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 );
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!
}
if ((k == MAX_NUM_DEST) && (j > 0)) {
UE_mac_inst[Mod_idP].groupList[j-1] = *groupL2Id;
// 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] );
}
}
//store list of LCIDs for SL
if (logicalChannelIdentity >0 ){
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!
}
if ((k == MAX_NUM_LCID) && (j > 0)) {
UE_mac_inst[Mod_idP].SL_LCID[j-1] = logicalChannelIdentity;
UE_mac_inst[Mod_idP].numCommFlows++;
} }
for (k=0; k< MAX_NUM_LCID; k++) { if (destinationL2Id){
LOG_I(MAC,"[UE %d] logical channel %d channel id %d\n", Mod_idP,k,UE_mac_inst[Mod_idP].SL_LCID[k] ); LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x\n", Mod_idP, *destinationL2Id );
j = 0;
k = 0;
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_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_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);
}
} }
} 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=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_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);
}
}
} }
break; break;
case CONFIG_ACTION_REMOVE: 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; break;
default: default:
break; break;
} }
......
...@@ -127,6 +127,7 @@ ...@@ -127,6 +127,7 @@
#define LCGID3 3 #define LCGID3 3
/*!\brief Maximum number of logical chanels */ /*!\brief Maximum number of logical chanels */
#define MAX_NUM_LCID 11 #define MAX_NUM_LCID 11
#define MAX_NUM_LCID_DATA 8
/*!\brief Maximum number od control elemenets */ /*!\brief Maximum number od control elemenets */
#define MAX_NUM_CE 5 #define MAX_NUM_CE 5
/*!\brief Maximum number of random access process */ /*!\brief Maximum number of random access process */
...@@ -1294,6 +1295,16 @@ typedef struct { ...@@ -1294,6 +1295,16 @@ typedef struct {
// Bucket size per lcid // Bucket size per lcid
int16_t bucket_size[MAX_NUM_LCID]; int16_t bucket_size[MAX_NUM_LCID];
} UE_SCHEDULING_INFO; } 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 */ /*!\brief Top level UE MAC structure */
typedef struct { typedef struct {
uint16_t Node_id; uint16_t Node_id;
...@@ -1342,12 +1353,9 @@ typedef struct { ...@@ -1342,12 +1353,9 @@ typedef struct {
uint32_t groupL2Id; uint32_t groupL2Id;
//SL destinationL2Id //SL destinationL2Id
uint32_t 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; uint8_t numCommFlows;
uint32_t SL_LCID[MAX_NUM_LCID]; //list of (SLID, G, D)s
SL_INFO sl_info[MAX_NUM_LCID];
#endif #endif
/// pointer to TDD Configuration (NULL for FDD) /// pointer to TDD Configuration (NULL for FDD)
......
...@@ -773,17 +773,17 @@ void ue_send_sl_sdu(module_id_t module_idP, ...@@ -773,17 +773,17 @@ void ue_send_sl_sdu(module_id_t module_idP,
LOG_D( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id ); LOG_D( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id );
//in case of 1-n communication, verify that UE belongs to that group //in case of 1-n communication, verify that UE belongs to that group
int i = 0; int i = 0;
for (i=0; i< MAX_NUM_DEST; i++) for (i=0; i< MAX_NUM_LCID; i++)
if (UE_mac_inst[module_idP].groupList[i] == destinationL2Id) break; if (UE_mac_inst[module_idP].sl_info[i].groupL2Id == destinationL2Id) break;
int j = 0; int j = 0;
for (j=0; j< MAX_NUM_DEST; j++) for (j=0; j< MAX_NUM_LCID; j++)
if (UE_mac_inst[module_idP].destinationList[j] == sourceL2Id) break; if (UE_mac_inst[module_idP].sl_info[j].destinationL2Id == sourceL2Id) break;
//match the destinationL2Id with UE L2Id or groupL2ID //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"); LOG_D( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
return; return;
} }
if (longh->F==1) { if (longh->F==1) {
...@@ -2807,7 +2807,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_ ...@@ -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); LOG_D(MAC,"Checking SLSCH for absSF %d\n",absSF);
if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period
ue->sltx_active = 0; ue->sltx_active = 0;
/*
for (i = 0; i < MAX_NUM_LCID; i++){ for (i = 0; i < MAX_NUM_LCID; i++){
if (ue->SL_LCID[i] > 0) { if (ue->SL_LCID[i] > 0) {
for (int j = 0; j < ue->numCommFlows; j++){ 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_ ...@@ -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; 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 } // we're not in the SCCH period
else if (((absSF & 3) == 0 ) && else if (((absSF & 3) == 0 ) &&
(ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC (ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC
......
...@@ -84,13 +84,13 @@ ...@@ -84,13 +84,13 @@
#define DIRECT_COMMUNICATION_ESTABLISH_RSP 6 #define DIRECT_COMMUNICATION_ESTABLISH_RSP 6
#define GROUP_COMMUNICATION_RELEASE_REQ 7 #define GROUP_COMMUNICATION_RELEASE_REQ 7
#define GROUP_COMMUNICATION_RELEASE_RSP 8 #define GROUP_COMMUNICATION_RELEASE_RSP 8
#define PC5S_ESTABLISH_REQ 9 #define DIRECT_COMMUNICATION_RELEASE_REQ 9
#define PC5S_ESTABLISH_RSP 10 #define DIRECT_COMMUNICATION_RELEASE_RSP 10
#define PC5_DISCOVERY_MESSAGE 11 #define PC5S_ESTABLISH_REQ 11
#define PC5S_ESTABLISH_RSP 12
#define PC5_DISCOVERY_MESSAGE 13
#define PC5_DISCOVERY_PAYLOAD_SIZE 29
#define PC5_DISCOVERY_PAYLOAD_SIZE 29
typedef enum { typedef enum {
UE_STATE_OFF_NETWORK, UE_STATE_OFF_NETWORK,
...@@ -140,6 +140,10 @@ typedef struct { ...@@ -140,6 +140,10 @@ typedef struct {
uint32_t measuredPower; uint32_t measuredPower;
} __attribute__((__packed__)) PC5DiscoveryMessage ; } __attribute__((__packed__)) PC5DiscoveryMessage ;
typedef enum {
DIRECT_COMMUNICATION_RELEASE_OK = 0,
DIRECT_COMMUNICATION_RELEASE_FAILURE
} Direct_Communication_Status_t;
struct sidelink_ctrl_element { struct sidelink_ctrl_element {
unsigned short type; unsigned short type;
...@@ -147,7 +151,7 @@ struct sidelink_ctrl_element { ...@@ -147,7 +151,7 @@ struct sidelink_ctrl_element {
struct GroupCommunicationEstablishReq group_comm_establish_req; struct GroupCommunicationEstablishReq group_comm_establish_req;
struct DirectCommunicationEstablishReq direct_comm_establish_req; struct DirectCommunicationEstablishReq direct_comm_establish_req;
Group_Communication_Status_t group_comm_release_rsp; 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; SL_UE_STATE_t ue_state;
int slrb_id; int slrb_id;
struct PC5SEstablishReq pc5s_establish_req; struct PC5SEstablishReq pc5s_establish_req;
...@@ -741,10 +745,7 @@ typedef struct UE_RRC_INST_s { ...@@ -741,10 +745,7 @@ typedef struct UE_RRC_INST_s {
uint32_t groupL2Id; uint32_t groupL2Id;
//current destination //current destination
uint32_t destinationL2Id; uint32_t destinationL2Id;
//List of destinations (unicast) SL_INFO sl_info[MAX_NUM_LCID];
uint32_t destinationList[MAX_NUM_DEST];
//List of groups (multicast)
uint32_t groupList[MAX_NUM_DEST];
//sl_discovery.. //sl_discovery..
SRB_INFO SL_Discovery[NB_CNX_UE]; SRB_INFO SL_Discovery[NB_CNX_UE];
#endif #endif
......
This diff is collapsed.
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