diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index 67fd2e6947..1efa0990f2 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -49,7 +49,7 @@ extern unsigned char NB_gNB_INST; extern RAN_CONTEXT_t RC; #define GNB_REGISTER_RETRY_DELAY 10 - +#if 0 /*------------------------------------------------------------------------------*/ static void configure_nr_rrc(uint32_t gnb_id) { @@ -68,7 +68,7 @@ static void configure_nr_rrc(uint32_t gnb_id) } else AssertFatal(0,"NRRRC context for gNB %d not allocated\n",gnb_id); } - +#endif /*------------------------------------------------------------------------------*/ diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 1bdd6c0937..7c454acee7 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -77,6 +77,7 @@ #include "NR_EUTRA-MBSFN-SubframeConfig.h" #include "RRC/NR/MESSAGES/asn1_msg.h" +#include "openair2/LAYER2/nr_pdcp/nr_pdcp.h" extern uint16_t sf_ahead; int macrlc_has_f1 = 0; @@ -531,7 +532,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { int num_gnbs = 0; char aprefix[MAX_OPTNAME_SIZE*2 + 8]; int32_t gnb_id = 0; - int k; + paramdef_t GNBSParams[] = GNBSPARAMS_DESC; ////////// Identification parameters paramdef_t GNBParams[] = GNBPARAMS_DESC; diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 2509f48d49..14d81e5c77 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -39,6 +39,7 @@ #include "PHY/defs_UE.h" #include "openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h" #include "executables/softmodem-common.h" +#include "openair2/LAYER2/nr_pdcp/nr_pdcp.h" static NR_UE_MAC_INST_t *nr_ue_mac_inst; @@ -56,7 +57,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) // if (IS_SOFTMODEM_NOS1){ if (1) { AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); - pdcp_layer_init(); + nr_pdcp_layer_init_ue(); nr_DRB_preconfiguration(nr_ue_mac_inst->crnti); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp.h b/openair2/LAYER2/nr_pdcp/nr_pdcp.h new file mode 100644 index 0000000000..a5f182c822 --- /dev/null +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp.h @@ -0,0 +1,31 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include + +#ifndef _NR_PDCP_H_ +#define _NR_PDCP_H_ + +void pdcp_layer_init_for_CU(void); +void nr_pdcp_layer_init_ue(void); +void nr_DRB_preconfiguration(uint16_t crnti); + +#endif /* _NR_PDCP_H_ */ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h index 0e5b645dd1..952f3137ee 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h @@ -27,14 +27,14 @@ typedef struct nr_pdcp_entity_t { /* functions provided by the PDCP module */ - void (*recv_pdu)(protocol_ctxt_t *ctxt_pP,struct nr_pdcp_entity_t *entity, char *buffer, int size); + void (*recv_pdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size); void (*recv_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size, int sdu_id); void (*delete)(struct nr_pdcp_entity_t *entity); void (*set_integrity_key)(struct nr_pdcp_entity_t *entity, char *key); /* callbacks provided to the PDCP module */ - void (*deliver_sdu)(protocol_ctxt_t *ctxt_pP,void *deliver_sdu_data, struct nr_pdcp_entity_t *entity, + void (*deliver_sdu)(void *deliver_sdu_data, struct nr_pdcp_entity_t *entity, char *buf, int size); void *deliver_sdu_data; void (*deliver_pdu)(void *deliver_pdu_data, struct nr_pdcp_entity_t *entity, diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_drb_am.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_drb_am.c index 328f5b4b7d..0e0c103f28 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_drb_am.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_drb_am.c @@ -26,13 +26,13 @@ #include #include "common/utils/LOG/log.h" -void nr_pdcp_entity_drb_am_recv_pdu( protocol_ctxt_t *ctxt_pP , nr_pdcp_entity_t *_entity, char *buffer, int size) +void nr_pdcp_entity_drb_am_recv_pdu( nr_pdcp_entity_t *_entity, char *buffer, int size) { nr_pdcp_entity_drb_am_t *entity = (nr_pdcp_entity_drb_am_t *)_entity; if (size < 3) abort(); if (!(buffer[0] & 0x80)) { printf("%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } - entity->common.deliver_sdu(ctxt_pP, entity->common.deliver_sdu_data, + entity->common.deliver_sdu(entity->common.deliver_sdu_data, (nr_pdcp_entity_t *)entity, buffer+3, size-3); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_drb_am.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_drb_am.h index 05828146c7..98d8676bd9 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_drb_am.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_drb_am.h @@ -33,7 +33,7 @@ typedef struct { int discard_timer; /* unit: ms, -1 means infinity */ } nr_pdcp_entity_drb_am_t; -void nr_pdcp_entity_drb_am_recv_pdu(protocol_ctxt_t *ctxt_pP,nr_pdcp_entity_t *entity, char *buffer, int size); +void nr_pdcp_entity_drb_am_recv_pdu(nr_pdcp_entity_t *entity, char *buffer, int size); void nr_pdcp_entity_drb_am_recv_sdu(nr_pdcp_entity_t *entity, char *buffer, int size, int sdu_id); void nr_pdcp_entity_drb_am_set_integrity_key(nr_pdcp_entity_t *entity, char *key); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c index c55323906c..73840aeb0a 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.c @@ -25,12 +25,12 @@ #include #include -void nr_pdcp_entity_srb_recv_pdu(protocol_ctxt_t *ctxt_pP, nr_pdcp_entity_t *_entity, char *buffer, int size) +void nr_pdcp_entity_srb_recv_pdu(nr_pdcp_entity_t *_entity, char *buffer, int size) { nr_pdcp_entity_srb_t *entity = (nr_pdcp_entity_srb_t *)_entity; if (size < 2) abort(); - entity->common.deliver_sdu(ctxt_pP, entity->common.deliver_sdu_data, + entity->common.deliver_sdu(entity->common.deliver_sdu_data, (nr_pdcp_entity_t *)entity, buffer+2, size-6); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.h index a334b700e5..f0f9d3e28f 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity_srb.h @@ -29,7 +29,7 @@ typedef struct { int srb_id; } nr_pdcp_entity_srb_t; -void nr_pdcp_entity_srb_recv_pdu(protocol_ctxt_t *ctxt_pP, nr_pdcp_entity_t *_entity, char *buffer, int size); +void nr_pdcp_entity_srb_recv_pdu(nr_pdcp_entity_t *_entity, char *buffer, int size); void nr_pdcp_entity_srb_recv_sdu(nr_pdcp_entity_t *_entity, char *buffer, int size, int sdu_id); void nr_pdcp_entity_srb_set_integrity_key(nr_pdcp_entity_t *_entity, char *key); void nr_pdcp_entity_srb_delete(nr_pdcp_entity_t *_entity); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 2cb53b7d03..42eb4255e0 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -33,6 +33,7 @@ /* from OAI */ #include "pdcp.h" +#include "nr_pdcp.h" #include "LAYER2/nr_rlc/nr_rlc_oai_api.h" #define TODO do { \ @@ -100,8 +101,7 @@ extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * con const NR_DRB_ToAddModList_t * const drb2add_listP, const NR_DRB_ToReleaseList_t * const drb2release_listP, const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_srb_bearer2add_list, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_drb_bearer2add_list); + struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); //------------------------------------------------------------------------------ void @@ -109,7 +109,7 @@ nr_rrc_data_ind( const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, const sdu_size_t sdu_sizeP, - const uint8_t *const buffer_pP + const char *const buffer_pP ) //------------------------------------------------------------------------------ { @@ -134,34 +134,6 @@ nr_rrc_data_ind( } } -//------------------------------------------------------------------------------ -void -nr_rrc_data_ind_ccch( - const protocol_ctxt_t *const ctxt_pP, - const rb_id_t Srb_id, - const sdu_size_t sdu_sizeP, - const uint8_t *const buffer_pP -) -//------------------------------------------------------------------------------ -{ - rb_id_t DCCH_index = Srb_id; - LOG_I(RRC, "[UE %x] Frame %d: received a CCCH %ld message on SRB %ld with Size %d from gNB %d\n", - ctxt_pP->module_id, ctxt_pP->frame, DCCH_index, Srb_id, sdu_sizeP, ctxt_pP->eNB_index); - { - MessageDef *message_p; - // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). - message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_GNB : TASK_RRC_NRUE, 0, NR_RRC_MAC_CCCH_DATA_IND); - NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = ctxt_pP->frame; - NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; - NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_sizeP; - NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = 0; - NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = 0; - NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = ctxt_pP->rnti; - memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu,buffer_pP,sdu_sizeP); - itti_send_msg_to_task (ctxt_pP->enb_flag ? TASK_RRC_GNB : TASK_RRC_NRUE, ctxt_pP->instance, message_p); - } -} - static void *rlc_data_req_thread(void *_) { int i; @@ -297,7 +269,7 @@ static void *enb_tun_read_thread(void *_) int rnti; protocol_ctxt_t ctxt; - int lc_id = 4; + int rb_id = 1; pthread_setname_np( pthread_self(),"enb_tun_read"); while (1) { @@ -307,7 +279,7 @@ static void *enb_tun_read_thread(void *_) exit(1); } -printf("\n\n\n########## nas_sock_fd read returns len %d\n", len); + LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len); nr_pdcp_manager_lock(nr_pdcp_ue_manager); rnti = nr_pdcp_get_first_rnti(nr_pdcp_ue_manager); @@ -331,7 +303,7 @@ printf("\n\n\n########## nas_sock_fd read returns len %d\n", len); } if (proto_agent_flag == 1) { - pdcp_data_req(&ctxt, SRB_FLAG_NO, lc_id, RLC_MUI_UNDEFINED, + pdcp_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); } @@ -348,7 +320,7 @@ static void *ue_tun_read_thread(void *_) int rnti; protocol_ctxt_t ctxt; - int lc_id = 4; + int rb_id = 1; pthread_setname_np( pthread_self(),"ue_tun_read"); while (1) { len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD); @@ -357,7 +329,7 @@ static void *ue_tun_read_thread(void *_) exit(1); } -printf("\n\n\n########## nas_sock_fd read returns len %d\n", len); + LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len); nr_pdcp_manager_lock(nr_pdcp_ue_manager); rnti = nr_pdcp_get_first_rnti(nr_pdcp_ue_manager); @@ -376,7 +348,7 @@ printf("\n\n\n########## nas_sock_fd read returns len %d\n", len); ctxt.rnti = rnti; - pdcp_data_req(&ctxt, SRB_FLAG_NO, lc_id, RLC_MUI_UNDEFINED, + pdcp_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); } @@ -417,7 +389,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) return 0; } -void pdcp_layer_init(void) +void pdcp_layer_init() { /* hack: be sure to initialize only once */ static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; @@ -435,6 +407,24 @@ void pdcp_layer_init(void) init_nr_rlc_data_req_queue(); } +void nr_pdcp_layer_init_ue() +{ + /* hack: be sure to initialize only once */ + static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; + static int initialized = 0; + if (pthread_mutex_lock(&m) != 0) abort(); + if (initialized) { + if (pthread_mutex_unlock(&m) != 0) abort(); + return; + } + initialized = 1; + if (pthread_mutex_unlock(&m) != 0) abort(); + + nr_pdcp_ue_manager = new_nr_pdcp_ue_manager(0); + + init_nr_rlc_data_req_queue(); +} + void pdcp_layer_init_for_CU(void) { /* hack: be sure to initialize only once */ @@ -508,7 +498,7 @@ uint64_t pdcp_module_init(uint64_t _pdcp_optmask) return pdcp_optmask ; } -static void deliver_sdu_drb(protocol_ctxt_t *ctxt_pP,void *_ue, nr_pdcp_entity_t *entity, +static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, char *buf, int size) { extern int nas_sock_fd[]; @@ -519,7 +509,7 @@ static void deliver_sdu_drb(protocol_ctxt_t *ctxt_pP,void *_ue, nr_pdcp_entity_t int rb_id = 0; int i; - if (1) { //(IS_SOFTMODEM_NOS1){ + if (ENB_NAS_USE_TUN_BIT || UE_NAS_USE_TUN_BIT){ len = write(nas_sock_fd[0], buf, size); if (len != size) { LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); @@ -605,25 +595,43 @@ rb_found: enqueue_rlc_data_req(&ctxt, 0, MBMS_FLAG_NO, rb_id, sdu_id, 0, size, memblock, NULL, NULL); } -static int ccch_or_dcch = 0; -static void deliver_sdu_srb(protocol_ctxt_t *ctxt_pP, void *_ue, nr_pdcp_entity_t *entity, +static void deliver_sdu_srb(void *_ue, nr_pdcp_entity_t *entity, char *buf, int size) { - /* Implementation to be added */ - - // nr_pdcp_ue_t *ue = _ue; - // MessageDef *message_p; - // uint8_t *gtpu_buffer_p; - // int srb_id; + nr_pdcp_ue_t *ue = _ue; + int srb_id; + int i; + protocol_ctxt_t ctxt; - if (ccch_or_dcch == 0) { - nr_rrc_data_ind_ccch( ctxt_pP, 1, size, (uint8_t *)buf); - ccch_or_dcch = 1; - } else { - nr_rrc_data_ind( ctxt_pP, 1, size, (uint8_t *)buf); + for (i = 0; i < 2; i++) { + if (entity == ue->srb[i]) { + srb_id = i+1; + goto rb_found; + } } + + LOG_E(PDCP, "%s:%d:%s: fatal, no RB found for ue %d\n", + __FILE__, __LINE__, __FUNCTION__, ue->rnti); + exit(1); + +rb_found: + ctxt.module_id = 0; + ctxt.enb_flag = nr_pdcp_manager_get_enb_flag(nr_pdcp_ue_manager); + ctxt.instance = 0; + ctxt.frame = 0; + ctxt.subframe = 0; + ctxt.eNB_index = 0; + ctxt.configured = 1; + ctxt.brOption = 0; + ctxt.rnti = ue->rnti; + + nr_rrc_data_ind( &ctxt, srb_id, size, buf); + + return; } + + static void deliver_pdu_srb(void *_ue, nr_pdcp_entity_t *entity, char *buf, int size, int sdu_id) { @@ -790,7 +798,7 @@ boolean_t pdcp_data_ind( } if (rb != NULL) { - rb->recv_pdu(ctxt_pP,rb, (char *)sdu_buffer->data, sdu_buffer_size); + rb->recv_pdu(rb, (char *)sdu_buffer->data, sdu_buffer_size); } else { LOG_E(PDCP, "%s:%d:%s: fatal: no RB found (rb_id %ld, srb_flag %d)\n", __FILE__, __LINE__, __FUNCTION__, rb_id, srb_flagP); @@ -816,7 +824,6 @@ void pdcp_run(const protocol_ctxt_t *const ctxt_pP) break; switch (ITTI_MSG_ID(msg_p)) { case RRC_DCCH_DATA_REQ: - LOG_I(PDCP, "Received message %s\n", ITTI_MSG_NAME(msg_p)); PROTOCOL_CTXT_SET_BY_MODULE_ID( &ctxt, RRC_DCCH_DATA_REQ(msg_p).module_id, @@ -826,7 +833,7 @@ void pdcp_run(const protocol_ctxt_t *const ctxt_pP) 0, RRC_DCCH_DATA_REQ(msg_p).eNB_index); result = pdcp_data_req(&ctxt, - SRB_FLAG_YES,//not used, use lcid to check + SRB_FLAG_YES, RRC_DCCH_DATA_REQ(msg_p).rb_id, RRC_DCCH_DATA_REQ(msg_p).muip, RRC_DCCH_DATA_REQ(msg_p).confirmp, @@ -854,8 +861,6 @@ static void add_srb(int rnti, struct NR_SRB_ToAddMod *s) int srb_id = s->srb_Identity; - printf("\n\n################# rnti %d add srb %d\n\n\n", rnti, srb_id); - if (srb_id > 3) { LOG_E(PDCP, "%s:%d:%s: fatal, bad srb id %d\n", __FILE__, __LINE__, __FUNCTION__, srb_id); @@ -871,7 +876,7 @@ static void add_srb(int rnti, struct NR_SRB_ToAddMod *s) pdcp_srb = new_nr_pdcp_entity_srb(srb_id, deliver_sdu_srb, ue, deliver_pdu_srb, ue); nr_pdcp_ue_add_srb_pdcp_entity(ue, srb_id, pdcp_srb); - LOG_I(PDCP, "%s:%d:%s: added srb %d to ue %d\n", + LOG_I(PDCP, "%s:%d:%s: added srb %d to ue 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); } nr_pdcp_manager_unlock(nr_pdcp_ue_manager); @@ -911,7 +916,7 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s) sn_size_dl, t_reordering, discard_timer); nr_pdcp_ue_add_drb_pdcp_entity(ue, drb_id, pdcp_drb); - LOG_D(PDCP, "%s:%d:%s: added drb %d to ue rnti %x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); + LOG_D(PDCP, "%s:%d:%s: added drb %d to ue rnti 0x%x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); } nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } @@ -932,7 +937,7 @@ static void add_drb(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_Config_t *rlc_Co __FILE__, __LINE__, __FUNCTION__); exit(1); } - LOG_I(PDCP, "%s:%s:%d: added DRB for UE RNTI %x\n", __FILE__, __FUNCTION__, __LINE__, rnti); + LOG_I(PDCP, "%s:%s:%d: added DRB for UE RNTI 0x%x\n", __FILE__, __FUNCTION__, __LINE__, rnti); } boolean_t nr_rrc_pdcp_config_asn1_req( @@ -1017,8 +1022,7 @@ void nr_DRB_preconfiguration(uint16_t crnti) { NR_RadioBearerConfig_t *rbconfig = NULL; - struct NR_CellGroupConfig__rlc_BearerToAddModList *Rlc_DRB_Bearer_ToAdd_list = NULL; - struct NR_CellGroupConfig__rlc_BearerToAddModList *Rlc_SRB_Bearer_ToAdd_list = NULL; + struct NR_CellGroupConfig__rlc_BearerToAddModList *Rlc_Bearer_ToAdd_list = NULL; protocol_ctxt_t ctxt; //fill_default_rbconfig(rb_config, 5, 1); rbconfig = calloc(1, sizeof(*rbconfig)); @@ -1030,9 +1034,6 @@ void nr_DRB_preconfiguration(uint16_t crnti) srb_ToAddMod->discardOnPDCP = NULL; srb_ToAddMod->pdcp_Config = NULL; ASN_SEQUENCE_ADD(&rbconfig->srb_ToAddModList->list,srb_ToAddMod); - // srb_ToAddMod = calloc(1,sizeof(*srb_ToAddMod)); - // srb_ToAddMod->srb_Identity = 2; - // ASN_SEQUENCE_ADD(&rbconfig->srb_ToAddModList->list,srb_ToAddMod); rbconfig->srb3_ToRelease = NULL; rbconfig->drb_ToAddModList = calloc(1,sizeof(*rbconfig->drb_ToAddModList)); @@ -1081,16 +1082,17 @@ void nr_DRB_preconfiguration(uint16_t crnti) nr_rlc_bearer_init(RLC_SRB_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity); nr_drb_config(RLC_SRB_BearerConfig->rlc_Config, NR_RLC_Config_PR_am); nr_rlc_bearer_init_ul_spec(RLC_SRB_BearerConfig->mac_LogicalChannelConfig); - Rlc_SRB_Bearer_ToAdd_list = calloc(1,sizeof(*Rlc_SRB_Bearer_ToAdd_list)); - ASN_SEQUENCE_ADD(&Rlc_SRB_Bearer_ToAdd_list->list, RLC_SRB_BearerConfig); /*Adding DRB RLC configuration to the corresponding list*/ NR_RLC_BearerConfig_t *RLC_DRB_BearerConfig = calloc(1,sizeof(*RLC_DRB_BearerConfig)); nr_rlc_bearer_init(RLC_DRB_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity); nr_drb_config(RLC_DRB_BearerConfig->rlc_Config, NR_RLC_Config_PR_am); nr_rlc_bearer_init_ul_spec(RLC_DRB_BearerConfig->mac_LogicalChannelConfig); - Rlc_DRB_Bearer_ToAdd_list = calloc(1,sizeof(*Rlc_DRB_Bearer_ToAdd_list)); - ASN_SEQUENCE_ADD(&Rlc_DRB_Bearer_ToAdd_list->list, RLC_DRB_BearerConfig); + + + Rlc_Bearer_ToAdd_list = calloc(1,sizeof(*Rlc_Bearer_ToAdd_list)); + ASN_SEQUENCE_ADD(&Rlc_Bearer_ToAdd_list->list, RLC_SRB_BearerConfig); + ASN_SEQUENCE_ADD(&Rlc_Bearer_ToAdd_list->list, RLC_DRB_BearerConfig); if (ENB_NAS_USE_TUN){ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_YES, crnti, 0, 0, 0); @@ -1111,7 +1113,7 @@ void nr_DRB_preconfiguration(uint16_t crnti) NULL, NULL, NULL, - Rlc_DRB_Bearer_ToAdd_list); + Rlc_Bearer_ToAdd_list); } if (!NODE_IS_CU(node_type)) { @@ -1120,8 +1122,7 @@ void nr_DRB_preconfiguration(uint16_t crnti) rbconfig->drb_ToAddModList, rbconfig->drb_ToReleaseList, (LTE_PMCH_InfoList_r9_t *) NULL, - Rlc_SRB_Bearer_ToAdd_list, - Rlc_DRB_Bearer_ToAdd_list); + Rlc_Bearer_ToAdd_list); } LOG_D(PDCP, "%s:%d: done RRC PDCP/RLC ASN1 request for UE rnti %x\n", __FUNCTION__, __LINE__, ctxt.rnti); @@ -1212,7 +1213,7 @@ static boolean_t pdcp_data_req_srb( nr_pdcp_manager_lock(nr_pdcp_ue_manager); - ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, 0x1234); + ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); if (rb_id < 1 || rb_id > 3) rb = NULL; @@ -1265,7 +1266,7 @@ static boolean_t pdcp_data_req_drb( rb = ue->drb[rb_id - 1]; if (rb == NULL) { - LOG_E(PDCP, "%s:%d:%s: no SRB found (rnti %d, rb_id %ld)\n", + LOG_E(PDCP, "%s:%d:%s: no DRB found (rnti %d, rb_id %ld)\n", __FILE__, __LINE__, __FUNCTION__, rnti, rb_id); return 0; } @@ -1292,13 +1293,11 @@ boolean_t pdcp_data_req( #endif ) { - if (srb_flagP) { - return pdcp_data_req_srb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, - sdu_buffer); + if (srb_flagP) { + return pdcp_data_req_srb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, sdu_buffer); + }else{ + return pdcp_data_req_drb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, sdu_buffer); } - // use rbid to check drb or srb. - return pdcp_data_req_drb(ctxt_pP, rb_id - 3, muiP, confirmP, sdu_buffer_size, - sdu_buffer); } void pdcp_set_pdcp_data_ind_func(pdcp_data_ind_func_t pdcp_data_ind) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index ac9cca5fc9..5cd34c0519 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -447,7 +447,7 @@ static void deliver_sdu(void *_ue, nr_rlc_entity_t *entity, char *buf, int size) exit(1); rb_found: - LOG_D(RLC, "%s:%d:%s: delivering SDU (rnti %d is_srb %d rb_id %d) size %d \n", + LOG_D(RLC, "%s:%d:%s: delivering SDU (rnti %d is_srb %d rb_id %d) size %d", __FILE__, __LINE__, __FUNCTION__, ue->rnti, is_srb, rb_id, size); memblock = get_free_mem_block(size, __func__); @@ -637,7 +637,7 @@ rb_found: #endif } -static void add_srb_am(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig_t *rlc_BearerConfig) +static void add_srb(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig_t *rlc_BearerConfig) { nr_rlc_entity_t *nr_rlc_am; nr_rlc_ue_t *ue; @@ -645,6 +645,7 @@ static void add_srb_am(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig_ struct NR_RLC_Config *r = rlc_BearerConfig->rlc_Config; struct NR_LogicalChannelConfig *l = rlc_BearerConfig->mac_LogicalChannelConfig; int srb_id = s->srb_Identity; + int channel_id = rlc_BearerConfig->logicalChannelIdentity; int logical_channel_group; int t_status_prohibit; @@ -655,12 +656,18 @@ static void add_srb_am(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig_ int t_reassembly; int sn_field_length; - if (srb_id > 3) { + if (srb_id != 1 && srb_id != 2) { LOG_E(RLC, "%s:%d:%s: fatal, bad srb id %d\n", __FILE__, __LINE__, __FUNCTION__, srb_id); exit(1); } + if (channel_id != srb_id) { + LOG_E(RLC, "%s:%d:%s: todo, remove this limitation\n", + __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + logical_channel_group = *l->ul_SpecificParameters->logicalChannelGroup; /* TODO: accept other values? */ @@ -694,7 +701,7 @@ static void add_srb_am(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig_ nr_rlc_manager_lock(nr_rlc_ue_manager); ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti); if (ue->srb[srb_id-1] != NULL) { - LOG_W(RLC, "%s:%d:%s: SRB %d already exists for UE with RNTI %d, do nothing\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); + LOG_W(RLC, "%s:%d:%s: SRB %d already exists for UE with RNTI 0x%x, do nothing\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); } else { nr_rlc_am = new_nr_rlc_entity_am(100000, 100000, @@ -707,26 +714,11 @@ static void add_srb_am(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig_ sn_field_length); nr_rlc_ue_add_srb_rlc_entity(ue, srb_id, nr_rlc_am); - LOG_D(RLC, "%s:%d:%s: added srb %d to UE with RNTI %x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); + LOG_I(RLC, "%s:%d:%s: added srb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } -static void add_srb(int rnti, struct NR_SRB_ToAddMod *s, struct NR_RLC_BearerConfig *rlc_BearerConfig) -{ - switch (rlc_BearerConfig->rlc_Config->present) { - case NR_RLC_Config_PR_am: - add_srb_am(rnti, s, rlc_BearerConfig); - break; - /*Missing case for RLC TM corresponding to SRB0 */ - default: - LOG_E(RLC, "%s:%d:%s: fatal: unhandled SRB type\n", - __FILE__, __LINE__, __FUNCTION__); - exit(1); - } - LOG_I(RLC, "%s:%s:%d: added SRB to UE with RNTI %x\n", __FILE__, __FUNCTION__, __LINE__, rnti); -} - static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_t *rlc_BearerConfig) { nr_rlc_entity_t *nr_rlc_am; @@ -793,8 +785,8 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ if (ue->drb[drb_id-1] != NULL) { LOG_W(RLC, "%s:%d:%s: DRB %d already exists for UE with RNTI %d, do nothing\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); } else { - nr_rlc_am = new_nr_rlc_entity_am(100000, - 100000, + nr_rlc_am = new_nr_rlc_entity_am(10000000, + 10000000, deliver_sdu, ue, successful_delivery, ue, max_retx_reached, ue, @@ -804,7 +796,7 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ sn_field_length); nr_rlc_ue_add_drb_rlc_entity(ue, drb_id, nr_rlc_am); - LOG_D(RLC, "%s:%d:%s: added drb %d to UE with RNTI %x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); + LOG_D(RLC, "%s:%d:%s: added drb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } @@ -865,14 +857,14 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ if (ue->drb[drb_id-1] != NULL) { LOG_W(RLC, "DEBUG add_drb_um %s:%d:%s: warning DRB %d already exist for ue %d, do nothing\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); } else { - nr_rlc_um = new_nr_rlc_entity_um(1000000, - 1000000, + nr_rlc_um = new_nr_rlc_entity_um(100000000, + 100000000, deliver_sdu, ue, t_reassembly, sn_field_length); nr_rlc_ue_add_drb_rlc_entity(ue, drb_id, nr_rlc_um); - LOG_D(RLC, "%s:%d:%s: added drb %d to UE with RNTI %x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); + LOG_D(RLC, "%s:%d:%s: added drb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } @@ -891,7 +883,7 @@ static void add_drb(int rnti, struct NR_DRB_ToAddMod *s, struct NR_RLC_BearerCon __FILE__, __LINE__, __FUNCTION__); exit(1); } - LOG_I(RLC, "%s:%s:%d: added DRB to UE with RNTI %x\n", __FILE__, __FUNCTION__, __LINE__, rnti); + LOG_I(RLC, "%s:%s:%d: added DRB to UE with RNTI 0x%x\n", __FILE__, __FUNCTION__, __LINE__, rnti); } /* Dummy function due to dependency from LTE libraries */ @@ -911,11 +903,10 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt const NR_DRB_ToAddModList_t * const drb2add_listP, const NR_DRB_ToReleaseList_t * const drb2release_listP, const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_srb_bearer2add_list, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_drb_bearer2add_list) + struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list) { int rnti = ctxt_pP->rnti; - int i; + int i,j; if (/*ctxt_pP->enb_flag != 1 ||*/ ctxt_pP->module_id != 0 /*|| ctxt_pP->instance != 0 || ctxt_pP->eNB_index != 0 || @@ -938,15 +929,30 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt if (srb2add_listP != NULL) { for (i = 0; i < srb2add_listP->list.count; i++) { - if(rlc_srb_bearer2add_list != NULL) - add_srb(rnti, srb2add_listP->list.array[i], rlc_srb_bearer2add_list->list.array[i]); + for(j = 0; j < rlc_bearer2add_list->list.count; j++){ + if(rlc_bearer2add_list->list.array[j]->servedRadioBearer != NULL){ + if(rlc_bearer2add_list->list.array[j]->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity){ + if(srb2add_listP->list.array[i]->srb_Identity == rlc_bearer2add_list->list.array[j]->servedRadioBearer->choice.srb_Identity){ + add_srb(rnti, srb2add_listP->list.array[i], rlc_bearer2add_list->list.array[j]); + } + } + } + } + } } if (drb2add_listP != NULL) { for (i = 0; i < drb2add_listP->list.count; i++) { - if(rlc_drb_bearer2add_list != NULL) - add_drb(rnti, drb2add_listP->list.array[i], rlc_drb_bearer2add_list->list.array[i]); + for(j = 0; j < rlc_bearer2add_list->list.count; j++){ + if(rlc_bearer2add_list->list.array[j]->servedRadioBearer != NULL){ + if(rlc_bearer2add_list->list.array[j]->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity){ + if(drb2add_listP->list.array[i]->drb_Identity == rlc_bearer2add_list->list.array[j]->servedRadioBearer->choice.drb_Identity){ + add_drb(rnti, drb2add_listP->list.array[i], rlc_bearer2add_list->list.array[j]); + } + } + } + } } } diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf index 305f397768..483fd34f2a 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf @@ -25,10 +25,10 @@ gNBs = local_s_if_name = "lo"; remote_s_address = "127.0.0.3"; local_s_address = "127.0.0.4"; - local_s_portc = 38472; #501; - remote_s_portc = 57113; #500; - local_s_portd = 2152; #601; - remote_s_portd = 2152; #600; + local_s_portc = 501; + remote_s_portc = 500; + local_s_portd = 601; + remote_s_portd = 600; ////////// Physical parameters: diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf index 42326699c8..dcb3010f20 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf @@ -230,12 +230,12 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "f1"; local_n_if_name = "lo"; - remote_n_address = "127.0.0.4"; #"127.0.0.4"; "192.168.12.75"; - local_n_address = "127.0.0.3"; #"127.0.0.3"; "192.168.12.188"; - local_n_portc = 57113; #500 - remote_n_portc = 38472; #501; - local_n_portd = 2152;#600; - remote_n_portd = 2152; #601; + remote_n_address = "127.0.0.4"; + local_n_address = "127.0.0.3"; + local_n_portc = 500; + remote_n_portc = 501; + local_n_portd = 600; + remote_n_portd = 601; } );