Commit cf30f61e authored by athanassopoulos's avatar athanassopoulos

Changes to SDAP code

1. Removed SDAP struct from protocol context.
2. Added configuration for the SDAP.
3. SDAP doesn't use pdcp_entities, the values come from function arguements.
4. Make nr_pdcp_ue_manager accessible from SDAP.
5. Avoid using the PDCP locking mechanism in SDAP.
6. Removed nr_pdcp_find_entity_sdap function.
7. Rename dummy eNB function to make GTP compile (no SDAP).
8. Fix: Regression issues with LTE
9. Fix: Regression issues with NR CU/DU
parent 30f14c7e
......@@ -234,19 +234,11 @@ typedef uint8_t pdusessionid_t;
// may be ITTI not enabled, but type instance is useful also for OTG,
typedef intptr_t instance_t;
typedef struct sdap_protocol_ctxt_s {
boolean_t rqi;
uint8_t qfi;
boolean_t dc;
int pdusession_id;
} sdap_protocol_ctxt_t;
typedef struct protocol_ctxt_s {
module_id_t module_id; /*!< \brief Virtualized module identifier */
eNB_flag_t enb_flag; /*!< \brief Flag to indicate eNB (1) or UE (0) */
instance_t instance; /*!< \brief ITTI or OTG module identifier */
rnti_t rnti;
sdap_protocol_ctxt_t sdap;
frame_t frame; /*!< \brief LTE frame number.*/
sub_frame_t subframe; /*!< \brief LTE sub frame number.*/
eNB_index_t eNB_index; /*!< \brief valid for UE indicating the index of connected eNB(s) */
......
......@@ -427,6 +427,7 @@ typedef struct NRRrcConfigurationReq_s {
bool force_256qam_off;
int pusch_TargetSNRx10;
int pucch_TargetSNRx10;
bool enable_sdap;
} gNB_RrcConfigurationReq;
typedef struct NRDuDlReq_s {
......
......@@ -32,7 +32,7 @@ void apply_macrlc_config(gNB_RRC_INST *rrc,
abort();
}
boolean_t sdap_gnb_data(protocol_ctxt_t *ctxt_p,
boolean_t sdap_data_req(protocol_ctxt_t *ctxt_p,
const srb_flag_t srb_flag,
const rb_id_t rb_id,
const mui_t mui,
......@@ -41,6 +41,9 @@ boolean_t sdap_gnb_data(protocol_ctxt_t *ctxt_p,
unsigned char *const sdu_buffer,
const pdcp_transmission_mode_t pt_mode,
const uint32_t *sourceL2Id,
const uint32_t *destinationL2Id) {
const uint32_t *destinationL2Id,
const uint8_t qfi,
const boolean_t rqi,
const int pdusession_id) {
abort();
}
......@@ -1192,7 +1192,9 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
LOG_I(RRC, "256 QAM: %s\n", NRRRC_CONFIGURATION_REQ (msg_p).force_256qam_off ? "force off" : "may be on");
NRRRC_CONFIGURATION_REQ (msg_p).scc = scc;
NRRRC_CONFIGURATION_REQ (msg_p).scd = scd;
NRRRC_CONFIGURATION_REQ (msg_p).enable_sdap = *GNBParamList.paramarray[i][GNB_ENABLE_SDAP_IDX].iptr;
LOG_I(GNB_APP, "SDAP layer is %s\n", NRRRC_CONFIGURATION_REQ (msg_p).enable_sdap ? "enabled" : "disabled");
}//
}//End for (k=0; k <num_gnbs ; k++)
memcpy(&rrc->configuration, &NRRRC_CONFIGURATION_REQ(msg_p), sizeof(NRRRC_CONFIGURATION_REQ(msg_p)));
......
......@@ -125,7 +125,8 @@ typedef enum {
#define GNB_CONFIG_STRING_MINRXTXTIME "min_rxtxtime"
#define GNB_CONFIG_STRING_ULPRBBLACKLIST "ul_prbblacklist"
#define GNB_CONFIG_STRING_FORCE256QAMOFF "force_256qam_off"
#define GNB_CONFIG_STRING_ENABLE_SDAP "enable_sdap"
#define GNB_CONFIG_HLP_STRING_ENABLE_SDAP "enable the SDAP layer\n"
#define GNB_CONFIG_HLP_FORCE256QAMOFF "suppress activation of 256 QAM despite UE support"
......@@ -159,7 +160,8 @@ typedef enum {
{GNB_CONFIG_STRING_NRCELLID, NULL, 0, u64ptr:NULL, defint64val:1, TYPE_UINT64, 0}, \
{GNB_CONFIG_STRING_MINRXTXTIME, NULL, 0, iptr:NULL, defintval:2, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_ULPRBBLACKLIST, NULL, 0, strptr:NULL, defstrval:"", TYPE_STRING, 0}, \
{GNB_CONFIG_STRING_FORCE256QAMOFF, GNB_CONFIG_HLP_FORCE256QAMOFF, PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0} \
{GNB_CONFIG_STRING_FORCE256QAMOFF, GNB_CONFIG_HLP_FORCE256QAMOFF, PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_ENABLE_SDAP, GNB_CONFIG_HLP_STRING_ENABLE_SDAP, PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0}, \
}
#define GNB_GNB_ID_IDX 0
......@@ -188,6 +190,7 @@ typedef enum {
#define GNB_MINRXTXTIME_IDX 23
#define GNB_ULPRBBLACKLIST_IDX 24
#define GNB_FORCE256QAMOFF_IDX 25
#define GNB_ENABLE_SDAP_IDX 26
#define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD}
#define GNBPARAMS_CHECK { \
......
......@@ -37,7 +37,6 @@
#include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
#include "openair2/SDAP/nr_sdap/nr_sdap.h"
#include "nr_pdcp_oai_api.h"
#define TODO do { \
printf("%s:%d:%s: todo\n", __FILE__, __LINE__, __FUNCTION__); \
......@@ -439,13 +438,13 @@ static void *enb_tun_read_thread(void *_)
ctxt.rnti = rnti;
ctxt.sdap.qfi = 7;
ctxt.sdap.rqi = 0;
ctxt.sdap.pdusession_id = 10;
uint8_t qfi = 7;
boolean_t rqi = 0;
int pdusession_id = 10;
sdap_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED,
RLC_SDU_CONFIRM_NO, len, (unsigned char *)rx_buf,
PDCP_TRANSMISSION_MODE_DATA, NULL, NULL);
RLC_SDU_CONFIRM_NO, len, (unsigned char *)rx_buf,
PDCP_TRANSMISSION_MODE_DATA, NULL, NULL, qfi, rqi, pdusession_id);
}
return NULL;
......@@ -486,13 +485,13 @@ static void *ue_tun_read_thread(void *_)
ctxt.rnti = rnti;
ctxt.sdap.dc = SDAP_HDR_UL_DATA_PDU;
ctxt.sdap.qfi = 7;
ctxt.sdap.pdusession_id = 10;
boolean_t dc = SDAP_HDR_UL_DATA_PDU;
uint8_t qfi = 7;
int pdusession_id = 10;
sdap_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED,
RLC_SDU_CONFIRM_NO, len, (unsigned char *)rx_buf,
PDCP_TRANSMISSION_MODE_DATA, NULL, NULL);
RLC_SDU_CONFIRM_NO, len, (unsigned char *)rx_buf,
PDCP_TRANSMISSION_MODE_DATA, NULL, NULL, qfi, dc, pdusession_id);
}
return NULL;
......@@ -622,7 +621,14 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity,
if (IS_SOFTMODEM_NOS1 || UE_NAS_USE_TUN) {
LOG_D(PDCP, "IP packet received with size %d, to be sent to SDAP interface, UE rnti: %d\n", size, ue->rnti);
sdap_data_ind(entity, ue->rnti, buf, size);
sdap_data_ind(entity->rb_id,
entity->is_gnb,
entity->has_sdap,
entity->has_sdapULheader,
entity->pdusession_id,
ue->rnti,
buf,
size);
}
else{
for (i = 0; i < 5; i++) {
......@@ -639,7 +645,14 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity,
rb_found:
{
LOG_D(PDCP, "%s() (drb %d) sending message to SDAP size %d\n", __func__, rb_id, size);
sdap_data_ind(entity, ue->rnti, buf, size);
sdap_data_ind(rb_id,
ue->drb[rb_id-1]->is_gnb,
ue->drb[rb_id-1]->has_sdap,
ue->drb[rb_id-1]->has_sdapULheader,
ue->drb[rb_id-1]->pdusession_id,
ue->rnti,
buf,
size);
}
}
}
......@@ -950,9 +963,9 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s,
exit(-1);
}
pdusession_id = s->cnAssociation->choice.sdap_Config->pdu_Session;
has_sdap = 1;
has_sdapULheader = s->cnAssociation->choice.sdap_Config->sdap_HeaderUL == NR_SDAP_Config__sdap_HeaderUL_present ? 1 : 0;
has_sdapDLheader = s->cnAssociation->choice.sdap_Config->sdap_HeaderDL == NR_SDAP_Config__sdap_HeaderDL_present ? 1 : 0;
has_sdap = has_sdapULheader | has_sdapDLheader;
is_sdap_DefaultDRB = s->cnAssociation->choice.sdap_Config->defaultDRB == true ? 1 : 0;
mappedQFIs2Add = (NR_QFI_t*)s->cnAssociation->choice.sdap_Config->mappedQoS_FlowsToAdd->list.array[0];
mappedQFIs2AddCount = s->cnAssociation->choice.sdap_Config->mappedQoS_FlowsToAdd->list.count;
......@@ -989,7 +1002,8 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s,
LOG_D(PDCP, "%s:%d:%s: added drb %d to ue rnti %x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti);
new_nr_sdap_entity(rnti,
new_nr_sdap_entity(has_sdap,
rnti,
pdusession_id,
is_sdap_DefaultDRB,
drb_id,
......@@ -1438,11 +1452,9 @@ void nr_pdcp_tick(int frame, int subframe)
}
}
nr_pdcp_entity_t *nr_pdcp_find_entity_sdap(int rnti, uint8_t sdap_drb_id){
nr_pdcp_ue_t *ue;
ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti);
if(ue->drb[sdap_drb_id-1])
return ue->drb[sdap_drb_id-1];
return NULL;
/*
* For the SDAP API
*/
nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager(){
return nr_pdcp_ue_manager;
}
#include "openair2/COMMON/platform_types.h"
nr_pdcp_entity_t *nr_pdcp_find_entity_sdap(int rnti, uint8_t sdap_drb_id);
......@@ -868,8 +868,13 @@ rrc_gNB_generate_dedicatedRRCReconfiguration(
sdap_config = CALLOC(1, sizeof(NR_SDAP_Config_t));
memset(sdap_config, 0, sizeof(NR_SDAP_Config_t));
sdap_config->pdu_Session = ue_context_pP->ue_context.pduSession[i].param.pdusession_id;
sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_present;
sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_present;
if (rrc->configuration.enable_sdap) {
sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_present;
sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_present;
} else {
sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_absent;
sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_absent;
}
sdap_config->defaultDRB = TRUE;
sdap_config->mappedQoS_FlowsToAdd = calloc(1, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd));
memset(sdap_config->mappedQoS_FlowsToAdd, 0, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd));
......
......@@ -30,12 +30,15 @@ boolean_t sdap_data_req(protocol_ctxt_t *ctxt_p,
unsigned char *const sdu_buffer,
const pdcp_transmission_mode_t pt_mode,
const uint32_t *sourceL2Id,
const uint32_t *destinationL2Id) {
const uint32_t *destinationL2Id,
const uint8_t qfi,
const boolean_t rqi,
const int pdusession_id) {
nr_sdap_entity_t *sdap_entity;
sdap_entity = nr_sdap_get_entity(ctxt_p->rnti, ctxt_p->sdap.pdusession_id);
sdap_entity = nr_sdap_get_entity(ctxt_p->rnti, pdusession_id);
if(sdap_entity == NULL) {
LOG_E(SDAP, "%s:%d:%s: Entity not found with ue rnti: %x and pdusession id: %d\n", __FILE__, __LINE__, __FUNCTION__, ctxt_p->rnti, ctxt_p->sdap.pdusession_id);
LOG_E(SDAP, "%s:%d:%s: Entity not found with ue rnti: %x and pdusession id: %d\n", __FILE__, __LINE__, __FUNCTION__, ctxt_p->rnti, pdusession_id);
return 0;
}
......@@ -49,16 +52,22 @@ boolean_t sdap_data_req(protocol_ctxt_t *ctxt_p,
sdu_buffer,
pt_mode,
sourceL2Id,
destinationL2Id);
destinationL2Id,
qfi,
rqi);
return ret;
}
void sdap_data_ind(nr_pdcp_entity_t *pdcp_entity,
void sdap_data_ind(rb_id_t pdcp_entity,
int is_gnb,
int has_sdap,
int has_sdapULheader,
int pdusession_id,
int rnti,
char *buf,
int size) {
nr_sdap_entity_t *sdap_entity;
sdap_entity = nr_sdap_get_entity(rnti, pdcp_entity->pdusession_id);
sdap_entity = nr_sdap_get_entity(rnti, pdusession_id);
if(sdap_entity == NULL) {
LOG_E(SDAP, "%s:%d:%s: Entity not found\n", __FILE__, __LINE__, __FUNCTION__);
......@@ -67,6 +76,10 @@ void sdap_data_ind(nr_pdcp_entity_t *pdcp_entity,
sdap_entity->rx_entity(sdap_entity,
pdcp_entity,
is_gnb,
has_sdap,
has_sdapULheader,
pdusession_id,
rnti,
buf,
size);
......
......@@ -41,7 +41,10 @@ boolean_t sdap_data_req(protocol_ctxt_t *ctxt_p,
unsigned char *const sdu_buffer,
const pdcp_transmission_mode_t pt_mode,
const uint32_t *sourceL2Id,
const uint32_t *destinationL2Id
const uint32_t *destinationL2Id,
const uint8_t qfi,
const boolean_t rqi,
const int pdusession_id
);
/*
......@@ -50,7 +53,11 @@ boolean_t sdap_data_req(protocol_ctxt_t *ctxt_p,
* Uplink - gNB
* Downlink - nrUE
*/
void sdap_data_ind(nr_pdcp_entity_t *pdcp_entity,
void sdap_data_ind(rb_id_t pdcp_entity,
int is_gnb,
int has_sdap,
int has_sdapULheader,
int pdusession_id,
int rnti,
char *buf,
int size
......
......@@ -23,7 +23,7 @@
#include "common/utils/LOG/log.h"
#include <openair2/LAYER2/PDCP_v10.1.0/pdcp.h>
#include <openair3/ocp-gtpu/gtp_itf.h>
#include "openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
#include "openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h"
#include <stdlib.h>
#include <string.h>
......@@ -35,6 +35,17 @@ typedef struct {
static nr_sdap_entity_info sdap_info;
nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager(void);
void nr_pdcp_submit_sdap_ctrl_pdu(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu){
nr_pdcp_ue_t *ue;
nr_pdcp_ue_manager_t *nr_pdcp_ue_manager;
nr_pdcp_ue_manager = nr_pdcp_sdap_get_ue_manager();
ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti);
ue->drb[sdap_ctrl_pdu_drb-1]->recv_sdu(ue->drb[sdap_ctrl_pdu_drb-1], (char*)&ctrl_pdu, SDAP_HDR_LENGTH, RLC_MUI_UNDEFINED);
return;
}
static boolean_t nr_sdap_tx_entity(nr_sdap_entity_t *entity,
protocol_ctxt_t *ctxt_p,
const srb_flag_t srb_flag,
......@@ -45,7 +56,9 @@ static boolean_t nr_sdap_tx_entity(nr_sdap_entity_t *entity,
unsigned char *const sdu_buffer,
const pdcp_transmission_mode_t pt_mode,
const uint32_t *sourceL2Id,
const uint32_t *destinationL2Id
const uint32_t *destinationL2Id,
const uint8_t qfi,
const boolean_t rqi
) {
/* The offset of the SDAP header, it might be 0 if the has_sdap is not true in the pdcp entity. */
int offset=0;
......@@ -60,11 +73,11 @@ static boolean_t nr_sdap_tx_entity(nr_sdap_entity_t *entity,
}
uint8_t sdap_buf[SDAP_MAX_PDU];
nr_pdcp_entity_t *pdcp_entity = entity->qfi2drb_map(entity, ctxt_p->sdap.qfi, rb_id);
rb_id_t pdcp_entity = entity->qfi2drb_map(entity, qfi, rb_id);
if(pdcp_entity){
sdap_drb_id = pdcp_entity->rb_id;
pdcp_ent_has_sdap = pdcp_entity->has_sdap;
sdap_drb_id = pdcp_entity;
pdcp_ent_has_sdap = entity->qfi2drb_table[qfi].hasSdap;
}
if(!pdcp_ent_has_sdap){
......@@ -99,8 +112,8 @@ static boolean_t nr_sdap_tx_entity(nr_sdap_entity_t *entity,
* Construct the DL SDAP data PDU.
*/
nr_sdap_dl_hdr_t sdap_hdr;
sdap_hdr.QFI = ctxt_p->sdap.qfi;
sdap_hdr.RQI = ctxt_p->sdap.rqi;
sdap_hdr.QFI = qfi;
sdap_hdr.RQI = rqi;
sdap_hdr.RDI = 0; // SDAP Hardcoded Value
/* Add the SDAP DL Header to the buffer */
memcpy(&sdap_buf[0], &sdap_hdr, SDAP_HDR_LENGTH);
......@@ -118,9 +131,9 @@ static boolean_t nr_sdap_tx_entity(nr_sdap_entity_t *entity,
* construct the UL SDAP data PDU as specified in the subclause 6.2.2.3.
*/
nr_sdap_ul_hdr_t sdap_hdr;
sdap_hdr.QFI = ctxt_p->sdap.qfi;
sdap_hdr.QFI = qfi;
sdap_hdr.R = 0;
sdap_hdr.DC = ctxt_p->sdap.dc;
sdap_hdr.DC = rqi;
/* Add the SDAP UL Header to the buffer */
memcpy(&sdap_buf[0], &sdap_hdr, SDAP_HDR_LENGTH);
memcpy(&sdap_buf[SDAP_HDR_LENGTH], sdu_buffer, sdu_buffer_size);
......@@ -154,15 +167,19 @@ static boolean_t nr_sdap_tx_entity(nr_sdap_entity_t *entity,
}
static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
nr_pdcp_entity_t *pdcp_entity,
rb_id_t pdcp_entity,
int is_gnb,
int has_sdap,
int has_sdapHeader,
int pdusession_id,
int rnti,
char *buf,
int size) {
/* The offset of the SDAP header, it might be 0 if the has_sdap is not true in the pdcp entity. */
int offset=0;
if(pdcp_entity->is_gnb) { // gNB
if(pdcp_entity->has_sdap && pdcp_entity->has_sdapULheader ) { // Handling the SDAP Header
if(is_gnb) { // gNB
if(has_sdap && has_sdapHeader ) { // Handling the SDAP Header
offset = SDAP_HDR_LENGTH;
nr_sdap_ul_hdr_t *sdap_hdr = (nr_sdap_ul_hdr_t *)buf;
LOG_D(SDAP, "RX Entity Received QFI : %u\n", sdap_hdr->QFI);
......@@ -192,16 +209,16 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).length = size-offset;
GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).rnti = rnti;
GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).pdusession_id = pdcp_entity->pdusession_id;
GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).pdusession_id = pdusession_id;
LOG_D(SDAP, "%s() sending message to gtp size %d\n", __func__, size-offset);
itti_send_msg_to_task(TASK_VARIABLE, INSTANCE_DEFAULT, message_p);
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
} else { //nrUE
/*
* TS 37.324 5.2 Data transfer
* 5.2.2 Downlink
* if the DRB from which this SDAP data PDU is received is configured by RRC with the presence of SDAP header.
*/
if(pdcp_entity->has_sdap && pdcp_entity->has_sdapDLheader) { // Handling the SDAP Header
if(has_sdap && has_sdapHeader) { // Handling the SDAP Header
offset = SDAP_HDR_LENGTH;
/*
* TS 37.324 5.2 Data transfer
......@@ -224,9 +241,9 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
* 5.3.2 Reflective mapping
* If there is no stored QoS flow to DRB mapping rule for the QoS flow and a default DRB is configured.
*/
if(!entity->qfi2drb_table[sdap_hdr->QFI] && entity->default_drb->rb_id){
if(!entity->qfi2drb_table[sdap_hdr->QFI].drb_id && entity->default_drb){
nr_sdap_ul_hdr_t sdap_ctrl_pdu = entity->sdap_construct_ctrl_pdu(sdap_hdr->QFI);
nr_pdcp_entity_t *sdap_ctrl_pdu_drb = entity->sdap_map_ctrl_pdu(entity, pdcp_entity, SDAP_CTRL_PDU_MAP_DEF_DRB, sdap_hdr->QFI);
rb_id_t sdap_ctrl_pdu_drb = entity->sdap_map_ctrl_pdu(entity, pdcp_entity, SDAP_CTRL_PDU_MAP_DEF_DRB, sdap_hdr->QFI);
entity->sdap_submit_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, sdap_ctrl_pdu);
}
......@@ -239,10 +256,10 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
* the DRB according to the stored QoS flow to DRB mapping rule is configured by RRC
* with the presence of UL SDAP header
*/
if( (pdcp_entity->rb_id != entity->qfi2drb_table[sdap_hdr->QFI]->rb_id) &&
pdcp_entity->has_sdapULheader ){
if( (pdcp_entity != entity->qfi2drb_table[sdap_hdr->QFI].drb_id) &&
has_sdapHeader ){
nr_sdap_ul_hdr_t sdap_ctrl_pdu = entity->sdap_construct_ctrl_pdu(sdap_hdr->QFI);
nr_pdcp_entity_t *sdap_ctrl_pdu_drb = entity->sdap_map_ctrl_pdu(entity, pdcp_entity, SDAP_CTRL_PDU_MAP_RULE_DRB, sdap_hdr->QFI);
rb_id_t sdap_ctrl_pdu_drb = entity->sdap_map_ctrl_pdu(entity, pdcp_entity, SDAP_CTRL_PDU_MAP_RULE_DRB, sdap_hdr->QFI);
entity->sdap_submit_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, sdap_ctrl_pdu);
}
......@@ -251,7 +268,7 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
* 5.3.2 Reflective mapping
* store the QoS flow to DRB mapping of the DL SDAP data PDU as the QoS flow to DRB mapping rule for the UL.
*/
entity->qfi2drb_table[sdap_hdr->QFI]->rb_id = pdcp_entity->rb_id;
entity->qfi2drb_table[sdap_hdr->QFI].drb_id = pdcp_entity;
}
/*
......@@ -280,45 +297,35 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
}
}
void nr_sdap_qfi2drb_map_update(nr_sdap_entity_t *entity, uint8_t qfi, uint8_t drb){
void nr_sdap_qfi2drb_map_update(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t drb, boolean_t hasSdap){
if(qfi < SDAP_MAX_QFI &&
qfi > SDAP_MAP_RULE_EMPTY &&
drb > 0 &&
drb <= AVLBL_DRB)
{
nr_pdcp_entity_t *pdcp_entity;
pdcp_entity = nr_pdcp_find_entity_sdap(entity->rnti, drb);
if(!pdcp_entity){
LOG_D(SDAP, "Map Update failed - PDCP Entity does not exist, should create it\n");
LOG_D(SDAP, "Map Update failed - Mapping to default DRB\n");
entity->qfi2drb_table[qfi] = entity->default_drb;
}
entity->qfi2drb_table[qfi] = pdcp_entity;
LOG_D(SDAP, "Updated QFI to DRB Map: QFI %u -> DRB %d \n", qfi, entity->qfi2drb_table[qfi]->rb_id);
entity->qfi2drb_table[qfi].drb_id = drb;
entity->qfi2drb_table[qfi].hasSdap = hasSdap;
LOG_D(SDAP, "Updated QFI to DRB Map: QFI %u -> DRB %ld \n", qfi, entity->qfi2drb_table[qfi].drb_id);
LOG_D(SDAP, "DRB %ld %s\n", entity->qfi2drb_table[qfi].drb_id, hasSdap ? "has SDAP" : "does not have SDAP");
}
}
void nr_sdap_qfi2drb_map_del(nr_sdap_entity_t *entity, uint8_t qfi){
entity->qfi2drb_table[qfi] = SDAP_NO_MAPPING_RULE;
entity->qfi2drb_table[qfi].drb_id = SDAP_NO_MAPPING_RULE;
LOG_D(SDAP, "Deleted QFI to DRB Map for QFI %u \n", qfi);
}
nr_pdcp_entity_t *nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi, long upper_layer_rb_id){
nr_pdcp_entity_t *pdcp_entity;
rb_id_t nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t upper_layer_rb_id){
rb_id_t pdcp_entity;
pdcp_entity = entity->qfi2drb_table[qfi];
pdcp_entity = entity->qfi2drb_table[qfi].drb_id;
if(pdcp_entity){
return pdcp_entity;
} else if(entity->default_drb) {
LOG_D(SDAP, "Mapped QFI %u to Default DRB\n", qfi);
entity->qfi2drb_map_update(entity, qfi, entity->default_drb->rb_id);
return entity->default_drb;
} else {
/* Update map for Hardcode DRB ID given from upper layer (ue/enb_tun_read_thread rb_id)*/
entity->qfi2drb_map_update(entity, qfi, upper_layer_rb_id);
return SDAP_MAP_RULE_EMPTY;
}
......@@ -336,28 +343,28 @@ nr_sdap_ul_hdr_t nr_sdap_construct_ctrl_pdu(uint8_t qfi){
return sdap_end_marker_hdr;
}
nr_pdcp_entity_t *nr_sdap_map_ctrl_pdu(nr_sdap_entity_t *entity, nr_pdcp_entity_t *pdcp_entity, int map_type, uint8_t dl_qfi){
nr_pdcp_entity_t *drb_of_endmarker = NULL;
rb_id_t nr_sdap_map_ctrl_pdu(nr_sdap_entity_t *entity, rb_id_t pdcp_entity, int map_type, uint8_t dl_qfi){
rb_id_t drb_of_endmarker = 0;
if(map_type == SDAP_CTRL_PDU_MAP_DEF_DRB){
drb_of_endmarker = entity->default_drb;
LOG_D(SDAP, "Mapped Control PDU to default drb\n");
}
if(map_type == SDAP_CTRL_PDU_MAP_RULE_DRB){
drb_of_endmarker = entity->qfi2drb_map(entity, dl_qfi, pdcp_entity->rb_id);
drb_of_endmarker = entity->qfi2drb_map(entity, dl_qfi, pdcp_entity);
LOG_D(SDAP, "Mapped Control PDU according to the mapping rule, qfi %u \n", dl_qfi);
}
return drb_of_endmarker;
}
void nr_sdap_submit_ctrl_pdu(int rnti, nr_pdcp_entity_t *sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu){
void nr_sdap_submit_ctrl_pdu(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu){
if(sdap_ctrl_pdu_drb){
sdap_ctrl_pdu_drb->recv_sdu(sdap_ctrl_pdu_drb, (char*)&ctrl_pdu, SDAP_HDR_LENGTH, RLC_MUI_UNDEFINED);
nr_pdcp_submit_sdap_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, ctrl_pdu);
LOG_D(SDAP, "Sent Control PDU to PDCP Layer.\n");
}
}
void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity,
nr_pdcp_entity_t *pdcp_entity,
rb_id_t pdcp_entity,
uint16_t rnti,
NR_QFI_t *mapped_qfi_2_add,
uint8_t mappedQFIs2AddCount,
......@@ -367,20 +374,21 @@ void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity,
for(int i = 0; i < mappedQFIs2AddCount; i++){
qfi = mapped_qfi_2_add[i];
if(existing_sdap_entity->default_drb && existing_sdap_entity->qfi2drb_table[qfi] == SDAP_NO_MAPPING_RULE){
if(existing_sdap_entity->default_drb && existing_sdap_entity->qfi2drb_table[qfi].drb_id == SDAP_NO_MAPPING_RULE){
nr_sdap_ul_hdr_t sdap_ctrl_pdu = existing_sdap_entity->sdap_construct_ctrl_pdu(qfi);
nr_pdcp_entity_t *sdap_ctrl_pdu_drb = existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_DEF_DRB, qfi);
rb_id_t sdap_ctrl_pdu_drb = existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_DEF_DRB, qfi);
existing_sdap_entity->sdap_submit_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, sdap_ctrl_pdu);
}
if(existing_sdap_entity->qfi2drb_table[qfi]->rb_id != drb_identity && pdcp_entity->has_sdapULheader){
if(existing_sdap_entity->qfi2drb_table[qfi].drb_id != drb_identity && existing_sdap_entity->qfi2drb_table[qfi].hasSdap){
nr_sdap_ul_hdr_t sdap_ctrl_pdu = existing_sdap_entity->sdap_construct_ctrl_pdu(qfi);
nr_pdcp_entity_t *sdap_ctrl_pdu_drb = existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_RULE_DRB, qfi);
rb_id_t sdap_ctrl_pdu_drb = existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_RULE_DRB, qfi);
existing_sdap_entity->sdap_submit_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, sdap_ctrl_pdu);
}
}
}
nr_sdap_entity_t *new_nr_sdap_entity(uint16_t rnti,
nr_sdap_entity_t *new_nr_sdap_entity(int has_sdap,
uint16_t rnti,
int pdusession_id,
boolean_t is_defaultDRB,
uint8_t drb_identity,
......@@ -390,7 +398,7 @@ nr_sdap_entity_t *new_nr_sdap_entity(uint16_t rnti,
if(nr_sdap_get_entity(rnti, pdusession_id)) {
LOG_E(SDAP, "SDAP Entity for UE already exists.\n");
nr_sdap_entity_t *existing_sdap_entity = nr_sdap_get_entity(rnti, pdusession_id);
nr_pdcp_entity_t *pdcp_entity = existing_sdap_entity->default_drb;
rb_id_t pdcp_entity = existing_sdap_entity->default_drb;
nr_sdap_ue_qfi2drb_config(existing_sdap_entity, pdcp_entity, rnti, mapped_qfi_2_add, mappedQFIs2AddCount, drb_identity);
return existing_sdap_entity;
}
......@@ -418,15 +426,14 @@ nr_sdap_entity_t *new_nr_sdap_entity(uint16_t rnti,
sdap_entity->qfi2drb_map = nr_sdap_qfi2drb_map;
if(is_defaultDRB) {
nr_pdcp_entity_t *pdcp_entity = nr_pdcp_find_entity_sdap(sdap_entity->rnti, drb_identity);
sdap_entity->default_drb = pdcp_entity;
LOG_I(SDAP, "Default DRB for the created SDAP entity: %d \n", sdap_entity->default_drb->rb_id);
sdap_entity->default_drb = drb_identity;
LOG_I(SDAP, "Default DRB for the created SDAP entity: %ld \n", sdap_entity->default_drb);
if(mappedQFIs2AddCount) {
for (int i = 0; i < mappedQFIs2AddCount; i++)
{
LOG_D(SDAP, "Mapped QFI to Add : %ld \n", mapped_qfi_2_add[i]);
sdap_entity->qfi2drb_map_update(sdap_entity, mapped_qfi_2_add[i], sdap_entity->default_drb->rb_id);
sdap_entity->qfi2drb_map_update(sdap_entity, mapped_qfi_2_add[i], sdap_entity->default_drb, has_sdap);
}
}
}
......
......@@ -62,19 +62,26 @@ typedef struct nr_sdap_ul_hdr_s {
uint8_t DC:1;
} __attribute__((packed)) nr_sdap_ul_hdr_t;
typedef struct qfi2drb_s {
rb_id_t drb_id;
boolean_t hasSdap;
} qfi2drb_t;
void nr_pdcp_submit_sdap_ctrl_pdu(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu);
typedef struct nr_sdap_entity_s {
uint16_t rnti;
nr_pdcp_entity_t *default_drb;
rb_id_t default_drb;
int pdusession_id;
nr_pdcp_entity_t *qfi2drb_table[SDAP_MAX_QFI];
qfi2drb_t qfi2drb_table[SDAP_MAX_QFI];
void (*qfi2drb_map_update)(struct nr_sdap_entity_s *entity, uint8_t qfi, uint8_t drb);
void (*qfi2drb_map_update)(struct nr_sdap_entity_s *entity, uint8_t qfi, rb_id_t drb, boolean_t hasSdap);
void (*qfi2drb_map_delete)(struct nr_sdap_entity_s *entity, uint8_t qfi);
nr_pdcp_entity_t *(*qfi2drb_map)(struct nr_sdap_entity_s *entity, uint8_t qfi, long upper_layer_rb_id);
rb_id_t (*qfi2drb_map)(struct nr_sdap_entity_s *entity, uint8_t qfi, rb_id_t upper_layer_rb_id);
nr_sdap_ul_hdr_t (*sdap_construct_ctrl_pdu)(uint8_t qfi);
nr_pdcp_entity_t *(*sdap_map_ctrl_pdu)(struct nr_sdap_entity_s *entity, nr_pdcp_entity_t *pdcp_entity, int map_type, uint8_t dl_qfi);
void (*sdap_submit_ctrl_pdu)(int rnti, nr_pdcp_entity_t *sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu);
rb_id_t (*sdap_map_ctrl_pdu)(struct nr_sdap_entity_s *entity, rb_id_t pdcp_entity, int map_type, uint8_t dl_qfi);
void (*sdap_submit_ctrl_pdu)(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu);
boolean_t (*tx_entity)(struct nr_sdap_entity_s *entity,
......@@ -87,10 +94,17 @@ typedef struct nr_sdap_entity_s {
unsigned char *const sdu_buffer,
const pdcp_transmission_mode_t pt_mode,
const uint32_t *sourceL2Id,
const uint32_t *destinationL2Id);
const uint32_t *destinationL2Id,
const uint8_t qfi,
const boolean_t rqi
);
void (*rx_entity)(struct nr_sdap_entity_s *entity,
nr_pdcp_entity_t *pdcp_entity,
rb_id_t pdcp_entity,
int is_gnb,
int has_sdap,
int has_sdapULheader,
int pdusession_id,
int rnti,
char *buf,
int size);
......@@ -100,7 +114,7 @@ typedef struct nr_sdap_entity_s {
} nr_sdap_entity_t;
/* QFI to DRB Mapping Related Function */
void nr_sdap_qfi2drb_map_update(nr_sdap_entity_t *entity, uint8_t qfi, uint8_t drb);
void nr_sdap_qfi2drb_map_update(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t drb, boolean_t hasSdap);
/* QFI to DRB Mapping Related Function */
void nr_sdap_qfi2drb_map_del(nr_sdap_entity_t *entity, uint8_t qfi);
......@@ -114,7 +128,7 @@ void nr_sdap_qfi2drb_map_del(nr_sdap_entity_t *entity, uint8_t qfi);
* If there is no stored QoS flow to DRB mapping rule for the QoS flow as specified in the subclause 5.3, map the SDAP SDU to the default DRB
* else, map the SDAP SDU to the DRB according to the stored QoS flow to DRB mapping rule.
*/
nr_pdcp_entity_t *nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi, long upper_layer_rb_id);
rb_id_t nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t upper_layer_rb_id);
/*
* TS 37.324 5.3 QoS flow to DRB Mapping
......@@ -128,20 +142,20 @@ nr_sdap_ul_hdr_t nr_sdap_construct_ctrl_pdu(uint8_t qfi);
* 1.) default DRB or
* 2.) DRB according to the stored QoS flow to DRB mapping rule
*/
nr_pdcp_entity_t *nr_sdap_map_ctrl_pdu(nr_sdap_entity_t *entity, nr_pdcp_entity_t *pdcp_entity, int map_type, uint8_t dl_qfi);
rb_id_t nr_sdap_map_ctrl_pdu(nr_sdap_entity_t *entity, rb_id_t pdcp_entity, int map_type, uint8_t dl_qfi);
/*
* TS 37.324 5.3 QoS flow to DRB Mapping
* Submit the end-marker control PDU to the lower layer.
*/
void nr_sdap_submit_ctrl_pdu(int rnti, nr_pdcp_entity_t *sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu);
void nr_sdap_submit_ctrl_pdu(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu);
/*
* TS 37.324 5.3 QoS flow to DRB Mapping
* 5.3.1 Configuration Procedures
*/
void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity,
nr_pdcp_entity_t *pdcp_entity,
rb_id_t pdcp_entity,
uint16_t rnti,
NR_QFI_t *mapped_qfi_2_add,
uint8_t mappedQFIs2AddCount,
......@@ -151,7 +165,8 @@ void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity,
* TS 37.324 4.4 5.1.1 SDAP entity establishment
* Establish an SDAP entity.
*/
nr_sdap_entity_t *new_nr_sdap_entity(uint16_t rnti,
nr_sdap_entity_t *new_nr_sdap_entity(int has_sdap,
uint16_t rnti,
int pdusession_id,
boolean_t is_defaultDRB,
uint8_t default_DRB,
......
......@@ -20,6 +20,8 @@ extern "C" {
#include "openair2/SDAP/nr_sdap/nr_sdap.h"
//#include <openair1/PHY/phy_extern.h>
static boolean_t is_gnb = false;
#pragma pack(1)
typedef struct Gtpv1uMsgHeader {
......@@ -92,6 +94,7 @@ typedef struct {
rnti_t rnti;
ebi_t incoming_rb_id;
gtpCallback callBack;
gtpCallbackSDAP callBackSDAP;
int pdusession_id;
} rntiData_t;
......@@ -476,6 +479,8 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer
inst->te2ue_mapping[incoming_teid].incoming_rb_id= incoming_bearer_id;
inst->te2ue_mapping[incoming_teid].callBack=callBack;
inst->te2ue_mapping[incoming_teid].callBackSDAP = sdap_data_req;
inst->te2ue_mapping[incoming_teid].pdusession_id = (uint8_t)outgoing_bearer_id;
......@@ -597,14 +602,14 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance,
create_tunnel_req->num_tunnels,
create_tunnel_req->outgoing_teid[0]);
tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport();
is_gnb = true;
for (int i = 0; i < create_tunnel_req->num_tunnels; i++) {
teid_t teid=newGtpuCreateTunnel(instance, create_tunnel_req->rnti,
create_tunnel_req->incoming_rb_id[i],
create_tunnel_req->pdusession_id[i],
create_tunnel_req->outgoing_teid[i],
create_tunnel_req->dst_addr[i], dstport,
sdap_data_req);
pdcp_data_req);
create_tunnel_resp->status=0;
create_tunnel_resp->rnti=create_tunnel_req->rnti;
create_tunnel_resp->num_tunnels=create_tunnel_req->num_tunnels;
......@@ -876,9 +881,6 @@ static int Gtpv1uHandleGpdu(int h,
ctxt.enb_flag = 1;
ctxt.instance = inst->addr.originInstance;
ctxt.rnti = tunnel->second.rnti;
ctxt.sdap.qfi = qfi;
ctxt.sdap.rqi = rqi;
ctxt.sdap.pdusession_id = tunnel->second.pdusession_id;
ctxt.frame = 0;
ctxt.subframe = 0;
ctxt.eNB_index = 0;
......@@ -894,17 +896,34 @@ static int Gtpv1uHandleGpdu(int h,
const uint32_t destinationL2Id=0;
pthread_mutex_unlock(&globGtp.gtp_lock);
if ( !tunnel->second.callBack(&ctxt,
srb_flag,
rb_id,
mui,
confirm,
sdu_buffer_size,
sdu_buffer,
mode,
&sourceL2Id,
&destinationL2Id) )
LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h);
if(is_gnb && qfi){
if ( !tunnel->second.callBackSDAP(&ctxt,
srb_flag,
rb_id,
mui,
confirm,
sdu_buffer_size,
sdu_buffer,
mode,
&sourceL2Id,
&destinationL2Id,
qfi,
rqi,
tunnel->second.pdusession_id) )
LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h);
} else {
if ( !tunnel->second.callBack(&ctxt,
srb_flag,
rb_id,
mui,
confirm,
sdu_buffer_size,
sdu_buffer,
mode,
&sourceL2Id,
&destinationL2Id) )
LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h);
}
LOG_D(GTPU,"[%d] Received a %d bytes packet for: teid:%x\n", h,
msgBufLen-offset,
......
......@@ -20,6 +20,21 @@ typedef boolean_t (*gtpCallback)(
const uint32_t *sourceL2Id,
const uint32_t *destinationL2Id);
typedef boolean_t (*gtpCallbackSDAP)(
protocol_ctxt_t *ctxt_pP,
const srb_flag_t srb_flagP,
const rb_id_t rb_idP,
const mui_t muiP,
const confirm_t confirmP,
const sdu_size_t sdu_buffer_sizeP,
unsigned char *const sdu_buffer_pP,
const pdcp_transmission_mode_t modeP,
const uint32_t *sourceL2Id,
const uint32_t *destinationL2Id,
const uint8_t qfi,
const boolean_t rqi,
const int pdusession_id);
typedef struct openAddr_s {
char originHost[HOST_NAME_MAX];
char originService[HOST_NAME_MAX];
......
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